diff --git "a/pgsql-performance.200503" "b/pgsql-performance.200503" new file mode 100644--- /dev/null +++ "b/pgsql-performance.200503" @@ -0,0 +1,66394 @@ +From pgsql-performance-owner@postgresql.org Tue Mar 1 01:09:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 354A2564AC + for ; + Tue, 1 Mar 2005 01:07:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16037-10 + for ; + Tue, 1 Mar 2005 01:07:24 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AD0D556498 + for ; + Tue, 1 Mar 2005 01:07:23 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2117KYL011428; + Mon, 28 Feb 2005 20:07:20 -0500 (EST) +To: Sven Willenberger +Cc: Postgresql Performance list +Subject: Re: Inheritence versus delete from +In-reply-to: <1109635153.4620.44.camel@lanshark.dmv.com> +References: <1109635153.4620.44.camel@lanshark.dmv.com> +Comments: In-reply-to Sven Willenberger + message dated "Mon, 28 Feb 2005 18:59:13 -0500" +Date: Mon, 28 Feb 2005 20:07:20 -0500 +Message-ID: <11427.1109639240@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/1 +X-Sequence-Number: 10706 + +Sven Willenberger writes: +> 3) Each month: +> CREATE newmonth_dynamically_named_table (like mastertable) INHERITS +> (mastertable); +> modify the copy.sql script to copy newmonth_dynamically_named_table; +> pg_dump 3monthsago_dynamically_named_table for archiving; +> drop table 3monthsago_dynamically_named_table; + +A number of people use the above approach. It's got some limitations, +mainly that the planner isn't super bright about what you are doing +--- in particular, joins involving such a table may work slowly. + +On the whole I'd probably go with the other approach (one big table). +A possible win is to use CLUSTER rather than VACUUM ANALYZE to recover +space after your big deletes; however this assumes that you can schedule +downtime to do the CLUSTERs in. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 1 01:41:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E012545F2 + for ; + Tue, 1 Mar 2005 01:41:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25457-01 + for ; + Tue, 1 Mar 2005 01:41:25 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 806145647F + for ; + Tue, 1 Mar 2005 01:41:24 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.2/8.12.9) with ESMTP id + j211fK0F000323; (envelope-from ) Mon, + 28 Feb 2005 19:41:20 -0600 (CST) +Received: from [192.168.1.13] (12-217-241-0.client.mchsi.com [12.217.241.0]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j211fJWI012293 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Mon, + 28 Feb 2005 19:41:20 -0600 (CST) +Message-ID: <4223C840.1060109@arbash-meinel.com> +Date: Mon, 28 Feb 2005 19:41:20 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Sven Willenberger +Cc: Postgresql Performance list +Subject: Re: Inheritence versus delete from +References: <1109635153.4620.44.camel@lanshark.dmv.com> +In-Reply-To: <1109635153.4620.44.camel@lanshark.dmv.com> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig3A79B20BA3BA1756EE8BC867" +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV 0.80/706/Sun Feb 13 18:14:02 2005, + clamav-milter version 0.75 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/2 +X-Sequence-Number: 10707 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig3A79B20BA3BA1756EE8BC867 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Sven Willenberger wrote: + +>Trying to determine the best overall approach for the following +>scenario: +> +>Each month our primary table accumulates some 30 million rows (which +>could very well hit 60+ million rows per month by year's end). Basically +>there will end up being a lot of historical data with little value +>beyond archival. +> +> +> +If this statement is true, then 2 seems the best plan. + +>2) Each month: +>SELECT * INTO 3monthsago_dynamically_named_table FROM bigtable WHERE +>targetdate < $3monthsago; +>DELETE FROM bigtable where targetdate < $3monthsago; +>VACUUM ANALYZE bigtable; +>pg_dump 3monthsago_dynamically_named_table for archiving; +> +> +> +It seems like this method would force the table to stay small, and would +keep your queries fast. But if you ever actually *need* the old data, +then you start having problems. + +... + +I think (3) would tend to force a whole bunch of joins (one for each +child table), rather than just one join against 3months of data. + +>Any takes on which approach makes most sense from a performance and/or +>maintenance point of view and are there other options I may have missed? +> +>Sven Willenberger +> +> +If you can get away with it 2 is the best. + +John +=:-> + + +--------------enig3A79B20BA3BA1756EE8BC867 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCI8hAJdeBCYSNAAMRAsCmAJkB7KPfpzIy50LAEU82HdXssfPGfACeNBGx +FdJJ9C5mZAIv2dhEWcGYB4s= +=qhfR +-----END PGP SIGNATURE----- + +--------------enig3A79B20BA3BA1756EE8BC867-- + +From pgsql-performance-owner@postgresql.org Tue Mar 1 05:27:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DEE952A4D + for ; + Tue, 1 Mar 2005 05:27:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98793-07 + for ; + Tue, 1 Mar 2005 05:27:15 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id A4128566F4 + for ; + Tue, 1 Mar 2005 05:27:13 +0000 (GMT) +Received: (qmail 22621 invoked from network); 1 Mar 2005 06:27:55 +0100 +Received: from unknown (HELO musicbox) (boutiquenumerique-lists@192.168.0.2) + by boutiquenumerique.com with SMTP; 1 Mar 2005 06:27:55 +0100 +Date: Tue, 01 Mar 2005 06:32:14 +0100 +To: "Bruce Momjian" , + "Magnus Hagander" +Subject: Re: seq scan cache vs. index cache smackdown +Cc: "Merlin Moncure" , + "Josh Berkus" , pgsql-performance@postgresql.org +References: <200502190411.j1J4B8T15005@candle.pha.pa.us> +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <200502190411.j1J4B8T15005@candle.pha.pa.us> +User-Agent: Opera M2/7.54u1 (Linux, build 892) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/3 +X-Sequence-Number: 10708 + + +>> (For those not knowing - it's ReadFile/WriteFile where you pass an array +>> of "this many bytes to this address" as parameters) +> +> Isn't that like the BSD writev()/readv() that Linux supports also? Is +> that something we should be using on Unix if it is supported by the OS? + + Nope, readv()/writev() read/write from/to the file sequentially to/from a +list of buffers in memory. The Windows calls read/write at random file +offsets to/from a list of buffers. + + + +From pgsql-performance-owner@postgresql.org Tue Mar 1 09:34:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3240954C58 + for ; + Tue, 1 Mar 2005 09:34:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81457-04 + for ; + Tue, 1 Mar 2005 09:34:31 +0000 (GMT) +Received: from mta.sara.nl (mta.sara.nl [145.100.16.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 88741564C5 + for ; + Tue, 1 Mar 2005 09:34:29 +0000 (GMT) +Received: from [145.100.6.93] (bastiaans.ka.sara.nl [145.100.6.93]) + by mta.sara.nl (8.12.10+Sun/8.12.10) with ESMTP id j219YUWk020408 + for ; + Tue, 1 Mar 2005 10:34:30 +0100 (MET) +Message-ID: <42243725.6060804@sara.nl> +Date: Tue, 01 Mar 2005 10:34:29 +0100 +From: Ramon Bastiaans +User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: multi billion row tables: possible or insane? +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/4 +X-Sequence-Number: 10709 + +Hi all, + +I am doing research for a project of mine where I need to store several +billion values for a monitoring and historical tracking system for a big +computer system. My currect estimate is that I have to store (somehow) +around 1 billion values each month (possibly more). + +I was wondering if anyone has had any experience with these kind of big +numbers of data in a postgres sql database and how this affects database +design and optimization. + +What would be important issues when setting up a database this big, and +is it at all doable? Or would it be a insane to think about storing up +to 5-10 billion rows in a postgres database. + +The database's performance is important. There would be no use in +storing the data if a query will take ages. Query's should be quite fast +if possible. + +I would really like to hear people's thoughts/suggestions or "go see a +shrink, you must be mad" statements ;) + +Kind regards, + +Ramon Bastiaans + + + +From pgsql-performance-owner@postgresql.org Wed Mar 2 06:00:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C285454D07 + for ; + Tue, 1 Mar 2005 12:40:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33677-05 + for ; + Tue, 1 Mar 2005 12:40:11 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D1ABF5445B + for ; + Tue, 1 Mar 2005 12:40:10 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id D794A32098; Tue, 1 Mar 2005 13:40:12 +0100 (MET) +From: Thomas Ganss + +X-Newsgroups: pgsql.performance +Subject: Re: multi billion row tables: possible or insane? +Date: Tue, 01 Mar 2005 13:40:23 +0100 +Organization: T-Online +Lines: 10 +Message-ID: +References: <42243725.6060804@sara.nl> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet-abuse@t-online.de +X-ID: VsS8k6Z-gepkdxZ98-3JKL1o0OnQ0qItSJQRlmArdCbQp85eSPMPUi +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: de-DE, de, en-us, en +In-Reply-To: <42243725.6060804@sara.nl> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=2.174 tagged_above=0 required=5 tests=FORGED_YAHOO_RCVD +X-Spam-Level: ** +X-Archive-Number: 200503/22 +X-Sequence-Number: 10727 + +Ramon Bastiaans schrieb: +> My currect estimate is that I have to store (somehow) +> around 1 billion values each month (possibly more). + +You should post the actual number or power of ten, +since "billion" is not always interpreted the same way... + +rgds + +thomas + +From pgsql-performance-owner@postgresql.org Tue Mar 1 13:35:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E700D5666A + for ; + Tue, 1 Mar 2005 13:35:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48111-06 + for ; + Tue, 1 Mar 2005 13:35:02 +0000 (GMT) +Received: from sccrmhc12.comcast.net (sccrmhc12.comcast.net [204.127.202.56]) + by svr1.postgresql.org (Postfix) with ESMTP id 3591454431 + for ; + Tue, 1 Mar 2005 13:34:58 +0000 (GMT) +Received: from jefftrout.com ([24.61.201.181]) + by comcast.net (sccrmhc12) with SMTP + id <2005030113350101200rqr4re>; Tue, 1 Mar 2005 13:35:01 +0000 +Received: (qmail 82229 invoked from network); 1 Mar 2005 13:35:01 -0000 +Received: from waltham-nat.ma.lycos.com (HELO ?10.124.7.65?) (209.202.205.1) + by 192.168.0.106 with SMTP; 1 Mar 2005 13:35:01 -0000 +In-Reply-To: <42243725.6060804@sara.nl> +References: <42243725.6060804@sara.nl> +Mime-Version: 1.0 (Apple Message framework v619.2) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <0ba53986bff9d72366213838353e459c@torgo.978.org> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Jeff +Subject: Re: multi billion row tables: possible or insane? +Date: Tue, 1 Mar 2005 08:37:16 -0500 +To: Ramon Bastiaans +X-Mailer: Apple Mail (2.619.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.201 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP, + RCVD_IN_SORBS_DUL +X-Spam-Level: +X-Archive-Number: 200503/5 +X-Sequence-Number: 10710 + + +On Mar 1, 2005, at 4:34 AM, Ramon Bastiaans wrote: +> +> What would be important issues when setting up a database this big, +> and is it at all doable? Or would it be a insane to think about +> storing up to 5-10 billion rows in a postgres database. +> + +Buy a bunch of disks. +And then go out and buy more disks. +When you are done with that - go buy some more disks. +Then buy some ram. +Then buy more disks. + +You want the fastest IO possible. + +I'd also recommend the opteron route since you can also put heaping +gobules of ram in there as well. + +> The database's performance is important. There would be no use in +> storing the data if a query will take ages. Query's should be quite +> fast if possible. +> + +And make sure you tune your queries. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Tue Mar 1 14:01:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CBEC56526 + for ; + Tue, 1 Mar 2005 14:01:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56727-05 + for ; + Tue, 1 Mar 2005 14:01:49 +0000 (GMT) +Received: from mail.logi-track.com (www.logi-track.com [213.239.193.212]) + by svr1.postgresql.org (Postfix) with ESMTP id A48845651B + for ; + Tue, 1 Mar 2005 14:01:49 +0000 (GMT) +Received: from kingfisher.intern.logi-track.com (pD95DCE38.dip0.t-ipconnect.de + [217.93.206.56]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logi-track.com (Postfix) with ESMTP id 746FC307FB; + Tue, 1 Mar 2005 15:01:56 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logi-track.com (Postfix) with ESMTP id E500EAB388; + Tue, 1 Mar 2005 15:01:50 +0100 (CET) +Message-ID: <422475CE.9030507@logi-track.com> +Date: Tue, 01 Mar 2005 15:01:50 +0100 +From: Markus Schaber +User-Agent: Mozilla Thunderbird 1.0 (X11/20050116) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: Ramon Bastiaans +Cc: pgsql-performance@postgresql.org +Subject: Re: multi billion row tables: possible or insane? +References: <42243725.6060804@sara.nl> +In-Reply-To: <42243725.6060804@sara.nl> +X-Enigmail-Version: 0.90.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.115 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/6 +X-Sequence-Number: 10711 + +Hi, Ramon, + +Ramon Bastiaans schrieb: + +> The database's performance is important. There would be no use in +> storing the data if a query will take ages. Query's should be quite fast +> if possible. + +Which kind of query do you want to run? + +Queries that involve only a few rows should stay quite fast when you set +up the right indices. + +However, queries that involve sequential scans over your table (like +average computation) will take years. Get faaaaaast I/O for this. Or, +better, use a multidimensional data warehouse engine. Those can +precalculate needed aggregate functions and reports. But they need loads +of storage (because of very redundant data storage), and I don't know +any open source or cheap software. + +Markus +-- +markus schaber | dipl. informatiker +logi-track ag | rennweg 14-16 | ch 8001 z�rich +phone +41-43-888 62 52 | fax +41-43-888 62 53 +mailto:schabios@logi-track.com | www.logi-track.com + +From pgsql-performance-owner@postgresql.org Tue Mar 1 15:19:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AF60856548 + for ; + Tue, 1 Mar 2005 15:19:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79938-09 + for ; + Tue, 1 Mar 2005 15:19:15 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E7ED564E0 + for ; + Tue, 1 Mar 2005 15:19:13 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.2/8.12.9) with ESMTP id + j21FJFO7018331; (envelope-from ) Tue, + 1 Mar 2005 09:19:15 -0600 (CST) +Received: from [192.168.1.13] (65-100-23-249.cdrr.qwest.net [65.100.23.249]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j21FJCBl009139 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Tue, + 1 Mar 2005 09:19:14 -0600 (CST) +Message-ID: <422487E4.6040107@arbash-meinel.com> +Date: Tue, 01 Mar 2005 09:19:00 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ramon Bastiaans +Cc: pgsql-performance@postgresql.org +Subject: Re: multi billion row tables: possible or insane? +References: <42243725.6060804@sara.nl> +In-Reply-To: <42243725.6060804@sara.nl> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigCE0F8D9888828DFFB231A659" +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/7 +X-Sequence-Number: 10712 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigCE0F8D9888828DFFB231A659 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Ramon Bastiaans wrote: + +> Hi all, +> +> I am doing research for a project of mine where I need to store +> several billion values for a monitoring and historical tracking system +> for a big computer system. My currect estimate is that I have to store +> (somehow) around 1 billion values each month (possibly more). +> +If you have that 1 billion perfectly distributed over all hours of the +day, then you need 1e9/30/24/3600 = 385 transactions per second. + +Which I'm pretty sure is possible with postgres, you just need pretty +beefy hardware. And like Jeff said, lots of disks for lots of IO. +Like a quad opteron, with 16GB of ram, and around 14-20 very fast disks. +raid10 not raid5, etc. To improve query performance, you can do some +load balancing by having replication machines by using Slony. + +Or if you can do batch processing, you could split up the work into a +few update machines, which then do bulk updates on the master database. +This lets you get more machines into the job, since you can't share a +database across multiple machines. + +> I was wondering if anyone has had any experience with these kind of +> big numbers of data in a postgres sql database and how this affects +> database design and optimization. +> +Well, one of the biggest things is if you can get bulk updates, or if +clients can handle data being slightly out of date, so you can use +cacheing. Can you segregate your data into separate tables as much as +possible? Are your clients okay if aggregate information takes a little +while to update? + +One trick is to use semi-lazy materialized views to get your updates to +be fast. + +> What would be important issues when setting up a database this big, +> and is it at all doable? Or would it be a insane to think about +> storing up to 5-10 billion rows in a postgres database. + +I think you if you can design the db properly, it is doable. But if you +have a clients saying "I need up to the second information on 1 billion +rows", you're never going to get it. + +> +> The database's performance is important. There would be no use in +> storing the data if a query will take ages. Query's should be quite +> fast if possible. +> +Again, it depends on the queries being done. +There are some nice tricks you can use, like doing a month-by-month +partitioning (if you are getting 1G inserts, you might want week-by-week +partitioning), and then with a date column index, and a union all view +you should be able to get pretty good insert speed, and still keep fast +*recent* queries. Going through 1billion rows is always going to be +expensive. + +> I would really like to hear people's thoughts/suggestions or "go see a +> shrink, you must be mad" statements ;) +> +> Kind regards, +> +> Ramon Bastiaans + +I think it would be possible, but there are a lot of design issues with +a system like this. You can't go into it thinking that you can design a +multi billion row database the same way you would design a million row db. + +John +=:-> + + +--------------enigCE0F8D9888828DFFB231A659 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCJIfoJdeBCYSNAAMRAmrZAJ4nXHHcTa+jwsPQuaIYKo2yj1zyPQCeOmlJ +XyiD6jlTES0S/PWR47imgYQ= +=hG3B +-----END PGP SIGNATURE----- + +--------------enigCE0F8D9888828DFFB231A659-- + +From pgsql-performance-owner@postgresql.org Tue Mar 1 15:40:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B0CF56473 + for ; + Tue, 1 Mar 2005 15:40:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88132-03 + for ; + Tue, 1 Mar 2005 15:40:29 +0000 (GMT) +Received: from mailin3.audi.de (mailin3.audi.de [143.164.102.17]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B5E556479 + for ; + Tue, 1 Mar 2005 15:40:27 +0000 (GMT) +Received: from mailin2.audi.de (inwlbesi2n10-proxy-ip1.web.audi.vwg + [10.198.7.251]) by mailin3.audi.de (Postfix) with ESMTP + id 9F94FE9456; Tue, 1 Mar 2005 16:40:31 +0100 (CET) +Message-ID: <977921B17B2F2048AA5AAE9B4CBB713E01423D75@huaudigs0035.audi.de> +From: "Vig, Sandor (G/FI-2)" +To: 'John Arbash Meinel' +Cc: "'pgsql-performance@postgresql.org'" +Subject: Re: multi billion row tables: possible or insane? +Date: Tue, 1 Mar 2005 16:40:29 +0100 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2656.59) +Content-Type: text/plain; + charset="ISO-8859-1" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.22 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/8 +X-Sequence-Number: 10713 + +385 transaction/sec? + +fsync = false + +risky but fast. + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]On Behalf Of John Arbash +Meinel +Sent: Tuesday, March 01, 2005 4:19 PM +To: Ramon Bastiaans +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] multi billion row tables: possible or insane? + + +Ramon Bastiaans wrote: + +> Hi all, +> +> I am doing research for a project of mine where I need to store +> several billion values for a monitoring and historical tracking system +> for a big computer system. My currect estimate is that I have to store +> (somehow) around 1 billion values each month (possibly more). +> +If you have that 1 billion perfectly distributed over all hours of the +day, then you need 1e9/30/24/3600 = 385 transactions per second. + +Which I'm pretty sure is possible with postgres, you just need pretty +beefy hardware. And like Jeff said, lots of disks for lots of IO. +Like a quad opteron, with 16GB of ram, and around 14-20 very fast disks. +raid10 not raid5, etc. To improve query performance, you can do some +load balancing by having replication machines by using Slony. + +Or if you can do batch processing, you could split up the work into a +few update machines, which then do bulk updates on the master database. +This lets you get more machines into the job, since you can't share a +database across multiple machines. + +> I was wondering if anyone has had any experience with these kind of +> big numbers of data in a postgres sql database and how this affects +> database design and optimization. +> +Well, one of the biggest things is if you can get bulk updates, or if +clients can handle data being slightly out of date, so you can use +cacheing. Can you segregate your data into separate tables as much as +possible? Are your clients okay if aggregate information takes a little +while to update? + +One trick is to use semi-lazy materialized views to get your updates to +be fast. + +> What would be important issues when setting up a database this big, +> and is it at all doable? Or would it be a insane to think about +> storing up to 5-10 billion rows in a postgres database. + +I think you if you can design the db properly, it is doable. But if you +have a clients saying "I need up to the second information on 1 billion +rows", you're never going to get it. + +> +> The database's performance is important. There would be no use in +> storing the data if a query will take ages. Query's should be quite +> fast if possible. +> +Again, it depends on the queries being done. +There are some nice tricks you can use, like doing a month-by-month +partitioning (if you are getting 1G inserts, you might want week-by-week +partitioning), and then with a date column index, and a union all view +you should be able to get pretty good insert speed, and still keep fast +*recent* queries. Going through 1billion rows is always going to be +expensive. + +> I would really like to hear people's thoughts/suggestions or "go see a +> shrink, you must be mad" statements ;) +> +> Kind regards, +> +> Ramon Bastiaans + +I think it would be possible, but there are a lot of design issues with +a system like this. You can't go into it thinking that you can design a +multi billion row database the same way you would design a million row db. + +John +=:-> + + +The information transmitted is intended only for the person or entity to +which it is addressed and may contain confidential and/or privileged +material. Any review, retransmission, dissemination or other use of, or +taking of any action in reliance upon, this information by persons or +entities other than the intended recipient is prohibited. If you received +this in error, please contact the sender and delete the material from any +computer. + +From pgsql-performance-owner@postgresql.org Wed Mar 2 06:00:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CD3A756479 + for ; + Tue, 1 Mar 2005 15:43:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88963-02 + for ; + Tue, 1 Mar 2005 15:43:18 +0000 (GMT) +Received: from webmail.moph.go.th (health.moph.go.th [203.157.0.1]) + by svr1.postgresql.org (Postfix) with SMTP id 378AC5646A + for ; + Tue, 1 Mar 2005 15:43:15 +0000 (GMT) +Received: (qmail 23890 invoked from network); 1 Mar 2005 15:46:06 -0000 +Received: from unknown (HELO localhost) (127.0.0.1) + by localhost with SMTP; 1 Mar 2005 15:46:06 -0000 +Received: from webmail.moph.go.th ([127.0.0.1]) + by localhost (webmail.moph.go.th [127.0.0.1]) (amavisd-new, port 10024) + with SMTP id 22439-39 for ; + Tue, 1 Mar 2005 22:46:04 +0700 (ICT) +Received: (qmail 23880 invoked from network); 1 Mar 2005 15:46:02 -0000 +Received: from unknown (HELO localhost) (203.157.0.1) + by health.moph.go.th with SMTP; 1 Mar 2005 15:46:02 -0000 +Received: from 203.157.100.42 ([203.157.100.42]) + by webmail.moph.go.th (IMP) with HTTP + for ; + Tue, 1 Mar 2005 22:46:02 +0700 +Message-ID: <1109691962.42248e3a3c898@webmail.moph.go.th> +Date: Tue, 1 Mar 2005 22:46:02 +0700 +From: amrit@health2.moph.go.th +To: PGsql-performance +Subject: What is the postgres sql command for last_user_id ??? +MIME-Version: 1.0 +Content-Type: text/plain; charset=TIS-620 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.3 +X-Originating-IP: 203.157.100.42 +X-Virus-Scanned: by amavisd-new at moph.go.th +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.178 tagged_above=0 required=5 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200503/21 +X-Sequence-Number: 10726 + +I would like to know whether there is any command which the server will give the +record ID back to the client when client puts the data and the server generates +an autoincrement ID for that record. +For example if many clients try to put the money data to the server and each +record from each client has its own record ID by autoincrement process of the +server [x+1] and i don't need to lock the record since it will bring the system +to slow down. That client wil then want to know which ID that server gives to +that record in order to select that record to print the reciept [bill]. +I know that in mysql there is a command "last_record_id" which acts the same as +I mention above. Does anybody know that , please give me the detail? + +Amrit,Thailand + + + +From pgsql-performance-owner@postgresql.org Tue Mar 1 15:52:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F10D65647C + for ; + Tue, 1 Mar 2005 15:52:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90665-06 + for ; + Tue, 1 Mar 2005 15:52:13 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 48BDB5445B + for ; + Tue, 1 Mar 2005 15:52:12 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.2/8.12.9) with ESMTP id + j21FqEFi020150; (envelope-from ) Tue, + 1 Mar 2005 09:52:14 -0600 (CST) +Received: from [192.168.1.13] (65-100-23-249.cdrr.qwest.net [65.100.23.249]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j21FqA9k021501 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Tue, + 1 Mar 2005 09:52:14 -0600 (CST) +Message-ID: <42248FAC.2010103@arbash-meinel.com> +Date: Tue, 01 Mar 2005 09:52:12 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Vig, Sandor (G/FI-2)" +Cc: "'pgsql-performance@postgresql.org'" +Subject: Re: multi billion row tables: possible or insane? +References: <977921B17B2F2048AA5AAE9B4CBB713E01423D75@huaudigs0035.audi.de> +In-Reply-To: <977921B17B2F2048AA5AAE9B4CBB713E01423D75@huaudigs0035.audi.de> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig290805DE7674AEAA80C8CCC2" +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/9 +X-Sequence-Number: 10714 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig290805DE7674AEAA80C8CCC2 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Vig, Sandor (G/FI-2) wrote: + +>385 transaction/sec? +> +>fsync = false +> +>risky but fast. +> +> + +I think with a dedicated RAID10 for pg_xlog (or possibly a battery +backed up ramdisk), and then a good amount of disks in a bulk RAID10 or +possibly a good partitioning of the db across multiple raids, you could +probably get a good enough tps. + +But you're right, fsync=false could certainly give you the performance, +though a power outage means potential *real* corruption. Not just +missing transactions, but duplicated rows, all sorts of ugliness. + +John +=:-> + + +--------------enig290805DE7674AEAA80C8CCC2 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCJI+sJdeBCYSNAAMRAhc+AJ0VsfXaFkt2BbtErfeiD2v5QrZO6wCfVSPL +Z06DTRGIUWugYK32bmKIS0c= +=7VV3 +-----END PGP SIGNATURE----- + +--------------enig290805DE7674AEAA80C8CCC2-- + +From pgsql-performance-owner@postgresql.org Tue Mar 1 15:54:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CF3355431 + for ; + Tue, 1 Mar 2005 15:54:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90665-08 + for ; + Tue, 1 Mar 2005 15:54:17 +0000 (GMT) +Received: from ns.surfnonstop.com (ns.surfnonstop.com [193.194.159.175]) + by svr1.postgresql.org (Postfix) with ESMTP id 8325052A4D + for ; + Tue, 1 Mar 2005 15:54:16 +0000 (GMT) +Received: by ns.surfnonstop.com (Postfix, from userid 501) + id E5DCBB31F6; Tue, 1 Mar 2005 16:54:42 +0100 (CET) +Received: from localhost (localhost [127.0.0.1]) + by ns.surfnonstop.com (Postfix) with ESMTP + id CB08EB31C9; Tue, 1 Mar 2005 16:54:42 +0100 (CET) +Date: Tue, 1 Mar 2005 16:54:42 +0100 (CET) +From: Andras Kadinger +To: Ramon Bastiaans +Cc: pgsql-performance@postgresql.org +Subject: Re: multi billion row tables: possible or insane? +In-Reply-To: <42243725.6060804@sara.nl> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/10 +X-Sequence-Number: 10715 + +What do your "values" consist of? + +Would it be possible to group several hundred or thousand of them into a +single row somehow that still makes it possible for your queries to get at +them efficiently? + +What kind of queries will you want to run against the data? + +For example if you have a measurement of some process value each +millisecond, it might be a good performance tradeoff to pack a whole +second of measurements into a single row if your data processing only +needs to access the values sequentially. With this single step you +immediately reduced your row and transaction number to the 1/1000th. + +Please tell us more. + +On Tue, 1 Mar 2005, Ramon Bastiaans wrote: + +> Hi all, +> +> I am doing research for a project of mine where I need to store several +> billion values for a monitoring and historical tracking system for a big +> computer system. My currect estimate is that I have to store (somehow) +> around 1 billion values each month (possibly more). +> +> I was wondering if anyone has had any experience with these kind of big +> numbers of data in a postgres sql database and how this affects database +> design and optimization. +> +> What would be important issues when setting up a database this big, and +> is it at all doable? Or would it be a insane to think about storing up +> to 5-10 billion rows in a postgres database. +> +> The database's performance is important. There would be no use in +> storing the data if a query will take ages. Query's should be quite fast +> if possible. +> +> I would really like to hear people's thoughts/suggestions or "go see a +> shrink, you must be mad" statements ;) +> +> Kind regards, +> +> Ramon Bastiaans +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> + + +From pgsql-performance-owner@postgresql.org Tue Mar 1 15:58:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CC4CA56489 + for ; + Tue, 1 Mar 2005 15:58:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92440-09 + for ; + Tue, 1 Mar 2005 15:58:30 +0000 (GMT) +Received: from unicorn.rentec.com (unicorn.rentec.com [216.223.240.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FC945647A + for ; + Tue, 1 Mar 2005 15:58:29 +0000 (GMT) +Received: from wren.rentec.com (wren.rentec.com [192.5.35.106]) + by unicorn.rentec.com (8.13.1/8.12.1) with ESMTP id j21FvsZA011131 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); + Tue, 1 Mar 2005 10:57:55 -0500 (EST) +X-Rentec: external +Received: from [172.26.132.145] (hoopoe.rentec.com [172.26.132.145]) + by wren.rentec.com (8.13.1/8.12.1) with ESMTP id j21FvsQX003128; + Tue, 1 Mar 2005 10:57:54 -0500 (EST) +Message-ID: <42249102.2060700@rentec.com> +Date: Tue, 01 Mar 2005 10:57:54 -0500 +From: Alan Stange +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b) Gecko/20050217 +MIME-Version: 1.0 +To: "Vig, Sandor (G/FI-2)" +Cc: "'John Arbash Meinel'" , + "'pgsql-performance@postgresql.org'" +Subject: Re: multi billion row tables: possible or insane? +References: <977921B17B2F2048AA5AAE9B4CBB713E01423D75@huaudigs0035.audi.de> +In-Reply-To: <977921B17B2F2048AA5AAE9B4CBB713E01423D75@huaudigs0035.audi.de> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/11 +X-Sequence-Number: 10716 + +Isn't that 385 rows/second. Presumably one can insert more than one +row in a transaction? + +-- Alan + +Vig, Sandor (G/FI-2) wrote: + +>385 transaction/sec? +> +>fsync = false +> +>risky but fast. +> +>-----Original Message----- +>From: pgsql-performance-owner@postgresql.org +>[mailto:pgsql-performance-owner@postgresql.org]On Behalf Of John Arbash +>Meinel +>Sent: Tuesday, March 01, 2005 4:19 PM +>To: Ramon Bastiaans +>Cc: pgsql-performance@postgresql.org +>Subject: Re: [PERFORM] multi billion row tables: possible or insane? +> +> +>Ramon Bastiaans wrote: +> +> +> +>>Hi all, +>> +>>I am doing research for a project of mine where I need to store +>>several billion values for a monitoring and historical tracking system +>>for a big computer system. My currect estimate is that I have to store +>>(somehow) around 1 billion values each month (possibly more). +>> +>> +>> +>If you have that 1 billion perfectly distributed over all hours of the +>day, then you need 1e9/30/24/3600 = 385 transactions per second. +> +>Which I'm pretty sure is possible with postgres, you just need pretty +>beefy hardware. And like Jeff said, lots of disks for lots of IO. +>Like a quad opteron, with 16GB of ram, and around 14-20 very fast disks. +>raid10 not raid5, etc. To improve query performance, you can do some +>load balancing by having replication machines by using Slony. +> +>Or if you can do batch processing, you could split up the work into a +>few update machines, which then do bulk updates on the master database. +>This lets you get more machines into the job, since you can't share a +>database across multiple machines. +> +> +> +>>I was wondering if anyone has had any experience with these kind of +>>big numbers of data in a postgres sql database and how this affects +>>database design and optimization. +>> +>> +>> +>Well, one of the biggest things is if you can get bulk updates, or if +>clients can handle data being slightly out of date, so you can use +>cacheing. Can you segregate your data into separate tables as much as +>possible? Are your clients okay if aggregate information takes a little +>while to update? +> +>One trick is to use semi-lazy materialized views to get your updates to +>be fast. +> +> +> +>>What would be important issues when setting up a database this big, +>>and is it at all doable? Or would it be a insane to think about +>>storing up to 5-10 billion rows in a postgres database. +>> +>> +> +>I think you if you can design the db properly, it is doable. But if you +>have a clients saying "I need up to the second information on 1 billion +>rows", you're never going to get it. +> +> +> +>>The database's performance is important. There would be no use in +>>storing the data if a query will take ages. Query's should be quite +>>fast if possible. +>> +>> +>> +>Again, it depends on the queries being done. +>There are some nice tricks you can use, like doing a month-by-month +>partitioning (if you are getting 1G inserts, you might want week-by-week +>partitioning), and then with a date column index, and a union all view +>you should be able to get pretty good insert speed, and still keep fast +>*recent* queries. Going through 1billion rows is always going to be +>expensive. +> +> +> +>>I would really like to hear people's thoughts/suggestions or "go see a +>>shrink, you must be mad" statements ;) +>> +>>Kind regards, +>> +>>Ramon Bastiaans +>> +>> +> +>I think it would be possible, but there are a lot of design issues with +>a system like this. You can't go into it thinking that you can design a +>multi billion row database the same way you would design a million row db. +> +>John +>=:-> +> +> +>The information transmitted is intended only for the person or entity to +>which it is addressed and may contain confidential and/or privileged +>material. Any review, retransmission, dissemination or other use of, or +>taking of any action in reliance upon, this information by persons or +>entities other than the intended recipient is prohibited. If you received +>this in error, please contact the sender and delete the material from any +>computer. +> +>---------------------------(end of broadcast)--------------------------- +>TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> +> + + +From pgsql-performance-owner@postgresql.org Tue Mar 1 16:27:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 661865649A + for ; + Tue, 1 Mar 2005 16:27:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05096-08 + for ; + Tue, 1 Mar 2005 16:27:01 +0000 (GMT) +Received: from mail.logi-track.com (burro.logi-track.com [213.239.193.212]) + by svr1.postgresql.org (Postfix) with ESMTP id 26F6356482 + for ; + Tue, 1 Mar 2005 16:27:00 +0000 (GMT) +Received: from kingfisher.intern.logi-track.com (pD95DCE38.dip0.t-ipconnect.de + [217.93.206.56]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logi-track.com (Postfix) with ESMTP id 0F43A307FB; + Tue, 1 Mar 2005 17:27:03 +0100 (CET) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logi-track.com (Postfix) with ESMTP id 0B51FAB388; + Tue, 1 Mar 2005 17:26:52 +0100 (CET) +Message-ID: <422497C8.4040109@logi-track.com> +Date: Tue, 01 Mar 2005 17:26:48 +0100 +From: Markus Schaber +User-Agent: Mozilla Thunderbird 1.0 (X11/20050116) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: John Arbash Meinel +Cc: Ramon Bastiaans , + pgsql-performance@postgresql.org +Subject: Re: multi billion row tables: possible or insane? +References: <42243725.6060804@sara.nl> <422487E4.6040107@arbash-meinel.com> +In-Reply-To: <422487E4.6040107@arbash-meinel.com> +X-Enigmail-Version: 0.90.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.109 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/13 +X-Sequence-Number: 10718 + +Hi, John, + +John Arbash Meinel schrieb: + +>> I am doing research for a project of mine where I need to store +>> several billion values for a monitoring and historical tracking system +>> for a big computer system. My currect estimate is that I have to store +>> (somehow) around 1 billion values each month (possibly more). +>> +> If you have that 1 billion perfectly distributed over all hours of the +> day, then you need 1e9/30/24/3600 = 385 transactions per second. + +I hope that he does not use one transaction per inserted row. + +In your in-house tests, we got a speedup factor of up to some hundred +when bundling rows on insertions. The fastest speed was with using +bunches of some thousand rows per transaction, and running about 5 +processes in parallel. + +Regard the usual performance tips: Use a small, but fast-writing RAID +for transaction log (no RAID-5 or RAID-6 variants), possibly a mirroring +of two harddisk-backed SSD. Use different disks for the acutal data +(here, LVM2 with growing volumes could be very handy). Have enough RAM. +Use a fast file system. + +BTW, as you read about the difficulties that you'll face with this +enormous amount of data: Don't think that your task will much be easier +or cheaper using any other DBMS, neither commercial nor open source. For +all of them, you'll need "big iron" hardware, and a skilled team of +admins to set up and maintain the database. + +Markus + +-- +markus schaber | dipl. informatiker +logi-track ag | rennweg 14-16 | ch 8001 z�rich +phone +41-43-888 62 52 | fax +41-43-888 62 53 +mailto:schabios@logi-track.com | www.logi-track.com + +From pgsql-performance-owner@postgresql.org Tue Mar 1 16:27:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 60FDE56498 + for ; + Tue, 1 Mar 2005 16:27:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05539-06 + for ; + Tue, 1 Mar 2005 16:26:56 +0000 (GMT) +Received: from smtp-gw-cl-d.dmv.com (smtp-gw-cl-d.dmv.com [216.240.97.42]) + by svr1.postgresql.org (Postfix) with ESMTP id 0987D5648A + for ; + Tue, 1 Mar 2005 16:26:53 +0000 (GMT) +Received: from lanshark.dmv.com (lanshark.dmv.com [216.240.97.46]) + by smtp-gw-cl-d.dmv.com (8.12.10/8.12.10) with ESMTP id j21GftWa031947; + Tue, 1 Mar 2005 11:41:55 -0500 (EST) (envelope-from sven@dmv.com) +Subject: Re: Inheritence versus delete from +From: Sven Willenberger +To: John Arbash Meinel +Cc: Postgresql Performance list +In-Reply-To: <42248ED5.4030306@arbash-meinel.com> +References: <1109635153.4620.44.camel@lanshark.dmv.com> + <42248ED5.4030306@arbash-meinel.com> +Content-Type: text/plain +Date: Tue, 01 Mar 2005 11:27:52 -0500 +Message-Id: <1109694472.5846.17.camel@lanshark.dmv.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 +Content-Transfer-Encoding: 7bit +X-Scanned-By: MIMEDefang 2.48 on 216.240.97.42 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.332 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_WHOIS +X-Spam-Level: +X-Archive-Number: 200503/12 +X-Sequence-Number: 10717 + +On Tue, 2005-03-01 at 09:48 -0600, John Arbash Meinel wrote: +> Sven Willenberger wrote: +> +> >Trying to determine the best overall approach for the following +> >scenario: +> > +> >Each month our primary table accumulates some 30 million rows (which +> >could very well hit 60+ million rows per month by year's end). Basically +> >there will end up being a lot of historical data with little value +> >beyond archival. +> > +> >The question arises then as the best approach of which I have enumerated +> >three: +> > +> +> I just thought of another possibility. You could create each table +> month-by-month, and then use a view to combine them, and possibly a rule +> to keep things clean. +> +> So you would do something like: +> +> I will assume you already have the data in one big table to show the +> easiest way to create the small tables. +> +> create table tblname-2005-01 as select * from orig_tbl where day >= +> '2005-01-01' and day < '2005-02-01'; +> create table tblname-2005-02 as select * from orig_tbl where day >= +> '2005-02-01' and day < '2005-03-01'; +> create table tblname-2005-03 as select * from orig_tbl where day >= +> '2005-03-01' and day < '2005-04-01'; +> -- create appropriate indicies, rules, constraints on these tables +> +> Then you create a view which includes all of these tables. +> +> create or replace view tblname as +> select * from tblname-2005-01 +> union all select * from tblname-2005-02 +> union all select * from tblname-2005-03 +> ; +> +> Then create insert and update rules which fixe which table gets the new +> data. +> +> create rule up_tblname as on update to tblname do instead +> update tblname-2005-03 set +> col1 = NEW.col1, +> col2 = NEW.col2, +> ... +> where id = NEW.id; +> -- This assumes that you have a unique id on your tables. This is just +> whatever your +> -- primary key is, so it should be a decent assumption. +> +> create rule ins_tblname as on insert to tblname do instead +> insert into tblname-2005-03 (col1, col2, ...) +> values (new.col1, new.col2, ...); +> +> Now the downside of this method, is that every month you need to create +> a new table, and then update the views and the rules. The update rules +> are pretty straightforward, though. +> +> The nice thing is that it keeps your data partitioned, and you don't +> ever have a large select/delete step. You probably will want a small one +> each month to keep the data exactly aligned by month. You don't really +> have to have exact alignments, but as humans, we tend to like that stuff. :) +> +> Probably this is more overhead than you would like to do. Especially if +> you know that you can get away with method 2 (keep 1 big table, and just +> remove old rows out of it every month.) +> +> But this method means that all of your data stays live, but queries with +> appropriate restrictions should stay fast. You also have the ability +> (with v8.0) to move the individual tables onto separate disks. +> +> One more time, though, if you can get away with removing old data and +> just archiving it, do so. But if you want to keep the data live, there +> are a couple of alternatives. +> + +Actually that was the thought behind my using inheritance; when querying +the , it basically does a union all; also, I think it would be +quicker to insert directly into the child table (simply by modifying my +query once a month) rather than the overhead sustained by the rule. + +Since the children tables are individual tables, all the benefits you +cite above still hold. + +Thanks for the input on this ... will have to try a couple things to see +which is most manageable.\ + +Sven + + +From pgsql-performance-owner@postgresql.org Tue Mar 1 16:41:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37CB25647A + for ; + Tue, 1 Mar 2005 16:41:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10602-02 + for ; + Tue, 1 Mar 2005 16:41:48 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id CBEBB5646D + for ; + Tue, 1 Mar 2005 16:41:46 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.2/8.12.9) with ESMTP id + j21Gfej6022773; (envelope-from ) Tue, + 1 Mar 2005 10:41:40 -0600 (CST) +Received: from [192.168.1.13] (65-100-23-249.cdrr.qwest.net [65.100.23.249]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j21GfcnD011528 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Tue, + 1 Mar 2005 10:41:39 -0600 (CST) +Message-ID: <42249B44.6020009@arbash-meinel.com> +Date: Tue, 01 Mar 2005 10:41:40 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Sven Willenberger +Cc: Postgresql Performance list +Subject: Re: Inheritence versus delete from +References: <1109635153.4620.44.camel@lanshark.dmv.com> + <42248ED5.4030306@arbash-meinel.com> + <1109694472.5846.17.camel@lanshark.dmv.com> +In-Reply-To: <1109694472.5846.17.camel@lanshark.dmv.com> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigD8DCEBD73A9385AF0D590A08" +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/14 +X-Sequence-Number: 10719 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigD8DCEBD73A9385AF0D590A08 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Sven Willenberger wrote: + +>On Tue, 2005-03-01 at 09:48 -0600, John Arbash Meinel wrote: +> +> +>>Sven Willenberger wrote: +>> +>> +>> +>>>Trying to determine the best overall approach for the following +>>>scenario: +>>> +>>>Each month our primary table accumulates some 30 million rows (which +>>>could very well hit 60+ million rows per month by year's end). Basically +>>>there will end up being a lot of historical data with little value +>>>beyond archival. +>>> +>>>The question arises then as the best approach of which I have enumerated +>>>three: +>>> +>>> +>>> +>>I just thought of another possibility. You could create each table +>>month-by-month, and then use a view to combine them, and possibly a rule +>>to keep things clean. +>> +>>So you would do something like: +>> +>>I will assume you already have the data in one big table to show the +>>easiest way to create the small tables. +>> +>>create table tblname-2005-01 as select * from orig_tbl where day >= +>>'2005-01-01' and day < '2005-02-01'; +>>create table tblname-2005-02 as select * from orig_tbl where day >= +>>'2005-02-01' and day < '2005-03-01'; +>>create table tblname-2005-03 as select * from orig_tbl where day >= +>>'2005-03-01' and day < '2005-04-01'; +>>-- create appropriate indicies, rules, constraints on these tables +>> +>>Then you create a view which includes all of these tables. +>> +>>create or replace view tblname as +>> select * from tblname-2005-01 +>> union all select * from tblname-2005-02 +>> union all select * from tblname-2005-03 +>>; +>> +>>Then create insert and update rules which fixe which table gets the new +>>data. +>> +>>create rule up_tblname as on update to tblname do instead +>> update tblname-2005-03 set +>> col1 = NEW.col1, +>> col2 = NEW.col2, +>> ... +>> where id = NEW.id; +>>-- This assumes that you have a unique id on your tables. This is just +>>whatever your +>>-- primary key is, so it should be a decent assumption. +>> +>>create rule ins_tblname as on insert to tblname do instead +>> insert into tblname-2005-03 (col1, col2, ...) +>> values (new.col1, new.col2, ...); +>> +>>Now the downside of this method, is that every month you need to create +>>a new table, and then update the views and the rules. The update rules +>>are pretty straightforward, though. +>> +>>The nice thing is that it keeps your data partitioned, and you don't +>>ever have a large select/delete step. You probably will want a small one +>>each month to keep the data exactly aligned by month. You don't really +>>have to have exact alignments, but as humans, we tend to like that stuff. :) +>> +>>Probably this is more overhead than you would like to do. Especially if +>>you know that you can get away with method 2 (keep 1 big table, and just +>>remove old rows out of it every month.) +>> +>>But this method means that all of your data stays live, but queries with +>>appropriate restrictions should stay fast. You also have the ability +>>(with v8.0) to move the individual tables onto separate disks. +>> +>>One more time, though, if you can get away with removing old data and +>>just archiving it, do so. But if you want to keep the data live, there +>>are a couple of alternatives. +>> +>> +>> +> +>Actually that was the thought behind my using inheritance; when querying +>the , it basically does a union all; also, I think it would be +>quicker to insert directly into the child table (simply by modifying my +>query once a month) rather than the overhead sustained by the rule. +> +>Since the children tables are individual tables, all the benefits you +>cite above still hold. +> +>Thanks for the input on this ... will have to try a couple things to see +>which is most manageable.\ +> +>Sven +> +> + +You're right, child tables to act like that. I just recall that at least +at one point, postgres didn't handle indexes with child tables very +well. That's more just what someone else ran into, so he could have been +doing something wrong. +I agree, if child tables end up doing a union all, then it is much +easier to maintain. A select against the master table should +automatically get all of the child tables. +It might just be that you need to create a new index on the child table +whenever you create it, and then postgres can use that new index to do +the filtering. + +John +=:-> + + +--------------enigD8DCEBD73A9385AF0D590A08 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCJJtEJdeBCYSNAAMRAl7VAJ9wjs59o0ScPDtfunQoHiTRy6bBjgCcC2ad +JEYbRXEyBPht2QPS8dPSxNE= +=4Etr +-----END PGP SIGNATURE----- + +--------------enigD8DCEBD73A9385AF0D590A08-- + +From pgsql-performance-owner@postgresql.org Tue Mar 1 16:45:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 574CB5649C + for ; + Tue, 1 Mar 2005 16:45:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09818-07 + for ; + Tue, 1 Mar 2005 16:45:02 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id E09D45647A + for ; + Tue, 1 Mar 2005 16:45:01 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.2/8.12.9) with ESMTP id + j21Giw8f022972; (envelope-from ) Tue, + 1 Mar 2005 10:44:58 -0600 (CST) +Received: from [192.168.1.13] (65-100-23-249.cdrr.qwest.net [65.100.23.249]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j21Gitfh012855 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Tue, + 1 Mar 2005 10:44:57 -0600 (CST) +Message-ID: <42249C0A.1090300@arbash-meinel.com> +Date: Tue, 01 Mar 2005 10:44:58 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Markus Schaber +Cc: Ramon Bastiaans , + pgsql-performance@postgresql.org +Subject: Re: multi billion row tables: possible or insane? +References: <42243725.6060804@sara.nl> <422487E4.6040107@arbash-meinel.com> + <422497C8.4040109@logi-track.com> +In-Reply-To: <422497C8.4040109@logi-track.com> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig2A284578D637918023E3BEB8" +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/15 +X-Sequence-Number: 10720 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig2A284578D637918023E3BEB8 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Markus Schaber wrote: + +>Hi, John, +> +>John Arbash Meinel schrieb: +> +> +> +>>>I am doing research for a project of mine where I need to store +>>>several billion values for a monitoring and historical tracking system +>>>for a big computer system. My currect estimate is that I have to store +>>>(somehow) around 1 billion values each month (possibly more). +>>> +>>> +>>> +>>If you have that 1 billion perfectly distributed over all hours of the +>>day, then you need 1e9/30/24/3600 = 385 transactions per second. +>> +>> +> +>I hope that he does not use one transaction per inserted row. +> +>In your in-house tests, we got a speedup factor of up to some hundred +>when bundling rows on insertions. The fastest speed was with using +>bunches of some thousand rows per transaction, and running about 5 +>processes in parallel. +> +> +You're right. I guess it just depends on how the data comes in, and what +you can do at the client ends. That is kind of where I was saying put a +machine in front which gathers up the information, and then does a batch +update. If your client can do this directly, then you have the same +advantage. + +> +> +John +=:-> + + +--------------enig2A284578D637918023E3BEB8 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCJJwKJdeBCYSNAAMRAv4cAKClpavspRY5NLu2savJTYzTgQwZagCfR0r2 +82QqSfMqD4nKOkdB8V4fCGs= +=gjzI +-----END PGP SIGNATURE----- + +--------------enig2A284578D637918023E3BEB8-- + +From pgsql-performance-owner@postgresql.org Wed Mar 2 00:44:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7BC8255456 + for ; + Wed, 2 Mar 2005 00:44:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55029-04 + for ; + Wed, 2 Mar 2005 00:44:17 +0000 (GMT) +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) + by svr1.postgresql.org (Postfix) with ESMTP id C77D1556D1 + for ; + Wed, 2 Mar 2005 00:44:15 +0000 (GMT) +Received: from localhost (localhost.coronasolutions.com [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 11A7D18B3E5 + for ; + Tue, 1 Mar 2005 17:42:44 -0700 (MST) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (debian [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 27307-06 for ; + Tue, 1 Mar 2005 17:42:43 -0700 (MST) +Received: from [4.228.114.71] (dialup-4.228.114.71.Dial1.Denver1.Level3.net + [4.228.114.71]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by crestone.coronasolutions.com (Postfix) with ESMTP id 9A90618B3DD + for ; + Tue, 1 Mar 2005 17:42:42 -0700 (MST) +Mime-Version: 1.0 (Apple Message framework v619.2) +Content-Transfer-Encoding: 7bit +Message-Id: <124c40d023eab9ed34fda472fbb3db3f@drivefaster.net> +Content-Type: text/plain; charset=US-ASCII; format=flowed +To: pgsql-performance@postgresql.org +From: Dan Harris +Subject: Confusion about locales and 'like' indexes +Date: Tue, 1 Mar 2005 17:44:07 -0700 +X-Mailer: Apple Mail (2.619.2) +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/16 +X-Sequence-Number: 10721 + +Greetings, + +I have been beating myself up today trying to optimize indices for a +query that uses LIKE. In my research I have read that the locale +setting may affect PostgreSQL's choice of seq scan vs index scan. I am +running Fedora Core 2 and it appears when I run "locale" that it is set +to 'en.US-UTF-8'. + +Did I fall into a "gotcha" trap here about C vs non-C locales? I'm not +much of a C programmer so I have no idea what all this touches and +everything has been left as default during PG compilation as well as +Fedora install. I can pg_dump and initdb again with --locale=C if +this will allow my LIKE queries to use indexes, but I just wanted to +know if there was some other place I needed to change locales in the +system? e.g. postgresql.conf or env vars? Or, would the initdb and +reload alone fix it? + +I'm running 8.0.1 if that matters. + +Thanks + + +From pgsql-performance-owner@postgresql.org Wed Mar 2 00:58:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A0AB52AA9 + for ; + Wed, 2 Mar 2005 00:58:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56496-07 + for ; + Wed, 2 Mar 2005 00:58:09 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A61B52A65 + for ; + Wed, 2 Mar 2005 00:58:08 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id DCC8632065; Wed, 2 Mar 2005 01:58:11 +0100 (MET) +From: Gaetano Mendola +X-Newsgroups: pgsql.performance +Subject: Re: Inheritence versus delete from +Date: Wed, 02 Mar 2005 01:56:52 +0100 +Organization: Hub.Org Networking Services +Lines: 32 +Message-ID: <42250F54.8060508@bigfoot.com> +References: <1109635153.4620.44.camel@lanshark.dmv.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +To: Sven Willenberger +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +In-Reply-To: <1109635153.4620.44.camel@lanshark.dmv.com> +X-Enigmail-Version: 0.90.1.1 +X-Enigmail-Supports: pgp-inline, pgp-mime +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/17 +X-Sequence-Number: 10722 + +Sven Willenberger wrote: +> Trying to determine the best overall approach for the following +> scenario: +> +> Each month our primary table accumulates some 30 million rows (which +> could very well hit 60+ million rows per month by year's end). Basically +> there will end up being a lot of historical data with little value +> beyond archival. +> +> The question arises then as the best approach of which I have enumerated +> three: +> +> 1) Just allow the records to accumulate and maintain constant vacuuming, +> etc allowing for the fact that most queries will only be from a recent +> subset of data and should be mostly cached. +> +> 2) Each month: +> SELECT * INTO 3monthsago_dynamically_named_table FROM bigtable WHERE +> targetdate < $3monthsago; +> DELETE FROM bigtable where targetdate < $3monthsago; +> VACUUM ANALYZE bigtable; +> pg_dump 3monthsago_dynamically_named_table for archiving; + + +In my experience copy/delete in a single transaction 60+ million rows +is not feseable, at least on my 1 GB ram, 2 way CPU box. + + + +Regards +Gaetano Mendola + + +From pgsql-performance-owner@postgresql.org Wed Mar 2 01:07:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 107AF53C92 + for ; + Wed, 2 Mar 2005 01:07:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60175-04 + for ; + Wed, 2 Mar 2005 01:06:58 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 954CB52AA9 + for ; + Wed, 2 Mar 2005 01:06:56 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7082052; Tue, 01 Mar 2005 17:08:47 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Ramon Bastiaans +Subject: Re: multi billion row tables: possible or insane? +Date: Tue, 1 Mar 2005 17:11:18 -0800 +User-Agent: KMail/1.7.1 +Cc: pgsql-performance@postgresql.org +References: <42243725.6060804@sara.nl> +In-Reply-To: <42243725.6060804@sara.nl> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200503011711.18571.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/18 +X-Sequence-Number: 10723 + +Ramon, + +> What would be important issues when setting up a database this big, and +> is it at all doable? Or would it be a insane to think about storing up +> to 5-10 billion rows in a postgres database. + +What's your budget? You're not going to do this on a Dell 2650. Do you +have the kind of a budget necessary to purchase/build a good SAN, +Quad-opteron machine, etc.? Or at least hire some tuning help? + + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Mar 2 01:42:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 18E5B566A3 + for ; + Wed, 2 Mar 2005 01:42:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68304-07 + for ; + Wed, 2 Mar 2005 01:42:12 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 32DA656146 + for ; + Wed, 2 Mar 2005 01:42:11 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j221gEVX003458; + Tue, 1 Mar 2005 20:42:14 -0500 (EST) +To: Dan Harris +Cc: pgsql-performance@postgresql.org +Subject: Re: Confusion about locales and 'like' indexes +In-reply-to: <124c40d023eab9ed34fda472fbb3db3f@drivefaster.net> +References: <124c40d023eab9ed34fda472fbb3db3f@drivefaster.net> +Comments: In-reply-to Dan Harris + message dated "Tue, 01 Mar 2005 17:44:07 -0700" +Date: Tue, 01 Mar 2005 20:42:14 -0500 +Message-ID: <3457.1109727734@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/19 +X-Sequence-Number: 10724 + +Dan Harris writes: +> query that uses LIKE. In my research I have read that the locale +> setting may affect PostgreSQL's choice of seq scan vs index scan. + +Non-C-locale indexes can't support LIKE because the sort ordering +isn't necessarily right. + +> I am running Fedora Core 2 and it appears when I run "locale" that it +> is set to 'en.US-UTF-8'. + +This is not a definitive indication of the environment the database +sees, though. Try "show lc_collate". + +> I can pg_dump and initdb again with --locale=C if +> this will allow my LIKE queries to use indexes, but I just wanted to +> know if there was some other place I needed to change locales in the +> system? e.g. postgresql.conf or env vars? Or, would the initdb and +> reload alone fix it? + +That would do it. Alternatively you can create special-purpose indexes +with one of the xxx_pattern_ops operator classes to support LIKE. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 2 03:17:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BDF652A69 + for ; + Wed, 2 Mar 2005 03:17:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91507-09 + for ; + Wed, 2 Mar 2005 03:17:48 +0000 (GMT) +Received: from unicorn.rentec.com (unicorn.rentec.com [216.223.240.9]) + by svr1.postgresql.org (Postfix) with ESMTP id B158C558AC + for ; + Wed, 2 Mar 2005 03:17:46 +0000 (GMT) +Received: from wren.rentec.com (wren.rentec.com [192.5.35.106]) + by unicorn.rentec.com (8.13.1/8.12.1) with ESMTP id j223HmGB019438 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); + Tue, 1 Mar 2005 22:17:49 -0500 (EST) +X-Rentec: external +Received: from [172.16.160.108] (stange-dhcp2.rentec.com [172.16.160.108]) + by wren.rentec.com (8.13.1/8.12.1) with ESMTP id j223Hjad009077; + Tue, 1 Mar 2005 22:17:46 -0500 (EST) +Message-ID: <422524D4.6000009@rentec.com> +Date: Tue, 01 Mar 2005 21:28:36 -0500 +From: Alan Stange +User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ramon Bastiaans +Cc: pgsql-performance@postgresql.org +Subject: Re: multi billion row tables: possible or insane? +References: <42243725.6060804@sara.nl> +In-Reply-To: <42243725.6060804@sara.nl> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/20 +X-Sequence-Number: 10725 + +Ramon Bastiaans wrote: + +> I am doing research for a project of mine where I need to store +> several billion values for a monitoring and historical tracking system +> for a big computer system. My currect estimate is that I have to store +> (somehow) around 1 billion values each month (possibly more). +> +> I was wondering if anyone has had any experience with these kind of +> big numbers of data in a postgres sql database and how this affects +> database design and optimization. +> +> What would be important issues when setting up a database this big, +> and is it at all doable? Or would it be a insane to think about +> storing up to 5-10 billion rows in a postgres database. +> +> The database's performance is important. There would be no use in +> storing the data if a query will take ages. Query's should be quite +> fast if possible. +> +> I would really like to hear people's thoughts/suggestions or "go see a +> shrink, you must be mad" statements ;) + +It just dawned on me that we're doing something that, while not the +same, might be relevant. One of our tables has ~85M rows in it +according to the output from an "explain select * from table". I don't +plan on trying a select count(*) any time soon :) We add and remove +about 25M rows a day to/from this table which would be about 750M +rows/month total. Given our current usage of the database, it could +handle a larger row/day rate without too much trouble. (The problem +isn't adding rows but deleting rows.) + + Column | Type | Modifiers +--------------+----------+----------- + timeseriesid | bigint | + bindata | bytea | + binsize | integer | + rateid | smallint | + ownerid | smallint | +Indexes: + "idx_timeseries" btree (timeseriesid) + +In this case, each bytea entry is typically about 2KB of data, so the +total table size is about 150GB, plus some index overhead. + +A second table has ~100M rows according to explain select *. Again it +has about 30M rows added and removed / day. + + Column | Type | Modifiers +------------+-----------------------+----------- + uniqid | bigint | + type | character varying(50) | + memberid | bigint | + tag | character varying(50) | + membertype | character varying(50) | + ownerid | smallint | +Indexes: + "composite_memberid" btree (memberid) + "composite_uniqid" btree (uniqid) + +There are some additional tables that have a few million rows / day of +activity, so call it 60M rows/day added and removed. We run a vacuum +every day. + +The box is an dual Opteron 248 from Sun. Linux 2.6, 8GB of memory. We +use reiserfs. We started with XFS but had several instances of file +system corruption. Obviously, no RAID 5. The xlog is on a 2 drive +mirror and the rest is on separate mirrored volume. The drives are +fiber channel but that was a mistake as the driver from IBM wasn't very +good. + +So, while we don't have a billion rows we do have ~200M total rows in +all the tables and we're certainly running the daily row count that +you'd need to obtain. But scaling this sort of thing up can be tricky +and your milage may vary. + +In a prior career I ran a "data intensive computing center" and helped +do some design work for a high energy physics experiment: petabytes of +data, big tape robots, etc., the usual Big Science toys. You might +take a look at ROOT and some of the activity from those folks if you +don't need transactions and all the features of a general database like +postgresql. + +-- Alan + +From pgsql-performance-owner@postgresql.org Fri Mar 4 21:57:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B0C6952AA6 + for ; + Wed, 2 Mar 2005 06:45:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46799-03 + for ; + Wed, 2 Mar 2005 06:45:49 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 58F4152A4F + for ; + Wed, 2 Mar 2005 06:45:48 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 0CA2F32064; Wed, 2 Mar 2005 07:45:49 +0100 (MET) +From: stig erikson +X-Newsgroups: pgsql.performance +Subject: Re: What is the postgres sql command for last_user_id ??? +Date: Wed, 02 Mar 2005 07:43:44 +0100 +Organization: Hub.Org Networking Services +Lines: 21 +Message-ID: +References: <1109691962.42248e3a3c898@webmail.moph.go.th> +Mime-Version: 1.0 +Content-Type: text/plain; charset=TIS-620; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b2) Gecko/20050226 +In-Reply-To: <1109691962.42248e3a3c898@webmail.moph.go.th> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/83 +X-Sequence-Number: 10788 + +amrit@health2.moph.go.th wrote: +> I would like to know whether there is any command which the server will give the +> record ID back to the client when client puts the data and the server generates +> an autoincrement ID for that record. +> For example if many clients try to put the money data to the server and each +> record from each client has its own record ID by autoincrement process of the +> server [x+1] and i don't need to lock the record since it will bring the system +> to slow down. That client wil then want to know which ID that server gives to +> that record in order to select that record to print the reciept [bill]. +> I know that in mysql there is a command "last_record_id" which acts the same as +> I mention above. Does anybody know that , please give me the detail? +> +> Amrit,Thailand +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend +> + +http://www.postgresql.org/docs/8.0/static/functions-sequence.html + +From pgsql-performance-owner@postgresql.org Wed Mar 2 06:51:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CF49252A55 + for ; + Wed, 2 Mar 2005 06:51:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48034-02 + for ; + Wed, 2 Mar 2005 06:51:07 +0000 (GMT) +Received: from fep3.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id CACC652A4F + for ; + Wed, 2 Mar 2005 06:51:05 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep3.cogeco.net (Postfix) with SMTP id BA29C4A4F + for ; + Wed, 2 Mar 2005 01:51:05 -0500 (EST) +Received: (qmail 31107 invoked from network); 2 Mar 2005 07:22:00 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 2 Mar 2005 07:22:00 -0000 +Message-ID: <001001c51ef4$3849eeb0$6a01a8c0@KEN> +From: "Ken Egervari" +To: +Subject: Help with tuning this query +Date: Wed, 2 Mar 2005 01:51:11 -0500 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_000D_01C51ECA.4F338250" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.657 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, HTML_50_60, HTML_MESSAGE, RCVD_IN_NJABL_DUL, + RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/23 +X-Sequence-Number: 10728 + +This is a multi-part message in MIME format. + +------=_NextPart_000_000D_01C51ECA.4F338250 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +I've tried to use Dan Tow's tuning method and created all the right = +indexes from his diagraming method, but the query still performs quite = +slow both inside the application and just inside pgadmin III. Can = +anyone be kind enough to help me tune it so that it performs better in = +postgres? I don't think it's using the right indexes, or maybe postgres = +needs special treatment. + +I've converted the below query to SQL from a Hibernate query, so the = +syntax is probably not perfect but it's semantics are exactly the same. = +I've done so by looking at the source code, but I can't run it to get = +the exact SQL since I don't have the database on my home machine. + +select s.* +from shipment s + inner join carrier_code cc on s.carrier_code_id =3D cc.id + inner join carrier c on cc.carrier_id =3D c.id + inner join carrier_to_person ctp on ctp.carrier_id =3D c.id + inner join person p on p.id =3D ctp.person_id + inner join shipment_status cs on s.current_status_id =3D cs.id + inner join release_code rc on cs.release_code_id =3D rc.id + left join shipment_status ss on ss.shipment_id =3D s.id +where + p.id =3D :personId and + s.is_purged =3D false and + rc.number =3D '9' and + cs is not null and + cs.date >=3D current_date - 31 +order by cs.date desc + +Just assume I have no indexes for the moment because while some of the = +indexes I made make it work faster, it's still around 250 milliseconds = +and under heavy load, the query performs very badly (6-7 seconds). + +For your information: + +shipment contains 40,000 rows +shipment_status contains 80,000 rows +release_code contains 8 rows +person contains 300 rows +carrier contains 60 rows +carrier_code contains 70 rows + +The filter ratios are: + +rc.number =3D '9' (0.125) +cs.date >=3D current_date - 31 (.10) +p.id =3D ? (0.003) +s.is_purged =3D false (.98) + +I really hope someone can help since I'm pretty much stuck. + +Best regards and many thanks, +Ken +------=_NextPart_000_000D_01C51ECA.4F338250 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
I've tried to use Dan Tow's tuning = +method and=20 +created all the right indexes from his diagraming method, but the query = +still=20 +performs quite slow both inside the application and just inside pgadmin=20 +III.  Can anyone be kind enough to help me tune it so that it = +performs=20 +better in postgres?  I don't think it's using the right indexes, or = +maybe=20 +postgres needs special treatment.
+
 
+
I've converted the below query to SQL = +from a=20 +Hibernate query, so the syntax is probably not perfect but it's = +semantics=20 +are exactly the same.  I've done = +so by=20 +looking at the source code, but I can't run it to get the exact SQL = +since I=20 +don't have the database on my home machine.
+
 
+
select s.*
from shipment=20 +s
    inner join carrier_code cc on s.carrier_code_id = +=3D=20 +cc.id
+
    inner join carrier c = +on=20 +cc.carrier_id =3D c.id
+
    inner join = +carrier_to_person ctp=20 +on ctp.carrier_id =3D c.id
+
    inner join person p = +on p.id =3D=20 +ctp.person_id
+
    inner join = +shipment_status cs on=20 +s.current_status_id =3D cs.id
+
    inner join = +release_code rc on=20 +cs.release_code_id =3D rc.id
+
    left join = +shipment_status ss on=20 +ss.shipment_id =3D s.id
where
    p.id =3D = +:personId=20 +and
    s.is_purged =3D false = +and
   =20 +rc.number =3D '9' and
    cs is not null=20 +and
    cs.date >=3D current_date - 31
order by = +cs.date=20 +desc
+
Just assume I have no indexes for the = +moment=20 +because while some of the indexes I made make it work faster, it's still = +around=20 +250 milliseconds and under heavy load, the query performs very badly = +(6-7=20 +seconds).
+
 
+
For your information:
+
 
+
shipment contains 40,000 = +rows
+
shipment_status contains 80,000 = +rows
+
release_code contains 8 = +rows
+
person contains 300 rows
+
carrier contains 60 rows
+
carrier_code contains 70 = +rows
+
 
+
The filter ratios are:
+
 
+
rc.number =3D = +'9' (0.125)
+
cs.date >=3D current_date - 31 = +(.10)
+
p.id =3D ? (0.003)
+
s.is_purged =3D false = +(.98)
+
 
+
I really hope someone can help since = +I'm pretty=20 +much stuck.
+
 
+
Best regards and many = +thanks,
+
Ken
+ +------=_NextPart_000_000D_01C51ECA.4F338250-- + + +From pgsql-performance-owner@postgresql.org Wed Mar 2 08:13:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F3DC6563D5 + for ; + Wed, 2 Mar 2005 08:13:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67576-06 + for ; + Wed, 2 Mar 2005 08:13:04 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F08E5639E + for ; + Wed, 2 Mar 2005 08:13:04 +0000 (GMT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j228Cw2x002158 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Wed, 2 Mar 2005 01:13:00 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j228Cv7p047949; + Wed, 2 Mar 2005 01:12:57 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j228CvWt047948; + Wed, 2 Mar 2005 01:12:57 -0700 (MST) (envelope-from mfuhr) +Date: Wed, 2 Mar 2005 01:12:57 -0700 +From: Michael Fuhr +To: amrit@health2.moph.go.th +Cc: PGsql-performance +Subject: Re: What is the postgres sql command for last_user_id ??? +Message-ID: <20050302081257.GB47871@winnie.fuhr.org> +References: <1109691962.42248e3a3c898@webmail.moph.go.th> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1109691962.42248e3a3c898@webmail.moph.go.th> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/24 +X-Sequence-Number: 10729 + +On Tue, Mar 01, 2005 at 10:46:02PM +0700, amrit@health2.moph.go.th wrote: + +> I would like to know whether there is any command which the server will give the +> record ID back to the client when client puts the data and the server generates +> an autoincrement ID for that record. + +See "How do I get the value of a SERIAL insert?" and the question +immediately following it in the FAQ: + +http://www.postgresql.org/files/documentation/faqs/FAQ.html#4.11.2 + +-- +Michael Fuhr +http://www.fuhr.org/~mfuhr/ + +From pgsql-performance-owner@postgresql.org Wed Mar 2 08:58:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4184F55773 + for ; + Wed, 2 Mar 2005 08:58:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79387-05 + for ; + Wed, 2 Mar 2005 08:58:08 +0000 (GMT) +Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net + [194.217.242.88]) + by svr1.postgresql.org (Postfix) with ESMTP id D75CD554DD + for ; + Wed, 2 Mar 2005 08:58:07 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-30.mail.demon.net with esmtp (Exim 4.42) + id 1D6PgF-000CYq-0c; Wed, 02 Mar 2005 08:58:08 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 3E6ED15976; Wed, 2 Mar 2005 08:58:06 +0000 (GMT) +Message-ID: <4225801E.8010003@archonet.com> +Date: Wed, 02 Mar 2005 08:58:06 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ken Egervari +Cc: pgsql-performance@postgresql.org +Subject: Re: Help with tuning this query +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> +In-Reply-To: <001001c51ef4$3849eeb0$6a01a8c0@KEN> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/25 +X-Sequence-Number: 10730 + +Ken Egervari wrote: +> I've tried to use Dan Tow's tuning method + +Who? What? + + > and created all the right +> indexes from his diagraming method, but the query still performs +> quite slow both inside the application and just inside pgadmin III. +> Can anyone be kind enough to help me tune it so that it performs +> better in postgres? I don't think it's using the right indexes, or +> maybe postgres needs special treatment. +> +> I've converted the below query to SQL from a Hibernate query, so the +> syntax is probably not perfect but it's semantics are exactly the +> same. I've done so by looking at the source code, but I can't run it +> to get the exact SQL since I don't have the database on my home +> machine. + +Hibernate is a java thing, no? It'd be helpful to have the actual SQL +the hibernate class (or whatever) generates. One of the problems with +SQL is that you can have multiple ways to get the same results and it's +not always possible for the planner to convert from one to the other. + +Anyway, people will want to see EXPLAIN ANALYSE for the query in +question. Obviously, make sure you've vacuumed and analysed the tables +in question recently. Oh, and make sure yousay what version of PG you're +running. + +> select s.* from shipment s inner join carrier_code cc on +> s.carrier_code_id = cc.id inner join carrier c on cc.carrier_id = +> c.id inner join carrier_to_person ctp on ctp.carrier_id = c.id inner +> join person p on p.id = ctp.person_id inner join shipment_status cs +> on s.current_status_id = cs.id inner join release_code rc on +> cs.release_code_id = rc.id left join shipment_status ss on +> ss.shipment_id = s.id where p.id = :personId and s.is_purged = false +> and rc.number = '9' and cs is not null and cs.date >= current_date - +> 31 order by cs.date desc + +1. Why are you quoting the 9 when checking against rc.number? +2. The "cs is not null" doesn't appear to be qualified - which table? + +> Just assume I have no indexes for the moment because while some of +> the indexes I made make it work faster, it's still around 250 +> milliseconds and under heavy load, the query performs very badly (6-7 +> seconds). + +3. If you rewrite the "current_date - 31" as a suitable ago(31) function +then you can use an index on cs.date +4. Are you familiar with the configuration setting "join_collapse_limit"? + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Mar 2 16:13:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C19F56418 + for ; + Wed, 2 Mar 2005 16:13:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10058-10 + for ; + Wed, 2 Mar 2005 16:13:38 +0000 (GMT) +Received: from presinet-main.presinet.com (mail.presinet.com [209.53.156.1]) + by svr1.postgresql.org (Postfix) with ESMTP id CD08955D73 + for ; + Wed, 2 Mar 2005 16:13:36 +0000 (GMT) +Received: from [10.10.1.151] (BRICK [10.10.1.151]) by + presinet-main.presinet.com with SMTP (Microsoft Exchange + Internet Mail Service Version 5.5.2658.3) + id 1VVB88N2; Wed, 2 Mar 2005 08:11:41 -0800 +Message-ID: <4225E62E.8080506@PresiNET.com> +Date: Wed, 02 Mar 2005 08:13:34 -0800 +From: Bricklen Anderson +User-Agent: Debian Thunderbird 1.0 (X11/20050116) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Richard Huxton +Cc: pgsql-performance@postgresql.org +Subject: Re: Help with tuning this query +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <4225801E.8010003@archonet.com> +In-Reply-To: <4225801E.8010003@archonet.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/26 +X-Sequence-Number: 10731 + +Richard Huxton wrote: +> Ken Egervari wrote: +> +>> I've tried to use Dan Tow's tuning method +> Who? What? + +http://www.singingsql.com/ +Dan has written some remarkable papers on sql tuning. Some of it is pretty complex, but his book +"SQL Tuning" is an excellent resource. + +-- +_______________________________ + +This e-mail may be privileged and/or confidential, and the sender does +not waive any related rights and obligations. Any distribution, use or +copying of this e-mail or the information it contains by other than an +intended recipient is unauthorized. If you received this e-mail in +error, please advise me (by return e-mail or otherwise) immediately. +_______________________________ + +From pgsql-performance-owner@postgresql.org Wed Mar 2 16:18:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E32775642F + for ; + Wed, 2 Mar 2005 16:18:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11857-09 + for ; + Wed, 2 Mar 2005 16:18:43 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) + by svr1.postgresql.org (Postfix) with ESMTP id 53ADF52A5A + for ; + Wed, 2 Mar 2005 16:18:42 +0000 (GMT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id j22GIxh04668; + Wed, 2 Mar 2005 11:18:59 -0500 (EST) +From: Bruce Momjian +Message-Id: <200503021618.j22GIxh04668@candle.pha.pa.us> +Subject: Re: Help with tuning this query +In-Reply-To: <4225E62E.8080506@PresiNET.com> +To: Bricklen Anderson +Date: Wed, 2 Mar 2005 11:18:59 -0500 (EST) +Cc: Richard Huxton , + pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/27 +X-Sequence-Number: 10732 + +Bricklen Anderson wrote: +> Richard Huxton wrote: +> > Ken Egervari wrote: +> > +> >> I've tried to use Dan Tow's tuning method +> > Who? What? +> +> http://www.singingsql.com/ + +That URL is invalid for me. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Wed Mar 2 16:57:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 94D0255D73 + for ; + Wed, 2 Mar 2005 16:57:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23453-09 + for ; + Wed, 2 Mar 2005 16:57:09 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C7E3550F4 + for ; + Wed, 2 Mar 2005 16:57:08 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j22Gv5hv007816; (envelope-from ) Wed, + 2 Mar 2005 10:57:05 -0600 (CST) +Received: from [192.168.1.13] (63-230-158-178.cdrr.qwest.net [63.230.158.178]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j22Gv0l7019860 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Wed, + 2 Mar 2005 10:57:02 -0600 (CST) +Message-ID: <4225F04F.6060305@arbash-meinel.com> +Date: Wed, 02 Mar 2005 10:56:47 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ken Egervari +Cc: pgsql-performance@postgresql.org +Subject: Re: Help with tuning this query +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> +In-Reply-To: <001001c51ef4$3849eeb0$6a01a8c0@KEN> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig73B7FDBABADFD8DA76398C77" +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/28 +X-Sequence-Number: 10733 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig73B7FDBABADFD8DA76398C77 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Ken Egervari wrote: + +> I've tried to use Dan Tow's tuning method and created all the right +> indexes from his diagraming method, but the query still performs quite +> slow both inside the application and just inside pgadmin III. Can +> anyone be kind enough to help me tune it so that it performs better in +> postgres? I don't think it's using the right indexes, or maybe +> postgres needs special treatment. +> + +First, what version of postgres, and have you run VACUUM ANALYZE recently? +Also, please attach the result of running EXPLAIN ANALYZE. +(eg, explain analyze select s.* from shipment ...) + +It's very possible that you don't have up-to-date statistics, which +causes postgres to make a bad estimate of what the fastest plan is. + +Also, if you are using an older version of postgres (like 7.1) you +really should upgrade. There are quite a few performance and real bug fixes. + +> I've converted the below query to SQL from a Hibernate query, so the +> syntax is probably not perfect but it's semantics are exactly the +> same. I've done so by looking at the source code, but I can't run it +> to get the exact SQL since I don't have the database on my home machine. + +I don't know how to make Hibernate do what you want, but if you change +the query to using subselects (not all databases support this, so +hibernate might not let you), you can see a performance improvement. +Also sometimes using explicit joins can be worse than just letting the +query manager figure it out. So something like +select s.* from shipment s, carrier_code cc, carrier c, ... + where s.carrier_code_id = cc.id and c.id = cc.carrier_id and .... + +But again, since this is generated from another program (Hibernate), I +really don't know how you tell it how to tune the SQL. Probably the +biggest "non-bug" performance improvements are from tuning the SQL. +But if postgres isn't using the right indexes, etc, you can probably fix +that. + +John +=:-> + +> +> select s.* +> from shipment s +> inner join carrier_code cc on s.carrier_code_id = cc.id +> inner join carrier c on cc.carrier_id = c.id +> inner join carrier_to_person ctp on ctp.carrier_id = c.id +> inner join person p on p.id = ctp.person_id +> inner join shipment_status cs on s.current_status_id = cs.id +> inner join release_code rc on cs.release_code_id = rc.id +> left join shipment_status ss on ss.shipment_id = s.id +> where +> p.id = :personId and +> s.is_purged = false and +> rc.number = '9' and +> cs is not null and +> cs.date >= current_date - 31 +> order by cs.date desc +> Just assume I have no indexes for the moment because while some of the +> indexes I made make it work faster, it's still around 250 milliseconds +> and under heavy load, the query performs very badly (6-7 seconds). +> +> For your information: +> +> shipment contains 40,000 rows +> shipment_status contains 80,000 rows +> release_code contains 8 rows +> person contains 300 rows +> carrier contains 60 rows +> carrier_code contains 70 rows +> +> The filter ratios are: +> +> rc.number = '9' (0.125) +> cs.date >= current_date - 31 (.10) +> p.id = ? (0.003) +> s.is_purged = false (.98) +> +> I really hope someone can help since I'm pretty much stuck. +> +> Best regards and many thanks, +> Ken + + + +--------------enig73B7FDBABADFD8DA76398C77 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCJfBRJdeBCYSNAAMRAhd8AJ0Za9S7yjBOyJBbrsnC20QCb10DNwCeKXD7 +oZWgu4d7mmEYg2+9iUYzzY0= +=5kTN +-----END PGP SIGNATURE----- + +--------------enig73B7FDBABADFD8DA76398C77-- + +From pgsql-performance-owner@postgresql.org Wed Mar 2 17:23:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C5DBB55D73 + for ; + Wed, 2 Mar 2005 17:23:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31497-06 + for ; + Wed, 2 Mar 2005 17:23:22 +0000 (GMT) +Received: from fep7.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B41052A54 + for ; + Wed, 2 Mar 2005 17:23:19 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep7.cogeco.net (Postfix) with SMTP id 0ABB31459 + for ; + Wed, 2 Mar 2005 12:23:18 -0500 (EST) +Received: (qmail 14334 invoked from network); 2 Mar 2005 17:54:15 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 2 Mar 2005 17:54:15 -0000 +Message-ID: <003701c51f4c$89cfce00$6a01a8c0@KEN> +From: "Ken Egervari" +To: , + "John Arbash Meinel" +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <4225F04F.6060305@arbash-meinel.com> +Subject: Re: Help with tuning this query +Date: Wed, 2 Mar 2005 12:23:23 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.637 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/29 +X-Sequence-Number: 10734 + +>First, what version of postgres, and have you run VACUUM ANALYZE recently? +>Also, please attach the result of running EXPLAIN ANALYZE. +>(eg, explain analyze select s.* from shipment ...) + +I'm using postgres 8.0. I wish I could paste explain analyze, but I won't +be at work for a few days. I was hoping some Postgres/SQL experts here +would be able to simply look at the query and make recommendations because +it's not a very difficult or unique query. + +>It's very possible that you don't have up-to-date statistics, which +>causes postgres to make a bad estimate of what the fastest plan is. + +I run VACUUM ANALYZE religiously. I even dumped the production database and +used it as my test database after a full vacuum analyze. It's really as +fresh as it can be. + +>I don't know how to make Hibernate do what you want, but if you change +>the query to using subselects (not all databases support this, so +>hibernate might not let you), you can see a performance improvement. + +Yes, Hibernate supports sub-selects. In fact, I can even drop down to JDBC +explicitly, so whatever SQL tricks out there I can use will work on +Hibernate. In what way will sub-selects improve this query? + +>Also sometimes using explicit joins can be worse than just letting the +>query manager figure it out. So something like +>select s.* from shipment s, carrier_code cc, carrier c, ... +> where s.carrier_code_id = cc.id and c.id = cc.carrier_id and .... + +I think I can avoid using joins in Hibernate, but it makes the query harder +to maintain. How much of a performance benefit are we talking with this +change? Since hibernate is an object language, you don't actually have to +specify many joins. You can use the "dot" notation. + + Query query = session.createQuery( + "select shipment " + + "from Shipment shipment " + + " inner join +shipment.cargoControlNumber.carrierCode.carrier.persons person " + + " inner join shipment.currentStatus currentStatus " + + " inner join currentStatus.releaseCode releaseCode " + + " left join fetch shipment.currentStatus " + + "where " + + " person.id = :personId and " + + " shipment.isPurged = false and " + + " releaseCode.number = '9' and " + + " currentStatus is not null and " + + " currentStatus.date >= current_date - 31 " + + "order by currentStatus.date desc" + ); + + query.setParameter( "personId", personId ); + + query.setFirstResult( firstResult ); + query.setMaxResults( maxResults ); + + return query.list(); + +As you can see, it's fairly elegant language and maps to SQL quite well. + +>But again, since this is generated from another program (Hibernate), I +>really don't know how you tell it how to tune the SQL. Probably the +>biggest "non-bug" performance improvements are from tuning the SQL. + +I agree, but the ones I've tried aren't good enough. I have made these +indexes that apply to this query as well as others in my from looking at my +SQL scripts. Many of my queries have really sped up to 14 milliseconds from +these indexes. But I can't make this query run any faster. + +CREATE INDEX carrier_to_person_person_id_idx ON carrier_to_person USING +btree (person_id); +CREATE INDEX carrier_to_person_carrier_id_idx ON carrier_to_person USING +btree (carrier_id); +CREATE INDEX carrier_code_carrier_id_idx ON carrier_code USING btree +(carrier_id); +CREATE INDEX shipment_carrier_code_id_idx ON shipment USING btree +(carrier_code_id); +CREATE INDEX current_status_date_idx ON shipment_status USING btree (date); +CREATE INDEX shipment_current_status_id_idx ON shipment USING btree +(current_status_id); +CREATE INDEX shipment_status_shipment_id_idx ON shipment_status USING btree +(shipment_id); + +Thanks for your responses everyone. I'll try and get you that explain +analyze. I'm just not at work at the moment but this is a problem that I'm +simply puzzled and worried about. I'm getting all of this from CVS on my +work server. + +Ken + + +From pgsql-performance-owner@postgresql.org Wed Mar 2 17:38:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E1E9756471 + for ; + Wed, 2 Mar 2005 17:38:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38087-02 + for ; + Wed, 2 Mar 2005 17:38:31 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 782C656467 + for ; + Wed, 2 Mar 2005 17:38:30 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j22HcUij009914; (envelope-from ) Wed, + 2 Mar 2005 11:38:30 -0600 (CST) +Received: from [192.168.1.13] (63-230-158-178.cdrr.qwest.net [63.230.158.178]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j22HcOKh004118 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Wed, + 2 Mar 2005 11:38:26 -0600 (CST) +Message-ID: <4225FA10.6070302@arbash-meinel.com> +Date: Wed, 02 Mar 2005 11:38:24 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ken Egervari +Cc: pgsql-performance@postgresql.org +Subject: Re: Help with tuning this query +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <4225F04F.6060305@arbash-meinel.com> + <003701c51f4c$89cfce00$6a01a8c0@KEN> +In-Reply-To: <003701c51f4c$89cfce00$6a01a8c0@KEN> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig48FE8154343E4349FB0047B7" +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/30 +X-Sequence-Number: 10735 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig48FE8154343E4349FB0047B7 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Ken Egervari wrote: + +>> First, what version of postgres, and have you run VACUUM ANALYZE +>> recently? +>> Also, please attach the result of running EXPLAIN ANALYZE. +>> (eg, explain analyze select s.* from shipment ...) +> +> +> I'm using postgres 8.0. I wish I could paste explain analyze, but I +> won't be at work for a few days. I was hoping some Postgres/SQL +> experts here would be able to simply look at the query and make +> recommendations because it's not a very difficult or unique query. +> +That's the problem. Without explain analyze, it's hard to say why it is +performing weird, because it *does* look like a straightforward query. + +>> It's very possible that you don't have up-to-date statistics, which +>> causes postgres to make a bad estimate of what the fastest plan is. +> +> +> I run VACUUM ANALYZE religiously. I even dumped the production +> database and used it as my test database after a full vacuum analyze. +> It's really as fresh as it can be. +> +Good. Again, this is just the first precaution, as not everyone is as +careful as you. And without the explain analyze, you can't tell what the +planner estimates are. + +>> I don't know how to make Hibernate do what you want, but if you change +>> the query to using subselects (not all databases support this, so +>> hibernate might not let you), you can see a performance improvement. +> +> +> Yes, Hibernate supports sub-selects. In fact, I can even drop down to +> JDBC explicitly, so whatever SQL tricks out there I can use will work +> on Hibernate. In what way will sub-selects improve this query? +> +When doing massive joins across multiple tables (as you are doing) it is +frequently faster to do a couple of small joins where you only need a +couple of rows as input to the rest. Something like: + +select * from shipment s +where s.carrier_code_id in + (select cc.id from carrier_code cc join carrier c on +cc.carrier_id = c.id) +and s.current_status_id in (select cs.id from shipment_status cs where ...) + +Again it's something that you can try. I have found quite a few of my +queries performed much better with subselects. +I'm guessing it's because with big queries it has a harder time figuring +out how to refactor (the decision tree becomes big). But I'm not really +sure. I just know it can work. + +>> Also sometimes using explicit joins can be worse than just letting the +>> query manager figure it out. So something like +>> select s.* from shipment s, carrier_code cc, carrier c, ... +>> where s.carrier_code_id = cc.id and c.id = cc.carrier_id and .... +> +> +> I think I can avoid using joins in Hibernate, but it makes the query +> harder to maintain. How much of a performance benefit are we talking +> with this change? Since hibernate is an object language, you don't +> actually have to specify many joins. You can use the "dot" notation. +> +I'm not saying this *will* improve performance. It is just something to +try. It very easily could not be worth the overhead. + +> Query query = session.createQuery( +> "select shipment " + +> "from Shipment shipment " + +> " inner join +> shipment.cargoControlNumber.carrierCode.carrier.persons person " + +> " inner join shipment.currentStatus currentStatus " + +> " inner join currentStatus.releaseCode releaseCode " + +> " left join fetch shipment.currentStatus " + +> "where " + +> " person.id = :personId and " + +> " shipment.isPurged = false and " + +> " releaseCode.number = '9' and " + +> " currentStatus is not null and " + +> " currentStatus.date >= current_date - 31 " + +> "order by currentStatus.date desc" +> ); +> +> query.setParameter( "personId", personId ); +> +> query.setFirstResult( firstResult ); +> query.setMaxResults( maxResults ); +> +> return query.list(); +> +> As you can see, it's fairly elegant language and maps to SQL quite well. +> +>> But again, since this is generated from another program (Hibernate), I +>> really don't know how you tell it how to tune the SQL. Probably the +>> biggest "non-bug" performance improvements are from tuning the SQL. +> +> +> I agree, but the ones I've tried aren't good enough. I have made +> these indexes that apply to this query as well as others in my from +> looking at my SQL scripts. Many of my queries have really sped up to +> 14 milliseconds from these indexes. But I can't make this query run +> any faster. +> +> CREATE INDEX carrier_to_person_person_id_idx ON carrier_to_person +> USING btree (person_id); +> CREATE INDEX carrier_to_person_carrier_id_idx ON carrier_to_person +> USING btree (carrier_id); +> CREATE INDEX carrier_code_carrier_id_idx ON carrier_code USING btree +> (carrier_id); +> CREATE INDEX shipment_carrier_code_id_idx ON shipment USING btree +> (carrier_code_id); +> CREATE INDEX current_status_date_idx ON shipment_status USING btree +> (date); +> CREATE INDEX shipment_current_status_id_idx ON shipment USING btree +> (current_status_id); +> CREATE INDEX shipment_status_shipment_id_idx ON shipment_status USING +> btree (shipment_id); +> +> Thanks for your responses everyone. I'll try and get you that explain +> analyze. I'm just not at work at the moment but this is a problem +> that I'm simply puzzled and worried about. I'm getting all of this +> from CVS on my work server. +> +> Ken + +There is also the possibility that you are having problems with +cross-column correlation, or poor distribution of a column. Postgres +doesn't keep cross-column statistics, so if 2 columns are correlated, +then it mis-estimates selectivity, and might pick the wrong plan. + +In general your query looks decent, we just need to figure out what is +going on. + +John +=:-> + + +--------------enig48FE8154343E4349FB0047B7 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCJfoQJdeBCYSNAAMRAhp/AJoDpwm9b2Gf0Kc2OZgSECt/vujO2QCffekm +sqdTxPtZYlpxLzN2sfwTLSQ= +=l69T +-----END PGP SIGNATURE----- + +--------------enig48FE8154343E4349FB0047B7-- + +From pgsql-performance-owner@postgresql.org Wed Mar 2 17:52:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 73A9656397 + for ; + Wed, 2 Mar 2005 17:52:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42361-01 + for ; + Wed, 2 Mar 2005 17:52:12 +0000 (GMT) +Received: from mailserver.sandvine.com (sandvine.com [199.243.201.138]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E22E56385 + for ; + Wed, 2 Mar 2005 17:52:11 +0000 (GMT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Performance tradeoff +Date: Wed, 2 Mar 2005 12:52:10 -0500 +Message-ID: <71837C040963F748B9B94E123A28967805710B@mailserver.sandvine.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Performance tradeoff +Thread-Index: AcUfUI7zBX13LqSSSYKqa+nvfysjMw== +From: "Shawn Chisholm" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/31 +X-Sequence-Number: 10736 + +Hi All, + +I am wondering about the relative performance of "insert into table1 = +select distinct a,b from ..." and "insert into table1 select a,b from = +... group by a,b" when querying tables of different sizes (10K, 100K, = +1s, 10s, 100s of millions of rows). =20 + +The distinct way tends to sort/unique and the group by tends to hash = +aggregate... any opinions on which is better? + +I can also change the schema to a certain extent, so would it be = +worthwhile to put indices on the queried tables (or refactor them) = +hoping the distinct does an index scan instead of sort... would the = +query planner take advantage of that? + +Thanks, + +Shawn + + +From pgsql-performance-owner@postgresql.org Wed Mar 2 18:11:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BFA4455D73 + for ; + Wed, 2 Mar 2005 18:11:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45167-08 + for ; + Wed, 2 Mar 2005 18:11:26 +0000 (GMT) +Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) + by svr1.postgresql.org (Postfix) with ESMTP id 55ED6550E3 + for ; + Wed, 2 Mar 2005 18:11:24 +0000 (GMT) +Received: from gnari ([157.157.175.249] [157.157.175.249]) by quasar.skima.is + with ESMTP; Wed, 2 Mar 2005 18:11:23 Z +Subject: Re: Help with tuning this query +From: Ragnar =?ISO-8859-1?Q?Hafsta=F0?= +To: Ken Egervari +Cc: pgsql-performance@postgresql.org +In-Reply-To: <001001c51ef4$3849eeb0$6a01a8c0@KEN> +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> +Content-Type: text/plain +Date: Wed, 02 Mar 2005 18:13:47 +0000 +Message-Id: <1109787227.31084.12.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/32 +X-Sequence-Number: 10737 + +On Wed, 2005-03-02 at 01:51 -0500, Ken Egervari wrote: +> +> select s.* +> from shipment s +> inner join carrier_code cc on s.carrier_code_id = cc.id +> inner join carrier c on cc.carrier_id = c.id +> inner join carrier_to_person ctp on ctp.carrier_id = c.id +> inner join person p on p.id = ctp.person_id +> inner join shipment_status cs on s.current_status_id = cs.id +> inner join release_code rc on cs.release_code_id = rc.id +> left join shipment_status ss on ss.shipment_id = s.id +> where +> p.id = :personId and +> s.is_purged = false and +> rc.number = '9' and +> cs is not null and +> cs.date >= current_date - 31 +> order by cs.date desc +> ... +> shipment contains 40,000 rows +> shipment_status contains 80,000 rows + +I may be missing something, but it looks like the second join +on shipment_status (the left join) is not adding anything to your +results, except more work. ss is not used for output, nor in the where +clause, so what is its purpose ? + +if cs.date has an upper limit, it might be helpful to change the +condition to a BETWEEN + +in any case, i would think you might need an index on + shipment(carrier_code_id) + shipment(current_status_id) + shipment_status(id) + +gnari + + + + +From pgsql-performance-owner@postgresql.org Wed Mar 2 18:28:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D517652A69 + for ; + Wed, 2 Mar 2005 18:28:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52885-04 + for ; + Wed, 2 Mar 2005 18:28:38 +0000 (GMT) +Received: from fep1.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 2361C52A71 + for ; + Wed, 2 Mar 2005 18:28:37 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep1.cogeco.net (Postfix) with SMTP id E5D6D6EB8 + for ; + Wed, 2 Mar 2005 13:28:37 -0500 (EST) +Received: (qmail 16844 invoked from network); 2 Mar 2005 18:59:35 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 2 Mar 2005 18:59:35 -0000 +Message-ID: <000901c51f55$aa4b7400$6a01a8c0@KEN> +From: "Ken Egervari" +To: =?iso-8859-1?Q?Ragnar_Hafsta=F0?= , + +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109787227.31084.12.camel@localhost.localdomain> +Subject: Re: Help with tuning this query +Date: Wed, 2 Mar 2005 13:28:43 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.671 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/33 +X-Sequence-Number: 10738 + +>> select s.* +>> from shipment s +>> inner join carrier_code cc on s.carrier_code_id = cc.id +>> inner join carrier c on cc.carrier_id = c.id +>> inner join carrier_to_person ctp on ctp.carrier_id = c.id +>> inner join person p on p.id = ctp.person_id +>> inner join shipment_status cs on s.current_status_id = cs.id +>> inner join release_code rc on cs.release_code_id = rc.id +>> left join shipment_status ss on ss.shipment_id = s.id +>> where +>> p.id = :personId and +>> s.is_purged = false and +>> rc.number = '9' and +>> cs is not null and +>> cs.date >= current_date - 31 +>> order by cs.date desc +>> ... +>> shipment contains 40,000 rows +>> shipment_status contains 80,000 rows +> +> I may be missing something, but it looks like the second join +> on shipment_status (the left join) is not adding anything to your +> results, except more work. ss is not used for output, nor in the where +> clause, so what is its purpose ? + +It does look strange doesn't it? I would think the same thing if it were +the first time I looked at it. But rest assured, it's done by design. A +shipment relates to many shipment_status rows, but only 1 is the current +shipment_status for the shipment. The first does queries on the current +status only and doesn't analyze the rest of the related items. The second +left join is for eager loading so that I don't have to run a seperate query +to fetch the children for each shipment. This really does improve +performance because otherwise you'll have to make N+1 queries to the +database, and that's just too much overhead. Since I need all the +shipment_status children along with the shipment for the domain logic to +work on them, I have to load them all. + +On average, a shipment will have 2 shipment_status rows. So if the query +selects 100 shipments, the query returns 200 rows. Hibernate is intelligent +enough to map the shipment_status children to the appropriate shipment +automatically. + +> if cs.date has an upper limit, it might be helpful to change the +> condition to a BETWEEN + +Well, I could create an upper limit. It would be the current date. Would +adding in this redundant condition improve performance? I've clustered the +shipment table so that the dates are together, which has improved +performance. I'm not sure adding in this implicit condition will speed up +anything, but I will definately try it. + +> in any case, i would think you might need an index on +> shipment(carrier_code_id) +> shipment(current_status_id) +> shipment_status(id) + +Unfortunately, I have indexes on all three (Postgres implicitly creates +indexes for unique keys). Here are the other 2 that are already created: + +CREATE INDEX shipment_carrier_code_id_idx ON shipment USING btree +(carrier_code_id); +CREATE INDEX shipment_current_status_id_idx ON shipment USING btree +(current_status_id); + +So I guess we've been thinking the same thing. Don't get me wrong. These +indexes speed up the query from 1.6 seconds to 250 milliseconds. I just +need to be around 30 milliseconds. + +Another idea that had occured to me was trying to force postgres to driver +on the person table because that filter ratio is so great compared to +everything else, but I do remember looking at the explain days ago and it +was one of the last tables being filtered/joined. Is there anyway to force +postgres to pick person? The reason I ask is because this would really +reduce the number of rows it pulls out from the shipment table. + +Thanks for comments. I'll try making that date explicit and change the +query to use between to see if that does anything. + +Regards and many thanks, +Ken + + +From pgsql-performance-owner@postgresql.org Wed Mar 2 18:47:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E4581555C6 + for ; + Wed, 2 Mar 2005 18:47:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57993-02 + for ; + Wed, 2 Mar 2005 18:47:26 +0000 (GMT) +Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) + by svr1.postgresql.org (Postfix) with ESMTP id A372B54D78 + for ; + Wed, 2 Mar 2005 18:47:25 +0000 (GMT) +Received: from gnari ([157.157.175.249] [157.157.175.249]) by quasar.skima.is + with ESMTP; Wed, 2 Mar 2005 18:47:25 Z +Subject: Re: Help with tuning this query +From: Ragnar =?ISO-8859-1?Q?Hafsta=F0?= +To: Ken Egervari +Cc: pgsql-performance@postgresql.org +In-Reply-To: <000901c51f55$aa4b7400$6a01a8c0@KEN> +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109787227.31084.12.camel@localhost.localdomain> + <000901c51f55$aa4b7400$6a01a8c0@KEN> +Content-Type: text/plain +Date: Wed, 02 Mar 2005 18:49:53 +0000 +Message-Id: <1109789394.31084.20.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/34 +X-Sequence-Number: 10739 + +On Wed, 2005-03-02 at 13:28 -0500, Ken Egervari wrote: +> >> select s.* +> >> from shipment s +> >> inner join carrier_code cc on s.carrier_code_id = cc.id +> >> inner join carrier c on cc.carrier_id = c.id +> >> inner join carrier_to_person ctp on ctp.carrier_id = c.id +> >> inner join person p on p.id = ctp.person_id +> >> inner join shipment_status cs on s.current_status_id = cs.id +> >> inner join release_code rc on cs.release_code_id = rc.id +> >> left join shipment_status ss on ss.shipment_id = s.id +> >> where +> >> p.id = :personId and +> >> s.is_purged = false and +> >> rc.number = '9' and +> >> cs is not null and +> >> cs.date >= current_date - 31 +> >> order by cs.date desc +> > +> > I may be missing something, but it looks like the second join +> > on shipment_status (the left join) is not adding anything to your +> > results, except more work. ss is not used for output, nor in the where +> > clause, so what is its purpose ? +> ... The second +> left join is for eager loading so that I don't have to run a seperate query +> to fetch the children for each shipment. This really does improve +> performance because otherwise you'll have to make N+1 queries to the +> database, and that's just too much overhead. + +are you saying that you are actually doing a + select s.*,ss.* ... +? + +> > if cs.date has an upper limit, it might be helpful to change the +> > condition to a BETWEEN +> +> Well, I could create an upper limit. It would be the current date. Would +> adding in this redundant condition improve performance? + +it might help the planner estimate better the number of cs rows +affected. whether this improves performance depends on whether +the best plans are sensitive to this. + +an EXPLAIN ANALYSE might reduce the guessing. + +gnari + + + +From pgsql-performance-owner@postgresql.org Wed Mar 2 18:56:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B3DD952A5A + for ; + Wed, 2 Mar 2005 18:56:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59192-07 + for ; + Wed, 2 Mar 2005 18:56:52 +0000 (GMT) +Received: from fep6.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F95D52A71 + for ; + Wed, 2 Mar 2005 18:56:51 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep6.cogeco.net (Postfix) with SMTP id EB815FC7 + for ; + Wed, 2 Mar 2005 13:56:51 -0500 (EST) +Received: (qmail 17878 invoked from network); 2 Mar 2005 19:27:49 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 2 Mar 2005 19:27:49 -0000 +Message-ID: <002801c51f59$9c043900$6a01a8c0@KEN> +From: "Ken Egervari" +To: +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109787227.31084.12.camel@localhost.localdomain> + <000901c51f55$aa4b7400$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> +Subject: Re: Help with tuning this query +Date: Wed, 2 Mar 2005 13:56:57 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.696 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/35 +X-Sequence-Number: 10740 + +>> left join is for eager loading so that I don't have to run a seperate +>> query +>> to fetch the children for each shipment. This really does improve +>> performance because otherwise you'll have to make N+1 queries to the +>> database, and that's just too much overhead. +> +> are you saying that you are actually doing a +> select s.*,ss.* ... +> ? + +Yes, this is how the SQL should be written. When I manually converted the +query, I forgot to include this detail. In hibernate, you don't need to +specifiy the ss.* because you are dealing with objects, so you just say +shipment. The ss.* is indicated in the "fetch" part of the Hibernate query. +That was my mistake. + +> it might help the planner estimate better the number of cs rows +> affected. whether this improves performance depends on whether +> the best plans are sensitive to this. + +This sounds like a good idea since cs rows are quite large. shipment and +shipment_status are the largest tables in the database and they will grow +very large over time. + + +From pgsql-performance-owner@postgresql.org Wed Mar 2 20:06:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EA32952A5D + for ; + Wed, 2 Mar 2005 20:06:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81393-02 + for ; + Wed, 2 Mar 2005 20:06:51 +0000 (GMT) +Received: from fep3.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 4DFBF5637F + for ; + Wed, 2 Mar 2005 20:06:50 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep3.cogeco.net (Postfix) with SMTP id 9CA7A4481 + for ; + Wed, 2 Mar 2005 15:06:51 -0500 (EST) +Received: (qmail 20347 invoked from network); 2 Mar 2005 20:37:49 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 2 Mar 2005 20:37:49 -0000 +Message-ID: <000601c51f63$63c8bb10$6a01a8c0@KEN> +From: "Ken Egervari" +To: =?iso-8859-1?Q?Ragnar_Hafsta=F0?= , + +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109787227.31084.12.camel@localhost.localdomain> + <000901c51f55$aa4b7400$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> +Subject: Re: Help with tuning this query (with explain analyze finally) +Date: Wed, 2 Mar 2005 15:06:58 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.714 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/36 +X-Sequence-Number: 10741 + +>it might help the planner estimate better the number of cs rows +>affected. whether this improves performance depends on whether +>the best plans are sensitive to this. + +I managed to try this and see if it did anything. Unfortunately, it made no +difference. It's still 250 milliseconds. It was a good suggestion though. +I believed it work too. + +> an EXPLAIN ANALYSE might reduce the guessing. + +Okay, here is the explain analyze I managed to get from work. It came out +to 312ms here, but without the analyze it actually runs at ~250ms. It is +using indexes, so my guess is that there are too many joins or it's not +driving on person fast enough. Release code is such a small table that I +dont think that sequencial scan matters. Thanks for taking the time to +analyze this. + +Sort (cost=1902.27..1902.31 rows=17 width=91) (actual time=312.000..312.000 +rows=39 loops=1) + Sort Key: ss.date + -> Hash Join (cost=617.07..1901.92 rows=17 width=91) (actual +time=234.000..312.000 rows=39 loops=1) + Hash Cond: ("outer".carrier_code_id = "inner".id) + -> Merge Join (cost=602.54..1882.73 rows=870 width=91) (actual +time=234.000..312.000 rows=310 loops=1) + Merge Cond: ("outer".current_status_id = "inner".id) + -> Index Scan using shipment_current_status_id_idx on +shipment s (cost=0.00..2552.13 rows=60327 width=66) (actual +time=0.000..61.000 rows=27711 loops=1) + Filter: (is_purged = false) + -> Sort (cost=602.54..607.21 rows=1866 width=25) (actual +time=125.000..125.000 rows=6934 loops=1) + Sort Key: ss.id + -> Hash Join (cost=1.11..501.17 rows=1866 width=25) +(actual time=0.000..78.000 rows=6934 loops=1) + Hash Cond: ("outer".release_code_id = "inner".id) + -> Index Scan using current_status_date_idx on +shipment_status ss (cost=0.00..406.78 rows=14924 width=25) (actual +time=0.000..47.000 rows=15053 loops=1) + Index Cond: (date >= (('now'::text)::date - +31)) + Filter: (id IS NOT NULL) + -> Hash (cost=1.10..1.10 rows=1 width=4) (actual +time=0.000..0.000 rows=0 loops=1) + -> Seq Scan on release_code rc +(cost=0.00..1.10 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=1) + Filter: ((number)::text = '9'::text) + -> Hash (cost=14.53..14.53 rows=2 width=4) (actual +time=0.000..0.000 rows=0 loops=1) + -> Nested Loop (cost=4.92..14.53 rows=2 width=4) (actual +time=0.000..0.000 rows=2 loops=1) + -> Index Scan using person_pkey on person p +(cost=0.00..5.75 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=1) + Index Cond: (id = 355) + -> Hash Join (cost=4.92..8.75 rows=2 width=8) (actual +time=0.000..0.000 rows=2 loops=1) + Hash Cond: ("outer".id = "inner".carrier_id) + -> Seq Scan on carrier c (cost=0.00..3.54 +rows=54 width=4) (actual time=0.000..0.000 rows=54 loops=1) + -> Hash (cost=4.92..4.92 rows=2 width=16) +(actual time=0.000..0.000 rows=0 loops=1) + -> Hash Join (cost=3.04..4.92 rows=2 +width=16) (actual time=0.000..0.000 rows=2 loops=1) + Hash Cond: ("outer".carrier_id = +"inner".carrier_id) + -> Seq Scan on carrier_code cc +(cost=0.00..1.57 rows=57 width=8) (actual time=0.000..0.000 rows=57 loops=1) + -> Hash (cost=3.04..3.04 rows=1 +width=8) (actual time=0.000..0.000 rows=0 loops=1) + -> Index Scan using +carrier_to_person_person_id_idx on carrier_to_person ctp (cost=0.00..3.04 +rows=1 width=8) (actual time=0.000..0.000 rows=1 loops=1) + Index Cond: (355 = +person_id) +Total runtime: 312.000 ms + +Ken + + +From pgsql-performance-owner@postgresql.org Wed Mar 2 20:29:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C0B2756397 + for ; + Wed, 2 Mar 2005 20:29:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87380-03 + for ; + Wed, 2 Mar 2005 20:29:30 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A60BB5638F + for ; + Wed, 2 Mar 2005 20:29:29 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j22KTULj013491; + Wed, 2 Mar 2005 15:29:30 -0500 (EST) +To: "Ken Egervari" +Cc: =?iso-8859-1?Q?Ragnar_Hafsta=F0?= , + pgsql-performance@postgresql.org +Subject: Re: Help with tuning this query (with explain analyze finally) +In-reply-to: <000601c51f63$63c8bb10$6a01a8c0@KEN> +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109787227.31084.12.camel@localhost.localdomain> + <000901c51f55$aa4b7400$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> + <000601c51f63$63c8bb10$6a01a8c0@KEN> +Comments: In-reply-to "Ken Egervari" + message dated "Wed, 02 Mar 2005 15:06:58 -0500" +Date: Wed, 02 Mar 2005 15:29:30 -0500 +Message-ID: <13490.1109795370@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/37 +X-Sequence-Number: 10742 + +"Ken Egervari" writes: +> Okay, here is the explain analyze I managed to get from work. + +What platform is this on? It seems very strange/fishy that all the +actual-time values are exact integral milliseconds. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 2 20:38:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D6AE52A4E + for ; + Wed, 2 Mar 2005 20:38:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88989-04 + for ; + Wed, 2 Mar 2005 20:38:09 +0000 (GMT) +Received: from fep4.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 903B655F4A + for ; + Wed, 2 Mar 2005 20:38:09 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep4.cogeco.net (Postfix) with SMTP id 0B0112B28 + for ; + Wed, 2 Mar 2005 15:38:10 -0500 (EST) +Received: (qmail 21418 invoked from network); 2 Mar 2005 21:09:08 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 2 Mar 2005 21:09:08 -0000 +Message-ID: <000801c51f67$c3abdcc0$6a01a8c0@KEN> +From: "Ken Egervari" +To: "Tom Lane" , + +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109787227.31084.12.camel@localhost.localdomain> + <000901c51f55$aa4b7400$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> + <000601c51f63$63c8bb10$6a01a8c0@KEN> + <13490.1109795370@sss.pgh.pa.us> +Subject: Re: Help with tuning this query (with explain analyze finally) +Date: Wed, 2 Mar 2005 15:38:16 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.728 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/38 +X-Sequence-Number: 10743 + +> "Ken Egervari" writes: +>> Okay, here is the explain analyze I managed to get from work. +> +> What platform is this on? It seems very strange/fishy that all the +> actual-time values are exact integral milliseconds. +> +> regards, tom lane + +My machine is WinXP professional, athon xp 2100, but I get similar results +on my Intel P4 3.0Ghz as well (which is also running WinXP). Why do you +ask? + + +From pgsql-hackers-win32-owner@postgresql.org Wed Mar 2 22:29:51 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0DEED56376; + Wed, 2 Mar 2005 22:29:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18040-07; Wed, 2 Mar 2005 22:29:47 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AA74456373; + Wed, 2 Mar 2005 22:29:45 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j22MTm5V014445; + Wed, 2 Mar 2005 17:29:48 -0500 (EST) +To: "Ken Egervari" +Cc: pgsql-performance@postgresql.org, + pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] Help with tuning this query (with explain analyze + finally) +In-reply-to: <000801c51f67$c3abdcc0$6a01a8c0@KEN> +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109787227.31084.12.camel@localhost.localdomain> + <000901c51f55$aa4b7400$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> + <000601c51f63$63c8bb10$6a01a8c0@KEN> + <13490.1109795370@sss.pgh.pa.us> + <000801c51f67$c3abdcc0$6a01a8c0@KEN> +Comments: In-reply-to "Ken Egervari" + message dated "Wed, 02 Mar 2005 15:38:16 -0500" +Date: Wed, 02 Mar 2005 17:29:48 -0500 +Message-ID: <14444.1109802588@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/41 +X-Sequence-Number: 2999 + +"Ken Egervari" writes: +>> What platform is this on? It seems very strange/fishy that all the +>> actual-time values are exact integral milliseconds. + +> My machine is WinXP professional, athon xp 2100, but I get similar results +> on my Intel P4 3.0Ghz as well (which is also running WinXP). Why do you +> ask? + +Well, what it suggests is that gettimeofday() is only returning a result +good to the nearest millisecond. (Win32 hackers, does that sound right?) + +If so, I'd have to take the EXPLAIN ANALYZE results with a big grain of +salt, because what it's trying to do is add up a lot of +mostly-sub-millisecond intervals. What would essentially happen is that +whichever plan node had control at a particular millisecond boundary +would get charged for the whole preceding millisecond, and any other +nodes (which might have actually eaten most of the millisecond) would +get charged nothing. + +Over a sufficiently long query run, the errors would average out, but +this wasn't that long --- 312 milliseconds, so in essence we are trying +to estimate the query's behavior from only 312 samples of where it was +at the millisecond boundaries. I don't trust profiles based on less +than a few thousand samples ... + +Most modern machines seem to have clocks that can count elapsed time +down to near the microsecond level. Anyone know if it's possible to get +such numbers out of Windows, or are we stuck with milliseconds? + + regards, tom lane + +From pgsql-hackers-win32-owner@postgresql.org Wed Mar 2 23:01:49 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FBAA56381; + Wed, 2 Mar 2005 23:01:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27918-01; Wed, 2 Mar 2005 23:01:18 +0000 (GMT) +Received: from asg002.asg.local (smtp2.arrayservicesgrp.com [208.14.218.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 26DDF56367; + Wed, 2 Mar 2005 23:01:17 +0000 (GMT) +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: [PERFORM] Help with tuning this query (with explain analyze + finally) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +Date: Wed, 2 Mar 2005 17:01:14 -0600 +Message-ID: <49E94D0CFCD4DB43AFBA928DDD20C8F90261845C@asg002.asg.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Help with tuning this query (with explain analyze + finally) +Thread-Index: AcUfd/T3N6irQHYYT62nzRQw6WtRFAAAlVjg +From: "Dave Held" +To: "Tom Lane" , "Ken Egervari" +Cc: , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.093 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/43 +X-Sequence-Number: 3001 + +> -----Original Message----- +> From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +> Sent: Wednesday, March 02, 2005 4:30 PM +> To: Ken Egervari +> Cc: pgsql-performance@postgresql.org;=20 +> pgsql-hackers-win32@postgresql.org +> Subject: Re: [PERFORM] Help with tuning this query (with=20 +> explain analyze +> finally) +>=20 +> [...] +> Well, what it suggests is that gettimeofday() is only=20 +> returning a result good to the nearest millisecond. (Win32 +> hackers, does that sound right?) + +No. There's no such thing as gettimeofday() in Win32. So it +must be making some other call, or perhaps an emulation. + +> [...] +> Most modern machines seem to have clocks that can count elapsed +> time down to near the microsecond level. Anyone know if it's=20 +> possible to get such numbers out of Windows, or are we stuck with +> milliseconds? + +QueryPerformanceCounter() is your friend. + +http://lists.boost.org/MailArchives/boost/msg45626.php + +__ +David B. Held +Software Engineer/Array Services Group +200 14th Ave. East, Sartell, MN 56377 +320.534.3637 320.253.7800 800.752.8129 + +From pgsql-performance-owner@postgresql.org Wed Mar 2 23:25:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5246B55CC5 + for ; + Wed, 2 Mar 2005 23:25:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32885-02 + for ; + Wed, 2 Mar 2005 23:25:25 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id CF57A558AC + for ; + Wed, 2 Mar 2005 23:25:23 +0000 (GMT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j22NPK324500; + Wed, 2 Mar 2005 17:25:21 -0600 +Message-ID: <42264B56.40007@arbash-meinel.com> +Date: Wed, 02 Mar 2005 17:25:10 -0600 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Ken Egervari , + =?ISO-8859-1?Q?Ragnar_Hafsta=F0?= , + pgsql-performance@postgresql.org +Subject: Re: Help with tuning this query (with explain analyze finally) +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109787227.31084.12.camel@localhost.localdomain> + <000901c51f55$aa4b7400$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> + <000601c51f63$63c8bb10$6a01a8c0@KEN> + <13490.1109795370@sss.pgh.pa.us> +In-Reply-To: <13490.1109795370@sss.pgh.pa.us> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigDBE8276913703A68AA30A857" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/41 +X-Sequence-Number: 10746 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigDBE8276913703A68AA30A857 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>"Ken Egervari" writes: +> +> +>>Okay, here is the explain analyze I managed to get from work. +>> +>> +> +>What platform is this on? It seems very strange/fishy that all the +>actual-time values are exact integral milliseconds. +> +> +> +I always get round milliseconds on running. In fact, I think I've seen +cases where it was actually rounding to 15/16ms. Which is the resolution +of the "clock()" call (IIRC). + +This is the function I have for returning time better than clock(), but +it looks like it is still stuck no better than 1ms. +/* + * MSVC has a function called _ftime64, which is in + * "sys/timeb.h", which should be accurate to milliseconds + */ + +#include +#include + +double mf::getTime() +{ + struct __timeb64 timeNow; + _ftime64(&timeNow); + return timeNow.time + timeNow.millitm / 1000.0; +} + +I did, however, find this page: +http://www.wideman-one.com/gw/tech/dataacq/wintiming.htm + +Which talks about the high performance counter, which is supposed to be +able to get better than 1us resolution. + +GetSystemTimes() returns the idle/kernel/user times, and seems to have a +resolution of about 100ns (.1us) GetLocalTime()/GetSystemTime() only has +a resolution of milliseconds. + +In my simple test, I was actually getting timings with a resolution of +.3us for the QueryPerformanceCounter(). That was the overhead of just +the call, since it was called either in a bare loop, or just one after +the other. + +So probably we just need to switch to QueryPerformanceCounter() +[/Frequency]. + +John +=:-> + + +--------------enigDBE8276913703A68AA30A857 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCJktbJdeBCYSNAAMRAoPBAKCwi3p3OwtwEvPaAGVUWrVROinv2QCg2Ckl +UOgj85Hf380DCBUv67nOu7Y= +=3TLj +-----END PGP SIGNATURE----- + +--------------enigDBE8276913703A68AA30A857-- + +From pgsql-performance-owner@postgresql.org Thu Mar 3 01:20:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A4F9656484 + for ; + Thu, 3 Mar 2005 01:20:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61280-03 + for ; + Thu, 3 Mar 2005 01:20:25 +0000 (GMT) +Received: from fep3.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id A017555DC4 + for ; + Thu, 3 Mar 2005 01:20:24 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep3.cogeco.net (Postfix) with SMTP id 667244ABA + for ; + Wed, 2 Mar 2005 20:20:26 -0500 (EST) +Received: (qmail 29116 invoked from network); 3 Mar 2005 01:51:25 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 3 Mar 2005 01:51:25 -0000 +Message-ID: <001a01c51f8f$32bba5b0$6a01a8c0@KEN> +From: "Ken Egervari" +To: "Tom Lane" , + +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109787227.31084.12.camel@localhost.localdomain> + <000901c51f55$aa4b7400$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> + <000601c51f63$63c8bb10$6a01a8c0@KEN> + <13490.1109795370@sss.pgh.pa.us> + <000801c51f67$c3abdcc0$6a01a8c0@KEN> + <14444.1109802588@sss.pgh.pa.us> +Subject: Re: Help with tuning this query (with explain analyze finally) +Date: Wed, 2 Mar 2005 20:20:33 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.74 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/42 +X-Sequence-Number: 10747 + +> If so, I'd have to take the EXPLAIN ANALYZE results with a big grain of +> salt, because what it's trying to do is add up a lot of +> mostly-sub-millisecond intervals. What would essentially happen is that +> whichever plan node had control at a particular millisecond boundary +> would get charged for the whole preceding millisecond, and any other +> nodes (which might have actually eaten most of the millisecond) would +> get charged nothing. + +Well, we do know that it's at least 75% accurate. I'm only looking for a +relative increase in performance. My goal is to try and get this query down +to 30 milliseconds. But even 125 or 75 would be an improvement. Any +improvement, even based on fuzzy data, is still an improvement. Being +precise isn't really that important, at least not to me or the people using +the application. I can see how rounding can throw off results in the inner +parts of the plan though, but I think we should try and work with the +explain as it is. If there is anything else I can give you to help me out, +please ask and I will kindly do it. I want to make this easy for you. + +> Over a sufficiently long query run, the errors would average out, but +> this wasn't that long --- 312 milliseconds, so in essence we are trying +> to estimate the query's behavior from only 312 samples of where it was +> at the millisecond boundaries. I don't trust profiles based on less +> than a few thousand samples ... + +I'm just using data from the production database, which only has 5 digits +worth of rows in the main tables. I don't think I can get millions of rows +in these tables, although I wish I could. I'd have to write a program to +insert the data randomly and try to make it distributed the way a real +production database might look in a few years if I wanted the most accurate +results. I would try to make the dates bunched up correctly and add more +carriers and shipments over time (as more customers would use the system) +expoentially. + +But I'm trying to be practical too. This query is too slow for 5 digits of +rows in the database. Imagine how bad it would be with millions! +Unfortunately, this query gets ran by hundreds of people logged in every 60 +seconds on average. It must be as fast as possible. During peak times, +people have to wait 5 or 6 seconds just to see the results of this query. + +I understand the app may be at fault too, but if this query performed +faster, I'm sure that would solve that problem because it's inheritly slow +and the app is very well layered. It makes good use of frameworks like +Spring, Hibernate and database pooling, which have been used on many +applications and have been running very well for us. The fact that the +query is slow in PgAdmin III or phpPgAdmin speaks that the query can be +tuned better. + +I am no master tuner. I have read as much as I could about database tuning +in general, about the proper use of Hibernate and so on. Frankly, I am not +experienced enough to solve this problem and I wish to learn from the +experts, like you Tom, John, Ragnar and others that have responded kindly to +my request. + +> Most modern machines seem to have clocks that can count elapsed time +> down to near the microsecond level. Anyone know if it's possible to get +> such numbers out of Windows, or are we stuck with milliseconds? + +These results came from PgAdmin III directly. I'm not sure how I can get +different results even if I knew of a way. + + +From pgsql-performance-owner@postgresql.org Thu Mar 3 02:51:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8602C5571D + for ; + Thu, 3 Mar 2005 02:51:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82612-04 + for ; + Thu, 3 Mar 2005 02:51:45 +0000 (GMT) +Received: from fep2.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id E10CB52A5A + for ; + Thu, 3 Mar 2005 02:51:44 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep2.cogeco.net (Postfix) with SMTP id DC9013E68 + for ; + Wed, 2 Mar 2005 21:51:47 -0500 (EST) +Received: (qmail 31013 invoked from network); 3 Mar 2005 03:22:47 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 3 Mar 2005 03:22:47 -0000 +Message-ID: <001001c51f9b$f606cd40$6a01a8c0@KEN> +From: "Ken Egervari" +To: "Ken Egervari" , + +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109787227.31084.12.camel@localhost.localdomain> + <000901c51f55$aa4b7400$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> + <000601c51f63$63c8bb10$6a01a8c0@KEN> + <13490.1109795370@sss.pgh.pa.us> + <000801c51f67$c3abdcc0$6a01a8c0@KEN> + <14444.1109802588@sss.pgh.pa.us> + <001a01c51f8f$32bba5b0$6a01a8c0@KEN> + <000401c51f9b$219ebbd0$6a01a8c0@KEN> +Subject: Re: Help with tuning this query (more musings) +Date: Wed, 2 Mar 2005 21:51:55 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=response +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.749 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/43 +X-Sequence-Number: 10748 + +>I took John's advice and tried to work with sub-selects. I tried this +>variation, which actually seems like it would make a difference +>conceptually since it drives on the person table quickly. But to my +>surprise, the query runs at about 375 milliseconds. I think it's because +>it's going over that shipment table multiple times, which is where the +>results are coming from. + +I also made a version that runs over shipment a single time, but it's +exactly 250 milliseconds. I guess the planner does the exact same thing. + +select s.*, ss.* + +from shipment s + inner join shipment_status ss on s.current_status_id=ss.id + inner join release_code rc on ss.release_code_id=rc.id + left outer join driver d on s.driver_id=d.id + left outer join carrier_code cc on s.carrier_code_id=cc.id +where s.carrier_code_id in ( + select cc.id + from person p + inner join carrier_to_person ctp on p.id=ctp.person_id + inner join carrier c on ctp.carrier_id=c.id + inner join carrier_code cc on cc.carrier_id = c.id + where p.id = 355 + ) + and s.current_status_id is not null + and s.is_purged=false + and(rc.number='9' ) + and(ss.date>=current_date-31 ) + +order by ss.date desc + + +From pgsql-performance-owner@postgresql.org Thu Mar 3 02:52:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EE5615571D + for ; + Thu, 3 Mar 2005 02:52:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83599-01 + for ; + Thu, 3 Mar 2005 02:52:29 +0000 (GMT) +Received: from fep6.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id EC06D53C92 + for ; + Thu, 3 Mar 2005 02:52:28 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep6.cogeco.net (Postfix) with SMTP id 32F9C8AF + for ; + Wed, 2 Mar 2005 21:52:32 -0500 (EST) +Received: (qmail 31034 invoked from network); 3 Mar 2005 03:23:32 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 3 Mar 2005 03:23:32 -0000 +Message-ID: <002a01c51f9c$1066d0e0$6a01a8c0@KEN> +From: "Ken Egervari" +To: +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109787227.31084.12.camel@localhost.localdomain> + <000901c51f55$aa4b7400$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> + <000601c51f63$63c8bb10$6a01a8c0@KEN> + <13490.1109795370@sss.pgh.pa.us> + <000801c51f67$c3abdcc0$6a01a8c0@KEN> + <14444.1109802588@sss.pgh.pa.us> +Subject: Re: Help with tuning this query (Some musings) +Date: Wed, 2 Mar 2005 21:52:39 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.753 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/44 +X-Sequence-Number: 10749 + +I took John's advice and tried to work with sub-selects. I tried this +variation, which actually seems like it would make a difference conceptually +since it drives on the person table quickly. But to my surprise, the query +runs at about 375 milliseconds. I think it's because it's going over that +shipment table multiple times, which is where the results are coming from. + +select s.*, ss.* + +from shipment s + inner join shipment_status ss on s.current_status_id=ss.id + inner join release_code rc on ss.release_code_id=rc.id + left outer join driver d on s.driver_id=d.id + left outer join carrier_code cc on s.carrier_code_id=cc.id +where s.id in ( + select s.id + from person p + inner join carrier_to_person ctp on p.id=ctp.person_id + inner join carrier c on ctp.carrier_id=c.id + inner join carrier_code cc on cc.carrier_id = c.id + inner join shipment s on s.carrier_code_id = cc.id + where p.id = 355 + and s.current_status_id is not null + and s.is_purged=false + ) + and(rc.number='9' ) + and(ss.date>=current_date-31 ) + +order by ss.date desc + +*** Musing 1 +Also, "s.current_status_id is not null" is an important filter that I forgot +to mention. In this example where p.id = 355, it filters out 90% of the +rows. In general, that filter ratio is 0.46 though, which is not quite so +high. However, this filter gets better over time because more and more +users will use a filter that will make this value null. It's still not as +strong as person though and probably never will be. But I thought I'd +mention it nonetheless. + +*** Musing 2 +I do think that the filter "ss.date>=current_date-31" is slowing this query +down. I don't think it's the mention of "current_date" or even that it's +dynamic instead of static. I think the range is just too big. For example, +if I use: + +and ss.date between '2005-02-01 00:00:00' and '2005-02-28 23:59:59' + +The query still results in 250 milliseconds. But if I make the range very +small - say Feb 22nd of 2005: + +and ss.date between '2005-02-22 00:00:00' and '2005-02-22 23:59:59' + +Now the entire query runs in 47 milliseconds on average. If I can't make +this query perform any better, should I change the user interface to select +the date instead of showing the last 31 days to benefit from this single-day +filter? This causes more clicks to select the day (like from a calendar), +but most users probably aren't interested in seeing the entire listing +anyway. However, it's a very important requirement that users know that +shipment enteries exist in the last 31 days (because they are usually +sure-fire problems if they are still in this query after a few days). + +I guess I'm wondering if tuning the query is futile and I should get the +requirements changed, or is there something I can do to really speed it up? + +Thanks again, +Ken + + +From pgsql-performance-owner@postgresql.org Thu Mar 3 04:30:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 18767566A8 + for ; + Thu, 3 Mar 2005 04:30:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09739-06 + for ; + Thu, 3 Mar 2005 04:30:25 +0000 (GMT) +Received: from mail.coretech.co.nz (coretech.co.nz [202.36.204.41]) + by svr1.postgresql.org (Postfix) with ESMTP id 73024566A0 + for ; + Thu, 3 Mar 2005 04:30:23 +0000 (GMT) +Received: (qmail 20376 invoked from network); 3 Mar 2005 04:28:47 -0000 +Received: from 218-101-13-54.paradise.net.nz (HELO ?192.168.1.11?) + (218.101.13.54) by 0 with SMTP; 3 Mar 2005 04:28:47 -0000 +Message-ID: <422692D8.2030002@coretech.co.nz> +Date: Thu, 03 Mar 2005 17:30:16 +1300 +From: Mark Kirkwood +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8b) Gecko/20050301 +MIME-Version: 1.0 +To: Ken Egervari +Cc: pgsql-performance@postgresql.org +Subject: Re: Help with tuning this query +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> +In-Reply-To: <001001c51ef4$3849eeb0$6a01a8c0@KEN> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/45 +X-Sequence-Number: 10750 + +Ken Egervari wrote: +> I've tried to use Dan Tow's tuning method and created all the right indexes from his diagraming method, but the query still performs quite slow both inside the application and just inside pgadmin III. Can anyone be kind enough to help me tune it so that it performs better in postgres? I don't think it's using the right indexes, or maybe postgres needs special treatment. +> +> I've converted the below query to SQL from a Hibernate query, so the syntax is probably not perfect but it's semantics are exactly the same. I've done so by looking at the source code, but I can't run it to get the exact SQL since I don't have the database on my home machine. +> +> select s.* +> from shipment s +> inner join carrier_code cc on s.carrier_code_id = cc.id +> inner join carrier c on cc.carrier_id = c.id +> inner join carrier_to_person ctp on ctp.carrier_id = c.id +> inner join person p on p.id = ctp.person_id +> inner join shipment_status cs on s.current_status_id = cs.id +> inner join release_code rc on cs.release_code_id = rc.id +> left join shipment_status ss on ss.shipment_id = s.id +> where +> p.id = :personId and +> s.is_purged = false and +> rc.number = '9' and +> cs is not null and +> cs.date >= current_date - 31 +> order by cs.date desc +> + +You might be able to coerce the planner to drive off person by +rearranging the join orders, plus a few other bits... hopefully I have +not brutalized the query to the point where it does not work :-) : + +select p.id, s*, ss.* +from person p + inner join carrier_to_person ctp on p.id = ctp.person_id + inner join carrier c on ctp.carrier_id = c.id + inner join carrier_code cc on cc.carrier_id = c.id + inner join shipment s on s.carrier_code_id = cc.id + inner join shipment_status cs on s.current_status_id = cs.id + inner join release_code rc on cs.release_code_id = rc.id + left join shipment_status ss on ss.shipment_id = s.id +where + p.id = :personId and + s.is_purged = false and + rc.number = 9 and + cs is not null and + cs.date between current_date - 31 and current_date +order by cs.date desc + + +I have added the 'p.id' in the select list in the hope that that might +encourage the planner to take seriously the idea of getting the person +row(?) first. In addition I made 9 a number and closed the inequality +(just in case it helps a bit). + + + + + + +From pgsql-performance-owner@postgresql.org Thu Mar 3 05:05:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C671D56649 + for ; + Thu, 3 Mar 2005 05:05:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22904-02 + for ; + Thu, 3 Mar 2005 05:05:08 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id C21FB5641B + for ; + Thu, 3 Mar 2005 05:05:06 +0000 (GMT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j23554326883; + Wed, 2 Mar 2005 23:05:04 -0600 +Message-ID: <42269AFB.9010700@arbash-meinel.com> +Date: Wed, 02 Mar 2005 23:04:59 -0600 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ken Egervari +Cc: pgsql-performance@postgresql.org +Subject: Re: Help with tuning this query (more musings) +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109787227.31084.12.camel@localhost.localdomain> + <000901c51f55$aa4b7400$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> + <000601c51f63$63c8bb10$6a01a8c0@KEN> + <13490.1109795370@sss.pgh.pa.us> + <000801c51f67$c3abdcc0$6a01a8c0@KEN> + <14444.1109802588@sss.pgh.pa.us> + <001a01c51f8f$32bba5b0$6a01a8c0@KEN> + <000401c51f9b$219ebbd0$6a01a8c0@KEN> + <001001c51f9b$f606cd40$6a01a8c0@KEN> +In-Reply-To: <001001c51f9b$f606cd40$6a01a8c0@KEN> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig5E8BBD2D38AF6FF290F40351" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/46 +X-Sequence-Number: 10751 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig5E8BBD2D38AF6FF290F40351 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Ken Egervari wrote: + +>> I took John's advice and tried to work with sub-selects. I tried +>> this variation, which actually seems like it would make a difference +>> conceptually since it drives on the person table quickly. But to my +>> surprise, the query runs at about 375 milliseconds. I think it's +>> because it's going over that shipment table multiple times, which is +>> where the results are coming from. +> +> +> I also made a version that runs over shipment a single time, but it's +> exactly 250 milliseconds. I guess the planner does the exact same thing. +> +Why are you now left joining driver and carrier code, but inner joining +shipment_status? I assume this is the *real* query that you are executing. + + From the earlier explain analyze, and your statements, the initial +person p should be the heavily selective portion. + +And what does "driver" get you? It isn't in the return, and it isn't +part of a selectivity clause. +You are also double joining against carrier code, once as a left outer +join, and once in the inner join. + +This query doesn't seem quite right. Are you sure it is generating the +rows you are expecting? + +> select s.*, ss.* +> +> from shipment s +> inner join shipment_status ss on s.current_status_id=ss.id +> inner join release_code rc on ss.release_code_id=rc.id +> left outer join driver d on s.driver_id=d.id +> left outer join carrier_code cc on s.carrier_code_id=cc.id +> where s.carrier_code_id in ( +> select cc.id +> from person p +> inner join carrier_to_person ctp on p.id=ctp.person_id +> inner join carrier c on ctp.carrier_id=c.id +> inner join carrier_code cc on cc.carrier_id = c.id +> where p.id = 355 +> ) +> and s.current_status_id is not null +> and s.is_purged=false +> and(rc.number='9' ) +> and(ss.date>=current_date-31 ) +> +> order by ss.date desc + +You might want to post the explain analyze of this query to have a point +of reference, but what about something like this: +select s.*, ss.* + +from shipment_status ss on s.current_status_id=ss.id +join (select s.* from shipment s + where s.carrier_code_id in + (select cc.id + from person p + inner join carrier_to_person ctp on p.id=ctp.person_id + inner join carrier c on ctp.carrier_id=c.id + inner join carrier_code cc on cc.carrier_id = c.id + where p.id = 355 + ) + and s.current_status_id is not null + and s.is_purged=false +) as i -- Just a name for the subselect since it is in a join +inner join release_code rc on ss.release_code_id=rc.id +where (rc.number='9' ) +and(ss.date between current_date-31 and current_date()) + +order by ss.date desc + +My idea with this query is to minimize the number of shipment rows that +need to be generated before joining with the other rows. My syntax is +probably a little bit off, since I can't actually run it against real +tables. +But looking at your *original* query, you were getting 15000 rows out of +shipment_status, and then 27700 rows out of shipment, which was then +being merge-joined down to only 300 rows, and then hash-joined down to 39. + +I'm just trying to think of ways to prevent it from blossoming into 27k +rows to start with. + +Please double check your query, because it seems to be grabbing +unnecessary rows with the left joins, and then post another explain +analyze with one (or several) different subselect forms. + +John +=:-> + + +--------------enig5E8BBD2D38AF6FF290F40351 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD4DBQFCJpr7JdeBCYSNAAMRArL1AJjJLQDR/C2yQ6j5jO56U1Zvf55xAKCpgtKD +89erOsVUz1I/Gl2TtXQ0jg== +=AiOK +-----END PGP SIGNATURE----- + +--------------enig5E8BBD2D38AF6FF290F40351-- + +From pgsql-performance-owner@postgresql.org Thu Mar 3 05:32:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 527B6564B8 + for ; + Thu, 3 Mar 2005 05:31:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31100-02 + for ; + Thu, 3 Mar 2005 05:31:54 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 18BD256491 + for ; + Thu, 3 Mar 2005 05:31:51 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7086502; Wed, 02 Mar 2005 21:33:38 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Shawn Chisholm" +Subject: Re: Performance tradeoff +Date: Wed, 2 Mar 2005 21:31:01 -0800 +User-Agent: KMail/1.6.2 +Cc: +References: <71837C040963F748B9B94E123A28967805710B@mailserver.sandvine.com> +In-Reply-To: <71837C040963F748B9B94E123A28967805710B@mailserver.sandvine.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200503022131.01658.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/47 +X-Sequence-Number: 10752 + +Shawn, + +> I can also change the schema to a certain extent, so would it be worthwhile +> to put indices on the queried tables (or refactor them) hoping the distinct +> does an index scan instead of sort... would the query planner take +> advantage of that? + +Use the GROUP BY, with an index on the grouped columns and lots of work_mem +(sort_mem in 7.4). This will give the planner the option of a hashaggregate +which could be significantly faster than the other methods. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Mar 3 05:37:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3AAC056414 + for ; + Thu, 3 Mar 2005 05:37:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33015-02 + for ; + Thu, 3 Mar 2005 05:37:13 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id E8A9856491 + for ; + Thu, 3 Mar 2005 05:37:12 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7086511; Wed, 02 Mar 2005 21:38:59 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Ken Egervari" +Subject: Re: Help with tuning this query +Date: Wed, 2 Mar 2005 21:36:23 -0800 +User-Agent: KMail/1.6.2 +Cc: +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> +In-Reply-To: <001001c51ef4$3849eeb0$6a01a8c0@KEN> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200503022136.23275.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/48 +X-Sequence-Number: 10753 + +Ken, + +> I've tried to use Dan Tow's tuning method and created all the right index= +es +> from his diagraming method, but the query still performs quite slow both +> inside the application and just inside pgadmin III. =C2=A0Can anyone be k= +ind +> enough to help me tune it so that it performs better in postgres? =C2=A0I= + don't +> think it's using the right indexes, or maybe postgres needs special +> treatment. + +=46WIW, I picked up Dan Tow's book to give it a read, and they guy isn't=20 +qualified to author "SQL Tuning". You should chuck that book, it won't he= +lp=20 +you -- not with Oracle or SQL Server, and certainly not with PostgreSQL. = +=20 +O'Reilly continues to have trouble turning out quality database books. + +Also, if you *were* using Dan's method, you'd be driving off Person, not=20 +Shipment. + +=2D-=20 +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Mar 3 05:53:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 60F685664C + for ; + Thu, 3 Mar 2005 05:53:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37545-04 + for ; + Thu, 3 Mar 2005 05:53:01 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 9470556491 + for ; + Thu, 3 Mar 2005 05:53:01 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7086546; Wed, 02 Mar 2005 21:54:49 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Ken Egervari" +Subject: Re: Help with tuning this query (with explain analyze finally) +Date: Wed, 2 Mar 2005 21:52:13 -0800 +User-Agent: KMail/1.6.2 +Cc: Ragnar =?iso-8859-1?q?Hafsta=F0?= , + +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> + <000601c51f63$63c8bb10$6a01a8c0@KEN> +In-Reply-To: <000601c51f63$63c8bb10$6a01a8c0@KEN> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200503022152.13211.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/49 +X-Sequence-Number: 10754 + +Ken, + +> =A0 =A0 =A0 =A0 -> =A0Merge Join =A0(cost=3D602.54..1882.73 rows=3D870 wi= +dth=3D91) (actual +> time=3D234.000..312.000 rows=3D310 loops=3D1) +> =A0 =A0 =A0 =A0 =A0 =A0 =A0 Merge Cond: ("outer".current_status_id =3D "i= +nner".id) + +Hmmm ... this merge join appears to be the majority of your execution=20 +time .... at least within the resolution that PGWin allows us. Please tr= +y=20 +two things, and give us Explain Analyzes: + +1) To determine your query order ala Dan Tow and drive off of person, pleas= +e=20 +SET JOIN_COLLAPSE_LIMIT =3D 1 and then run Mark Kirkwood's version of the=20 +query. (Not that I believe in Dan Tow ... see previous message ... but it= +=20 +would be interesting to see the results. + +2) Force PG to drop the merge join via SET ENABLE_MERGEJOIN =3D FALSE; + +Also, please let us know some about the server you're using and your=20 +configuration parameters, particularly: +shared_buffers +work_mem +effective_cache_size +random_page_cost + +=2D-=20 +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Mar 3 06:35:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4077C52D44 + for ; + Thu, 3 Mar 2005 06:35:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49077-09 + for ; + Thu, 3 Mar 2005 06:35:40 +0000 (GMT) +Received: from fep4.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 8AEF252AA9 + for ; + Thu, 3 Mar 2005 06:35:38 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep4.cogeco.net (Postfix) with SMTP id 25FB749D6 + for ; + Thu, 3 Mar 2005 01:35:35 -0500 (EST) +Received: (qmail 1954 invoked from network); 3 Mar 2005 07:06:35 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 3 Mar 2005 07:06:35 -0000 +Message-ID: <001b01c51fbb$39377b90$6a01a8c0@KEN> +From: "Ken Egervari" +To: "John A Meinel" , + +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109787227.31084.12.camel@localhost.localdomain> + <000901c51f55$aa4b7400$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> + <000601c51f63$63c8bb10$6a01a8c0@KEN> + <13490.1109795370@sss.pgh.pa.us> + <000801c51f67$c3abdcc0$6a01a8c0@KEN> + <14444.1109802588@sss.pgh.pa.us> + <001a01c51f8f$32bba5b0$6a01a8c0@KEN> + <000401c51f9b$219ebbd0$6a01a8c0@KEN> + <001001c51f9b$f606cd40$6a01a8c0@KEN> + <42269AFB.9010700@arbash-meinel.com> +Subject: Re: Help with tuning this query (more musings) +Date: Thu, 3 Mar 2005 01:35:42 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.763 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/50 +X-Sequence-Number: 10755 + +John, + +>Why are you now left joining driver and carrier code, but inner joining +>shipment_status? I assume this is the *real* query that you are executing. + +Well, the old and new versions are real queries. I changed the query a bit +because I noticed for some users, the listing was pulling out many different +drivers. Each separate query on the driver took about 10 milliseconds. For +a listing of 39 results, that's a possible 390 milliseconds assuming all the +drivers are different and none of them are cached. So, I just left joined +the driver and it added about 5 milliseconds of overhead to this query. I +apoligize for not communicating this change, but I had to make it to speed +this stuff up during the day until I could fix the root of the problem. One +thing that I learned is that left joining and including lots of columns +rarely slows the query. The same was done for the carrier_code, although +this only saved 15 milliseconds. + +The end result is still high because the query we are talking about is very +expensive, but at least the following queries that appeared after are +eliminated altogether. The overhead and separate queries really places a +hamper on overall performance. For the person 355, the overhead was about +300 milliseconds since 10 of the drivers were null. I hope this makes +sense. + +>From the earlier explain analyze, and your statements, the initial +>person p should be the heavily selective portion. + +I totally agree. I just never really figured out how to tell postgres my +intentions. + +>You are also double joining against carrier code, once as a left outer +>join, and once in the inner join. + +Yes, that was my mistake since Hibernate didn't generate that - I manually +put in those sub-selects. + +>This query doesn't seem quite right. Are you sure it is generating the +>rows you are expecting? + +Yes, the results are the same with the left joins. I didn't include d.* and +cc.* in the select, which again, is my mistake. The main problem is when I +make changes to the query, I don't think about it in terms of how SQL does +it. I think about Hibernate does it. Earger loading rows is different from +selecting the main row at the top of the query. I bet this comes as very +strange, but in Hibernate they are two-different things. I've been using +Hibernate for so long that working with SQL is not so natural for me. This +is my mistake and I apologize. + +>You might want to post the explain analyze of this query to have a point +>of reference, but what about something like this: +>select s.*, ss.* + +Okay. Here is syntax-corrected version of your very creative query. I +wouldn't have thought of doing something like this at all. It makes perfect +sense that you are commanding the database to do what it should be doing, +which is something I really like since the concept of a planner picking +stuff for me makes me unsettled (even if it is doing it right). + +select i.*, ss.* +from shipment_status ss + inner join release_code rc on ss.release_code_id=rc.id, + ( + select s.* + from shipment s + where s.current_status_id is not null + and s.is_purged=false + and s.carrier_code_id in ( + select cc.id + from person p + inner join carrier_to_person ctp on p.id=ctp.person_id + inner join carrier c on ctp.carrier_id=c.id + inner join carrier_code cc on cc.carrier_id = c.id + where p.id = 355 + ) + ) as i +where (rc.number='9' ) + and(i.current_status_id = ss.id) + and(ss.date between current_date-31 and current_date); + +When running this on my production database, the speed is 265 milliseconds +on average running it 20 times (lowest was 250, highest was 281). Not quite +what we want, but I'm sure the tuning of this new query hasn't really +started. Here is the EXPLAIN ANALYZE. It seems very similiar to the one +postgres picked out but it's a bit shorter. + +Hash IN Join (cost=676.15..1943.11 rows=14 width=91) (actual +time=250.000..328.000 rows=39 loops=1) + Hash Cond: ("outer".carrier_code_id = "inner".id) + -> Merge Join (cost=661.65..1926.51 rows=392 width=91) (actual +time=250.000..328.000 rows=310 loops=1) + Merge Cond: ("outer".current_status_id = "inner".id) + -> Index Scan using shipment_current_status_id_idx on shipment s +(cost=0.00..2702.56 rows=27257 width=66) (actual time=0.000..110.000 +rows=27711 loops=1) + Filter: ((current_status_id IS NOT NULL) AND (is_purged = +false)) + -> Sort (cost=661.65..666.46 rows=1922 width=25) (actual +time=140.000..172.000 rows=6902 loops=1) + Sort Key: ss.id + -> Hash Join (cost=1.11..556.82 rows=1922 width=25) (actual +time=0.000..94.000 rows=6902 loops=1) + Hash Cond: ("outer".release_code_id = "inner".id) + -> Index Scan using current_status_date_idx on +shipment_status ss (cost=0.01..459.64 rows=15372 width=25) (actual +time=0.000..94.000 rows=14925 loops=1) + Index Cond: ((date >= (('now'::text)::date - 31)) +AND (date <= ('now'::text)::date)) + -> Hash (cost=1.10..1.10 rows=1 width=4) (actual +time=0.000..0.000 rows=0 loops=1) + -> Seq Scan on release_code rc (cost=0.00..1.10 +rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=1) + Filter: ((number)::text = '9'::text) + -> Hash (cost=14.49..14.49 rows=2 width=4) (actual time=0.000..0.000 +rows=0 loops=1) + -> Nested Loop (cost=6.87..14.49 rows=2 width=4) (actual +time=0.000..0.000 rows=2 loops=1) + -> Index Scan using person_pkey on person p (cost=0.00..5.73 +rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=1) + Index Cond: (id = 355) + -> Hash Join (cost=6.87..8.74 rows=2 width=8) (actual +time=0.000..0.000 rows=2 loops=1) + Hash Cond: ("outer".carrier_id = "inner".carrier_id) + -> Seq Scan on carrier_code cc (cost=0.00..1.57 +rows=57 width=8) (actual time=0.000..0.000 rows=57 loops=1) + -> Hash (cost=6.86..6.86 rows=1 width=12) (actual +time=0.000..0.000 rows=0 loops=1) + -> Hash Join (cost=3.04..6.86 rows=1 width=12) +(actual time=0.000..0.000 rows=1 loops=1) + Hash Cond: ("outer".id = "inner".carrier_id) + -> Seq Scan on carrier c (cost=0.00..3.54 +rows=54 width=4) (actual time=0.000..0.000 rows=54 loops=1) + -> Hash (cost=3.04..3.04 rows=1 width=8) +(actual time=0.000..0.000 rows=0 loops=1) + -> Index Scan using +carrier_to_person_person_id_idx on carrier_to_person ctp (cost=0.00..3.04 +rows=1 width=8) (actual time=0.000..0.000 rows=1 loops=1) + Index Cond: (355 = person_id) +Total runtime: 344.000 ms + +>My idea with this query is to minimize the number of shipment rows that +>need to be generated before joining with the other rows. My syntax is +>probably a little bit off, since I can't actually run it against real +>tables. + +Yes, I tried adding redundant 'from clauses' with the shipment or +shipment_status tables and each caluse adds 100 milliseconds. I wish they +weren't so expensive. + +>But looking at your *original* query, you were getting 15000 rows out of +>shipment_status, and then 27700 rows out of shipment, which was then +>being merge-joined down to only 300 rows, and then hash-joined down to 39. +>I'm just trying to think of ways to prevent it from blossoming into 27k +>rows to start with. + +Yes, nothing has changed from the original query. By the looks of things, +the sub-select version returns slightly less rows but not much +unfortunately. I'm trying to figure out how to minimize the rows +traversals. Maybe I should explain a bit about the app so you can get an +idea on why the shipment rows are so big? + +You see, the app keeps track of custom status for shipments. Either the +status comes in, so the shipment row is created along with 1 or more +shipment_status rows, or the shipments are prepared in advance (so no +shipment_status rows are assigned to them immediately). + +In the case of p.id = 355, there are ~27000 shipments. But most of these +are prepared in advance, which don't concern this query at all and should be +filtered out. That's why the "s.current_status is not null" is important. +This filter will reduce the rows from 27000 to about 3500, which is all the +real shipments with customs status. The others will gain rows in +shipment_status over time, but new shipment rows will be created in advance +as well. + +At some point, it will probably balance out, but since the features to +prepare shipments in advance are new, only some carriers will have more +shipments than shipment_status rows. In some cases, there are no prepared +shipments. When this happens, there is usually a 1:2 ratio between shipment +and shipment_status. I think this weird distribution makes queries like +this kind of hard to predict the performance of. Anyway, I think it's +better to assume that previous case where shipment rows > shipment_status +will tend to be the norm over time. + +If the query won't perform properly, I'm wondering if the requirements +should really change. For example, there is another table called +release_office that is also associated with shipment. I could filter by +that too. I could then offer a screen to select the release office first +and only show the shipments with that release office. The will reduce the +number of shipments for some users, but not all. Some users use only one or +two release offices, so it wouldn't be a big help. + +I could also make the query select a certain day instead of a range. Like I +said in a previous post, this makes the query run at 47 milliseconds. +However, this might make it harder for users to access the information... +and if they clicked 31 days on the calendar, that's really 47*31 +milliseconds total. I guess I'd have to ask for usability studies or +something to figure out what people really hope to gain from these listings +in the first place and how they'd want to work with them. Maybe it's not a +performance problem - maybe it's a usability problem. However, even if that +were the case, I'd still want to know how to fix something like this for my +own knowledge since I'm still learning. + +I also know others are using postgres quite successfully with tables +containing millions of rows, in applications far more riskier than mine. +I'm not sure why this query is any different. Is there a configuration +setting I can use to make things speed up perhaps? + +Anyhow, thanks for taking the time helping me out John. I'm going to play +with more sub-selects and see if I find a combination that works a bit +better. I'll post my results in a bit. If we do figure this out, it might +be worthwhile for me to make a case-study and make it available over +www.postgres.org so other people can benefit from this experience too. + +Many thanks! + +Ken + + +From pgsql-performance-owner@postgresql.org Thu Mar 3 06:59:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6875A5636F + for ; + Thu, 3 Mar 2005 06:59:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55143-05 + for ; + Thu, 3 Mar 2005 06:59:06 +0000 (GMT) +Received: from fep3.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 8522E560C5 + for ; + Thu, 3 Mar 2005 06:59:05 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep3.cogeco.net (Postfix) with SMTP id 798762C8C + for ; + Thu, 3 Mar 2005 01:59:06 -0500 (EST) +Received: (qmail 2299 invoked from network); 3 Mar 2005 07:30:07 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 3 Mar 2005 07:30:07 -0000 +Message-ID: <004601c51fbe$828bbb50$6a01a8c0@KEN> +From: "Ken Egervari" +To: "Josh Berkus" , + +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> + <000601c51f63$63c8bb10$6a01a8c0@KEN> + <200503022152.13211.josh@agliodbs.com> +Subject: Re: Help with tuning this query (with explain analyze finally) +Date: Thu, 3 Mar 2005 01:59:13 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.769 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/51 +X-Sequence-Number: 10756 + +Josh, + +>1) To determine your query order ala Dan Tow and drive off of person, +>please +>SET JOIN_COLLAPSE_LIMIT = 1 and then run Mark Kirkwood's version of the +>query. (Not that I believe in Dan Tow ... see previous message ... but it +>would be interesting to see the results. + +Unfortunately, the query still takes 250 milliseconds. I tried it with +other queries and the results are the same as before. Here is the explain +analayze anyway: + +Sort (cost=2036.83..2036.87 rows=16 width=103) (actual +time=328.000..328.000 rows=39 loops=1) + Sort Key: cs.date + -> Nested Loop Left Join (cost=620.61..2036.51 rows=16 width=103) +(actual time=250.000..328.000 rows=39 loops=1) + -> Hash Join (cost=620.61..1984.90 rows=16 width=78) (actual +time=250.000..328.000 rows=39 loops=1) + Hash Cond: ("outer".carrier_code_id = "inner".id) + -> Merge Join (cost=606.11..1965.99 rows=825 width=74) +(actual time=250.000..328.000 rows=310 loops=1) + Merge Cond: ("outer".current_status_id = "inner".id) + -> Index Scan using shipment_current_status_id_idx on +shipment s (cost=0.00..2701.26 rows=60307 width=66) (actual +time=0.000..77.000 rows=27711 loops=1) + Filter: (is_purged = false) + -> Sort (cost=606.11..610.50 rows=1756 width=12) +(actual time=141.000..141.000 rows=6902 loops=1) + Sort Key: cs.id + -> Hash Join (cost=1.11..511.48 rows=1756 +width=12) (actual time=0.000..109.000 rows=6902 loops=1) + Hash Cond: ("outer".release_code_id = +"inner".id) + -> Index Scan Backward using +current_status_date_idx on shipment_status cs (cost=0.01..422.58 rows=14047 +width=16) (actual time=0.000..78.000 rows=14925 loops=1) + Index Cond: ((date >= +(('now'::text)::date - 31)) AND (date <= ('now'::text)::date)) + Filter: (cs.* IS NOT NULL) + -> Hash (cost=1.10..1.10 rows=1 width=4) +(actual time=0.000..0.000 rows=0 loops=1) + -> Seq Scan on release_code rc +(cost=0.00..1.10 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=1) + Filter: ((number)::text = +'9'::text) + -> Hash (cost=14.49..14.49 rows=2 width=8) (actual +time=0.000..0.000 rows=0 loops=1) + -> Nested Loop (cost=6.87..14.49 rows=2 width=8) +(actual time=0.000..0.000 rows=2 loops=1) + -> Index Scan using person_pkey on person p +(cost=0.00..5.73 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=1) + Index Cond: (id = 355) + -> Hash Join (cost=6.87..8.74 rows=2 width=8) +(actual time=0.000..0.000 rows=2 loops=1) + Hash Cond: ("outer".carrier_id = +"inner".carrier_id) + -> Seq Scan on carrier_code cc +(cost=0.00..1.57 rows=57 width=8) (actual time=0.000..0.000 rows=57 loops=1) + -> Hash (cost=6.86..6.86 rows=1 width=12) +(actual time=0.000..0.000 rows=0 loops=1) + -> Hash Join (cost=3.04..6.86 rows=1 +width=12) (actual time=0.000..0.000 rows=1 loops=1) + Hash Cond: ("outer".id = +"inner".carrier_id) + -> Seq Scan on carrier c +(cost=0.00..3.54 rows=54 width=4) (actual time=0.000..0.000 rows=54 loops=1) + -> Hash (cost=3.04..3.04 +rows=1 width=8) (actual time=0.000..0.000 rows=0 loops=1) + -> Index Scan using +carrier_to_person_person_id_idx on carrier_to_person ctp (cost=0.00..3.04 +rows=1 width=8) (actual time=0.000..0.000 rows=1 loops=1) + Index Cond: (355 = +person_id) + -> Index Scan using shipment_status_shipment_id_idx on +shipment_status ss (cost=0.00..3.20 rows=2 width=25) (actual +time=0.000..0.000 rows=1 loops=39) + Index Cond: (ss.shipment_id = "outer".id) +Total runtime: 328.000 ms + +>2) Force PG to drop the merge join via SET ENABLE_MERGEJOIN = FALSE; + +Setting this option had no effect either In fact, the query is a bit slower +(266 milliseconds but 250 came up once in 20 executions). + +>Also, please let us know some about the server you're using and your +>configuration parameters, particularly: +>shared_buffers +>work_mem +>effective_cache_size +>random_page_cost + +Well, I'm on a test machine so the settings haven't changed one bit from the +defaults. This may sound embarrassing, but I bet the production server is +not custom configured either. The computer I'm running these queries on is +just a simple Athon XP 2100+ on WinXP with 1GB of RAM. The production +server is a faster P4, but the rest is the same. Here are the 4 values in +my configuration, but 3 of them were commented: + +shared_buffers = 1000 +#work_mem = 1024 +#effective_cache_size = 1000 +#random_page_cost = 4 + +I'm not sure what these do, but I'm guessing the last 2 affect the planner +to do different things with the statistics. Should I increase the first +two? + +Regards, +Ken + + +From pgsql-performance-owner@postgresql.org Thu Mar 3 07:06:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0CF9455E98 + for ; + Thu, 3 Mar 2005 07:06:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57360-06 + for ; + Thu, 3 Mar 2005 07:06:51 +0000 (GMT) +Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net + [194.217.242.85]) + by svr1.postgresql.org (Postfix) with ESMTP id 083F855CC5 + for ; + Thu, 3 Mar 2005 07:06:50 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-35.mail.demon.net with esmtp (Exim 4.42) + id 1D6kO5-000J8B-JG; Thu, 03 Mar 2005 07:04:46 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 7753216540; Thu, 3 Mar 2005 07:06:47 +0000 (GMT) +Message-ID: <4226B787.3090605@archonet.com> +Date: Thu, 03 Mar 2005 07:06:47 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ken Egervari +Cc: John A Meinel , + pgsql-performance@postgresql.org +Subject: Re: Help with tuning this query (more musings) +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109787227.31084.12.camel@localhost.localdomain> + <000901c51f55$aa4b7400$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> + <000601c51f63$63c8bb10$6a01a8c0@KEN> + <13490.1109795370@sss.pgh.pa.us> + <000801c51f67$c3abdcc0$6a01a8c0@KEN> + <14444.1109802588@sss.pgh.pa.us> + <001a01c51f8f$32bba5b0$6a01a8c0@KEN> + <000401c51f9b$219ebbd0$6a01a8c0@KEN> + <001001c51f9b$f606cd40$6a01a8c0@KEN> + <42269AFB.9010700@arbash-meinel.com> + <001b01c51fbb$39377b90$6a01a8c0@KEN> +In-Reply-To: <001b01c51fbb$39377b90$6a01a8c0@KEN> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/52 +X-Sequence-Number: 10757 + +Ken Egervari wrote: +> +> Hash IN Join (cost=676.15..1943.11 rows=14 width=91) (actual +> time=250.000..328.000 rows=39 loops=1) +> Hash Cond: ("outer".carrier_code_id = "inner".id) +> -> Merge Join (cost=661.65..1926.51 rows=392 width=91) (actual +> time=250.000..328.000 rows=310 loops=1) +> Merge Cond: ("outer".current_status_id = "inner".id) +> -> Index Scan using shipment_current_status_id_idx on shipment s +> (cost=0.00..2702.56 rows=27257 width=66) (actual time=0.000..110.000 +> rows=27711 loops=1) +> Filter: ((current_status_id IS NOT NULL) AND (is_purged = +> false)) + +There's a feature in PG called partial indexes - see CREATE INDEX +reference for details. Basically you can do something like: + +CREATE INDEX foo_idx ON shipment (carrier_code_id) +WHERE current_status_id IS NOT NULL +AND is_purged = FALSE; + +Something similar may be a win here, although the above index might not +be quite right - sorry, bit tired at moment. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Thu Mar 3 09:21:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 989F456146 + for ; + Thu, 3 Mar 2005 09:21:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97724-09 + for ; + Thu, 3 Mar 2005 09:21:25 +0000 (GMT) +Received: from fep1.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 79CA2556EE + for ; + Thu, 3 Mar 2005 09:21:24 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep1.cogeco.net (Postfix) with SMTP id A51D473DF + for ; + Thu, 3 Mar 2005 04:21:26 -0500 (EST) +Received: (qmail 4380 invoked from network); 3 Mar 2005 09:52:27 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 3 Mar 2005 09:52:27 -0000 +Message-ID: <000a01c51fd2$64bc6a70$6a01a8c0@KEN> +From: "Ken Egervari" +To: +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <1109789394.31084.20.camel@localhost.localdomain> + <000601c51f63$63c8bb10$6a01a8c0@KEN> + <200503022152.13211.josh@agliodbs.com> +Subject: Re: Help with tuning this query (with explain analyze finally) +Date: Thu, 3 Mar 2005 04:21:33 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.774 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/53 +X-Sequence-Number: 10758 + +>2) Force PG to drop the merge join via SET ENABLE_MERGEJOIN = FALSE; + +Actually, it was 312 milliseconds, so it got worse. + +From pgsql-performance-owner@postgresql.org Thu Mar 3 16:38:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 92A4652A63 + for ; + Thu, 3 Mar 2005 16:38:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21832-08 + for ; + Thu, 3 Mar 2005 16:38:35 +0000 (GMT) +Received: from penguin.goodinassociates.com (penguin.goodinassociates.com + [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id 51D2C5521B + for ; + Thu, 3 Mar 2005 16:38:33 +0000 (GMT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.12.11/8.12.11) with ESMTP id + j23GcT2A006940 + for ; Thu, 3 Mar 2005 10:38:29 -0600 +Subject: name search query speed +From: Jeremiah Jahn +To: postgres performance +Content-Type: text/plain +Date: Thu, 03 Mar 2005 10:38:29 -0600 +Message-Id: <1109867909.16326.58.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-1) +Content-Transfer-Encoding: 7bit +X-RAVMilter-Version: 8.4.4(snapshot 20030410) (penguin.goodinassociates.com) +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/54 +X-Sequence-Number: 10759 + +I have about 5M names stored on my DB. Currently the searches are very +quick unless, they are on a very common last name ie. SMITH. The Index +is always used, but I still hit 10-20 seconds on a SMITH or Jones +search, and I average about 6 searches a second and max out at about +30/s. Any suggestions on how I could arrange things to make this search +quicker? I have 4gb of mem on a raid 5 w/ 3 drives. I'm hoping that I +can increase this speed w/o a HW upgrade. + +thanx, +-jj- + + + +-- +You probably wouldn't worry about what people think of you if you could +know how seldom they do. + -- Olin Miller. + + +From pgsql-performance-owner@postgresql.org Thu Mar 3 17:00:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E10E154D6F + for ; + Thu, 3 Mar 2005 17:00:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31994-02 + for ; + Thu, 3 Mar 2005 16:59:56 +0000 (GMT) +Received: from fep2.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 58D2B5514D + for ; + Thu, 3 Mar 2005 16:59:54 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep2.cogeco.net (Postfix) with SMTP id A205F309D + for ; + Thu, 3 Mar 2005 11:59:53 -0500 (EST) +Received: (qmail 14384 invoked from network); 3 Mar 2005 17:30:56 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 3 Mar 2005 17:30:56 -0000 +Message-ID: <000601c52012$70808c20$6a01a8c0@KEN> +From: "Ken Egervari" +To: "Jeremiah Jahn" , + +References: <1109867909.16326.58.camel@bluejay.goodinassociates.com> +Subject: Re: name search query speed +Date: Thu, 3 Mar 2005 12:00:01 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.778 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/55 +X-Sequence-Number: 10760 + +I'm not sure what the answer is but maybe I can help? Would clustering the +name index make this faster? I thought that would bunch up the pages so the +names were more or less in order, which would improve search time. Just a +guess though. + +Ken + +----- Original Message ----- +From: "Jeremiah Jahn" +To: "postgres performance" +Sent: Thursday, March 03, 2005 11:38 AM +Subject: [PERFORM] name search query speed + + +>I have about 5M names stored on my DB. Currently the searches are very +> quick unless, they are on a very common last name ie. SMITH. The Index +> is always used, but I still hit 10-20 seconds on a SMITH or Jones +> search, and I average about 6 searches a second and max out at about +> 30/s. Any suggestions on how I could arrange things to make this search +> quicker? I have 4gb of mem on a raid 5 w/ 3 drives. I'm hoping that I +> can increase this speed w/o a HW upgrade. +> +> thanx, +> -jj- +> +> +> +> -- +> You probably wouldn't worry about what people think of you if you could +> know how seldom they do. +> -- Olin Miller. +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: Have you searched our list archives? +> +> http://archives.postgresql.org +> + + +From pgsql-performance-owner@postgresql.org Thu Mar 3 17:24:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DBBF455478 + for ; + Thu, 3 Mar 2005 17:23:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37292-09 + for ; + Thu, 3 Mar 2005 17:23:54 +0000 (GMT) +Received: from penguin.goodinassociates.com (penguin.goodinassociates.com + [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id F0E6C566CD + for ; + Thu, 3 Mar 2005 17:23:37 +0000 (GMT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.12.11/8.12.11) with ESMTP id + j23HNbEt007660; Thu, 3 Mar 2005 11:23:37 -0600 +Subject: Re: name search query speed +From: Jeremiah Jahn +To: Ken Egervari +Cc: pgsql-performance@postgresql.org +In-Reply-To: <000601c52012$70808c20$6a01a8c0@KEN> +References: <1109867909.16326.58.camel@bluejay.goodinassociates.com> + <000601c52012$70808c20$6a01a8c0@KEN> +Content-Type: text/plain +Date: Thu, 03 Mar 2005 11:23:37 -0600 +Message-Id: <1109870617.16326.63.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-1) +Content-Transfer-Encoding: 7bit +X-RAVMilter-Version: 8.4.4(snapshot 20030410) (penguin.goodinassociates.com) +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/56 +X-Sequence-Number: 10761 + +yes, it does. I forgot to mention, that I also have clustering on that +table by my name_field index. My Bad. + +On Thu, 2005-03-03 at 12:00 -0500, Ken Egervari wrote: +> I'm not sure what the answer is but maybe I can help? Would clustering the +> name index make this faster? I thought that would bunch up the pages so the +> names were more or less in order, which would improve search time. Just a +> guess though. +> +> Ken +> +> ----- Original Message ----- +> From: "Jeremiah Jahn" +> To: "postgres performance" +> Sent: Thursday, March 03, 2005 11:38 AM +> Subject: [PERFORM] name search query speed +> +> +> >I have about 5M names stored on my DB. Currently the searches are very +> > quick unless, they are on a very common last name ie. SMITH. The Index +> > is always used, but I still hit 10-20 seconds on a SMITH or Jones +> > search, and I average about 6 searches a second and max out at about +> > 30/s. Any suggestions on how I could arrange things to make this search +> > quicker? I have 4gb of mem on a raid 5 w/ 3 drives. I'm hoping that I +> > can increase this speed w/o a HW upgrade. +> > +> > thanx, +> > -jj- +> > +> > +> > +> > -- +> > You probably wouldn't worry about what people think of you if you could +> > know how seldom they do. +> > -- Olin Miller. +> > +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 6: Have you searched our list archives? +> > +> > http://archives.postgresql.org +> > +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +-- +You probably wouldn't worry about what people think of you if you could +know how seldom they do. + -- Olin Miller. + + +From pgsql-performance-owner@postgresql.org Thu Mar 3 17:36:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AE3C75445B + for ; + Thu, 3 Mar 2005 17:36:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42046-02 + for ; + Thu, 3 Mar 2005 17:36:06 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id C8BD252A8D + for ; + Thu, 3 Mar 2005 17:36:05 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7088298; Thu, 03 Mar 2005 09:37:53 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Ken Egervari" +Subject: Re: Help with tuning this query (with explain analyze finally) +Date: Thu, 3 Mar 2005 09:35:14 -0800 +User-Agent: KMail/1.6.2 +Cc: +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <200503022152.13211.josh@agliodbs.com> + <004601c51fbe$828bbb50$6a01a8c0@KEN> +In-Reply-To: <004601c51fbe$828bbb50$6a01a8c0@KEN> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200503030935.14537.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/57 +X-Sequence-Number: 10762 + +Ken, + +Well, I'm a bit stumped on troubleshooting the actual query since Windows' +poor time resolution makes it impossible to trust the actual execution times. +Obviously this is something we need to look into for the Win32 port for +8.1 .. + +> shared_buffers = 1000 + +This may be slowing up that merge join. Try resetting it to 6000. I'm not +sure what system settings you might have to do on Windows to get it to +support higher shared buffers; see the docs. + +> #work_mem = 1024 + +Up this to 4096 for testing purposes; your production value will vary +depending on several factors; see link below. + +> #effective_cache_size = 1000 + +Increase this to the actual amount of RAM you have available, about 750MB (you +do the math) + +> #random_page_cost = 4 + +Leave this for now. + +See www.powerpostgresql.com/PerfList for more information. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Mar 3 17:45:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D93615656C + for ; + Thu, 3 Mar 2005 17:45:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42923-08 + for ; + Thu, 3 Mar 2005 17:45:28 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 85A3D56463 + for ; + Thu, 3 Mar 2005 17:45:28 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7088345; Thu, 03 Mar 2005 09:47:17 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Jeremiah Jahn +Subject: Re: name search query speed +Date: Thu, 3 Mar 2005 09:44:37 -0800 +User-Agent: KMail/1.6.2 +Cc: postgres performance +References: <1109867909.16326.58.camel@bluejay.goodinassociates.com> +In-Reply-To: <1109867909.16326.58.camel@bluejay.goodinassociates.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200503030944.37743.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/58 +X-Sequence-Number: 10763 + +Jeremiah, + +> I have about 5M names stored on my DB. Currently the searches are very +> quick unless, they are on a very common last name ie. SMITH. The Index +> is always used, but I still hit 10-20 seconds on a SMITH or Jones +> search, and I average about 6 searches a second and max out at about +> 30/s. Any suggestions on how I could arrange things to make this search +> quicker? I have 4gb of mem on a raid 5 w/ 3 drives. I'm hoping that I +> can increase this speed w/o a HW upgrade. + +First off, see http://www.powerpostgresql.com/PerfList about your +configuration settings. + +The problem you're running into with SMITH is that, if your query is going to +return a substantial number of rows (variable, but generally anything over 5% +of the table and 1000 rows) is not able to make effective use of an index. +This makes it fall back on a sequential scan, and based on you execution +time, I'd guess that the table is a bit too large to fit in memory. + +AFTER you've made the configuration changes above, AND run VACUUM ANALYZE on +your database, if you're still having problems post an EXPLAIN ANALYZE of the +query to this list. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Mar 3 17:46:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BE7E05574D + for ; + Thu, 3 Mar 2005 17:46:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44180-05 + for ; + Thu, 3 Mar 2005 17:46:28 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id DFEFB566A0 + for ; + Thu, 3 Mar 2005 17:46:20 +0000 (GMT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j23HkA331834; + Thu, 3 Mar 2005 11:46:10 -0600 +Message-ID: <42274D5A.1070402@arbash-meinel.com> +Date: Thu, 03 Mar 2005 11:46:02 -0600 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeremiah Jahn +Cc: postgres performance +Subject: Re: name search query speed +References: <1109867909.16326.58.camel@bluejay.goodinassociates.com> +In-Reply-To: <1109867909.16326.58.camel@bluejay.goodinassociates.com> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigCEF05B15A5A9B1D17863308B" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/59 +X-Sequence-Number: 10764 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigCEF05B15A5A9B1D17863308B +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Jeremiah Jahn wrote: + +>I have about 5M names stored on my DB. Currently the searches are very +>quick unless, they are on a very common last name ie. SMITH. The Index +>is always used, but I still hit 10-20 seconds on a SMITH or Jones +>search, and I average about 6 searches a second and max out at about +>30/s. Any suggestions on how I could arrange things to make this search +>quicker? I have 4gb of mem on a raid 5 w/ 3 drives. I'm hoping that I +>can increase this speed w/o a HW upgrade. +> +>thanx, +>-jj- +> +> +> +> +> +It sounds like the problem is just that you have a lot of rows that need +to be returned. Can you just put a limit on the query? And then change +the client app to recognize when the limit is reached, and either give a +link to more results, or refine query, or something like that. + +John +=:-> + + +--------------enigCEF05B15A5A9B1D17863308B +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCJ01dJdeBCYSNAAMRArw/AJoDbm9FRRy++bbW3IqBcRHnw4HlUQCfZB7h +ynQLDO9yIVQ6NPWa8XiM3uc= +=kodJ +-----END PGP SIGNATURE----- + +--------------enigCEF05B15A5A9B1D17863308B-- + +From pgsql-performance-owner@postgresql.org Thu Mar 3 18:37:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E4E50563AA + for ; + Thu, 3 Mar 2005 18:36:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57420-09 + for ; + Thu, 3 Mar 2005 18:36:54 +0000 (GMT) +Received: from mail.logix-tt.com (wallaby.dingens.org [212.75.36.180]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C8475639B + for ; + Thu, 3 Mar 2005 18:36:51 +0000 (GMT) +Received: from kingfisher.intern.logi-track.com (pD95DCDF2.dip0.t-ipconnect.de + [217.93.205.242]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 063A8A859A; + Thu, 3 Mar 2005 18:36:52 +0000 (UTC) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logi-track.com (Postfix) with ESMTP id 9FFDEAB3D8; + Thu, 3 Mar 2005 19:36:46 +0100 (CET) +Message-ID: <4227593D.4020209@logix-tt.com> +Date: Thu, 03 Mar 2005 19:36:45 +0100 +From: Markus Schaber +User-Agent: Mozilla Thunderbird 1.0 (X11/20050116) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: Jeremiah Jahn +Cc: Ken Egervari , pgsql-performance@postgresql.org +Subject: Re: name search query speed +References: <1109867909.16326.58.camel@bluejay.goodinassociates.com> + <000601c52012$70808c20$6a01a8c0@KEN> + <1109870617.16326.63.camel@bluejay.goodinassociates.com> +In-Reply-To: <1109870617.16326.63.camel@bluejay.goodinassociates.com> +X-Enigmail-Version: 0.90.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-15 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/60 +X-Sequence-Number: 10765 + +Hi, Jeremiah, + +Jeremiah Jahn schrieb: +> yes, it does. I forgot to mention, that I also have clustering on that +> table by my name_field index. My Bad. + +Fine. Did you run ANALYZE and CLUSTER on the table after every large +bunch of insertions / updates? + +Markus + + +-- +Markus Schaber | Dipl. Informatiker | Software Development GIS + +Fight against software patents in EU! http://ffii.org/ + http://nosoftwarepatents.org/ + +From pgsql-performance-owner@postgresql.org Thu Mar 3 20:14:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 46D435639B + for ; + Thu, 3 Mar 2005 20:14:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84151-04 + for ; + Thu, 3 Mar 2005 20:14:48 +0000 (GMT) +Received: from penguin.goodinassociates.com (penguin.goodinassociates.com + [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E99556398 + for ; + Thu, 3 Mar 2005 20:14:47 +0000 (GMT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.12.11/8.12.11) with ESMTP id + j23KEk3B010468; Thu, 3 Mar 2005 14:14:46 -0600 +Subject: Re: name search query speed +From: Jeremiah Jahn +To: John A Meinel +Cc: postgres performance +In-Reply-To: <42274D5A.1070402@arbash-meinel.com> +References: <1109867909.16326.58.camel@bluejay.goodinassociates.com> + <42274D5A.1070402@arbash-meinel.com> +Content-Type: text/plain +Date: Thu, 03 Mar 2005 14:14:47 -0600 +Message-Id: <1109880887.16326.86.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-1) +Content-Transfer-Encoding: 7bit +X-RAVMilter-Version: 8.4.4(snapshot 20030410) (penguin.goodinassociates.com) +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/61 +X-Sequence-Number: 10766 + +On Thu, 2005-03-03 at 11:46 -0600, John A Meinel wrote: +> Jeremiah Jahn wrote: +> +> >I have about 5M names stored on my DB. Currently the searches are very +> >quick unless, they are on a very common last name ie. SMITH. The Index +> >is always used, but I still hit 10-20 seconds on a SMITH or Jones +> >search, and I average about 6 searches a second and max out at about +> >30/s. Any suggestions on how I could arrange things to make this search +> >quicker? I have 4gb of mem on a raid 5 w/ 3 drives. I'm hoping that I +> >can increase this speed w/o a HW upgrade. +> > +> >thanx, +> >-jj- +> > +> > +> > +> > +> > +> It sounds like the problem is just that you have a lot of rows that need +> to be returned. Can you just put a limit on the query? And then change +> the client app to recognize when the limit is reached, and either give a +> link to more results, or refine query, or something like that. +Not really, about 2% of the returned rows are thrown away for security +reasons based on the current user, security groups they belong to and +different flags in the data itself. So the count for this is generated +on the fly needed for pagination in the app which expresses the total +number of finds, but only displays 40 of them. If any one knows a way to +determine the total number of matches without needing to iterate through +them using jdbc, I'm all ears as this would save me huge amounts of time +and limit/offset would become an option. + +> +> John +> =:-> +> +-- +"A power so great, it can only be used for Good or Evil!" + -- Firesign Theatre, "The Giant Rat of Summatra" + + +From pgsql-performance-owner@postgresql.org Thu Mar 3 20:19:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3250D54FDF + for ; + Thu, 3 Mar 2005 20:19:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84220-07 + for ; + Thu, 3 Mar 2005 20:19:19 +0000 (GMT) +Received: from penguin.goodinassociates.com (penguin.goodinassociates.com + [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id 35B7352A6A + for ; + Thu, 3 Mar 2005 20:19:18 +0000 (GMT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.12.11/8.12.11) with ESMTP id + j23KJGsa010518; Thu, 3 Mar 2005 14:19:16 -0600 +Subject: Re: name search query speed +From: Jeremiah Jahn +To: Josh Berkus +Cc: postgres performance +In-Reply-To: <200503030944.37743.josh@agliodbs.com> +References: <1109867909.16326.58.camel@bluejay.goodinassociates.com> + <200503030944.37743.josh@agliodbs.com> +Content-Type: text/plain +Date: Thu, 03 Mar 2005 14:19:17 -0600 +Message-Id: <1109881157.16326.91.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-1) +Content-Transfer-Encoding: 7bit +X-RAVMilter-Version: 8.4.4(snapshot 20030410) (penguin.goodinassociates.com) +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/62 +X-Sequence-Number: 10767 + +On Thu, 2005-03-03 at 09:44 -0800, Josh Berkus wrote: +> Jeremiah, +> +> > I have about 5M names stored on my DB. Currently the searches are very +> > quick unless, they are on a very common last name ie. SMITH. The Index +> > is always used, but I still hit 10-20 seconds on a SMITH or Jones +> > search, and I average about 6 searches a second and max out at about +> > 30/s. Any suggestions on how I could arrange things to make this search +> > quicker? I have 4gb of mem on a raid 5 w/ 3 drives. I'm hoping that I +> > can increase this speed w/o a HW upgrade. +> +> First off, see http://www.powerpostgresql.com/PerfList about your +> configuration settings. +> +> The problem you're running into with SMITH is that, if your query is going to +> return a substantial number of rows (variable, but generally anything over 5% +> of the table and 1000 rows) is not able to make effective use of an index. +> This makes it fall back on a sequential scan, and based on you execution +> time, I'd guess that the table is a bit too large to fit in memory. +> +> AFTER you've made the configuration changes above, AND run VACUUM ANALYZE on +> your database, if you're still having problems post an EXPLAIN ANALYZE of the +> query to this list. +> + +ie. throw more hardware at it. All of the other things on the list, +except for effective_cache_size have always been done. I bumped it up +from the default to 2600000. Will see if that makes a difference. + +thanx, +-jj- + + +-- +"A power so great, it can only be used for Good or Evil!" + -- Firesign Theatre, "The Giant Rat of Summatra" + + +From pgsql-performance-owner@postgresql.org Thu Mar 3 20:26:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 481CE5574D + for ; + Thu, 3 Mar 2005 20:26:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88190-01 + for ; + Thu, 3 Mar 2005 20:26:39 +0000 (GMT) +Received: from asg002.asg.local (smtp2.arrayservicesgrp.com [208.14.218.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D9AE5513E + for ; + Thu, 3 Mar 2005 20:26:38 +0000 (GMT) +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: name search query speed +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +Date: Thu, 3 Mar 2005 14:26:27 -0600 +Message-ID: <49E94D0CFCD4DB43AFBA928DDD20C8F90261845D@asg002.asg.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] name search query speed +Thread-Index: AcUgLqDC+v1LvFF3Q92InjPO9q2gaAAAJuwQ +From: "Dave Held" +To: "Jeremiah Jahn" , + "John A Meinel" +Cc: "postgres performance" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.067 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/63 +X-Sequence-Number: 10768 + +> -----Original Message----- +> From: Jeremiah Jahn [mailto:jeremiah@cs.earlham.edu] +> Sent: Thursday, March 03, 2005 2:15 PM +> To: John A Meinel +> Cc: postgres performance +> Subject: Re: [PERFORM] name search query speed +>=20 +> [...] +> So the count for this is generated on the fly needed for +> pagination in the app which expresses the total number of +> finds, but only displays 40 of them. If any one knows a way +> to determine the total number of matches without needing to=20 +> iterate through them using jdbc, I'm all ears as this would +> save me huge amounts of time and limit/offset would become +> an option.=20 + +Is there a reason you can't do a count(field) query first? If +so, you can get the number of records returned by setting +absolute(-1) and getting the row number. + +__ +David B. Held +Software Engineer/Array Services Group +200 14th Ave. East, Sartell, MN 56377 +320.534.3637 320.253.7800 800.752.8129 + +From pgsql-performance-owner@postgresql.org Thu Mar 3 20:47:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 53FED52A6A + for ; + Thu, 3 Mar 2005 20:47:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91267-08 + for ; + Thu, 3 Mar 2005 20:47:42 +0000 (GMT) +Received: from penguin.goodinassociates.com (penguin.goodinassociates.com + [206.80.71.229]) + by svr1.postgresql.org (Postfix) with ESMTP id 433E55514D + for ; + Thu, 3 Mar 2005 20:47:41 +0000 (GMT) +Received: from [206.80.71.242] ([206.80.71.242]) + by penguin.goodinassociates.com (8.12.11/8.12.11) with ESMTP id + j23KlTIM011117; Thu, 3 Mar 2005 14:47:29 -0600 +Subject: Re: name search query speed +From: Jeremiah Jahn +To: Dave Held +Cc: John A Meinel , + postgres performance +In-Reply-To: <49E94D0CFCD4DB43AFBA928DDD20C8F90261845D@asg002.asg.local> +References: <49E94D0CFCD4DB43AFBA928DDD20C8F90261845D@asg002.asg.local> +Content-Type: text/plain +Date: Thu, 03 Mar 2005 14:47:29 -0600 +Message-Id: <1109882849.16326.99.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-1) +Content-Transfer-Encoding: 7bit +X-RAVMilter-Version: 8.4.4(snapshot 20030410) (penguin.goodinassociates.com) +Received-SPF: none (penguin.goodinassociates.com: 206.80.71.242 is neither + permitted nor denied by domain of cs.earlham.edu) + client-ip=206.80.71.242; envelope-from=jeremiah@cs.earlham.edu; + helo=[206.80.71.242]; +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/64 +X-Sequence-Number: 10769 + +doesn't that cause two queries? I used to do it that way and cut my time +substantially by counting in-line. Even though the results were cached +it still took more time. Also since the tables is constantly be updated +the returned total would not always match the number of results on the +second query. + +On Thu, 2005-03-03 at 14:26 -0600, Dave Held wrote: +> > -----Original Message----- +> > From: Jeremiah Jahn [mailto:jeremiah@cs.earlham.edu] +> > Sent: Thursday, March 03, 2005 2:15 PM +> > To: John A Meinel +> > Cc: postgres performance +> > Subject: Re: [PERFORM] name search query speed +> > +> > [...] +> > So the count for this is generated on the fly needed for +> > pagination in the app which expresses the total number of +> > finds, but only displays 40 of them. If any one knows a way +> > to determine the total number of matches without needing to +> > iterate through them using jdbc, I'm all ears as this would +> > save me huge amounts of time and limit/offset would become +> > an option. +> +> Is there a reason you can't do a count(field) query first? If +> so, you can get the number of records returned by setting +> absolute(-1) and getting the row number. +> +> __ +> David B. Held +> Software Engineer/Array Services Group +> 200 14th Ave. East, Sartell, MN 56377 +> 320.534.3637 320.253.7800 800.752.8129 +-- +"A power so great, it can only be used for Good or Evil!" + -- Firesign Theatre, "The Giant Rat of Summatra" + + +From pgsql-performance-owner@postgresql.org Thu Mar 3 21:37:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C34052AAA + for ; + Thu, 3 Mar 2005 21:37:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04256-09 + for ; + Thu, 3 Mar 2005 21:37:28 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 09B8152A4D + for ; + Thu, 3 Mar 2005 21:37:27 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j23LbNtu004675; (envelope-from ) Thu, + 3 Mar 2005 15:37:23 -0600 (CST) +Received: from [192.168.1.13] (63-230-158-178.cdrr.qwest.net [63.230.158.178]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j23LbLqu022107 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Thu, + 3 Mar 2005 15:37:22 -0600 (CST) +Message-ID: <42278391.7090509@arbash-meinel.com> +Date: Thu, 03 Mar 2005 15:37:21 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeremiah Jahn +Cc: postgres performance +Subject: Re: name search query speed +References: <1109867909.16326.58.camel@bluejay.goodinassociates.com> + <42274D5A.1070402@arbash-meinel.com> + <1109880887.16326.86.camel@bluejay.goodinassociates.com> +In-Reply-To: <1109880887.16326.86.camel@bluejay.goodinassociates.com> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigE590B28BECAE19068497DD61" +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/65 +X-Sequence-Number: 10770 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigE590B28BECAE19068497DD61 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Jeremiah Jahn wrote: + +>On Thu, 2005-03-03 at 11:46 -0600, John A Meinel wrote: +> +> +... + +>Not really, about 2% of the returned rows are thrown away for security +>reasons based on the current user, security groups they belong to and +>different flags in the data itself. So the count for this is generated +>on the fly needed for pagination in the app which expresses the total +>number of finds, but only displays 40 of them. If any one knows a way to +>determine the total number of matches without needing to iterate through +>them using jdbc, I'm all ears as this would save me huge amounts of time +>and limit/offset would become an option. +> +> +> +Well, what is wrong with "select count(*) from "? +Are you saying 2% are thrown away, or only 2% are kept? +Is this being done at the client side? Is there a way to incorporate the +security info into the database, so that the query actually only returns +the rows you care about? That seems like it would be a decent way to +speed it up, if you can restrict the number of rows that it needs to +look at. + +There are other alternatives, such as materialized views, or temp +tables, where you select into the temp table the rows that the user +would request, and then you generate limit/offset from that. The first +query would be a little slow, since it would get all the rows, but all +subsequent accesses for that user could be really fast. + +The other possibility is to do "limit 200", and then in your list of +pages, you could have: +1, 2, 3, 4, 5, ... +This means that you don't have to worry about getting 10,000 entries, +which probably isn't really useful for the user anyway, and you can +still break things into 40 entry pages, just 200 entries at a time. +John +=:-> + +>>John +>>=:-> +>> +>> +>> + + +--------------enigE590B28BECAE19068497DD61 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCJ4ORJdeBCYSNAAMRAhn+AKC5RPu0LT6SN3ICzLkad5ycwmgCzgCfSg/Y +DmmFtAMtK+kDBc6RIdwFbnY= +=ghHh +-----END PGP SIGNATURE----- + +--------------enigE590B28BECAE19068497DD61-- + +From pgsql-performance-owner@postgresql.org Thu Mar 3 22:03:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D0A8353C92 + for ; + Thu, 3 Mar 2005 22:03:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13522-01 + for ; + Thu, 3 Mar 2005 22:03:46 +0000 (GMT) +Received: from mail.logix-tt.com (wallaby.dingens.org [212.75.36.180]) + by svr1.postgresql.org (Postfix) with ESMTP id 49D0952A66 + for ; + Thu, 3 Mar 2005 22:03:45 +0000 (GMT) +Received: from kingfisher.intern.logi-track.com (pD95DCDF2.dip0.t-ipconnect.de + [217.93.205.242]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id A4413A859A; + Thu, 3 Mar 2005 22:03:49 +0000 (UTC) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logi-track.com (Postfix) with ESMTP id 3BF55AB3D8; + Thu, 3 Mar 2005 23:03:45 +0100 (CET) +Message-ID: <422789C0.20201@logix-tt.com> +Date: Thu, 03 Mar 2005 23:03:44 +0100 +From: Markus Schaber +User-Agent: Mozilla Thunderbird 1.0 (X11/20050116) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: Jeremiah Jahn +Cc: Dave Held , + John A Meinel , + postgres performance +Subject: Re: name search query speed +References: <49E94D0CFCD4DB43AFBA928DDD20C8F90261845D@asg002.asg.local> + <1109882849.16326.99.camel@bluejay.goodinassociates.com> +In-Reply-To: <1109882849.16326.99.camel@bluejay.goodinassociates.com> +X-Enigmail-Version: 0.90.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-15 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/66 +X-Sequence-Number: 10771 + +Hi, Jeremiah, + +Jeremiah Jahn schrieb: +> doesn't that cause two queries? I used to do it that way and cut my time +> substantially by counting in-line. Even though the results were cached +> it still took more time. + +This sounds rather strange. + +> Also since the tables is constantly be updated +> the returned total would not always match the number of results on the +> second query. + +Did you run both queries in the same transaction, with transaction +isolation level set to serializable? If yes, you found a serious bug in +PostgreSQL transaction engine. + +Markus + +-- +Markus Schaber | Dipl. Informatiker | Software Development GIS + +Fight against software patents in EU! http://ffii.org/ + http://nosoftwarepatents.org/ + +From pgsql-performance-owner@postgresql.org Thu Mar 3 23:42:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E068E52A6A + for ; + Thu, 3 Mar 2005 23:42:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34197-10 + for ; + Thu, 3 Mar 2005 23:42:38 +0000 (GMT) +Received: from fep7.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id D474D52A63 + for ; + Thu, 3 Mar 2005 23:42:36 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep7.cogeco.net (Postfix) with SMTP id 171B4AF4 + for ; + Thu, 3 Mar 2005 18:42:39 -0500 (EST) +Received: (qmail 25103 invoked from network); 4 Mar 2005 00:13:43 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 4 Mar 2005 00:13:43 -0000 +Message-ID: <001d01c5204a$b440edf0$6a01a8c0@KEN> +From: "Ken Egervari" +To: "Josh Berkus" , + +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <200503022152.13211.josh@agliodbs.com> + <004601c51fbe$828bbb50$6a01a8c0@KEN> + <200503030935.14537.josh@agliodbs.com> +Subject: Re: Help with tuning this query (with explain analyze finally) +Date: Thu, 3 Mar 2005 18:42:46 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.782 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/67 +X-Sequence-Number: 10772 + +Josh, + +I did everything you said and my query does perform a bit better. I've been +getting speeds from 203 to 219 to 234 milliseconds now. I tried increasing +the work mem and the effective cache size from the values you provided, but +I didn't see any more improvement. I've tried to looking into setting the +shared buffers for Windows XP, but I'm not sure how to do it. I'm looking +in the manual at: +http://www.postgresql.org/docs/8.0/interactive/kernel-resources.html#SYSVIPC-PARAMETERS + +It doesn't mention windows at all. Does anyone have any ideas on have to +fix this? + +Here is the new explain analyze. + +Sort (cost=1996.21..1996.26 rows=17 width=165) (actual +time=297.000..297.000 rows=39 loops=1) + Sort Key: ss.date + -> Merge Right Join (cost=1951.26..1995.87 rows=17 width=165) (actual +time=297.000..297.000 rows=39 loops=1) + Merge Cond: ("outer".id = "inner".driver_id) + -> Index Scan using driver_pkey on driver d (cost=0.00..42.16 +rows=922 width=43) (actual time=0.000..0.000 rows=922 loops=1) + -> Sort (cost=1951.26..1951.30 rows=17 width=122) (actual +time=297.000..297.000 rows=39 loops=1) + Sort Key: s.driver_id + -> Hash Join (cost=586.48..1950.91 rows=17 width=122) +(actual time=219.000..297.000 rows=39 loops=1) + Hash Cond: ("outer".carrier_code_id = "inner".id) + -> Merge Join (cost=571.97..1931.95 rows=830 width=87) +(actual time=219.000..297.000 rows=310 loops=1) + Merge Cond: ("outer".current_status_id = +"inner".id) + -> Index Scan using +shipment_current_status_id_idx on shipment s (cost=0.00..2701.26 rows=60307 +width=66) (actual time=0.000..62.000 rows=27711 loops=1) + Filter: (is_purged = false) + -> Sort (cost=571.97..576.38 rows=1766 width=21) +(actual time=125.000..156.000 rows=6902 loops=1) + Sort Key: ss.id + -> Hash Join (cost=1.11..476.72 rows=1766 +width=21) (actual time=0.000..93.000 rows=6902 loops=1) + Hash Cond: ("outer".release_code_id = +"inner".id) + -> Index Scan Backward using +current_status_date_idx on shipment_status ss (cost=0.00..387.35 rows=14122 +width=21) (actual time=0.000..16.000 rows=14925 loops=1) + Index Cond: (date >= +(('now'::text)::date - 31)) + -> Hash (cost=1.10..1.10 rows=1 +width=4) (actual time=0.000..0.000 rows=0 loops=1) + -> Seq Scan on release_code rc +(cost=0.00..1.10 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=1) + Filter: ((number)::text = +'9'::text) + -> Hash (cost=14.51..14.51 rows=2 width=35) (actual +time=0.000..0.000 rows=0 loops=1) + -> Nested Loop (cost=4.92..14.51 rows=2 +width=35) (actual time=0.000..0.000 rows=2 loops=1) + -> Index Scan using person_pkey on person p +(cost=0.00..5.73 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=1) + Index Cond: (id = 355) + -> Hash Join (cost=4.92..8.75 rows=2 +width=39) (actual time=0.000..0.000 rows=2 loops=1) + Hash Cond: ("outer".id = +"inner".carrier_id) + -> Seq Scan on carrier c +(cost=0.00..3.54 rows=54 width=4) (actual time=0.000..0.000 rows=54 loops=1) + -> Hash (cost=4.92..4.92 rows=2 +width=43) (actual time=0.000..0.000 rows=0 loops=1) + -> Hash Join (cost=3.04..4.92 +rows=2 width=43) (actual time=0.000..0.000 rows=2 loops=1) + Hash Cond: +("outer".carrier_id = "inner".carrier_id) + -> Seq Scan on +carrier_code cc (cost=0.00..1.57 rows=57 width=35) (actual +time=0.000..0.000 rows=57 loops=1) + -> Hash (cost=3.04..3.04 +rows=1 width=8) (actual time=0.000..0.000 rows=0 loops=1) + -> Index Scan using +carrier_to_person_person_id_idx on carrier_to_person ctp (cost=0.00..3.04 +rows=1 width=8) (actual time=0.000..0.000 rows=1 loops=1) + Index Cond: +(355 = person_id) +Total runtime: 297.000 ms + + +From pgsql-performance-owner@postgresql.org Fri Mar 4 00:22:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1328B550EE + for ; + Fri, 4 Mar 2005 00:22:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45264-06 + for ; + Fri, 4 Mar 2005 00:22:24 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 89AFF54431 + for ; + Fri, 4 Mar 2005 00:22:21 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j240MM4h010851; (envelope-from ) Thu, + 3 Mar 2005 18:22:22 -0600 (CST) +Received: from [192.168.1.13] (63-230-158-178.cdrr.qwest.net [63.230.158.178]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j240MI3G006638 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Thu, + 3 Mar 2005 18:22:20 -0600 (CST) +Message-ID: <4227AA36.2080700@arbash-meinel.com> +Date: Thu, 03 Mar 2005 18:22:14 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ken Egervari +Cc: Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: Help with tuning this query (with explain analyze finally) +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <200503022152.13211.josh@agliodbs.com> + <004601c51fbe$828bbb50$6a01a8c0@KEN> + <200503030935.14537.josh@agliodbs.com> + <001d01c5204a$b440edf0$6a01a8c0@KEN> +In-Reply-To: <001d01c5204a$b440edf0$6a01a8c0@KEN> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigEF41C74903B51B1B829BFBCA" +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/68 +X-Sequence-Number: 10773 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigEF41C74903B51B1B829BFBCA +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Ken Egervari wrote: + +> Josh, +> +> I did everything you said and my query does perform a bit better. +> I've been getting speeds from 203 to 219 to 234 milliseconds now. I +> tried increasing the work mem and the effective cache size from the +> values you provided, but I didn't see any more improvement. I've +> tried to looking into setting the shared buffers for Windows XP, but +> I'm not sure how to do it. I'm looking in the manual at: +> http://www.postgresql.org/docs/8.0/interactive/kernel-resources.html#SYSVIPC-PARAMETERS +> +> +You probably don't need to change anything for Windows. If you set +shared_buffers too high, then postgres won't start. If it is starting, +then you don't need to modify the OS to get more shared buffers. (For +instance, on my Mac, I can't get shared_buffers > 500 without changing +things, but on windows I run with 3000 and no modification). + +> It doesn't mention windows at all. Does anyone have any ideas on have +> to fix this? +> +Do you need the interior sort? It's taking ~93ms to get 7k rows from +shipment_status, and then another 30ms to sort them. This isn't a lot, +so it might be fine. + +Also, did you ever try CLUSTER current_status_date_idx ON shipment_status. +This groups the rows in shipment_status by their status date, which +helps put items with the same date next to eachother. This may effect +other portions of the query, or other queries. Also, if you are +inserting sequentially, it would seem that the items would already be +naturally near eachother based on date. + +The next big cost is having to merge the 28k rows with the fast hash +plan, which takes about 80ms. + +I guess the biggest issue is that you are doing a lot of work, and it +takes time to do it. Also, I've noticed that this query is being run +with exactly the same data. Which is good to compare two methods. But +remember to test on multiple potential values. You might be better off +one way with this query, but much worse for a different dataset. I +noticed that this seems to have fewer rows than what postgres thinks the +*average* number would be. (It predicts 60k and you only get 28k rows). + +If this query is performed a lot, and you can be okay with a slight +delay in updating, you could always switch to some sort of lazy +materialized view. + +You could also always throw more hardware at it. :) If the +shipment_status is one of the bottlenecks, create a 4-disk raid10 and +move the table over. +I don't remember what your hardware is, but I don't remember it being a +quad opteron with 16GB ram, and 20 15k SCSI disks, with the transaction +log on a solid state disk. :) + +Why do you need the query to be 30ms? ~250ms is still pretty fast. If +you are needing updates faster than that, you might look more into *why* +and then handle it from a higher level. + +And naturally, the most important this is to test it under load. 250ms +is pretty good, but if under load it goes back to 6s, then we probably +should look for different alternatives. Also, what is the load that is +causing the problem? Is it that you have some other big seqscans which +are causing all of your tables to go out of cache? + +Also, I believe I remember you saying that your production server is a +P4, is that a single P4? Because I know postgres prefers Opterons to +Pentium Xeons when in a multiprocessor machine. Look through the +archives about spinlocks and the context switch bug. (context storm, +etc). Plus, since opterons are 64-bit, you can throw a lot more RAM at +them. I believe opterons outperform xeons for the same cost, *and* you +can scale them up with extra ram. + +But remember, the biggest bottleneck is almost *always* the I/O. So put +more & faster disks into the system first. + +John +=:-> + +> Here is the new explain analyze. +> +> Sort (cost=1996.21..1996.26 rows=17 width=165) (actual +> time=297.000..297.000 rows=39 loops=1) +> Sort Key: ss.date +> -> Merge Right Join (cost=1951.26..1995.87 rows=17 width=165) +> (actual time=297.000..297.000 rows=39 loops=1) +> Merge Cond: ("outer".id = "inner".driver_id) +> -> Index Scan using driver_pkey on driver d (cost=0.00..42.16 +> rows=922 width=43) (actual time=0.000..0.000 rows=922 loops=1) +> -> Sort (cost=1951.26..1951.30 rows=17 width=122) (actual +> time=297.000..297.000 rows=39 loops=1) +> Sort Key: s.driver_id +> -> Hash Join (cost=586.48..1950.91 rows=17 width=122) +> (actual time=219.000..297.000 rows=39 loops=1) +> Hash Cond: ("outer".carrier_code_id = "inner".id) +> -> Merge Join (cost=571.97..1931.95 rows=830 +> width=87) (actual time=219.000..297.000 rows=310 loops=1) +> Merge Cond: ("outer".current_status_id = +> "inner".id) +> -> Index Scan using +> shipment_current_status_id_idx on shipment s (cost=0.00..2701.26 +> rows=60307 width=66) (actual time=0.000..62.000 rows=27711 loops=1) +> Filter: (is_purged = false) +> -> Sort (cost=571.97..576.38 rows=1766 +> width=21) (actual time=125.000..156.000 rows=6902 loops=1) +> Sort Key: ss.id +> -> Hash Join (cost=1.11..476.72 +> rows=1766 width=21) (actual time=0.000..93.000 rows=6902 loops=1) +> Hash Cond: +> ("outer".release_code_id = "inner".id) +> -> Index Scan Backward using +> current_status_date_idx on shipment_status ss (cost=0.00..387.35 +> rows=14122 width=21) (actual time=0.000..16.000 rows=14925 loops=1) +> Index Cond: (date >= +> (('now'::text)::date - 31)) +> -> Hash (cost=1.10..1.10 rows=1 +> width=4) (actual time=0.000..0.000 rows=0 loops=1) +> -> Seq Scan on +> release_code rc (cost=0.00..1.10 rows=1 width=4) (actual +> time=0.000..0.000 rows=1 loops=1) +> Filter: +> ((number)::text = '9'::text) +> -> Hash (cost=14.51..14.51 rows=2 width=35) +> (actual time=0.000..0.000 rows=0 loops=1) +> -> Nested Loop (cost=4.92..14.51 rows=2 +> width=35) (actual time=0.000..0.000 rows=2 loops=1) +> -> Index Scan using person_pkey on +> person p (cost=0.00..5.73 rows=1 width=4) (actual time=0.000..0.000 +> rows=1 loops=1) +> Index Cond: (id = 355) +> -> Hash Join (cost=4.92..8.75 rows=2 +> width=39) (actual time=0.000..0.000 rows=2 loops=1) +> Hash Cond: ("outer".id = +> "inner".carrier_id) +> -> Seq Scan on carrier c +> (cost=0.00..3.54 rows=54 width=4) (actual time=0.000..0.000 rows=54 +> loops=1) +> -> Hash (cost=4.92..4.92 rows=2 +> width=43) (actual time=0.000..0.000 rows=0 loops=1) +> -> Hash Join +> (cost=3.04..4.92 rows=2 width=43) (actual time=0.000..0.000 rows=2 +> loops=1) +> Hash Cond: +> ("outer".carrier_id = "inner".carrier_id) +> -> Seq Scan on +> carrier_code cc (cost=0.00..1.57 rows=57 width=35) (actual +> time=0.000..0.000 rows=57 loops=1) +> -> Hash +> (cost=3.04..3.04 rows=1 width=8) (actual time=0.000..0.000 rows=0 +> loops=1) +> -> Index Scan +> using carrier_to_person_person_id_idx on carrier_to_person ctp +> (cost=0.00..3.04 rows=1 width=8) (actual time=0.000..0.000 rows=1 +> loops=1) +> Index +> Cond: (355 = person_id) +> Total runtime: 297.000 ms +> +> ---------------------------(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 + + + +--------------enigEF41C74903B51B1B829BFBCA +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCJ6o6JdeBCYSNAAMRAtRvAJ46n974ZPYYdmE0GFdLtjTnGNbAHQCgrJ1g +6437Q0gq2jau5gmHmxY7HjU= +=Jruy +-----END PGP SIGNATURE----- + +--------------enigEF41C74903B51B1B829BFBCA-- + +From pgsql-performance-owner@postgresql.org Fri Mar 4 02:58:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5941F52A88 + for ; + Fri, 4 Mar 2005 02:58:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46215-08 + for ; + Fri, 4 Mar 2005 02:58:11 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4504852A72 + for ; + Fri, 4 Mar 2005 02:58:10 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 0EBDC31DA7; Fri, 4 Mar 2005 03:58:15 +0100 (MET) +From: William Yu +X-Newsgroups: pgsql.performance +Subject: Re: name search query speed +Date: Thu, 03 Mar 2005 18:55:55 -0800 +Organization: Hub.Org Networking Services +Lines: 21 +Message-ID: +References: <1109867909.16326.58.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +In-Reply-To: <1109867909.16326.58.camel@bluejay.goodinassociates.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/69 +X-Sequence-Number: 10774 + +Jeremiah Jahn wrote: +> I have about 5M names stored on my DB. Currently the searches are very +> quick unless, they are on a very common last name ie. SMITH. The Index +> is always used, but I still hit 10-20 seconds on a SMITH or Jones +> search, and I average about 6 searches a second and max out at about +> 30/s. Any suggestions on how I could arrange things to make this search +> quicker? I have 4gb of mem on a raid 5 w/ 3 drives. I'm hoping that I +> can increase this speed w/o a HW upgrade. + +If it's just "SMITH", the only fix is to throw more hardware at the +problem. I've got my own database of medical providers & facilities in +the millions and anytime somebody tries to search for MEDICAL FACILITY, +it takes forever. I've tried every optimization possible but when you +have 500K records with the word "MEDICAL" in it, what can you do? You've +got to check all 500K records to see if it matches your criteria. + +For multi-word searches, what I've found does work is to periodically +generate stats on work frequencies and use those stats to search the +least common words first. For example, if somebody enters "ALTABATES +MEDICAL HOSPITAL", I can get the ~50 providers with ALTABATES in the +name and then do a 2nd and 3rd pass to filter against MEDICAL and HOSPITAL. + +From pgsql-performance-owner@postgresql.org Fri Mar 4 05:22:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 35E14563A4 + for ; + Fri, 4 Mar 2005 05:22:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32166-05 + for ; + Fri, 4 Mar 2005 05:22:09 +0000 (GMT) +Received: from fep7.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C74652A50 + for ; + Fri, 4 Mar 2005 05:22:08 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep7.cogeco.net (Postfix) with SMTP id BC997120F + for ; + Fri, 4 Mar 2005 00:22:06 -0500 (EST) +Received: (qmail 31762 invoked from network); 4 Mar 2005 05:53:11 -0000 +Received: from d36-80-110.home1.cgocable.net (HELO KEN) (24.36.80.110) + by 0 with SMTP; 4 Mar 2005 05:53:11 -0000 +Message-ID: <000e01c5207a$1f668ac0$6a01a8c0@KEN> +From: "Ken Egervari" +To: "John Arbash Meinel" , + +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <200503022152.13211.josh@agliodbs.com> + <004601c51fbe$828bbb50$6a01a8c0@KEN> + <200503030935.14537.josh@agliodbs.com> + <001d01c5204a$b440edf0$6a01a8c0@KEN> + <4227AA36.2080700@arbash-meinel.com> +Subject: Re: Help with tuning this query (with explain analyze finally) +Date: Fri, 4 Mar 2005 00:22:12 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.785 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/70 +X-Sequence-Number: 10775 + +Josh, + +Thanks so much for your comments. They are incredibly insightful and you +clearly know your stuff. It's so great that I'm able to learn so much from +you. I really appreciate it. + +>Do you need the interior sort? It's taking ~93ms to get 7k rows from +>shipment_status, and then another 30ms to sort them. This isn't a lot, +>so it might be fine. + +Running the query without the sort doesn't actually improve performance +unfortunately, which I find strange. I think the analyze is giving bad +feedback because taking all sorts out completely makes no difference in +performance. Dan Tow's book actually said the same thing... how sorting +rarely takes up the bulk of the work. Although I know you didn't like his +book much, but I had observed that in my experience too. + +>Also, did you ever try CLUSTER current_status_date_idx ON shipment_status. +>This groups the rows in shipment_status by their status date, which +>helps put items with the same date next to eachother. This may effect +>other portions of the query, or other queries. Also, if you are +>inserting sequentially, it would seem that the items would already be +>naturally near eachother based on date. + +Yes, this was one of the first things I tried actually and it is currently +clustered. Since shipment status comes into our system at real time, the +dates are more or less in order as well. + +>The next big cost is having to merge the 28k rows with the fast hash +>plan, which takes about 80ms. +> +>I guess the biggest issue is that you are doing a lot of work, and it +>takes time to do it. Also, I've noticed that this query is being run +>with exactly the same data. Which is good to compare two methods. But +>remember to test on multiple potential values. You might be better off +>one way with this query, but much worse for a different dataset. I +>noticed that this seems to have fewer rows than what postgres thinks the +>*average* number would be. (It predicts 60k and you only get 28k rows). + +Well, the example where p.id = 355 is an above normal case where performance +is typically bad. If a user's company has very few shipments and +shipment_status rows, performance isn't going to matter much and those +queries usually perform much faster. I really needed to tune this for the +larger customers who do have thousands of rows for their entire company and +will probably reach 6 digits by the end of next year. For the person 355, +they've only been on the system for 3 months and they already have 27700 +rows. Even if this makes the smaller customers a bit slower, I think it's +worth it if I can speed up cases like this, who all have very similar data +distribution. + +>If this query is performed a lot, and you can be okay with a slight +>delay in updating, you could always switch to some sort of lazy +>materialized view. + +I thought about this, but it's very important since shipment and +shipment_status are both updated in real time 24/7/365. I think I might be +able to cache it within the application for 60 seconds at most, but it would +make little difference since people tend to refresh within that time anyway. +It's very important that real-time inforamtion exists though. + +>You could also always throw more hardware at it. :) If the +>shipment_status is one of the bottlenecks, create a 4-disk raid10 and +>move the table over. +>I don't remember what your hardware is, but I don't remember it being a +>quad opteron with 16GB ram, and 20 15k SCSI disks, with the transaction +>log on a solid state disk. :) + +That sounds like an awesome system. I loved to have something like that. +Unfortunately, the production server is just a single processor machine with +1 GB ram. I think throwing more disks at it is probably the best bet, +moving the shipment and shipment_status tables over as you suggested. +That's great advice. + +>Why do you need the query to be 30ms? ~250ms is still pretty fast. If +>you are needing updates faster than that, you might look more into *why* +>and then handle it from a higher level. + +30ms is a good target, although I guess I was naive for setting that goal +perhaps. I've just taken queries that ran at 600ms and with 1 or 2 indexes, +they went down to 15ms. + +Let's say we have 200 users signed into the application at the same time. +The application refreshes their shipment information automatically to make +sure it's up to date on the user's screen. The application will execute the +query we are trying to tune every 60 seconds for most of these users. Users +can set the refresh time to be higher, but 60 is the lowest amount so I'm +just assuming everyone has it at 60. + +Anyway, if you have 200 users logged in, that's 200 queries in the 60 second +period, which is about 3-4 queries every second. As you can see, it's +getting maxed out, and because of bad luck, the queries are bunched together +and are being called at the same time, making 8-9 queries in the same second +and that's where the performance is starting to degrade. I just know that +if I could get this down to 30 ms, or even 100, we'd be okay for a few +months without throwing hardware at the problem. Also keep in mind that +other application logic and Hibernate mapping is occuring to, so 3-4 queries +a second is already no good when everything is running on a single machine. + +This isn't the best setup, but it's the best we can afford. We are just a +new startup company. Cheaper servers and open source keep our costs low. +But money is starting to come in after 10 months of hard work, so we'll be +able to replace our server within the next 2 months. It'll be a neccessity +because we are signing on some big clients now and they'll have 40 or 50 +users for a single company. If they are all logged in at the same time, +that's a lot of queries. + +>And naturally, the most important this is to test it under load. 250ms +>is pretty good, but if under load it goes back to 6s, then we probably +>should look for different alternatives. Also, what is the load that is +>causing the problem? Is it that you have some other big seqscans which +>are causing all of your tables to go out of cache? + +No, this query and another very close to it are probably the most executed +in the system. In fact, even checking the page stats on the web server +tells us that the pages that use these queries are 80% of the pages viewed +in our application. If I can fix this problem, I've fixed our performance +problems period. The statistics queries are very slow too, but I don't care +about that since nobody goes to them much (maybe once a month. People don't +mind waiting for that sort of information anyway). + +I'm very interested in those other alternatives since I may have to +experiment with them. I'm under the impression that this query is actually +performing quite well for what I'm throwing at it and the work that it's +doing. + +>Also, I believe I remember you saying that your production server is a +>P4, is that a single P4? Because I know postgres prefers Opterons to +>Pentium Xeons when in a multiprocessor machine. Look through the +>archives about spinlocks and the context switch bug. (context storm, +>etc). Plus, since opterons are 64-bit, you can throw a lot more RAM at +>them. I believe opterons outperform xeons for the same cost, *and* you +>can scale them up with extra ram. + +Yeah, we have nothing of that sort. It's really just a P4 3.0 Ghz +processor. Like I mentioned before, we just put computers together from +what we had and built our application on them. Our business is new, we +don't have a lot of money and we're just starting to actually have a good +client base. It's finally growing after all of this time but we are still +using the servers we started with. + +>But remember, the biggest bottleneck is almost *always* the I/O. So put +>more & faster disks into the system first. + +I will price that raid setup you recommended. That will probably be the +first adjustment to our server if we don't just replace the entire thing. + +Thanks again, +Ken + + +From pgsql-performance-owner@postgresql.org Fri Mar 4 11:26:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7043C52A56 + for ; + Fri, 4 Mar 2005 11:26:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25942-06 + for ; + Fri, 4 Mar 2005 11:26:11 +0000 (GMT) +Received: from ylpvm43.prodigy.net (ylpvm43-ext.prodigy.net [207.115.57.74]) + by svr1.postgresql.org (Postfix) with ESMTP id 7DC6752A5C + for ; + Fri, 4 Mar 2005 11:26:10 +0000 (GMT) +Received: from one (adsl-68-124-176-26.dsl.pltn13.pacbell.net [68.124.176.26]) + by ylpvm43.prodigy.net (8.12.10 outbound/8.12.10) with ESMTP id + j24BQBoo030878 + for ; Fri, 4 Mar 2005 06:26:12 -0500 +Received: from [192.168.69.8] (rondesktop [192.168.69.8]) + by one (Postfix) with ESMTP id B5264F1CF9 + for ; + Fri, 4 Mar 2005 03:26:10 -0800 (PST) +Date: Fri, 4 Mar 2005 03:27:23 -0800 (PST) +From: Ron Mayer +X-X-Sender: mayer@greenie.cheapcomplexdevices.com +To: pgsql-performance@postgresql.org +Subject: Query's fast standalone - slow as a subquery. +In-Reply-To: <20050304002724.650A95AF649@svr4.postgresql.org> +Message-ID: +References: <20050304002724.650A95AF649@svr4.postgresql.org> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/71 +X-Sequence-Number: 10776 + + +I have a query that runs quite quickly using a hash join when run +standalone. + +When I use this query as a subquery the planner always seems to +pick a differnt plan with an order of magnitude worse performance. + +This bad plan is chosen even when the outer sql statement is +a trivial expression like this: + select * from (query) as a; +which I believe should be a no-op. + + +Should the optimizer have noticed that it could have used a hash +join in this case? Anything I can do to help convince it to? + + Explain analyze output follows. + Thanks, + Ron + + + +============================================================================ + +fli=# explain analyze SELECT * from (select * from userfeatures.points join icons using (iconid) where the_geom && setSRID('BOX3D(-123.40 25.66,-97.87 43.17)'::BOX3D, -1 )) as upf ; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..446.42 rows=1 width=120) (actual time=-0.096..7928.546 rows=15743 loops=1) + Join Filter: ("outer".iconid = "inner".iconid) + -> Seq Scan on points (cost=0.00..444.43 rows=1 width=82) (actual time=0.096..132.255 rows=15743 loops=1) + Filter: (the_geom && '010300000001000000050000009A99999999D95EC0295C8FC2F5A839409A99999999D95EC0F6285C8FC295454048E17A14AE7758C0F6285C8FC295454048E17A14AE7758C0295C8FC2F5A839409A99999999D95EC0295C8FC2F5A83940'::geometry) + -> Seq Scan on icons (cost=0.00..1.44 rows=44 width=42) (actual time=0.006..0.242 rows=44 loops=15743) + Total runtime: 8005.766 ms +(6 rows) + +fli=# explain analyze select * from userfeatures.points join icons using (iconid) where the_geom && setSRID('BOX3D(-123.40 25.66,-97.87 43.17)'::BOX3D, -1 ); + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=1.55..682.84 rows=15789 width=120) (actual time=0.641..320.002 rows=15743 loops=1) + Hash Cond: ("outer".iconid = "inner".iconid) + -> Seq Scan on points (cost=0.00..444.43 rows=15794 width=82) (actual time=0.067..94.307 rows=15743 loops=1) + Filter: (the_geom && '010300000001000000050000009A99999999D95EC0295C8FC2F5A839409A99999999D95EC0F6285C8FC295454048E17A14AE7758C0F6285C8FC295454048E17A14AE7758C0295C8FC2F5A839409A99999999D95EC0295C8FC2F5A83940'::geometry) + -> Hash (cost=1.44..1.44 rows=44 width=42) (actual time=0.530..0.530 rows=0 loops=1) + -> Seq Scan on icons (cost=0.00..1.44 rows=44 width=42) (actual time=0.026..0.287 rows=44 loops=1) + Total runtime: 397.003 ms +(7 rows) + + + + + + +From pgsql-performance-owner@postgresql.org Fri Mar 4 15:23:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EB1EB54FDB + for ; + Fri, 4 Mar 2005 15:22:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93644-02 + for ; + Fri, 4 Mar 2005 15:22:52 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 8EB4254E9E + for ; + Fri, 4 Mar 2005 15:22:52 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j24FMuYF027482; + Fri, 4 Mar 2005 10:22:56 -0500 (EST) +To: Ron Mayer +Cc: pgsql-performance@postgresql.org +Subject: Re: Query's fast standalone - slow as a subquery. +In-reply-to: + +References: <20050304002724.650A95AF649@svr4.postgresql.org> + +Comments: In-reply-to Ron Mayer + message dated "Fri, 04 Mar 2005 03:27:23 -0800" +Date: Fri, 04 Mar 2005 10:22:56 -0500 +Message-ID: <27481.1109949776@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/72 +X-Sequence-Number: 10777 + +Ron Mayer writes: +> -> Seq Scan on points (cost=0.00..444.43 rows=1 width=82) (actual time=0.096..132.255 rows=15743 loops=1) +> Filter: (the_geom && '010300000001000000050000009A99999999D95EC0295C8FC2F5A839409A99999999D95EC0F6285C8FC295454048E17A14AE7758C0F6285C8FC295454048E17A14AE7758C0295C8FC2F5A839409A99999999D95EC0295C8FC2F5A83940'::geometry) + +> -> Seq Scan on points (cost=0.00..444.43 rows=15794 width=82) (actual time=0.067..94.307 rows=15743 loops=1) +> Filter: (the_geom && '010300000001000000050000009A99999999D95EC0295C8FC2F5A839409A99999999D95EC0F6285C8FC295454048E17A14AE7758C0F6285C8FC295454048E17A14AE7758C0295C8FC2F5A839409A99999999D95EC0295C8FC2F5A83940'::geometry) + +Apparently the selectivity of the && condition is misestimated in the +first case (note the radically wrong rowcount estimate), leading to an +inefficient join plan choice. I suppose this is a bug in the postgis +selectivity routines --- better complain to them. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 4 21:56:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 74E2A54E95 + for ; + Fri, 4 Mar 2005 15:46:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98835-09 + for ; + Fri, 4 Mar 2005 15:46:47 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EA9AF54D05 + for ; + Fri, 4 Mar 2005 15:46:46 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id A317431DD9; Fri, 4 Mar 2005 16:46:51 +0100 (MET) +From: stig erikson +X-Newsgroups: pgsql.performance +Subject: Re: name search query speed +Date: Fri, 04 Mar 2005 16:46:28 +0100 +Organization: Hub.Org Networking Services +Lines: 16 +Message-ID: +References: <1109867909.16326.58.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8b2) Gecko/20050226 +In-Reply-To: <1109867909.16326.58.camel@bluejay.goodinassociates.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/82 +X-Sequence-Number: 10787 + +Jeremiah Jahn wrote: +> I have about 5M names stored on my DB. Currently the searches are very +> quick unless, they are on a very common last name ie. SMITH. The Index +> is always used, but I still hit 10-20 seconds on a SMITH or Jones +> search, and I average about 6 searches a second and max out at about +> 30/s. Any suggestions on how I could arrange things to make this search +> quicker? I have 4gb of mem on a raid 5 w/ 3 drives. I'm hoping that I +> can increase this speed w/o a HW upgrade. +> +> thanx, +> -jj- +> + +is there a chance you could benefit from indices spanning over multiple columns? +maybe the user that searches for SMITH knows more then the last name, ie first +name, location (zip code, name of city, etc.)? + +From pgsql-performance-owner@postgresql.org Fri Mar 4 15:56:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AFE9354F47 + for ; + Fri, 4 Mar 2005 15:56:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04004-05 + for ; + Fri, 4 Mar 2005 15:56:44 +0000 (GMT) +Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net + [194.217.242.90]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FDAF54E95 + for ; + Fri, 4 Mar 2005 15:56:43 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 4.42) + id 1D7FAR-000Kma-7i; Fri, 04 Mar 2005 15:56:46 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 2FCCB162ED; Fri, 4 Mar 2005 15:56:26 +0000 (GMT) +Message-ID: <42288529.7000803@archonet.com> +Date: Fri, 04 Mar 2005 15:56:25 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ken Egervari +Cc: John Arbash Meinel , + pgsql-performance@postgresql.org +Subject: Re: Help with tuning this query (with explain analyze finally) +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <200503022152.13211.josh@agliodbs.com> + <004601c51fbe$828bbb50$6a01a8c0@KEN> + <200503030935.14537.josh@agliodbs.com> + <001d01c5204a$b440edf0$6a01a8c0@KEN> + <4227AA36.2080700@arbash-meinel.com> + <000e01c5207a$1f668ac0$6a01a8c0@KEN> +In-Reply-To: <000e01c5207a$1f668ac0$6a01a8c0@KEN> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/73 +X-Sequence-Number: 10778 + +Ken Egervari wrote: +> Let's say we have 200 users signed into the application at the same +> time. The application refreshes their shipment information automatically +> to make sure it's up to date on the user's screen. The application will +> execute the query we are trying to tune every 60 seconds for most of +> these users. Users can set the refresh time to be higher, but 60 is the +> lowest amount so I'm just assuming everyone has it at 60. +> +> Anyway, if you have 200 users logged in, that's 200 queries in the 60 +> second period, which is about 3-4 queries every second. + +Can you turn the problem around? Calculate what you want for all users +(once every 60 seconds) and stuff those results into a summary table. +Then let the users query the summary table as often as they like (with +the understanding that the figures aren't going to update any faster +than once a minute) +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Mar 4 16:36:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D83D9555BA + for ; + Fri, 4 Mar 2005 16:36:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15768-07 + for ; + Fri, 4 Mar 2005 16:36:26 +0000 (GMT) +Received: from fep3.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F8B755554 + for ; + Fri, 4 Mar 2005 16:36:25 +0000 (GMT) +Received: from windsortransportationclub.com (d57-59-156.home.cgocable.net + [24.57.59.156]) by fep3.cogeco.net (Postfix) with SMTP id 90E653ECD + for ; + Fri, 4 Mar 2005 11:36:24 -0500 (EST) +Received: (qmail 13556 invoked from network); 4 Mar 2005 17:07:33 -0000 +Received: from unknown (HELO javadude) (24.57.59.156) + by 0 with SMTP; 4 Mar 2005 17:07:33 -0000 +Message-ID: <000e01c520d8$4f899a90$780ba8c0@javadude> +From: "Ken" +To: "Richard Huxton" , + +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <200503022152.13211.josh@agliodbs.com> + <004601c51fbe$828bbb50$6a01a8c0@KEN> + <200503030935.14537.josh@agliodbs.com> + <001d01c5204a$b440edf0$6a01a8c0@KEN> + <4227AA36.2080700@arbash-meinel.com> + <000e01c5207a$1f668ac0$6a01a8c0@KEN> + <42288529.7000803@archonet.com> +Subject: Re: Help with tuning this query (with explain analyze finally) +Date: Fri, 4 Mar 2005 11:36:26 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=response +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2527 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/74 +X-Sequence-Number: 10779 + +Richard, + +What do you mean by summary table? Basically a cache of the query into a +table with replicated column names of all the joins? I'd probably have to +whipe out the table every minute and re-insert the data for each carrier in +the system. I'm not sure how expensive this operation would be, but I'm +guessing it would be fairly heavy-weight. And maintaince would be a lot +harder because of the duplicated columns, making refactorings on the +database more error-prone. Am I understanding your suggestion correctly? +Please correct me if I am. + +> Can you turn the problem around? Calculate what you want for all users +> (once every 60 seconds) and stuff those results into a summary table. Then +> let the users query the summary table as often as they like (with the +> understanding that the figures aren't going to update any faster than once +> a minute) + + +From pgsql-performance-owner@postgresql.org Fri Mar 4 16:57:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 38BAF5526B + for ; + Fri, 4 Mar 2005 16:57:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22937-02 + for ; + Fri, 4 Mar 2005 16:57:03 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 8585B54F47 + for ; + Fri, 4 Mar 2005 16:57:02 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j24GuviY003425; (envelope-from ) Fri, + 4 Mar 2005 10:56:57 -0600 (CST) +Received: from [192.168.1.13] (70-57-223-15.cdrr.qwest.net [70.57.223.15]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j24GusVY007566 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Fri, + 4 Mar 2005 10:56:56 -0600 (CST) +Message-ID: <42289347.7040607@arbash-meinel.com> +Date: Fri, 04 Mar 2005 10:56:39 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ken +Cc: Richard Huxton , + pgsql-performance@postgresql.org +Subject: Re: Help with tuning this query (with explain analyze finally) +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <200503022152.13211.josh@agliodbs.com> + <004601c51fbe$828bbb50$6a01a8c0@KEN> + <200503030935.14537.josh@agliodbs.com> + <001d01c5204a$b440edf0$6a01a8c0@KEN> + <4227AA36.2080700@arbash-meinel.com> + <000e01c5207a$1f668ac0$6a01a8c0@KEN> + <42288529.7000803@archonet.com> + <000e01c520d8$4f899a90$780ba8c0@javadude> +In-Reply-To: <000e01c520d8$4f899a90$780ba8c0@javadude> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig87B918931C5FE81078B74AC3" +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/75 +X-Sequence-Number: 10780 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig87B918931C5FE81078B74AC3 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Ken wrote: + +> Richard, +> +> What do you mean by summary table? Basically a cache of the query +> into a table with replicated column names of all the joins? I'd +> probably have to whipe out the table every minute and re-insert the +> data for each carrier in the system. I'm not sure how expensive this +> operation would be, but I'm guessing it would be fairly heavy-weight. +> And maintaince would be a lot harder because of the duplicated +> columns, making refactorings on the database more error-prone. Am I +> understanding your suggestion correctly? Please correct me if I am. +> +>> Can you turn the problem around? Calculate what you want for all +>> users (once every 60 seconds) and stuff those results into a summary +>> table. Then let the users query the summary table as often as they +>> like (with the understanding that the figures aren't going to update +>> any faster than once a minute) +> +It's the same idea of a materialized view, or possibly just a lazy cache. + +Just try this query: + +CREATE TABLE cachedview AS +select p.id as person_id, s.*, ss.* + +from shipment s +inner join shipment_status ss on s.current_status_id=ss.id +inner join release_code rc on ss.release_code_id=rc.id +left outer join driver d on s.driver_id=d.id +left outer join carrier_code cc on s.carrier_code_id=cc.id +where s.carrier_code_id in ( + select cc.id + from person p + inner join carrier_to_person ctp on p.id=ctp.person_id + inner join carrier c on ctp.carrier_id=c.id + inner join carrier_code cc on cc.carrier_id = c.id +) +and s.current_status_id is not null +and s.is_purged=false +and(rc.number='9' ) +and(ss.date>=current_date-31 ) + +order by ss.date desc ; + +Notice that I took out the internal p.id = blah. +Then you can do: + +CREATE INDEX cachedview_person_id_idx ON cachedview(person_id); + +Then from the client side, you can just run: +SELECT * from cachedview WHERE person_id = ; + +Now, this assumes that rc.number='9' is what you always want. If that +isn't the case, you could refactor a little bit. + +This unrolls all of the work, a table which should be really fast to +query. If this query takes less than 10s to generate, than just have a +service run it every 60s. I think for refreshing, it is actually faster +to drop the table and recreate it, rather than deleteing the entries. +Dropping also has the advantage that if you ever add more rows to s or +ss, then the table automatically gets the new entries. + +Another possibility, is to have the "cachedview" not use "s.*, ss.*", +but instead just include whatever the primary keys are for those tables. +Then your final query becomes: + +SELECT s.*, ss.* FROM cachedview cv, s, ss WHERE cv.person_id = , +cv.s_id = s., cv.ss_id = ss.; + +Again, this should be really fast, because you should have an index on +cv.person_id and only have say 300 rows there, and then you are just +fetching a few rows from s and ss. You can also use this time to do some +of your left joins against other tables. + +Does this make sense? The biggest advantage you have is your "60s" +statement. With that in hand, I think you can do a lot of caching +optimizations. + +John +=:-> + + +--------------enig87B918931C5FE81078B74AC3 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCKJNLJdeBCYSNAAMRAhKpAJ0ZW5Kk4l3VfFjhjrmLdMqor7rOXwCgtWMo +LRXA/Wtpid9SrV5kjXRSkLg= +=UVCE +-----END PGP SIGNATURE----- + +--------------enig87B918931C5FE81078B74AC3-- + +From pgsql-performance-owner@postgresql.org Fri Mar 4 17:07:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C5E1F52A86 + for ; + Fri, 4 Mar 2005 17:07:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24742-08 + for ; + Fri, 4 Mar 2005 17:07:41 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id CD1A252A5C + for ; + Fri, 4 Mar 2005 17:07:39 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j24H7ciJ003981; (envelope-from ) Fri, + 4 Mar 2005 11:07:38 -0600 (CST) +Received: from [192.168.1.13] (70-57-223-15.cdrr.qwest.net [70.57.223.15]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j24H7asu011199 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Fri, + 4 Mar 2005 11:07:37 -0600 (CST) +Message-ID: <422895D7.80006@arbash-meinel.com> +Date: Fri, 04 Mar 2005 11:07:35 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ken Egervari +Cc: pgsql-performance@postgresql.org +Subject: Re: Help with tuning this query (with explain analyze finally) +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <200503022152.13211.josh@agliodbs.com> + <004601c51fbe$828bbb50$6a01a8c0@KEN> + <200503030935.14537.josh@agliodbs.com> + <001d01c5204a$b440edf0$6a01a8c0@KEN> + <4227AA36.2080700@arbash-meinel.com> + <000e01c5207a$1f668ac0$6a01a8c0@KEN> +In-Reply-To: <000e01c5207a$1f668ac0$6a01a8c0@KEN> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigC001B7E761D1648B8D434EC3" +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/76 +X-Sequence-Number: 10781 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigC001B7E761D1648B8D434EC3 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Ken Egervari wrote: + +> Josh, +> +... + +> I thought about this, but it's very important since shipment and +> shipment_status are both updated in real time 24/7/365. I think I +> might be able to cache it within the application for 60 seconds at +> most, but it would make little difference since people tend to refresh +> within that time anyway. It's very important that real-time +> inforamtion exists though. +> +Is 60s real-time enough for you? That's what it sounds like. It would be +nice if you could have 1hr, but there's still a lot of extra work you +can do in 60s. + +>> You could also always throw more hardware at it. :) If the +>> shipment_status is one of the bottlenecks, create a 4-disk raid10 and +>> move the table over. +>> I don't remember what your hardware is, but I don't remember it being a +>> quad opteron with 16GB ram, and 20 15k SCSI disks, with the transaction +>> log on a solid state disk. :) +> +> +> That sounds like an awesome system. I loved to have something like +> that. Unfortunately, the production server is just a single processor +> machine with 1 GB ram. I think throwing more disks at it is probably +> the best bet, moving the shipment and shipment_status tables over as +> you suggested. That's great advice. +> +Well, disk I/O is one side, but probably sticking another 1GB (2GB +total) also would be a fairly economical upgrade for performance. + +You are looking for query performance, not really update performance, +right? So buy a 4-port SATA controller, and some WD Raptor 10k SATA +disks. With this you can create a RAID10 for < $2k (probably like $1k). + +> 30ms is a good target, although I guess I was naive for setting that +> goal perhaps. I've just taken queries that ran at 600ms and with 1 or +> 2 indexes, they went down to 15ms. + +It all depends on your query. If you have a giant table (1M rows), and +you are doing a seqscan for only 5 rows, then adding an index will give +you enormous productivity gains. But you are getting 30k rows, and +combining them with 6k rows, plus a bunch of other stuff. I think we've +tuned the query about as far as we can. + +> +> Let's say we have 200 users signed into the application at the same +> time. The application refreshes their shipment information +> automatically to make sure it's up to date on the user's screen. The +> application will execute the query we are trying to tune every 60 +> seconds for most of these users. Users can set the refresh time to be +> higher, but 60 is the lowest amount so I'm just assuming everyone has +> it at 60. +> +> Anyway, if you have 200 users logged in, that's 200 queries in the 60 +> second period, which is about 3-4 queries every second. As you can +> see, it's getting maxed out, and because of bad luck, the queries are +> bunched together and are being called at the same time, making 8-9 +> queries in the same second and that's where the performance is +> starting to degrade. I just know that if I could get this down to 30 +> ms, or even 100, we'd be okay for a few months without throwing +> hardware at the problem. Also keep in mind that other application +> logic and Hibernate mapping is occuring to, so 3-4 queries a second is +> already no good when everything is running on a single machine. +> +The other query I just sent, where you do the query for all users at +once, and then cache the result, *might* be cheaper than doing a bunch +of different queries. +However, you may find that doing the query for *all* users takes to +long. So you could keep another table indicating who the most recent +people logged in are, and then only cache the info for those people. +This does start getting a little more involved, so see if you can do all +users before heading down this road. + +> This isn't the best setup, but it's the best we can afford. We are +> just a new startup company. Cheaper servers and open source keep our +> costs low. But money is starting to come in after 10 months of hard +> work, so we'll be able to replace our server within the next 2 +> months. It'll be a neccessity because we are signing on some big +> clientsnow and they'll have 40 or 50 users for a single company. If +> they are all logged in at the same time, that's a lot of queries. +> +Sure. Just realize you can't really support 200 concurrent connections +with a single P4 and 1GB of ram. + +John +=:-> + + +--------------enigC001B7E761D1648B8D434EC3 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCKJXXJdeBCYSNAAMRAmkHAJ0WPDkF0xNE0hVY44zmnCXWFMIc5wCdE18s +Dgf0p7wOC5b8E7Gkd1jJJiU= +=+aUe +-----END PGP SIGNATURE----- + +--------------enigC001B7E761D1648B8D434EC3-- + +From pgsql-performance-owner@postgresql.org Fri Mar 4 17:53:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DF131545EE + for ; + Fri, 4 Mar 2005 17:53:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37634-04 + for ; + Fri, 4 Mar 2005 17:53:29 +0000 (GMT) +Received: from web54301.mail.yahoo.com (web54301.mail.yahoo.com + [68.142.225.143]) + by svr1.postgresql.org (Postfix) with SMTP id 64FBF5529B + for ; + Fri, 4 Mar 2005 17:53:28 +0000 (GMT) +Received: (qmail 92962 invoked by uid 60001); 4 Mar 2005 17:53:28 -0000 +Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + b=6WvN7yWj+GDjb9lchocen9gihTDMS3fLhvb8owkTEC8jhavqgdMYvq7BXgLt3j7AlzhKKtpzdiFl7GGSAG/yShmeAU959b1AlDFf5BMCgZ+jH4PV+m4sGFGwkYEe5L+mTC9+tMs3LaNtfexRPBjMTU1rsxYWrkmYiGtXaSLcKoM= + ; +Message-ID: <20050304175328.92960.qmail@web54301.mail.yahoo.com> +Received: from [202.158.105.240] by web54301.mail.yahoo.com via HTTP; + Fri, 04 Mar 2005 09:53:28 PST +Date: Fri, 4 Mar 2005 09:53:28 -0800 (PST) +From: Charles Joseph +Subject: Select in FOR LOOP Performance +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.581 tagged_above=0 required=5 + tests=DNS_FROM_RFC_ABUSE, UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200503/77 +X-Sequence-Number: 10782 + + I face problem when running the following pgplsql +function. The problem is it takes more than 24hours to +complete + the calculation. The EMP table has about 200,000 +records. I execute the function through psql "select +calculate()"; + (There is no cyclic link inside the data). + + Computer used: IBM xSeries 225, RAM 1GB, SCSI 36GB + O/S : RedHat Linux Enterprise 3.0 AS + PostgreSQL version 8.0.1 + fsync=false + + I would very appreciate if anyone can help to find +out what the problem is, or any others way to improve +the performance + of the function. + + Is there any difference between select in FOR LOOP +with CURSOR in term of performance ? + + EMP Table + GEN char(3), + CODE varchar(20), + PARENT varchar(20), + POSITION INT4 DEFAULT 0, + PG NUMERIC(15,2) DEFAULT 0, + P NUMERIC(15,2) DEFAULT 0, + QUA CHAR(1) DEFAULT '0', + . + . + . + create index EMP_GEN on EMP (GEN); + create index EMP_CODE on EMP (CODE); + create index EMP_PARENT on PARENT (PARENT); + + Sample EMP DATA: + GEN CODE PARENT POSITION P PG QUA + =============================================== + 000 A001 **** 3 100 0 '1' + 001 A002 A001 2 50 0 '1' + 001 A003 A001 1 50 0 '1' + 001 A004 A001 1 20 0 '1' + 002 A005 A003 2 20 0 '1' + 002 A006 A004 3 30 0 '1' + ... + ... + + + for vTMP_ROW in select CODE,PARENT,POSITION from +EMP order by GEN desc loop + vCODE := vTMP_ROW.CODE; + vPARENT := vTMP_ROW.PARENT; + nPOSITION := vTMP_ROW.POSITION; + + update EMP set PG=PG+P where CODE = vCODE; + + select into vCURR_ROW PG,POSITION from EMP +where CODE = vCODE; + + nPG := vCURR_ROW.PG; + nPOSITION := vCURR_ROW.POSITION; + + vUPL := vPARENT; + + loop + select into vUPL_ROW +CODE,PARENT,POSITION,P,QUA from EMP where CODE = vUPL; + if found then + if vUPL_ROW.POSITION > nPOSITION and +vUPL_ROW.QUA = ''1'' then + update EMP set PG=PG+nPG where CODE = +vUPL; + exit; + end if; + else + exit; + end if; + vUPL := vUPL_ROW.PARENT; + end loop; + end loop; + + . + . + . + +Thank You + + + + + +__________________________________ +Celebrate Yahoo!'s 10th Birthday! +Yahoo! Netrospective: 100 Moments of the Web +http://birthday.yahoo.com/netrospective/ + +From pgsql-performance-owner@postgresql.org Fri Mar 4 18:29:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F42E52D45 + for ; + Fri, 4 Mar 2005 18:29:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46046-09 + for ; + Fri, 4 Mar 2005 18:29:03 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A07A752D42 + for ; + Fri, 4 Mar 2005 18:29:02 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j24IT2ic028976; + Fri, 4 Mar 2005 13:29:02 -0500 (EST) +To: Charles Joseph +Cc: pgsql-performance@postgresql.org +Subject: Re: Select in FOR LOOP Performance +In-reply-to: <20050304175328.92960.qmail@web54301.mail.yahoo.com> +References: <20050304175328.92960.qmail@web54301.mail.yahoo.com> +Comments: In-reply-to Charles Joseph + message dated "Fri, 04 Mar 2005 09:53:28 -0800" +Date: Fri, 04 Mar 2005 13:29:02 -0500 +Message-ID: <28975.1109960942@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/78 +X-Sequence-Number: 10783 + +Charles Joseph writes: +> I face problem when running the following pgplsql +> function. The problem is it takes more than 24hours to +> complete +> the calculation. The EMP table has about 200,000 +> records. + +Sure there are no infinite loops of PARENT links in your table? + +Also, if CODE is supposed to be unique, you should probably declare +its index that way. Or at least make sure the planner knows it's +unique (have you ANALYZEd the table lately?) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 4 18:30:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7164952A4D + for ; + Fri, 4 Mar 2005 18:30:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47786-05 + for ; + Fri, 4 Mar 2005 18:30:10 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 1914652D45 + for ; + Fri, 4 Mar 2005 18:30:08 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7092290; Fri, 04 Mar 2005 10:31:58 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Ken Egervari" +Subject: Re: Help with tuning this query (with explain analyze finally) +Date: Fri, 4 Mar 2005 10:29:11 -0800 +User-Agent: KMail/1.6.2 +Cc: +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <200503030935.14537.josh@agliodbs.com> + <001d01c5204a$b440edf0$6a01a8c0@KEN> +In-Reply-To: <001d01c5204a$b440edf0$6a01a8c0@KEN> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200503041029.11608.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/79 +X-Sequence-Number: 10784 + +Ken, + +> I did everything you said and my query does perform a bit better. I've +> been getting speeds from 203 to 219 to 234 milliseconds now. I tried +> increasing the work mem and the effective cache size from the values you +> provided, but I didn't see any more improvement. I've tried to looking +> into setting the shared buffers for Windows XP, but I'm not sure how to do +> it. I'm looking in the manual at: + +Now that you know how to change the shared_buffers, want to go ahead and run +the query again? + +I'm pretty concerned about your case, because based on your description I +would expect < 100ms on a Linux machine. So I'm wondering if this is a +problem with WindowsXP performance, or if it's something we can fix through +tuning. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Mar 4 19:56:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2573954F47 + for ; + Fri, 4 Mar 2005 19:56:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70799-09 + for ; + Fri, 4 Mar 2005 19:56:28 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C7A454E34 + for ; + Fri, 4 Mar 2005 19:56:27 +0000 (GMT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j24JuJ310009; + Fri, 4 Mar 2005 13:56:20 -0600 +Message-ID: <4228BD5C.9020800@arbash-meinel.com> +Date: Fri, 04 Mar 2005 13:56:12 -0600 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ken +Cc: Richard Huxton , + pgsql-performance@postgresql.org +Subject: Re: Help with tuning this query (with explain analyze finally) +References: <001001c51ef4$3849eeb0$6a01a8c0@KEN> + <200503022152.13211.josh@agliodbs.com> + <004601c51fbe$828bbb50$6a01a8c0@KEN> + <200503030935.14537.josh@agliodbs.com> + <001d01c5204a$b440edf0$6a01a8c0@KEN> + <4227AA36.2080700@arbash-meinel.com> + <000e01c5207a$1f668ac0$6a01a8c0@KEN> + <42288529.7000803@archonet.com> + <000e01c520d8$4f899a90$780ba8c0@javadude> + <42289347.7040607@arbash-meinel.com> +In-Reply-To: <42289347.7040607@arbash-meinel.com> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigF3BC37F711E5725CDBD5F520" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/80 +X-Sequence-Number: 10785 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigF3BC37F711E5725CDBD5F520 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +John Arbash Meinel wrote: + +> Ken wrote: +> +>> Richard, +>> +>> What do you mean by summary table? Basically a cache of the query +>> into a table with replicated column names of all the joins? I'd +>> probably have to whipe out the table every minute and re-insert the +>> data for each carrier in the system. I'm not sure how expensive this +>> operation would be, but I'm guessing it would be fairly heavy-weight. +>> And maintaince would be a lot harder because of the duplicated +>> columns, making refactorings on the database more error-prone. Am I +>> understanding your suggestion correctly? Please correct me if I am. +>> +>>> Can you turn the problem around? Calculate what you want for all +>>> users (once every 60 seconds) and stuff those results into a summary +>>> table. Then let the users query the summary table as often as they +>>> like (with the understanding that the figures aren't going to update +>>> any faster than once a minute) +>> +>> +> It's the same idea of a materialized view, or possibly just a lazy cache. +> +... + +> This unrolls all of the work, a table which should be really fast to +> query. If this query takes less than 10s to generate, than just have a +> service run it every 60s. I think for refreshing, it is actually faster +> to drop the table and recreate it, rather than deleteing the entries. +> Dropping also has the advantage that if you ever add more rows to s or +> ss, then the table automatically gets the new entries. +> +Just as a small update. If completely regenerating the cache takes to +long, the other way to do it, is to create insert and update triggers on +s and ss, such that as they change, they also update the cachedview table. + +Something like + +CREATE TRIGGER on_ss_ins AFTER INSERT ON ss FOR EACH ROW EXECUTE + INSERT INTO cached_view SELECT p.id as person_id, s.*, ss.* FROM + WHERE s.id = NEW.id; + +This runs the same query, but notice that the WHERE means it only allows +the new row. So this query should run fast. It is a little bit of +overhead on each of your inserts, but it should keep the cache +up-to-date. With something like this, I would have the final client +query still include the date restriction, since you accumulate older +rows into the cached view. But you can run a daily process that prunes +out everything older than 31 days, which keeps the cachedview from +getting really large. + +John +=:-> + + +--------------enigF3BC37F711E5725CDBD5F520 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCKL1fJdeBCYSNAAMRAoQ2AKCrcTSv3Kc21WdAzFq5LsJx1RbBdACgw78C +IQWDOtHPh4MBTEVTpYmrCEA= +=zjI/ +-----END PGP SIGNATURE----- + +--------------enigF3BC37F711E5725CDBD5F520-- + +From pgsql-performance-owner@postgresql.org Fri Mar 4 20:59:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DFDD154FDF + for ; + Fri, 4 Mar 2005 20:59:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86390-09 + for ; + Fri, 4 Mar 2005 20:59:04 +0000 (GMT) +Received: from asg002.asg.local (smtp2.arrayservicesgrp.com [208.14.218.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 7534854E34 + for ; + Fri, 4 Mar 2005 20:59:03 +0000 (GMT) +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: MAIN vs. PLAIN +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +Date: Fri, 4 Mar 2005 14:59:01 -0600 +Message-ID: <49E94D0CFCD4DB43AFBA928DDD20C8F902618465@asg002.asg.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Select in FOR LOOP Performance +Thread-Index: AcUg48jfky1VnCQ8R/ivAKC9heWFEwAGIAWA +From: "Dave Held" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.154 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/81 +X-Sequence-Number: 10786 + +I notice that by default, postgres sets numeric fields to +storage MAIN. What exactly does that mean? Does that mean +it stores it in some type of compressed BCD format? If so, +how much performance gain can I expect by setting the storage +to PLAIN? Also, the docs say that char(n) is implemented more +or less the same way as text. Does that mean that setting +a field to, say, char(2) PLAIN is not going be any faster +than text PLAIN? That seems a bit counter-intuitive. I +would hope that a char(2) PLAIN would just reserve two chars +in the record structure without any overhead of pointers to +external data. Is there a reason this isn't supported? + +__ +David B. Held +Software Engineer/Array Services Group +200 14th Ave. East, Sartell, MN 56377 +320.534.3637 320.253.7800 800.752.8129 + +From pgsql-performance-owner@postgresql.org Fri Mar 4 22:07:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A740256231 + for ; + Fri, 4 Mar 2005 22:05:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11832-08 + for ; + Fri, 4 Mar 2005 22:05:15 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id C500054593 + for ; + Fri, 4 Mar 2005 22:05:06 +0000 (GMT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id D10091C91F; Fri, 4 Mar 2005 16:05:07 -0600 (CST) +Date: Fri, 4 Mar 2005 16:05:07 -0600 +From: "Jim C. Nasby" +To: Ramon Bastiaans +Cc: pgsql-performance@postgresql.org +Subject: Re: multi billion row tables: possible or insane? +Message-ID: <20050304220507.GH2209@decibel.org> +References: <42243725.6060804@sara.nl> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <42243725.6060804@sara.nl> +X-Operating-System: FreeBSD 4.10-RELEASE-p3 i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.089 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/84 +X-Sequence-Number: 10789 + +On Tue, Mar 01, 2005 at 10:34:29AM +0100, Ramon Bastiaans wrote: +> Hi all, +> +> I am doing research for a project of mine where I need to store several +> billion values for a monitoring and historical tracking system for a big +> computer system. My currect estimate is that I have to store (somehow) +> around 1 billion values each month (possibly more). + +On a side-note, do you need to keep the actual row-level details for +history? http://rrs.decibel.org might be of some use. + +Other than that, what others have said. Lots and lots of disks in +RAID10, and opterons (though I would choose opterons not for memory size +but because of memory *bandwidth*). +-- +Jim C. Nasby, Database Consultant decibel@decibel.org +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 Mar 5 00:16:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EF6C54CF8 + for ; + Sat, 5 Mar 2005 00:15:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46862-09 + for ; + Sat, 5 Mar 2005 00:15:53 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.199]) + by svr1.postgresql.org (Postfix) with ESMTP id 5009754C55 + for ; + Sat, 5 Mar 2005 00:15:52 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 70so983133wra + for ; + Fri, 04 Mar 2005 16:15:55 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=nflCwM70N/60i38w5YKQy+40L0HfPod3sgR6kTvbaIXGflwpBzpjOxJII9hBrVw6Dx9vMNDYeoeFaBirfHtJXmHzgcj04kZepJO/yeWAOPMbkZii5piFQUwJhSsWdK6cW9OwFnfXsuB19QouWafq1b2O7fwFHxe0I+wr7jyTTFc= +Received: by 10.54.10.36 with SMTP id 36mr19906wrj; + Fri, 04 Mar 2005 16:15:55 -0800 (PST) +Received: by 10.54.18.59 with HTTP; Fri, 4 Mar 2005 16:15:55 -0800 (PST) +Message-ID: <33c6269f05030416151b826a9c@mail.gmail.com> +Date: Fri, 4 Mar 2005 19:15:55 -0500 +From: Alex Turner +Reply-To: Alex Turner +To: "Vig, Sandor (G/FI-2)" +Subject: Re: multi billion row tables: possible or insane? +Cc: John Arbash Meinel , + "pgsql-performance@postgresql.org" +In-Reply-To: <977921B17B2F2048AA5AAE9B4CBB713E01423D75@huaudigs0035.audi.de> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <977921B17B2F2048AA5AAE9B4CBB713E01423D75@huaudigs0035.audi.de> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.033 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/85 +X-Sequence-Number: 10790 + +Not true - with fsync on I get nearly 500 tx/s, with it off I'm as +high as 1600/sec with dual opteron and 14xSATA drives and 4GB RAM on a +3ware Escalade. Database has 3 million rows. + +As long as queries use indexes, multi billion row shouldn't be too +bad. Full table scan will suck though. + +Alex Turner +netEconomist + + +On Tue, 1 Mar 2005 16:40:29 +0100, Vig, Sandor (G/FI-2) + wrote: +> 385 transaction/sec? +> +> fsync = false +> +> risky but fast. +> +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of John Arbash +> Meinel +> Sent: Tuesday, March 01, 2005 4:19 PM +> To: Ramon Bastiaans +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] multi billion row tables: possible or insane? +> +> Ramon Bastiaans wrote: +> +> > Hi all, +> > +> > I am doing research for a project of mine where I need to store +> > several billion values for a monitoring and historical tracking system +> > for a big computer system. My currect estimate is that I have to store +> > (somehow) around 1 billion values each month (possibly more). +> > +> If you have that 1 billion perfectly distributed over all hours of the +> day, then you need 1e9/30/24/3600 = 385 transactions per second. +> +> Which I'm pretty sure is possible with postgres, you just need pretty +> beefy hardware. And like Jeff said, lots of disks for lots of IO. +> Like a quad opteron, with 16GB of ram, and around 14-20 very fast disks. +> raid10 not raid5, etc. To improve query performance, you can do some +> load balancing by having replication machines by using Slony. +> +> Or if you can do batch processing, you could split up the work into a +> few update machines, which then do bulk updates on the master database. +> This lets you get more machines into the job, since you can't share a +> database across multiple machines. +> +> > I was wondering if anyone has had any experience with these kind of +> > big numbers of data in a postgres sql database and how this affects +> > database design and optimization. +> > +> Well, one of the biggest things is if you can get bulk updates, or if +> clients can handle data being slightly out of date, so you can use +> cacheing. Can you segregate your data into separate tables as much as +> possible? Are your clients okay if aggregate information takes a little +> while to update? +> +> One trick is to use semi-lazy materialized views to get your updates to +> be fast. +> +> > What would be important issues when setting up a database this big, +> > and is it at all doable? Or would it be a insane to think about +> > storing up to 5-10 billion rows in a postgres database. +> +> I think you if you can design the db properly, it is doable. But if you +> have a clients saying "I need up to the second information on 1 billion +> rows", you're never going to get it. +> +> > +> > The database's performance is important. There would be no use in +> > storing the data if a query will take ages. Query's should be quite +> > fast if possible. +> > +> Again, it depends on the queries being done. +> There are some nice tricks you can use, like doing a month-by-month +> partitioning (if you are getting 1G inserts, you might want week-by-week +> partitioning), and then with a date column index, and a union all view +> you should be able to get pretty good insert speed, and still keep fast +> *recent* queries. Going through 1billion rows is always going to be +> expensive. +> +> > I would really like to hear people's thoughts/suggestions or "go see a +> > shrink, you must be mad" statements ;) +> > +> > Kind regards, +> > +> > Ramon Bastiaans +> +> I think it would be possible, but there are a lot of design issues with +> a system like this. You can't go into it thinking that you can design a +> multi billion row database the same way you would design a million row db. +> +> John +> =:-> +> +> The information transmitted is intended only for the person or entity to +> which it is addressed and may contain confidential and/or privileged +> material. Any review, retransmission, dissemination or other use of, or +> taking of any action in reliance upon, this information by persons or +> entities other than the intended recipient is prohibited. If you received +> this in error, please contact the sender and delete the material from any +> computer. +> +> ---------------------------(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 Sat Mar 5 04:34:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BFC5652A50 + for ; + Sat, 5 Mar 2005 04:33:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12324-06 + for ; + Sat, 5 Mar 2005 04:33:49 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id D574054C94 + for ; + Sat, 5 Mar 2005 04:33:48 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j254XgIp013976; + Fri, 4 Mar 2005 23:33:42 -0500 (EST) +To: "Dave Held" +Cc: pgsql-performance@postgresql.org +Subject: Re: MAIN vs. PLAIN +In-reply-to: <49E94D0CFCD4DB43AFBA928DDD20C8F902618465@asg002.asg.local> +References: <49E94D0CFCD4DB43AFBA928DDD20C8F902618465@asg002.asg.local> +Comments: In-reply-to "Dave Held" + message dated "Fri, 04 Mar 2005 14:59:01 -0600" +Date: Fri, 04 Mar 2005 23:33:42 -0500 +Message-ID: <13975.1109997222@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/86 +X-Sequence-Number: 10791 + +"Dave Held" writes: +> I notice that by default, postgres sets numeric fields to +> storage MAIN. What exactly does that mean? + +See http://developer.postgresql.org/docs/postgres/storage-toast.html + +There isn't any amazingly strong reason why numeric defaults to MAIN +rather than EXTENDED, which is the default for every other toastable +datatype --- except that I thought it'd be a good idea to have at +least one type that did so, just to exercise that code path in the +tuple toaster. And numeric shouldn't ordinarily be large enough to +need out-of-line storage anyway. It's unlikely even to need +compression, really, but as long as it's a varlena type the overhead +to support toasting is nearly nil. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 8 04:26:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 55CC353C92 + for ; + Sat, 5 Mar 2005 12:26:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25744-07 + for ; + Sat, 5 Mar 2005 12:26:37 +0000 (GMT) +Received: from natpreptil.rzone.de (natpreptil.rzone.de [81.169.145.163]) + by svr1.postgresql.org (Postfix) with ESMTP id 2ACD253C91 + for ; + Sat, 5 Mar 2005 12:26:36 +0000 (GMT) +Received: from mainframe (pD4B9E93C.dip.t-dialin.net [212.185.233.60]) + by post.webmailer.de (8.13.1/8.13.1) with SMTP id j25CQa7t005195 + for ; + Sat, 5 Mar 2005 13:26:37 +0100 (MET) +Message-ID: <020301c5217e$94643c00$65a8a8c0@mainframe> +From: "Michael Zoephel" +To: +Subject: performance problems +Date: Sat, 5 Mar 2005 13:26:37 +0100 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0200_01C52186.F5973970" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2527 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200503/117 +X-Sequence-Number: 10822 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0200_01C52186.F5973970 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi, + +I have performance problems with the postmaster-process. The CPU usage = +is permanently=20 +around 90 %. + +My DB: + + 3,5 GB Size + largest table ca. 700 000 rows + +Most access: + + Finde a row - Update if exist Insert else + +Average access: + + 10 times a second + + every Query needs ca. 20 ms + + +All server options are still default !! + +Any idea on wich "screw" I can turn ?. + + +Thanks for suggestions! + + +Michael Z=F6phel + +e-Mail: zoephel@rechnerbetriebsgruppe.de + +------=_NextPart_000_0200_01C52186.F5973970 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi,
+
 
+
I have performance problems with the=20 +postmaster-process. The CPU usage is permanently 
+
around 90 %.
+
 
+
My DB:
+
 
+
    3,5 GB = +Size
+
    largest table ca. = +700 000=20 +rows
+
 
+
Most access:
+
 
+
    Finde a row - Update = +if exist=20 +Insert else
+
 
+
Average access:
+
 
+
    10 times a = +second
+
 
+
    every Query needs = +ca. 20=20 +ms
+
 
+
 
+
All server options are still default=20 +!!
+
 
+
Any idea on wich "screw" I can turn = +?.
+
 
+
 
+
Thanks for suggestions!
+
 
+
 
+
Michael Z=F6phel
+
 
+
e-Mail: zoephel@rechnerbetriebsg= +ruppe.de
+ +------=_NextPart_000_0200_01C52186.F5973970-- + + +From pgsql-performance-owner@postgresql.org Sat Mar 5 18:39:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C289052A57 + for ; + Sat, 5 Mar 2005 18:38:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15845-02 + for ; + Sat, 5 Mar 2005 18:38:39 +0000 (GMT) +Received: from smtpout02-03.prod.mesa1.secureserver.net + (smtpout02-03.prod.mesa1.secureserver.net [64.202.165.193]) + by svr1.postgresql.org (Postfix) with SMTP id 3924C52A6F + for ; + Sat, 5 Mar 2005 18:38:35 +0000 (GMT) +Received: (qmail 8138 invoked from network); 5 Mar 2005 18:38:35 -0000 +Received: from unknown (HELO webmail02.mesa1.secureserver.net) (64.202.166.81) + by smtpout02-03.prod.mesa1.secureserver.net with SMTP; + 5 Mar 2005 18:38:35 -0000 +Received: (qmail 17458 invoked by uid 99); 5 Mar 2005 18:38:35 -0000 +Message-ID: <20050305183835.17457.qmail@webmail02.mesa1.secureserver.net> +Date: Sat, 5 Mar 2005 11:38:35 -0700 +From: mark.lubratt@indeq.com +Subject: Query Optimization - Hash Join estimate off? +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: TEXT/html; CHARSET=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/87 +X-Sequence-Number: 10792 + +
Hello!
+
 
+
First off, I'm a real newbie at trying to read the output of explain +analyze.
+
 
+
I have several similar queries in my application that I've got +incorporated into views.  When they run sub 300ms, the users don't +seem to mind.  However, one of them (query is below along with some +relevant table information) is running about 800ms and my users are +starting to grumble.
+
 
+
I ran explain analyze on it (explain analyze results are +below).  I noticed that the biggest chunk of time is being taken +by a Hash Join near the top of the output (I'm still not sure what the +indentation means and what the order means).  If I look at the +estimate, it is comparable to several other hash join estimates in the +query; however, the actual cost in time is significantly higher than +those other hash joins.  Is this significant?
+
 
+
I tried optimizing according to "SQL Tuning" by Tow, but this +actually seemed to slow things down.  It also seemed that the +query optimizer in PostgreSQL reordered things on its own according to +its own plan anyway.  Is this correct?
+
 
+
I'd appreciate any help I can get to try to get this query below +300ms.
+
 
+
Thanks!
+
Mark
+
 
+
The platform is a dual 2.2GHz Xeon 1.2GB RAM with mirrored drives +(raid 1) running Win2000 Pro.  I run "vacuum analyze" every +night.  The postgresql.conf is basically standard except that I've +opened it up to listen to the external network.  Other changes:
+
 
+
max_connections = 100
+
shared_buffers = 10000
+
 
+
query (the person_id = 1 in the where clause is changed on a case by +case basis - depending upon who's running the query):
+
 
+
explain analyze
 SELECT DISTINCT c.job_id, g.person_id, +c.job_no, b.deadline, c.name, bid_date(c.job_id) AS bid_date, c.miscq, +c.city, c.st, j.name AS eng, c.s_team AS salesteam, +
        +CASE
            +WHEN c.file_loc = 0 THEN 'No Bid'::character +varying
            +WHEN c.file_loc = -1 THEN 'Bid Board'::character +varying
            +WHEN c.file_loc = -2 THEN 'Lost Job'::character +varying
            +WHEN c.file_loc = -3 THEN 'See Job Notes'::character +varying
            +WHEN c.file_loc < -3 OR c.file_loc IS NULL THEN ''::character +varying
            +WHEN h.initials IS NOT NULL THEN +h.initials
            +ELSE 'Unknown person'::character +varying
        END AS file_loc, +COALESCE(c.city::text || COALESCE(', '::text || c.st::text, ''::text), +COALESCE(c.st, ''::character varying)::text) AS "location", c.file_loc +AS file_loc_id
   FROM status a
   LEFT JOIN +status_list b ON a.status_id = b.status_id AND b.active
   +LEFT JOIN job c ON c.job_id = b.job_id
   LEFT JOIN +builder_list d ON c.job_id = d.job_id AND (d.won_heat OR d.won_vent OR +d.won_tc OR c.heat AND d.bid_heat AND d.won_heat IS NULL OR c.vent AND +d.bid_vent AND d.won_vent IS NULL OR c.tc AND d.bid_tc AND d.won_tc IS +NULL) AND d.role = 'C'::bpchar
   LEFT JOIN company e ON +d.company_id = e.company_id
   LEFT JOIN call_list f ON +e.company_id = f.company_id
   LEFT JOIN person g ON +f.person_id = g.person_id OR "position"(c.s_team::text, +g.initials::text) > 0
   LEFT JOIN person h ON +c.file_loc = h.person_id
   LEFT JOIN builder_list i ON +c.job_id = i.job_id AND i.role = 'E'::bpchar
   LEFT JOIN +company j ON i.company_id = j.company_id
  WHERE a.name::text = +'Awaiting Award'::character varying::text and g.person_id = 1
  +ORDER BY c.job_id, g.person_id, c.job_no, b.deadline, c.name, +bid_date(c.job_id), c.miscq, c.city, COALESCE(c.city::text || +COALESCE(', '::text || c.st::text, ''::text), COALESCE(c.st, +''::character varying)::text), c.st,
CASE
    +WHEN c.file_loc = 0 THEN 'No Bid'::character +varying
    WHEN c.file_loc = -1 THEN 'Bid +Board'::character varying
    WHEN c.file_loc = -2 +THEN 'Lost Job'::character varying
    WHEN +c.file_loc = -3 THEN 'See Job Notes'::character +varying
    WHEN c.file_loc < -3 OR c.file_loc IS +NULL THEN ''::character varying
    WHEN h.initials +IS NOT NULL THEN h.initials
    ELSE 'Unknown +person'::character varying
END, j.name, c.s_team, +c.file_loc;
+
Tables:
+
status - 14 rows
+
status_list - 6566 rows
+
job - 2210 rows
+
builder_list - 9670 rows
+
company - 1249 rows
+
call_list - 4731 rows
+
person - 27 rows
+
 
+
Primary keys:
+
any field with a "_id" suffix is a primary key; and thus is +implicitly indexed.
+
 
+
Other indexes:
+
status_list(job_id) btree
+
status_list(status_id) btree
+
job(file_loc) btree
+
builder_list(company_id) btree
+
call_list(company_id) btree
+
call_list(person_id) btree
+
call_list(company_id) btree
+
person(company_id) btree
+
 
+
explain analyze:
+
Unique  (cost=1798.47..1809.38 rows=291 width=114) (actual +time=766.000..781.000 rows=566 loops=1)
  ->  +Sort  (cost=1798.47..1799.19 rows=291 width=114) (actual +time=766.000..766.000 rows=1473 +loops=1)
        Sort Key: +c.job_id, g.person_id, c.job_no, b.deadline, c.name, +bid_date(c.job_id), c.miscq, c.city, COALESCE(((c.city)::text || +COALESCE((', '::text || (c.st)::text), ''::text)), (COALESCE(c.st, +''::character varying))::text), c.st, CASE WHEN (c.fi +(..)
        ->  Hash +Left Join  (cost=1750.81..1786.56 rows=291 width=114) (actual +time=453.000..750.000 rows=1473 +loops=1)
              +Hash Cond: ("outer".company_id = +"inner".company_id)
              +->  Merge Left Join  (cost=1707.20..1722.53 rows=291 +width=95) (actual time=437.000..484.000 rows=1473 +loops=1)
                    +Merge Cond: ("outer".job_id = +"inner".job_id)
                    +->  Sort  (cost=1382.44..1383.17 rows=291 width=91) (actual +time=406.000..406.000 rows=1473 +loops=1)
                          +Sort Key: +c.job_id
                          +->  Hash Left Join  (cost=1137.28..1370.53 rows=291 +width=91) (actual time=234.000..390.000 rows=1473 +loops=1)
                                +Hash Cond: ("outer".file_loc = +"inner".person_id)
                                +->  Nested Loop  (cost=1135.94..1365.27 rows=291 width=84) +(actual time=234.000..390.000 rows=1473 +loops=1)
                                      +Join Filter: (("inner".person_id = "outer".person_id) OR +("position"(("inner".s_team)::text, ("outer".initials)::text) > +0))
                                      +->  Seq Scan on person g  (cost=0.00..1.34 rows=1 width=11) +(actual time=0.000..0.000 rows=1 +loops=1)
                                            +Filter: (person_id = +1)
                                      +->  Merge Right Join  (cost=1135.94..1349.74 rows=811 +width=84) (actual time=234.000..297.000 rows=7490 +loops=1)
                                            +Merge Cond: ("outer".company_id = +"inner".company_id)
                                            +->  Index Scan using idx_company_id_call_list on call_list +f  (cost=0.00..189.80 rows=4731 width=8) (actual +time=0.000..15.000 rows=4731 +loops=1)
                                            +->  Sort  (cost=1135.94..1136.48 rows=214 width=84) (actual +time=234.000..234.000 rows=7490 +loops=1)
                                                  +Sort Key: +e.company_id
                                                  +->  Merge Right Join  (cost=1004.19..1127.66 rows=214 +width=84) (actual time=203.000..219.000 rows=1569 +loops=1)
                                                        +Merge Cond: ("outer".company_id = +"inner".company_id)
                                                        +->  Index Scan using company_pkey on company e  +(cost=0.00..117.13 rows=1249 width=4) (actual time=0.000..0.000 +rows=1249 +loops=1)
                                                        +->  Sort  (cost=1004.19..1004.73 rows=214 width=84) (actual +time=203.000..203.000 rows=1569 +loops=1)
                                                              +Sort Key: +d.company_id
                                                              +->  Hash Left Join  (cost=633.74..995.91 rows=214 width=84) +(actual time=156.000..187.000 rows=1569 +loops=1)
                                                                    +Hash Cond: ("outer".job_id = +"inner".job_id)
                                                                    +Join Filter: ("inner".won_heat OR "inner".won_vent OR "inner".won_tc OR +("outer".heat AND "inner".bid_heat AND ("inner".won_heat IS NULL)) OR +("outer".vent AND "inner".bid_vent AND ("inner +(..)
                                                                    +->  Merge Left Join  (cost=368.17..381.60 rows=159 +width=83) (actual time=78.000..93.000 rows=695 +loops=1)
                                                                          +Merge Cond: ("outer".job_id = +"inner".job_id)
                                                                          +->  Sort  (cost=168.31..168.71 rows=159 width=8) (actual +time=31.000..31.000 rows=695 +loops=1)
                                                                +                +Sort Key: +b.job_id
                                                                                +->  Nested Loop Left Join  (cost=0.00..162.50 rows=159 +width=8) (actual time=0.000..31.000 rows=695 +loops=1)
                                                                                      +Join Filter: ("outer".status_id = +"inner".status_id)
                                                                                      +->  Seq Scan on status a  (cost=0.00..1.18 rows=1 width=4) +(actual time=0.000..0.000 rows=1 +loops=1)
                                                                                            +Filter: ((name)::text = 'Awaiting +Award'::text)
                                                                                      +->  Seq Scan on status_list b  (cost=0.00..133.66 rows=2213 +width=12) (actual time=0.000..15.000 rows=2210 +loops=1)
                                                                                            +Filter: +active
                                                                          +->  Sort  (cost=199.86..205.39 rows=2210 width=79) (actual +time=47.000..47.000 rows=2194 +loops=1)
                                                                                +Sort Key: +c.job_id
                                                                                +->  Seq Scan on job c  (cost=0.00..77.10 rows=2210 +width=79) (actual time=0.000..31.000 rows=2210 +loops=1)
                                                                    +->  Hash  (cost=202.88..202.88 rows=7475 width=14) (actual +time=78.000..78.000 rows=0 +loops=1)
                                                                          +->  Seq Scan on builder_list d  (cost=0.00..202.88 +rows=7475 width=14) (actual time=0.000..15.000 rows=7517 +loops=1)
                                                                                +Filter: (role = +'C'::bpchar)
                                +->  Hash  (cost=1.27..1.27 rows=27 width=11) (actual +time=0.000..0.000 rows=0 +loops=1)
                                      +->  Seq Scan on person h  (cost=0.00..1.27 rows=27 +width=11) (actual time=0.000..0.000 rows=27 +loops=1)
                    +->  Sort  (cost=324.76..330.25 rows=2196 width=8) (actual +time=31.000..31.000 rows=3044 +loops=1)
                          +Sort Key: +i.job_id
                          +->  Seq Scan on builder_list i  (cost=0.00..202.88 +rows=2196 width=8) (actual time=0.000..31.000 rows=2153 +loops=1)
                                +Filter: (role = +'E'::bpchar)
              +->  Hash  (cost=40.49..40.49 rows=1249 width=27) (actual +time=16.000..16.000 rows=0 loops=1)
+
                    +->  Seq Scan on company j  (cost=0.00..40.49 rows=1249 +width=27) (actual time=0.000..0.000 rows=1249 loops=1)
Total +runtime: 781.000 ms
+ + +From pgsql-performance-owner@postgresql.org Mon Mar 7 06:33:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E04652A60 + for ; + Mon, 7 Mar 2005 06:32:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26487-04 + for ; + Mon, 7 Mar 2005 06:32:50 +0000 (GMT) +Received: from mails.tsinghua.edu.cn (mails.tsinghua.edu.cn [166.111.8.16]) + by svr1.postgresql.org (Postfix) with SMTP id A58A455CEE + for ; + Mon, 7 Mar 2005 06:32:48 +0000 (GMT) +Received: (eyou send program); Mon, 07 Mar 2005 14:26:18 +0800 +Message-ID: <310176778.01687@mails.tsinghua.edu.cn> +Received: from 162.105.246.5 by mails.tsinghua.edu.cn with HTTP; + Mon, 07 Mar 2005 14:26:18 +0800 +X-WebMAIL-MUA: [162.105.246.5] +From: "xsk" +To: pgsql-performance@postgresql.org +Date: Mon, 07 Mar 2005 14:26:18 +0800 +Reply-To: "xsk" +X-Priority: 3 +Subject: How to Partition? +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.968 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, MSGID_FROM_MTA_HEADER, PRIORITY_NO_NAME +X-Spam-Level: * +X-Archive-Number: 200503/88 +X-Sequence-Number: 10793 + +Hi, +I have been doing a project that modify the original codes for pg. +Now I feel very interesting in table or index partition. +And I have paid great attention to the discussion about that before, and +got so much information. +Now I have some ideas about how to partition on pg. I want to mainly modify +the query part, or the storage part. Can any one give me some suggestions +for this? Thank you. + +Best regards +Alford + + + +From pgsql-hackers-win32-owner@postgresql.org Mon Mar 7 08:55:53 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E76FE563DE; + Mon, 7 Mar 2005 08:55:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73509-10; Mon, 7 Mar 2005 08:55:43 +0000 (GMT) +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B79356372; + Mon, 7 Mar 2005 08:55:42 +0000 (GMT) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id 34B918F282; Mon, 7 Mar 2005 09:55:42 +0100 (CET) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: [PERFORM] Help with tuning this query (with explain analyze + finally) +Date: Mon, 7 Mar 2005 09:55:41 +0100 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE476A46@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [pgsql-hackers-win32] [PERFORM] Help with tuning this query + (with explain analyze finally) +Thread-Index: AcUfd36Xd/3uGgxUQdK1AqtgI9jF6wDd6dXQ +From: "Magnus Hagander" +To: "Tom Lane" , "Ken Egervari" +Cc: , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.071 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/49 +X-Sequence-Number: 3007 + +> >> What platform is this on? It seems very strange/fishy=20 +> that all the=20 +> >> actual-time values are exact integral milliseconds. +>=20 +> > My machine is WinXP professional, athon xp 2100, but I get similar=20 +> > results on my Intel P4 3.0Ghz as well (which is also=20 +> running WinXP). =20 +> > Why do you ask? +>=20 +> Well, what it suggests is that gettimeofday() is only=20 +> returning a result good to the nearest millisecond. (Win32=20 +> hackers, does that sound right?) + +Yes. The gettimeofday() implementation (in +src/backend/port/gettimeofday.c). +Actually, in reality you don't even get millisecond resolution it seems +(after some reading up). More along the line of +10-millisecond-resolution. + +See for example +http://msdn.microsoft.com/msdnmag/issues/04/03/HighResolutionTimer/. + + + +> Most modern machines seem to have clocks that can count=20 +> elapsed time down to near the microsecond level. Anyone know=20 +> if it's possible to get such numbers out of Windows, or are=20 +> we stuck with milliseconds? + +There are, see link above. But it's definitly not easy. I don't think we +can just take the complete code from their exmaple (due to licensing). +We could go with the "middle way", but it has a couple of pitfalls. + +Do we need actual high precision time, or do we just need to be able to +get high precision differences? Getting the differences is fairly easy, +but if you need to "sync up" any drif then it becomes a bit more +difficult. + + +//Magnus + +From pgsql-hackers-win32-owner@postgresql.org Mon Mar 7 14:11:08 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 999A856475; + Mon, 7 Mar 2005 14:11:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68356-01; Mon, 7 Mar 2005 14:11:04 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CF7256419; + Mon, 7 Mar 2005 14:11:02 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j27EB63f022781; + Mon, 7 Mar 2005 09:11:06 -0500 (EST) +To: "Magnus Hagander" +Cc: "Ken Egervari" , + pgsql-performance@postgresql.org, pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] Help with tuning this query (with explain analyze + finally) +In-reply-to: <6BCB9D8A16AC4241919521715F4D8BCE476A46@algol.sollentuna.se> +References: <6BCB9D8A16AC4241919521715F4D8BCE476A46@algol.sollentuna.se> +Comments: In-reply-to "Magnus Hagander" + message dated "Mon, 07 Mar 2005 09:55:41 +0100" +Date: Mon, 07 Mar 2005 09:11:05 -0500 +Message-ID: <22780.1110204665@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/50 +X-Sequence-Number: 3008 + +"Magnus Hagander" writes: +> Do we need actual high precision time, or do we just need to be able to +> get high precision differences? Getting the differences is fairly easy, +> but if you need to "sync up" any drif then it becomes a bit more +> difficult. + +You're right, we only care about differences not absolute time. If +there's something like a microseconds-since-bootup counter, it would +be fine. + + regards, tom lane + +From pgsql-hackers-win32-owner@postgresql.org Mon Mar 7 14:38:55 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E11056382; + Mon, 7 Mar 2005 14:36:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74651-06; Mon, 7 Mar 2005 14:36:42 +0000 (GMT) +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F90A5561A; + Mon, 7 Mar 2005 14:36:41 +0000 (GMT) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id 02F868F283; Mon, 7 Mar 2005 15:36:43 +0100 (CET) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: [PERFORM] Help with tuning this query (with explain analyze + finally) +Date: Mon, 7 Mar 2005 15:36:42 +0100 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE476A60@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [pgsql-hackers-win32] [PERFORM] Help with tuning this query + (with explain analyze finally) +Thread-Index: AcUjH4Z2FEYk18/hQCWbVe42XvFtNgAAy6/w +From: "Magnus Hagander" +To: "Tom Lane" +Cc: "Ken Egervari" , , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.071 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/51 +X-Sequence-Number: 3009 + +> > Do we need actual high precision time, or do we just need=20 +> to be able=20 +> > to get high precision differences? Getting the differences=20 +> is fairly=20 +> > easy, but if you need to "sync up" any drif then it becomes=20 +> a bit more=20 +> > difficult. +>=20 +> You're right, we only care about differences not absolute=20 +> time. If there's something like a microseconds-since-bootup=20 +> counter, it would be fine. + +There is. I beleive QueryPerformanceCounter has sub-mirosecond +resolution. + +Can we just replace gettimeofday() with a version that's basically: +if (never_run_before) + GetSystemTime() and get current timer for baseline. +now =3D baseline + current timer - baseline timer; +return now; + + +Or do we need to make changes at the points where the function is +actually called? + + +//Magnus + +From pgsql-hackers-win32-owner@postgresql.org Mon Mar 7 14:45:57 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1EB5156493; + Mon, 7 Mar 2005 14:45:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77458-07; Mon, 7 Mar 2005 14:45:34 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 12D7A56499; + Mon, 7 Mar 2005 14:45:33 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j27Ejbab023087; + Mon, 7 Mar 2005 09:45:37 -0500 (EST) +To: "Magnus Hagander" +Cc: "Ken Egervari" , + pgsql-performance@postgresql.org, pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] Help with tuning this query (with explain analyze + finally) +In-reply-to: <6BCB9D8A16AC4241919521715F4D8BCE476A60@algol.sollentuna.se> +References: <6BCB9D8A16AC4241919521715F4D8BCE476A60@algol.sollentuna.se> +Comments: In-reply-to "Magnus Hagander" + message dated "Mon, 07 Mar 2005 15:36:42 +0100" +Date: Mon, 07 Mar 2005 09:45:37 -0500 +Message-ID: <23086.1110206737@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/52 +X-Sequence-Number: 3010 + +"Magnus Hagander" writes: +> There is. I beleive QueryPerformanceCounter has sub-mirosecond +> resolution. + +> Can we just replace gettimeofday() with a version that's basically: + +No, because it's also used for actual time-of-day calls. It'd be +necessary to hack executor/instrument.c in particular. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 7 14:49:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F2C5B56493 + for ; + Mon, 7 Mar 2005 14:46:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78207-05 + for ; + Mon, 7 Mar 2005 14:46:40 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.192]) + by svr1.postgresql.org (Postfix) with ESMTP id B1C9756492 + for ; + Mon, 7 Mar 2005 14:46:35 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id a41so1077870rng + for ; + Mon, 07 Mar 2005 06:46:39 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type; + b=nNfhARhtvK0iWuRluXQz5R2IBYCmSVO3vM5UPGuGh0a7FtkQdP9fMNVEq28a66aVb39esa7rELSgfYP7sDTNp0xzS48kbiwshHcUTYSNPo1WO1KvXttdI8ayU5ULPRJyPURurD8fEZNwRJFIPWPdYU59f0mO67dTVQ9r7I0qtKA= +Received: by 10.38.90.65 with SMTP id n65mr198657rnb; + Mon, 07 Mar 2005 06:46:39 -0800 (PST) +Received: by 10.38.24.6 with HTTP; Mon, 7 Mar 2005 06:46:38 -0800 (PST) +Message-ID: <156a90fe050307064678d5a6e9@mail.gmail.com> +Date: Mon, 7 Mar 2005 14:46:38 +0000 +From: +Reply-To: +To: Postgres - Performance +Subject: Tuning, configuration for 7.3.5 on a Sun E4500 +Mime-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_1042_8766129.1110206798950" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.202 tagged_above=0 required=5 tests=NO_REAL_NAME, + RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/93 +X-Sequence-Number: 10798 + +------=_Part_1042_8766129.1110206798950 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +Env: Sun E4500 with 8 gig of RAM in total. Database is stored +locally (not on a network storage devise). A copy of the +postgresql.conf file is attached. + +When running queries we are experiencing much bigger result times than +anticipated. + +Attached is a copy of our postgresql.conf file and of our the table +definitions and row counts. + +Below is an example of SQL and the explain plans. + +Any help/pointers/tips/etc. for getting this speed up would be great!! + +Cheers + + +SELECT C.component_id, I.cli, + BL.ncos_value, BL.description, + SG.switch_group_code, SG.servcom_name, + S.description AS status, + RC.description AS process_status, + OT.description AS order_type, + P.party_name, + RDCR.consumer_ref AS consumer_ref, + C.raised_dtm AS created_dtm, + (SELECT dtm FROM orders.communication WHERE +component_id = C.component_id ORDER BY dtm DESC LIMIT 1) AS status_dtm + FROM (SELECT * FROM parties.party WHERE +party_id = 143 AND is_active = true) P + JOIN orders.commercial_order CO ON +CO.party_id = P.party_id + JOIN (SELECT raised_dtm, component_id, +last_supplier_status, component_type_id, current_status_id_fr, +commercial_order_id FROM orders.component WHERE raised_dtm BETWEEN +'2003-01-01 00:00:00'::timestamp AND '2005-01-01 23:59:59'::timestamp +AND component_type_id IN (3, 2, 1)) C ON C.commercial_order_id = +CO.commercial_order_id + JOIN (SELECT * FROM orders.ida WHERE cli IS +NOT NULL ) I ON C.component_id = I.component_id + --Get the consumer reference if there is one + LEFT JOIN parties.consumer_ref RDCR ON +CO.consumer_ref = RDCR.consumer_ref_id + --May or may not have barring level or ncos +dependant on the order type + LEFT JOIN line_configs.ida_barring_level BL +ON I.ida_barring_level_id = BL.ida_barring_level_id + LEFT JOIN line_configs.switch_group SG ON +I.switchgroup_id = SG.switch_group_id + --Get the order type + JOIN business_rules.component_type CT ON +C.component_type_id = CT.component_type_id + JOIN business_rules.order_type OT ON +OT.order_type_id = CT.order_type_id + --Get the status + LEFT JOIN orders.status S ON S.status_id = +C.current_status_id_fr + --Get the process status + LEFT JOIN orders.response_code RC ON +RC.response_code_id = C.last_supplier_status + + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + + Hash Join (cost=18.02..16067.46 rows=1158 width=277) (actual +time=639100.57..957020.42 rows=34638 loops=1) + Hash Cond: ("outer".last_supplier_status = "inner".response_code_id) + -> Hash Join (cost=9.29..16038.49 rows=1158 width=218) (actual +time=639084.27..937250.67 rows=34638 loops=1) + Hash Cond: ("outer".current_status_id_fr = "inner".status_id) + -> Hash Join (cost=8.17..16017.14 rows=1158 width=197) +(actual time=639083.19..931508.95 rows=34638 loops=1) + Hash Cond: ("outer".order_type_id = "inner".order_type_id) + -> Hash Join (cost=6.99..15995.69 rows=1158 +width=180) (actual time=639082.01..926146.92 rows=34638 loops=1) + Hash Cond: ("outer".component_type_id = +"inner".component_type_id) + -> Hash Join (cost=5.47..15973.91 rows=1158 +width=172) (actual time=639080.29..921574.75 rows=34638 loops=1) + Hash Cond: ("outer".switchgroup_id = +"inner".switch_group_id) + -> Hash Join (cost=1.49..15949.66 +rows=1158 width=147) (actual time=639074.90..917437.55 rows=34638 +loops=1) + Hash Cond: +("outer".ida_barring_level_id = "inner".ida_barring_level_id) + -> Merge Join (cost=0.00..15927.90 +rows=1158 width=112) (actual time=639073.24..914042.15 rows=34638 +loops=1) + Merge Cond: +("outer".consumer_ref = "inner".consumer_ref_id) + -> Nested Loop +(cost=0.00..2630554.06 rows=1158 width=91) (actual +time=639072.57..909395.62 rows=34638 loops=1) + -> Nested Loop +(cost=0.00..2626789.68 rows=1244 width=66) (actual +time=639053.64..902100.16 rows=34638 loops=1) + -> Nested Loop +(cost=0.00..2599576.29 rows=7041 width=38) (actual +time=2073.94..891860.92 rows=46376 loops=1) + Join Filter: +("outer".party_id = "inner".party_id) + -> Index +Scan using commercial_order_consumer_ref_ix on commercial_order co +(cost=0.00..19499.42 rows=725250 width=12) (actual time=8.62..30310.16 +rows=725250 loops=1) + -> Seq Scan +on party (cost=0.00..3.54 rows=1 width=26) (actual time=0.62..1.16 +rows=1 loops=725250) + Filter: +((party_id = 143) AND (is_active = true)) + -> Index Scan +using component_commercial_order_id_ix on component (cost=0.00..3.85 +rows=1 width=28) (actual time=0.17..0.18 rows=1 loops=46376) + Index Cond: +(component.commercial_order_id = "outer".commercial_order_id) + Filter: +((raised_dtm >= '2003-01-01 00:00:00'::timestamp without time zone) +AND (raised_dtm <= '2005-01-01 23:59:59'::timestamp without time zone) +AND ((component_type_id = 3) OR (component_type_id = 2) OR +(component_type_id = 1))) + -> Index Scan using +ida_pkey on ida (cost=0.00..3.01 rows=1 width=25) (actual +time=0.12..0.14 rows=1 loops=34638) + Index Cond: +("outer".component_id = ida.component_id) + Filter: (cli IS NOT NULL) + -> Index Scan using +consumer_ref_pk on consumer_ref rdcr (cost=0.00..24.31 rows=937 +width=21) (actual time=0.48..0.48 rows=1 loops=1) + -> Hash (cost=1.39..1.39 rows=39 +width=35) (actual time=1.07..1.07 rows=0 loops=1) + -> Seq Scan on +ida_barring_level bl (cost=0.00..1.39 rows=39 width=35) (actual +time=0.07..0.76 rows=39 loops=1) + -> Hash (cost=3.59..3.59 rows=159 +width=25) (actual time=4.54..4.54 rows=0 loops=1) + -> Seq Scan on switch_group sg +(cost=0.00..3.59 rows=159 width=25) (actual time=0.09..3.13 rows=159 +loops=1) + -> Hash (cost=1.41..1.41 rows=41 width=8) +(actual time=0.90..0.90 rows=0 loops=1) + -> Seq Scan on component_type ct +(cost=0.00..1.41 rows=41 width=8) (actual time=0.08..0.64 rows=41 +loops=1) + -> Hash (cost=1.15..1.15 rows=15 width=17) (actual +time=0.43..0.43 rows=0 loops=1) + -> Seq Scan on order_type ot (cost=0.00..1.15 +rows=15 width=17) (actual time=0.08..0.31 rows=15 loops=1) + -> Hash (cost=1.09..1.09 rows=9 width=21) (actual +time=0.29..0.29 rows=0 loops=1) + -> Seq Scan on status s (cost=0.00..1.09 rows=9 +width=21) (actual time=0.08..0.22 rows=9 loops=1) + -> Hash (cost=7.99..7.99 rows=299 width=59) (actual +time=8.69..8.69 rows=0 loops=1) + -> Seq Scan on response_code rc (cost=0.00..7.99 rows=299 +width=59) (actual time=0.16..5.94 rows=299 loops=1) + SubPlan + -> Limit (cost=21.23..21.23 rows=1 width=8) (actual +time=0.45..0.46 rows=1 loops=34638) + -> Sort (cost=21.23..21.27 rows=16 width=8) (actual +time=0.44..0.44 rows=1 loops=34638) + Sort Key: dtm + -> Index Scan using communication_component_id_ix on +communication (cost=0.00..20.90 rows=16 width=8) (actual +time=0.12..0.14 rows=1 loops=34638) + Index Cond: (component_id = $0) + Total runtime: 957091.40 msec +(47 rows) + + + +SELECT raised_dtm, component_id, last_supplier_status, +component_type_id, current_status_id_fr, commercial_order_id FROM +orders.component WHERE raised_dtm BETWEEN '2003-01-01 +00:00:00'::timestamp AND '2005-01-01 23:59:59'::timestamp AND +component_type_id IN (3, 2, 1) + + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using component_raised_dtm_ix on component +(cost=0.00..17442.38 rows=128571 width=28) (actual time=1.04..20781.05 +rows=307735 loops=1) + Index Cond: ((raised_dtm >= '2003-01-01 00:00:00'::timestamp +without time zone) AND (raised_dtm <= '2005-01-01 23:59:59'::timestamp +without time zone)) + Filter: ((component_type_id = 3) OR (component_type_id = 2) OR +(component_type_id = 1)) + Total runtime: 21399.79 msec +(4 rows) + + +SELECT * FROM orders.ida WHERE cli IS NOT NULL; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------- + Seq Scan on ida (cost=0.00..12420.24 rows=677424 width=25) (actual +time=0.15..16782.27 rows=677415 loops=1) + Filter: (cli IS NOT NULL) + Total runtime: 17885.80 msec +(3 rows) + +------=_Part_1042_8766129.1110206798950 +Content-Type: text/plain; name="postgresql.conf" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: attachment; filename="postgresql.conf" + +# +# PostgreSQL configuration file +# ----------------------------- +# +# This file consists of lines of the form: +# +# name =3D value +# +# (The '=3D' is optional.) White space may be used. Comments are introduced +# with '#' anywhere on a line. The complete list of option names and +# allowed values can be found in the PostgreSQL documentation. The +# commented-out settings shown in this file represent the default values. +# +# Any option can also be given as a command line switch to the +# postmaster, e.g. 'postmaster -c log_connections=3Don'. Some options +# can be changed at run-time with the 'SET' SQL command. +# +# This file is read on postmaster startup and when the postmaster +# receives a SIGHUP. If you edit the file on a running system, you have=20 +# to SIGHUP the postmaster for the changes to take effect, or use=20 +# "pg_ctl reload". + + +#=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + +# +#=09Connection Parameters +# +tcpip_socket =3D true +#ssl =3D false + +max_connections =3D100=20 +superuser_reserved_connections =3D10=20 + +port =3D 5432=20 +#hostname_lookup =3D false +#show_source_port =3D false + +#unix_socket_directory =3D '' +#unix_socket_group =3D '' +#unix_socket_permissions =3D 0777=09# octal + +#virtual_host =3D '' + +#krb_server_keyfile =3D '' + + +# +#=09Shared Memory Size +# +#shared_buffers =3D 64=09=09# min max_connections*2 or 16, 8KB each +##2005-01-26 1600 VBG: Changed shared_buffers from 64 to 1000 +shared_buffers =3D 10000 # min max_connections*2 or 16, 8KB each + +#max_fsm_relations =3D 1000=09# min 10, fsm is free space map, ~40 bytes +#max_fsm_pages =3D 10000=09=09# min 1000, fsm is free space map, ~6 bytes +#max_locks_per_transaction =3D 64=09# min 10 +#wal_buffers =3D 8=09=09# min 4, typically 8KB each + +# +#=09Non-shared Memory Sizes +# +sort_mem =3D 4096=09=09# min 64, size in KB +#vacuum_mem =3D 8192=09=09# min 1024, size in KB + + +# +#=09Write-ahead log (WAL) +# +#checkpoint_segments =3D 3=09# in logfile segments, min 1, 16MB each +#checkpoint_timeout =3D 300=09# range 30-3600, in seconds +# +#commit_delay =3D 0=09=09# range 0-100000, in microseconds +#commit_siblings =3D 5=09=09# range 1-1000 +# +#fsync =3D true +#wal_sync_method =3D fsync=09# the default varies across platforms: +#=09=09=09=09# fsync, fdatasync, open_sync, or open_datasync +#wal_debug =3D 0=09=09=09# range 0-16 + + +# +#=09Optimizer Parameters +# +#enable_seqscan =3D true +#enable_indexscan =3D true +#enable_tidscan =3D true +#enable_sort =3D true +#enable_nestloop =3D true +#enable_mergejoin =3D true +#enable_hashjoin =3D true + +effective_cache_size =3D 100000=09# typically 8KB each +#random_page_cost =3D 4=09=09# units are one sequential page fetch cost +#cpu_tuple_cost =3D 0.01=09=09# (same) +#cpu_index_tuple_cost =3D 0.001=09# (same) +#cpu_operator_cost =3D 0.0025=09# (same) + +#default_statistics_target =3D 10=09# range 1-1000 + +# +#=09GEQO Optimizer Parameters +# +#geqo =3D true +#geqo_selection_bias =3D 2.0=09# range 1.5-2.0 +#geqo_threshold =3D 11 +#geqo_pool_size =3D 0=09=09# default based on tables in statement,=20 +=09=09=09=09# range 128-1024 +#geqo_effort =3D 1 +#geqo_generations =3D 0 +#geqo_random_seed =3D -1=09=09# auto-compute seed + + +# +#=09Message display +# +#server_min_messages =3D notice=09# Values, in order of decreasing detail: +=09=09=09=09# debug5, debug4, debug3, debug2, debug1, +=09=09=09=09# info, notice, warning, error, log, fatal, +=09=09=09=09# panic +#client_min_messages =3D notice=09# Values, in order of decreasing detail: +=09=09=09=09# debug5, debug4, debug3, debug2, debug1, +=09=09=09=09# log, info, notice, warning, error +#silent_mode =3D false + +#log_connections =3D false +#log_pid =3D false +#log_statement =3D false +#log_duration =3D false +log_timestamp =3D true=20 + +#log_min_error_statement =3D panic # Values in order of increasing severity= +: +=09=09=09=09 # debug5, debug4, debug3, debug2, debug1, +=09=09=09=09 # info, notice, warning, error, panic(off) + +#debug_print_parse =3D false +#debug_print_rewritten =3D false +#debug_print_plan =3D false +#debug_pretty_print =3D false + +#explain_pretty_print =3D true + +# requires USE_ASSERT_CHECKING +#debug_assertions =3D true + + +# +#=09Syslog +# +#syslog =3D 0=09=09=09# range 0-2 +#syslog_facility =3D 'LOCAL0' +#syslog_ident =3D 'postgres' + + +# +#=09Statistics +# +#show_parser_stats =3D false +#show_planner_stats =3D false +#show_executor_stats =3D false +#show_statement_stats =3D false + +# requires BTREE_BUILD_STATS +#show_btree_build_stats =3D false + + +# +#=09Access statistics collection +# +#stats_start_collector =3D true +#stats_reset_on_server_start =3D true +#stats_command_string =3D false +#stats_row_level =3D false +#stats_block_level =3D false + + +# +#=09Lock Tracing +# +#trace_notify =3D false + +# requires LOCK_DEBUG +#trace_locks =3D false +#trace_userlocks =3D false +#trace_lwlocks =3D false +#debug_deadlocks =3D false +#trace_lock_oidmin =3D 16384 +#trace_lock_table =3D 0 + + +# +#=09Misc +# +#autocommit =3D true +#dynamic_library_path =3D '$libdir' +#search_path =3D '$user,public' +#datestyle =3D 'iso, us' +#timezone =3D unknown=09=09# actually, defaults to TZ environment setting +#australian_timezones =3D false +#client_encoding =3D sql_ascii=09# actually, defaults to database encoding +#authentication_timeout =3D 60=09# 1-600, in seconds +#deadlock_timeout =3D 1000=09# in milliseconds +#default_transaction_isolation =3D 'read committed' +#max_expr_depth =3D 10000=09=09# min 10 +#max_files_per_process =3D 1000=09# min 25 +#password_encryption =3D true +#sql_inheritance =3D true +#transform_null_equals =3D false +#statement_timeout =3D 0=09=09# 0 is disabled, in milliseconds +#db_user_namespace =3D false +=20 + + +# +#=09Locale settings +# +# (initialized by initdb -- may be changed) +LC_MESSAGES =3D 'C' +LC_MONETARY =3D 'C' +LC_NUMERIC =3D 'C' +LC_TIME =3D 'C' + +------=_Part_1042_8766129.1110206798950 +Content-Type: application/octet-stream; name="tables.sql" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="tables.sql" + +LS1Sb3cgY291bnQgPSAxMDMKQ1JFQVRFIFRBQkxFICJwYXJ0aWVzIi4icGFydHkiICgKICAicGFy +dHlfaWQiIFNFUklBTCwKICAicGFyZW50X3BhcnR5X2lkIiBJTlRFR0VSLAogICJwYXJ0eV90eXBl +IiBURVhUIE5PVCBOVUxMLAogICJwYXJ0eV9uYW1lIiBURVhUIE5PVCBOVUxMLAogICJwYXJ0eV9w +YXRoIiBURVhULAogICJpc19hY3RpdmUiIEJPT0xFQU4gREVGQVVMVCB0cnVlIE5PVCBOVUxMLAog +ICJwYXJ0eV91c2VzX3NwaWQiIFRFWFQsCiAgQ09OU1RSQUlOVCAicGFydHlfcGsiIFBSSU1BUlkg +S0VZKCJwYXJ0eV9pZCIpLAogIENPTlNUUkFJTlQgIm5vX3NlbGZfcGFyZW50aW5nX2NrIiBDSEVD +SyAocGFydHlfaWQgPD4gcGFyZW50X3BhcnR5X2lkKSwKICBDT05TVFJBSU5UICJwYXJ0eV9pZF9j +ayIgQ0hFQ0sgKHBhcnR5X2lkID4gMCksCiAgQ09OU1RSQUlOVCAicGFydHlfdHlwZV9jayIgQ0hF +Q0sgKCgoKHBhcnR5X3R5cGUgPSAnQyc6OnRleHQpIE9SIChwYXJ0eV90eXBlID0gJ1InOjp0ZXh0 +KSkgT1IgKHBhcnR5X3R5cGUgPSAnUyc6OnRleHQpKSBPUiAocGFydHlfdHlwZSA9ICdXJzo6dGV4 +dCkpLAogIENPTlNUUkFJTlQgInBhcnR5X3BhcmVudF9wYXJ0eV9pZF9mayIgRk9SRUlHTiBLRVkg +KCJwYXJlbnRfcGFydHlfaWQiKQogICAgUkVGRVJFTkNFUyAicGFydGllcyIuInBhcnR5IigicGFy +dHlfaWQiKQogICAgT04gREVMRVRFIFJFU1RSSUNUCiAgICBPTiBVUERBVEUgUkVTVFJJQ1QKICAg +IE5PVCBERUZFUlJBQkxFCikgV0lUSCBPSURTOwoKQ1JFQVRFIElOREVYICJwYXJ0eV9wYXJlbnRf +cGFydHlfaWRfaXgiIE9OICJwYXJ0aWVzIi4icGFydHkiClVTSU5HIGJ0cmVlICgicGFyZW50X3Bh +cnR5X2lkIik7CgpDUkVBVEUgSU5ERVggInBhcnR5X3BhcnR5X3BhdGhfaXgiIE9OICJwYXJ0aWVz +Ii4icGFydHkiClVTSU5HIGJ0cmVlICgicGFydHlfcGF0aCIpOwoKQ1JFQVRFIFVOSVFVRSBJTkRF +WCAicGFydHlfcGFydHluYW1lX3VpeCIgT04gInBhcnRpZXMiLiJwYXJ0eSIKVVNJTkcgYnRyZWUg +KCJwZ19jYXRhbG9nIi4ibG93ZXIiKCJwYXJ0eV9uYW1lIikpOwoKLS1Sb3cgY291bnQgPSA3MjUy +NTAKQ1JFQVRFIFRBQkxFICJvcmRlcnMiLiJjb21tZXJjaWFsX29yZGVyIiAoCiAgImNvbW1lcmNp +YWxfb3JkZXJfaWQiIFNFUklBTCwKICAiY29tbWVyY2lhbF9vcmRlcl90eXBlX2lkIiBJTlRFR0VS +IE5PVCBOVUxMLAogICJwYXJ0eV9pZCIgSU5URUdFUiBOT1QgTlVMTCwKICAidXNyX2lkIiBJTlRF +R0VSIE5PVCBOVUxMLAogICJyYWlzZWRfZHRtIiBUSU1FU1RBTVAoMCkgV0lUSE9VVCBUSU1FIFpP +TkUgREVGQVVMVCAoJ25vdyc6OnRleHQpOjp0aW1lc3RhbXAgd2l0aCB0aW1lIHpvbmUgTk9UIE5V +TEwsCiAgInN0YXR1c19pZCIgSU5URUdFUiwKICAiY29uc3VtZXJfcmVmIiBJTlRFR0VSLAogIENP +TlNUUkFJTlQgImNvbW1lcmNpYWxfb3JkZXJfcGsiIFBSSU1BUlkgS0VZKCJjb21tZXJjaWFsX29y +ZGVyX2lkIiksCiAgQ09OU1RSQUlOVCAiY29tbWVyY2lhbF9vcmRlcl9jb21tZXJjaWFsX29yZGVy +X2lkX2NrIiBDSEVDSyAoY29tbWVyY2lhbF9vcmRlcl9pZCA+PSAxKSwKICBDT05TVFJBSU5UICJj +b21tZXJjaWFsX29yZGVyX3BhcnR5X2lkX2ZrIiBGT1JFSUdOIEtFWSAoInBhcnR5X2lkIikKICAg +IFJFRkVSRU5DRVMgInBhcnRpZXMiLiJwYXJ0eSIoInBhcnR5X2lkIikKICAgIE9OIERFTEVURSBS +RVNUUklDVAogICAgT04gVVBEQVRFIFJFU1RSSUNUCiAgICBOT1QgREVGRVJSQUJMRSwKICBDT05T +VFJBSU5UICJjb21tZXJjaWFsX29yZGVyX3N0YXR1c19mayIgRk9SRUlHTiBLRVkgKCJzdGF0dXNf +aWQiKQogICAgUkVGRVJFTkNFUyAib3JkZXJzIi4ic3RhdHVzIigic3RhdHVzX2lkIikKICAgIE9O +IERFTEVURSBSRVNUUklDVAogICAgT04gVVBEQVRFIFJFU1RSSUNUCiAgICBOT1QgREVGRVJSQUJM +RSwKICBDT05TVFJBSU5UICJjb21tZXJjaWFsX29yZGVyX3R5cGVfY29tbWVyY2lhbF9vcmRlciIg +Rk9SRUlHTiBLRVkgKCJjb21tZXJjaWFsX29yZGVyX3R5cGVfaWQiKQogICAgUkVGRVJFTkNFUyAi +YnVzaW5lc3NfcnVsZXMiLiJjb21tZXJjaWFsX29yZGVyX3R5cGUiKCJjb21tZXJjaWFsX29yZGVy +X3R5cGVfaWQiKQogICAgT04gREVMRVRFIFJFU1RSSUNUCiAgICBPTiBVUERBVEUgUkVTVFJJQ1QK +ICAgIE5PVCBERUZFUlJBQkxFLAogIENPTlNUUkFJTlQgImNvbW1lcmNpYWxfb3JkZXJfdXNyX2lk +X2ZrIiBGT1JFSUdOIEtFWSAoInVzcl9pZCIpCiAgICBSRUZFUkVOQ0VTICJ1c2VycyIuInVzciIo +InVzcl9pZCIpCiAgICBPTiBERUxFVEUgUkVTVFJJQ1QKICAgIE9OIFVQREFURSBSRVNUUklDVAog +ICAgTk9UIERFRkVSUkFCTEUKKSBXSVRIIE9JRFM7CgpDUkVBVEUgSU5ERVggImNvbW1lcmNpYWxf +b3JkZXJfY29uc3VtZXJfcmVmX2l4IiBPTiAib3JkZXJzIi4iY29tbWVyY2lhbF9vcmRlciIKVVNJ +TkcgYnRyZWUgKCJjb25zdW1lcl9yZWYiKTsKCkNSRUFURSBJTkRFWCAiY29tbWVyY2lhbF9vcmRl +cl9wYXJ0eV9pZF9peCIgT04gIm9yZGVycyIuImNvbW1lcmNpYWxfb3JkZXIiClVTSU5HIGJ0cmVl +ICgicGFydHlfaWQiKTsKCkNSRUFURSBJTkRFWCAiY29tbWVyY2lhbF9vcmRlcl9yYWlzZWRfZHRt +X2l4IiBPTiAib3JkZXJzIi4iY29tbWVyY2lhbF9vcmRlciIKVVNJTkcgYnRyZWUgKCJyYWlzZWRf +ZHRtIik7CgpDUkVBVEUgSU5ERVggImNvbW1lcmNpYWxfb3JkZXJfc3RhdHVzX2lkX2l4IiBPTiAi +b3JkZXJzIi4iY29tbWVyY2lhbF9vcmRlciIKVVNJTkcgYnRyZWUgKCJzdGF0dXNfaWQiKTsKCkNS +RUFURSBJTkRFWCAiY29tbWVyY2lhbF9vcmRlcl90eXBlX2NvbW1lcmNpYWxfb3JkZXJfaXgiIE9O +ICJvcmRlcnMiLiJjb21tZXJjaWFsX29yZGVyIgpVU0lORyBidHJlZSAoImNvbW1lcmNpYWxfb3Jk +ZXJfdHlwZV9pZCIpOwoKQ1JFQVRFIElOREVYICJjb21tZXJjaWFsX29yZGVyX3Vzcl9pZF9peCIg +T04gIm9yZGVycyIuImNvbW1lcmNpYWxfb3JkZXIiClVTSU5HIGJ0cmVlICgidXNyX2lkIik7Cgot +LVJvdyBjb3VudCA9NzI3NzI2CkNSRUFURSBUQUJMRSAib3JkZXJzIi4iY29tcG9uZW50IiAoCiAg +ImNvbXBvbmVudF9pZCIgU0VSSUFMLAogICJkZXBlbmRzX29uX2NvbXBvbmVudF9pZCIgSU5URUdF +UiwKICAiY29tbWVyY2lhbF9vcmRlcl9pZCIgSU5URUdFUiBOT1QgTlVMTCwKICAiY29tcG9uZW50 +X3R5cGVfaWQiIElOVEVHRVIgTk9UIE5VTEwsCiAgInJhaXNlZF9kdG0iIFRJTUVTVEFNUCgwKSBX +SVRIT1VUIFRJTUUgWk9ORSBERUZBVUxUICgnbm93Jzo6dGV4dCk6OnRpbWVzdGFtcCB3aXRoIHRp +bWUgem9uZSBOT1QgTlVMTCwKICAiY3VycmVudF9zdGF0dXNfaWRfZnIiIElOVEVHRVIsCiAgInVz +cl9pZCIgSU5URUdFUiBOT1QgTlVMTCwKICAibGFzdF9zdXBwbGllcl9zdGF0dXMiIElOVEVHRVIs +CiAgQ09OU1RSQUlOVCAiY29tcG9uZW50X3BrIiBQUklNQVJZIEtFWSgiY29tcG9uZW50X2lkIiks +CiAgQ09OU1RSQUlOVCAiY29tcG9uZW50X2NvbXBvbmVudF9pZF9jayIgQ0hFQ0sgKGNvbXBvbmVu +dF9pZCA+PSAxKSwKICBDT05TVFJBSU5UICJjb21wb25lbnRfYWZmZWN0c19jb21wb25lbnRfaWRf +ZmsiIEZPUkVJR04gS0VZICgiZGVwZW5kc19vbl9jb21wb25lbnRfaWQiKQogICAgUkVGRVJFTkNF +UyAib3JkZXJzIi4iY29tcG9uZW50IigiY29tcG9uZW50X2lkIikKICAgIE9OIERFTEVURSBSRVNU +UklDVAogICAgT04gVVBEQVRFIFJFU1RSSUNUCiAgICBOT1QgREVGRVJSQUJMRSwKICBDT05TVFJB +SU5UICJjb21wb25lbnRfY29tbWVyY2lhbF9vcmRlcl9pZF9mayIgRk9SRUlHTiBLRVkgKCJjb21t +ZXJjaWFsX29yZGVyX2lkIikKICAgIFJFRkVSRU5DRVMgIm9yZGVycyIuImNvbW1lcmNpYWxfb3Jk +ZXIiKCJjb21tZXJjaWFsX29yZGVyX2lkIikKICAgIE9OIERFTEVURSBOTyBBQ1RJT04KICAgIE9O +IFVQREFURSBOTyBBQ1RJT04KICAgIE5PVCBERUZFUlJBQkxFLAogIENPTlNUUkFJTlQgImNvbXBv +bmVudF9jdXJyZW50X3N0YXR1c19mayIgRk9SRUlHTiBLRVkgKCJjdXJyZW50X3N0YXR1c19pZF9m +ciIpCiAgICBSRUZFUkVOQ0VTICJvcmRlcnMiLiJzdGF0dXMiKCJzdGF0dXNfaWQiKQogICAgT04g +REVMRVRFIE5PIEFDVElPTgogICAgT04gVVBEQVRFIE5PIEFDVElPTgogICAgTk9UIERFRkVSUkFC +TEUsCiAgQ09OU1RSQUlOVCAiY29tcG9uZW50X3N1cHBsaWVyX2NvZGVfZmsiIEZPUkVJR04gS0VZ +ICgibGFzdF9zdXBwbGllcl9zdGF0dXMiKQogICAgUkVGRVJFTkNFUyAib3JkZXJzIi4icmVzcG9u +c2VfY29kZSIoInJlc3BvbnNlX2NvZGVfaWQiKQogICAgT04gREVMRVRFIFJFU1RSSUNUCiAgICBP +TiBVUERBVEUgUkVTVFJJQ1QKICAgIE5PVCBERUZFUlJBQkxFLAogIENPTlNUUkFJTlQgImNvbXBv +bmVudF90eXBlX2ZrIiBGT1JFSUdOIEtFWSAoImNvbXBvbmVudF90eXBlX2lkIikKICAgIFJFRkVS +RU5DRVMgImJ1c2luZXNzX3J1bGVzIi4iY29tcG9uZW50X3R5cGUiKCJjb21wb25lbnRfdHlwZV9p +ZCIpCiAgICBPTiBERUxFVEUgUkVTVFJJQ1QKICAgIE9OIFVQREFURSBSRVNUUklDVAogICAgTk9U +IERFRkVSUkFCTEUsCiAgQ09OU1RSQUlOVCAiY29tcG9uZW50X3Vzcl9pZF9mayIgRk9SRUlHTiBL +RVkgKCJ1c3JfaWQiKQogICAgUkVGRVJFTkNFUyAidXNlcnMiLiJ1c3IiKCJ1c3JfaWQiKQogICAg +T04gREVMRVRFIFJFU1RSSUNUCiAgICBPTiBVUERBVEUgUkVTVFJJQ1QKICAgIE5PVCBERUZFUlJB +QkxFCikgV0lUSCBPSURTOwoKQ1JFQVRFIElOREVYICJjb21wb25lbnRfYWZmZWN0c19jb21wb25l +bnRfaWRfaXgiIE9OICJvcmRlcnMiLiJjb21wb25lbnQiClVTSU5HIGJ0cmVlICgiZGVwZW5kc19v +bl9jb21wb25lbnRfaWQiKTsKCkNSRUFURSBJTkRFWCAiY29tcG9uZW50X2NvbW1lcmNpYWxfb3Jk +ZXJfaWRfaXgiIE9OICJvcmRlcnMiLiJjb21wb25lbnQiClVTSU5HIGJ0cmVlICgiY29tbWVyY2lh +bF9vcmRlcl9pZCIpOwoKQ1JFQVRFIElOREVYICJjb21wb25lbnRfY3RpX2l4IiBPTiAib3JkZXJz +Ii4iY29tcG9uZW50IgpVU0lORyBidHJlZSAoImNvbXBvbmVudF90eXBlX2lkIik7CgpDUkVBVEUg +SU5ERVggImNvbXBvbmVudF9jdXJyZW50X3N0YXR1c19peCIgT04gIm9yZGVycyIuImNvbXBvbmVu +dCIKVVNJTkcgYnRyZWUgKCJjdXJyZW50X3N0YXR1c19pZF9mciIpOwoKQ1JFQVRFIElOREVYICJj +b21wb25lbnRfbGFzdF9zdXBwbGllcl9zdGF0dXNfaXgiIE9OICJvcmRlcnMiLiJjb21wb25lbnQi +ClVTSU5HIGJ0cmVlICgibGFzdF9zdXBwbGllcl9zdGF0dXMiKTsKCkNSRUFURSBJTkRFWCAiY29t +cG9uZW50X3JhaXNlZF9kdG1faXgiIE9OICJvcmRlcnMiLiJjb21wb25lbnQiClVTSU5HIGJ0cmVl +ICgicmFpc2VkX2R0bSIpOwoKQ1JFQVRFIElOREVYICJjb21wb25lbnRfdXNyX2lkX2l4IiBPTiAi +b3JkZXJzIi4iY29tcG9uZW50IgpVU0lORyBidHJlZSAoInVzcl9pZCIpOwoKLS1Sb3cgY291bnQg +PSA2Nzc0MjQKQ1JFQVRFIFRBQkxFICJvcmRlcnMiLiJpZGEiICgKICAiY29tcG9uZW50X2lkIiBJ +TlRFR0VSIE5PVCBOVUxMLAogICJjbGkiIFRFWFQsCiAgImlkYV9iYXJyaW5nX2xldmVsX2lkIiBJ +TlRFR0VSIE5PVCBOVUxMLAogICJzd2l0Y2hncm91cF9pZCIgSU5URUdFUiwKICBDT05TVFJBSU5U +ICJpZGFfcGtleSIgUFJJTUFSWSBLRVkoImNvbXBvbmVudF9pZCIpLAogIENPTlNUUkFJTlQgImlk +YV9iYXJyaW5nX2xldmVsX2lkX2ZrIiBGT1JFSUdOIEtFWSAoImlkYV9iYXJyaW5nX2xldmVsX2lk +IikKICAgIFJFRkVSRU5DRVMgImxpbmVfY29uZmlncyIuImlkYV9iYXJyaW5nX2xldmVsIigiaWRh +X2JhcnJpbmdfbGV2ZWxfaWQiKQogICAgT04gREVMRVRFIFJFU1RSSUNUCiAgICBPTiBVUERBVEUg +UkVTVFJJQ1QKICAgIE5PVCBERUZFUlJBQkxFLAogIENPTlNUUkFJTlQgImlkYV9jb21wb25lbnRf +aWRfZmsiIEZPUkVJR04gS0VZICgiY29tcG9uZW50X2lkIikKICAgIFJFRkVSRU5DRVMgIm9yZGVy +cyIuImNvbXBvbmVudCIoImNvbXBvbmVudF9pZCIpCiAgICBPTiBERUxFVEUgUkVTVFJJQ1QKICAg +IE9OIFVQREFURSBSRVNUUklDVAogICAgTk9UIERFRkVSUkFCTEUsCiAgQ09OU1RSQUlOVCAiaWRh +X3N3aXRjaGdyb3VwX2lkX2ZrIiBGT1JFSUdOIEtFWSAoInN3aXRjaGdyb3VwX2lkIikKICAgIFJF +RkVSRU5DRVMgImxpbmVfY29uZmlncyIuInN3aXRjaF9ncm91cCIoInN3aXRjaF9ncm91cF9pZCIp +CiAgICBPTiBERUxFVEUgUkVTVFJJQ1QKICAgIE9OIFVQREFURSBSRVNUUklDVAogICAgTk9UIERF +RkVSUkFCTEUKKSBXSVRIIE9JRFM7CgpDUkVBVEUgSU5ERVggImlkYV9ibF9pZF9peCIgT04gIm9y +ZGVycyIuImlkYSIKVVNJTkcgYnRyZWUgKCJpZGFfYmFycmluZ19sZXZlbF9pZCIpOwoKQ1JFQVRF +IElOREVYICJpZGFfY2xpX2l4IiBPTiAib3JkZXJzIi4iaWRhIgpVU0lORyBidHJlZSAoImNsaSIp +OwoKQ1JFQVRFIElOREVYICJpZGFfc2dfaWRfaXgiIE9OICJvcmRlcnMiLiJpZGEiClVTSU5HIGJ0 +cmVlICgic3dpdGNoZ3JvdXBfaWQiKTsKCi0tUm93IGNvdW50ID05MzcKQ1JFQVRFIFRBQkxFICJw +YXJ0aWVzIi4iY29uc3VtZXJfcmVmIiAoCiAgImNvbnN1bWVyX3JlZl9pZCIgU0VSSUFMLAogICJy +ZXRhaWxlcl9pZCIgSU5URUdFUiBOT1QgTlVMTCwKICAiY29uc3VtZXJfcmVmIiBURVhULAogICJp +c19hY3RpdmUiIEJPT0xFQU4gREVGQVVMVCAndCcgTk9UIE5VTEwsCiAgImNvbnN1bWVyX2lkIiBJ +TlRFR0VSLAogIENPTlNUUkFJTlQgImNvbnN1bWVyX3JlZl9wayIgUFJJTUFSWSBLRVkoImNvbnN1 +bWVyX3JlZl9pZCIpLAogIENPTlNUUkFJTlQgImNvbnN1bWVyX3JlZl9pZF9jayIgQ0hFQ0sgKGNv +bnN1bWVyX3JlZl9pZCA+IDApLAogIENPTlNUUkFJTlQgImNvbnN1bWVyX3JlZl9jb25zdW1lcl9p +ZCIgRk9SRUlHTiBLRVkgKCJjb25zdW1lcl9pZCIpCiAgICBSRUZFUkVOQ0VTICJwYXJ0aWVzIi4i +cGFydHkiKCJwYXJ0eV9pZCIpCiAgICBPTiBERUxFVEUgUkVTVFJJQ1QKICAgIE9OIFVQREFURSBS +RVNUUklDVAogICAgTk9UIERFRkVSUkFCTEUsCiAgQ09OU1RSQUlOVCAiY29uc3VtZXJfcmVmX3Jl +dGFpbGVyX2lkX2ZrIiBGT1JFSUdOIEtFWSAoInJldGFpbGVyX2lkIikKICAgIFJFRkVSRU5DRVMg +InBhcnRpZXMiLiJwYXJ0eSIoInBhcnR5X2lkIikKICAgIE9OIERFTEVURSBSRVNUUklDVAogICAg +T04gVVBEQVRFIFJFU1RSSUNUCiAgICBOT1QgREVGRVJSQUJMRQopIFdJVEggT0lEUzsKCkNSRUFU +RSBVTklRVUUgSU5ERVggImNvbnN1bWVyX3JlZl9pZF9yZWZfdWl4IiBPTiAicGFydGllcyIuImNv +bnN1bWVyX3JlZiIKVVNJTkcgYnRyZWUgKCJyZXRhaWxlcl9pZCIsICJjb25zdW1lcl9yZWYiKTsK +Ci0tUm93IGNvdW50ID0gMzkKQ1JFQVRFIFRBQkxFICJsaW5lX2NvbmZpZ3MiLiJpZGFfYmFycmlu +Z19sZXZlbCIgKAogICJpZGFfYmFycmluZ19sZXZlbF9pZCIgU0VSSUFMLAogICJkZXNjcmlwdGlv +biIgVEVYVCwKICAiaXNfYWN0aXZlIiBCT09MRUFOIERFRkFVTFQgdHJ1ZSBOT1QgTlVMTCwKICAi +bmNvc192YWx1ZSIgSU5URUdFUiBOT1QgTlVMTCwKICBDT05TVFJBSU5UICJpZGFfYmFycmluZ19s +ZXZlbF9uY29zX3ZhbHVlX2tleSIgVU5JUVVFKCJuY29zX3ZhbHVlIiksCiAgQ09OU1RSQUlOVCAi +aWRhX2JhcnJpbmdfbGV2ZWxfcGtleSIgUFJJTUFSWSBLRVkoImlkYV9iYXJyaW5nX2xldmVsX2lk +IiksCiAgQ09OU1RSQUlOVCAiaWRhX2JhcnJpbmdfbGV2ZWxfaWRfY2siIENIRUNLIChpZGFfYmFy +cmluZ19sZXZlbF9pZCA+IDApCikgV0lUSCBPSURTOwoKCi0tUm93IGNvdW50ID0gMTU5CkNSRUFU +RSBUQUJMRSAibGluZV9jb25maWdzIi4ic3dpdGNoX2dyb3VwIiAoCiAgInN3aXRjaF9ncm91cF9p +ZCIgU0VSSUFMLAogICJzZXJ2Y29tX25hbWUiIFRFWFQgTk9UIE5VTEwsCiAgInBhcnR5X2lkIiBJ +TlRFR0VSLAogICJpc19kZWZhdWx0IiBCT09MRUFOIERFRkFVTFQgJ0YnIE5PVCBOVUxMLAogICJz +d2l0Y2hfZ3JvdXBfbmFtZSIgVEVYVCBOT1QgTlVMTCwKICAic3dpdGNoX2dyb3VwX2NvZGUiIElO +VEVHRVIgTk9UIE5VTEwsCiAgImlzX2FjdGl2ZSIgQk9PTEVBTiBERUZBVUxUICdUJywKICAiY29u +c3VtZXJfYWNjZXNzIiBCT09MRUFOIERFRkFVTFQgZmFsc2UgTk9UIE5VTEwsCiAgQ09OU1RSQUlO +VCAic3dpdGNoX2dyb3VwX3BrIiBQUklNQVJZIEtFWSgic3dpdGNoX2dyb3VwX2lkIiksCiAgQ09O +U1RSQUlOVCAic3dpdGNoX2dyb3VwX3N3aXRjaF9ncm91cF9jb2RlX2tleSIgVU5JUVVFKCJzd2l0 +Y2hfZ3JvdXBfY29kZSIpLAogIENPTlNUUkFJTlQgInN3aXRjaF9ncm91cF9zd2l0Y2hfZ3JvdXBf +aWRfY2siIENIRUNLIChzd2l0Y2hfZ3JvdXBfaWQgPj0gMSksCiAgQ09OU1RSQUlOVCAic3dpdGNo +X2dyb3VwX3BhcnR5X2ZrIiBGT1JFSUdOIEtFWSAoInBhcnR5X2lkIikKICAgIFJFRkVSRU5DRVMg +InBhcnRpZXMiLiJwYXJ0eSIoInBhcnR5X2lkIikKICAgIE9OIERFTEVURSBSRVNUUklDVAogICAg +T04gVVBEQVRFIFJFU1RSSUNUCiAgICBOT1QgREVGRVJSQUJMRQopIFdJVEggT0lEUzsKCkNSRUFU +RSBJTkRFWCAic3dpdGNoX2dyb3VwX3BhcnR5X2l4IiBPTiAibGluZV9jb25maWdzIi4ic3dpdGNo +X2dyb3VwIgpVU0lORyBidHJlZSAoInBhcnR5X2lkIik7CgotLVJvdyBjb3VudCA9IDQxCkNSRUFU +RSBUQUJMRSAiYnVzaW5lc3NfcnVsZXMiLiJjb21wb25lbnRfdHlwZSIgKAogICJjb21wb25lbnRf +dHlwZV9pZCIgU0VSSUFMLAogICJwcm9kdWN0X2lkIiBJTlRFR0VSIE5PVCBOVUxMLAogICJvcmRl +cl90eXBlX2lkIiBJTlRFR0VSIE5PVCBOVUxMLAogICJpc19hY3RpdmUiIEJPT0xFQU4gREVGQVVM +VCAndCcgTk9UIE5VTEwsCiAgImFmZmVjdHNfcXVvdGEiIEJPT0xFQU4gREVGQVVMVCB0cnVlIE5P +VCBOVUxMLAogICJ1c2VzX29yZGVyX3RhYmxlIiBURVhULAogIENPTlNUUkFJTlQgInByb2R1Y3Rf +b3JkZXJfdHlwZV9wa2V5IiBQUklNQVJZIEtFWSgiY29tcG9uZW50X3R5cGVfaWQiKSwKICBDT05T +VFJBSU5UICJjb21wb25lbnRfdHlwZV9vcmRlcl90eXBlX2ZrIiBGT1JFSUdOIEtFWSAoIm9yZGVy +X3R5cGVfaWQiKQogICAgUkVGRVJFTkNFUyAiYnVzaW5lc3NfcnVsZXMiLiJvcmRlcl90eXBlIigi +b3JkZXJfdHlwZV9pZCIpCiAgICBPTiBERUxFVEUgUkVTVFJJQ1QKICAgIE9OIFVQREFURSBSRVNU +UklDVAogICAgTk9UIERFRkVSUkFCTEUsCiAgQ09OU1RSQUlOVCAiY29tcG9uZW50X3R5cGVfcHJv +ZHVjdF9mayIgRk9SRUlHTiBLRVkgKCJwcm9kdWN0X2lkIikKICAgIFJFRkVSRU5DRVMgImJ1c2lu +ZXNzX3J1bGVzIi4icHJvZHVjdCIoInByb2R1Y3RfaWQiKQogICAgT04gREVMRVRFIFJFU1RSSUNU +CiAgICBPTiBVUERBVEUgUkVTVFJJQ1QKICAgIE5PVCBERUZFUlJBQkxFCikgV0lUSCBPSURTOwoK +Q1JFQVRFIFVOSVFVRSBJTkRFWCAiY29tcG9uZW50X3R5cGVfdWl4IiBPTiAiYnVzaW5lc3NfcnVs +ZXMiLiJjb21wb25lbnRfdHlwZSIKVVNJTkcgYnRyZWUgKCJwcm9kdWN0X2lkIiwgIm9yZGVyX3R5 +cGVfaWQiKTsKCi0tUm93IGNvdW50ID0gMTUKQ1JFQVRFIFRBQkxFICJidXNpbmVzc19ydWxlcyIu +Im9yZGVyX3R5cGUiICgKICAib3JkZXJfdHlwZV9pZCIgU0VSSUFMLAogICJkZXNjcmlwdGlvbiIg +VEVYVCBOT1QgTlVMTCwKICAiaXNfYWN0aXZlIiBCT09MRUFOIERFRkFVTFQgJ3QnIE5PVCBOVUxM +LAogIENPTlNUUkFJTlQgIm9yZGVyX3R5cGVfcGsiIFBSSU1BUlkgS0VZKCJvcmRlcl90eXBlX2lk +IiksCiAgQ09OU1RSQUlOVCAib3JkZXJfdHlwZV9pZF9jayIgQ0hFQ0sgKG9yZGVyX3R5cGVfaWQg +PiAwKQopIFdJVEggT0lEUzsKCkNSRUFURSBVTklRVUUgSU5ERVggIm9yZGVyX3R5cGVfZGVzY3Jp +cHRpb25fdWl4IiBPTiAiYnVzaW5lc3NfcnVsZXMiLiJvcmRlcl90eXBlIgpVU0lORyBidHJlZSAo +ImRlc2NyaXB0aW9uIik7CgotLVJvdyBjb3VudCA9IDkKQ1JFQVRFIFRBQkxFICJvcmRlcnMiLiJz +dGF0dXMiICgKICAic3RhdHVzX2lkIiBTRVJJQUwsCiAgImRlc2NyaXB0aW9uIiBURVhUIE5PVCBO +VUxMLAogICJmdXJ0aGVyX2RldGFpbCIgVEVYVCwKICAiaXNfZmluYWwiIEJPT0xFQU4gREVGQVVM +VCB0cnVlIE5PVCBOVUxMLAogICJtYWtlX3Bvc3QiIEJPT0xFQU4gREVGQVVMVCBmYWxzZSwKICBD +T05TVFJBSU5UICJzdGF0dXNfcGsiIFBSSU1BUlkgS0VZKCJzdGF0dXNfaWQiKSwKICBDT05TVFJB +SU5UICJzdGF0dXNfc3RhdHVzX2lkX2NrIiBDSEVDSyAoc3RhdHVzX2lkID49IDEpCikgV0lUSCBP +SURTOwoKLS1Sb3cgY291bnQgPSAyOTkKQ1JFQVRFIFRBQkxFICJvcmRlcnMiLiJyZXNwb25zZV9j +b2RlIiAoCiAgInJlc3BvbnNlX2NvZGVfaWQiIFNFUklBTCwKICAicmVzcG9uc2VfY29kZSIgVEVY +VCBOT1QgTlVMTCwKICAiZGVzY3JpcHRpb24iIFRFWFQgTk9UIE5VTEwsCiAgInN0YXR1c19pZCIg +SU5URUdFUiwKICAic3VwcGxpZXJfaWQiIElOVEVHRVIgTk9UIE5VTEwsCiAgImlzX2FjdGl2ZSIg +Qk9PTEVBTiBERUZBVUxUICd0JyBOT1QgTlVMTCwKICAiY2hhbmdlc19zdXBwbGllcl9zdGF0dXMi +IEJPT0xFQU4gREVGQVVMVCB0cnVlIE5PVCBOVUxMLAogIENPTlNUUkFJTlQgInJlc3BvbnNlX2Nv +ZGVfcGsiIFBSSU1BUlkgS0VZKCJyZXNwb25zZV9jb2RlX2lkIiksCiAgQ09OU1RSQUlOVCAicmVz +cG9uc2VfY29kZV9yZXNwb25zZV9pZF9jayIgQ0hFQ0sgKHJlc3BvbnNlX2NvZGVfaWQgPj0gMSks +CiAgQ09OU1RSQUlOVCAicmVzcG9uc2VfY29kZV9zdGF0dXNfaWRfZmsiIEZPUkVJR04gS0VZICgi +c3RhdHVzX2lkIikKICAgIFJFRkVSRU5DRVMgIm9yZGVycyIuInN0YXR1cyIoInN0YXR1c19pZCIp +CiAgICBPTiBERUxFVEUgUkVTVFJJQ1QKICAgIE9OIFVQREFURSBSRVNUUklDVAogICAgTk9UIERF +RkVSUkFCTEUsCiAgQ09OU1RSQUlOVCAicmVzcG9uc2VfY29kZV9zdXBwbGllcl9pZF9mayIgRk9S +RUlHTiBLRVkgKCJzdXBwbGllcl9pZCIpCiAgICBSRUZFUkVOQ0VTICJwYXJ0aWVzIi4icGFydHki +KCJwYXJ0eV9pZCIpCiAgICBPTiBERUxFVEUgUkVTVFJJQ1QKICAgIE9OIFVQREFURSBSRVNUUklD +VAogICAgTk9UIERFRkVSUkFCTEUKKSBXSVRIIE9JRFM7CgpDUkVBVEUgVU5JUVVFIElOREVYICJy +ZXNwb25zZV9jb2RlX3Jlc3BvbnNlX2NvZGVfaWRfc3VwcGxpZXJfaWRfdWl4IiBPTiAib3JkZXJz +Ii4icmVzcG9uc2VfY29kZSIKVVNJTkcgYnRyZWUgKCJyZXNwb25zZV9jb2RlIiwgInN1cHBsaWVy +X2lkIik7CgpDUkVBVEUgSU5ERVggInJlc3BvbnNlX2NvZGVfc3RhdHVzX2lkX2l4IiBPTiAib3Jk +ZXJzIi4icmVzcG9uc2VfY29kZSIKVVNJTkcgYnRyZWUgKCJzdGF0dXNfaWQiKTsKCkNSRUFURSBJ +TkRFWCAicmVzcG9uc2VfY29kZV9zdXBwbGllcl9pZF9peCIgT04gIm9yZGVycyIuInJlc3BvbnNl +X2NvZGUiClVTSU5HIGJ0cmVlICgic3VwcGxpZXJfaWQiKTsKCi0tUm93IGNvdW50ID0gOTAzMjgz +CgpDUkVBVEUgVEFCTEUgIm9yZGVycyIuImNvbW11bmljYXRpb24iICgKICAiY29tbXVuaWNhdGlv +bl9pZCIgU0VSSUFMLAogICJjb21wb25lbnRfaWQiIElOVEVHRVIgTk9UIE5VTEwsCiAgImR0bSIg +VElNRVNUQU1QIFdJVEhPVVQgVElNRSBaT05FIERFRkFVTFQgKCdub3cnOjp0ZXh0KTo6dGltZXN0 +YW1wKDYpIHdpdGggdGltZSB6b25lIE5PVCBOVUxMLAogICJkZXRhaWwiIFRFWFQsCiAgInJlc3Bv +bnNlX2NvZGVfaWQiIElOVEVHRVIgTk9UIE5VTEwsCiAgInVzcl9pZCIgSU5URUdFUiBOT1QgTlVM +TCwKICBDT05TVFJBSU5UICJjb21tdW5pY2F0aW9uX3BrIiBQUklNQVJZIEtFWSgiY29tbXVuaWNh +dGlvbl9pZCIpLAogIENPTlNUUkFJTlQgImNvbW11bmljYXRpb25fY29tbXVuaWNhdGlvbl9pZF9j +ayIgQ0hFQ0sgKGNvbW11bmljYXRpb25faWQgPj0gMSksCiAgRk9SRUlHTiBLRVkgKCJ1c3JfaWQi +KQogICAgUkVGRVJFTkNFUyAidXNlcnMiLiJ1c3IiKCJ1c3JfaWQiKQogICAgT04gREVMRVRFIFJF +U1RSSUNUCiAgICBPTiBVUERBVEUgUkVTVFJJQ1QKICAgIE5PVCBERUZFUlJBQkxFLAogIENPTlNU +UkFJTlQgImNvbW11bmljYXRpb25fY29tcG9uZW50X2lkX2ZrIiBGT1JFSUdOIEtFWSAoImNvbXBv +bmVudF9pZCIpCiAgICBSRUZFUkVOQ0VTICJvcmRlcnMiLiJjb21wb25lbnQiKCJjb21wb25lbnRf +aWQiKQogICAgT04gREVMRVRFIFJFU1RSSUNUCiAgICBPTiBVUERBVEUgUkVTVFJJQ1QKICAgIE5P +VCBERUZFUlJBQkxFLAogIENPTlNUUkFJTlQgImNvbW11bmljYXRpb25fcmVzcG9uc2VfY29kZV9m +ayIgRk9SRUlHTiBLRVkgKCJyZXNwb25zZV9jb2RlX2lkIikKICAgIFJFRkVSRU5DRVMgIm9yZGVy +cyIuInJlc3BvbnNlX2NvZGUiKCJyZXNwb25zZV9jb2RlX2lkIikKICAgIE9OIERFTEVURSBSRVNU +UklDVAogICAgT04gVVBEQVRFIFJFU1RSSUNUCiAgICBOT1QgREVGRVJSQUJMRQopIFdJVEggT0lE +UzsKCkNSRUFURSBJTkRFWCAiY29tbXVuaWNhdGlvbl9jb21wb25lbnRfaWRfaXgiIE9OICJvcmRl +cnMiLiJjb21tdW5pY2F0aW9uIgpVU0lORyBidHJlZSAoImNvbXBvbmVudF9pZCIpOwoKQ1JFQVRF +IElOREVYICJjb21tdW5pY2F0aW9uX2R0bV9peCIgT04gIm9yZGVycyIuImNvbW11bmljYXRpb24i +ClVTSU5HIGJ0cmVlICgiZHRtIik7CgpDUkVBVEUgSU5ERVggImNvbW11bmljYXRpb25fcmVzcG9u +c2VfY29kZV9pZF9peCIgT04gIm9yZGVycyIuImNvbW11bmljYXRpb24iClVTSU5HIGJ0cmVlICgi +cmVzcG9uc2VfY29kZV9pZCIpOwoK +------=_Part_1042_8766129.1110206798950-- + +From pgsql-hackers-win32-owner@postgresql.org Mon Mar 7 16:33:44 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 28EE756594; + Mon, 7 Mar 2005 16:30:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19279-07; Mon, 7 Mar 2005 16:30:06 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id A87B85659A; + Mon, 7 Mar 2005 16:29:59 +0000 (GMT) +Received: from [129.255.60.32] (natu.i-clic.uihc.uiowa.edu [129.255.60.32]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j27GTk309693; + Mon, 7 Mar 2005 10:29:46 -0600 +Message-ID: <422C817A.8050009@arbash-meinel.com> +Date: Mon, 07 Mar 2005 10:29:46 -0600 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Magnus Hagander , + Ken Egervari , pgsql-performance@postgresql.org, + pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] Help with tuning this query (with +References: <6BCB9D8A16AC4241919521715F4D8BCE476A60@algol.sollentuna.se> + <23086.1110206737@sss.pgh.pa.us> +In-Reply-To: <23086.1110206737@sss.pgh.pa.us> +X-Enigmail-Version: 0.90.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig66A13755854B5C23F3A788DF" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/53 +X-Sequence-Number: 3011 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig66A13755854B5C23F3A788DF +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>"Magnus Hagander" writes: +> +> +>>There is. I beleive QueryPerformanceCounter has sub-mirosecond +>>resolution. +>> +>> +>>Can we just replace gettimeofday() with a version that's basically: +>> +>> +> +>No, because it's also used for actual time-of-day calls. It'd be +>necessary to hack executor/instrument.c in particular. +> +> regards, tom lane +> +> +It seems that there are 2 possibilities. Leave gettimeofday as it is, +and then change code that calls it for deltas with a +"pg_get_high_res_delta_time()", which on most platforms is just +gettimeofday, but on win32 is a wrapper for QueryPerformanceCounter(). + +Or we modify the win32 gettimeofday call to something like: + +gettimeofday(struct timeval *tv, struct timezone *tz) +{ + static int initialized = 0; + static LARGE_INTEGER freq = {0}; + static LARGE_INTEGER base = {0}; + static struct time_t base_tm = {0}; + LARGE_INTEGER now = {0}; + int64_t delta_secs = 0; + + if(!initialized) { + QueryPerformanceFrequency(&freq); + base_tm = time(NULL); // This can be any moderately accurate time +function, maybe getlocaltime if it exists + QueryPerformanceCounter(&base); + } + + QueryPerformanceCounter(&now); + delta_secs = now.QuadPart - base.QuadPart; + tv->tv_sec = delta_secs / freq.QuadPart; + delta_secs -= *tv.tv_sec * freq.QuadPart; + tv->tv_usec = delta_secs * 1000000 / freq.QuadPart + + tv->tv_sec += base_tm; + + return 0; +} + + +--------------enig66A13755854B5C23F3A788DF +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.1 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCLIF6JdeBCYSNAAMRAgvEAJ4rg9GJNkX0j+ViiQ6nGE8MIS1GVwCdFKQ3 +iOPu9Lp51/cPaHoZ4TJ7LoQ= +=RE9x +-----END PGP SIGNATURE----- + +--------------enig66A13755854B5C23F3A788DF-- + +From pgsql-hackers-win32-owner@postgresql.org Mon Mar 7 17:03:10 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 50A695659A + for ; + Mon, 7 Mar 2005 16:39:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23017-08 + for ; + Mon, 7 Mar 2005 16:38:59 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 61E5F563D0 + for ; + Mon, 7 Mar 2005 16:38:59 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j27GcqGw002556; + Mon, 7 Mar 2005 11:38:52 -0500 (EST) +To: John A Meinel +Cc: Magnus Hagander , + Ken Egervari , pgsql-performance@postgresql.org, + pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] Help with tuning this query (with explain analyze + finally) +In-reply-to: <422C817A.8050009@arbash-meinel.com> +References: <6BCB9D8A16AC4241919521715F4D8BCE476A60@algol.sollentuna.se> + <23086.1110206737@sss.pgh.pa.us> + <422C817A.8050009@arbash-meinel.com> +Comments: In-reply-to John A Meinel + message dated "Mon, 07 Mar 2005 10:29:46 -0600" +Date: Mon, 07 Mar 2005 11:38:51 -0500 +Message-ID: <2555.1110213531@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/54 +X-Sequence-Number: 3012 + +John A Meinel writes: +>>> Can we just replace gettimeofday() with a version that's basically: +>> +>> No, because it's also used for actual time-of-day calls. It'd be +>> necessary to hack executor/instrument.c in particular. + +> Or we modify the win32 gettimeofday call to something like: + +That's what Magnus was talking about, but it's really no good because +it would cause Postgres' now() function to fail to track post-boot-time +changes in the system date setting. Which I think would rightly be +considered a bug. + +The EXPLAIN ANALYZE instrumentation code will really be happier with a +straight time-since-bootup counter; by using gettimeofday, it is +vulnerable to giving wrong answers if someone changes the date setting +while the EXPLAIN is running. But there is (AFAIK) no such call among +the portable Unix syscalls. It seems reasonable to me to #ifdef that +code to make use of QueryPerformanceCounter on Windows. This does not +mean we want to alter the behavior of gettimeofday() where it's being +used to find out the time of day. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 7 17:04:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D8F9565BD + for ; + Mon, 7 Mar 2005 17:03:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32402-06 + for ; + Mon, 7 Mar 2005 17:02:54 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.192]) + by svr1.postgresql.org (Postfix) with ESMTP id EDDB552A67 + for ; + Mon, 7 Mar 2005 17:02:45 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 70so1507566wra + for ; + Mon, 07 Mar 2005 09:02:44 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=uJAh03Q2f1Nd7uFxXWbbN924VupLYCgvTIBnkQA4TafnNm00Fj6I/Fcrl/iHVHNHNk5+95SeolQzoWR0Zu2VQoQQDf3ebMiw086NtNQXs49KXZzQ/mtLUS3jvR4p206jbCFoBp6K1DSfbUxBKOLAmUQvew1+t2m/ihxwNe0g+5g= +Received: by 10.54.73.12 with SMTP id v12mr52772wra; + Mon, 07 Mar 2005 09:01:59 -0800 (PST) +Received: by 10.54.18.9 with HTTP; Mon, 7 Mar 2005 09:01:58 -0800 (PST) +Message-ID: <4e8efcf50503070901406808be@mail.gmail.com> +Date: Mon, 7 Mar 2005 17:01:58 +0000 +From: Hugo Ferreira +Reply-To: Hugo Ferreira +To: pgsql-performance@postgresql.org +Subject: Help trying to tune query that executes 40x slower than in SqlServer +In-Reply-To: <4e8efcf50503040413245d80f9@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <20050304002724.650A95AF649@svr4.postgresql.org> + <4e8efcf50503040413245d80f9@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.534 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/96 +X-Sequence-Number: 10801 + +Hi there :-) + +I'm really, really having trouble with this query... It is a part of, +hmmm... 200 similar querys that I dinyamically build and run in a +stored procedure. This one, for example, takes 27seconds to run. The +whole stored procedure executes in about 15minutes. This is too much +when compared to the exact same database, with the same indexes and +same data running under SqlServer 2000, which takes 21seconds to run +the whole batch. + +Any help would be extremely appreciated. I've also tried to tune up +the configuration + +insert into MRS_REPLICATION_OUT select 514, 10000168, C.contxt_id, +C.contxt_elmt_ix, CAST(null as NUMERIC(18)), CAST(null as +NUMERIC(18)), CAST(null as NUMERIC(18)), CAST(null as NUMERIC(18)), +CAST(null as NUMERIC(18)), null, 1 from c2iedm.CONTXT as P inner join +c2iedm.CONTXT_ELMT as C on (P.contxt_id=C.contxt_id) inner join +MRS_REPLICATION_OUT as S on S.ent_id=10000029 and (CAST(P.contxt_id AS +numeric(18)) = S.pk1) inner join MRS_TRANSACTION TRANS on +TRANS.trans_id=514 left join NON_REPL_DATA_OWNER NRDO on +NRDO.non_repl_data_owner_id=C.owner_id left join REPL_DATA_OWNER_RSDNC +RDOR on RDOR.owner_id=C.owner_id and +RDOR.rsdnc_node_id=TRANS.recv_node_id left join MRS_REPLICATION_OUT +OUT on OUT.trans_id=514 and OUT.ent_id=10000168 and ((CAST(C.contxt_id +AS numeric(18)) = OUT.pk1 AND CAST(C.contxt_elmt_ix AS numeric(18)) = +OUT.pk2)) inner join MRS_TRANSACTION RED_TRANS on +TRANS.prov_node_id=RED_TRANS.prov_node_id and +TRANS.recv_node_id=RED_TRANS.recv_node_id left join +MRS_REPLICATION_OUT RED_OUT on RED_TRANS.cat_code = 'OUT' and +RED_TRANS.trans_type in ('X01', 'X02') and +RED_TRANS.trans_id=RED_OUT.trans_id where S.age=0 and S.trans_id=514 +and (NRDO.non_repl_data_owner_id is null) AND (RDOR.repl_data_owner_id +is null) AND (OUT.trans_id is null) AND (RED_OUT.trans_id is null); + +This kind of inserts generate few rows. Between 8k and 15k for this particular +insert, and about 20k for the whole batch. If I try to run a batch +to generate about 50k rows, then I'll be stuck here for more that 45h. +Compare this to 12minutes when running SqlServer 2000. + +Here is the result of explain analyze: + +"Merge Left Join (cost=1338.32..1377.99 rows=45 width=32) (actual +time=719.000..26437.000 rows=14862 loops=1)" +" Merge Cond: ("outer".trans_id = "inner".trans_id)" +" Join Filter: (("outer".cat_code = 'OUT'::bpchar) AND +(("outer".trans_type = 'X01'::bpchar) OR ("outer".trans_type = +'X02'::bpchar)))" +" Filter: ("inner".trans_id IS NULL)" +" -> Sort (cost=1067.36..1067.47 rows=45 width=56) (actual +time=719.000..735.000 rows=14862 loops=1)" +" Sort Key: red_trans.trans_id" +" -> Merge Join (cost=851.66..1066.12 rows=45 width=56) +(actual time=407.000..673.000 rows=14862 loops=1)" +" Merge Cond: ("outer".recv_node_id = "inner".recv_node_id)" +" Join Filter: ("outer".prov_node_id = "inner".prov_node_id)" +" -> Nested Loop Left Join (cost=847.14..987.28 +rows=3716 width=60) (actual time=407.000..610.000 rows=14862 loops=1)" +" Join Filter: ((("outer".contxt_id)::numeric(18,0) += "inner".pk1) AND (("outer".contxt_elmt_ix)::numeric(18,0) = +"inner".pk2))" +" Filter: ("inner".trans_id IS NULL)" +" -> Merge Left Join (cost=718.22..746.87 +rows=3716 width=60) (actual time=407.000..563.000 rows=14862 loops=1)" +" Merge Cond: (("outer".recv_node_id = +"inner".rsdnc_node_id) AND ("outer".owner_id = "inner".owner_id))" +" Filter: ("inner".repl_data_owner_id IS NULL)" +" -> Sort (cost=717.19..726.48 rows=3716 +width=74) (actual time=407.000..423.000 rows=14862 loops=1)" +" Sort Key: trans.recv_node_id, c.owner_id" +" -> Nested Loop Left Join +(cost=1.01..496.84 rows=3716 width=74) (actual time=0.000..312.000 +rows=14862 loops=1)" +" Join Filter: +("inner".non_repl_data_owner_id = "outer".owner_id)" +" Filter: +("inner".non_repl_data_owner_id IS NULL)" +" -> Nested Loop +(cost=0.00..412.22 rows=3716 width=74) (actual time=0.000..186.000 +rows=14862 loops=1)" +" -> Seq Scan on +mrs_transaction trans (cost=0.00..2.05 rows=1 width=28) (actual +time=0.000..0.000 rows=1 loops=1)" +" Filter: (trans_id = +514::numeric)" +" -> Nested Loop +(cost=0.00..373.01 rows=3716 width=46) (actual time=0.000..139.000 +rows=14862 loops=1)" +" Join Filter: +("outer".contxt_id = "inner".contxt_id)" +" -> Nested Loop +(cost=0.00..4.81 rows=1 width=16) (actual time=0.000..0.000 rows=4 +loops=1)" +" Join Filter: +(("inner".contxt_id)::numeric(18,0) = "outer".pk1)" +" -> Index +Scan using ix_mrs_replication_out_all on mrs_replication_out s +(cost=0.00..3.76 rows=1 width=16) (actual time=0.000..0.000 rows=4 +loops=1)" +" Index +Cond: ((ent_id = 10000029::numeric) AND (age = 0::numeric) AND +(trans_id = 514::numeric))" +" -> Seq Scan +on contxt p (cost=0.00..1.02 rows=2 width=16) (actual +time=0.000..0.000 rows=2 loops=4)" +" -> Seq Scan on +contxt_elmt c (cost=0.00..275.31 rows=7431 width=46) (actual +time=0.000..7.500 rows=7431 loops=4)" +" -> Materialize +(cost=1.01..1.02 rows=1 width=12) (actual time=0.000..0.001 rows=1 +loops=14862)" +" -> Seq Scan on +non_repl_data_owner nrdo (cost=0.00..1.01 rows=1 width=12) (actual +time=0.000..0.000 rows=1 loops=1)" +" -> Sort (cost=1.03..1.03 rows=2 width=42) +(actual time=0.000..0.000 rows=2 loops=1)" +" Sort Key: rdor.rsdnc_node_id, rdor.owner_id" +" -> Seq Scan on repl_data_owner_rsdnc +rdor (cost=0.00..1.02 rows=2 width=42) (actual time=0.000..0.000 +rows=2 loops=1)" +" -> Materialize (cost=128.92..128.93 rows=1 +width=42) (actual time=0.000..0.000 rows=0 loops=14862)" +" -> Seq Scan on mrs_replication_out "out" +(cost=0.00..128.92 rows=1 width=42) (actual time=0.000..0.000 rows=0 +loops=1)" +" Filter: ((trans_id = 514::numeric) +AND (ent_id = 10000168::numeric))" +" -> Sort (cost=4.52..4.73 rows=84 width=52) (actual +time=0.000..15.000 rows=1 loops=1)" +" Sort Key: red_trans.recv_node_id" +" -> Seq Scan on mrs_transaction red_trans +(cost=0.00..1.84 rows=84 width=52) (actual time=0.000..0.000 rows=1 +loops=1)" +" -> Sort (cost=270.96..277.78 rows=2728 width=10) (actual +time=0.000..5255.000 rows=8932063 loops=1)" +" Sort Key: red_out.trans_id" +" -> Seq Scan on mrs_replication_out red_out +(cost=0.00..115.28 rows=2728 width=10) (actual time=0.000..0.000 +rows=602 loops=1)" +"Total runtime: 27094.000 ms" + +Once again, thanks in advance. + +Hugo Ferreira +-- +GPG Fingerprint: B0D7 1249 447D F5BB 22C5 5B9B 078C 2615 504B 7B85 + +From pgsql-hackers-win32-owner@postgresql.org Mon Mar 7 17:24:22 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 79C3254D3A; + Mon, 7 Mar 2005 17:24:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40904-08; Mon, 7 Mar 2005 17:24:19 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 3EDBE56484; + Mon, 7 Mar 2005 17:24:17 +0000 (GMT) +Received: from [129.255.60.32] (natu.i-clic.uihc.uiowa.edu [129.255.60.32]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j27HOC310274; + Mon, 7 Mar 2005 11:24:12 -0600 +Message-ID: <422C8E37.8000009@arbash-meinel.com> +Date: Mon, 07 Mar 2005 11:24:07 -0600 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Magnus Hagander , + Ken Egervari , pgsql-performance@postgresql.org, + pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] Help with tuning this query (with +References: <6BCB9D8A16AC4241919521715F4D8BCE476A60@algol.sollentuna.se> + <23086.1110206737@sss.pgh.pa.us> + <422C817A.8050009@arbash-meinel.com> + <2555.1110213531@sss.pgh.pa.us> +In-Reply-To: <2555.1110213531@sss.pgh.pa.us> +X-Enigmail-Version: 0.90.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigFF8E46B93B8E65A5C48E5155" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/55 +X-Sequence-Number: 3013 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigFF8E46B93B8E65A5C48E5155 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>John A Meinel writes: +> +> +>>>>Can we just replace gettimeofday() with a version that's basically: +>>>> +>>>> +>>>No, because it's also used for actual time-of-day calls. It'd be +>>>necessary to hack executor/instrument.c in particular. +>>> +>>> +> +> +> +>>Or we modify the win32 gettimeofday call to something like: +>> +>> +> +>That's what Magnus was talking about, but it's really no good because +>it would cause Postgres' now() function to fail to track post-boot-time +>changes in the system date setting. Which I think would rightly be +>considered a bug. +> +>The EXPLAIN ANALYZE instrumentation code will really be happier with a +>straight time-since-bootup counter; by using gettimeofday, it is +>vulnerable to giving wrong answers if someone changes the date setting +>while the EXPLAIN is running. But there is (AFAIK) no such call among +>the portable Unix syscalls. It seems reasonable to me to #ifdef that +>code to make use of QueryPerformanceCounter on Windows. This does not +>mean we want to alter the behavior of gettimeofday() where it's being +>used to find out the time of day. +> +> regards, tom lane +> +> +> + +What if you changed the "initialized" to + +if (count & 0xFF == 0) { + count = 1; + // get the new time of day +} +++count; + +Then we would only be wrong for 256 gettimeofday calls. I agree it isn't +great, though. And probably better to just abstract (possibly just with +#ifdef) the calls for accurate timing, from the calls that actually need +the real time. + +John +=:-> + + + +--------------enigFF8E46B93B8E65A5C48E5155 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.1 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCLI43JdeBCYSNAAMRAsOhAJ9D+CIcXiTShDZrxZE+E/TdNzqVWQCgiYza +Nj8wY5Jaeewh9gDWDsvR+Io= +=HBf/ +-----END PGP SIGNATURE----- + +--------------enigFF8E46B93B8E65A5C48E5155-- + +From pgsql-performance-owner@postgresql.org Mon Mar 7 17:28:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 828AE52A88 + for ; + Mon, 7 Mar 2005 17:28:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43828-02 + for ; + Mon, 7 Mar 2005 17:28:57 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 2F0C252A67 + for ; + Mon, 7 Mar 2005 17:28:56 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7101653; Mon, 07 Mar 2005 09:30:45 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Hugo Ferreira +Subject: Re: Help trying to tune query that executes 40x slower than in + SqlServer +Date: Mon, 7 Mar 2005 09:28:47 -0800 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <20050304002724.650A95AF649@svr4.postgresql.org> + <4e8efcf50503040413245d80f9@mail.gmail.com> + <4e8efcf50503070901406808be@mail.gmail.com> +In-Reply-To: <4e8efcf50503070901406808be@mail.gmail.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200503070928.47118.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.114 tagged_above=0 required=5 tests=AWL, + UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200503/98 +X-Sequence-Number: 10803 + +Hugo, + +> insert into MRS_REPLICATION_OUT select 514, 10000168, =A0C.contxt_id, +> C.contxt_elmt_ix, CAST(null as NUMERIC(18)), CAST(null as +> NUMERIC(18)), CAST(null as NUMERIC(18)), CAST(null as NUMERIC(18)), +> CAST(null as NUMERIC(18)), null, 1 from c2iedm.CONTXT as P inner join +> c2iedm.CONTXT_ELMT as C on (P.contxt_id=3DC.contxt_id) inner join +> MRS_REPLICATION_OUT as S on S.ent_id=3D10000029 and (CAST(P.contxt_id AS +> numeric(18)) =3D S.pk1) inner join MRS_TRANSACTION TRANS on + +Can you *format* this query please, and re-submit it? Proper query format= +=20 +looks like: + +SELECT a.1, b.2 +=46ROM a JOIN b ON a.1 =3D b.3 + JOIN c ON b.4 =3D c.1 +WHERE a.5 < 6 + AND c.7 =3D '2005-01-01'; + +=2E.. for maximum readability. =20 + +Also, when asking others to help debug your queries, it helps them (and,=20 +frankly, you) if you can NOT use single-letter table aliases. Single-lett= +er=20 +table aliases are evil for the same reason that single-letter variables in= +=20 +code are. + +Thanks! + +=2D-=20 +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Mar 7 17:31:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D5DDE54D3A + for ; + Mon, 7 Mar 2005 17:31:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44659-03 + for ; + Mon, 7 Mar 2005 17:31:15 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BB5F545F2 + for ; + Mon, 7 Mar 2005 17:31:14 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7101661; Mon, 07 Mar 2005 09:33:04 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: +Subject: Re: Tuning, configuration for 7.3.5 on a Sun E4500 +Date: Mon, 7 Mar 2005 09:31:06 -0800 +User-Agent: KMail/1.6.2 +Cc: Postgres - Performance +References: <156a90fe050307064678d5a6e9@mail.gmail.com> +In-Reply-To: <156a90fe050307064678d5a6e9@mail.gmail.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200503070931.06241.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/99 +X-Sequence-Number: 10804 + +Tsarevich, + +> When running queries we are experiencing much bigger result times than +> anticipated. +> +> Attached is a copy of our postgresql.conf file and of our the table +> definitions and row counts. + +Looks like you haven't run ANALYZE on the database anytime recently. Try that +and re-run. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Mar 7 17:45:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2603B52A7A + for ; + Mon, 7 Mar 2005 17:45:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50253-01 + for ; + Mon, 7 Mar 2005 17:45:34 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.200]) + by svr1.postgresql.org (Postfix) with ESMTP id 9CE2552A62 + for ; + Mon, 7 Mar 2005 17:45:33 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 70so1520283wra + for ; + Mon, 07 Mar 2005 09:45:34 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=ID1xudcvxTJfevddAooFOnY8N8OOhv3mjGBgHjCAVPKuFp+le/2gMOg+55/LJ6WNZg2zCS0AdSVDas7x7OgtIAwmBSga5lLnXzik3ucOVFJAas6PTRG+/TENs3L7HDB6c5iG7SKnO0wBRC6Zede5h9HRtBOrADzQT9do72RXils= +Received: by 10.54.66.2 with SMTP id o2mr88074wra; + Mon, 07 Mar 2005 09:45:33 -0800 (PST) +Received: by 10.54.18.9 with HTTP; Mon, 7 Mar 2005 09:45:32 -0800 (PST) +Message-ID: <4e8efcf50503070945332778bb@mail.gmail.com> +Date: Mon, 7 Mar 2005 17:45:32 +0000 +From: Hugo Ferreira +Reply-To: Hugo Ferreira +To: Josh Berkus +Subject: Re: Help trying to tune query that executes 40x slower than in + SqlServer +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200503070928.47118.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_3151_5208518.1110217532117" +References: <20050304002724.650A95AF649@svr4.postgresql.org> + <4e8efcf50503040413245d80f9@mail.gmail.com> + <4e8efcf50503070901406808be@mail.gmail.com> + <200503070928.47118.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.468 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP, + UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200503/100 +X-Sequence-Number: 10805 + +------=_Part_3151_5208518.1110217532117 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +I'm sorry for my unpolite query alignment. Here is the query in a more +human-readable format: + +SELECT 514, 10000168, C.contxt_id, C.contxt_elmt_ix, null, null, +null, null, null, null, 1 +FROM CONTXT as P INNER JOIN CONTXT_ELMT as C on P.contxt_id = C.contxt_id + INNER JOIN MRS_REPLICATION_OUT as S on S.ent_id=10000029 + AND P.contxt_id = S.pk1 + INNER JOIN MRS_TRANSACTION TRANS on TRANS.trans_id=514 + LEFT JOIN ON_REPL_DATA_OWNER NRDO on +NRDO.non_repl_data_owner_id = C.owner_id + LEFT JOIN REPL_DATA_OWNER_RSDNC RDOR on RDOR.owner_id = C.owner_id + AND RDOR.rsdnc_node_id=TRANS.recv_node_id + LEFT JOIN MRS_REPLICATION_OUT OUT on OUT.trans_id = 514 + AND OUT.ent_id=10000168 and C.contxt_id = OUT.pk1 + AND C.contxt_elmt_ix = OUT.pk2 + INNER JOIN MRS_TRANSACTION RED_TRANS on +TRANS.prov_node_id=RED_TRANS.prov_node_id + AND TRANS.recv_node_id=RED_TRANS.recv_node_id + LEFT JOIN MRS_REPLICATION_OUT RED_OUT on RED_TRANS.cat_code = 'OUT' + AND RED_TRANS.trans_type in ('X01', 'X02') + AND RED_TRANS.trans_id = RED_OUT.trans_id +WHERE S.age=0 and S.trans_id=514 + AND (NRDO.non_repl_data_owner_id is null) + AND (RDOR.repl_data_owner_id is null) + AND (OUT.trans_id is null) + AND (RED_OUT.trans_id is null); + +Because GMAIL also cuts out text at 80 characters, I also send the +query in attachment. + +Once again thanks for your help, + +Hugo Ferreira + +> Can you *format* this query please, and re-submit it? Proper query format +> looks like: +> +> SELECT a.1, b.2 +> FROM a JOIN b ON a.1 = b.3 +> JOIN c ON b.4 = c.1 +> WHERE a.5 < 6 +> AND c.7 = '2005-01-01'; +> +> ... for maximum readability. + +-- +GPG Fingerprint: B0D7 1249 447D F5BB 22C5 5B9B 078C 2615 504B 7B85 + +------=_Part_3151_5208518.1110217532117 +Content-Type: text/plain; name="query.txt" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: attachment; filename="query.txt" + +SELECT 514, 10000168, C.contxt_id, C.contxt_elmt_ix, null, null, null, nul= +l, null, null, 1=20 +FROM CONTXT as P INNER JOIN CONTXT_ELMT as C on P.contxt_id =3D C.contxt_id +=09INNER JOIN MRS_REPLICATION_OUT as S on S.ent_id=3D10000029=20 +=09=09 AND P.contxt_id =3D S.pk1 +=09INNER JOIN MRS_TRANSACTION TRANS on TRANS.trans_id=3D514=20 +=09LEFT JOIN ON_REPL_DATA_OWNER NRDO on NRDO.non_repl_data_owner_id =3D C.= +owner_id=20 +=09LEFT JOIN REPL_DATA_OWNER_RSDNC RDOR on RDOR.owner_id =3D C.owner_id=20 +=09=09 AND RDOR.rsdnc_node_id=3DTRANS.recv_node_id=20 +=09LEFT JOIN MRS_REPLICATION_OUT OUT on OUT.trans_id =3D 514=20 +=09 AND OUT.ent_id=3D10000168 and C.contxt_id =3D OUT.pk1 +=09=09 AND C.contxt_elmt_ix =3D OUT.pk2 +=09INNER JOIN MRS_TRANSACTION RED_TRANS on TRANS.prov_node_id=3DRED_TRANS.p= +rov_node_id +=09=09 AND TRANS.recv_node_id=3DRED_TRANS.recv_node_id=20 +=09LEFT JOIN MRS_REPLICATION_OUT RED_OUT on RED_TRANS.cat_code =3D 'OUT'= +=20 +=09=09 AND RED_TRANS.trans_type in ('X01', 'X02')=20 +=09=09 AND RED_TRANS.trans_id =3D RED_OUT.trans_id=20 +WHERE S.age=3D0 and S.trans_id=3D514 +=09AND (NRDO.non_repl_data_owner_id is null)=20 +=09AND (RDOR.repl_data_owner_id is null)=20 +=09AND (OUT.trans_id is null)=20 +=09AND (RED_OUT.trans_id is null); +------=_Part_3151_5208518.1110217532117-- + +From pgsql-performance-owner@postgresql.org Mon Mar 7 18:02:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C1D0E563A7 + for ; + Mon, 7 Mar 2005 18:02:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55284-07 + for ; + Mon, 7 Mar 2005 18:02:14 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AAA6355478 + for ; + Mon, 7 Mar 2005 18:02:12 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j27I27AG003277; + Mon, 7 Mar 2005 13:02:07 -0500 (EST) +To: Hugo Ferreira +Cc: Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: Help trying to tune query that executes 40x slower than in + SqlServer +In-reply-to: <4e8efcf50503070945332778bb@mail.gmail.com> +References: <20050304002724.650A95AF649@svr4.postgresql.org> + <4e8efcf50503040413245d80f9@mail.gmail.com> + <4e8efcf50503070901406808be@mail.gmail.com> + <200503070928.47118.josh@agliodbs.com> + <4e8efcf50503070945332778bb@mail.gmail.com> +Comments: In-reply-to Hugo Ferreira + message dated "Mon, 07 Mar 2005 17:45:32 +0000" +Date: Mon, 07 Mar 2005 13:02:07 -0500 +Message-ID: <3276.1110218527@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.111 tagged_above=0 required=5 tests=AWL, + UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200503/101 +X-Sequence-Number: 10806 + +Hugo Ferreira writes: +> SELECT 514, 10000168, C.contxt_id, C.contxt_elmt_ix, null, null, +> null, null, null, null, 1 +> FROM CONTXT as P INNER JOIN CONTXT_ELMT as C on P.contxt_id = C.contxt_id +> INNER JOIN MRS_REPLICATION_OUT as S on S.ent_id=10000029 +> AND P.contxt_id = S.pk1 +> INNER JOIN MRS_TRANSACTION TRANS on TRANS.trans_id=514 +> LEFT JOIN ON_REPL_DATA_OWNER NRDO on +> NRDO.non_repl_data_owner_id = C.owner_id +> LEFT JOIN REPL_DATA_OWNER_RSDNC RDOR on RDOR.owner_id = C.owner_id +> AND RDOR.rsdnc_node_id=TRANS.recv_node_id +> LEFT JOIN MRS_REPLICATION_OUT OUT on OUT.trans_id = 514 +> AND OUT.ent_id=10000168 and C.contxt_id = OUT.pk1 +> AND C.contxt_elmt_ix = OUT.pk2 +> INNER JOIN MRS_TRANSACTION RED_TRANS on +> TRANS.prov_node_id=RED_TRANS.prov_node_id +> AND TRANS.recv_node_id=RED_TRANS.recv_node_id +> LEFT JOIN MRS_REPLICATION_OUT RED_OUT on RED_TRANS.cat_code = 'OUT' +> AND RED_TRANS.trans_type in ('X01', 'X02') +> AND RED_TRANS.trans_id = RED_OUT.trans_id + +I think the problem is that the intermix of inner and left joins forces +Postgres to do the joins in a particular order, per +http://www.postgresql.org/docs/8.0/static/explicit-joins.html +and this order is quite non optimal for your data. In particular it +looks like joining red_trans to red_out first, instead of last, +would be a good idea (I think but am not 100% certain that this +doesn't change the results). + +It is possible but complicated to determine that reordering outer joins +is safe in some cases. We don't currently have such logic in PG. It +may be that SQL Server does have that capability and that's why it's +finding a much better plan ... but for now you have to do that by hand +in PG. + + regards, tom lane + +From pgsql-hackers-win32-owner@postgresql.org Tue Mar 8 04:13:53 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 68CED564D5; + Mon, 7 Mar 2005 18:05:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56257-07; Mon, 7 Mar 2005 18:05:50 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A7E656454; + Mon, 7 Mar 2005 18:05:48 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1D8Mbi-0002io-00; Mon, 07 Mar 2005 13:05:30 -0500 +To: John A Meinel +Cc: Tom Lane , Magnus Hagander , + Ken Egervari , pgsql-performance@postgresql.org, + pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] Help with tuning this query (with +References: <6BCB9D8A16AC4241919521715F4D8BCE476A60@algol.sollentuna.se> + <23086.1110206737@sss.pgh.pa.us> <422C817A.8050009@arbash-meinel.com> + <2555.1110213531@sss.pgh.pa.us> <422C8E37.8000009@arbash-meinel.com> +In-Reply-To: <422C8E37.8000009@arbash-meinel.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 07 Mar 2005 13:05:30 -0500 +Message-ID: <874qfnbac5.fsf@stark.xeocode.com> +Lines: 17 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.015 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/67 +X-Sequence-Number: 3025 + +John A Meinel writes: + +> Then we would only be wrong for 256 gettimeofday calls. I agree it isn't +> great, though. And probably better to just abstract (possibly just with +> #ifdef) the calls for accurate timing, from the calls that actually need +> the real time. + +What would be really neato would be to use the rtdsc (sp?) or equivalent +assembly instruction where available. Most processors provide such a thing and +it would give much lower overhead and much more accurate answers. + +The main problem I see with this would be on multi-processor machines. +(QueryPerformanceCounter does work properly on multi-processor machines, +right?) + +-- +greg + + +From pgsql-performance-owner@postgresql.org Thu Apr 7 22:26:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BE425367C + for ; + Thu, 7 Apr 2005 22:26:25 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18023-04 + for ; + Thu, 7 Apr 2005 21:26:17 +0000 (GMT) +Received: from castle.comp.uvic.ca (castle.comp.uvic.ca [142.104.5.97]) + by svr1.postgresql.org (Postfix) with ESMTP id AB3C953519 + for ; + Thu, 7 Apr 2005 22:26:15 +0100 (BST) +Received: from [127.0.0.1] (bkbox.idc.uvic.ca [142.104.12.33]) + by castle.comp.uvic.ca (8.13.2/8.13.2) with ESMTP id j37LQ5ec4124690; + Thu, 7 Apr 2005 14:26:13 -0700 +Message-ID: <422CD4FC.6080007@aers.ca> +Date: Mon, 07 Mar 2005 14:26:04 -0800 +From: Adam Palmblad +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Mohan, Ross" +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Building postmaster with Profiling Support WAS "Tweaking a C +References: +In-Reply-To: + +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-UVic-Virus-Scanned: OK - Passed virus scan by Sophos (sophie) on castle +X-UVic-Spam-Scan: castle.comp.uvic.ca Not_scanned_LOCAL +X-Scanned-By: MIMEDefang 2.33 (www . roaringpenguin . com / mimedefang) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.686 tagged_above=0 required=5 tests=AWL, + DATE_IN_PAST_96_XX +X-Spam-Level: +X-Archive-Number: 200504/171 +X-Sequence-Number: 11568 + +The recompile was done by the sysadmin, but I believe the flags are -pg +-DLINUX_PROFILING for profiling, and -g for debug symbols. +This leaves gmon.out files around, which you can then do a "gprof +/usr/bin/postmaster gmon.out" to see whats going on. + +My problem is that this gives me data on what functions are being called +with respect to the postmaster binary, but I don't know +which of my functions - in my shared library - in my C procedure are +taking the most time. + +-Adam +Mohan, Ross wrote: + +>Adam - +> +>Is compiling postmaster with profiling support just a flag +>in the build/make? Or is there something more involved? +> +>I'd like to be able to do this in the future and so am +>curious about means/methods. +> +>If this is a RTFM, just let me know that (am currently +>Reading The F Manual), but if you have any "special sauce" +>here, that'd be of great interest. +> +>Thanks +> +>-Ross +> +>-----Original Message----- +>From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Adam Palmblad +>Sent: Wednesday, April 06, 2005 7:23 PM +>To: pgsql-performance@postgresql.org +>Subject: [PERFORM] Tweaking a C Function I wrote +> +> +>I wanted to see if I could squeeze any more performance out of a C set +>returning function I wrote. As such, I looked to a profiler. Is it +>possible to get profile information on the function I wrote? I've got +>postmaster and my function compiled with profiling support, and can find +>the gmon.out files... can I actually look at the call tree that occurs +>when my function is being executed or will I be limited to viewing calls +>to functions in the postmaster binary? +> +>-Adam +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> +> +> +> + + +From pgsql-hackers-win32-owner@postgresql.org Tue Mar 8 04:14:29 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F271564D1; + Mon, 7 Mar 2005 22:30:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27420-07; Mon, 7 Mar 2005 22:30:45 +0000 (GMT) +Received: from asg002.asg.local (smtp2.arrayservicesgrp.com [208.14.218.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 590BD56419; + Mon, 7 Mar 2005 22:30:44 +0000 (GMT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: [PERFORM] Help with tuning this query (with +Date: Mon, 7 Mar 2005 16:30:40 -0600 +Message-ID: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846A@asg002.asg.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [pgsql-hackers-win32] [PERFORM] Help with tuning this query + (with +Thread-Index: AcUjRIDds63QOQN3RpiRXXzvtyH7wgAIJXAw +From: "Dave Held" +To: "Greg Stark" , + "John A Meinel" +Cc: "Tom Lane" , "Magnus Hagander" , + "Ken Egervari" , , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/69 +X-Sequence-Number: 3027 + +> -----Original Message----- +> From: Greg Stark [mailto:gsstark@mit.edu] +> Sent: Monday, March 07, 2005 12:06 PM +> To: John A Meinel +> Cc: Tom Lane; Magnus Hagander; Ken Egervari; +> pgsql-performance@postgresql.org; pgsql-hackers-win32@postgresql.org +> Subject: Re: [pgsql-hackers-win32] [PERFORM] Help with tuning=20 +> this query (with +> [...] +> What would be really neato would be to use the rtdsc (sp?) or=20 +> equivalent assembly instruction where available. Most processors +> provide such a thing and it would give much lower overhead and much +> more accurate answers. +>=20 +> The main problem I see with this would be on multi-processor +> machines. (QueryPerformanceCounter does work properly on=20 +> multi-processor machines, right?) + +I believe QueryPerformanceCounter() already does this. + +__ +David B. Held +Software Engineer/Array Services Group +200 14th Ave. East, Sartell, MN 56377 +320.534.3637 320.253.7800 800.752.8129 + +From pgsql-hackers-win32-owner@postgresql.org Tue Mar 8 04:14:02 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6AB45564D1; + Mon, 7 Mar 2005 22:34:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28892-03; Mon, 7 Mar 2005 22:34:35 +0000 (GMT) +Received: from asg002.asg.local (smtp2.arrayservicesgrp.com [208.14.218.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 8ECD35647E; + Mon, 7 Mar 2005 22:34:33 +0000 (GMT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: [PERFORM] Help with tuning this query (with explain analyze + finally) +Date: Mon, 7 Mar 2005 16:34:32 -0600 +Message-ID: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846B@asg002.asg.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [pgsql-hackers-win32] [PERFORM] Help with tuning this query + (with explain analyze finally) +Thread-Index: AcUjO+Rv4481UOS/TZ6BTTI8D4hjfgAKYKvw +From: "Dave Held" +To: "Tom Lane" , + "John A Meinel" +Cc: "Magnus Hagander" , "Ken Egervari" , + , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.122 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/68 +X-Sequence-Number: 3026 + +> -----Original Message----- +> From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +> Sent: Monday, March 07, 2005 10:39 AM +> To: John A Meinel +> Cc: Magnus Hagander; Ken Egervari; pgsql-performance@postgresql.org; +> pgsql-hackers-win32@postgresql.org +> Subject: Re: [pgsql-hackers-win32] [PERFORM] Help with tuning=20 +> this query +> (with explain analyze finally) +>=20 +> [...] +> The EXPLAIN ANALYZE instrumentation code will really be happier with a +> straight time-since-bootup counter; by using gettimeofday, it is +> vulnerable to giving wrong answers if someone changes the date setting +> while the EXPLAIN is running. But there is (AFAIK) no such call among +> the portable Unix syscalls. It seems reasonable to me to #ifdef that +> code to make use of QueryPerformanceCounter on Windows. This does not +> mean we want to alter the behavior of gettimeofday() where it's being +> used to find out the time of day. + +There is always clock(). It's mandated by ANSI C, but my docs say +that POSIX requires CLOCKS_PER_SEC =3D=3D 1000000 regardless of actual +timer resolution, which seems a little brain-dead to me. + +__ +David B. Held +Software Engineer/Array Services Group +200 14th Ave. East, Sartell, MN 56377 +320.534.3637 320.253.7800 800.752.8129 + +From pgsql-hackers-win32-owner@postgresql.org Mon Mar 7 22:48:30 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 168D5564D1; + Mon, 7 Mar 2005 22:48:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30623-07; Mon, 7 Mar 2005 22:48:27 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 7160A56495; + Mon, 7 Mar 2005 22:48:16 +0000 (GMT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j27MmC313707; + Mon, 7 Mar 2005 16:48:12 -0600 +Message-ID: <422CDA2A.1000105@arbash-meinel.com> +Date: Mon, 07 Mar 2005 16:48:10 -0600 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Dave Held +Cc: pgsql-performance@postgresql.org, + pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] Help with tuning this query (with +References: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846B@asg002.asg.local> +In-Reply-To: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846B@asg002.asg.local> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig3C838764BDD360BA5B5CDC40" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/56 +X-Sequence-Number: 3014 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig3C838764BDD360BA5B5CDC40 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Dave Held wrote: + +>There is always clock(). It's mandated by ANSI C, but my docs say +>that POSIX requires CLOCKS_PER_SEC == 1000000 regardless of actual +>timer resolution, which seems a little brain-dead to me. +> +>__ +>David B. Held +> +> + +My experience with clock() on win32 is that CLOCKS_PER_SEC was 1000, and +it had a resolution of 55clocks / s. When I just did this: + +int main(int argc, char **argv) +{ + int start = clock(); + int now = start; + cout << "Clock: " << CLOCKS_PER_SEC << endl; + for(int i = 0; i < 10; ++i) { + while(now == clock()) { + // Do nothing + } + now = clock(); + cout << now-start << "\t" << (now - start) / (double) +CLOCKS_PER_SEC << endl; + } +} + +I got: +Clock: 1000 +16 0.016 +31 0.031 +47 0.047 +62 0.062 +78 0.078 +93 0.093 +109 0.109 +125 0.125 +141 0.141 +156 0.156 + +Which is about 1/0.016 = 62.5 clocks per second. +I'm pretty sure this is slightly worse than what we want. :) +It might be better on other platforms, but on win32 clock() is most +definitely *not* what you want. +John +=:-> + + +--------------enig3C838764BDD360BA5B5CDC40 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCLNoqJdeBCYSNAAMRAirhAJ9F+kf/UrfrETjIkHsuNHlFD9HLlACgkxOo +9G1LiIrMDp6AhEwKYL04EPo= +=vnxj +-----END PGP SIGNATURE----- + +--------------enig3C838764BDD360BA5B5CDC40-- + +From pgsql-hackers-win32-owner@postgresql.org Mon Mar 7 22:56:55 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0483656441; + Mon, 7 Mar 2005 22:56:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34310-05; Mon, 7 Mar 2005 22:56:43 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C084563A7; + Mon, 7 Mar 2005 22:56:42 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j27Mud72015995; + Mon, 7 Mar 2005 17:56:39 -0500 (EST) +To: John A Meinel +Cc: Dave Held , + pgsql-performance@postgresql.org, pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] Help with tuning this query (with +In-reply-to: <422CDA2A.1000105@arbash-meinel.com> +References: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846B@asg002.asg.local> + <422CDA2A.1000105@arbash-meinel.com> +Comments: In-reply-to John A Meinel + message dated "Mon, 07 Mar 2005 16:48:10 -0600" +Date: Mon, 07 Mar 2005 17:56:39 -0500 +Message-ID: <15994.1110236199@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/57 +X-Sequence-Number: 3015 + +John A Meinel writes: +> Dave Held wrote: +>> There is always clock(). + +> My experience with clock() on win32 is that CLOCKS_PER_SEC was 1000, and +> it had a resolution of 55clocks / s. When I just did this: + +The other problem is it measures process CPU time, not elapsed time +which is probably more significant for our purposes. + +Which brings up a question: just what does QueryPerformanceCounter +measure? + + regards, tom lane + +From pgsql-hackers-win32-owner@postgresql.org Mon Mar 7 23:09:10 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 66A7C564CE; + Mon, 7 Mar 2005 23:09:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37953-02; Mon, 7 Mar 2005 23:08:56 +0000 (GMT) +Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net + [194.217.242.89]) + by svr1.postgresql.org (Postfix) with ESMTP id 1329B5513E; + Mon, 7 Mar 2005 23:08:55 +0000 (GMT) +Received: from mailgate.vale-housing.co.uk ([194.217.48.34] + helo=ratbert.vale-housing.co.uk) + by anchor-post-31.mail.demon.net with esmtp (Exim 4.42) + id 1D8RJU-0004we-3T; Mon, 07 Mar 2005 23:07:00 +0000 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: [PERFORM] Help with tuning this query (with +Date: Mon, 7 Mar 2005 23:08:57 -0000 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [pgsql-hackers-win32] [PERFORM] Help with tuning this query + (with +Thread-Index: AcUjaQVOY3Pu9mSJQW6+4tclvC+8fgAAT77A +From: "Dave Page" +To: "Tom Lane" , + "John A Meinel" +Cc: "Dave Held" , + , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/58 +X-Sequence-Number: 3016 + +=20 + +> -----Original Message----- +> From: pgsql-hackers-win32-owner@postgresql.org=20 +> [mailto:pgsql-hackers-win32-owner@postgresql.org] On Behalf=20 +> Of Tom Lane +> Sent: 07 March 2005 22:57 +> To: John A Meinel +> Cc: Dave Held; pgsql-performance@postgresql.org;=20 +> pgsql-hackers-win32@postgresql.org +> Subject: Re: [pgsql-hackers-win32] [PERFORM] Help with tuning=20 +> this query (with=20 +>=20 +> Which brings up a question: just what does QueryPerformanceCounter +> measure? + +http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/winui/= +w +inui/windowsuserinterface/windowing/timers/abouttimers.asp says: + +If a high-resolution performance counter exists on the system, you can +use the QueryPerformanceFrequency function to express the frequency, in +counts per second. The value of the count is processor dependent. On +some processors, for example, the count might be the cycle rate of the +processor clock. + +The QueryPerformanceCounter function retrieves the current value of the +high-resolution performance counter. By calling this function at the +beginning and end of a section of code, an application essentially uses +the counter as a high-resolution timer. For example, suppose that +QueryPerformanceFrequency indicates that the frequency of the +high-resolution performance counter is 50,000 counts per second. If the +application calls QueryPerformanceCounter immediately before and +immediately after the section of code to be timed, the counter values +might be 1500 counts and 3500 counts, respectively. These values would +indicate that .04 seconds (2000 counts) elapsed while the code executed. + + +Regards, Dave. + +From pgsql-hackers-win32-owner@postgresql.org Tue Mar 8 04:12:34 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E79A1564A7; + Mon, 7 Mar 2005 23:15:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39890-01; Mon, 7 Mar 2005 23:15:48 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 7BD1656488; + Mon, 7 Mar 2005 23:15:47 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1D8RRh-0003wi-00; Mon, 07 Mar 2005 18:15:29 -0500 +To: "Dave Held" +Cc: "Greg Stark" , "John A Meinel" , + "Tom Lane" , "Magnus Hagander" , + "Ken Egervari" , , + +Subject: Re: [PERFORM] Help with tuning this query (with +References: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846A@asg002.asg.local> +In-Reply-To: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846A@asg002.asg.local> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 07 Mar 2005 18:15:29 -0500 +Message-ID: <87br9v9hf2.fsf@stark.xeocode.com> +Lines: 31 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.014 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/63 +X-Sequence-Number: 3021 + + +"Dave Held" writes: + +> > What would be really neato would be to use the rtdsc (sp?) or +> > equivalent assembly instruction where available. Most processors +> > provide such a thing and it would give much lower overhead and much +> > more accurate answers. +> > +> > The main problem I see with this would be on multi-processor +> > machines. (QueryPerformanceCounter does work properly on +> > multi-processor machines, right?) +> +> I believe QueryPerformanceCounter() already does this. + +This would be a good example of why selectively quoting the part of the +message to which you're responding to is more useful than just blindly echoing +my message back to me. + +Already does what? + +Use rtdsc? In which case using it would be a mistake. Since rtdsc doesn't work +across processors. And using it via QueryPerformanceCounter would be a +non-portable approach to using rtdsc. Much better to devise a portable +approach that works on any architecture where something equivalent is +available. + +Or already works on multi-processor machines? In which case, uh, ok. + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Mar 8 04:25:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 13C2356404 + for ; + Mon, 7 Mar 2005 23:39:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43874-07 + for ; + Mon, 7 Mar 2005 23:39:46 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D155156424 + for ; + Mon, 7 Mar 2005 23:39:42 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id A4E8231FC9; Tue, 8 Mar 2005 00:39:45 +0100 (MET) +From: "Michael McFarland" +X-Newsgroups: pgsql.performance +Subject: adding 'limit' leads to very slow query +Date: Mon, 07 Mar 2005 18:39:43 -0500 +Organization: Hub.Org Networking Services +Lines: 38 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; delsp=yes; charset=us-ascii +Content-Transfer-Encoding: Quoted-Printable +X-Complaints-To: usenet@news.hub.org +User-Agent: Opera M2(BETA1)/8.00 (Linux, build 913) +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=2.174 tagged_above=0 required=5 tests=FORGED_YAHOO_RCVD +X-Spam-Level: ** +X-Archive-Number: 200503/114 +X-Sequence-Number: 10819 + + I'm trying to understand why a particular query is slow, and it seems= + = + +like the optimizer is choosing a strange plan. See this summary: + + +* I have a large table, with an index on the primary key 'id' and on a = + +field 'foo'. +> select count(*) from foo; +1,000,000 +> select count(*) from foo where bar =3D 41; +7 + +* This query happens very quickly. +> explain select * from foo where barId =3D 412 order by id desc; +Sort () + Sort key=3D id + -> Index scan using bar_index on foo () + Index cond: barId =3D 412 + +But this query takes forever + +> explain select * from foo where barId =3D 412 order by id desc limit 2= +5; +Limit () + -> Index scan backward using primarykey_index + Filter: barID =3D 412 + + +Could anyone shed some light on what might be happening here? + + - Michael + + +-- = + +Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ + +From pgsql-performance-owner@postgresql.org Tue Mar 8 04:25:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 708FE56539 + for ; + Mon, 7 Mar 2005 23:54:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49066-02 + for ; + Mon, 7 Mar 2005 23:54:07 +0000 (GMT) +Received: from web42106.mail.yahoo.com (web42106.mail.yahoo.com + [66.218.93.199]) + by svr1.postgresql.org (Postfix) with SMTP id 91D1556535 + for ; + Mon, 7 Mar 2005 23:54:05 +0000 (GMT) +Received: (qmail 30051 invoked by uid 60001); 7 Mar 2005 23:54:08 -0000 +Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + b=uNEpwc6gkcBZknkBcRBZzvvuvYPjdySyKbzPHvJI8m/DF9aF1k2wJuOlqzV76WYx5gXKhjTlDplmPJ9Cl5gEMdlRRf+SmsxnErOjFYb3I6e3nLbEZmqXpPsLadxXx8rFHlMJSHNdDeiKJl/ziebdCJxmMIsbqrX8K8jDHgyRcUc= + ; +Message-ID: <20050307235408.30049.qmail@web42106.mail.yahoo.com> +Received: from [64.40.43.71] by web42106.mail.yahoo.com via HTTP; + Mon, 07 Mar 2005 15:54:08 PST +Date: Mon, 7 Mar 2005 15:54:08 -0800 (PST) +From: jesse d +Subject: Help with slow running query +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.251 tagged_above=0 required=5 + tests=DNS_FROM_RFC_ABUSE, FROM_ENDS_IN_NUMS, FROM_HAS_ULINE_NUMS +X-Spam-Level: * +X-Archive-Number: 200503/115 +X-Sequence-Number: 10820 + +The following query takes approx. 3-5+ minutes +to complete. I would like to get this down to around +2-3 seconds. Other RDBMS complete it in <1 second. + +I am running 8.0.1 on XP P4 2.6 1GB for dev work. + +select i.internalid, c.code +from local.internal i +inner join country.ip c on +(i.ip between c.startip and c.endip) + +Nested Loop (cost=167.59..7135187.85 rows=31701997 +width=10) (actual +time=63.000..776094.000 rows=5235 loops=1) + Join Filter: ((inner.ip >= outer.startip) AND +(inner.ip <= +outer.endip)) + -> Seq Scan on ip c (cost=0.00..2071.02 rows=54502 +width=28) +(actual time=0.000..313.000 rows=54502 loops=1) + -> Materialize (cost=167.59..219.94 rows=5235 +width=15) (actual +time=0.000..2.973 rows=5235 loops=54502) + -> Seq Scan on internal i (cost=0.00..162.35 +rows=5235 +width=15) (actual time=0.000..16.000 rows=5235 +loops=1) +Total runtime: 776110.000 ms + + +-- data from ip-to-country.webhosting.info +CREATE TABLE country.ip -- 54,502 rows +( + startip inet NOT NULL, + endip inet NOT NULL, + code char(2) NOT NULL, + CONSTRAINT ip_pkey PRIMARY KEY (startip, endip) +); +-- 1, 192.168.1.10, 192.168.2.100, US +-- 2, 192.168.3.0, 192.168.3.118, US + +CREATE TABLE local.internal -- 5000+ rows +( + internalid serial NOT NULL, + ip inet NOT NULL, + port int2 NOT NULL, + CONSTRAINT internal_pkey PRIMARY KEY (internalid) +); +CREATE INDEX ip_idx ON local.internal (ip); +-- 1, 10.0.0.100, 80 +-- 2, 10.0.0.102, 80 +-- 3, 10.0.0.103, 443 + +-- +postgresql.conf +have tried many settings with no improvement +max_connections = 50 +shared_buffers = 30000 +work_mem = 2048 +sort_mem = 2048 + + +Have tried many different indexes with no help: +CREATE INDEX endip_idx ON country.ip; +CREATE INDEX startip_idx ON country.ip; +CREATE UNIQUE INDEX e_s_idx ON country.ip + (endip, startip); + + +Any suggestions would be greatly appreciated. + + + + +__________________________________ +Celebrate Yahoo!'s 10th Birthday! +Yahoo! Netrospective: 100 Moments of the Web +http://birthday.yahoo.com/netrospective/ + +From pgsql-hackers-win32-owner@postgresql.org Tue Mar 8 04:11:58 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EDEE5636A; + Tue, 8 Mar 2005 00:11:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52537-09; Tue, 8 Mar 2005 00:11:48 +0000 (GMT) +Received: from asg002.asg.local (smtp2.arrayservicesgrp.com [208.14.218.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C1D8560C5; + Tue, 8 Mar 2005 00:11:45 +0000 (GMT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: [PERFORM] Help with tuning this query (with +Date: Mon, 7 Mar 2005 18:11:34 -0600 +Message-ID: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846C@asg002.asg.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [pgsql-hackers-win32] [PERFORM] Help with tuning this query + (with +Thread-Index: AcUja8t+taMVcvO1T72Xv6+ZIZrUjgABlAyg +From: "Dave Held" +To: "Greg Stark" +Cc: "John A Meinel" , "Tom Lane" , + "Magnus Hagander" , "Ken Egervari" , + , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.113 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/61 +X-Sequence-Number: 3019 + +> -----Original Message----- +> From: Greg Stark [mailto:gsstark@mit.edu] +> Sent: Monday, March 07, 2005 5:15 PM +> To: Dave Held +> Cc: Greg Stark; John A Meinel; Tom Lane; Magnus Hagander; Ken=20 +> Egervari; +> pgsql-performance@postgresql.org; pgsql-hackers-win32@postgresql.org +> Subject: Re: [pgsql-hackers-win32] [PERFORM] Help with tuning=20 +> this query +> (with +>=20 +> "Dave Held" writes: +>=20 +> > > What would be really neato would be to use the rtdsc (sp?) or=20 +> > > equivalent assembly instruction where available. Most +> > > processors provide such a thing and it would give much lower=20 +> > > overhead and much more accurate answers. +> > >=20 +> > > The main problem I see with this would be on multi-processor +> > > machines. (QueryPerformanceCounter does work properly on=20 +> > > multi-processor machines, right?) +> >=20 +> > I believe QueryPerformanceCounter() already does this. +> [...] +> Already does what?=20 +>=20 +> Use rtdsc? + +Yes. + +> In which case using it would be a mistake. Since rtdsc doesn't +> work across processors. + +It doesn't always use RDTSC. I can't find anything authoritative on +when it does. I would assume that it would use RDTSC when available +and something else otherwise. + +> And using it via QueryPerformanceCounter would be a non-portable +> approach to using rtdsc. Much better to devise a portable +> approach that works on any architecture where something equivalent +> is available. + +How do you know that QueryPerformanceCounter doesn't use RDTSC +where available, and something appropriate otherwise? I don't see +how any strategy that explicitly executes RDTSC can be called=20 +"portable". + +> Or already works on multi-processor machines? In which case, uh, ok. + +According to MSDN it does work on MP systems, and they say that "it +doesn't matter which CPU gets called". + +__ +David B. Held +Software Engineer/Array Services Group +200 14th Ave. East, Sartell, MN 56377 +320.534.3637 320.253.7800 800.752.8129 + +From pgsql-hackers-win32-owner@postgresql.org Tue Mar 8 04:13:03 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C22B5641F; + Tue, 8 Mar 2005 00:29:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57019-02; Tue, 8 Mar 2005 00:29:42 +0000 (GMT) +Received: from asg002.asg.local (smtp2.arrayservicesgrp.com [208.14.218.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F2B65612C; + Tue, 8 Mar 2005 00:29:39 +0000 (GMT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: [PERFORM] Help with tuning this query (with +Date: Mon, 7 Mar 2005 18:29:31 -0600 +Message-ID: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846D@asg002.asg.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [pgsql-hackers-win32] [PERFORM] Help with tuning this query + (with +Thread-Index: AcUjaRPKtimVfn82RBuz4+nbTxh8mgACpPQw +From: "Dave Held" +To: "Tom Lane" , + "John A Meinel" +Cc: , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.105 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/66 +X-Sequence-Number: 3024 + +> -----Original Message----- +> From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +> Sent: Monday, March 07, 2005 4:57 PM +> To: John A Meinel +> Cc: Dave Held; pgsql-performance@postgresql.org; +> pgsql-hackers-win32@postgresql.org +> Subject: Re: [pgsql-hackers-win32] [PERFORM] Help with tuning=20 +> this query +> (with +>=20 +> John A Meinel writes: +> > Dave Held wrote: +> >> There is always clock(). +>=20 +> > My experience with clock() on win32 is that CLOCKS_PER_SEC=20 +> > was 1000, and it had a resolution of 55clocks / s. + +Which is why I suggested QueryPerformanceCounter for Win32. I +only suggested clock() for *nix. + +> The other problem is it measures process CPU time, not elapsed time +> which is probably more significant for our purposes. + +Actually, the bigger problem is that a quick test of clock() on +Linux shows that it only has a maximum resolution of 10ms on my +hardware. Looks like gettimeofday() is the best choice. + +> Which brings up a question: just what does QueryPerformanceCounter +> measure? + +I think it measures raw CPU cycles, roughly, which seems like it=20 +would more or less correspond to wall time. + +__ +David B. Held +Software Engineer/Array Services Group +200 14th Ave. East, Sartell, MN 56377 +320.534.3637 320.253.7800 800.752.8129 + +From pgsql-hackers-win32-owner@postgresql.org Tue Mar 8 04:12:36 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 10DF052AA6; + Tue, 8 Mar 2005 01:38:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77490-07; Tue, 8 Mar 2005 01:38:12 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 9036C56491; + Tue, 8 Mar 2005 01:38:11 +0000 (GMT) +Received: from trofast.ipv6.sesse.net ([2001:700:300:dc03:20e:cff:fe36:a766] + helo=trofast.sesse.net) + by cassarossa.samfundet.no with esmtp (Exim 4.34) + id 1D8TfW-0004j5-NJ; Tue, 08 Mar 2005 02:37:58 +0100 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1D8TfT-0007lE-00; Tue, 08 Mar 2005 02:37:51 +0100 +Date: Tue, 8 Mar 2005 02:37:50 +0100 +From: "Steinar H. Gunderson" +To: Dave Held +Cc: Greg Stark , + John A Meinel , Tom Lane , + Magnus Hagander , + Ken Egervari , pgsql-performance@postgresql.org, + pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] Help with tuning this query (with +Message-ID: <20050308013750.GA29367@uio.no> +Mail-Followup-To: Dave Held , + Greg Stark , John A Meinel , + Tom Lane , Magnus Hagander , + Ken Egervari , pgsql-performance@postgresql.org, + pgsql-hackers-win32@postgresql.org +References: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846C@asg002.asg.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846C@asg002.asg.local> +X-Operating-System: Linux 2.6.11-rc3 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.6+20040907i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.026 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/64 +X-Sequence-Number: 3022 + +On Mon, Mar 07, 2005 at 06:11:34PM -0600, Dave Held wrote: +>> In which case using it would be a mistake. Since rtdsc doesn't +>> work across processors. +> It doesn't always use RDTSC. I can't find anything authoritative on +> when it does. I would assume that it would use RDTSC when available +> and something else otherwise. + +RDTSC is a bad source of information for this kind of thing, as the CPU +frequency might vary. Check your QueryPerformanceFrequency() -- most likely +it will not match your clock speed. I haven't tested on a lot of machines, +but I've never seen QueryPerformanceFrequency() ever match the clock speed, +which it most probably would if it was using RDTSC. (I've been told it uses +some other kind of timer available on most motherboards, but I don't know the +details.) + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-hackers-win32-owner@postgresql.org Tue Mar 8 02:03:00 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1615D563D4 + for ; + Tue, 8 Mar 2005 02:02:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82538-08 + for ; + Tue, 8 Mar 2005 02:02:48 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 9651354E9E + for ; + Tue, 8 Mar 2005 02:02:48 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2822cpk001972; + Mon, 7 Mar 2005 21:02:38 -0500 (EST) +To: "Steinar H. Gunderson" +Cc: Dave Held , + Greg Stark , John A Meinel , + Magnus Hagander , + Ken Egervari , pgsql-performance@postgresql.org, + pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] Help with tuning this query (with +In-reply-to: <20050308013750.GA29367@uio.no> +References: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846C@asg002.asg.local> + <20050308013750.GA29367@uio.no> +Comments: In-reply-to "Steinar H. Gunderson" + message dated "Tue, 08 Mar 2005 02:37:50 +0100" +Date: Mon, 07 Mar 2005 21:02:38 -0500 +Message-ID: <1971.1110247358@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/59 +X-Sequence-Number: 3017 + +"Steinar H. Gunderson" writes: +> RDTSC is a bad source of information for this kind of thing, as the CPU +> frequency might vary. + +One thought that was bothering me was that if the CPU goes idle while +waiting for disk I/O, its clock might stop or slow down dramatically. +If we believed such a counter for EXPLAIN, we'd severely understate +the cost of disk I/O. + +I dunno if that is the case on any Windows hardware or not, but none +of this thread is making me feel confident that we know what +QueryPerformanceCounter does measure. + + regards, tom lane + +From pgsql-hackers-win32-owner@postgresql.org Tue Mar 8 04:12:02 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BCFCD56388; + Tue, 8 Mar 2005 02:06:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83425-07; Tue, 8 Mar 2005 02:06:41 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id CDC1252AA6; + Tue, 8 Mar 2005 02:06:40 +0000 (GMT) +Received: from trofast.ipv6.sesse.net ([2001:700:300:dc03:20e:cff:fe36:a766] + helo=trofast.sesse.net) + by cassarossa.samfundet.no with esmtp (Exim 4.34) + id 1D8U7A-0004tL-N6; Tue, 08 Mar 2005 03:06:29 +0100 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1D8U76-0000Hn-00; Tue, 08 Mar 2005 03:06:24 +0100 +Date: Tue, 8 Mar 2005 03:06:24 +0100 +From: "Steinar H. Gunderson" +To: Tom Lane +Cc: Dave Held , + Greg Stark , John A Meinel , + Magnus Hagander , + Ken Egervari , pgsql-performance@postgresql.org, + pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] Help with tuning this query (with +Message-ID: <20050308020624.GA753@uio.no> +Mail-Followup-To: Tom Lane , + Dave Held , + Greg Stark , John A Meinel , + Magnus Hagander , + Ken Egervari , pgsql-performance@postgresql.org, + pgsql-hackers-win32@postgresql.org +References: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846C@asg002.asg.local> + <20050308013750.GA29367@uio.no> <1971.1110247358@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <1971.1110247358@sss.pgh.pa.us> +X-Operating-System: Linux 2.6.11-rc3 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.6+20040907i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/62 +X-Sequence-Number: 3020 + +On Mon, Mar 07, 2005 at 09:02:38PM -0500, Tom Lane wrote: +> One thought that was bothering me was that if the CPU goes idle while +> waiting for disk I/O, its clock might stop or slow down dramatically. +> If we believed such a counter for EXPLAIN, we'd severely understate +> the cost of disk I/O. +> +> I dunno if that is the case on any Windows hardware or not, but none +> of this thread is making me feel confident that we know what +> QueryPerformanceCounter does measure. + +I believe the counter is actually good in such a situation -- I'm not a Win32 +guru, but I believe it is by far the best timer for measuring, well, +performance of a process like this. After all, it's what it was designed to +be :-) + +OBTW, I think I can name something like 15 or 20 different function calls to +measure time in the Win32 API (all of them in use); it really is a giant +mess. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-hackers-win32-owner@postgresql.org Tue Mar 8 04:12:57 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 20BC356487 + for ; + Tue, 8 Mar 2005 03:53:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18170-07 + for ; + Tue, 8 Mar 2005 03:52:50 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id B518152A8F + for ; + Tue, 8 Mar 2005 03:52:48 +0000 (GMT) +Received: (qmail 14677 invoked from network); 8 Mar 2005 04:53:41 +0100 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 8 Mar 2005 04:53:41 +0100 +To: "Steinar H. Gunderson" , + "Tom Lane" +Cc: "Dave Held" , + "Greg Stark" , "John A Meinel" , + "Magnus Hagander" , + "Ken Egervari" , pgsql-performance@postgresql.org, + pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] Help with tuning this query (with +References: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846C@asg002.asg.local> + <20050308013750.GA29367@uio.no> <1971.1110247358@sss.pgh.pa.us> + <20050308020624.GA753@uio.no> +Message-ID: +Date: Tue, 08 Mar 2005 04:51:43 +0100 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <20050308013750.GA29367@uio.no> +User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/65 +X-Sequence-Number: 3023 + + + From the Linux Kernel (make menuconfig) there seem to be two new reliable +sources for timing information. Note the remark about "Time Stamp Counter" +below. Question is, which one of these (or others) are your API functions +using ? I have absolutely no idea ! + + +CONFIG_HPET_TIMER: +This enables the use of the HPET for the kernel's internal timer. + HPET is the next generation timer replacing legacy 8254s. + You can safely choose Y here. However, HPET will only be + activated if the platform and the BIOS support this feature. + Otherwise the 8254 will be used for timing services. + Choose N to continue using the legacy 8254 timer. + Symbol: HPET_TIMER [=y] + Prompt: HPET Timer Support + Defined at arch/i386/Kconfig:440 + Location: + -> Processor type and features + +CONFIG_X86_PM_TIMER: +The Power Management Timer is available on all +ACPI-capable, in most cases even if +ACPI is unusable or blacklisted. +This timing source is not affected by powermanagement +features like aggressive processor +idling, throttling, frequency and/or +voltage scaling, unlike the commonly used Time Stamp +Counter (TSC) timing source. + So, if you see messages like 'Losing too many ticks!' in +the kernel logs, and/or you are using +this on a notebook which does not +yet have an HPET, you should say "Y" here. + Symbol: X86_PM_TIMER +[=y] +Prompt: Power Management Timer +Support +Defined at +drivers/acpi/Kconfig:319 +Depends on: !X86_VOYAGER && !X86_VISWS && !IA64_HP_SIM && (IA64 || X86) && +X86 && ACPI && ACPI_ + Location: +-> Power management options (ACPI, +APM) -> ACPI +(Advanced Configuration and Power Interface) +Support -> ACPI Support (ACPI [=y]) + + + + + + + + + +On Tue, 08 Mar 2005 03:06:24 +0100, Steinar H. Gunderson + wrote: + +> On Mon, Mar 07, 2005 at 09:02:38PM -0500, Tom Lane wrote: +>> One thought that was bothering me was that if the CPU goes idle while +>> waiting for disk I/O, its clock might stop or slow down dramatically. +>> If we believed such a counter for EXPLAIN, we'd severely understate +>> the cost of disk I/O. +>> +>> I dunno if that is the case on any Windows hardware or not, but none +>> of this thread is making me feel confident that we know what +>> QueryPerformanceCounter does measure. +> +> I believe the counter is actually good in such a situation -- I'm not a +> Win32 +> guru, but I believe it is by far the best timer for measuring, well, +> performance of a process like this. After all, it's what it was designed +> to +> be :-) +> +> OBTW, I think I can name something like 15 or 20 different function +> calls to +> measure time in the Win32 API (all of them in use); it really is a giant +> mess. +> +> /* Steinar */ + + + +From pgsql-hackers-win32-owner@postgresql.org Tue Mar 8 04:36:45 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C1562564E3; + Tue, 8 Mar 2005 04:35:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34029-02; Tue, 8 Mar 2005 04:35:16 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 74C0D53DCA; + Tue, 8 Mar 2005 04:35:14 +0000 (GMT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j284ZB316350; + Mon, 7 Mar 2005 22:35:11 -0600 +Message-ID: <422D2B7D.5080702@arbash-meinel.com> +Date: Mon, 07 Mar 2005 22:35:09 -0600 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Dave Held , + pgsql-performance@postgresql.org, pgsql-hackers-win32@postgresql.org +Subject: Re: [PERFORM] Help with tuning this query (with +References: <49E94D0CFCD4DB43AFBA928DDD20C8F90261846B@asg002.asg.local> + <422CDA2A.1000105@arbash-meinel.com> + <15994.1110236199@sss.pgh.pa.us> +In-Reply-To: <15994.1110236199@sss.pgh.pa.us> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigC693134A2FD033AA11630BAA" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/71 +X-Sequence-Number: 3029 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigC693134A2FD033AA11630BAA +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>John A Meinel writes: +> +> +>>Dave Held wrote: +>> +>> +>>>There is always clock(). +>>> +>>> +> +> +> +>>My experience with clock() on win32 is that CLOCKS_PER_SEC was 1000, and +>>it had a resolution of 55clocks / s. When I just did this: +>> +>> +> +>The other problem is it measures process CPU time, not elapsed time +>which is probably more significant for our purposes. +> +>Which brings up a question: just what does QueryPerformanceCounter +>measure? +> +> regards, tom lane +> +> +clock() according to the Visual Studio Help measures wall clock time. +But you're right, POSIX says it is approximation of processor time. + +The docs don't say specifically what QueryPerformanceCounter() measures, +but states + +> The *QueryPerformanceCounter* function retrieves the current value of +> the high-resolution performance counter. +> +It also states: + +> +> Remarks +> +> On a multiprocessor machine, it should not matter which processor is +> called. However, you can get different results on different processors +> due to bugs in the BIOS or the HAL. To specify processor affinity for +> a thread, use the *SetThreadAffinityMask* function. +> + +So it sounds like it is actually querying some counter independent of +processing. + +In fact, there is also this statement: + +> *QueryPerformanceFrequency* +> +> The QueryPerformanceFrequency function retrieves the frequency of the +> high-resolution performance counter, if one exists. The frequency +> cannot change while the system is running. +> +If that is accurate, it would make QueryPerformanceCounter independent +of things like speed stepping, etc. So again, it sounds independent of +processing. + +John +=:-> + + +--------------enigC693134A2FD033AA11630BAA +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCLSt9JdeBCYSNAAMRAkCJAKCwuSLVFX1TWf0fWGwJmTleLjR2igCgkFPC +SNF8uLWStHMD6OZC4RcWygk= +=2sNH +-----END PGP SIGNATURE----- + +--------------enigC693134A2FD033AA11630BAA-- + +From pgsql-performance-owner@postgresql.org Tue Mar 8 04:46:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CE2FE56455 + for ; + Tue, 8 Mar 2005 04:46:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36596-05 + for ; + Tue, 8 Mar 2005 04:46:40 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 6975655012 + for ; + Tue, 8 Mar 2005 04:46:40 +0000 (GMT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j284kd316450; + Mon, 7 Mar 2005 22:46:39 -0600 +Message-ID: <422D2E2D.5080305@arbash-meinel.com> +Date: Mon, 07 Mar 2005 22:46:37 -0600 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Michael McFarland +Cc: pgsql-performance@postgresql.org +Subject: Re: adding 'limit' leads to very slow query +References: +In-Reply-To: +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig5D767027BFABF85233AE18BF" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/119 +X-Sequence-Number: 10824 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig5D767027BFABF85233AE18BF +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Michael McFarland wrote: + +> I'm trying to understand why a particular query is slow, and it +> seems like the optimizer is choosing a strange plan. See this summary: +> +... + +>> explain select * from foo where barId = 412 order by id desc limit 25; +> +> Limit () +> -> Index scan backward using primarykey_index +> Filter: barID = 412 +> +> +> Could anyone shed some light on what might be happening here? +> +> - Michael + +It is using the wrong index. The problem is that order by + limit +generally means that you can use the index on the "+" to get the items +in the correct order. In this case, however, you need it to find all of +the barId=412 first, since apparently that is more selective than the limit. + +It really sounds like the postgres statistics are out of date. And +either you haven't run vacuum analyze recently, or you need to keep +higher statistics on either one or both of barId and id. + +John +=:-> + + +--------------enig5D767027BFABF85233AE18BF +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCLS4tJdeBCYSNAAMRAonGAKDSTmRTj+C+p021JDcPdt1eEMdrqQCfR3GV +MyZHj3Qy5dBfMTX5fxSrXXw= +=sc4R +-----END PGP SIGNATURE----- + +--------------enig5D767027BFABF85233AE18BF-- + +From pgsql-performance-owner@postgresql.org Tue Mar 8 07:03:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 95FE6564DC + for ; + Tue, 8 Mar 2005 07:03:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66244-05 + for ; + Tue, 8 Mar 2005 07:03:46 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 207FD564B6 + for ; + Tue, 8 Mar 2005 07:03:45 +0000 (GMT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id B7DFF353A4; Mon, 7 Mar 2005 23:03:43 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id B650F353A0; Mon, 7 Mar 2005 23:03:43 -0800 (PST) +Date: Mon, 7 Mar 2005 23:03:43 -0800 (PST) +From: Stephan Szabo +To: Michael McFarland +Cc: pgsql-performance@postgresql.org +Subject: Re: adding 'limit' leads to very slow query +In-Reply-To: +Message-ID: <20050307230123.L97147@megazone.bigpanda.com> +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/120 +X-Sequence-Number: 10825 + +On Mon, 7 Mar 2005, Michael McFarland wrote: + +> I'm trying to understand why a particular query is slow, and it seems +> like the optimizer is choosing a strange plan. See this summary: +> +> +> * I have a large table, with an index on the primary key 'id' and on a +> field 'foo'. +> > select count(*) from foo; +> 1,000,000 +> > select count(*) from foo where bar = 41; +> 7 +> +> * This query happens very quickly. +> > explain select * from foo where barId = 412 order by id desc; +> Sort () +> Sort key= id +> -> Index scan using bar_index on foo () +> Index cond: barId = 412 +> +> But this query takes forever +> +> > explain select * from foo where barId = 412 order by id desc limit 25; +> Limit () +> -> Index scan backward using primarykey_index +> Filter: barID = 412 + +You didn't show the row estimates, but I'd guess that it's expecting +either that ther are more rows that match barId=412 than there actually +are (which may be solvable by raising the statistics target on the column +and re-analyzing) such that going backwards on id in order to make 25 +matching rows isn't a bad plan or that barId and id are correlated which +is unfortunately not going to be recognized right now. + +From pgsql-performance-owner@postgresql.org Tue Mar 8 07:47:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 93FBF564CE + for ; + Tue, 8 Mar 2005 07:47:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77621-01 + for ; + Tue, 8 Mar 2005 07:47:37 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.204]) + by svr1.postgresql.org (Postfix) with ESMTP id 1DB1C563EF + for ; + Tue, 8 Mar 2005 07:47:36 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id a41so1268197rng + for ; + Mon, 07 Mar 2005 23:47:37 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=P6r8TwThCV+OYKFkFn7nbdY3LQKd4yJECnADpSclkVl+JfqPZ/rRtyUwkD63DY3LyhX1i/oTNAhhMtJA/bZJ9qECHBsmLiGvtBBu3mw/tr88V0ESkPteHuJ5G2Y+g+cVvIKU3wGqH/hcUcqSl0hNPDmHiiLK8xzrLxc4OBluwOM= +Received: by 10.38.149.41 with SMTP id w41mr168480rnd; + Mon, 07 Mar 2005 23:47:37 -0800 (PST) +Received: by 10.38.24.6 with HTTP; Mon, 7 Mar 2005 23:47:37 -0800 (PST) +Message-ID: <156a90fe05030723477c3ee7d3@mail.gmail.com> +Date: Tue, 8 Mar 2005 07:47:37 +0000 +From: +Reply-To: +To: Josh Berkus +Subject: Re: Tuning, configuration for 7.3.5 on a Sun E4500 +Cc: Postgres - Performance +In-Reply-To: <200503070931.06241.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <156a90fe050307064678d5a6e9@mail.gmail.com> + <200503070931.06241.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.408 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, NO_REAL_NAME, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/121 +X-Sequence-Number: 10826 + +Analyze has been run on the database quite frequently during the +course of us trying to figure out this performance issue. It is also +a task that is crontabbed nightly. + + +On Mon, 7 Mar 2005 09:31:06 -0800, Josh Berkus wrote: +> Tsarevich, +> +> > When running queries we are experiencing much bigger result times than +> > anticipated. +> > +> > Attached is a copy of our postgresql.conf file and of our the table +> > definitions and row counts. +> +> Looks like you haven't run ANALYZE on the database anytime recently. Try that +> and re-run. +> +> -- +> Josh Berkus +> Aglio Database Solutions +> San Francisco +> + +From pgsql-hackers-win32-owner@postgresql.org Tue Mar 8 09:05:19 2005 +X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E7EE4564E9; + Tue, 8 Mar 2005 09:05:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93860-08; Tue, 8 Mar 2005 09:05:12 +0000 (GMT) +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by svr1.postgresql.org (Postfix) with ESMTP id 35496564F0; + Tue, 8 Mar 2005 09:05:08 +0000 (GMT) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id 419888F282; Tue, 8 Mar 2005 10:05:09 +0100 (CET) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: [PERFORM] Help with tuning this query (with +Date: Tue, 8 Mar 2005 10:05:08 +0100 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE476A65@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [pgsql-hackers-win32] [PERFORM] Help with tuning this query + (with +Thread-Index: AcUjgvTP7b0/cgzzQfizdnyN8u6zTQAOf7/Q +From: "Magnus Hagander" +To: "Tom Lane" , + "Steinar H. Gunderson" +Cc: "Dave Held" , + "Greg Stark" , "John A Meinel" , + "Ken Egervari" , , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.071 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/72 +X-Sequence-Number: 3030 + +> > RDTSC is a bad source of information for this kind of thing, as the=20 +> > CPU frequency might vary. +>=20 +> One thought that was bothering me was that if the CPU goes=20 +> idle while waiting for disk I/O, its clock might stop or slow=20 +> down dramatically. +> If we believed such a counter for EXPLAIN, we'd severely=20 +> understate the cost of disk I/O. +>=20 +> I dunno if that is the case on any Windows hardware or not,=20 +> but none of this thread is making me feel confident that we=20 +> know what QueryPerformanceCounter does measure. + +I'm "reasonaly confident" that QPC will measure actual wallclock time as +passed, using a chip that is external to the CPU. (Don't ask me which +chip :P). + +The docs specifically say: "Note that the frequency of the +high-resolution performance counter is not the processor speed."=20 + +It also indicates that it is possible for hardware not to support it, in +which case the frequency will be reported as zero. I don't know any +remotely modern wintel system that doesn't, though - it seems this may +be referring to the old MIPS port of NT that didn't have it. + +I also find: +"Depending on the processor and exact version of NT you're using, on an +Intel you get either the Time Stamp Counter, or the 1.1... MHz timer +built into the motherboard." + + +So I think we're perfectly safe relying on it. And certainly not alone +in doing so :-) + +//Magnus + +From pgsql-performance-owner@postgresql.org Tue Mar 8 10:32:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 903695612C + for ; + Tue, 8 Mar 2005 10:32:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18972-03 + for ; + Tue, 8 Mar 2005 10:32:14 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id A33B052A77 + for ; + Tue, 8 Mar 2005 10:32:12 +0000 (GMT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j28BZHu14410 + for ; Tue, 8 Mar 2005 12:35:17 +0100 +Received: from [127.0.0.1] (accesspoint.mm.eutelsat.org [194.214.173.4]) + by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j28AWER31890 + for ; Tue, 8 Mar 2005 11:32:14 +0100 +Message-ID: <422D7F23.7000109@bigfoot.com> +Date: Tue, 08 Mar 2005 11:32:03 +0100 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Subject: bad plan +X-Enigmail-Version: 0.90.1.1 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=0.47 tagged_above=0 required=5 tests=TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200503/123 +X-Sequence-Number: 10828 + +I posted this on hackers, but I had to post it here. + +=================================================================================================================================== +Hi all, +running a 7.4.5 engine, I'm facing this bad plan: + + +empdb=# explain analyze SELECT name,url,descr,request_status,url_status,size_mb,estimated_start,request_time_stamp +empdb-# FROM v_sc_user_request +empdb-# WHERE +empdb-# login = 'babinow1' +empdb-# LIMIT 10 ; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + Limit (cost=1716.38..1716.39 rows=1 width=232) (actual time=52847.239..52847.322 rows=10 loops=1) + -> Subquery Scan v_sc_user_request (cost=1716.38..1716.39 rows=1 width=232) (actual time=52847.234..52847.301 rows=10 loops=1) + -> Sort (cost=1716.38..1716.39 rows=1 width=201) (actual time=52847.219..52847.227 rows=10 loops=1) + Sort Key: sr.id_sat_request + -> Nested Loop Left Join (cost=1478.82..1716.37 rows=1 width=201) (actual time=3254.483..52847.064 rows=31 loops=1) + Join Filter: ("outer".id_package = "inner".id_package) + -> Nested Loop (cost=493.09..691.55 rows=1 width=193) (actual time=347.665..940.582 rows=31 loops=1) + -> Nested Loop (cost=493.09..688.49 rows=1 width=40) (actual time=331.446..505.628 rows=31 loops=1) + Join Filter: ("inner".id_user = "outer".id_user) + -> Index Scan using user_login_login_key on user_login ul (cost=0.00..4.00 rows=2 width=16) (actual time=12.065..12.071 rows=1 loops=1) + Index Cond: ((login)::text = 'babinow1'::text) + -> Materialize (cost=493.09..531.37 rows=7656 width=28) (actual time=167.654..481.813 rows=8363 loops=1) + -> Seq Scan on sat_request sr (cost=0.00..493.09 rows=7656 width=28) (actual time=167.644..467.344 rows=8363 loops=1) + Filter: (request_time > (now() - '1 mon'::interval)) + -> Index Scan using url_pkey on url u (cost=0.00..3.05 rows=1 width=161) (actual time=13.994..14.000 rows=1 loops=31) + Index Cond: ("outer".id_url = u.id_url) + -> Subquery Scan vsp (cost=985.73..1016.53 rows=1103 width=12) (actual time=25.328..1668.754 rows=493 loops=31) + -> Merge Join (cost=985.73..1011.01 rows=1103 width=130) (actual time=25.321..1666.666 rows=493 loops=31) + Merge Cond: ("outer".id_program = "inner".id_program) + -> Sort (cost=20.74..20.97 rows=93 width=19) (actual time=0.385..0.431 rows=47 loops=31) + Sort Key: programs.id_program + -> Seq Scan on programs (cost=0.00..17.70 rows=93 width=19) (actual time=0.022..11.709 rows=48 loops=1) + Filter: (id_program <> 0) + -> Sort (cost=964.99..967.75 rows=1102 width=115) (actual time=14.592..15.218 rows=493 loops=31) + Sort Key: sequences.id_program + -> Merge Join (cost=696.16..909.31 rows=1102 width=115) (actual time=79.717..451.495 rows=493 loops=1) + Merge Cond: ("outer".id_package = "inner".id_package) + -> Merge Left Join (cost=0.00..186.59 rows=1229 width=103) (actual time=0.101..366.854 rows=1247 loops=1) + Merge Cond: ("outer".id_package = "inner".id_package) + -> Index Scan using packages_pkey on packages p (cost=0.00..131.04 rows=1229 width=103) (actual time=0.048..163.503 rows=1247 loops=1) + -> Index Scan using package_security_id_package_key on package_security ps (cost=0.00..46.83 rows=855 width=4) (actual time=0.022..178.599 rows=879 loops=1) + -> Sort (cost=696.16..705.69 rows=3812 width=16) (actual time=79.582..79.968 rows=493 loops=1) + Sort Key: sequences.id_package + -> Seq Scan on sequences (cost=0.00..469.42 rows=3812 width=16) (actual time=0.012..78.863 rows=493 loops=1) + Filter: (estimated_start IS NOT NULL) + Total runtime: 52878.516 ms +(36 rows) + + +Disabling the nestloop then the execution time become more affordable: + +empdb=# set enable_nestloop = false; +SET +empdb=# explain analyze SELECT name,url,descr,request_status,url_status,size_mb,estimated_start,request_time_stamp +empdb-# FROM v_sc_user_request +empdb-# WHERE +empdb-# login = 'babinow1' +empdb-# LIMIT 10 ; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + Limit (cost=4467.64..4467.65 rows=1 width=232) (actual time=7091.233..7091.289 rows=10 loops=1) + -> Subquery Scan v_sc_user_request (cost=4467.64..4467.65 rows=1 width=232) (actual time=7091.228..7091.272 rows=10 loops=1) + -> Sort (cost=4467.64..4467.64 rows=1 width=201) (actual time=7091.216..7091.221 rows=10 loops=1) + Sort Key: sr.id_sat_request + -> Merge Left Join (cost=4462.07..4467.63 rows=1 width=201) (actual time=6377.732..7091.067 rows=31 loops=1) + Merge Cond: ("outer".id_package = "inner".id_package) + -> Sort (cost=3389.81..3389.81 rows=1 width=193) (actual time=1338.759..1338.814 rows=31 loops=1) + Sort Key: sr.id_package + -> Merge Join (cost=3285.05..3389.80 rows=1 width=193) (actual time=1318.877..1338.651 rows=31 loops=1) + Merge Cond: ("outer".id_url = "inner".id_url) + -> Sort (cost=1029.26..1029.26 rows=1 width=40) (actual time=703.085..703.113 rows=31 loops=1) + Sort Key: sr.id_url + -> Merge Join (cost=991.00..1029.25 rows=1 width=40) (actual time=702.740..702.984 rows=31 loops=1) + Merge Cond: ("outer".id_user = "inner".id_user) + -> Sort (cost=986.99..1006.13 rows=7656 width=28) (actual time=648.559..655.302 rows=8041 loops=1) + Sort Key: sr.id_user + -> Seq Scan on sat_request sr (cost=0.00..493.09 rows=7656 width=28) (actual time=201.968..614.631 rows=8363 loops=1) + Filter: (request_time > (now() - '1 mon'::interval)) + -> Sort (cost=4.01..4.02 rows=2 width=16) (actual time=35.252..35.282 rows=1 loops=1) + Sort Key: ul.id_user + -> Index Scan using user_login_login_key on user_login ul (cost=0.00..4.00 rows=2 width=16) (actual time=35.214..35.221 rows=1 loops=1) + Index Cond: ((login)::text = 'babinow1'::text) + -> Sort (cost=2255.79..2308.95 rows=21264 width=161) (actual time=587.664..602.490 rows=21250 loops=1) + Sort Key: u.id_url + -> Seq Scan on url u (cost=0.00..727.32 rows=21264 width=161) (actual time=0.026..418.586 rows=21264 loops=1) + -> Sort (cost=1072.27..1075.03 rows=1103 width=12) (actual time=5015.761..5016.092 rows=493 loops=1) + Sort Key: vsp.id_package + -> Subquery Scan vsp (cost=985.73..1016.53 rows=1103 width=12) (actual time=898.876..5014.570 rows=494 loops=1) + -> Merge Join (cost=985.73..1011.01 rows=1103 width=130) (actual time=898.869..5011.954 rows=494 loops=1) + Merge Cond: ("outer".id_program = "inner".id_program) + -> Sort (cost=20.74..20.97 rows=93 width=19) (actual time=29.669..29.708 rows=47 loops=1) + Sort Key: programs.id_program + -> Seq Scan on programs (cost=0.00..17.70 rows=93 width=19) (actual time=0.035..29.525 rows=48 loops=1) + Filter: (id_program <> 0) + -> Sort (cost=964.99..967.75 rows=1102 width=115) (actual time=868.619..869.286 rows=494 loops=1) + Sort Key: sequences.id_program + -> Merge Join (cost=696.16..909.31 rows=1102 width=115) (actual time=44.820..867.649 rows=494 loops=1) + Merge Cond: ("outer".id_package = "inner".id_package) + -> Merge Left Join (cost=0.00..186.59 rows=1229 width=103) (actual time=19.563..835.352 rows=1248 loops=1) + Merge Cond: ("outer".id_package = "inner".id_package) + -> Index Scan using packages_pkey on packages p (cost=0.00..131.04 rows=1229 width=103) (actual time=12.796..457.520 rows=1248 loops=1) + -> Index Scan using package_security_id_package_key on package_security ps (cost=0.00..46.83 rows=855 width=4) (actual time=6.703..283.944 rows=879 loops=1) + -> Sort (cost=696.16..705.69 rows=3812 width=16) (actual time=25.222..25.705 rows=494 loops=1) + Sort Key: sequences.id_package + -> Seq Scan on sequences (cost=0.00..469.42 rows=3812 width=16) (actual time=0.017..24.412 rows=494 loops=1) + Filter: (estimated_start IS NOT NULL) + Total runtime: 7104.946 ms +(47 rows) + + + +May I know wich parameter may I tune in order to avoid to "disable" the nested loop ? +=================================================================================================================================== + +I tried to reduce the runtime cost adding a new column on sat_request ( expired boolean ) in order to +have a better row extimation ( I used a partial index ) but nothing changed. + + +I finally was able to reduce the cost putting ( just for this query ): +set cpu_tuple_cost = 0.07 + +is it a resonable value ? + + +empdb=# set cpu_tuple_cost = 0.07; +SET +empdb=# explain analyze select * +empdb-# from v_sc_user_request +empdb-# where login = 'babinow1'; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Subquery Scan v_sc_user_request (cost=1978.23..1978.30 rows=1 width=364) (actual time=1612.719..1613.064 rows=31 loops=1) + -> Sort (cost=1978.23..1978.23 rows=1 width=201) (actual time=1612.700..1612.728 rows=31 loops=1) + Sort Key: sr.id_sat_request + -> Merge Left Join (cost=1974.05..1978.22 rows=1 width=201) (actual time=1537.343..1612.565 rows=31 loops=1) + Merge Cond: ("outer".id_package = "inner".id_package) + -> Sort (cost=887.92..887.93 rows=1 width=193) (actual time=475.924..476.020 rows=31 loops=1) + Sort Key: sr.id_package + -> Nested Loop (cost=4.07..887.91 rows=1 width=193) (actual time=145.782..475.851 rows=31 loops=1) + -> Hash Join (cost=4.07..884.65 rows=1 width=40) (actual time=139.816..464.678 rows=31 loops=1) + Hash Cond: ("outer".id_user = "inner".id_user) + -> Index Scan using idx_sat_request_expired on sat_request sr (cost=0.00..838.69 rows=8363 width=28) (actual time=19.696..443.702 rows=8460 loops=1) + Index Cond: (expired = false) + -> Hash (cost=4.07..4.07 rows=2 width=16) (actual time=11.779..11.779 rows=0 loops=1) + -> Index Scan using user_login_login_key on user_login ul (cost=0.00..4.07 rows=2 width=16) (actual time=11.725..11.732 rows=1 loops=1) + Index Cond: ((login)::text = 'babinow1'::text) + -> Index Scan using url_pkey on url u (cost=0.00..3.19 rows=1 width=161) (actual time=0.345..0.347 rows=1 loops=31) + Index Cond: ("outer".id_url = u.id_url) + -> Sort (cost=1086.13..1088.16 rows=813 width=12) (actual time=1060.374..1060.622 rows=390 loops=1) + Sort Key: vsp.id_package + -> Subquery Scan vsp (cost=676.18..1046.83 rows=813 width=12) (actual time=625.645..1059.388 rows=480 loops=1) + -> Hash Join (cost=676.18..989.92 rows=813 width=131) (actual time=625.637..1057.105 rows=480 loops=1) + Hash Cond: ("outer".id_package = "inner".id_package) + -> Hash Left Join (cost=79.67..302.87 rows=1341 width=104) (actual time=4.336..18.549 rows=1342 loops=1) + Hash Cond: ("outer".id_package = "inner".id_package) + -> Seq Scan on packages p (cost=0.00..145.87 rows=1341 width=104) (actual time=0.007..3.357 rows=1342 loops=1) + -> Hash (cost=77.27..77.27 rows=961 width=4) (actual time=3.685..3.685 rows=0 loops=1) + -> Seq Scan on package_security ps (cost=0.00..77.27 rows=961 width=4) (actual time=0.016..2.175 rows=974 loops=1) + -> Hash (cost=594.48..594.48 rows=813 width=31) (actual time=620.397..620.397 rows=0 loops=1) + -> Hash Join (cost=20.60..594.48 rows=813 width=31) (actual time=38.307..619.406 rows=480 loops=1) + Hash Cond: ("outer".id_program = "inner".id_program) + -> Seq Scan on sequences (cost=0.00..512.82 rows=830 width=16) (actual time=16.858..595.262 rows=480 loops=1) + Filter: (estimated_start IS NOT NULL) + -> Hash (cost=20.48..20.48 rows=47 width=19) (actual time=21.093..21.093 rows=0 loops=1) + -> Seq Scan on programs (cost=0.00..20.48 rows=47 width=19) (actual time=9.369..20.980 rows=48 loops=1) + Filter: (id_program <> 0) + Total runtime: 1614.123 ms +(36 rows) + + + +Regards +Gaetano Mendola + + + + + + + + + +From pgsql-performance-owner@postgresql.org Tue Mar 8 11:40:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 399B456401 + for ; + Tue, 8 Mar 2005 11:40:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37144-01 + for ; + Tue, 8 Mar 2005 11:40:00 +0000 (GMT) +Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net + [194.217.242.92]) + by svr1.postgresql.org (Postfix) with ESMTP id 265EE5641A + for ; + Tue, 8 Mar 2005 11:39:57 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-34.mail.demon.net with esmtp (Exim 4.42) + id 1D8d4B-0009Nq-D5; Tue, 08 Mar 2005 11:39:59 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 6951716CC0; Tue, 8 Mar 2005 11:39:55 +0000 (GMT) +Message-ID: <422D8F0E.8000906@archonet.com> +Date: Tue, 08 Mar 2005 11:39:58 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gaetano Mendola +Cc: "pgsql-performance@postgresql.org" +Subject: Re: bad plan +References: <422D7F23.7000109@bigfoot.com> +In-Reply-To: <422D7F23.7000109@bigfoot.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/124 +X-Sequence-Number: 10829 + +Gaetano Mendola wrote: +> running a 7.4.5 engine, I'm facing this bad plan: +> +> empdb=# explain analyze SELECT name,url,descr,request_status,url_status,size_mb,estimated_start,request_time_stamp +> empdb-# FROM v_sc_user_request +> empdb-# WHERE +> empdb-# login = 'babinow1' +> empdb-# LIMIT 10 ; + +> -> Subquery Scan vsp (cost=985.73..1016.53 rows=1103 width=12) (actual time=25.328..1668.754 rows=493 loops=31) +> -> Merge Join (cost=985.73..1011.01 rows=1103 width=130) (actual time=25.321..1666.666 rows=493 loops=31) +> Merge Cond: ("outer".id_program = "inner".id_program) + +The problem to address is in this subquery. That's a total of 31 x +(1668.754 - 25.328) = 50seconds (about). + +Since your query is so simple, I'm guessing v_sc_user_request is a view. +Can you provide the definition? +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Mar 8 12:20:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 340975621A + for ; + Tue, 8 Mar 2005 12:20:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46495-09 + for ; + Tue, 8 Mar 2005 12:20:37 +0000 (GMT) +Received: from web11.manitu.net (web11.manitu.net [217.11.48.111]) + by svr1.postgresql.org (Postfix) with ESMTP id 3F8F955F07 + for ; + Tue, 8 Mar 2005 12:20:36 +0000 (GMT) +Received: from dicaprio.akademie1.de (dicaprio.akademie1.de [62.165.4.166]) + (authenticated) + by web11.manitu.net (8.10.2-SOL3/8.10.2) with ESMTP id j28CKXW12739 + for ; Tue, 8 Mar 2005 13:20:34 +0100 +Subject: pl/pgsql faster than raw SQL? +From: Markus Bertheau =?UTF-8?Q?=E2=98=AD?= +To: "pgsql-performance@postgresql.org" +Content-Type: text/plain; charset=UTF-8 +Date: Tue, 08 Mar 2005 13:20:32 +0100 +Message-Id: <1110284432.4905.18.camel@dicaprio.akademie1.de> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.235 tagged_above=0 required=5 tests=AWL, + TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200503/125 +X-Sequence-Number: 10830 + +Hi, I have the following strange situation: + +oocms=# vacuum full analyze; +VACUUM +oocms=# \df+ class_get_number_of_objects + Список функций + Схема | Имя | Тип данных результата | Типы данных аргументов | Владелец | Язык | Исходный текст | Описание +-------+-----------------------------+-----------------------+------------------------+----------+---------+----------------+----------------------------------------------------------------------------------------------- + oocms | class_get_number_of_objects | integer | text | oocms | plpgsql | +DECLARE + arg_class_name ALIAS FOR $1; +BEGIN + IF arg_class_name IS NULL THEN + RAISE WARNING 'class_get_number_of_objects() with NULL class name called'; + RETURN NULL; + END IF; + RETURN + count(1) + FROM + objects + WHERE + class = arg_class_name; +END; + | Return the number of existing or deleted objects of a class. Arguments: the name of the class +(1 запись) + +oocms=# explain analyze select count(1) from objects where class = 'Picture'; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------- + Aggregate (cost=278.16..278.16 rows=1 width=0) (actual time=44.121..44.123 rows=1 loops=1) + -> Seq Scan on objects (cost=0.00..267.65 rows=4205 width=0) (actual time=0.030..33.325 rows=4308 loops=1) + Filter: ("class" = 'Picture'::text) + Total runtime: 44.211 ms +(записей: 4) + +oocms=# explain analyze select class_get_number_of_objects('Picture'); + QUERY PLAN +-------------------------------------------------------------------------------------- + Result (cost=0.00..0.01 rows=1 width=0) (actual time=27.019..27.022 rows=1 loops=1) + Total runtime: 27.062 ms +(записей: 2) + + +I.e. a function takes 27 ms to do what takes an equivalent piece of sql +43 ms. How can this be explained? + +Some more info: + +oocms=# select class_get_number_of_objects('Picture'); + class_get_number_of_objects +----------------------------- + 4308 +(1 запись) + +oocms=# select count(1) from objects; + count +------- + 13332 +(1 запись) + +oocms=# \d objects + Таблица "oocms.objects" + Колонка | Тип | Модификаторы +-----------+--------------------------+--------------------------------------------------------------- + object_id | integer | not null default nextval('oocms.objects_object_id_seq'::text) + class | text | not null + created | timestamp with time zone | not null default ('now'::text)::timestamp(6) with time zone +Индексы: + "objects_pkey" PRIMARY KEY, btree (object_id) + "fooooo" btree ("class") +Ограничения по внешнему ключу: + "objects_class_fkey" FOREIGN KEY ("class") REFERENCES classes(name) ON UPDATE CASCADE + + +-- +Markus Bertheau ☭ + + +From pgsql-performance-owner@postgresql.org Tue Mar 8 12:22:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 28DB05636A + for ; + Tue, 8 Mar 2005 12:22:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47260-07 + for ; + Tue, 8 Mar 2005 12:22:40 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 245AD562E9 + for ; + Tue, 8 Mar 2005 12:22:38 +0000 (GMT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j28DPhV14866; + Tue, 8 Mar 2005 14:25:43 +0100 +Received: from [127.0.0.1] (accesspoint.mm.eutelsat.org [194.214.173.4]) + by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j28CMeR32523; + Tue, 8 Mar 2005 13:22:40 +0100 +Message-ID: <422D9904.5010904@bigfoot.com> +Date: Tue, 08 Mar 2005 13:22:28 +0100 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Richard Huxton +Cc: Gaetano Mendola , + "pgsql-performance@postgresql.org" +Subject: Re: bad plan +References: <422D7F23.7000109@bigfoot.com> <422D8F0E.8000906@archonet.com> +In-Reply-To: <422D8F0E.8000906@archonet.com> +X-Enigmail-Version: 0.90.1.1 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.235 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/126 +X-Sequence-Number: 10831 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Richard Huxton wrote: +> Gaetano Mendola wrote: +> +>> running a 7.4.5 engine, I'm facing this bad plan: +>> +>> empdb=# explain analyze SELECT +>> name,url,descr,request_status,url_status,size_mb,estimated_start,request_time_stamp +>> +>> empdb-# FROM v_sc_user_request +>> empdb-# WHERE +>> empdb-# login = 'babinow1' +>> empdb-# LIMIT 10 ; +> +> +>> -> Subquery Scan vsp (cost=985.73..1016.53 +>> rows=1103 width=12) (actual time=25.328..1668.754 rows=493 loops=31) +>> -> Merge Join (cost=985.73..1011.01 +>> rows=1103 width=130) (actual time=25.321..1666.666 rows=493 loops=31) +>> Merge Cond: ("outer".id_program = +>> "inner".id_program) +> +> +> The problem to address is in this subquery. That's a total of 31 x +> (1668.754 - 25.328) = 50seconds (about). +> +> Since your query is so simple, I'm guessing v_sc_user_request is a view. +> Can you provide the definition? + +Of course: + + + +CREATE OR REPLACE VIEW v_sc_user_request AS + SELECT + * + FROM + v_sat_request vsr LEFT OUTER JOIN v_sc_packages vsp USING ( id_package ) + WHERE + vsr.request_time > now() - '1 month'::interval AND + vsr.expired = FALSE + ORDER BY id_sat_request DESC +; + + +CREATE OR REPLACE VIEW v_sc_packages AS + SELECT + * + FROM + v_programs vpr, + v_packages vpk, + v_sequences vs + + WHERE + ------------ JOIN ------------- + vpr.id_program = vs.id_program AND + vpk.id_package = vs.id_package AND + ------------------------------- + vs.estimated_start IS NOT NULL +; + +CREATE OR REPLACE VIEW v_sat_request AS + SELECT + * + FROM + sat_request sr, + url u, + user_login ul + WHERE + ---------------- JOIN --------------------- + sr.id_url = u.id_url AND + sr.id_user = ul.id_user + ------------------------------------------- +; + + +that column expired was added since yesterday + +Regards +Gaetano Mendola + + + + + + + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCLZkD7UpzwH2SGd4RAv8/AKCA5cNfu6vEKZ6m/ke1JsVRdsOTXQCbBMt4 +ZPTFjwyb52CrFxdUTD6gejs= +=STzz +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Tue Mar 8 12:48:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CD21545F2 + for ; + Tue, 8 Mar 2005 12:48:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53320-09 + for ; + Tue, 8 Mar 2005 12:48:34 +0000 (GMT) +Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net + [194.217.242.90]) + by svr1.postgresql.org (Postfix) with ESMTP id 0692752AA9 + for ; + Tue, 8 Mar 2005 12:48:33 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 4.42) + id 1D8e8Z-000Evh-8P; Tue, 08 Mar 2005 12:48:36 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id E8DE516D47; Tue, 8 Mar 2005 12:48:32 +0000 (GMT) +Message-ID: <422D9F20.2040104@archonet.com> +Date: Tue, 08 Mar 2005 12:48:32 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?UTF-8?B?TWFya3VzIEJlcnRoZWF1IOKYrQ==?= +Cc: "pgsql-performance@postgresql.org" +Subject: Re: pl/pgsql faster than raw SQL? +References: <1110284432.4905.18.camel@dicaprio.akademie1.de> +In-Reply-To: <1110284432.4905.18.camel@dicaprio.akademie1.de> +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/127 +X-Sequence-Number: 10832 + +Markus Bertheau ☭ wrote: +> oocms=# explain analyze select count(1) from objects where class = 'Picture'; +> QUERY PLAN +> ---------------------------------------------------------------------------------------------------------------- +> Aggregate (cost=278.16..278.16 rows=1 width=0) (actual time=44.121..44.123 rows=1 loops=1) +> -> Seq Scan on objects (cost=0.00..267.65 rows=4205 width=0) (actual time=0.030..33.325 rows=4308 loops=1) +> Filter: ("class" = 'Picture'::text) +> Total runtime: 44.211 ms +> (записей: 4) +> +> oocms=# explain analyze select class_get_number_of_objects('Picture'); +> QUERY PLAN +> -------------------------------------------------------------------------------------- +> Result (cost=0.00..0.01 rows=1 width=0) (actual time=27.019..27.022 rows=1 loops=1) +> Total runtime: 27.062 ms + +Well, you're saving planning time with the plpgsql version, but that's +not going to come to 17ms (you'd hope). The EXPLAIN will take up time +itself, and it can look deeper into the SQL version. Try timing two +scripts with 100 of each and see if they really differ by that much. +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Mar 8 13:20:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 111255636B + for ; + Tue, 8 Mar 2005 13:20:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62336-06 + for ; + Tue, 8 Mar 2005 13:20:42 +0000 (GMT) +Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net + [194.217.242.89]) + by svr1.postgresql.org (Postfix) with ESMTP id C6458562E9 + for ; + Tue, 8 Mar 2005 13:20:40 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-31.mail.demon.net with esmtp (Exim 4.42) + id 1D8ebi-000J4O-54; Tue, 08 Mar 2005 13:18:44 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 6F563170FA; Tue, 8 Mar 2005 13:20:37 +0000 (GMT) +Message-ID: <422DA6A5.2060908@archonet.com> +Date: Tue, 08 Mar 2005 13:20:37 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gaetano Mendola +Cc: "pgsql-performance@postgresql.org" +Subject: Re: bad plan +References: <422D7F23.7000109@bigfoot.com> <422D8F0E.8000906@archonet.com> + <422D9904.5010904@bigfoot.com> +In-Reply-To: <422D9904.5010904@bigfoot.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/128 +X-Sequence-Number: 10833 + +Gaetano Mendola wrote: +> -----BEGIN PGP SIGNED MESSAGE----- +> Hash: SHA1 +> +> Richard Huxton wrote: +> +>>Gaetano Mendola wrote: +>> +>> +>>>running a 7.4.5 engine, I'm facing this bad plan: +>>> +>>>empdb=# explain analyze SELECT +>>>name,url,descr,request_status,url_status,size_mb,estimated_start,request_time_stamp +>>> +>>>empdb-# FROM v_sc_user_request +>>>empdb-# WHERE +>>>empdb-# login = 'babinow1' +>>>empdb-# LIMIT 10 ; +>> +>> +>>> -> Subquery Scan vsp (cost=985.73..1016.53 +>>>rows=1103 width=12) (actual time=25.328..1668.754 rows=493 loops=31) +>>> -> Merge Join (cost=985.73..1011.01 +>>>rows=1103 width=130) (actual time=25.321..1666.666 rows=493 loops=31) +>>> Merge Cond: ("outer".id_program = +>>>"inner".id_program) +>> +>> +>>The problem to address is in this subquery. That's a total of 31 x +>>(1668.754 - 25.328) = 50seconds (about). +>> +>>Since your query is so simple, I'm guessing v_sc_user_request is a view. +>>Can you provide the definition? +> +> +> Of course: +> +> +> +> CREATE OR REPLACE VIEW v_sc_user_request AS +> SELECT +> * +> FROM +> v_sat_request vsr LEFT OUTER JOIN v_sc_packages vsp USING ( id_package ) +> WHERE +> vsr.request_time > now() - '1 month'::interval AND +> vsr.expired = FALSE +> ORDER BY id_sat_request DESC +> ; +> +> +> CREATE OR REPLACE VIEW v_sc_packages AS +> SELECT +> * +> FROM +> v_programs vpr, +> v_packages vpk, +> v_sequences vs +> +> WHERE +> ------------ JOIN ------------- +> vpr.id_program = vs.id_program AND +> vpk.id_package = vs.id_package AND +> ------------------------------- +> vs.estimated_start IS NOT NULL +> ; +> +> CREATE OR REPLACE VIEW v_sat_request AS +> SELECT +> * +> FROM +> sat_request sr, +> url u, +> user_login ul +> WHERE +> ---------------- JOIN --------------------- +> sr.id_url = u.id_url AND +> sr.id_user = ul.id_user +> ------------------------------------------- +> ; + +OK, so looking at the original EXPLAIN the order of processing seems to be: +1. v_sat_request is evaluated and filtered on login='...' (lines 7..15) +This gives us 31 rows +2. The left-join from v_sat_request to v_sc_packages is processed (lines +5..6) +This involves the subquery scan on vsp (from line 16) where it seems to +think the best idea is a merge join of programs to sequences. + +So - I think we need to look at the performance of your view +"v_sc_packages" and the views that it depends on. OK - can you reply to +this with just the definitions of v_sc_packages and what it depends on, +and we can have a look at that. + +Do you need all these tables involved in this query? I don't think PG is +smart enough to completely discard a join if it's not needed by the +output. Thinking about it, I'm not sure you could safely. +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Mar 8 15:10:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DA80755F51 + for ; + Tue, 8 Mar 2005 15:10:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94930-02 + for ; + Tue, 8 Mar 2005 15:10:38 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 5AF5F54F2C + for ; + Tue, 8 Mar 2005 15:10:35 +0000 (GMT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j28FAV319920; + Tue, 8 Mar 2005 09:10:31 -0600 +Message-ID: <422DC066.10802@arbash-meinel.com> +Date: Tue, 08 Mar 2005 09:10:30 -0600 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?UTF-8?B?TWFya3VzIEJlcnRoZWF1IOKYrQ==?= +Cc: "pgsql-performance@postgresql.org" +Subject: Re: pl/pgsql faster than raw SQL? +References: <1110284432.4905.18.camel@dicaprio.akademie1.de> +In-Reply-To: <1110284432.4905.18.camel@dicaprio.akademie1.de> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig60B70C74B37CC3795F87B5AA" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/129 +X-Sequence-Number: 10834 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig60B70C74B37CC3795F87B5AA +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 8bit + +Markus Bertheau ☭ wrote: + +>Hi, I have the following strange situation: +> +> +> +... + +>oocms=# explain analyze select count(1) from objects where class = 'Picture'; +> QUERY PLAN +>---------------------------------------------------------------------------------------------------------------- +> Aggregate (cost=278.16..278.16 rows=1 width=0) (actual time=44.121..44.123 rows=1 loops=1) +> -> Seq Scan on objects (cost=0.00..267.65 rows=4205 width=0) (actual time=0.030..33.325 rows=4308 loops=1) +> Filter: ("class" = 'Picture'::text) +> Total runtime: 44.211 ms +>(записей: 4) +> +>oocms=# explain analyze select class_get_number_of_objects('Picture'); +> QUERY PLAN +>-------------------------------------------------------------------------------------- +> Result (cost=0.00..0.01 rows=1 width=0) (actual time=27.019..27.022 rows=1 loops=1) +> Total runtime: 27.062 ms +>(записей: 2) +> +> +>I.e. a function takes 27 ms to do what takes an equivalent piece of sql +>43 ms. How can this be explained? +> +>Some more info: +> +> +In explain analyze, there is a per-row overhead of 2 gettimeofday() +calls. This is usually very low and hidden in I/O, but on queries where +you go through a lot of rows, but things are cached in ram, it can show up. +So the explain analyze is going deep into the SQL query. +With a stored procedure, explain analyze only runs the procedure, it +doesn't instrument the actual function. So you don't have that per-row +overhead. + +For an alternate accurate view. Try: +# \timing +# explain analyze select count(1) from objects where class = 'Picture'; +# explain analyze select class_get_number_of_objects('Picture'); + +\timing will also give you the time it takes to run the query, but it +doesn't instrument anything. + +John +=:-> + + +--------------enig60B70C74B37CC3795F87B5AA +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCLcBmJdeBCYSNAAMRAgghAJ9V78gFK+Bg7Y9LVQVeyGuyQEHSfACfU/Nb +UWrd+SLSmfuJ2amIDaNvC88= +=AOIb +-----END PGP SIGNATURE----- + +--------------enig60B70C74B37CC3795F87B5AA-- + +From pgsql-performance-owner@postgresql.org Tue Mar 8 17:11:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D43A8564B4 + for ; + Tue, 8 Mar 2005 17:11:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34780-07 + for ; + Tue, 8 Mar 2005 17:11:17 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 7389F564A2 + for ; + Tue, 8 Mar 2005 17:11:12 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7105556; Tue, 08 Mar 2005 09:13:01 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: +Subject: Re: Tuning, configuration for 7.3.5 on a Sun E4500 +Date: Tue, 8 Mar 2005 09:10:57 -0800 +User-Agent: KMail/1.6.2 +Cc: Postgres - Performance +References: <156a90fe050307064678d5a6e9@mail.gmail.com> + <200503070931.06241.josh@agliodbs.com> + <156a90fe05030723477c3ee7d3@mail.gmail.com> +In-Reply-To: <156a90fe05030723477c3ee7d3@mail.gmail.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200503080910.57409.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/130 +X-Sequence-Number: 10835 + +Tsarevich, + +> Analyze has been run on the database quite frequently during the +> course of us trying to figure out this performance issue. It is also +> a task that is crontabbed nightly. + +Hmmm. Then you probably need to up the STATISTICS levels on the target=20 +column, because PG is mis-estimating the number of rows returned=20 +significantly. That's done by: + +ALTER TABLE {table} ALTER COLUMN {column} SET STATISTICS {number} + +Generally, I find that if mis-estimation occurs, you need to raise statisti= +cs=20 +to at least 250. + +Here's where I see the estimation issues with your EXPLAIN: + +=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-> =A0Index Scan +using component_commercial_order_id_ix on component =A0(cost=3D0.00..3.85 +rows=3D1 width=3D28) (actual time=3D0.17..0.18 rows=3D1 loops=3D46376) +=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 =A0Index Cond: +(component.commercial_order_id =3D "outer".commercial_order_id) +=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 =A0Filter: +((raised_dtm >=3D '2003-01-01 00:00:00'::timestamp without time zone) +AND (raised_dtm <=3D '2005-01-01 23:59:59'::timestamp without time zone) +AND ((component_type_id =3D 3) OR (component_type_id =3D 2) OR +(component_type_id =3D 1))) + +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0-> =A0Index Scan using communication_com= +ponent_id_ix on +communication =A0(cost=3D0.00..20.90 rows=3D16 width=3D8) (actual +time=3D0.12..0.14 rows=3D1 loops=3D34638) +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Index Cond: (component_id = +=3D $0) + +So it looks like you need to raise the stats on communication.component_id = +and=20 +component.commercial_order_id,raised_dtm,component_type_id. You also may= +=20 +want to consider a multi-column index on the last set. + +BTW, if you have any kind of data update traffic at all, ANALYZE once a day= + is=20 +not adequate. + +=2D-=20 +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Mar 8 18:35:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A489A550E6 + for ; + Tue, 8 Mar 2005 18:35:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55985-07 + for ; + Tue, 8 Mar 2005 18:35:48 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CE7055012 + for ; + Tue, 8 Mar 2005 18:35:47 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id D318632033; Tue, 8 Mar 2005 19:35:46 +0100 (MET) +From: Gaetano Mendola +X-Newsgroups: pgsql.performance +Subject: Re: bad plan +Date: Tue, 08 Mar 2005 19:35:31 +0100 +Organization: Hub.Org Networking Services +Lines: 96 +Message-ID: <422DF073.7080307@bigfoot.com> +References: <422D7F23.7000109@bigfoot.com> <422D8F0E.8000906@archonet.com> + <422D9904.5010904@bigfoot.com> <422DA6A5.2060908@archonet.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +To: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +In-Reply-To: <422DA6A5.2060908@archonet.com> +X-Enigmail-Version: 0.90.1.1 +X-Enigmail-Supports: pgp-inline, pgp-mime +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/131 +X-Sequence-Number: 10836 + +Richard Huxton wrote: + +> OK, so looking at the original EXPLAIN the order of processing seems to be: +> 1. v_sat_request is evaluated and filtered on login='...' (lines 7..15) +> This gives us 31 rows +> 2. The left-join from v_sat_request to v_sc_packages is processed (lines +> 5..6) +> This involves the subquery scan on vsp (from line 16) where it seems to +> think the best idea is a merge join of programs to sequences. + +Whel basically v_sc_packages depends on other 3 views that are just a simple +interface to a plain table. + + +If I execute a select only on this table I get reasonable executions time: + + +=== cpu_tuple_cost = 0.07 + +# explain analyze select * from v_sc_packages where id_package = 19628; + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..15.96 rows=1 width=131) (actual time=41.450..41.494 rows=1 loops=1) + -> Nested Loop (cost=0.00..11.86 rows=1 width=116) (actual time=1.022..1.055 rows=1 loops=1) + -> Nested Loop Left Join (cost=0.00..7.89 rows=1 width=104) (actual time=0.330..0.345 rows=1 loops=1) + -> Index Scan using packages_pkey on packages p (cost=0.00..3.90 rows=1 width=104) (actual time=0.070..0.075 rows=1 loops=1) + Index Cond: (id_package = 19628) + -> Index Scan using package_security_id_package_key on package_security ps (cost=0.00..3.91 rows=1 width=4) (actual time=0.232..0.237 rows=1 loops=1) + Index Cond: ("outer".id_package = ps.id_package) + -> Index Scan using idx_sequences_id_package on sequences (cost=0.00..3.90 rows=1 width=16) (actual time=0.670..0.685 rows=1 loops=1) + Index Cond: (19628 = id_package) + Filter: (estimated_start IS NOT NULL) + -> Index Scan using programs_pkey on programs (cost=0.00..4.02 rows=1 width=19) (actual time=0.078..0.086 rows=1 loops=1) + Index Cond: (programs.id_program = "outer".id_program) + Filter: (id_program <> 0) + Total runtime: 42.650 ms +(14 rows) + +=== cpu_tuple_cost = 0.01 + +# explain analyze select * from v_sc_packages where id_package = 19628; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + Nested Loop (cost=0.00..15.54 rows=1 width=131) (actual time=25.062..69.977 rows=1 loops=1) + -> Nested Loop (cost=0.00..11.56 rows=1 width=116) (actual time=5.396..50.299 rows=1 loops=1) + -> Nested Loop Left Join (cost=0.00..7.71 rows=1 width=104) (actual time=5.223..32.842 rows=1 loops=1) + -> Index Scan using packages_pkey on packages p (cost=0.00..3.84 rows=1 width=104) (actual time=0.815..7.235 rows=1 loops=1) + Index Cond: (id_package = 19628) + -> Index Scan using package_security_id_package_key on package_security ps (cost=0.00..3.85 rows=1 width=4) (actual time=4.366..25.555 rows=1 loops=1) + Index Cond: ("outer".id_package = ps.id_package) + -> Index Scan using idx_sequences_id_package on sequences (cost=0.00..3.84 rows=1 width=16) (actual time=0.147..17.422 rows=1 loops=1) + Index Cond: (19628 = id_package) + Filter: (estimated_start IS NOT NULL) + -> Index Scan using programs_pkey on programs (cost=0.00..3.96 rows=1 width=19) (actual time=0.043..0.049 rows=1 loops=1) + Index Cond: (programs.id_program = "outer".id_program) + Filter: (id_program <> 0) + Total runtime: 70.254 ms +(14 rows) + + +and I get the best with this: + +=== cpu_tuple_cost = 0.001 + + +# explain analyze select * from v_sc_packages where id_package = 19628; + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..15.48 rows=1 width=131) (actual time=2.516..2.553 rows=1 loops=1) + -> Nested Loop (cost=0.00..7.78 rows=1 width=31) (actual time=1.439..1.457 rows=1 loops=1) + -> Index Scan using idx_sequences_id_package on sequences (cost=0.00..3.83 rows=1 width=16) (actual time=0.442..0.450 rows=1 loops=1) + Index Cond: (19628 = id_package) + Filter: (estimated_start IS NOT NULL) + -> Index Scan using programs_pkey on programs (cost=0.00..3.95 rows=1 width=19) (actual time=0.972..0.978 rows=1 loops=1) + Index Cond: (programs.id_program = "outer".id_program) + Filter: (id_program <> 0) + -> Nested Loop Left Join (cost=0.00..7.68 rows=1 width=104) (actual time=0.110..0.125 rows=1 loops=1) + -> Index Scan using packages_pkey on packages p (cost=0.00..3.84 rows=1 width=104) (actual time=0.040..0.046 rows=1 loops=1) + Index Cond: (id_package = 19628) + -> Index Scan using package_security_id_package_key on package_security ps (cost=0.00..3.84 rows=1 width=4) (actual time=0.036..0.042 rows=1 loops=1) + Index Cond: ("outer".id_package = ps.id_package) + Total runtime: 2.878 ms +(14 rows) + + + +but with this last setting for the original query is choosed a very bad plan. + + +Regards +Gaetano Mendola + + + + + + +From pgsql-performance-owner@postgresql.org Tue Mar 8 18:36:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8AF6856401 + for ; + Tue, 8 Mar 2005 18:36:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55985-08 + for ; + Tue, 8 Mar 2005 18:35:57 +0000 (GMT) +Received: from rwcrmhc11.comcast.net (rwcrmhc14.comcast.net [216.148.227.89]) + by svr1.postgresql.org (Postfix) with ESMTP id A8B865514D + for ; + Tue, 8 Mar 2005 18:35:54 +0000 (GMT) +Received: from dell8200 + (pcp05158174pcs.rte20201.de.comcast.net[69.139.132.79]) + by comcast.net (rwcrmhc14) with SMTP + id <20050308183553014001k0mqe>; Tue, 8 Mar 2005 18:35:53 +0000 +From: "Rick Schumeyer" +To: +Subject: index scan on =, but not < ? +Date: Tue, 8 Mar 2005 13:35:53 -0500 +Message-ID: <001f01c5240d$a920c8c0$0200a8c0@dell8200> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0020_01C523E3.C04AC0C0" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.6626 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200503/132 +X-Sequence-Number: 10837 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0020_01C523E3.C04AC0C0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +I have two index questions. The first is about an issue that has been +recently discussed, + +and I just wanted to be sure of my understanding. Functions like count(), +max(), etc. will + +use sequential scans instead of index scans because the index doesn't know +which rows + +are actually visible.is this correct? + + + +Second: + + + +I created an index in a table with over 10 million rows. + +The index is on field x, which is a double. + + + +The following command, as I expected, results in an index scan: + + + +=# explain select * from data where x = 0; + + QUERY PLAN + +------------------------------------------------------------------------- + + Index Scan using data_x_ix on data (cost=0.00..78.25 rows=19 width=34) + + Index Cond: (x = 0::double precision) + +(2 rows) + + + + + +But this command, in which the only difference if > instead of =, is a +sequential scan. + + + +=# explain select * from data where x > 0; + + QUERY PLAN + +------------------------------------------------------------------ + + Seq Scan on data (cost=0.00..1722605.20 rows=62350411 width=34) + + Filter: (x > 0::double precision) + +(2 rows) + + + +Why is this? + +(This is with pg 8.0.1 on a PC running FC3 with 1GB ram.if it matters) + + +------=_NextPart_000_0020_01C523E3.C04AC0C0 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + + +
+ +

I have two index questions.  The first is about = +an +issue that has been recently discussed,

+ +

and I just wanted to be sure of my = +understanding.  +Functions like count(), max(), etc. will

+ +

use sequential scans instead of index scans because = +the +index doesn’t know which rows

+ +

are actually visible…is this = +correct?

+ +

 

+ +

Second:

+ +

 

+ +

I created an index in a table with over 10 million = +rows.

+ +

The index is on field x, which is a = +double.

+ +

 

+ +

The following command, as I expected, results in an = +index +scan:

+ +

 

+ +

=3D# explain select * from data where x =3D = +0;

+ +

         = +            &= +nbsp;         +QUERY PLAN

+ +

------------------------------------------------------= +-------------------

+ +

 Index Scan using data_x_ix on data  = +(cost=3D0.00..78.25 +rows=3D19 width=3D34)

+ +

   Index Cond: (x =3D 0::double = +precision)

+ +

(2 rows)

+ +

 

+ +

 

+ +

But this command, in which the only difference if = +> +instead of =3D, is a sequential scan.

+ +

 

+ +

=3D# explain select * from data where x > = +0;

+ +

         = +            &= +nbsp;      +QUERY PLAN

+ +

------------------------------------------------------= +------------

+ +

 Seq Scan on data  (cost=3D0.00..1722605.20 +rows=3D62350411 width=3D34)

+ +

   Filter: (x > 0::double = +precision)

+ +

(2 rows)

+ +

 

+ +

Why is this?

+ +

(This is with pg 8.0.1 on a PC running FC3 with 1GB = +ram…if +it matters)

+ +
+ + + + + +------=_NextPart_000_0020_01C523E3.C04AC0C0-- + + +From pgsql-performance-owner@postgresql.org Tue Mar 8 18:52:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 811C35641F + for ; + Tue, 8 Mar 2005 18:52:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60793-06 + for ; + Tue, 8 Mar 2005 18:52:44 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id B788E56401 + for ; + Tue, 8 Mar 2005 18:52:42 +0000 (GMT) +Received: (qmail 29133 invoked from network); 8 Mar 2005 18:52:43 -0000 +Received: from host-209.149.56.238.nashville.net (HELO ?10.0.1.2?) + (209.149.56.238) by 0 with SMTP; 8 Mar 2005 18:52:43 -0000 +In-Reply-To: <001f01c5240d$a920c8c0$0200a8c0@dell8200> +References: <001f01c5240d$a920c8c0$0200a8c0@dell8200> +Mime-Version: 1.0 (Apple Message framework v619.2) +Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed +Message-Id: <9b7a46c3c46a4fdf1beeef7eb5727493@sitening.com> +Content-Transfer-Encoding: quoted-printable +Cc: +From: Thomas F.O'Connell +Subject: Re: index scan on =, but not < ? +Date: Tue, 8 Mar 2005 12:52:41 -0600 +To: "Rick Schumeyer" +X-Mailer: Apple Mail (2.619.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/133 +X-Sequence-Number: 10838 + +Your hypothesis about index usage of count() and max() is correct. + +As for why you see index usage in your first example query and not your =20= + +second: compare the number of rows in question. An index is extremely =20= + +useful if 19 rows will be returned. But when 62350411 rows will be =20 +returned, you're talking about a substantial fraction of the table. A =20= + +sequential scan will probably correctly be judged to be faster by the =20= + +planner. + +-tfo + +-- +Thomas F. O'Connell +Co-Founder, Information Architect +Sitening, LLC +http://www.sitening.com/ +110 30th Avenue North, Suite 6 +Nashville, TN 37203-6320 +615-260-0005 + +On Mar 8, 2005, at 12:35 PM, Rick Schumeyer wrote: + +> I have two index questions.=A0 The first is about an issue that has = +been =20 +> recently discussed, +> and I just wanted to be sure of my understanding.=A0 Functions like =20= + +> count(), max(), etc. will +> use sequential scans instead of index scans because the index doesn=92t = +=20 +> know which rows +> are actually visible=85is this correct? +> +> =A0 +> +> Second: +> +> =A0 +> +> I created an index in a table with over 10 million rows. +> The index is on field x, which is a double. +> +> The following command, as I expected, results in an index scan: +> +> =3D# explain select * from data where x =3D 0; +> +> =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 QUERY PLAN +> +> = +-----------------------------------------------------------------------=20= + +> -- +> =A0Index Scan using data_x_ix on data=A0 (cost=3D0.00..78.25 rows=3D19 = +=20 +> width=3D34) +> =A0=A0 Index Cond: (x =3D 0::double precision) +> (2 rows) +> =A0 +> +> But this command, in which the only difference if > instead of =3D, is = +a =20 +> sequential scan. +> +> +> =3D# explain select * from data where x > 0; +> +> =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 QUERY PLAN +> +> ------------------------------------------------------------------ +> +> =A0Seq Scan on data=A0 (cost=3D0.00..1722605.20 rows=3D62350411 = +width=3D34) +> =A0=A0 Filter: (x > 0::double precision) +> (2 rows) +> +> Why is this? +> +> (This is with pg 8.0.1 on a PC running FC3 with 1GB ram=85if it = +matters) + + +From pgsql-performance-owner@postgresql.org Tue Mar 8 19:01:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 60B485513E + for ; + Tue, 8 Mar 2005 19:01:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62610-10 + for ; + Tue, 8 Mar 2005 19:01:35 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id C713656446 + for ; + Tue, 8 Mar 2005 19:01:30 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j28J1Orb019402; (envelope-from ) Tue, + 8 Mar 2005 13:01:24 -0600 (CST) +Received: from [192.168.1.13] (63-230-159-69.cdrr.qwest.net [63.230.159.69]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j28J1LcD000850 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Tue, + 8 Mar 2005 13:01:23 -0600 (CST) +Message-ID: <422DF680.1000409@arbash-meinel.com> +Date: Tue, 08 Mar 2005 13:01:20 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Rick Schumeyer +Cc: pgsql-performance@postgresql.org +Subject: Re: index scan on =, but not < ? +References: <001f01c5240d$a920c8c0$0200a8c0@dell8200> +In-Reply-To: <001f01c5240d$a920c8c0$0200a8c0@dell8200> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig3995DA4B113C496627888CFC" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/134 +X-Sequence-Number: 10839 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig3995DA4B113C496627888CFC +Content-Type: text/plain; charset=windows-1252; format=flowed +Content-Transfer-Encoding: 8bit + +Rick Schumeyer wrote: + +> I have two index questions. The first is about an issue that has been +> recently discussed, +> +> and I just wanted to be sure of my understanding. Functions like +> count(), max(), etc. will +> +> use sequential scans instead of index scans because the index doesn�t +> know which rows +> +> are actually visible�is this correct? +> +Actually, index scans are chosen whenever the cost is expected to be +cheaper than a sequential scan. This is generally about < 10% of the +total number of rows. + +> Second: +> +> I created an index in a table with over 10 million rows. +> +> The index is on field x, which is a double. +> +> The following command, as I expected, results in an index scan: +> +> =# explain select * from data where x = 0; +> +> QUERY PLAN +> +> ------------------------------------------------------------------------- +> +> Index Scan using data_x_ix on data (cost=0.00..78.25 rows=19 width=34) +> +> Index Cond: (x = 0::double precision) +> +> (2 rows) +> +Since you have 10m rows, when it expects to get only 19 rows, it is much +faster to use an index. + +> But this command, in which the only difference if > instead of =, is a +> sequential scan. +> +> =# explain select * from data where x > 0; +> +> QUERY PLAN +> +> ------------------------------------------------------------------ +> +> Seq Scan on data (cost=0.00..1722605.20 rows=62350411 width=34) +> +> Filter: (x > 0::double precision) +> +> (2 rows) +> +Here, pg expects to find 62M rows (you must have significantly more than +10M rows). In this case a sequential scan is much faster than an indexed +one, so that's what pg does. + +> Why is this? +> +> (This is with pg 8.0.1 on a PC running FC3 with 1GB ram�if it matters) +> +If you think there is truly a performance problem, try attaching the +results of "explain analyze" in which we might be able to tell you that +your statistics inaccurate (run vacuum analyze if you haven't). + +John +=:-> + + +--------------enig3995DA4B113C496627888CFC +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCLfaAJdeBCYSNAAMRArIOAJsFE/b+GjmlClMhtYb8oESRYEFF+gCgjh0U +NYwh/iFa4Oj4omGTUvRFLKc= +=W/9K +-----END PGP SIGNATURE----- + +--------------enig3995DA4B113C496627888CFC-- + +From pgsql-performance-owner@postgresql.org Tue Mar 8 19:02:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E1E35513E + for ; + Tue, 8 Mar 2005 19:02:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64373-07 + for ; + Tue, 8 Mar 2005 19:02:52 +0000 (GMT) +Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) + by svr1.postgresql.org (Postfix) with ESMTP id 4AC0A54EE6 + for ; + Tue, 8 Mar 2005 19:02:51 +0000 (GMT) +Received: from dell8200 + (pcp05158174pcs.rte20201.de.comcast.net[69.139.132.79]) + by comcast.net (rwcrmhc11) with SMTP + id <2005030819025101300ofegue>; Tue, 8 Mar 2005 19:02:51 +0000 +From: "Rick Schumeyer" +To: "'Thomas F.O'Connell'" +Cc: +Subject: Re: index scan on =, but not < ? +Date: Tue, 8 Mar 2005 14:02:50 -0500 +Message-ID: <002801c52411$6d510f40$0200a8c0@dell8200> +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.6626 +In-Reply-To: <9b7a46c3c46a4fdf1beeef7eb5727493@sitening.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/135 +X-Sequence-Number: 10840 + +That makes a lot of sense. Sure enough, if I change the query from +WHERE x > 0 (which return a lot of rows) to +WHERE x > 0 AND x < 1 +I now get an index scan. + +> As for why you see index usage in your first example query and not your +> second: compare the number of rows in question. An index is extremely +> useful if 19 rows will be returned. But when 62350411 rows will be +> returned, you're talking about a substantial fraction of the table. A +> sequential scan will probably correctly be judged to be faster by the +> planner. +> + + +From pgsql-performance-owner@postgresql.org Tue Mar 8 19:05:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DB55456414 + for ; + Tue, 8 Mar 2005 19:04:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65729-03 + for ; + Tue, 8 Mar 2005 19:04:59 +0000 (GMT) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id B2CE256401 + for ; + Tue, 8 Mar 2005 19:04:57 +0000 (GMT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 67A458467; Tue, 8 Mar 2005 20:04:55 +0100 (CET) +Date: Tue, 8 Mar 2005 20:04:55 +0100 (CET) +From: Dennis Bjorklund +To: Rick Schumeyer +Cc: pgsql-performance@postgresql.org +Subject: Re: index scan on =, but not < ? +In-Reply-To: <001f01c5240d$a920c8c0$0200a8c0@dell8200> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.324 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/136 +X-Sequence-Number: 10841 + +On Tue, 8 Mar 2005, Rick Schumeyer wrote: + +> =# explain select * from data where x = 0; +> ------------------------------------------------------------------------- +> Index Scan using data_x_ix on data (cost=0.00..78.25 rows=19 width=34) +> Index Cond: (x = 0::double precision) +> +> But this command, in which the only difference if > instead of =, is a +> sequential scan. +> +> =# explain select * from data where x > 0; +> ------------------------------------------------------------------ +> Seq Scan on data (cost=0.00..1722605.20 rows=62350411 width=34) +> Filter: (x > 0::double precision) +> +> Why is this? + +That is because it's faster to execute the x>0 query with a seq. scan then +a index scan. Postgresql is doing the right thing here. + +Pg estimates that the first query will return 19 rows and that the second +query will return 62350411 rows. To return 62350411 rows it's faster to +just scan the table and not use the index. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Tue Mar 8 19:20:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F2C456401 + for ; + Tue, 8 Mar 2005 19:20:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67636-07 + for ; + Tue, 8 Mar 2005 19:20:27 +0000 (GMT) +Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net + [194.217.242.89]) + by svr1.postgresql.org (Postfix) with ESMTP id 06D20563FE + for ; + Tue, 8 Mar 2005 19:20:26 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-31.mail.demon.net with esmtp (Exim 4.42) + id 1D8kDr-00013I-3N; Tue, 08 Mar 2005 19:18:27 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id BF571168BB; Tue, 8 Mar 2005 19:20:23 +0000 (GMT) +Message-ID: <422DFAF6.2080201@archonet.com> +Date: Tue, 08 Mar 2005 19:20:22 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gaetano Mendola +Cc: 'Postgresql Performance' +Subject: Re: bad plan +References: <422D7F23.7000109@bigfoot.com> <422D8F0E.8000906@archonet.com> + <422D9904.5010904@bigfoot.com> <422DA6A5.2060908@archonet.com> + <422DF073.7080307@bigfoot.com> +In-Reply-To: <422DF073.7080307@bigfoot.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/137 +X-Sequence-Number: 10842 + +Gaetano Mendola wrote: +> Richard Huxton wrote: +> +> +>>OK, so looking at the original EXPLAIN the order of processing seems to be: +>>1. v_sat_request is evaluated and filtered on login='...' (lines 7..15) +>>This gives us 31 rows +>>2. The left-join from v_sat_request to v_sc_packages is processed (lines +>>5..6) +>>This involves the subquery scan on vsp (from line 16) where it seems to +>>think the best idea is a merge join of programs to sequences. +> +> +> Whel basically v_sc_packages depends on other 3 views that are just a simple +> interface to a plain table. +> +> +> If I execute a select only on this table I get reasonable executions time: +> +> +> === cpu_tuple_cost = 0.07 +> +> # explain analyze select * from v_sc_packages where id_package = 19628; +> QUERY PLAN +> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- +> Nested Loop (cost=0.00..15.96 rows=1 width=131) (actual time=41.450..41.494 rows=1 loops=1) +> -> Nested Loop (cost=0.00..11.86 rows=1 width=116) (actual time=1.022..1.055 rows=1 loops=1) +> -> Nested Loop Left Join (cost=0.00..7.89 rows=1 width=104) (actual time=0.330..0.345 rows=1 loops=1) +> -> Index Scan using packages_pkey on packages p (cost=0.00..3.90 rows=1 width=104) (actual time=0.070..0.075 rows=1 loops=1) +> Index Cond: (id_package = 19628) +> -> Index Scan using package_security_id_package_key on package_security ps (cost=0.00..3.91 rows=1 width=4) (actual time=0.232..0.237 rows=1 loops=1) +> Index Cond: ("outer".id_package = ps.id_package) +> -> Index Scan using idx_sequences_id_package on sequences (cost=0.00..3.90 rows=1 width=16) (actual time=0.670..0.685 rows=1 loops=1) +> Index Cond: (19628 = id_package) +> Filter: (estimated_start IS NOT NULL) +> -> Index Scan using programs_pkey on programs (cost=0.00..4.02 rows=1 width=19) (actual time=0.078..0.086 rows=1 loops=1) +> Index Cond: (programs.id_program = "outer".id_program) +> Filter: (id_program <> 0) +> Total runtime: 42.650 ms +> (14 rows) + +> === cpu_tuple_cost = 0.01 + +> === cpu_tuple_cost = 0.001 + +I don't know what you think you're measuring, but it's nothing to do +with the plans. If you look at the plans carefully, you'll see they're +all the same. The "cost" numbers change because that's the parameter +you're changing. + +I'm not sure it makes sense to vary cpu_tuple_cost from 0.07 down to +0.001 - that's a factor of 70 difference. I might be tempted to halve or +double it, but even then only after some serious testing. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Mar 8 20:01:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3AAB25643E + for ; + Tue, 8 Mar 2005 20:01:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81309-01 + for ; + Tue, 8 Mar 2005 20:01:24 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 600BA56378 + for ; + Tue, 8 Mar 2005 20:01:23 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j28K1GIE013635; + Tue, 8 Mar 2005 15:01:16 -0500 (EST) +To: Gaetano Mendola +Cc: Richard Huxton , + "pgsql-performance@postgresql.org" +Subject: Re: bad plan +In-reply-to: <422D9904.5010904@bigfoot.com> +References: <422D7F23.7000109@bigfoot.com> <422D8F0E.8000906@archonet.com> + <422D9904.5010904@bigfoot.com> +Comments: In-reply-to Gaetano Mendola + message dated "Tue, 08 Mar 2005 13:22:28 +0100" +Date: Tue, 08 Mar 2005 15:01:15 -0500 +Message-ID: <13634.1110312075@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/138 +X-Sequence-Number: 10843 + +Gaetano Mendola writes: +>> Since your query is so simple, I'm guessing v_sc_user_request is a view. +>> Can you provide the definition? + +> Of course: + +I don't think you've told us the whole truth about the v_sc_packages +view. The definition as given doesn't work at all (it'll have +duplicate column names), but more to the point, if it were that simple +then the planner would fold it into the parent query. The subquery +scan node indicates that folding did not occur. The most likely reason +for that is that there's an ORDER BY in the view. + +Putting ORDER BYs in views that you intend to use as components of other +views is a bad practice from a performance perspective... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 8 20:14:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5631555F03 + for ; + Tue, 8 Mar 2005 20:14:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82987-06 + for ; + Tue, 8 Mar 2005 20:13:58 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 015EF55916 + for ; + Tue, 8 Mar 2005 20:13:57 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7106189 for pgsql-performance@postgresql.org; + Tue, 08 Mar 2005 12:15:48 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "pgsql-performance@postgresql.org" +Subject: Why would writes to pgsql_tmp bottleneck at 1mb/s? +Date: Tue, 8 Mar 2005 12:18:24 -0800 +User-Agent: KMail/1.7.1 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200503081218.24093.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.284 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200503/139 +X-Sequence-Number: 10844 + +PG Hackers, + +What follows is iostat output from a TPC-H test on Solaris 10. The machine +is creating indexes on a table which is 50G in size, so it needs to use +pgsql_tmp for internal swapping: + + tty md15 sd1 sd2 sd3 cpu + tin tout kps tps serv kps tps serv kps tps serv kps tps serv us sy wt id + 0 84 22526 1211 1 1024 1 5 0 0 0 5634 337 1 30 8 +0 61 + 0 242 24004 1337 1 1024 1 5 0 0 0 6007 355 1 33 8 +0 59 + 0 85 22687 1277 1 1024 1 5 0 0 0 5656 322 1 31 8 +0 62 + 0 85 20876 1099 1 1024 2 9 0 0 0 5185 292 1 28 7 +0 64 + +md15 is WAL (pg_xlog). +sd3 is PGDATA. +sd1 i pgsql_tmp. + +As you can see, we're getting a nice 23mb/s peak for WAL (thanks to +forcedirectio) and database writes peak at 6mb/s. However, pgsql_tmp, which +is being used heavily, hovers around 1mb/s, and never goes above 1.5mb/s. +This seems to be throttling the whole system. + +Any suggestions on why this should be? Do we have a performance bug in the +pg_tmp code? + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Mar 8 20:25:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B110D55CEE + for ; + Tue, 8 Mar 2005 20:25:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87567-01 + for ; + Tue, 8 Mar 2005 20:25:03 +0000 (GMT) +Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net + [194.217.242.90]) + by svr1.postgresql.org (Postfix) with ESMTP id D246B52AA9 + for ; + Tue, 8 Mar 2005 20:25:02 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 4.42) + id 1D8lGI-000CV4-81; Tue, 08 Mar 2005 20:25:02 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id F00D5168B4; Tue, 8 Mar 2005 20:25:00 +0000 (GMT) +Message-ID: <422E0A1E.1080804@archonet.com> +Date: Tue, 08 Mar 2005 20:25:02 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Gaetano Mendola , + "pgsql-performance@postgresql.org" +Subject: Re: bad plan +References: <422D7F23.7000109@bigfoot.com> <422D8F0E.8000906@archonet.com> + <422D9904.5010904@bigfoot.com> <13634.1110312075@sss.pgh.pa.us> +In-Reply-To: <13634.1110312075@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/140 +X-Sequence-Number: 10845 + +Tom Lane wrote: +> +> Putting ORDER BYs in views that you intend to use as components of other +> views is a bad practice from a performance perspective... + +There are also a lot of views involved here for very few output columns. +Tom - is the planner smart enough to optimise-out unneeded columns from +a SELECT * view if it's part of a join/subquery and you only use one or +two columns? + +Secondly, in the original plan we have: +-> Nested Loop Left Join (cost=1478.82..1716.37 rows=1 width=201) +(actual time=3254.483..52847.064 rows=31 loops=1) + +Now, we've got 31 rows instead of 1 here. The one side of the join ends +up as: +-> Subquery Scan vsp (cost=985.73..1016.53 rows=1103 width=12) (actual +time=25.328..1668.754 rows=493 loops=31) +-> Merge Join (cost=985.73..1011.01 rows=1103 width=130) (actual +time=25.321..1666.666 rows=493 loops=31) + +Would I be right in thinking the planner doesn't materialise the +subquery because it's expecting 1 loop not 31? If there were 1 row the +plan would seem OK to me. + +Is there any mileage in the idea of a "lazy" planner that keeps some +alternative paths around in case they're needed? Or a reactive one that +can re-plan nodes when assumptions turn out to be wrong? + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Mar 8 20:42:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A21155F03 + for ; + Tue, 8 Mar 2005 20:42:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91413-04 + for ; + Tue, 8 Mar 2005 20:42:08 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id CE35A54D3A + for ; + Tue, 8 Mar 2005 20:42:06 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j28Kg3JI013881; + Tue, 8 Mar 2005 15:42:04 -0500 (EST) +To: Richard Huxton +Cc: Gaetano Mendola , + "pgsql-performance@postgresql.org" +Subject: Re: bad plan +In-reply-to: <422E0A1E.1080804@archonet.com> +References: <422D7F23.7000109@bigfoot.com> <422D8F0E.8000906@archonet.com> + <422D9904.5010904@bigfoot.com> <13634.1110312075@sss.pgh.pa.us> + <422E0A1E.1080804@archonet.com> +Comments: In-reply-to Richard Huxton + message dated "Tue, 08 Mar 2005 20:25:02 +0000" +Date: Tue, 08 Mar 2005 15:42:03 -0500 +Message-ID: <13880.1110314523@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/141 +X-Sequence-Number: 10846 + +Richard Huxton writes: +> There are also a lot of views involved here for very few output columns. +> Tom - is the planner smart enough to optimise-out unneeded columns from +> a SELECT * view if it's part of a join/subquery and you only use one or +> two columns? + +If the view gets flattened, yes, but I believe that it's not bright +enough to do so when it can't flatten the view. You could tell easily +enough by looking at the row-width estimates at various levels of the +plan. (Let's see ... in Gaetano's plan the SubqueryScan is returning +12-byte rows where its input MergeJoin is returning 130-byte rows, +so sure enough the view is computing a lot of stuff that then gets +thrown away.) + +> Would I be right in thinking the planner doesn't materialise the +> subquery because it's expecting 1 loop not 31? If there were 1 row the +> plan would seem OK to me. + +Right; it doesn't see any predicted gain from the extra cost of +materializing. But to me the main problem here is not that, it is that +the entire shape of the plan would likely be different if it weren't for +the "optimization fence" that the Subquery Scan node represents. I +suspect too that the use of mergejoin as opposed to anything else within +the vsp subplan is driven more by the need to produce sorted output than +by what is the cheapest way to get the rows. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 9 00:04:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CA03563DF + for ; + Wed, 9 Mar 2005 00:04:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39942-09 + for ; + Wed, 9 Mar 2005 00:04:34 +0000 (GMT) +Received: from alpinegeophysics.com (sta-206-168-222-6.rockynet.com + [206.168.222.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B9DA563D5 + for ; + Wed, 9 Mar 2005 00:04:32 +0000 (GMT) +Received: from [192.168.1.100] [168.103.51.63] by alpinegeophysics.com with + ESMTP (SMTPD32-7.07) id ACCF7B200AC; Tue, 08 Mar 2005 17:01:19 -0700 +Message-ID: <422E3D81.3000407@alpinegeophysics.com> +Date: Tue, 08 Mar 2005 16:04:17 -0800 +From: James G Wilkinson +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Query Optimization +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/142 +X-Sequence-Number: 10847 + +All, + +I hope that this is the right place to post. I am relatively new to +PostgreSQL (i.e., < 1 year in coding) and am just starting to +delve into the issues of query optimization. I have hunted around +the web for the basics of query optimization, but I have not had +much success in interpreting the documents. I have also been +trying to learn the basics of the EXPLAIN command....also without +much success, but I will keep trying. + +Anyway, here is what the system reports on the following command: + +EXPLAIN SELECT a.country_code, a.state_county_fips, + icell, jcell, a.beld3_species_id, pollutant_code, + SUM(b.ratio * d.emissions_factor * a.percent_ag * + e.ag_fraction * 10000) as normalized_emissions +FROM "globals"."biogenic_beld3_data" a, + "spatial"."tmpgrid" b, + "globals"."biogenic_emissions_factors" d, + "globals"."biogenic_beld3_ag_data" e +WHERE a.beld3_icell=b.b_icell AND + a.beld3_jcell=b.b_jcell AND + a.country_code=e.country_code AND + a.state_county_fips=e.state_county_fips AND + a.beld3_species_id=d.beld3_species_id AND + a.ag_forest_records > 0 AND + a.percent_ag > 0 AND d.emissions_factor > 0 +GROUP BY a.country_code, a.state_county_fips, icell, jcell, + a.beld3_species_id, pollutant_code +ORDER BY a.country_code, a.state_county_fips, icell, jcell, + a.beld3_species_id, pollutant_code; + + QUERY +PLAN +----------------------------------------------------------------------------------------------- +GroupAggregate (cost=65034.94..71110.50 rows=151889 width=73) +->Sort (cost=65034.94..65414.66 rows=151889 width=73) + Sort Key: a.country_code, a.state_county_fips, b.icell, b.jcell, + a.beld3_species_id, d.pollutant_code + ->Hash Join (cost=33749.64..37412.88 rows=151889 width=73) + Hash Cond: ("outer".beld3_species_id = "inner".beld3_species_id) + ->Merge Join (cost=33728.84..35303.61 rows=37972 width=56) + Merge Cond: ((("outer".country_code)::text = +"inner"."?column8?") AND + (("outer".state_county_fips)::text = +"inner"."?column9?")) + ->Index Scan using biogenic_beld3_ag_data_pk on +biogenic_beld3_ag_data e + (cost=0.00..806.68 rows=20701 width=26) + ->Sort (cost=33728.84..33741.67 rows=5131 width=45) + Sort Key: (a.country_code)::text, +(a.state_county_fips)::text + ->Nested Loop (cost=0.00..33412.65 rows=5131 width=45) + ->Seq Scan on biogenic_beld3_data a +(cost=0.00..3593.02 rows=5637 width=37) + Filter: ((ag_forest_records > 0) AND (percent_ag + > 0::numeric)) + ->Index Scan using tmpgrid_pk on tmpgrid b +(cost=0.00..5.27 rows=1 width=24) + Index Cond: ((b.b_icell = "outer".beld3_icell) AND + (b.b_jcell = "outer".beld3_jcell)) + ->Hash (cost=18.50..18.50 rows=920 width=21) + ->Seq Scan on biogenic_emissions_factors d +(cost=0.00..18.50 rows=920 width=21) + Filter: (emissions_factor > 0::numeric) +(18 rows) + + +Firstly, I am frankly mystified on how to interpret all this. If anyone +could point me to a document or two that will help me decipher this, +I will greatly appreciate it. + +Secondly, I have figured out that SEQ SCANs are typically bad. I am +concerned that a SEQ SCAN is being performed on 'biogenic_beld3_data' +which is the largest table in the query. I would rather have a SEQ SCAN +be performed on 'tmpgrid' which contains the keys that subset the data +from 'biogenic_beld3_data.' Is this naive on my part? + +Thirdly, I have run EXPLAIN on other queries that report back a +GroupAggregate Cost= that runs in about 30 minutes +on my relatively highend linux machine. But when I run this particular +query, it takes on the order of 90 minutes to complete. Any thoughts +on why this happens will be appreciated. + +Finally, if anyone can be so kind as to provide insight on how to better +optimize this query, I will, again, be deeply grateful. + +Thanks in advance. + +terrakit + +From pgsql-performance-owner@postgresql.org Wed Mar 9 00:13:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CD749563D5 + for ; + Wed, 9 Mar 2005 00:13:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45377-05 + for ; + Wed, 9 Mar 2005 00:13:30 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F714563F1 + for ; + Wed, 9 Mar 2005 00:13:29 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7106879 for pgsql-performance@postgresql.org; + Tue, 08 Mar 2005 16:15:21 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "pgsql-performance@postgresql.org" +Subject: Re: Why would writes to pgsql_tmp bottleneck at 1mb/s? +Date: Tue, 8 Mar 2005 16:17:57 -0800 +User-Agent: KMail/1.7.1 +References: <200503081218.24093.josh@agliodbs.com> +In-Reply-To: <200503081218.24093.josh@agliodbs.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200503081617.57190.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.285 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200503/143 +X-Sequence-Number: 10848 + +People: + +> As you can see, we're getting a nice 23mb/s peak for WAL (thanks to +> forcedirectio) and database writes peak at 6mb/s. However, pgsql_tmp, +> which is being used heavily, hovers around 1mb/s, and never goes above +> 1.5mb/s. This seems to be throttling the whole system. + +Never mind, I'm a dork. I accidentally cut the "SET maintenance_work_mem = +2000000" out of my config file, and it was running with the default +1024K .... + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Mar 9 00:40:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 297C65639A + for ; + Wed, 9 Mar 2005 00:40:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50750-07 + for ; + Wed, 9 Mar 2005 00:40:05 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id AC3D35638B + for ; + Wed, 9 Mar 2005 00:40:03 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7106979 for pgsql-performance@postgresql.org; + Tue, 08 Mar 2005 16:41:56 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "pgsql-performance@postgresql.org" +Subject: Re: Why would writes to pgsql_tmp bottleneck at 1mb/s? +Date: Tue, 8 Mar 2005 16:44:32 -0800 +User-Agent: KMail/1.7.1 +References: <200503081218.24093.josh@agliodbs.com> + <200503081617.57190.josh@agliodbs.com> +In-Reply-To: <200503081617.57190.josh@agliodbs.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200503081644.32497.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.286 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200503/144 +X-Sequence-Number: 10849 + +Hmmmm..... + +> > As you can see, we're getting a nice 23mb/s peak for WAL (thanks to +> > forcedirectio) and database writes peak at 6mb/s. However, pgsql_tmp, +> > which is being used heavily, hovers around 1mb/s, and never goes above +> > 1.5mb/s. This seems to be throttling the whole system. +> +> Never mind, I'm a dork. I accidentally cut the "SET maintenance_work_mem +> = 2000000" out of my config file, and it was running with the default 1024K + +Maybe I'm not an idiot (really!) even with almost 2GB of maintenance_mem, PG +still writes to pgsql_tmp no faster than 2MB/s. I think there may be an +artificial bottleneck there. Question is, PostgreSQL, OS or hardware? + +Suggestions? + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Mar 9 00:47:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D19FE563A7 + for ; + Wed, 9 Mar 2005 00:47:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56800-08 + for ; + Wed, 9 Mar 2005 00:47:46 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 2625D56391 + for ; + Wed, 9 Mar 2005 00:47:44 +0000 (GMT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j291olP20492; + Wed, 9 Mar 2005 02:50:47 +0100 +Received: from [127.0.0.1] (accesspoint.mm.eutelsat.org [194.214.173.4]) + by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j290lhR05505; + Wed, 9 Mar 2005 01:47:43 +0100 +Message-ID: <422E47A0.1080008@bigfoot.com> +Date: Wed, 09 Mar 2005 01:47:28 +0100 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane , + "pgsql-performance@postgresql.org" +Subject: Re: bad plan +References: <422D7F23.7000109@bigfoot.com> <422D8F0E.8000906@archonet.com> + <422D9904.5010904@bigfoot.com> <13634.1110312075@sss.pgh.pa.us> +In-Reply-To: <13634.1110312075@sss.pgh.pa.us> +X-Enigmail-Version: 0.90.1.1 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.196 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/145 +X-Sequence-Number: 10850 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Tom Lane wrote: +> Gaetano Mendola writes: +> +>>>Since your query is so simple, I'm guessing v_sc_user_request is a view. +>>>Can you provide the definition? +> +> +>>Of course: +> +> +> I don't think you've told us the whole truth about the v_sc_packages +> view. The definition as given doesn't work at all (it'll have +> duplicate column names), but more to the point, if it were that simple +> then the planner would fold it into the parent query. The subquery +> scan node indicates that folding did not occur. The most likely reason +> for that is that there's an ORDER BY in the view. + +I didn't say the complete truth because the view definition is long so I just omitted +all fields. + +explain analyze SELECT name,url,descr,request_status,url_status,size_mb,estimated_start,request_time_stamp +FROM v_sc_user_request +WHERE login = 'babinow1' +LIMIT 10 ; + +these are the complete definitions of views involved in the query: + + + +CREATE OR REPLACE VIEW v_sc_user_request AS + SELECT + vsr.id_sat_request AS id_sat_request, + vsr.id_user AS id_user, + vsr.login AS login, + vsr.url AS url, + vsr.name AS name, + vsr.descr AS descr, + vsr.size AS size, + trunc(vsr.size/1024.0/1024.0,2) AS size_mb, + vsr.id_sat_request_status AS id_sat_request_status, + sp_lookup_key('sat_request_status', vsr.id_sat_request_status) AS request_status, + sp_lookup_descr('sat_request_status', vsr.id_sat_request_status) AS request_status_descr, + vsr.id_url_status AS id_url_status, + sp_lookup_key('url_status', vsr.id_url_status) AS url_status, + sp_lookup_descr('url_status', vsr.id_url_status) AS url_status_descr, + vsr.url_time_stamp AS url_time_stamp, + date_trunc('seconds',vsr.request_time) AS request_time_stamp, + vsr.id_package AS id_package, + COALESCE(date_trunc('seconds',vsp.estimated_start)::text,'NA') AS estimated_start + + FROM + v_sat_request vsr LEFT OUTER JOIN v_sc_packages vsp USING ( id_package ) + WHERE + vsr.request_time > now() - '1 month'::interval AND + vsr.expired = FALSE + ORDER BY id_sat_request DESC +; + + + + +CREATE OR REPLACE VIEW v_sat_request AS + SELECT + sr.id_user AS id_user, + ul.login AS login, + sr.id_sat_request AS id_sat_request, + u.id_url AS id_url, + u.url AS url, + u.name AS name, + u.descr AS descr, + u.size AS size, + u.storage AS storage, + sr.id_package AS id_package, + sr.id_sat_request_status AS id_sat_request_status, + sr.request_time AS request_time, + sr.work_time AS request_work_time, + u.id_url_status AS id_url_status, + u.time_stamp AS url_time_stamp, + sr.expired AS expired + FROM + sat_request sr, + url u, + user_login ul + WHERE + ---------------- JOIN --------------------- + sr.id_url = u.id_url AND + sr.id_user = ul.id_user + ------------------------------------------- +; + + + + +CREATE OR REPLACE VIEW v_sc_packages AS + SELECT + + vpr.id_program AS id_program, + vpr.name AS program_name, + + vpk.id_package AS id_package, + date_trunc('seconds', vs.estimated_start) AS estimated_start, + + vpk.name AS package_name, + vpk.TYPE AS TYPE, + vpk.description AS description, + vpk.target AS target, + vpk.fec AS fec_alg, + vpk.output_group - vpk.input_group AS fec_redundancy, + vpk.priority AS priority, + vpk.updatable AS updatable, + vpk.auto_listen AS auto_listen, + vpk.start_file AS start_file, + vpk.view_target_group AS view_target_group, + vpk.target_group AS target_group + + FROM + v_programs vpr, + v_packages vpk, + v_sequences vs + + WHERE + ------------ JOIN ------------- + vpr.id_program = vs.id_program AND + vpk.id_package = vs.id_package AND + + ------------------------------- + vs.estimated_start IS NOT NULL +; + + + +CREATE OR REPLACE VIEW v_programs AS + SELECT id_program AS id_program, + id_publisher AS id_publisher, + name AS name, + description AS description, + sp_lookup_key('program_type', id_program_type) AS TYPE, + sp_lookup_key('program_status', id_program_status) AS status, + last_position AS last_position + FROM programs + WHERE id_program<>0 +; + + +CREATE OR REPLACE VIEW v_packages AS + SELECT p.id_package AS id_package, + p.id_publisher AS id_publisher, + p.name AS name, + p.information AS information, + p.description AS description, + sp_lookup_key('package_type', p.id_package_type) + AS TYPE, + sp_lookup_key('target', p.id_target) + AS target, + p.port AS port, + p.priority AS priority, + sp_lookup_key('fec', p.id_fec) + AS fec, + p.input_group AS input_group, + p.output_group AS output_group, + p.updatable AS updatable, + p.checksum AS checksum, + p.version AS version, + p.start_file AS start_file, + p.view_target_group AS view_target_group, + p.target_group AS target_group, + p.auto_listen AS auto_listen, + p.public_flag AS public_flag, + p.needed_version AS needed_version, + p.logic_version AS logic_version, + p.package_size AS package_size, + ps.id_drm_process AS id_drm_process, + ps.id_cas_service AS id_cas_service, + ps.id_cas_settings AS id_cas_settings, + ps.id_drm_service AS id_drm_service + + FROM packages p LEFT OUTER JOIN package_security ps USING (id_package) + ; + + + +CREATE OR REPLACE VIEW v_sequences AS + SELECT id_package AS id_package, + id_program AS id_program, + internal_position AS internal_position, + estimated_start AS estimated_start + FROM sequences +; + + + +> Putting ORDER BYs in views that you intend to use as components of other +> views is a bad practice from a performance perspective... + +Indeed when a view is involved in a join we do not put "order by" in it ( at +least this is what I try to do ), I have to say also that some time I see that replacing +the view with the tables that it represent the execution time is better +( I have an example to show you if you are interested in it ). + + +Regards +Gaetano Mendola + + + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCLkef7UpzwH2SGd4RAt90AJ9e3qUSx2fxiOO2aA30TbLsOdyV7ACfd0RY ++2A3U6dDfWw/H4eWcmI8mS0= +=t1AD +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Wed Mar 9 00:58:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7847D563A7 + for ; + Wed, 9 Mar 2005 00:58:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61618-04 + for ; + Wed, 9 Mar 2005 00:58:09 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 37902563A4 + for ; + Wed, 9 Mar 2005 00:58:09 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id A87BD3198E; Wed, 9 Mar 2005 01:58:12 +0100 (MET) +From: Gaetano Mendola +X-Newsgroups: pgsql.performance +Subject: Re: pl/pgsql faster than raw SQL? +Date: Wed, 09 Mar 2005 01:54:32 +0100 +Organization: Hub.Org Networking Services +Lines: 26 +Message-ID: <422E4948.3090208@bigfoot.com> +References: <1110284432.4905.18.camel@dicaprio.akademie1.de> +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +X-Complaints-To: usenet@news.hub.org +To: =?UTF-8?B?TWFya3VzIEJlcnRoZWF1IOKYrQ==?= +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +In-Reply-To: <1110284432.4905.18.camel@dicaprio.akademie1.de> +X-Enigmail-Version: 0.90.1.1 +X-Enigmail-Supports: pgp-inline, pgp-mime +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/146 +X-Sequence-Number: 10851 + +Markus Bertheau ☭ wrote: +> Hi, I have the following strange situation: + +that is no so strange. I have an example where: + +SELECT * FROM my_view WHERE field1 = 'New'; ==> 800 seconds + +SELECT * FROM my_view; ==> 2 seconds + +the only solution I had was to write a function table with +the second select in a loop that was returnin the row if +the field1 was equal = 'New'. +It's strange but happen. + + + +Regards +Gaetano Mendola + + + + + + + + + +From pgsql-performance-owner@postgresql.org Wed Mar 9 01:02:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0816652A5B + for ; + Wed, 9 Mar 2005 01:02:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65390-01 + for ; + Wed, 9 Mar 2005 01:02:28 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 09493563F6 + for ; + Wed, 9 Mar 2005 01:02:24 +0000 (GMT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j2925TS20586 + for ; Wed, 9 Mar 2005 03:05:29 +0100 +Received: from [127.0.0.1] (accesspoint.mm.eutelsat.org [194.214.173.4]) + by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j2912RR05617 + for ; Wed, 9 Mar 2005 02:02:27 +0100 +Message-ID: <422E4B15.60806@bigfoot.com> +Date: Wed, 09 Mar 2005 02:02:13 +0100 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Subject: vacuum full, why multiple times ? +X-Enigmail-Version: 0.90.1.1 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.403 tagged_above=0 required=5 tests=AWL, + TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200503/147 +X-Sequence-Number: 10852 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Hi all, +this is the third email that I post but I do not see it in archives, +the email was too long I believe so this time I will limit the rows. +Basically I'm noticing that a simple vacuum full is not enough to +shrink completelly the table: + +# vacuum full verbose url; +INFO: vacuuming "public.url" +INFO: "url": found 268392 removable, 21286 nonremovable row versions in 8563 pages +DETAIL: 22 dead row versions cannot be removed yet. +Nonremovable row versions range from 104 to 860 bytes long. +There were 13924 unused item pointers. +Total free space (including removable row versions) is 63818404 bytes. +4959 pages are or will become empty, including 7 at the end of the table. +8296 pages containing 63753840 free bytes are potential move destinations. +CPU 0.33s/0.12u sec elapsed 9.55 sec. + +[SNIPPED] + +INFO: "url": moved 2 row versions, truncated 8563 to 8550 pages + + +and after 4 vacuum full: + + + +empdb=# vacuum full verbose url; +INFO: vacuuming "public.url" +INFO: "url": found 13 removable, 21264 nonremovable row versions in 8504 pages +DETAIL: 0 dead row versions cannot be removed yet. +Nonremovable row versions range from 104 to 860 bytes long. +There were 280528 unused item pointers. +Total free space (including removable row versions) is 63349188 bytes. +4913 pages are or will become empty, including 0 at the end of the table. +8234 pages containing 63340628 free bytes are potential move destinations. +CPU 0.17s/0.04u sec elapsed 0.49 sec. + +[SNIPPED] + +INFO: "url": moved 5666 row versions, truncated 8504 to 621 pages + + + + +anyone knows why ? I had the same behaviour with a 46000 rows table with +46000 pages! It was reduced to 3000 pages after 7 vacuum full. + + +Regards +Gaetano Mendola + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCLksV7UpzwH2SGd4RAoz3AKDvXSx3w/jRz/NR1pgtrxIZs8cJcwCg/0xm +zSr0sPDBkp8V1WXjREoVdLk= +=EHv2 +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Wed Mar 9 01:13:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 79134563A7 + for ; + Wed, 9 Mar 2005 01:13:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65770-07 + for ; + Wed, 9 Mar 2005 01:13:27 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.193]) + by svr1.postgresql.org (Postfix) with ESMTP id 5AC36556EA + for ; + Wed, 9 Mar 2005 01:13:25 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 68so134705wra + for ; + Tue, 08 Mar 2005 17:13:29 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=T3FRMuLjsVwIb0EM0M7bVKPI+60RkTez36tYs0tKPZpTqVJzSujRBC0PlNHxi5P577mFrb4tj0274gk/YKLBiC+LTgTke5rg75Mj5HvPJZ6Ec8uxpVVpIg7tI8pMCICvLSx+1pxaQXBlQJ0ySSE4d4G3nVEXOtugo46SQSAOq+k= +Received: by 10.54.45.41 with SMTP id s41mr338450wrs; + Tue, 08 Mar 2005 17:13:29 -0800 (PST) +Received: by 10.54.14.41 with HTTP; Tue, 8 Mar 2005 17:13:29 -0800 (PST) +Message-ID: <19ab0ccd05030817132e702cd4@mail.gmail.com> +Date: Tue, 8 Mar 2005 20:13:29 -0500 +From: Aaron Birkland +Reply-To: apb18@cornell.edu +To: josh@agliodbs.com +Subject: Re: Why would writes to pgsql_tmp bottleneck at 1mb/s? +Cc: "pgsql-performance@postgresql.org" +In-Reply-To: <200503081644.32497.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <200503081218.24093.josh@agliodbs.com> + <200503081617.57190.josh@agliodbs.com> + <200503081644.32497.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.211 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/148 +X-Sequence-Number: 10853 + +> Maybe I'm not an idiot (really!) even with almost 2GB of maintenance_mem, PG +> still writes to pgsql_tmp no faster than 2MB/s. I think there may be an +> artificial bottleneck there. Question is, PostgreSQL, OS or hardware? + +I'm curious: what is your cpu usage while this is happening? I've +noticed similar slow index creation behaviour, but I did not make any +connection to pgsql_temp (because it was not on a separate partition). + I was indexing an oid field of a 700GB table and it took about four +days on a 1.2GHz UltraSparcIII (solaris 9, 8GB core). I noticed that +the one CPU that was pegged at near 100%, leading me to believe it +was CPU bound. Odd thing is that the same operation on a 2GHz Pentium +IV box (Linux) on the same data took about a day. Truss showed that +a great majority of that time was in userland. + + -Aaron + +From pgsql-performance-owner@postgresql.org Wed Mar 9 01:28:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 573C0563D5 + for ; + Wed, 9 Mar 2005 01:28:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69567-05 + for ; + Wed, 9 Mar 2005 01:28:08 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C7FC563C1 + for ; + Wed, 9 Mar 2005 01:28:07 +0000 (GMT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j291S3326223; + Tue, 8 Mar 2005 19:28:04 -0600 +Message-ID: <422E511B.40102@arbash-meinel.com> +Date: Tue, 08 Mar 2005 19:27:55 -0600 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gaetano Mendola +Cc: =?UTF-8?B?TWFya3VzIEJlcnRoZWF1IOKYrQ==?= , + pgsql-performance@postgresql.org +Subject: Re: pl/pgsql faster than raw SQL? +References: <1110284432.4905.18.camel@dicaprio.akademie1.de> + <422E4948.3090208@bigfoot.com> +In-Reply-To: <422E4948.3090208@bigfoot.com> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig0B5D74354F9ECD1724F0A569" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/149 +X-Sequence-Number: 10854 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig0B5D74354F9ECD1724F0A569 +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 8bit + +Gaetano Mendola wrote: + +>Markus Bertheau ☭ wrote: +> +> +>>Hi, I have the following strange situation: +>> +>> +> +>that is no so strange. I have an example where: +> +>SELECT * FROM my_view WHERE field1 = 'New'; ==> 800 seconds +> +>SELECT * FROM my_view; ==> 2 seconds +> +>the only solution I had was to write a function table with +>the second select in a loop that was returnin the row if +>the field1 was equal = 'New'. +>It's strange but happen. +> +> +> +>Regards +>Gaetano Mendola +> +> + +That sounds more like you had bad statistics on the field1 column, which +caused postgres to switch from a seqscan to an index scan, only there +were so many rows with field1='New' that it actually would have been +faster with a seqscan. + +Otherwise what you did is very similar to the "nested loop" of postgres +which it selects when appropriate. + +The other issue with views is that depending on their definition, +sometimes postgres can flatten them out and optimize the query, and +sometimes it can't. Order by is one of the big culprits for bad queries +involving views. + +John +=:-> + + +--------------enig0B5D74354F9ECD1724F0A569 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCLlEeJdeBCYSNAAMRAt20AJ9vnwejH4/RXNUNFc152sduBtE0PACgmxuf +BQ45wBmqOYlJLK3uP72iIp0= +=M0Jt +-----END PGP SIGNATURE----- + +--------------enig0B5D74354F9ECD1724F0A569-- + +From pgsql-performance-owner@postgresql.org Wed Mar 9 01:46:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A3F5D563A4 + for ; + Wed, 9 Mar 2005 01:46:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72451-10 + for ; + Wed, 9 Mar 2005 01:46:39 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 68752563C2 + for ; + Wed, 9 Mar 2005 01:46:38 +0000 (GMT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j291kf326383; + Tue, 8 Mar 2005 19:46:42 -0600 +Message-ID: <422E557D.7030500@arbash-meinel.com> +Date: Tue, 08 Mar 2005 19:46:37 -0600 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: James G Wilkinson +Cc: pgsql-performance@postgresql.org +Subject: Re: Query Optimization +References: <422E3D81.3000407@alpinegeophysics.com> +In-Reply-To: <422E3D81.3000407@alpinegeophysics.com> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig9C17025D65B09BA78C75E059" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/150 +X-Sequence-Number: 10855 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig9C17025D65B09BA78C75E059 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +James G Wilkinson wrote: + +> All, +> +... + +> Firstly, I am frankly mystified on how to interpret all this. If anyone +> could point me to a document or two that will help me decipher this, +> I will greatly appreciate it. +> +I assume you have looked at: +http://www.postgresql.org/docs/8.0/static/performance-tips.html +And didn't find it helpful enough. I'm not really sure what help you are +asking. Are you saying that this query is performing slowly and you want +to speed it up? Or you just want to understand how to interpret the +output of explain? + +> Secondly, I have figured out that SEQ SCANs are typically bad. I am +> concerned that a SEQ SCAN is being performed on 'biogenic_beld3_data' +> which is the largest table in the query. I would rather have a SEQ SCAN +> be performed on 'tmpgrid' which contains the keys that subset the data +> from 'biogenic_beld3_data.' Is this naive on my part? + +It depends how much data is being extracted. If you have 1,000,000 rows, +and only need 10, then an index scan is wonderful. If you need 999,999, +then a sequential scan is much better (the break even point is <10%) + From the explain, it thinks it is going to be needing 5,637 rows from +biogenic_beld3_data, what is that portion relative to the total? + +The values at least look like you've run vacuum analyze. Have you tried +running "explain analyze" instead of just explain? Then you can see if +the planners estimates are accurate. + +If you want some help to force it, you could try a subselect query. +Something like: + +select * from biogenic_beld3_data b where b.beld3_icell = (select +b_icell from tmpgrid_pk) and b.beld3_jcell = (select b_jcell from +tmpgrid_pk); + +> +> Thirdly, I have run EXPLAIN on other queries that report back a +> GroupAggregate Cost= that runs in about 30 minutes +> on my relatively highend linux machine. But when I run this particular +> query, it takes on the order of 90 minutes to complete. Any thoughts +> on why this happens will be appreciated. +> +Remember cost is in terms of page fetches, not in seconds. +Probably it is just an issue of postgres mis-estimating the selectivity +of one of your queries. +Also, you have a fairly complex SUM occurring involving 4 +multiplications on an estimated 150,000 rows. While doesn't seem like it +should take 90 minutes, it also isn't a trivial operation. + +> Finally, if anyone can be so kind as to provide insight on how to better +> optimize this query, I will, again, be deeply grateful. +> +> Thanks in advance. +> +> terrakit +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster + +John +=:-> + + +--------------enig9C17025D65B09BA78C75E059 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCLlV9JdeBCYSNAAMRAoSyAKClXsPxacgTYhjhAzUiik5uIE4AJgCgy6FO ++UzLbTuP7opLvnAKsKSO/ww= +=8cBI +-----END PGP SIGNATURE----- + +--------------enig9C17025D65B09BA78C75E059-- + +From pgsql-performance-owner@postgresql.org Wed Mar 9 02:15:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 065E656408 + for ; + Wed, 9 Mar 2005 02:15:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81286-05 + for ; + Wed, 9 Mar 2005 02:15:37 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id A5587563F6 + for ; + Wed, 9 Mar 2005 02:15:35 +0000 (GMT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j292FYNs011649 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Tue, 8 Mar 2005 19:15:36 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j292FYdu014052; + Tue, 8 Mar 2005 19:15:34 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j292FXLP014051; + Tue, 8 Mar 2005 19:15:33 -0700 (MST) (envelope-from mfuhr) +Date: Tue, 8 Mar 2005 19:15:33 -0700 +From: Michael Fuhr +To: Gaetano Mendola +Cc: "pgsql-performance@postgresql.org" +Subject: Re: vacuum full, why multiple times ? +Message-ID: <20050309021533.GB13883@winnie.fuhr.org> +References: <422E4B15.60806@bigfoot.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <422E4B15.60806@bigfoot.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/151 +X-Sequence-Number: 10856 + +On Wed, Mar 09, 2005 at 02:02:13AM +0100, Gaetano Mendola wrote: + +> Basically I'm noticing that a simple vacuum full is not enough to +> shrink completelly the table: +> +> # vacuum full verbose url; +> INFO: vacuuming "public.url" +> INFO: "url": found 268392 removable, 21286 nonremovable row versions in 8563 pages +> DETAIL: 22 dead row versions cannot be removed yet. + +How busy is the database? I'd guess that each time you run VACUUM, +there are still open transactions that have visibility to the dead +rows, so VACUUM doesn't touch them. Those transactions eventually +complete, and eventually VACUUM FULL does what you're expecting. +I don't know if that's the only possible cause, but I get results +similar to yours if I have transactions open when I run VACUUM. + +-- +Michael Fuhr +http://www.fuhr.org/~mfuhr/ + +From pgsql-performance-owner@postgresql.org Wed Mar 9 03:07:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 57B5B5640D + for ; + Wed, 9 Mar 2005 03:07:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98841-07 + for ; + Wed, 9 Mar 2005 03:07:44 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 990D556386 + for ; + Wed, 9 Mar 2005 03:07:43 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 70so39033wra + for ; + Tue, 08 Mar 2005 19:07:48 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; + b=uLnU2TTCfWe9Z9PVk7ymJBSwZgqv06I/qqgidTSw2niF5xjdB7/54xeA9Mj3/naww18qCkZu1klH4cA3fDq2YeQemmaK5QIGPNWryWs/D7m23EAN5l1VuUKj02MEY56XFBvm45FYZduwwLYyeDYNrgl1q2kwkHfqBL66/RqTwoY= +Received: by 10.54.71.17 with SMTP id t17mr346121wra; + Tue, 08 Mar 2005 19:07:48 -0800 (PST) +Received: by 10.54.40.28 with HTTP; Tue, 8 Mar 2005 19:07:48 -0800 (PST) +Message-ID: +Date: Tue, 8 Mar 2005 19:07:48 -0800 +From: David B +Reply-To: David B +To: pgsql-performance@postgresql.org +Subject: 64bit Opteron multi drive raid. Help with best config settings +Mime-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.914 tagged_above=0 required=5 + tests=DNS_FROM_RFC_ABUSE, FROM_ENDS_IN_NUMS, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/152 +X-Sequence-Number: 10857 + +Hi folks, + +I'm about to start testing PGv8 on an Opteron 64bit box with 12GB Ram +running RedHat. +A bunch of raided drives in the backend. + +Expecting 50GB of data per month (100GB+ initial load). + +I do not see any example config settings. Have some MySql experience +and and for it there are config settings for small or large server +operations. + +Does PG have similar examples (if so they are well hidden=E2=80=A6at least +from Google search). + +If not can any of you send me a typical config for such an environment. +I basically want to get a good setting so I can good insert +performance=E2=80=A6low vol selects. + +DB data consists of customer info and their call history. +Lots of customers=E2=80=A6lots of call history. Not that wide of rows. + +Want to be able to insert at rate of 1000's per sec. Should think thats pos= +s. + +Any help you folks can provide to optimize this in a shootout between +it and MSql (we hope to be move from Oracle) + +Tx, +David + +From pgsql-performance-owner@postgresql.org Wed Mar 9 03:49:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 374195648F + for ; + Wed, 9 Mar 2005 03:49:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12941-03 + for ; + Wed, 9 Mar 2005 03:49:13 +0000 (GMT) +Received: from mailgate2.nau.edu (mailgate2.nau.edu [134.114.96.59]) + by svr1.postgresql.org (Postfix) with ESMTP id BB31A56483 + for ; + Wed, 9 Mar 2005 03:49:12 +0000 (GMT) +Received: from CONVERSION-DAEMON.mailgate2.nau.edu by mailgate2.nau.edu + (PMDF V6.2-X17 #30770) id <0ID200L01FY40C@mailgate2.nau.edu> for + pgsql-performance@postgresql.org; Tue, 08 Mar 2005 20:49:16 -0700 (MST) +Received: from k2.cet.nau.edu (net9-213.cet.nau.edu [134.114.9.213]) + by mailgate2.nau.edu (PMDF V6.2-X17 #30770) + with ESMTP id <0ID2009B1FY3CG@mailgate2.nau.edu>; Tue, + 08 Mar 2005 20:49:15 -0700 (MST) +Date: Tue, 08 Mar 2005 20:53:06 -0700 +From: Karim Nassar +Subject: Re: 64bit Opteron multi drive raid. Help with best config +In-reply-to: +To: David B +Cc: pgsql-performance@postgresql.org +Message-id: <1110340386.6368.74.camel@k2.cet.nau.edu> +MIME-version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="=-FgnPHES8pzz788m9zUyH" +References: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/153 +X-Sequence-Number: 10858 + + +--=-FgnPHES8pzz788m9zUyH +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Tue, 2005-03-08 at 19:07 -0800, David B wrote: +> I do not see any example config settings. Have some MySql experience +> and and for it there are config settings for small or large server +> operations. + +For starters, this might be helpful: + +http://www.powerpostgresql.com/PerfList + +Then this: +http://www.powerpostgresql.com/Downloads/annotated_conf_80.html +http://www.powerpostgresql.com/Downloads/annotated_conf_80.pdf + +Someone else might have an example config for you. + +HTH, + +--=20 +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=3D- Mobile: (928) 699-9221 + +--=-FgnPHES8pzz788m9zUyH +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (GNU/Linux) + +iD8DBQBCLnMiXcetVcVKInsRAtaEAKDs7XZGgilYtW/rokdFTtSU5KQgNwCgkF1c +WredDLiZHKsR7cenIULxtOI= +=2RK1 +-----END PGP SIGNATURE----- + +--=-FgnPHES8pzz788m9zUyH-- + + +From pgsql-performance-owner@postgresql.org Wed Mar 9 04:28:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A79B156002 + for ; + Wed, 9 Mar 2005 04:28:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25328-05 + for ; + Wed, 9 Mar 2005 04:27:48 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 24A6A563F2 + for ; + Wed, 9 Mar 2005 04:27:47 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j294Rit9016216; + Tue, 8 Mar 2005 23:27:44 -0500 (EST) +To: josh@agliodbs.com +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Why would writes to pgsql_tmp bottleneck at 1mb/s? +In-reply-to: <200503081644.32497.josh@agliodbs.com> +References: <200503081218.24093.josh@agliodbs.com> + <200503081617.57190.josh@agliodbs.com> + <200503081644.32497.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Tue, 08 Mar 2005 16:44:32 -0800" +Date: Tue, 08 Mar 2005 23:27:44 -0500 +Message-ID: <16215.1110342464@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/155 +X-Sequence-Number: 10860 + +Josh Berkus writes: +> Maybe I'm not an idiot (really!) even with almost 2GB of maintenance_mem, PG +> still writes to pgsql_tmp no faster than 2MB/s. I think there may be an +> artificial bottleneck there. Question is, PostgreSQL, OS or hardware? + +AFAIR that's just fwrite() ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 9 04:33:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C8ED5648E + for ; + Wed, 9 Mar 2005 04:33:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26597-09 + for ; + Wed, 9 Mar 2005 04:33:20 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 059BF56483 + for ; + Wed, 9 Mar 2005 04:33:19 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7107550; Tue, 08 Mar 2005 20:35:08 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Tom Lane +Subject: Re: Why would writes to pgsql_tmp bottleneck at 1mb/s? +Date: Tue, 8 Mar 2005 20:37:44 -0800 +User-Agent: KMail/1.7.1 +Cc: "pgsql-performance@postgresql.org" +References: <200503081218.24093.josh@agliodbs.com> + <200503081644.32497.josh@agliodbs.com> + <16215.1110342464@sss.pgh.pa.us> +In-Reply-To: <16215.1110342464@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200503082037.44639.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/156 +X-Sequence-Number: 10861 + +Tom, + +> > Maybe I'm not an idiot (really!) even with almost 2GB of +> > maintenance_mem, PG still writes to pgsql_tmp no faster than 2MB/s. I +> > think there may be an artificial bottleneck there. Question is, +> > PostgreSQL, OS or hardware? +> +> AFAIR that's just fwrite() ... + +Well, are there any hacks to speed it up? It's about doubling the amount of +time it takes to create an index on a very large table. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Mar 9 04:38:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 11FED56454 + for ; + Wed, 9 Mar 2005 04:38:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28473-09 + for ; + Wed, 9 Mar 2005 04:38:02 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C624C5642A + for ; + Wed, 9 Mar 2005 04:38:01 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j294bxSY016321; + Tue, 8 Mar 2005 23:37:59 -0500 (EST) +To: josh@agliodbs.com +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Why would writes to pgsql_tmp bottleneck at 1mb/s? +In-reply-to: <200503082037.44639.josh@agliodbs.com> +References: <200503081218.24093.josh@agliodbs.com> + <200503081644.32497.josh@agliodbs.com> + <16215.1110342464@sss.pgh.pa.us> + <200503082037.44639.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Tue, 08 Mar 2005 20:37:44 -0800" +Date: Tue, 08 Mar 2005 23:37:58 -0500 +Message-ID: <16320.1110343078@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/157 +X-Sequence-Number: 10862 + +Josh Berkus writes: +>> AFAIR that's just fwrite() ... + +> Well, are there any hacks to speed it up? It's about doubling the amount of +> time it takes to create an index on a very large table. + +Huh? Doubled compared to what? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 9 04:22:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CDC92563F6 + for ; + Wed, 9 Mar 2005 04:22:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23599-07 + for ; + Wed, 9 Mar 2005 04:22:32 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 86D5656375 + for ; + Wed, 9 Mar 2005 04:22:30 +0000 (GMT) +Received: (qmail 2678 invoked by uid 500); 9 Mar 2005 04:38:21 -0000 +Date: Tue, 8 Mar 2005 22:38:21 -0600 +From: Bruno Wolff III +To: Rick Schumeyer +Cc: pgsql-performance@postgresql.org +Subject: Re: index scan on =, but not < ? +Message-ID: <20050309043821.GA1569@wolff.to> +Mail-Followup-To: Rick Schumeyer , + pgsql-performance@postgresql.org +References: <001f01c5240d$a920c8c0$0200a8c0@dell8200> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <001f01c5240d$a920c8c0$0200a8c0@dell8200> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/154 +X-Sequence-Number: 10859 + +On Tue, Mar 08, 2005 at 13:35:53 -0500, + Rick Schumeyer wrote: +> I have two index questions. The first is about an issue that has been +> recently discussed, +> +> and I just wanted to be sure of my understanding. Functions like count(), +> max(), etc. will +> +> use sequential scans instead of index scans because the index doesn't know +> which rows +> +> are actually visible.is this correct? + +Not exactly. If the number of rows to be examined is on the order of 5% +of the table, an index scan will probably be slower than a sequential +scan. The visibility issue makes index scans slower in the case that +the only columns of interest are in the index. +Another issue is that max could in theory use an index, but there isn't +a mechanism for Postgres to know how to do this in general for aggregates +where it is possible. There have been discussions in the past about +how this could be done, but no one has done it yet. + +From pgsql-performance-owner@postgresql.org Wed Mar 9 04:55:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B4C5156471 + for ; + Wed, 9 Mar 2005 04:55:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35415-04 + for ; + Wed, 9 Mar 2005 04:55:23 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E2195644B + for ; + Wed, 9 Mar 2005 04:55:22 +0000 (GMT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id F3A331C8B3; Wed, 9 Mar 2005 04:55:19 +0000 (GMT) +Date: Tue, 8 Mar 2005 22:55:19 -0600 +From: "Jim C. Nasby" +To: Rick Schumeyer , + pgsql-performance@postgresql.org +Subject: Re: index scan on =, but not < ? +Message-ID: <20050309045519.GA509@decibel.org> +References: <001f01c5240d$a920c8c0$0200a8c0@dell8200> + <20050309043821.GA1569@wolff.to> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050309043821.GA1569@wolff.to> +X-Operating-System: FreeBSD 4.11-RELEASE i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.053 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/158 +X-Sequence-Number: 10863 + +On Tue, Mar 08, 2005 at 10:38:21PM -0600, Bruno Wolff III wrote: +> Not exactly. If the number of rows to be examined is on the order of 5% +> of the table, an index scan will probably be slower than a sequential +> scan. The visibility issue makes index scans slower in the case that + +Shouldn't that be 50%? +-- +Jim C. Nasby, Database Consultant decibel@decibel.org +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 Mar 9 05:04:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F225D563F2 + for ; + Wed, 9 Mar 2005 05:04:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37721-08 + for ; + Wed, 9 Mar 2005 05:04:30 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id C95725551D + for ; + Wed, 9 Mar 2005 05:04:29 +0000 (GMT) +Received: (qmail 3826 invoked by uid 500); 9 Mar 2005 05:20:20 -0000 +Date: Tue, 8 Mar 2005 23:20:20 -0600 +From: Bruno Wolff III +To: "Jim C. Nasby" +Cc: Rick Schumeyer , + pgsql-performance@postgresql.org +Subject: Re: index scan on =, but not < ? +Message-ID: <20050309052020.GB1569@wolff.to> +Mail-Followup-To: "Jim C. Nasby" , + Rick Schumeyer , + pgsql-performance@postgresql.org +References: <001f01c5240d$a920c8c0$0200a8c0@dell8200> + <20050309043821.GA1569@wolff.to> <20050309045519.GA509@decibel.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050309045519.GA509@decibel.org> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/159 +X-Sequence-Number: 10864 + +On Tue, Mar 08, 2005 at 22:55:19 -0600, + "Jim C. Nasby" wrote: +> On Tue, Mar 08, 2005 at 10:38:21PM -0600, Bruno Wolff III wrote: +> > Not exactly. If the number of rows to be examined is on the order of 5% +> > of the table, an index scan will probably be slower than a sequential +> > scan. The visibility issue makes index scans slower in the case that +> +> Shouldn't that be 50%? + +No. When you are doing an index scan of a significant part of the table, +you will fetch some heap pages more than once. You will also be fetching +blocks out of order, so you will lose out on read ahead optimization +by the OS. This assumes that you don't get a lot of cache hits on the +help pages. If a significant portion of the table is cached, then the +trade off point will be at a higher percentage of the table. + +From pgsql-performance-owner@postgresql.org Wed Mar 9 06:56:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9491A5644F + for ; + Wed, 9 Mar 2005 06:56:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74205-09 + for ; + Wed, 9 Mar 2005 06:56:22 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 94451563D8 + for ; + Wed, 9 Mar 2005 06:56:21 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7108016; Tue, 08 Mar 2005 22:58:11 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Tom Lane +Subject: Re: Why would writes to pgsql_tmp bottleneck at 1mb/s? +Date: Tue, 8 Mar 2005 23:00:46 -0800 +User-Agent: KMail/1.7.1 +Cc: "pgsql-performance@postgresql.org" +References: <200503081218.24093.josh@agliodbs.com> + <200503082037.44639.josh@agliodbs.com> + <16320.1110343078@sss.pgh.pa.us> +In-Reply-To: <16320.1110343078@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200503082300.47085.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/160 +X-Sequence-Number: 10865 + +Tom, + +> Huh? Doubled compared to what? + +Compared to how much data writing I can do to the database when pgsql_tmp +isn't engaged. + +In other words, when pgsql_tmp isn't being written, database writing is 9mb/s. +When pgsql_tmp gets engaged, that drops to 4mb/s. + +Alternatively, the WAL drive, which is the same hardware, will write at +10mb/s. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Mar 9 11:21:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 67C84563A7 + for ; + Wed, 9 Mar 2005 11:21:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75047-06 + for ; + Wed, 9 Mar 2005 11:21:15 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 46D4156378 + for ; + Wed, 9 Mar 2005 11:21:13 +0000 (GMT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j29CODA24789; + Wed, 9 Mar 2005 13:24:14 +0100 +Received: from [127.0.0.1] (accesspoint.mm.eutelsat.org [194.214.173.4]) + by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j29BLBR11739; + Wed, 9 Mar 2005 12:21:11 +0100 +Message-ID: <422EDC19.4080105@bigfoot.com> +Date: Wed, 09 Mar 2005 12:20:57 +0100 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: John A Meinel +Cc: Gaetano Mendola , + =?UTF-8?B?TWFya3VzIEJlcnRoZWF1?= =?UTF-8?B?IOKYrQ==?= + , pgsql-performance@postgresql.org +Subject: Re: pl/pgsql faster than raw SQL? +References: <1110284432.4905.18.camel@dicaprio.akademie1.de> + <422E4948.3090208@bigfoot.com> <422E511B.40102@arbash-meinel.com> +In-Reply-To: <422E511B.40102@arbash-meinel.com> +X-Enigmail-Version: 0.90.1.1 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.176 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/161 +X-Sequence-Number: 10866 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +John A Meinel wrote: + > That sounds more like you had bad statistics on the field1 column, which +> caused postgres to switch from a seqscan to an index scan, only there +> were so many rows with field1='New' that it actually would have been +> faster with a seqscan. + +The field1 was a calculated field and with the filter "='New'" +postgres was executing that function on more rows than without filter. + + + +Regards +Gaetano Mendola + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCLtwZ7UpzwH2SGd4RAhU5AJwMeFWwIO/UfdU0QTDo+FTCxPhqYACfYNVl +1yBUEObhZhUDnNDXdsJ/bi0= +=xc8U +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Wed Mar 9 11:27:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 54A1C5636F + for ; + Wed, 9 Mar 2005 11:27:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76378-10 + for ; + Wed, 9 Mar 2005 11:27:43 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F1355636A + for ; + Wed, 9 Mar 2005 11:27:41 +0000 (GMT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j29CUjw24827; + Wed, 9 Mar 2005 13:30:45 +0100 +Received: from [127.0.0.1] (accesspoint.mm.eutelsat.org [194.214.173.4]) + by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j29BRhR11771; + Wed, 9 Mar 2005 12:27:43 +0100 +Message-ID: <422EDDA2.5000901@bigfoot.com> +Date: Wed, 09 Mar 2005 12:27:30 +0100 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Michael Fuhr , + "pgsql-performance@postgresql.org" +Subject: Re: vacuum full, why multiple times ? +References: <422E4B15.60806@bigfoot.com> + <20050309021533.GB13883@winnie.fuhr.org> +In-Reply-To: <20050309021533.GB13883@winnie.fuhr.org> +X-Enigmail-Version: 0.90.1.1 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.157 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/162 +X-Sequence-Number: 10867 + +Michael Fuhr wrote: +> On Wed, Mar 09, 2005 at 02:02:13AM +0100, Gaetano Mendola wrote: +> +> +>>Basically I'm noticing that a simple vacuum full is not enough to +>>shrink completelly the table: +>> +>># vacuum full verbose url; +>>INFO: vacuuming "public.url" +>>INFO: "url": found 268392 removable, 21286 nonremovable row versions in 8563 pages +>>DETAIL: 22 dead row versions cannot be removed yet. +> +> +> How busy is the database? I'd guess that each time you run VACUUM, +> there are still open transactions that have visibility to the dead +> rows, so VACUUM doesn't touch them. Those transactions eventually +> complete, and eventually VACUUM FULL does what you're expecting. +> I don't know if that's the only possible cause, but I get results +> similar to yours if I have transactions open when I run VACUUM. +> + +That was my first tough but it seem strange that 2 dead rows where +grabbing 7883 pages, don't you think ? + + +# vacuum full verbose url; +INFO: vacuuming "public.url" +INFO: "url": found 74 removable, 21266 nonremovable row versions in 8550 pages +DETAIL: 2 dead row versions cannot be removed yet. +[SNIP] +INFO: "url": moved 11 row versions, truncated 8550 to 8504 pages + + +and in the next run: + + +# vacuum full verbose url; +INFO: vacuuming "public.url" +INFO: "url": found 13 removable, 21264 nonremovable row versions in 8504 pages +DETAIL: 0 dead row versions cannot be removed yet. +[SNIP] +INFO: "url": moved 5666 row versions, truncated 8504 to 621 pages + + + + +Regards +Gaetano Mendola + + + + + +From pgsql-performance-owner@postgresql.org Wed Mar 9 12:08:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1869356378 + for ; + Wed, 9 Mar 2005 12:08:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91062-01 + for ; + Wed, 9 Mar 2005 12:08:22 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.193]) + by svr1.postgresql.org (Postfix) with ESMTP id 68C975636F + for ; + Wed, 9 Mar 2005 12:08:21 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 70so155619wra + for ; + Wed, 09 Mar 2005 04:08:21 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=F2G7PekvnWxoA8AD2TRJMlyJlxcPoOlu41PbGYJwNQZCRIMKeS58uG5iRwcU+skiyQIQ7KCNl6NzIASy4Uz+GD4OiuqFp8xZPDDnKUoYoeZGqBEE4jb0olp4ms8Ukyn6Cdqw2vUowoJ72Fz5Uo3FUopQ4OSouVyEH0ryWuWKJ/Q= +Received: by 10.54.72.6 with SMTP id u6mr607226wra; + Wed, 09 Mar 2005 04:08:21 -0800 (PST) +Received: by 10.54.18.9 with HTTP; Wed, 9 Mar 2005 04:08:21 -0800 (PST) +Message-ID: <4e8efcf5050309040836b06cc5@mail.gmail.com> +Date: Wed, 9 Mar 2005 12:08:21 +0000 +From: Hugo Ferreira +Reply-To: Hugo Ferreira +To: pgsql-performance@postgresql.org +Subject: Re: Help trying to tune query that executes 40x slower than in + SqlServer +In-Reply-To: <3276.1110218527@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <20050304002724.650A95AF649@svr4.postgresql.org> + <4e8efcf50503040413245d80f9@mail.gmail.com> + <4e8efcf50503070901406808be@mail.gmail.com> + <200503070928.47118.josh@agliodbs.com> + <4e8efcf50503070945332778bb@mail.gmail.com> + <3276.1110218527@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.501 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/163 +X-Sequence-Number: 10868 + +Hi, + +Well, I think the problem is far more complex than just joins +reordering... I've restrucutred the query so that it won't use any +explicit joins.Instead it now has a series of 'in (select ...)' and +'not exists (select ...)'. This actually got faster... sometimes!!! + +select 1, 10000168, C.contxt_id, C.contxt_elmt_ix, null, null, null, +null, null, null, 1 +from CONTXT as P, CONTXT_ELMT as C, MRS_REPLICATION_OUT as S, +MRS_TRANSACTION as TRANS +where S.age=0 + and S.trans_id=1 + and S.trans_id = TRANS.trans_id + and S.ent_id = 10000029 + and (P.contxt_id=C.contxt_id) and (P.contxt_id = S.pk1) + and (C.owner_id not in (select non_repl_data_owner_id from +NON_REPL_DATA_OWNER)) + AND (C.owner_id not in (select repl_data_owner_id from REPL_DATA_OWNER_RSDNC + where rsdnc_node_id = TRANS.recv_node_id)) + AND (not exists (select pk1 from MRS_REPLICATION_OUT + where trans_id=1 + and ent_id=10000168 + and C.contxt_id = pk1 + AND C.contxt_elmt_ix = pk2)) + AND (not exists (select pk1 from MRS_TRANSACTION RED_TRANS, +MRS_REPLICATION_OUT RED_OUT + where RED_TRANS.cat_code = 'OUT' + and RED_TRANS.trans_type in ('X01', 'X02') + and RED_TRANS.trans_id=RED_OUT.trans_id + and RED_TRANS.prov_node_id=TRANS.prov_node_id + and RED_TRANS.recv_node_id=TRANS.recv_node_id + and RED_OUT.ent_id=10000168 + and C.contxt_id = pk1 + AND C.contxt_elmt_ix = pk2)) + + +For example... I run the query, it takes 122seconds. Then I delete the +target tables, vacuum the database, re-run it again: 9s. But if I run +vacuum several times, and then run, it takes again 122seconds. If I +stop this 122seconds query, say, at second 3 and then run it again, it +will only take 9s. It simply doesn't make sense. Also, explain analyse +will give me diferent plans each time I run it... Unfortunately, this +is rendering PostgreSQL unusable for our goals. Any ideas? + +By the way, I got the following indexes over MRS_REPLICATION_OUT which +seems to speed up things: + +CREATE INDEX ix_mrs_replication_out_all ON mrs_replication_out +USING btree (ent_id, age, trans_id); + +CREATE INDEX ix_mrs_replication_pks ON mrs_replication_out +USING btree (trans_id, ent_id, pk1, pk2, pk3, pk4, pk5, pk6, pk7); + +Note: pk2... pk7 are nullable columns. trans_id is the least variant +column. pk1 is the most variant column. Most of the times, the +execution plan includes an 'index scan' over the first index +(ix_mrs_replication_out_all), followed by a filter with columns from +the second index (trans_id, ent_id, pk1, pk2, pk3, pk4, pk5, pk6, +pk7), though the 'age' column is not used... Any guess why?? + +Thanks in advance, + +Hugo Ferreira + +> It is possible but complicated to determine that reordering outer joins +> is safe in some cases. We don't currently have such logic in PG. It +> may be that SQL Server does have that capability and that's why it's +> finding a much better plan ... but for now you have to do that by hand +> in PG. + +-- +GPG Fingerprint: B0D7 1249 447D F5BB 22C5 5B9B 078C 2615 504B 7B85 + +From pgsql-performance-owner@postgresql.org Wed Mar 9 12:30:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DB20E56458 + for ; + Wed, 9 Mar 2005 12:30:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95332-08 + for ; + Wed, 9 Mar 2005 12:30:02 +0000 (GMT) +Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net + [194.217.242.90]) + by svr1.postgresql.org (Postfix) with ESMTP id 1448B5645A + for ; + Wed, 9 Mar 2005 12:30:01 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 4.42) + id 1D90KB-000LBf-8r; Wed, 09 Mar 2005 12:30:04 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id ADDF1176A3; Wed, 9 Mar 2005 12:30:02 +0000 (GMT) +Message-ID: <422EEC49.7080202@archonet.com> +Date: Wed, 09 Mar 2005 12:30:01 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gaetano Mendola +Cc: Michael Fuhr , + "pgsql-performance@postgresql.org" +Subject: Re: vacuum full, why multiple times ? +References: <422E4B15.60806@bigfoot.com> + <20050309021533.GB13883@winnie.fuhr.org> + <422EDDA2.5000901@bigfoot.com> +In-Reply-To: <422EDDA2.5000901@bigfoot.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.063 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/164 +X-Sequence-Number: 10869 + +Gaetano Mendola wrote: +> +> # vacuum full verbose url; +> INFO: vacuuming "public.url" +> INFO: "url": found 74 removable, 21266 nonremovable row versions in 8550 pages +> DETAIL: 2 dead row versions cannot be removed yet. +> [SNIP] +> INFO: "url": moved 11 row versions, truncated 8550 to 8504 pages +> +> +> and in the next run: +> +> +> # vacuum full verbose url; +> INFO: vacuuming "public.url" +> INFO: "url": found 13 removable, 21264 nonremovable row versions in 8504 pages +> DETAIL: 0 dead row versions cannot be removed yet. +> [SNIP] +> INFO: "url": moved 5666 row versions, truncated 8504 to 621 pages + +If page number 8549 was the one being held, I don't think vacuum can +truncate the file. The empty space can be re-used, but the rows can't be +moved to a lower page while a transaction is using them. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Mar 9 14:30:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D932564E9 + for ; + Wed, 9 Mar 2005 14:30:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29003-09 + for ; + Wed, 9 Mar 2005 14:30:24 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 3653756517 + for ; + Wed, 9 Mar 2005 14:30:23 +0000 (GMT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j29FXR826081; + Wed, 9 Mar 2005 16:33:27 +0100 +Received: from [127.0.0.1] (accesspoint.mm.eutelsat.org [194.214.173.4]) + by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j29EUPR13167; + Wed, 9 Mar 2005 15:30:25 +0100 +Message-ID: <422F086F.9080605@bigfoot.com> +Date: Wed, 09 Mar 2005 15:30:07 +0100 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Richard Huxton +Cc: Michael Fuhr , + "pgsql-performance@postgresql.org" +Subject: Re: vacuum full, why multiple times ? +References: <422E4B15.60806@bigfoot.com> + <20050309021533.GB13883@winnie.fuhr.org> + <422EDDA2.5000901@bigfoot.com> <422EEC49.7080202@archonet.com> +In-Reply-To: <422EEC49.7080202@archonet.com> +X-Enigmail-Version: 0.90.1.1 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.141 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/165 +X-Sequence-Number: 10870 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Richard Huxton wrote: +> Gaetano Mendola wrote: +> +>> +>> # vacuum full verbose url; +>> INFO: vacuuming "public.url" +>> INFO: "url": found 74 removable, 21266 nonremovable row versions in +>> 8550 pages +>> DETAIL: 2 dead row versions cannot be removed yet. +>> [SNIP] +>> INFO: "url": moved 11 row versions, truncated 8550 to 8504 pages +>> +>> +>> and in the next run: +>> +>> +>> # vacuum full verbose url; +>> INFO: vacuuming "public.url" +>> INFO: "url": found 13 removable, 21264 nonremovable row versions in +>> 8504 pages +>> DETAIL: 0 dead row versions cannot be removed yet. +>> [SNIP] +>> INFO: "url": moved 5666 row versions, truncated 8504 to 621 pages +> +> +> If page number 8549 was the one being held, I don't think vacuum can +> truncate the file. The empty space can be re-used, but the rows can't be +> moved to a lower page while a transaction is using them. + +It's clear now. + + +Regards +Gaetano Mendola +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCLwhu7UpzwH2SGd4RAhEIAKDodnb03RvInDOJz9H+4w//DgJifACeNINP +0UMkQ0yBwNAZw91clvAUjRI= +=e+mM +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Wed Mar 9 15:17:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A74356535 + for ; + Wed, 9 Mar 2005 15:17:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44352-10 + for ; + Wed, 9 Mar 2005 15:17:01 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A74435638F + for ; + Wed, 9 Mar 2005 15:16:58 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j29FGr3v023847; + Wed, 9 Mar 2005 10:16:53 -0500 (EST) +To: Gaetano Mendola +Cc: Richard Huxton , Michael Fuhr , + "pgsql-performance@postgresql.org" +Subject: Re: vacuum full, why multiple times ? +In-reply-to: <422F086F.9080605@bigfoot.com> +References: <422E4B15.60806@bigfoot.com> + <20050309021533.GB13883@winnie.fuhr.org> + <422EDDA2.5000901@bigfoot.com> <422EEC49.7080202@archonet.com> + <422F086F.9080605@bigfoot.com> +Comments: In-reply-to Gaetano Mendola + message dated "Wed, 09 Mar 2005 15:30:07 +0100" +Date: Wed, 09 Mar 2005 10:16:52 -0500 +Message-ID: <23846.1110381412@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/166 +X-Sequence-Number: 10871 + +Gaetano Mendola writes: +> Richard Huxton wrote: +>> If page number 8549 was the one being held, I don't think vacuum can +>> truncate the file. The empty space can be re-used, but the rows can't be +>> moved to a lower page while a transaction is using them. + +> It's clear now. + +Not entirely. VACUUM FULL doesn't really worry about whether anyone +else "is using" the table --- it knows no one else is, because it holds +exclusive lock on the table. However it must preserve dead tuples that +would still be visible to any existing transaction, because that other +transaction could come along and look at the table after VACUUM +finishes and releases the lock. + +What really drives the process is that VACUUM FULL moves tuples in order +to make the file shorter (release empty pages at the end) --- and not +for any other reason. So it could stop when there is still plenty of +dead space in the table. It stops when the last nonempty page contains +a tuple that it can't find room for in any earlier page. + +What I suppose you saw was that page 8503 contained a tuple so large it +wouldn't fit in the free space on any earlier page. By the time of the +second vacuum, either this tuple was deleted, or deletion of some other +tuples had made a hole big enough for it to fit in. + +The extent of the truncation in the second vacuum says that you had +quite a lot of free space, so it's a bit surprising that there wasn't +enough room in any one page for such a tuple to be moved, but that seems +to be what happened. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 14 02:23:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BE81956374 + for ; + Wed, 9 Mar 2005 16:00:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59062-08 + for ; + Wed, 9 Mar 2005 16:00:25 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C2CC55A07 + for ; + Wed, 9 Mar 2005 16:00:24 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 5FAE431E23; Wed, 9 Mar 2005 17:00:23 +0100 (MET) +From: "Michael McFarland" +X-Newsgroups: pgsql.performance +Subject: Re: adding 'limit' leads to very slow query +Date: Wed, 09 Mar 2005 11:00:20 -0500 +Organization: Hub.Org Networking Services +Lines: 91 +Message-ID: +References: + <20050307230123.L97147@megazone.bigpanda.com> +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; delsp=yes; charset=us-ascii +Content-Transfer-Encoding: Quoted-Printable +X-Complaints-To: usenet@news.hub.org +User-Agent: Opera M2(BETA1)/8.00 (Linux, build 913) +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=2.174 tagged_above=0 required=5 tests=FORGED_YAHOO_RCVD +X-Spam-Level: ** +X-Archive-Number: 200503/238 +X-Sequence-Number: 10943 + + I continue to be stumped by this. You are right that I should have = + = + +listed the estimates provided by explain... basically for the select whe= +re = + +bar =3D 41, it's estimating there will be 40,000 rows instead of 7, out = +of = + +what's actuallly 5 million records in the table. + + So far I've tried increase statistics for the bar column from the = + +default 10 to 100 (vacuum analyzing after) and the explain-plan hasn't = + +changed. I also notice that afterward, the pg_stats record for the bar = + = + +column still only lists the top 5 values of bar (out of 68 unique values= + = + +in the table). Are there any other settings I could try to improve the = + = + +detail of the statistics? + + By the way, I think I do have a workaround for this particular query= +: + select * from (select * from foo where barId =3D 412 order by i= +d = + +desc) as tempview limit 25; +This query uses the bar index and completes instantly. However, I feel = + = + +like I should find the heart of the problem, since bad statistics could = + = + +end up affecting other plans, right? + + - Mike + + +On Mon, 7 Mar 2005 23:03:43 -0800 (PST), Stephan Szabo = + + wrote: + +> On Mon, 7 Mar 2005, Michael McFarland wrote: +> +>> I'm trying to understand why a particular query is slow, and it se= +ems +>> like the optimizer is choosing a strange plan. See this summary: +>> +>> +>> * I have a large table, with an index on the primary key 'id' and on = +a +>> field 'foo'. +>> > select count(*) from foo; +>> 1,000,000 +>> > select count(*) from foo where bar =3D 41; +>> 7 +>> +>> * This query happens very quickly. +>> > explain select * from foo where barId =3D 412 order by id desc; +>> Sort () +>> Sort key=3D id +>> -> Index scan using bar_index on foo () +>> Index cond: barId =3D 412 +>> +>> But this query takes forever +>> +>> > explain select * from foo where barId =3D 412 order by id desc limi= +t 25; +>> Limit () +>> -> Index scan backward using primarykey_index +>> Filter: barID =3D 412 +> +> You didn't show the row estimates, but I'd guess that it's expecting +> either that ther are more rows that match barId=3D412 than there actua= +lly +> are (which may be solvable by raising the statistics target on the col= +umn +> and re-analyzing) such that going backwards on id in order to make 25 +> matching rows isn't a bad plan or that barId and id are correlated whi= +ch +> is unfortunately not going to be recognized right now. +> + +-- = + +Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ + +From pgsql-performance-owner@postgresql.org Wed Mar 9 16:17:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C9FF56472 + for ; + Wed, 9 Mar 2005 16:17:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65759-01 + for ; + Wed, 9 Mar 2005 16:17:42 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BA2156469 + for ; + Wed, 9 Mar 2005 16:17:41 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id C54AA31E35; Wed, 9 Mar 2005 17:17:40 +0100 (MET) +From: Gaetano Mendola +X-Newsgroups: pgsql.performance +Subject: Re: vacuum full, why multiple times ? +Date: Wed, 09 Mar 2005 17:17:20 +0100 +Organization: Hub.Org Networking Services +Lines: 52 +Message-ID: <422F2190.2090903@bigfoot.com> +References: <422E4B15.60806@bigfoot.com> + <20050309021533.GB13883@winnie.fuhr.org> + <422EDDA2.5000901@bigfoot.com> <422EEC49.7080202@archonet.com> + <422F086F.9080605@bigfoot.com> <23846.1110381412@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +To: Tom Lane +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +In-Reply-To: <23846.1110381412@sss.pgh.pa.us> +X-Enigmail-Version: 0.90.1.1 +X-Enigmail-Supports: pgp-inline, pgp-mime +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/167 +X-Sequence-Number: 10872 + +Tom Lane wrote: +> Gaetano Mendola writes: +> +>>Richard Huxton wrote: +>> +>>>If page number 8549 was the one being held, I don't think vacuum can +>>>truncate the file. The empty space can be re-used, but the rows can't be +>>>moved to a lower page while a transaction is using them. +> +> +>>It's clear now. +> +> +> Not entirely. VACUUM FULL doesn't really worry about whether anyone +> else "is using" the table --- it knows no one else is, because it holds +> exclusive lock on the table. However it must preserve dead tuples that +> would still be visible to any existing transaction, because that other +> transaction could come along and look at the table after VACUUM +> finishes and releases the lock. +> +> What really drives the process is that VACUUM FULL moves tuples in order +> to make the file shorter (release empty pages at the end) --- and not +> for any other reason. So it could stop when there is still plenty of +> dead space in the table. It stops when the last nonempty page contains +> a tuple that it can't find room for in any earlier page. +> +> What I suppose you saw was that page 8503 contained a tuple so large it +> wouldn't fit in the free space on any earlier page. By the time of the +> second vacuum, either this tuple was deleted, or deletion of some other +> tuples had made a hole big enough for it to fit in. +> +> The extent of the truncation in the second vacuum says that you had +> quite a lot of free space, so it's a bit surprising that there wasn't +> enough room in any one page for such a tuple to be moved, but that seems +> to be what happened. + +All rows of that table are almost of the same size, so this is not the +reason, and neither any row was deleted. +May be the page 8503 was cointainig a dead row ? + +I can send you off line another vacuum full sequence if you need it, I sent it +to list but apparently the size was too much and noone of you seen it. + +Regards +Gaetano Mendola + + + + + + + + +From pgsql-performance-owner@postgresql.org Wed Mar 9 17:22:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CCDB956588 + for ; + Wed, 9 Mar 2005 17:22:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84364-09 + for ; + Wed, 9 Mar 2005 17:22:39 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C448564CE + for ; + Wed, 9 Mar 2005 17:22:38 +0000 (GMT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 8EADD1C8F3; Wed, 9 Mar 2005 11:22:38 -0600 (CST) +Date: Wed, 9 Mar 2005 11:22:38 -0600 +From: "Jim C. Nasby" +To: Rick Schumeyer , + pgsql-performance@postgresql.org +Subject: Re: index scan on =, but not < ? +Message-ID: <20050309172238.GD528@decibel.org> +References: <001f01c5240d$a920c8c0$0200a8c0@dell8200> + <20050309043821.GA1569@wolff.to> <20050309045519.GA509@decibel.org> + <20050309052020.GB1569@wolff.to> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050309052020.GB1569@wolff.to> +X-Operating-System: FreeBSD 4.11-RELEASE i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.043 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/168 +X-Sequence-Number: 10873 + +On Tue, Mar 08, 2005 at 11:20:20PM -0600, Bruno Wolff III wrote: +> On Tue, Mar 08, 2005 at 22:55:19 -0600, +> "Jim C. Nasby" wrote: +> > On Tue, Mar 08, 2005 at 10:38:21PM -0600, Bruno Wolff III wrote: +> > > Not exactly. If the number of rows to be examined is on the order of 5% +> > > of the table, an index scan will probably be slower than a sequential +> > > scan. The visibility issue makes index scans slower in the case that +> > +> > Shouldn't that be 50%? +> +> No. When you are doing an index scan of a significant part of the table, +> you will fetch some heap pages more than once. You will also be fetching +> blocks out of order, so you will lose out on read ahead optimization +> by the OS. This assumes that you don't get a lot of cache hits on the +> help pages. If a significant portion of the table is cached, then the +> trade off point will be at a higher percentage of the table. + +Ahh, I was thinking of a high correlation factor on the index. I still +question 5% though... that seems awefully low. +-- +Jim C. Nasby, Database Consultant decibel@decibel.org +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 Mar 9 17:25:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A2A0056503 + for ; + Wed, 9 Mar 2005 17:25:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86130-04 + for ; + Wed, 9 Mar 2005 17:25:20 +0000 (GMT) +Received: from omr4.netsolmail.com (omr4.netsolmail.com [216.168.230.140]) + by svr1.postgresql.org (Postfix) with ESMTP id 35F06564AB + for ; + Wed, 9 Mar 2005 17:25:15 +0000 (GMT) +Received: from ms9.netsolmail.com (IDENT:mirapoint@[216.168.230.183]) + by omr4.netsolmail.com (8.12.10/8.12.10) with ESMTP id j29HPDqp004997 + for ; + Wed, 9 Mar 2005 12:25:15 -0500 (EST) +Received: from 192.168.2.2 ([200.12.239.103]) + by ms9.netsolmail.com (Mirapoint Messaging Server MOS 3.2.2-GA) + with ESMTP id CSV39072; Wed, 9 Mar 2005 12:25:10 -0500 (EST) +Subject: How to speed up tsearch2 indexing +From: Werner Bohl +Reply-To: WernerBohl@infutor.com +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Organization: IDS de Costa Rica S.A. +Date: Wed, 09 Mar 2005 11:25:47 -0600 +Message-Id: <1110389147.21620.6.camel@sirio> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/169 +X-Sequence-Number: 10874 + +All, + +I have a table with ~ 3 million records. I'm indexing a field holding +names, no more than 200 bytes each. Indexing the resulting tsvector +takes forever. It's been running now for more than 40 hours on a Linux +with PG 8.01, a single Xeon & 4GB RAM. My work_mem postgresql.conf +parameter is at 240960 and maintenance_work_mem at 96384, although the +index task is using at most 12MB. Task is 99% cpu bound. Is there any +way I may speed up the indexing? + + +TIA, + + +-- +Werner Bohl +IDS de Costa Rica S.A. + + +From pgsql-performance-owner@postgresql.org Wed Mar 9 17:41:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E61856584 + for ; + Wed, 9 Mar 2005 17:41:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90911-05 + for ; + Wed, 9 Mar 2005 17:41:18 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9038856454 + for ; + Wed, 9 Mar 2005 17:41:10 +0000 (GMT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id j29Hf15Q013277; + Wed, 9 Mar 2005 20:41:01 +0300 (MSK) +Date: Wed, 9 Mar 2005 20:41:01 +0300 (MSK) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Werner Bohl +Cc: pgsql-performance@postgresql.org +Subject: Re: How to speed up tsearch2 indexing +In-Reply-To: <1110389147.21620.6.camel@sirio> +Message-ID: +References: <1110389147.21620.6.camel@sirio> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.35 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/170 +X-Sequence-Number: 10875 + +On Wed, 9 Mar 2005, Werner Bohl wrote: + +> All, +> +> I have a table with ~ 3 million records. I'm indexing a field holding +> names, no more than 200 bytes each. Indexing the resulting tsvector +> takes forever. It's been running now for more than 40 hours on a Linux +> with PG 8.01, a single Xeon & 4GB RAM. My work_mem postgresql.conf +> parameter is at 240960 and maintenance_work_mem at 96384, although the +> index task is using at most 12MB. Task is 99% cpu bound. Is there any +> way I may speed up the indexing? + +What's your tsearch2 configuration ? Do you use dictionaries ? +I wrote a brief explanation of tsearch2 internals +http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_internals + +Hope, it could help you. + +> +> +> TIA, +> +> +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Wed Mar 9 20:20:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DD7A756566 + for ; + Wed, 9 Mar 2005 20:20:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36975-01 + for ; + Wed, 9 Mar 2005 20:20:33 +0000 (GMT) +Received: from omr5.netsolmail.com (omr5.netsolmail.com [216.168.230.142]) + by svr1.postgresql.org (Postfix) with ESMTP id 63327564C4 + for ; + Wed, 9 Mar 2005 20:20:32 +0000 (GMT) +Received: from ms9.netsolmail.com (IDENT:mirapoint@[216.168.230.183]) + by omr5.netsolmail.com (8.12.10/8.12.10) with ESMTP id j29KKXqp000553; + Wed, 9 Mar 2005 15:20:33 -0500 (EST) +Received: from 192.168.2.2 ([200.12.239.103]) + by ms9.netsolmail.com (Mirapoint Messaging Server MOS 3.2.2-GA) + with ESMTP id CSW10451; Wed, 9 Mar 2005 15:20:28 -0500 (EST) +Subject: Re: How to speed up tsearch2 indexing +From: Werner Bohl +Reply-To: WernerBohl@infutor.com +To: Oleg Bartunov +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: <1110389147.21620.6.camel@sirio> + +Content-Type: text/plain +Organization: IDS de Costa Rica S.A. +Date: Wed, 09 Mar 2005 14:21:06 -0600 +Message-Id: <1110399666.3528.1.camel@sirio> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/171 +X-Sequence-Number: 10876 + +On Wed, 2005-03-09 at 20:41 +0300, Oleg Bartunov wrote: + +> What's your tsearch2 configuration ? Do you use dictionaries ? +> I wrote a brief explanation of tsearch2 internals +> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_internals +> +Tsearch2 is using default english configuration. No dictionaries, just +put some more stop words (10) in english.stop. + +> Hope, it could help you. +> +> > +> > +> > TIA, +> > +> > +> > +> +> Regards, +> Oleg +> _____________________________________________________________ +> Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +> Sternberg Astronomical Institute, Moscow University (Russia) +> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +> phone: +007(095)939-16-83, +007(095)939-23-83 +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: Have you searched our list archives? +> +> http://archives.postgresql.org + + +From pgsql-performance-owner@postgresql.org Wed Mar 9 20:27:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 848745644B + for ; + Wed, 9 Mar 2005 20:27:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39511-01 + for ; + Wed, 9 Mar 2005 20:27:48 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B3954559C2 + for ; + Wed, 9 Mar 2005 20:27:40 +0000 (GMT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id j29KRX5Q017055; + Wed, 9 Mar 2005 23:27:33 +0300 (MSK) +Date: Wed, 9 Mar 2005 23:27:33 +0300 (MSK) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Werner Bohl +Cc: pgsql-performance@postgresql.org +Subject: Re: How to speed up tsearch2 indexing +In-Reply-To: <1110399666.3528.1.camel@sirio> +Message-ID: +References: <1110389147.21620.6.camel@sirio> + + <1110399666.3528.1.camel@sirio> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.35 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/172 +X-Sequence-Number: 10877 + +On Wed, 9 Mar 2005, Werner Bohl wrote: + +> On Wed, 2005-03-09 at 20:41 +0300, Oleg Bartunov wrote: +> +>> What's your tsearch2 configuration ? Do you use dictionaries ? +>> I wrote a brief explanation of tsearch2 internals +>> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_internals +>> +> Tsearch2 is using default english configuration. No dictionaries, just +> put some more stop words (10) in english.stop. + +it's not good, because you, probably, have a lot of unique words. +Do you have some statistics, see stat() function ? + + +> +>> Hope, it could help you. +>> +>>> +>>> +>>> TIA, +>>> +>>> +>>> +>> +>> Regards, +>> Oleg +>> _____________________________________________________________ +>> Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +>> Sternberg Astronomical Institute, Moscow University (Russia) +>> Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +>> phone: +007(095)939-16-83, +007(095)939-23-83 +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 6: Have you searched our list archives? +>> +>> http://archives.postgresql.org +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Wed Mar 9 22:08:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A122455431 + for ; + Wed, 9 Mar 2005 22:08:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65927-07 + for ; + Wed, 9 Mar 2005 22:08:41 +0000 (GMT) +Received: from pws.com.au (mail.pws.com.au [210.23.138.139]) + by svr1.postgresql.org (Postfix) with SMTP id 132B854D6F + for ; + Wed, 9 Mar 2005 22:08:38 +0000 (GMT) +Received: (qmail 27111 invoked from network); 9 Mar 2005 22:08:33 -0000 +Received: from unknown (HELO wizzard.pws.com.au) + (russell@pws.com.au@138.217.54.70) + by mail.pws.com.au with SMTP; 9 Mar 2005 22:08:33 -0000 +From: Russell Smith +To: Hugo Ferreira +Subject: Re: Help trying to tune query that executes 40x slower than in + SqlServer +Date: Thu, 10 Mar 2005 09:08:32 +1100 +User-Agent: KMail/1.7 +Cc: pgsql-performance@postgresql.org +References: <20050304002724.650A95AF649@svr4.postgresql.org> + <3276.1110218527@sss.pgh.pa.us> + <4e8efcf5050309040836b06cc5@mail.gmail.com> +In-Reply-To: <4e8efcf5050309040836b06cc5@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200503100908.32467.mr-russ@pws.com.au> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/173 +X-Sequence-Number: 10878 + +On Wed, 9 Mar 2005 11:08 pm, Hugo Ferreira wrote: +> For example... I run the query, it takes 122seconds. Then I delete the +> target tables, vacuum the database, re-run it again: 9s. But if I run +> vacuum several times, and then run, it takes again 122seconds. If I +> stop this 122seconds query, say, at second 3 and then run it again, it +> will only take 9s. It simply doesn't make sense. Also, explain analyse +> will give me diferent plans each time I run it... Unfortunately, this +> is rendering PostgreSQL unusable for our goals. Any ideas? +> +The explain analyze is still be best information if you want assistance with +what postgresql is doing, and how to stop it. If you could attach +explain analyzes for both the fast (9s), and slow (122s) runs, that would +help people get an idea of how the query is running. At the moment +we don't know how postgresql is actually executing the query. + +Regards + +Russell Smith. + +From pgsql-performance-owner@postgresql.org Thu Mar 10 00:06:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 08C3355E26 + for ; + Thu, 10 Mar 2005 00:06:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97090-03 + for ; + Thu, 10 Mar 2005 00:06:22 +0000 (GMT) +Received: from gizmo11bw.bigpond.com (gizmo11bw.bigpond.com [144.140.70.21]) + by svr1.postgresql.org (Postfix) with SMTP id 7598D555BA + for ; + Thu, 10 Mar 2005 00:06:19 +0000 (GMT) +Received: (qmail 2601 invoked from network); 10 Mar 2005 00:06:19 -0000 +Received: from unknown (HELO bwmam05.bigpond.com) (144.135.24.81) + by gizmo11bw.bigpond.com with SMTP; 10 Mar 2005 00:06:19 -0000 +Received: from cpe-203-45-203-73.qld.bigpond.net.au ([203.45.203.73]) by + bwmam05.bigpond.com(MAM REL_3_4_2a 44/6526778) with SMTP id + 6526778; Thu, 10 Mar 2005 10:06:19 +1000 +Message-ID: <422F8F7F.2040505@bigpond.net.au> +Date: Thu, 10 Mar 2005 10:06:23 +1000 +From: David Brown +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bruno Wolff III +Cc: pgsql-performance@postgresql.org +Subject: Re: index scan on =, but not < ? +References: <001f01c5240d$a920c8c0$0200a8c0@dell8200> + <20050309043821.GA1569@wolff.to> <20050309045519.GA509@decibel.org> + <20050309052020.GB1569@wolff.to> +In-Reply-To: <20050309052020.GB1569@wolff.to> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.764 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_WHOIS +X-Spam-Level: +X-Archive-Number: 200503/174 +X-Sequence-Number: 10879 + +Assuming your system isn't starved for memory, shouldn't repeated page +fetches be hitting the cache? + +I've also wondered about the conventional wisdom that read ahead doesn't +help random reads. I may well be missing something, but *if* the OS has +enough memory to cache most of the table, surely read ahead will still +work to your advantage? + +Bruno Wolff III wrote: + +>No. When you are doing an index scan of a significant part of the table, +>you will fetch some heap pages more than once. You will also be fetching +>blocks out of order, so you will lose out on read ahead optimization +>by the OS. This assumes that you don't get a lot of cache hits on the +>help pages. If a significant portion of the table is cached, then the +>trade off point will be at a higher percentage of the table. +> +> + +From pgsql-performance-owner@postgresql.org Thu Mar 10 00:24:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F1BA555BA + for ; + Thu, 10 Mar 2005 00:24:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99965-06 + for ; + Thu, 10 Mar 2005 00:24:44 +0000 (GMT) +Received: from gizmo07bw.bigpond.com (gizmo07bw.bigpond.com [144.140.70.42]) + by svr1.postgresql.org (Postfix) with SMTP id 97EC556448 + for ; + Thu, 10 Mar 2005 00:24:41 +0000 (GMT) +Received: (qmail 26809 invoked from network); 10 Mar 2005 00:24:41 -0000 +Received: from unknown (HELO bwmam05.bigpond.com) (144.135.24.81) + by gizmo07bw.bigpond.com with SMTP; 10 Mar 2005 00:24:41 -0000 +Received: from cpe-203-45-203-73.qld.bigpond.net.au ([203.45.203.73]) by + bwmam05.bigpond.com(MAM REL_3_4_2a 44/6531782) with SMTP id + 6531782; Thu, 10 Mar 2005 10:24:41 +1000 +Message-ID: <422F93CE.10400@bigpond.net.au> +Date: Thu, 10 Mar 2005 10:24:46 +1000 +From: David Brown +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Jim C. Nasby" +Cc: pgsql-performance@postgresql.org, Tom Lane +Subject: Re: index scan on =, but not < ? +References: <001f01c5240d$a920c8c0$0200a8c0@dell8200> + <20050309043821.GA1569@wolff.to> <20050309045519.GA509@decibel.org> + <20050309052020.GB1569@wolff.to> <20050309172238.GD528@decibel.org> +In-Reply-To: <20050309172238.GD528@decibel.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.752 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_WHOIS +X-Spam-Level: +X-Archive-Number: 200503/175 +X-Sequence-Number: 10880 + +Jim C. Nasby wrote: + +>Ahh, I was thinking of a high correlation factor on the index. I still +>question 5% though... that seems awefully low. +> +> +Not really. It all depends on how many records you're packing into each +page. 1% may well be the threshold for small records. + +Tom mentioned this in the last couple of months. He was citing a uniform +distribution as an example and I thought that sounded a little +pessimistic, but when I did the (possibly faulty) math with a random +distribution, I discovered he wasn't far off. + +It's not this simple, but if you can fit 50 randomly organized records +into each page and you want to retrieve 2% of the rows, it's likely +you'll have to fetch every page - believe it or not. + +What concerns me is that this all depends on the correlation factor, and +I suspect that the planner is not giving enough weight to this. +Actually, I'm wondering if it's even looking at the statistic, but I +haven't created a test to check. It might explain quite a few complaints +about the planner not utilizing indexes. + +From pgsql-performance-owner@postgresql.org Thu Mar 10 01:59:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A31B356426 + for ; + Thu, 10 Mar 2005 01:59:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21672-05 + for ; + Thu, 10 Mar 2005 01:59:24 +0000 (GMT) +Received: from smtp.gvtc.com (smtp3.gvtc.com [216.177.160.85]) + by svr1.postgresql.org (Postfix) with SMTP id 4F42B564BA + for ; + Thu, 10 Mar 2005 01:59:23 +0000 (GMT) +Received: (qmail 12751 invoked from network); 10 Mar 2005 01:59:18 -0000 +Received: from ip-12-181-66-221.dsl0-blvrtx.gvtc.com (HELO ?192.168.1.102?) + (12.181.66.221) + by smtp.gvtc.com with SMTP; 10 Mar 2005 01:59:18 -0000 +Message-ID: <422FAC50.4060500@gvtc.com> +Date: Wed, 09 Mar 2005 20:09:20 -0600 +From: Jim Johannsen +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Help trying to tune query that executes 40x slower +References: <20050304002724.650A95AF649@svr4.postgresql.org> + <4e8efcf50503040413245d80f9@mail.gmail.com> + <4e8efcf50503070901406808be@mail.gmail.com> +In-Reply-To: <4e8efcf50503070901406808be@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/176 +X-Sequence-Number: 10881 + +Hugo, + + I think your problem is with the MRS_TRANSACTION TRANS table. It is +not joining anything when declared, but later it is joining thru a LEFT +JOIN of the REPL_DATA_OWNER_RSDNC table. In fact I'm not sure that this +table is really needed. I would suggest rewriting your FROM clause. It +appears a little busy and includes additional filters that are taken +care of in the WHERE clause. + + What are the table layouts and what fields are indexed? + + + +Hugo Ferreira wrote: + +>Hi there :-) +> +>I'm really, really having trouble with this query... It is a part of, +>hmmm... 200 similar querys that I dinyamically build and run in a +>stored procedure. This one, for example, takes 27seconds to run. The +>whole stored procedure executes in about 15minutes. This is too much +>when compared to the exact same database, with the same indexes and +>same data running under SqlServer 2000, which takes 21seconds to run +>the whole batch. +> +>Any help would be extremely appreciated. I've also tried to tune up +>the configuration +> +>insert into MRS_REPLICATION_OUT select 514, 10000168, C.contxt_id, +>C.contxt_elmt_ix, CAST(null as NUMERIC(18)), CAST(null as +>NUMERIC(18)), CAST(null as NUMERIC(18)), CAST(null as NUMERIC(18)), +>CAST(null as NUMERIC(18)), null, 1 from c2iedm.CONTXT as P inner join +>c2iedm.CONTXT_ELMT as C on (P.contxt_id=C.contxt_id) inner join +>MRS_REPLICATION_OUT as S on S.ent_id=10000029 and (CAST(P.contxt_id AS +>numeric(18)) = S.pk1) inner join MRS_TRANSACTION TRANS on +>TRANS.trans_id=514 left join NON_REPL_DATA_OWNER NRDO on +>NRDO.non_repl_data_owner_id=C.owner_id left join REPL_DATA_OWNER_RSDNC +>RDOR on RDOR.owner_id=C.owner_id and +>RDOR.rsdnc_node_id=TRANS.recv_node_id left join MRS_REPLICATION_OUT +>OUT on OUT.trans_id=514 and OUT.ent_id=10000168 and ((CAST(C.contxt_id +>AS numeric(18)) = OUT.pk1 AND CAST(C.contxt_elmt_ix AS numeric(18)) = +>OUT.pk2)) inner join MRS_TRANSACTION RED_TRANS on +>TRANS.prov_node_id=RED_TRANS.prov_node_id and +>TRANS.recv_node_id=RED_TRANS.recv_node_id left join +>MRS_REPLICATION_OUT RED_OUT on RED_TRANS.cat_code = 'OUT' and +>RED_TRANS.trans_type in ('X01', 'X02') and +>RED_TRANS.trans_id=RED_OUT.trans_id where S.age=0 and S.trans_id=514 +>and (NRDO.non_repl_data_owner_id is null) AND (RDOR.repl_data_owner_id +>is null) AND (OUT.trans_id is null) AND (RED_OUT.trans_id is null); +> +>This kind of inserts generate few rows. Between 8k and 15k for this particular +>insert, and about 20k for the whole batch. If I try to run a batch +>to generate about 50k rows, then I'll be stuck here for more that 45h. +>Compare this to 12minutes when running SqlServer 2000. +> +>Here is the result of explain analyze: +> +>"Merge Left Join (cost=1338.32..1377.99 rows=45 width=32) (actual +>time=719.000..26437.000 rows=14862 loops=1)" +>" Merge Cond: ("outer".trans_id = "inner".trans_id)" +>" Join Filter: (("outer".cat_code = 'OUT'::bpchar) AND +>(("outer".trans_type = 'X01'::bpchar) OR ("outer".trans_type = +>'X02'::bpchar)))" +>" Filter: ("inner".trans_id IS NULL)" +>" -> Sort (cost=1067.36..1067.47 rows=45 width=56) (actual +>time=719.000..735.000 rows=14862 loops=1)" +>" Sort Key: red_trans.trans_id" +>" -> Merge Join (cost=851.66..1066.12 rows=45 width=56) +>(actual time=407.000..673.000 rows=14862 loops=1)" +>" Merge Cond: ("outer".recv_node_id = "inner".recv_node_id)" +>" Join Filter: ("outer".prov_node_id = "inner".prov_node_id)" +>" -> Nested Loop Left Join (cost=847.14..987.28 +>rows=3716 width=60) (actual time=407.000..610.000 rows=14862 loops=1)" +>" Join Filter: ((("outer".contxt_id)::numeric(18,0) +>= "inner".pk1) AND (("outer".contxt_elmt_ix)::numeric(18,0) = +>"inner".pk2))" +>" Filter: ("inner".trans_id IS NULL)" +>" -> Merge Left Join (cost=718.22..746.87 +>rows=3716 width=60) (actual time=407.000..563.000 rows=14862 loops=1)" +>" Merge Cond: (("outer".recv_node_id = +>"inner".rsdnc_node_id) AND ("outer".owner_id = "inner".owner_id))" +>" Filter: ("inner".repl_data_owner_id IS NULL)" +>" -> Sort (cost=717.19..726.48 rows=3716 +>width=74) (actual time=407.000..423.000 rows=14862 loops=1)" +>" Sort Key: trans.recv_node_id, c.owner_id" +>" -> Nested Loop Left Join +>(cost=1.01..496.84 rows=3716 width=74) (actual time=0.000..312.000 +>rows=14862 loops=1)" +>" Join Filter: +>("inner".non_repl_data_owner_id = "outer".owner_id)" +>" Filter: +>("inner".non_repl_data_owner_id IS NULL)" +>" -> Nested Loop +>(cost=0.00..412.22 rows=3716 width=74) (actual time=0.000..186.000 +>rows=14862 loops=1)" +>" -> Seq Scan on +>mrs_transaction trans (cost=0.00..2.05 rows=1 width=28) (actual +>time=0.000..0.000 rows=1 loops=1)" +>" Filter: (trans_id = +>514::numeric)" +>" -> Nested Loop +>(cost=0.00..373.01 rows=3716 width=46) (actual time=0.000..139.000 +>rows=14862 loops=1)" +>" Join Filter: +>("outer".contxt_id = "inner".contxt_id)" +>" -> Nested Loop +>(cost=0.00..4.81 rows=1 width=16) (actual time=0.000..0.000 rows=4 +>loops=1)" +>" Join Filter: +>(("inner".contxt_id)::numeric(18,0) = "outer".pk1)" +>" -> Index +>Scan using ix_mrs_replication_out_all on mrs_replication_out s +>(cost=0.00..3.76 rows=1 width=16) (actual time=0.000..0.000 rows=4 +>loops=1)" +>" Index +>Cond: ((ent_id = 10000029::numeric) AND (age = 0::numeric) AND +>(trans_id = 514::numeric))" +>" -> Seq Scan +>on contxt p (cost=0.00..1.02 rows=2 width=16) (actual +>time=0.000..0.000 rows=2 loops=4)" +>" -> Seq Scan on +>contxt_elmt c (cost=0.00..275.31 rows=7431 width=46) (actual +>time=0.000..7.500 rows=7431 loops=4)" +>" -> Materialize +>(cost=1.01..1.02 rows=1 width=12) (actual time=0.000..0.001 rows=1 +>loops=14862)" +>" -> Seq Scan on +>non_repl_data_owner nrdo (cost=0.00..1.01 rows=1 width=12) (actual +>time=0.000..0.000 rows=1 loops=1)" +>" -> Sort (cost=1.03..1.03 rows=2 width=42) +>(actual time=0.000..0.000 rows=2 loops=1)" +>" Sort Key: rdor.rsdnc_node_id, rdor.owner_id" +>" -> Seq Scan on repl_data_owner_rsdnc +>rdor (cost=0.00..1.02 rows=2 width=42) (actual time=0.000..0.000 +>rows=2 loops=1)" +>" -> Materialize (cost=128.92..128.93 rows=1 +>width=42) (actual time=0.000..0.000 rows=0 loops=14862)" +>" -> Seq Scan on mrs_replication_out "out" +>(cost=0.00..128.92 rows=1 width=42) (actual time=0.000..0.000 rows=0 +>loops=1)" +>" Filter: ((trans_id = 514::numeric) +>AND (ent_id = 10000168::numeric))" +>" -> Sort (cost=4.52..4.73 rows=84 width=52) (actual +>time=0.000..15.000 rows=1 loops=1)" +>" Sort Key: red_trans.recv_node_id" +>" -> Seq Scan on mrs_transaction red_trans +>(cost=0.00..1.84 rows=84 width=52) (actual time=0.000..0.000 rows=1 +>loops=1)" +>" -> Sort (cost=270.96..277.78 rows=2728 width=10) (actual +>time=0.000..5255.000 rows=8932063 loops=1)" +>" Sort Key: red_out.trans_id" +>" -> Seq Scan on mrs_replication_out red_out +>(cost=0.00..115.28 rows=2728 width=10) (actual time=0.000..0.000 +>rows=602 loops=1)" +>"Total runtime: 27094.000 ms" +> +>Once again, thanks in advance. +> +>Hugo Ferreira +>-- +>GPG Fingerprint: B0D7 1249 447D F5BB 22C5 5B9B 078C 2615 504B 7B85 +> +>---------------------------(end of broadcast)--------------------------- +>TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> +> +> +> + + +From pgsql-performance-owner@postgresql.org Thu Mar 10 05:29:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D81E56598 + for ; + Thu, 10 Mar 2005 05:29:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85324-07 + for ; + Thu, 10 Mar 2005 05:29:49 +0000 (GMT) +Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net + [199.185.220.220]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B71A5659E + for ; + Thu, 10 Mar 2005 05:29:48 +0000 (GMT) +Received: from localhost ([199.185.220.240]) by priv-edtnes56.telusplanet.net + (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP + id <20050310052947.DNXD26721.priv-edtnes56.telusplanet.net@localhost> + for ; + Wed, 9 Mar 2005 22:29:47 -0700 +Received: from 64.180.225.200 ( [64.180.225.200]) + as user a3a18850@192.168.200.1 by webmail.telus.net with HTTP; + Wed, 9 Mar 2005 21:29:47 -0800 +Message-ID: <1110432587.422fdb4baaffd@webmail.telus.net> +Date: Wed, 9 Mar 2005 21:29:47 -0800 +From: Mischa +To: pgsql-performance@postgresql.org +Subject: Multi-line requests in COPY ... FROM STDIN +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.1-cvs +X-Originating-IP: 64.180.225.200 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.082 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_POST, FORGED_RCVD_HELO +X-Spam-Level: * +X-Archive-Number: 200503/177 +X-Sequence-Number: 10882 + +I'm using a 7.4.6 Perl app that bulk-loads a table, +by executing a "COPY TMP_Message FROM STDIN", then letting +$dbh->func($message_text."\n", "putline") + +Speculation made me try catenating Several \n-terminated lines +together, and making a single putline() call with that. +Lo and behold, all the lines went in as separate rows, as I hoped. + +I haven't measured the performance difference using this multiline +batching. I'm hoping that there will be as much,since the app is really sucking +on a 500 msg/sec firehose, and the db side needs serious speeding up. Question +is, am I playing with a version-dependent anomaly, or should I expect this +to continue in 8.x (until, eventually, silently, something causes +this to break)? + +I'm presuming that this is not a Perl DBI/DBD::Pg question, +but rather, depending on the underlying pq lib and fe protocol. + +-- +"Dreams come true, not free." + + +From pgsql-performance-owner@postgresql.org Thu Mar 10 07:41:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A7F79564AB + for ; + Thu, 10 Mar 2005 07:41:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24056-04 + for ; + Thu, 10 Mar 2005 07:40:57 +0000 (GMT) +Received: from mailgate3.nau.edu (mailgate3.nau.edu [134.114.96.145]) + by svr1.postgresql.org (Postfix) with ESMTP id 8FA07564C6 + for ; + Thu, 10 Mar 2005 07:40:56 +0000 (GMT) +Received: from CONVERSION-DAEMON.mailgate3.nau.edu by mailgate3.nau.edu + (PMDF V6.2-X17 #30845) id <0ID400101LC8UE@mailgate3.nau.edu> for + pgsql-performance@postgresql.org; Thu, 10 Mar 2005 00:40:57 -0700 (MST) +Received: from k2.cet.nau.edu (net9-213.cet.nau.edu [134.114.9.213]) + by mailgate3.nau.edu (PMDF V6.2-X17 #30845) + with ESMTP id <0ID400BE6LC848@mailgate3.nau.edu> for + pgsql-performance@postgresql.org; Thu, 10 Mar 2005 00:40:56 -0700 (MST) +Date: Thu, 10 Mar 2005 00:44:44 -0700 +From: Karim Nassar +Subject: What's better: Raid 0 or disk for seperate pg_xlog +To: pgsql-performance@postgresql.org +Message-id: <1110440684.6368.163.camel@k2.cet.nau.edu> +MIME-version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="=-yq9LhudNh8UnGe/lSGWF" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/178 +X-Sequence-Number: 10883 + + +--=-yq9LhudNh8UnGe/lSGWF +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +=46rom rom http://www.powerpostgresql.com/PerfList/ + +"even in a two-disk server, you can put the transaction log onto the +operating system disk and reap some benefits." + +Context: I have a two disk server that is about to become dedicated to +postgresql (it's a sun v40z running gentoo linux). + +What's "theoretically better"?=20 + +1) OS and pg_xlog on one disk, rest of postgresql on the other? (if I + understand the above correctly) +2) Everything striped Raid 0? +3) + +TIA, +--=20 +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=3D- Mobile: (928) 699-9221 + +--=-yq9LhudNh8UnGe/lSGWF +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (GNU/Linux) + +iD8DBQBCL/rsXcetVcVKInsRAth/AJ0TAeTEqMOOJWH+3DIIGAQUjWbmcACfbIUm +K8/oDMqIdzu1d63v8zKOYL4= +=UhKZ +-----END PGP SIGNATURE----- + +--=-yq9LhudNh8UnGe/lSGWF-- + + +From pgsql-performance-owner@postgresql.org Thu Mar 10 14:14:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 89227562E9 + for ; + Thu, 10 Mar 2005 14:14:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35094-04 + for ; + Thu, 10 Mar 2005 14:14:32 +0000 (GMT) +Received: from gizmo10ps.bigpond.com (gizmo10ps.bigpond.com [144.140.71.20]) + by svr1.postgresql.org (Postfix) with SMTP id D896D55CF0 + for ; + Thu, 10 Mar 2005 14:14:30 +0000 (GMT) +Received: (qmail 11003 invoked from network); 10 Mar 2005 14:14:32 -0000 +Received: from unknown (HELO psmam05.bigpond.com) (144.135.25.81) + by gizmo10ps.bigpond.com with SMTP; 10 Mar 2005 14:14:32 -0000 +Received: from cpe-203-45-203-73.qld.bigpond.net.au ([203.45.203.73]) by + psmam05.bigpond.com(MAM REL_3_4_2a 107/6629491) with SMTP id + 6629491; Fri, 11 Mar 2005 00:14:32 +1000 +Message-ID: <4230564C.3090906@bigpond.net.au> +Date: Fri, 11 Mar 2005 00:14:36 +1000 +From: David Brown +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Karim Nassar +Cc: pgsql-performance@postgresql.org +Subject: Re: What's better: Raid 0 or disk for seperate pg_xlog +References: <1110440684.6368.163.camel@k2.cet.nau.edu> +In-Reply-To: <1110440684.6368.163.camel@k2.cet.nau.edu> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.743 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_WHOIS +X-Spam-Level: +X-Archive-Number: 200503/179 +X-Sequence-Number: 10884 + +Karim Nassar wrote: + +>Context: I have a two disk server that is about to become dedicated to +>postgresql (it's a sun v40z running gentoo linux). +> +>What's "theoretically better"? +> +>1) OS and pg_xlog on one disk, rest of postgresql on the other? (if I +> understand the above correctly) +>2) Everything striped Raid 0? +> +How lucky are you feeling? If you don't mind doubling your chances of +data loss (a bit worse than that because recovery is nearly impossible), +go ahead and use RAID 0 (which of course is not RAID by definition). + +The WAL on a separate disk is your best bet if the problem is slow updates. + +If prevention of data loss is a consideration, RAID 1 (mirroring) is the +answer. + + + +From pgsql-performance-owner@postgresql.org Thu Mar 10 15:27:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D4C5D52A66 + for ; + Thu, 10 Mar 2005 15:27:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57058-05 + for ; + Thu, 10 Mar 2005 15:26:57 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 29EC056391 + for ; + Thu, 10 Mar 2005 15:26:55 +0000 (GMT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j2AFQv309379; + Thu, 10 Mar 2005 09:26:57 -0600 +Message-ID: <4230673B.3020400@arbash-meinel.com> +Date: Thu, 10 Mar 2005 09:26:51 -0600 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Karim Nassar +Cc: pgsql-performance@postgresql.org +Subject: Re: What's better: Raid 0 or disk for seperate pg_xlog +References: <1110440684.6368.163.camel@k2.cet.nau.edu> +In-Reply-To: <1110440684.6368.163.camel@k2.cet.nau.edu> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig3B09910D8F9D6428C3A88634" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/180 +X-Sequence-Number: 10885 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig3B09910D8F9D6428C3A88634 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Karim Nassar wrote: + +>From rom http://www.powerpostgresql.com/PerfList/ +> +>"even in a two-disk server, you can put the transaction log onto the +>operating system disk and reap some benefits." +> +>Context: I have a two disk server that is about to become dedicated to +>postgresql (it's a sun v40z running gentoo linux). +> +>What's "theoretically better"? +> +>1) OS and pg_xlog on one disk, rest of postgresql on the other? (if I +> understand the above correctly) +>2) Everything striped Raid 0? +>3) +> +>TIA, +> +> +With 2 disks, you have 3 options, RAID0, RAID1, and 2 independent disks. + +RAID0 - Fastest read and write speed. Not redundant, if either disk +fails you lose everything on *both* disks. +RAID1 - Redundant, slow write speed, but should be fast read speed. If +one disk fails, you have a backup. +2 independent - With pg_xlog on a separate disk, writing (updates) +should stay reasonably fast. If one disk dies, you lose that disk, but +not both. + +How critical is your data? How update heavy versus read heavy, etc are +you? Do you have a way to restore the database if something fails? If +you do nightly pg_dumps, will you survive if you lose a days worth of +transactions? + +In general I would recommend RAID1, because that is the safe bet. If +your db is the bottleneck, and your data isn't all that critical, and +you are read heavy, I would probably go with RAID1, if you are write +heavy I would say 2 independent disks. + +John +=:-> + + +--------------enig3B09910D8F9D6428C3A88634 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCMGc7JdeBCYSNAAMRAkVGAKChu39z/Vx0sjhpRRh4WqgpJD2p6wCgyVN1 +h6uIxwJau3cvVd6cSI6Gmzs= +=Mz6i +-----END PGP SIGNATURE----- + +--------------enig3B09910D8F9D6428C3A88634-- + +From pgsql-performance-owner@postgresql.org Thu Mar 10 16:41:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CD30455683 + for ; + Thu, 10 Mar 2005 16:41:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80638-10 + for ; + Thu, 10 Mar 2005 16:41:42 +0000 (GMT) +Received: from relay.icomedias.com (office.icomedias.com [62.99.232.80]) + by svr1.postgresql.org (Postfix) with ESMTP id CE5A85636F + for ; + Thu, 10 Mar 2005 16:41:39 +0000 (GMT) +Received: from loki.icomedias.com ([10.192.17.128]) + by relay.icomedias.com (8.13.1/8.13.0) with ESMTP id j2AGfTlV004941; + Thu, 10 Mar 2005 17:41:29 +0100 +From: Mario Weilguni +To: pgsql-performance@postgresql.org +Subject: Re: What's better: Raid 0 or disk for seperate pg_xlog +Date: Thu, 10 Mar 2005 17:41:28 +0100 +User-Agent: KMail/1.8 +Cc: Karim Nassar +References: <1110440684.6368.163.camel@k2.cet.nau.edu> +In-Reply-To: <1110440684.6368.163.camel@k2.cet.nau.edu> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200503101741.28407.mweilguni@sime.com> +X-Scanned-By: MIMEDefang 2.43 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.159 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_BOGUSMX, DNS_FROM_RFC_POST +X-Spam-Level: ** +X-Archive-Number: 200503/181 +X-Sequence-Number: 10886 + +Am Donnerstag, 10. M=E4rz 2005 08:44 schrieb Karim Nassar: +> From rom http://www.powerpostgresql.com/PerfList/ +> +> "even in a two-disk server, you can put the transaction log onto the +> operating system disk and reap some benefits." +> +> Context: I have a two disk server that is about to become dedicated to +> postgresql (it's a sun v40z running gentoo linux). +> +> What's "theoretically better"? +> +> 1) OS and pg_xlog on one disk, rest of postgresql on the other? (if I +> understand the above correctly) +> 2) Everything striped Raid 0? +> 3) + +Because of hard disk seeking times, a separate disk for WAL will be a lot=20 +better. + +regards + +From pgsql-performance-owner@postgresql.org Thu Mar 10 19:47:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0116455F07 + for ; + Thu, 10 Mar 2005 19:47:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37852-04 + for ; + Thu, 10 Mar 2005 19:47:03 +0000 (GMT) +Received: from mailgate2.nau.edu (mailgate2.nau.edu [134.114.96.59]) + by svr1.postgresql.org (Postfix) with ESMTP id D76C5565A0 + for ; + Thu, 10 Mar 2005 19:47:02 +0000 (GMT) +Received: from CONVERSION-DAEMON.mailgate2.nau.edu by mailgate2.nau.edu + (PMDF V6.2-X17 #30770) id <0ID500G01IY816@mailgate2.nau.edu> for + pgsql-performance@postgresql.org; Thu, 10 Mar 2005 12:47:01 -0700 (MST) +Received: from k2.cet.nau.edu (net9-213.cet.nau.edu [134.114.9.213]) + by mailgate2.nau.edu (PMDF V6.2-X17 #30770) + with ESMTP id <0ID500F1RIXV37@mailgate2.nau.edu>; Thu, + 10 Mar 2005 12:46:43 -0700 (MST) +Date: Thu, 10 Mar 2005 12:50:31 -0700 +From: Karim Nassar +Subject: Re: What's better: Raid 0 or disk for seperate pg_xlog +In-reply-to: <4230673B.3020400@arbash-meinel.com> +To: John A Meinel +Cc: pgsql-performance@postgresql.org +Message-id: <1110484232.9252.211.camel@k2.cet.nau.edu> +MIME-version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-type: text/plain +Content-transfer-encoding: 7BIT +References: <1110440684.6368.163.camel@k2.cet.nau.edu> + <4230673B.3020400@arbash-meinel.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/182 +X-Sequence-Number: 10887 + +Thanks to all for the tips. + +On Thu, 2005-03-10 at 09:26 -0600, John A Meinel wrote: +> How critical is your data? How update heavy versus read heavy, etc are you? + +Large, relatively infrequent uploads, with frequent reads. The +application is a web front-end to scientific research data. The +scientists have their own copy of the data, so if something went really +bad, we could probably get them to upload again. + +> Do you have a way to restore the database if something fails? If +> you do nightly pg_dumps, will you survive if you lose a days worth of +> transactions? + +For now, we have access to a terabyte backup server, and the DB is small +enough that my sysadmin lets me have hourly pg_dumps for last 24 hours +backed up nightly. Veritas is configured to save daily pg_dumps for the +last week, a weekly dump for the last month and a monthly version for +the last 6 months. + +> In general I would recommend RAID1, because that is the safe bet. If +> your db is the bottleneck, and your data isn't all that critical, and +> you are read heavy, I would probably go with RAID1, if you are write +> heavy I would say 2 independent disks. + +I feel that we have enough data safety such that I want to go for speed. +Some of the queries are very large joins, and I am going for pure +throughput at this point - unless someone can find a hole in my backup +tactic. + +Of course, later we will have money to throw at more spindles. But for +now, I am trying gaze in to the future and maximize my current +capabilities. + + +Seems to me that the "best" solution would be: + +* disk 0 partition 1..n - os mounts + partition n+1 - /var/lib/postgres/data/pg_xlog + +* disk 1 partition 1 - /var/lib/postgres/data + +* Further (safe) performance gains can be had by adding more spindles as +such: + - first disk: RAID1 to disk 1 + - next 2 disks: RAID 0 across the above + +Do I grok it? + +Thanks again, +-- +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=- Mobile: (928) 699-9221 + + +From pgsql-performance-owner@postgresql.org Thu Mar 10 19:56:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E8BC55456 + for ; + Thu, 10 Mar 2005 19:56:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40815-02 + for ; + Thu, 10 Mar 2005 19:56:15 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id D9463545E9 + for ; + Thu, 10 Mar 2005 19:56:13 +0000 (GMT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j2AJu8311748; + Thu, 10 Mar 2005 13:56:08 -0600 +Message-ID: <4230A653.4090708@arbash-meinel.com> +Date: Thu, 10 Mar 2005 13:56:03 -0600 +From: John Arbash Meinel +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.8b) Gecko/20050217 +MIME-Version: 1.0 +To: Karim Nassar , + pgsql-performance@postgresql.org +Subject: Re: What's better: Raid 0 or disk for seperate pg_xlog +References: <1110440684.6368.163.camel@k2.cet.nau.edu> + <4230673B.3020400@arbash-meinel.com> + <1110484232.9252.211.camel@k2.cet.nau.edu> +In-Reply-To: <1110484232.9252.211.camel@k2.cet.nau.edu> +X-Enigmail-Version: 0.90.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig8BCB7333F80A668AA336961B" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/183 +X-Sequence-Number: 10888 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig8BCB7333F80A668AA336961B +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Karim Nassar wrote: + +>Thanks to all for the tips. +> +> +... + +>>In general I would recommend RAID1, because that is the safe bet. If +>>your db is the bottleneck, and your data isn't all that critical, and +>>you are read heavy, I would probably go with RAID1, if you are write +>> +>> + ^^^^^ -> RAID0 + +>>heavy I would say 2 independent disks. +>> +>> +> +>I feel that we have enough data safety such that I want to go for speed. +>Some of the queries are very large joins, and I am going for pure +>throughput at this point - unless someone can find a hole in my backup +>tactic. +> +>Of course, later we will have money to throw at more spindles. But for +>now, I am trying gaze in to the future and maximize my current +>capabilities. +> +> +>Seems to me that the "best" solution would be: +> +>* disk 0 partition 1..n - os mounts +> partition n+1 - /var/lib/postgres/data/pg_xlog +> +>* disk 1 partition 1 - /var/lib/postgres/data +> +>* Further (safe) performance gains can be had by adding more spindles as +>such: +> - first disk: RAID1 to disk 1 +> - next 2 disks: RAID 0 across the above +> +> +Sounds decent to me. +I did make the mistake that you might want to consider a RAID0. But the +performance gains might be small, and you potentially lose everything. +But your update strategy seems dead on. + +>Do I grok it? +> +>Thanks again, +> +> + +John +=:-> + + +--------------enig8BCB7333F80A668AA336961B +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (Cygwin) +Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org + +iD8DBQFCMKZUJdeBCYSNAAMRAm0EAKCJ5w9IjmpQcxiBVqi0xxVKAhQtxgCgoXIQ +Qx5E1GrX2AvGh2g14XI2tIk= +=2pCv +-----END PGP SIGNATURE----- + +--------------enig8BCB7333F80A668AA336961B-- + +From pgsql-performance-owner@postgresql.org Fri Mar 11 08:06:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E7C9656635 + for ; + Fri, 11 Mar 2005 08:06:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32585-06 + for ; + Fri, 11 Mar 2005 08:06:02 +0000 (GMT) +Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net + [194.217.242.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 0DFFE56601 + for ; + Fri, 11 Mar 2005 08:05:59 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-33.mail.demon.net with esmtp (Exim 4.42) + id 1D9f9i-000MGM-C8; Fri, 11 Mar 2005 08:05:59 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id A990A166EC; Fri, 11 Mar 2005 08:05:57 +0000 (GMT) +Message-ID: <42315165.1050202@archonet.com> +Date: Fri, 11 Mar 2005 08:05:57 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Karim Nassar +Cc: John A Meinel , + pgsql-performance@postgresql.org +Subject: Re: What's better: Raid 0 or disk for seperate pg_xlog +References: <1110440684.6368.163.camel@k2.cet.nau.edu> + <4230673B.3020400@arbash-meinel.com> + <1110484232.9252.211.camel@k2.cet.nau.edu> +In-Reply-To: <1110484232.9252.211.camel@k2.cet.nau.edu> +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.063 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/184 +X-Sequence-Number: 10889 + +Karim Nassar wrote: +> Thanks to all for the tips. +> +> On Thu, 2005-03-10 at 09:26 -0600, John A Meinel wrote: +> +>>How critical is your data? How update heavy versus read heavy, etc are you? +> +> +> Large, relatively infrequent uploads, with frequent reads. The +> application is a web front-end to scientific research data. The +> scientists have their own copy of the data, so if something went really +> bad, we could probably get them to upload again. + +If you have very few updates and your reads aren't mostly from RAM you +could be better off with simply mirroring (assuming that gains you read +bandwidth). Failing that, use the tablespace feature to balance your +read load as far as you can. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Mar 11 11:53:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8EBE3565CD + for ; + Fri, 11 Mar 2005 11:53:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00783-03 + for ; + Fri, 11 Mar 2005 11:53:17 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.200]) + by svr1.postgresql.org (Postfix) with ESMTP id 1AF78565B9 + for ; + Fri, 11 Mar 2005 11:53:16 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 70so921532wra + for ; + Fri, 11 Mar 2005 03:53:19 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; + b=LuORoPAjKNvy3CvBuxs4DvWqPhAjyWg007K1/AYnujN0iGVvGdVezNZwvwzGCfKItGlUWsycq16KeNIf6noiR1P9k3+u2beraQgcAQsuJpD9KRnTpotvnnHMqvZgpFpZfLnPpVNZh26rBMHP0ES2UddOpSf3EvgKFdxZKmyzrbc= +Received: by 10.54.77.7 with SMTP id z7mr1268326wra; + Fri, 11 Mar 2005 03:53:18 -0800 (PST) +Received: by 10.54.18.9 with HTTP; Fri, 11 Mar 2005 03:53:18 -0800 (PST) +Message-ID: <4e8efcf505031103531e49c8d0@mail.gmail.com> +Date: Fri, 11 Mar 2005 11:53:18 +0000 +From: Hugo Ferreira +Reply-To: Hugo Ferreira +To: pgsql-performance@postgresql.org +Subject: Statistics not working?? +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.462 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/185 +X-Sequence-Number: 10890 + +Hi there! + +I think I may have a problem with the statistics in my postgresql 8.0 +running under Windowx XP. When I view both pg_stat_all_tables and +pg_stat_all_indexes, all the numeric columns that should hold the +statistics are 0 (zero). My configuration file has the following: + +stats_start_collector = true +stats_command_string = true +stats_reset_on_server_start = false + +Any tip? + +Thanks in advance, + +Hugo Ferreira + +-- +GPG Fingerprint: B0D7 1249 447D F5BB 22C5 5B9B 078C 2615 504B 7B85 + +From pgsql-benchmarks-owner@postgresql.org Mon Mar 14 01:52:39 2005 +X-Original-To: pgsql-benchmarks-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CD59565AA; + Fri, 11 Mar 2005 11:58:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00990-09; Fri, 11 Mar 2005 11:58:13 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A13F54E9E; + Fri, 11 Mar 2005 11:58:13 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 1F9B131E35; Fri, 11 Mar 2005 12:58:15 +0100 (MET) +From: "AL� �EL�K" +X-Newsgroups: pgsql.benchmarks,pgsql.general,pgsql.performance,pgsql.sql +Subject: more execution time +Date: Fri, 11 Mar 2005 13:54:56 +0200 +Organization: Hub.Org Networking Services +Lines: 90 +Message-ID: +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 +X-RFC2646: Format=Flowed; Original +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +To: pgsql-benchmarks@postgresql.org, pgsql-general@postgresql.org, + pgsql-performance@postgresql.org, pgsql-sql@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Amavis-Alert: BAD HEADER Non-encoded 8-bit data (char DD hex) in message + header 'From': From: "AL\335 \307EL\335K" Merge Left Join (cost=108.27..108.46 rows=5 width=409) + Merge Cond: ("outer".regtypeid = "inner".id) + -> Sort (cost=106.19..106.20 rows=5 width=347) + Sort Key: pd2.regtypeid + -> Hash Left Join (cost=90.11..106.13 rows=5 width=347) + Hash Cond: ("outer".id = "inner".masterid) + -> Hash Left Join (cost=45.49..45.71 rows=5 width=219) + Hash Cond: ("outer".dateid = "inner".id) + -> Merge Left Join (cost=44.44..44.63 rows=5 +width=194) + Merge Cond: ("outer".regtypeid = "inner".id) + -> Sort (cost=42.36..42.37 rows=5 +width=132) + Sort Key: personaldetails.regtypeid + -> Seq Scan on personaldetails +(cost=0.00..42.30 rows=5 width=132) + Filter: (masterid IS NULL) + -> Sort (cost=2.08..2.16 rows=31 width=66) + Sort Key: regtypes.id + -> Seq Scan on regtypes +(cost=0.00..1.31 rows=31 width=66) + -> Hash (cost=1.04..1.04 rows=4 width=33) + -> Seq Scan on regtypedates +(cost=0.00..1.04 rows=4 width=33) + -> Hash (cost=42.30..42.30 rows=930 width=132) + -> Seq Scan on personaldetails pd2 +(cost=0.00..42.30 rows=930 width=132) + -> Sort (cost=2.08..2.16 rows=31 width=66) + Sort Key: rt2.id + -> Seq Scan on regtypes rt2 (cost=0.00..1.31 rows=31 +width=66) + -> Hash (cost=1.04..1.04 rows=4 width=33) + -> Seq Scan on regtypedates rd2 (cost=0.00..1.04 rows=4 width=33) + + + + +From pgsql-performance-owner@postgresql.org Fri Mar 11 12:03:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9CC97565E1 + for ; + Fri, 11 Mar 2005 12:03:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05244-02 + for ; + Fri, 11 Mar 2005 12:03:32 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BFDB4565B9 + for ; + Fri, 11 Mar 2005 12:03:22 +0000 (GMT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id j2BC3F5Q023485; + Fri, 11 Mar 2005 15:03:15 +0300 (MSK) +Date: Fri, 11 Mar 2005 15:03:15 +0300 (MSK) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Hugo Ferreira +Cc: pgsql-performance@postgresql.org +Subject: Re: Statistics not working?? +In-Reply-To: <4e8efcf505031103531e49c8d0@mail.gmail.com> +Message-ID: +References: <4e8efcf505031103531e49c8d0@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.349 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/186 +X-Sequence-Number: 10891 + +On Fri, 11 Mar 2005, Hugo Ferreira wrote: + +> Hi there! +> +> I think I may have a problem with the statistics in my postgresql 8.0 +> running under Windowx XP. When I view both pg_stat_all_tables and +> pg_stat_all_indexes, all the numeric columns that should hold the +> statistics are 0 (zero). My configuration file has the following: +> +> stats_start_collector = true +> stats_command_string = true +> stats_reset_on_server_start = false +> +> Any tip? + +You need to define stats_block_level and/or stats_row_level + + +> +> Thanks in advance, +> +> Hugo Ferreira +> +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-benchmarks-owner@postgresql.org Mon Mar 14 02:07:03 2005 +X-Original-To: pgsql-benchmarks-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BDCC3556EE; + Fri, 11 Mar 2005 13:05:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20175-08; Fri, 11 Mar 2005 13:05:34 +0000 (GMT) +Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net + [194.217.242.85]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E30B5653D; + Fri, 11 Mar 2005 13:05:28 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-35.mail.demon.net with esmtp (Exim 4.42) + id 1D9jnT-000CPH-Go; Fri, 11 Mar 2005 13:03:19 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id BEE271755A; Fri, 11 Mar 2005 13:05:28 +0000 (GMT) +Message-ID: <42319798.1060206@archonet.com> +Date: Fri, 11 Mar 2005 13:05:28 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?ISO-8859-15?Q?AL=DD_=C7EL=DDK?= +Cc: pgsql-benchmarks@postgresql.org, pgsql-general@postgresql.org, + pgsql-performance@postgresql.org, pgsql-sql@postgresql.org +Subject: Re: [GENERAL] more execution time +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.062 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/2 +X-Sequence-Number: 40 + +AL� �EL�K wrote: +> why this query needs more time? Its very slow + +Difficult to say for sure - could you provide the output of EXPLAIN +ANALYSE rather than just EXPLAIN? + +Some other immediate observations: +1. Perhaps don't post to so many mailing lists at once. If you reply to +this, maybe reduce it to pgsql-performance? +2. You don't say whether the row estimates are accurate in the EXPLAIN. +3. You seem to be needlessly coalescing personaldetails.masterid since +you check for it being null in your WHERE clause +4. Do you really need to cast to numeric and generate a "sorting" column +that you then don't ORDER BY? +5. Is ppid an id number? And are you sure it's safe to calculate it like +that? +6. What is balance() and how long does it take to calculate its result? + +> select +> coalesce(personaldetails.masterid::numeric,personaldetails.id) + +> (coalesce(personaldetails.id::numeric,0)/1000000) as sorting, +> floor(coalesce(personaldetails.masterid::numeric,personaldetails.id) + +> (coalesce(personaldetails.id::numeric,0)/1000000)) as ppid, + +> balance('MASTER-REGISTRATION',personaldetails.id) as balance, + +> balance('MASTER-REGISTRATION',pd2.id) as accbalance, + +I'm guessing point 6 is actually your problem - try it without the calls +to balance() and see what that does to your timings. +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Mar 11 13:45:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3423F5654C + for ; + Fri, 11 Mar 2005 13:45:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33206-07 + for ; + Fri, 11 Mar 2005 13:45:11 +0000 (GMT) +Received: from obelix.askesis.nl (laudanum.demon.nl [82.161.125.16]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FF6D54F6A + for ; + Fri, 11 Mar 2005 13:45:08 +0000 (GMT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Subject: What is the number of rows in explain? +Date: Fri, 11 Mar 2005 14:45:12 +0100 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: What is the number of rows in explain? +Thread-Index: AcUmQIwoOjms6pLtRc+fC6pCe3wBHQ== +From: "Joost Kraaijeveld" +To: "Pgsql-Performance (E-mail)" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.103 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/188 +X-Sequence-Number: 10893 + +Hi all, + +Is the number of rows in explain the number of rows that is expected to = +be visited or retrieved? + +Groeten, + +Joost Kraaijeveld +Askesis B.V. +Molukkenstraat 14 +6524NB Nijmegen +tel: 024-3888063 / 06-51855277 +fax: 024-3608416 +e-mail: J.Kraaijeveld@Askesis.nl +web: www.askesis.nl=20 + +From pgsql-performance-owner@postgresql.org Mon Mar 14 02:20:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AC86D565D9 + for ; + Fri, 11 Mar 2005 14:25:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45161-06 + for ; + Fri, 11 Mar 2005 14:25:15 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 51D0E565B7 + for ; + Fri, 11 Mar 2005 14:25:13 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id AC32431E24; Fri, 11 Mar 2005 15:25:17 +0100 (MET) +From: Daniel Schuchardt +X-Newsgroups: pgsql.performance +Subject: cpu_tuple_cost +Date: Fri, 11 Mar 2005 15:25:29 +0100 +Organization: Hub.Org Networking Services +Lines: 68 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.204 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/236 +X-Sequence-Number: 10941 + +Hi List, + +i have a query plan who is bad with standard cpu_tuple_costs and good if +I raise cpu_tuple_costs. Is it is a good practice to raise them if i +want to force postgres to use indexes more often? Or is it is better to +disable sequence scans? + +CIMSOFT=# ANALYSE mitpln; +ANALYZE + +CIMSOFT=# EXPLAIN ANALYSE SELECT * FROM mitpln WHERE +date_to_yearmonth_dec(mpl_date)='20050'; + QUERY PLAN + +-------------------------------------------------------------------------------- + Seq Scan on mitpln (cost=0.00..1411.85 rows=2050 width=69) (actual +time=562.000..1203.000 rows=1269 loops=1) + Filter: ((date_to_yearmonth_dec((mpl_date)::timestamp without time +zone))::text = '20050'::text) + Total runtime: 1203.000 ms +(3 rows) + +CIMSOFT=# SET cpu_tuple_cost = 0.07; +SET +CIMSOFT=# EXPLAIN ANALYSE SELECT * FROM mitpln WHERE +date_to_yearmonth_dec(mpl_date)='20050'; + QUERY PLAN + +-------------------------------------------------------------------------------- + Index Scan using mitpln_yearmonth_dec on mitpln (cost=0.00..2962.86 +rows=2050width=69) (actual time=0.000..0.000 rows=1269 loops=1) + Index Cond: ((date_to_yearmonth_dec((mpl_date)::timestamp without +time zone))::text = '20050'::text) + Total runtime: 16.000 ms +(3 rows) + + +CIMSOFT=# \d mitpln + Table "public.mitpln" + Column | Type | Modifiers + +--------------+-----------------------+----------------------------------------- + mpl_id | integer | not null default +nextval('public.mitpln_mpl_id_seq'::text) + mpl_date | date | + mpl_minr | integer | not null + mpl_tpl_name | character varying(20) | + mpl_feiertag | character varying(50) | + mpl_min | real | + mpl_saldo | real | + mpl_buch | boolean | not null default false + mpl_absaldo | real | + mpl_vhz | real | + dbrid | character varying | default nextval('db_id_seq'::text) +Indexes: + "mitpln_pkey" PRIMARY KEY, btree (mpl_id) + "mitpln_idindex" UNIQUE, btree (dbrid) + "xtt5126" UNIQUE, btree (mpl_date, mpl_minr) + "mitpln_yearmonth_dec" btree +(date_to_yearmonth_dec(mpl_date::timestamp with +out time zone)) + + +CIMSOFT=# SELECT count(*) FROM mitpln; + count +------- + 26128 +(1 row) + +From pgsql-performance-owner@postgresql.org Mon Mar 14 02:20:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 106C5566AD + for ; + Fri, 11 Mar 2005 14:27:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45214-08 + for ; + Fri, 11 Mar 2005 14:27:31 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 54D84566AA + for ; + Fri, 11 Mar 2005 14:27:31 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 37AF331E24; Fri, 11 Mar 2005 15:27:34 +0100 (MET) +From: Daniel Schuchardt +X-Newsgroups: pgsql.performance +Subject: Re: cpu_tuple_cost +Date: Fri, 11 Mar 2005 15:27:46 +0100 +Organization: Hub.Org Networking Services +Lines: 7 +Message-ID: +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +In-Reply-To: +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.646 tagged_above=0 required=5 tests=AWL, + UPPERCASE_50_75 +X-Spam-Level: +X-Archive-Number: 200503/235 +X-Sequence-Number: 10940 + +I have forgotten this : + +CREATE OR REPLACE FUNCTION date_to_yearmonth_dec(TIMESTAMP) RETURNS +VARCHAR AS' +BEGIN + RETURN extract(year FROM $1) || extract(month FROM $1)-1; +END'LANGUAGE plpgsql IMMUTABLE; + +From pgsql-performance-owner@postgresql.org Fri Mar 11 14:43:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D62AA565D4 + for ; + Fri, 11 Mar 2005 14:43:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50813-09 + for ; + Fri, 11 Mar 2005 14:43:55 +0000 (GMT) +Received: from ct.radiology.uiowa.edu (ct.radiology.uiowa.edu + [129.255.60.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 072BC565AC + for ; + Fri, 11 Mar 2005 14:43:53 +0000 (GMT) +Received: from [192.168.1.11] (12-217-241-0.client.mchsi.com [12.217.241.0]) + by ct.radiology.uiowa.edu (8.11.6/8.11.6) with ESMTP id j2BEht320430; + Fri, 11 Mar 2005 08:43:56 -0600 +Message-ID: <4231AEA1.7070300@arbash-meinel.com> +Date: Fri, 11 Mar 2005 08:43:45 -0600 +From: John A Meinel +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Joost Kraaijeveld +Cc: "Pgsql-Performance (E-mail)" +Subject: Re: What is the number of rows in explain? +References: +In-Reply-To: +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig9B513C46F6EDA591C4B7ED11" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/189 +X-Sequence-Number: 10894 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig9B513C46F6EDA591C4B7ED11 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Joost Kraaijeveld wrote: + +>Hi all, +> +>Is the number of rows in explain the number of rows that is expected to be visited or retrieved? +> +>Groeten, +> +>Joost Kraaijeveld +>Askesis B.V. +>Molukkenstraat 14 +>6524NB Nijmegen +>tel: 024-3888063 / 06-51855277 +>fax: 024-3608416 +>e-mail: J.Kraaijeveld@Askesis.nl +>web: www.askesis.nl +> +>---------------------------(end of broadcast)--------------------------- +>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +> +> +In general, it is the number of rows expected to be retrieved. Since a +Sequential Scan always visits every row, but the rows= number is after +filtering. + +John +=:-> + + +--------------enig9B513C46F6EDA591C4B7ED11 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.6 (Cygwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCMa6lJdeBCYSNAAMRAi9gAJ4v1q+WVhGBM8ta1mcFmeh5QqujEQCfYuR2 +ZSNOiEJAdfvGdAy+Kw3kWqM= +=z7iU +-----END PGP SIGNATURE----- + +--------------enig9B513C46F6EDA591C4B7ED11-- + +From pgsql-performance-owner@postgresql.org Fri Mar 11 15:41:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F30C752D8A + for ; + Fri, 11 Mar 2005 15:41:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68923-07 + for ; + Fri, 11 Mar 2005 15:41:01 +0000 (GMT) +Received: from mars.interactivemediafactory.net (mars.imfeurope.net + [194.2.222.161]) + by svr1.postgresql.org (Postfix) with ESMTP id 50D5E52A7C + for ; + Fri, 11 Mar 2005 15:40:57 +0000 (GMT) +Received: from JC-8600.directinfos.com (localhost [127.0.0.1]) + by mars.interactivemediafactory.net (8.12.11/8.12.11) with ESMTP id + j2BFf0km009424 for ; + Fri, 11 Mar 2005 16:41:00 +0100 (CET) + (envelope-from jc@directinfos.com) +Message-Id: + <6.2.0.14.0.20050311155221.041aa528@pop.interactivemediafactory.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.0.14 +Date: Fri, 11 Mar 2005 16:40:49 +0100 +To: pgsql-performance@postgresql.org +From: Jacques Caron +Subject: Performance tuning +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/190 +X-Sequence-Number: 10895 + +Hi all, + +I'm preparing a set of servers which will eventually need to handle a high +volume of queries (both reads and writes, but most reads are very simple +index-based queries returning a limited set of rows, when not just one), +and I would like to optimize things as much as possible, so I have a few +questions on the exact way PostgreSQL's MVCC works, and how transactions, +updates and vacuuming interact. I hope someone will be able to point me in +the right direction (feel free to give pointers if I missed the places +where this is described). + + From what I understand (and testing confirms it), bundling many queries in +one single transaction is more efficient than having each query be a +separate transaction (like with autocommit on). However, I wonder about the +limits of this: + +- are there any drawbacks to grouping hundreds or thousands of queries +(inserts/updates) over several minutes in one single transaction? Other +than the fact that the inserts/updates will not be visible until committed, +of course. Essentially turning autocommit off, and doing a commit once in a +while. + +- does this apply only to inserts/selects/updates or also for selects? +Another way to put this is: does a transaction with only one select +actually have much transaction-related work to do? Or, does a transaction +with only selects actually have any impact anywhere? Does it really leave a +trace anywhere? Again, I understand that selects grouped in a transaction +will not see updates done after the start of the transaction (unless done +by the same process). + +- if during a single transaction several UPDATEs affect the same row, will +MVCC generate as many row versions as there are updates (like would be the +case with autocommit) or will they be grouped into one single row version? + +Another related issue is that many of the tables are indexed on a date +field, and one process does a lot of updates on "recent" rows (which lead +to many dead tuples), but after that "older" rows tend to remain pretty +much unchanged for quite a while. Other than splitting the tables into +"old" and "recent" tables, is there any way to make vacuum more efficient? +Scanning the whole table for dead tuples when only a small portion of the +table actually has any does not feel like being very efficient in this +situation. + +Other issue: every five minutes or so, I see a noticeable performance drop +as PostgreSQL checkpoints. This is 7.4.3 with pretty lousy hardware, I know +8.0 with decent hardware and separate disk(s) for pg_xlog will definitely +help, but I really wonder if there is any way to reduce the amount of work +that needs to be done at that point (I'm a strong believer of fixing +software before hardware). I have already bumped checkpoint_segments to 8, +but I'm not quite sure I understand how this helps (or doesn't help) +things. Logs show 3 to 6 "recycled transaction log file" lines at that +time, that seems quite a lot of work for a load that's still pretty low. +Does grouping of more queries in transactions help with this? Are there +other parameters that can affect things, or is just a matter of how much +inserts/updates/deletes are done, and the amount of data that was changed? + +Last point: some of the servers have expandable data (and will be +replicated with slony-I) and will run with fsync off. I have read +conflicting statements as to what exactly this does: some sources indicate +that setting fsync off actually switches off WAL/checkpointing, others that +it just prevents the fsync (or equivalent) system calls. Since I still see +checkpointing in that case, I guess it's not exactly the former, but I +would love to understand more about it. Really, I would love to be able to +set some tables or databases to "go as fast as you can and don't worry +about transactions, MVCC or anything like that", but I'm not sure that +option exists... + +Thanks, + +Jacques. + + + +From pgsql-performance-owner@postgresql.org Fri Mar 11 18:48:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D542B5651C + for ; + Fri, 11 Mar 2005 18:48:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34045-07 + for ; + Fri, 11 Mar 2005 18:48:20 +0000 (GMT) +Received: from mesagate.talleyds.com (unknown [207.114.138.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 35C0F563DE + for ; + Fri, 11 Mar 2005 18:48:18 +0000 (GMT) +Received: from TDS-MTA by mesagate.talleyds.com + with Novell_GroupWise; Fri, 11 Mar 2005 11:48:19 -0700 +Message-Id: +X-Mailer: Novell GroupWise Internet Agent 6.5.4 +Date: Fri, 11 Mar 2005 11:47:54 -0700 +From: "Lou O'Quin" +To: +Subject: Query performance +Mime-Version: 1.0 +Content-Type: multipart/alternative; boundary="=__Part361548CA.0__=" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.505 tagged_above=0 required=5 tests=HTML_20_30, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200503/191 +X-Sequence-Number: 10896 + +--=__Part361548CA.0__= +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: quoted-printable + +As a test, I ran a query in the pgAdmin query tool, which returns about = +15K records from a PostgreSQL v8.01 table on my Win2K server. + +I ran the same query from the local server, from another PC on the same = +100 mbit local network, and from a PC on a different network, over the = +internet.=20 + +The times for the query to run and the data to return for each of the = +three=20 +locations are shown here: Local Server : 571+521 ms Local network: = +1187+1266 ms Internet:14579+4016 msMy question is this: Why does the = +execution time for the query to run increase so much? Since the query = +should be running on the server, it's time should be somewhat independent = +of the network transport delay. (unlike the data transport time) However, = +it appears to actually be hypersensitive to the transport delay. The = +ratios of time for the data transport (assuming 1 for the local server) = +are: +1 : 2.43 : 7.71 + +whereas the query execution time ratios are: +1 : 2.08 : 25.5 (!!!) + +Obviously, the transport times will be greater. But why does the = +execution time bloat so? + +--=__Part361548CA.0__= +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Description: HTML + + + + +As a = +test, I ran a query in the pgAdmin query tool, which returns about 15K = +records from a PostgreSQL v8.01 table on my Win2K server.

I ran the = +same query from the local server, from another PC on the same 100 mbit = +local network, and from a PC on a different network, over the internet. = +

The times for the query to run and the data to return for each of = +the three
locations are shown here:=20 +
    +
  • Local Server : 571+521 ms=20 +
  • Local network: 1187+1266 ms=20 +
  • Internet:14579+4016 ms
My question is this: Why does the = +execution time for the query to run increase so much? Since the query = +should be running on the server, it's time should be somewhat = +independent of the network transport delay. (unlike the data transport = +time) However, it appears to actually be hypersensitive to the transport = +delay. The ratios of time for the data transport (assuming 1 for the local = +server) are:
1 : 2.43 : 7.71

whereas the query execution = +time ratios are:
1 : 2.08 : 25.5  (!!!)

Obviousl= +y, the transport times will be greater.  But why does the execution = +time bloat so? + +--=__Part361548CA.0__=-- + +From pgsql-performance-owner@postgresql.org Fri Mar 11 20:14:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 77A66565E3 + for ; + Fri, 11 Mar 2005 20:14:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56456-07 + for ; + Fri, 11 Mar 2005 20:14:34 +0000 (GMT) +Received: from smtp814.mail.sc5.yahoo.com (smtp814.mail.sc5.yahoo.com + [66.163.170.84]) + by svr1.postgresql.org (Postfix) with SMTP id 9BF7C565AC + for ; + Fri, 11 Mar 2005 20:14:32 +0000 (GMT) +Received: from unknown (HELO treebeard) (jellej@pacbell.net@67.116.141.103 + with login) + by smtp814.mail.sc5.yahoo.com with SMTP; 11 Mar 2005 18:54:05 -0000 +Date: Fri, 11 Mar 2005 10:54:30 -0800 (PST) +From: jelle +X-X-Sender: jelle@localhost.localdomain +Reply-To: jellej@pacbell.net +To: pgsql-performance@postgresql.org +Subject: Questions about 2 databases. +In-Reply-To: + <6.2.0.14.0.20050311155221.041aa528@pop.interactivemediafactory.net> +Message-ID: +References: + <6.2.0.14.0.20050311155221.041aa528@pop.interactivemediafactory.net> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.75 tagged_above=0 required=5 + tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST +X-Spam-Level: * +X-Archive-Number: 200503/194 +X-Sequence-Number: 10899 + + +Hello All, + +I have a couple of questions about running 2 databases: + +1) on a single 7.4.6 postgres instance does each database have it own WAL + file or is that shared? Is it the same on 8.0.x? + +2) what's the high performance way of moving 200 rows between similar + tables on different databases? Does it matter if the databases are + on the same or seperate postgres instances? + +Background: +My web app does lots of inserts that aren't read until a session is +complete. The plan is to put the heavy insert session onto a ramdisk based +pg-db and transfer the relevant data to the master pg-db upon session +completion. Currently running 7.4.6. + +Individual session data is not as critical as the master pg-db so the risk +associated with running the session pg-db on a ramdisk is acceptable. +All this is to get past the I/O bottleneck, already tweaked the config +files, run on multiple RAID-1 spindles, profiled the queries, maxed +the CPU/ram. Migrating to 64bit fedora soon. + +Thanks, this mailing list has been invaluable. + +Jelle + +From pgsql-performance-owner@postgresql.org Fri Mar 11 19:10:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 73021563E7 + for ; + Fri, 11 Mar 2005 19:10:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39460-05 + for ; + Fri, 11 Mar 2005 19:10:28 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id B7BFA55119 + for ; + Fri, 11 Mar 2005 19:10:27 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2BJARqu004476; + Fri, 11 Mar 2005 14:10:27 -0500 (EST) +To: "Lou O'Quin" +Cc: pgsql-performance@postgresql.org +Subject: Re: Query performance +In-reply-to: +References: +Comments: In-reply-to "Lou O'Quin" + message dated "Fri, 11 Mar 2005 11:47:54 -0700" +Date: Fri, 11 Mar 2005 14:10:27 -0500 +Message-ID: <4475.1110568227@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/192 +X-Sequence-Number: 10897 + +"Lou O'Quin" writes: +> it appears to actually be hypersensitive to the transport delay. The = +> ratios of time for the data transport (assuming 1 for the local server) = +> are: +> 1 : 2.43 : 7.71 + +> whereas the query execution time ratios are: +> 1 : 2.08 : 25.5 (!!!) + +How do you know that's what the data transport time is --- ie, how can +you measure that separately from the total query time? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 11 19:38:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AC4A35644B + for ; + Fri, 11 Mar 2005 19:38:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45702-10 + for ; + Fri, 11 Mar 2005 19:38:32 +0000 (GMT) +Received: from mesagate.talleyds.com (unknown [207.114.138.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F53754469 + for ; + Fri, 11 Mar 2005 19:38:30 +0000 (GMT) +Received: from TDS-MTA by mesagate.talleyds.com + with Novell_GroupWise; Fri, 11 Mar 2005 12:38:31 -0700 +Message-Id: +X-Mailer: Novell GroupWise Internet Agent 6.5.4 +Date: Fri, 11 Mar 2005 12:38:16 -0700 +From: "Lou O'Quin" +To: +Cc: +Subject: Re: Query performance +Mime-Version: 1.0 +Content-Type: multipart/alternative; boundary="=__Part50732EB8.0__=" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.281 tagged_above=0 required=5 tests=AWL, HTML_30_40, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200503/193 +X-Sequence-Number: 10898 + +--=__Part50732EB8.0__= +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: quoted-printable + +Hi Tom. I referenced the status line of pgAdmin. Per the pgAdmin help = +file: +=20 +"The status line will show how long the last query took to complete. If a = +dataset was returned, not only the elapsed time for server execution is = +displayed, but also the time to retrieve the data from the server to the = +Data Output page." +=20 +Lou + +>>> Tom Lane 3/11/2005 12:10 PM >>> + +"Lou O'Quin" writes: +> it appears to actually be hypersensitive to the transport delay. The =3D +> ratios of time for the data transport (assuming 1 for the local server) = +=3D +> are: +> 1 : 2.43 : 7.71 + +> whereas the query execution time ratios are: +> 1 : 2.08 : 25.5 (!!!) + +How do you know that's what the data transport time is --- ie, how can +you measure that separately from the total query time? + + regards, tom lane + + + +--=__Part50732EB8.0__= +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Description: HTML + + + + + +
Hi Tom.  I referenced the status line of pgAdmin.  Per = +the pgAdmin help file:
+
 
+
"The status line will show how long the last query took to complete. = +If a dataset was returned, not only the elapsed time for server execution = +is displayed, but also the time to retrieve the data from the server to = +the Data Output page."
+
 
+
Lou

>>> Tom Lane <tgl@sss.pgh.pa.us> 3/11/2005 = +12:10 PM >>>
+
"Lou O'Quin" <loquin@talleyds.com> = +writes:
> it appears to actually be hypersensitive to the transport = +delay. The =3D
> ratios of time for the data transport (assuming 1 = +for the local server) =3D
> are:
> 1 : 2.43 : 7.71

> = +whereas the query execution time ratios are:
> 1 : 2.08 : 25.5  = +(!!!)

How do you know that's what the data transport time is --- = +ie, how can
you measure that separately from the total query time?
            regards, tom = +lane
+ +--=__Part50732EB8.0__=-- + +From pgsql-performance-owner@postgresql.org Mon Mar 14 02:23:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8232D56560 + for ; + Fri, 11 Mar 2005 19:48:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49575-07 + for ; + Fri, 11 Mar 2005 19:48:22 +0000 (GMT) +Received: from mail2.m-cam.com (unknown [63.124.102.77]) + by svr1.postgresql.org (Postfix) with ESMTP id 559C15655B + for ; + Fri, 11 Mar 2005 19:48:21 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail2.m-cam.com (Postfix) with ESMTP + id 036953E8F7; Fri, 11 Mar 2005 14:53:11 -0500 (EST) +Received: from mail2.m-cam.com ([127.0.0.1]) + by localhost (mail2.m-cam.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 21177-06; Fri, 11 Mar 2005 14:52:54 -0500 (EST) +Received: from [192.168.1.21] (unknown [192.168.1.21]) + by mail2.m-cam.com (Postfix) with ESMTP + id 935C73E8F1; Fri, 11 Mar 2005 14:52:52 -0500 (EST) +Message-ID: <4231F5F2.6000509@m-cam.com> +Date: Fri, 11 Mar 2005 14:48:02 -0500 +From: Arshavir Grigorian +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: linux-raid@vger.kernel.org, pgsql-performance@postgresql.org +Subject: Postgres on RAID5 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at m-cam.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/239 +X-Sequence-Number: 10944 + +Hi, + +I have a RAID5 array (mdadm) with 14 disks + 1 spare. This partition has +an Ext3 filesystem which is used by Postgres. Currently we are loading a +50G database on this server from a Postgres dump (copy, not insert) and +are experiencing very slow write performance (35 records per second). + +Top shows that the Postgres process (postmaster) is being constantly put +into D state for extended periods of time (2-3 seconds) which I assume +is because it's waiting for disk io. I have just started gathering +system statistics and here is what sar -b shows: (this is while the db +is being loaded - pg_restore) + + tps rtps wtps bread/s bwrtn/s +01:35:01 PM 275.77 76.12 199.66 709.59 2315.23 +01:45:01 PM 287.25 75.56 211.69 706.52 2413.06 +01:55:01 PM 281.73 76.35 205.37 711.84 2389.86 +02:05:01 PM 282.83 76.14 206.69 720.85 2418.51 +02:15:01 PM 284.07 76.15 207.92 707.38 2443.60 +02:25:01 PM 265.46 75.91 189.55 708.87 2089.21 +02:35:01 PM 285.21 76.02 209.19 709.58 2446.46 +Average: 280.33 76.04 204.30 710.66 2359.47 + +This is a Sun e450 with dual TI UltraSparc II processors and 2G of RAM. +It is currently running Debian Sarge with a 2.4.27-sparc64-smp custom +compiled kernel. Postgres is installed from the Debian package and uses +all the configuration defaults. + +I am also copying the pgsql-performance list. + +Thanks in advance for any advice/pointers. + + +Arshavir + +Following is some other info that might be helpful. + +/proc/scsi# mdadm -D /dev/md1 +/dev/md1: + Version : 00.90.00 + Creation Time : Wed Feb 23 17:23:41 2005 + Raid Level : raid5 + Array Size : 123823616 (118.09 GiB 126.80 GB) + Device Size : 8844544 (8.43 GiB 9.06 GB) + Raid Devices : 15 + Total Devices : 17 +Preferred Minor : 1 + Persistence : Superblock is persistent + + Update Time : Thu Feb 24 10:05:38 2005 + State : active + Active Devices : 15 +Working Devices : 16 + Failed Devices : 1 + Spare Devices : 1 + + Layout : left-symmetric + Chunk Size : 64K + + UUID : 81ae2c97:06fa4f4d:87bfc6c9:2ee516df + Events : 0.8 + + Number Major Minor RaidDevice State + 0 8 64 0 active sync /dev/sde + 1 8 80 1 active sync /dev/sdf + 2 8 96 2 active sync /dev/sdg + 3 8 112 3 active sync /dev/sdh + 4 8 128 4 active sync /dev/sdi + 5 8 144 5 active sync /dev/sdj + 6 8 160 6 active sync /dev/sdk + 7 8 176 7 active sync /dev/sdl + 8 8 192 8 active sync /dev/sdm + 9 8 208 9 active sync /dev/sdn + 10 8 224 10 active sync /dev/sdo + 11 8 240 11 active sync /dev/sdp + 12 65 0 12 active sync /dev/sdq + 13 65 16 13 active sync /dev/sdr + 14 65 32 14 active sync /dev/sds + + 15 65 48 15 spare /dev/sdt + +# dumpe2fs -h /dev/md1 +dumpe2fs 1.35 (28-Feb-2004) +Filesystem volume name: +Last mounted on: +Filesystem UUID: 1bb95bd6-94c7-4344-adf2-8414cadae6fc +Filesystem magic number: 0xEF53 +Filesystem revision #: 1 (dynamic) +Filesystem features: has_journal dir_index needs_recovery large_file +Default mount options: (none) +Filesystem state: clean +Errors behavior: Continue +Filesystem OS type: Linux +Inode count: 15482880 +Block count: 30955904 +Reserved block count: 1547795 +Free blocks: 28767226 +Free inodes: 15482502 +First block: 0 +Block size: 4096 +Fragment size: 4096 +Blocks per group: 32768 +Fragments per group: 32768 +Inodes per group: 16384 +Inode blocks per group: 512 +Filesystem created: Wed Feb 23 17:27:13 2005 +Last mount time: Wed Feb 23 17:45:25 2005 +Last write time: Wed Feb 23 17:45:25 2005 +Mount count: 2 +Maximum mount count: 28 +Last checked: Wed Feb 23 17:27:13 2005 +Check interval: 15552000 (6 months) +Next check after: Mon Aug 22 18:27:13 2005 +Reserved blocks uid: 0 (user root) +Reserved blocks gid: 0 (group root) +First inode: 11 +Inode size: 128 +Journal inode: 8 +Default directory hash: tea +Directory Hash Seed: c35c0226-3b52-4dad-b102-f22feb773592 +Journal backup: inode blocks + +# lspci | grep SCSI +0000:00:03.0 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +(rev 14) +0000:00:03.1 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +(rev 14) +0000:00:04.0 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +(rev 14) +0000:00:04.1 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +(rev 14) +0000:04:02.0 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +(rev 03) +0000:04:03.0 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +(rev 03) + +/proc/scsi# more scsi +Attached devices: +Host: scsi0 Channel: 00 Id: 00 Lun: 00 + Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi0 Channel: 00 Id: 01 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi0 Channel: 00 Id: 02 Lun: 00 + Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi0 Channel: 00 Id: 03 Lun: 00 + Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi1 Channel: 00 Id: 00 Lun: 00 + Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi1 Channel: 00 Id: 01 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi1 Channel: 00 Id: 02 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi1 Channel: 00 Id: 03 Lun: 00 + Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi2 Channel: 00 Id: 00 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi2 Channel: 00 Id: 01 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi2 Channel: 00 Id: 02 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi2 Channel: 00 Id: 03 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi3 Channel: 00 Id: 00 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi3 Channel: 00 Id: 01 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi3 Channel: 00 Id: 02 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi3 Channel: 00 Id: 03 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi4 Channel: 00 Id: 06 Lun: 00 + Vendor: TOSHIBA Model: XM6201TASUN32XCD Rev: 1103 + Type: CD-ROM ANSI SCSI revision: 02 +Host: scsi5 Channel: 00 Id: 00 Lun: 00 + Vendor: FUJITSU Model: MAG3091L SUN9.0G Rev: 1111 + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi5 Channel: 00 Id: 01 Lun: 00 + Vendor: FUJITSU Model: MAG3091L SUN9.0G Rev: 1111 + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi5 Channel: 00 Id: 02 Lun: 00 + Vendor: FUJITSU Model: MAG3091L SUN9.0G Rev: 1111 + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi5 Channel: 00 Id: 03 Lun: 00 + Vendor: FUJITSU Model: MAG3091L SUN9.0G Rev: 1111 + Type: Direct-Access ANSI SCSI revision: 02 + + + + + + +-- +Arshavir Grigorian +Systems Administrator/Engineer + +From pgsql-performance-owner@postgresql.org Fri Mar 11 20:21:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ABAF7565E1 + for ; + Fri, 11 Mar 2005 20:21:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58703-08 + for ; + Fri, 11 Mar 2005 20:21:12 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id CA160565AC + for ; + Fri, 11 Mar 2005 20:21:11 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2BKLCav004961; + Fri, 11 Mar 2005 15:21:12 -0500 (EST) +To: "Lou O'Quin" +Cc: pgsql-performance@postgresql.org +Subject: Re: Query performance +In-reply-to: +References: +Comments: In-reply-to "Lou O'Quin" + message dated "Fri, 11 Mar 2005 12:38:16 -0700" +Date: Fri, 11 Mar 2005 15:21:12 -0500 +Message-ID: <4960.1110572472@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/195 +X-Sequence-Number: 10900 + +"Lou O'Quin" writes: +> Hi Tom. I referenced the status line of pgAdmin. Per the pgAdmin help +> file: +> +> "The status line will show how long the last query took to complete. If a +> dataset was returned, not only the elapsed time for server execution is +> displayed, but also the time to retrieve the data from the server to the +> Data Output page." + +Well, you should probably ask the pgadmin boys exactly what they are +measuring. In any case, the Postgres server overlaps query execution +with result sending, so I don't think it's possible to get a pure +measurement of just one of those costs --- certainly not by looking at +it only from the client end. + +BTW, one factor to consider is that if the test client machines weren't +all the same speed, that would have some impact on their ability to +absorb 15K records ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 11 20:33:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F84756607 + for ; + Fri, 11 Mar 2005 20:33:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62515-04 + for ; + Fri, 11 Mar 2005 20:33:44 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 7AAA4565E6 + for ; + Fri, 11 Mar 2005 20:33:44 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2BKXg5s005056; + Fri, 11 Mar 2005 15:33:42 -0500 (EST) +To: jellej@pacbell.net +Cc: pgsql-performance@postgresql.org +Subject: Re: Questions about 2 databases. +In-reply-to: +References: + <6.2.0.14.0.20050311155221.041aa528@pop.interactivemediafactory.net> + +Comments: In-reply-to jelle + message dated "Fri, 11 Mar 2005 10:54:30 -0800" +Date: Fri, 11 Mar 2005 15:33:42 -0500 +Message-ID: <5055.1110573222@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/196 +X-Sequence-Number: 10901 + +jelle writes: +> 1) on a single 7.4.6 postgres instance does each database have it own WAL +> file or is that shared? Is it the same on 8.0.x? + +Shared. + +> 2) what's the high performance way of moving 200 rows between similar +> tables on different databases? Does it matter if the databases are +> on the same or seperate postgres instances? + +COPY would be my recommendation. For a no-programming-effort solution +you could just pipe the output of pg_dump --data-only -t mytable +into psql. Not sure if it's worth developing a custom application to +replace that. + +> My web app does lots of inserts that aren't read until a session is +> complete. The plan is to put the heavy insert session onto a ramdisk based +> pg-db and transfer the relevant data to the master pg-db upon session +> completion. Currently running 7.4.6. + +Unless you have a large proportion of sessions that are abandoned and +hence never need be transferred to the main database at all, this seems +like a dead waste of effort :-(. The work to put the data into the main +database isn't lessened at all; you've just added extra work to manage +the buffer database. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 11 20:35:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E31056616 + for ; + Fri, 11 Mar 2005 20:35:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63693-04 + for ; + Fri, 11 Mar 2005 20:35:22 +0000 (GMT) +Received: from mesagate.talleyds.com (unknown [207.114.138.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 460A85661A + for ; + Fri, 11 Mar 2005 20:35:20 +0000 (GMT) +Received: from TDS-MTA by mesagate.talleyds.com + with Novell_GroupWise; Fri, 11 Mar 2005 13:35:22 -0700 +Message-Id: +X-Mailer: Novell GroupWise Internet Agent 6.5.4 +Date: Fri, 11 Mar 2005 13:35:03 -0700 +From: "Lou O'Quin" +To: +Cc: +Subject: Re: Query performance +Mime-Version: 1.0 +Content-Type: multipart/alternative; boundary="=__PartFFDC82E7.0__=" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.384 tagged_above=0 required=5 tests=AWL, HTML_20_30, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200503/197 +X-Sequence-Number: 10902 + +--=__PartFFDC82E7.0__= +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: quoted-printable + +I'll post there concerning how they determine the query execution time vs. = +data retrieval time. +=20 +I did think about the processor/memory when choosing the machines - all = +three of the processors are similar. All are Pentium P4s with 512 MB = +memory. +the server is Win2K, P4, 2.3 gHz +the local network client is a WinXP Pro, P4, 2.2 gHz +the remote network client is WinXP Pro, P4, 1.9 gHz +=20 +Lou + +>>> Tom Lane 3/11/2005 1:21 PM >>> + +"Lou O'Quin" writes: +> Hi Tom. I referenced the status line of pgAdmin. Per the pgAdmin help +> file: +> +> "The status line will show how long the last query took to complete. If = +a +> dataset was returned, not only the elapsed time for server execution is +> displayed, but also the time to retrieve the data from the server to the +> Data Output page." + +Well, you should probably ask the pgadmin boys exactly what they are +measuring. In any case, the Postgres server overlaps query execution +with result sending, so I don't think it's possible to get a pure +measurement of just one of those costs --- certainly not by looking at +it only from the client end. + +BTW, one factor to consider is that if the test client machines weren't +all the same speed, that would have some impact on their ability to +absorb 15K records ... + + regards, tom lane + +---------------------------(end of broadcast)--------------------------- +TIP 9: the planner will ignore your desire to choose an index scan if your + joining column's datatypes do not match + + + +--=__PartFFDC82E7.0__= +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Description: HTML + + + + + +
I'll post there concerning how they determine the query execution = +time vs. data retrieval time.
+
 
+
I did think about the processor/memory when choosing the machines - = +all three of the processors are similar.  All are Pentium P4s with = +512 MB memory.
+
the server is Win2K, P4, 2.3 gHz
+
the local network client  is a WinXP Pro, P4, 2.2 gHz
the = +remote network client is WinXP Pro, P4, 1.9 gHz
+
 
+
Lou
+

>>> Tom Lane <tgl@sss.pgh.pa.us> 3/11/2005 1:21 PM = +>>>
+
"Lou O'Quin" <loquin@talleyds.com> = +writes:
> Hi Tom.  I referenced the status line of pgAdmin. = +; Per the pgAdmin help
> file:
>
> "The status line will = +show how long the last query took to complete. If a
> dataset was = +returned, not only the elapsed time for server execution is
> = +displayed, but also the time to retrieve the data from the server to = +the
> Data Output page."

Well, you should probably ask the = +pgadmin boys exactly what they are
measuring.  In any case, the = +Postgres server overlaps query execution
with result sending, so I = +don't think it's possible to get a pure
measurement of just one of = +those costs --- certainly not by looking at
it only from the client = +end.

BTW, one factor to consider is that if the test client = +machines weren't
all the same speed, that would have some impact on = +their ability to
absorb 15K records ...

    = +        regards, tom lane

------------= +---------------(end of broadcast)---------------------------
TIP 9: the = +planner will ignore your desire to choose an index scan if your
 &n= +bsp;    joining column's datatypes do not match
+ +--=__PartFFDC82E7.0__=-- + +From pgsql-performance-owner@postgresql.org Fri Mar 11 20:53:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C1CC56607; + Fri, 11 Mar 2005 20:53:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69182-01; Fri, 11 Mar 2005 20:52:55 +0000 (GMT) +Received: from dfw-gate4.raytheon.com (dfw-gate4.raytheon.com + [199.46.199.233]) + by svr1.postgresql.org (Postfix) with ESMTP id B8F4156609; + Fri, 11 Mar 2005 20:52:53 +0000 (GMT) +Received: from ds02c00.directory.ray.com (ds02c00.directory.ray.com + [147.25.138.118]) + by dfw-gate4.raytheon.com (8.12.10/8.12.10) with ESMTP id + j2BKpKoH010713; Fri, 11 Mar 2005 14:51:25 -0600 (CST) +Received: from ds02c00 (localhost [127.0.0.1]) + by ds02c00.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id + j2BKpF1D014184; Fri, 11 Mar 2005 20:51:15 GMT +Received: from ds02c00.directory.ray.com with LMTP by ds02c00 + (2.0.6/sieved-2-0-build-559); Fri, 11 Mar 2005 20:51:14 +0000 +Received: from notesserver5.ftw.us.ray.com (notesserver5.ftw.us.ray.com + [151.168.145.35]) + by ds02c00.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id + j2BKp8W9014134 sender Richard_D_Levine@raytheon.com; + Fri, 11 Mar 2005 20:51:09 GMT +Subject: Re: Questions about 2 databases. +To: Tom Lane +Cc: jellej@pacbell.net, pgsql-performance@postgresql.org, + pgsql-performance-owner@postgresql.org +X-Mailer: Lotus Notes Release 5.0.8 June 18, 2001 +Message-ID: +From: Richard_D_Levine@raytheon.com +Date: Fri, 11 Mar 2005 15:51:07 -0500 +X-MIMETrack: Serialize by Router on NotesServer5/HDC(Release 6.5.2|June 01, + 2004) at 03/11/2005 03:51:09 PM +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +X-SPAM: 0.00 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.214 tagged_above=0 required=5 tests=AWL, + NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200503/198 +X-Sequence-Number: 10903 + +> this seems +> like a dead waste of effort :-(. The work to put the data into the main +> database isn't lessened at all; you've just added extra work to manage +> the buffer database. + +True from the view point of the server, but not from the throughput in the +client session (client viewpoint). The client will have a blazingly fast +session with the buffer database. I'm assuming the buffer database table +size is zero or very small. Constraints will be a problem if there are +PKs, FKs that need satisfied on the server that are not adequately testable +in the buffer. Might not be a problem if the full table fits on the RAM +disk, but you still have to worry about two clients inserting the same PK. + +Rick + + + + Tom Lane + To: jellej@pacbell.net + Sent by: cc: pgsql-performance@postgresql.org + pgsql-performance-owner@pos Subject: Re: [PERFORM] Questions about 2 databases. + tgresql.org + + + 03/11/2005 03:33 PM + + + + + + +jelle writes: +> 1) on a single 7.4.6 postgres instance does each database have it own WAL +> file or is that shared? Is it the same on 8.0.x? + +Shared. + +> 2) what's the high performance way of moving 200 rows between similar +> tables on different databases? Does it matter if the databases are +> on the same or seperate postgres instances? + +COPY would be my recommendation. For a no-programming-effort solution +you could just pipe the output of pg_dump --data-only -t mytable +into psql. Not sure if it's worth developing a custom application to +replace that. + +> My web app does lots of inserts that aren't read until a session is +> complete. The plan is to put the heavy insert session onto a ramdisk +based +> pg-db and transfer the relevant data to the master pg-db upon session +> completion. Currently running 7.4.6. + +Unless you have a large proportion of sessions that are abandoned and +hence never need be transferred to the main database at all, this seems +like a dead waste of effort :-(. The work to put the data into the main +database isn't lessened at all; you've just added extra work to manage +the buffer database. + + regards, tom lane + +---------------------------(end of broadcast)--------------------------- +TIP 9: the planner will ignore your desire to choose an index scan if your + joining column's datatypes do not match + + + + +From pgsql-performance-owner@postgresql.org Fri Mar 11 21:13:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4CA5E5636A + for ; + Fri, 11 Mar 2005 21:13:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71966-06 + for ; + Fri, 11 Mar 2005 21:13:16 +0000 (GMT) +Received: from mail2.m-cam.com (unknown [63.124.102.77]) + by svr1.postgresql.org (Postfix) with ESMTP id 2FA995586A + for ; + Fri, 11 Mar 2005 21:13:15 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail2.m-cam.com (Postfix) with ESMTP id B52F03E8F7 + for ; + Fri, 11 Mar 2005 16:18:05 -0500 (EST) +Received: from mail2.m-cam.com ([127.0.0.1]) + by localhost (mail2.m-cam.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 21258-07 for ; + Fri, 11 Mar 2005 16:17:56 -0500 (EST) +Received: from [192.168.1.21] (unknown [192.168.1.21]) + by mail2.m-cam.com (Postfix) with ESMTP id 383EA3E8F1 + for ; + Fri, 11 Mar 2005 16:17:56 -0500 (EST) +Message-ID: <423209E1.6090200@m-cam.com> +Date: Fri, 11 Mar 2005 16:13:05 -0500 +From: Arshavir Grigorian +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Postgres on RAID5 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at m-cam.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/199 +X-Sequence-Number: 10904 + +Hi, + +I have a RAID5 array (mdadm) with 14 disks + 1 spare. This partition has +an Ext3 filesystem which is used by Postgres. Currently we are loading a +50G database on this server from a Postgres dump (copy, not insert) and +are experiencing very slow write performance (35 records per second). + +Top shows that the Postgres process (postmaster) is being constantly put +into D state for extended periods of time (2-3 seconds) which I assume +is because it's waiting for disk io. I have just started gathering +system statistics and here is what sar -b shows: (this is while the db +is being loaded - pg_restore) + + tps rtps wtps bread/s bwrtn/s +01:35:01 PM 275.77 76.12 199.66 709.59 2315.23 +01:45:01 PM 287.25 75.56 211.69 706.52 2413.06 +01:55:01 PM 281.73 76.35 205.37 711.84 2389.86 +02:05:01 PM 282.83 76.14 206.69 720.85 2418.51 +02:15:01 PM 284.07 76.15 207.92 707.38 2443.60 +02:25:01 PM 265.46 75.91 189.55 708.87 2089.21 +02:35:01 PM 285.21 76.02 209.19 709.58 2446.46 +Average: 280.33 76.04 204.30 710.66 2359.47 + +This is a Sun e450 with dual TI UltraSparc II processors and 2G of RAM. +It is currently running Debian Sarge with a 2.4.27-sparc64-smp custom +compiled kernel. Postgres is installed from the Debian package and uses +all the configuration defaults. + +I am also copying the pgsql-performance list. + +Thanks in advance for any advice/pointers. + + +Arshavir + +Following is some other info that might be helpful. + +/proc/scsi# mdadm -D /dev/md1 +/dev/md1: + Version : 00.90.00 + Creation Time : Wed Feb 23 17:23:41 2005 + Raid Level : raid5 + Array Size : 123823616 (118.09 GiB 126.80 GB) + Device Size : 8844544 (8.43 GiB 9.06 GB) + Raid Devices : 15 + Total Devices : 17 +Preferred Minor : 1 + Persistence : Superblock is persistent + + Update Time : Thu Feb 24 10:05:38 2005 + State : active + Active Devices : 15 +Working Devices : 16 + Failed Devices : 1 + Spare Devices : 1 + + Layout : left-symmetric + Chunk Size : 64K + + UUID : 81ae2c97:06fa4f4d:87bfc6c9:2ee516df + Events : 0.8 + + Number Major Minor RaidDevice State + 0 8 64 0 active sync /dev/sde + 1 8 80 1 active sync /dev/sdf + 2 8 96 2 active sync /dev/sdg + 3 8 112 3 active sync /dev/sdh + 4 8 128 4 active sync /dev/sdi + 5 8 144 5 active sync /dev/sdj + 6 8 160 6 active sync /dev/sdk + 7 8 176 7 active sync /dev/sdl + 8 8 192 8 active sync /dev/sdm + 9 8 208 9 active sync /dev/sdn + 10 8 224 10 active sync /dev/sdo + 11 8 240 11 active sync /dev/sdp + 12 65 0 12 active sync /dev/sdq + 13 65 16 13 active sync /dev/sdr + 14 65 32 14 active sync /dev/sds + + 15 65 48 15 spare /dev/sdt + +# dumpe2fs -h /dev/md1 +dumpe2fs 1.35 (28-Feb-2004) +Filesystem volume name: +Last mounted on: +Filesystem UUID: 1bb95bd6-94c7-4344-adf2-8414cadae6fc +Filesystem magic number: 0xEF53 +Filesystem revision #: 1 (dynamic) +Filesystem features: has_journal dir_index needs_recovery large_file +Default mount options: (none) +Filesystem state: clean +Errors behavior: Continue +Filesystem OS type: Linux +Inode count: 15482880 +Block count: 30955904 +Reserved block count: 1547795 +Free blocks: 28767226 +Free inodes: 15482502 +First block: 0 +Block size: 4096 +Fragment size: 4096 +Blocks per group: 32768 +Fragments per group: 32768 +Inodes per group: 16384 +Inode blocks per group: 512 +Filesystem created: Wed Feb 23 17:27:13 2005 +Last mount time: Wed Feb 23 17:45:25 2005 +Last write time: Wed Feb 23 17:45:25 2005 +Mount count: 2 +Maximum mount count: 28 +Last checked: Wed Feb 23 17:27:13 2005 +Check interval: 15552000 (6 months) +Next check after: Mon Aug 22 18:27:13 2005 +Reserved blocks uid: 0 (user root) +Reserved blocks gid: 0 (group root) +First inode: 11 +Inode size: 128 +Journal inode: 8 +Default directory hash: tea +Directory Hash Seed: c35c0226-3b52-4dad-b102-f22feb773592 +Journal backup: inode blocks + +# lspci | grep SCSI +0000:00:03.0 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +(rev 14) +0000:00:03.1 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +(rev 14) +0000:00:04.0 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +(rev 14) +0000:00:04.1 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +(rev 14) +0000:04:02.0 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +(rev 03) +0000:04:03.0 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +(rev 03) + +/proc/scsi# more scsi +Attached devices: +Host: scsi0 Channel: 00 Id: 00 Lun: 00 + Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi0 Channel: 00 Id: 01 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi0 Channel: 00 Id: 02 Lun: 00 + Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi0 Channel: 00 Id: 03 Lun: 00 + Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi1 Channel: 00 Id: 00 Lun: 00 + Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi1 Channel: 00 Id: 01 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi1 Channel: 00 Id: 02 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi1 Channel: 00 Id: 03 Lun: 00 + Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi2 Channel: 00 Id: 00 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi2 Channel: 00 Id: 01 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi2 Channel: 00 Id: 02 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi2 Channel: 00 Id: 03 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi3 Channel: 00 Id: 00 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi3 Channel: 00 Id: 01 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi3 Channel: 00 Id: 02 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi3 Channel: 00 Id: 03 Lun: 00 + Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 + Type: Direct-Access ANSI SCSI revision: 03 +Host: scsi4 Channel: 00 Id: 06 Lun: 00 + Vendor: TOSHIBA Model: XM6201TASUN32XCD Rev: 1103 + Type: CD-ROM ANSI SCSI revision: 02 +Host: scsi5 Channel: 00 Id: 00 Lun: 00 + Vendor: FUJITSU Model: MAG3091L SUN9.0G Rev: 1111 + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi5 Channel: 00 Id: 01 Lun: 00 + Vendor: FUJITSU Model: MAG3091L SUN9.0G Rev: 1111 + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi5 Channel: 00 Id: 02 Lun: 00 + Vendor: FUJITSU Model: MAG3091L SUN9.0G Rev: 1111 + Type: Direct-Access ANSI SCSI revision: 02 +Host: scsi5 Channel: 00 Id: 03 Lun: 00 + Vendor: FUJITSU Model: MAG3091L SUN9.0G Rev: 1111 + Type: Direct-Access ANSI SCSI revision: 02 + + + + + + +-- +Arshavir Grigorian +Systems Administrator/Engineer + + +From pgsql-performance-owner@postgresql.org Fri Mar 11 21:47:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37B7E56719 + for ; + Fri, 11 Mar 2005 21:47:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81812-08 + for ; + Fri, 11 Mar 2005 21:47:49 +0000 (GMT) +Received: from smtp803.mail.sc5.yahoo.com (smtp803.mail.sc5.yahoo.com + [66.163.168.182]) + by svr1.postgresql.org (Postfix) with SMTP id C33E956715 + for ; + Fri, 11 Mar 2005 21:47:47 +0000 (GMT) +Received: from unknown (HELO treebeard) (jellej@pacbell.net@67.116.141.103 + with login) + by smtp803.mail.sc5.yahoo.com with SMTP; 11 Mar 2005 21:42:36 -0000 +Date: Fri, 11 Mar 2005 13:43:00 -0800 (PST) +From: jelle +X-X-Sender: jelle@localhost.localdomain +Reply-To: jellej@pacbell.net +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Questions about 2 databases. +In-Reply-To: <5055.1110573222@sss.pgh.pa.us> +Message-ID: +References: + <6.2.0.14.0.20050311155221.041aa528@pop.interactivemediafactory.net> + + <5055.1110573222@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.312 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST +X-Spam-Level: * +X-Archive-Number: 200503/200 +X-Sequence-Number: 10905 + +On Fri, 11 Mar 2005, Tom Lane wrote: + +[ snip ] + +> COPY would be my recommendation. For a no-programming-effort solution +> you could just pipe the output of pg_dump --data-only -t mytable +> into psql. Not sure if it's worth developing a custom application to +> replace that. + +I'm a programming-effort kind of guy so I'll try COPY. + +> +>> My web app does lots of inserts that aren't read until a session is +>> complete. The plan is to put the heavy insert session onto a ramdisk based +>> pg-db and transfer the relevant data to the master pg-db upon session +>> completion. Currently running 7.4.6. +> +> Unless you have a large proportion of sessions that are abandoned and +> hence never need be transferred to the main database at all, this seems +> like a dead waste of effort :-(. The work to put the data into the main +> database isn't lessened at all; you've just added extra work to manage +> the buffer database. + +The insert heavy sessions average 175 page hits generating XML, 1000 +insert/updates which comprise 90% of the insert/update load, of which 200 +inserts need to be transferred to the master db. The other sessions are +read/cache bound. I hoping to get a speed-up from moving the temporary +stuff off the master db and using 1 transaction instead of 175 to the disk +based master db. + +Thanks, +Jelle + +From pgsql-performance-owner@postgresql.org Fri Mar 11 22:07:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3FB5253D6E + for ; + Fri, 11 Mar 2005 22:07:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86854-10 + for ; + Fri, 11 Mar 2005 22:07:34 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5765852AA6 + for ; + Fri, 11 Mar 2005 22:07:33 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2BM7Z1A005670; + Fri, 11 Mar 2005 17:07:35 -0500 (EST) +To: Arshavir Grigorian +Cc: pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +In-reply-to: <423209E1.6090200@m-cam.com> +References: <423209E1.6090200@m-cam.com> +Comments: In-reply-to Arshavir Grigorian + message dated "Fri, 11 Mar 2005 16:13:05 -0500" +Date: Fri, 11 Mar 2005 17:07:35 -0500 +Message-ID: <5669.1110578855@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/201 +X-Sequence-Number: 10906 + +Arshavir Grigorian writes: +> I have a RAID5 array (mdadm) with 14 disks + 1 spare. This partition has +> an Ext3 filesystem which is used by Postgres. Currently we are loading a +> 50G database on this server from a Postgres dump (copy, not insert) and +> are experiencing very slow write performance (35 records per second). + +What PG version is this? What version of pg_dump made the dump file? +How are you measuring that write rate (seeing that pg_restore doesn't +provide any such info)? + +> Postgres is installed from the Debian package and uses +> all the configuration defaults. + +The defaults are made for a fairly small machine, not big iron. At a +minimum you want to kick shared_buffers up to 10K or more. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 11 22:29:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1283656530 + for ; + Fri, 11 Mar 2005 22:29:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94027-03 + for ; + Fri, 11 Mar 2005 22:29:17 +0000 (GMT) +Received: from mail2.m-cam.com (unknown [63.124.102.77]) + by svr1.postgresql.org (Postfix) with ESMTP id 86F185644B + for ; + Fri, 11 Mar 2005 22:29:16 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail2.m-cam.com (Postfix) with ESMTP + id 81E443E8F7; Fri, 11 Mar 2005 17:34:08 -0500 (EST) +Received: from mail2.m-cam.com ([127.0.0.1]) + by localhost (mail2.m-cam.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 21471-06; Fri, 11 Mar 2005 17:34:04 -0500 (EST) +Received: from [192.168.1.21] (unknown [192.168.1.21]) + by mail2.m-cam.com (Postfix) with ESMTP + id 06C9A3E8F1; Fri, 11 Mar 2005 17:34:03 -0500 (EST) +Message-ID: <42321BB7.9030808@m-cam.com> +Date: Fri, 11 Mar 2005 17:29:11 -0500 +From: Arshavir Grigorian +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +References: <423209E1.6090200@m-cam.com> <5669.1110578855@sss.pgh.pa.us> +In-Reply-To: <5669.1110578855@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at m-cam.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/202 +X-Sequence-Number: 10907 + +Tom Lane wrote: +> Arshavir Grigorian writes: +> +>>I have a RAID5 array (mdadm) with 14 disks + 1 spare. This partition has +>>an Ext3 filesystem which is used by Postgres. Currently we are loading a +>>50G database on this server from a Postgres dump (copy, not insert) and +>>are experiencing very slow write performance (35 records per second). +> +> +> What PG version is this? What version of pg_dump made the dump file? +> How are you measuring that write rate (seeing that pg_restore doesn't +> provide any such info)? + +Sorry I missed the version. Both (the db from which the dump was created +and the one it's being loaded on) run on Pg 7.4. + +Well, if the restore is going on for X number of hours and you have Y +records loaded, it's not hard to ballpark. + +> +> +>>Postgres is installed from the Debian package and uses +>>all the configuration defaults. +> +> +> The defaults are made for a fairly small machine, not big iron. At a +> minimum you want to kick shared_buffers up to 10K or more. +> +> regards, tom lane +Will do. Thanks. + + +Arshavir + + +From pgsql-performance-owner@postgresql.org Fri Mar 11 22:36:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4EAD152D8A + for ; + Fri, 11 Mar 2005 22:36:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94994-04 + for ; + Fri, 11 Mar 2005 22:36:56 +0000 (GMT) +Received: from sunsite.dcc.uchile.cl (sunsite.dcc.uchile.cl [192.80.24.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B55415640D + for ; + Fri, 11 Mar 2005 22:36:52 +0000 (GMT) +Received: from anakena.dcc.uchile.cl (anakena [192.80.24.6]) + by sunsite.dcc.uchile.cl (8.12.11/8.12.11) with ESMTP id j2BMaluh020551; + Fri, 11 Mar 2005 19:36:47 -0300 (CLST) +Received: by anakena.dcc.uchile.cl (Postfix, from userid 4151) + id 02E6C5251F; Fri, 11 Mar 2005 19:36:46 -0300 (CLST) +Date: Fri, 11 Mar 2005 19:36:46 -0300 +From: Alvaro Herrera +To: Arshavir Grigorian +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +Message-ID: <20050311223646.GA18059@dcc.uchile.cl> +References: <423209E1.6090200@m-cam.com> <5669.1110578855@sss.pgh.pa.us> + <42321BB7.9030808@m-cam.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <42321BB7.9030808@m-cam.com> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.351 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/203 +X-Sequence-Number: 10908 + +On Fri, Mar 11, 2005 at 05:29:11PM -0500, Arshavir Grigorian wrote: +> Tom Lane wrote: + +> >The defaults are made for a fairly small machine, not big iron. At a +> >minimum you want to kick shared_buffers up to 10K or more. +> > +> Will do. Thanks. + +Also, it may help that you bump up sort_mem while doing [the CREATE +INDEX part of] the restore. + +-- +Alvaro Herrera () +"We are who we choose to be", sang the goldfinch +when the sun is high (Sandman) + +From pgsql-performance-owner@postgresql.org Fri Mar 11 22:37:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6847656590 + for ; + Fri, 11 Mar 2005 22:37:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95624-02 + for ; + Fri, 11 Mar 2005 22:37:10 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C0A7856595 + for ; + Fri, 11 Mar 2005 22:37:09 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2BMbACK005898; + Fri, 11 Mar 2005 17:37:10 -0500 (EST) +To: Arshavir Grigorian +Cc: pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +In-reply-to: <42321BB7.9030808@m-cam.com> +References: <423209E1.6090200@m-cam.com> <5669.1110578855@sss.pgh.pa.us> + <42321BB7.9030808@m-cam.com> +Comments: In-reply-to Arshavir Grigorian + message dated "Fri, 11 Mar 2005 17:29:11 -0500" +Date: Fri, 11 Mar 2005 17:37:10 -0500 +Message-ID: <5897.1110580630@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/204 +X-Sequence-Number: 10909 + +Arshavir Grigorian writes: +> Tom Lane wrote: +>> How are you measuring that write rate (seeing that pg_restore doesn't +>> provide any such info)? + +> Well, if the restore is going on for X number of hours and you have Y +> records loaded, it's not hard to ballpark. + +Yeah, but how do you know that you have Y records loaded? + +What I'm trying to get at is what the restore is actually spending its +time on. It seems unlikely that a COPY per se would run that slowly; +far more likely that the expense is involved with index construction +or foreign key verification. You could possibly determine what's what +by watching the backend process with "ps" to see what statement type +it's executing most of the time. + +BTW, is this a full database restore (schema + data), or are you trying +to load data into pre-existing tables? The latter is generally a whole +lot slower because both index updates and foreign key checks have to be +done retail instead of wholesale. There are various ways of working +around that but you have to be aware of what you're doing. + +Also, if it is indexing that's eating the time, boosting the sort_mem +setting for the server would help a lot. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Mar 12 00:23:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E9779563DE + for ; + Sat, 12 Mar 2005 00:23:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20281-04 + for ; + Sat, 12 Mar 2005 00:23:01 +0000 (GMT) +Received: from mail2.m-cam.com (unknown [63.124.102.77]) + by svr1.postgresql.org (Postfix) with ESMTP id BBF64563B3 + for ; + Sat, 12 Mar 2005 00:23:00 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail2.m-cam.com (Postfix) with ESMTP id 351E33E8F7 + for ; + Fri, 11 Mar 2005 19:27:53 -0500 (EST) +Received: from mail2.m-cam.com ([127.0.0.1]) + by localhost (mail2.m-cam.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 21571-08 for ; + Fri, 11 Mar 2005 19:27:50 -0500 (EST) +Received: from [192.168.1.21] (unknown [192.168.1.21]) + by mail2.m-cam.com (Postfix) with ESMTP id 070753E8F2 + for ; + Fri, 11 Mar 2005 19:27:49 -0500 (EST) +Message-ID: <42323660.6090002@m-cam.com> +Date: Fri, 11 Mar 2005 19:22:56 -0500 +From: Arshavir Grigorian +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +References: <423209E1.6090200@m-cam.com> +In-Reply-To: <423209E1.6090200@m-cam.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at m-cam.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/205 +X-Sequence-Number: 10910 + +Many thanks for all the response. + +I guess there are a lot of things to change and tweak and I wonder what +would be a good benchmarking sample dataset (size, contents). + +My tables are very large (the smallest is 7+ mil records) and take +several days to load (if not weeks). It would be nice to have a sample +dataset that would be large enough to mimic my large datasets, but small +enough to load in a short priod of time. Any suggestions? + + +Arshavir + +From pgsql-performance-owner@postgresql.org Sat Mar 12 01:27:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6ABCE5655B + for ; + Sat, 12 Mar 2005 01:27:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33332-08 + for ; + Sat, 12 Mar 2005 01:27:45 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id A38F956484 + for ; + Sat, 12 Mar 2005 01:27:45 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7118538; Fri, 11 Mar 2005 17:29:38 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Arshavir Grigorian +Subject: Re: Postgres on RAID5 +Date: Fri, 11 Mar 2005 17:32:10 -0800 +User-Agent: KMail/1.7.1 +Cc: pgsql-performance@postgresql.org +References: <423209E1.6090200@m-cam.com> +In-Reply-To: <423209E1.6090200@m-cam.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200503111732.10213.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.051 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/206 +X-Sequence-Number: 10911 + +A, + +> This is a Sun e450 with dual TI UltraSparc II processors and 2G of RAM. +> It is currently running Debian Sarge with a 2.4.27-sparc64-smp custom +> compiled kernel. Postgres is installed from the Debian package and uses +> all the configuration defaults. + +Please read http://www.powerpostgresql.com/PerfList + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sat Mar 12 02:47:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A628565E7 + for ; + Sat, 12 Mar 2005 02:47:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52585-02 + for ; + Sat, 12 Mar 2005 02:47:10 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 211485659E + for ; + Sat, 12 Mar 2005 02:47:09 +0000 (GMT) +Received: (qmail 12092 invoked from network); 12 Mar 2005 03:47:14 +0100 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 12 Mar 2005 03:47:14 +0100 +To: jellej@pacbell.net, pgsql-performance@postgresql.org +Subject: Re: Questions about 2 databases. +References: + <6.2.0.14.0.20050311155221.041aa528@pop.interactivemediafactory.net> + +Message-ID: +Date: Sat, 12 Mar 2005 03:15:21 +0100 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: +User-Agent: Opera M2/7.54 (Linux, build 955) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/207 +X-Sequence-Number: 10912 + + + +> My web app does lots of inserts that aren't read until a session is +> complete. The plan is to put the heavy insert session onto a ramdisk +> based pg-db and transfer the relevant data to the master pg-db upon +> session completion. Currently running 7.4.6. + + From what you say I'd think you want to avoid making one write +transaction to the main database on each page view, right ? + You could simply store the data in a file, and at the end of the session, +read the file and do all the writes in one transaction. + +From pgsql-performance-owner@postgresql.org Sat Mar 12 02:52:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C5295651C + for ; + Sat, 12 Mar 2005 02:52:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53545-07 + for ; + Sat, 12 Mar 2005 02:52:06 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 70F7A5653D + for ; + Sat, 12 Mar 2005 02:52:05 +0000 (GMT) +Received: (qmail 12328 invoked from network); 12 Mar 2005 03:52:11 +0100 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 12 Mar 2005 03:52:11 +0100 +To: "Arshavir Grigorian" , + pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +References: <423209E1.6090200@m-cam.com> <42323660.6090002@m-cam.com> +Message-ID: +Date: Sat, 12 Mar 2005 03:20:18 +0100 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <42323660.6090002@m-cam.com> +User-Agent: Opera M2/7.54 (Linux, build 955) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/208 +X-Sequence-Number: 10913 + + + Look for the possibility that a foreign key check might not be using an +index. This would yield a seq scan for each insertion, which might be your +problem. + + +On Fri, 11 Mar 2005 19:22:56 -0500, Arshavir Grigorian +wrote: + +> Many thanks for all the response. +> +> I guess there are a lot of things to change and tweak and I wonder what +> would be a good benchmarking sample dataset (size, contents). +> +> My tables are very large (the smallest is 7+ mil records) and take +> several days to load (if not weeks). It would be nice to have a sample +> dataset that would be large enough to mimic my large datasets, but small +> enough to load in a short priod of time. Any suggestions? +> +> +> Arshavir +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> + + + +From pgsql-performance-owner@postgresql.org Mon Mar 14 02:20:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DA19356410 + for ; + Sat, 12 Mar 2005 02:21:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46000-02 + for ; + Sat, 12 Mar 2005 02:21:26 +0000 (GMT) +Received: from r163ip.btv.lv (r163ip.btv.lv [217.198.224.163]) + by svr1.postgresql.org (Postfix) with ESMTP id 7225456474 + for ; + Sat, 12 Mar 2005 02:21:24 +0000 (GMT) +Received: from p4 (pIV.homenet [192.168.88.4]) + by r163ip.btv.lv (8.12.9/8.12.6) with ESMTP id j2C2LP3A041247 + for ; + Sat, 12 Mar 2005 04:21:27 +0200 (EET) + (envelope-from postgres@bilteks.com) +From: "Alexander Kirpa" +To: pgsql-performance@postgresql.org +Date: Sat, 12 Mar 2005 04:21:29 +0200 +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Subject: Re: Postgres on RAID5 +Message-ID: <42326E49.18978.3A504719@localhost> +X-mailer: Pegasus Mail for Win32 (v3.12c) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/237 +X-Sequence-Number: 10942 + +Hi Arshavir Grigorian, + +0. If possible move to 8.0.1 - bgwriter help you + +1. Create RAID1 for redo and place drives on separate +SCSI channel + +2. Update postgresql.conf: +shared_buffers = 10000-50000 +work_mem = 100000-300000 +maintenance_work_mem = 100000-300000 +max_fsm_pages = 1500000 +max_fsm_relations = 16000 +wal_buffers = 32 +checkpoint_segments = 32 # 16MB each !! +checkpoint_timeout = 600 +checkpoint_warning = 60 +effective_cache_size = 128000 +random_page_cost = 3 +default_statistics_target = 100 +log_min_error_statement = warning +log_min_duration_statement = 1000 # for logging long SQL + +3. If possible migrate from RAID5 to RAID10. + +4. Add (if need) 2 new drive for OS and use ALL +20x9GB drive for DB storage. + +5. Remove CDROM from work configuration and start use +this scsi channel. + +Best regards, + Alexander Kirpa + + +From pgsql-performance-owner@postgresql.org Sat Mar 12 03:50:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F2FC25669B + for ; + Sat, 12 Mar 2005 03:50:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74148-07 + for ; + Sat, 12 Mar 2005 03:50:18 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.206]) + by svr1.postgresql.org (Postfix) with ESMTP id 53F3C566BE + for ; + Sat, 12 Mar 2005 03:50:17 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 70so1161223wra + for ; + Fri, 11 Mar 2005 19:50:22 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=OKb3GUbmCsmx7wNIEFt01iALQbRGlGgDOYpD1mZ16Tyz6kKjbmOr3VfMEuq5U1i9+S8/Fju80oncdmvqXD3lPv8txJ9prd1gbiPRbPYHzowAg2tV9BcX8kpV3SGTEX+JJBivvFijxpxKEnLcivOg2zC6NRmce+7fqUyvunVld7g= +Received: by 10.54.40.2 with SMTP id n2mr3017492wrn; + Fri, 11 Mar 2005 19:50:20 -0800 (PST) +Received: by 10.54.18.53 with HTTP; Fri, 11 Mar 2005 19:50:20 -0800 (PST) +Message-ID: <33c6269f05031119506fee5c31@mail.gmail.com> +Date: Fri, 11 Mar 2005 22:50:20 -0500 +From: Alex Turner +Reply-To: Alex Turner +To: Arshavir Grigorian +Subject: Re: Postgres on RAID5 +Cc: pgsql-performance@postgresql.org +In-Reply-To: <423209E1.6090200@m-cam.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <423209E1.6090200@m-cam.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.225 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/209 +X-Sequence-Number: 10914 + +I would recommend running a bonnie++ benchmark on your array to see if +it's the array/controller/raid being crap, or wether it's postgres. I +have had some very surprising results from arrays that theoretically +should be fast, but turned out to be very slow. + +I would also seriously have to recommend against a 14 drive RAID 5! +This is statisticaly as likely to fail as a 7 drive RAID 0 (not +counting the spare, but rebuiling a spare is very hard on existing +drives). + +Alex Turner +netEconomist + + +On Fri, 11 Mar 2005 16:13:05 -0500, Arshavir Grigorian wrote: +> Hi, +> +> I have a RAID5 array (mdadm) with 14 disks + 1 spare. This partition has +> an Ext3 filesystem which is used by Postgres. Currently we are loading a +> 50G database on this server from a Postgres dump (copy, not insert) and +> are experiencing very slow write performance (35 records per second). +> +> Top shows that the Postgres process (postmaster) is being constantly put +> into D state for extended periods of time (2-3 seconds) which I assume +> is because it's waiting for disk io. I have just started gathering +> system statistics and here is what sar -b shows: (this is while the db +> is being loaded - pg_restore) +> +> tps rtps wtps bread/s bwrtn/s +> 01:35:01 PM 275.77 76.12 199.66 709.59 2315.23 +> 01:45:01 PM 287.25 75.56 211.69 706.52 2413.06 +> 01:55:01 PM 281.73 76.35 205.37 711.84 2389.86 +> +[snip] + +From pgsql-performance-owner@postgresql.org Sat Mar 12 04:04:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AC4BB566C2 + for ; + Sat, 12 Mar 2005 04:04:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78537-08 + for ; + Sat, 12 Mar 2005 04:04:38 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id E15E6566B5 + for ; + Sat, 12 Mar 2005 04:04:37 +0000 (GMT) +Received: from [192.168.1.20] (clbb-248.saw.net [64.146.135.248]) + (authenticated bits=0) + by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id + j2C42nkh015718; Fri, 11 Mar 2005 20:02:49 -0800 +Message-ID: <42326AA2.1010700@commandprompt.com> +Date: Fri, 11 Mar 2005 20:05:54 -0800 +From: "Joshua D. Drake" +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alex Turner +Cc: Arshavir Grigorian , + pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +References: <423209E1.6090200@m-cam.com> + <33c6269f05031119506fee5c31@mail.gmail.com> +In-Reply-To: <33c6269f05031119506fee5c31@mail.gmail.com> +Content-Type: multipart/mixed; boundary="------------010304040703040007050409" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.04 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/210 +X-Sequence-Number: 10915 + +This is a multi-part message in MIME format. +--------------010304040703040007050409 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + + +>On Fri, 11 Mar 2005 16:13:05 -0500, Arshavir Grigorian wrote: +> +> +>>Hi, +>> +>>I have a RAID5 array (mdadm) with 14 disks + 1 spare. This partition has +>>an Ext3 filesystem which is used by Postgres. Currently we are loading a +>>50G database on this server from a Postgres dump (copy, not insert) and +>>are experiencing very slow write performance (35 records per second). +>> +>> + +That isn't that surprising. RAID 5 has never been known for its write +performance. You should be running RAID 10. + +Sincerely, + +Joshua D. Drake + + +>>Top shows that the Postgres process (postmaster) is being constantly put +>>into D state for extended periods of time (2-3 seconds) which I assume +>>is because it's waiting for disk io. I have just started gathering +>>system statistics and here is what sar -b shows: (this is while the db +>>is being loaded - pg_restore) +>> +>> tps rtps wtps bread/s bwrtn/s +>>01:35:01 PM 275.77 76.12 199.66 709.59 2315.23 +>>01:45:01 PM 287.25 75.56 211.69 706.52 2413.06 +>>01:55:01 PM 281.73 76.35 205.37 711.84 2389.86 +>> +>> +>> +>[snip] +> +>---------------------------(end of broadcast)--------------------------- +>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +> +> + + +-- +Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC +Postgresql support, programming shared hosting and dedicated hosting. ++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com +PostgreSQL Replicator -- production quality replication for PostgreSQL + + +--------------010304040703040007050409 +Content-Type: text/x-vcard; charset=utf-8; + name="jd.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="jd.vcf" + +begin:vcard +fn:Joshua Drake +n:Drake;Joshua +org:Command Prompt, Inc. +adr:;;PO Box 215 ;Cascade Locks;OR;97014;US +email;internet:jd@commandprompt.com +title:Consultant +tel;work:503-667-4564 +tel;fax:503-210-0334 +x-mozilla-html:FALSE +url:http://www.commandprompt.com +version:2.1 +end:vcard + + +--------------010304040703040007050409-- + +From pgsql-performance-owner@postgresql.org Sat Mar 12 13:08:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B9C345592D + for ; + Sat, 12 Mar 2005 13:08:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18229-01 + for ; + Sat, 12 Mar 2005 13:08:31 +0000 (GMT) +Received: from ns.aprote.ee (ns.aprote.ee [80.235.78.106]) + by svr1.postgresql.org (Postfix) with ESMTP id A597D5516A + for ; + Sat, 12 Mar 2005 13:08:29 +0000 (GMT) +Received: Message by Barricade ns.aprote.ee with ESMTP id j2CD9D5u002366 + for ; Sat, 12 Mar 2005 15:09:14 +0200 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6556.0 +Subject: One tuple per transaction +Date: Sat, 12 Mar 2005 15:08:32 +0200 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: One tuple per transaction +Thread-Index: AcUnBJeLW6qt4bBqQW+SUJ79yfFyAA== +From: "Tambet Matiisen" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.016 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/211 +X-Sequence-Number: 10916 + +Hi! + +In one of our applications we have a database function, which +recalculates COGS (cost of good sold) for certain period. This involves +deleting bunch of rows from one table, inserting them again in correct +order and updating them one-by-one (sometimes one row twice) to reflect +current state. The problem is, that this generates an enormous amount of +tuples in that table. + +If I'm correct, the dead tuples must be scanned also during table and +index scan, so a lot of dead tuples slows down queries considerably, +especially when the table doesn't fit into shared buffers any more. And +as I'm in transaction, I can't VACUUM to get rid of those tuples. In one +occasion the page count for a table went from 400 to 22000 at the end. + +All this made me wonder, why is new tuple created after every update? +One tuple per transaction should be enough, because you always commit or +rollback transaction as whole. And my observations seem to indicate, +that new index tuple is created after column update even if this column +is not indexed. + +One tuple per transaction would save a loads of I/O bandwidth, so I +believe there must be a reason why it isn't implemented as such. Or were +my assumptions wrong, that dead tuples must be read from disk? + + Tambet + +From pgsql-performance-owner@postgresql.org Sat Mar 12 22:06:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6326252A52 + for ; + Sat, 12 Mar 2005 22:06:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74502-05 + for ; + Sat, 12 Mar 2005 22:06:02 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id B12DB531C8 + for ; + Sat, 12 Mar 2005 22:06:00 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7120931; Sat, 12 Mar 2005 14:07:52 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Tambet Matiisen" +Subject: Re: One tuple per transaction +Date: Sat, 12 Mar 2005 14:05:20 -0800 +User-Agent: KMail/1.6.2 +Cc: +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200503121405.20943.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.012 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/212 +X-Sequence-Number: 10917 + +Tambet, + +> In one of our applications we have a database function, which +> recalculates COGS (cost of good sold) for certain period. This involves +> deleting bunch of rows from one table, inserting them again in correct +> order and updating them one-by-one (sometimes one row twice) to reflect +> current state. The problem is, that this generates an enormous amount of +> tuples in that table. + +Sounds like you have an application design problem ... how about re-writing +your function so it's a little more sensible? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sun Mar 13 05:40:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 53DB7564B4 + for ; + Sun, 13 Mar 2005 05:40:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22440-04 + for ; + Sun, 13 Mar 2005 05:40:48 +0000 (GMT) +Received: from spider.tela.com (spider.tela.com [206.98.7.34]) + by svr1.postgresql.org (Postfix) with ESMTP id BA64654E1E + for ; + Sun, 13 Mar 2005 05:40:47 +0000 (GMT) +Received: from tela.com (localhost [127.0.0.1]) + by spider.tela.com (Postfix) with ESMTP id 63705111DEE4 + for ; + Sat, 12 Mar 2005 23:40:47 -0600 (CST) +From: "Tom Pfeifer" +To: pgsql-performance@postgresql.org +Subject: Index use and slow queries +Date: Sat, 12 Mar 2005 23:40:47 -0600 +Message-Id: <20050313051830.M98712@tela.com> +X-Mailer: Open WebMail 2.41 20040926 +X-OriginatingIP: 206.103.217.120 (tpfeifer) +MIME-Version: 1.0 +Content-Type: text/html; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.187 tagged_above=0 required=5 tests=AWL, HTML_30_40, + HTML_MESSAGE, MIME_HTML_ONLY +X-Spam-Level: * +X-Archive-Number: 200503/213 +X-Sequence-Number: 10918 + + + + + + + + +

Hello,

+ +

My version of Postgresql is=A07.4.3. +
I have a simple table with 2 indexes: +
=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 Table "public.tst" +
=A0Column |=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Type=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 Modifiers +
--------+-----------------------------+------------------------------= +------- +
=A0tst_id | bigint=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= +=A0=A0=A0=A0 | default nextval('tst_id_seq'::text) +
=A0mmd5=A0=A0 | character varying(32)=A0=A0=A0=A0=A0=A0 | not null +
=A0active | character(1)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= + | not null +
=A0lud=A0=A0=A0 | timestamp without time zone | default now() +
Indexes: +
=A0=A0=A0 "tst_idx" unique, btree (mmd5, active) +
=A0=A0=A0 "tst_tst_id_key" unique, btree (tst_id) +
+

There are exactly 1,000,000 (one million) rows in the t= +able (tst).=A0 There are no NULLS, empty columns in any row.

+ +

I get really fast response times=A0when=A0using the fol= +lowing select statement (Less than 1 second). +
maach=3D# explain select * from tst where mmd= +5 =3D '71e1c18cbc708a0bf28fe106e03256c7' and active =3D 'A'; +
=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 QUERY PL= +AN +
---------------------------------------------------------------------= +--------------------------------- +
=A0Index Scan using tst_idx on tst=A0 (cost=3D0.00..6.02 rows=3D1 wid= +th=3D57) +
=A0=A0 Index Cond: (((mmd5)::text =3D '71e1c18cbc708a0bf28fe106e03256= +c7'::text) AND (active =3D 'A'::bpchar)) +
(2 rows) +
+

I get=A0really slow repoonse times=A0when=A0using the f= +ollowing select statement (About 20 seconds). +
maach=3D# explain select * from tst where tst_id =3D 639246; +
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 QU= +ERY PLAN +
-------------------------------------------------------- +
=A0Seq Scan on tst=A0 (cost=3D0.00..23370.00 rows=3D1 width=3D57) +
=A0=A0 Filter: (tst_id =3D 639246) +
(2 rows) +

+ +

Why is the second select statement so slow, it should b= +e using the "tst_tst_id_key" unique, btree (tst_id) index, but in= +stead EXPLAIN says it's using a Seq Scan.=A0 If it was using the index, thi= +s select statement should be as fast if not faster than the above select st= +atement.

+ +

When I turned off,=A0 maach=3D# SET ENABLE_SEQSCAN TO O= +FF; +
The slow select statement gets even slower. +
maach=3D# explain select * from tst where tst_id =3D 639246; +
=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 QUERY PLAN +
-------------------------------------------------------------------- +
=A0Seq Scan on tst=A0 (cost=3D100000000.00..100023370.00 rows=3D1 wid= +th=3D57) +
=A0=A0 Filter: (tst_id =3D 639246) +
(2 rows) +

+ +

Why do I have to use 2 columns=A0to create a fast/effic= +ient index?=A0=A0I want to get the single column index to be the fastest in= +dex for my select statements.=A0 How do I accomplish this.

+ +

Thanks, +
Tom

+

+

+ + + + + +From pgsql-performance-owner@postgresql.org Sun Mar 13 06:08:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DFBEB54D07 + for ; + Sun, 13 Mar 2005 06:08:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27725-05 + for ; + Sun, 13 Mar 2005 06:07:52 +0000 (GMT) +Received: from pws.com.au (mail.pws.com.au [210.23.138.139]) + by svr1.postgresql.org (Postfix) with SMTP id 7AB5054507 + for ; + Sun, 13 Mar 2005 06:07:50 +0000 (GMT) +Received: (qmail 13243 invoked from network); 13 Mar 2005 06:07:47 -0000 +Received: from unknown (HELO wizzard.pws.com.au) + (russell@pws.com.au@138.217.54.70) + by mail.pws.com.au with SMTP; 13 Mar 2005 06:07:47 -0000 +From: Russell Smith +To: "Tom Pfeifer" +Subject: Re: Index use and slow queries +Date: Sun, 13 Mar 2005 17:07:46 +1100 +User-Agent: KMail/1.7 +Cc: pgsql-performance@postgresql.org +References: <20050313051830.M98712@tela.com> +In-Reply-To: <20050313051830.M98712@tela.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200503131707.46690.mr-russ@pws.com.au> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.03 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/214 +X-Sequence-Number: 10919 + +On Sun, 13 Mar 2005 04:40 pm, Tom Pfeifer wrote: +> Hello, +>=20 +>=20 +> My version of Postgresql is=A07.4.3.=20 +> I have a simple table with 2 indexes:=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 Table "public.tst"=20 +> =A0Column |=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 Type=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 Modifiers=20 +> --------+-----------------------------+----------------------------------= +=2D--=20 +> =A0tst_id | bigint=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= +=A0=A0=A0 | default nextval('tst_id_seq'::text)=20 +> =A0mmd5=A0=A0 | character varying(32)=A0=A0=A0=A0=A0=A0 | not null=20 +> =A0active | character(1)=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 | n= +ot null=20 +> =A0lud=A0=A0=A0 | timestamp without time zone | default now()=20 +> Indexes:=20 +> =A0=A0=A0 "tst_idx" unique, btree (mmd5, active)=20 +> =A0=A0=A0 "tst_tst_id_key" unique, btree (tst_id)=20 +> =20 +>=20 +>=20 +> There are exactly 1,000,000 (one million) rows in the table (tst).=A0 The= +re are no NULLS, empty columns in any row. +>=20 +>=20 +> I get really fast response times=A0when=A0using the following select stat= +ement (Less than 1 second).=20 +> maach=3D# explain select * from tst where mmd5 =3D '71e1c18cbc708a0bf28fe= +106e03256c7' and active =3D 'A';=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 QUERY PLAN= +=20 +> -------------------------------------------------------------------------= +=2D----------------------------=20 +> =A0Index Scan using tst_idx on tst=A0 (cost=3D0.00..6.02 rows=3D1 width= +=3D57)=20 +> =A0=A0 Index Cond: (((mmd5)::text =3D '71e1c18cbc708a0bf28fe106e03256c7':= +:text) AND (active =3D 'A'::bpchar))=20 +> (2 rows)=20 +> =20 +>=20 +>=20 +> I get=A0really slow repoonse times=A0when=A0using the following select st= +atement (About 20 seconds).=20 +> maach=3D# explain select * from tst where tst_id =3D 639246;=20 + +Before 8.0, bigint would not use an index unless you cast it, or quote it. + +eg +explain select * from tst where tst_id =3D 639246::int8;=20 +explain select * from tst where tst_id =3D '639246';=20 + +Hope this helps. + +Russell Smith + +From pgsql-performance-owner@postgresql.org Sun Mar 13 06:26:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 535F654DA7 + for ; + Sun, 13 Mar 2005 06:26:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32231-06 + for ; + Sun, 13 Mar 2005 06:26:12 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 8081754E05 + for ; + Sun, 13 Mar 2005 06:26:11 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2D6QCLg014750; + Sun, 13 Mar 2005 01:26:12 -0500 (EST) +To: Russell Smith +Cc: "Tom Pfeifer" , + pgsql-performance@postgresql.org +Subject: Re: Index use and slow queries +In-reply-to: <200503131707.46690.mr-russ@pws.com.au> +References: <20050313051830.M98712@tela.com> + <200503131707.46690.mr-russ@pws.com.au> +Comments: In-reply-to Russell Smith + message dated "Sun, 13 Mar 2005 17:07:46 +1100" +Date: Sun, 13 Mar 2005 01:26:12 -0500 +Message-ID: <14749.1110695172@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/215 +X-Sequence-Number: 10920 + +Russell Smith writes: +> On Sun, 13 Mar 2005 04:40 pm, Tom Pfeifer wrote: +>> I get really slow repoonse times when using the following select statement (About 20 seconds). +>> maach=# explain select * from tst where tst_id = 639246; + +> Before 8.0, bigint would not use an index unless you cast it, or quote it. + +> explain select * from tst where tst_id = 639246::int8; +> explain select * from tst where tst_id = '639246'; + +... or you compare to a value large enough to be int8 naturally, eg + +> explain select * from tst where tst_id = 123456639246; + +The issue here is that (a) 639246 is naturally typed as int4, and +(b) before 8.0 we couldn't use cross-type comparisons such as int8 = int4 +with an index. + +You can find a whole lot of angst about this issue and related ones +if you care to review the last six or eight years of the pgsql-hackers +archives. It was only recently that we found a way to support +cross-type index operations without breaking the fundamental +type-extensibility features of Postgres. (In hindsight, we spent way +too much time fixated on the notion that we needed to find a way to +implicitly convert the non-indexed value to match the indexed column's +type, rather than biting the bullet and supporting cross-type operations +directly with indexes. Oh well, hindsight is always 20/20.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 13 15:32:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 74D8D5657A + for ; + Sun, 13 Mar 2005 15:32:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58694-05 + for ; + Sun, 13 Mar 2005 15:32:47 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 81B43563F7 + for ; + Sun, 13 Mar 2005 15:32:45 +0000 (GMT) +Received: (qmail 16118 invoked from network); 13 Mar 2005 16:32:50 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by sranda.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 13 Mar 2005 16:32:50 +0100 +Message-ID: <42345D24.8070104@startnet.cz> +Date: Sun, 13 Mar 2005 16:32:52 +0100 +From: =?ISO-8859-2?Q?Miroslav_=A9ulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PGSQL mailing list +Subject: How to read query plan +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------050809060501030404040009" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/216 +X-Sequence-Number: 10921 + +This is a multi-part message in MIME format. +--------------050809060501030404040009 +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 8bit + +Hi all, + +I am new to PostgreSQL and query optimizations. We have recently moved +our project from MySQL to PostgreSQL and we are having performance +problem with one of our most often used queries. On MySQL the speed was +sufficient but PostgreSQL chooses time expensive query plan. I would +like to optimize it somehow but the query plan from EXPLAIN ANALYZE is +little bit cryptic to me. + +So the first thing I would like is to understand the query plan. I have +read "performance tips" and FAQ but it didn't move me too much further. + +I would appreciate if someone could help me to understand the query plan +and what are the possible general options I can test. I think at this +moment the most expensive part is the "Sort". Am I right? If so, how +could I generally avoid it (turning something on or off, using +parentheses for JOINs etc.) to force some more efficient query plan? + +Thank you for any suggestions. + +QUERY PLAN + +Merge Right Join (cost=9868.84..9997.74 rows=6364 width=815) (actual time=9982.022..10801.216 rows=6364 loops=1) + + Merge Cond: ("outer".idpk = "inner".cadastralunitidfk) + + -> Index Scan using cadastralunits_pkey on cadastralunits (cost=0.00..314.72 rows=13027 width=31) (actual time=0.457..0.552 rows=63 loops=1) + + -> Sort (cost=9868.84..9884.75 rows=6364 width=788) (actual time=9981.405..10013.708 rows=6364 loops=1) + + Sort Key: addevicessites.cadastralunitidfk + + -> Hash Left Join (cost=5615.03..7816.51 rows=6364 width=788) (actual time=3898.603..9884.248 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitepartnerstickeridfk = "inner".idpk) + + -> Hash Left Join (cost=5612.27..7718.29 rows=6364 width=762) (actual time=3898.243..9104.791 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitepartnermaintaineridfk = "inner".idpk) + + -> Hash Left Join (cost=5609.51..7620.06 rows=6364 width=736) (actual time=3897.996..8341.965 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitepartnerelectricitysupplieridfk = "inner".idpk) + + -> Hash Left Join (cost=5606.74..7521.84 rows=6364 width=710) (actual time=3897.736..7572.182 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitepartneridentificationoperatoridfk = "inner".idpk) + + -> Nested Loop Left Join (cost=5603.98..7423.62 rows=6364 width=684) (actual time=3897.436..6821.713 rows=6364 loops=1) + + Join Filter: ("outer".addevicessitestatustypeidfk = "inner".idpk) + + -> Nested Loop Left Join (cost=5602.93..6706.61 rows=6364 width=657) (actual time=3897.294..6038.976 rows=6364 loops=1) + + Join Filter: ("outer".addevicessitepositionidfk = "inner".idpk) + + -> Nested Loop Left Join (cost=5601.89..6276.01 rows=6364 width=634) (actual time=3897.158..5303.575 rows=6364 loops=1) + + Join Filter: ("outer".addevicessitevisibilityidfk = "inner".idpk) + + -> Merge Right Join (cost=5600.85..5702.21 rows=6364 width=602) (actual time=3896.963..4583.749 rows=6364 loops=1) + + Merge Cond: ("outer".idpk = "inner".addevicessitesizeidfk) + + -> Index Scan using addevicessitesizes_pkey on addevicessitesizes (cost=0.00..5.62 rows=110 width=14) (actual time=0.059..0.492 rows=110 loops=1) + + -> Sort (cost=5600.85..5616.76 rows=6364 width=592) (actual time=3896.754..3915.022 rows=6364 loops=1) + + Sort Key: addevicessites.addevicessitesizeidfk + + -> Hash Left Join (cost=2546.59..4066.81 rows=6364 width=592) (actual time=646.162..3792.310 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitedistrictidfk = "inner".idpk) + + -> Hash Left Join (cost=2539.29..3964.05 rows=6364 width=579) (actual time=645.296..3142.128 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitestreetdescriptionidfk = "inner".idpk) + + -> Hash Left Join (cost=2389.98..2724.64 rows=6364 width=544) (actual time=632.806..2466.030 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitestreetidfk = "inner".idpk) + + -> Hash Left Join (cost=2324.25..2515.72 rows=6364 width=518) (actual time=626.081..1822.137 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitecityidfk = "inner".idpk) + + -> Merge Right Join (cost=2321.70..2417.71 rows=6364 width=505) (actual time=625.598..1220.967 rows=6364 loops=1) + + Merge Cond: ("outer".idpk = "inner".addevicessitecountyidfk) + + -> Sort (cost=5.83..6.10 rows=110 width=17) (actual time=0.348..0.391 rows=110 loops=1) + + Sort Key: addevicessitecounties.idpk + + -> Seq Scan on addevicessitecounties (cost=0.00..2.10 rows=110 width=17) (actual time=0.007..0.145 rows=110 loops=1) + + -> Sort (cost=2315.87..2331.78 rows=6364 width=492) (actual time=625.108..640.325 rows=6364 loops=1) + + Sort Key: addevicessites.addevicessitecountyidfk + + -> Merge Right Join (cost=0.00..1006.90 rows=6364 width=492) (actual time=0.145..543.043 rows=6364 loops=1) + + Merge Cond: ("outer".idpk = "inner".addevicessiteregionidfk) + + -> Index Scan using addevicessiteregions_pkey on addevicessiteregions (cost=0.00..3.17 rows=15 width=23) (actual time=0.011..0.031 rows=15 loops=1) + + -> Index Scan using addevicessites_addevicessiteregionidfk on addevicessites (cost=0.00..924.14 rows=6364 width=473) (actual time=0.010..9.825 rows=6364 loops=1) + + -> Hash (cost=2.24..2.24 rows=124 width=17) (actual time=0.238..0.238 rows=0 loops=1) + + -> Seq Scan on addevicessitecities (cost=0.00..2.24 rows=124 width=17) (actual time=0.009..0.145 rows=124 loops=1) + + -> Hash (cost=58.58..58.58 rows=2858 width=34) (actual time=6.532..6.532 rows=0 loops=1) + + -> Seq Scan on addevicessitestreets (cost=0.00..58.58 rows=2858 width=34) (actual time=0.040..4.129 rows=2858 loops=1) + + -> Hash (cost=96.85..96.85 rows=4585 width=43) (actual time=11.786..11.786 rows=0 loops=1) + + -> Seq Scan on addevicessitestreetdescriptions (cost=0.00..96.85 rows=4585 width=43) (actual time=0.036..7.290 rows=4585 loops=1) + + -> Hash (cost=6.44..6.44 rows=344 width=21) (actual time=0.730..0.730 rows=0 loops=1) + + -> Seq Scan on addevicessitedistricts (cost=0.00..6.44 rows=344 width=21) (actual time=0.027..0.478 rows=344 loops=1) + + -> Materialize (cost=1.04..1.08 rows=4 width=36) (actual time=0.000..0.002 rows=4 loops=6364) + + -> Seq Scan on addevicessitevisibilities (cost=0.00..1.04 rows=4 width=36) (actual time=0.036..0.050 rows=4 loops=1) + + -> Materialize (cost=1.03..1.06 rows=3 width=27) (actual time=0.001..0.002 rows=3 loops=6364) + + -> Seq Scan on addevicessitepositions (cost=0.00..1.03 rows=3 width=27) (actual time=0.013..0.017 rows=3 loops=1) + + -> Materialize (cost=1.05..1.10 rows=5 width=31) (actual time=0.000..0.002 rows=5 loops=6364) + + -> Seq Scan on addevicessitestatustypes (cost=0.00..1.05 rows=5 width=31) (actual time=0.012..0.019 rows=5 loops=1) + + -> Hash (cost=2.61..2.61 rows=61 width=34) (actual time=0.171..0.171 rows=0 loops=1) + + -> Seq Scan on partneridentifications partneridentificationsoperator (cost=0.00..2.61 rows=61 width=34) (actual time=0.027..0.126 rows=61 loops=1) + + -> Hash (cost=2.61..2.61 rows=61 width=34) (actual time=0.130..0.130 rows=0 loops=1) + + -> Seq Scan on partners partnerselectricitysupplier (cost=0.00..2.61 rows=61 width=34) (actual time=0.003..0.076 rows=61 loops=1) + + -> Hash (cost=2.61..2.61 rows=61 width=34) (actual time=0.118..0.118 rows=0 loops=1) + + -> Seq Scan on partners partnersmaintainer (cost=0.00..2.61 rows=61 width=34) (actual time=0.003..0.075 rows=61 loops=1) + + -> Hash (cost=2.61..2.61 rows=61 width=34) (actual time=0.171..0.171 rows=0 loops=1) + + -> Seq Scan on partners partnerssticker (cost=0.00..2.61 rows=61 width=34) (actual time=0.029..0.120 rows=61 loops=1) + +Total runtime: 10811.567 ms + + +-- +Miroslav �ulc + + +--------------050809060501030404040009 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------050809060501030404040009-- + +From pgsql-performance-owner@postgresql.org Sun Mar 13 16:24:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DF70955F07 + for ; + Sun, 13 Mar 2005 16:24:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69611-06 + for ; + Sun, 13 Mar 2005 16:24:24 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id CCD6F5549A + for ; + Sun, 13 Mar 2005 16:24:18 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j2DGOHbE010618; (envelope-from ) Sun, + 13 Mar 2005 10:24:17 -0600 (CST) +Received: from [192.168.1.13] (12-217-241-0.client.mchsi.com [12.217.241.0]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j2DGOEY9013042 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Sun, + 13 Mar 2005 10:24:16 -0600 (CST) +Message-ID: <4234692E.3050802@arbash-meinel.com> +Date: Sun, 13 Mar 2005 10:24:14 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?ISO-8859-2?Q?Miroslav_=A9ulc?= +Cc: PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> +In-Reply-To: <42345D24.8070104@startnet.cz> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigD8ADF1C7CDACB5748302A498" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/217 +X-Sequence-Number: 10922 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigD8ADF1C7CDACB5748302A498 +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 8bit + +Miroslav �ulc wrote: + +> Hi all, +> +> I am new to PostgreSQL and query optimizations. We have recently moved +> our project from MySQL to PostgreSQL and we are having performance +> problem with one of our most often used queries. On MySQL the speed +> was sufficient but PostgreSQL chooses time expensive query plan. I +> would like to optimize it somehow but the query plan from EXPLAIN +> ANALYZE is little bit cryptic to me. +> +> So the first thing I would like is to understand the query plan. I +> have read "performance tips" and FAQ but it didn't move me too much +> further. +> +> I would appreciate if someone could help me to understand the query +> plan and what are the possible general options I can test. I think at +> this moment the most expensive part is the "Sort". Am I right? If so, +> how could I generally avoid it (turning something on or off, using +> parentheses for JOINs etc.) to force some more efficient query plan? +> +> Thank you for any suggestions. +> +You really need to post the original query, so we can see *why* postgres +thinks it needs to run the plan this way. + +Also, the final sort actually isn't that expensive. + +When you have the numbers (cost=xxx..yyy) the xxx is the time when the +step can start, and the yyy is the time when the step can finish. For a +lot of steps, it can start running while the sub-steps are still feeding +back more data, for others, it has to wait for the sub-steps to finish. + +The first thing to look for, is to make sure the estimated number of +rows is close to the actual number of rows. If they are off, then +postgres may be mis-estimating the optimal plan. (If postgres thinks it +is going to only need 10 rows, it may use an index scan, but when 1000 +rows are returned, a seq scan might have been faster.) + +You seem to be doing a lot of outer joins. Is that necessary? I don't +really know what you are looking for, but you are joining against enough +tables, that I think this query is always going to be slow. + + From what I can tell, you have 1 table which has 6364 rows, and you are +grabbing all of those rows, and then outer joining it with about 11 +other tables. + +I would actually guess that the most expensive parts of the plan are the +NESTED LOOPS which when they go to materialize have to do a sequential +scan, and they get executed 6364 times. It looks like the other tables +are small (only 3-5 rows), so it takes about 0.05 ms for each seqscan, +the problem is that because you are doing it 6k times, it ends up taking +about 300ms of your time. + +You could try setting "set enable_nestloop to off". +I don't know that it will be faster, but it could be. + +In general, though, it seems like you should be asking a different +question, rather than trying to optimize the query that you have. + +Can you post the original SQL statement, and maybe describe what you are +trying to do? + +John +=:-> + + +--------------enigD8ADF1C7CDACB5748302A498 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCNGkuJdeBCYSNAAMRAjIBAKDBwrsJPleMH9McZtef2qvOBP/jDwCggL/I +ReXVBERC/9egYUlwB3KXBlw= +=hxPR +-----END PGP SIGNATURE----- + +--------------enigD8ADF1C7CDACB5748302A498-- + +From pgsql-performance-owner@postgresql.org Sun Mar 13 16:51:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 65889565CC + for ; + Sun, 13 Mar 2005 16:51:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76879-02 + for ; + Sun, 13 Mar 2005 16:51:06 +0000 (GMT) +Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D7DD52A93 + for ; + Sun, 13 Mar 2005 16:51:04 +0000 (GMT) +Received: from gnari ([157.157.184.242] [157.157.184.242]) by quasar.skima.is + with ESMTP; Sun, 13 Mar 2005 16:51:03 Z +Subject: Re: How to read query plan +From: Ragnar =?ISO-8859-1?Q?Hafsta=F0?= +To: Miroslav =?iso-8859-2?Q?=A9ulc?= +Cc: PGSQL mailing list +In-Reply-To: <42345D24.8070104@startnet.cz> +References: <42345D24.8070104@startnet.cz> +Content-Type: text/plain; charset=iso-8859-2 +Date: Sun, 13 Mar 2005 16:51:04 +0000 +Message-Id: <1110732664.4659.13.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/218 +X-Sequence-Number: 10923 + +On Sun, 2005-03-13 at 16:32 +0100, Miroslav �ulc wrote: +> Hi all, +> +> I am new to PostgreSQL and query optimizations. We have recently moved +> our project from MySQL to PostgreSQL and we are having performance +> problem with one of our most often used queries. On MySQL the speed was +> sufficient but PostgreSQL chooses time expensive query plan. I would +> like to optimize it somehow but the query plan from EXPLAIN ANALYZE is +> little bit cryptic to me. +> + +[snip output of EXPLAIN ANALYZE] + +for those of us who have not yet reached the level where one can +infer it from the query plan, how abour showing us the actual +query too ? + +but as an example of what to look for, consider the first few lines +(reformatted): + +> Merge Right Join (cost=9868.84..9997.74 rows=6364 width=815) +> (actual time=9982.022..10801.216 rows=6364 loops=1) +> Merge Cond: ("outer".idpk = "inner".cadastralunitidfk) +> -> Index Scan using cadastralunits_pkey on cadastralunits +> (cost=0.00..314.72 rows=13027 width=31) +> (actual time=0.457..0.552 rows=63 loops=1) +> -> Sort (cost=9868.84..9884.75 rows=6364 width=788) +> (actual time=9981.405..10013.708 rows=6364 loops=1) + +notice that the index scan is expected to return 13027 rows, but +actually returns 63. this might influence the a choice of plan. + +gnari + + + + +From pgsql-performance-owner@postgresql.org Sun Mar 13 17:10:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5117B566A1 + for ; + Sun, 13 Mar 2005 17:10:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80829-07 + for ; + Sun, 13 Mar 2005 17:10:30 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 98E86565C5 + for ; + Sun, 13 Mar 2005 17:10:26 +0000 (GMT) +Received: (qmail 28598 invoked from network); 13 Mar 2005 18:10:25 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by ns.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 13 Mar 2005 18:10:25 +0100 +Message-ID: <42347407.2000202@startnet.cz> +Date: Sun, 13 Mar 2005 18:10:31 +0100 +From: =?ISO-8859-2?Q?Miroslav_=A9ulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: John Arbash Meinel +Cc: PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> +In-Reply-To: <4234692E.3050802@arbash-meinel.com> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------090403030103070309050905" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/219 +X-Sequence-Number: 10924 + +This is a multi-part message in MIME format. +--------------090403030103070309050905 +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 7bit + +Hi John, + +thank you for your response. + +John Arbash Meinel wrote: + +> You really need to post the original query, so we can see *why* postgres +> thinks it needs to run the plan this way. + +Here it is: + +SELECT AdDevicesSites.IDPK, AdDevicesSites.AdDevicesSiteSizeIDFK, +AdDevicesSites.AdDevicesSiteRegionIDFK, +AdDevicesSites.AdDevicesSiteCountyIDFK, +AdDevicesSites.AdDevicesSiteCityIDFK, +AdDevicesSites.AdDevicesSiteDistrictIDFK, +AdDevicesSites.AdDevicesSiteStreetIDFK, +AdDevicesSites.AdDevicesSiteStreetDescriptionIDFK, +AdDevicesSites.AdDevicesSitePositionIDFK, +AdDevicesSites.AdDevicesSiteVisibilityIDFK, +AdDevicesSites.AdDevicesSiteStatusTypeIDFK, +AdDevicesSites.AdDevicesSitePartnerIdentificationOperatorIDFK, +AdDevicesSites.AdDevicesSitePartnerElectricitySupplierIDFK, +AdDevicesSites.AdDevicesSitePartnerMaintainerIDFK, +AdDevicesSites.AdDevicesSitePartnerStickerIDFK, +AdDevicesSites.CadastralUnitIDFK, AdDevicesSites.MediaType, +AdDevicesSites.Mark, AdDevicesSites.Amount, AdDevicesSites.Distance, +AdDevicesSites.OwnLightening, AdDevicesSites.LocationDownTown, +AdDevicesSites.LocationSuburb, AdDevicesSites.LocationBusinessDistrict, +AdDevicesSites.LocationResidentialDistrict, +AdDevicesSites.LocationIndustrialDistrict, +AdDevicesSites.LocationNoBuildings, AdDevicesSites.ParkWayHighWay, +AdDevicesSites.ParkWayFirstClassRoad, AdDevicesSites.ParkWayOtherRoad, +AdDevicesSites.ParkWayStreet, AdDevicesSites.ParkWayAccess, +AdDevicesSites.ParkWayExit, AdDevicesSites.ParkWayParkingPlace, +AdDevicesSites.ParkWayPassangersOnly, AdDevicesSites.ParkWayCrossRoad, +AdDevicesSites.PositionStandAlone, +AdDevicesSites.NeighbourhoodPublicTransportation, +AdDevicesSites.NeighbourhoodInterCityTransportation, +AdDevicesSites.NeighbourhoodPostOffice, +AdDevicesSites.NeighbourhoodNewsStand, +AdDevicesSites.NeighbourhoodAmenities, +AdDevicesSites.NeighbourhoodSportsSpot, +AdDevicesSites.NeighbourhoodHealthServiceSpot, +AdDevicesSites.NeighbourhoodShops, +AdDevicesSites.NeighbourhoodShoppingCenter, +AdDevicesSites.NeighbourhoodSuperMarket, +AdDevicesSites.NeighbourhoodPetrolStation, +AdDevicesSites.NeighbourhoodSchool, AdDevicesSites.NeighbourhoodBank, +AdDevicesSites.NeighbourhoodRestaurant, +AdDevicesSites.NeighbourhoodHotel, AdDevicesSites.RestrictionCigarettes, +AdDevicesSites.RestrictionPolitics, AdDevicesSites.RestrictionSpirits, +AdDevicesSites.RestrictionSex, AdDevicesSites.RestrictionOther, +AdDevicesSites.RestrictionNote, AdDevicesSites.SpotMapFile, +AdDevicesSites.SpotPhotoFile, AdDevicesSites.SourcePhotoTimeStamp, +AdDevicesSites.SourceMapTimeStamp, AdDevicesSites.Price, +AdDevicesSites.WebPrice, AdDevicesSites.CadastralUnitCode, +AdDevicesSites.BuildingNumber, AdDevicesSites.ParcelNumber, +AdDevicesSites.GPSLatitude, AdDevicesSites.GPSLongitude, +AdDevicesSites.GPSHeight, AdDevicesSites.MechanicalOpticalCoordinates, +AdDevicesSites.Deleted, AdDevicesSites.Protected, +AdDevicesSites.DateCreated, AdDevicesSites.DateLastModified, +AdDevicesSites.DateDeleted, AdDevicesSites.CreatedByUserIDFK, +AdDevicesSites.LastModifiedByUserIDFK, AdDevicesSites.DeletedByUserIDFK, +AdDevicesSites.PhotoLastModificationDate, +AdDevicesSites.MapLastModificationDate, AdDevicesSites.DateLastImported, +AdDevicesSiteRegions.Name AS AdDevicesSiteRegionName, +AdDevicesSiteCounties.Name AS AdDevicesSiteCountyName, +AdDevicesSiteCities.Name AS AdDevicesSiteCityName, +AdDevicesSiteStreets.Name AS AdDevicesSiteStreetName, +AdDevicesSiteDistricts.Name AS AdDevicesSiteDistrictName, +AdDevicesSiteStreetDescriptions.Name_cs AS +AdDevicesSiteStreetDescriptionName_cs, +AdDevicesSiteStreetDescriptions.Name_en AS +AdDevicesSiteStreetDescriptionName_en, AdDevicesSiteSizes.Name AS +AdDevicesSiteSizeName, SUBSTRING(AdDevicesSiteVisibilities.Name_cs, 3) +AS AdDevicesSiteVisibilityName_cs, +SUBSTRING(AdDevicesSiteVisibilities.Name_en, 3) AS +AdDevicesSiteVisibilityName_en, AdDevicesSitePositions.Name_cs AS +AdDevicesSitePositionName_cs, AdDevicesSitePositions.Name_en AS +AdDevicesSitePositionName_en, AdDevicesSiteStatusTypes.Name_cs AS +AdDevicesSiteStatusTypeName_cs, AdDevicesSiteStatusTypes.Name_en AS +AdDevicesSiteStatusTypeName_en, PartnerIdentificationsOperator.Name AS +PartnerIdentificationOperatorName, PartnersElectricitySupplier.Name AS +PartnerElectricitySupplierName, PartnersMaintainer.Name AS +PartnerMaintainerName, PartnersSticker.Name AS PartnerStickerName, +CadastralUnits.Code AS CadastralUnitCodeNative, CadastralUnits.Name AS +CadastralUnitName +FROM AdDevicesSites +LEFT JOIN AdDevicesSiteRegions ON AdDevicesSites.AdDevicesSiteRegionIDFK += AdDevicesSiteRegions.IDPK +LEFT JOIN AdDevicesSiteCounties ON +AdDevicesSites.AdDevicesSiteCountyIDFK = AdDevicesSiteCounties.IDPK +LEFT JOIN AdDevicesSiteCities ON AdDevicesSites.AdDevicesSiteCityIDFK = +AdDevicesSiteCities.IDPK +LEFT JOIN AdDevicesSiteStreets ON AdDevicesSites.AdDevicesSiteStreetIDFK += AdDevicesSiteStreets.IDPK +LEFT JOIN AdDevicesSiteStreetDescriptions ON +AdDevicesSites.AdDevicesSiteStreetDescriptionIDFK = +AdDevicesSiteStreetDescriptions.IDPK +LEFT JOIN AdDevicesSiteDistricts ON +AdDevicesSites.AdDevicesSiteDistrictIDFK = AdDevicesSiteDistricts.IDPK +LEFT JOIN AdDevicesSiteSizes ON AdDevicesSites.AdDevicesSiteSizeIDFK = +AdDevicesSiteSizes.IDPK +LEFT JOIN AdDevicesSiteVisibilities ON +AdDevicesSites.AdDevicesSiteVisibilityIDFK = AdDevicesSiteVisibilities.IDPK +LEFT JOIN AdDevicesSitePositions ON +AdDevicesSites.AdDevicesSitePositionIDFK = AdDevicesSitePositions.IDPK +LEFT JOIN AdDevicesSiteStatusTypes ON +AdDevicesSites.AdDevicesSiteStatusTypeIDFK = AdDevicesSiteStatusTypes.IDPK +LEFT JOIN PartnerIdentifications AS PartnerIdentificationsOperator ON +AdDevicesSites.AdDevicesSitePartnerIdentificationOperatorIDFK = +PartnerIdentificationsOperator.IDPK +LEFT JOIN Partners AS PartnersElectricitySupplier ON +AdDevicesSites.AdDevicesSitePartnerElectricitySupplierIDFK = +PartnersElectricitySupplier.IDPK +LEFT JOIN Partners AS PartnersMaintainer ON +AdDevicesSites.AdDevicesSitePartnerMaintainerIDFK = PartnersMaintainer.IDPK +LEFT JOIN Partners AS PartnersSticker ON +AdDevicesSites.AdDevicesSitePartnerStickerIDFK = PartnersSticker.IDPK +LEFT JOIN CadastralUnits ON AdDevicesSites.CadastralUnitIDFK = +CadastralUnits.IDPK + +> Also, the final sort actually isn't that expensive. +> +> When you have the numbers (cost=xxx..yyy) the xxx is the time when the +> step can start, and the yyy is the time when the step can finish. For a +> lot of steps, it can start running while the sub-steps are still feeding +> back more data, for others, it has to wait for the sub-steps to finish. + +This is thi bit of information I didn't find in the documentation and +were looking for. Thank you for the enlightening :-) With this knowledge +I can see that the JOINs are the bottleneck. + +> The first thing to look for, is to make sure the estimated number of +> rows is close to the actual number of rows. If they are off, then +> postgres may be mis-estimating the optimal plan. (If postgres thinks it +> is going to only need 10 rows, it may use an index scan, but when 1000 +> rows are returned, a seq scan might have been faster.) + +The "row=" numbers are equal to those of the total count of items in +that tables (generated by VACUUM ANALYZE). + +> You seem to be doing a lot of outer joins. Is that necessary? + +These external tables contain information that are a unique parameter of +the AdDevice (like Position, Region, County, City etc.), in some +containing localized description of the property attribute. Some of them +could be moved into the main table but that would create a redundancy, +some of them cannot be moved into the main table (like information about +Partners which is definitely another object with respect to AdDevices). +I think the names of the tables are self-explanatory so it should be +clear what each table stores. Is this design incorrect? + +In fact, we only need about 30 records at a time but LIMIT can speed-up +the query only when looking for the first 30 records. Setting OFFSET +slows the query down. + +> I don't +> really know what you are looking for, but you are joining against enough +> tables, that I think this query is always going to be slow. + +In MySQL the query was not so slow and I don't see any reason why there +should be large differences in SELECT speed. But if the design of the +tables is incorrect, we will correct it. + +> From what I can tell, you have 1 table which has 6364 rows, and you are +> grabbing all of those rows, and then outer joining it with about 11 +> other tables. + +Here are the exact numbers: + +AdDevicesSites - 6364 +AdDevicesSiteRegions - 15 +AdDevicesSiteCounties - 110 +AdDevicesSiteCities - 124 +AdDevicesSiteStreets - 2858 +AdDevicesSiteStreetDescriptions - 4585 +AdDevicesSiteDistricts - 344 +AdDevicesSiteSizes - 110 +AdDevicesSiteVisibilities - 4 +AdDevicesSitePositions - 3 +AdDevicesSiteStatusTypes - 5 +PartnerIdentifications - 61 +Partners - 61 +CadastralUnits - 13027 + +> I would actually guess that the most expensive parts of the plan are the +> NESTED LOOPS which when they go to materialize have to do a sequential +> scan, and they get executed 6364 times. It looks like the other tables +> are small (only 3-5 rows), so it takes about 0.05 ms for each seqscan, +> the problem is that because you are doing it 6k times, it ends up taking +> about 300ms of your time. +> +> You could try setting "set enable_nestloop to off". +> I don't know that it will be faster, but it could be. + +I have tried that and it resulted in about 2 sec slowdown :-( + +> In general, though, it seems like you should be asking a different +> question, rather than trying to optimize the query that you have. + +You mean "how should I improve the design to make the query faster"? + +> Can you post the original SQL statement, and maybe describe what you are +> trying to do? + +I hope the explanation above is clear and sufficient :-) + +> +> John +> =:-> +> + +--------------090403030103070309050905 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------090403030103070309050905-- + +From pgsql-performance-owner@postgresql.org Sun Mar 13 17:21:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BF82356685 + for ; + Sun, 13 Mar 2005 17:21:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81949-07 + for ; + Sun, 13 Mar 2005 17:21:31 +0000 (GMT) +Received: from ns.aprote.ee (ns.aprote.ee [80.235.78.106]) + by svr1.postgresql.org (Postfix) with ESMTP id A7FAB55119 + for ; + Sun, 13 Mar 2005 17:21:29 +0000 (GMT) +Received: Message by Barricade ns.aprote.ee with ESMTP id j2DHMAqN029060 + for ; Sun, 13 Mar 2005 19:22:11 +0200 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6556.0 +Subject: Re: One tuple per transaction +Date: Sun, 13 Mar 2005 19:21:26 +0200 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] One tuple per transaction +Thread-Index: AcUnT8qlu7syWGefQJa24rs7z+uCjAAnlsjw +From: "Tambet Matiisen" +To: "Josh Berkus" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/220 +X-Sequence-Number: 10925 + + + +> -----Original Message----- +> From: Josh Berkus [mailto:josh@agliodbs.com]=20 +> Sent: Sunday, March 13, 2005 12:05 AM +> To: Tambet Matiisen +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] One tuple per transaction +>=20 +>=20 +> Tambet, +>=20 +> > In one of our applications we have a database function, which=20 +> > recalculates COGS (cost of good sold) for certain period. This=20 +> > involves deleting bunch of rows from one table, inserting=20 +> them again=20 +> > in correct order and updating them one-by-one (sometimes one row=20 +> > twice) to reflect current state. The problem is, that this=20 +> generates=20 +> > an enormous amount of tuples in that table. +>=20 +> Sounds like you have an application design problem ... how=20 +> about re-writing=20 +> your function so it's a little more sensible? +>=20 + +I agree, that I have violated the no 1 rule of transactions - don't make +the transaction last too long. But imagine a situation, where a table is +updated twice in transaction. Why? Perhaps programmer felt, that the +code is more modular in this way. Now if you have tons of those +transactions, the I/O throughput is twice as big as it could be, because +every transaction creates two tuples instead of one. One tuple per +transaction could allow the programmer to keep his modular code and +benefit from the increased performance. + + Tambet + +From pgsql-performance-owner@postgresql.org Sun Mar 13 17:23:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A61856685 + for ; + Sun, 13 Mar 2005 17:23:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82862-06 + for ; + Sun, 13 Mar 2005 17:23:46 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E1BF5669D + for ; + Sun, 13 Mar 2005 17:23:45 +0000 (GMT) +Received: (qmail 10695 invoked from network); 13 Mar 2005 18:23:45 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by mail.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 13 Mar 2005 18:23:45 +0100 +Message-ID: <42347727.4060109@startnet.cz> +Date: Sun, 13 Mar 2005 18:23:51 +0100 +From: =?UTF-8?B?TWlyb3NsYXYgxaB1bGM=?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?UTF-8?B?UmFnbmFyIEhhZnN0YcSR?= +Cc: PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <1110732664.4659.13.camel@localhost.localdomain> +In-Reply-To: <1110732664.4659.13.camel@localhost.localdomain> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------090701050400070602010807" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/221 +X-Sequence-Number: 10926 + +This is a multi-part message in MIME format. +--------------090701050400070602010807 +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 8bit + +Hi Ragnar, + +Ragnar Hafstað wrote: + +>[snip output of EXPLAIN ANALYZE] +> +>for those of us who have not yet reached the level where one can +>infer it from the query plan, how abour showing us the actual +>query too ? +> +> +I thought it will be sufficient to show me where the main bottleneck is. +And in fact, the query is rather lengthy. But I have included it in the +response to John. So sorry for the incompletness. + +>but as an example of what to look for, consider the first few lines +>(reformatted): +> +> +>>Merge Right Join (cost=9868.84..9997.74 rows=6364 width=815) +>> (actual time=9982.022..10801.216 rows=6364 loops=1) +>> Merge Cond: ("outer".idpk = "inner".cadastralunitidfk) +>> -> Index Scan using cadastralunits_pkey on cadastralunits +>> (cost=0.00..314.72 rows=13027 width=31) +>> (actual time=0.457..0.552 rows=63 loops=1) +>> -> Sort (cost=9868.84..9884.75 rows=6364 width=788) +>> (actual time=9981.405..10013.708 rows=6364 loops=1) +>> +>> +>notice that the index scan is expected to return 13027 rows, but +>actually returns 63. this might influence the a choice of plan. +> +> +Yes, the situation in this scenario is that the table of CadastralUnits +contains all units from country but the AdDevices in this case are only +from the 63 CadastralUnits. So the result - 63 rows - is just this +little subset. Up to that, not all AdDevices have CadastralUnitIDFK set +to an IDPK that exists in CadastralUnits but to zero (= no CadastralUnit +set). + +>gnari +> +> +Miroslav Šulc + +--------------090701050400070602010807 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +YmVnaW46dmNhcmQNCmZuO3F1b3RlZC1wcmludGFibGU6TWlyb3NsYXYgPUM1PUEwdWxjDQpu +O3F1b3RlZC1wcmludGFibGU6PUM1PUEwdWxjO01pcm9zbGF2DQpvcmc6U3RhcnROZXQgcy5y +Lm8uDQphZHI7cXVvdGVkLXByaW50YWJsZTtxdW90ZWQtcHJpbnRhYmxlOjs7VnJjaGxpY2s9 +QzM9QTlobyAxNjEvNTtQcmFoYSA1OzsxNTAgMDA7PUM0PThDZXNrPUMzPUExIHJlcHVibGlr +YQ0KZW1haWw7aW50ZXJuZXQ6bWlyb3NsYXYuc3VsY0BzdGFydG5ldC5jeg0KdGl0bGU6Q0VP +DQp0ZWw7d29yazorNDIwIDI1NyAyMjUgNjAyDQp0ZWw7Y2VsbDorNDIwIDYwMyA3MTEgNDEz +DQp4LW1vemlsbGEtaHRtbDpUUlVFDQp1cmw6aHR0cDovL3d3dy5zdGFydG5ldC5jeg0KdmVy +c2lvbjoyLjENCmVuZDp2Y2FyZA0KDQo= +--------------090701050400070602010807-- + +From pgsql-performance-owner@postgresql.org Sun Mar 13 17:30:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 69033566D0 + for ; + Sun, 13 Mar 2005 17:30:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85483-03 + for ; + Sun, 13 Mar 2005 17:30:31 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id F293F566CC + for ; + Sun, 13 Mar 2005 17:30:27 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j2DHUQl2011525; (envelope-from ) Sun, + 13 Mar 2005 11:30:26 -0600 (CST) +Received: from [192.168.1.13] (12-217-241-0.client.mchsi.com [12.217.241.0]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j2DHUPPW020251 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Sun, + 13 Mar 2005 11:30:26 -0600 (CST) +Message-ID: <423478B1.7080106@arbash-meinel.com> +Date: Sun, 13 Mar 2005 11:30:25 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?ISO-8859-2?Q?Miroslav_=A9ulc?= +Cc: PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> +In-Reply-To: <42347407.2000202@startnet.cz> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig231672C9C2218E88EB8E8560" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/222 +X-Sequence-Number: 10927 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig231672C9C2218E88EB8E8560 +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 8bit + +Miroslav �ulc wrote: + +> Hi John, +> +> thank you for your response. +> +How about a quick side track. +Have you played around with your shared_buffers, maintenance_work_mem, +and work_mem settings? +What version of postgres are you using? The above names changed in 8.0, +and 8.0 also has some perfomance improvements over the 7.4 series. + +What is your hardware? Are you testing this while there is load on the +system, or under no load. +Are you re-running the query multiple times, and reporting the later +speeds, or just the first time? (If nothing is loaded into memory, the +first run is easily 10x slower than later ones.) + +Just some background info. If you have set these to reasonable values, +we probably don't need to spend much time here, but it's just one of +those things to check. + +John +=:-> + + +--------------enig231672C9C2218E88EB8E8560 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCNHixJdeBCYSNAAMRAn7vAJ4rU076R+1NsOnF+DR2kU44L4OR5ACeNjIe +98k3dWkuppK7+0uA5wWUpG0= +=z6R9 +-----END PGP SIGNATURE----- + +--------------enig231672C9C2218E88EB8E8560-- + +From pgsql-performance-owner@postgresql.org Sun Mar 13 17:50:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E52845667C + for ; + Sun, 13 Mar 2005 17:50:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87814-05 + for ; + Sun, 13 Mar 2005 17:50:26 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id CC6BF5657E + for ; + Sun, 13 Mar 2005 17:50:25 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j2DHoPDt011802; (envelope-from ) Sun, + 13 Mar 2005 11:50:25 -0600 (CST) +Received: from [192.168.1.13] (12-217-241-0.client.mchsi.com [12.217.241.0]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j2DHoNj4022359 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Sun, + 13 Mar 2005 11:50:24 -0600 (CST) +Message-ID: <42347D5E.9000900@arbash-meinel.com> +Date: Sun, 13 Mar 2005 11:50:22 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?ISO-8859-2?Q?Miroslav_=A9ulc?= +Cc: PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> +In-Reply-To: <42347407.2000202@startnet.cz> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig952127B4890254E52799F9DB" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.315 tagged_above=0 required=5 tests=AWL, URIBL_SBL +X-Spam-Level: +X-Archive-Number: 200503/223 +X-Sequence-Number: 10928 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig952127B4890254E52799F9DB +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 8bit + +Miroslav �ulc wrote: + +> Hi John, +> +> thank you for your response. +> +I will comment on things separately. + +> John Arbash Meinel wrote: +> +... + +> These external tables contain information that are a unique parameter +> of the AdDevice (like Position, Region, County, City etc.), in some +> containing localized description of the property attribute. Some of +> them could be moved into the main table but that would create a +> redundancy, some of them cannot be moved into the main table (like +> information about Partners which is definitely another object with +> respect to AdDevices). I think the names of the tables are +> self-explanatory so it should be clear what each table stores. Is this +> design incorrect? +> +It's actually more of a question as to why you are doing left outer +joins, rather than simple joins. +Are the tables not fully populated? If so, why not? + +How are you using this information? Why is it useful to get back rows +that don't have all of their information filled out? +Why is it useful to have so many columns returned? It seems like it most +cases, you are only going to be able to use *some* of the information, +why not create more queries that are specialized, rather than one get +everything query. + +> In fact, we only need about 30 records at a time but LIMIT can +> speed-up the query only when looking for the first 30 records. Setting +> OFFSET slows the query down. +> +Have you thought about using a cursor instead of using limit + offset? +This may not help the overall time, but it might let you split up when +the time is spent. +BEGIN; +DECLARE CURSOR FOR SELECT ... FROM ...; +FETCH FORWARD 30 FROM ; +FETCH FORWARD 30 FROM ; +... +END; + +>> I don't +>> really know what you are looking for, but you are joining against enough +>> tables, that I think this query is always going to be slow. +> +> +> In MySQL the query was not so slow and I don't see any reason why +> there should be large differences in SELECT speed. But if the design +> of the tables is incorrect, we will correct it. +> +In the other post I asked about your postgres settings. The defaults are +pretty stingy, so that *might* be an issue. + +>> From what I can tell, you have 1 table which has 6364 rows, and you are +>> grabbing all of those rows, and then outer joining it with about 11 +>> other tables. +> +> +> Here are the exact numbers: +> +> AdDevicesSites - 6364 +> AdDevicesSiteRegions - 15 +> AdDevicesSiteCounties - 110 +> AdDevicesSiteCities - 124 +> AdDevicesSiteStreets - 2858 +> AdDevicesSiteStreetDescriptions - 4585 +> AdDevicesSiteDistricts - 344 +> AdDevicesSiteSizes - 110 +> AdDevicesSiteVisibilities - 4 +> AdDevicesSitePositions - 3 +> AdDevicesSiteStatusTypes - 5 +> PartnerIdentifications - 61 +> Partners - 61 +> CadastralUnits - 13027 +> +And if I understand correctly, you consider all of these to be outer +joins. Meaning you want *all* of AdDevicesSites, and whatever info goes +along with it, but there are no restrictions as to what rows you want. +You want everything you can get. + +Do you actually need *everything*? You mention only needing 30, what for? + +>> I would actually guess that the most expensive parts of the plan are the +>> NESTED LOOPS which when they go to materialize have to do a sequential +>> scan, and they get executed 6364 times. It looks like the other tables +>> are small (only 3-5 rows), so it takes about 0.05 ms for each seqscan, +>> the problem is that because you are doing it 6k times, it ends up taking +>> about 300ms of your time. +>> +>> You could try setting "set enable_nestloop to off". +>> I don't know that it will be faster, but it could be. +> +> +> I have tried that and it resulted in about 2 sec slowdown :-( + +Generally, the optimizer *does* select the best query plan. As long as +it has accurate statistics, which it seems to in this case. + +> +>> In general, though, it seems like you should be asking a different +>> question, rather than trying to optimize the query that you have. +> +> +> You mean "how should I improve the design to make the query faster"? +> +There is one possibility if we don't find anything nicer. Which is to +create a lazy materialized view. Basically, you run this query, and +store it in a table. Then when you want to do the SELECT, you just do +that against the unrolled table. +You can then create triggers, etc to keep the data up to date. +Here is a good documentation of it: +http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html + +It is basically a way that you can un-normalize data, in a safe way. + +Also, another thing that you can do, is instead of using a cursor, you +can create a temporary table with the results of the query, and create a +primary key which is just a simple counter. Then instead of doing limit ++ offset, you can select * where id > 0 and id < 30; ... select * where +id > 30 and id < 60; etc. + +It still requires the original query to be run, though, so it is not +necessarily optimal for you. + +>> Can you post the original SQL statement, and maybe describe what you are +>> trying to do? +> +> +> I hope the explanation above is clear and sufficient :-) +> +>> +>> John +>> =:-> +> + +Unfortunately, I don't really see any obvious problems with your query +in the way that you are using it. The problem is that you are not +applying any selectivity, so postgres has to go to all the tables, and +get all the rows, and then try to logically merge them together. It is +doing a hash merge, which is generally one of the faster ones and it +seems to be doing the right thing. + +I would be curious to see how mysql was handling this query, to see if +there was something different it was trying to do. I'm also curious how +much of a difference there was. + +John +=:-> + + +--------------enig952127B4890254E52799F9DB +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCNH1eJdeBCYSNAAMRAouDAJ0QzYAwZ0tzdDeq7x36zTE+VoyVDACcD4ul +WrA0bOI5m2f/E4NpAwQZSpY= +=/YsJ +-----END PGP SIGNATURE----- + +--------------enig952127B4890254E52799F9DB-- + +From pgsql-performance-owner@postgresql.org Sun Mar 13 18:10:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E2CB566DE + for ; + Sun, 13 Mar 2005 18:10:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94622-03 + for ; + Sun, 13 Mar 2005 18:10:19 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 71F46566E0 + for ; + Sun, 13 Mar 2005 18:10:17 +0000 (GMT) +Received: (qmail 31973 invoked from network); 13 Mar 2005 19:10:17 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by mail.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 13 Mar 2005 19:10:17 +0100 +Message-ID: <4234820D.5080301@startnet.cz> +Date: Sun, 13 Mar 2005 19:10:21 +0100 +From: =?ISO-8859-2?Q?Miroslav_=A9ulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: John Arbash Meinel +Cc: PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <423478B1.7080106@arbash-meinel.com> +In-Reply-To: <423478B1.7080106@arbash-meinel.com> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------040709050505070601070105" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/224 +X-Sequence-Number: 10929 + +This is a multi-part message in MIME format. +--------------040709050505070601070105 +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 7bit + +John Arbash Meinel wrote: + +> How about a quick side track. +> Have you played around with your shared_buffers, maintenance_work_mem, +> and work_mem settings? + +I have tried to set shared_buffers to 48000 now but no speedup +(11,098.813 ms third try). The others are still default. I'll see +documentation and will play with the other parameters. + +> What version of postgres are you using? + +8.0.1 + +> The above names changed in 8.0, +> and 8.0 also has some perfomance improvements over the 7.4 series. +> +> What is your hardware? + +My dev notebook Acer TravelMate 292LMi +$ cat /proc/cpuinfo +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 9 +model name : Intel(R) Pentium(R) M processor 1500MHz +stepping : 5 +cpu MHz : 1495.485 +cache size : 1024 KB +fdiv_bug : no +hlt_bug : no +f00f_bug : no +coma_bug : no +fpu : yes +fpu_exception : yes +cpuid level : 2 +wp : yes +flags : fpu vme de pse tsc msr mce cx8 sep mtrr pge mca cmov +pat clflush dts acpi mmx fxsr sse sse2 tm pbe est tm2 +bogomips : 2957.31 + +$ cat /proc/meminfo +MemTotal: 516136 kB +MemFree: 18024 kB +Buffers: 21156 kB +Cached: 188868 kB +SwapCached: 24 kB +Active: 345596 kB +Inactive: 119344 kB +HighTotal: 0 kB +HighFree: 0 kB +LowTotal: 516136 kB +LowFree: 18024 kB +SwapTotal: 1004020 kB +SwapFree: 1003996 kB +Dirty: 4 kB +Writeback: 0 kB +Mapped: 343676 kB +Slab: 18148 kB +CommitLimit: 1262088 kB +Committed_AS: 951536 kB +PageTables: 2376 kB +VmallocTotal: 516056 kB +VmallocUsed: 90528 kB +VmallocChunk: 424912 kB + +IDE disc. + +# hdparm -Tt /dev/hda +/dev/hda: + Timing cached reads: 1740 MB in 2.00 seconds = 870.13 MB/sec + Timing buffered disk reads: 40 MB in 3.30 seconds = 12.10 MB/sec + +> Are you testing this while there is load on the +> system, or under no load. + +The load is low. This is few seconds after I have run the EXPLAIN ANALYZE. + +# cat /proc/loadavg +0.31 0.51 0.33 1/112 6909 + +> Are you re-running the query multiple times, and reporting the later +> speeds, or just the first time? (If nothing is loaded into memory, the +> first run is easily 10x slower than later ones.) + +The times changes only little. First run was about 13 sec, second about +10 sec, third about 11 sec etc. + +> Just some background info. If you have set these to reasonable values, +> we probably don't need to spend much time here, but it's just one of +> those things to check. + +Sure you are right. I'll try the other parameters. + +> +> John +> =:-> +> +Miroslav + +--------------040709050505070601070105 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------040709050505070601070105-- + +From pgsql-performance-owner@postgresql.org Sun Mar 13 19:07:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9536E563E2 + for ; + Sun, 13 Mar 2005 19:07:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06342-02 + for ; + Sun, 13 Mar 2005 19:06:58 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 64C7B56371 + for ; + Sun, 13 Mar 2005 19:06:56 +0000 (GMT) +Received: (qmail 31875 invoked from network); 13 Mar 2005 20:06:56 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by ns.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 13 Mar 2005 20:06:56 +0100 +Message-ID: <42348F54.1000408@startnet.cz> +Date: Sun, 13 Mar 2005 20:07:00 +0100 +From: =?ISO-8859-2?Q?Miroslav_=A9ulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: John Arbash Meinel +Cc: PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> +In-Reply-To: <42347D5E.9000900@arbash-meinel.com> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------090607070107030402010008" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.138 tagged_above=0 required=5 tests=AWL, URIBL_SBL +X-Spam-Level: +X-Archive-Number: 200503/225 +X-Sequence-Number: 10930 + +This is a multi-part message in MIME format. +--------------090607070107030402010008 +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 7bit + +John Arbash Meinel wrote: + +> It's actually more of a question as to why you are doing left outer +> joins, rather than simple joins. +> Are the tables not fully populated? If so, why not? + +Some records do not consist of full information (they are collected from +different sources which use different approach to the data collection) +so using INNER JOIN would cause some records wouldn't be displayed which +is unacceptable. + +> How are you using this information? Why is it useful to get back rows +> that don't have all of their information filled out? + +Each row contains main information which are important. The other +information are also important but may be missing. Information are +display on lists of 30 rows or on a card. When using filter the query is +much faster but the case without filter has these results. + +> Why is it useful to have so many columns returned? It seems like it most +> cases, you are only going to be able to use *some* of the information, +> why not create more queries that are specialized, rather than one get +> everything query. + +Many of the columns are just varchar(1) (because of the migration from +MySQL enum field type) so the record is not so long as it could seem. +These fields are just switches (Y(es) or N(o)). The problem is users can +define their own templates and in different scenarios there might be +displayed different information so reducing the number of fields would +mean in some cases it wouldn't work as expected. But if we couldn't +speed the query up, we will try to improve it other way. +Is there any serious reason not to use so much fields except memory +usage? It seems to me that it shouldn't have a great impact on the speed +in this case. + +> Have you thought about using a cursor instead of using limit + offset? +> This may not help the overall time, but it might let you split up when +> the time is spent. +> ...... + +No. I come from MySQL world where these things are not common (at least +when using MyISAM databases). The other reason (if I understand it well) +is that the retrieval of the packages of 30 records is not sequential. +Our app is web based and we use paging. User can select page 1 and then +page 10, then go backward to page 9 etc. + +> And if I understand correctly, you consider all of these to be outer +> joins. Meaning you want *all* of AdDevicesSites, and whatever info goes +> along with it, but there are no restrictions as to what rows you want. +> You want everything you can get. +> +> Do you actually need *everything*? You mention only needing 30, what for? + +For display of single page consisting of 30 rows. The reason I query all +rows is that this is one of the filters users can use. User can display +just bigboards or billboards (or specify more advanced filters) but +he/she can also display AdDevices without any filter (page by page). +Before I select the 30 row, I need to order them by a key and after that +select the records, so this is also the reason why to ask for all rows. +The key for sorting might be different for each run. + +> There is one possibility if we don't find anything nicer. Which is to +> create a lazy materialized view. Basically, you run this query, and +> store it in a table. Then when you want to do the SELECT, you just do +> that against the unrolled table. +> You can then create triggers, etc to keep the data up to date. +> Here is a good documentation of it: +> http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html +> +> It is basically a way that you can un-normalize data, in a safe way. +> +> Also, another thing that you can do, is instead of using a cursor, you +> can create a temporary table with the results of the query, and create a +> primary key which is just a simple counter. Then instead of doing limit +> + offset, you can select * where id > 0 and id < 30; ... select * where +> id > 30 and id < 60; etc. +> +> It still requires the original query to be run, though, so it is not +> necessarily optimal for you. + +These might be the other steps in case we cannot speed-up the query. I +would prefer to speed the query up :-) + +> Unfortunately, I don't really see any obvious problems with your query +> in the way that you are using it. The problem is that you are not +> applying any selectivity, so postgres has to go to all the tables, and +> get all the rows, and then try to logically merge them together. It is +> doing a hash merge, which is generally one of the faster ones and it +> seems to be doing the right thing. +> +> I would be curious to see how mysql was handling this query, to see if +> there was something different it was trying to do. I'm also curious how +> much of a difference there was. + +In fact, on MySQL I didn't see any slow reactions so I didn't measure +and inspect it. But I can try it if I figure out how to copy the +database from PostgreSQL to MySQL. + +> +> John +> =:-> +> +Thank you for your time and help. + +Miroslav + +--------------090607070107030402010008 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------090607070107030402010008-- + +From pgsql-performance-owner@postgresql.org Sun Mar 13 19:16:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 81E8856587 + for ; + Sun, 13 Mar 2005 19:16:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08129-09 + for ; + Sun, 13 Mar 2005 19:15:56 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id B091652A56 + for ; + Sun, 13 Mar 2005 19:15:55 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2DJFsvr018382; + Sun, 13 Mar 2005 14:15:54 -0500 (EST) +To: John Arbash Meinel +Cc: =?ISO-8859-2?Q?Miroslav_=A9ulc?= , + PGSQL mailing list +Subject: Re: How to read query plan +In-reply-to: <423478B1.7080106@arbash-meinel.com> +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <423478B1.7080106@arbash-meinel.com> +Comments: In-reply-to John Arbash Meinel + message dated "Sun, 13 Mar 2005 11:30:25 -0600" +Date: Sun, 13 Mar 2005 14:15:54 -0500 +Message-ID: <18381.1110741354@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/226 +X-Sequence-Number: 10931 + +John Arbash Meinel writes: +> How about a quick side track. +> Have you played around with your shared_buffers, maintenance_work_mem, +> and work_mem settings? + +Indeed. The hash joins seem unreasonably slow considering how little +data they are processing (unless this is being run on some ancient +toaster...). One thought that comes to mind is that work_mem may be +set so small that the hashes are forced into multiple batches. + +Another question worth asking is what are the data types of the columns +being joined on. If they are character types, what locale and encoding +is the database using? + +> Are you re-running the query multiple times, and reporting the later +> speeds, or just the first time? (If nothing is loaded into memory, the +> first run is easily 10x slower than later ones.) + +That cost would be paid during the bottom-level scans though. The thing +that strikes me here is that nearly all of the cost is being spent +joining. + +> What version of postgres are you using? + +And what's the platform (hardware and OS)? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 13 19:26:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ED8A356521 + for ; + Sun, 13 Mar 2005 19:26:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09754-05 + for ; + Sun, 13 Mar 2005 19:26:35 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id E2FA6563A5 + for ; + Sun, 13 Mar 2005 19:26:34 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j2DJQZr7012944; (envelope-from ) Sun, + 13 Mar 2005 13:26:35 -0600 (CST) +Received: from [192.168.1.13] (12-217-241-0.client.mchsi.com [12.217.241.0]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j2DJQX5a002875 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Sun, + 13 Mar 2005 13:26:34 -0600 (CST) +Message-ID: <423493E5.6040203@arbash-meinel.com> +Date: Sun, 13 Mar 2005 13:26:29 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?ISO-8859-2?Q?Miroslav_=A9ulc?= +Cc: PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> + <42348F54.1000408@startnet.cz> +In-Reply-To: <42348F54.1000408@startnet.cz> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig93FAA8B7BBEF58F5248439E7" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/227 +X-Sequence-Number: 10932 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig93FAA8B7BBEF58F5248439E7 +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 8bit + +Miroslav �ulc wrote: + +> John Arbash Meinel wrote: + +... + +> Many of the columns are just varchar(1) (because of the migration from +> MySQL enum field type) so the record is not so long as it could seem. +> These fields are just switches (Y(es) or N(o)). The problem is users +> can define their own templates and in different scenarios there might +> be displayed different information so reducing the number of fields +> would mean in some cases it wouldn't work as expected. But if we +> couldn't speed the query up, we will try to improve it other way. +> Is there any serious reason not to use so much fields except memory +> usage? It seems to me that it shouldn't have a great impact on the +> speed in this case. + +Is there a reason to use varchar(1) instead of char(1). There probably +is 0 performance difference, I'm just curious. + +> +>> Have you thought about using a cursor instead of using limit + offset? +>> This may not help the overall time, but it might let you split up when +>> the time is spent. +>> ...... +> +> +> No. I come from MySQL world where these things are not common (at +> least when using MyISAM databases). The other reason (if I understand +> it well) is that the retrieval of the packages of 30 records is not +> sequential. Our app is web based and we use paging. User can select +> page 1 and then page 10, then go backward to page 9 etc. +> +Well, with cursors you can also do "FETCH ABSOLUTE 1 FROM +", which sets the cursor position, and then you can "FETCH +FORWARD 30". +I honestly don't know how the performance will be, but it is something +that you could try. + +>> And if I understand correctly, you consider all of these to be outer +>> joins. Meaning you want *all* of AdDevicesSites, and whatever info goes +>> along with it, but there are no restrictions as to what rows you want. +>> You want everything you can get. +>> +>> Do you actually need *everything*? You mention only needing 30, what +>> for? +> +> +> For display of single page consisting of 30 rows. The reason I query +> all rows is that this is one of the filters users can use. User can +> display just bigboards or billboards (or specify more advanced +> filters) but he/she can also display AdDevices without any filter +> (page by page). Before I select the 30 row, I need to order them by a +> key and after that select the records, so this is also the reason why +> to ask for all rows. The key for sorting might be different for each run. +> +How are you caching the information in the background in order to +support paging? Since you aren't using limit/offset, and you don't seem +to be creating a temporary table, I assume you have a layer inbetween +the web server and the database (or possibly inside the webserver) which +keeps track of current session information. Is that true? + +> These might be the other steps in case we cannot speed-up the query. I +> would prefer to speed the query up :-) + +Naturally fast query comes first. I just have the feeling it is either a +postgres configuration problem, or an intrinsic problem to postgres. +Given your constraints, there's not much that we can change about the +query itself. + +> In fact, on MySQL I didn't see any slow reactions so I didn't measure +> and inspect it. But I can try it if I figure out how to copy the +> database from PostgreSQL to MySQL. + +I figured you still had a copy of the MySQL around to compare to. You +probably don't need to spend too much time on it yet. + +John +=:-> + +--------------enig93FAA8B7BBEF58F5248439E7 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCNJPpJdeBCYSNAAMRAkhzAJ42BdbB9zZAw4Pzm22DdlDe89Aw/gCgs7PD +i3k8saCxAiCYvpoujPJzO3E= +=o/ya +-----END PGP SIGNATURE----- + +--------------enig93FAA8B7BBEF58F5248439E7-- + +From pgsql-performance-owner@postgresql.org Sun Mar 13 19:44:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B90FD565E9 + for ; + Sun, 13 Mar 2005 19:44:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13871-05 + for ; + Sun, 13 Mar 2005 19:43:53 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 67A4A565AF + for ; + Sun, 13 Mar 2005 19:43:51 +0000 (GMT) +Received: (qmail 9130 invoked from network); 13 Mar 2005 20:43:52 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by sranda.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 13 Mar 2005 20:43:52 +0100 +Message-ID: <423497FE.6040908@startnet.cz> +Date: Sun, 13 Mar 2005 20:43:58 +0100 +From: =?windows-1250?Q?Miroslav_=8Aulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: John Arbash Meinel , + PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <423478B1.7080106@arbash-meinel.com> + <18381.1110741354@sss.pgh.pa.us> +In-Reply-To: <18381.1110741354@sss.pgh.pa.us> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------070302000306050507080505" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/228 +X-Sequence-Number: 10933 + +This is a multi-part message in MIME format. +--------------070302000306050507080505 +Content-Type: text/plain; charset=windows-1250; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>John Arbash Meinel writes: +> +> +>>How about a quick side track. +>>Have you played around with your shared_buffers, maintenance_work_mem, +>>and work_mem settings? +>> +>> +> +>Indeed. The hash joins seem unreasonably slow considering how little +>data they are processing (unless this is being run on some ancient +>toaster...). One thought that comes to mind is that work_mem may be +>set so small that the hashes are forced into multiple batches. +> +> +I've just tried to uncomment the settings for these parameters with with +no impact on the query speed. + +shared_buffers = 48000 # min 16, at least max_connections*2, +8KB each +work_mem = 1024 # min 64, size in KB +maintenance_work_mem = 16384 # min 1024, size in KB +max_stack_depth = 2048 # min 100, size in KB + +>Another question worth asking is what are the data types of the columns +>being joined on. If they are character types, what locale and encoding +>is the database using? +> +> +I have checked this and there are some JOINs smallint against integer. +Is that problem? I would use smallint for IDPKs of some smaller tables +but the lack of SMALLSERIAL and my laziness made me use SERIAL instead +which is integer. + +>That cost would be paid during the bottom-level scans though. The thing +>that strikes me here is that nearly all of the cost is being spent +>joining. +> +> +>>What version of postgres are you using? +>> +>> +> +>And what's the platform (hardware and OS)? +> +> +I've already posted the hardware info. OS is Linux (Gentoo) with kernel +2.6.11. + +> regards, tom lane +> +> +Miroslav + +--------------070302000306050507080505 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------070302000306050507080505-- + +From pgsql-performance-owner@postgresql.org Sun Mar 13 19:51:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D25135662F + for ; + Sun, 13 Mar 2005 19:51:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13871-10 + for ; + Sun, 13 Mar 2005 19:50:59 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 792FB565E9 + for ; + Sun, 13 Mar 2005 19:50:58 +0000 (GMT) +Received: (qmail 17102 invoked from network); 13 Mar 2005 20:50:58 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by mail.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 13 Mar 2005 20:50:58 +0100 +Message-ID: <423499A9.5080504@startnet.cz> +Date: Sun, 13 Mar 2005 20:51:05 +0100 +From: =?ISO-8859-2?Q?Miroslav_=A9ulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: John Arbash Meinel +Cc: PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> + <42348F54.1000408@startnet.cz> <423493E5.6040203@arbash-meinel.com> +In-Reply-To: <423493E5.6040203@arbash-meinel.com> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------040805050708000200020000" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/229 +X-Sequence-Number: 10934 + +This is a multi-part message in MIME format. +--------------040805050708000200020000 +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 7bit + +John Arbash Meinel wrote: + +> Is there a reason to use varchar(1) instead of char(1). There probably +> is 0 performance difference, I'm just curious. + +No, not at all. I'm just not used to char(). + +> Well, with cursors you can also do "FETCH ABSOLUTE 1 FROM +> ", which sets the cursor position, and then you can "FETCH +> FORWARD 30". +> I honestly don't know how the performance will be, but it is something +> that you could try. + +This is science for me at this moment :-) + +>> For display of single page consisting of 30 rows. The reason I query +>> all rows is that this is one of the filters users can use. User can +>> display just bigboards or billboards (or specify more advanced +>> filters) but he/she can also display AdDevices without any filter +>> (page by page). Before I select the 30 row, I need to order them by a +>> key and after that select the records, so this is also the reason why +>> to ask for all rows. The key for sorting might be different for each +>> run. +>> +> How are you caching the information in the background in order to +> support paging? Since you aren't using limit/offset, and you don't seem +> to be creating a temporary table, I assume you have a layer inbetween +> the web server and the database (or possibly inside the webserver) which +> keeps track of current session information. Is that true? + +I just need three information: +1) used filter (stored in session, identified by filter index in query +string) +2) page length (static predefined) +3) what page to display (in query string) + +>> In fact, on MySQL I didn't see any slow reactions so I didn't measure +>> and inspect it. But I can try it if I figure out how to copy the +>> database from PostgreSQL to MySQL. +> +> +> I figured you still had a copy of the MySQL around to compare to. You +> probably don't need to spend too much time on it yet. + +It's not so simple because there are some differences between MySQL and +PostgreSQL in how they handle case sensitivity etc. The database table +structures are not the same too because of different data types support +and data values support. + +> +> John +> =:-> + +Miroslav + +--------------040805050708000200020000 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------040805050708000200020000-- + +From pgsql-performance-owner@postgresql.org Sun Mar 13 19:54:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1627D56638 + for ; + Sun, 13 Mar 2005 19:54:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17522-01 + for ; + Sun, 13 Mar 2005 19:54:36 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id D4F1256629 + for ; + Sun, 13 Mar 2005 19:54:35 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2DJsXku019294; + Sun, 13 Mar 2005 14:54:33 -0500 (EST) +To: =?windows-1250?Q?Miroslav_=8Aulc?= +Cc: John Arbash Meinel , + PGSQL mailing list +Subject: Re: How to read query plan +In-reply-to: <423497FE.6040908@startnet.cz> +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <423478B1.7080106@arbash-meinel.com> + <18381.1110741354@sss.pgh.pa.us> <423497FE.6040908@startnet.cz> +Comments: In-reply-to =?windows-1250?Q?Miroslav_=8Aulc?= + + message dated "Sun, 13 Mar 2005 20:43:58 +0100" +Date: Sun, 13 Mar 2005 14:54:33 -0500 +Message-ID: <19293.1110743673@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/230 +X-Sequence-Number: 10935 + +=?windows-1250?Q?Miroslav_=8Aulc?= writes: +> I've just tried to uncomment the settings for these parameters with with +> no impact on the query speed. + +> shared_buffers = 48000 # min 16, at least max_connections*2, +> 8KB each +> work_mem = 1024 # min 64, size in KB +> maintenance_work_mem = 16384 # min 1024, size in KB +> max_stack_depth = 2048 # min 100, size in KB + +Hmm. Given the small size of the auxiliary tables, you'd think they'd +fit in 1MB work_mem no problem. But try bumping work_mem up to 10MB +just to see if it makes a difference. (BTW, you do know that altering +the .conf file doesn't in itself do anything? You have to SIGHUP the +postmaster to make it notice the change ... and for certain parameters +such as shared_buffers, you actually have to stop and restart the +postmaster. You can use the SHOW command to verify whether a change +has taken effect.) + +> I have checked this and there are some JOINs smallint against integer. +> Is that problem? + +That probably explains why some of the joins are merges instead of +hashes --- hash join doesn't work across datatypes. Doesn't seem like +it should be a huge problem though. I was more concerned about the +possibility of slow locale-dependent string comparisons. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 13 20:03:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 14CEC5662A + for ; + Sun, 13 Mar 2005 20:03:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17964-09 + for ; + Sun, 13 Mar 2005 20:03:29 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 5ECAE56626 + for ; + Sun, 13 Mar 2005 20:03:27 +0000 (GMT) +Received: (qmail 31552 invoked from network); 13 Mar 2005 21:03:28 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by ns.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 13 Mar 2005 21:03:28 +0100 +Message-ID: <42349C96.60401@startnet.cz> +Date: Sun, 13 Mar 2005 21:03:34 +0100 +From: =?windows-1250?Q?Miroslav_=8Aulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: John Arbash Meinel , + PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <423478B1.7080106@arbash-meinel.com> + <18381.1110741354@sss.pgh.pa.us> <423497FE.6040908@startnet.cz> + <19293.1110743673@sss.pgh.pa.us> +In-Reply-To: <19293.1110743673@sss.pgh.pa.us> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------000100030707080605050102" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/231 +X-Sequence-Number: 10936 + +This is a multi-part message in MIME format. +--------------000100030707080605050102 +Content-Type: text/plain; charset=windows-1250; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>=?windows-1250?Q?Miroslav_=8Aulc?= writes: +> +> +>>shared_buffers = 48000 # min 16, at least max_connections*2, +>>8KB each +>>work_mem = 1024 # min 64, size in KB +>>maintenance_work_mem = 16384 # min 1024, size in KB +>>max_stack_depth = 2048 # min 100, size in KB +>> +>> +> +>Hmm. Given the small size of the auxiliary tables, you'd think they'd +>fit in 1MB work_mem no problem. But try bumping work_mem up to 10MB +>just to see if it makes a difference. (BTW, you do know that altering +>the .conf file doesn't in itself do anything? You have to SIGHUP the +>postmaster to make it notice the change ... and for certain parameters +>such as shared_buffers, you actually have to stop and restart the +>postmaster. You can use the SHOW command to verify whether a change +>has taken effect.) +> +> +I've tried to set work_mem to 10240, restarted postmaster and tried the +EXPLAIN ANALYZE but there is only cca 200 ms speedup. + +>>I have checked this and there are some JOINs smallint against integer. +>>Is that problem? +>> +>> +>That probably explains why some of the joins are merges instead of +>hashes --- hash join doesn't work across datatypes. Doesn't seem like +>it should be a huge problem though. I was more concerned about the +>possibility of slow locale-dependent string comparisons. +> +> +There are only JOINs number against number. I've tried to change one of +the fields from smallint to integer but there was no speedup. + +> regards, tom lane +> +> +Miroslav + +--------------000100030707080605050102 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------000100030707080605050102-- + +From pgsql-performance-owner@postgresql.org Sun Mar 13 20:26:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D2955662A + for ; + Sun, 13 Mar 2005 20:26:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24526-01 + for ; + Sun, 13 Mar 2005 20:26:28 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 493D35665A + for ; + Sun, 13 Mar 2005 20:26:27 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2DKQR61003175; + Sun, 13 Mar 2005 15:26:27 -0500 (EST) +To: =?windows-1250?Q?Miroslav_=8Aulc?= +Cc: John Arbash Meinel , + PGSQL mailing list +Subject: Re: How to read query plan +In-reply-to: <42349C96.60401@startnet.cz> +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <423478B1.7080106@arbash-meinel.com> + <18381.1110741354@sss.pgh.pa.us> <423497FE.6040908@startnet.cz> + <19293.1110743673@sss.pgh.pa.us> <42349C96.60401@startnet.cz> +Comments: In-reply-to =?windows-1250?Q?Miroslav_=8Aulc?= + + message dated "Sun, 13 Mar 2005 21:03:34 +0100" +Date: Sun, 13 Mar 2005 15:26:27 -0500 +Message-ID: <3174.1110745587@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/232 +X-Sequence-Number: 10937 + +=?windows-1250?Q?Miroslav_=8Aulc?= writes: +> There are only JOINs number against number. + +Hmph. There's no reason I can see that hash joins should be as slow as +they seem to be in your test. + +Is the data confidential? If you'd be willing to send me a pg_dump +off-list, I'd like to replicate this test and try to see where the time +is going. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Mon Mar 14 00:08:47 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37AC15666E; + Mon, 14 Mar 2005 00:08:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78364-01; Mon, 14 Mar 2005 00:08:40 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 3F7AF56664; + Mon, 14 Mar 2005 00:08:38 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2E08fAj006716; + Sun, 13 Mar 2005 19:08:41 -0500 (EST) +To: =?windows-1250?Q?Miroslav_=8Aulc?= +Cc: pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org +Subject: Re: [PERFORM] How to read query plan +In-reply-to: <4234AF56.1040509@startnet.cz> +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <423478B1.7080106@arbash-meinel.com> + <18381.1110741354@sss.pgh.pa.us> <423497FE.6040908@startnet.cz> + <19293.1110743673@sss.pgh.pa.us> <42349C96.60401@startnet.cz> + <3174.1110745587@sss.pgh.pa.us> <4234AF56.1040509@startnet.cz> +Comments: In-reply-to =?windows-1250?Q?Miroslav_=8Aulc?= + + message dated "Sun, 13 Mar 2005 22:23:34 +0100" +Date: Sun, 13 Mar 2005 19:08:41 -0500 +Message-ID: <6715.1110758921@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/398 +X-Sequence-Number: 65200 + +=?windows-1250?Q?Miroslav_=8Aulc?= writes: +>> Is the data confidential? If you'd be willing to send me a pg_dump +>> off-list, I'd like to replicate this test and try to see where the time +>> is going. +>> +> Thank you very much for your offer. The data are partially confidental +> so I hashed some of the text information and changed some values (not +> the values for the JOINs) so I could send it to you. I've checked the +> EXPLAIN ANALYZE if anything changed and the result is merely the same +> (maybe cca 1 sec slower - maybe because the hash caused the text data to +> be longer). + +No problem; thank you for supplying the test case. What I find is +rather surprising: most of the runtime can be blamed on disassembling +and reassembling tuples during the join steps. Here are the hot spots +according to gprof: + +----------------------------------------------- + 1.27 7.38 8277/103737 ExecScan [16] + 2.93 17.02 19092/103737 ExecNestLoop [14] + 3.91 22.70 25456/103737 ExecMergeJoin [13] + 7.81 45.40 50912/103737 ExecHashJoin [12] +[9] 86.3 15.92 92.50 103737 ExecProject [9] + 7.65 76.45 8809835/9143692 ExecEvalVar [10] + 3.42 4.57 103737/103775 heap_formtuple [17] + 0.03 0.24 12726/143737 ExecMakeFunctionResultNoSets [24] + 0.02 0.12 103737/290777 ExecStoreTuple [44] + 0.01 0.00 2/2 ExecEvalFunc [372] + 0.00 0.00 2/22 ExecMakeFunctionResult [166] +----------------------------------------------- + 0.00 0.00 42/9143692 ExecEvalFuncArgs [555] + 0.05 0.51 59067/9143692 ExecHashGetHashValue [32] + 0.24 2.38 274748/9143692 ExecMakeFunctionResultNoSets [24] + 7.65 76.45 8809835/9143692 ExecProject [9] +[10] 69.5 7.94 79.34 9143692 ExecEvalVar [10] + 79.34 0.00 8750101/9175517 nocachegetattr [11] +----------------------------------------------- + +I think the reason this is popping to the top of the runtime is that the +joins are so wide (an average of ~85 columns in a join tuple according +to the numbers above). Because there are lots of variable-width columns +involved, most of the time the fast path for field access doesn't apply +and we end up going to nocachegetattr --- which itself is going to be +slow because it has to scan over so many columns. So the cost is +roughly O(N^2) in the number of columns. + +As a short-term hack, you might be able to improve matters if you can +reorder your LEFT JOINs to have the minimum number of columns +propagating up from the earlier join steps. In other words make the +later joins add more columns than the earlier, as much as you can. + +This is actually good news, because before 8.0 we had much worse +problems than this with extremely wide tuples --- there were O(N^2) +behaviors all over the place due to the old List algorithms. Neil +Conway's rewrite of the List code got rid of those problems, and now +we can see the places that are left to optimize. The fact that there +seems to be just one is very nice indeed. + +Since ExecProject operations within a nest of joins are going to be +dealing entirely with Vars, I wonder if we couldn't speed matters up +by having a short-circuit case for a projection that is only Vars. +Essentially it would be a lot like execJunk.c, except able to cope +with two input tuples. Using heap_deformtuple instead of retail +extraction of fields would eliminate the O(N^2) penalty for wide tuples. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 14 02:20:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3EB3056466 + for ; + Mon, 14 Mar 2005 01:47:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10341-03 + for ; + Mon, 14 Mar 2005 01:47:21 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 80F0B5643C + for ; + Mon, 14 Mar 2005 01:46:07 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 25DEA30939; Mon, 14 Mar 2005 02:46:10 +0100 (MET) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: One tuple per transaction +Date: Mon, 14 Mar 2005 09:41:30 +0800 +Organization: Hub.Org Networking Services +Lines: 47 +Message-ID: +References: +Reply-To: "Qingqing Zhou" +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.197 tagged_above=0 required=5 tests=AWL, + PRIORITY_NO_NAME +X-Spam-Level: * +X-Archive-Number: 200503/234 +X-Sequence-Number: 10939 + +""Tambet Matiisen"" writes +> Hi! +> +> In one of our applications we have a database function, which +> recalculates COGS (cost of good sold) for certain period. This involves +> deleting bunch of rows from one table, inserting them again in correct +> order and updating them one-by-one (sometimes one row twice) to reflect +> current state. The problem is, that this generates an enormous amount of +> tuples in that table. +> +> If I'm correct, the dead tuples must be scanned also during table and +> index scan, so a lot of dead tuples slows down queries considerably, +> especially when the table doesn't fit into shared buffers any more. And +> as I'm in transaction, I can't VACUUM to get rid of those tuples. In one +> occasion the page count for a table went from 400 to 22000 at the end. + +Not exactly. The dead tuple in the index will be scanned the first time (and +its pointed heap tuple as well), then we will mark it dead, then next time +we came here, we will know that the index tuple actually points to a uesless +tuple, so we will not scan its pointed heap tuple. + +> +> All this made me wonder, why is new tuple created after every update? +> One tuple per transaction should be enough, because you always commit or +> rollback transaction as whole. And my observations seem to indicate, +> that new index tuple is created after column update even if this column +> is not indexed. + +This is one cost of MVCC. A good thing of MVCC is there is no conflict +between read and write - maybe some applications need this. + +A reference could be found here: + +http://www.postgresql.org/docs/8.0/static/storage-page-layout.html#HEAPTUPLEHEADERDATA-TABLE + +> +> One tuple per transaction would save a loads of I/O bandwidth, so I +> believe there must be a reason why it isn't implemented as such. Or were +> my assumptions wrong, that dead tuples must be read from disk? +> +> Tambet +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend +> + + + +From pgsql-performance-owner@postgresql.org Mon Mar 14 04:36:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 589385641F + for ; + Mon, 14 Mar 2005 04:36:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65678-05 + for ; + Mon, 14 Mar 2005 04:36:21 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D148563EB + for ; + Mon, 14 Mar 2005 04:36:20 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DAhJN-0005Or-00; Sun, 13 Mar 2005 23:36:13 -0500 +To: Arshavir Grigorian +Cc: linux-raid@vger.kernel.org, pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +References: <4231F5F2.6000509@m-cam.com> +In-Reply-To: <4231F5F2.6000509@m-cam.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 13 Mar 2005 23:36:13 -0500 +Message-ID: <87hdje7sjm.fsf@stark.xeocode.com> +Lines: 28 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/241 +X-Sequence-Number: 10946 + + +Arshavir Grigorian writes: + +> Hi, +> +> I have a RAID5 array (mdadm) with 14 disks + 1 spare. This partition has an +> Ext3 filesystem which is used by Postgres. + +People are going to suggest moving to RAID1+0. I'm unconvinced that RAID5 +across 14 drivers shouldn't be able to keep up with RAID1 across 7 drives +though. It would be interesting to see empirical data. + +One thing that does scare me is the Postgres transaction log and the ext3 +journal both sharing these disks with the data. Ideally both of these things +should get (mirrored) disks of their own separate from the data files. + +But 2-3s pauses seem disturbing. I wonder whether ext3 is issuing a cache +flush on every fsync to get the journal pushed out. This is a new linux +feature that's necessary with ide but shouldn't be necessary with scsi. + +It would be interesting to know whether postgres performs differently with +fsync=off. This would even be a reasonable mode to run under for initial +database loads. It shouldn't make much of a difference with hardware like this +though. And you should be aware that running under this mode in production +would put your data at risk. + +-- +greg + + +From pgsql-hackers-owner@postgresql.org Mon Mar 14 05:00:28 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9B8AC5676E; + Mon, 14 Mar 2005 05:00:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72960-05; Mon, 14 Mar 2005 05:00:22 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E70056796; + Mon, 14 Mar 2005 05:00:14 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2E50Baw004851; + Mon, 14 Mar 2005 00:00:11 -0500 (EST) +To: =?windows-1250?Q?Miroslav_=8Aulc?= +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] How to read query plan +In-reply-to: <6715.1110758921@sss.pgh.pa.us> +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <423478B1.7080106@arbash-meinel.com> + <18381.1110741354@sss.pgh.pa.us> <423497FE.6040908@startnet.cz> + <19293.1110743673@sss.pgh.pa.us> <42349C96.60401@startnet.cz> + <3174.1110745587@sss.pgh.pa.us> <4234AF56.1040509@startnet.cz> + <6715.1110758921@sss.pgh.pa.us> +Comments: In-reply-to Tom Lane + message dated "Sun, 13 Mar 2005 19:08:41 -0500" +Date: Mon, 14 Mar 2005 00:00:11 -0500 +Message-ID: <4850.1110776411@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/419 +X-Sequence-Number: 65221 + +I wrote: +> Since ExecProject operations within a nest of joins are going to be +> dealing entirely with Vars, I wonder if we couldn't speed matters up +> by having a short-circuit case for a projection that is only Vars. +> Essentially it would be a lot like execJunk.c, except able to cope +> with two input tuples. Using heap_deformtuple instead of retail +> extraction of fields would eliminate the O(N^2) penalty for wide tuples. + +Actually, we already had a pending patch (from Atsushi Ogawa) that +eliminates that particular O(N^2) behavior in another way. After +applying it, I get about a factor-of-4 reduction in the runtime for +Miroslav's example. + +ExecEvalVar and associated routines are still a pretty good fraction of +the runtime, so it might still be worth doing something like the above, +but it'd probably be just a marginal win instead of a big win. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 14 06:29:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B59E5639E + for ; + Mon, 14 Mar 2005 06:29:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94618-04 + for ; + Mon, 14 Mar 2005 06:29:06 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E9A055F4A + for ; + Mon, 14 Mar 2005 06:29:05 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2E6T6iK005581; + Mon, 14 Mar 2005 01:29:06 -0500 (EST) +To: Daniel Schuchardt +Cc: pgsql-performance@postgresql.org +Subject: Re: cpu_tuple_cost +In-reply-to: +References: +Comments: In-reply-to Daniel Schuchardt + message dated "Fri, 11 Mar 2005 15:25:29 +0100" +Date: Mon, 14 Mar 2005 01:29:06 -0500 +Message-ID: <5580.1110781746@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/243 +X-Sequence-Number: 10948 + +Daniel Schuchardt writes: +> i have a query plan who is bad with standard cpu_tuple_costs and good if +> I raise cpu_tuple_costs. Is it is a good practice to raise them if i +> want to force postgres to use indexes more often? + +Reducing random_page_cost is usually the best way to get the planner to +favor indexscans more. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 14 07:16:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F4F356381 + for ; + Mon, 14 Mar 2005 07:16:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06302-01 + for ; + Mon, 14 Mar 2005 07:16:09 +0000 (GMT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by svr1.postgresql.org (Postfix) with ESMTP id 98F5856386 + for ; + Mon, 14 Mar 2005 07:16:09 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.196]) + by svr4.postgresql.org (Postfix) with ESMTP id 6DED25AF5A0 + for ; + Mon, 14 Mar 2005 07:16:10 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id j1so1755560rnf + for ; + Sun, 13 Mar 2005 23:14:09 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; + b=kSkwOVqmJ+Lg+WqcLTicWDffGeZA7TPgMrcJcJA6IkQ692uik8THP9rnTE0BjsxzdQrin7XY3GKlBlp1lwRkDXmKwoIf7OnUUP8Ok5tn9MC8DSps6Saub9NrDYcosM3gFQv2Rinvvg3n2GNnFtW6Q42A/2E1b/A9Z0PONtzDu2k= +Received: by 10.38.78.70 with SMTP id a70mr5012811rnb; + Sun, 13 Mar 2005 23:14:08 -0800 (PST) +Received: by 10.38.97.43 with HTTP; Sun, 13 Mar 2005 23:14:08 -0800 (PST) +Message-ID: <674d1f8a0503132314754df153@mail.gmail.com> +Date: Mon, 14 Mar 2005 12:44:08 +0530 +From: Gourish Singbal +Reply-To: Gourish Singbal +To: pgsql-performance@postgresql.org +Subject: column name is "LIMIT" +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.245 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/244 +X-Sequence-Number: 10949 + +Guys, + +I am having a problem firing queries on one of the tables which is +having "limit" as the column name. + +If a run an insert/select/update command on that table i get the below error. + +ERROR: syntax error at or near "limit" at character 71 + +Any Help would be realyl great to solve the problem. + +postgresql 7.4.5 and linux OS + +-- +Best, +Gourish Singbal + +From pgsql-performance-owner@postgresql.org Mon Mar 14 07:22:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 51FA35639E + for ; + Mon, 14 Mar 2005 07:21:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07931-03 + for ; + Mon, 14 Mar 2005 07:21:42 +0000 (GMT) +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 714CC56399 + for ; + Mon, 14 Mar 2005 07:21:38 +0000 (GMT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 8DAD425054; + Mon, 14 Mar 2005 15:21:31 +0800 (WST) +Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 719D92501A; + Mon, 14 Mar 2005 15:21:31 +0800 (WST) +Message-ID: <42353B91.5050004@familyhealth.com.au> +Date: Mon, 14 Mar 2005 15:21:53 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gourish Singbal +Cc: pgsql-performance@postgresql.org +Subject: Re: column name is "LIMIT" +References: <674d1f8a0503132314754df153@mail.gmail.com> +In-Reply-To: <674d1f8a0503132314754df153@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.084 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/245 +X-Sequence-Number: 10950 + +Put "" around the column name, eg: + +insert into "limit" values (1, 2,3 ); + +Chris + +Gourish Singbal wrote: +> Guys, +> +> I am having a problem firing queries on one of the tables which is +> having "limit" as the column name. +> +> If a run an insert/select/update command on that table i get the below error. +> +> ERROR: syntax error at or near "limit" at character 71 +> +> Any Help would be realyl great to solve the problem. +> +> postgresql 7.4.5 and linux OS +> + +From pgsql-performance-owner@postgresql.org Mon Mar 14 07:25:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D33C8563A8 + for ; + Mon, 14 Mar 2005 07:25:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06510-09 + for ; + Mon, 14 Mar 2005 07:25:27 +0000 (GMT) +Received: from pws.com.au (mail.pws.com.au [210.23.138.139]) + by svr1.postgresql.org (Postfix) with SMTP id 40843563A2 + for ; + Mon, 14 Mar 2005 07:25:24 +0000 (GMT) +Received: (qmail 23669 invoked from network); 14 Mar 2005 07:25:24 -0000 +Received: from unknown (HELO wizzard.pws.com.au) + (russell@pws.com.au@138.217.54.70) + by mail.pws.com.au with SMTP; 14 Mar 2005 07:25:24 -0000 +From: Russell Smith +To: Gourish Singbal +Subject: Re: column name is "LIMIT" +Date: Mon, 14 Mar 2005 18:25:22 +1100 +User-Agent: KMail/1.7 +Cc: pgsql-performance@postgresql.org +References: <674d1f8a0503132314754df153@mail.gmail.com> +In-Reply-To: <674d1f8a0503132314754df153@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200503141825.22827.mr-russ@pws.com.au> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/246 +X-Sequence-Number: 10951 + +On Mon, 14 Mar 2005 06:14 pm, Gourish Singbal wrote: +> Guys, +> +> I am having a problem firing queries on one of the tables which is +> having "limit" as the column name. +> +> If a run an insert/select/update command on that table i get the below error. +> +> ERROR: syntax error at or near "limit" at character 71 + +select "limit" from limit_table WHERE "limit" < 50 LIMIT 2; + +You need to quote the field name, and make sure the case is correct. +> +> Any Help would be realyl great to solve the problem. +> +> postgresql 7.4.5 and linux OS +> +You should probably upgrade to 7.4.7 + +Regards + +Russell Smith. + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:52:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B880755F20 + for ; + Mon, 14 Mar 2005 07:44:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11844-09 + for ; + Mon, 14 Mar 2005 07:44:55 +0000 (GMT) +Received: from mail.ukfsn.org (s2.ukfsn.org [217.158.120.143]) + by svr1.postgresql.org (Postfix) with ESMTP id 2292252A8E + for ; + Mon, 14 Mar 2005 07:44:54 +0000 (GMT) +Received: from localhost (lucy.ukfsn.org [127.0.0.1]) + by mail.ukfsn.org (Postfix) with ESMTP + id 0443DE6D67; Mon, 14 Mar 2005 07:39:56 +0000 (GMT) +Received: from mail.ukfsn.org ([127.0.0.1]) + by localhost (lucy.ukfsn.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 19198-14; Mon, 14 Mar 2005 07:39:55 +0000 (GMT) +Received: from oak.dgreaves.com (modem-2470.leopard.dialup.pol.co.uk + [217.135.153.166]) by mail.ukfsn.org (Postfix) with ESMTP + id 31094E6D65; Mon, 14 Mar 2005 07:39:55 +0000 (GMT) +Received: from ash.dgreaves.com ([10.0.0.90]) + by oak.dgreaves.com with esmtp (Exim 4.20) + id 1DAkFv-000855-O0; Mon, 14 Mar 2005 07:44:51 +0000 +Message-ID: <423540F5.8090609@dgreaves.com> +Date: Mon, 14 Mar 2005 07:44:53 +0000 +From: David Greaves +User-Agent: Debian Thunderbird 1.0 (X11/20050116) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: Arshavir Grigorian , linux-raid@vger.kernel.org, + pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 (possible sync blocking read type +References: <4231F5F2.6000509@m-cam.com> <87hdje7sjm.fsf@stark.xeocode.com> +In-Reply-To: <87hdje7sjm.fsf@stark.xeocode.com> +X-Enigmail-Version: 0.90.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/411 +X-Sequence-Number: 11116 + +Greg Stark wrote: + +>Arshavir Grigorian writes: +> +> +> +>>Hi, +>> +>>I have a RAID5 array (mdadm) with 14 disks + 1 spare. This partition has an +>>Ext3 filesystem which is used by Postgres. +>> +>> +> +>People are going to suggest moving to RAID1+0. I'm unconvinced that RAID5 +>across 14 drivers shouldn't be able to keep up with RAID1 across 7 drives +>though. It would be interesting to see empirical data. +> +>One thing that does scare me is the Postgres transaction log and the ext3 +>journal both sharing these disks with the data. Ideally both of these things +>should get (mirrored) disks of their own separate from the data files. +> +>But 2-3s pauses seem disturbing. I wonder whether ext3 is issuing a cache +>flush on every fsync to get the journal pushed out. This is a new linux +>feature that's necessary with ide but shouldn't be necessary with scsi. +> +>It would be interesting to know whether postgres performs differently with +>fsync=off. This would even be a reasonable mode to run under for initial +>database loads. It shouldn't make much of a difference with hardware like this +>though. And you should be aware that running under this mode in production +>would put your data at risk. +> +Hi +I'm coming in from the raid list so I didn't get the full story. + +May I ask what kernel? + +I only ask because I upgraded to 2.6.11.2 and happened to be watching +xosview on my (probably) completely different setup (1Tb xfs/lvm2/raid5 +served by nfs to a remote sustained read/write app), when I saw all read +activity cease for 2/3 seconds whilst the disk wrote, then disk read +resumed. This occured repeatedly during a read/edit/write of a 3Gb file. + +Performance not critical here so on the "hmm, that's odd" todo list :) + +David + + +From pgsql-hackers-owner@postgresql.org Mon Mar 21 03:21:53 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3ABC6563E3 + for ; + Mon, 14 Mar 2005 08:43:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29712-03 + for ; + Mon, 14 Mar 2005 08:43:12 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A68D563D6 + for ; + Mon, 14 Mar 2005 08:43:11 +0000 (GMT) +Received: (qmail 11495 invoked from network); 14 Mar 2005 09:43:12 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by smtp.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 14 Mar 2005 09:43:12 +0100 +Message-ID: <42354EA7.4020907@startnet.cz> +Date: Mon, 14 Mar 2005 09:43:19 +0100 +From: =?windows-1250?Q?Miroslav_=8Aulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org +Subject: Re: [PERFORM] How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <423478B1.7080106@arbash-meinel.com> + <18381.1110741354@sss.pgh.pa.us> <423497FE.6040908@startnet.cz> + <19293.1110743673@sss.pgh.pa.us> <42349C96.60401@startnet.cz> + <3174.1110745587@sss.pgh.pa.us> <4234AF56.1040509@startnet.cz> + <6715.1110758921@sss.pgh.pa.us> +In-Reply-To: <6715.1110758921@sss.pgh.pa.us> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------030406020708070302050304" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/731 +X-Sequence-Number: 65533 + +This is a multi-part message in MIME format. +--------------030406020708070302050304 +Content-Type: text/plain; charset=windows-1250; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>... +>I think the reason this is popping to the top of the runtime is that the +>joins are so wide (an average of ~85 columns in a join tuple according +>to the numbers above). Because there are lots of variable-width columns +>involved, most of the time the fast path for field access doesn't apply +>and we end up going to nocachegetattr --- which itself is going to be +>slow because it has to scan over so many columns. So the cost is +>roughly O(N^2) in the number of columns. +> +> +As there are a lot of varchar(1) in the AdDevicesSites table, wouldn't +be helpful to change them to char(1)? Would it solve the variable-width +problem at least for some fields and speed the query up? + +>As a short-term hack, you might be able to improve matters if you can +>reorder your LEFT JOINs to have the minimum number of columns +>propagating up from the earlier join steps. In other words make the +>later joins add more columns than the earlier, as much as you can. +> +> +That will be hard as the main table which contains most of the fields is +LEFT JOINed with the others. I'll look at it if I find some way to +improve it. + +I'm not sure whether I understand the process of performing the plan but +I imagine that the data from AdDevicesSites are retrieved only once when +they are loaded and maybe stored in memory. Are the columns stored in +the order they are in the SQL command? If so, wouldn't it be useful to +move all varchar fields at the end of the SELECT query? I'm just +guessing because I don't know at all how a database server is +implemented and what it really does. + +>.. +> regards, tom lane +> +> +Miroslav + +--------------030406020708070302050304 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------030406020708070302050304-- + +From pgsql-hackers-owner@postgresql.org Mon Mar 21 03:19:54 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BAE4563BA + for ; + Mon, 14 Mar 2005 08:44:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30595-02 + for ; + Mon, 14 Mar 2005 08:44:41 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F8DD5638A + for ; + Mon, 14 Mar 2005 08:44:40 +0000 (GMT) +Received: (qmail 12852 invoked from network); 14 Mar 2005 09:44:41 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by ns.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 14 Mar 2005 09:44:41 +0100 +Message-ID: <42354F00.5060904@startnet.cz> +Date: Mon, 14 Mar 2005 09:44:48 +0100 +From: =?windows-1250?Q?Miroslav_=8Aulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <423478B1.7080106@arbash-meinel.com> + <18381.1110741354@sss.pgh.pa.us> <423497FE.6040908@startnet.cz> + <19293.1110743673@sss.pgh.pa.us> <42349C96.60401@startnet.cz> + <3174.1110745587@sss.pgh.pa.us> <4234AF56.1040509@startnet.cz> + <6715.1110758921@sss.pgh.pa.us> <4850.1110776411@sss.pgh.pa.us> +In-Reply-To: <4850.1110776411@sss.pgh.pa.us> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------050105060807070004020401" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/730 +X-Sequence-Number: 65532 + +This is a multi-part message in MIME format. +--------------050105060807070004020401 +Content-Type: text/plain; charset=windows-1250; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>I wrote: +> +> +>>Since ExecProject operations within a nest of joins are going to be +>>dealing entirely with Vars, I wonder if we couldn't speed matters up +>>by having a short-circuit case for a projection that is only Vars. +>>Essentially it would be a lot like execJunk.c, except able to cope +>>with two input tuples. Using heap_deformtuple instead of retail +>>extraction of fields would eliminate the O(N^2) penalty for wide tuples. +>> +>> +> +>Actually, we already had a pending patch (from Atsushi Ogawa) that +>eliminates that particular O(N^2) behavior in another way. After +>applying it, I get about a factor-of-4 reduction in the runtime for +>Miroslav's example. +> +> +Is there a chance we will see this patch in the 8.0.2 release? And when +can we expect this release? + +>ExecEvalVar and associated routines are still a pretty good fraction of +>the runtime, so it might still be worth doing something like the above, +>but it'd probably be just a marginal win instead of a big win. +> +> regards, tom lane +> +> +Miroslav + +--------------050105060807070004020401 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------050105060807070004020401-- + +From pgsql-performance-owner@postgresql.org Mon Mar 14 08:51:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4521F563CD + for ; + Mon, 14 Mar 2005 08:51:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31384-09 + for ; + Mon, 14 Mar 2005 08:51:05 +0000 (GMT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by svr1.postgresql.org (Postfix) with ESMTP id F05915612C + for ; + Mon, 14 Mar 2005 08:51:04 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.201]) + by svr4.postgresql.org (Postfix) with ESMTP id C47A75AF958 + for ; + Mon, 14 Mar 2005 08:51:06 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id j1so1803414rnf + for ; + Mon, 14 Mar 2005 00:48:57 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=iDnliX/0++2TdlsJv2Uhf50JgtBm8pnNAo48KefD65/poKl+d/5peZDeYfZWPlKrpfV1ke5e0ud5gO/Ro57HsU6YmCdoxxmS9JL32mzR1NZBieQnTT4Gu0INYFkHItzbDh4sDLRnc1m4vn33jOUuCHvPpMO2lhJyNNfR3eHb018= +Received: by 10.38.11.1 with SMTP id 1mr1405650rnk; + Mon, 14 Mar 2005 00:48:55 -0800 (PST) +Received: by 10.38.97.43 with HTTP; Mon, 14 Mar 2005 00:48:55 -0800 (PST) +Message-ID: <674d1f8a05031400482c413087@mail.gmail.com> +Date: Mon, 14 Mar 2005 14:18:55 +0530 +From: Gourish Singbal +Reply-To: Gourish Singbal +To: Russell Smith +Subject: Re: column name is "LIMIT" +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200503141825.22827.mr-russ@pws.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <674d1f8a0503132314754df153@mail.gmail.com> + <200503141825.22827.mr-russ@pws.com.au> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.249 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/249 +X-Sequence-Number: 10954 + +Thanks a lot, + +we might be upgrading to 8.0.1 soon.. till than using double quotes +should be fine. + +regards +gourish + +On Mon, 14 Mar 2005 18:25:22 +1100, Russell Smith wrote: +> On Mon, 14 Mar 2005 06:14 pm, Gourish Singbal wrote: +> > Guys, +> > +> > I am having a problem firing queries on one of the tables which is +> > having "limit" as the column name. +> > +> > If a run an insert/select/update command on that table i get the below error. +> > +> > ERROR: syntax error at or near "limit" at character 71 +> +> select "limit" from limit_table WHERE "limit" < 50 LIMIT 2; +> +> You need to quote the field name, and make sure the case is correct. +> > +> > Any Help would be realyl great to solve the problem. +> > +> > postgresql 7.4.5 and linux OS +> > +> You should probably upgrade to 7.4.7 +> +> Regards +> +> Russell Smith. +> + + +-- +Best, +Gourish Singbal + +From pgsql-performance-owner@postgresql.org Mon Mar 14 08:55:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A43325638F + for ; + Mon, 14 Mar 2005 08:55:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32512-08 + for ; + Mon, 14 Mar 2005 08:55:06 +0000 (GMT) +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id AA25A56381 + for ; + Mon, 14 Mar 2005 08:55:04 +0000 (GMT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 7656A25054; + Mon, 14 Mar 2005 16:55:05 +0800 (WST) +Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 6EC872501A; + Mon, 14 Mar 2005 16:55:05 +0800 (WST) +Message-ID: <42355185.3070803@familyhealth.com.au> +Date: Mon, 14 Mar 2005 16:55:33 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gourish Singbal +Cc: Russell Smith , + pgsql-performance@postgresql.org +Subject: Re: column name is "LIMIT" +References: <674d1f8a0503132314754df153@mail.gmail.com> + <200503141825.22827.mr-russ@pws.com.au> + <674d1f8a05031400482c413087@mail.gmail.com> +In-Reply-To: <674d1f8a05031400482c413087@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.081 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/250 +X-Sequence-Number: 10955 + +You will still need to use double quotes in 8.0.1... + +Chris + +Gourish Singbal wrote: +> Thanks a lot, +> +> we might be upgrading to 8.0.1 soon.. till than using double quotes +> should be fine. +> +> regards +> gourish +> +> On Mon, 14 Mar 2005 18:25:22 +1100, Russell Smith wrote: +> +>>On Mon, 14 Mar 2005 06:14 pm, Gourish Singbal wrote: +>> +>>>Guys, +>>> +>>>I am having a problem firing queries on one of the tables which is +>>>having "limit" as the column name. +>>> +>>>If a run an insert/select/update command on that table i get the below error. +>>> +>>>ERROR: syntax error at or near "limit" at character 71 +>> +>>select "limit" from limit_table WHERE "limit" < 50 LIMIT 2; +>> +>>You need to quote the field name, and make sure the case is correct. +>> +>>>Any Help would be realyl great to solve the problem. +>>> +>>>postgresql 7.4.5 and linux OS +>>> +>> +>>You should probably upgrade to 7.4.7 +>> +>>Regards +>> +>>Russell Smith. +>> +> +> +> + +From pgsql-performance-owner@postgresql.org Mon Mar 14 08:58:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BBB4F5638A + for ; + Mon, 14 Mar 2005 08:58:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33115-09 + for ; + Mon, 14 Mar 2005 08:58:42 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id F1A99563CD + for ; + Mon, 14 Mar 2005 08:58:40 +0000 (GMT) +Received: (qmail 28479 invoked from network); 14 Mar 2005 09:58:42 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by smtp.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 14 Mar 2005 09:58:42 +0100 +Message-ID: <42355249.8090101@startnet.cz> +Date: Mon, 14 Mar 2005 09:58:49 +0100 +From: =?ISO-8859-2?Q?Miroslav_=A9ulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: John Arbash Meinel +Cc: PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> + <42348F54.1000408@startnet.cz> <423493E5.6040203@arbash-meinel.com> +In-Reply-To: <423493E5.6040203@arbash-meinel.com> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------060203020203020207060708" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/251 +X-Sequence-Number: 10956 + +This is a multi-part message in MIME format. +--------------060203020203020207060708 +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 7bit + +John Arbash Meinel wrote: + +>> In fact, on MySQL I didn't see any slow reactions so I didn't measure +>> and inspect it. But I can try it if I figure out how to copy the +>> database from PostgreSQL to MySQL. +> +> +> I figured you still had a copy of the MySQL around to compare to. You +> probably don't need to spend too much time on it yet. + +So I have some results. I have tested the query on both PostgreSQL 8.0.1 +and MySQL 4.1.8 with LIMIT set to 30 and OFFSET set to 6000. PostgreSQL +result is 11,667.916 ms, MySQL result is 448.4 ms. + +Both databases are running on the same machine (my laptop) and contain +the same data. However there are some differences in the data table +definitions: +1) in PostgreSQL I use 'varchar(1)' for a lot of fields and in MySQL I +use 'enum' +2) in PostgreSQL in some cases I use connection fields that are not of +the same type (smallint <-> integer (SERIAL)), in MySQL I use the same types + +> +> John +> =:-> + +Miroslav + +--------------060203020203020207060708 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------060203020203020207060708-- + +From pgsql-performance-owner@postgresql.org Mon Mar 14 09:02:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 95236563DE + for ; + Mon, 14 Mar 2005 09:02:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36190-04 + for ; + Mon, 14 Mar 2005 09:02:25 +0000 (GMT) +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 63DFD563D6 + for ; + Mon, 14 Mar 2005 09:02:25 +0000 (GMT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 4FC1C25058; + Mon, 14 Mar 2005 17:02:26 +0800 (WST) +Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 4A8B125054; + Mon, 14 Mar 2005 17:02:26 +0800 (WST) +Message-ID: <4235533E.8040100@familyhealth.com.au> +Date: Mon, 14 Mar 2005 17:02:54 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?ISO-8859-2?Q?Miroslav_=A9ulc?= +Cc: John Arbash Meinel , + PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> + <42348F54.1000408@startnet.cz> <423493E5.6040203@arbash-meinel.com> + <42355249.8090101@startnet.cz> +In-Reply-To: <42355249.8090101@startnet.cz> +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.08 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/252 +X-Sequence-Number: 10957 + +> 1) in PostgreSQL I use 'varchar(1)' for a lot of fields and in MySQL I +> use 'enum' +> 2) in PostgreSQL in some cases I use connection fields that are not of +> the same type (smallint <-> integer (SERIAL)), in MySQL I use the same +> types + +Well both those things will make PostgreSQL slower... + +Chris + +From pgsql-performance-owner@postgresql.org Mon Mar 14 09:08:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 53EC1563B3 + for ; + Mon, 14 Mar 2005 09:08:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37277-05 + for ; + Mon, 14 Mar 2005 09:08:49 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 63AAF5638A + for ; + Mon, 14 Mar 2005 09:08:47 +0000 (GMT) +Received: (qmail 23861 invoked from network); 14 Mar 2005 10:08:53 +0100 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 14 Mar 2005 10:08:53 +0100 +Date: Mon, 14 Mar 2005 10:08:48 +0100 +To: =?iso-8859-15?B?TWlyb3NsYXYgpnVsYw==?= , + "John Arbash Meinel" +Subject: Re: How to read query plan +Cc: "PGSQL mailing list" +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> + <42348F54.1000408@startnet.cz> <423493E5.6040203@arbash-meinel.com> + <42355249.8090101@startnet.cz> +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <42355249.8090101@startnet.cz> +User-Agent: Opera M2/7.54 (Linux, build 955) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/253 +X-Sequence-Number: 10958 + + + Instead of a varchar(1) containing 'y' or 'n' you could use a BOOL or an +integer. + Your query seems of the form : + + SELECT FROM main_table LEFT JOIN a lot of tables ORDER BY sort_key LIMIT +N OFFSET M; + + I would suggest to rewrite it in a simpler way : instead of generating +the whole result set, sorting it, and then grabbing a slice, generate only +the ror id's, grab a slice, and then generate the full rows from that. + + - If you order by a field which is in main_table : + SELECT FROM main_table LEFT JOIN a lot of tables WHERE main_table.id IN +(SELECT id FROM main_table ORDER BY sort_key LIMIT N OFFSET M +) ORDER BY sort_key LIMIT N OFFSET M; + + - If you order by a field in one of the child tables, I guess you only +want to display the rows in the main table which have this field, ie. +not-null in the LEFT JOIN. You can also use the principle above. + + - You can use a straight join instead of an IN. + + +On Mon, 14 Mar 2005 09:58:49 +0100, Miroslav �ulc + wrote: + +> John Arbash Meinel wrote: +> +>>> In fact, on MySQL I didn't see any slow reactions so I didn't measure +>>> and inspect it. But I can try it if I figure out how to copy the +>>> database from PostgreSQL to MySQL. +>> +>> +>> I figured you still had a copy of the MySQL around to compare to. You +>> probably don't need to spend too much time on it yet. +> +> So I have some results. I have tested the query on both PostgreSQL 8.0.1 +> and MySQL 4.1.8 with LIMIT set to 30 and OFFSET set to 6000. PostgreSQL +> result is 11,667.916 ms, MySQL result is 448.4 ms. +> +> Both databases are running on the same machine (my laptop) and contain +> the same data. However there are some differences in the data table +> definitions: +> 1) in PostgreSQL I use 'varchar(1)' for a lot of fields and in MySQL I +> use 'enum' +> 2) in PostgreSQL in some cases I use connection fields that are not of +> the same type (smallint <-> integer (SERIAL)), in MySQL I use the same +> types +> +>> +>> John +>> =:-> +> +> Miroslav + + + +From pgsql-performance-owner@postgresql.org Mon Mar 14 09:09:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9FD57563D7 + for ; + Mon, 14 Mar 2005 09:09:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37139-07 + for ; + Mon, 14 Mar 2005 09:09:30 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id B57CC563C8 + for ; + Mon, 14 Mar 2005 09:09:29 +0000 (GMT) +Received: (qmail 8458 invoked from network); 14 Mar 2005 10:09:31 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by mail.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 14 Mar 2005 10:09:31 +0100 +Message-ID: <423554D2.9000207@startnet.cz> +Date: Mon, 14 Mar 2005 10:09:38 +0100 +From: =?ISO-8859-2?Q?Miroslav_=A9ulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christopher Kings-Lynne +Cc: John Arbash Meinel , + PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> + <42348F54.1000408@startnet.cz> <423493E5.6040203@arbash-meinel.com> + <42355249.8090101@startnet.cz> + <4235533E.8040100@familyhealth.com.au> +In-Reply-To: <4235533E.8040100@familyhealth.com.au> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------040408030304060807070905" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/254 +X-Sequence-Number: 10959 + +This is a multi-part message in MIME format. +--------------040408030304060807070905 +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 7bit + +Christopher Kings-Lynne wrote: + +>> 1) in PostgreSQL I use 'varchar(1)' for a lot of fields and in MySQL +>> I use 'enum' +>> 2) in PostgreSQL in some cases I use connection fields that are not +>> of the same type (smallint <-> integer (SERIAL)), in MySQL I use the +>> same types +> +> +> Well both those things will make PostgreSQL slower... + +I think so. I'll change the varchar(1) fields to char(1) where possible +and will think out what I will do with the smallint <-> integer JOINs. +Something like SMALLSERIAL would be pleasant :-) I thought I will wait +for Tom Lane's reaction to my improvement suggestions I have posted in +other mail but maybe he has a deep night because of different time zone. + +> +> Chris + +Miroslav + +--------------040408030304060807070905 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------040408030304060807070905-- + +From pgsql-performance-owner@postgresql.org Mon Mar 14 09:17:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 537455636B + for ; + Mon, 14 Mar 2005 09:17:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39155-06 + for ; + Mon, 14 Mar 2005 09:17:41 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 354BF567AF + for ; + Mon, 14 Mar 2005 09:17:35 +0000 (GMT) +Received: (qmail 17412 invoked from network); 14 Mar 2005 10:17:37 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by smtp.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 14 Mar 2005 10:17:37 +0100 +Message-ID: <423556B8.4020500@startnet.cz> +Date: Mon, 14 Mar 2005 10:17:44 +0100 +From: =?ISO-8859-15?Q?Miroslav_=A6ulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PFC +Cc: John Arbash Meinel , + PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> + <42348F54.1000408@startnet.cz> <423493E5.6040203@arbash-meinel.com> + <42355249.8090101@startnet.cz> +In-Reply-To: +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------080901070901040409070600" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/255 +X-Sequence-Number: 10960 + +This is a multi-part message in MIME format. +--------------080901070901040409070600 +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit + +PFC wrote: + +> +> Instead of a varchar(1) containing 'y' or 'n' you could use a BOOL +> or an integer. + +Sure I could. The problem is our project still supports both MySQL and +PostgreSQL. We used enum('Y','N') in MySQL so there would be a lot of +changes in the code if we would change to the BOOL data type. + +> Your query seems of the form : +> +> SELECT FROM main_table LEFT JOIN a lot of tables ORDER BY sort_key +> LIMIT N OFFSET M; +> +> I would suggest to rewrite it in a simpler way : instead of +> generating the whole result set, sorting it, and then grabbing a +> slice, generate only the ror id's, grab a slice, and then generate +> the full rows from that. +> +> - If you order by a field which is in main_table : +> SELECT FROM main_table LEFT JOIN a lot of tables WHERE +> main_table.id IN (SELECT id FROM main_table ORDER BY sort_key LIMIT N +> OFFSET M +> ) ORDER BY sort_key LIMIT N OFFSET M; +> +> - If you order by a field in one of the child tables, I guess you +> only want to display the rows in the main table which have this +> field, ie. not-null in the LEFT JOIN. You can also use the principle +> above. +> +> - You can use a straight join instead of an IN. + +Do you mean something like this? + +SELECT Table.IDPK, Table2.varchar1, Table2.varchar2, ... +FROM Table +LEFT JOIN many tables +INNER JOIN Table AS Table2 + +Miroslav + +--------------080901070901040409070600 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------080901070901040409070600-- + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:52:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 82795563D6 + for ; + Mon, 14 Mar 2005 09:31:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44942-02 + for ; + Mon, 14 Mar 2005 09:31:37 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D2C652A57 + for ; + Mon, 14 Mar 2005 09:31:36 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id A2E9130941; Mon, 14 Mar 2005 10:31:38 +0100 (MET) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: column name is "LIMIT" +Date: Mon, 14 Mar 2005 17:26:55 +0800 +Organization: Hub.Org Networking Services +Lines: 64 +Message-ID: +References: <674d1f8a0503132314754df153@mail.gmail.com> + <200503141825.22827.mr-russ@pws.com.au> + <674d1f8a05031400482c413087@mail.gmail.com> + <42355185.3070803@familyhealth.com.au> +Reply-To: "Qingqing Zhou" +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.194 tagged_above=0 required=5 tests=AWL, + PRIORITY_NO_NAME +X-Spam-Level: * +X-Archive-Number: 200503/409 +X-Sequence-Number: 11114 + +So is it to make SQL parser context-sensitive - say the parser will +understand that in statement "SELECT * from LIMIT", LIMIT is just a table +name, instead of keyword? + +There might be some conflicts when using Yacc, but I am not sure how +difficult will be ... + +Cheers, +Qingqing + +"Christopher Kings-Lynne" +> You will still need to use double quotes in 8.0.1... +> +> Chris +> +> Gourish Singbal wrote: +> > Thanks a lot, +> > +> > we might be upgrading to 8.0.1 soon.. till than using double quotes +> > should be fine. +> > +> > regards +> > gourish +> > +> > On Mon, 14 Mar 2005 18:25:22 +1100, Russell Smith +wrote: +> > +> >>On Mon, 14 Mar 2005 06:14 pm, Gourish Singbal wrote: +> >> +> >>>Guys, +> >>> +> >>>I am having a problem firing queries on one of the tables which is +> >>>having "limit" as the column name. +> >>> +> >>>If a run an insert/select/update command on that table i get the below +error. +> >>> +> >>>ERROR: syntax error at or near "limit" at character 71 +> >> +> >>select "limit" from limit_table WHERE "limit" < 50 LIMIT 2; +> >> +> >>You need to quote the field name, and make sure the case is correct. +> >> +> >>>Any Help would be realyl great to solve the problem. +> >>> +> >>>postgresql 7.4.5 and linux OS +> >>> +> >> +> >>You should probably upgrade to 7.4.7 +> >> +> >>Regards +> >> +> >>Russell Smith. +> >> +> > +> > +> > +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> + + + +From pgsql-performance-owner@postgresql.org Mon Mar 14 09:41:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A62852A5A + for ; + Mon, 14 Mar 2005 09:41:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46438-07 + for ; + Mon, 14 Mar 2005 09:41:30 +0000 (GMT) +Received: from anchor-post-36.mail.demon.net (anchor-post-36.mail.demon.net + [194.217.242.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 0CCFC52A57 + for ; + Mon, 14 Mar 2005 09:41:29 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-36.mail.demon.net with esmtp (Exim 4.42) + id 1DAm4l-000OMz-Jt; Mon, 14 Mar 2005 09:41:30 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id D2DA3166F3; Mon, 14 Mar 2005 09:41:22 +0000 (GMT) +Message-ID: <42355C40.1070207@archonet.com> +Date: Mon, 14 Mar 2005 09:41:20 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jacques Caron +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance tuning +References: + <6.2.0.14.0.20050311155221.041aa528@pop.interactivemediafactory.net> +In-Reply-To: + <6.2.0.14.0.20050311155221.041aa528@pop.interactivemediafactory.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.062 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/256 +X-Sequence-Number: 10961 + +Jacques Caron wrote: +> I'm preparing a set of servers which will eventually need to handle a +> high volume of queries (both reads and writes, but most reads are very +> simple index-based queries returning a limited set of rows, when not +> just one), and I would like to optimize things as much as possible, so I +> have a few questions on the exact way PostgreSQL's MVCC works, and how +> transactions, updates and vacuuming interact. I hope someone will be +> able to point me in the right direction (feel free to give pointers if I +> missed the places where this is described). +> +> From what I understand (and testing confirms it), bundling many queries +> in one single transaction is more efficient than having each query be a +> separate transaction (like with autocommit on). However, I wonder about +> the limits of this: +> +> - are there any drawbacks to grouping hundreds or thousands of queries +> (inserts/updates) over several minutes in one single transaction? Other +> than the fact that the inserts/updates will not be visible until +> committed, of course. Essentially turning autocommit off, and doing a +> commit once in a while. + +1. If any locks are held then they will be held for much longer, causing +other processes to block. +2. PG needs to be able to roll back the changes - thousands of simple +inserts are fine, millions will probably not be. + +> - does this apply only to inserts/selects/updates or also for selects? +> Another way to put this is: does a transaction with only one select +> actually have much transaction-related work to do? Or, does a +> transaction with only selects actually have any impact anywhere? Does it +> really leave a trace anywhere? Again, I understand that selects grouped +> in a transaction will not see updates done after the start of the +> transaction (unless done by the same process). + +There are implications if a SELECT has side-effects (I can call a +function in a select - that might do anything). + +> - if during a single transaction several UPDATEs affect the same row, +> will MVCC generate as many row versions as there are updates (like would +> be the case with autocommit) or will they be grouped into one single row +> version? + +I believe there will be many versions. Certainly for 8.0 that must be +the case to support savepoints within a transaction. + +> Another related issue is that many of the tables are indexed on a date +> field, and one process does a lot of updates on "recent" rows (which +> lead to many dead tuples), but after that "older" rows tend to remain +> pretty much unchanged for quite a while. Other than splitting the tables +> into "old" and "recent" tables, is there any way to make vacuum more +> efficient? Scanning the whole table for dead tuples when only a small +> portion of the table actually has any does not feel like being very +> efficient in this situation. + +Not really. + +> Other issue: every five minutes or so, I see a noticeable performance +> drop as PostgreSQL checkpoints. This is 7.4.3 with pretty lousy +> hardware, I know 8.0 with decent hardware and separate disk(s) for +> pg_xlog will definitely help, but I really wonder if there is any way to +> reduce the amount of work that needs to be done at that point (I'm a +> strong believer of fixing software before hardware). I have already +> bumped checkpoint_segments to 8, but I'm not quite sure I understand how +> this helps (or doesn't help) things. Logs show 3 to 6 "recycled +> transaction log file" lines at that time, that seems quite a lot of work +> for a load that's still pretty low. Does grouping of more queries in +> transactions help with this? Are there other parameters that can affect +> things, or is just a matter of how much inserts/updates/deletes are +> done, and the amount of data that was changed? + +You might be better off reducing the number of checkpoint segments, and +decreasing the timeout. There is a balance between doing a lot of work +in one go, and the overhead of many smaller bursts of activity. + +> Last point: some of the servers have expandable data (and will be +> replicated with slony-I) and will run with fsync off. I have read +> conflicting statements as to what exactly this does: some sources +> indicate that setting fsync off actually switches off WAL/checkpointing, +> others that it just prevents the fsync (or equivalent) system calls. +> Since I still see checkpointing in that case, I guess it's not exactly +> the former, but I would love to understand more about it. Really, I +> would love to be able to set some tables or databases to "go as fast as +> you can and don't worry about transactions, MVCC or anything like that", +> but I'm not sure that option exists... + +Setting fsync=false means the sync isn't done, so data might still be +cached below PG's level. I'm not sure it's ever going to be possible to +mark a table as "ignore transactions" - it would be a lot of work, and +means you couldn't guarantee transactions that included that table in +any way. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:50:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B1CC563AB + for ; + Mon, 14 Mar 2005 10:43:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62865-07 + for ; + Mon, 14 Mar 2005 10:43:53 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.250.190.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E92D5639E + for ; + Mon, 14 Mar 2005 10:43:52 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id A611730941; Mon, 14 Mar 2005 11:43:54 +0100 (MET) +From: Mirko Zeibig +X-Newsgroups: pgsql.performance +Subject: Re: Questions about 2 databases. +Date: Mon, 14 Mar 2005 11:43:52 +0100 +Lines: 17 +Message-ID: <42356AE8.8080907@zeibig.net> +References: + <6.2.0.14.0.20050311155221.041aa528@pop.interactivemediafactory.net> + + <5055.1110573222@sss.pgh.pa.us> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +In-Reply-To: +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/407 +X-Sequence-Number: 11112 + +jelle wrote: +> The insert heavy sessions average 175 page hits generating XML, 1000 +> insert/updates which comprise 90% of the insert/update load, of which +> 200 inserts need to be transferred to the master db. The other +> sessions are read/cache bound. I hoping to get a speed-up from moving +> the temporary stuff off the master db and using 1 transaction +> instead of 175 to the disk based master db. + +Just a thought: +Wouldn't it be sufficient to have the "temporary", fast session-table +in a RAM-disk? I suspect you could do this rather easily using a TABLESPACE. +All the indices could be in this TABLESPACE as well (at least after +having a quick look at the short help for CREATE TABLE and assuming you are +using PostgreSQL >= 8.0). + +Regards +Mirko + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:49:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3059D55F4A + for ; + Mon, 14 Mar 2005 11:54:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84125-07 + for ; + Mon, 14 Mar 2005 11:54:36 +0000 (GMT) +Received: from ankama.com (unknown [195.6.184.58]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CD5055EAE + for ; + Mon, 14 Mar 2005 11:54:34 +0000 (GMT) +Received: from [192.168.0.18] by ankama.com (MDaemon.PRO.v7.2.3.R) + with ESMTP id md50000019710.msg + for ; Mon, 14 Mar 2005 13:07:08 +0100 +Message-ID: <42357B92.8020904@ankama.com> +Date: Mon, 14 Mar 2005 12:54:58 +0100 +From: Camille Chafer +Organization: Ankama +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: fr, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Hardware impact on performances +Content-Type: multipart/alternative; + boundary="------------020601090709030704080803" +X-Authenticated-Sender: cchafer@ankama.com +X-Spam-Processed: ankama.com, Mon, 14 Mar 2005 13:07:08 +0100 + (not processed: message from valid local sender) +X-Lookup-Warning: HELO/EHLO lookup on 192.168.0.18 does not match + 80.15.140.119 +X-MDRemoteIP: 80.15.140.119 +X-Return-Path: camille@ankama.com +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.55 tagged_above=0 required=5 tests=HTML_20_30, + HTML_MESSAGE, HTML_TITLE_EMPTY +X-Spam-Level: +X-Archive-Number: 200503/406 +X-Sequence-Number: 11111 + +This is a multi-part message in MIME format. +--------------020601090709030704080803 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Hi, + +I'm using PostgreSQL 8 for a mmorpg. +The part of each operation is : select: 50%, update: 40%, insert: 10%. +I have no more than 4-5 concurrent connections to the database, but each +of them does A LOT of queries (several per second). +The database size is about 1GB, but it'll probably be around 2GB in a +fews months. +The OS will be FreeBSD (version production 5.3 probably, or 4.10) + +At this time, i'm looking for a new server. Before to buy it, I grab +some informations.. +So, my question is : what would be the best hardware for this type of +needs ? +Of course, I'm not asking for a trademark and/or for prices, but for hints. + +- What is the most important part of the system : CPU ? RAM ? Disks ? +- Is a server with 2 or more CPUs much better than a server with a +single one, for a pgsql database ? +- How much RAM do I need ? The size of the data ? Twice the size ? +- I heard Raid1+0 is better than Raid 5. Is it right ? What would be the +best configuration, regarding performances and security ? +- Does the CPU type (i386, PowerPC, ....) matters ? +- A lot of queries probably generate a lot of network output. Does the +network controller matters ? +- And finally, last question : is it possible to run a single postgresql +database on several servers ? (hardware clustering) + +Thanks in advance for your answers, and sorry for my crap english (i'm +french). + +Camille Chafer + +--------------020601090709030704080803 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + + +Hi,
+
+I'm using PostgreSQL 8 for a mmorpg.
+The part of each operation is : select: 50%, update: 40%, insert: 10%.
+I have no more than 4-5 concurrent connections to the database, but +each of them does A LOT of queries (several per second).
+The database size is about 1GB, but it'll probably be around 2GB in a +fews months.
+The OS will be FreeBSD (version production 5.3 probably, or 4.10)
+
+At this time, i'm looking for a new server. Before to buy it, I grab +some informations..
+So, my question is : what would be the best hardware for this type of +needs ?
+Of course, I'm not asking for a trademark and/or for prices, but for +hints.
+
+- What is the most important part of the system : CPU ? RAM ? Disks ?
+- Is a server with 2 or more CPUs much better than a server with a +single one, for a pgsql database ?
+- How much RAM do I need ? The size of the data ? Twice the size ?
+- I heard Raid1+0 is better than Raid 5. Is it right ? What would be +the best configuration, regarding performances and security ?
+- Does the CPU type (i386, PowerPC, ....) matters ?
+- A lot of queries probably generate a lot of network output. Does the +network controller matters ?
+- And finally, last question : is it possible to run a single +postgresql database on several servers ? (hardware clustering)
+
+Thanks in advance for your answers, and sorry for my crap english (i'm +french).
+
+Camille Chafer
+
+ + + +--------------020601090709030704080803-- + + +From pgsql-performance-owner@postgresql.org Mon Mar 14 15:10:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C1E6756662 + for ; + Mon, 14 Mar 2005 15:10:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49970-06 + for ; + Mon, 14 Mar 2005 15:10:33 +0000 (GMT) +Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 357A7563D9 + for ; + Mon, 14 Mar 2005 15:10:32 +0000 (GMT) +Received: from root by ciao.gmane.org with local (Exim 4.43) + id 1DAr3g-0003QB-38 + for pgsql-performance@postgresql.org; Mon, 14 Mar 2005 16:00:41 +0100 +Received: from srv.protecting.net ([212.126.218.242]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Mon, 14 Mar 2005 16:00:40 +0100 +Received: from hf1122x by srv.protecting.net with local (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Mon, 14 Mar 2005 16:00:40 +0100 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +From: Harald Fuchs +Subject: Re: How to read query plan +Date: 14 Mar 2005 15:05:52 +0100 +Organization: Linux Private Site +Lines: 15 +Message-ID: +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> + <42348F54.1000408@startnet.cz> <423493E5.6040203@arbash-meinel.com> + <42355249.8090101@startnet.cz> + <423556B8.4020500@startnet.cz> +Reply-To: hf1122x@protecting.net +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +X-Complaints-To: usenet@sea.gmane.org +X-Gmane-NNTP-Posting-Host: srv.protecting.net +User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 +X-Gmane-MailScanner: Found to be clean +X-Gmane-MailScanner: Found to be clean +X-MailScanner-From: gcdpp-pgsql-performance@m.gmane.org +X-MailScanner-To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/260 +X-Sequence-Number: 10965 + +In article <423556B8.4020500@startnet.cz>, +=?ISO-8859-15?Q?Miroslav_=A6ulc?= writes: + +>> Instead of a varchar(1) containing 'y' or 'n' you could use a +>> BOOL or an integer. + +> Sure I could. The problem is our project still supports both MySQL and +> PostgreSQL. We used enum('Y','N') in MySQL so there would be a lot of +> changes in the code if we would change to the BOOL data type. + +Since BOOL is exactly what you want to express and since MySQL also +supports BOOL (*), you should make that change anyway. + +(*) MySQL recognizes BOOL as a column type and silently uses +TINYINT(1) instead. + + +From pgsql-performance-owner@postgresql.org Mon Mar 14 14:51:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4616056381 + for ; + Mon, 14 Mar 2005 14:51:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41105-10 + for ; + Mon, 14 Mar 2005 14:51:19 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id F136D563A5 + for ; + Mon, 14 Mar 2005 14:51:18 +0000 (GMT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id D695D355AE; Mon, 14 Mar 2005 06:50:21 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id D4F8B35596; Mon, 14 Mar 2005 06:50:21 -0800 (PST) +Date: Mon, 14 Mar 2005 06:50:21 -0800 (PST) +From: Stephan Szabo +To: Michael McFarland +Cc: pgsql-performance@postgresql.org +Subject: Re: adding 'limit' leads to very slow query +In-Reply-To: +Message-ID: <20050314064241.V6400@megazone.bigpanda.com> +References: + <20050307230123.L97147@megazone.bigpanda.com> + +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/257 +X-Sequence-Number: 10962 + +On Wed, 9 Mar 2005, Michael McFarland wrote: + +> I continue to be stumped by this. You are right that I should have +> listed the estimates provided by explain... basically for the select where +> bar = 41, it's estimating there will be 40,000 rows instead of 7, out of +> what's actuallly 5 million records in the table. +> +> So far I've tried increase statistics for the bar column from the +> default 10 to 100 (vacuum analyzing after) and the explain-plan hasn't +> changed. I also notice that afterward, the pg_stats record for the bar + +Did the estimates change at all? + +> column still only lists the top 5 values of bar (out of 68 unique values +> in the table). Are there any other settings I could try to improve the +> detail of the statistics? + +Well, I'd first try moving up to a statistic target of 1000 in +order to try sampling a greater number of rows. I'd wonder if there's +enough difference in frequency that it's just not visiting any with the +other values. I'm not sure that it'll help that much though; hopefully +someone else will have an idea. + +> By the way, I think I do have a workaround for this particular query: +> select * from (select * from foo where barId = 412 order by id +> desc) as tempview limit 25; +> This query uses the bar index and completes instantly. However, I feel +> like I should find the heart of the problem, since bad statistics could +> end up affecting other plans, right? + +Yeah, it's best to get it to estimate somewhat reasonably before looking +for workarounds. + +From pgsql-hackers-owner@postgresql.org Mon Mar 14 15:03:11 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 64497563D9; + Mon, 14 Mar 2005 15:03:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46277-07; Mon, 14 Mar 2005 15:02:59 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F38752A57; + Mon, 14 Mar 2005 15:02:58 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2EF31lF013459; + Mon, 14 Mar 2005 10:03:01 -0500 (EST) +To: =?windows-1250?Q?Miroslav_=8Aulc?= +Cc: pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org +Subject: Re: [PERFORM] How to read query plan +In-reply-to: <42354EA7.4020907@startnet.cz> +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <423478B1.7080106@arbash-meinel.com> + <18381.1110741354@sss.pgh.pa.us> <423497FE.6040908@startnet.cz> + <19293.1110743673@sss.pgh.pa.us> <42349C96.60401@startnet.cz> + <3174.1110745587@sss.pgh.pa.us> <4234AF56.1040509@startnet.cz> + <6715.1110758921@sss.pgh.pa.us> <42354EA7.4020907@startnet.cz> +Comments: In-reply-to =?windows-1250?Q?Miroslav_=8Aulc?= + + message dated "Mon, 14 Mar 2005 09:43:19 +0100" +Date: Mon, 14 Mar 2005 10:03:01 -0500 +Message-ID: <13458.1110812581@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/444 +X-Sequence-Number: 65246 + +=?windows-1250?Q?Miroslav_=8Aulc?= writes: +> As there are a lot of varchar(1) in the AdDevicesSites table, wouldn't +> be helpful to change them to char(1)? Would it solve the variable-width +> problem at least for some fields and speed the query up? + +No, because char(1) isn't physically fixed-width (consider multibyte +encodings). There's really no advantage to char(N) in Postgres. + +I don't know what you're doing with those fields, but if they are +effectively booleans or small codes you might be able to convert them to +bool or int fields. There is also the "char" datatype (not to be +confused with char(1)) which can hold single ASCII characters, but is +nonstandard and a bit impoverished as to functionality. + +However, I doubt this is worth pursuing. One of the things I tested +yesterday was a quick hack to organize the storage of intermediate join +tuples with fixed-width fields first and non-fixed ones later. It +really didn't help much at all :-(. I think the trouble with your +example is that in the existing code, the really fast path applies only +when the tuple contains no nulls --- and since you're doing all that +left joining, there's frequently at least one null lurking. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Mon Mar 14 15:04:23 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EC90D5665F; + Mon, 14 Mar 2005 15:04:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47222-07; Mon, 14 Mar 2005 15:04:21 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AAB235668A; + Mon, 14 Mar 2005 15:04:20 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2EF4PIP013477; + Mon, 14 Mar 2005 10:04:25 -0500 (EST) +To: =?windows-1250?Q?Miroslav_=8Aulc?= +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] How to read query plan +In-reply-to: <42354F00.5060904@startnet.cz> +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <423478B1.7080106@arbash-meinel.com> + <18381.1110741354@sss.pgh.pa.us> <423497FE.6040908@startnet.cz> + <19293.1110743673@sss.pgh.pa.us> <42349C96.60401@startnet.cz> + <3174.1110745587@sss.pgh.pa.us> <4234AF56.1040509@startnet.cz> + <6715.1110758921@sss.pgh.pa.us> <4850.1110776411@sss.pgh.pa.us> + <42354F00.5060904@startnet.cz> +Comments: In-reply-to =?windows-1250?Q?Miroslav_=8Aulc?= + + message dated "Mon, 14 Mar 2005 09:44:48 +0100" +Date: Mon, 14 Mar 2005 10:04:25 -0500 +Message-ID: <13476.1110812665@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/445 +X-Sequence-Number: 65247 + +=?windows-1250?Q?Miroslav_=8Aulc?= writes: +> Tom Lane wrote: +>> Actually, we already had a pending patch (from Atsushi Ogawa) that +>> eliminates that particular O(N^2) behavior in another way. After +>> applying it, I get about a factor-of-4 reduction in the runtime for +>> Miroslav's example. +>> +> Is there a chance we will see this patch in the 8.0.2 release? + +No. We are not in the habit of making non-bug-fix changes in stable +branches. Ogawa's patch is in CVS for 8.1. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Mon Mar 21 03:18:07 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 02B795666B + for ; + Mon, 14 Mar 2005 15:21:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53360-05 + for ; + Mon, 14 Mar 2005 15:21:36 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id BF61D5665F + for ; + Mon, 14 Mar 2005 15:21:34 +0000 (GMT) +Received: (qmail 20641 invoked from network); 14 Mar 2005 16:21:37 +0100 +Received: from startnet.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.6.17) + by sranda.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 14 Mar 2005 16:21:37 +0100 +Message-ID: <4235AC01.600@startnet.cz> +Date: Mon, 14 Mar 2005 16:21:37 +0100 +From: =?windows-1250?Q?Miroslav_=8Aulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgreSQL.org, pgsql-hackers@postgreSQL.org +Subject: Re: [PERFORM] How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <423478B1.7080106@arbash-meinel.com> + <18381.1110741354@sss.pgh.pa.us> <423497FE.6040908@startnet.cz> + <19293.1110743673@sss.pgh.pa.us> <42349C96.60401@startnet.cz> + <3174.1110745587@sss.pgh.pa.us> <4234AF56.1040509@startnet.cz> + <6715.1110758921@sss.pgh.pa.us> <42354EA7.4020907@startnet.cz> + <13458.1110812581@sss.pgh.pa.us> +In-Reply-To: <13458.1110812581@sss.pgh.pa.us> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------020308040300050508020701" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/728 +X-Sequence-Number: 65530 + +This is a multi-part message in MIME format. +--------------020308040300050508020701 +Content-Type: text/plain; charset=windows-1250; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>=?windows-1250?Q?Miroslav_=8Aulc?= writes: +> +> +>>As there are a lot of varchar(1) in the AdDevicesSites table, wouldn't +>>be helpful to change them to char(1)? Would it solve the variable-width +>>problem at least for some fields and speed the query up? +>> +>> +> +>No, because char(1) isn't physically fixed-width (consider multibyte +>encodings). There's really no advantage to char(N) in Postgres. +> +> +I was aware of that :-( + +>I don't know what you're doing with those fields, but if they are +>effectively booleans or small codes you might be able to convert them to +>bool or int fields. There is also the "char" datatype (not to be +>confused with char(1)) which can hold single ASCII characters, but is +>nonstandard and a bit impoverished as to functionality. +> +> +The problem lies in migration from MySQL to PostgreSQL. In MySQL we +(badly) choose enum for yes/no switches (there's nothing like boolean +field type in MySQL as I know but we could use tinyint). It will be very +time consuming to rewrite all such enums and check the code whether it +works. + +>However, I doubt this is worth pursuing. One of the things I tested +>yesterday was a quick hack to organize the storage of intermediate join +>tuples with fixed-width fields first and non-fixed ones later. It +>really didn't help much at all :-(. I think the trouble with your +>example is that in the existing code, the really fast path applies only +>when the tuple contains no nulls --- and since you're doing all that +>left joining, there's frequently at least one null lurking. +> +> +Unfortunatelly I don't see any other way than LEFT JOINing in this case. + +> regards, tom lane +> +> +Miroslav + +--------------020308040300050508020701 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------020308040300050508020701-- + +From pgsql-performance-owner@postgresql.org Mon Mar 14 15:29:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 319AD56918 + for ; + Mon, 14 Mar 2005 15:29:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57339-03 + for ; + Mon, 14 Mar 2005 15:29:29 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 18B825686B + for ; + Mon, 14 Mar 2005 15:27:41 +0000 (GMT) +Received: (qmail 27265 invoked from network); 14 Mar 2005 16:27:44 +0100 +Received: from startnet.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.6.17) + by ns.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 14 Mar 2005 16:27:44 +0100 +Message-ID: <4235AD70.60407@startnet.cz> +Date: Mon, 14 Mar 2005 16:27:44 +0100 +From: =?windows-1252?Q?Miroslav_=8Aulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: hf1122x@protecting.net +Cc: pgsql-performance@postgresql.org +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> + <42348F54.1000408@startnet.cz> <423493E5.6040203@arbash-meinel.com> + <42355249.8090101@startnet.cz> + <423556B8.4020500@startnet.cz> +In-Reply-To: +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------080008030501040400020606" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/262 +X-Sequence-Number: 10967 + +This is a multi-part message in MIME format. +--------------080008030501040400020606 +Content-Type: text/plain; charset=windows-1252; format=flowed +Content-Transfer-Encoding: 7bit + +Harald Fuchs wrote: + +>>Sure I could. The problem is our project still supports both MySQL and +>>PostgreSQL. We used enum('Y','N') in MySQL so there would be a lot of +>>changes in the code if we would change to the BOOL data type. +>> +>> +> +>Since BOOL is exactly what you want to express and since MySQL also +>supports BOOL (*), you should make that change anyway. +> +> +I know that. The time will have to come. + +>(*) MySQL recognizes BOOL as a column type and silently uses +>TINYINT(1) instead. +> +> +I've checked that and you are right, but the BOOL is in MySQL from +version 4.1.0 though we could use tinyint instead of enum - our bad choice. + +Miroslav + +--------------080008030501040400020606 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------080008030501040400020606-- + +From pgsql-hackers-owner@postgresql.org Mon Mar 21 03:16:03 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3244052A5B; + Mon, 14 Mar 2005 15:54:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65419-07; Mon, 14 Mar 2005 15:54:29 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 2124F55E98; + Mon, 14 Mar 2005 15:54:26 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j2EFsT2f002904; (envelope-from ) Mon, + 14 Mar 2005 09:54:30 -0600 (CST) +Received: from [192.168.1.13] (12-217-241-0.client.mchsi.com [12.217.241.0]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j2EFsSGO022321 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Mon, + 14 Mar 2005 09:54:29 -0600 (CST) +Message-ID: <4235B3B5.3040209@arbash-meinel.com> +Date: Mon, 14 Mar 2005 09:54:29 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?windows-1250?Q?Miroslav_=8Aulc?= +Cc: Tom Lane , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <423478B1.7080106@arbash-meinel.com> + <18381.1110741354@sss.pgh.pa.us> <423497FE.6040908@startnet.cz> + <19293.1110743673@sss.pgh.pa.us> <42349C96.60401@startnet.cz> + <3174.1110745587@sss.pgh.pa.us> <4234AF56.1040509@startnet.cz> + <6715.1110758921@sss.pgh.pa.us> <42354EA7.4020907@startnet.cz> +In-Reply-To: <42354EA7.4020907@startnet.cz> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig6877F4BA4242716DD3BB785E" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/726 +X-Sequence-Number: 65528 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig6877F4BA4242716DD3BB785E +Content-Type: text/plain; charset=windows-1250; format=flowed +Content-Transfer-Encoding: 8bit + +Miroslav �ulc wrote: + +> Tom Lane wrote: +> +>> ... +>> I think the reason this is popping to the top of the runtime is that the +>> joins are so wide (an average of ~85 columns in a join tuple according +>> to the numbers above). Because there are lots of variable-width columns +>> involved, most of the time the fast path for field access doesn't apply +>> and we end up going to nocachegetattr --- which itself is going to be +>> slow because it has to scan over so many columns. So the cost is +>> roughly O(N^2) in the number of columns. +>> +>> +> As there are a lot of varchar(1) in the AdDevicesSites table, wouldn't +> be helpful to change them to char(1)? Would it solve the +> variable-width problem at least for some fields and speed the query up? +> +I'm guessing there really wouldn't be a difference. I think varchar() +and char() are stored the same way, just one always has space padding. I +believe they are both varlena types, so they are still "variable" length. + +>> As a short-term hack, you might be able to improve matters if you can +>> reorder your LEFT JOINs to have the minimum number of columns +>> propagating up from the earlier join steps. In other words make the +>> later joins add more columns than the earlier, as much as you can. +>> +>> +> That will be hard as the main table which contains most of the fields +> is LEFT JOINed with the others. I'll look at it if I find some way to +> improve it. + +One thing that you could try, is to select just the primary keys from +the main table, and then later on, join back to that table to get the +rest of the columns. It is a little bit hackish, but if it makes your +query faster, you might want to try it. + +> +> I'm not sure whether I understand the process of performing the plan +> but I imagine that the data from AdDevicesSites are retrieved only +> once when they are loaded and maybe stored in memory. Are the columns +> stored in the order they are in the SQL command? If so, wouldn't it be +> useful to move all varchar fields at the end of the SELECT query? I'm +> just guessing because I don't know at all how a database server is +> implemented and what it really does. +> +I don't think they are stored in the order of the SELECT <> portion. I'm +guessing they are loaded and saved as you go. But that the order of the +LEFT JOIN at the end is probably important. + +>> .. +>> regards, tom lane +>> +>> +> Miroslav + + +John +=:-> + + +--------------enig6877F4BA4242716DD3BB785E +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCNbO1JdeBCYSNAAMRAsumAJ4yGUVZvYqBgKBLnYI2GVabC69GbwCfeL99 +JRGLUKxq6NLt0R5YciE2odM= +=wUoo +-----END PGP SIGNATURE----- + +--------------enig6877F4BA4242716DD3BB785E-- + +From pgsql-performance-owner@postgresql.org Mon Mar 14 15:59:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BD95565CD + for ; + Mon, 14 Mar 2005 15:59:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66047-10 + for ; + Mon, 14 Mar 2005 15:59:14 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id EEF415644C + for ; + Mon, 14 Mar 2005 15:59:11 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DAry4-0002E5-00; Mon, 14 Mar 2005 10:58:56 -0500 +To: =?iso-8859-1?q?Miroslav_=A9ulc?= +Cc: Christopher Kings-Lynne , + John Arbash Meinel , + PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> <42347407.2000202@startnet.cz> + <42347D5E.9000900@arbash-meinel.com> <42348F54.1000408@startnet.cz> + <423493E5.6040203@arbash-meinel.com> <42355249.8090101@startnet.cz> + <4235533E.8040100@familyhealth.com.au> <423554D2.9000207@startnet.cz> +In-Reply-To: <423554D2.9000207@startnet.cz> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 14 Mar 2005 10:58:55 -0500 +Message-ID: <877jkauslc.fsf@stark.xeocode.com> +Lines: 9 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.014 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/264 +X-Sequence-Number: 10969 + +Miroslav �ulc writes: + +> I think so. I'll change the varchar(1) fields to char(1) where possible + +char isn't faster than varchar on postgres. If anything it may be slightly +slower because every comparison first needs to pad both sides with spaces. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Mar 14 16:23:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C39BA563F4 + for ; + Mon, 14 Mar 2005 16:23:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74603-06 + for ; + Mon, 14 Mar 2005 16:23:41 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 41C4F563AA + for ; + Mon, 14 Mar 2005 16:23:40 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2EGNaZD014080; + Mon, 14 Mar 2005 11:23:36 -0500 (EST) +To: =?ISO-8859-15?Q?Miroslav_=A6ulc?= +Cc: PFC , + John Arbash Meinel , + PGSQL mailing list +Subject: Re: How to read query plan +In-reply-to: <423556B8.4020500@startnet.cz> +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> + <42348F54.1000408@startnet.cz> <423493E5.6040203@arbash-meinel.com> + <42355249.8090101@startnet.cz> + <423556B8.4020500@startnet.cz> +Comments: In-reply-to =?ISO-8859-15?Q?Miroslav_=A6ulc?= + + message dated "Mon, 14 Mar 2005 10:17:44 +0100" +Date: Mon, 14 Mar 2005 11:23:36 -0500 +Message-ID: <14079.1110817416@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/265 +X-Sequence-Number: 10970 + +=?ISO-8859-15?Q?Miroslav_=A6ulc?= writes: +> PFC wrote: +>> Instead of a varchar(1) containing 'y' or 'n' you could use a BOOL +>> or an integer. + +> Sure I could. The problem is our project still supports both MySQL and +> PostgreSQL. We used enum('Y','N') in MySQL so there would be a lot of +> changes in the code if we would change to the BOOL data type. + +Just FYI, I did a quick search-and-replace on your dump to replace +varchar(1) by "char", which makes the column fixed-width without any +change in the visible data. This made hardly any difference in the +join speed though :-(. So that is looking like a dead end. + +John's idea about re-joining to the main table to pick up the bulk of +its fields only after joining to the sub-tables might work. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 14 16:33:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 03A325638B + for ; + Mon, 14 Mar 2005 16:33:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77312-06 + for ; + Mon, 14 Mar 2005 16:33:47 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 12A4D55F07 + for ; + Mon, 14 Mar 2005 16:33:45 +0000 (GMT) +Received: (qmail 3827 invoked from network); 14 Mar 2005 17:33:45 +0100 +Received: from startnet.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.6.17) + by mail.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 14 Mar 2005 17:33:45 +0100 +Message-ID: <4235BCE8.1090705@startnet.cz> +Date: Mon, 14 Mar 2005 17:33:44 +0100 +From: =?windows-1250?Q?Miroslav_=8Aulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: PFC , + John Arbash Meinel , + PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> + <42348F54.1000408@startnet.cz> <423493E5.6040203@arbash-meinel.com> + <42355249.8090101@startnet.cz> + <423556B8.4020500@startnet.cz> <14079.1110817416@sss.pgh.pa.us> +In-Reply-To: <14079.1110817416@sss.pgh.pa.us> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------050307060105030602050402" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/266 +X-Sequence-Number: 10971 + +This is a multi-part message in MIME format. +--------------050307060105030602050402 +Content-Type: text/plain; charset=windows-1250; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>Just FYI, I did a quick search-and-replace on your dump to replace +>varchar(1) by "char", which makes the column fixed-width without any +>change in the visible data. This made hardly any difference in the +>join speed though :-(. So that is looking like a dead end. +> +> +I'll try to change the data type to bool but the problem I stand in +front of is that the code expects that SELECTs return 'Y' or 'N' but +what I have found out till now is that PostgreSQL returns 't' or 'f' for +bool data. I think about some solution but they use CPU :-( + +>John's idea about re-joining to the main table to pick up the bulk of +>its fields only after joining to the sub-tables might work. +> +> +I'll try that. It seems it could work. + +> regards, tom lane +> +> +Miroslav + +--------------050307060105030602050402 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------050307060105030602050402-- + +From pgsql-performance-owner@postgresql.org Mon Mar 14 16:36:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A6B555EAE + for ; + Mon, 14 Mar 2005 16:36:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78444-06 + for ; + Mon, 14 Mar 2005 16:36:25 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 3983B52A7A + for ; + Mon, 14 Mar 2005 16:36:24 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j2EGaKDh004391; (envelope-from ) Mon, + 14 Mar 2005 10:36:22 -0600 (CST) +Received: from [192.168.1.13] (12-217-241-0.client.mchsi.com [12.217.241.0]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j2EGaIrN002461 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Mon, + 14 Mar 2005 10:36:19 -0600 (CST) +Message-ID: <4235BD81.1060606@arbash-meinel.com> +Date: Mon, 14 Mar 2005 10:36:17 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: =?ISO-8859-15?Q?Miroslav_=A6ulc?= +Cc: PFC , + PGSQL mailing list +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> + <42348F54.1000408@startnet.cz> <423493E5.6040203@arbash-meinel.com> + <42355249.8090101@startnet.cz> + <423556B8.4020500@startnet.cz> +In-Reply-To: <423556B8.4020500@startnet.cz> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig3FC72B5A1B44F3B4815DC440" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/267 +X-Sequence-Number: 10972 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig3FC72B5A1B44F3B4815DC440 +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 8bit + +Miroslav �ulc wrote: + +> PFC wrote: +> +>> Your query seems of the form : +>> +>> SELECT FROM main_table LEFT JOIN a lot of tables ORDER BY +>> sort_key LIMIT N OFFSET M; +>> +>> I would suggest to rewrite it in a simpler way : instead of +>> generating the whole result set, sorting it, and then grabbing a +>> slice, generate only the ror id's, grab a slice, and then generate +>> the full rows from that. +>> +>> - If you order by a field which is in main_table : +>> SELECT FROM main_table LEFT JOIN a lot of tables WHERE +>> main_table.id IN (SELECT id FROM main_table ORDER BY sort_key LIMIT +>> N OFFSET M +>> ) ORDER BY sort_key LIMIT N OFFSET M; +>> +>> - If you order by a field in one of the child tables, I guess you +>> only want to display the rows in the main table which have this +>> field, ie. not-null in the LEFT JOIN. You can also use the principle +>> above. +>> +>> - You can use a straight join instead of an IN. +> +> +> Do you mean something like this? +> +> SELECT Table.IDPK, Table2.varchar1, Table2.varchar2, ... +> FROM Table +> LEFT JOIN many tables +> INNER JOIN Table AS Table2 +> +> Miroslav + +I would also recommend using the subselect format. Where any columns +that you are going to need to sort on show up in the subselect. + +So you would have: + +SELECT ... + FROM main_table + LEFT JOIN tablea ON ... + LEFT JOIN tableb ON ... + ... + JOIN other_table ON ... + WHERE main_table.idpk IN + (SELECT idpk + FROM main_table JOIN other_table ON main_table.idpk = +other_table. + WHERE ... + ORDER BY other_table.abcd LIMIT n OFFSET m) +; + +I think the final LIMIT + OFFSET would give you the wrong results, since +you have already filtered out the important rows. +I also think you don't need the final order by, since the results should +already be in sorted order. + +Now this also assumes that if someone is sorting on a row, then they +don't want null entries. If they do, then you can change the subselect +into a left join. But with appropriate selectivity and indexes, an inner +join can filter out a lot of rows, and give you better performance. + +The inner subselect gives you selectivity on the main table, so that you +don't have to deal with all the columns in the search, and then you +don't have to deal with all the rows later on. + +I think you can also do this: + +SELECT ... + FROM (SELECT main_table.idpk, other_table. FROM main_table +JOIN other_table ....) as p + LEFT JOIN ... + JOIN main_table ON main_table.idpk = p.idpk; + +In that case instead of selecting out the id and putting that into the +where, you put it in the from, and then join against it. +I don't really know which is better. + +John +=:-> + + +--------------enig3FC72B5A1B44F3B4815DC440 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCNb2BJdeBCYSNAAMRAoUlAKC0bUOwRIiE/8aTNcfeGqvMRijdpwCeOBcV +B/4iGWCyl9z0vn/czJ48SG4= +=iF5Y +-----END PGP SIGNATURE----- + +--------------enig3FC72B5A1B44F3B4815DC440-- + +From pgsql-performance-owner@postgresql.org Mon Mar 14 16:50:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 00C18563EA + for ; + Mon, 14 Mar 2005 16:50:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83279-05 + for ; + Mon, 14 Mar 2005 16:50:18 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id E3BE755EAE + for ; + Mon, 14 Mar 2005 16:50:16 +0000 (GMT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j2EHr6p02117 + for ; Mon, 14 Mar 2005 18:53:07 +0100 +Received: from [127.0.0.1] (accesspoint.mm.eutelsat.org [194.214.173.4]) + by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j2EGoBR03049 + for ; Mon, 14 Mar 2005 17:50:11 +0100 +Message-ID: <4235C028.9060200@bigfoot.com> +Date: Mon, 14 Mar 2005 17:47:36 +0100 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Subject: Bad Performance[2] +X-Enigmail-Version: 0.90.1.1 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.363 tagged_above=0 required=5 tests=AWL, + TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200503/268 +X-Sequence-Number: 10973 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Hi all, +running 7.4.x I still have problem +with the select but I do not find any solution apart to rise to 0.7 the +cpu_tuple_cost, I'm reposting it in the hope to discover a glitch in +the planner. + + +# explain analyze select * from v_sc_user_request where login = 'Zoneon'; + QUERY PLAN +- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Subquery Scan v_sc_user_request (cost=1029.67..1029.68 rows=1 width=364) (actual time=319350.564..319352.632 rows=228 loops=1) + -> Sort (cost=1029.67..1029.68 rows=1 width=203) (actual time=319350.537..319350.683 rows=228 loops=1) + Sort Key: sr.id_sat_request + -> Nested Loop Left Join (cost=491.15..1029.66 rows=1 width=203) (actual time=897.252..319349.443 rows=228 loops=1) + Join Filter: ("outer".id_package = "inner".id_package) + -> Nested Loop (cost=4.00..382.67 rows=1 width=195) (actual time=31.252..2635.751 rows=228 loops=1) + -> Hash Join (cost=4.00..379.59 rows=1 width=40) (actual time=31.174..578.979 rows=228 loops=1) + Hash Cond: ("outer".id_user = "inner".id_user) + -> Index Scan using idx_sat_request_expired on sat_request sr (cost=0.00..360.02 rows=3112 width=28) (actual time=0.150..535.697 rows=7990 loops=1) + Index Cond: (expired = false) + Filter: (request_time > (now() - '1 mon'::interval)) + -> Hash (cost=4.00..4.00 rows=2 width=16) (actual time=30.542..30.542 rows=0 loops=1) + -> Index Scan using user_login_login_key on user_login ul (cost=0.00..4.00 rows=2 width=16) (actual time=30.482..30.490 rows=1 loops=1) + Index Cond: ((login)::text = 'Zoneon'::text) + -> Index Scan using url_pkey on url u (cost=0.00..3.08 rows=1 width=163) (actual time=8.982..8.988 rows=1 loops=228) + Index Cond: ("outer".id_url = u.id_url) + -> Subquery Scan vsp (cost=487.15..642.42 rows=1298 width=12) (actual time=4.703..1384.172 rows=429 loops=228) + -> Hash Join (cost=487.15..641.12 rows=1298 width=128) (actual time=4.697..1382.081 rows=429 loops=228) + Hash Cond: ("outer".id_program = "inner".id_program) + -> Hash Join (cost=469.80..599.65 rows=1320 width=113) (actual time=0.755..30.305 rows=429 loops=228) + Hash Cond: ("outer".id_package = "inner".id_package) + -> Hash Left Join (cost=13.86..79.54 rows=1479 width=101) (actual time=0.298..24.121 rows=1468 loops=228) + Hash Cond: ("outer".id_package = "inner".id_package) + -> Seq Scan on packages p (cost=0.00..53.48 rows=1479 width=101) (actual time=0.265..10.898 rows=1468 loops=228) + -> Hash (cost=11.10..11.10 rows=1104 width=4) (actual time=2.506..2.506 rows=0 loops=1) + -> Seq Scan on package_security ps (cost=0.00..11.10 rows=1104 width=4) (actual time=0.018..1.433 rows=1096 loops=1) + -> Hash (cost=450.47..450.47 rows=2186 width=16) (actual time=92.435..92.435 rows=0 loops=1) + -> Seq Scan on sequences (cost=0.00..450.47 rows=2186 width=16) (actual time=0.044..91.641 rows=429 loops=1) + Filter: (estimated_start IS NOT NULL) + -> Hash (cost=17.20..17.20 rows=57 width=19) (actual time=0.383..0.383 rows=0 loops=1) + -> Seq Scan on programs (cost=0.00..17.20 rows=57 width=19) (actual time=0.024..0.323 rows=48 loops=1) + Filter: (id_program <> 0) + Total runtime: 319364.927 ms + +# set cpu_tuple_cost = 0.7; + + +# explain analyze select * from v_sc_user_request where login = 'Zoneon'; + QUERY PLAN +- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Subquery Scan v_sc_user_request (cost=14708.99..14709.69 rows=1 width=364) (actual time=9956.650..9958.273 rows=228 loops=1) + -> Sort (cost=14708.99..14708.99 rows=1 width=203) (actual time=9956.635..9956.778 rows=228 loops=1) + Sort Key: sr.id_sat_request + -> Merge Left Join (cost=14701.75..14708.98 rows=1 width=203) (actual time=8138.468..9955.724 rows=228 loops=1) + Merge Cond: ("outer".id_package = "inner".id_package) + -> Sort (cost=6909.94..6909.95 rows=1 width=195) (actual time=5454.427..5454.760 rows=228 loops=1) + Sort Key: sr.id_package + -> Nested Loop (cost=4.70..6909.93 rows=1 width=195) (actual time=0.763..5453.236 rows=228 loops=1) + -> Hash Join (cost=4.70..6905.45 rows=1 width=40) (actual time=0.718..2325.661 rows=228 loops=1) + Hash Cond: ("outer".id_user = "inner".id_user) + -> Index Scan using idx_sat_request_expired on sat_request sr (cost=0.00..6884.49 rows=3112 width=28) (actual time=0.090..2310.108 rows=7989 loops=1) + Index Cond: (expired = false) + Filter: (request_time > (now() - '1 mon'::interval)) + -> Hash (cost=4.70..4.70 rows=2 width=16) (actual time=0.150..0.150 rows=0 loops=1) + -> Index Scan using user_login_login_key on user_login ul (cost=0.00..4.70 rows=2 width=16) (actual time=0.129..0.133 rows=1 loops=1) + Index Cond: ((login)::text = 'Zoneon'::text) + -> Index Scan using url_pkey on url u (cost=0.00..3.78 rows=1 width=163) (actual time=13.029..13.685 rows=1 loops=228) + Index Cond: ("outer".id_url = u.id_url) + -> Sort (cost=7791.81..7795.05 rows=1298 width=12) (actual time=2674.369..2674.791 rows=429 loops=1) + Sort Key: vsp.id_package + -> Subquery Scan vsp (cost=3026.61..7724.69 rows=1298 width=12) (actual time=177.979..2672.841 rows=429 loops=1) + -> Hash Join (cost=3026.61..6816.09 rows=1298 width=128) (actual time=177.969..2670.402 rows=429 loops=1) + Hash Cond: ("outer".id_program = "inner".id_program) + -> Hash Join (cost=2968.72..5826.77 rows=1320 width=113) (actual time=158.053..200.867 rows=429 loops=1) + Hash Cond: ("outer".id_package = "inner".id_package) + -> Hash Left Join (cost=785.56..2656.75 rows=1479 width=101) (actual time=3.127..40.350 rows=1468 loops=1) + Hash Cond: ("outer".id_package = "inner".id_package) + -> Seq Scan on packages p (cost=0.00..1087.30 rows=1479 width=101) (actual time=0.039..24.680 rows=1468 loops=1) + -> Hash (cost=782.80..782.80 rows=1104 width=4) (actual time=2.622..2.622 rows=0 loops=1) + -> Seq Scan on package_security ps (cost=0.00..782.80 rows=1104 width=4) (actual time=0.012..1.401 rows=1096 loops=1) + -> Hash (cost=2177.70..2177.70 rows=2186 width=16) (actual time=154.563..154.563 rows=0 loops=1) + -> Seq Scan on sequences (cost=0.00..2177.70 rows=2186 width=16) (actual time=0.012..153.654 rows=429 loops=1) + Filter: (estimated_start IS NOT NULL) + -> Hash (cost=57.74..57.74 rows=57 width=19) (actual time=0.289..0.289 rows=0 loops=1) + -> Seq Scan on programs (cost=0.00..57.74 rows=57 width=19) (actual time=0.022..0.224 rows=48 loops=1) + Filter: (id_program <> 0) + Total runtime: 9959.293 ms +(37 rows) + + + +here the views definition: + +CREATE OR REPLACE VIEW v_sc_user_request AS + SELECT + vsr.id_sat_request AS id_sat_request, + vsr.id_user AS id_user, + vsr.login AS login, + vsr.url AS url, + vsr.name AS name, + vsr.descr AS descr, + vsr.size AS size, + trunc(vsr.size/1024.0/1024.0,2) AS size_mb, + vsr.id_sat_request_status AS id_sat_request_status, + sp_lookup_key('sat_request_status', vsr.id_sat_request_status) AS request_status, + sp_lookup_descr('sat_request_status', vsr.id_sat_request_status) AS request_status_descr, + vsr.id_url_status AS id_url_status, + sp_lookup_key('url_status', vsr.id_url_status) AS url_status, + sp_lookup_descr('url_status', vsr.id_url_status) AS url_status_descr, + vsr.url_time_stamp AS url_time_stamp, + date_trunc('seconds',vsr.request_time) AS request_time_stamp, + vsr.id_package AS id_package, + COALESCE(date_trunc('seconds',vsp.estimated_start)::text,'NA') AS estimated_start + + FROM + v_sat_request vsr LEFT OUTER JOIN v_sc_packages vsp USING ( id_package ) + WHERE + vsr.request_time > now() - '1 month'::interval AND + vsr.expired = FALSE + ORDER BY id_sat_request DESC +; + + + + +CREATE OR REPLACE VIEW v_sat_request AS + SELECT + sr.id_user AS id_user, + ul.login AS login, + sr.id_sat_request AS id_sat_request, + u.id_url AS id_url, + u.url AS url, + u.name AS name, + u.descr AS descr, + u.size AS size, + u.storage AS storage, + sr.id_package AS id_package, + sr.id_sat_request_status AS id_sat_request_status, + sr.request_time AS request_time, + sr.work_time AS request_work_time, + u.id_url_status AS id_url_status, + u.time_stamp AS url_time_stamp, + sr.expired AS expired + FROM + sat_request sr, + url u, + user_login ul + WHERE + ---------------- JOIN --------------------- + sr.id_url = u.id_url AND + sr.id_user = ul.id_user + ------------------------------------------- +; + + + + +CREATE OR REPLACE VIEW v_sc_packages AS + SELECT + + vpr.id_program AS id_program, + vpr.name AS program_name, + + vpk.id_package AS id_package, + date_trunc('seconds', vs.estimated_start) AS estimated_start, + + vpk.name AS package_name, + vpk.TYPE AS TYPE, + vpk.description AS description, + vpk.target AS target, + vpk.fec AS fec_alg, + vpk.output_group - vpk.input_group AS fec_redundancy, + vpk.priority AS priority, + vpk.updatable AS updatable, + vpk.auto_listen AS auto_listen, + vpk.start_file AS start_file, + vpk.view_target_group AS view_target_group, + vpk.target_group AS target_group + + FROM + v_programs vpr, + v_packages vpk, + v_sequences vs + + WHERE + ------------ JOIN ------------- + vpr.id_program = vs.id_program AND + vpk.id_package = vs.id_package AND + + ------------------------------- + vs.estimated_start IS NOT NULL +; + + + +CREATE OR REPLACE VIEW v_programs AS + SELECT id_program AS id_program, + id_publisher AS id_publisher, + name AS name, + description AS description, + sp_lookup_key('program_type', id_program_type) AS TYPE, + sp_lookup_key('program_status', id_program_status) AS status, + last_position AS last_position + FROM programs + WHERE id_program<>0 +; + + +CREATE OR REPLACE VIEW v_packages AS + SELECT p.id_package AS id_package, + p.id_publisher AS id_publisher, + p.name AS name, + p.information AS information, + p.description AS description, + sp_lookup_key('package_type', p.id_package_type) + AS TYPE, + sp_lookup_key('target', p.id_target) + AS target, + p.port AS port, + p.priority AS priority, + sp_lookup_key('fec', p.id_fec) + AS fec, + p.input_group AS input_group, + p.output_group AS output_group, + p.updatable AS updatable, + p.checksum AS checksum, + p.version AS version, + p.start_file AS start_file, + p.view_target_group AS view_target_group, + p.target_group AS target_group, + p.auto_listen AS auto_listen, + p.public_flag AS public_flag, + p.needed_version AS needed_version, + p.logic_version AS logic_version, + p.package_size AS package_size, + ps.id_drm_process AS id_drm_process, + ps.id_cas_service AS id_cas_service, + ps.id_cas_settings AS id_cas_settings, + ps.id_drm_service AS id_drm_service + + FROM packages p LEFT OUTER JOIN package_security ps USING (id_package) + ; + + + +CREATE OR REPLACE VIEW v_sequences AS + SELECT id_package AS id_package, + id_program AS id_program, + internal_position AS internal_position, + estimated_start AS estimated_start + FROM sequences +; + + + +Regards +Gaetano Mendola + + + + + + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCNcAn7UpzwH2SGd4RAkBrAJ4+TFXKVggjNH2ddjezNt1GAGgSAQCfXGQt +BeEVkXECodZRCg395mAdaJE= +=UVGS +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Mon Mar 14 16:50:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 56EE655EAE + for ; + Mon, 14 Mar 2005 16:50:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83055-06 + for ; + Mon, 14 Mar 2005 16:50:38 +0000 (GMT) +Received: from school.digsys.bg (school.digsys.bg [193.68.6.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EA4D56634 + for ; + Mon, 14 Mar 2005 16:50:36 +0000 (GMT) +Received: from faith.digsys.bg (sigma.digsys.bg [193.68.6.19]) + by school.digsys.bg (8.11.6/8.10.1) with ESMTP id j2EGoWV15917; + Mon, 14 Mar 2005 18:50:32 +0200 (EET) +Message-ID: <4235C3E9.2080505@faith.digsys.bg> +Date: Mon, 14 Mar 2005 19:03:37 +0200 +From: Kaloyan Iliev Iliev +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040115 +X-Accept-Language: en-us, en, bg +MIME-Version: 1.0 +To: =?windows-1251?Q?Miroslav_=8Aulc?= , + pgsql-performance@postgresql.org +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> + <42348F54.1000408@startnet.cz> <423493E5.6040203@arbash-meinel.com> + <42355249.8090101@startnet.cz> + <423556B8.4020500@startnet.cz> <14079.1110817416@sss.pgh.pa.us> + <4235BCE8.1090705@startnet.cz> +In-Reply-To: <4235BCE8.1090705@startnet.cz> +Content-Type: multipart/alternative; + boundary="------------050004070400010902040206" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.12 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, HTML_30_40, HTML_MESSAGE, HTML_TITLE_EMPTY +X-Spam-Level: +X-Archive-Number: 200503/269 +X-Sequence-Number: 10974 + +This is a multi-part message in MIME format. +--------------050004070400010902040206 +Content-Type: text/plain; charset=windows-1251; format=flowed +Content-Transfer-Encoding: 8bit + +Hi, + +I have an idea about your problem. Will it be difficult not to change +the entire code but only the queries? You can change type in the +Postgres to bool. Then, when select data you can use a CASE..WHEN to +return 'Y' or 'N' or even write a little function which accepts bool and +returns 'Y' or 'N'. In this case in all your queries you will have to +replace the select of bool field with select form the function. + +Kaloyan + +Miroslav �ulc wrote: + +> Tom Lane wrote: +> +>> Just FYI, I did a quick search-and-replace on your dump to replace +>> varchar(1) by "char", which makes the column fixed-width without any +>> change in the visible data. This made hardly any difference in the +>> join speed though :-(. So that is looking like a dead end. +>> +>> +> I'll try to change the data type to bool but the problem I stand in +> front of is that the code expects that SELECTs return 'Y' or 'N' but +> what I have found out till now is that PostgreSQL returns 't' or 'f' +> for bool data. I think about some solution but they use CPU :-( +> +>> John's idea about re-joining to the main table to pick up the bulk of +>> its fields only after joining to the sub-tables might work. +>> +>> +> I'll try that. It seems it could work. +> +>> regards, tom lane +>> +>> +> Miroslav +> +>------------------------------------------------------------------------ +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> +> + +--------------050004070400010902040206 +Content-Type: text/html; charset=windows-1251 +Content-Transfer-Encoding: 8bit + + + + + + + + +Hi,
+
+I have an idea about your problem. Will it be difficult not to change +the entire code but only the queries? You can change type in the +Postgres to bool. Then, when select data you can use a CASE..WHEN to +return 'Y' or 'N' or even write a little function which accepts bool +and returns 'Y' or 'N'. In this case in all your queries you will have +to replace the select of bool field with select form the function.
+
+Kaloyan
+
+Miroslav �ulc wrote: +
Tom Lane +wrote: +
+
+
Just FYI, I did a quick search-and-replace on +your dump to replace +
+varchar(1) by "char", which makes the column fixed-width without any +
+change in the visible data.� This made hardly any difference in the +
+join speed though :-(.� So that is looking like a dead end. +
+� +
+
+
+I'll try to change the data type to bool but the problem I stand in +front of is that the code expects that SELECTs return 'Y' or 'N' but +what I have found out till now is that PostgreSQL returns 't' or 'f' +for bool data. I think about some solution but they use CPU :-( +
+
+
John's idea about re-joining to the main +table to pick up the bulk of +
+its fields only after joining to the sub-tables might work. +
+� +
+
+
+I'll try that. It seems it could work. +
+
+
����������� regards, tom lane +
+� +
+
+
+Miroslav +
+
+
+ +---------------------------(end of broadcast)--------------------------- +TIP 5: Have you checked our extensive FAQ? + + http://www.postgresql.org/docs/faq +
+
+ + + +--------------050004070400010902040206-- + +From pgsql-performance-owner@postgresql.org Mon Mar 14 17:08:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 841AA567AF + for ; + Mon, 14 Mar 2005 17:08:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88395-10 + for ; + Mon, 14 Mar 2005 17:08:01 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id A764655F51 + for ; + Mon, 14 Mar 2005 17:07:58 +0000 (GMT) +Received: (qmail 9464 invoked from network); 14 Mar 2005 18:07:55 +0100 +Received: from startnet.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.6.17) + by mail.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 14 Mar 2005 18:07:55 +0100 +Message-ID: <4235C4EA.40704@startnet.cz> +Date: Mon, 14 Mar 2005 18:07:54 +0100 +From: =?UTF-8?B?TWlyb3NsYXYgxaB1bGM=?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Kaloyan Iliev Iliev +Cc: pgsql-performance@postgresql.org +Subject: Re: How to read query plan +References: <42345D24.8070104@startnet.cz> + <4234692E.3050802@arbash-meinel.com> + <42347407.2000202@startnet.cz> <42347D5E.9000900@arbash-meinel.com> + <42348F54.1000408@startnet.cz> <423493E5.6040203@arbash-meinel.com> + <42355249.8090101@startnet.cz> + <423556B8.4020500@startnet.cz> <14079.1110817416@sss.pgh.pa.us> + <4235BCE8.1090705@startnet.cz> <4235C3E9.2080505@faith.digsys.bg> +In-Reply-To: <4235C3E9.2080505@faith.digsys.bg> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------070209000404000505020609" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/270 +X-Sequence-Number: 10975 + +This is a multi-part message in MIME format. +--------------070209000404000505020609 +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit + +Kaloyan Iliev Iliev wrote: + +> Hi, +> +> I have an idea about your problem. Will it be difficult not to change +> the entire code but only the queries? You can change type in the +> Postgres to bool. Then, when select data you can use a CASE..WHEN to +> return 'Y' or 'N' or even write a little function which accepts bool +> and returns 'Y' or 'N'. In this case in all your queries you will have +> to replace the select of bool field with select form the function. + +Thank you for your suggestion. I had a private message exchange with +Harald Fuchs who suggested the same (except the function). Here is what +whe "exchanged": + +Harald Fuchs wrote: + +> If you can control the SELECTs, just use +> +> SELECT CASE col WHEN true THEN 'Y' ELSE 'N' END +> +> instead of +> +> SELECT col +> +> Thus you wouldn't need to change your application code. +> +> +I use single SELECT for both PostgreSQL and MySQL. I could use your +solution. It would just require some tagging of bool fields in SELECTs +so I could add the CASE statement in case I use PostgreSQL backend. + +Miroslav + +--------------070209000404000505020609 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +YmVnaW46dmNhcmQNCmZuO3F1b3RlZC1wcmludGFibGU6TWlyb3NsYXYgPUM1PUEwdWxjDQpu +O3F1b3RlZC1wcmludGFibGU6PUM1PUEwdWxjO01pcm9zbGF2DQpvcmc6U3RhcnROZXQgcy5y +Lm8uDQphZHI7cXVvdGVkLXByaW50YWJsZTtxdW90ZWQtcHJpbnRhYmxlOjs7VnJjaGxpY2s9 +QzM9QTlobyAxNjEvNTtQcmFoYSA1OzsxNTAgMDA7PUM0PThDZXNrPUMzPUExIHJlcHVibGlr +YQ0KZW1haWw7aW50ZXJuZXQ6bWlyb3NsYXYuc3VsY0BzdGFydG5ldC5jeg0KdGl0bGU6Q0VP +DQp0ZWw7d29yazorNDIwIDI1NyAyMjUgNjAyDQp0ZWw7Y2VsbDorNDIwIDYwMyA3MTEgNDEz +DQp4LW1vemlsbGEtaHRtbDpUUlVFDQp1cmw6aHR0cDovL3d3dy5zdGFydG5ldC5jeg0KdmVy +c2lvbjoyLjENCmVuZDp2Y2FyZA0KDQo= +--------------070209000404000505020609-- + +From pgsql-hackers-owner@postgresql.org Mon Mar 14 17:24:29 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5132456665; + Mon, 14 Mar 2005 17:24:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92534-10; Mon, 14 Mar 2005 17:24:24 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 06A065663A; + Mon, 14 Mar 2005 17:24:23 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2EHONnq014578; + Mon, 14 Mar 2005 12:24:23 -0500 (EST) +To: pgsql-hackers@postgreSQL.org +Cc: =?ISO-8859-2?Q?Miroslav_=A9ulc?= , + pgsql-performance@postgreSQL.org +Subject: Avoiding tuple construction/deconstruction during joining +References: <42345D24.8070104@startnet.cz> +Date: Mon, 14 Mar 2005 12:24:22 -0500 +Message-ID: <14577.1110821062@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/453 +X-Sequence-Number: 65255 + +=?ISO-8859-2?Q?Miroslav_=A9ulc?= writes: +> [ concerning a deeply nested LEFT JOIN to get data from a star schema ] + +> So I have some results. I have tested the query on both PostgreSQL 8.0.1 +> and MySQL 4.1.8 with LIMIT set to 30 and OFFSET set to 6000. PostgreSQL +> result is 11,667.916 ms, MySQL result is 448.4 ms. + +That's a fairly impressive discrepancy :-(, and even the slot_getattr() +patch that Atsushi Ogawa provided isn't going to close the gap. +(I got about a 4x speedup on Miroslav's example in my testing, which +leaves us still maybe 6x slower than MySQL.) + +Looking at the post-patch profile for the test case, there is still +quite a lot of cycles going into tuple assembly and disassembly: + +Each sample counts as 0.01 seconds. + % cumulative self self total + time seconds seconds calls ms/call ms/call name + 24.47 4.49 4.49 _mcount + 8.01 5.96 1.47 9143692 0.00 0.00 ExecEvalVar + 6.92 7.23 1.27 6614373 0.00 0.00 slot_deformtuple + 6.54 8.43 1.20 9143692 0.00 0.00 slot_getattr + 6.21 9.57 1.14 103737 0.01 0.03 ExecTargetList + 5.56 10.59 1.02 103775 0.01 0.01 DataFill + 3.22 11.18 0.59 103775 0.01 0.01 ComputeDataSize + 2.83 11.70 0.52 ExecEvalVar + 2.72 12.20 0.50 9094122 0.00 0.00 memcpy + 2.51 12.66 0.46 encore + 2.40 13.10 0.44 427448 0.00 0.00 nocachegetattr + 2.13 13.49 0.39 103775 0.00 0.02 heap_formtuple + 2.07 13.87 0.38 noshlibs + 1.20 14.09 0.22 225329 0.00 0.00 _doprnt + 1.20 14.31 0.22 msquadloop + 1.14 14.52 0.21 chunks + 0.98 14.70 0.18 871885 0.00 0.00 AllocSetAlloc + 0.98 14.88 0.18 $$dyncall + 0.76 15.02 0.14 594242 0.00 0.00 FunctionCall3 + 0.71 15.15 0.13 213312 0.00 0.00 comparetup_heap + 0.65 15.27 0.12 6364 0.02 0.13 printtup + 0.60 15.38 0.11 790702 0.00 0.00 pfree + +(_mcount is profiling overhead, ignore it.) It looks to me like just +about everything in the top dozen functions is there as a result of the +fact that join steps form new tuples that are the merge of their input +tuples. Even our favorite villains, palloc and pfree, are down in the +sub-percent range. + +I am guessing that the reason MySQL wins on this is that they avoid +doing any data copying during a join step. I wonder whether we could +accomplish the same by taking Ogawa's patch to the next level: allow +a TupleTableSlot to contain either a "materialized" tuple as now, +or a "virtual" tuple that is simply an array of Datums and null flags. +(It's virtual in the sense that any pass-by-reference Datums would have +to be pointing to data at the next level down.) This would essentially +turn the formtuple and deformtuple operations into no-ops, and get rid +of a lot of the associated overhead such as ComputeDataSize and +DataFill. The only operations that would have to forcibly materialize +a tuple would be ones that need to keep the tuple till after they fetch +their next input tuple --- hashing and sorting are examples, but very +many plan node types don't ever need to do that. + +I haven't worked out the details, but it seems likely that this could be +a relatively nonintrusive patch. The main thing that would be an issue +would be that direct reference to slot->val would become verboten (since +you could no longer be sure there was a materialized tuple there). +I think this would possibly affect some contrib stuff, which is a strong +hint that it'd break some existing user-written code out there. + +Thoughts? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 14 18:29:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B599567EC + for ; + Mon, 14 Mar 2005 18:29:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15683-03 + for ; + Mon, 14 Mar 2005 18:29:08 +0000 (GMT) +Received: from bramble.mmrd.com (bramble.mmrd.com [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id ABC5F567E4 + for ; + Mon, 14 Mar 2005 18:29:06 +0000 (GMT) +Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) + by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id j2EI2BoJ027140; + Mon, 14 Mar 2005 13:02:11 -0500 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [10.225.10.110]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id j2EISZJ15293; + Mon, 14 Mar 2005 13:28:38 -0500 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id 12GR2343; Mon, 14 Mar 2005 13:28:33 -0500 +Subject: Re: column name is "LIMIT" +From: Robert Treat +To: Christopher Kings-Lynne +Cc: Gourish Singbal , + Russell Smith , pgsql-performance@postgresql.org +In-Reply-To: <42355185.3070803@familyhealth.com.au> +References: <674d1f8a0503132314754df153@mail.gmail.com> + <200503141825.22827.mr-russ@pws.com.au> + <674d1f8a05031400482c413087@mail.gmail.com> + <42355185.3070803@familyhealth.com.au> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 14 Mar 2005 13:28:34 -0500 +Message-Id: <1110824915.4281.123.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.04 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/272 +X-Sequence-Number: 10977 + +Yeah... how come no one told him "don't do that"? LIMIT is an SQL +reserved word, so it's likely to cause trouble in any database you try +to use it on... I'd strongly recommend renaming that column asap. You +can see other reserved words at +http://www.postgresql.org/docs/8.0/interactive/sql-keywords-appendix.html + +Robert Treat + +On Mon, 2005-03-14 at 03:55, Christopher Kings-Lynne wrote: +> You will still need to use double quotes in 8.0.1... +> +> Chris +> +> Gourish Singbal wrote: +> > Thanks a lot, +> > +> > we might be upgrading to 8.0.1 soon.. till than using double quotes +> > should be fine. +> > +> > regards +> > gourish +> > +> > On Mon, 14 Mar 2005 18:25:22 +1100, Russell Smith wrote: +> > +> >>On Mon, 14 Mar 2005 06:14 pm, Gourish Singbal wrote: +> >> +> >>>Guys, +> >>> +> >>>I am having a problem firing queries on one of the tables which is +> >>>having "limit" as the column name. +> >>> +> >>>If a run an insert/select/update command on that table i get the below error. +> >>> +> >>>ERROR: syntax error at or near "limit" at character 71 +> >> +> >>select "limit" from limit_table WHERE "limit" < 50 LIMIT 2; +> >> +> >>You need to quote the field name, and make sure the case is correct. +> >> +> >>>Any Help would be realyl great to solve the problem. +> >>> +> >>>postgresql 7.4.5 and linux OS +> >>> +> >> +> >>You should probably upgrade to 7.4.7 +> >> +> >>Regards +> >> +> >>Russell Smith. +> >> +> > +> > +> > +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Mon Mar 14 18:55:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C6BF563D5 + for ; + Mon, 14 Mar 2005 18:55:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21851-07 + for ; + Mon, 14 Mar 2005 18:54:56 +0000 (GMT) +Received: from mail2.m-cam.com (unknown [63.124.102.77]) + by svr1.postgresql.org (Postfix) with ESMTP id 34FBD55DC4 + for ; + Mon, 14 Mar 2005 18:54:54 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail2.m-cam.com (Postfix) with ESMTP + id 2FD983E8F8; Mon, 14 Mar 2005 13:59:58 -0500 (EST) +Received: from mail2.m-cam.com ([127.0.0.1]) + by localhost (mail2.m-cam.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 13413-07; Mon, 14 Mar 2005 13:59:49 -0500 (EST) +Received: from [192.168.1.21] (unknown [192.168.1.21]) + by mail2.m-cam.com (Postfix) with ESMTP + id 54C4B3E8F2; Mon, 14 Mar 2005 13:59:49 -0500 (EST) +Message-ID: <4235DDF4.2070200@m-cam.com> +Date: Mon, 14 Mar 2005 13:54:44 -0500 +From: Arshavir Grigorian +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +References: <423209E1.6090200@m-cam.com> + <200503111732.10213.josh@agliodbs.com> +In-Reply-To: <200503111732.10213.josh@agliodbs.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at m-cam.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/273 +X-Sequence-Number: 10978 + +Josh Berkus wrote: +> A, +> +> +>>This is a Sun e450 with dual TI UltraSparc II processors and 2G of RAM. +>>It is currently running Debian Sarge with a 2.4.27-sparc64-smp custom +>>compiled kernel. Postgres is installed from the Debian package and uses +>>all the configuration defaults. +> +> +> Please read http://www.powerpostgresql.com/PerfList +> +I have read that document. Very informative/useful. Thanks. + +From pgsql-performance-owner@postgresql.org Mon Mar 14 18:56:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E48385643C + for ; + Mon, 14 Mar 2005 18:56:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21112-08 + for ; + Mon, 14 Mar 2005 18:56:06 +0000 (GMT) +Received: from smtp103.mail.sc5.yahoo.com (smtp103.mail.sc5.yahoo.com + [66.163.169.222]) + by svr1.postgresql.org (Postfix) with SMTP id 36243563DE + for ; + Mon, 14 Mar 2005 18:56:03 +0000 (GMT) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp103.mail.sc5.yahoo.com with SMTP; 14 Mar 2005 18:56:02 -0000 +Received: from [172.21.8.128] (ismtp.afilias.com [216.217.55.254]) + (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + j2EIu0OU027648; Mon, 14 Mar 2005 13:56:00 -0500 (EST) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <4235DE36.2070608@Yahoo.com> +Date: Mon, 14 Mar 2005 13:55:50 -0500 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Robert Treat +Cc: Christopher Kings-Lynne , + Gourish Singbal , + Russell Smith , pgsql-performance@postgresql.org +Subject: Re: column name is "LIMIT" +References: <674d1f8a0503132314754df153@mail.gmail.com> + <200503141825.22827.mr-russ@pws.com.au> + <674d1f8a05031400482c413087@mail.gmail.com> + <42355185.3070803@familyhealth.com.au> + <1110824915.4281.123.camel@camel> +In-Reply-To: <1110824915.4281.123.camel@camel> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.122 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, + RCVD_IN_SORBS_DUL +X-Spam-Level: ** +X-Archive-Number: 200503/274 +X-Sequence-Number: 10979 + +On 3/14/2005 1:28 PM, Robert Treat wrote: + +> Yeah... how come no one told him "don't do that"? LIMIT is an SQL +> reserved word, so it's likely to cause trouble in any database you try +> to use it on... I'd strongly recommend renaming that column asap. You +> can see other reserved words at +> http://www.postgresql.org/docs/8.0/interactive/sql-keywords-appendix.html +> +> Robert Treat + +Note also that the Slony-I replication system has problems with column +names identical to reserved words. This is rooted in the fact that the +quote_ident() function doesn't quote reserved words ... as it IMHO is +supposed to do. + + +Jan + +> +> On Mon, 2005-03-14 at 03:55, Christopher Kings-Lynne wrote: +>> You will still need to use double quotes in 8.0.1... +>> +>> Chris +>> +>> Gourish Singbal wrote: +>> > Thanks a lot, +>> > +>> > we might be upgrading to 8.0.1 soon.. till than using double quotes +>> > should be fine. +>> > +>> > regards +>> > gourish +>> > +>> > On Mon, 14 Mar 2005 18:25:22 +1100, Russell Smith wrote: +>> > +>> >>On Mon, 14 Mar 2005 06:14 pm, Gourish Singbal wrote: +>> >> +>> >>>Guys, +>> >>> +>> >>>I am having a problem firing queries on one of the tables which is +>> >>>having "limit" as the column name. +>> >>> +>> >>>If a run an insert/select/update command on that table i get the below error. +>> >>> +>> >>>ERROR: syntax error at or near "limit" at character 71 +>> >> +>> >>select "limit" from limit_table WHERE "limit" < 50 LIMIT 2; +>> >> +>> >>You need to quote the field name, and make sure the case is correct. +>> >> +>> >>>Any Help would be realyl great to solve the problem. +>> >>> +>> >>>postgresql 7.4.5 and linux OS +>> >>> +>> >> +>> >>You should probably upgrade to 7.4.7 +>> >> +>> >>Regards +>> >> +>> >>Russell Smith. +>> >> +>> > +>> > +>> > +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 2: you can get off all lists at once with the unregister command +>> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> + + +-- +#======================================================================# +# 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-hackers-owner@postgresql.org Mon Mar 21 03:17:08 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 866F4563DF + for ; + Mon, 14 Mar 2005 19:11:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25652-08 + for ; + Mon, 14 Mar 2005 19:11:48 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E851564E9 + for ; + Mon, 14 Mar 2005 19:11:46 +0000 (GMT) +Received: (qmail 21097 invoked from network); 14 Mar 2005 20:11:46 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by mail.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 14 Mar 2005 20:11:46 +0100 +Message-ID: <4235E1EF.2000402@startnet.cz> +Date: Mon, 14 Mar 2005 20:11:43 +0100 +From: =?windows-1250?Q?Miroslav_=8Aulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-hackers@postgreSQL.org, pgsql-performance@postgreSQL.org +Subject: Re: Avoiding tuple construction/deconstruction during joining +References: <42345D24.8070104@startnet.cz> <14577.1110821062@sss.pgh.pa.us> +In-Reply-To: <14577.1110821062@sss.pgh.pa.us> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------030107090901050401050703" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/727 +X-Sequence-Number: 65529 + +This is a multi-part message in MIME format. +--------------030107090901050401050703 +Content-Type: text/plain; charset=windows-1250; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>>So I have some results. I have tested the query on both PostgreSQL 8.0.1 +>>and MySQL 4.1.8 with LIMIT set to 30 and OFFSET set to 6000. PostgreSQL +>>result is 11,667.916 ms, MySQL result is 448.4 ms. +>> +>> +> +>That's a fairly impressive discrepancy :-(, and even the slot_getattr() +>patch that Atsushi Ogawa provided isn't going to close the gap. +>(I got about a 4x speedup on Miroslav's example in my testing, which +>leaves us still maybe 6x slower than MySQL.) +> +> +As I wrote, the comparison is not "fair". Here are the conditions: + +"Both databases are running on the same machine (my laptop) and contain +the same data. However there are some differences in the data table +definitions: +1) in PostgreSQL I use 'varchar(1)' for a lot of fields and in MySQL I +use 'enum' +2) in PostgreSQL in some cases I use connection fields that are not of +the same type (smallint <-> integer (SERIAL)), in MySQL I use the same +types" + +For those not used to MySQL, enum is an integer "mapped" to a text +string (that's how I see it). That means that when you have field such +as enum('yes','no','DK'), in the table there are stored numbers 1, 2 and +3 which are mapped to the text values 'yes', 'no' and 'DK'. The +description is not accurate (I'm not MySQL programmer, I didn't check it +recently and I didn't inspect the code - I wouldn't understand it +either) but I think it's not that important. What is important is the +fact that MySQL has to work with some dozen fields that are numbers and +PostgreSQL has to work with the same fields as varchar(). Some of the +other fields are also varchars. This might (or might not) cause the +speed difference. However I think that if devs figure out how to speed +this up, other cases will benefit from the improvement too. + +As I understood from the contributions of other, the 2) shouldn't have a +great impact on the speed. + +>Looking at the post-patch profile for the test case, there is still +>quite a lot of cycles going into tuple assembly and disassembly: +> +>Each sample counts as 0.01 seconds. +> % cumulative self self total +> time seconds seconds calls ms/call ms/call name +> 24.47 4.49 4.49 _mcount +> 8.01 5.96 1.47 9143692 0.00 0.00 ExecEvalVar +> 6.92 7.23 1.27 6614373 0.00 0.00 slot_deformtuple +> 6.54 8.43 1.20 9143692 0.00 0.00 slot_getattr +> 6.21 9.57 1.14 103737 0.01 0.03 ExecTargetList +> 5.56 10.59 1.02 103775 0.01 0.01 DataFill +> 3.22 11.18 0.59 103775 0.01 0.01 ComputeDataSize +> 2.83 11.70 0.52 ExecEvalVar +> 2.72 12.20 0.50 9094122 0.00 0.00 memcpy +> 2.51 12.66 0.46 encore +> 2.40 13.10 0.44 427448 0.00 0.00 nocachegetattr +> 2.13 13.49 0.39 103775 0.00 0.02 heap_formtuple +> 2.07 13.87 0.38 noshlibs +> 1.20 14.09 0.22 225329 0.00 0.00 _doprnt +> 1.20 14.31 0.22 msquadloop +> 1.14 14.52 0.21 chunks +> 0.98 14.70 0.18 871885 0.00 0.00 AllocSetAlloc +> 0.98 14.88 0.18 $$dyncall +> 0.76 15.02 0.14 594242 0.00 0.00 FunctionCall3 +> 0.71 15.15 0.13 213312 0.00 0.00 comparetup_heap +> 0.65 15.27 0.12 6364 0.02 0.13 printtup +> 0.60 15.38 0.11 790702 0.00 0.00 pfree +> +>(_mcount is profiling overhead, ignore it.) It looks to me like just +>about everything in the top dozen functions is there as a result of the +>fact that join steps form new tuples that are the merge of their input +>tuples. Even our favorite villains, palloc and pfree, are down in the +>sub-percent range. +> +>I am guessing that the reason MySQL wins on this is that they avoid +>doing any data copying during a join step. I wonder whether we could +>accomplish the same by taking Ogawa's patch to the next level: allow +>a TupleTableSlot to contain either a "materialized" tuple as now, +>or a "virtual" tuple that is simply an array of Datums and null flags. +>(It's virtual in the sense that any pass-by-reference Datums would have +>to be pointing to data at the next level down.) This would essentially +>turn the formtuple and deformtuple operations into no-ops, and get rid +>of a lot of the associated overhead such as ComputeDataSize and +>DataFill. The only operations that would have to forcibly materialize +>a tuple would be ones that need to keep the tuple till after they fetch +>their next input tuple --- hashing and sorting are examples, but very +>many plan node types don't ever need to do that. +> +>I haven't worked out the details, but it seems likely that this could be +>a relatively nonintrusive patch. The main thing that would be an issue +>would be that direct reference to slot->val would become verboten (since +>you could no longer be sure there was a materialized tuple there). +>I think this would possibly affect some contrib stuff, which is a strong +>hint that it'd break some existing user-written code out there. +> +>Thoughts? +> +> +Mine thought is that I don't know what you are talking about :-) Now +seriously, I am far below this level of knowledge. But I can contribute +a test that (maybe) can help. I have rewritten the query so it JOINs the +varchar() fields (in fact all fields except the IDPK) at the last INNER +JOIN. Though there is one more JOIN, the query is more than 5 times +faster (1975.312 ms) :-) + +So my silly opinion is that if the planner could decide that there are +too much time expensive fields that are not needed during performing +JOINs and these could be JOINed at the last step, it would do it this +way :-) + +Below is the adjusted query and the EXPLAIN ANALYZE output. (Tom, you +can run it on the data I have sent you and it should run without changes.) + +SELECT AdDevicesSites.IDPK, AdDevicesSites2.AdDevicesSiteSizeIDFK, +AdDevicesSites2.AdDevicesSiteRegionIDFK, +AdDevicesSites2.AdDevicesSiteCountyIDFK, +AdDevicesSites2.AdDevicesSiteCityIDFK, +AdDevicesSites2.AdDevicesSiteDistrictIDFK, +AdDevicesSites2.AdDevicesSiteStreetIDFK, +AdDevicesSites2.AdDevicesSiteStreetDescriptionIDFK, +AdDevicesSites2.AdDevicesSitePositionIDFK, +AdDevicesSites2.AdDevicesSiteVisibilityIDFK, +AdDevicesSites2.AdDevicesSiteStatusTypeIDFK, +AdDevicesSites2.AdDevicesSitePartnerIdentificationOperatorIDFK, +AdDevicesSites2.AdDevicesSitePartnerElectricitySupplierIDFK, +AdDevicesSites2.AdDevicesSitePartnerMaintainerIDFK, +AdDevicesSites2.AdDevicesSitePartnerStickerIDFK, +AdDevicesSites2.CadastralUnitIDFK, AdDevicesSites2.MediaType, +AdDevicesSites2.Mark, AdDevicesSites2.Amount, AdDevicesSites2.Distance, +AdDevicesSites2.OwnLightening, AdDevicesSites2.LocationDownTown, +AdDevicesSites2.LocationSuburb, +AdDevicesSites2.LocationBusinessDistrict, +AdDevicesSites2.LocationResidentialDistrict, +AdDevicesSites2.LocationIndustrialDistrict, +AdDevicesSites2.LocationNoBuildings, AdDevicesSites2.ParkWayHighWay, +AdDevicesSites2.ParkWayFirstClassRoad, AdDevicesSites2.ParkWayOtherRoad, +AdDevicesSites2.ParkWayStreet, AdDevicesSites2.ParkWayAccess, +AdDevicesSites2.ParkWayExit, AdDevicesSites2.ParkWayParkingPlace, +AdDevicesSites2.ParkWayPassangersOnly, AdDevicesSites2.ParkWayCrossRoad, +AdDevicesSites2.PositionStandAlone, +AdDevicesSites2.NeighbourhoodPublicTransportation, +AdDevicesSites2.NeighbourhoodInterCityTransportation, +AdDevicesSites2.NeighbourhoodPostOffice, +AdDevicesSites2.NeighbourhoodNewsStand, +AdDevicesSites2.NeighbourhoodAmenities, +AdDevicesSites2.NeighbourhoodSportsSpot, +AdDevicesSites2.NeighbourhoodHealthServiceSpot, +AdDevicesSites2.NeighbourhoodShops, +AdDevicesSites2.NeighbourhoodShoppingCenter, +AdDevicesSites2.NeighbourhoodSuperMarket, +AdDevicesSites2.NeighbourhoodPetrolStation, +AdDevicesSites2.NeighbourhoodSchool, AdDevicesSites2.NeighbourhoodBank, +AdDevicesSites2.NeighbourhoodRestaurant, +AdDevicesSites2.NeighbourhoodHotel, +AdDevicesSites2.RestrictionCigarettes, +AdDevicesSites2.RestrictionPolitics, AdDevicesSites2.RestrictionSpirits, +AdDevicesSites2.RestrictionSex, AdDevicesSites2.RestrictionOther, +AdDevicesSites2.RestrictionNote, AdDevicesSites2.SpotMapFile, +AdDevicesSites2.SpotPhotoFile, AdDevicesSites2.SourcePhotoTimeStamp, +AdDevicesSites2.SourceMapTimeStamp, AdDevicesSites2.Price, +AdDevicesSites2.WebPrice, AdDevicesSites2.CadastralUnitCode, +AdDevicesSites2.BuildingNumber, AdDevicesSites2.ParcelNumber, +AdDevicesSites2.GPSLatitude, AdDevicesSites2.GPSLongitude, +AdDevicesSites2.GPSHeight, AdDevicesSites2.MechanicalOpticalCoordinates, +AdDevicesSites2.Deleted, AdDevicesSites2.Protected, +AdDevicesSites2.DateCreated, AdDevicesSites2.DateLastModified, +AdDevicesSites2.DateDeleted, AdDevicesSites2.CreatedByUserIDFK, +AdDevicesSites2.LastModifiedByUserIDFK, +AdDevicesSites2.DeletedByUserIDFK, +AdDevicesSites2.PhotoLastModificationDate, +AdDevicesSites2.MapLastModificationDate, +AdDevicesSites2.DateLastImported, AdDevicesSiteRegions.Name AS +AdDevicesSiteRegionName, AdDevicesSiteCounties.Name AS +AdDevicesSiteCountyName, AdDevicesSiteCities.Name AS +AdDevicesSiteCityName, AdDevicesSiteStreets.Name AS +AdDevicesSiteStreetName, AdDevicesSiteDistricts.Name AS +AdDevicesSiteDistrictName, AdDevicesSiteStreetDescriptions.Name_cs AS +AdDevicesSiteStreetDescriptionName_cs, +AdDevicesSiteStreetDescriptions.Name_en AS +AdDevicesSiteStreetDescriptionName_en, AdDevicesSiteSizes.Name AS +AdDevicesSiteSizeName, SUBSTRING(AdDevicesSiteVisibilities.Name_cs, 3) +AS AdDevicesSiteVisibilityName_cs, +SUBSTRING(AdDevicesSiteVisibilities.Name_en, 3) AS +AdDevicesSiteVisibilityName_en, AdDevicesSitePositions.Name_cs AS +AdDevicesSitePositionName_cs, AdDevicesSitePositions.Name_en AS +AdDevicesSitePositionName_en, AdDevicesSiteStatusTypes.Name_cs AS +AdDevicesSiteStatusTypeName_cs, AdDevicesSiteStatusTypes.Name_en AS +AdDevicesSiteStatusTypeName_en, PartnerIdentificationsOperator.Name AS +PartnerIdentificationOperatorName, PartnersElectricitySupplier.Name AS +PartnerElectricitySupplierName, PartnersMaintainer.Name AS +PartnerMaintainerName, PartnersSticker.Name AS PartnerStickerName, +CadastralUnits.Code AS CadastralUnitCodeNative, CadastralUnits.Name AS +CadastralUnitName +FROM AdDevicesSites +LEFT JOIN AdDevicesSiteRegions ON AdDevicesSites.AdDevicesSiteRegionIDFK += AdDevicesSiteRegions.IDPK +LEFT JOIN AdDevicesSiteCounties ON +AdDevicesSites.AdDevicesSiteCountyIDFK = AdDevicesSiteCounties.IDPK +LEFT JOIN AdDevicesSiteCities ON AdDevicesSites.AdDevicesSiteCityIDFK = +AdDevicesSiteCities.IDPK +LEFT JOIN AdDevicesSiteStreets ON AdDevicesSites.AdDevicesSiteStreetIDFK += AdDevicesSiteStreets.IDPK +LEFT JOIN AdDevicesSiteStreetDescriptions ON +AdDevicesSites.AdDevicesSiteStreetDescriptionIDFK = +AdDevicesSiteStreetDescriptions.IDPK +LEFT JOIN AdDevicesSiteDistricts ON +AdDevicesSites.AdDevicesSiteDistrictIDFK = AdDevicesSiteDistricts.IDPK +LEFT JOIN AdDevicesSiteSizes ON AdDevicesSites.AdDevicesSiteSizeIDFK = +AdDevicesSiteSizes.IDPK +LEFT JOIN AdDevicesSiteVisibilities ON +AdDevicesSites.AdDevicesSiteVisibilityIDFK = AdDevicesSiteVisibilities.IDPK +LEFT JOIN AdDevicesSitePositions ON +AdDevicesSites.AdDevicesSitePositionIDFK = AdDevicesSitePositions.IDPK +LEFT JOIN AdDevicesSiteStatusTypes ON +AdDevicesSites.AdDevicesSiteStatusTypeIDFK = AdDevicesSiteStatusTypes.IDPK +LEFT JOIN PartnerIdentifications AS PartnerIdentificationsOperator ON +AdDevicesSites.AdDevicesSitePartnerIdentificationOperatorIDFK = +PartnerIdentificationsOperator.IDPK +LEFT JOIN Partners AS PartnersElectricitySupplier ON +AdDevicesSites.AdDevicesSitePartnerElectricitySupplierIDFK = +PartnersElectricitySupplier.IDPK +LEFT JOIN Partners AS PartnersMaintainer ON +AdDevicesSites.AdDevicesSitePartnerMaintainerIDFK = PartnersMaintainer.IDPK +LEFT JOIN Partners AS PartnersSticker ON +AdDevicesSites.AdDevicesSitePartnerStickerIDFK = PartnersSticker.IDPK +LEFT JOIN CadastralUnits ON AdDevicesSites.CadastralUnitIDFK = +CadastralUnits.IDPK +INNER JOIN AdDevicesSites AS AdDevicesSites2 ON AdDevicesSites.IDPK = +AdDevicesSites2.IDPK + +QUERY PLAN + +Hash Join (cost=193867.68..235417.92 rows=142556 width=815) (actual time=1577.080..2200.677 rows=6364 loops=1) + + Hash Cond: ("outer".idpk = "inner".idpk) + + -> Seq Scan on addevicessites addevicessites2 (cost=0.00..13118.56 rows=142556 width=473) (actual time=40.650..49.195 rows=6364 loops=1) + + -> Hash (cost=186898.29..186898.29 rows=142556 width=350) (actual time=1534.080..1534.080 rows=0 loops=1) + + -> Merge Right Join (cost=184758.38..186898.29 rows=142556 width=350) (actual time=1187.653..1244.955 rows=6364 loops=1) + + Merge Cond: ("outer".idpk = "inner".cadastralunitidfk) + + -> Index Scan using cadastralunits_pkey on cadastralunits (cost=0.00..314.49 rows=13027 width=31) (actual time=0.034..0.128 rows=63 loops=1) + + -> Sort (cost=184758.38..185114.77 rows=142556 width=325) (actual time=1187.582..1190.111 rows=6364 loops=1) + + Sort Key: addevicessites.cadastralunitidfk + + -> Hash Left Join (cost=93887.04..143074.76 rows=142556 width=325) (actual time=502.584..1129.145 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitepartnerstickeridfk = "inner".idpk) + + -> Hash Left Join (cost=93884.28..140933.65 rows=142556 width=307) (actual time=502.388..1075.572 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitepartnermaintaineridfk = "inner".idpk) + + -> Hash Left Join (cost=93881.51..138792.55 rows=142556 width=289) (actual time=502.208..1023.802 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitepartnerelectricitysupplieridfk = "inner".idpk) + + -> Hash Left Join (cost=93878.75..136651.45 rows=142556 width=271) (actual time=502.041..969.959 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitepartneridentificationoperatoridfk = "inner".idpk) + + -> Nested Loop Left Join (cost=93875.99..134510.35 rows=142556 width=253) (actual time=501.849..915.256 rows=6364 loops=1) + + Join Filter: ("outer".addevicessitestatustypeidfk = "inner".idpk) + + -> Nested Loop Left Join (cost=93874.93..118471.74 rows=142556 width=228) (actual time=501.826..818.436 rows=6364 loops=1) + + Join Filter: ("outer".addevicessitepositionidfk = "inner".idpk) + + -> Nested Loop Left Join (cost=93873.90..108848.18 rows=142556 width=207) (actual time=501.802..737.137 rows=6364 loops=1) + + Join Filter: ("outer".addevicessitevisibilityidfk = "inner".idpk) + + -> Merge Right Join (cost=93872.86..96017.09 rows=142556 width=177) (actual time=501.741..554.834 rows=6364 loops=1) + + Merge Cond: ("outer".idpk = "inner".addevicessitesizeidfk) + + -> Index Scan using addevicessitesizes_pkey on addevicessitesizes (cost=0.00..5.62 rows=110 width=14) (actual time=0.009..0.264 rows=110 loops=1) + + -> Sort (cost=93872.86..94229.25 rows=142556 width=169) (actual time=501.697..504.267 rows=6364 loops=1) + + Sort Key: addevicessites.addevicessitesizeidfk + + -> Hash Left Join (cost=57752.91..65764.23 rows=142556 width=169) (actual time=234.321..466.130 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitedistrictidfk = "inner".idpk) + + -> Hash Left Join (cost=57743.17..63616.15 rows=142556 width=164) (actual time=233.456..421.267 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitestreetdescriptionidfk = "inner".idpk) + + -> Hash Left Join (cost=57634.86..62707.43 rows=142556 width=137) (actual time=223.396..362.945 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitestreetidfk = "inner".idpk) + + -> Hash Left Join (cost=57566.95..61844.20 rows=142556 width=119) (actual time=217.101..312.605 rows=6364 loops=1) + + Hash Cond: ("outer".addevicessitecityidfk = "inner".idpk) + + -> Merge Right Join (cost=57561.85..59700.76 rows=142556 width=110) (actual time=216.635..266.672 rows=6364 loops=1) + + Merge Cond: ("outer".idpk = "inner".addevicessitecountyidfk) + + -> Sort (cost=6.19..6.48 rows=117 width=17) (actual time=0.350..0.389 rows=116 loops=1) + + Sort Key: addevicessitecounties.idpk + + -> Seq Scan on addevicessitecounties (cost=0.00..2.17 rows=117 width=17) (actual time=0.008..0.146 rows=117 loops=1) + + -> Sort (cost=57555.66..57912.05 rows=142556 width=99) (actual time=216.250..218.611 rows=6364 loops=1) + + Sort Key: addevicessites.addevicessitecountyidfk + + -> Merge Right Join (cost=33573.63..35712.03 rows=142556 width=99) (actual time=173.646..199.036 rows=6364 loops=1) + + Merge Cond: ("outer".idpk = "inner".addevicessiteregionidfk) + + -> Sort (cost=1.44..1.48 rows=15 width=23) (actual time=0.055..0.059 rows=13 loops=1) + + Sort Key: addevicessiteregions.idpk + + -> Seq Scan on addevicessiteregions (cost=0.00..1.15 rows=15 width=23) (actual time=0.016..0.032 rows=15 loops=1) + + -> Sort (cost=33572.19..33928.58 rows=142556 width=82) (actual time=173.559..176.398 rows=6364 loops=1) + + Sort Key: addevicessites.addevicessiteregionidfk + + -> Seq Scan on addevicessites (cost=0.00..13118.56 rows=142556 width=82) (actual time=62.345..164.783 rows=6364 loops=1) + + -> Hash (cost=4.48..4.48 rows=248 width=17) (actual time=0.283..0.283 rows=0 loops=1) + + -> Seq Scan on addevicessitecities (cost=0.00..4.48 rows=248 width=17) (actual time=0.011..0.162 rows=138 loops=1) + + -> Hash (cost=60.53..60.53 rows=2953 width=34) (actual time=6.229..6.229 rows=0 loops=1) + + -> Seq Scan on addevicessitestreets (cost=0.00..60.53 rows=2953 width=34) (actual time=0.010..3.816 rows=2984 loops=1) + + -> Hash (cost=96.85..96.85 rows=4585 width=43) (actual time=10.017..10.017 rows=0 loops=1) + + -> Seq Scan on addevicessitestreetdescriptions (cost=0.00..96.85 rows=4585 width=43) (actual time=0.008..6.371 rows=4585 loops=1) + + -> Hash (cost=8.59..8.59 rows=459 width=21) (actual time=0.815..0.815 rows=0 loops=1) + + -> Seq Scan on addevicessitedistricts (cost=0.00..8.59 rows=459 width=21) (actual time=0.007..0.541 rows=382 loops=1) + + -> Materialize (cost=1.04..1.08 rows=4 width=36) (actual time=0.000..0.002 rows=4 loops=6364) + + -> Seq Scan on addevicessitevisibilities (cost=0.00..1.04 rows=4 width=36) (actual time=0.026..0.035 rows=4 loops=1) + + -> Materialize (cost=1.03..1.06 rows=3 width=27) (actual time=0.000..0.001 rows=3 loops=6364) + + -> Seq Scan on addevicessitepositions (cost=0.00..1.03 rows=3 width=27) (actual time=0.007..0.010 rows=3 loops=1) + + -> Materialize (cost=1.05..1.10 rows=5 width=31) (actual time=0.000..0.002 rows=5 loops=6364) + + -> Seq Scan on addevicessitestatustypes (cost=0.00..1.05 rows=5 width=31) (actual time=0.006..0.016 rows=5 loops=1) + + -> Hash (cost=2.61..2.61 rows=61 width=34) (actual time=0.144..0.144 rows=0 loops=1) + + -> Seq Scan on partneridentifications partneridentificationsoperator (cost=0.00..2.61 rows=61 width=34) (actual time=0.007..0.103 rows=61 loops=1) + + -> Hash (cost=2.61..2.61 rows=61 width=34) (actual time=0.122..0.122 rows=0 loops=1) + + -> Seq Scan on partners partnerselectricitysupplier (cost=0.00..2.61 rows=61 width=34) (actual time=0.004..0.072 rows=61 loops=1) + + -> Hash (cost=2.61..2.61 rows=61 width=34) (actual time=0.136..0.136 rows=0 loops=1) + + -> Seq Scan on partners partnersmaintainer (cost=0.00..2.61 rows=61 width=34) (actual time=0.005..0.086 rows=61 loops=1) + + -> Hash (cost=2.61..2.61 rows=61 width=34) (actual time=0.143..0.143 rows=0 loops=1) + + -> Seq Scan on partners partnerssticker (cost=0.00..2.61 rows=61 width=34) (actual time=0.009..0.098 rows=61 loops=1) + +Total runtime: 2210.937 ms + + +> regards, tom lane +> +> +Miroslav + +--------------030107090901050401050703 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------030107090901050401050703-- + +From pgsql-hackers-owner@postgresql.org Mon Mar 14 19:22:48 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E295F5636D; + Mon, 14 Mar 2005 19:22:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31014-02; Mon, 14 Mar 2005 19:22:39 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 10A9E567FF; + Mon, 14 Mar 2005 19:22:35 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2EJMZEP029031; + Mon, 14 Mar 2005 14:22:35 -0500 (EST) +To: =?windows-1250?Q?Miroslav_=8Aulc?= +Cc: pgsql-hackers@postgreSQL.org, pgsql-performance@postgreSQL.org +Subject: Re: Avoiding tuple construction/deconstruction during joining +In-reply-to: <4235E1EF.2000402@startnet.cz> +References: <42345D24.8070104@startnet.cz> <14577.1110821062@sss.pgh.pa.us> + <4235E1EF.2000402@startnet.cz> +Comments: In-reply-to =?windows-1250?Q?Miroslav_=8Aulc?= + + message dated "Mon, 14 Mar 2005 20:11:43 +0100" +Date: Mon, 14 Mar 2005 14:22:35 -0500 +Message-ID: <29030.1110828155@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/457 +X-Sequence-Number: 65259 + +=?windows-1250?Q?Miroslav_=8Aulc?= writes: +> seriously, I am far below this level of knowledge. But I can contribute +> a test that (maybe) can help. I have rewritten the query so it JOINs the +> varchar() fields (in fact all fields except the IDPK) at the last INNER +> JOIN. Though there is one more JOIN, the query is more than 5 times +> faster (1975.312 ms) :-) + +That confirms my thought that passing the data up through multiple +levels of join is what's killing us. I'll work on a solution. This +will of course be even less back-patchable to 8.0.* than Ogawa's work, +but hopefully it will fix the issue for 8.1. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 14 19:28:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D296555056 + for ; + Mon, 14 Mar 2005 19:28:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31624-09 + for ; + Mon, 14 Mar 2005 19:28:07 +0000 (GMT) +Received: from mail.valleypres.org (mail.valleypres.org [63.196.151.90]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F38356813 + for ; + Mon, 14 Mar 2005 19:28:04 +0000 (GMT) +Received: from valleypres.org (mail.valleypres.org [172.16.12.253]) + by mail.valleypres.org (Postfix) with ESMTP id 0C30493663; + Mon, 14 Mar 2005 11:28:04 -0800 (PST) +Received: from [172.16.14.58] (helo=clamav.valleypres.org) + by valleypres.org with esmtp (Exim 3.13 #3) + id 1DAvES-0004w9-00; Mon, 14 Mar 2005 11:28:04 -0800 +Received: from AT10111 (unknown [172.16.30.202]) + by clamav.valleypres.org (Postfix) with SMTP id A74D217C407; + Mon, 14 Mar 2005 11:27:58 -0800 (PST) +Reply-To: +From: "Bryan Encina" +To: +Cc: "'Jan Wieck'" +Subject: Re: column name is "LIMIT" +Date: Mon, 14 Mar 2005 11:26:44 -0800 +Message-ID: <01a201c528cb$c23f7d20$ca1e10ac@AT10111> +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 CWS, Build 9.0.2416 (9.0.2911.0) +In-Reply-To: <4235DE36.2070608@Yahoo.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 +Importance: Normal +X-VPH-MailScanner-Information: Please contact the ISP for more information +X-VPH-MailScanner: Found to be clean +X-MailScanner-From: bryan.encina@valleypres.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.12 tagged_above=0 required=5 tests=AWL +X-Spam-Level: * +X-Archive-Number: 200503/277 +X-Sequence-Number: 10982 + +> Note also that the Slony-I replication system has problems +> with column +> names identical to reserved words. This is rooted in the fact +> that the +> quote_ident() function doesn't quote reserved words ... as it IMHO is +> supposed to do. +> +> +> Jan +> + +Does this apply to table names as well or just columns? + +Bryan + +From pgsql-performance-owner@postgresql.org Mon Mar 14 19:30:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B4D452AA2 + for ; + Mon, 14 Mar 2005 19:30:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33181-03 + for ; + Mon, 14 Mar 2005 19:30:49 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 09BA452A5B + for ; + Mon, 14 Mar 2005 19:30:48 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2EJUdvQ029102; + Mon, 14 Mar 2005 14:30:39 -0500 (EST) +To: Jan Wieck +Cc: Robert Treat , + Christopher Kings-Lynne , + Gourish Singbal , + Russell Smith , pgsql-performance@postgresql.org +Subject: Re: column name is "LIMIT" +In-reply-to: <4235DE36.2070608@Yahoo.com> +References: <674d1f8a0503132314754df153@mail.gmail.com> + <200503141825.22827.mr-russ@pws.com.au> + <674d1f8a05031400482c413087@mail.gmail.com> + <42355185.3070803@familyhealth.com.au> + <1110824915.4281.123.camel@camel> <4235DE36.2070608@Yahoo.com> +Comments: In-reply-to Jan Wieck + message dated "Mon, 14 Mar 2005 13:55:50 -0500" +Date: Mon, 14 Mar 2005 14:30:39 -0500 +Message-ID: <29101.1110828639@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/278 +X-Sequence-Number: 10983 + +Jan Wieck writes: +> quote_ident() function doesn't quote reserved words ... as it IMHO is +> supposed to do. + +You're right, it probably should. The equivalent code in pg_dump knows +about this, but quote_ident() doesn't. + +One thing that's been on my mind with respect to all this is that it +would be nice not to quote "non-reserved" keywords. Most of the weird +non-SQL-spec keywords that we have are non-reserved, and we could more +easily keep them out of people's faces if we didn't quote them in dumps. +Of course such a policy would raise the ante for any change that makes +an existing keyword reserved when it wasn't before, but that's already +a dangerous kind of change. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Mon Mar 21 03:14:39 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 95E955680C + for ; + Mon, 14 Mar 2005 19:31:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34213-03 + for ; + Mon, 14 Mar 2005 19:31:52 +0000 (GMT) +Received: from sranda.klamovka.kosire.czf (unknown [82.113.63.66]) + by svr1.postgresql.org (Postfix) with ESMTP id EFF3256807 + for ; + Mon, 14 Mar 2005 19:31:50 +0000 (GMT) +Received: (qmail 15126 invoked from network); 14 Mar 2005 20:31:51 +0100 +Received: from fordfrog.klamovka.kosire.czf (HELO ?192.168.11.101?) + (10.15.70.18) + by mail.klamovka.kosire.czf with AES256-SHA encrypted SMTP; + 14 Mar 2005 20:31:51 +0100 +Message-ID: <4235E6A7.6010703@startnet.cz> +Date: Mon, 14 Mar 2005 20:31:51 +0100 +From: =?windows-1250?Q?Miroslav_=8Aulc?= +Organization: StartNet s.r.o. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-hackers@postgreSQL.org, pgsql-performance@postgreSQL.org +Subject: Re: Avoiding tuple construction/deconstruction during joining +References: <42345D24.8070104@startnet.cz> <14577.1110821062@sss.pgh.pa.us> + <4235E1EF.2000402@startnet.cz> <29030.1110828155@sss.pgh.pa.us> +In-Reply-To: <29030.1110828155@sss.pgh.pa.us> +X-Enigmail-Version: 0.89.5.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/mixed; boundary="------------010303050800020409010001" +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/725 +X-Sequence-Number: 65527 + +This is a multi-part message in MIME format. +--------------010303050800020409010001 +Content-Type: text/plain; charset=windows-1250; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>=?windows-1250?Q?Miroslav_=8Aulc?= writes: +> +> +>>seriously, I am far below this level of knowledge. But I can contribute +>>a test that (maybe) can help. I have rewritten the query so it JOINs the +>>varchar() fields (in fact all fields except the IDPK) at the last INNER +>>JOIN. Though there is one more JOIN, the query is more than 5 times +>>faster (1975.312 ms) :-) +>> +>> +> +>That confirms my thought that passing the data up through multiple +>levels of join is what's killing us. I'll work on a solution. This +>will of course be even less back-patchable to 8.0.* than Ogawa's work, +>but hopefully it will fix the issue for 8.1. +> +> regards, tom lane +> +> +Tom, thank you and the others for help. I'm glad that my problem can +help PostgreSQL improve and that there are people like you that +understand each little bit of the software :-) + +Miroslav + +--------------010303050800020409010001 +Content-Type: text/x-vcard; charset=utf-8; + name="miroslav.sulc.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="miroslav.sulc.vcf" + +begin:vcard +fn;quoted-printable:Miroslav =C5=A0ulc +n;quoted-printable:=C5=A0ulc;Miroslav +org:StartNet s.r.o. +adr;quoted-printable;quoted-printable:;;Vrchlick=C3=A9ho 161/5;Praha 5;;150 00;=C4=8Cesk=C3=A1 republika +email;internet:miroslav.sulc@startnet.cz +title:CEO +tel;work:+420 257 225 602 +tel;cell:+420 603 711 413 +x-mozilla-html:TRUE +url:http://www.startnet.cz +version:2.1 +end:vcard + + +--------------010303050800020409010001-- + +From pgsql-performance-owner@postgresql.org Mon Mar 14 19:53:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3406C5650E + for ; + Mon, 14 Mar 2005 19:53:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40301-02 + for ; + Mon, 14 Mar 2005 19:53:44 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.199]) + by svr1.postgresql.org (Postfix) with ESMTP id 85A48564E9 + for ; + Mon, 14 Mar 2005 19:53:41 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 70so1820263wra + for ; + Mon, 14 Mar 2005 11:53:42 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=K/Zl+CKf+2pKuSOxnvrOMyLFlBKQdnTTjZdHIvuvPg39c5y35VwpGHwqJg8z5bcNio/ecGHodlhCYMdPG8xRnC3LkS3SJi0nRLQKKWzDO2WBnkNS33pHiy7/ioN/rYkQcGTr9CpciFz58bJXp6uNMfuHxrG8feI/G/T+GSItzrA= +Received: by 10.54.40.2 with SMTP id n2mr4906543wrn; + Mon, 14 Mar 2005 11:53:42 -0800 (PST) +Received: by 10.54.18.53 with HTTP; Mon, 14 Mar 2005 11:53:42 -0800 (PST) +Message-ID: <33c6269f050314115339b6861d@mail.gmail.com> +Date: Mon, 14 Mar 2005 14:53:42 -0500 +From: Alex Turner +Reply-To: Alex Turner +To: Greg Stark +Subject: Re: Postgres on RAID5 +Cc: Arshavir Grigorian , linux-raid@vger.kernel.org, + pgsql-performance@postgresql.org +In-Reply-To: <87hdje7sjm.fsf@stark.xeocode.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <4231F5F2.6000509@m-cam.com> <87hdje7sjm.fsf@stark.xeocode.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.226 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/280 +X-Sequence-Number: 10985 + +a 14 drive stripe will max out the PCI bus long before anything else, +the only reason for a stripe this size is to get a total accessible +size up. A 6 drive RAID 10 on a good controller can get up to +400Mb/sec which is pushing the limit of the PCI bus (taken from +offical 3ware 9500S 8MI benchmarks). 140 drives is not going to beat +6 drives because you've run out of bandwidth on the PCI bus. + +The debait on RAID 5 rages onward. The benchmarks I've seen suggest +that RAID 5 is consistantly slower than RAID 10 with the same number +of drivers, but others suggest that RAID 5 can be much faster that +RAID 10 (see arstechnica.com) (Theoretical performance of RAID 5 is +inline with a RAID 0 stripe of N-1 drives, RAID 10 has only N/2 drives +in a stripe, perfomance should be nearly double - in theory of +course). + +35 Trans/sec is pretty slow, particularly if they are only one row at +a time. I typicaly get 200-400/sec on our DB server on a bad day. Up +to 1100 on a fresh database. + +I suggested running a bonnie benchmark, or some other IO perftest to +determine if it's the array itself performing badly, or if there is +something wrong with postgresql. + +If the array isn't kicking out at least 50MB/sec read/write +performance, something is wrong. + +Until you've isolated the problem to either postgres or the array, +everything else is simply speculation. + +In a perfect world, you would have two 6 drive RAID 10s. on two PCI +busses, with system tables on a third parition, and archive logging on +a fourth. Unsurprisingly this looks alot like the Oracle recommended +minimum config. + +Also a note for interest is that this is _software_ raid... + +Alex Turner +netEconomist + +On 13 Mar 2005 23:36:13 -0500, Greg Stark wrote: +> +> Arshavir Grigorian writes: +> +> > Hi, +> > +> > I have a RAID5 array (mdadm) with 14 disks + 1 spare. This partition has an +> > Ext3 filesystem which is used by Postgres. +> +> People are going to suggest moving to RAID1+0. I'm unconvinced that RAID5 +> across 14 drivers shouldn't be able to keep up with RAID1 across 7 drives +> though. It would be interesting to see empirical data. +> +> One thing that does scare me is the Postgres transaction log and the ext3 +> journal both sharing these disks with the data. Ideally both of these things +> should get (mirrored) disks of their own separate from the data files. +> +> But 2-3s pauses seem disturbing. I wonder whether ext3 is issuing a cache +> flush on every fsync to get the journal pushed out. This is a new linux +> feature that's necessary with ide but shouldn't be necessary with scsi. +> +> It would be interesting to know whether postgres performs differently with +> fsync=off. This would even be a reasonable mode to run under for initial +> database loads. It shouldn't make much of a difference with hardware like this +> though. And you should be aware that running under this mode in production +> would put your data at risk. +> +> -- +> greg +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: the planner will ignore your desire to choose an index scan if your +> joining column's datatypes do not match +> + +From pgsql-performance-owner@postgresql.org Mon Mar 14 20:17:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 02AE556537 + for ; + Mon, 14 Mar 2005 20:17:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46995-02 + for ; + Mon, 14 Mar 2005 20:17:27 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id D15995652E + for ; + Mon, 14 Mar 2005 20:17:23 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DAw00-0007hh-00; Mon, 14 Mar 2005 15:17:12 -0500 +To: Alex Turner +Cc: Greg Stark , Arshavir Grigorian , + linux-raid@vger.kernel.org, pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +References: <4231F5F2.6000509@m-cam.com> <87hdje7sjm.fsf@stark.xeocode.com> + <33c6269f050314115339b6861d@mail.gmail.com> +In-Reply-To: <33c6269f050314115339b6861d@mail.gmail.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 14 Mar 2005 15:17:11 -0500 +Message-ID: <87zmx6rni0.fsf@stark.xeocode.com> +Lines: 17 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.021 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/281 +X-Sequence-Number: 10986 + + +Alex Turner writes: + +> a 14 drive stripe will max out the PCI bus long before anything else, + +Hopefully anyone with a 14 drive stripe is using some combination of 64 bit +PCI-X cards running at 66Mhz... + +> the only reason for a stripe this size is to get a total accessible +> size up. + +Well, many drives also cuts average latency. So even if you have no need for +more bandwidth you still benefit from a lower average response time by adding +more drives. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Mar 14 21:11:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 89E8153DF0 + for ; + Mon, 14 Mar 2005 21:11:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62496-09 + for ; + Mon, 14 Mar 2005 21:11:40 +0000 (GMT) +Received: from amanda.contactbda.com (ipn36372-e65122.cidr.lightship.net + [216.204.66.226]) + by svr1.postgresql.org (Postfix) with ESMTP id D8D2F567E7 + for ; + Mon, 14 Mar 2005 21:11:38 +0000 (GMT) +Received: from amanda.contactbda.com (amanda.contactbda.com [192.168.1.2]) + by amanda.contactbda.com (8.12.11/8.12.11/Debian-3) with ESMTP id + j2EKZfF4024964; Mon, 14 Mar 2005 15:35:51 -0500 +From: "Jim Buttafuoco" +To: Greg Stark , Alex Turner +Cc: Arshavir Grigorian , linux-raid@vger.kernel.org, + pgsql-performance@postgresql.org +Reply-To: jim@contactbda.com +Subject: Re: Postgres on RAID5 +Date: Mon, 14 Mar 2005 15:35:41 -0500 +Message-Id: <20050314202823.M3327@contactbda.com> +In-Reply-To: <87zmx6rni0.fsf@stark.xeocode.com> +References: <4231F5F2.6000509@m-cam.com> <87hdje7sjm.fsf@stark.xeocode.com> + <33c6269f050314115339b6861d@mail.gmail.com> + <87zmx6rni0.fsf@stark.xeocode.com> +X-Mailer: Open WebMail 2.41 20040926 +X-OriginatingIP: 192.168.1.1 (jim) +MIME-Version: 1.0 +Content-Type: text/plain; + charset=iso-8859-1 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.052 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/284 +X-Sequence-Number: 10989 + +All, + +I have a 13 disk (250G each) software raid 5 set using 1 16 port adaptec SATA controller. +I am very happy with the performance. The reason I went with the 13 disk raid 5 set was for the space NOT performance. + I have a single postgresql database that is over 2 TB with about 500 GB free on the disk. This raid set performs +about the same as my ICP SCSI raid controller (also with raid 5). + +That said, now that postgresql 8 has tablespaces, I would NOT create 1 single raid 5 set, but 3 smaller sets. I also DO +NOT have my wal and log's on this raid set, but on a smaller 2 disk mirror. + +Jim + +---------- Original Message ----------- +From: Greg Stark +To: Alex Turner +Cc: Greg Stark , Arshavir Grigorian , linux-raid@vger.kernel.org, +pgsql-performance@postgresql.org +Sent: 14 Mar 2005 15:17:11 -0500 +Subject: Re: [PERFORM] Postgres on RAID5 + +> Alex Turner writes: +> +> > a 14 drive stripe will max out the PCI bus long before anything else, +> +> Hopefully anyone with a 14 drive stripe is using some combination of 64 bit +> PCI-X cards running at 66Mhz... +> +> > the only reason for a stripe this size is to get a total accessible +> > size up. +> +> Well, many drives also cuts average latency. So even if you have no need for +> more bandwidth you still benefit from a lower average response time by adding +> more drives. +> +> -- +> greg +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: the planner will ignore your desire to choose an index scan if your +> joining column's datatypes do not match +------- End of Original Message ------- + + +From pgsql-performance-owner@postgresql.org Mon Mar 14 20:54:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 757D756819 + for ; + Mon, 14 Mar 2005 20:54:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59966-03 + for ; + Mon, 14 Mar 2005 20:54:43 +0000 (GMT) +Received: from mail2.m-cam.com (unknown [63.124.102.77]) + by svr1.postgresql.org (Postfix) with ESMTP id EEEF756816 + for ; + Mon, 14 Mar 2005 20:54:42 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail2.m-cam.com (Postfix) with ESMTP + id 378663E8F8; Mon, 14 Mar 2005 15:59:47 -0500 (EST) +Received: from mail2.m-cam.com ([127.0.0.1]) + by localhost (mail2.m-cam.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 13506-10; Mon, 14 Mar 2005 15:59:39 -0500 (EST) +Received: from [192.168.1.21] (unknown [192.168.1.21]) + by mail2.m-cam.com (Postfix) with ESMTP + id 47B343E8F2; Mon, 14 Mar 2005 15:59:39 -0500 (EST) +Message-ID: <4235FA0A.40600@m-cam.com> +Date: Mon, 14 Mar 2005 15:54:34 -0500 +From: Arshavir Grigorian +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alex Turner +Cc: pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +References: <423209E1.6090200@m-cam.com> + <33c6269f05031119506fee5c31@mail.gmail.com> +In-Reply-To: <33c6269f05031119506fee5c31@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at m-cam.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/282 +X-Sequence-Number: 10987 + +Alex Turner wrote: +> I would recommend running a bonnie++ benchmark on your array to see if +> it's the array/controller/raid being crap, or wether it's postgres. I +> have had some very surprising results from arrays that theoretically +> should be fast, but turned out to be very slow. +> +> I would also seriously have to recommend against a 14 drive RAID 5! +> This is statisticaly as likely to fail as a 7 drive RAID 0 (not +> counting the spare, but rebuiling a spare is very hard on existing +> drives). + +Thanks for the reply. + +Here are the results of the bonnie test on my array: + +./bonnie -s 10000 -d . > oo 2>&1 +File './Bonnie.23736', size: 10485760000 +Writing with putc()...done +Rewriting...done +Writing intelligently...done +Reading with getc()...done +Reading intelligently...done +Seeker 1...Seeker 2...Seeker 3...start 'em...done...done...done... + -------Sequential Output-------- ---Sequential Input-- --Random-- + -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks--- + MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU /sec %CPU + 10000 4762 96.0 46140 78.8 31180 61.0 3810 99.9 71586 67.7 411.8 13.1 + +On a different note, I am not sure how the probability of RAID5 over 15 +disks failing is the same as that of a RAID0 array over 7 disks. RAID5 +can operate in a degraded mode (14 disks - 1 bad), RAID0 on the other +hand cannot operate on 6 disks (6 disks - 1 bad). Am I missing something? + +Are you saying running RAID0 on a set of 2 RAID1 arrays of 7 each? That +would work fine, except I cannot afford to "loose" that much space. + +Care to comment on these numbers? Thanks. + + + +Arshavir + +From pgsql-performance-owner@postgresql.org Mon Mar 14 21:04:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E994E563B4 + for ; + Mon, 14 Mar 2005 21:04:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62112-03 + for ; + Mon, 14 Mar 2005 21:03:54 +0000 (GMT) +Received: from mail2.m-cam.com (unknown [63.124.102.77]) + by svr1.postgresql.org (Postfix) with ESMTP id 557AA55EE3 + for ; + Mon, 14 Mar 2005 21:03:53 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail2.m-cam.com (Postfix) with ESMTP + id 32AB03E8F8; Mon, 14 Mar 2005 16:08:59 -0500 (EST) +Received: from mail2.m-cam.com ([127.0.0.1]) + by localhost (mail2.m-cam.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 13617-01; Mon, 14 Mar 2005 16:08:51 -0500 (EST) +Received: from [192.168.1.21] (unknown [192.168.1.21]) + by mail2.m-cam.com (Postfix) with ESMTP + id C32C43E8F2; Mon, 14 Mar 2005 16:08:48 -0500 (EST) +Message-ID: <4235FC2F.9060000@m-cam.com> +Date: Mon, 14 Mar 2005 16:03:43 -0500 +From: Arshavir Grigorian +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alex Turner +Cc: Greg Stark , linux-raid@vger.kernel.org, + pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +References: <4231F5F2.6000509@m-cam.com> <87hdje7sjm.fsf@stark.xeocode.com> + <33c6269f050314115339b6861d@mail.gmail.com> +In-Reply-To: <33c6269f050314115339b6861d@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at m-cam.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/283 +X-Sequence-Number: 10988 + +Alex Turner wrote: +> a 14 drive stripe will max out the PCI bus long before anything else, +> the only reason for a stripe this size is to get a total accessible +> size up. A 6 drive RAID 10 on a good controller can get up to +> 400Mb/sec which is pushing the limit of the PCI bus (taken from +> offical 3ware 9500S 8MI benchmarks). 140 drives is not going to beat +> 6 drives because you've run out of bandwidth on the PCI bus. +> +> The debait on RAID 5 rages onward. The benchmarks I've seen suggest +> that RAID 5 is consistantly slower than RAID 10 with the same number +> of drivers, but others suggest that RAID 5 can be much faster that +> RAID 10 (see arstechnica.com) (Theoretical performance of RAID 5 is +> inline with a RAID 0 stripe of N-1 drives, RAID 10 has only N/2 drives +> in a stripe, perfomance should be nearly double - in theory of +> course). +> +> 35 Trans/sec is pretty slow, particularly if they are only one row at +> a time. I typicaly get 200-400/sec on our DB server on a bad day. Up +> to 1100 on a fresh database. + +Well, by putting the pg_xlog directory on a separate disk/partition, I +was able to increase this rate to about 50 or so per second (still +pretty far from your numbers). Next I am going to try putting the +pg_xlog on a RAID1+0 array and see if that helps. + +> I suggested running a bonnie benchmark, or some other IO perftest to +> determine if it's the array itself performing badly, or if there is +> something wrong with postgresql. +> +> If the array isn't kicking out at least 50MB/sec read/write +> performance, something is wrong. +> +> Until you've isolated the problem to either postgres or the array, +> everything else is simply speculation. +> +> In a perfect world, you would have two 6 drive RAID 10s. on two PCI +> busses, with system tables on a third parition, and archive logging on +> a fourth. Unsurprisingly this looks alot like the Oracle recommended +> minimum config. + +Could you please elaborate on this setup a little more? How do you put +system tables on a separate partition? I am still using version 7, and +without tablespaces (which is how Oracle controls this), I can't figure +out how to put different tables on different partitions. Thanks. + + +Arshavir + + + +> Also a note for interest is that this is _software_ raid... +> +> Alex Turner +> netEconomist +> +> On 13 Mar 2005 23:36:13 -0500, Greg Stark wrote: +> +>>Arshavir Grigorian writes: +>> +>> +>>>Hi, +>>> +>>>I have a RAID5 array (mdadm) with 14 disks + 1 spare. This partition has an +>>>Ext3 filesystem which is used by Postgres. +>> +>>People are going to suggest moving to RAID1+0. I'm unconvinced that RAID5 +>>across 14 drivers shouldn't be able to keep up with RAID1 across 7 drives +>>though. It would be interesting to see empirical data. +>> +>>One thing that does scare me is the Postgres transaction log and the ext3 +>>journal both sharing these disks with the data. Ideally both of these things +>>should get (mirrored) disks of their own separate from the data files. +>> +>>But 2-3s pauses seem disturbing. I wonder whether ext3 is issuing a cache +>>flush on every fsync to get the journal pushed out. This is a new linux +>>feature that's necessary with ide but shouldn't be necessary with scsi. +>> +>>It would be interesting to know whether postgres performs differently with +>>fsync=off. This would even be a reasonable mode to run under for initial +>>database loads. It shouldn't make much of a difference with hardware like this +>>though. And you should be aware that running under this mode in production +>>would put your data at risk. +>> +>>-- +>>greg +>> +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 9: the planner will ignore your desire to choose an index scan if your +>> joining column's datatypes do not match +>> + + +-- +Arshavir Grigorian +Systems Administrator/Engineer +M-CAM, Inc. +ag@m-cam.com ++1 703-682-0570 ext. 432 +Contents Confidential + +From pgsql-performance-owner@postgresql.org Mon Mar 14 21:18:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F050754EE6 + for ; + Mon, 14 Mar 2005 21:18:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65012-05 + for ; + Mon, 14 Mar 2005 21:18:01 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 6FF45563EA + for ; + Mon, 14 Mar 2005 21:17:58 +0000 (GMT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Subject: Re: Postgres on RAID5 +Date: Mon, 14 Mar 2005 16:18:00 -0500 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A763F@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Postgres on RAID5 +Thread-Index: AcUoz/XLh7FFKa9FQYunMwO061W+cAACquCQ +From: "Merlin Moncure" +To: "Alex Turner" +Cc: , + "Arshavir Grigorian" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.058 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/285 +X-Sequence-Number: 10990 + +Alex Turner wrote:=20 +> 35 Trans/sec is pretty slow, particularly if they are only one row at +> a time. I typicaly get 200-400/sec on our DB server on a bad day. Up +> to 1100 on a fresh database. + +Well, don't rule out that his raid controller is not caching his writes. +His WAL sync method may be overriding his raid cache policy and flushing +his writes to disk, always. Win32 has the same problem, and before +Magnus's O_DIRECT patch, there was no way to easily work around it +without turning fsync off. I'd suggest playing with different WAL sync +methods before trying anything else. + +Merli + +From pgsql-performance-owner@postgresql.org Mon Mar 14 21:31:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D47F563C1 + for ; + Mon, 14 Mar 2005 21:31:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67322-07 + for ; + Mon, 14 Mar 2005 21:31:05 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195]) + by svr1.postgresql.org (Postfix) with ESMTP id E9B855547E + for ; + Mon, 14 Mar 2005 21:31:02 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 70so1852436wra + for ; + Mon, 14 Mar 2005 13:31:04 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=KUawNjjQW5ey8aOAPpy5iLzaUoBdhWM32pHAsMyUpzxy2/yLw3F1EN7nSitdN7dkdccKJ09nroeLDpFXIwROvOI0H8ADBTeSNboIQoNtLrpNkWlxRVdrMF1lxglDbHTYKXoDMSqr9wO07qICmdE0vzBS72DY5yw5Tb4iwgJFDHY= +Received: by 10.54.7.54 with SMTP id 54mr215573wrg; + Mon, 14 Mar 2005 13:31:04 -0800 (PST) +Received: by 10.54.18.53 with HTTP; Mon, 14 Mar 2005 13:31:03 -0800 (PST) +Message-ID: <33c6269f05031413315458d3cb@mail.gmail.com> +Date: Mon, 14 Mar 2005 16:31:03 -0500 +From: Alex Turner +Reply-To: Alex Turner +To: Arshavir Grigorian +Subject: Re: Postgres on RAID5 +Cc: pgsql-performance@postgresql.org +In-Reply-To: <4235FA0A.40600@m-cam.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <423209E1.6090200@m-cam.com> + <33c6269f05031119506fee5c31@mail.gmail.com> <4235FA0A.40600@m-cam.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.228 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/286 +X-Sequence-Number: 10991 + +Actualy my statistics were off a bit I realised - chance of failure +for one drive is 1 in X. change of failure in RAID 0 is 7 in X, +chance of one drive failure in 14 drive RAID 5 is 14 in X,13 in X for +second drive, total probably is 182 in X*X, which is much lower than +RAID 0. + +Your drive performance is less than stellar for a 14 drive stripe, and +CPU usage for writes is very high. Even so - this should be enough +through put to get over 100 rows/sec assuming you have virtualy no +stored procs (I have noticed that stored procs in plpgsql REALLY slow +pg_sql down). + +Alex Turner +netEconomist + +On Mon, 14 Mar 2005 15:54:34 -0500, Arshavir Grigorian wrote: +> Alex Turner wrote: +> > I would recommend running a bonnie++ benchmark on your array to see if +> > it's the array/controller/raid being crap, or wether it's postgres. I +> > have had some very surprising results from arrays that theoretically +> > should be fast, but turned out to be very slow. +> > +> > I would also seriously have to recommend against a 14 drive RAID 5! +> > This is statisticaly as likely to fail as a 7 drive RAID 0 (not +> > counting the spare, but rebuiling a spare is very hard on existing +> > drives). +> +> Thanks for the reply. +> +> Here are the results of the bonnie test on my array: +> +> ./bonnie -s 10000 -d . > oo 2>&1 +> File './Bonnie.23736', size: 10485760000 +> Writing with putc()...done +> Rewriting...done +> Writing intelligently...done +> Reading with getc()...done +> Reading intelligently...done +> Seeker 1...Seeker 2...Seeker 3...start 'em...done...done...done... +> -------Sequential Output-------- ---Sequential Input-- --Random-- +> -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks--- +> MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU /sec %CPU +> 10000 4762 96.0 46140 78.8 31180 61.0 3810 99.9 71586 67.7 411.8 13.1 +> +> On a different note, I am not sure how the probability of RAID5 over 15 +> disks failing is the same as that of a RAID0 array over 7 disks. RAID5 +> can operate in a degraded mode (14 disks - 1 bad), RAID0 on the other +> hand cannot operate on 6 disks (6 disks - 1 bad). Am I missing something? +> +> Are you saying running RAID0 on a set of 2 RAID1 arrays of 7 each? That +> would work fine, except I cannot afford to "loose" that much space. +> +> Care to comment on these numbers? Thanks. +> +> +> Arshavir +> + +From pgsql-performance-owner@postgresql.org Mon Mar 14 21:44:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8AD5756719 + for ; + Mon, 14 Mar 2005 21:44:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75613-01 + for ; + Mon, 14 Mar 2005 21:44:40 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.206]) + by svr1.postgresql.org (Postfix) with ESMTP id C771A56755 + for ; + Mon, 14 Mar 2005 21:42:05 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 70so1855900wra + for ; + Mon, 14 Mar 2005 13:42:07 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=Jt2evZPzU0C2GcZkVXe5Aih58bG6yZHOdTMCmQb6G63kOUQa4fqZpnJZqzutUSjJGaB2jFnOhc/76Cr83IRGPcsZbnp1YToS4pp21Sha7oYx9yXNYNL/OYac0K8NkANlmPpy0N8DGMfXp3jLR3rMYmfwOAujZfUIwd+NJU/UaQ4= +Received: by 10.54.22.38 with SMTP id 38mr305296wrv; + Mon, 14 Mar 2005 13:42:07 -0800 (PST) +Received: by 10.54.18.53 with HTTP; Mon, 14 Mar 2005 13:42:07 -0800 (PST) +Message-ID: <33c6269f05031413424d749d5f@mail.gmail.com> +Date: Mon, 14 Mar 2005 16:42:07 -0500 +From: Alex Turner +Reply-To: Alex Turner +To: Merlin Moncure +Subject: Re: Postgres on RAID5 +Cc: pgsql-performance@postgresql.org, + Arshavir Grigorian +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A763F@Herge.rcsinc.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <6EE64EF3AB31D5448D0007DD34EEB3412A763F@Herge.rcsinc.local> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.229 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/287 +X-Sequence-Number: 10992 + +He doesn't have a RAID controller, it's software RAID... + +Alex Turner +netEconomis + + +On Mon, 14 Mar 2005 16:18:00 -0500, Merlin Moncure + wrote: +> Alex Turner wrote: +> > 35 Trans/sec is pretty slow, particularly if they are only one row at +> > a time. I typicaly get 200-400/sec on our DB server on a bad day. Up +> > to 1100 on a fresh database. +> +> Well, don't rule out that his raid controller is not caching his writes. +> His WAL sync method may be overriding his raid cache policy and flushing +> his writes to disk, always. Win32 has the same problem, and before +> Magnus's O_DIRECT patch, there was no way to easily work around it +> without turning fsync off. I'd suggest playing with different WAL sync +> methods before trying anything else. +> +> Merli +> + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:51:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C347656718 + for ; + Mon, 14 Mar 2005 22:47:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92023-01 + for ; + Mon, 14 Mar 2005 22:47:27 +0000 (GMT) +Received: from hobbit.corpit.ru (hobbit.corpit.ru [81.13.94.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 5CAB6564E2 + for ; + Mon, 14 Mar 2005 22:47:21 +0000 (GMT) +Received: from localhost (localhost [127.0.0.1]) + by hobbit.corpit.ru (Postfix) with ESMTP id 1209E295DD; + Tue, 15 Mar 2005 01:47:18 +0300 (MSK) (envelope-from mjt@tls.msk.ru) +Received: from [192.168.1.200] (mjt.ppp.tls.msk.ru [192.168.1.200]) + by hobbit.corpit.ru (Postfix) with ESMTP; + Tue, 15 Mar 2005 01:47:17 +0300 (MSK) (envelope-from mjt@tls.msk.ru) +Message-ID: <42361474.9060500@tls.msk.ru> +Date: Tue, 15 Mar 2005 01:47:16 +0300 +From: Michael Tokarev +Organization: Telecom Service, JSC +User-Agent: Debian Thunderbird 1.0 (X11/20050116) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Arshavir Grigorian +Cc: linux-raid@vger.kernel.org, pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +References: <4231F5F2.6000509@m-cam.com> <87hdje7sjm.fsf@stark.xeocode.com> + <33c6269f050314115339b6861d@mail.gmail.com> + <4235FC2F.9060000@m-cam.com> +In-Reply-To: <4235FC2F.9060000@m-cam.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/408 +X-Sequence-Number: 11113 + +Arshavir Grigorian wrote: +> Alex Turner wrote: +> +[] +> Well, by putting the pg_xlog directory on a separate disk/partition, I +> was able to increase this rate to about 50 or so per second (still +> pretty far from your numbers). Next I am going to try putting the +> pg_xlog on a RAID1+0 array and see if that helps. + +pg_xlog is written syncronously, right? It should be, or else reliability +of the database will be at a big question... + +I posted a question on Feb-22 here in linux-raid, titled "*terrible* +direct-write performance with raid5". There's a problem with write +performance of a raid4/5/6 array, which is due to the design. + +Consider raid5 array (raid4 will be exactly the same, and for raid6, +just double the parity writes) with N data block and 1 parity block. +At the time of writing a portion of data, parity block should be +updated too, to be consistent and recoverable. And here, the size of +the write plays very significant role. If your write size is smaller +than chunk_size*N (N = number of data blocks in a stripe), in order +to calculate correct parity you have to read data from the remaining +drives. The only case where you don't need to read data from other +drives is when you're writing by the size of chunk_size*N, AND the +write is block-aligned. By default, chunk_size is 64Kb (min is 4Kb). +So the only reasonable direct-write size of N drives will be 64Kb*N, +or else raid code will have to read "missing" data to calculate the +parity block. Ofcourse, in 99% cases you're writing in much smaller +sizes, say 4Kb or so. And here, the more drives you have, the +LESS write speed you will have. + +When using the O/S buffer and filesystem cache, the system has much +more chances to re-order requests and sometimes even omit reading +entirely (when you perform many sequentional writes for example, +without sync in between), so buffered writes might be much fast. +But not direct or syncronous writes, again especially when you're +doing alot of sequential writes... + +So to me it looks like an inherent problem of raid5 architecture +wrt database-like workload -- databases tends to use syncronous +or direct writes to ensure good data consistency. + +For pgsql, which (i don't know for sure but reportedly) uses syncronous +writs only for the transaction log, it is a good idea to put that log +only to a raid1 or raid10 array, but NOT to raid5 array. + +Just IMHO ofcourse. + +/mjt + +From pgsql-performance-owner@postgresql.org Mon Mar 14 23:16:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BCA0056476 + for ; + Mon, 14 Mar 2005 23:16:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97047-09 + for ; + Mon, 14 Mar 2005 23:16:14 +0000 (GMT) +Received: from smtp104.mail.sc5.yahoo.com (smtp104.mail.sc5.yahoo.com + [66.163.169.223]) + by svr1.postgresql.org (Postfix) with SMTP id BF9BE558CF + for ; + Mon, 14 Mar 2005 23:16:10 +0000 (GMT) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp104.mail.sc5.yahoo.com with SMTP; 14 Mar 2005 23:16:09 -0000 +Received: from [172.21.8.128] (ganymed.black-lion.info [192.168.192.101] (may + be forged)) (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + j2ENG8OU028611; Mon, 14 Mar 2005 18:16:08 -0500 (EST) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <42361B32.4000303@Yahoo.com> +Date: Mon, 14 Mar 2005 18:16:02 -0500 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: bryan.encina@valleypres.org +Cc: pgsql-performance@postgresql.org +Subject: Re: column name is "LIMIT" +References: <01a201c528cb$c23f7d20$ca1e10ac@AT10111> +In-Reply-To: <01a201c528cb$c23f7d20$ca1e10ac@AT10111> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.325 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/288 +X-Sequence-Number: 10993 + +On 3/14/2005 2:26 PM, Bryan Encina wrote: +>> Note also that the Slony-I replication system has problems +>> with column +>> names identical to reserved words. This is rooted in the fact +>> that the +>> quote_ident() function doesn't quote reserved words ... as it IMHO is +>> supposed to do. +>> +>> +>> Jan +>> +> +> Does this apply to table names as well or just columns? +> +> Bryan + +Sure does, don't try to replicate a table named "user". + + +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 Mon Mar 21 04:52:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 921F756594 + for ; + Mon, 14 Mar 2005 23:49:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08351-01 + for ; + Mon, 14 Mar 2005 23:49:26 +0000 (GMT) +Received: from sccrmhc11.comcast.net (sccrmhc11.comcast.net [204.127.202.55]) + by svr1.postgresql.org (Postfix) with ESMTP id 6948856754 + for ; + Mon, 14 Mar 2005 23:49:22 +0000 (GMT) +Received: from www.watkins-home.com ([68.33.47.154]) + by comcast.net (sccrmhc11) with ESMTP + id <20050314234919011005pggue>; Mon, 14 Mar 2005 23:49:23 +0000 +Received: from m5 ([192.168.0.193]) + by www.watkins-home.com (8.11.6/8.11.6) with ESMTP id j2ENnG510033; + Mon, 14 Mar 2005 18:49:16 -0500 +Message-Id: <200503142349.j2ENnG510033@www.watkins-home.com> +Received: from 127.0.0.1 (AVG SMTP 7.0.308 [266.7.2]); + Mon, 14 Mar 2005 18:49:11 -0500 +From: "Guy" +To: "'Michael Tokarev'" , + "'Arshavir Grigorian'" +Cc: , +Subject: Re: Postgres on RAID5 +Date: Mon, 14 Mar 2005 18:49:11 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +Thread-Index: AcUo6T0/QXzy6oicQJ+4yF22n8922QABNl2w +In-Reply-To: <42361474.9060500@tls.msk.ru> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO, + MSGID_FROM_MTA_HEADER +X-Spam-Level: +X-Archive-Number: 200503/410 +X-Sequence-Number: 11115 + +You said: +"If your write size is smaller than chunk_size*N (N = number of data blocks +in a stripe), in order to calculate correct parity you have to read data +from the remaining drives." + +Neil explained it in this message: +http://marc.theaimsgroup.com/?l=linux-raid&m=108682190730593&w=2 + +Guy + +-----Original Message----- +From: linux-raid-owner@vger.kernel.org +[mailto:linux-raid-owner@vger.kernel.org] On Behalf Of Michael Tokarev +Sent: Monday, March 14, 2005 5:47 PM +To: Arshavir Grigorian +Cc: linux-raid@vger.kernel.org; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Postgres on RAID5 + +Arshavir Grigorian wrote: +> Alex Turner wrote: +> +[] +> Well, by putting the pg_xlog directory on a separate disk/partition, I +> was able to increase this rate to about 50 or so per second (still +> pretty far from your numbers). Next I am going to try putting the +> pg_xlog on a RAID1+0 array and see if that helps. + +pg_xlog is written syncronously, right? It should be, or else reliability +of the database will be at a big question... + +I posted a question on Feb-22 here in linux-raid, titled "*terrible* +direct-write performance with raid5". There's a problem with write +performance of a raid4/5/6 array, which is due to the design. + +Consider raid5 array (raid4 will be exactly the same, and for raid6, +just double the parity writes) with N data block and 1 parity block. +At the time of writing a portion of data, parity block should be +updated too, to be consistent and recoverable. And here, the size of +the write plays very significant role. If your write size is smaller +than chunk_size*N (N = number of data blocks in a stripe), in order +to calculate correct parity you have to read data from the remaining +drives. The only case where you don't need to read data from other +drives is when you're writing by the size of chunk_size*N, AND the +write is block-aligned. By default, chunk_size is 64Kb (min is 4Kb). +So the only reasonable direct-write size of N drives will be 64Kb*N, +or else raid code will have to read "missing" data to calculate the +parity block. Ofcourse, in 99% cases you're writing in much smaller +sizes, say 4Kb or so. And here, the more drives you have, the +LESS write speed you will have. + +When using the O/S buffer and filesystem cache, the system has much +more chances to re-order requests and sometimes even omit reading +entirely (when you perform many sequentional writes for example, +without sync in between), so buffered writes might be much fast. +But not direct or syncronous writes, again especially when you're +doing alot of sequential writes... + +So to me it looks like an inherent problem of raid5 architecture +wrt database-like workload -- databases tends to use syncronous +or direct writes to ensure good data consistency. + +For pgsql, which (i don't know for sure but reportedly) uses syncronous +writs only for the transaction log, it is a good idea to put that log +only to a raid1 or raid10 array, but NOT to raid5 array. + +Just IMHO ofcourse. + +/mjt +- +To unsubscribe from this list: send the line "unsubscribe linux-raid" in +the body of a message to majordomo@vger.kernel.org +More majordomo info at http://vger.kernel.org/majordomo-info.html + + +From pgsql-performance-owner@postgresql.org Tue Mar 15 02:05:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4CD5856713 + for ; + Tue, 15 Mar 2005 02:05:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43526-01 + for ; + Tue, 15 Mar 2005 02:05:02 +0000 (GMT) +Received: from biglumber.com (biglumber.com [207.228.252.42]) + by svr1.postgresql.org (Postfix) with SMTP id 2BC4C56602 + for ; + Tue, 15 Mar 2005 02:04:58 +0000 (GMT) +Received: (qmail 20575 invoked from network); 15 Mar 2005 02:05:01 -0000 +Received: from unknown (HELO localhost) (207.228.252.42) + by 0 with SMTP; 15 Mar 2005 02:05:01 -0000 +From: "Greg Sabino Mullane" +To: pgsql-performance@postgresql.org +Subject: Re: cpu_tuple_cost +X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 +X-Request-PGP: + http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 +In-Reply-To: <5580.1110781746@sss.pgh.pa.us> +Date: Tue, 15 Mar 2005 02:05:01 -0000 +X-Mailer: JoyMail 1.48 +Message-ID: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.164 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/289 +X-Sequence-Number: 10994 + + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + + +> Reducing random_page_cost is usually the best way to get the +> planner to favor indexscans more. + +On that note, can I raise the idea again of dropping the default +value for random_page_cost in postgresql.conf? I think 4 is too +conservative in this day and age. Certainly the person who will +be negatively impacted by a default drop of 4 to 3 will be the +exception and not the rule. + +- -- +Greg Sabino Mullane greg@turnstep.com +PGP Key: 0x14964AC8 200503140702 +http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 +-----BEGIN PGP SIGNATURE----- + +iD8DBQFCNX2avJuQZxSWSsgRAk7QAJ4lye7pEcQIWMRV2fs15bHGY2zBbACeJtLC +E/vUG/lagjcyWPt9gfngsn0= +=CKIq +-----END PGP SIGNATURE----- + + + +From pgsql-performance-owner@postgresql.org Tue Mar 15 02:18:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C0C7C56718 + for ; + Tue, 15 Mar 2005 02:18:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43769-07 + for ; + Tue, 15 Mar 2005 02:17:53 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) + by svr1.postgresql.org (Postfix) with ESMTP id 878CA563D6 + for ; + Tue, 15 Mar 2005 02:17:48 +0000 (GMT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id j2F2HqA01460; + Mon, 14 Mar 2005 21:17:52 -0500 (EST) +From: Bruce Momjian +Message-Id: <200503150217.j2F2HqA01460@candle.pha.pa.us> +Subject: Re: cpu_tuple_cost +In-Reply-To: +To: Greg Sabino Mullane +Date: Mon, 14 Mar 2005 21:17:52 -0500 (EST) +Cc: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/290 +X-Sequence-Number: 10995 + +Greg Sabino Mullane wrote: +[ There is text before PGP section. ] +> +> -----BEGIN PGP SIGNED MESSAGE----- +> Hash: SHA1 +> +> +> > Reducing random_page_cost is usually the best way to get the +> > planner to favor indexscans more. +> +> On that note, can I raise the idea again of dropping the default +> value for random_page_cost in postgresql.conf? I think 4 is too +> conservative in this day and age. Certainly the person who will +> be negatively impacted by a default drop of 4 to 3 will be the +> exception and not the rule. + +Agreed. I think we should reduce it at least to 3. + +-- + 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 Mar 15 02:23:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 853615671E + for ; + Tue, 15 Mar 2005 02:23:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45830-08 + for ; + Tue, 15 Mar 2005 02:23:30 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 905A55671A + for ; + Tue, 15 Mar 2005 02:23:27 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2F2NT5X001677; + Mon, 14 Mar 2005 21:23:29 -0500 (EST) +To: "Greg Sabino Mullane" +Cc: pgsql-performance@postgresql.org +Subject: Re: cpu_tuple_cost +In-reply-to: +References: +Comments: In-reply-to "Greg Sabino Mullane" + message dated "Tue, 15 Mar 2005 02:05:01 +0000" +Date: Mon, 14 Mar 2005 21:23:29 -0500 +Message-ID: <1676.1110853409@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/291 +X-Sequence-Number: 10996 + +"Greg Sabino Mullane" writes: +> On that note, can I raise the idea again of dropping the default +> value for random_page_cost in postgresql.conf? I think 4 is too +> conservative in this day and age. Certainly the person who will +> be negatively impacted by a default drop of 4 to 3 will be the +> exception and not the rule. + +The ones who'd be negatively impacted are the ones we haven't +been hearing from ;-). To assume that they aren't out there +is a logical fallacy. + +I still think that 4 is about right for large databases (where +"large" is in comparison to available RAM). + +Also, to the extent that we think these numbers mean anything at all, +we should try to keep them matching the physical parameters we think +they represent. I think that the "reduce random_page_cost" mantra +is not an indication that that parameter is wrong, but that the +cost models it feeds into need more work. One thing we *know* +is wrong is the costing of nestloop inner indexscans: there needs +to be a correction for caching of index blocks across repeated +scans. I've looked at this a few times but not come up with +anything that seemed convincing. Another thing I've wondered +about more than once is if we shouldn't discount fetching of +higher-level btree pages on the grounds that they're probably +in RAM already, even if the indexscan isn't inside a loop. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 15 05:30:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E90E756846 + for ; + Tue, 15 Mar 2005 05:30:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78633-09 + for ; + Tue, 15 Mar 2005 05:30:48 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 1070156843 + for ; + Tue, 15 Mar 2005 05:30:45 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DB4dd-0002Sj-00 + for ; Tue, 15 Mar 2005 00:30:41 -0500 +To: pgsql-performance@postgresql.org +Subject: Re: cpu_tuple_cost +From: Gregory Stark +Date: 15 Mar 2005 00:30:41 -0500 +Message-ID: <87psy1mq66.fsf@stark.xeocode.com> +Lines: 19 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.02 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/292 +X-Sequence-Number: 10997 + + +Bruce Momjian wrote: + +> Agreed. I think we should reduce it at least to 3. + +Note that changing it from 4 to 3 or even 2 is unlikely to really change much. +Many of the plans people complain about turn out to have critical points +closer to 1.2 or 1.1. + +The only reason things work out better with such low values is because people +have data sets that fit more or less entirely in RAM. So values close to 1 or +even equal to 1 actually represent the reality. + +The "this day and age" argument isn't very convincing. Hard drive capacity +growth has far outstripped hard drive seek time and bandwidth improvements. +Random access has more penalty than ever. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Mar 15 06:11:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2CEB35641D + for ; + Tue, 15 Mar 2005 06:11:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15323-05 + for ; + Tue, 15 Mar 2005 06:11:50 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id B36B756419 + for ; + Tue, 15 Mar 2005 06:11:45 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7128246 for pgsql-performance@postgresql.org; + Mon, 14 Mar 2005 22:13:32 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: cpu_tuple_cost +Date: Mon, 14 Mar 2005 22:10:40 -0800 +User-Agent: KMail/1.6.2 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200503142210.40717.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/293 +X-Sequence-Number: 10998 + +Greg, + +> On that note, can I raise the idea again of dropping the default +> value for random_page_cost in postgresql.conf? I think 4 is too +> conservative in this day and age. Certainly the person who will +> be negatively impacted by a default drop of 4 to 3 will be the +> exception and not the rule. + +I don't agree. The defaults are there for people who aren't going to read +enough of the documentation to set them. As such, conservative for the +defaults is appropriate. + +If we were going to change anything automatically, it would be to set +effective_cache_size to 1/3 of RAM at initdb time. However, I don't know any +method to determine RAM size that works on all the platforms we support. + +Tom, + +> Also, to the extent that we think these numbers mean anything at all, +> we should try to keep them matching the physical parameters we think +> they represent. + +Personally, what I would love to see is the system determining and caching +some of these parameters automatically. For example, in a database which +has been running in production for a couple of days, it should be possible to +determine the ratio of average random seek tuple cost to average seq scan +tuple cost. + +Other parameters should really work the same way. Effective_cache_size, for +example, is a blunt instrument to replace what the database should ideally do +through automated interactive fine tuning. Particularly since we have 2 +separate caches (or 3, if you count t1 and t2 from 2Q). What the planner +really needs to know is: is this table or index already in the t1 or t2 cache +(can't we determine this?)? How likely is it to be in the filesystem cache? +The latter question is not just one of size (table < memory), but one of +frequency of access. + +Of course, this stuff is really, really hard which is why we rely on the +GUCs ... + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Mar 15 09:01:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A8E7F5654D + for ; + Tue, 15 Mar 2005 09:01:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56396-08 + for ; + Tue, 15 Mar 2005 09:01:24 +0000 (GMT) +Received: from ns.aprote.ee (ns.aprote.ee [80.235.78.106]) + by svr1.postgresql.org (Postfix) with ESMTP id C7F17564F1 + for ; + Tue, 15 Mar 2005 09:01:22 +0000 (GMT) +Received: Message by Barricade ns.aprote.ee with ESMTP id j2F92Ams003742 + for ; Tue, 15 Mar 2005 11:02:10 +0200 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6556.0 +Subject: Re: One tuple per transaction +Date: Tue, 15 Mar 2005 11:01:22 +0200 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: One tuple per transaction +Thread-Index: AcUoPUM79PLrsUJPSdyauDuXr/guUwA+Eg7w +From: "Tambet Matiisen" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/294 +X-Sequence-Number: 10999 + +> ------------------------------ +>=20 +> Date: Mon, 14 Mar 2005 09:41:30 +0800 +> From: "Qingqing Zhou" +> To: pgsql-performance@postgresql.org +> Subject: Re: One tuple per transaction +> Message-ID: +>=20 +> ""Tambet Matiisen"" writes +... +> > If I'm correct, the dead tuples must be scanned also during=20 +> table and=20 +> > index scan, so a lot of dead tuples slows down queries=20 +> considerably,=20 +> > especially when the table doesn't fit into shared buffers any more.=20 +> > And as I'm in transaction, I can't VACUUM to get rid of=20 +> those tuples.=20 +> > In one occasion the page count for a table went from 400 to=20 +> 22000 at=20 +> > the end. +>=20 +> Not exactly. The dead tuple in the index will be scanned the=20 +> first time (and its pointed heap tuple as well), then we will=20 +> mark it dead, then next time we came here, we will know that=20 +> the index tuple actually points to a uesless tuple, so we=20 +> will not scan its pointed heap tuple. +>=20 + +But the dead index tuple will still be read from disk next time? Maybe +really the performance loss will be neglible, but if most of tuples in +your table/index are dead, then it might be significant. + +Consider the often suggested solution for speeding up "select count(*) +from table" query: make another table rowcounts and for each of the +original tables add insert and delete triggers to update row count in +rowcounts table. Actually this is standard denormalization technique, +which I use often. For example to ensure that order.total =3D +sum(order_line.total). + +Now, if typical inserts into your most active table occur in batches of +3 rows, in one transaction, then row count for this table is updated 3 +times during transaction. 3 updates generate 3 tuples, while 2 of them +are dead from the very start. You effectively commit 2 useless tuples. +After millions of inserts you end up with rowcounts table having 2/3 of +dead tuples and queries start to slow down. + +Current solution is to vacuum often. My proposal was to create new tuple +only with first update. The next updates in the same transaction would +update the existing tuple, not create a new.=20 + +But as I'm writing this, I'm starting to get some of the associated +implementation problems. The updated tuple might not be the same size as +previous tuple. Tuple updates are probably not implemented anyway. And +for a reason, as disk write takes the same time, regardless if you +update or write new data. And tons of other problems, which developers +are probably more aware of. + +But one thing still bothers me. Why is new index tuple generated when I +update non-indexed column? OK, I get it again. Index tuple points to +heap tuple, thus after update it would point to dead tuple. And as it +takes the same time to update pointer or to write a new tuple, it's +easier to write a new. + +Case closed. + + Tambet + +From pgsql-performance-owner@postgresql.org Tue Mar 15 09:37:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CD1FC563AA + for ; + Tue, 15 Mar 2005 09:37:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67386-08 + for ; + Tue, 15 Mar 2005 09:37:42 +0000 (GMT) +Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net + [194.217.242.92]) + by svr1.postgresql.org (Postfix) with ESMTP id 33DCE54EE6 + for ; + Tue, 15 Mar 2005 09:37:41 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-34.mail.demon.net with esmtp (Exim 4.42) + id 1DB8Uf-000OD3-G2; Tue, 15 Mar 2005 09:37:42 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id E6CD115A44; Tue, 15 Mar 2005 09:37:40 +0000 (GMT) +Message-ID: <4236ACE5.1040004@archonet.com> +Date: Tue, 15 Mar 2005 09:37:41 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tambet Matiisen +Cc: pgsql-performance@postgresql.org +Subject: Re: One tuple per transaction +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.062 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/295 +X-Sequence-Number: 11000 + +Tambet Matiisen wrote: +>> +>>Not exactly. The dead tuple in the index will be scanned the +>>first time (and its pointed heap tuple as well), then we will +>>mark it dead, then next time we came here, we will know that +>>the index tuple actually points to a uesless tuple, so we +>>will not scan its pointed heap tuple. +>> +> +> +> But the dead index tuple will still be read from disk next time? Maybe +> really the performance loss will be neglible, but if most of tuples in +> your table/index are dead, then it might be significant. + +When a block is read from disk, any dead tuples in that block will be +read in. Vacuum recovers these. + +> Consider the often suggested solution for speeding up "select count(*) +> from table" query: make another table rowcounts and for each of the +> original tables add insert and delete triggers to update row count in +> rowcounts table. Actually this is standard denormalization technique, +> which I use often. For example to ensure that order.total = +> sum(order_line.total). + +This does of course completely destroy concurrency. Since you need to +lock the summary table, other clients have to wait until you are done. + +> Now, if typical inserts into your most active table occur in batches of +> 3 rows, in one transaction, then row count for this table is updated 3 +> times during transaction. 3 updates generate 3 tuples, while 2 of them +> are dead from the very start. You effectively commit 2 useless tuples. +> After millions of inserts you end up with rowcounts table having 2/3 of +> dead tuples and queries start to slow down. +> +> Current solution is to vacuum often. My proposal was to create new tuple +> only with first update. The next updates in the same transaction would +> update the existing tuple, not create a new. + +How do you roll back to a savepoint with this model? + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Mar 15 10:24:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C5BD56596 + for ; + Tue, 15 Mar 2005 10:24:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81337-06 + for ; + Tue, 15 Mar 2005 10:24:50 +0000 (GMT) +Received: from ns.aprote.ee (ns.aprote.ee [80.235.78.106]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C0E556572 + for ; + Tue, 15 Mar 2005 10:24:49 +0000 (GMT) +Received: Message by Barricade ns.aprote.ee with ESMTP id j2FAPcxX005221 + for ; Tue, 15 Mar 2005 12:25:38 +0200 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6556.0 +Subject: Re: One tuple per transaction +Date: Tue, 15 Mar 2005 12:24:49 +0200 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] One tuple per transaction +Thread-Index: AcUpQruzu9pPGI7KQFmt9GyzqJAPVgABFu3Q +From: "Tambet Matiisen" +To: "Richard Huxton" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/296 +X-Sequence-Number: 11001 + + + +> -----Original Message----- +> From: Richard Huxton [mailto:dev@archonet.com]=20 +> Sent: Tuesday, March 15, 2005 11:38 AM +> To: Tambet Matiisen +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] One tuple per transaction +>=20 +... +>=20 +> > Consider the often suggested solution for speeding up=20 +> "select count(*)=20 +> > from table" query: make another table rowcounts and for each of the=20 +> > original tables add insert and delete triggers to update=20 +> row count in=20 +> > rowcounts table. Actually this is standard denormalization=20 +> technique,=20 +> > which I use often. For example to ensure that order.total =3D=20 +> > sum(order_line.total). +>=20 +> This does of course completely destroy concurrency. Since you need to=20 +> lock the summary table, other clients have to wait until you are done. +>=20 + +Yes, it does for rowcounts table. But consider the orders example - it +only locks the order which I add lines. As there is mostly one client +dealing with one order, but possibly thousands dealing with different +orders, it should not pose any concurrency restrictions. + +> > Now, if typical inserts into your most active table occur=20 +> in batches=20 +> > of 3 rows, in one transaction, then row count for this table is=20 +> > updated 3 times during transaction. 3 updates generate 3=20 +> tuples, while=20 +> > 2 of them are dead from the very start. You effectively commit 2=20 +> > useless tuples. After millions of inserts you end up with rowcounts=20 +> > table having 2/3 of dead tuples and queries start to slow down. +> >=20 +> > Current solution is to vacuum often. My proposal was to create new=20 +> > tuple only with first update. The next updates in the same=20 +> transaction=20 +> > would update the existing tuple, not create a new. +>=20 +> How do you roll back to a savepoint with this model? +>=20 + +Every savepoint initiates a new (sub)transaction. + + Tambet + +From pgsql-performance-owner@postgresql.org Tue Mar 15 12:35:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F839563DE + for ; + Tue, 15 Mar 2005 12:35:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21251-02 + for ; + Tue, 15 Mar 2005 12:35:21 +0000 (GMT) +Received: from biglumber.com (biglumber.com [207.228.252.42]) + by svr1.postgresql.org (Postfix) with SMTP id 3C38B563E1 + for ; + Tue, 15 Mar 2005 12:35:17 +0000 (GMT) +Received: (qmail 16386 invoked from network); 15 Mar 2005 12:35:19 -0000 +Received: from unknown (HELO localhost) (207.228.252.42) + by 0 with SMTP; 15 Mar 2005 12:35:19 -0000 +From: "Greg Sabino Mullane" +To: pgsql-performance@postgresql.org +Subject: Re: Changing the random_page_cost default (was: cpu_tuple_cost) +X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 +X-Request-PGP: + http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 +In-Reply-To: <200503142210.40717.josh@agliodbs.com> +Date: Tue, 15 Mar 2005 12:35:19 -0000 +X-Mailer: JoyMail 1.48 +Message-ID: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.159 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/297 +X-Sequence-Number: 11002 + + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + + +Josh Berkus wrote: +> I don't agree. The defaults are there for people who aren't going to read +> enough of the documentation to set them. As such, conservative for the +> defaults is appropriate. + +Sure, but I would argue that 4 is *too* conservative. We've certainly changed +other values over the years. I see it as those most affected by this change +are those who are least likely to have the know-how to change the default, +and are also the majority of our users. I've often had to reduce this, working +on many databases, on many versions of PostgreSQL. Granted, I don't work on +any huge, complex, hundreds of gig databases, but that supports my point - +if you are really better off with a /higher/ (than 3) random_page_cost, you +already should be tweaking a lot of stuff yourself anyway. Tom Lane has a +good point about tweaking other default parameters as well, and that's a +worthy goal, but I don't think extended searching for a "sweet spot" should +prevent us from making a small yet important (IMO!) change in the default +of this one variable. + +N.B. My own personal starting default is 2, but I thought 3 was a nice +middle ground more likely to reach consensus here. :) + +- -- +Greg Sabino Mullane greg@turnstep.com +PGP Key: 0x14964AC8 200503141727 +http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 +-----BEGIN PGP SIGNATURE----- + +iD8DBQFCNhFAvJuQZxSWSsgRAgZiAJ9947emxFoMMXKooJHi2ZPIQr9xGACgjaFf +hBCPTuHZwGFzomf1Z1TDpVo= +=KX9t +-----END PGP SIGNATURE----- + + + +From pgsql-performance-owner@postgresql.org Tue Mar 15 13:31:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 675605652E + for ; + Tue, 15 Mar 2005 13:31:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37237-06 + for ; + Tue, 15 Mar 2005 13:31:34 +0000 (GMT) +Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.85]) + by svr1.postgresql.org (Postfix) with ESMTP id D157E564A2 + for ; + Tue, 15 Mar 2005 13:31:32 +0000 (GMT) +Received: from [192.168.11.5] + (c-24-118-153-224.mn.client2.attbi.com[24.118.153.224]) + by comcast.net (rwcrmhc12) with SMTP + id <2005031513313501400js0que>; Tue, 15 Mar 2005 13:31:35 +0000 +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v619.2) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <8dd8c52718f9c9153fe089d64a496150@propertykey.com> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Jeff Hoffmann +Subject: Re: Changing the random_page_cost default (was: cpu_tuple_cost) +Date: Tue, 15 Mar 2005 07:31:19 -0600 +To: "Greg Sabino Mullane" +X-Mailer: Apple Mail (2.619.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/298 +X-Sequence-Number: 11003 + + +On Mar 15, 2005, at 6:35 AM, Greg Sabino Mullane wrote: + +> Granted, I don't work on +> any huge, complex, hundreds of gig databases, but that supports my +> point - +> if you are really better off with a /higher/ (than 3) +> random_page_cost, you +> already should be tweaking a lot of stuff yourself anyway. + +I think this is a good point. The people that tend to benefit from the +lower cost are precisely the people least likely to know to change it. +It's the "install & go" crowd with smaller databases and only a few +users/low concurrency that expect it to "just work". The bigger +installations are more like to have dedicated DB admins that understand +tuning. + +Wasn't there an idea on the table once to ship with several different +configuration files with different defaults for small, medium, large, +etc. installs? Wouldn't it make sense to ask the user during initdb to +pick from one of the default config files? Or even have a few simple +questions like "How much memory do you expect to be available to +PostgreSQL?" and "How many concurrent users do you expect to have?". +It's one thing to know how much memory is in a machine, it quite +another thing to know how much the user wants dedicated to PostgreSQL. +A couple of questions like that can go a long way to coming up with +better ballpark figures. + +-- +Jeff Hoffmann +jeff@propertykey.com + + +From pgsql-performance-owner@postgresql.org Tue Mar 15 13:44:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DB3BC56469 + for ; + Tue, 15 Mar 2005 13:44:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41464-09 + for ; + Tue, 15 Mar 2005 13:44:08 +0000 (GMT) +Received: from my.endian.it (unknown [62.146.87.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 3824152A63 + for ; + Tue, 15 Mar 2005 13:44:06 +0000 (GMT) +Received: from [192.168.1.6] (host98-26.pool80180.interbusiness.it + [80.180.26.98]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id j2FEU8R12459 + for ; Tue, 15 Mar 2005 15:30:08 +0100 +Subject: interesting benchmarks PG/Firebird Linux/Windows fsync/nofsync +From: Chris Mair +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Message-Id: <1110894247.4441.49.camel@dell> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) +Date: Tue, 15 Mar 2005 14:44:07 +0100 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/299 +X-Sequence-Number: 11004 + +Hello, + +just recently I held a short course on PG. + +One course attendant, Robert Dollinger, got +interested in benchmarking single inserts (since +he currently maintains an application that does +exactly that on Firebird and speed is an issue +there). + +He came up with a table that I think is interesting +for other people so I asked permission to publish +it on this list. + +Here it is: +http://1006.org/pg/postgresql_firebird_win_linux.pdf + +Note: some german words are there, I can't change +the pdf, so here's a short explanation: + +He tested the speed of 4000 inserts through a Delphi +application with zeos components. + +the 3 parameters are: + +* transaction + - single: all 4000 inserts inside 1 transaction + - multi: 4000 inserts with 4000 commits + +* fsync (for PG) or forced writes (for FB) + - true/false + +* "Verbindung" = connection + - local + - LAN + - wireless + + notes: the server ran either on a windows desktop + machine or a linux laptop; the client allways ran + on the windows desktop + +Timings are in msec, note that you cannot directly +compare Windows and Linux Performance, since machines +were different. + +You can, however, compare PG to Firebird, and you +can see the effect of the 3 varied parametert. + +One thing that stands out is how terribly +bad Windows performed with many small single +transactions and fsync=true. + +Appearantly fsync on Windows is a very costly +operation. + +Another (good) thing is that PG beats FB on all +other tests :-) + + +Bye, Chris. + + + + + + +From pgsql-performance-owner@postgresql.org Tue Mar 15 13:52:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 28E4156479 + for ; + Tue, 15 Mar 2005 13:52:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45234-02 + for ; + Tue, 15 Mar 2005 13:52:05 +0000 (GMT) +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by svr1.postgresql.org (Postfix) with ESMTP id B369456469 + for ; + Tue, 15 Mar 2005 13:52:03 +0000 (GMT) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id 14C948F287; Tue, 15 Mar 2005 14:52:06 +0100 (CET) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: interesting benchmarks PG/Firebird Linux/Windows fsync/nofsync +Date: Tue, 15 Mar 2005 14:52:05 +0100 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE476B04@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] interesting benchmarks PG/Firebird Linux/Windows + fsync/nofsync +Thread-Index: AcUpZauNufDiZwqDTAuS3k0zzGbOGgAACFrg +From: "Magnus Hagander" +To: "Chris Mair" , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.07 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/300 +X-Sequence-Number: 11005 + + +> One thing that stands out is how terribly bad Windows=20 +> performed with many small single transactions and fsync=3Dtrue. +>=20 +> Appearantly fsync on Windows is a very costly operation. + +What's the hardware? If you're running on disks with write cache +enabled, fsync on windows will write through the write cache *no matter +what*. I don't know of any other OS where it will do that. + +If you don't have a battery backed write cache, then all other +configurations are considered very dangerous in case your machine +crashes. + +If you have battery backed write cache, then yes, pg on windows will +perform poorly indeed. + + +There is a patch in the queue for 8.0.2, and already applied to 8.1 +IIRC, that will fix the bad performance with write-cache on win32. + +(can't read the PDF, it crashes my adobe reader for some reason. Perhaps +it contains the information above...) + +//Magnus + +From pgsql-performance-owner@postgresql.org Tue Mar 15 13:55:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ED2385646C + for ; + Tue, 15 Mar 2005 13:55:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44785-06 + for ; + Tue, 15 Mar 2005 13:55:33 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) + by svr1.postgresql.org (Postfix) with ESMTP id CCDAB56410 + for ; + Tue, 15 Mar 2005 13:55:32 +0000 (GMT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id j2FDtYi13867; + Tue, 15 Mar 2005 08:55:34 -0500 (EST) +From: Bruce Momjian +Message-Id: <200503151355.j2FDtYi13867@candle.pha.pa.us> +Subject: Re: interesting benchmarks PG/Firebird Linux/Windows fsync/nofsync +In-Reply-To: <1110894247.4441.49.camel@dell> +To: Chris Mair +Date: Tue, 15 Mar 2005 08:55:34 -0500 (EST) +Cc: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/301 +X-Sequence-Number: 11006 + +Chris Mair wrote: +> Timings are in msec, note that you cannot directly +> compare Windows and Linux Performance, since machines +> were different. +> +> You can, however, compare PG to Firebird, and you +> can see the effect of the 3 varied parametert. +> +> One thing that stands out is how terribly +> bad Windows performed with many small single +> transactions and fsync=true. +> +> Appearantly fsync on Windows is a very costly +> operation. + +Yes, we now enable FILE_FLAG_WRITE_THROUGH on Win32 for open_sync and I +am about to open a discussion whether this should be the default for +Win32, and whether we should backpatch this to 8.0.X. + +-- + 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 Mar 15 15:24:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 467AC568C4 + for ; + Tue, 15 Mar 2005 15:24:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73931-02 + for ; + Tue, 15 Mar 2005 15:23:51 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id DD1C256912 + for ; + Tue, 15 Mar 2005 15:22:52 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2FFMux4006321; + Tue, 15 Mar 2005 10:22:56 -0500 (EST) +To: "Greg Sabino Mullane" +Cc: pgsql-performance@postgresql.org +Subject: Re: Changing the random_page_cost default (was: cpu_tuple_cost) +In-reply-to: +References: +Comments: In-reply-to "Greg Sabino Mullane" + message dated "Tue, 15 Mar 2005 12:35:19 +0000" +Date: Tue, 15 Mar 2005 10:22:56 -0500 +Message-ID: <6320.1110900176@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/302 +X-Sequence-Number: 11007 + +"Greg Sabino Mullane" writes: +> N.B. My own personal starting default is 2, but I thought 3 was a nice +> middle ground more likely to reach consensus here. :) + +Your argument seems to be "this produces nice results for me", not +"I have done experiments to measure the actual value of the parameter +and it is X". I *have* done experiments of that sort, which is where +the default of 4 came from. I remain of the opinion that reducing +random_page_cost is a band-aid that compensates (but only partially) +for problems elsewhere. We can see that it's not a real fix from +the not-infrequent report that people have to reduce random_page_cost +below 1.0 to get results anywhere near local reality. That doesn't say +that the parameter value is wrong, it says that the model it's feeding +into is wrong. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 15 15:25:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CB638568D9 + for ; + Tue, 15 Mar 2005 15:25:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74263-05 + for ; + Tue, 15 Mar 2005 15:25:11 +0000 (GMT) +Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5EA88568CF + for ; + Tue, 15 Mar 2005 15:23:54 +0000 (GMT) +Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 20D022BD57 + for ; + Tue, 15 Mar 2005 17:23:38 +0200 (SAST) +Received: from jhb.ucs.co.za (jhb.ucs.co.za [172.31.1.3]) + by ucspost.ucs.co.za (Postfix) with ESMTP id 0BC1BD9F62 + for ; + Tue, 15 Mar 2005 17:23:46 +0200 (SAST) +Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) + by jhb.ucs.co.za (Postfix) with ESMTP id 0470F97AEF + for ; + Tue, 15 Mar 2005 17:23:46 +0200 (SAST) +Date: Tue, 15 Mar 2005 17:23:45 +0200 +From: Stef +To: pgsql-performance@postgresql.org +Subject: Slow loads when indexes added. +Message-ID: <20050315172345.7e444432@svb.ucs.co.za> +X-Mailer: Sylpheed-Claws 1.0.1 (GTK+ 1.2.10; i386-pc-linux-gnu) +User-Agent: sillypheed-claws (anti-aliased) +X-Face: +lU/o'$=Zv9%Xjo]Kq[_{n&Kb`f{YEWH4&Y#M]'6BkD?VoWe#*@S\MWyD'I>s:0v4{#\[J]l*?]t2uaO(j$d*77Ca-UHo.tkl2)0$B3Jxww\o:xor]<:*Yfx9Vceh)9I/'2g\RKhGTxIIsR^ke^`LVeZ9ksb*:$kQeR@ +X-Operating-System: sid +X-X-X: _-^-_ +Mime-Version: 1.0 +Content-Type: multipart/mixed; + boundary="Multipart_Tue__15_Mar_2005_17_23_45_+0200_iq9C8up/zs86qPmm" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.46 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_WHOIS, LONGWORDS +X-Spam-Level: * +X-Archive-Number: 200503/303 +X-Sequence-Number: 11008 + +--Multipart_Tue__15_Mar_2005_17_23_45_+0200_iq9C8up/zs86qPmm +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +Hi all, + +I suspect this problem/bug has been dealt with already, but I couldn't +find anything in the mail archives. + +I'm using postgres 7.3, and I managed to recreate the problem using the attached +files. + +The database structure is in slow_structure.sql + +After creating the database, using this script, I ran run_before_load__fast.sql + +Then I created a load file using create_loadfile.sh (It creates a file called load.sql) + +I timed the loading of this file, and it loaded in 1 min 11.567 sec + +Then I recreated the database from slow_structure.sql, ran run_before_load__slow.sql, +and then loaded the same load.sql and it took 3 min 51.293 sec which is about 6 times slower. + +I tried the same thing on postgres 8.0.0 to see if it does the same thing, but there it +was consistently slow : 3 min 31.367 sec + +The only way I got the load.sql to load fast on postgres 8.0.0, was by not creating +any of the foreign key constraints that point to the "main" table, and then enabling them +afterwards. This gave me the fastest time overall : 1 min 4.911 sec + +My problem is that on the postgres 7.3.4 database I'm working with, a load process that +used to take 40 minutes, now takes 4 hours, because of 3 rows data being loaded into +a table (similar in setup to the "main" table in the example) before the indexes were created. +(This happens automatically when you dump and re-import the database (7.3.4)) + +Is there a way to get it to load fast again on the 7.3 database without dropping the foreign +key constraints (After running run_before_load_slow.sql) ? + +And, if someone knows off-hand, what's happening here? + +TIA +Kind Regards +Stefan +--Multipart_Tue__15_Mar_2005_17_23_45_+0200_iq9C8up/zs86qPmm +Content-Type: text/x-sh; name=create_loadfile.sh +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; filename=create_loadfile.sh + +#!/bin/bash + +for x in one two three four five six seven eight nine ten +do + for y in eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty + do + for z in `seq 1 100` + do + echo "insert into main (c_text,d_text) values ('${x}','${y}');" >> load.sql + echo "insert into a(id) values (currval('public.main_id_seq'::text));" >> load.sql + echo "insert into b(id) values (currval('public.main_id_seq'::text));" >> load.sql + echo "insert into e(id) values (currval('public.main_id_seq'::text));" >> load.sql + echo "insert into f(id) values (currval('public.main_id_seq'::text));" >> load.sql + echo "insert into g(id) values (currval('public.main_id_seq'::text));" >> load.sql + echo "insert into h(id) values (currval('public.main_id_seq'::text));" >> load.sql + done + done +done + +--Multipart_Tue__15_Mar_2005_17_23_45_+0200_iq9C8up/zs86qPmm +Content-Type: application/octet-stream; name=run_before_load__fast.sql +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename=run_before_load__fast.sql + +Q1JFQVRFIElOREVYIG1haW5fY19pZHggb24gbWFpbiAoY190ZXh0KTsKQ1JFQVRFIElOREVYIG1h +aW5fZF9pZHggb24gbWFpbiAoZF90ZXh0KTsKCmNvcHkgbWFpbihpZCxjX3RleHQsZF90ZXh0KSBm +cm9tIHN0ZGluOwoxCWVpZ2h0CWZvdXJ0ZWVuCjIJdGhyZWUJZWlnaHRlZW4KMwl0d28JdHdlbHZl +ClwuCnNlbGVjdCBzZXR2YWwoJ3B1YmxpYy5tYWluX2lkX3NlcSc6OnRleHQsbWF4KGlkKSkgZnJv +bSBtYWluOwo= + +--Multipart_Tue__15_Mar_2005_17_23_45_+0200_iq9C8up/zs86qPmm +Content-Type: application/octet-stream; name=run_before_load__slow.sql +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename=run_before_load__slow.sql + +Y29weSBtYWluKGlkLGNfdGV4dCxkX3RleHQpIGZyb20gc3RkaW47CjEJZWlnaHQJZm91cnRlZW4K +Mgl0aHJlZQllaWdodGVlbgozCXR3bwl0d2VsdmUKXC4KCkNSRUFURSBJTkRFWCBtYWluX2NfaWR4 +IG9uIG1haW4gKGNfdGV4dCk7CkNSRUFURSBJTkRFWCBtYWluX2RfaWR4IG9uIG1haW4gKGRfdGV4 +dCk7CnNlbGVjdCBzZXR2YWwoJ3B1YmxpYy5tYWluX2lkX3NlcSc6OnRleHQsbWF4KGlkKSkgZnJv +bSBtYWluOwo= + +--Multipart_Tue__15_Mar_2005_17_23_45_+0200_iq9C8up/zs86qPmm +Content-Type: application/octet-stream; name=slow_structure.sql +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename=slow_structure.sql + +LS0KLS0gUG9zdGdyZVNRTCBkYXRhYmFzZSBkdW1wCi0tCgpcY29ubmVjdCAtIHBvc3RncmVzCgpT +RVQgc2VhcmNoX3BhdGggPSBwdWJsaWMsIHBnX2NhdGFsb2c7CgotLQotLSBUT0MgZW50cnkgMiAo +T0lEIDIwODMxMjI3KQotLSBOYW1lOiBjOyBUeXBlOiBUQUJMRTsgU2NoZW1hOiBwdWJsaWM7IE93 +bmVyOiBwb3N0Z3JlcwotLQoKQ1JFQVRFIFRBQkxFIGMgKAogICAgY190ZXh0IHRleHQgTk9UIE5V +TEwsCiAgICBkZXNjciB0ZXh0Cik7CgoKLS0KLS0gVE9DIGVudHJ5IDMgKE9JRCAyMDgzMTIzNCkK +LS0gTmFtZTogZDsgVHlwZTogVEFCTEU7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMK +LS0KCkNSRUFURSBUQUJMRSBkICgKICAgIGRfdGV4dCB0ZXh0IE5PVCBOVUxMLAogICAgZGVzY3Ig +dGV4dAopOwoKCi0tCi0tIFRPQyBlbnRyeSA0IChPSUQgMjA4MzEyNjMpCi0tIE5hbWU6IG1haW47 +IFR5cGU6IFRBQkxFOyBTY2hlbWE6IHB1YmxpYzsgT3duZXI6IHBvc3RncmVzCi0tCgpDUkVBVEUg +VEFCTEUgbWFpbiAoCiAgICBpZCBzZXJpYWwgTk9UIE5VTEwsCiAgICBjX3RleHQgdGV4dCwKICAg +IGRfdGV4dCB0ZXh0Cik7CgoKLS0KLS0gVE9DIGVudHJ5IDUgKE9JRCAyMDgzMTI4MSkKLS0gTmFt +ZTogYTsgVHlwZTogVEFCTEU7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkNS +RUFURSBUQUJMRSBhICgKICAgIGFfaWQgc2VyaWFsIE5PVCBOVUxMLAogICAgaWQgaW50ZWdlcgop +OwoKCi0tCi0tIFRPQyBlbnRyeSA2IChPSUQgMjA4MzEyOTIpCi0tIE5hbWU6IGI7IFR5cGU6IFRB +QkxFOyBTY2hlbWE6IHB1YmxpYzsgT3duZXI6IHBvc3RncmVzCi0tCgpDUkVBVEUgVEFCTEUgYiAo +CiAgICBiX2lkIHNlcmlhbCBOT1QgTlVMTCwKICAgIGlkIGludGVnZXIKKTsKCgotLQotLSBUT0Mg +ZW50cnkgNyAoT0lEIDIwODMxMzAzKQotLSBOYW1lOiBlOyBUeXBlOiBUQUJMRTsgU2NoZW1hOiBw +dWJsaWM7IE93bmVyOiBwb3N0Z3JlcwotLQoKQ1JFQVRFIFRBQkxFIGUgKAogICAgZV9pZCBzZXJp +YWwgTk9UIE5VTEwsCiAgICBpZCBpbnRlZ2VyCik7CgoKLS0KLS0gVE9DIGVudHJ5IDggKE9JRCAy +MDgzMTMxNCkKLS0gTmFtZTogZjsgVHlwZTogVEFCTEU7IFNjaGVtYTogcHVibGljOyBPd25lcjog +cG9zdGdyZXMKLS0KCkNSRUFURSBUQUJMRSBmICgKICAgIGZfaWQgc2VyaWFsIE5PVCBOVUxMLAog +ICAgaWQgaW50ZWdlcgopOwoKCi0tCi0tIFRPQyBlbnRyeSA5IChPSUQgMjA4MzEzMjUpCi0tIE5h +bWU6IGc7IFR5cGU6IFRBQkxFOyBTY2hlbWE6IHB1YmxpYzsgT3duZXI6IHBvc3RncmVzCi0tCgpD +UkVBVEUgVEFCTEUgZyAoCiAgICBnX2lkIHNlcmlhbCBOT1QgTlVMTCwKICAgIGlkIGludGVnZXIK +KTsKCgotLQotLSBUT0MgZW50cnkgMTAgKE9JRCAyMDgzMTMzNikKLS0gTmFtZTogaDsgVHlwZTog +VEFCTEU7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkNSRUFURSBUQUJMRSBo +ICgKICAgIGhfaWQgc2VyaWFsIE5PVCBOVUxMLAogICAgaWQgaW50ZWdlcgopOwoKCi0tCi0tIERh +dGEgZm9yIFRPQyBlbnRyeSAyNyAoT0lEIDIwODMxMjI3KQotLSBOYW1lOiBjOyBUeXBlOiBUQUJM +RSBEQVRBOyBTY2hlbWE6IHB1YmxpYzsgT3duZXI6IHBvc3RncmVzCi0tCgpDT1BZIGMgKGNfdGV4 +dCwgZGVzY3IpIEZST00gc3RkaW47Cm9uZQlvbmUKdHdvCXR3bwp0aHJlZQl0aHJlZQpmb3VyCWZv +dXIKZml2ZQlmaXZlCnNpeAlzaXgKc2V2ZW4Jc2V2ZW4KZWlnaHQJZWlnaHQKbmluZQluaW5lCnRl +bgl0ZW4KXC4KCgotLQotLSBEYXRhIGZvciBUT0MgZW50cnkgMjggKE9JRCAyMDgzMTIzNCkKLS0g +TmFtZTogZDsgVHlwZTogVEFCTEUgREFUQTsgU2NoZW1hOiBwdWJsaWM7IE93bmVyOiBwb3N0Z3Jl +cwotLQoKQ09QWSBkIChkX3RleHQsIGRlc2NyKSBGUk9NIHN0ZGluOwplbGV2ZW4JZWxldmVuCnR3 +ZWx2ZQl0d2VsdmUKdGhpcnRlZW4JdGhpcnRlZW4KZm91cnRlZW4JZm91cnRlZW4KZmlmdGVlbglm +aWZ0ZWVuCnNpeHRlZW4Jc2lzdGVlbgpzZXZlbnRlZW4Jc2V2ZW50ZWVuCmVpZ2h0ZWVuCWVpZ2h0 +ZWVuCm5pbmV0ZWVuCW5pbmV0ZWVuCnR3ZW50eQl0d2VudHkKXC4KCgotLQotLSBEYXRhIGZvciBU +T0MgZW50cnkgMjkgKE9JRCAyMDgzMTI2MykKLS0gTmFtZTogbWFpbjsgVHlwZTogVEFCTEUgREFU +QTsgU2NoZW1hOiBwdWJsaWM7IE93bmVyOiBwb3N0Z3JlcwotLQoKQ09QWSBtYWluIChpZCwgY190 +ZXh0LCBkX3RleHQpIEZST00gc3RkaW47ClwuCgoKLS0KLS0gRGF0YSBmb3IgVE9DIGVudHJ5IDMw +IChPSUQgMjA4MzEyODEpCi0tIE5hbWU6IGE7IFR5cGU6IFRBQkxFIERBVEE7IFNjaGVtYTogcHVi +bGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkNPUFkgYSAoYV9pZCwgaWQpIEZST00gc3RkaW47Clwu +CgoKLS0KLS0gRGF0YSBmb3IgVE9DIGVudHJ5IDMxIChPSUQgMjA4MzEyOTIpCi0tIE5hbWU6IGI7 +IFR5cGU6IFRBQkxFIERBVEE7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkNP +UFkgYiAoYl9pZCwgaWQpIEZST00gc3RkaW47ClwuCgoKLS0KLS0gRGF0YSBmb3IgVE9DIGVudHJ5 +IDMyIChPSUQgMjA4MzEzMDMpCi0tIE5hbWU6IGU7IFR5cGU6IFRBQkxFIERBVEE7IFNjaGVtYTog +cHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkNPUFkgZSAoZV9pZCwgaWQpIEZST00gc3RkaW47 +ClwuCgoKLS0KLS0gRGF0YSBmb3IgVE9DIGVudHJ5IDMzIChPSUQgMjA4MzEzMTQpCi0tIE5hbWU6 +IGY7IFR5cGU6IFRBQkxFIERBVEE7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0K +CkNPUFkgZiAoZl9pZCwgaWQpIEZST00gc3RkaW47ClwuCgoKLS0KLS0gRGF0YSBmb3IgVE9DIGVu +dHJ5IDM0IChPSUQgMjA4MzEzMjUpCi0tIE5hbWU6IGc7IFR5cGU6IFRBQkxFIERBVEE7IFNjaGVt +YTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkNPUFkgZyAoZ19pZCwgaWQpIEZST00gc3Rk +aW47ClwuCgoKLS0KLS0gRGF0YSBmb3IgVE9DIGVudHJ5IDM1IChPSUQgMjA4MzEzMzYpCi0tIE5h +bWU6IGg7IFR5cGU6IFRBQkxFIERBVEE7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMK +LS0KCkNPUFkgaCAoaF9pZCwgaWQpIEZST00gc3RkaW47ClwuCgoKLS0KLS0gVE9DIGVudHJ5IDE4 +IChPSUQgMjA4MzEyMzIpCi0tIE5hbWU6IGNfcGtleTsgVHlwZTogQ09OU1RSQUlOVDsgU2NoZW1h +OiBwdWJsaWM7IE93bmVyOiBwb3N0Z3JlcwotLQoKQUxURVIgVEFCTEUgT05MWSBjCiAgICBBREQg +Q09OU1RSQUlOVCBjX3BrZXkgUFJJTUFSWSBLRVkgKGNfdGV4dCk7CgoKLS0KLS0gVE9DIGVudHJ5 +IDE5IChPSUQgMjA4MzEyMzkpCi0tIE5hbWU6IGRfcGtleTsgVHlwZTogQ09OU1RSQUlOVDsgU2No +ZW1hOiBwdWJsaWM7IE93bmVyOiBwb3N0Z3JlcwotLQoKQUxURVIgVEFCTEUgT05MWSBkCiAgICBB +REQgQ09OU1RSQUlOVCBkX3BrZXkgUFJJTUFSWSBLRVkgKGRfdGV4dCk7CgoKLS0KLS0gVE9DIGVu +dHJ5IDIwIChPSUQgMjA4MzEyNjkpCi0tIE5hbWU6IG1haW5fcGtleTsgVHlwZTogQ09OU1RSQUlO +VDsgU2NoZW1hOiBwdWJsaWM7IE93bmVyOiBwb3N0Z3JlcwotLQoKQUxURVIgVEFCTEUgT05MWSBt +YWluCiAgICBBREQgQ09OU1RSQUlOVCBtYWluX3BrZXkgUFJJTUFSWSBLRVkgKGlkKTsKCgotLQot +LSBUT0MgZW50cnkgMzYgKE9JRCAyMDgzMTI3MSkKLS0gTmFtZTogJDE7IFR5cGU6IENPTlNUUkFJ +TlQ7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkFMVEVSIFRBQkxFIE9OTFkg +bWFpbgogICAgQUREIENPTlNUUkFJTlQgIiQxIiBGT1JFSUdOIEtFWSAoY190ZXh0KSBSRUZFUkVO +Q0VTIGMoY190ZXh0KSBPTiBVUERBVEUgTk8gQUNUSU9OIE9OIERFTEVURSBOTyBBQ1RJT047CgoK +LS0KLS0gVE9DIGVudHJ5IDM3IChPSUQgMjA4MzEyNzUpCi0tIE5hbWU6ICQyOyBUeXBlOiBDT05T +VFJBSU5UOyBTY2hlbWE6IHB1YmxpYzsgT3duZXI6IHBvc3RncmVzCi0tCgpBTFRFUiBUQUJMRSBP +TkxZIG1haW4KICAgIEFERCBDT05TVFJBSU5UICIkMiIgRk9SRUlHTiBLRVkgKGRfdGV4dCkgUkVG +RVJFTkNFUyBkKGRfdGV4dCkgT04gVVBEQVRFIE5PIEFDVElPTiBPTiBERUxFVEUgTk8gQUNUSU9O +OwoKCi0tCi0tIFRPQyBlbnRyeSAyMSAoT0lEIDIwODMxMjg0KQotLSBOYW1lOiBhX3BrZXk7IFR5 +cGU6IENPTlNUUkFJTlQ7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkFMVEVS +IFRBQkxFIE9OTFkgYQogICAgQUREIENPTlNUUkFJTlQgYV9wa2V5IFBSSU1BUlkgS0VZIChhX2lk +KTsKCgotLQotLSBUT0MgZW50cnkgMzggKE9JRCAyMDgzMTI4NikKLS0gTmFtZTogJDE7IFR5cGU6 +IENPTlNUUkFJTlQ7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkFMVEVSIFRB +QkxFIE9OTFkgYQogICAgQUREIENPTlNUUkFJTlQgIiQxIiBGT1JFSUdOIEtFWSAoaWQpIFJFRkVS +RU5DRVMgbWFpbihpZCkgT04gVVBEQVRFIE5PIEFDVElPTiBPTiBERUxFVEUgTk8gQUNUSU9OOwoK +Ci0tCi0tIFRPQyBlbnRyeSAyMiAoT0lEIDIwODMxMjk1KQotLSBOYW1lOiBiX3BrZXk7IFR5cGU6 +IENPTlNUUkFJTlQ7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkFMVEVSIFRB +QkxFIE9OTFkgYgogICAgQUREIENPTlNUUkFJTlQgYl9wa2V5IFBSSU1BUlkgS0VZIChiX2lkKTsK +CgotLQotLSBUT0MgZW50cnkgMzkgKE9JRCAyMDgzMTI5NykKLS0gTmFtZTogJDE7IFR5cGU6IENP +TlNUUkFJTlQ7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkFMVEVSIFRBQkxF +IE9OTFkgYgogICAgQUREIENPTlNUUkFJTlQgIiQxIiBGT1JFSUdOIEtFWSAoaWQpIFJFRkVSRU5D +RVMgbWFpbihpZCkgT04gVVBEQVRFIE5PIEFDVElPTiBPTiBERUxFVEUgTk8gQUNUSU9OOwoKCi0t +Ci0tIFRPQyBlbnRyeSAyMyAoT0lEIDIwODMxMzA2KQotLSBOYW1lOiBlX3BrZXk7IFR5cGU6IENP +TlNUUkFJTlQ7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkFMVEVSIFRBQkxF +IE9OTFkgZQogICAgQUREIENPTlNUUkFJTlQgZV9wa2V5IFBSSU1BUlkgS0VZIChlX2lkKTsKCgot +LQotLSBUT0MgZW50cnkgNDAgKE9JRCAyMDgzMTMwOCkKLS0gTmFtZTogJDE7IFR5cGU6IENPTlNU +UkFJTlQ7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkFMVEVSIFRBQkxFIE9O +TFkgZQogICAgQUREIENPTlNUUkFJTlQgIiQxIiBGT1JFSUdOIEtFWSAoaWQpIFJFRkVSRU5DRVMg +bWFpbihpZCkgT04gVVBEQVRFIE5PIEFDVElPTiBPTiBERUxFVEUgTk8gQUNUSU9OOwoKCi0tCi0t +IFRPQyBlbnRyeSAyNCAoT0lEIDIwODMxMzE3KQotLSBOYW1lOiBmX3BrZXk7IFR5cGU6IENPTlNU +UkFJTlQ7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkFMVEVSIFRBQkxFIE9O +TFkgZgogICAgQUREIENPTlNUUkFJTlQgZl9wa2V5IFBSSU1BUlkgS0VZIChmX2lkKTsKCgotLQot +LSBUT0MgZW50cnkgNDEgKE9JRCAyMDgzMTMxOSkKLS0gTmFtZTogJDE7IFR5cGU6IENPTlNUUkFJ +TlQ7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkFMVEVSIFRBQkxFIE9OTFkg +ZgogICAgQUREIENPTlNUUkFJTlQgIiQxIiBGT1JFSUdOIEtFWSAoaWQpIFJFRkVSRU5DRVMgbWFp +bihpZCkgT04gVVBEQVRFIE5PIEFDVElPTiBPTiBERUxFVEUgTk8gQUNUSU9OOwoKCi0tCi0tIFRP +QyBlbnRyeSAyNSAoT0lEIDIwODMxMzI4KQotLSBOYW1lOiBnX3BrZXk7IFR5cGU6IENPTlNUUkFJ +TlQ7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkFMVEVSIFRBQkxFIE9OTFkg +ZwogICAgQUREIENPTlNUUkFJTlQgZ19wa2V5IFBSSU1BUlkgS0VZIChnX2lkKTsKCgotLQotLSBU +T0MgZW50cnkgNDIgKE9JRCAyMDgzMTMzMCkKLS0gTmFtZTogJDE7IFR5cGU6IENPTlNUUkFJTlQ7 +IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkFMVEVSIFRBQkxFIE9OTFkgZwog +ICAgQUREIENPTlNUUkFJTlQgIiQxIiBGT1JFSUdOIEtFWSAoaWQpIFJFRkVSRU5DRVMgbWFpbihp +ZCkgT04gVVBEQVRFIE5PIEFDVElPTiBPTiBERUxFVEUgTk8gQUNUSU9OOwoKCi0tCi0tIFRPQyBl +bnRyeSAyNiAoT0lEIDIwODMxMzM5KQotLSBOYW1lOiBoX3BrZXk7IFR5cGU6IENPTlNUUkFJTlQ7 +IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkFMVEVSIFRBQkxFIE9OTFkgaAog +ICAgQUREIENPTlNUUkFJTlQgaF9wa2V5IFBSSU1BUlkgS0VZIChoX2lkKTsKCgotLQotLSBUT0Mg +ZW50cnkgNDMgKE9JRCAyMDgzMTM0MSkKLS0gTmFtZTogJDE7IFR5cGU6IENPTlNUUkFJTlQ7IFNj +aGVtYTogcHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KCkFMVEVSIFRBQkxFIE9OTFkgaAogICAg +QUREIENPTlNUUkFJTlQgIiQxIiBGT1JFSUdOIEtFWSAoaWQpIFJFRkVSRU5DRVMgbWFpbihpZCkg +T04gVVBEQVRFIE5PIEFDVElPTiBPTiBERUxFVEUgTk8gQUNUSU9OOwoKCi0tCi0tIFRPQyBlbnRy +eSAxMSAoT0lEIDIwODMxMjYxKQotLSBOYW1lOiBtYWluX2lkX3NlcTsgVHlwZTogU0VRVUVOQ0Ug +U0VUOyBTY2hlbWE6IHB1YmxpYzsgT3duZXI6IHBvc3RncmVzCi0tCgpTRUxFQ1QgcGdfY2F0YWxv +Zy5zZXR2YWwgKCdtYWluX2lkX3NlcScsIDEsIGZhbHNlKTsKCgotLQotLSBUT0MgZW50cnkgMTIg +KE9JRCAyMDgzMTI3OSkKLS0gTmFtZTogYV9hX2lkX3NlcTsgVHlwZTogU0VRVUVOQ0UgU0VUOyBT +Y2hlbWE6IHB1YmxpYzsgT3duZXI6IHBvc3RncmVzCi0tCgpTRUxFQ1QgcGdfY2F0YWxvZy5zZXR2 +YWwgKCdhX2FfaWRfc2VxJywgMSwgZmFsc2UpOwoKCi0tCi0tIFRPQyBlbnRyeSAxMyAoT0lEIDIw +ODMxMjkwKQotLSBOYW1lOiBiX2JfaWRfc2VxOyBUeXBlOiBTRVFVRU5DRSBTRVQ7IFNjaGVtYTog +cHVibGljOyBPd25lcjogcG9zdGdyZXMKLS0KClNFTEVDVCBwZ19jYXRhbG9nLnNldHZhbCAoJ2Jf +Yl9pZF9zZXEnLCAxLCBmYWxzZSk7CgoKLS0KLS0gVE9DIGVudHJ5IDE0IChPSUQgMjA4MzEzMDEp +Ci0tIE5hbWU6IGVfZV9pZF9zZXE7IFR5cGU6IFNFUVVFTkNFIFNFVDsgU2NoZW1hOiBwdWJsaWM7 +IE93bmVyOiBwb3N0Z3JlcwotLQoKU0VMRUNUIHBnX2NhdGFsb2cuc2V0dmFsICgnZV9lX2lkX3Nl +cScsIDEsIGZhbHNlKTsKCgotLQotLSBUT0MgZW50cnkgMTUgKE9JRCAyMDgzMTMxMikKLS0gTmFt +ZTogZl9mX2lkX3NlcTsgVHlwZTogU0VRVUVOQ0UgU0VUOyBTY2hlbWE6IHB1YmxpYzsgT3duZXI6 +IHBvc3RncmVzCi0tCgpTRUxFQ1QgcGdfY2F0YWxvZy5zZXR2YWwgKCdmX2ZfaWRfc2VxJywgMSwg +ZmFsc2UpOwoKCi0tCi0tIFRPQyBlbnRyeSAxNiAoT0lEIDIwODMxMzIzKQotLSBOYW1lOiBnX2df +aWRfc2VxOyBUeXBlOiBTRVFVRU5DRSBTRVQ7IFNjaGVtYTogcHVibGljOyBPd25lcjogcG9zdGdy +ZXMKLS0KClNFTEVDVCBwZ19jYXRhbG9nLnNldHZhbCAoJ2dfZ19pZF9zZXEnLCAxLCBmYWxzZSk7 +CgoKLS0KLS0gVE9DIGVudHJ5IDE3IChPSUQgMjA4MzEzMzQpCi0tIE5hbWU6IGhfaF9pZF9zZXE7 +IFR5cGU6IFNFUVVFTkNFIFNFVDsgU2NoZW1hOiBwdWJsaWM7IE93bmVyOiBwb3N0Z3JlcwotLQoK +U0VMRUNUIHBnX2NhdGFsb2cuc2V0dmFsICgnaF9oX2lkX3NlcScsIDEsIGZhbHNlKTsKCgo= + +--Multipart_Tue__15_Mar_2005_17_23_45_+0200_iq9C8up/zs86qPmm-- + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:47:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E6ADA568B4 + for ; + Tue, 15 Mar 2005 16:18:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91078-03 + for ; + Tue, 15 Mar 2005 16:18:40 +0000 (GMT) +Received: from ivimey.org (i-194-106-52-201.freedom2surf.net [194.106.52.201]) + by svr1.postgresql.org (Postfix) with ESMTP id B4FC2568C4 + for ; + Tue, 15 Mar 2005 16:18:38 +0000 (GMT) +Received: from gandalf.ivimey.org ([192.168.0.8] helo=gandalf) + by gatemaster.ivimey.org with esmtp (Exim 4.44) + id 1DBEkB-0002FF-7b; Tue, 15 Mar 2005 16:18:23 +0000 +From: "Ruth Ivimey-Cook" +To: "'Guy'" , "'Michael Tokarev'" , + "'Arshavir Grigorian'" +Cc: , +Subject: Effect of Stripe Size (was Postgres on RAID5) +Date: Tue, 15 Mar 2005 16:17:55 -0000 +Organization: At Home +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +In-Reply-To: <200503142349.j2ENnG510033@www.watkins-home.com> +Thread-Index: AcUo6T0/QXzy6oicQJ+4yF22n8922QABNl2wACLx38A= +Message-Id: <20050315161838.B4FC2568C4@svr1.postgresql.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.754 tagged_above=0 required=5 + tests=FORGED_RCVD_HELO, MSGID_FROM_MTA_ID +X-Spam-Level: * +X-Archive-Number: 200503/402 +X-Sequence-Number: 11107 + +Folks, + +> You said: +> "If your write size is smaller than chunk_size*N (N = number +> of data blocks in a stripe), in order to calculate correct +> parity you have to read data from the remaining drives." +> +> Neil explained it in this message: +> http://marc.theaimsgroup.com/?l=linux-raid&m=108682190730593&w=2 + +Having read that and the recent posts: + +Has anyone done any performance checks on the md code to determine what, if +any, effect the stripe size has on performance? One might suppose the variables +would be stripe size, file size and read vs write. Possibly number of drives in +array, too. + +Reason for asking: + +When I set up my raid5 array, I chose a stripe of 256K, on the grounds that a +large number of the files on the drive are multi-megabytes (fairly evenly in +the 20MB - 100MB range) and I supposed that a large stripe would speed things +up for those files. Was I right? + +Regards, + +Ruth + + + +From pgsql-hackers-owner@postgresql.org Mon Mar 21 03:09:39 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E761568D9 + for ; + Tue, 15 Mar 2005 17:17:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09396-06 + for ; + Tue, 15 Mar 2005 17:17:34 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 137D0568D6 + for ; + Tue, 15 Mar 2005 17:17:33 +0000 (GMT) +Received: (qmail 2433 invoked from network); 15 Mar 2005 18:17:37 +0100 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 15 Mar 2005 18:17:37 +0100 +To: "Tom Lane" , pgsql-hackers@postgresql.org +Cc: =?iso-8859-15?B?TWlyb3NsYXYgpnVsYw==?= , + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Avoiding tuple construction/deconstruction during + joining +References: <42345D24.8070104@startnet.cz> <14577.1110821062@sss.pgh.pa.us> +Message-ID: +Date: Tue, 15 Mar 2005 18:17:31 +0100 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <14577.1110821062@sss.pgh.pa.us> +User-Agent: Opera M2/7.54 (Linux, build 955) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/722 +X-Sequence-Number: 65524 + + + I have asked him for the data and played with his queries, and obtained +massive speedups with the following queries : + +http://boutiquenumerique.com/pf/miroslav/query.sql +http://boutiquenumerique.com/pf/miroslav/query2.sql +http://boutiquenumerique.com/pf/miroslav/materialize.sql + + Note that my optimized version of the Big Joins is not much faster that +the materialized view without index (hash joins are damn fast in postgres) +but of course using an index... + +From pgsql-hackers-owner@postgresql.org Mon Mar 21 03:11:13 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C0ED5568B7 + for ; + Tue, 15 Mar 2005 19:53:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92330-09 + for ; + Tue, 15 Mar 2005 19:53:15 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id C9408568A5 + for ; + Tue, 15 Mar 2005 19:53:14 +0000 (GMT) +Received: (qmail 9887 invoked from network); 15 Mar 2005 20:53:19 +0100 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 15 Mar 2005 20:53:19 +0100 +Date: Tue, 15 Mar 2005 20:53:13 +0100 +To: "Tom Lane" , pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] Avoiding tuple construction/deconstruction during + joining +Cc: =?iso-8859-15?B?TWlyb3NsYXYgpnVsYw==?= , + pgsql-performance@postgresql.org +References: <42345D24.8070104@startnet.cz> <14577.1110821062@sss.pgh.pa.us> +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <14577.1110821062@sss.pgh.pa.us> +User-Agent: Opera M2/7.54 (Linux, build 955) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/723 +X-Sequence-Number: 65525 + + + On my machine (Laptop with Pentium-M 1.6 GHz and 512MB DDR333) I get the +following timings : + + Big Joins Query will all the fields and no order by (I just put a SELECT +* in the first table) yielding about 6k rows : + => 12136.338 ms + + Replacing the SELECT * from the table with many fields by just a SELECT +of the foreign key columns : + => 1874.612 ms + + I felt like playing a bit so I implemented a hash join in python +(download the file, it works on Miroslav's data) : + All timings do not include time to fetch the data from the database. +Fetching all the tables takes about 1.1 secs. + + * With something that looks like the current implementation (copying +tuples around) and fetching all the fields from the big table : + => Fetching all the tables : 1.1 secs. + => Joining : 4.3 secs + + * Fetching only the integer fields + => Fetching all the tables : 0.4 secs. + => Joining : 1.7 secs + + * A smarter join which copies nothing and updates the rows as they are +processed, adding fields : + => Fetching all the tables : 1.1 secs. + => Joining : 0.4 secs + With the just-in-time compiler activated, it goes down to about 0.25 +seconds. + + First thing, this confirms what Tom said. + It also means that doing this query in the application can be a lot +faster than doing it in postgres including fetching all of the tables. +There's a problem somewhere ! It should be the other way around ! The +python mappings (dictionaries : { key : value } ) are optimized like crazy +but they store column names for each row. And it's a dynamic script +language ! Argh. + + Note : run the program like this : + +python test.py |less -S + + So that the time spent scrolling your terminal does not spoil the +measurements. + +Download test program : +http://boutiquenumerique.com/pf/miroslav/test.py + +From pgsql-performance-owner@postgresql.org Tue Mar 15 21:21:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 89A6F563EA + for ; + Tue, 15 Mar 2005 21:21:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27260-02 + for ; + Tue, 15 Mar 2005 21:21:13 +0000 (GMT) +Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) + by svr1.postgresql.org (Postfix) with ESMTP id 13E0C56391 + for ; + Tue, 15 Mar 2005 21:21:12 +0000 (GMT) +Received: from [192.168.1.100] ([24.202.23.128]) by + VL-MO-MR007.ip.videotron.ca + (iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep 8 2003)) + with ESMTP id <0IDE0092WWNCMU@VL-MO-MR007.ip.videotron.ca> for + pgsql-performance@postgresql.org; Tue, 15 Mar 2005 16:21:13 -0500 (EST) +Date: Tue, 15 Mar 2005 16:24:17 -0500 +From: David Gagnon +Subject: Performance problem on delete from for 10k rows. May takes 20 minutes + through JDBC interface +To: pgsql-performance@postgresql.org +Message-id: <42375281.9090102@siunik.com> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.015 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/306 +X-Sequence-Number: 11011 + +Hi all, + + Il get this strange problem when deleting rows from a Java program. +Sometime (For what I noticed it's not all the time) the server take +almost forever to delete rows from table. + +Here It takes 20 minutes to delete the IC table. + +Java logs: +INFO [Thread-386] (Dao.java:227) 2005-03-15 15:38:34,754 : Execution +SQL file: resources/ukConfiguration/reset_application.sql +DELETE FROM YR +INFO [Thread-386] (Dao.java:227) 2005-03-15 15:38:34,964 : Execution +SQL file: resources/inventory/item/reset_application.sql +DELETE FROM IC +INFO [Thread-386] (Dao.java:227) 2005-03-15 15:58:45,072 : Execution +SQL file: resources/ukResource/reset_application.sql +DELETE FROM RA + + + I get this problem on my dev (Windows/7.4/Cygwin) environment. But now +I see that it's also have this problem on my production env. Yes I +tought I was maybe just a cygwin/Windows problem .. apparently not :-(((( + +On my dev I can see the Postgresql related process running at almost 50% +of CPU usage for all the time. So I suppose it's something inside +Postgresql. I rememeber having tried to delete the content of my table +(IC) from PgAdminIII and I took couples of seconds!!! Not minutes. So +the process don't jam but take time .. any Idea what postgresql is doing +during this time?? + +If you have any idea on what the problem could be... I really appreciate +it. + +Thanks for any help! +/David + + + + + +From pgsql-performance-owner@postgresql.org Tue Mar 15 21:47:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9644F5581F + for ; + Tue, 15 Mar 2005 21:47:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33487-06 + for ; + Tue, 15 Mar 2005 21:47:36 +0000 (GMT) +Received: from lakermmtao08.cox.net (lakermmtao08.cox.net [68.230.240.31]) + by svr1.postgresql.org (Postfix) with ESMTP id B0FDE54EBA + for ; + Tue, 15 Mar 2005 21:47:34 +0000 (GMT) +Received: from [192.168.0.17] (really [24.170.194.78]) by lakermmtao08.cox.net + (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP + id <20050315214736.OWFV18351.lakermmtao08.cox.net@[192.168.0.17]>; + Tue, 15 Mar 2005 16:47:36 -0500 +From: Robert Treat +To: Richard Huxton +Subject: Re: One tuple per transaction +Date: Tue, 15 Mar 2005 16:52:30 -0500 +User-Agent: KMail/1.6.2 +Cc: Tambet Matiisen , + pgsql-performance@postgresql.org +References: + <4236ACE5.1040004@archonet.com> +In-Reply-To: <4236ACE5.1040004@archonet.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200503151652.30266.xzilla@users.sourceforge.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/307 +X-Sequence-Number: 11012 + +On Tuesday 15 March 2005 04:37, Richard Huxton wrote: +> Tambet Matiisen wrote: +> > Now, if typical inserts into your most active table occur in batches of +> > 3 rows, in one transaction, then row count for this table is updated 3 +> > times during transaction. 3 updates generate 3 tuples, while 2 of them +> > are dead from the very start. You effectively commit 2 useless tuples. +> > After millions of inserts you end up with rowcounts table having 2/3 of +> > dead tuples and queries start to slow down. +> > +> > Current solution is to vacuum often. My proposal was to create new tuple +> > only with first update. The next updates in the same transaction would +> > update the existing tuple, not create a new. +> +> How do you roll back to a savepoint with this model? +> + +You can't, but you could add the caveat to just do this auto-reuse within any +given nested transaction. Then as long as you aren't using savepoints you +get to reclaim all the space/ + + On a similar note I was just wondering if it would be possible to mark any of +these dead tuples as ready to be reused at transaction commit time, since we +know that they are dead to any and all other transactions currently going on. +This would save you from having to vacuum to get the tuples marked ready for +reuse. In the above scenario this could be a win, whether it would be +overall is hard to say. + +-- +Robert Treat +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + +From pgsql-performance-owner@postgresql.org Tue Mar 15 22:44:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E513056694 + for ; + Tue, 15 Mar 2005 22:44:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49412-05 + for ; + Tue, 15 Mar 2005 22:44:10 +0000 (GMT) +Received: from linda-1.paradise.net.nz (bm-1a.paradise.net.nz [202.0.58.20]) + by svr1.postgresql.org (Postfix) with ESMTP id A5B6D5661E + for ; + Tue, 15 Mar 2005 22:44:06 +0000 (GMT) +Received: from smtp-3.paradise.net.nz (smtp-3a.paradise.net.nz [202.0.32.196]) + by linda-1.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0IDF00B590HJK3@linda-1.paradise.net.nz> for + pgsql-performance@postgresql.org; Wed, 16 Mar 2005 11:44:08 +1300 (NZDT) +Received: from [192.168.1.11] (218-101-14-18.paradise.net.nz [218.101.14.18]) + by smtp-3.paradise.net.nz (Postfix) with ESMTP id 201A8ADFDF; Wed, + 16 Mar 2005 11:44:07 +1300 (NZDT) +Date: Wed, 16 Mar 2005 11:44:06 +1300 +From: Mark Kirkwood +Subject: Re: Changing the random_page_cost default (was: +In-reply-to: <6320.1110900176@sss.pgh.pa.us> +To: Tom Lane +Cc: Greg Sabino Mullane , pgsql-performance@postgresql.org +Message-id: <42376536.10500@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8b) Gecko/20050301 +References: + <6320.1110900176@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.145 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/308 +X-Sequence-Number: 11013 + +Tom Lane wrote: +> "Greg Sabino Mullane" writes: +> +>>N.B. My own personal starting default is 2, but I thought 3 was a nice +>>middle ground more likely to reach consensus here. :) +> +> +> Your argument seems to be "this produces nice results for me", not +> "I have done experiments to measure the actual value of the parameter +> and it is X". I *have* done experiments of that sort, which is where +> the default of 4 came from. I remain of the opinion that reducing +> random_page_cost is a band-aid that compensates (but only partially) +> for problems elsewhere. We can see that it's not a real fix from +> the not-infrequent report that people have to reduce random_page_cost +> below 1.0 to get results anywhere near local reality. That doesn't say +> that the parameter value is wrong, it says that the model it's feeding +> into is wrong. +> + +I would like to second that. A while back I performed a number of +experiments on differing hardware and came to the conclusion that *real* +random_page_cost was often higher than 4 (like 10-15 for multi-disk raid + systems). + +However I have frequently adjusted Pg's random_page_cost to be less than +4 - if it helped queries perform better. + +So yes, it looks like the model is the issue - not the value of the +parameter! + +regards + +Mark + + +From pgsql-performance-owner@postgresql.org Tue Mar 15 23:38:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BA725566F1 + for ; + Tue, 15 Mar 2005 23:38:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66508-09 + for ; + Tue, 15 Mar 2005 23:38:36 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id B08EC566F0 + for ; + Tue, 15 Mar 2005 23:38:35 +0000 (GMT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j2FNcZH2021303 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Tue, 15 Mar 2005 16:38:37 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j2FNcYSt068337; + Tue, 15 Mar 2005 16:38:34 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j2FNcYLe068336; + Tue, 15 Mar 2005 16:38:34 -0700 (MST) (envelope-from mfuhr) +Date: Tue, 15 Mar 2005 16:38:34 -0700 +From: Michael Fuhr +To: David Gagnon +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problem on delete from for 10k rows. May takes 20 + minutes through JDBC interface +Message-ID: <20050315233834.GA68209@winnie.fuhr.org> +References: <42375281.9090102@siunik.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <42375281.9090102@siunik.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/309 +X-Sequence-Number: 11014 + +On Tue, Mar 15, 2005 at 04:24:17PM -0500, David Gagnon wrote: + +> Il get this strange problem when deleting rows from a Java program. +> Sometime (For what I noticed it's not all the time) the server take +> almost forever to delete rows from table. + +Do other tables have foreign key references to the table you're +deleting from? If so, are there indexes on the foreign key columns? + +Do you have triggers or rules on the table? + +Have you queried pg_locks during the long-lasting deletes to see +if the deleting transaction is waiting for a lock on something? + +> I rememeber having tried to delete the content of my table (IC) from +> PgAdminIII and I took couples of seconds!!! Not minutes. + +How many records did you delete in this case? If there are foreign +key references, how many records were in the referencing tables? +How repeatable is the disparity in delete time? A single test case +might have been done under different conditions, so it might not +mean much. No offense intended, but "I remember" doesn't carry as +much weight as a documented example. + +-- +Michael Fuhr +http://www.fuhr.org/~mfuhr/ + +From pgsql-performance-owner@postgresql.org Tue Mar 15 23:41:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E26856796 + for ; + Tue, 15 Mar 2005 23:41:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67038-06 + for ; + Tue, 15 Mar 2005 23:41:23 +0000 (GMT) +Received: from gizmo03ps.bigpond.com (gizmo03ps.bigpond.com [144.140.71.13]) + by svr1.postgresql.org (Postfix) with SMTP id 3101956795 + for ; + Tue, 15 Mar 2005 23:41:20 +0000 (GMT) +Received: (qmail 10109 invoked from network); 15 Mar 2005 23:41:20 -0000 +Received: from unknown (HELO psmam05.bigpond.com) (144.135.25.81) + by gizmo03ps.bigpond.com with SMTP; 15 Mar 2005 23:41:20 -0000 +Received: from cpe-203-45-203-73.qld.bigpond.net.au ([203.45.203.73]) by + psmam05.bigpond.com(MAM REL_3_4_2a 107/8150853) with SMTP id + 8150853; Wed, 16 Mar 2005 09:41:20 +1000 +Message-ID: <42377293.1010801@bigpond.net.au> +Date: Wed, 16 Mar 2005 09:41:07 +1000 +From: David Brown +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gregory Stark +Subject: Re: cpu_tuple_cost +References: <87psy1mq66.fsf@stark.xeocode.com> +In-Reply-To: <87psy1mq66.fsf@stark.xeocode.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.735 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_WHOIS +X-Spam-Level: +X-Archive-Number: 200503/310 +X-Sequence-Number: 11015 + +Gregory Stark wrote: + +>The "this day and age" argument isn't very convincing. Hard drive capacity +>growth has far outstripped hard drive seek time and bandwidth improvements. +>Random access has more penalty than ever. +> +> +In point of fact, there haven't been noticeable seek time improvements +for years. Transfer rates, on the other hand, have gone through the roof. + +Which is why I would question the published tuning advice that +recommends lowering it to 2 for arrays. Arrays increase the effective +transfer rate more than they reduce random access times. Dropping from 4 +to 2 would reflect going from a typical single 7200rpm ATA drive to a +15000rpm SCSI drive, but striping will move it back up again - probably +even higher than 4 with a big array (at a guess, perhaps the +relationship might be approximated as a square root after allowing for +the array type?). + +With default settings, I've seen the planner pick the wrong index unless +random_page_cost was set to 2. But in testing on an ATA drive, I +achieved slightly better plan costings by increasing cpu_tuple_cost +(relative to cpu_index_tuple_cost - by default it's only a factor of 10) +and actually *raising* random_page_cost to 5! So why pick on one +parameter? It's all going to vary according to the query and the data. + +I agree with Tom 100%. Pulling levers on a wonky model is no solution. + +From pgsql-performance-owner@postgresql.org Tue Mar 15 23:51:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 83F1E56445 + for ; + Tue, 15 Mar 2005 23:51:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70398-04 + for ; + Tue, 15 Mar 2005 23:51:18 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 210FA563FB + for ; + Tue, 15 Mar 2005 23:51:17 +0000 (GMT) +Received: from dyn-70-66.tor.dsl.tht.net (dyn-70-66.tor.dsl.tht.net + [134.22.70.66]) by tht.net (Postfix) with ESMTP + id 8931276A8A; Tue, 15 Mar 2005 18:51:18 -0500 (EST) +Subject: Re: Performance problem on delete from for 10k rows. +From: Rod Taylor +To: David Gagnon +Cc: pgsql-performance@postgresql.org +In-Reply-To: <42375281.9090102@siunik.com> +References: <42375281.9090102@siunik.com> +Content-Type: text/plain +Date: Tue, 15 Mar 2005 18:50:27 -0500 +Message-Id: <1110930627.1132.196.camel@home> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.0 FreeBSD GNOME Team Port +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/311 +X-Sequence-Number: 11016 + +> I get this problem on my dev (Windows/7.4/Cygwin) environment. But now +> I see that it's also have this problem on my production env. Yes I +> tought I was maybe just a cygwin/Windows problem .. apparently not :-(((( + +Care to try again with logging enabled on the PostgreSQL side within the +development environment? + +log_statement = true +log_duration = true +log_connections = on + +Then run it via Java and from pgAdminIII and send us the two log +snippets as attachments? + +Thanks. +-- + + +From pgsql-performance-owner@postgresql.org Tue Mar 15 23:51:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 195A8566D7 + for ; + Tue, 15 Mar 2005 23:51:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69811-04 + for ; + Tue, 15 Mar 2005 23:51:27 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4AA23566ED + for ; + Tue, 15 Mar 2005 23:51:26 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2FNpJWf000819; + Tue, 15 Mar 2005 18:51:19 -0500 (EST) +To: Robert Treat +Cc: Richard Huxton , Tambet Matiisen , + pgsql-performance@postgresql.org +Subject: Re: One tuple per transaction +In-reply-to: <200503151652.30266.xzilla@users.sourceforge.net> +References: + <4236ACE5.1040004@archonet.com> + <200503151652.30266.xzilla@users.sourceforge.net> +Comments: In-reply-to Robert Treat + message dated "Tue, 15 Mar 2005 16:52:30 -0500" +Date: Tue, 15 Mar 2005 18:51:19 -0500 +Message-ID: <818.1110930679@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/312 +X-Sequence-Number: 11017 + +Robert Treat writes: +> On a similar note I was just wondering if it would be possible to +> mark any of these dead tuples as ready to be reused at transaction +> commit time, since we know that they are dead to any and all other +> transactions currently going on. + +I believe VACUUM already knows that xmin = xmax implies the tuple +is dead to everyone. + +> This would save you from having to vacuum to get the tuples marked +> ready for reuse. + +No; you forgot about reclaiming associated index entries. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 16 00:06:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A00E6563FB + for ; + Wed, 16 Mar 2005 00:06:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73575-07 + for ; + Wed, 16 Mar 2005 00:06:45 +0000 (GMT) +Received: from sunsite.dcc.uchile.cl (sunsite.dcc.uchile.cl [192.80.24.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C173A564B6 + for ; + Wed, 16 Mar 2005 00:06:43 +0000 (GMT) +Received: from anakena.dcc.uchile.cl (anakena [192.80.24.6]) + by sunsite.dcc.uchile.cl (8.12.11/8.12.11) with ESMTP id j2G06Tjq019309; + Tue, 15 Mar 2005 20:06:29 -0400 (CLT) +Received: by anakena.dcc.uchile.cl (Postfix, from userid 4151) + id D2FD15236D; Tue, 15 Mar 2005 20:06:29 -0400 (CLT) +Date: Tue, 15 Mar 2005 20:06:29 -0400 +From: Alvaro Herrera +To: Tom Lane +Cc: Robert Treat , + Richard Huxton , Tambet Matiisen , + pgsql-performance@postgresql.org +Subject: Re: One tuple per transaction +Message-ID: <20050316000629.GB17051@dcc.uchile.cl> +References: + <4236ACE5.1040004@archonet.com> + <200503151652.30266.xzilla@users.sourceforge.net> + <818.1110930679@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: <818.1110930679@sss.pgh.pa.us> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.35 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/313 +X-Sequence-Number: 11018 + +On Tue, Mar 15, 2005 at 06:51:19PM -0500, Tom Lane wrote: +> Robert Treat writes: +> > On a similar note I was just wondering if it would be possible to +> > mark any of these dead tuples as ready to be reused at transaction +> > commit time, since we know that they are dead to any and all other +> > transactions currently going on. +> +> I believe VACUUM already knows that xmin = xmax implies the tuple +> is dead to everyone. + +Huh, that is too simplistic in a subtransactions' world, isn't it? + +One way to solve this would be that a transaction that kills a tuple +checks whether it was created by itself (not necessarily the same Xid), +and somehow report it to the FSM right away. + +That'd mean physically moving a lot of tuples in the page, so ISTM it's +too expensive an "optimization." Oh, and also delete the tuple from +indexes. + +-- +Alvaro Herrera () +"Vivir y dejar de vivir son soluciones imaginarias. +La existencia est� en otra parte" (Andre Breton) + +From pgsql-performance-owner@postgresql.org Wed Mar 16 01:03:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A81E5655F + for ; + Wed, 16 Mar 2005 01:03:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88213-05 + for ; + Wed, 16 Mar 2005 01:03:08 +0000 (GMT) +Received: from biglumber.com (biglumber.com [207.228.252.42]) + by svr1.postgresql.org (Postfix) with SMTP id DA4335651E + for ; + Wed, 16 Mar 2005 01:03:06 +0000 (GMT) +Received: (qmail 25992 invoked from network); 16 Mar 2005 01:03:10 -0000 +Received: from unknown (HELO localhost) (207.228.252.42) + by 0 with SMTP; 16 Mar 2005 01:03:10 -0000 +From: "Greg Sabino Mullane" +To: pgsql-performance@postgresql.org +Subject: Re: Changing the random_page_cost default (was: cpu_tuple_cost) +X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 +X-Request-PGP: + http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 +In-Reply-To: <6320.1110900176@sss.pgh.pa.us> +Date: Wed, 16 Mar 2005 01:03:10 -0000 +X-Mailer: JoyMail 1.48 +Message-ID: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.156 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/314 +X-Sequence-Number: 11019 + + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + + +> Your argument seems to be "this produces nice results for me", not +> "I have done experiments to measure the actual value of the parameter +> and it is X". I *have* done experiments of that sort, which is where +> the default of 4 came from. I remain of the opinion that reducing +> random_page_cost is a band-aid that compensates (but only partially) +> for problems elsewhere. We can see that it's not a real fix from +> the not-infrequent report that people have to reduce random_page_cost +> below 1.0 to get results anywhere near local reality. That doesn't say +> that the parameter value is wrong, it says that the model it's feeding +> into is wrong. + +Good points: allow me to rephrase my question then: + +When I install a new version of PostgreSQL and start testing my +applications, one of the most common problems is that many of my queries +are not hitting an index. I typically drop random_page_cost to 2 or +lower and this speeds things very significantly. How can I determine a +better way to speed up my queries, and why would this be advantageous +over simply dropping random_page_cost? How can I use my particular +situation to help develop a better model and perhaps make the defaults +work better for my queries and other people with databaes like mine. +(fairly simple schema, not too large (~2 Gig total), SCSI, medium to +high complexity queries, good amount of RAM available)? + +- -- +Greg Sabino Mullane greg@turnstep.com +PGP Key: 0x14964AC8 200503150600 +http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 + +-----BEGIN PGP SIGNATURE----- + +iD8DBQFCNsCbvJuQZxSWSsgRAs0sAJwLFsGApzfYNV5jPL0gGVW5BH37hwCfRSW8 +ed3sLnMg1UOTgN3oL9JSIFo= +=cZIe +-----END PGP SIGNATURE----- + + + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:49:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C31E156644 + for ; + Wed, 16 Mar 2005 02:11:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79798-01 + for ; + Wed, 16 Mar 2005 02:10:55 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 06F5C5664C + for ; + Wed, 16 Mar 2005 02:10:55 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.13.1/8.13.1) with ESMTP id j2G2Apf0080441 + for ; Wed, 16 Mar 2005 02:10:51 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.13.1/8.13.1/Submit) id j2G1mxdY075215 + for pgsql-performance@postgresql.org; Wed, 16 Mar 2005 01:48:59 GMT + (envelope-from news) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: interesting benchmarks PG/Firebird Linux/Windows fsync/nofsync +Date: Wed, 16 Mar 2005 09:44:18 +0800 +Organization: Hub.Org Networking Services +Lines: 13 +Message-ID: +References: <1110894247.4441.49.camel@dell> + <200503151355.j2FDtYi13867@candle.pha.pa.us> +Reply-To: "Qingqing Zhou" +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/405 +X-Sequence-Number: 11110 + +"Bruce Momjian" writes +> +> Yes, we now enable FILE_FLAG_WRITE_THROUGH on Win32 for open_sync and I +> am about to open a discussion whether this should be the default for +> Win32, and whether we should backpatch this to 8.0.X. + +Just a short msg: Oracle/SQL Server enable it as default in win32 *no matter +what* ... + +Regards, +Qingqing + + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 04:45:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D5EFC56839 + for ; + Wed, 16 Mar 2005 04:45:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08037-03 + for ; + Wed, 16 Mar 2005 04:44:59 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 207895656D + for ; + Wed, 16 Mar 2005 04:44:57 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2G4iUGn002285; + Tue, 15 Mar 2005 23:44:31 -0500 (EST) +To: Alvaro Herrera +Cc: Robert Treat , + Richard Huxton , Tambet Matiisen , + pgsql-performance@postgresql.org +Subject: Re: One tuple per transaction +In-reply-to: <20050316000629.GB17051@dcc.uchile.cl> +References: + <4236ACE5.1040004@archonet.com> + <200503151652.30266.xzilla@users.sourceforge.net> + <818.1110930679@sss.pgh.pa.us> + <20050316000629.GB17051@dcc.uchile.cl> +Comments: In-reply-to Alvaro Herrera + message dated "Tue, 15 Mar 2005 20:06:29 -0400" +Date: Tue, 15 Mar 2005 23:44:30 -0500 +Message-ID: <2284.1110948270@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/315 +X-Sequence-Number: 11020 + +Alvaro Herrera writes: +> On Tue, Mar 15, 2005 at 06:51:19PM -0500, Tom Lane wrote: +>> I believe VACUUM already knows that xmin = xmax implies the tuple +>> is dead to everyone. + +> Huh, that is too simplistic in a subtransactions' world, isn't it? + +Well, it's still correct as a fast-path check. There are extensions +you could imagine making ... but offhand I agree that it's not worth +the trouble. Maybe in a few years when everyone and his sister is +using subtransactions constantly, we'll feel a need to optimize these +cases. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 16 07:24:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 45A1B56646 + for ; + Wed, 16 Mar 2005 07:24:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68235-02 + for ; + Wed, 16 Mar 2005 07:24:05 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 831D95665B + for ; + Wed, 16 Mar 2005 07:24:01 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DBSsd-0007Jt-00; Wed, 16 Mar 2005 02:23:48 -0500 +To: David Brown +Cc: Gregory Stark +Subject: Re: cpu_tuple_cost +References: <87psy1mq66.fsf@stark.xeocode.com> + <42377293.1010801@bigpond.net.au> +In-Reply-To: <42377293.1010801@bigpond.net.au> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 16 Mar 2005 02:23:47 -0500 +Message-ID: <87acp4kq9o.fsf@stark.xeocode.com> +Lines: 58 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.019 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/316 +X-Sequence-Number: 11021 + + +David Brown writes: + +> Gregory Stark wrote: +> +> >The "this day and age" argument isn't very convincing. Hard drive capacity +> >growth has far outstripped hard drive seek time and bandwidth improvements. +> >Random access has more penalty than ever. +> +> In point of fact, there haven't been noticeable seek time improvements for +> years. Transfer rates, on the other hand, have gone through the roof. + +Er, yeah. I stated it wrong. The real ratio here is between seek time and +throughput. + +Typical 7200RPM drives have average seek times are in the area of 10ms. +Typical sustained transfer rates are in the range of 40Mb/s. Postgres reads +8kB blocks at a time. + +So 800kB/s for random access reads. And 40Mb/s for sequential reads. That's a +factor of 49. I don't think anyone wants random_page_cost to be set to 50 +though. + +For a high end 15k drive I see average seek times get as low as 3ms. And +sustained transfer rates get as high as 100Mb/s. So about 2.7Mb/s for random +access reads or about a random_page_cost of 37. Still pretty extreme. + +So what's going on with the empirically derived value of 4? Perhaps this is +because even though Postgres is reading an entire table sequentially it's +unlikely to be the only I/O consumer? The sequential reads would be +interleaved occasionally by some other I/O forcing a seek to continue. + +In which case the true random_page_cost seems like it would be extremely +sensitive to the amount of readahead the OS does. To reach a random_page_cost +of 4 given the numbers above for a 7200RPM drive requires that just under 25% +of the I/O of a sequential table scan be random seeks [*]. That translates to +32kB of sequential reading, which actually does sound like a typical value for +OS readahead. + +I wonder if those same empirical tests would show even higher values of +random_page_cost if the readahead were turned up to 64kB or 128kB. + + + + +[*] A bit of an algebraic diversion: + + 1s/10ms = 100 random buffers/s. + random_page_cost = 4 so net sequential buffers/s = 400. + + solve: + + 400 buffers = rnd+seq + 1000ms = .2*seq + 10*rnd + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 08:00:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F1BE7566AD + for ; + Wed, 16 Mar 2005 08:00:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76654-10 + for ; + Wed, 16 Mar 2005 07:59:58 +0000 (GMT) +Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C84E566D7 + for ; + Wed, 16 Mar 2005 07:59:51 +0000 (GMT) +Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 9AF832BD79; + Wed, 16 Mar 2005 09:59:36 +0200 (SAST) +Received: from jhb.ucs.co.za (jhb.ucs.co.za [172.31.1.3]) + by ucspost.ucs.co.za (Postfix) with ESMTP + id 614AAD9E97; Wed, 16 Mar 2005 09:59:39 +0200 (SAST) +Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) + by jhb.ucs.co.za (Postfix) with ESMTP id 7108E97AE9; + Wed, 16 Mar 2005 09:59:39 +0200 (SAST) +Date: Wed, 16 Mar 2005 09:59:39 +0200 +From: Stef +To: andrew@pillette.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow loads when indexes added. +Message-ID: <20050316095939.2d58a128@svb.ucs.co.za> +In-Reply-To: <200503152042.j2FKgOo29331@pillette.com> +References: <200503152042.j2FKgOo29331@pillette.com> +X-Mailer: Sylpheed-Claws 1.0.1 (GTK+ 1.2.10; i386-pc-linux-gnu) +User-Agent: sillypheed-claws (anti-aliased) +X-Face: +lU/o'$=Zv9%Xjo]Kq[_{n&Kb`f{YEWH4&Y#M]'6BkD?VoWe#*@S\MWyD'I>s:0v4{#\[J]l*?]t2uaO(j$d*77Ca-UHo.tkl2)0$B3Jxww\o:xor]<:*Yfx9Vceh)9I/'2g\RKhGTxIIsR^ke^`LVeZ9ksb*:$kQeR@ +X-Operating-System: sid +X-X-X: _-^-_ +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.411 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_WHOIS +X-Spam-Level: +X-Archive-Number: 200503/317 +X-Sequence-Number: 11022 + +andrew@pillette.com mentioned : +=> Try ANALYZE after loading the referenced tables, but before loading the main table + +I attached a new script for creating the load file... + +Analyze didn't help, it actually took longer to load. +I set autocommit to off, and put a commit after every 100 +inserts, chattr'd noatime atrribute off recursively on PGDATA, and +set fsync to off, this improved the time from 3min 51sec to 2min 37 sec +for the slow scenario. + +But I was already doing all these things in the app that +used to take 40 minutes, but now takes four hours to load. + +Any other suggestions? + +Kind Regards +Stefan + +From pgsql-performance-owner@postgresql.org Wed Mar 16 09:42:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 64E3D5648D + for ; + Wed, 16 Mar 2005 09:42:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05927-10 + for ; + Wed, 16 Mar 2005 09:42:05 +0000 (GMT) +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by svr1.postgresql.org (Postfix) with ESMTP id 207105641A + for ; + Wed, 16 Mar 2005 09:42:03 +0000 (GMT) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id 6ADA48F28B; Wed, 16 Mar 2005 10:42:04 +0100 (CET) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Subject: Re: cpu_tuple_cost +Date: Wed, 16 Mar 2005 10:42:04 +0100 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE6C7095@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] cpu_tuple_cost +Thread-Index: AcUp+5/Uj5jDzKxWQxmc1SAKdYVFrgAEH3Aw +From: "Magnus Hagander" +To: "Greg Stark" , + "David Brown" +Cc: "Gregory Stark" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.07 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/318 +X-Sequence-Number: 11023 + +> > >The "this day and age" argument isn't very convincing. Hard drive=20 +> > >capacity growth has far outstripped hard drive seek time=20 +> and bandwidth improvements. +> > >Random access has more penalty than ever. +> > +> > In point of fact, there haven't been noticeable seek time=20 +> improvements=20 +> > for years. Transfer rates, on the other hand, have gone=20 +> through the roof. +>=20 +> Er, yeah. I stated it wrong. The real ratio here is between=20 +> seek time and throughput. +>=20 +> Typical 7200RPM drives have average seek times are in the=20 +> area of 10ms. +> Typical sustained transfer rates are in the range of 40Mb/s.=20 +> Postgres reads 8kB blocks at a time. +>=20 +> So 800kB/s for random access reads. And 40Mb/s for sequential=20 +> reads. That's a factor of 49. I don't think anyone wants=20 +> random_page_cost to be set to 50 though. +>=20 +> For a high end 15k drive I see average seek times get as low=20 +> as 3ms. And sustained transfer rates get as high as 100Mb/s.=20 +> So about 2.7Mb/s for random access reads or about a=20 +> random_page_cost of 37. Still pretty extreme. +>=20 +> So what's going on with the empirically derived value of 4?=20 +> Perhaps this is because even though Postgres is reading an=20 +> entire table sequentially it's unlikely to be the only I/O=20 +> consumer? The sequential reads would be interleaved=20 +> occasionally by some other I/O forcing a seek to continue. + +What about the cache memory on the disk? Even IDE disks have some 8Mb +cache today, which makes a lot of difference for fairly short scans. +Even if it's just read cache. That'll bring the speed of random access +down to a 1=3D1 relationship with sequential access, assuming all fits = +in +the cache. + + +//Magnus + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:49:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D941A5656B + for ; + Wed, 16 Mar 2005 11:40:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42326-01 + for ; + Wed, 16 Mar 2005 11:40:57 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 71232564EF + for ; + Wed, 16 Mar 2005 11:40:57 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.13.1/8.13.1) with ESMTP id j2GBeudA042341 + for ; Wed, 16 Mar 2005 11:40:56 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.13.1/8.13.1/Submit) id j2GBFlnw034863 + for pgsql-performance@postgresql.org; Wed, 16 Mar 2005 11:15:47 GMT + (envelope-from news) +From: "Rosny" +X-Newsgroups: pgsql.performance +Subject: Which one is faster: one way reading ="single pass reading" +Date: Wed, 16 Mar 2005 03:15:48 -0800 +Organization: Hub.Org Networking Services +Lines: 35 +Message-ID: +Reply-To: "Rosny" +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.3790.181 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/404 +X-Sequence-Number: 11109 + +Hi, + +Which one is faster: one way reading ="single pass reading" +Assumption : +a. Need to have 3 millions records +b. Need to have call 10 or 20 records repeatly + (so for database it will be 10 times connection, each connection with one +record. + or can be fancy 1 connection call return 10 sets of records) + + +1. Reading from Flat file + Assume already give file name and just need to read the file + (since it is flat file, each record represent a filename, with multiple +directory category) + +2. Reading from XML file + Assume schema already given just need to read the file + (since it is xml file, each record represent an xml filename, with +multiple directory category) + +3. Reading from Postgresql + Assume primary key has been done with indexing + just need to search the number and grap the text content + (assume 3 millions of records, search the number, read the content file) + +trying to recreate WebDBReader (from nutch) using C# +http://nutch.sourceforge.net/docs/api/net/nutch/db/WebDBReader.html + +Thank you in advances, +Rosny + + + + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 13:17:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 77CD9545F7 + for ; + Wed, 16 Mar 2005 13:17:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68179-04 + for ; + Wed, 16 Mar 2005 13:16:58 +0000 (GMT) +Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B31C56939 + for ; + Wed, 16 Mar 2005 13:16:57 +0000 (GMT) +Received: from [192.168.1.100] ([24.202.23.128]) by + VL-MO-MR011.ip.videotron.ca + (iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep 8 2003)) + with ESMTP id <0IDG001LM4TXKW@VL-MO-MR011.ip.videotron.ca> for + pgsql-performance@postgresql.org; Wed, 16 Mar 2005 08:15:34 -0500 (EST) +Date: Wed, 16 Mar 2005 08:18:39 -0500 +From: David Gagnon +Subject: Re: Performance problem on delete from for 10k rows. May +In-reply-to: <20050315233834.GA68209@winnie.fuhr.org> +To: Michael Fuhr +Cc: pgsql-performance@postgresql.org +Message-id: <4238322F.10302@siunik.com> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 8BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +References: <42375281.9090102@siunik.com> + <20050315233834.GA68209@winnie.fuhr.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.117 tagged_above=0 required=5 tests=AWL, + UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200503/319 +X-Sequence-Number: 11024 + +Hi All, + +I rerun the example with the debug info turned on in postgresl. As you +can see all dependent tables (that as foreign key on table IC) are +emptied before the DELETE FROM IC statement is issued. For what I +understand the performance problem seem to came from those selects that +point back to IC ( LOG: statement: SELECT 1 FROM ONLY "public"."ic" x +WHERE "icnum" = $1 FOR UPDATE OF x). There are 6 of them. I don't know +where they are comming from. But if I want to delete the content of the +table (~10k) it may be long to those 6 selects for each deleted rows. +Why are those selects are there ? Are those select really run on each +row deleted? + +I'm running version 7.4.5 on cygwin. I ran the same delete from +pgAdminIII and I got 945562ms for all the deletes within the same +transaction .. (so I was wrong saying it took less time in +PgAdminIII... sorry about this). + +Do you have any idea why those 6 selects are there? + +Maybe I can drop indexes before deleting the content of the table. I +didn't planned to because tables are quite small and it's more +complicated in my environment. And tell me if I'm wrong but if I drop +indexed do I have to reload all my stored procedure (to reset the +planner related info)??? Remember having read that somewhere.. (was it +in the Postgresql General Bit newletter ...anyway) + +Thanks for your help I really appr�ciate it :-) + +/David + +LOG: duration: 144.000 ms +LOG: statement: DELETE FROM YN +LOG: duration: 30.000 ms +LOG: statement: DELETE FROM YO +LOG: statement: SELECT 1 FROM ONLY "public"."yo" x WHERE "yotype" = $1 +AND "yonum" = $2 FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."yn" x WHERE "ynyotype" = +$1 AND "ynyonum" = $2 FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."yo" x WHERE "yotype" = $1 +AND "yonum" = $2 FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."yr" x WHERE "yryotype" = +$1 AND "yryonum" = $2 FOR UPDATE OF x +LOG: duration: 83.000 ms +LOG: connection received: host=127.0.0.1 port=2196 +LOG: connection authorized: user=admin database=webCatalog +LOG: statement: set datestyle to 'ISO'; select version(), case when +pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else +getdatabaseencoding() end; +LOG: duration: 2.000 ms +LOG: statement: set client_encoding = 'UNICODE' +LOG: duration: 0.000 ms +LOG: statement: DELETE FROM IY +LOG: duration: 71.000 ms +LOG: statement: DELETE FROM IA +LOG: duration: 17.000 ms +LOG: statement: DELETE FROM IQ +LOG: duration: 384.000 ms +LOG: statement: DELETE FROM IC +LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."iq" x WHERE "iqicnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."ia" x WHERE "iaicnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."iy" x WHERE "iyicnumo" = +$1 FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."iy" x WHERE "iyicnumr" = +$1 FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."il" x WHERE "ilicnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."bd" x WHERE "bdicnum" = $1 +FOR UPDATE OF x +LOG: duration: 656807.000 msMichael Fuhr wrote: + + + + + +----------------------- +DELETE FROM BM; +DELETE FROM BD; +DELETE FROM BO; +DELETE FROM IL; +DELETE FROM YR; +DELETE FROM YN; +DELETE FROM YO; +DELETE FROM IY; +DELETE FROM IA; +DELETE FROM IQ; +DELETE FROM IC; + +Michael Fuhr wrote: + +>On Tue, Mar 15, 2005 at 04:24:17PM -0500, David Gagnon wrote: +> +> +> +>> Il get this strange problem when deleting rows from a Java program. +>>Sometime (For what I noticed it's not all the time) the server take +>>almost forever to delete rows from table. +>> +>> +> +>Do other tables have foreign key references to the table you're +>deleting from? If so, are there indexes on the foreign key columns? +> +>Do you have triggers or rules on the table? +> +>Have you queried pg_locks during the long-lasting deletes to see +>if the deleting transaction is waiting for a lock on something? +> +> +> +>>I rememeber having tried to delete the content of my table (IC) from +>>PgAdminIII and I took couples of seconds!!! Not minutes. +>> +>> +> +>How many records did you delete in this case? If there are foreign +>key references, how many records were in the referencing tables? +>How repeatable is the disparity in delete time? A single test case +>might have been done under different conditions, so it might not +>mean much. No offense intended, but "I remember" doesn't carry as +>much weight as a documented example. +> +> +> + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 14:06:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2CACA5672D + for ; + Wed, 16 Mar 2005 14:06:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82329-04 + for ; + Wed, 16 Mar 2005 14:06:34 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id F183F565F9 + for ; + Wed, 16 Mar 2005 14:06:32 +0000 (GMT) +Received: (qmail 1936 invoked from network); 16 Mar 2005 14:05:33 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 16 Mar 2005 14:05:33 -0000 +Message-ID: <42383D60.7080900@fastcrypt.com> +Date: Wed, 16 Mar 2005 09:06:24 -0500 +From: Dave Cramer +Reply-To: pg@fastcrypt.com +Organization: Postgres International +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: David Gagnon +Cc: Michael Fuhr , pgsql-performance@postgresql.org +Subject: Re: Performance problem on delete from for 10k rows. May +References: <42375281.9090102@siunik.com> + <20050315233834.GA68209@winnie.fuhr.org> + <4238322F.10302@siunik.com> +In-Reply-To: <4238322F.10302@siunik.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.141 tagged_above=0 required=5 tests=AWL, + UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200503/320 +X-Sequence-Number: 11025 + + + +David Gagnon wrote: + +> Hi All, +> +> I rerun the example with the debug info turned on in postgresl. As you +> can see all dependent tables (that as foreign key on table IC) are +> emptied before the DELETE FROM IC statement is issued. For what I +> understand the performance problem seem to came from those selects +> that point back to IC ( LOG: statement: SELECT 1 FROM ONLY +> "public"."ic" x WHERE "icnum" = $1 FOR UPDATE OF x). There are 6 of +> them. I don't know where they are comming from. But if I want to +> delete the content of the table (~10k) it may be long to those 6 +> selects for each deleted rows. Why are those selects are there ? Are +> those select really run on each row deleted? + +You are using hibernate. Hibernate is generating them to lock the tables. + +> +> +> I'm running version 7.4.5 on cygwin. I ran the same delete from +> pgAdminIII and I got 945562ms for all the deletes within the same +> transaction .. (so I was wrong saying it took less time in +> PgAdminIII... sorry about this). +> +> Do you have any idea why those 6 selects are there? + +Hibernate + +> +> Maybe I can drop indexes before deleting the content of the table. I +> didn't planned to because tables are quite small and it's more +> complicated in my environment. And tell me if I'm wrong but if I drop +> indexed do I have to reload all my stored procedure (to reset the +> planner related info)??? Remember having read that somewhere.. (was it +> in the Postgresql General Bit newletter ...anyway) +> +> Thanks for your help I really appr�ciate it :-) +> +> /David +> +> LOG: duration: 144.000 ms +> LOG: statement: DELETE FROM YN +> LOG: duration: 30.000 ms +> LOG: statement: DELETE FROM YO +> LOG: statement: SELECT 1 FROM ONLY "public"."yo" x WHERE "yotype" = +> $1 AND "yonum" = $2 FOR UPDATE OF x +> LOG: statement: SELECT 1 FROM ONLY "public"."yn" x WHERE "ynyotype" = +> $1 AND "ynyonum" = $2 FOR UPDATE OF x +> LOG: statement: SELECT 1 FROM ONLY "public"."yo" x WHERE "yotype" = +> $1 AND "yonum" = $2 FOR UPDATE OF x +> LOG: statement: SELECT 1 FROM ONLY "public"."yr" x WHERE "yryotype" = +> $1 AND "yryonum" = $2 FOR UPDATE OF x +> LOG: duration: 83.000 ms +> LOG: connection received: host=127.0.0.1 port=2196 +> LOG: connection authorized: user=admin database=webCatalog +> LOG: statement: set datestyle to 'ISO'; select version(), case when +> pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else +> getdatabaseencoding() end; +> LOG: duration: 2.000 ms +> LOG: statement: set client_encoding = 'UNICODE' +> LOG: duration: 0.000 ms +> LOG: statement: DELETE FROM IY +> LOG: duration: 71.000 ms +> LOG: statement: DELETE FROM IA +> LOG: duration: 17.000 ms +> LOG: statement: DELETE FROM IQ +> LOG: duration: 384.000 ms +> LOG: statement: DELETE FROM IC +> LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +> FOR UPDATE OF x +> LOG: statement: SELECT 1 FROM ONLY "public"."iq" x WHERE "iqicnum" = +> $1 FOR UPDATE OF x +> LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +> FOR UPDATE OF x +> LOG: statement: SELECT 1 FROM ONLY "public"."ia" x WHERE "iaicnum" = +> $1 FOR UPDATE OF x +> LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +> FOR UPDATE OF x +> LOG: statement: SELECT 1 FROM ONLY "public"."iy" x WHERE "iyicnumo" = +> $1 FOR UPDATE OF x +> LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +> FOR UPDATE OF x +> LOG: statement: SELECT 1 FROM ONLY "public"."iy" x WHERE "iyicnumr" = +> $1 FOR UPDATE OF x +> LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +> FOR UPDATE OF x +> LOG: statement: SELECT 1 FROM ONLY "public"."il" x WHERE "ilicnum" = +> $1 FOR UPDATE OF x +> LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +> FOR UPDATE OF x +> LOG: statement: SELECT 1 FROM ONLY "public"."bd" x WHERE "bdicnum" = +> $1 FOR UPDATE OF x +> LOG: duration: 656807.000 msMichael Fuhr wrote: +> +> +> +> +> +> ----------------------- +> DELETE FROM BM; +> DELETE FROM BD; +> DELETE FROM BO; +> DELETE FROM IL; +> DELETE FROM YR; +> DELETE FROM YN; +> DELETE FROM YO; +> DELETE FROM IY; +> DELETE FROM IA; +> DELETE FROM IQ; +> DELETE FROM IC; +> +> Michael Fuhr wrote: +> +>> On Tue, Mar 15, 2005 at 04:24:17PM -0500, David Gagnon wrote: +>> +>> +>> +>>> Il get this strange problem when deleting rows from a Java program. +>>> Sometime (For what I noticed it's not all the time) the server take +>>> almost forever to delete rows from table. +>>> +>> +>> +>> Do other tables have foreign key references to the table you're +>> deleting from? If so, are there indexes on the foreign key columns? +>> +>> Do you have triggers or rules on the table? +>> +>> Have you queried pg_locks during the long-lasting deletes to see +>> if the deleting transaction is waiting for a lock on something? +>> +>> +>> +>>> I rememeber having tried to delete the content of my table (IC) from +>>> PgAdminIII and I took couples of seconds!!! Not minutes. +>>> +>> +>> +>> How many records did you delete in this case? If there are foreign +>> key references, how many records were in the referencing tables? +>> How repeatable is the disparity in delete time? A single test case +>> might have been done under different conditions, so it might not +>> mean much. No offense intended, but "I remember" doesn't carry as +>> much weight as a documented example. +>> +>> +>> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend +> +> + +-- +Dave Cramer +http://www.postgresintl.com +519 939 0336 +ICQ#14675561 + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 14:23:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1853356949 + for ; + Wed, 16 Mar 2005 14:23:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89475-03 + for ; + Wed, 16 Mar 2005 14:23:17 +0000 (GMT) +Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) + by svr1.postgresql.org (Postfix) with ESMTP id 666D05695B + for ; + Wed, 16 Mar 2005 14:23:16 +0000 (GMT) +Received: from [192.168.1.100] ([24.202.23.128]) by + VL-MO-MR011.ip.videotron.ca + (iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep 8 2003)) + with ESMTP id <0IDG00L737YWF4@VL-MO-MR011.ip.videotron.ca> for + pgsql-performance@postgresql.org; Wed, 16 Mar 2005 09:23:21 -0500 (EST) +Date: Wed, 16 Mar 2005 09:26:26 -0500 +From: David Gagnon +Subject: Re: Performance problem on delete from for 10k rows. May +In-reply-to: <42383D60.7080900@fastcrypt.com> +To: pg@fastcrypt.com +Cc: Michael Fuhr , pgsql-performance@postgresql.org +Message-id: <42384212.8070000@siunik.com> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 8BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +References: <42375281.9090102@siunik.com> + <20050315233834.GA68209@winnie.fuhr.org> <4238322F.10302@siunik.com> + <42383D60.7080900@fastcrypt.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.021 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/321 +X-Sequence-Number: 11026 + +Hi, + +I'm using ibatis. But in this particular case the sql statement come +from a plain ascii file and it's run by the Ibatis ScriptRunner class. +Beside the fact this class come from ibatis framework it's just plain +sql connection (I'm I wrong???). Just to be sure, here is the code from +the class. I must say that i run script that contains create table, +alter table, insert statements with the same runner. + +If I wrong please tell me .. I like to be wrong when the result is +eliminating a misunderstanding from my part :-) + +Thanks for your help! + +/David + + + + public void runScript(Connection conn, Reader reader) + throws IOException, SQLException { + StringBuffer command = null; + try { + LineNumberReader lineReader = new LineNumberReader(reader); + String line = null; + while ((line = lineReader.readLine()) != null) { + if (command == null) { + command = new StringBuffer(); + } + String trimmedLine = line.trim(); + if (trimmedLine.startsWith("--")) { + println(trimmedLine); + if (log.isDebugEnabled()) { + log.debug(trimmedLine); + } + } else if (trimmedLine.length() < 1 || +trimmedLine.startsWith("//")) { + //Do nothing + } else if (trimmedLine.endsWith(";")) { + command.append(line.substring(0, +line.lastIndexOf(";"))); + command.append(" "); + Statement statement = conn.createStatement(); + + println(command); + if (log.isDebugEnabled()) { + log.debug(command); + } + + boolean hasResults = false; + if (stopOnError) { + hasResults = statement.execute(command.toString()); + } else { + try { + statement.execute(command.toString()); + } catch (SQLException e) { + e.fillInStackTrace(); + printlnError("Error executing: " + command); + printlnError(e); + } + } + + if (autoCommit && !conn.getAutoCommit()) { + conn.commit(); + } + + ResultSet rs = statement.getResultSet(); + if (hasResults && rs != null) { + ResultSetMetaData md = rs.getMetaData(); + int cols = md.getColumnCount(); + for (int i = 0; i < cols; i++) { + String name = md.getColumnName(i); + print(name + "\t"); + } + println(""); + while (rs.next()) { + for (int i = 0; i < cols; i++) { + String value = rs.getString(i); + print(value + "\t"); + } + println(""); + } + } + + command = null; + try { + statement.close(); + } catch (Exception e) { + // Ignore to workaround a bug in Jakarta DBCP +// e.printStackTrace(); + } + Thread.yield(); + } else { + command.append(line); + command.append(" "); + } + } + if (!autoCommit) { + conn.commit(); + } + } catch (SQLException e) { + e.fillInStackTrace(); + printlnError("Error executing: " + command); + printlnError(e); + log.error("Error executing: " + command, e); + throw e; + } catch (IOException e) { + e.fillInStackTrace(); + printlnError("Error executing: " + command); + printlnError(e); + log.error("Error executing: " + command, e); + throw e; + } finally { + conn.rollback(); + flush(); + } + } + + +Dave Cramer wrote: + +> +> +> David Gagnon wrote: +> +>> Hi All, +>> +>> I rerun the example with the debug info turned on in postgresl. As +>> you can see all dependent tables (that as foreign key on table IC) +>> are emptied before the DELETE FROM IC statement is issued. For what +>> I understand the performance problem seem to came from those selects +>> that point back to IC ( LOG: statement: SELECT 1 FROM ONLY +>> "public"."ic" x WHERE "icnum" = $1 FOR UPDATE OF x). There are 6 of +>> them. I don't know where they are comming from. But if I want to +>> delete the content of the table (~10k) it may be long to those 6 +>> selects for each deleted rows. Why are those selects are there ? +>> Are those select really run on each row deleted? +> +> +> You are using hibernate. Hibernate is generating them to lock the tables. +> +>> +>> +>> I'm running version 7.4.5 on cygwin. I ran the same delete from +>> pgAdminIII and I got 945562ms for all the deletes within the same +>> transaction .. (so I was wrong saying it took less time in +>> PgAdminIII... sorry about this). +>> +>> Do you have any idea why those 6 selects are there? +> +> +> Hibernate +> +>> +>> Maybe I can drop indexes before deleting the content of the table. I +>> didn't planned to because tables are quite small and it's more +>> complicated in my environment. And tell me if I'm wrong but if I +>> drop indexed do I have to reload all my stored procedure (to reset +>> the planner related info)??? Remember having read that somewhere.. +>> (was it in the Postgresql General Bit newletter ...anyway) +>> +>> Thanks for your help I really appr�ciate it :-) +>> +>> /David +>> +>> LOG: duration: 144.000 ms +>> LOG: statement: DELETE FROM YN +>> LOG: duration: 30.000 ms +>> LOG: statement: DELETE FROM YO +>> LOG: statement: SELECT 1 FROM ONLY "public"."yo" x WHERE "yotype" = +>> $1 AND "yonum" = $2 FOR UPDATE OF x +>> LOG: statement: SELECT 1 FROM ONLY "public"."yn" x WHERE "ynyotype" +>> = $1 AND "ynyonum" = $2 FOR UPDATE OF x +>> LOG: statement: SELECT 1 FROM ONLY "public"."yo" x WHERE "yotype" = +>> $1 AND "yonum" = $2 FOR UPDATE OF x +>> LOG: statement: SELECT 1 FROM ONLY "public"."yr" x WHERE "yryotype" +>> = $1 AND "yryonum" = $2 FOR UPDATE OF x +>> LOG: duration: 83.000 ms +>> LOG: connection received: host=127.0.0.1 port=2196 +>> LOG: connection authorized: user=admin database=webCatalog +>> LOG: statement: set datestyle to 'ISO'; select version(), case when +>> pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else +>> getdatabaseencoding() end; +>> LOG: duration: 2.000 ms +>> LOG: statement: set client_encoding = 'UNICODE' +>> LOG: duration: 0.000 ms +>> LOG: statement: DELETE FROM IY +>> LOG: duration: 71.000 ms +>> LOG: statement: DELETE FROM IA +>> LOG: duration: 17.000 ms +>> LOG: statement: DELETE FROM IQ +>> LOG: duration: 384.000 ms +>> LOG: statement: DELETE FROM IC +>> LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = +>> $1 FOR UPDATE OF x +>> LOG: statement: SELECT 1 FROM ONLY "public"."iq" x WHERE "iqicnum" = +>> $1 FOR UPDATE OF x +>> LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = +>> $1 FOR UPDATE OF x +>> LOG: statement: SELECT 1 FROM ONLY "public"."ia" x WHERE "iaicnum" = +>> $1 FOR UPDATE OF x +>> LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = +>> $1 FOR UPDATE OF x +>> LOG: statement: SELECT 1 FROM ONLY "public"."iy" x WHERE "iyicnumo" +>> = $1 FOR UPDATE OF x +>> LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = +>> $1 FOR UPDATE OF x +>> LOG: statement: SELECT 1 FROM ONLY "public"."iy" x WHERE "iyicnumr" +>> = $1 FOR UPDATE OF x +>> LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = +>> $1 FOR UPDATE OF x +>> LOG: statement: SELECT 1 FROM ONLY "public"."il" x WHERE "ilicnum" = +>> $1 FOR UPDATE OF x +>> LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = +>> $1 FOR UPDATE OF x +>> LOG: statement: SELECT 1 FROM ONLY "public"."bd" x WHERE "bdicnum" = +>> $1 FOR UPDATE OF x +>> LOG: duration: 656807.000 msMichael Fuhr wrote: +>> +>> +>> +>> +>> +>> ----------------------- +>> DELETE FROM BM; +>> DELETE FROM BD; +>> DELETE FROM BO; +>> DELETE FROM IL; +>> DELETE FROM YR; +>> DELETE FROM YN; +>> DELETE FROM YO; +>> DELETE FROM IY; +>> DELETE FROM IA; +>> DELETE FROM IQ; +>> DELETE FROM IC; +>> +>> Michael Fuhr wrote: +>> +>>> On Tue, Mar 15, 2005 at 04:24:17PM -0500, David Gagnon wrote: +>>> +>>> +>>> +>>>> Il get this strange problem when deleting rows from a Java +>>>> program. Sometime (For what I noticed it's not all the time) the +>>>> server take almost forever to delete rows from table. +>>>> +>>> +>>> +>>> +>>> Do other tables have foreign key references to the table you're +>>> deleting from? If so, are there indexes on the foreign key columns? +>>> +>>> Do you have triggers or rules on the table? +>>> +>>> Have you queried pg_locks during the long-lasting deletes to see +>>> if the deleting transaction is waiting for a lock on something? +>>> +>>> +>>> +>>>> I rememeber having tried to delete the content of my table (IC) from +>>>> PgAdminIII and I took couples of seconds!!! Not minutes. +>>>> +>>> +>>> +>>> +>>> How many records did you delete in this case? If there are foreign +>>> key references, how many records were in the referencing tables? +>>> How repeatable is the disparity in delete time? A single test case +>>> might have been done under different conditions, so it might not +>>> mean much. No offense intended, but "I remember" doesn't carry as +>>> much weight as a documented example. +>>> +>>> +>>> +>> +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 8: explain analyze is your friend +>> +>> +> + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 14:35:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 12F5C56965 + for ; + Wed, 16 Mar 2005 14:35:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92732-07 + for ; + Wed, 16 Mar 2005 14:35:12 +0000 (GMT) +Received: from sunsite.dcc.uchile.cl (sunsite.dcc.uchile.cl [192.80.24.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9399656962 + for ; + Wed, 16 Mar 2005 14:35:11 +0000 (GMT) +Received: from anakena.dcc.uchile.cl (anakena [192.80.24.6]) + by sunsite.dcc.uchile.cl (8.12.11/8.12.11) with ESMTP id j2GEZB7n016370; + Wed, 16 Mar 2005 10:35:11 -0400 (CLT) +Received: by anakena.dcc.uchile.cl (Postfix, from userid 4151) + id A307D5236B; Wed, 16 Mar 2005 10:35:11 -0400 (CLT) +Date: Wed, 16 Mar 2005 10:35:11 -0400 +From: Alvaro Herrera +To: David Gagnon +Cc: Michael Fuhr , pgsql-performance@postgresql.org +Subject: Re: Performance problem on delete from for 10k rows. May +Message-ID: <20050316143511.GC21935@dcc.uchile.cl> +References: <42375281.9090102@siunik.com> + <20050315233834.GA68209@winnie.fuhr.org> + <4238322F.10302@siunik.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4238322F.10302@siunik.com> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.35 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/322 +X-Sequence-Number: 11027 + +On Wed, Mar 16, 2005 at 08:18:39AM -0500, David Gagnon wrote: + +David, + +> I rerun the example with the debug info turned on in postgresl. As you +> can see all dependent tables (that as foreign key on table IC) are +> emptied before the DELETE FROM IC statement is issued. For what I +> understand the performance problem seem to came from those selects that +> point back to IC ( LOG: statement: SELECT 1 FROM ONLY "public"."ic" x +> WHERE "icnum" = $1 FOR UPDATE OF x). There are 6 of them. I don't know +> where they are comming from. + +I think they come from the FK checking code. Try to run a VACUUM on the +IC table just before you delete from the other tables; that should make +the checking almost instantaneous (assuming the vacuuming actually +empties the table, which would depend on other transactions). + +It would be better to be able to use TRUNCATE to do this, but in 8.0 you +can't if the tables have FKs. 8.1 is better on that regard ... + +-- +Alvaro Herrera () +"Ninguna manada de bestias tiene una voz tan horrible como la humana" (Orual) + +From pgsql-performance-owner@postgresql.org Wed Mar 16 14:56:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 02C9D565DD + for ; + Wed, 16 Mar 2005 14:56:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98153-09 + for ; + Wed, 16 Mar 2005 14:56:45 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id E7A0C5646C + for ; + Wed, 16 Mar 2005 14:56:44 +0000 (GMT) +Received: (qmail 2478 invoked from network); 16 Mar 2005 14:55:45 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 16 Mar 2005 14:55:45 -0000 +Message-ID: <4238492B.2000801@fastcrypt.com> +Date: Wed, 16 Mar 2005 09:56:43 -0500 +From: Dave Cramer +Reply-To: pg@fastcrypt.com +Organization: Postgres International +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alvaro Herrera +Cc: David Gagnon , Michael Fuhr , + pgsql-performance@postgresql.org +Subject: Re: Performance problem on delete from for 10k rows. May +References: <42375281.9090102@siunik.com> + <20050315233834.GA68209@winnie.fuhr.org> + <4238322F.10302@siunik.com> <20050316143511.GC21935@dcc.uchile.cl> +In-Reply-To: <20050316143511.GC21935@dcc.uchile.cl> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.038 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/323 +X-Sequence-Number: 11028 + +Really? Postgres is generating these queries ??? + +Dave + +Alvaro Herrera wrote: + +>On Wed, Mar 16, 2005 at 08:18:39AM -0500, David Gagnon wrote: +> +>David, +> +> +> +>>I rerun the example with the debug info turned on in postgresl. As you +>>can see all dependent tables (that as foreign key on table IC) are +>>emptied before the DELETE FROM IC statement is issued. For what I +>>understand the performance problem seem to came from those selects that +>>point back to IC ( LOG: statement: SELECT 1 FROM ONLY "public"."ic" x +>>WHERE "icnum" = $1 FOR UPDATE OF x). There are 6 of them. I don't know +>>where they are comming from. +>> +>> +> +>I think they come from the FK checking code. Try to run a VACUUM on the +>IC table just before you delete from the other tables; that should make +>the checking almost instantaneous (assuming the vacuuming actually +>empties the table, which would depend on other transactions). +> +>It would be better to be able to use TRUNCATE to do this, but in 8.0 you +>can't if the tables have FKs. 8.1 is better on that regard ... +> +> +> + +-- +Dave Cramer +http://www.postgresintl.com +519 939 0336 +ICQ#14675561 + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 15:11:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4131456975 + for ; + Wed, 16 Mar 2005 15:11:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04658-08 + for ; + Wed, 16 Mar 2005 15:11:10 +0000 (GMT) +Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) + by svr1.postgresql.org (Postfix) with ESMTP id AF3E056968 + for ; + Wed, 16 Mar 2005 15:11:09 +0000 (GMT) +Received: from [192.168.1.100] ([24.202.23.128]) by + VL-MO-MR007.ip.videotron.ca + (iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep 8 2003)) + with ESMTP id <0IDG00INNA5NEK@VL-MO-MR007.ip.videotron.ca> for + pgsql-performance@postgresql.org; Wed, 16 Mar 2005 10:10:36 -0500 (EST) +Date: Wed, 16 Mar 2005 10:13:42 -0500 +From: David Gagnon +Subject: Re: Performance problem on delete from for 10k rows. May +In-reply-to: <20050316143511.GC21935@dcc.uchile.cl> +To: Alvaro Herrera +Cc: Michael Fuhr , pgsql-performance@postgresql.org +Message-id: <42384D26.4020903@siunik.com> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +References: <42375281.9090102@siunik.com> + <20050315233834.GA68209@winnie.fuhr.org> <4238322F.10302@siunik.com> + <20050316143511.GC21935@dcc.uchile.cl> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.123 tagged_above=0 required=5 tests=AWL, + UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200503/324 +X-Sequence-Number: 11029 + +Hi + +>>I rerun the example with the debug info turned on in postgresl. As you +>>can see all dependent tables (that as foreign key on table IC) are +>>emptied before the DELETE FROM IC statement is issued. For what I +>>understand the performance problem seem to came from those selects that +>>point back to IC ( LOG: statement: SELECT 1 FROM ONLY "public"."ic" x +>>WHERE "icnum" = $1 FOR UPDATE OF x). There are 6 of them. I don't know +>>where they are comming from. +>> +>> +> +>I think they come from the FK checking code. Try to run a VACUUM on the +>IC table just before you delete from the other tables; that should make +>the checking almost instantaneous (assuming the vacuuming actually +>empties the table, which would depend on other transactions). +> +> +I'll try to vaccum first before I start the delete to see if it change +something. + +There is probably a good reason why but I don't understant why in a +foreign key check it need to check the date it points to. + +You delete a row from table IC and do a check for integrity on tables +that have foreign keys on IC (make sense). But why checking back IC? +I'm pretty sure there is a good reason but it seems to have a big +performance impact... In this case. It means it's not really feasable +to empty the content of a schema. The table has only 10k .. with a huge +table it's not feasible just because the checks on itselft! + +Is someone can explain why there is this extra check? Is that can be +fixed or improved? + +Thanks for your help + +/David + + + + + +LOG: duration: 144.000 ms +LOG: statement: DELETE FROM YN +LOG: duration: 30.000 ms +LOG: statement: DELETE FROM YO +LOG: statement: SELECT 1 FROM ONLY "public"."yo" x WHERE "yotype" = $1 +AND "yonum" = $2 FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."yn" x WHERE "ynyotype" = +$1 AND "ynyonum" = $2 FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."yo" x WHERE "yotype" = $1 +AND "yonum" = $2 FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."yr" x WHERE "yryotype" = +$1 AND "yryonum" = $2 FOR UPDATE OF x +LOG: duration: 83.000 ms +LOG: connection received: host=127.0.0.1 port=2196 +LOG: connection authorized: user=admin database=webCatalog +LOG: statement: set datestyle to 'ISO'; select version(), case when +pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else +getdatabaseencoding() end; +LOG: duration: 2.000 ms +LOG: statement: set client_encoding = 'UNICODE' +LOG: duration: 0.000 ms +LOG: statement: DELETE FROM IY +LOG: duration: 71.000 ms +LOG: statement: DELETE FROM IA +LOG: duration: 17.000 ms +LOG: statement: DELETE FROM IQ +LOG: duration: 384.000 ms +LOG: statement: DELETE FROM IC +LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."iq" x WHERE "iqicnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."ia" x WHERE "iaicnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."iy" x WHERE "iyicnumo" = +$1 FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."iy" x WHERE "iyicnumr" = +$1 FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."il" x WHERE "ilicnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."ic" x WHERE "icnum" = $1 +FOR UPDATE OF x +LOG: statement: SELECT 1 FROM ONLY "public"."bd" x WHERE "bdicnum" = $1 +FOR UPDATE OF x +LOG: duration: 656807.000 msMichael Fuhr wrote: + + + + +>It would be better to be able to use TRUNCATE to do this, but in 8.0 you +>can't if the tables have FKs. 8.1 is better on that regard ... +> +> +> + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 15:43:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EA6D5674C + for ; + Wed, 16 Mar 2005 15:43:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20650-08 + for ; + Wed, 16 Mar 2005 15:43:02 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 934FD566BA + for ; + Wed, 16 Mar 2005 15:43:01 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DBafc-0000Bn-00; Wed, 16 Mar 2005 10:42:52 -0500 +To: "Magnus Hagander" +Cc: "Greg Stark" , "David Brown" , + "Gregory Stark" +Subject: Re: cpu_tuple_cost +References: <6BCB9D8A16AC4241919521715F4D8BCE6C7095@algol.sollentuna.se> +In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCE6C7095@algol.sollentuna.se> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 16 Mar 2005 10:42:52 -0500 +Message-ID: <874qfblhqb.fsf@stark.xeocode.com> +Lines: 15 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.019 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/325 +X-Sequence-Number: 11030 + +"Magnus Hagander" writes: + +> What about the cache memory on the disk? Even IDE disks have some 8Mb +> cache today, which makes a lot of difference for fairly short scans. +> Even if it's just read cache. That'll bring the speed of random access +> down to a 1=1 relationship with sequential access, assuming all fits in +> the cache. + +8MB cache is really insignificant compared to the hundreds or thousands of +megabytes the OS would be using to cache. You could just add the 8MB to your +effective_cache_size (except it's not really 100% effective since it would +contain some of the same blocks as the OS cache). + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 16:09:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E1BB4564CD + for ; + Wed, 16 Mar 2005 16:09:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31739-07 + for ; + Wed, 16 Mar 2005 16:09:04 +0000 (GMT) +Received: from audi.ibcp.fr (audi.ibcp.fr [193.51.160.127]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A7A95514D + for ; + Wed, 16 Mar 2005 16:09:00 +0000 (GMT) +Received: from [193.51.160.65] (gdeleage14.ibcp.fr [193.51.160.65]) + by audi.ibcp.fr (Postfix) with ESMTP id 3E01C1AF286 + for ; + Wed, 16 Mar 2005 17:08:59 +0100 (CET) +Message-ID: <42385A1B.9090305@ibcp.fr> +Date: Wed, 16 Mar 2005 17:08:59 +0100 +From: Daniel Crisan +User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PostgreSQL +Subject: multi-column index +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/326 +X-Sequence-Number: 11031 + +Hello. + +I have a problem concerning multi-column indexes. + +I have a table containing some 250k lines. + +Table "public.descriptionprodftdiclnk" + Column | Type | Modifiers +-------------+---------+----------- + idword | integer | not null + idqualifier | integer | not null +Indexes: + "descriptionprodftdiclnk_pkey" primary key, btree (idword, idqualifier) + "ix_descriptionprodftdiclnk_idqualif" btree (idqualifier) + +When analyzing a simple query on the idword column the query planner +displays: + +explain analyze select * from descriptionprodftdiclnk where idword=44; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on descriptionprodftdiclnk (cost=0.00..4788.14 rows=44388 +width=8) (actual time=87.582..168.041 rows=43792 loops=1) + Filter: (idword = 44) + Total runtime: 195.339 ms +(3 rows) + +I don't understand why the query planner would not use the default +created multi-column index +on the primary key. According to the Postgres online documentation it +should. By setting the +"enable_seqscan" parameter to off, i can force the planner to use the index: + +explain analyze select * from descriptionprodftdiclnk where idword=44; + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using descriptionprodftdiclnk_pkey on +descriptionprodftdiclnk (cost=0.00..36720.39 rows=44388 width=8) +(actual time=0.205..73.489 rows=43792 loops=1) + Index Cond: (idword = 44) + Total runtime: 100.564 ms +(3 rows) + + + +On the other hand, by defining a new index on the idword column (and +"enable_seqscan" set to on), +the query uses the index: + +create index ix_tempIndex on descriptionprodftdiclnk(idword); +CREATE INDEX +explain analyze select * from descriptionprodftdiclnk where idword=44; + QUERY +PLAN +------------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using ix_tempindex on descriptionprodftdiclnk +(cost=0.00..916.24 rows=44388 width=8) (actual time=0.021..79.879 +rows=43792 loops=1) + Index Cond: (idword = 44) + Total runtime: 107.081 ms +(3 rows) + +Could someone provide an explanation for the planner's behaviour? + +Thanks for your help, +Daniel + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 16:28:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 83E735521B + for ; + Wed, 16 Mar 2005 16:28:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38767-06 + for ; + Wed, 16 Mar 2005 16:28:08 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 86BA85514D + for ; + Wed, 16 Mar 2005 16:28:07 +0000 (GMT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id A1681359EA; Wed, 16 Mar 2005 08:28:07 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 9FAAE359E9; Wed, 16 Mar 2005 08:28:07 -0800 (PST) +Date: Wed, 16 Mar 2005 08:28:07 -0800 (PST) +From: Stephan Szabo +To: David Gagnon +Cc: Alvaro Herrera , + Michael Fuhr , pgsql-performance@postgresql.org +Subject: Re: Performance problem on delete from for 10k rows. May +In-Reply-To: <42384D26.4020903@siunik.com> +Message-ID: <20050316082636.J53581@megazone.bigpanda.com> +References: <42375281.9090102@siunik.com> + <20050315233834.GA68209@winnie.fuhr.org> + <4238322F.10302@siunik.com> <20050316143511.GC21935@dcc.uchile.cl> + <42384D26.4020903@siunik.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/327 +X-Sequence-Number: 11032 + +On Wed, 16 Mar 2005, David Gagnon wrote: + +> Hi +> +> >>I rerun the example with the debug info turned on in postgresl. As you +> >>can see all dependent tables (that as foreign key on table IC) are +> >>emptied before the DELETE FROM IC statement is issued. For what I +> >>understand the performance problem seem to came from those selects that +> >>point back to IC ( LOG: statement: SELECT 1 FROM ONLY "public"."ic" x +> >>WHERE "icnum" = $1 FOR UPDATE OF x). There are 6 of them. I don't know +> >>where they are comming from. +> >> +> >> +> > +> >I think they come from the FK checking code. Try to run a VACUUM on the +> >IC table just before you delete from the other tables; that should make +> >the checking almost instantaneous (assuming the vacuuming actually +> >empties the table, which would depend on other transactions). +> > +> > +> I'll try to vaccum first before I start the delete to see if it change +> something. +> +> There is probably a good reason why but I don't understant why in a +> foreign key check it need to check the date it points to. +> +> You delete a row from table IC and do a check for integrity on tables +> that have foreign keys on IC (make sense). But why checking back IC? + +Because in the general case there might be another row which satisfies the +constraint added between the delete and the check. + + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:46:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 056585656A + for ; + Wed, 16 Mar 2005 16:48:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47011-01 + for ; + Wed, 16 Mar 2005 16:47:59 +0000 (GMT) +Received: from postal2.et.byu.edu (postal2.et.byu.edu [128.187.122.132]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E9AD564CD + for ; + Wed, 16 Mar 2005 16:47:58 +0000 (GMT) +Received: from lewis.et.byu.edu (lewis.et.byu.edu [128.187.112.50]) + by postal2.et.byu.edu (8.12.10/8.12.10) with ESMTP id j2GGlZOH017190; + Wed, 16 Mar 2005 09:47:35 -0700 +Date: Wed, 16 Mar 2005 09:47:35 -0700 (MST) +From: David Dougall +To: Arshavir Grigorian +Cc: linux-raid@vger.kernel.org, pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +In-Reply-To: <4231F5F2.6000509@m-cam.com> +Message-ID: +References: <4231F5F2.6000509@m-cam.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Scanned-By: MIMEDefang 2.38 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/401 +X-Sequence-Number: 11106 + +In my experience, if you are concerned about filesystem performance, don't +use ext3. It is one of the slowest filesystems I have ever used +especially for writes. I would suggest either reiserfs or xfs. +--David Dougall + + +On Fri, 11 Mar 2005, Arshavir Grigorian wrote: + +> Hi, +> +> I have a RAID5 array (mdadm) with 14 disks + 1 spare. This partition has +> an Ext3 filesystem which is used by Postgres. Currently we are loading a +> 50G database on this server from a Postgres dump (copy, not insert) and +> are experiencing very slow write performance (35 records per second). +> +> Top shows that the Postgres process (postmaster) is being constantly put +> into D state for extended periods of time (2-3 seconds) which I assume +> is because it's waiting for disk io. I have just started gathering +> system statistics and here is what sar -b shows: (this is while the db +> is being loaded - pg_restore) +> +> tps rtps wtps bread/s bwrtn/s +> 01:35:01 PM 275.77 76.12 199.66 709.59 2315.23 +> 01:45:01 PM 287.25 75.56 211.69 706.52 2413.06 +> 01:55:01 PM 281.73 76.35 205.37 711.84 2389.86 +> 02:05:01 PM 282.83 76.14 206.69 720.85 2418.51 +> 02:15:01 PM 284.07 76.15 207.92 707.38 2443.60 +> 02:25:01 PM 265.46 75.91 189.55 708.87 2089.21 +> 02:35:01 PM 285.21 76.02 209.19 709.58 2446.46 +> Average: 280.33 76.04 204.30 710.66 2359.47 +> +> This is a Sun e450 with dual TI UltraSparc II processors and 2G of RAM. +> It is currently running Debian Sarge with a 2.4.27-sparc64-smp custom +> compiled kernel. Postgres is installed from the Debian package and uses +> all the configuration defaults. +> +> I am also copying the pgsql-performance list. +> +> Thanks in advance for any advice/pointers. +> +> +> Arshavir +> +> Following is some other info that might be helpful. +> +> /proc/scsi# mdadm -D /dev/md1 +> /dev/md1: +> Version : 00.90.00 +> Creation Time : Wed Feb 23 17:23:41 2005 +> Raid Level : raid5 +> Array Size : 123823616 (118.09 GiB 126.80 GB) +> Device Size : 8844544 (8.43 GiB 9.06 GB) +> Raid Devices : 15 +> Total Devices : 17 +> Preferred Minor : 1 +> Persistence : Superblock is persistent +> +> Update Time : Thu Feb 24 10:05:38 2005 +> State : active +> Active Devices : 15 +> Working Devices : 16 +> Failed Devices : 1 +> Spare Devices : 1 +> +> Layout : left-symmetric +> Chunk Size : 64K +> +> UUID : 81ae2c97:06fa4f4d:87bfc6c9:2ee516df +> Events : 0.8 +> +> Number Major Minor RaidDevice State +> 0 8 64 0 active sync /dev/sde +> 1 8 80 1 active sync /dev/sdf +> 2 8 96 2 active sync /dev/sdg +> 3 8 112 3 active sync /dev/sdh +> 4 8 128 4 active sync /dev/sdi +> 5 8 144 5 active sync /dev/sdj +> 6 8 160 6 active sync /dev/sdk +> 7 8 176 7 active sync /dev/sdl +> 8 8 192 8 active sync /dev/sdm +> 9 8 208 9 active sync /dev/sdn +> 10 8 224 10 active sync /dev/sdo +> 11 8 240 11 active sync /dev/sdp +> 12 65 0 12 active sync /dev/sdq +> 13 65 16 13 active sync /dev/sdr +> 14 65 32 14 active sync /dev/sds +> +> 15 65 48 15 spare /dev/sdt +> +> # dumpe2fs -h /dev/md1 +> dumpe2fs 1.35 (28-Feb-2004) +> Filesystem volume name: +> Last mounted on: +> Filesystem UUID: 1bb95bd6-94c7-4344-adf2-8414cadae6fc +> Filesystem magic number: 0xEF53 +> Filesystem revision #: 1 (dynamic) +> Filesystem features: has_journal dir_index needs_recovery large_file +> Default mount options: (none) +> Filesystem state: clean +> Errors behavior: Continue +> Filesystem OS type: Linux +> Inode count: 15482880 +> Block count: 30955904 +> Reserved block count: 1547795 +> Free blocks: 28767226 +> Free inodes: 15482502 +> First block: 0 +> Block size: 4096 +> Fragment size: 4096 +> Blocks per group: 32768 +> Fragments per group: 32768 +> Inodes per group: 16384 +> Inode blocks per group: 512 +> Filesystem created: Wed Feb 23 17:27:13 2005 +> Last mount time: Wed Feb 23 17:45:25 2005 +> Last write time: Wed Feb 23 17:45:25 2005 +> Mount count: 2 +> Maximum mount count: 28 +> Last checked: Wed Feb 23 17:27:13 2005 +> Check interval: 15552000 (6 months) +> Next check after: Mon Aug 22 18:27:13 2005 +> Reserved blocks uid: 0 (user root) +> Reserved blocks gid: 0 (group root) +> First inode: 11 +> Inode size: 128 +> Journal inode: 8 +> Default directory hash: tea +> Directory Hash Seed: c35c0226-3b52-4dad-b102-f22feb773592 +> Journal backup: inode blocks +> +> # lspci | grep SCSI +> 0000:00:03.0 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +> (rev 14) +> 0000:00:03.1 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +> (rev 14) +> 0000:00:04.0 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +> (rev 14) +> 0000:00:04.1 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +> (rev 14) +> 0000:04:02.0 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +> (rev 03) +> 0000:04:03.0 SCSI storage controller: LSI Logic / Symbios Logic 53c875 +> (rev 03) +> +> /proc/scsi# more scsi +> Attached devices: +> Host: scsi0 Channel: 00 Id: 00 Lun: 00 +> Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A +> Type: Direct-Access ANSI SCSI revision: 02 +> Host: scsi0 Channel: 00 Id: 01 Lun: 00 +> Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 +> Type: Direct-Access ANSI SCSI revision: 03 +> Host: scsi0 Channel: 00 Id: 02 Lun: 00 +> Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A +> Type: Direct-Access ANSI SCSI revision: 02 +> Host: scsi0 Channel: 00 Id: 03 Lun: 00 +> Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A +> Type: Direct-Access ANSI SCSI revision: 02 +> Host: scsi1 Channel: 00 Id: 00 Lun: 00 +> Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A +> Type: Direct-Access ANSI SCSI revision: 02 +> Host: scsi1 Channel: 00 Id: 01 Lun: 00 +> Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 +> Type: Direct-Access ANSI SCSI revision: 03 +> Host: scsi1 Channel: 00 Id: 02 Lun: 00 +> Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 +> Type: Direct-Access ANSI SCSI revision: 03 +> Host: scsi1 Channel: 00 Id: 03 Lun: 00 +> Vendor: SEAGATE Model: ST39103LCSUN9.0G Rev: 034A +> Type: Direct-Access ANSI SCSI revision: 02 +> Host: scsi2 Channel: 00 Id: 00 Lun: 00 +> Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 +> Type: Direct-Access ANSI SCSI revision: 03 +> Host: scsi2 Channel: 00 Id: 01 Lun: 00 +> Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 +> Type: Direct-Access ANSI SCSI revision: 03 +> Host: scsi2 Channel: 00 Id: 02 Lun: 00 +> Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 +> Type: Direct-Access ANSI SCSI revision: 03 +> Host: scsi2 Channel: 00 Id: 03 Lun: 00 +> Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 +> Type: Direct-Access ANSI SCSI revision: 03 +> Host: scsi3 Channel: 00 Id: 00 Lun: 00 +> Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 +> Type: Direct-Access ANSI SCSI revision: 03 +> Host: scsi3 Channel: 00 Id: 01 Lun: 00 +> Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 +> Type: Direct-Access ANSI SCSI revision: 03 +> Host: scsi3 Channel: 00 Id: 02 Lun: 00 +> Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 +> Type: Direct-Access ANSI SCSI revision: 03 +> Host: scsi3 Channel: 00 Id: 03 Lun: 00 +> Vendor: SEAGATE Model: ST39204LCSUN9.0G Rev: 4207 +> Type: Direct-Access ANSI SCSI revision: 03 +> Host: scsi4 Channel: 00 Id: 06 Lun: 00 +> Vendor: TOSHIBA Model: XM6201TASUN32XCD Rev: 1103 +> Type: CD-ROM ANSI SCSI revision: 02 +> Host: scsi5 Channel: 00 Id: 00 Lun: 00 +> Vendor: FUJITSU Model: MAG3091L SUN9.0G Rev: 1111 +> Type: Direct-Access ANSI SCSI revision: 02 +> Host: scsi5 Channel: 00 Id: 01 Lun: 00 +> Vendor: FUJITSU Model: MAG3091L SUN9.0G Rev: 1111 +> Type: Direct-Access ANSI SCSI revision: 02 +> Host: scsi5 Channel: 00 Id: 02 Lun: 00 +> Vendor: FUJITSU Model: MAG3091L SUN9.0G Rev: 1111 +> Type: Direct-Access ANSI SCSI revision: 02 +> Host: scsi5 Channel: 00 Id: 03 Lun: 00 +> Vendor: FUJITSU Model: MAG3091L SUN9.0G Rev: 1111 +> Type: Direct-Access ANSI SCSI revision: 02 +> +> +> +> +> +> +> -- +> Arshavir Grigorian +> Systems Administrator/Engineer +> - +> To unsubscribe from this list: send the line "unsubscribe linux-raid" in +> the body of a message to majordomo@vger.kernel.org +> More majordomo info at http://vger.kernel.org/majordomo-info.html +> +> +> + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:48:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A4EA8565CB + for ; + Wed, 16 Mar 2005 16:56:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48802-10 + for ; + Wed, 16 Mar 2005 16:55:57 +0000 (GMT) +Received: from hobbit.corpit.ru (hobbit.corpit.ru [81.13.94.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 00A5B565BB + for ; + Wed, 16 Mar 2005 16:55:53 +0000 (GMT) +Received: from localhost (localhost [127.0.0.1]) + by hobbit.corpit.ru (Postfix) with ESMTP id 1819E295DD; + Wed, 16 Mar 2005 19:55:50 +0300 (MSK) (envelope-from mjt@tls.msk.ru) +Received: from [192.168.1.1] (paltus.tls.msk.ru [192.168.1.1]) + by hobbit.corpit.ru (Postfix) with ESMTP; + Wed, 16 Mar 2005 19:55:50 +0300 (MSK) (envelope-from mjt@tls.msk.ru) +Message-ID: <42386515.1070103@tls.msk.ru> +Date: Wed, 16 Mar 2005 19:55:49 +0300 +From: Michael Tokarev +User-Agent: Debian Thunderbird 1.0 (X11/20050116) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: David Dougall +Cc: Arshavir Grigorian , linux-raid@vger.kernel.org, + pgsql-performance@postgresql.org +Subject: Re: Postgres on RAID5 +References: <4231F5F2.6000509@m-cam.com> + +In-Reply-To: +X-Enigmail-Version: 0.90.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/403 +X-Sequence-Number: 11108 + +David Dougall wrote: +> In my experience, if you are concerned about filesystem performance, don't +> use ext3. It is one of the slowest filesystems I have ever used +> especially for writes. I would suggest either reiserfs or xfs. + +I'm a bit afraid to start yet another filesystem flamewar, but. +Please don't make such a claims without providing actual numbers +and config details. Pretty please. + +ext3 performs well for databases, there's no reason for it to be +slow. Ok, enable data=journal and use it with eg Oracle - you will +see it is slow. But in that case it isn't the filesystem to blame, +it's operator error, simple as that. + +And especially reiserfs, with its tail packing enabled by default, +is NOT suitable for databases... + +/mjt + +From pgsql-performance-owner@postgresql.org Wed Mar 16 17:00:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2178C565D3 + for ; + Wed, 16 Mar 2005 17:00:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51838-01 + for ; + Wed, 16 Mar 2005 17:00:20 +0000 (GMT) +Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) + by svr1.postgresql.org (Postfix) with ESMTP id 47815565C9 + for ; + Wed, 16 Mar 2005 17:00:18 +0000 (GMT) +Received: from [192.168.1.100] ([24.202.23.128]) by + VL-MO-MR007.ip.videotron.ca + (iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep 8 2003)) + with ESMTP id <0IDG00B55F69WO@VL-MO-MR007.ip.videotron.ca> for + pgsql-performance@postgresql.org; Wed, 16 Mar 2005 11:58:58 -0500 (EST) +Date: Wed, 16 Mar 2005 12:02:04 -0500 +From: David Gagnon +Subject: Re: Performance problem on delete from for 10k rows. May +In-reply-to: <20050316082636.J53581@megazone.bigpanda.com> +To: Stephan Szabo +Cc: Alvaro Herrera , + Michael Fuhr , pgsql-performance@postgresql.org +Message-id: <4238668C.5080002@siunik.com> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +References: <42375281.9090102@siunik.com> + <20050315233834.GA68209@winnie.fuhr.org> <4238322F.10302@siunik.com> + <20050316143511.GC21935@dcc.uchile.cl> <42384D26.4020903@siunik.com> + <20050316082636.J53581@megazone.bigpanda.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.025 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/328 +X-Sequence-Number: 11033 + + + +Stephan Szabo wrote: + +>On Wed, 16 Mar 2005, David Gagnon wrote: +> +> +> +>>Hi +>> +>> +>> +>>>>I rerun the example with the debug info turned on in postgresl. As you +>>>>can see all dependent tables (that as foreign key on table IC) are +>>>>emptied before the DELETE FROM IC statement is issued. For what I +>>>>understand the performance problem seem to came from those selects that +>>>>point back to IC ( LOG: statement: SELECT 1 FROM ONLY "public"."ic" x +>>>>WHERE "icnum" = $1 FOR UPDATE OF x). There are 6 of them. I don't know +>>>>where they are comming from. +>>>> +>>>> +>>>> +>>>> +>>>I think they come from the FK checking code. Try to run a VACUUM on the +>>>IC table just before you delete from the other tables; that should make +>>>the checking almost instantaneous (assuming the vacuuming actually +>>>empties the table, which would depend on other transactions). +>>> +>>> +>>> +>>> +>>I'll try to vaccum first before I start the delete to see if it change +>>something. +>> +>>There is probably a good reason why but I don't understant why in a +>>foreign key check it need to check the date it points to. +>> +>>You delete a row from table IC and do a check for integrity on tables +>>that have foreign keys on IC (make sense). But why checking back IC? +>> +>> +> +>Because in the general case there might be another row which satisfies the +>constraint added between the delete and the check. +> +> +> +So it's means if I want to reset the shema with DELETE FROM Table +statemnets I must first drop indexes, delete the data and then recreate +indexes and reload stored procedure. + +Or I can suspend the foreign key check in the db right. I saw something +on this. Is that possible to do this from the JDBC interface? + +Is there any other options I can consider ? + +Thanks for your help! +/David + +From pgsql-performance-owner@postgresql.org Wed Mar 16 17:59:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B068656622 + for ; + Wed, 16 Mar 2005 17:58:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76048-07 + for ; + Wed, 16 Mar 2005 17:58:45 +0000 (GMT) +Received: from stan.aopsys (aopsysadsl.net1.nerim.net [62.212.101.94]) + by svr1.postgresql.org (Postfix) with ESMTP id 756A6565AE + for ; + Wed, 16 Mar 2005 17:58:43 +0000 (GMT) +Received: from [127.0.0.1] (helo=localhost ident=laurent) + by stan.aopsys with esmtp (Exim 4.44) id 1DBcmx-0001Oz-QB + for pgsql-performance@postgresql.org; Wed, 16 Mar 2005 18:58:35 +0100 +To: pgsql-performance@postgresql.org +Subject: Speeding up select distinct +From: Laurent Martelli +Organization: AOPSYS +Date: Wed, 16 Mar 2005 18:58:35 +0100 +Message-ID: <87k6o74gms.fsf@stan.aopsys> +User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/329 +X-Sequence-Number: 11034 + +Consider this query: + +SELECT distinct owner from pictures; + + Unique (cost=361.18..382.53 rows=21 width=4) (actual time=14.197..17.639 rows=21 loops=1) + -> Sort (cost=361.18..371.86 rows=4270 width=4) (actual time=14.188..15.450 rows=4270 loops=1) + Sort Key: "owner" + -> Seq Scan on pictures (cost=0.00..103.70 rows=4270 width=4) (actual time=0.012..5.795 rows=4270 loops=1) + Total runtime: 19.147 ms + +I thought that 19ms to return 20 rows out of a 4000 rows table so I +added an index: + +CREATE INDEX pictures_owner ON pictures (owner); + +It gives a slight improvement: + + Unique (cost=0.00..243.95 rows=21 width=4) (actual time=0.024..10.293 rows=21 loops=1) + -> Index Scan using pictures_owner on pictures (cost=0.00..233.27 rows=4270 width=4) (actual time=0.022..8.227 rows=4270 loops=1) + Total runtime: 10.369 ms + +But still, it's a lot for 20 rows. I looked at other type of indexes, +but they seem to either not give beter perfs or be irrelevant. + +Any ideas, apart from more or less manually maintaining a list of +distinct owners in another table ? + +-- +Laurent Martelli +laurent@aopsys.com Java Aspect Components +http://www.aopsys.com/ http://jac.objectweb.org + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 18:04:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 25880567F0 + for ; + Wed, 16 Mar 2005 18:04:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78889-05 + for ; + Wed, 16 Mar 2005 18:04:15 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 918CE567CD + for ; + Wed, 16 Mar 2005 18:04:15 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7134689; Wed, 16 Mar 2005 10:06:06 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Greg Stark +Subject: Re: cpu_tuple_cost +Date: Wed, 16 Mar 2005 10:03:10 -0800 +User-Agent: KMail/1.6.2 +Cc: David Brown , + Gregory Stark +References: <87psy1mq66.fsf@stark.xeocode.com> + <42377293.1010801@bigpond.net.au> + <87acp4kq9o.fsf@stark.xeocode.com> +In-Reply-To: <87acp4kq9o.fsf@stark.xeocode.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200503161003.10916.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/330 +X-Sequence-Number: 11035 + +Greg, + +> So 800kB/s for random access reads. And 40Mb/s for sequential reads. That's +> a factor of 49. I don't think anyone wants random_page_cost to be set to 50 +> though. +> +> For a high end 15k drive I see average seek times get as low as 3ms. And +> sustained transfer rates get as high as 100Mb/s. So about 2.7Mb/s for +> random access reads or about a random_page_cost of 37. Still pretty +> extreme. + +Actually, what you're demonstrating here is that there's really no point in +having a random_page_cost GUC, since the seek/scan ratio is going to be high +regardless. + +Although I can point out that you left out the fact that the disk needs to do +a seek to find the beginning of the seq scan area, and even then some file +fragmentation is possible. Finally, I've never seen PostgreSQL manage more +than 70% of the maximum read rate, and in most cases more like 30%. + +> So what's going on with the empirically derived value of 4? + +It's not empirically derived; it's a value we plug into an +internal-to-postgresql formula. And "4" is a fairly conservative value that +works for a lot of systems. + +Realistically, the values we should be deriving from are: +-- median file cache size for postgresql files +-- average disk read throughput +-- effective processor calculation throughput +-- median I/O contention + +However, working those 4 hardware "facts" into forumulas that allow us to +calculate the actual cost of a query execution plan is somebody's PhD paper. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Mar 16 18:07:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DFBF3565F9 + for ; + Wed, 16 Mar 2005 18:07:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77506-10 + for ; + Wed, 16 Mar 2005 18:07:25 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B691569AD + for ; + Wed, 16 Mar 2005 18:07:22 +0000 (GMT) +Received: (qmail 23449 invoked from network); 16 Mar 2005 19:07:27 +0100 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 16 Mar 2005 19:07:27 +0100 +To: "Laurent Martelli" , pgsql-performance@postgresql.org +Subject: Re: Speeding up select distinct +References: <87k6o74gms.fsf@stan.aopsys> +Message-ID: +Date: Wed, 16 Mar 2005 19:07:21 +0100 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <87k6o74gms.fsf@stan.aopsys> +User-Agent: Opera M2/7.54 (Linux, build 955) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/331 +X-Sequence-Number: 11036 + + + Try : + + SELECT owner from pictures group by owner; + +> Any ideas, apart from more or less manually maintaining a list of +> distinct owners in another table ? + + That would be a good idea too for normalizing your database. + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 18:10:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C915567F7 + for ; + Wed, 16 Mar 2005 18:10:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79540-06 + for ; + Wed, 16 Mar 2005 18:10:32 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id A4B5D569CA + for ; + Wed, 16 Mar 2005 18:10:28 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7134725; Wed, 16 Mar 2005 10:12:20 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Daniel Crisan +Subject: Re: multi-column index +Date: Wed, 16 Mar 2005 10:09:24 -0800 +User-Agent: KMail/1.6.2 +Cc: PostgreSQL +References: <42385A1B.9090305@ibcp.fr> +In-Reply-To: <42385A1B.9090305@ibcp.fr> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200503161009.24713.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/332 +X-Sequence-Number: 11037 + +Daniel, + +> Table "public.descriptionprodftdiclnk" + +What is this, German? ;-) + +> explain analyze select * from descriptionprodftdiclnk where idword=44; +> QUERY PLAN +> --------------------------------------------------------------------------- +>---------------------------------------------------- Seq Scan on +> descriptionprodftdiclnk (cost=0.00..4788.14 rows=44388 width=8) (actual +> time=87.582..168.041 rows=43792 loops=1) +> Filter: (idword = 44) +> Total runtime: 195.339 ms +> (3 rows) + +> explain analyze select * from descriptionprodftdiclnk where idword=44; +> +> QUERY PLAN +> --------------------------------------------------------------------------- +>---------------------------------------------------------------------------- +>------------ Index Scan using descriptionprodftdiclnk_pkey on +> descriptionprodftdiclnk (cost=0.00..36720.39 rows=44388 width=8) +> (actual time=0.205..73.489 rows=43792 loops=1) +> Index Cond: (idword = 44) +> Total runtime: 100.564 ms +> (3 rows) + +> create index ix_tempIndex on descriptionprodftdiclnk(idword); +> CREATE INDEX +> explain analyze select * from descriptionprodftdiclnk where idword=44; +> QUERY +> PLAN +> --------------------------------------------------------------------------- +>---------------------------------------------------------------------- Index +> Scan using ix_tempindex on descriptionprodftdiclnk +> (cost=0.00..916.24 rows=44388 width=8) (actual time=0.021..79.879 +> rows=43792 loops=1) +> Index Cond: (idword = 44) +> Total runtime: 107.081 ms +> (3 rows) +> +> Could someone provide an explanation for the planner's behaviour? + +Pretty simple, really. Look at the cost calculations for the index scan for +the multi-column index. PostgreSQL believes that: +The cost of a seq scan is 4788.14 +The cost of an 2-column index scan is 36720.39 +The cost of a 1-column index scan is 916.24 + +Assuming that you ran each of these queries multiple times to eliminate +caching as a factor, the issue is that the cost calculations are wrong. We +give you a number of GUC variables to change that: +effective_cache_size +random_page_cost +cpu_tuple_cost +etc. + +See the RUNTIME-CONFIGURATION docs for more details. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Mar 16 18:11:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AF32C567F7 + for ; + Wed, 16 Mar 2005 18:11:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79620-10 + for ; + Wed, 16 Mar 2005 18:11:17 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F3AF567F0 + for ; + Wed, 16 Mar 2005 18:11:14 +0000 (GMT) +Received: from dyn-70-66.tor.dsl.tht.net (dyn-70-66.tor.dsl.tht.net + [134.22.70.66]) by tht.net (Postfix) with ESMTP + id 1526A76A5C; Wed, 16 Mar 2005 13:11:14 -0500 (EST) +Subject: Re: Speeding up select distinct +From: Rod Taylor +To: Laurent Martelli +Cc: pgsql-performance@postgresql.org +In-Reply-To: <87k6o74gms.fsf@stan.aopsys> +References: <87k6o74gms.fsf@stan.aopsys> +Content-Type: text/plain +Date: Wed, 16 Mar 2005 13:10:23 -0500 +Message-Id: <1110996623.1132.244.camel@home> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.0 FreeBSD GNOME Team Port +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.012 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/333 +X-Sequence-Number: 11038 + +On Wed, 2005-03-16 at 18:58 +0100, Laurent Martelli wrote: +> Consider this query: +> +> SELECT distinct owner from pictures; + +The performance has nothing to do with the number of rows returned, but +rather the complexity of calculations and amount of data to sift through +in order to find it. + +> Any ideas, apart from more or less manually maintaining a list of +> distinct owners in another table ? + +This would be the proper thing to do, along with adding a foreign key +from pictures to the new owner structure for integrity enforcement. +-- + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 18:19:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 48FC25692E + for ; + Wed, 16 Mar 2005 18:19:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85038-05 + for ; + Wed, 16 Mar 2005 18:19:17 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id BF641569C1 + for ; + Wed, 16 Mar 2005 18:19:13 +0000 (GMT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Subject: Re: Speeding up select distinct +Date: Wed, 16 Mar 2005 13:19:09 -0500 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A7650@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Speeding up select distinct +Thread-Index: AcUqUmTzmRSz4RTuS9aan0mviIpsuwAAJ8zA +From: "Merlin Moncure" +To: "Laurent Martelli" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/334 +X-Sequence-Number: 11039 + +> Consider this query: +>=20 +> SELECT distinct owner from pictures; + +[...] +> Any ideas, apart from more or less manually maintaining a list of +> distinct owners in another table ? + +you answered your own question. With a 20 row owners table, you should +be directing your efforts there group by is faster than distinct, but +both are very wasteful and essentially require s full seqscan of the +detail table. =20 + +With a little hacking, you can change 'manual maintenance' to 'automatic +maintenance'. + +1. create table owner as select distinct owner from pictures; +2. alter table owner add constraint owner_pkey(owner); +3. alter table pictures add constraint ri_picture_owner(owner) +references owner; +4. make a little append_ownder function which adds an owner to the owner +table if there is not already one there. Inline this to your insert +statement on pictures. + +Voila! +Merlin +p.s. normalize your data always! + +From pgsql-performance-owner@postgresql.org Wed Mar 16 18:30:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8559D56960 + for ; + Wed, 16 Mar 2005 18:30:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97732-02 + for ; + Wed, 16 Mar 2005 18:30:04 +0000 (GMT) +Received: from stan.aopsys (aopsysadsl.net1.nerim.net [62.212.101.94]) + by svr1.postgresql.org (Postfix) with ESMTP id E04945692E + for ; + Wed, 16 Mar 2005 18:30:01 +0000 (GMT) +Received: from [127.0.0.1] (helo=localhost ident=laurent) + by stan.aopsys with esmtp (Exim 4.44) + id 1DBdHG-0001U1-JQ; Wed, 16 Mar 2005 19:29:54 +0100 +To: PFC +Cc: pgsql-performance@postgresql.org +Subject: Re: Speeding up select distinct +References: <87k6o74gms.fsf@stan.aopsys> +From: Laurent Martelli +Organization: AOPSYS +Date: Wed, 16 Mar 2005 19:29:54 +0100 +In-Reply-To: (lists@boutiquenumerique.com's + message of "Wed, 16 Mar 2005 19:07:21 +0100") +Message-ID: <87fyyv4f6l.fsf@stan.aopsys> +User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/335 +X-Sequence-Number: 11040 + +Wow, what a fast response !!! + +>>>>> "PFC" == PFC writes: + + PFC> Try : + + PFC> SELECT owner from pictures group by owner; + +That's a slight improvement, but there's still a seq scan on pictures: + + HashAggregate (cost=114.38..114.38 rows=21 width=4) (actual time=7.585..7.605 rows=21 loops=1) + -> Seq Scan on pictures (cost=0.00..103.70 rows=4270 width=4) (actual time=0.015..3.272 rows=4270 loops=1) + Total runtime: 7.719 ms + + + + +-- +Laurent Martelli +laurent@aopsys.com Java Aspect Components +http://www.aopsys.com/ http://jac.objectweb.org + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 18:31:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2503956A37 + for ; + Wed, 16 Mar 2005 18:31:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88091-06 + for ; + Wed, 16 Mar 2005 18:31:28 +0000 (GMT) +Received: from stan.aopsys (aopsysadsl.net1.nerim.net [62.212.101.94]) + by svr1.postgresql.org (Postfix) with ESMTP id 997E1569D5 + for ; + Wed, 16 Mar 2005 18:31:22 +0000 (GMT) +Received: from [127.0.0.1] (helo=localhost ident=laurent) + by stan.aopsys with esmtp (Exim 4.44) + id 1DBdIY-0001UE-Mc; Wed, 16 Mar 2005 19:31:14 +0100 +To: Rod Taylor +Cc: pgsql-performance@postgresql.org +Subject: Re: Speeding up select distinct +References: <87k6o74gms.fsf@stan.aopsys> <1110996623.1132.244.camel@home> +From: Laurent Martelli +Organization: AOPSYS +Date: Wed, 16 Mar 2005 19:31:14 +0100 +In-Reply-To: <1110996623.1132.244.camel@home> (Rod Taylor's message of "Wed, + 16 Mar 2005 13:10:23 -0500") +Message-ID: <87br9j4f4d.fsf@stan.aopsys> +User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/336 +X-Sequence-Number: 11041 + +>>>>> "Rod" == Rod Taylor writes: + + Rod> On Wed, 2005-03-16 at 18:58 +0100, Laurent Martelli wrote: + >> Consider this query: + >> + >> SELECT distinct owner from pictures; + + Rod> The performance has nothing to do with the number of rows + Rod> returned, but rather the complexity of calculations and amount + Rod> of data to sift through in order to find it. + +Yes, but I thought that an index might be able to know what distinct +values there are and help optime that query very much. + +-- +Laurent Martelli +laurent@aopsys.com Java Aspect Components +http://www.aopsys.com/ http://jac.objectweb.org + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 18:38:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DBC3656588 + for ; + Wed, 16 Mar 2005 18:38:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00713-01 + for ; + Wed, 16 Mar 2005 18:38:41 +0000 (GMT) +Received: from stan.aopsys (aopsysadsl.net1.nerim.net [62.212.101.94]) + by svr1.postgresql.org (Postfix) with ESMTP id 7471D56621 + for ; + Wed, 16 Mar 2005 18:38:38 +0000 (GMT) +Received: from [127.0.0.1] (helo=localhost ident=laurent) + by stan.aopsys with esmtp (Exim 4.44) + id 1DBdPa-0001UV-T4; Wed, 16 Mar 2005 19:38:30 +0100 +To: "Merlin Moncure" +Cc: +Subject: Re: Speeding up select distinct +References: <6EE64EF3AB31D5448D0007DD34EEB3412A7650@Herge.rcsinc.local> +From: Laurent Martelli +Organization: AOPSYS +Date: Wed, 16 Mar 2005 19:38:30 +0100 +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A7650@Herge.rcsinc.local> + (Merlin Moncure's message of "Wed, 16 Mar 2005 13:19:09 -0500") +Message-ID: <877jk74es9.fsf@stan.aopsys> +User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/20.7 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/337 +X-Sequence-Number: 11042 + +>>>>> "Merlin" == Merlin Moncure writes: + + >> Consider this query: + >> + >> SELECT distinct owner from pictures; + + Merlin> [...] + >> Any ideas, apart from more or less manually maintaining a list of + >> distinct owners in another table ? + + Merlin> you answered your own question. With a 20 row owners table, + Merlin> you should be directing your efforts there group by is + Merlin> faster than distinct, but both are very wasteful and + Merlin> essentially require s full seqscan of the detail table. + + Merlin> With a little hacking, you can change 'manual maintenance' + Merlin> to 'automatic maintenance'. + + Merlin> 1. create table owner as select distinct owner from + Merlin> pictures; 2. alter table owner add constraint + Merlin> owner_pkey(owner); 3. alter table pictures add constraint + Merlin> ri_picture_owner(owner) references owner; 4. make a little + Merlin> append_ownder function which adds an owner to the owner + Merlin> table if there is not already one there. Inline this to your + Merlin> insert statement on pictures. + +I just wished there was a means to fully automate all this and render +it transparent to the user, just like an index. + + Merlin> Voila! Merlin p.s. normalize your data always! + +I have this: + +pictures( + PictureID serial PRIMARY KEY, + Owner integer NOT NULL REFERENCES users, + [...]); +CREATE TABLE users ( + UserID serial PRIMARY KEY, + Name character varying(255), + [...]); + +Isn't it normalized ? + +-- +Laurent Martelli +laurent@aopsys.com Java Aspect Components +http://www.aopsys.com/ http://jac.objectweb.org + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 18:41:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D612956588 + for ; + Wed, 16 Mar 2005 18:41:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00738-06 + for ; + Wed, 16 Mar 2005 18:41:52 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A8B4C565B4 + for ; + Wed, 16 Mar 2005 18:41:51 +0000 (GMT) +Received: from dyn-70-66.tor.dsl.tht.net (dyn-70-66.tor.dsl.tht.net + [134.22.70.66]) by tht.net (Postfix) with ESMTP + id 66C2D76B09; Wed, 16 Mar 2005 13:41:55 -0500 (EST) +Subject: Re: Speeding up select distinct +From: Rod Taylor +To: Laurent Martelli +Cc: pgsql-performance@postgresql.org +In-Reply-To: <87br9j4f4d.fsf@stan.aopsys> +References: <87k6o74gms.fsf@stan.aopsys> <1110996623.1132.244.camel@home> + <87br9j4f4d.fsf@stan.aopsys> +Content-Type: text/plain +Date: Wed, 16 Mar 2005 13:41:04 -0500 +Message-Id: <1110998464.1132.252.camel@home> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.0 FreeBSD GNOME Team Port +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/338 +X-Sequence-Number: 11043 + +On Wed, 2005-03-16 at 19:31 +0100, Laurent Martelli wrote: +> >>>>> "Rod" == Rod Taylor writes: +> +> Rod> On Wed, 2005-03-16 at 18:58 +0100, Laurent Martelli wrote: +> >> Consider this query: +> >> +> >> SELECT distinct owner from pictures; +> +> Rod> The performance has nothing to do with the number of rows +> Rod> returned, but rather the complexity of calculations and amount +> Rod> of data to sift through in order to find it. +> +> Yes, but I thought that an index might be able to know what distinct +> values there are and help optime that query very much. + +The index does know. You just have to visit all of the pages within the +index to find out, which it does, and that's why you dropped 10ms. + +But if you want a sub ms query, you're going to have to normalize the +structure. + +-- + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 18:57:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F6DA56649 + for ; + Wed, 16 Mar 2005 18:57:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07667-08 + for ; + Wed, 16 Mar 2005 18:57:05 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 14B0B54D6F + for ; + Wed, 16 Mar 2005 18:56:57 +0000 (GMT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Subject: Re: Speeding up select distinct +Date: Wed, 16 Mar 2005 13:56:07 -0500 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A7651@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Speeding up select distinct +Thread-Index: AcUqV1v8veryKcdWQc+fOwgkUV4ERAAAUCWA +From: "Merlin Moncure" +To: "Laurent Martelli" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/339 +X-Sequence-Number: 11044 + +> I just wished there was a means to fully automate all this and render +> it transparent to the user, just like an index. +>=20 +> Merlin> Voila! Merlin p.s. normalize your data always! +>=20 +> I have this: +>=20 +> pictures( +> PictureID serial PRIMARY KEY, +> Owner integer NOT NULL REFERENCES users, +> [...]); +> CREATE TABLE users ( +> UserID serial PRIMARY KEY, +> Name character varying(255), +> [...]); +>=20 +> Isn't it normalized ? + +try: +select * from users where UserID in (select pictureId from pictures); +select * userid from users intersect select pictureid from pictures; +select distinct userid, [...] from users, pictures where user userid =3D +pictureid) + +if none of these give you what you want then you can solve this with a +new tble, picture_user using the instructions I gave previously. + +Not sure if your data is normalized, but ISTM you are over-using +surrogate keys. It may not be possible, but consider downgrading ID +columns to unique and picking a natural key. Now you get better benefit +of RI and you can sometimes remove joins from certain queries. + +Rule: use natural keys when you can, surrogate keys when you have to. +Corollary: use domains for fields used in referential integrity. + +Merlin + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 19:46:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6645055683 + for ; + Wed, 16 Mar 2005 19:45:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81666-05 + for ; + Wed, 16 Mar 2005 19:45:40 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 214AF56702 + for ; + Wed, 16 Mar 2005 19:45:39 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DBeSM-0001Cu-00; Wed, 16 Mar 2005 14:45:26 -0500 +To: Josh Berkus +Cc: Greg Stark , David Brown , + Gregory Stark +Subject: Re: cpu_tuple_cost +References: <87psy1mq66.fsf@stark.xeocode.com> + <42377293.1010801@bigpond.net.au> <87acp4kq9o.fsf@stark.xeocode.com> + <200503161003.10916.josh@agliodbs.com> +In-Reply-To: <200503161003.10916.josh@agliodbs.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 16 Mar 2005 14:45:26 -0500 +Message-ID: <87psxzjrxl.fsf@stark.xeocode.com> +Lines: 24 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.019 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/340 +X-Sequence-Number: 11045 + + +Josh Berkus writes: + +> Although I can point out that you left out the fact that the disk needs to do +> a seek to find the beginning of the seq scan area, and even then some file +> fragmentation is possible. Finally, I've never seen PostgreSQL manage more +> than 70% of the maximum read rate, and in most cases more like 30%. + +Hm. I just did a quick test. It wasn't really long enough to get a good +estimate, but it seemed to reach about 30MB/s on this drive that's only +capable of 40-50MB/s depending on the location on the platters. + +That's true though, some of my calculated 25% random seeks could be caused by +fragmentation. But it seems like that would be a small part. + +> > So what's going on with the empirically derived value of 4? +> +> It's not empirically derived; it's a value we plug into an +> internal-to-postgresql formula. + +I thought Tom said he got the value by doing empirical tests. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 20:10:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9579255720 + for ; + Wed, 16 Mar 2005 20:10:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88382-04 + for ; + Wed, 16 Mar 2005 20:10:29 +0000 (GMT) +Received: from linares.terra.com.br (linares.terra.com.br [200.154.55.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 2688656561 + for ; + Wed, 16 Mar 2005 20:10:28 +0000 (GMT) +Received: from estero.terra.com.br (estero.terra.com.br [200.154.55.138]) + by linares.terra.com.br (Postfix) with ESMTP id C964FDDD0C4 + for ; + Wed, 16 Mar 2005 17:10:28 -0300 (BRT) +X-Terra-Karma: -2% +X-Terra-Hash: 8cbf0ac0ec4001ae18f3216749fabd71 +Received-SPF: pass (estero.terra.com.br: domain of terra.com.br designates + 200.154.55.138 as permitted sender) client-ip=200.154.55.138; + envelope-from=rodrigo.miguel@terra.com.br; helo=rmsmnote; +Received: from rmsmnote (unknown [200.207.51.149]) + (authenticated user rodrmigu) + by estero.terra.com.br (Postfix) with ESMTP id 757D5F4126 + for ; + Wed, 16 Mar 2005 17:10:27 -0300 (BRT) +From: "Rodrigo Moreno" +To: +Subject: Help to find out problem with joined tables +Date: Wed, 16 Mar 2005 17:10:17 -0300 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 +Thread-Index: AcUo2ejgW/rXrgWtRJCZrWmu7U1CHgBiUP2w +In-Reply-To: <200503142105.j2EL5mkj026255@hosting.commandprompt.com> +Message-Id: <20050316201027.757D5F4126@estero.terra.com.br> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.376 tagged_above=0 required=5 tests=DNS_FROM_RFC_POST +X-Spam-Level: * +X-Archive-Number: 200503/341 +X-Sequence-Number: 11046 + +Hi all, + +Could someone explain me when I joined tree tables the querys that took +about 1sec to finish, takes 17secs to complete when I put tree tables joined +? + +If I join movest/natope, it's fast, if I join movest/produt, it's fast too, +but when I put a third joined table, forget, it's very slow. + +All tables are vacuumed by vacummdb --full --analyze, every night +All Indexes are reindexed every night + +TABLES: +------- + +Movest: +- 2 milions rows, indexed +Natope: 30 rows PK(natope_id) +Produt: +- 1400 Rows PK(codpro) + +EXPLAINS: +--------- +explain analyze +select a.codpro, a.datmov, a.vlrtot +from movest a, natope b +where a.tipmov = 'S' + and a.codpro = 629001 + and a.datmov between '2005-03-01' and '2005-03-31' + and a.natope = b.natope_id + +"Merge Join (cost=35.68..36.23 rows=1 width=25) (actual time=2.613..2.840 +rows=6 loops=1)" +" Merge Cond: ("outer".natope = "inner"."?column2?")" +" -> Sort (cost=32.02..32.04 rows=7 width=35) (actual time=1.296..1.314 +rows=10 loops=1)" +" Sort Key: a.natope" +" -> Index Scan using ix_movest_03 on movest a (cost=0.00..31.92 +rows=7 width=35) (actual time=0.507..1.215 rows=10 loops=1)" +" Index Cond: ((codpro = 629001::numeric) AND (datmov >= +'2005-03-01'::date) AND (datmov <= '2005-03-31'::date))" +" Filter: (tipmov = 'S'::bpchar)" +" -> Sort (cost=3.65..3.82 rows=66 width=4) (actual time=1.132..1.203 +rows=49 loops=1)" +" Sort Key: (b.natope_id)::numeric" +" -> Seq Scan on natope b (cost=0.00..1.66 rows=66 width=4) (actual +time=0.117..0.500 rows=66 loops=1)" +"Total runtime: 3.077 ms" + + +--------------- +explain analyze +select a.codpro, a.datmov, a.vlrtot +from movest a, natope b, produt c +where a.tipmov = 'S' + and a.codpro = 629001 + and a.datmov between '2005-03-01' and '2005-03-31' + and a.natope = b.natope_id + and a.codpro = c.codpro + +"Nested Loop (cost=35.68..144.57 rows=2 width=25) (actual +time=2838.121..17257.168 rows=6 loops=1)" +" -> Merge Join (cost=35.68..36.23 rows=1 width=25) (actual +time=1.808..2.280 rows=6 loops=1)" +" Merge Cond: ("outer".natope = "inner"."?column2?")" +" -> Sort (cost=32.02..32.04 rows=7 width=35) (actual +time=0.485..0.504 rows=10 loops=1)" +" Sort Key: a.natope" +" -> Index Scan using ix_movest_03 on movest a +(cost=0.00..31.92 rows=7 width=35) (actual time=0.135..0.390 rows=10 +loops=1)" +" Index Cond: ((codpro = 629001::numeric) AND (datmov >= +'2005-03-01'::date) AND (datmov <= '2005-03-31'::date))" +" Filter: (tipmov = 'S'::bpchar)" +" -> Sort (cost=3.65..3.82 rows=66 width=4) (actual +time=1.114..1.209 rows=49 loops=1)" +" Sort Key: (b.natope_id)::numeric" +" -> Seq Scan on natope b (cost=0.00..1.66 rows=66 width=4) +(actual time=0.058..0.485 rows=66 loops=1)" +" -> Seq Scan on produt c (cost=0.00..108.26 rows=8 width=4) (actual +time=2688.356..2875.743 rows=1 loops=6)" +" Filter: ((codpro)::numeric = 629001::numeric)" +"Total runtime: 17257.865 ms" + +Best Regards +Rodrigo Moreno + + + +From pgsql-performance-owner@postgresql.org Wed Mar 16 20:35:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3027B56561 + for ; + Wed, 16 Mar 2005 20:35:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73976-01 + for ; + Wed, 16 Mar 2005 20:35:44 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 4504C56482 + for ; + Wed, 16 Mar 2005 20:35:44 +0000 (GMT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 755AD35209; Wed, 16 Mar 2005 12:35:45 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 737DE351EF; Wed, 16 Mar 2005 12:35:45 -0800 (PST) +Date: Wed, 16 Mar 2005 12:35:45 -0800 (PST) +From: Stephan Szabo +To: David Gagnon +Cc: Alvaro Herrera , + Michael Fuhr , pgsql-performance@postgresql.org +Subject: Re: Performance problem on delete from for 10k rows. May +In-Reply-To: <4238668C.5080002@siunik.com> +Message-ID: <20050316092030.S57120@megazone.bigpanda.com> +References: <42375281.9090102@siunik.com> + <20050315233834.GA68209@winnie.fuhr.org> + <4238322F.10302@siunik.com> <20050316143511.GC21935@dcc.uchile.cl> + <42384D26.4020903@siunik.com> + <20050316082636.J53581@megazone.bigpanda.com> + <4238668C.5080002@siunik.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/342 +X-Sequence-Number: 11047 + +On Wed, 16 Mar 2005, David Gagnon wrote: + +> +> +> Stephan Szabo wrote: +> +> >On Wed, 16 Mar 2005, David Gagnon wrote: +> > +> > +> > +> >>Hi +> >> +> >> +> >> +> >>>>I rerun the example with the debug info turned on in postgresl. As you +> >>>>can see all dependent tables (that as foreign key on table IC) are +> >>>>emptied before the DELETE FROM IC statement is issued. For what I +> >>>>understand the performance problem seem to came from those selects that +> >>>>point back to IC ( LOG: statement: SELECT 1 FROM ONLY "public"."ic" x +> >>>>WHERE "icnum" = $1 FOR UPDATE OF x). There are 6 of them. I don't know +> >>>>where they are comming from. +> >>>> +> >>>> +> >>>> +> >>>> +> >>>I think they come from the FK checking code. Try to run a VACUUM on the +> >>>IC table just before you delete from the other tables; that should make +> >>>the checking almost instantaneous (assuming the vacuuming actually +> >>>empties the table, which would depend on other transactions). +> >>> +> >>> +> >>> +> >>> +> >>I'll try to vaccum first before I start the delete to see if it change +> >>something. +> >> +> >>There is probably a good reason why but I don't understant why in a +> >>foreign key check it need to check the date it points to. +> >> +> >>You delete a row from table IC and do a check for integrity on tables +> >>that have foreign keys on IC (make sense). But why checking back IC? +> >> +> >> +> > +> >Because in the general case there might be another row which satisfies the +> >constraint added between the delete and the check. +> > +> > +> > +> So it's means if I want to reset the shema with DELETE FROM Table +> statemnets I must first drop indexes, delete the data and then recreate +> indexes and reload stored procedure. +> +> Or I can suspend the foreign key check in the db right. I saw something +> on this. Is that possible to do this from the JDBC interface? + +I think you can remove the constraints and re-add them after which should +hopefully be fast (a vacuum on the tables after the delete and before the +add might help, but I'm not sure). You could potentially defer the +constraint if it were deferrable, but I don't think that would help any. + +From pgsql-performance-owner@postgresql.org Wed Mar 16 20:42:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CD1BD55720 + for ; + Wed, 16 Mar 2005 20:42:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79728-05 + for ; + Wed, 16 Mar 2005 20:42:37 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id B27CF5567D + for ; + Wed, 16 Mar 2005 20:42:35 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2GKgIWc008150; + Wed, 16 Mar 2005 15:42:18 -0500 (EST) +To: Josh Berkus +Cc: Greg Stark , David Brown , + Gregory Stark +Subject: Re: cpu_tuple_cost +In-reply-to: <200503161003.10916.josh@agliodbs.com> +References: <87psy1mq66.fsf@stark.xeocode.com> + <42377293.1010801@bigpond.net.au> + <87acp4kq9o.fsf@stark.xeocode.com> + <200503161003.10916.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Wed, 16 Mar 2005 10:03:10 -0800" +Date: Wed, 16 Mar 2005 15:42:18 -0500 +Message-ID: <8149.1111005738@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/343 +X-Sequence-Number: 11048 + +Josh Berkus writes: +>> So what's going on with the empirically derived value of 4? + +> It's not empirically derived; + +Yes it is. I ran experiments back in the late 90s to derive it. +Check the archives. + +Disks have gotten noticeably bigger since then, but I don't think +the ratio of seek time to rotation rate has changed much. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 17 00:26:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A8AA2565DC + for ; + Thu, 17 Mar 2005 00:26:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76833-04 + for ; + Thu, 17 Mar 2005 00:26:00 +0000 (GMT) +Received: from gizmo04bw.bigpond.com (gizmo04bw.bigpond.com [144.140.70.14]) + by svr1.postgresql.org (Postfix) with SMTP id 49AB5565DD + for ; + Thu, 17 Mar 2005 00:25:57 +0000 (GMT) +Received: (qmail 3344 invoked from network); 17 Mar 2005 00:25:58 -0000 +Received: from unknown (HELO bwmam05.bigpond.com) (144.135.24.81) + by gizmo04bw.bigpond.com with SMTP; 17 Mar 2005 00:25:58 -0000 +Received: from cpe-203-45-203-73.qld.bigpond.net.au ([203.45.203.73]) by + bwmam05.bigpond.com(MAM REL_3_4_2a 44/8555369) with SMTP id + 8555369; Thu, 17 Mar 2005 10:25:58 +1000 +Message-ID: <4238CE87.1040904@bigpond.net.au> +Date: Thu, 17 Mar 2005 10:25:43 +1000 +From: David Brown +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Josh Berkus +Subject: Re: multi-column index +References: <42385A1B.9090305@ibcp.fr> <200503161009.24713.josh@agliodbs.com> +In-Reply-To: <200503161009.24713.josh@agliodbs.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.728 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_WHOIS +X-Spam-Level: +X-Archive-Number: 200503/344 +X-Sequence-Number: 11049 + +Whoa Josh! I don't believe you're going to reduce the cost by 10 times +through a bit of tweaking - not without lowering the sequential scan +cost as well. + +The only thing I can think of is perhaps his primary index drastically +needs repacking. Otherwise, isn't there a real anomaly here? Halving the +key width might account for some of it, but it's still miles out of court. + +Actually, I'm surprised the planner came up with such a low cost for the +single column index, unless ... perhaps correlation statistics aren't +used when determining costs for multi-column indexes? + +Josh Berkus wrote: + +>Pretty simple, really. Look at the cost calculations for the index scan for +>the multi-column index. PostgreSQL believes that: +>The cost of a seq scan is 4788.14 +>The cost of an 2-column index scan is 36720.39 +>The cost of a 1-column index scan is 916.24 +> +>Assuming that you ran each of these queries multiple times to eliminate +>caching as a factor, the issue is that the cost calculations are wrong. We +>give you a number of GUC variables to change that: +>effective_cache_size +>random_page_cost +>cpu_tuple_cost +>etc. +> +>See the RUNTIME-CONFIGURATION docs for more details. +> + +From pgsql-performance-owner@postgresql.org Thu Mar 17 02:29:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B6B1F56440 + for ; + Thu, 17 Mar 2005 02:29:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08622-10 + for ; + Thu, 17 Mar 2005 02:29:24 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 8200752A62 + for ; + Thu, 17 Mar 2005 02:29:23 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DBkl7-0002Qy-00; Wed, 16 Mar 2005 21:29:13 -0500 +To: Laurent Martelli +Cc: PFC , + pgsql-performance@postgresql.org +Subject: Re: Speeding up select distinct +References: <87k6o74gms.fsf@stan.aopsys> + <87fyyv4f6l.fsf@stan.aopsys> +In-Reply-To: <87fyyv4f6l.fsf@stan.aopsys> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 16 Mar 2005 21:29:13 -0500 +Message-ID: <87ekefj98m.fsf@stark.xeocode.com> +Lines: 16 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.018 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/345 +X-Sequence-Number: 11050 + +Laurent Martelli writes: + +> PFC> SELECT owner from pictures group by owner; +> +> That's a slight improvement, but there's still a seq scan on pictures: + +It should be a sequential scan. An index will be slower. + +> HashAggregate (cost=114.38..114.38 rows=21 width=4) (actual time=7.585..7.605 rows=21 loops=1) +> -> Seq Scan on pictures (cost=0.00..103.70 rows=4270 width=4) (actual time=0.015..3.272 rows=4270 loops=1) +> Total runtime: 7.719 ms + +That's the best plan for this query. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Thu Mar 17 03:19:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DDDA2569AD + for ; + Thu, 17 Mar 2005 03:19:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41783-10 + for ; + Thu, 17 Mar 2005 03:19:13 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 7DB1856991 + for ; + Thu, 17 Mar 2005 03:19:12 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2H3JDYD019589; + Wed, 16 Mar 2005 22:19:13 -0500 (EST) +To: David Brown +Cc: Josh Berkus +Subject: Re: multi-column index +In-reply-to: <4238CE87.1040904@bigpond.net.au> +References: <42385A1B.9090305@ibcp.fr> <200503161009.24713.josh@agliodbs.com> + <4238CE87.1040904@bigpond.net.au> +Comments: In-reply-to David Brown + message dated "Thu, 17 Mar 2005 10:25:43 +1000" +Date: Wed, 16 Mar 2005 22:19:13 -0500 +Message-ID: <19588.1111029553@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/346 +X-Sequence-Number: 11051 + +David Brown writes: +> Actually, I'm surprised the planner came up with such a low cost for the +> single column index, unless ... perhaps correlation statistics aren't +> used when determining costs for multi-column indexes? + +The correlation calculation for multi-column indexes is pretty whacked +out pre-8.0. I don't think it's that great in 8.0 either --- we really +need to make ANALYZE calculate the correlation explicitly for each +index, probably, rather than trying to use per-column correlations. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 17 04:42:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B949569BF + for ; + Thu, 17 Mar 2005 04:42:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74793-02 + for ; + Thu, 17 Mar 2005 04:42:23 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id E89CA569BB + for ; + Thu, 17 Mar 2005 04:42:22 +0000 (GMT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j2H4gJaf023626 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Wed, 16 Mar 2005 21:42:21 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j2H4gIDi055917; + Wed, 16 Mar 2005 21:42:18 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j2H4gING055916; + Wed, 16 Mar 2005 21:42:18 -0700 (MST) (envelope-from mfuhr) +Date: Wed, 16 Mar 2005 21:42:18 -0700 +From: Michael Fuhr +To: Rodrigo Moreno +Cc: pgsql-performance@postgresql.org +Subject: Re: Help to find out problem with joined tables +Message-ID: <20050317044217.GA23968@winnie.fuhr.org> +References: <200503142105.j2EL5mkj026255@hosting.commandprompt.com> + <20050316201027.757D5F4126@estero.terra.com.br> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050316201027.757D5F4126@estero.terra.com.br> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/347 +X-Sequence-Number: 11052 + +On Wed, Mar 16, 2005 at 05:10:17PM -0300, Rodrigo Moreno wrote: + +> If I join movest/natope, it's fast, if I join movest/produt, it's fast too, +> but when I put a third joined table, forget, it's very slow. + +What version of PostgreSQL are you using? + +> All tables are vacuumed by vacummdb --full --analyze, every night +> All Indexes are reindexed every night + +How many updates/deletes do the tables see between vacuums? + +> Movest: +- 2 milions rows, indexed +> Natope: 30 rows PK(natope_id) +> Produt: +- 1400 Rows PK(codpro) + +Could you show the table definitions, or at least the definitions +for the relevant columns and indexes? + +> -> Seq Scan on produt c (cost=0.00..108.26 rows=8 width=4) (actual +> time=2688.356..2875.743 rows=1 loops=6) +> Filter: ((codpro)::numeric = 629001::numeric) + +What type is produt.codpro? You might be missing a potential index +scan here due to mismatched types. + +The times (2688.356..2875.743) here look odd, although I might be +overlooking or misinterpreting something. I don't know what else +might cause that, but one thing that can is a lot of dead tuples +in the table, hence my question about how much activity the tables +see between vacuums. Maybe somebody else can provide a better +explanation. + +-- +Michael Fuhr +http://www.fuhr.org/~mfuhr/ + +From pgsql-performance-owner@postgresql.org Thu Mar 17 06:16:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B9E156482 + for ; + Thu, 17 Mar 2005 06:16:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96536-09 + for ; + Thu, 17 Mar 2005 06:16:28 +0000 (GMT) +Received: from smtpout02-03.prod.mesa1.secureserver.net + (smtpout02-03.prod.mesa1.secureserver.net [64.202.165.193]) + by svr1.postgresql.org (Postfix) with SMTP id 8715656537 + for ; + Thu, 17 Mar 2005 06:16:24 +0000 (GMT) +Received: (qmail 16234 invoked from network); 17 Mar 2005 06:16:24 -0000 +Received: from unknown (HELO gem-wbe01.mesa1.secureserver.net) (64.202.189.26) + by smtpout02-03.prod.mesa1.secureserver.net with SMTP; + 17 Mar 2005 06:16:24 -0000 +Received: (qmail 12921 invoked by uid 99); 17 Mar 2005 06:16:24 -0000 +Message-ID: <20050317061624.12920.qmail@gem-wbe01.mesa1.secureserver.net> +Date: Wed, 16 Mar 2005 23:16:24 -0700 +From: mark.lubratt@indeq.com +Subject: Join method influences scan method? +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: TEXT/plain; CHARSET=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.304 tagged_above=0 required=5 tests=AWL, + NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200503/348 +X-Sequence-Number: 11053 + +This apparently didn't go through the first time; so, I'm reposting... +------------------------------------------------------------------------------------- +Hello! + +First off, I'm running 8.0.1 on Win2000 Server. Vacuum analyze is done +every night. Query cost parameters are standard, I've only bumped the +estimated_cache_size up to 50000; shared_buffers=15000. + +I've been working on optimizing a query. In the process, I've been +playing around with Tow's method from "SQL Tuning." He seems pretty +enamored with nested loops over hash joins or merge joins. So, I +thought +I'd give that a try. Here's the explain analyze prior to my little +adventure: + +QUERY PLAN +Subquery Scan view_get_all_user_award2 (cost=1091.20..1116.09 rows=524 +width=493) (actual time=499.000..499.000 rows=368 loops=1) + - Unique (cost=1091.20..1110.85 rows=524 width=114) (actual +time=499.000..499.000 rows=368 loops=1) + - Sort (cost=1091.20..1092.51 rows=524 width=114) (actual +time=499.000..499.000 rows=1103 loops=1) + Sort Key: c.job_id, g.person_id, c.job_no, b.deadline, +c.name, bid_date(c.job_id), c.miscq, c.city, COALESCE(((c.city)::text || +COALESCE((', '::text || (c.st)::text), ''::text)), (COALESCE(c.st, +''::character varying))::text), c.st, CASE WHEN (c.file_loc = 0) THEN +'No +Bid'::character varying WHEN (c.file_loc = -1) THEN 'Bid +Board'::character +varying WHEN (c.file_loc = -2) THEN 'Lost Job'::character varying WHEN +(c.file_loc = -3) THEN 'See Job Notes'::character varying WHEN +((c.file_loc < -3) OR (c.file_loc IS NULL)) THEN ''::character varying +WHEN (h.initials IS NOT NULL) THEN h.initials ELSE 'Unknown +person'::character varying END, j.name, c.s_team, c.file_loc + - Hash Join (cost=848.87..1067.53 rows=524 width=114) +(actual time=171.000..484.000 rows=1103 loops=1) + Hash Cond: ("outer".company_id = "inner".company_id) + - Nested Loop (cost=805.21..1005.53 rows=524 +width=122) (actual time=156.000..314.000 rows=1103 loops=1) + Join Filter: (("inner".person_id = +"outer".person_id) OR ("position"(("inner".s_team)::text, +("outer".initials)::text) 0)) + - Seq Scan on person g (cost=0.00..1.34 +rows=1 width=11) (actual time=0.000..0.000 rows=1 loops=1) + Filter: (person_id = 1) + - Hash Join (cost=805.21..988.81 rows=879 +width=122) (actual time=156.000..251.000 rows=5484 loops=1) + Hash Cond: ("outer".company_id = +"inner".company_id) + - Hash Join (cost=761.55..931.96 +rows=879 width=103) (actual time=156.000..188.000 rows=5484 loops=1) + Hash Cond: ("outer".company_id = +"inner".company_id) + - Seq Scan on call_list f +(cost=0.00..78.46 rows=4746 width=8) (actual time=0.000..16.000 +rows=4752 +loops=1) + - Hash (cost=761.11..761.11 +rows=176 width=95) (actual time=156.000..156.000 rows=0 loops=1) + - Hash Join +(cost=505.90..761.11 rows=176 width=95) (actual time=94.000..140.000 +rows=1079 loops=1) + Hash Cond: +("outer".job_id = "inner".job_id) + Join Filter: +("outer".won_heat OR "outer".won_vent OR "outer".won_tc OR ("inner".heat +AND "outer".bid_heat AND ("outer".won_heat IS NULL)) OR ("inner".vent +AND +"outer".bid_vent AND ("outer".won_vent IS NULL)) OR ("inner".tc AND +"outer".bid_tc AND ("outer".won_tc IS NULL))) + - Seq Scan on +builder_list d (cost=0.00..212.26 rows=7687 width=14) (actual +time=0.000..16.000 rows=7758 loops=1) + Filter: (role = +'C'::bpchar) + - Hash +(cost=505.55..505.55 rows=138 width=102) (actual time=94.000..94.000 +rows=0 loops=1) + - Hash Join +(cost=268.41..505.55 rows=138 width=102) (actual time=47.000..94.000 +rows=443 loops=1) + Hash Cond: +("outer".job_id = "inner".job_id) + - Seq +Scan on builder_list i (cost=0.00..212.26 rows=2335 width=8) (actual +time=0.000..47.000 rows=2245 loops=1) + +Filter: (role = 'E'::bpchar) + - Hash +(cost=268.06..268.06 rows=139 width=94) (actual time=47.000..47.000 +rows=0 loops=1) + - +Hash Join (cost=156.15..268.06 rows=139 width=94) (actual +time=31.000..47.000 rows=451 loops=1) + + +Hash Cond: ("outer".file_loc = "inner".person_id) + + +- Hash Join (cost=154.81..264.51 rows=166 width=87) (actual +time=31.000..47.000 rows=694 loops=1) + + + Hash Cond: ("outer".job_id = "inner".job_id) + + + - Seq Scan on job c (cost=0.00..78.57 rows=2357 width=79) (actual +time=0.000..0.000 rows=2302 loops=1) + + + - Hash (cost=154.40..154.40 rows=166 width=8) (actual +time=31.000..31.000 rows=0 loops=1) + + + - Hash Join (cost=1.18..154.40 rows=166 width=8) (actual +time=0.000..31.000 rows=694 loops=1) + + + Hash Cond: ("outer".status_id = "inner".status_id) + + + - Seq Scan on status_list b (cost=0.00..139.96 +rows=2320 width=12) (actual time=0.000..15.000 rows=2302 loops=1) + + + Filter: active + + + - Hash (cost=1.18..1.18 rows=1 width=4) (actual +time=0.000..0.000 rows=0 loops=1) + + + - Seq Scan on status a (cost=0.00..1.18 rows=1 +width=4) (actual time=0.000..0.000 rows=1 loops=1) + + + Filter: ((name)::text = 'Awaiting +Award'::text) + + +- Hash (cost=1.27..1.27 rows=27 width=11) (actual time=0.000..0.000 +rows=0 loops=1) + + + - Seq Scan on person h (cost=0.00..1.27 rows=27 width=11) (actual +time=0.000..0.000 rows=27 loops=1) + - Hash (cost=40.53..40.53 rows=1253 +width=27) (actual time=0.000..0.000 rows=0 loops=1) + - Seq Scan on company j +(cost=0.00..40.53 rows=1253 width=27) (actual time=0.000..0.000 +rows=1254 +loops=1) + - Hash (cost=40.53..40.53 rows=1253 width=4) +(actual time=15.000..15.000 rows=0 loops=1) + - Seq Scan on company e (cost=0.00..40.53 +rows=1253 width=4) (actual time=0.000..0.000 rows=1254 loops=1) +Total runtime: 499.000 ms + + +As you can see, it's almost all hash joins and sequential scans. I +tried +explain analyze again after setting enable_hashjoin=false and the +planner +started using merge joins. So, I set enable_mergejoin=false and ran it +again. Here is the resulting explain analyze: + +QUERY PLAN +Subquery Scan view_get_all_user_award2 (cost=9525.65..9550.54 rows=524 +width=493) (actual time=531.000..547.000 rows=368 loops=1) + - Unique (cost=9525.65..9545.30 rows=524 width=114) (actual +time=531.000..547.000 rows=368 loops=1) + - Sort (cost=9525.65..9526.96 rows=524 width=114) (actual +time=531.000..531.000 rows=1103 loops=1) + Sort Key: c.job_id, g.person_id, c.job_no, b.deadline, +c.name, bid_date(c.job_id), c.miscq, c.city, COALESCE(((c.city)::text || +COALESCE((', '::text || (c.st)::text), ''::text)), (COALESCE(c.st, +''::character varying))::text), c.st, CASE WHEN (c.file_loc = 0) THEN +'No +Bid'::character varying WHEN (c.file_loc = -1) THEN 'Bid +Board'::character +varying WHEN (c.file_loc = -2) THEN 'Lost Job'::character varying WHEN +(c.file_loc = -3) THEN 'See Job Notes'::character varying WHEN +((c.file_loc < -3) OR (c.file_loc IS NULL)) THEN ''::character varying +WHEN (h.initials IS NOT NULL) THEN h.initials ELSE 'Unknown +person'::character varying END, j.name, c.s_team, c.file_loc + - Nested Loop (cost=1.30..9501.98 rows=524 width=114) +(actual time=0.000..500.000 rows=1103 loops=1) + Join Filter: (("inner".person_id = +"outer".person_id) +OR ("position"(("inner".s_team)::text, ("outer".initials)::text) 0)) + - Seq Scan on person g (cost=0.00..1.34 rows=1 +width=11) (actual time=0.000..0.000 rows=1 loops=1) + Filter: (person_id = 1) + - Nested Loop (cost=1.30..9464.56 rows=1463 +width=114) (actual time=0.000..360.000 rows=5484 loops=1) + - Nested Loop (cost=1.30..5350.20 rows=174 +width=118) (actual time=0.000..268.000 rows=1079 loops=1) + - Nested Loop (cost=1.30..4399.46 +rows=174 width=114) (actual time=0.000..237.000 rows=1079 loops=1) + Join Filter: ("inner".won_heat OR +"inner".won_vent OR "inner".won_tc OR ("outer".heat AND "inner".bid_heat +AND ("inner".won_heat IS NULL)) OR ("outer".vent AND "inner".bid_vent +AND +("inner".won_vent IS NULL)) OR ("outer".tc AND "inner".bid_tc AND +("inner".won_tc IS NULL))) + - Nested Loop +(cost=1.30..3207.87 rows=138 width=121) (actual time=0.000..221.000 +rows=443 loops=1) + - Nested Loop +(cost=1.30..2453.84 rows=138 width=102) (actual time=0.000..221.000 +rows=443 loops=1) + - Nested Loop +(cost=1.30..1258.83 rows=139 width=94) (actual time=0.000..189.000 +rows=451 loops=1) + Join Filter: +("outer".file_loc = "inner".person_id) + - Nested Loop +(cost=0.00..1156.69 rows=166 width=87) (actual time=0.000..31.000 +rows=694 loops=1) + - Nested +Loop (cost=0.00..170.14 rows=166 width=8) (actual time=0.000..0.000 +rows=694 loops=1) + Join +Filter: ("outer".status_id = "inner".status_id) + - +Seq Scan on status a (cost=0.00..1.18 rows=1 width=4) (actual +time=0.000..0.000 rows=1 loops=1) + + +Filter: ((name)::text = 'Awaiting Award'::text) + - +Seq Scan on status_list b (cost=0.00..139.96 rows=2320 width=12) +(actual +time=0.000..0.000 rows=2302 loops=1) + + +Filter: active + - Index +Scan using job_pkey on job c (cost=0.00..5.93 rows=1 width=79) (actual +time=0.000..0.023 rows=1 loops=694) + +Index +Cond: (c.job_id = "outer".job_id) + - Materialize +(cost=1.30..1.57 rows=27 width=11) (actual time=0.000..0.069 rows=27 +loops=694) + - Seq +Scan on person h (cost=0.00..1.27 rows=27 width=11) (actual +time=0.000..0.000 rows=27 loops=1) + - Index Scan using +idx_builder_list_job_id on builder_list i (cost=0.00..8.57 rows=2 +width=8) (actual time=0.000..0.000 rows=1 loops=451) + Index Cond: +(i.job_id = "outer".job_id) + Filter: (role = +'E'::bpchar) + - Index Scan using +company_pkey on company j (cost=0.00..5.45 rows=1 width=27) (actual +time=0.000..0.000 rows=1 loops=443) + Index Cond: +("outer".company_id = j.company_id) + - Index Scan using +idx_builder_list_job_id on builder_list d (cost=0.00..8.57 rows=5 +width=14) (actual time=0.000..0.036 rows=3 loops=443) + Index Cond: (d.job_id = +"outer".job_id) + Filter: (role = 'C'::bpchar) + - Index Scan using company_pkey on +company e (cost=0.00..5.45 rows=1 width=4) (actual time=0.029..0.029 +rows=1 loops=1079) + Index Cond: ("outer".company_id = +e.company_id) + - Index Scan using idx_company_id_call_list +on call_list f (cost=0.00..23.57 rows=6 width=8) (actual +time=0.014..0.057 rows=5 loops=1079) + Index Cond: (f.company_id = +"outer".company_id) +Total runtime: 547.000 ms + + +The total run times turn out to be anecdotally insignificant (due to +variations from one run to the next). I haven't had a chance to +quantify +the variations, I plan on doing that soon. However, now the planner is +choosing index scans for almost all the tables. Granted that the +planner +seems to have chosen a different plan, but if I compare the estimated +costs and actual time for the index scans vs. the sequential scans, it +looks like the planner should be choosing index scans, but it isn't. + +So, it would seem like my optimal plan should have hash joins with index +scans. How do I get the planner to the same conclusion? Should the +join +method influence the scan method? These seem like they should be +unrelated to me. + +Of course, all of this might be moot if my lack of knowledge is +showing... + +Any thoughts?? +Mark + + + +From pgsql-performance-owner@postgresql.org Thu Mar 17 06:41:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8080656715 + for ; + Thu, 17 Mar 2005 06:41:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05788-06 + for ; + Thu, 17 Mar 2005 06:41:18 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 9CA3856606 + for ; + Thu, 17 Mar 2005 06:41:17 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2H6fFvb020911; + Thu, 17 Mar 2005 01:41:15 -0500 (EST) +To: mark.lubratt@indeq.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Join method influences scan method? +In-reply-to: <20050317061624.12920.qmail@gem-wbe01.mesa1.secureserver.net> +References: <20050317061624.12920.qmail@gem-wbe01.mesa1.secureserver.net> +Comments: In-reply-to mark.lubratt@indeq.com + message dated "Wed, 16 Mar 2005 23:16:24 -0700" +Date: Thu, 17 Mar 2005 01:41:15 -0500 +Message-ID: <20910.1111041675@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/349 +X-Sequence-Number: 11054 + +mark.lubratt@indeq.com writes: +> So, it would seem like my optimal plan should have hash joins with index +> scans. + +No. The thing you are looking at here is a nestloop join with inner +index scan, which has to be understood as a unit even though EXPLAIN +doesn't describe it that way. The inner indexscan is repeated once +for each outer row, using a join key from the outer row as part of the +index lookup. That's simply not relevant to the other kinds of joins, +because they expect the inner and outer relations to be scanned +independently. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 17 08:09:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A36CB52A4D + for ; + Thu, 17 Mar 2005 08:09:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30336-10 + for ; + Thu, 17 Mar 2005 08:09:48 +0000 (GMT) +Received: from email.aon.at (warsl404pip8.highway.telekom.at [195.3.96.102]) + by svr1.postgresql.org (Postfix) with ESMTP id 91A0956710 + for ; + Thu, 17 Mar 2005 08:09:45 +0000 (GMT) +Received: (qmail 16934 invoked from network); 17 Mar 2005 08:09:45 -0000 +Received: from m154p025.dipool.highway.telekom.at (HELO PASCAL) ([62.46.9.57]) + (envelope-sender ) + by smarthub71.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 17 Mar 2005 08:09:45 -0000 +From: Manfred Koizar +To: David Brown +Cc: "Jim C. Nasby" , + pgsql-performance@postgresql.org, Tom Lane +Subject: Re: index scan on =, but not < ? +Date: Thu, 17 Mar 2005 09:12:42 +0100 +Message-ID: <3oei31lc0uitgvmgfbsehm4r92ad9reas3@email.aon.at> +References: <001f01c5240d$a920c8c0$0200a8c0@dell8200> + <20050309043821.GA1569@wolff.to> <20050309045519.GA509@decibel.org> + <20050309052020.GB1569@wolff.to> <20050309172238.GD528@decibel.org> + <422F93CE.10400@bigpond.net.au> +In-Reply-To: <422F93CE.10400@bigpond.net.au> +X-Mailer: Forte Agent 2.0/32.652 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.357 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/350 +X-Sequence-Number: 11055 + +On Thu, 10 Mar 2005 10:24:46 +1000, David Brown +wrote: +>What concerns me is that this all depends on the correlation factor, and +>I suspect that the planner is not giving enough weight to this. + +The planner does the right thing for correlations very close to 1 (and +-1) and for correlations near zero. For correlations somewhere between +0 and 1 the cost is estimated by interpolation, but it tends too much +towards the bad end, IMHO. + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Thu Mar 17 08:18:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DA8A56723 + for ; + Thu, 17 Mar 2005 08:18:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35133-02 + for ; + Thu, 17 Mar 2005 08:18:02 +0000 (GMT) +Received: from email.aon.at (warsl404pip6.highway.telekom.at [195.3.96.89]) + by svr1.postgresql.org (Postfix) with ESMTP id 853245670F + for ; + Thu, 17 Mar 2005 08:17:58 +0000 (GMT) +Received: (qmail 20453 invoked from network); 17 Mar 2005 08:17:58 -0000 +Received: from m154p025.dipool.highway.telekom.at (HELO PASCAL) ([62.46.9.57]) + (envelope-sender ) + by smarthub74.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 17 Mar 2005 08:17:58 -0000 +From: Manfred Koizar +To: Tom Lane +Cc: "Greg Sabino Mullane" , + pgsql-performance@postgresql.org +Subject: Re: cpu_tuple_cost +Date: Thu, 17 Mar 2005 09:20:55 +0100 +Message-ID: +References: + <1676.1110853409@sss.pgh.pa.us> +In-Reply-To: <1676.1110853409@sss.pgh.pa.us> +X-Mailer: Forte Agent 2.0/32.652 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.356 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/351 +X-Sequence-Number: 11056 + +On Mon, 14 Mar 2005 21:23:29 -0500, Tom Lane wrote: +> I think that the "reduce random_page_cost" mantra +>is not an indication that that parameter is wrong, but that the +>cost models it feeds into need more work. + +One of these areas is the cost interpolation depending on correlation. +This has been discussed on -hackes in October 2002 and August 2003 +("Correlation in cost_index()"). My Postgres installations contain the +patch presented during that discussion (and another index correlation +patch), and I use *higher* values for random_page_cost (up to 10). + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Thu Mar 17 08:48:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 167A9566D2 + for ; + Thu, 17 Mar 2005 08:48:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43676-08 + for ; + Thu, 17 Mar 2005 08:48:38 +0000 (GMT) +Received: from email.aon.at (warsl404pip7.highway.telekom.at [195.3.96.91]) + by svr1.postgresql.org (Postfix) with ESMTP id E12E956482 + for ; + Thu, 17 Mar 2005 08:48:37 +0000 (GMT) +Received: (qmail 23400 invoked from network); 17 Mar 2005 08:48:37 -0000 +Received: from m154p025.dipool.highway.telekom.at (HELO PASCAL) ([62.46.9.57]) + (envelope-sender ) + by smarthub73.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 17 Mar 2005 08:48:37 -0000 +From: Manfred Koizar +To: Tom Lane +Cc: David Brown , + Josh Berkus +Subject: Re: multi-column index +Date: Thu, 17 Mar 2005 09:51:36 +0100 +Message-ID: +References: <42385A1B.9090305@ibcp.fr> <200503161009.24713.josh@agliodbs.com> + <4238CE87.1040904@bigpond.net.au> <19588.1111029553@sss.pgh.pa.us> +In-Reply-To: <19588.1111029553@sss.pgh.pa.us> +X-Mailer: Forte Agent 2.0/32.652 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.355 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/352 +X-Sequence-Number: 11057 + +On Wed, 16 Mar 2005 22:19:13 -0500, Tom Lane wrote: +>calculate the correlation explicitly for each index + +May be it's time to revisit an old proposal that has failed to catch +anybody's attention during the 7.4 beta period: +http://archives.postgresql.org/pgsql-hackers/2003-08/msg00937.php + +I'm not sure I'd store index correlation in a separate table today. +You've invented something better for functional index statistics, AFAIR. + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Thu Mar 17 08:55:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D3E88567D2 + for ; + Thu, 17 Mar 2005 08:55:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47557-02 + for ; + Thu, 17 Mar 2005 08:55:16 +0000 (GMT) +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 9AA415679A + for ; + Thu, 17 Mar 2005 08:55:12 +0000 (GMT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 5EC4124FDD; + Thu, 17 Mar 2005 16:55:10 +0800 (WST) +Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 4360824FCD; + Thu, 17 Mar 2005 16:55:10 +0800 (WST) +Message-ID: <423945F3.8030800@familyhealth.com.au> +Date: Thu, 17 Mar 2005 16:55:15 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Manfred Koizar +Cc: Tom Lane , David Brown , + Josh Berkus +Subject: Re: multi-column index +References: <42385A1B.9090305@ibcp.fr> <200503161009.24713.josh@agliodbs.com> + <4238CE87.1040904@bigpond.net.au> <19588.1111029553@sss.pgh.pa.us> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.075 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/353 +X-Sequence-Number: 11058 + +> May be it's time to revisit an old proposal that has failed to catch +> anybody's attention during the 7.4 beta period: +> http://archives.postgresql.org/pgsql-hackers/2003-08/msg00937.php +> +> I'm not sure I'd store index correlation in a separate table today. +> You've invented something better for functional index statistics, AFAIR. + +Make it deal with cross-table fk correlations as well :) + +Chris + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:46:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 05B6E56627 + for ; + Thu, 17 Mar 2005 09:37:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59260-06 + for ; + Thu, 17 Mar 2005 09:37:01 +0000 (GMT) +Received: from floppy.pyrenet.fr (unknown [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CF87654DAC + for ; + Thu, 17 Mar 2005 09:36:59 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id D450B30959; Thu, 17 Mar 2005 10:36:59 +0100 (MET) +From: Daniel Schuchardt +X-Newsgroups: pgsql.performance +Subject: Re: cpu_tuple_cost +Date: Thu, 17 Mar 2005 10:37:05 +0100 +Organization: Hub.Org Networking Services +Lines: 88 +Message-ID: +References: <5580.1110781746@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) +X-Accept-Language: en-us, en +In-Reply-To: <5580.1110781746@sss.pgh.pa.us> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/400 +X-Sequence-Number: 11105 + +Tom Lane wrote: + +> +> Reducing random_page_cost is usually the best way to get the planner to +> favor indexscans more. +> + +Ok, I tried a bit with random_page_cost and I have set it to 1 to become + PG using the index on mitpln: + +CIMSOFT=# ANALYSE mitpln; +ANALYZE +CIMSOFT=# SET random_page_cost=2; +SET +CIMSOFT=# EXPLAIN ANALYSE SELECT * FROM mitpln WHERE +date_to_yearmonth_dec(mpl_date)='20050'; + QUERY PLAN + +-------------------------------------------------------------------------------- + + Seq Scan on mitpln (cost=0.00..1173.78 rows=1431 width=69) (actual +time=219.000..1125.000 rows=1266 loops=1) + Filter: ((date_to_yearmonth_dec((mpl_date)::timestamp without time +zone))::text = '20050'::text) + Total runtime: 1125.000 ms +(3 rows) + +CIMSOFT=# SET random_page_cost=1; +SET +CIMSOFT=# EXPLAIN ANALYSE SELECT * FROM mitpln WHERE +date_to_yearmonth_dec(mpl_date)='20050'; + QUERY PLAN + +-------------------------------------------------------------------------------- + Index Scan using mitpln_yearmonth_dec on mitpln (cost=0.00..699.01 +rows=1431 width=69) (actual time=0.000..16.000 rows=1266 loops=1) + Index Cond: ((date_to_yearmonth_dec((mpl_date)::timestamp without +time zone))::text = '20050'::text) + Total runtime: 16.000 ms +(3 rows) + + +CIMSOFT=# \d mitpln + Table "public.mitpln" + Column | Type | Modifiers + +--------------+-----------------------+----------------------------------------- + mpl_id | integer | not null default +nextval('public.mitpln_mpl_id_seq'::text) + mpl_date | date | + mpl_minr | integer | not null + mpl_tpl_name | character varying(20) | + mpl_feiertag | character varying(50) | + mpl_min | real | + mpl_saldo | real | + mpl_buch | boolean | not null default false + mpl_absaldo | real | + mpl_vhz | real | + dbrid | character varying | default nextval('db_id_seq'::text) +Indexes: + "mitpln_pkey" PRIMARY KEY, btree (mpl_id) + "mitpln_idindex" UNIQUE, btree (dbrid) + "xtt5126" UNIQUE, btree (mpl_date, mpl_minr) + "mitpln_yearmonth_dec" btree +(date_to_yearmonth_dec(mpl_date::timestamp with +out time zone)) + "mpl_minr" btree (mpl_minr) + "mpl_minr_nobuch" btree (mpl_minr) WHERE NOT mpl_buch + + +CIMSOFT=# SELECT count(*) FROM mitpln; + count +------- + 26330 +(1 row) + + +CREATE OR REPLACE FUNCTION date_to_yearmonth_dec(TIMESTAMP) RETURNS +VARCHAR AS' +BEGIN + RETURN extract(year FROM $1) || extract(month FROM $1)-1; +END'LANGUAGE plpgsql IMMUTABLE; + + +Daniel + +PS : thats a 2.4 GHZ P4 Server with 1 GB Ram and RAID - SCSI +(WIN2000, PG8.0.1) + +From pgsql-performance-owner@postgresql.org Thu Mar 17 11:15:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 899C85697C + for ; + Thu, 17 Mar 2005 11:15:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90951-07 + for ; + Thu, 17 Mar 2005 11:15:09 +0000 (GMT) +Received: from email.aon.at (warsl404pip6.highway.telekom.at [195.3.96.89]) + by svr1.postgresql.org (Postfix) with ESMTP id 330C856502 + for ; + Thu, 17 Mar 2005 11:15:07 +0000 (GMT) +Received: (qmail 30236 invoked from network); 17 Mar 2005 11:15:08 -0000 +Received: from m154p025.dipool.highway.telekom.at (HELO PASCAL) ([62.46.9.57]) + (envelope-sender ) + by smarthub74.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 17 Mar 2005 11:15:08 -0000 +From: Manfred Koizar +To: Christopher Kings-Lynne +Cc: Tom Lane , David Brown , + Josh Berkus +Subject: Re: multi-column index +Date: Thu, 17 Mar 2005 12:18:28 +0100 +Message-ID: +References: <42385A1B.9090305@ibcp.fr> <200503161009.24713.josh@agliodbs.com> + <4238CE87.1040904@bigpond.net.au> <19588.1111029553@sss.pgh.pa.us> + + <423945F3.8030800@familyhealth.com.au> +In-Reply-To: <423945F3.8030800@familyhealth.com.au> +X-Mailer: Forte Agent 2.0/32.652 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.354 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/354 +X-Sequence-Number: 11059 + +On Thu, 17 Mar 2005 16:55:15 +0800, Christopher Kings-Lynne + wrote: +>Make it deal with cross-table fk correlations as well :) + +That's a different story. I guess it boils down to cross-column +statistics for a single table. Part of this is the correlation between +values in two or more columns, which is not the same as the correlation +between column (or index tuple) values and tuple positions. + +And yes, I did notice the smiley ;-) + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Thu Mar 17 12:03:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 39B9956A30 + for ; + Thu, 17 Mar 2005 12:03:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04269-07 + for ; + Thu, 17 Mar 2005 12:03:15 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id B5A7356A1F + for ; + Thu, 17 Mar 2005 12:03:13 +0000 (GMT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j2HD65825795 + for ; Thu, 17 Mar 2005 14:06:06 +0100 +Received: from [127.0.0.1] (accesspoint.mm.eutelsat.org [194.214.173.4]) + by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id j2HC3ER32535 + for ; Thu, 17 Mar 2005 13:03:14 +0100 +Message-ID: <423971F2.3050701@bigfoot.com> +Date: Thu, 17 Mar 2005 13:02:58 +0100 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Subject: 2 rows expected on a primary key +X-Enigmail-Version: 0.90.1.1 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.372 tagged_above=0 required=5 tests=AWL, + TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200503/355 +X-Sequence-Number: 11060 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Hi all, +I'm running a 7.4.x engine and I'm seeing in a explain analyze: + +- -> Hash (cost=4.00..4.00 rows=2 width=16) (actual time=30.542..30.542 rows=0 loops=1) + -> Index Scan using user_login_login_key on user_login ul (cost=0.00..4.00 rows=2 width=16) (actual time=30.482..30.490 rows=1 loops=1) + Index Cond: ((login)::text = 'Zoneon'::text) + +why postgres perform an extimation of 2 rows knowing that column it's a primary key ? + +If I do an explain analyze directly on the table I get: + +# explain analyze select * from user_login where login = 'Zoneon'; + QUERY PLAN +- ---------------------------------------------------------------------------------------------------------------------------------- + Index Scan using user_login_login_key on user_login (cost=0.00..4.00 rows=1 width=16) (actual time=0.050..0.052 rows=1 loops=1) + Index Cond: ((login)::text = 'Zoneon'::text) + Total runtime: 4.627 ms +(3 rows) + +btw, is it normal that cast ? + + + +Regards +Gaetano Mendola + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.5 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCOXHy7UpzwH2SGd4RAgwAAJ9SMJ3OfYjv03IhhTbJ9GSLby4nfwCg5ezu +UOH8wXRsNAvWRni7GSKlMps= +=6yFm +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Thu Mar 17 13:15:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B1CC566D2 + for ; + Thu, 17 Mar 2005 13:15:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28646-04 + for ; + Thu, 17 Mar 2005 13:15:09 +0000 (GMT) +Received: from mail.fbl.cz (mail.fbl.cz [212.80.68.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D9A456644 + for ; + Thu, 17 Mar 2005 13:14:52 +0000 (GMT) +Received: from localhost (mail.fbl.cz [127.0.0.1]) + by mail.fbl.cz (Postfix) with ESMTP id 20B132B001F + for ; + Thu, 17 Mar 2005 14:20:45 +0100 (CET) +Received: from mail.fbl.cz ([127.0.0.1]) + by localhost (mail.fbl.cz [127.0.0.1]) (amavisd-new, + port 10024) with ESMTP + id 27491-04 for ; + Thu, 17 Mar 2005 14:20:25 +0100 (CET) +Received: from [172.16.18.200] (unknown [172.16.18.200]) + by mail.fbl.cz (Postfix) with ESMTP id 825452B0011 + for ; + Thu, 17 Mar 2005 14:20:25 +0100 (CET) +Message-ID: <42398380.3000904@fbl.cz> +Date: Thu, 17 Mar 2005 14:17:52 +0100 +From: Ales Vojacek +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: TOP 10 SQL commands and more +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at fbl.cz +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/356 +X-Sequence-Number: 11061 + +Hi, + is there some utilities for PG for tunnig database performance. To see +top 10 sql commands and so? +Thank you a lot. + +From pgsql-performance-owner@postgresql.org Thu Mar 17 14:00:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AC4D05665D + for ; + Thu, 17 Mar 2005 14:00:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41196-05 + for ; + Thu, 17 Mar 2005 13:59:53 +0000 (GMT) +Received: from mx1.aftenposten.no (mx1.aftenposten.no [80.91.34.51]) + by svr1.postgresql.org (Postfix) with ESMTP id 56DBA565DB + for ; + Thu, 17 Mar 2005 13:59:51 +0000 (GMT) +Received: from localhost (amavis-mx1.aftenposten.no [80.91.34.52]) + by mx1.aftenposten.no (Postfix) with ESMTP id 65BFE8CAC75 + for ; + Thu, 17 Mar 2005 14:59:55 +0100 (CET) +Received: from smtp1.aftenposten.no (unknown [80.91.34.6]) + by mx1.aftenposten.no (Postfix) with ESMTP id E30BA8CAAD1 + for ; + Thu, 17 Mar 2005 14:59:54 +0100 (CET) +Received: from telecommail.inpoc.no (unverified) by smtp1.aftenposten.no + (Content Technologies SMTPRS 4.3.14) with ESMTP id + for + ; Thu, 17 Mar 2005 15:01:25 +0100 +Received: by TELECOMMAIL with Internet Mail Service (5.5.2653.19) + id ; Thu, 17 Mar 2005 15:01:44 +0100 +Message-ID: +From: "Lending, Rune" +To: "'pgsql-performance@postgresql.org'" +Subject: queries on huge tables +Date: Thu, 17 Mar 2005 15:01:43 +0100 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C52AF9.D9B26E60" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200503/357 +X-Sequence-Number: 11062 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C52AF9.D9B26E60 +Content-Type: text/plain + +Hello all. + +I am having a couple of tables with couple of hundre millions records in +them. The tables contains a timestamp column. +I am almost always interested in getting datas from a specific day or month. +Each day contains aprox. 400.000 entries. + +When I do such queries as " select ... from archive where m_date between +'2005-01-01' and '2005-02-01' group by ... " and so on. +It takes very long. I am having indexes that kicks in, but still it takes +sometime. + +I have splitted the archive table in smaller monthly tables, it then goes a +lot faster, but not fast enough. + +I know simular systems that uses Oracle and gains a lot on performance +because of the partioning. That kind of anoyes me a bit :) + +Does anyone of you have some good ideas on how speed up such queries on +huge tables? + +regards +rune + + + + + +------_=_NextPart_001_01C52AF9.D9B26E60 +Content-Type: text/html + + + + +Melding + + + +
Hello +all.
+
 
+
I am having a couple +of tables with couple of hundre millions records in them. The tables +contains a timestamp column.
+
I am almost always +interested in getting datas from a specific day or month. Each day contains +aprox. 400.000 entries.
+
 
+
When I do such +queries as " select ... from archive where m_date between '2005-01-01' and +'2005-02-01' group by ... " and so on.
+
It takes very long. +I am having +indexes that kicks in, but still it takes sometime.
+
 
+
I have splitted the +archive table in smaller monthly tables, it then goes a lot faster, but not fast +enough.
+
 
+
I know simular +systems that uses Oracle and gains a lot on performance because of the +partioning. That kind of anoyes me a bit :)
+
 
+
Does anyone of you +have some good ideas on how speed up  such queries on huge +tables?
+
 
+
regards
+
rune
+
 
+
 
+
 
+
 
+ +------_=_NextPart_001_01C52AF9.D9B26E60-- + +From pgsql-performance-owner@postgresql.org Thu Mar 17 15:56:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 010C2564A3 + for ; + Thu, 17 Mar 2005 15:56:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83268-03 + for ; + Thu, 17 Mar 2005 15:56:06 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B96156401 + for ; + Thu, 17 Mar 2005 15:56:05 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id 1so120607rny + for ; + Thu, 17 Mar 2005 07:56:10 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; + b=VWWjsJeOhFTlTIdvyPF362/l4hGIsabmADoGLzdh2yh/JMXzu4TNxtTej69tZuGf06nHsK7A1+OjPoi2KazSoEAw8M+6DPzZ4OQrslucU8ndRFWQ58rLD+9O2BrN+V6Z8/aotitdK8MUVqvu0Q+B42Tv/E52liStda4rJs22Zx4= +Received: by 10.38.206.58 with SMTP id d58mr488833rng; + Thu, 17 Mar 2005 07:56:10 -0800 (PST) +Received: by 10.38.179.55 with HTTP; Thu, 17 Mar 2005 07:56:10 -0800 (PST) +Message-ID: +Date: Thu, 17 Mar 2005 10:56:10 -0500 +From: Alexander Ranaldi +Reply-To: Alexander Ranaldi +To: pgsql-performance@postgresql.org +Subject: Building a DB with performance in mind +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.398 tagged_above=0 required=5 + tests=DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/358 +X-Sequence-Number: 11063 + +Greetings everyone, + +I am about to migrate to Postgres from MySQL. My DB isn't enormous (< +1gb), consists mostly of just text, but is accessed quite heavily. +Because size isn't a huge issue, but performance is, I am willing to +normalize as necessary. + +Currently I have a table "Entries" containing 500k rows. The table +contains many text columns, and a few others: +EntryID (unique, indexed) +UserID (references "Users" table, indexed) +Private (boolean. indexed) + +Most of my queries return rows based on UserID, and also only if +Private is FALSE. Would it be in the interest of best performance to +split this table into two tables: "EntriesPrivate", +"EntriesNotPrivate" and remove the "Private" column? + +I appreciate any feedback. I'm certainly not a DB design expert. :) + +Thanks, +Alex + +From pgsql-performance-owner@postgresql.org Thu Mar 17 16:09:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 427115658E + for ; + Thu, 17 Mar 2005 16:09:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86656-08 + for ; + Thu, 17 Mar 2005 16:09:38 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FD4A563F5 + for ; + Thu, 17 Mar 2005 16:09:37 +0000 (GMT) +Received: from trofast.ipv6.sesse.net ([2001:700:300:dc03:20e:cff:fe36:a766] + helo=trofast.sesse.net) + by cassarossa.samfundet.no with esmtp (Exim 4.34) id 1DBxZ1-0000M4-4T + for pgsql-performance@postgresql.org; Thu, 17 Mar 2005 17:09:35 +0100 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1DBxZ0-0004Kq-00 + for ; Thu, 17 Mar 2005 17:09:34 +0100 +Date: Thu, 17 Mar 2005 17:09:34 +0100 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Building a DB with performance in mind +Message-ID: <20050317160934.GB16434@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: +X-Operating-System: Linux 2.6.11-rc3 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.6+20040907i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.022 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/359 +X-Sequence-Number: 11064 + +On Thu, Mar 17, 2005 at 10:56:10AM -0500, Alexander Ranaldi wrote: +> Most of my queries return rows based on UserID, and also only if +> Private is FALSE. Would it be in the interest of best performance to +> split this table into two tables: "EntriesPrivate", +> "EntriesNotPrivate" and remove the "Private" column? + +You could do a partial index if you'd like (ie. one only indexing rows where +Private=FALSE), but I'm not sure if it's the best solution. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Thu Mar 17 16:21:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 22FCC56420 + for ; + Thu, 17 Mar 2005 16:21:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90243-10 + for ; + Thu, 17 Mar 2005 16:21:41 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id EDC9B5643B + for ; + Thu, 17 Mar 2005 16:21:39 +0000 (GMT) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j2HGLUk4020685; (envelope-from ) Thu, + 17 Mar 2005 10:21:36 -0600 (CST) +Received: from [192.168.1.13] (12-217-241-0.client.mchsi.com [12.217.241.0]) + (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j2HGGWgu001278 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Thu, + 17 Mar 2005 10:16:33 -0600 (CST) +Message-ID: <4239AD60.3060607@arbash-meinel.com> +Date: Thu, 17 Mar 2005 10:16:32 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alexander Ranaldi +Cc: pgsql-performance@postgresql.org +Subject: Re: Building a DB with performance in mind +References: +In-Reply-To: +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig7590E6DC0DEF68DEE6934DB7" +X-Virus-Scanned: ClamAV 0.83/723/Thu Feb 24 05:54:24 2005 + clamav-milter version 0.80j on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/360 +X-Sequence-Number: 11065 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig7590E6DC0DEF68DEE6934DB7 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Alexander Ranaldi wrote: + +>Greetings everyone, +> +>I am about to migrate to Postgres from MySQL. My DB isn't enormous (< +>1gb), consists mostly of just text, but is accessed quite heavily. +>Because size isn't a huge issue, but performance is, I am willing to +>normalize as necessary. +> +>Currently I have a table "Entries" containing 500k rows. The table +>contains many text columns, and a few others: +>EntryID (unique, indexed) +>UserID (references "Users" table, indexed) +>Private (boolean. indexed) +> +>Most of my queries return rows based on UserID, and also only if +>Private is FALSE. Would it be in the interest of best performance to +>split this table into two tables: "EntriesPrivate", +>"EntriesNotPrivate" and remove the "Private" column? +> +> +Perhaps. You might also consider creating a multi-column index on +(UserID, Private). +However, in a more conceptual idea, separating the tables may help you +with preventing accidental queries. It's pretty easy to forget to add +"... AND Private = False". It is much harder to accidentally add "... +JOIN EntriesPrivate ON ..." + +>I appreciate any feedback. I'm certainly not a DB design expert. :) +> +> +> +It shouldn't be very hard to test which one works better for you: + +\timing +CREATE INDEX entries_user_private_idx ON Entries(UserID, Private); + +SELECT * FROM Entries WHERE ... AND Private = False; + +CREATE TABLE EntriesPrivate AS SELECT * FROM Entries WHERE Private=True; +CREATE TABLE EntriesPublic AS SELECT * FROM Entries WHERE Private=False; +ALTER TABLE EntriesPrivate DROP COLUMN Private; +ALTER TABLE EntriesPrivate ADD PRIMARY KEY (EntriesID); +ALTER TABLE EntriesPrivate ALTER COLUMN SET +DEFAULT=nextval('Entries_...EntryId'); +-- Make sure you don't have duplicate entries. This could also be done +with a foreign key to some +-- other entries table +ALTER TABLE EntriesPrivate ADD CONSTRAINT EntriesID NOT in (SELECT +EntriesId FROM EntriesPublic); +CREATE INDEX entriesprivate_userid_idx ON EntriesPrivate(UserID); + +-- Do the same thing for EntriesPublic +ALTER TABLE EntriesPublic DROP COLUMN Private; + +These queries have not been tested, but they should give you a decent +starting point to creating 2 tables, and running a bunch of test queries +on them. +I think the biggest difficulty is making sure that you don't get +duplicate EntriesID values, assuming that is important to you. +Also, if you have foreign key references, this won't work. You'll have +to create a new table (it can have just 1 column) containing EntriesID, +and then you can reference that column from both of these tables. + +John +=:-> + +>Thanks, +>Alex +> +>---------------------------(end of broadcast)--------------------------- +>TIP 8: explain analyze is your friend +> +> + + +--------------enig7590E6DC0DEF68DEE6934DB7 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCOa1hJdeBCYSNAAMRAlaRAKCwUtp9Q6dREzvIfNt7qBFZ/I2ayACeJMIk +2QEQXEigMTWnsG3olKo4Jdo= +=GapE +-----END PGP SIGNATURE----- + +--------------enig7590E6DC0DEF68DEE6934DB7-- + +From pgsql-performance-owner@postgresql.org Thu Mar 17 17:10:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AF4BD5669C + for ; + Thu, 17 Mar 2005 17:10:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06828-01 + for ; + Thu, 17 Mar 2005 17:10:26 +0000 (GMT) +Received: from loncoche.terra.com.br (loncoche.terra.com.br [200.154.55.229]) + by svr1.postgresql.org (Postfix) with ESMTP id 2DD57566D1 + for ; + Thu, 17 Mar 2005 17:10:25 +0000 (GMT) +Received: from talara.terra.com.br (talara.terra.com.br [200.154.55.136]) + by loncoche.terra.com.br (Postfix) with ESMTP + id 165C9E780B7; Thu, 17 Mar 2005 14:10:24 -0300 (BRT) +X-Terra-Karma: -2% +X-Terra-Hash: b5fb09de200a8d5920e24ba526854aa0 +Received-SPF: pass (talara.terra.com.br: domain of terra.com.br designates + 200.154.55.136 as permitted sender) client-ip=200.154.55.136; + envelope-from=rodrigo.miguel@terra.com.br; helo=rmsmnote; +Received: from rmsmnote (unknown [200.168.177.120]) + (authenticated user rodrmigu) + by talara.terra.com.br (Postfix) with ESMTP id C96B414C087; + Thu, 17 Mar 2005 14:10:23 -0300 (BRT) +From: "Rodrigo Moreno" +To: "'Michael Fuhr'" +Cc: +Subject: RES: Help to find out problem with joined tables +Date: Thu, 17 Mar 2005 14:10:14 -0300 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +In-Reply-To: <20050317044217.GA23968@winnie.fuhr.org> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 +Thread-Index: AcUqq7e4EucO1/6bQXmM90FWxgc94QAaCSkg +Message-Id: <20050317171023.C96B414C087@talara.terra.com.br> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.986 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_POST +X-Spam-Level: +X-Archive-Number: 200503/361 +X-Sequence-Number: 11066 + +Hi, + +Thanks for your reply. + +I have made this test without any user connect and after vacuum and all +index recteated and tables analyzed. + +Well, produt.codpro is SERIAL +And movest.codpro is NUMBER(8)=20 + + +Thanks +Rodrigo + +-----Mensagem original----- +De: Michael Fuhr [mailto:mike@fuhr.org]=20 +Enviada em: quinta-feira, 17 de mar=E7o de 2005 01:42 +Para: Rodrigo Moreno +Cc: pgsql-performance@postgresql.org +Assunto: Re: [PERFORM] Help to find out problem with joined tables + +On Wed, Mar 16, 2005 at 05:10:17PM -0300, Rodrigo Moreno wrote: + +> If I join movest/natope, it's fast, if I join movest/produt, it's fast = + +> too, but when I put a third joined table, forget, it's very slow. + +What version of PostgreSQL are you using? + +> All tables are vacuumed by vacummdb --full --analyze, every night All=20 +> Indexes are reindexed every night + +How many updates/deletes do the tables see between vacuums? + +> Movest: +- 2 milions rows, indexed +> Natope: 30 rows PK(natope_id) +> Produt: +- 1400 Rows PK(codpro) + +Could you show the table definitions, or at least the definitions for = +the +relevant columns and indexes? + +> -> Seq Scan on produt c (cost=3D0.00..108.26 rows=3D8 width=3D4) = +(actual +> time=3D2688.356..2875.743 rows=3D1 loops=3D6) +> Filter: ((codpro)::numeric =3D 629001::numeric) + +What type is produt.codpro? You might be missing a potential index scan +here due to mismatched types. + +The times (2688.356..2875.743) here look odd, although I might be +overlooking or misinterpreting something. I don't know what else might +cause that, but one thing that can is a lot of dead tuples in the table, +hence my question about how much activity the tables see between = +vacuums. +Maybe somebody else can provide a better explanation. + +-- +Michael Fuhr +http://www.fuhr.org/~mfuhr/ + + + + +From pgsql-performance-owner@postgresql.org Thu Mar 17 17:48:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E3F95656A + for ; + Thu, 17 Mar 2005 17:47:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18181-03 + for ; + Thu, 17 Mar 2005 17:47:52 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 890B456859 + for ; + Thu, 17 Mar 2005 17:47:51 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7138647; Thu, 17 Mar 2005 09:49:43 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Ales Vojacek +Subject: Re: TOP 10 SQL commands and more +Date: Thu, 17 Mar 2005 09:46:41 -0800 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <42398380.3000904@fbl.cz> +In-Reply-To: <42398380.3000904@fbl.cz> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200503170946.41779.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/362 +X-Sequence-Number: 11067 + +Ales, + +> is there some utilities for PG for tunnig database performance. To see +> top 10 sql commands and so? + +Look up "PQA" on www.pgFoundry.org + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Mar 17 17:55:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C8E35656A + for ; + Thu, 17 Mar 2005 17:55:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18362-06 + for ; + Thu, 17 Mar 2005 17:55:40 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 3831A56850 + for ; + Thu, 17 Mar 2005 17:55:39 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7138679; Thu, 17 Mar 2005 09:57:31 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Tom Lane +Subject: Re: cpu_tuple_cost +Date: Thu, 17 Mar 2005 09:54:29 -0800 +User-Agent: KMail/1.6.2 +Cc: Greg Stark , David Brown , + Gregory Stark +References: <87psy1mq66.fsf@stark.xeocode.com> + <200503161003.10916.josh@agliodbs.com> + <8149.1111005738@sss.pgh.pa.us> +In-Reply-To: <8149.1111005738@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200503170954.29269.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/363 +X-Sequence-Number: 11068 + +Tom, + +> Yes it is. =C2=A0I ran experiments back in the late 90s to derive it. +> Check the archives. + +Hmmmm ... which list? + +=2D-=20 +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Mar 17 17:58:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F324563F6 + for ; + Thu, 17 Mar 2005 17:57:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18362-09 + for ; + Thu, 17 Mar 2005 17:57:39 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 991B356862 + for ; + Thu, 17 Mar 2005 17:57:38 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2HHvKLc025692; + Thu, 17 Mar 2005 12:57:20 -0500 (EST) +To: Josh Berkus +Cc: Greg Stark , David Brown , + Gregory Stark +Subject: Re: cpu_tuple_cost +In-reply-to: <200503170954.29269.josh@agliodbs.com> +References: <87psy1mq66.fsf@stark.xeocode.com> + <200503161003.10916.josh@agliodbs.com> + <8149.1111005738@sss.pgh.pa.us> + <200503170954.29269.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Thu, 17 Mar 2005 09:54:29 -0800" +Date: Thu, 17 Mar 2005 12:57:20 -0500 +Message-ID: <25691.1111082240@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/364 +X-Sequence-Number: 11069 + +Josh Berkus writes: +>> Yes it is.  I ran experiments back in the late 90s to derive it. +>> Check the archives. + +> Hmmmm ... which list? + +-hackers, no doubt. -performance didn't exist then. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 17 18:15:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C140D55E75 + for ; + Thu, 17 Mar 2005 18:15:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26235-02 + for ; + Thu, 17 Mar 2005 18:15:39 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 43AA156854 + for ; + Thu, 17 Mar 2005 18:15:37 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2HIFWch025833; + Thu, 17 Mar 2005 13:15:32 -0500 (EST) +To: Manfred Koizar +Cc: David Brown , + pgsql-performance@postgresql.org +Subject: Re: multi-column index +In-reply-to: +References: <42385A1B.9090305@ibcp.fr> <200503161009.24713.josh@agliodbs.com> + <4238CE87.1040904@bigpond.net.au> <19588.1111029553@sss.pgh.pa.us> + +Comments: In-reply-to Manfred Koizar + message dated "Thu, 17 Mar 2005 09:51:36 +0100" +Date: Thu, 17 Mar 2005 13:15:32 -0500 +Message-ID: <25832.1111083332@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/365 +X-Sequence-Number: 11070 + +Manfred Koizar writes: +> On Wed, 16 Mar 2005 22:19:13 -0500, Tom Lane wrote: +>> calculate the correlation explicitly for each index + +> May be it's time to revisit an old proposal that has failed to catch +> anybody's attention during the 7.4 beta period: +> http://archives.postgresql.org/pgsql-hackers/2003-08/msg00937.php + +> I'm not sure I'd store index correlation in a separate table today. +> You've invented something better for functional index statistics, AFAIR. + +Well, the original motivation for calculating correlations on columns +was that historically, you didn't need to re-ANALYZE after creating an +index: the stats on the base table were already in place. So the idea +was to have the correlations already available whether or not the index +existed. This works fine for plain indexes on single columns ;-). We +didn't realize (or at least I didn't) how poorly the per-column stats +apply to multi-column indexes. + +I am coming around to the view that we really do need to calculate +index-specific correlation numbers, and that probably does need a +special table ... or maybe better, add a column to pg_index. The column +in pg_statistic is useless and should be removed, because there isn't +any need for per-column correlation. + +Now, as to the actual mechanics of getting the numbers: the above link +seems to imply reading the whole index in index order. Which is a +hugely expensive proposition for a big index, especially one that's +grown rather than been built recently --- the physical and logical +orderings of the index will be different. (Hm, maybe we need a stat +about the extent of disorder within the index itself?) We need a way +to get the number from a small sample of pages. + +The idea I was toying with was to recalculate the index keys for the +sample rows that ANALYZE already acquires, and then compare/sort +those. This is moderately expensive CPU-wise though, and it's also not +clear what "compare/sort" means for non-btree indexes. + +If we could get a correlation estimate by probing only a small fraction +of the index pages, that would work, but in a disordered index I'm not +sure how you figure out what you're looking at. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 17 18:27:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F140654CF5 + for ; + Thu, 17 Mar 2005 18:27:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28420-07 + for ; + Thu, 17 Mar 2005 18:27:13 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 0179554C55 + for ; + Thu, 17 Mar 2005 18:27:12 +0000 (GMT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j2HIQt4W024550 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Thu, 17 Mar 2005 11:26:57 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j2HIQsNQ055449; + Thu, 17 Mar 2005 11:26:54 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j2HIQsBA055448; + Thu, 17 Mar 2005 11:26:54 -0700 (MST) (envelope-from mfuhr) +Date: Thu, 17 Mar 2005 11:26:53 -0700 +From: Michael Fuhr +To: Josh Berkus +Cc: Tom Lane , Greg Stark , + David Brown , + Gregory Stark +Subject: Re: cpu_tuple_cost +Message-ID: <20050317182653.GA55368@winnie.fuhr.org> +References: <87psy1mq66.fsf@stark.xeocode.com> + <200503161003.10916.josh@agliodbs.com> + <8149.1111005738@sss.pgh.pa.us> + <200503170954.29269.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: <200503170954.29269.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/366 +X-Sequence-Number: 11071 + +On Thu, Mar 17, 2005 at 09:54:29AM -0800, Josh Berkus wrote: +> +> > Yes it is. �I ran experiments back in the late 90s to derive it. +> > Check the archives. +> +> Hmmmm ... which list? + +These look like relevant threads: + +http://archives.postgresql.org/pgsql-hackers/2000-01/msg00910.php +http://archives.postgresql.org/pgsql-hackers/2000-02/msg00215.php + +-- +Michael Fuhr +http://www.fuhr.org/~mfuhr/ + +From pgsql-performance-owner@postgresql.org Fri Mar 18 09:10:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C44152A54 + for ; + Fri, 18 Mar 2005 09:10:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60904-06 + for ; + Fri, 18 Mar 2005 09:10:02 +0000 (GMT) +Received: from fuji.krosing.net (joltid-gw.joltid.org [195.50.194.24]) + by svr1.postgresql.org (Postfix) with ESMTP id EFDF052A50 + for ; + Fri, 18 Mar 2005 09:10:00 +0000 (GMT) +Received: from fuji.krosing.net (localhost [127.0.0.1]) + by fuji.krosing.net (8.13.1/8.13.1) with ESMTP id j2HLRXQF006382; + Thu, 17 Mar 2005 23:27:34 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.13.1/8.13.1/Submit) id j2HLRQfA006381; + Thu, 17 Mar 2005 23:27:26 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: One tuple per transaction +From: Hannu Krosing +To: Josh Berkus +Cc: Tambet Matiisen , + pgsql-performance@postgresql.org +In-Reply-To: <200503121405.20943.josh@agliodbs.com> +References: + <200503121405.20943.josh@agliodbs.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Thu, 17 Mar 2005 23:27:25 +0200 +Message-Id: <1111094845.6281.1.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-1) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/367 +X-Sequence-Number: 11072 + +On L, 2005-03-12 at 14:05 -0800, Josh Berkus wrote: +> Tambet, +> +> > In one of our applications we have a database function, which +> > recalculates COGS (cost of good sold) for certain period. This involves +> > deleting bunch of rows from one table, inserting them again in correct +> > order and updating them one-by-one (sometimes one row twice) to reflect +> > current state. The problem is, that this generates an enormous amount of +> > tuples in that table. +> +> Sounds like you have an application design problem ... how about re-writing +> your function so it's a little more sensible? + +Also, you could at least use a temp table for intermediate steps. This +will at least save WAL traffic. + +-- +Hannu Krosing + +From pgsql-performance-owner@postgresql.org Fri Mar 18 10:31:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BCE9752AA7 + for ; + Fri, 18 Mar 2005 10:31:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84320-04 + for ; + Fri, 18 Mar 2005 10:31:45 +0000 (GMT) +Received: from email.aon.at (WARSL404PIP1.highway.telekom.at [195.3.96.112]) + by svr1.postgresql.org (Postfix) with ESMTP id ADA2C56A4B + for ; + Fri, 18 Mar 2005 10:31:43 +0000 (GMT) +Received: (qmail 1693 invoked from network); 18 Mar 2005 10:31:42 -0000 +Received: from m162p016.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.10.48]) + (envelope-sender ) + by smarthub72.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 18 Mar 2005 10:31:42 -0000 +From: Manfred Koizar +To: Ron Mayer +Cc: pgsql-performance@postgresql.org +Subject: Re: multi-column index +Date: Fri, 18 Mar 2005 11:34:03 +0100 +Message-ID: <985l31t5jn1bvmhaihifslitbc940pdo5f@email.aon.at> +References: <42385A1B.9090305@ibcp.fr> <200503161009.24713.josh@agliodbs.com> + <4238CE87.1040904@bigpond.net.au> <19588.1111029553@sss.pgh.pa.us> + + <423A87CE.2020302@cheapcomplexdevices.com> +In-Reply-To: <423A87CE.2020302@cheapcomplexdevices.com> +X-Mailer: Forte Agent 2.0/32.652 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.348 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/368 +X-Sequence-Number: 11073 + +On Thu, 17 Mar 2005 23:48:30 -0800, Ron Mayer + wrote: +>Would this also help estimates in the case where values in a table +>are tightly clustered, though not in strictly ascending or descending +>order? + +No, I was just expanding the existing notion of correlation from single +columns to index tuples. + +>For example, address data has many fields that are related +>to each other (postal codes, cities, states/provinces). + +This looks like a case for cross-column statistics, though you might not +have meant it as such. I guess what you're talking about can also be +described with a single column. In a list like + + 3 3 ... 3 1 1 ... 1 7 7 ... 7 4 4 ... 4 ... + +equal items are "clustered" together but the values are not "correlated" +to their positions. This would require a whole new column +characteristic, something like the probability that we find the same +value in adjacent heap tuples, or the number of different values we can +expect on one heap page. The latter might even be easy to compute +during ANALYSE. + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Fri Mar 18 10:40:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 14FFA56A47 + for ; + Fri, 18 Mar 2005 10:40:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84564-07 + for ; + Fri, 18 Mar 2005 10:40:04 +0000 (GMT) +Received: from email.aon.at (warsl404pip8.highway.telekom.at [195.3.96.102]) + by svr1.postgresql.org (Postfix) with ESMTP id 5592F56A44 + for ; + Fri, 18 Mar 2005 10:40:02 +0000 (GMT) +Received: (qmail 7235 invoked from network); 18 Mar 2005 10:40:03 -0000 +Received: from m162p016.dipool.highway.telekom.at (HELO PASCAL) + ([62.46.10.48]) + (envelope-sender ) + by smarthub75.highway.telekom.at (qmail-ldap-1.03) with SMTP + for ; 18 Mar 2005 10:40:03 -0000 +From: Manfred Koizar +To: Tom Lane +Cc: David Brown , + pgsql-performance@postgresql.org +Subject: Re: multi-column index +Date: Fri, 18 Mar 2005 11:42:23 +0100 +Message-ID: <968l3192dup7lukgkeaggoj1nlbdq8q3up@email.aon.at> +References: <42385A1B.9090305@ibcp.fr> <200503161009.24713.josh@agliodbs.com> + <4238CE87.1040904@bigpond.net.au> <19588.1111029553@sss.pgh.pa.us> + + <25832.1111083332@sss.pgh.pa.us> +In-Reply-To: <25832.1111083332@sss.pgh.pa.us> +X-Mailer: Forte Agent 2.0/32.652 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.347 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/369 +X-Sequence-Number: 11074 + +On Thu, 17 Mar 2005 13:15:32 -0500, Tom Lane wrote: +>I am coming around to the view that we really do need to calculate +>index-specific correlation numbers, + +Correlation is a first step. We might also want distribution +information like number of distinct index tuples and histograms. + +>Now, as to the actual mechanics of getting the numbers: the above link +>seems to imply reading the whole index in index order. + +That turned out to be surprisingly easy (no need to look at data values, +no operator lookup, etc.) to implement as a proof of concept. As it's +good enough for my use cases I never bothered to change it. + +> Which is a +>hugely expensive proposition for a big index, + +Just a thought: Could the gathering of the sample be integrated into +the bulk delete phase of VACUUM? (I know, ANALYSE is not always +performed as an option to VACUUM, and VACUUM might not even have to +delete any index tuples.) + +> We need a way +>to get the number from a small sample of pages. + +I had better (or at least different) ideas at that time, like walking +down the tree, but somehow lost impetus :-( + +>The idea I was toying with was to recalculate the index keys for the +>sample rows that ANALYZE already acquires, and then compare/sort +>those. + +This seems to be the approach that perfectly fits into what we have now. + +> This is moderately expensive CPU-wise though, and it's also not +>clear what "compare/sort" means for non-btree indexes. + +Nothing. We'd need some notion of "clusteredness" instead of +correlation. C.f. my answer to Ron in this thread. + +BTW, the more I think about it, the more I come to the conclusion that +when the planner starts to account for "clusteredness", random page cost +has to be raised. + +Servus + Manfred + +From pgsql-bugs-owner@postgresql.org Mon Mar 21 02:24:56 2005 +X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CAF6856962 + for ; + Fri, 18 Mar 2005 23:23:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91226-03 + for ; + Fri, 18 Mar 2005 23:23:51 +0000 (GMT) +Received: from svr2.postgresql.org (unknown [65.19.161.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 03B465687E + for ; Fri, 18 Mar 2005 23:23:51 +0000 (GMT) +Received: by svr2.postgresql.org (Postfix, from userid 80) + id 08FA0F0E5D; Fri, 18 Mar 2005 23:21:02 +0000 (GMT) +To: pgsql-bugs@postgresql.org +Subject: BUG #1552: massive performance hit between 7.4 and 8.0.1 +From: "Brian O'Reilly" +Message-Id: <20050318232102.08FA0F0E5D@svr2.postgresql.org> +Date: Fri, 18 Mar 2005 23:21:02 +0000 (GMT) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/183 +X-Sequence-Number: 11303 + + +The following bug has been logged online: + +Bug reference: 1552 +Logged by: Brian O'Reilly +Email address: fade@deepsky.com +PostgreSQL version: 8.0.1 +Operating system: Linux 2.6.11 +Description: massive performance hit between 7.4 and 8.0.1 +Details: + +When doing a lot of inserts to an empty table with a foreign key to another +table, there is an incredible performance degredation issue on 8.0.1. I have +a program that is inserting rows in an iterative loop, and in this form it +inserts about 110,000 rows. On postgresql 7.4 on a debian machine it takes a +shade over 2 minutes to complete. On an amd64 box running gentoo, it takes +over an hour and fourty minutes to complete. The query plan on the debian +host that completes quickly follows: + + "Fast" machine, Debian, PSQL 7.4: + +---------------------------------------------------------------------------- +---------------------------------------------------- + Index Scan using requirements_pkey on requirements (cost=0.00..4.82 rows=2 +width=0) (actual time=0.013..0.013 rows=0 loops=1) + Index Cond: (reqid = 10::bigint) + Total runtime: 0.134 ms +(3 rows) + +and the query plan on the 'slow' machine: + + + QUERY PLAN +---------------------------------------------------------------------------- +-------------------------- + Seq Scan on requirements (cost=0.00..0.00 rows=1 width=0) (actual +time=0.002..0.002 rows=0 loops=1) + Filter: (reqid = 10::bigint) + Total runtime: 0.040 ms +(3 rows) + +The script I am using to show this behaviour follows: + +CREATE TABLE packages + (name text PRIMARY KEY); +CREATE TABLE binary_packages + (name text REFERENCES packages, + version text, + PRIMARY KEY(name, version)); +CREATE TABLE requirements + (reqid bigint PRIMARY KEY, + name text, + version text, + FOREIGN KEY (name, version) REFERENCES +binary_packages); +CREATE TABLE constraints + (constid bigint PRIMARY KEY, + reqid bigint REFERENCES requirements, + type text, + name text REFERENCES packages, + version text DEFAULT '', + relation character(2)); + +explain analyze select 1 from only requirements where reqid='10'; + +the query optimiser seems to be setting a default strategy of doing +sequential scans on an empty table, which is a fast strategy when the table +is empty and not particularly full, but obviously on a large table the +performance is O(N^2). This is clearly a bug. Please let me know if I can +provide any more information. + +Brian O'Reilly +System Architect., +DeepSky Media Resources + +From pgsql-performance-owner@postgresql.org Sat Mar 19 13:16:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 60483563AC + for ; + Sat, 19 Mar 2005 13:16:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44031-03 + for ; + Sat, 19 Mar 2005 13:16:40 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.196]) + by svr1.postgresql.org (Postfix) with ESMTP id B3A615637B + for ; + Sat, 19 Mar 2005 13:16:38 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id j1so399432rnf + for ; + Sat, 19 Mar 2005 05:16:42 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=f3dxD+GcqtUtWz64FBTVRAsUOS2d9WTvm0xY0CZNeayv0tmBN4xlCXCKYHwIBJBzfimwwcPBt/lKW2It6DP/FKeGdiwbxikZ780Ypl9BjTfmoS/4299oFFfWeu8iq0sOSZN1CpaN4BmEOYiJVsne/ZOBEkYhJPy+LVYmfXyqlRY= +Received: by 10.38.89.49 with SMTP id m49mr1469331rnb; + Sat, 19 Mar 2005 05:16:42 -0800 (PST) +Received: by 10.38.126.9 with HTTP; Sat, 19 Mar 2005 05:16:42 -0800 (PST) +Message-ID: +Date: Sat, 19 Mar 2005 13:16:42 +0000 +From: Mike Rylander +Reply-To: Mike Rylander +To: "Lending, Rune" , pgsql-performance@postgresql.org +Subject: Re: queries on huge tables +In-Reply-To: +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +References: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.242 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/370 +X-Sequence-Number: 11075 + +The most recent version of this thread starts here: +http://archives.postgresql.org/pgsql-general/2005-03/msg00321.php . +Search the archives for "table partition", "union view" and "partition +inherits" and you should find most relevant discussions. + +Hope that helps! + +On Thu, 17 Mar 2005 15:01:43 +0100, Lending, Rune + wrote: +> +> Hello all. +> +> I am having a couple of tables with couple of hundre millions records in +> them. The tables contains a timestamp column. +> I am almost always interested in getting datas from a specific day or month. +> Each day contains aprox. 400.000 entries. +> +> When I do such queries as " select ... from archive where m_date between +> '2005-01-01' and '2005-02-01' group by ... " and so on. +> It takes very long. I am having indexes that kicks in, but still it takes +> sometime. +> +> I have splitted the archive table in smaller monthly tables, it then goes a +> lot faster, but not fast enough. +> +> I know simular systems that uses Oracle and gains a lot on performance +> because of the partioning. That kind of anoyes me a bit :) +> +> Does anyone of you have some good ideas on how speed up such queries on +> huge tables? +> +> regards +> rune +> +> +> +> + + +-- +Mike Rylander +mrylander@gmail.com +GPLS -- PINES Development +Database Developer +http://open-ils.org + +From pgsql-performance-owner@postgresql.org Sat Mar 19 20:02:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E42D35684C + for ; + Sat, 19 Mar 2005 20:02:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37305-01 + for ; + Sat, 19 Mar 2005 20:02:51 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 65FE856826 + for ; + Sat, 19 Mar 2005 20:02:50 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7145685 for pgsql-performance@postgresql.org; + Sat, 19 Mar 2005 12:04:42 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: What needs to be done for real Partitioning? +Date: Sat, 19 Mar 2005 12:02:38 -0800 +User-Agent: KMail/1.6.2 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Message-Id: <200503191202.38089.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/371 +X-Sequence-Number: 11076 + +Folks, + +I may (or may not) soon have funding for implementing full table partitioning +in PostgreSQL. I thought it would be a good idea to discuss with people here +who are already using pseudo-partitioning what things need to be added to +Postgresql in order to make full paritioning a reality; that is, what do +other databases do that we don't? + +Implementations are seperated into phases I and II, II being +harder-and-optional-stuff that may get done later, I being essential +features. + +Ph. I +-- CREATE TABLE ... WITH PARTITION ON {expression} + ---- should automatically create expression index on {expression} +-- INSERT INTO should automatically create new partitions where necessary + ---- new tables should automatically inherit all constraints, indexes, + keys of "parent" table +-- UPDATE should automatically move rows between partitions where applicable +-- Query Planner/Executor should be improved to not always materialize +paritioned tables used in subqueries and joins. + +Ph. II +-- Foreign Keys to/from partitioned tables should become possible +-- Query Planner/Executor should be improved to only join partitions which are +compliant with the query's WHERE or JOIN clauses where reasonable +-- DELETE FROM should automatically drop empty partitions +-- setting of WITH PARTITION ON {expression} TABLESPACE should automatically +create a new tablespace for each new partition and its indexes. +-- It should be possible to create new, empty partitions via a CREATE TABLE +PARTITION OF {table} ON {value} expression. + +All syntax above is, of course, highly debatable. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sat Mar 19 20:49:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B49EB568A7 + for ; + Sat, 19 Mar 2005 20:49:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46172-08 + for ; + Sat, 19 Mar 2005 20:49:29 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E5D095637A + for ; + Sat, 19 Mar 2005 20:49:28 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2JKnSQb018169; + Sat, 19 Mar 2005 15:49:28 -0500 (EST) +To: Josh Berkus +Cc: pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +In-reply-to: <200503191202.38089.josh@agliodbs.com> +References: <200503191202.38089.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Sat, 19 Mar 2005 12:02:38 -0800" +Date: Sat, 19 Mar 2005 15:49:28 -0500 +Message-ID: <18168.1111265368@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/372 +X-Sequence-Number: 11077 + +Josh Berkus writes: +> -- CREATE TABLE ... WITH PARTITION ON {expression} + +I'd rather see the partition control stuff as ALTER TABLE commands, +not decoration on CREATE TABLE. See the WITH OIDS business we just went +through: adding nonstandard decoration to a standard command isn't good. + +> -- INSERT INTO should automatically create new partitions where necessary +> -- DELETE FROM should automatically drop empty partitions + +I am not sure I agree with either of those, and the reason is that they +would turn low-lock operations into high-lock operations. DELETE FROM +would be particularly bad. Furthermore, who wants to implement DROP +PARTITION as a DELETE FROM? ISTM the whole point of partitioning is to +be able to load and unload whole partitions quickly, and having to +DELETE all the rows in a partition isn't my idea of quick. + +> -- setting of WITH PARTITION ON {expression} TABLESPACE should automatically +> create a new tablespace for each new partition and its indexes. + +This is a bad idea. Where are you going to create these automatic +tablespaces? What will they be named? Won't this require superuser +privileges? And what's the point anyway? + +> -- It should be possible to create new, empty partitions via a CREATE TABLE +> PARTITION OF {table} ON {value} expression. + +Huh? ISTM this confuses establishment of a table's partition rule with +the act of pre-creating empty partitions for not-yet-used ranges of +partition keys. Or are you trying to suggest that a table could be +partitioned more than one way at a time? If so, how? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Mar 19 22:25:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C07BE56919 + for ; + Sat, 19 Mar 2005 22:25:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75587-03 + for ; + Sat, 19 Mar 2005 22:25:09 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id D45F05692C + for ; + Sat, 19 Mar 2005 22:24:42 +0000 (GMT) +Received: (qmail 9858 invoked from network); 19 Mar 2005 23:24:48 +0100 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 19 Mar 2005 23:24:48 +0100 +To: "Josh Berkus" , + pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +References: <200503191202.38089.josh@agliodbs.com> +Message-ID: +Date: Sat, 19 Mar 2005 23:24:39 +0100 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <200503191202.38089.josh@agliodbs.com> +User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/373 +X-Sequence-Number: 11078 + + + This is really great ! + + Think about altering the partitioning (this is quite complex) : imagine a +table split in several partitions "archive" and "current" where a row is +moved from current to archive when it will not be updated anymore. +Sometimes you can partition on a simple numeric value, or even a boolean +value in this case. Other times you'd have to partition on a date, +(current month, current year, archive...). So, how to move the partition +between the two tables so that the oldest rows in the current month table +are moved to the current year table at the end of each month ? + + Some ideas : + hidden field (like oid was) to indicate in which partition the tuple is ? + + +On Sat, 19 Mar 2005 21:02:38 +0100, Josh Berkus wrote: + +> Folks, +> +> I may (or may not) soon have funding for implementing full table +> partitioning +> in PostgreSQL. I thought it would be a good idea to discuss with people +> here +> who are already using pseudo-partitioning what things need to be added to +> Postgresql in order to make full paritioning a reality; that is, what do +> other databases do that we don't? +> +> Implementations are seperated into phases I and II, II being +> harder-and-optional-stuff that may get done later, I being essential +> features. +> +> Ph. I +> -- CREATE TABLE ... WITH PARTITION ON {expression} +> ---- should automatically create expression index on {expression} +> -- INSERT INTO should automatically create new partitions where necessary +> ---- new tables should automatically inherit all constraints, +> indexes, +> keys of "parent" table +> -- UPDATE should automatically move rows between partitions where +> applicable +> -- Query Planner/Executor should be improved to not always materialize +> paritioned tables used in subqueries and joins. +> +> Ph. II +> -- Foreign Keys to/from partitioned tables should become possible +> -- Query Planner/Executor should be improved to only join partitions +> which are +> compliant with the query's WHERE or JOIN clauses where reasonable +> -- DELETE FROM should automatically drop empty partitions +> -- setting of WITH PARTITION ON {expression} TABLESPACE should +> automatically +> create a new tablespace for each new partition and its indexes. +> -- It should be possible to create new, empty partitions via a CREATE +> TABLE +> PARTITION OF {table} ON {value} expression. +> +> All syntax above is, of course, highly debatable. +> + + + +From pgsql-performance-owner@postgresql.org Sat Mar 19 22:52:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CB74D563A0 + for ; + Sat, 19 Mar 2005 22:52:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80989-08 + for ; + Sat, 19 Mar 2005 22:52:42 +0000 (GMT) +Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 46C3852A64 + for ; + Sat, 19 Mar 2005 22:52:41 +0000 (GMT) +Received: from grownups (c-24-21-166-228.client.comcast.net[24.21.166.228]) + by comcast.net (sccrmhc13) with SMTP + id <20050319225243016007mqooe>; Sat, 19 Mar 2005 22:52:43 +0000 +Message-ID: <001d01c52cd6$9702be10$0200a8c0@grownups> +From: "Stacy White" +To: +References: <200503191202.38089.josh@agliodbs.com> + <18168.1111265368@sss.pgh.pa.us> +Subject: Re: What needs to be done for real Partitioning? +Date: Sat, 19 Mar 2005 14:54:20 -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.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.249 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/374 +X-Sequence-Number: 11079 + +From: "Tom Lane" +> Josh Berkus writes: +> > -- INSERT INTO should automatically create new partitions where +necessary +> > -- DELETE FROM should automatically drop empty partitions +> +> I am not sure I agree with either of those, and the reason is that they +> would turn low-lock operations into high-lock operations. + +I second this. We're current using an inheritance based partitioning scheme +with automatic partition creation in the application code, and have seen at +least one case of deadlock due to partition creation. + +Other phase II/III items might include: + +- Modify the partitioning scheme of a table. In the above example, adding a +'200504' partition, and moving the '200502' orders into 'ARCHIVE' + +- The ability to place a partition in a tablespace. In the example above, +it would be nice to put the 'ARCHIVE' partition would likely be placed on a +slower set of disks than the most recent month's partition. + +- Global indexes (that is to say, an index spanning the the table rather +than an individual partition). This seems counterintuitive, but they've +dramatically increased performance on one of our Oracle systems and should +at least be worth considering. + + +From pgsql-performance-owner@postgresql.org Sat Mar 19 22:56:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5723F55E75 + for ; + Sat, 19 Mar 2005 22:56:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82580-03 + for ; + Sat, 19 Mar 2005 22:56:29 +0000 (GMT) +Received: from sunsite.dcc.uchile.cl (sunsite.dcc.uchile.cl [192.80.24.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FBB952A64 + for ; + Sat, 19 Mar 2005 22:56:28 +0000 (GMT) +Received: from anakena.dcc.uchile.cl (anakena [192.80.24.6]) + by sunsite.dcc.uchile.cl (8.12.11/8.12.11) with ESMTP id j2JMuOsZ013034; + Sat, 19 Mar 2005 18:56:24 -0400 (CLT) +Received: by anakena.dcc.uchile.cl (Postfix, from userid 4151) + id 46FB2523B1; Sat, 19 Mar 2005 18:56:24 -0400 (CLT) +Date: Sat, 19 Mar 2005 18:56:24 -0400 +From: Alvaro Herrera +To: PFC +Cc: Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +Message-ID: <20050319225624.GA8467@dcc.uchile.cl> +References: <200503191202.38089.josh@agliodbs.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.352 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/375 +X-Sequence-Number: 11080 + +On Sat, Mar 19, 2005 at 11:24:39PM +0100, PFC wrote: + +> Some ideas : +> hidden field (like oid was) to indicate in which partition the tuple +> is ? + +I think that to make partitioning really possible we need to have +multi-relfilenode tables. + +We probably also need multi-table indexes. Implementing these would be +good for inheritance too. + +-- +Alvaro Herrera () +Dios hizo a Ad�n, pero fue Eva quien lo hizo hombre. + +From pgsql-performance-owner@postgresql.org Sat Mar 19 23:04:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2BAD9567A7 + for ; + Sat, 19 Mar 2005 23:02:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84204-05 + for ; + Sat, 19 Mar 2005 23:02:41 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E84056390 + for ; + Sat, 19 Mar 2005 23:02:40 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2JN2d0m002093; + Sat, 19 Mar 2005 18:02:39 -0500 (EST) +To: PFC +Cc: "Josh Berkus" , + pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +In-reply-to: +References: <200503191202.38089.josh@agliodbs.com> + +Comments: In-reply-to PFC + message dated "Sat, 19 Mar 2005 23:24:39 +0100" +Date: Sat, 19 Mar 2005 18:02:39 -0500 +Message-ID: <2092.1111273359@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/376 +X-Sequence-Number: 11081 + +PFC writes: +> Some ideas : +> hidden field (like oid was) to indicate in which partition the tuple is ? + +tableoid would accomplish that already, assuming that the "partitioned +table" is effectively a view on separate physical tables. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Mar 19 23:30:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 482C65662A + for ; + Sat, 19 Mar 2005 23:30:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89286-06 + for ; + Sat, 19 Mar 2005 23:30:10 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id EC92B54507 + for ; + Sat, 19 Mar 2005 23:30:09 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7146080; Sat, 19 Mar 2005 15:32:02 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Tom Lane +Subject: Re: What needs to be done for real Partitioning? +Date: Sat, 19 Mar 2005 15:29:51 -0800 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <200503191202.38089.josh@agliodbs.com> + <18168.1111265368@sss.pgh.pa.us> +In-Reply-To: <18168.1111265368@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200503191529.51794.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/377 +X-Sequence-Number: 11082 + +Tom, Stacy, Alvaro, + +> I'd rather see the partition control stuff as ALTER TABLE commands, +> not decoration on CREATE TABLE. See the WITH OIDS business we just went +> through: adding nonstandard decoration to a standard command isn't good. + +OK, sure. + +> > -- INSERT INTO should automatically create new partitions where necessary +> > -- DELETE FROM should automatically drop empty partitions +> +> I am not sure I agree with either of those, and the reason is that they +> would turn low-lock operations into high-lock operations. + +For INSERT, I think that's a problem we need to work through. Partitioning +on any scheme where you have to depend on the middleware to create new +partitions could never be more than a halfway implementation. For one thing, +if we can't have 100% dependence on the idea that Table M, Partition 34 +contains index values Y-Z, then that form of advanced query rewriting (which +is a huge performance gain on really large tables) becomes inaccessable. + +Or are you proposing, instead, that attempts to insert beyond the range raise +an error? + +> DELETE FROM +> would be particularly bad. Furthermore, who wants to implement DROP +> PARTITION as a DELETE FROM? ISTM the whole point of partitioning is to +> be able to load and unload whole partitions quickly, and having to +> DELETE all the rows in a partition isn't my idea of quick. + +I mostly threw DELETE in for obvious symmetry. If it's complicated, we can +drop it. + +And you're right, I forgot DROP PARTITION. + +> This is a bad idea. Where are you going to create these automatic +> tablespaces? What will they be named? Won't this require superuser +> privileges? And what's the point anyway? + +Stacy White suggests the more sensible version of this: +ALTER TABLE {table} CREATE PARTITION WITH VALUE {value} ON TABLESPACE +{tablespacename}. Manually creating the partitions in the appropriate +location probably makes the most sense. + +The point, btw, is that if you have a 2TB table, you probably want to put its +partitions on several seperate disk arrays. + +> Huh? ISTM this confuses establishment of a table's partition rule with +> the act of pre-creating empty partitions for not-yet-used ranges of +> partition keys. + +I don't understand why this would be confusing. If INSERT isn't creating +partitions on new value breakpoint, then CREATE PARTITION needs to. + +> Or are you trying to suggest that a table could be +> partitioned more than one way at a time? If so, how? + +No. + +> - Modify the partitioning scheme of a table. In the above example, adding +> a '200504' partition, and moving the '200502' orders into 'ARCHIVE' + +Hmmm ... I don't see the point in automating this. Can you explain? + +> - Global indexes (that is to say, an index spanning the the table rather +> than an individual partition). This seems counterintuitive, but they've +> dramatically increased performance on one of our Oracle systems and should +> at least be worth considering. + +Hmmm, again can you detail this? Maybe some performance examples? It seems +to me that global indexes might interfere with the maintenance advantages of +partitioning. + +> We probably also need multi-table indexes. Implementing these would be +> good for inheritance too. + +They would be nice, but I don't see them as a requirement for making +partitioning work. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sat Mar 19 23:35:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B22D35662A + for ; + Sat, 19 Mar 2005 23:35:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90455-07 + for ; + Sat, 19 Mar 2005 23:35:37 +0000 (GMT) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 97C63567FA + for ; + Sat, 19 Mar 2005 23:35:36 +0000 (GMT) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id E054590001A; Sat, 19 Mar 2005 15:38:11 -0800 (PST) +Date: Sat, 19 Mar 2005 15:38:11 -0800 +From: Steve Atkins +To: pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +Message-ID: <20050319233811.GB6342@gp.word-to-the-wise.com> +References: <200503191202.38089.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200503191202.38089.josh@agliodbs.com> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/378 +X-Sequence-Number: 11083 + +On Sat, Mar 19, 2005 at 12:02:38PM -0800, Josh Berkus wrote: + +> Folks, +> +> I may (or may not) soon have funding for implementing full table partitioning +> in PostgreSQL. I thought it would be a good idea to discuss with people here +> who are already using pseudo-partitioning what things need to be added to +> Postgresql in order to make full paritioning a reality; that is, what do +> other databases do that we don't? +> +> Implementations are seperated into phases I and II, II being +> harder-and-optional-stuff that may get done later, I being essential +> features. +> +> Ph. I +> -- CREATE TABLE ... WITH PARTITION ON {expression} +> ---- should automatically create expression index on {expression} + +ALTER TABLE might be cleaner, perhaps? + +> -- INSERT INTO should automatically create new partitions where necessary +> ---- new tables should automatically inherit all constraints, indexes, +> keys of "parent" table +> -- UPDATE should automatically move rows between partitions where applicable +> -- Query Planner/Executor should be improved to not always materialize +> paritioned tables used in subqueries and joins. + +Would the SELECT also look at the parent table, if it weren't empty? I can +think of cases where that'd be useful, especially if an existing table +can be partitioned with an ALTER TABLE. + +This covers almost everything I'd want from table partitioning in the +short term. + +> Ph. II +> -- Foreign Keys to/from partitioned tables should become possible +> -- Query Planner/Executor should be improved to only join partitions which are +> compliant with the query's WHERE or JOIN clauses where reasonable +> -- DELETE FROM should automatically drop empty partitions +> -- setting of WITH PARTITION ON {expression} TABLESPACE should automatically +> create a new tablespace for each new partition and its indexes. +> -- It should be possible to create new, empty partitions via a CREATE TABLE +> PARTITION OF {table} ON {value} expression. +> +> All syntax above is, of course, highly debatable. + +Multi-table indexes would be nice too, though that leads to some problems +when a partition is truncated or dropped, I guess. + +Cheers, + Steve + +From pgsql-performance-owner@postgresql.org Sat Mar 19 23:52:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A2B3854C26 + for ; + Sat, 19 Mar 2005 23:52:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95271-09 + for ; + Sat, 19 Mar 2005 23:52:45 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id C7A6152AA3 + for ; + Sat, 19 Mar 2005 23:52:43 +0000 (GMT) +Received: (qmail 14770 invoked from network); 20 Mar 2005 00:52:54 +0100 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 20 Mar 2005 00:52:54 +0100 +Date: Sun, 20 Mar 2005 00:52:45 +0100 +To: "Josh Berkus" , + pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +References: <200503191202.38089.josh@agliodbs.com> + <2092.1111273359@sss.pgh.pa.us> +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <2092.1111273359@sss.pgh.pa.us> +User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/379 +X-Sequence-Number: 11084 + + +> tableoid would accomplish that already, assuming that the "partitioned +> table" is effectively a view on separate physical tables. +> +> regards, tom lane + + Very good. + + Also note the possibility to mark a partition READ ONLY. Or even a table. + It does not seem very useful but just think that for instance the "1999", +"2000" ... "2004" partitions of a big archive probably never change. +READLONY means we're sure they never change, thus no need to backup them +every time. Keeping the example of some DB arranged by years / current +year / current month, Just backup the "current month" part every day and +the "current year" every month when you switch partitions. + This could be achieved also by storing the time of last modification of a +table somewhere. + + +From pgsql-performance-owner@postgresql.org Sun Mar 20 00:03:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C3D5356881 + for ; + Sun, 20 Mar 2005 00:03:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00437-01 + for ; + Sun, 20 Mar 2005 00:03:18 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5ECC1568C6 + for ; + Sun, 20 Mar 2005 00:03:17 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2K03JAJ003376; + Sat, 19 Mar 2005 19:03:19 -0500 (EST) +To: Josh Berkus +Cc: pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +In-reply-to: <200503191529.51794.josh@agliodbs.com> +References: <200503191202.38089.josh@agliodbs.com> + <18168.1111265368@sss.pgh.pa.us> + <200503191529.51794.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Sat, 19 Mar 2005 15:29:51 -0800" +Date: Sat, 19 Mar 2005 19:03:19 -0500 +Message-ID: <3375.1111276999@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/380 +X-Sequence-Number: 11085 + +Josh Berkus writes: +>>> -- INSERT INTO should automatically create new partitions where necessary +>>> -- DELETE FROM should automatically drop empty partitions +>> +>> I am not sure I agree with either of those, and the reason is that they +>> would turn low-lock operations into high-lock operations. + +> For INSERT, I think that's a problem we need to work through. + +Possibly, but I'm concerned about locking and deadlock issues. The +reason that this is iffy is you would start the operation with only +an INSERT-grade lock, and then discover that you needed to add a +partition, which is surely something that needs an exclusive-grade +lock (consider two sessions trying to add the same partition at the +same time). So I don't see how to do it without lock upgrading, +and lock upgrading is always a recipe for deadlocks. + +The DELETE case is even worse because you can't physically release +storage until you're sure nothing in it is needed anymore by any open +transaction --- that introduces VACUUM-like issues as well as the +deadlock problem. + +> Or are you proposing, instead, that attempts to insert beyond the +> range raise an error? + +That was what I had in mind --- then adding partitions would require +a manual operation. This would certainly be good enough for "phase I" +IMHO. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 20 00:06:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 91133568DC + for ; + Sun, 20 Mar 2005 00:05:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01047-02 + for ; + Sun, 20 Mar 2005 00:05:54 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 34468568CE + for ; + Sun, 20 Mar 2005 00:05:53 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2K05rCi003405; + Sat, 19 Mar 2005 19:05:53 -0500 (EST) +To: Alvaro Herrera +Cc: PFC , + Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +In-reply-to: <20050319225624.GA8467@dcc.uchile.cl> +References: <200503191202.38089.josh@agliodbs.com> + <20050319225624.GA8467@dcc.uchile.cl> +Comments: In-reply-to Alvaro Herrera + message dated "Sat, 19 Mar 2005 18:56:24 -0400" +Date: Sat, 19 Mar 2005 19:05:53 -0500 +Message-ID: <3404.1111277153@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/381 +X-Sequence-Number: 11086 + +Alvaro Herrera writes: +> We probably also need multi-table indexes. + +As Josh says, that seems antithetical to the main point of partitioning, +which is to be able to rapidly remove (and add) partitions of a table. +If you have to do index cleaning before you can drop a partition, what's +the point of partitioning? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 20 00:16:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AECEA56881 + for ; + Sun, 20 Mar 2005 00:16:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00437-09 + for ; + Sun, 20 Mar 2005 00:16:24 +0000 (GMT) +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 545BB568A7 + for ; + Sun, 20 Mar 2005 00:16:23 +0000 (GMT) +Received: from trofast.sesse.net ([129.241.93.32]) + by cassarossa.samfundet.no with esmtp (Exim 4.34) id 1DCo7E-0007kt-Am + for pgsql-performance@postgresql.org; Sun, 20 Mar 2005 01:16:25 +0100 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1DCo7D-0004iX-00 + for ; Sun, 20 Mar 2005 01:16:23 +0100 +Date: Sun, 20 Mar 2005 01:16:23 +0100 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +Message-ID: <20050320001623.GA16805@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <200503191202.38089.josh@agliodbs.com> + <18168.1111265368@sss.pgh.pa.us> + <200503191529.51794.josh@agliodbs.com> + <3375.1111276999@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <3375.1111276999@sss.pgh.pa.us> +X-Operating-System: Linux 2.6.11-rc3 on a i686 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.6+20040907i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.021 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/382 +X-Sequence-Number: 11087 + +On Sat, Mar 19, 2005 at 07:03:19PM -0500, Tom Lane wrote: +> Possibly, but I'm concerned about locking and deadlock issues. The +> reason that this is iffy is you would start the operation with only +> an INSERT-grade lock, and then discover that you needed to add a +> partition, which is surely something that needs an exclusive-grade +> lock (consider two sessions trying to add the same partition at the +> same time). So I don't see how to do it without lock upgrading, +> and lock upgrading is always a recipe for deadlocks. + +What about letting something periodical (say, vacuum) do this? + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Sun Mar 20 04:29:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1EC7655F07 + for ; + Sun, 20 Mar 2005 04:29:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56855-07 + for ; + Sun, 20 Mar 2005 04:29:28 +0000 (GMT) +Received: from sunsite.dcc.uchile.cl (sunsite.dcc.uchile.cl [192.80.24.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A866A55CC9 + for ; + Sun, 20 Mar 2005 04:29:26 +0000 (GMT) +Received: from anakena.dcc.uchile.cl (anakena [192.80.24.6]) + by sunsite.dcc.uchile.cl (8.12.11/8.12.11) with ESMTP id j2K4THcn028331; + Sun, 20 Mar 2005 00:29:17 -0400 (CLT) +Received: by anakena.dcc.uchile.cl (Postfix, from userid 4151) + id 5E9E65236B; Sun, 20 Mar 2005 00:29:17 -0400 (CLT) +Date: Sun, 20 Mar 2005 00:29:17 -0400 +From: Alvaro Herrera +To: Tom Lane +Cc: PFC , + Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +Message-ID: <20050320042917.GA25831@dcc.uchile.cl> +References: <200503191202.38089.josh@agliodbs.com> + <20050319225624.GA8467@dcc.uchile.cl> + <3404.1111277153@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3404.1111277153@sss.pgh.pa.us> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.352 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/383 +X-Sequence-Number: 11088 + +On Sat, Mar 19, 2005 at 07:05:53PM -0500, Tom Lane wrote: +> Alvaro Herrera writes: +> > We probably also need multi-table indexes. +> +> As Josh says, that seems antithetical to the main point of partitioning, +> which is to be able to rapidly remove (and add) partitions of a table. +> If you have to do index cleaning before you can drop a partition, what's +> the point of partitioning? + +Hmm. You are right, but without that we won't be able to enforce +uniqueness on the partitioned table (we could only enforce it on each +partition, which would mean we can't partition on anything else than +primary keys if the tables have one). IMHO this is something to +consider. + +-- +Alvaro Herrera () +"El hombre nunca sabe de lo que es capaz hasta que lo intenta" (C. Dickens) + +From pgsql-performance-owner@postgresql.org Sun Mar 20 04:43:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 451CA558AC + for ; + Sun, 20 Mar 2005 04:43:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61986-01 + for ; + Sun, 20 Mar 2005 04:43:03 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C6EFD556D3 + for ; + Sun, 20 Mar 2005 04:43:01 +0000 (GMT) +Received: from dyn-70-66.tor.dsl.tht.net (dyn-70-66.tor.dsl.tht.net + [134.22.70.66]) by tht.net (Postfix) with ESMTP + id CB2207787F; Sat, 19 Mar 2005 23:43:04 -0500 (EST) +Subject: Re: What needs to be done for real Partitioning? +From: Rod Taylor +To: Alvaro Herrera +Cc: pgsql-performance@postgresql.org, + Josh Berkus , PFC , + Tom Lane +In-Reply-To: <20050320042917.GA25831@dcc.uchile.cl> +References: <200503191202.38089.josh@agliodbs.com> + <20050319225624.GA8467@dcc.uchile.cl> + <3404.1111277153@sss.pgh.pa.us> <20050320042917.GA25831@dcc.uchile.cl> +Content-Type: text/plain +Date: Sat, 19 Mar 2005 23:42:17 -0500 +Message-Id: <1111293737.1132.358.camel@home> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.0 FreeBSD GNOME Team Port +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/384 +X-Sequence-Number: 11089 + +On Sun, 2005-03-20 at 00:29 -0400, Alvaro Herrera wrote: +> On Sat, Mar 19, 2005 at 07:05:53PM -0500, Tom Lane wrote: +> > Alvaro Herrera writes: +> > > We probably also need multi-table indexes. +> > +> > As Josh says, that seems antithetical to the main point of partitioning, +> > which is to be able to rapidly remove (and add) partitions of a table. +> > If you have to do index cleaning before you can drop a partition, what's +> > the point of partitioning? +> +> Hmm. You are right, but without that we won't be able to enforce +> uniqueness on the partitioned table (we could only enforce it on each +> partition, which would mean we can't partition on anything else than +> primary keys if the tables have one). IMHO this is something to +> consider. + +Could uniqueness across partitions be checked for using a mechanism +similar to what a deferred unique constraint would use (trigger / index +combination)? + + +From pgsql-performance-owner@postgresql.org Sun Mar 20 04:48:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 73CD15513E + for ; + Sun, 20 Mar 2005 04:48:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60769-08 + for ; + Sun, 20 Mar 2005 04:48:00 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 12EB95458B + for ; + Sun, 20 Mar 2005 04:47:59 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2K4lrWP004508; + Sat, 19 Mar 2005 23:47:53 -0500 (EST) +To: Alvaro Herrera +Cc: PFC , + Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +In-reply-to: <20050320042917.GA25831@dcc.uchile.cl> +References: <200503191202.38089.josh@agliodbs.com> + <20050319225624.GA8467@dcc.uchile.cl> + <3404.1111277153@sss.pgh.pa.us> + <20050320042917.GA25831@dcc.uchile.cl> +Comments: In-reply-to Alvaro Herrera + message dated "Sun, 20 Mar 2005 00:29:17 -0400" +Date: Sat, 19 Mar 2005 23:47:53 -0500 +Message-ID: <4507.1111294073@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/385 +X-Sequence-Number: 11090 + +Alvaro Herrera writes: +> Hmm. You are right, but without that we won't be able to enforce +> uniqueness on the partitioned table (we could only enforce it on each +> partition, which would mean we can't partition on anything else than +> primary keys if the tables have one). IMHO this is something to +> consider. + +Well, partitioning on the primary key would be Good Enough for 95% or +99% of the real problems out there. I'm not excited about adding a +large chunk of complexity to cover another few percent. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 20 06:14:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1847C5680B + for ; + Sun, 20 Mar 2005 06:14:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81869-06 + for ; + Sun, 20 Mar 2005 06:14:11 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 03E0056803 + for ; + Sun, 20 Mar 2005 06:14:09 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DCthK-0006Yn-00; Sun, 20 Mar 2005 01:14:02 -0500 +To: Josh Berkus +Cc: pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +References: <200503191202.38089.josh@agliodbs.com> +In-Reply-To: <200503191202.38089.josh@agliodbs.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 20 Mar 2005 01:14:01 -0500 +Message-ID: <87br9ehmja.fsf@stark.xeocode.com> +Lines: 99 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.016 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/386 +X-Sequence-Number: 11091 + + +Josh Berkus writes: + +> -- INSERT INTO should automatically create new partitions where necessary +> ---- new tables should automatically inherit all constraints, indexes, +> keys of "parent" table + +I think you're going about this backwards. + +Phase I should be an entirely manual system where you add and remove +partitions manually and create and drop indexes you want manually. You need +these low level interfaces anyways for a complete system, it doesn't make +sense to have everything automatic and then later try to wedge in a low level +interface. Only once you have that do you then start offering options to do +these things automatically. + +I also think there are a few other components mixed up in your proposal that +are really not integral to partitioned tables. Tablespaces and expression +indexes may well be useful features to use in combination with partitioned +tables, but they shouldn't be required or automatic. + + From my experience with Oracle I think there's one big concept that makes the +whole system make a lot more sense: individual partitions are really tables. +The partitioned tables themselves are just meta-objects like views. + +Once you get that concept the whole featureset makes a lot more sense. You can +pull a partition out of a partitioned table and it becomes a normal table. You +can take a normal table and put it into a partitioned table. Creating a new +partition or altering a partition is just the same as creating or altering a +new table (except for the actual data definition part). + +Given that understanding it's clear that tablespaces are an entirely +orthogonal feature. One that happens to play well with partitioned tables, but +not one that partitioned tables need any special support for. When you create +a new partition or create a table intending to add it as a partition to a +partitioned table you specify the tablespace just as you would normally do. + +It's also clear that the last thing you want is an index on the partition key. +A big part of the advantage of partitioned tables is precisely that you get +the advantage of an index on a column without the extra expense. + +It would also be reasonable to allow clustering individual partitions; +creating table or column constraints on some partitions and not others; or +even allow having indexes on some partitions and not others. In general the +only operations that you wouldn't be able to do on an individual partition +would be operations that make the column definitions incompatible with the +parent table. + +The $64 question is how to specify the partitioning rules. That is, the rule +for determining which partition an insert should go into and which partitions +to look for records in. Oracle handles this by specifying a list of columns +when creating the partitioned table and then specifying either a range or +specific values for each individual partition. I can imagine other approaches +but none that allow for the planner and optimizer to take as much advantage of +the information. + +So I think Phase I should look like: + + An ALTER TABLE command to make an inherited table "abstract" in the object + oriented sense. That is, no records can be inserted in the parent table. If + you follow the oracle model this is also where you specify the partition + key. There's no index associated with this partition key though. + + A command to create a new partition, essentially syntactic sugar for a + CREATE TABLE with an implied INHERITS clause and a constraint on the + partition key. If you follow the oracle model then you explicitly specify + which range or specific value of the partition key this partition holds. + + A command to remove a partition from the partitioned table and turn it into + a regular table. + + A command to take a regular table and turn it into a partition. Again here + you specify the range or value of the partition key. There has to be some + verification that the table really holds the correct data though. Perhaps + this could be skipped by providing a table with a properly constructed + constraint in place. + + Magic to make INSERT/UPDATE figure out the correct partition to insert the new + record. (Normally I would have suggested that UPDATE wasn't really necessary + but in Postgres it seems like it would fall out naturally from having INSERT.) + +Phase II would be planner and executor improvements to take advantage of the +information to speed up queries and allow for individual partitions to be +read-only or otherwise inaccessible without impeding queries that don't need +that partition. + +Phase III would be autopilot features like having new partitions automatically +created and destroyed and being able to specify in advance rules for +determining which tablespaces to use for these new partitions. + +I'm not sure whether to put global indexes under Phase II or III. Personally I +think there's no point to them at all. They defeat the whole point of +partitioned tables. Once you have global indexes adding and removing +partitions becomes a lot harder and slower. You may as well have kept +everything in one table in the first place. But apparently some people find +them useful. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sun Mar 20 10:20:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 94C6C56679 + for ; + Sun, 20 Mar 2005 10:20:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29965-08 + for ; + Sun, 20 Mar 2005 10:20:27 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 18A565660C + for ; + Sun, 20 Mar 2005 10:20:26 +0000 (GMT) +Received: (qmail 21552 invoked from network); 20 Mar 2005 11:20:32 +0100 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 20 Mar 2005 11:20:32 +0100 +To: "Greg Stark" , "Josh Berkus" +Cc: pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +References: <200503191202.38089.josh@agliodbs.com> + <87br9ehmja.fsf@stark.xeocode.com> +Message-ID: +Date: Sun, 20 Mar 2005 11:20:23 +0100 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <87br9ehmja.fsf@stark.xeocode.com> +User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/387 +X-Sequence-Number: 11092 + + + +> It would also be reasonable to allow clustering individual partitions; +> creating table or column constraints on some partitions and not others; + + I have a session mamagement which works like that, using views now. + + sessions.online is a table of the online sessions. It has a UNIQUE on +user_id. + sessions.archive contains all the closed sessions. Obviously it does not +have a UNIQUE on user_id. + + + + + +From pgsql-performance-owner@postgresql.org Sun Mar 20 17:58:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 062F355DC4 + for ; + Sun, 20 Mar 2005 17:58:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39960-01 + for ; + Sun, 20 Mar 2005 17:58:40 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id F0DA452A64 + for ; + Sun, 20 Mar 2005 17:58:39 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2KHwUCH008165; + Sun, 20 Mar 2005 12:58:31 -0500 (EST) +To: Greg Stark +Cc: Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +In-reply-to: <87br9ehmja.fsf@stark.xeocode.com> +References: <200503191202.38089.josh@agliodbs.com> + <87br9ehmja.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "20 Mar 2005 01:14:01 -0500" +Date: Sun, 20 Mar 2005 12:58:30 -0500 +Message-ID: <8164.1111341510@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/388 +X-Sequence-Number: 11093 + +Greg Stark writes: +> So I think Phase I should look like: + +> An ALTER TABLE command to make an inherited table "abstract" in the object +> oriented sense. That is, no records can be inserted in the parent table. If +> you follow the oracle model this is also where you specify the partition +> key. There's no index associated with this partition key though. + +Check. + +> A command to create a new partition, essentially syntactic sugar for a +> CREATE TABLE with an implied INHERITS clause and a constraint on the +> partition key. If you follow the oracle model then you explicitly specify +> which range or specific value of the partition key this partition holds. + +Check. + +> A command to remove a partition from the partitioned table and turn it into +> a regular table. + +Ugh. Why? You can access the table directly anyway. + +> A command to take a regular table and turn it into a partition. + +Double ugh. Verifying that the table matches the partition scheme seems +like a lot of ugly, bug-prone, unnecessary code. What's the use case +for this anyway? + +Those last two are *certainly* not Phase I requirements, and I don't +think we need them at all ever. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 20 19:58:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E64656478 + for ; + Sun, 20 Mar 2005 19:58:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96227-09 + for ; + Sun, 20 Mar 2005 19:57:51 +0000 (GMT) +Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) + by svr1.postgresql.org (Postfix) with ESMTP id E54DC56480 + for ; + Sun, 20 Mar 2005 19:57:49 +0000 (GMT) +Received: from grownups (c-24-21-166-228.client.comcast.net[24.21.166.228]) + by comcast.net (rwcrmhc11) with SMTP + id <2005032019574901300eh125e>; Sun, 20 Mar 2005 19:57:50 +0000 +Message-ID: <002a01c52d87$543d1010$0200a8c0@grownups> +From: "Stacy White" +To: "Alvaro Herrera" , "Tom Lane" +Cc: "PFC" , + "Josh Berkus" , +References: <200503191202.38089.josh@agliodbs.com> + <20050319225624.GA8467@dcc.uchile.cl> + <3404.1111277153@sss.pgh.pa.us> +Subject: Re: What needs to be done for real Partitioning? +Date: Sun, 20 Mar 2005 11:59:29 -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.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.255 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/389 +X-Sequence-Number: 11094 + +From: "Tom Lane" +> Alvaro Herrera writes: +> > We probably also need multi-table indexes. +> As Josh says, that seems antithetical to the main point of partitioning, +> which is to be able to rapidly remove (and add) partitions of a table. +> If you have to do index cleaning before you can drop a partition, what's +> the point of partitioning? + +Global indexes (as opposed to partition local indexes) are useful in cases +where you have a large number of partitions, index columns different than +the partition key, and index values that limit the query to just a subset of +the partitions. + +The two domains that I'm most familiar with are warehouse management, and +the film industry. In both these cases it's logical to partition on +day/week/month, it's frequently important to keep a lot of history, and it's +common to have products that only show activity for a few months. In one of +our production systems we have 800 partitions (by week, with a lot of +history), but a popular product might have only 20 weeks worth of activity. +Selecting records for the product requires at least 800 random-access reads +if you have local indexes on 'product_no', 780 of which just tell the +executor that the partition doesn't include any information on the product. + +This is definitely a phase II item, but as I said before it's worth +considering since good DBAs can do a lot with global indexes. + +FWIW, we see large benefits from partitioning other than the ability to +easily drop data, for example: + +- We can vacuum only the active portions of a table +- Postgres automatically keeps related records clustered together on disk, +which makes it more likely that the blocks used by common queries can be +found in cache +- The query engine uses full table scans on the relevant sections of data, +and quickly skips over the irrelevant sections +- 'CLUSTER'ing a single partition is likely to be significantly more +performant than clustering a large table + +In fact, we have yet to drop a partition on any of our Oracle or Postgres +production systems. + + +From pgsql-performance-owner@postgresql.org Sun Mar 20 20:04:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6668B56374 + for ; + Sun, 20 Mar 2005 20:04:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96180-09 + for ; + Sun, 20 Mar 2005 20:04:01 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 378E854E09 + for ; + Sun, 20 Mar 2005 20:04:00 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7148369; Sun, 20 Mar 2005 12:05:53 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Alvaro Herrera +Subject: Re: What needs to be done for real Partitioning? +Date: Sun, 20 Mar 2005 12:03:41 -0800 +User-Agent: KMail/1.6.2 +Cc: Tom Lane , PFC , + pgsql-performance@postgresql.org +References: <200503191202.38089.josh@agliodbs.com> + <3404.1111277153@sss.pgh.pa.us> + <20050320042917.GA25831@dcc.uchile.cl> +In-Reply-To: <20050320042917.GA25831@dcc.uchile.cl> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200503201203.41249.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/390 +X-Sequence-Number: 11095 + +Alvaro, Greg, Tom, + +> Hmm. You are right, but without that we won't be able to enforce +> uniqueness on the partitioned table (we could only enforce it on each +> partition, which would mean we can't partition on anything else than +> primary keys if the tables have one). IMHO this is something to +> consider. + +Sure. However, for most partitioned use cases, the partition column will be +part of the real key of the table (for example, for a security log, the real +key might be (timestamp, machine, application, event_type) with the partition +on extract(hour from timestamp)). As a result, there is no need to enforce +inter-partition uniqueness; the paritioning scheme enforces it already. + +The only need for inter-partition uniqueness is on surrogate integer keys. +This can already be enforced de-facto simply by using a sequence. While it +would be possible to create a uniqueness check that spans partitions, it +would be very expensive to do so, thus elminating some of the advantage of +partitioning in the first place. I'm not saying that we won't want this +some day as an option, I just see it as a Phase III refinement. + +Greg, first of all, thanks for helping clean up my muddy thinking about +implementing partitions. Comments below: + +> Phase I should be an entirely manual system where you add and remove +> partitions manually and create and drop indexes you want manually. You need +> these low level interfaces anyways for a complete system, it doesn't make +> sense to have everything automatic and then later try to wedge in a low +> level interface. Only once you have that do you then start offering options +> to do these things automatically. + +This makes sense. Thanks! + +> whole system make a lot more sense: individual partitions are really +> tables. The partitioned tables themselves are just meta-objects like views. + +So, like the current pseudo-partitioning implementation, partitions would be +"full tables" just with some special rules for query-rewriting when they are +pulled. This makes sense, I think I just got carried away in another +direction. + +> It's also clear that the last thing you want is an index on the partition +> key. A big part of the advantage of partitioned tables is precisely that +> you get the advantage of an index on a column without the extra expense. + +Well, you need it with the current pseudo-partitioning. What would allow us +to eliminate indexing the partition key is special re-writing rules that only +pull the partitions compliant with the outer query. Until that step takes +place, the indexes are very much needed. So maybe the advanced planner +rewriting is a Phase I item, not a Phase II item? + +> The $64 question is how to specify the partitioning rules. That is, the +> rule for determining which partition an insert should go into and which +> partitions to look for records in. Oracle handles this by specifying a list +> of columns when creating the partitioned table and then specifying either a +> range or specific values for each individual partition. I can imagine other +> approaches but none that allow for the planner and optimizer to take as +> much advantage of the information. + +Well, I would think that specifying an expression that defines a new partition +at each change in value (like EXTRACT(day FROM timestamp) on a time-based +partitioning) would cover 90% of implemenations and be a lot simpler to +administer. The Oracle approach has the advantage of allowing "custom +paritioning" at the expense of greater complexity. + +> A command to remove a partition from the partitioned table and turn it +> into a regular table. +> +> A command to take a regular table and turn it into a partition. Again +> here you specify the range or value of the partition key. There has to be +> some verification that the table really holds the correct data though. +> Perhaps this could be skipped by providing a table with a properly +> constructed constraint in place. + +Like Tom, I don't see the point in these. What do they do that CREATE TABLE +AS and/or INSERT INTO do not? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sun Mar 20 20:23:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 64D7A56483 + for ; + Sun, 20 Mar 2005 20:23:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80818-05 + for ; + Sun, 20 Mar 2005 20:23:28 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 08FB4540C9 + for ; + Sun, 20 Mar 2005 20:23:21 +0000 (GMT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id j2KKMv5Q024775; + Sun, 20 Mar 2005 23:22:57 +0300 (MSK) +Date: Sun, 20 Mar 2005 23:22:57 +0300 (MSK) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Josh Berkus +Cc: Alvaro Herrera , + Tom Lane , PFC , + pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +In-Reply-To: <200503201203.41249.josh@agliodbs.com> +Message-ID: +References: <200503191202.38089.josh@agliodbs.com> + <3404.1111277153@sss.pgh.pa.us> + <20050320042917.GA25831@dcc.uchile.cl> + <200503201203.41249.josh@agliodbs.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.346 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/391 +X-Sequence-Number: 11096 + +On Sun, 20 Mar 2005, Josh Berkus wrote: + +> +>> whole system make a lot more sense: individual partitions are really +>> tables. The partitioned tables themselves are just meta-objects like views. + +If partition is a table, so I could define different indices for them ? +In our prototype of scaled full text search we create another index +which is optimized for "archived" (not changed) data - it's sort of +standard inverted index which is proven to be scaled, while tsearch2's index +is good for "online" data. All interfaces ( dictionaries, parsers, ranking) +are the same, so it's possible to combine search results. +This is rather easy to implement using table inheritance, but I'd like +to do this with partitioning + + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Sun Mar 20 22:18:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D19EC567C5 + for ; + Sun, 20 Mar 2005 22:18:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33405-03 + for ; + Sun, 20 Mar 2005 22:18:47 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 5BACA567CB + for ; + Sun, 20 Mar 2005 22:18:46 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DD8kl-0000Dl-00; Sun, 20 Mar 2005 17:18:36 -0500 +To: Tom Lane +Cc: Greg Stark , Josh Berkus , + pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +References: <200503191202.38089.josh@agliodbs.com> + <87br9ehmja.fsf@stark.xeocode.com> <8164.1111341510@sss.pgh.pa.us> +In-Reply-To: <8164.1111341510@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 20 Mar 2005 17:18:35 -0500 +Message-ID: <87oedeezb8.fsf@stark.xeocode.com> +Lines: 44 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.015 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/392 +X-Sequence-Number: 11097 + + +Tom Lane writes: + +> > A command to remove a partition from the partitioned table and turn it into +> > a regular table. +> +> Ugh. Why? You can access the table directly anyway. +> +> > A command to take a regular table and turn it into a partition. +> +> Double ugh. Verifying that the table matches the partition scheme seems +> like a lot of ugly, bug-prone, unnecessary code. What's the use case +> for this anyway? +> +> Those last two are *certainly* not Phase I requirements, and I don't +> think we need them at all ever. + +These are effectively equivalent to "ALTER TABLE RENAME". Without these +commands you would be in pretty much the same position as a DBA without the +ability to rename tables. + +The heart of partitioned tables is being able to load and unload entire +partitions quickly. You have to have somewhere to "unload" them too. Most +people aren't happy just watching their data disappear entirely. They want to +move them other tables or even other databases. + +Similarly, they have to have somewhere to load them from. They're usually not +happy loading data directly into their production data warehouse tables +without manipulating the data, or doing things like clustering or indexing. + +You could argue for some sort of setup where you could take a partition +"offline" during which you could safely do things like export or manipulate +the data. But that's awfully limiting. What if I want to do things like add +columns, or change data types, or any other manipulation that breaks the +symmetry with the production partitioned table. + +I don't think it's really hard at all to check that the table matches the +partition scheme. You can just require that there be an existing table +constraint in place that matches the partitioning scheme. I think you can even +be fascist about the exact syntax of the constraint fitting precisely a +specified format. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sun Mar 20 23:02:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CD64756462 + for ; + Sun, 20 Mar 2005 23:01:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42693-03 + for ; + Sun, 20 Mar 2005 23:01:55 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CDDA56454 + for ; + Sun, 20 Mar 2005 23:01:55 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2KN1nqr014173; + Sun, 20 Mar 2005 18:01:49 -0500 (EST) +To: "Stacy White" +Cc: "Alvaro Herrera" , + "PFC" , + "Josh Berkus" , pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +In-reply-to: <002a01c52d87$543d1010$0200a8c0@grownups> +References: <200503191202.38089.josh@agliodbs.com> + <20050319225624.GA8467@dcc.uchile.cl> + <3404.1111277153@sss.pgh.pa.us> + <002a01c52d87$543d1010$0200a8c0@grownups> +Comments: In-reply-to "Stacy White" + message dated "Sun, 20 Mar 2005 11:59:29 -0800" +Date: Sun, 20 Mar 2005 18:01:49 -0500 +Message-ID: <14172.1111359709@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/393 +X-Sequence-Number: 11098 + +"Stacy White" writes: +> FWIW, we see large benefits from partitioning other than the ability to +> easily drop data, for example: + +> - We can vacuum only the active portions of a table +> - Postgres automatically keeps related records clustered together on disk, +> which makes it more likely that the blocks used by common queries can be +> found in cache +> - The query engine uses full table scans on the relevant sections of data, +> and quickly skips over the irrelevant sections +> - 'CLUSTER'ing a single partition is likely to be significantly more +> performant than clustering a large table + +Global indexes would seriously reduce the performance of both vacuum and +cluster for a single partition, and if you want seq scans you don't need +an index for that at all. So the above doesn't strike me as a strong +argument for global indexes ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 20 23:05:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 06094564B3 + for ; + Sun, 20 Mar 2005 23:05:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44115-03 + for ; + Sun, 20 Mar 2005 23:05:33 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D35C56487 + for ; + Sun, 20 Mar 2005 23:05:32 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2KN5Qc8014202; + Sun, 20 Mar 2005 18:05:26 -0500 (EST) +To: Greg Stark +Cc: Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +In-reply-to: <87oedeezb8.fsf@stark.xeocode.com> +References: <200503191202.38089.josh@agliodbs.com> + <87br9ehmja.fsf@stark.xeocode.com> <8164.1111341510@sss.pgh.pa.us> + <87oedeezb8.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "20 Mar 2005 17:18:35 -0500" +Date: Sun, 20 Mar 2005 18:05:25 -0500 +Message-ID: <14201.1111359925@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/394 +X-Sequence-Number: 11099 + +Greg Stark writes: +> You could argue for some sort of setup where you could take a partition +> "offline" during which you could safely do things like export or manipulate +> the data. But that's awfully limiting. What if I want to do things like add +> columns, or change data types, or any other manipulation that breaks the +> symmetry with the production partitioned table. + +[ scrapes eyebrows off ceiling... ] You don't really expect to be able +to do that kind of thing to just one partition do you? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 20 23:15:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B238F5645D + for ; + Sun, 20 Mar 2005 23:15:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44523-06 + for ; + Sun, 20 Mar 2005 23:15:11 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F1E256435 + for ; + Sun, 20 Mar 2005 23:15:10 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DD9dM-0000Lh-00; Sun, 20 Mar 2005 18:15:00 -0500 +To: Josh Berkus +Cc: Alvaro Herrera , + Tom Lane , PFC , + pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +References: <200503191202.38089.josh@agliodbs.com> + <3404.1111277153@sss.pgh.pa.us> <20050320042917.GA25831@dcc.uchile.cl> + <200503201203.41249.josh@agliodbs.com> +In-Reply-To: <200503201203.41249.josh@agliodbs.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 20 Mar 2005 18:14:59 -0500 +Message-ID: <87fyypgb9o.fsf@stark.xeocode.com> +Lines: 66 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.015 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/395 +X-Sequence-Number: 11100 + +Josh Berkus writes: + +> Well, I would think that specifying an expression that defines a new partition +> at each change in value (like EXTRACT(day FROM timestamp) on a time-based +> partitioning) would cover 90% of implemenations and be a lot simpler to +> administer. The Oracle approach has the advantage of allowing "custom +> paritioning" at the expense of greater complexity. + +Hm. This is where I might be less helpful. Once you're submersed in one way of +doing things it can be hard to think outside the box like this. + +But I fear this scheme might be harder to actually take advantage of. If I do +a query like + + WHERE timestamp BETWEEN '2005-01-01 11:00' AND '2005-01-01 12:00' + +How do you determine which partitions that range will cover? + +Also, it seems like it would be inconvenient to try to construct expressions +to handle things like "start a new partition ever 1 million values". + +And worse, how would you handle changing schemes with this? Like, say we want +to switch from starting one partition per month to starting one partition per +week? + + + +I think some actual use cases might be helpful for you. I can contribute an +interesting one, though I have to be intentionally vague even though I don't +work on that system any more. + +We had a table with a layout like: + +txnid serial, +groupid integer, +data... + +Each day a cron job created 6 new groups (actually later that was changed to +some other number). It then added a new partition to handle the range of the +new day's groups. Later another cron job exchanged out the partition from a +week earlier and exported that table, transfered it to another machine and +loaded it there. + +txnid was a unique identifier but we couldn't have a unique constraint because +that would have required a global index. That didn't cause any problems since +it was a sequence generated column anyways. + +We did have a unique index on which is a local index because +groupid was the partition key. In reality nothing in our system ever really +needed a txn without knowing which group it came from anyways, so it was easy +to change our queries to take advantage of this. + +We had a lot of jobs, some *extremely* performance sensitive that depended on +being able to scan the entire list of txns for a given day or a given set of +groupids. The partitions meant it could do a full table scan which made these +extremely fast. + +This was with Oracle 8i. All partition keys in 8i were ranges. In 9 Oracle +added the ability to make partition reference specific id values. Sort of like +how you're describing having a key expression. We might have considered using +that scheme with groupid but then it would have meant adding a bunch of new +partitions each day and having some queries that would involve scanning +multiple partitions. + +-- +Greg + + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:07:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A859E563D3 + for ; + Mon, 21 Mar 2005 03:33:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20705-05 + for ; + Mon, 21 Mar 2005 03:33:21 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 6312C563BC + for ; + Mon, 21 Mar 2005 03:33:20 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DDDfE-0000uU-00; Sun, 20 Mar 2005 22:33:12 -0500 +To: Tom Lane +Cc: Greg Stark , Josh Berkus , + pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +References: <200503191202.38089.josh@agliodbs.com> + <87br9ehmja.fsf@stark.xeocode.com> <8164.1111341510@sss.pgh.pa.us> + <87oedeezb8.fsf@stark.xeocode.com> <14201.1111359925@sss.pgh.pa.us> +In-Reply-To: <14201.1111359925@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 20 Mar 2005 22:33:12 -0500 +Message-ID: <87acoxfzbb.fsf@stark.xeocode.com> +Lines: 23 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.015 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/398 +X-Sequence-Number: 11103 + +Tom Lane writes: + +> Greg Stark writes: +> > You could argue for some sort of setup where you could take a partition +> > "offline" during which you could safely do things like export or manipulate +> > the data. But that's awfully limiting. What if I want to do things like add +> > columns, or change data types, or any other manipulation that breaks the +> > symmetry with the production partitioned table. +> +> [ scrapes eyebrows off ceiling... ] You don't really expect to be able +> to do that kind of thing to just one partition do you? + +Well no. That's exactly why I would want to pull the partition out of the +partitioned table so that I can then do whatever work I need to archive it +without affecting the partitioned table. + +Take an analogous situation. I have a huge log file I want to rotate. The +quickest most efficient way to do this would be to move it aside, HUP the +daemon (or whatever else I have to do to get it to open a new file) then gzip +and archive the old log files. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:04:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8EF7156486 + for ; + Mon, 21 Mar 2005 03:37:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22344-02 + for ; + Mon, 21 Mar 2005 03:37:21 +0000 (GMT) +Received: from mxsf32.cluster1.charter.net (mxsf32.cluster1.charter.net + [209.225.28.156]) + by svr1.postgresql.org (Postfix) with ESMTP id 404A6563DE + for ; + Mon, 21 Mar 2005 03:37:20 +0000 (GMT) +Received: from mxip06.cluster1.charter.net (mxip06a.cluster1.charter.net + [209.225.28.136]) + by mxsf32.cluster1.charter.net (8.12.11/8.12.11) with ESMTP id + j2L3bNeH031493 + for ; Sun, 20 Mar 2005 22:37:24 -0500 +Received: from pc-68-118-180-13.will.ct.charter.com (HELO [192.168.116.102]) + (68.118.180.13) + by mxip06.cluster1.charter.net with ESMTP; 20 Mar 2005 22:37:23 -0500 +X-Ironport-AV: i="3.91,105,1110171600"; + d="scan'208"; a="682501728:sNHT26986800" +Message-ID: <423E420D.1020503@NarrowPathInc.com> +Date: Sun, 20 Mar 2005 22:39:57 -0500 +From: Keith Worthington +Reply-To: KeithW@NarrowPathInc.com +Organization: Narrow Path, Inc. +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: View vs function +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.12 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/397 +X-Sequence-Number: 11102 + +Hi All, + +I have been reading about set returning functions. What I would like to +know is is there a performance advantage in using SRFs versus querying a +view. Assuming the underlying SQL is the same for the view vs the +function except for the WHERE clause which of these would you expect to +be faster? Or does the planner realize all this... + +SELECT * FROM view_big_query WHERE column1 = 1234; + +SELECT * FROM func_bug_query(1234); + +-- +Kind Regards, +Keith + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:01:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 73F31563FD + for ; + Mon, 21 Mar 2005 03:47:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25481-05 + for ; + Mon, 21 Mar 2005 03:47:46 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 4297E52A85 + for ; + Mon, 21 Mar 2005 03:47:45 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DDDtH-0000wa-00; Sun, 20 Mar 2005 22:47:43 -0500 +To: Tom Lane +Cc: "Stacy White" , + "Alvaro Herrera" , + "PFC" , + "Josh Berkus" , pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +References: <200503191202.38089.josh@agliodbs.com> + <20050319225624.GA8467@dcc.uchile.cl> + <3404.1111277153@sss.pgh.pa.us> + <002a01c52d87$543d1010$0200a8c0@grownups> + <14172.1111359709@sss.pgh.pa.us> +In-Reply-To: <14172.1111359709@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 20 Mar 2005 22:47:43 -0500 +Message-ID: <871xa9fyn4.fsf@stark.xeocode.com> +Lines: 26 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.015 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/396 +X-Sequence-Number: 11101 + +Tom Lane writes: + +> Global indexes would seriously reduce the performance of both vacuum and +> cluster for a single partition, and if you want seq scans you don't need +> an index for that at all. So the above doesn't strike me as a strong +> argument for global indexes ... + +I think he means some sort of plan for queries like + + select * from invoices where customer_id = 1 + +where customer 1 only did business with us for two years. One could imagine +some kind of very coarse grained bitmap index that just knows which partitions +customer_id=1 appears in, and then does a sequential scan of those partitions. + +But I think you can do nearly as well without using global indexes of any +type. Assuming you had local indexes on customer_id for each partition and +separate histograms for each partition the planner could conclude that it +needs sequential scans for some partitions and a quick index lookup expecting +0 records for other partitions. + +Not as good as pruning partitions entirely but if you're doing a sequential +scan the performance hit of a few index lookups isn't a problem. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Mar 21 04:41:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 75CD756786 + for ; + Mon, 21 Mar 2005 04:11:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32969-01 + for ; + Mon, 21 Mar 2005 04:11:03 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 2F3D356655 + for ; + Mon, 21 Mar 2005 04:11:02 +0000 (GMT) +Received: (qmail 27153 invoked by uid 500); 21 Mar 2005 04:27:20 -0000 +Date: Sun, 20 Mar 2005 22:27:20 -0600 +From: Bruno Wolff III +To: Keith Worthington +Cc: pgsql-performance@postgresql.org +Subject: Re: View vs function +Message-ID: <20050321042720.GA27098@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Keith Worthington , + pgsql-performance@postgresql.org +References: <423E420D.1020503@NarrowPathInc.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <423E420D.1020503@NarrowPathInc.com> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/399 +X-Sequence-Number: 11104 + +On Sun, Mar 20, 2005 at 22:39:57 -0500, + Keith Worthington wrote: +> Hi All, +> +> I have been reading about set returning functions. What I would like to +> know is is there a performance advantage in using SRFs versus querying a +> view. Assuming the underlying SQL is the same for the view vs the +> function except for the WHERE clause which of these would you expect to +> be faster? Or does the planner realize all this... + +In general you are going to be better off with a view, since the planner +knows what the view is doing and there may be some optimizations it +can make. Functions are just black boxes to the planner. + +> +> SELECT * FROM view_big_query WHERE column1 = 1234; +> +> SELECT * FROM func_bug_query(1234); +> +> -- +> Kind Regards, +> Keith +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq + +From pgsql-performance-owner@postgresql.org Mon Mar 21 05:13:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6FA925678A + for ; + Mon, 21 Mar 2005 05:13:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51561-07 + for ; + Mon, 21 Mar 2005 05:13:16 +0000 (GMT) +Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 20CA356742 + for ; + Mon, 21 Mar 2005 05:13:15 +0000 (GMT) +Received: from localhost (mailbox.samurai.com [205.207.28.82]) + by mailbox.samurai.com (Postfix) with ESMTP id 78FFA18D039; + Mon, 21 Mar 2005 00:13:14 -0500 (EST) +Received: from mailbox.samurai.com ([205.207.28.82]) + by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, + port 10024) + with LMTP id 71915-02-7; Mon, 21 Mar 2005 00:13:12 -0500 (EST) +Received: from [61.88.101.19] (unknown [61.88.101.19]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mailbox.samurai.com (Postfix) with ESMTP id D0F4F18D03A; + Mon, 21 Mar 2005 00:13:11 -0500 (EST) +Message-ID: <423E57E5.4070405@samurai.com> +Date: Mon, 21 Mar 2005 16:13:09 +1100 +From: Neil Conway +User-Agent: Debian Thunderbird 1.0 (X11/20050116) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bruno Wolff III +Cc: Keith Worthington , + pgsql-performance@postgresql.org +Subject: Re: View vs function +References: <423E420D.1020503@NarrowPathInc.com> + <20050321042720.GA27098@wolff.to> +In-Reply-To: <20050321042720.GA27098@wolff.to> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at mailbox.samurai.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.032 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/413 +X-Sequence-Number: 11118 + +Bruno Wolff III wrote: +> Functions are just black boxes to the planner. + +... unless the function is a SQL function that is trivial enough for the +planner to inline it into the plan of the invoking query. Currently, we +won't inline set-returning SQL functions that are used in the query's +rangetable, though. This would be worth doing, I think -- I'm not sure +how much work it would be, though. + +-Neil + +From pgsql-performance-owner@postgresql.org Mon Mar 21 05:13:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 36B4E565AA + for ; + Mon, 21 Mar 2005 05:13:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51471-07 + for ; + Mon, 21 Mar 2005 05:13:00 +0000 (GMT) +Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.85]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E07956494 + for ; + Mon, 21 Mar 2005 05:12:59 +0000 (GMT) +Received: from grownups (c-24-21-166-228.client.comcast.net[24.21.166.228]) + by comcast.net (rwcrmhc12) with SMTP + id <20050321051255014004rjnpe>; Mon, 21 Mar 2005 05:12:59 +0000 +Message-ID: <005901c52dd4$e3877830$0200a8c0@grownups> +From: "Stacy White" +To: "Tom Lane" +Cc: "Alvaro Herrera" , + "PFC" , + "Josh Berkus" , +References: <200503191202.38089.josh@agliodbs.com> + <20050319225624.GA8467@dcc.uchile.cl> + <3404.1111277153@sss.pgh.pa.us> + <002a01c52d87$543d1010$0200a8c0@grownups> + <14172.1111359709@sss.pgh.pa.us> +Subject: Re: What needs to be done for real Partitioning? +Date: Sun, 20 Mar 2005 21:14:37 -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.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.259 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/412 +X-Sequence-Number: 11117 + +From: "Tom Lane" +> "Stacy White" writes: +> > FWIW, we see large benefits from partitioning other than the ability to +> > easily drop data, for example: +> +> > - We can vacuum only the active portions of a table +> > - Postgres automatically keeps related records clustered together on +disk, +> > which makes it more likely that the blocks used by common queries can be +> > found in cache +> > - The query engine uses full table scans on the relevant sections of +data, +> > and quickly skips over the irrelevant sections +> > - 'CLUSTER'ing a single partition is likely to be significantly more +> > performant than clustering a large table +> Global indexes would seriously reduce the performance of both vacuum and +> cluster for a single partition, and if you want seq scans you don't need +> an index for that at all. So the above doesn't strike me as a strong +> argument for global indexes ... + +Tom, this list was in response to your question "If you have to do index +cleaning before you can drop a partition, what's the point of +partitioning?". I was trying to make the point that partioning isn't just +about being able to quickly drop data. The argument for global indexes came +in the form of my war story and the description of the conditions under +which global indexes will perform better than local indexes (see my original +email for details) . But, like I said, this would definitely be a phase +II/III item. + + +From pgsql-performance-owner@postgresql.org Mon Mar 21 05:38:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EF9FD563D3 + for ; + Mon, 21 Mar 2005 05:38:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59308-04 + for ; + Mon, 21 Mar 2005 05:38:30 +0000 (GMT) +Received: from rwcrmhc13.comcast.net (rwcrmhc13.comcast.net [204.127.198.39]) + by svr1.postgresql.org (Postfix) with ESMTP id 857DB552D4 + for ; + Mon, 21 Mar 2005 05:38:29 +0000 (GMT) +Received: from grownups (c-24-21-166-228.client.comcast.net[24.21.166.228]) + by comcast.net (rwcrmhc13) with SMTP + id <2005032105382801500el30fe>; Mon, 21 Mar 2005 05:38:29 +0000 +Message-ID: <007401c52dd8$73395450$0200a8c0@grownups> +From: "Stacy White" +To: "Tom Lane" , "Greg Stark" +Cc: "Alvaro Herrera" , + "PFC" , + "Josh Berkus" , +References: + <200503191202.38089.josh@agliodbs.com> + <20050319225624.GA8467@dcc.uchile.cl><3404.1111277153@sss.pgh.pa.us><002a01c52d87$543d1010$0200a8c0@grownups><14172.1111359709@sss.pgh.pa.us> + <871xa9fyn4.fsf@stark.xeocode.com> +Subject: Re: What needs to be done for real Partitioning? +Date: Sun, 20 Mar 2005 21:40:10 -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.1409 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.262 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/414 +X-Sequence-Number: 11119 + +From: "Greg Stark" +> Tom Lane writes: +> Not as good as pruning partitions entirely but if you're doing a +sequential +> scan the performance hit of a few index lookups isn't a problem. + +Greg, I think you've got the right idea. For large databases, though, it +won't be uncommon to have large numbers of partitions, in which case we're +not talking about a few index lookups. The database I used in my example +wasn't huge, but the table in question had over 800 partitions. A larger +database could have thousands. I suppose the importance of global indexes +depends on the sizes of the databases your target audience is running. + +Here's some more detail on our real-world experience: The group made the +decision to partition some of the larger tables for better performance. The +idea that global indexes aren't useful is pretty common in the database +world, and 2 or 3 good DBAs suggested that the 'product_no' index be local. +But with the local indexes, performance on some queries was bad enough that +the group actually made the decision to switch back to unpartitioned tables. +(The performance problems came about because of the overhead involved in +searching >800 indices to find the relevant rows). + +Luckily they that had the chance to work with a truly fantastic DBA (the +author of an Oracle Press performance tuning book even) before they could +switch back. He convinced them to make some of their indexes global. +Performance dramatically improved (compared with both the unpartitioned +schema, and the partitioned-and-locally-indexed schema), and they've since +stayed with partitioned tables and a mix of local and global indexes. + +But once again, I think that global indexes aren't as important as the Phase +I items in any of the Phase I/Phase II breakdowns that have been proposed in +this thread. + + +From pgsql-performance-owner@postgresql.org Mon Mar 21 06:40:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D7AB56758 + for ; + Mon, 21 Mar 2005 06:40:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72487-05 + for ; + Mon, 21 Mar 2005 06:40:42 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id CF2E856754 + for ; + Mon, 21 Mar 2005 06:40:41 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2L6egAf011189; + Mon, 21 Mar 2005 01:40:42 -0500 (EST) +To: Neil Conway +Cc: Bruno Wolff III , + Keith Worthington , + pgsql-performance@postgresql.org +Subject: Re: View vs function +In-reply-to: <423E57E5.4070405@samurai.com> +References: <423E420D.1020503@NarrowPathInc.com> + <20050321042720.GA27098@wolff.to> <423E57E5.4070405@samurai.com> +Comments: In-reply-to Neil Conway + message dated "Mon, 21 Mar 2005 16:13:09 +1100" +Date: Mon, 21 Mar 2005 01:40:42 -0500 +Message-ID: <11188.1111387242@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/415 +X-Sequence-Number: 11120 + +Neil Conway writes: +> Bruno Wolff III wrote: +>> Functions are just black boxes to the planner. + +> ... unless the function is a SQL function that is trivial enough for the +> planner to inline it into the plan of the invoking query. Currently, we +> won't inline set-returning SQL functions that are used in the query's +> rangetable, though. This would be worth doing, I think -- I'm not sure +> how much work it would be, though. + +Yeah, I've been thinking the same. It seems like it shouldn't be unduly +difficult --- not harder than inlining scalar-valued SQL functions, just +different validity conditions. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 21 09:55:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E12D956407 + for ; + Mon, 21 Mar 2005 09:55:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25316-02 + for ; + Mon, 21 Mar 2005 09:55:07 +0000 (GMT) +Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net + [194.217.242.88]) + by svr1.postgresql.org (Postfix) with ESMTP id EBA5255286 + for ; + Mon, 21 Mar 2005 09:55:06 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-30.mail.demon.net with esmtp (Exim 4.42) + id 1DDJco-000Nna-2p; Mon, 21 Mar 2005 09:55:07 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 0C2C51684D; Mon, 21 Mar 2005 09:55:06 +0000 (GMT) +Message-ID: <423E99F4.5000702@archonet.com> +Date: Mon, 21 Mar 2005 09:55:00 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Camille Chafer +Cc: pgsql-performance@postgresql.org +Subject: Re: Hardware impact on performances +References: <42357B92.8020904@ankama.com> +In-Reply-To: <42357B92.8020904@ankama.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/416 +X-Sequence-Number: 11121 + +Camille Chafer wrote: +> Hi, +> +> I'm using PostgreSQL 8 for a mmorpg. +> The part of each operation is : select: 50%, update: 40%, insert: 10%. +> I have no more than 4-5 concurrent connections to the database, but each +> of them does A LOT of queries (several per second). +> The database size is about 1GB, but it'll probably be around 2GB in a +> fews months. +> The OS will be FreeBSD (version production 5.3 probably, or 4.10) +> +> At this time, i'm looking for a new server. Before to buy it, I grab +> some informations.. +> So, my question is : what would be the best hardware for this type of +> needs ? +> Of course, I'm not asking for a trademark and/or for prices, but for hints. +> +> - What is the most important part of the system : CPU ? RAM ? Disks ? + +Usually Disks/RAM. Since you've got a lot of updates/inserts, +battery-backed write-cache on your raid controller would be good. + +> - Is a server with 2 or more CPUs much better than a server with a +> single one, for a pgsql database ? + +With 2+ connections, each can be serviced by one CPU. Of course, if your +disk I/O is saturated then it won't help. + +> - How much RAM do I need ? The size of the data ? Twice the size ? + +Ideally, enough to hold your "working set". That is, enough cache to +store all pages/indexes you regularly access. + +> - I heard Raid1+0 is better than Raid 5. Is it right ? What would be the +> best configuration, regarding performances and security ? + +It can depend - check the list archives for a lot of discussion on this. + More disks is always better. + +> - Does the CPU type (i386, PowerPC, ....) matters ? + +Dual-Xeons have given problems. A lot of people seem to think +Opteron-based systems provide good value. + +> - A lot of queries probably generate a lot of network output. Does the +> network controller matters ? + +Well, obviously the more time spent handling network I/O, the less time +you spend running queries. I'd think it would have to be a *lot* of +activity to make a serious difference. + +> - And finally, last question : is it possible to run a single postgresql +> database on several servers ? (hardware clustering) + +Not easily, and it probably wouldn't provide any performance benefit. +Plenty of replication options though. + +> Thanks in advance for your answers, and sorry for my crap english (i'm +> french). + +Your English is perfect. +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Mon Mar 21 10:06:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 96C08560F2 + for ; + Mon, 21 Mar 2005 10:06:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27261-05 + for ; + Mon, 21 Mar 2005 10:06:01 +0000 (GMT) +Received: from ns.aprote.ee (ns.aprote.ee [80.235.78.106]) + by svr1.postgresql.org (Postfix) with ESMTP id 4819255E26 + for ; + Mon, 21 Mar 2005 10:05:59 +0000 (GMT) +Received: Message by Barricade ns.aprote.ee with ESMTP id j2LA6v2m021233 + for ; Mon, 21 Mar 2005 12:06:58 +0200 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6556.0 +Subject: What about utility to calculate planner cost constants? +Date: Mon, 21 Mar 2005 12:05:56 +0200 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: What about utility to calculate planner cost constants? +Thread-Index: AcUt/ZNQx5K0TymxRn2wGRaUF9kj8g== +From: "Tambet Matiisen" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/417 +X-Sequence-Number: 11122 + + +I was following the cpu_tuple_cost thread and wondering, if it could be +possible to make PQA style utility to calculate configuration-specific +values for planner cost constants. It could make use of output of +log_(statement|parser|planner|executor)_stats, tough I'm not sure if the +output contains anything useful for those purposes.=20 + +Otherwise it could just collect statements, run EXPLAIN ANALYZE for all +of them and then play with planner cost constants to get the estimated +values as close as possible to actual values. Something like Goal Seek +in Excel, if you pardon my reference to MS :). + +Somewhat similar project seems to be pgautotune from pgFoundry, but it +only considers shared_buffers, sort_mem and vacuum_mem. And it seems to +use synthetic data instead of actual database and actual statements from +log. And it has been inactive for a while. + + Tambet + +From pgsql-performance-owner@postgresql.org Mon Mar 21 14:59:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 17674568CB + for ; + Mon, 21 Mar 2005 14:59:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15549-10 + for ; + Mon, 21 Mar 2005 14:59:30 +0000 (GMT) +Received: from smtp018.mail.yahoo.com (smtp018.mail.yahoo.com + [216.136.174.115]) + by svr1.postgresql.org (Postfix) with SMTP id D5F51568C9 + for ; + Mon, 21 Mar 2005 14:59:29 +0000 (GMT) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp018.mail.yahoo.com with SMTP; 21 Mar 2005 14:59:32 -0000 +Received: from [172.21.8.128] (ismtp.afilias.com [216.217.55.254]) + (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + j2LExUOU056199; Mon, 21 Mar 2005 09:59:31 -0500 (EST) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <423EE14A.5080202@Yahoo.com> +Date: Mon, 21 Mar 2005 09:59:22 -0500 +From: Jan Wieck +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.1) Gecko/20040707 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Qingqing Zhou +Cc: pgsql-performance@postgresql.org +Subject: Re: column name is "LIMIT" +References: <674d1f8a0503132314754df153@mail.gmail.com> + <200503141825.22827.mr-russ@pws.com.au> + <674d1f8a05031400482c413087@mail.gmail.com> + <42355185.3070803@familyhealth.com.au> +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.122 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO, RCVD_IN_NJABL_DUL, + RCVD_IN_SORBS_DUL +X-Spam-Level: ** +X-Archive-Number: 200503/418 +X-Sequence-Number: 11123 + +On 3/14/2005 4:26 AM, Qingqing Zhou wrote: + +> So is it to make SQL parser context-sensitive - say the parser will +> understand that in statement "SELECT * from LIMIT", LIMIT is just a table +> name, instead of keyword? + +More or less, yes. To use a reserved keyword as an identifier (table or +column name), it must be enclosed in double quotes. Double quotes are +also used to make identifiers case sensitive. So + + select someval, "SOMEVAL", "someVAL" from "user"; + +is a valid query retrieving 3 distinct columns from the table "user". +There is a builtin function quote_ident() in PostgreSQL that is supposed +to return a properly quoted string allowed as an identifier for whatever +name is passed in. But it fails to do so for all lower case names that +are reserved keywords. + +The queries Slony executes on the replicas are constructed using that +quoting function, and therefore Slony fails to build valid SQL for +replicated table containing reserved keyword identifiers. One solution +would be to brute-force quote all identifiers in Slony ... not sure what +the side effects performance wise would be. + + +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-bugs-owner@postgresql.org Sun Mar 27 06:48:47 2005 +X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 99B255658A + for ; + Mon, 21 Mar 2005 15:27:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26893-04 + for ; + Mon, 21 Mar 2005 15:27:27 +0000 (GMT) +Received: from freewebz.com (herndon-13.freewebs.com [38.144.96.13]) + by svr1.postgresql.org (Postfix) with ESMTP id 0FB0F56553 + for ; Mon, 21 Mar 2005 15:27:26 +0000 (GMT) +Received: from [127.0.0.1] (members [127.0.0.1]) + by freewebz.com (8.11.6/8.11.6) with ESMTP id j2LFRL225370; + Mon, 21 Mar 2005 10:27:23 -0500 +Message-ID: <423EE7D5.7090506@freewebz.com> +Date: Mon, 21 Mar 2005 10:27:17 -0500 +From: Zeki +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Brian O'Reilly" +Cc: pgsql-bugs@postgresql.org +Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 +References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> +In-Reply-To: <20050318232102.08FA0F0E5D@svr2.postgresql.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/286 +X-Sequence-Number: 11406 + +Have you tried an analyze after 1,000 or so inserts? Also, you should +be able to disable sequence scans for the duration of the connection +using SET enable_seqscan=false. + +-Zeki + +Brian O'Reilly wrote: + +>The following bug has been logged online: +> +>Bug reference: 1552 +>Logged by: Brian O'Reilly +>Email address: fade@deepsky.com +>PostgreSQL version: 8.0.1 +>Operating system: Linux 2.6.11 +>Description: massive performance hit between 7.4 and 8.0.1 +>Details: +> +>When doing a lot of inserts to an empty table with a foreign key to another +>table, there is an incredible performance degredation issue on 8.0.1. I have +>a program that is inserting rows in an iterative loop, and in this form it +>inserts about 110,000 rows. On postgresql 7.4 on a debian machine it takes a +>shade over 2 minutes to complete. On an amd64 box running gentoo, it takes +>over an hour and fourty minutes to complete. The query plan on the debian +>host that completes quickly follows: +> +> "Fast" machine, Debian, PSQL 7.4: +> +>---------------------------------------------------------------------------- +>---------------------------------------------------- +> Index Scan using requirements_pkey on requirements (cost=0.00..4.82 rows=2 +>width=0) (actual time=0.013..0.013 rows=0 loops=1) +> Index Cond: (reqid = 10::bigint) +> Total runtime: 0.134 ms +>(3 rows) +> +>and the query plan on the 'slow' machine: +> +> +> QUERY PLAN +>---------------------------------------------------------------------------- +>-------------------------- +> Seq Scan on requirements (cost=0.00..0.00 rows=1 width=0) (actual +>time=0.002..0.002 rows=0 loops=1) +> Filter: (reqid = 10::bigint) +> Total runtime: 0.040 ms +>(3 rows) +> +>The script I am using to show this behaviour follows: +> +>CREATE TABLE packages +> (name text PRIMARY KEY); +>CREATE TABLE binary_packages +> (name text REFERENCES packages, +> version text, +> PRIMARY KEY(name, version)); +>CREATE TABLE requirements +> (reqid bigint PRIMARY KEY, +> name text, +> version text, +> FOREIGN KEY (name, version) REFERENCES +>binary_packages); +>CREATE TABLE constraints +> (constid bigint PRIMARY KEY, +> reqid bigint REFERENCES requirements, +> type text, +> name text REFERENCES packages, +> version text DEFAULT '', +> relation character(2)); +> +>explain analyze select 1 from only requirements where reqid='10'; +> +>the query optimiser seems to be setting a default strategy of doing +>sequential scans on an empty table, which is a fast strategy when the table +>is empty and not particularly full, but obviously on a large table the +>performance is O(N^2). This is clearly a bug. Please let me know if I can +>provide any more information. +> +>Brian O'Reilly +>System Architect., +>DeepSky Media Resources +> +>---------------------------(end of broadcast)--------------------------- +>TIP 8: explain analyze is your friend +> +> + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 11:33:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 187E9569C1 + for ; + Tue, 22 Mar 2005 11:30:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86714-07 + for ; + Tue, 22 Mar 2005 11:30:03 +0000 (GMT) +Received: from fuji.krosing.net (joltid-gw.joltid.org [195.50.194.24]) + by svr1.postgresql.org (Postfix) with ESMTP id C0FFD563F1 + for ; + Tue, 22 Mar 2005 11:30:02 +0000 (GMT) +Received: from fuji.krosing.net (localhost [127.0.0.1]) + by fuji.krosing.net (8.13.1/8.13.1) with ESMTP id j2LG7dlp005623; + Mon, 21 Mar 2005 18:07:39 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.13.1/8.13.1/Submit) id j2LG7Q7w005618; + Mon, 21 Mar 2005 18:07:26 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: What needs to be done for real Partitioning? +From: Hannu Krosing +To: Tom Lane +Cc: Alvaro Herrera , + PFC , Josh Berkus , + pgsql-performance@postgresql.org +In-Reply-To: <4507.1111294073@sss.pgh.pa.us> +References: <200503191202.38089.josh@agliodbs.com> + <20050319225624.GA8467@dcc.uchile.cl> + <3404.1111277153@sss.pgh.pa.us> <20050320042917.GA25831@dcc.uchile.cl> + <4507.1111294073@sss.pgh.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Mon, 21 Mar 2005 18:07:25 +0200 +Message-Id: <1111421245.4675.8.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-1) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/437 +X-Sequence-Number: 11142 + +On L, 2005-03-19 at 23:47 -0500, Tom Lane wrote: +> Alvaro Herrera writes: +> > Hmm. You are right, but without that we won't be able to enforce +> > uniqueness on the partitioned table (we could only enforce it on each +> > partition, which would mean we can't partition on anything else than +> > primary keys if the tables have one). IMHO this is something to +> > consider. +> +> Well, partitioning on the primary key would be Good Enough for 95% or +> 99% of the real problems out there. I'm not excited about adding a +> large chunk of complexity to cover another few percent. + +That automatically means that partitioning expression has to be a range +over PK. (you dont want to have every tuple in separate tabel :) + +And it also means that you have to automatically create new partitions. + +Are you sure that partitioning on anything else than PK would be +significantly harder ? + +I have a case where I do manual partitioning over start_time +(timestamp), but the PK is an id from a sequence. They are almost, but +not exactly in the same order. And I don't think that moving the PK to +be (start_time, id) just because of "partitioning on PK only" would be a +good design in any way. + +So please don't design the system to partition on PK only. + +-- +Hannu Krosing + +From pgsql-performance-owner@postgresql.org Mon Mar 21 16:30:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EC52652A52 + for ; + Mon, 21 Mar 2005 16:30:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47264-08 + for ; + Mon, 21 Mar 2005 16:30:51 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id DD343568F0 + for ; + Mon, 21 Mar 2005 16:30:50 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2LGUnWO029805; + Mon, 21 Mar 2005 11:30:49 -0500 (EST) +To: Jan Wieck +Cc: Qingqing Zhou , + pgsql-performance@postgresql.org +Subject: Re: column name is "LIMIT" +In-reply-to: <423EE14A.5080202@Yahoo.com> +References: <674d1f8a0503132314754df153@mail.gmail.com> + <200503141825.22827.mr-russ@pws.com.au> + <674d1f8a05031400482c413087@mail.gmail.com> + <42355185.3070803@familyhealth.com.au> + <423EE14A.5080202@Yahoo.com> +Comments: In-reply-to Jan Wieck + message dated "Mon, 21 Mar 2005 09:59:22 -0500" +Date: Mon, 21 Mar 2005 11:30:49 -0500 +Message-ID: <29804.1111422649@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/419 +X-Sequence-Number: 11124 + +Jan Wieck writes: +> There is a builtin function quote_ident() in PostgreSQL that is supposed +> to return a properly quoted string allowed as an identifier for whatever +> name is passed in. But it fails to do so for all lower case names that +> are reserved keywords. + +Not any more ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 22 11:29:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0153C569AE + for ; + Tue, 22 Mar 2005 11:29:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87873-09 + for ; + Tue, 22 Mar 2005 11:29:28 +0000 (GMT) +Received: from fuji.krosing.net (joltid-gw.joltid.org [195.50.194.24]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A3E9569B6 + for ; + Tue, 22 Mar 2005 11:29:28 +0000 (GMT) +Received: from fuji.krosing.net (localhost [127.0.0.1]) + by fuji.krosing.net (8.13.1/8.13.1) with ESMTP id j2LGWs26005678; + Mon, 21 Mar 2005 18:32:54 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.13.1/8.13.1/Submit) id j2LGWrSY005676; + Mon, 21 Mar 2005 18:32:53 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: What needs to be done for real Partitioning? +From: Hannu Krosing +To: Josh Berkus +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200503191202.38089.josh@agliodbs.com> +References: <200503191202.38089.josh@agliodbs.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Mon, 21 Mar 2005 18:32:53 +0200 +Message-Id: <1111422773.4675.33.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-1) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/434 +X-Sequence-Number: 11139 + +On L, 2005-03-19 at 12:02 -0800, Josh Berkus wrote: +> Folks, +> +> I may (or may not) soon have funding for implementing full table partitioning +> in PostgreSQL. + +If you don't get it, contact me as there is a small possibility that I +know a company interested enough to fund (some) of it :) + +> I thought it would be a good idea to discuss with people here +> who are already using pseudo-partitioning what things need to be added to +> Postgresql in order to make full paritioning a reality; that is, what do +> other databases do that we don't? + +As these are already discussed in this thread, I'll try to outline a +method of providing a global index (unique or not) in a way that will +still make it possible to quickly remove (and not-quite-so-quickly add) +a partition. + +The structure is inspired by the current way of handling >1Gb tables. + +As each tid consists of 32 bit page pointer we have pointerspace of +35184372088832 bytes/index (4G of 8k pages). currently this is directly +partitioned mapped to 1Gbyte/128kpage files, but we can, with minimal +changes to indexes, put a lookup table between index and page lookup. + +In case of global index over partitions this table could point to 1G +subtables from different partition tables. + +The drop partition table can also be fast - just record the pages in +lookup table as deleted - means one change per 1G of dropped table. +The next vacuum should free pointers to deleted subfiles. + +Adding partitions is trickier - + +If the added table forms part of partitioning index (say names from C to +E), and there is a matching index on subtable, + +Then that part of btree can probably copied into the main btree index as +a tree btanch, which should be relatively fast (compared to building it +one tid at a time). + +Else adding the the index could probably also be sped up by some kind of +index merge - faster than building from scratch but slower than above. + + +To repeat - the global index over partitioned table should have te same +structure as our current b-tree index, only with added map of 128k index +partitions to 1G subfiles of (possibly different) tables. This map will +be quite small - for 1Tb of data it will be only 1k entries - this will +fit in cache on all modern processors and thus should add only tiny +slowdown from current direct tid.page/128k method + +-- +Hannu Krosing + +From pgsql-performance-owner@postgresql.org Mon Mar 21 17:51:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C5700568C3 + for ; + Mon, 21 Mar 2005 17:51:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 76074-04 + for ; + Mon, 21 Mar 2005 17:51:35 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id C063E568B0 + for ; + Mon, 21 Mar 2005 17:51:34 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7151238; Mon, 21 Mar 2005 09:53:24 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Tambet Matiisen" +Subject: Re: What about utility to calculate planner cost constants? +Date: Mon, 21 Mar 2005 09:51:06 -0800 +User-Agent: KMail/1.6.2 +Cc: +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200503210951.06044.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/420 +X-Sequence-Number: 11125 + +Tambet, + +> I was following the cpu_tuple_cost thread and wondering, if it could be +> possible to make PQA style utility to calculate configuration-specific +> values for planner cost constants. It could make use of output of +> log_(statement|parser|planner|executor)_stats, tough I'm not sure if the +> output contains anything useful for those purposes. + +Yeah, that's something I need to look at. + +> Otherwise it could just collect statements, run EXPLAIN ANALYZE for all +> of them and then play with planner cost constants to get the estimated +> values as close as possible to actual values. Something like Goal Seek +> in Excel, if you pardon my reference to MS :). + +That's not really practical. There are currently 5 major query tuning +parameters, not counting the memory adjustments which really can't be left +out. You can't realistically test all combinations of 6 variables. + +> Somewhat similar project seems to be pgautotune from pgFoundry, but it +> only considers shared_buffers, sort_mem and vacuum_mem. And it seems to +> use synthetic data instead of actual database and actual statements from +> log. And it has been inactive for a while. + +Yeah, pg_autotune is a dead project. Once we got OSDL able to run tests, we +came up with some rules-of-thumb which are more useful than autotune's +output. More importantly, the approach doesn't scale to the 15-20 GUCs which +we'd realistically want to test. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Mar 21 17:55:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D1D4568C6 + for ; + Mon, 21 Mar 2005 17:55:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78470-01 + for ; + Mon, 21 Mar 2005 17:55:28 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F2D4568C3 + for ; + Mon, 21 Mar 2005 17:55:28 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7151254; Mon, 21 Mar 2005 09:57:19 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Stacy White" +Subject: Re: What needs to be done for real Partitioning? +Date: Mon, 21 Mar 2005 09:55:03 -0800 +User-Agent: KMail/1.6.2 +Cc: "Tom Lane" , "Greg Stark" , + "Alvaro Herrera" , + "PFC" , +References: <200503191202.38089.josh@agliodbs.com> + <871xa9fyn4.fsf@stark.xeocode.com> + <007401c52dd8$73395450$0200a8c0@grownups> +In-Reply-To: <007401c52dd8$73395450$0200a8c0@grownups> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200503210955.03083.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/421 +X-Sequence-Number: 11126 + +Stacy, + +> Luckily they that had the chance to work with a truly fantastic DBA (the +> author of an Oracle Press performance tuning book even) before they could +> switch back. He convinced them to make some of their indexes global. +> Performance dramatically improved (compared with both the unpartitioned +> schema, and the partitioned-and-locally-indexed schema), and they've since +> stayed with partitioned tables and a mix of local and global indexes. + +Hmmm. Wouldn't Greg's suggestion of a bitmap index which holds information on +what values are found in what partition also solve this? Without 1/2 of +the overhead imposed by global indexes? + +I can actually see such a bitmap as being universally useful to the +partitioning concept ... for one, it would resolve the whole "partition on +{value}" issue. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Mar 21 18:18:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 570AB568E6 + for ; + Mon, 21 Mar 2005 18:18:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84490-10 + for ; + Mon, 21 Mar 2005 18:18:24 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id 5346D567DD + for ; + Mon, 21 Mar 2005 18:18:22 +0000 (GMT) +Received: (qmail 24998 invoked from network); 21 Mar 2005 18:18:22 -0000 +Received: from host-209.149.56.238.nashville.net (HELO ?10.0.1.2?) + (209.149.56.238) by 0 with SMTP; 21 Mar 2005 18:18:22 -0000 +In-Reply-To: <200503210951.06044.josh@agliodbs.com> +References: + <200503210951.06044.josh@agliodbs.com> +Mime-Version: 1.0 (Apple Message framework v619.2) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <11322edfb476c82809712b9796f78a5f@sitening.com> +Content-Transfer-Encoding: 7bit +Cc: "Tambet Matiisen" , + +From: Thomas F.O'Connell +Subject: Re: What about utility to calculate planner cost constants? +Date: Mon, 21 Mar 2005 12:18:17 -0600 +To: Josh Berkus +X-Mailer: Apple Mail (2.619.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/422 +X-Sequence-Number: 11127 + +If by not practical you mean, "no one has implemented a multivariable +testing approach," I'll agree with you. But multivariable testing is +definitely a valid statistical approach to solving just such problems. + +-tfo + +-- +Thomas F. O'Connell +Co-Founder, Information Architect +Sitening, LLC +http://www.sitening.com/ +110 30th Avenue North, Suite 6 +Nashville, TN 37203-6320 +615-260-0005 + +On Mar 21, 2005, at 11:51 AM, Josh Berkus wrote: + +> That's not really practical. There are currently 5 major query tuning +> parameters, not counting the memory adjustments which really can't be +> left +> out. You can't realistically test all combinations of 6 variables. + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 11:29:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ED0C6569B5 + for ; + Tue, 22 Mar 2005 11:29:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86687-04 + for ; + Tue, 22 Mar 2005 11:29:44 +0000 (GMT) +Received: from fuji.krosing.net (joltid-gw.joltid.org [195.50.194.24]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D23C569AE + for ; + Tue, 22 Mar 2005 11:29:43 +0000 (GMT) +Received: from fuji.krosing.net (localhost [127.0.0.1]) + by fuji.krosing.net (8.13.1/8.13.1) with ESMTP id j2LINKmj005821; + Mon, 21 Mar 2005 20:23:21 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.13.1/8.13.1/Submit) id j2LINGTQ005820; + Mon, 21 Mar 2005 20:23:16 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: What needs to be done for real Partitioning? +From: Hannu Krosing +To: Tom Lane +Cc: Josh Berkus , pgsql-performance@postgresql.org +In-Reply-To: <3375.1111276999@sss.pgh.pa.us> +References: <200503191202.38089.josh@agliodbs.com> + <18168.1111265368@sss.pgh.pa.us> <200503191529.51794.josh@agliodbs.com> + <3375.1111276999@sss.pgh.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Mon, 21 Mar 2005 20:23:15 +0200 +Message-Id: <1111429395.4675.38.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-1) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/436 +X-Sequence-Number: 11141 + +On L, 2005-03-19 at 19:03 -0500, Tom Lane wrote: +> Josh Berkus writes: +> >>> -- INSERT INTO should automatically create new partitions where necessary +> >>> -- DELETE FROM should automatically drop empty partitions +> >> +> >> I am not sure I agree with either of those, and the reason is that they +> >> would turn low-lock operations into high-lock operations. +> +> > For INSERT, I think that's a problem we need to work through. +> +> Possibly, but I'm concerned about locking and deadlock issues. The +> reason that this is iffy is you would start the operation with only +> an INSERT-grade lock, and then discover that you needed to add a +> partition, which is surely something that needs an exclusive-grade +> lock (consider two sessions trying to add the same partition at the +> same time). So I don't see how to do it without lock upgrading, +> and lock upgrading is always a recipe for deadlocks. +> +> The DELETE case is even worse because you can't physically release +> storage until you're sure nothing in it is needed anymore by any open +> transaction --- that introduces VACUUM-like issues as well as the +> deadlock problem. +> + +If we go with my proposal (other post in this thread) of doing most of +the partitioning in the level between logical file and physikal 1Gb +storage files, then adding a partition should be nearly the same as +crossing the 1G boundary is now. + +removing the partition would be just plain vacuum (if we can make pg +shring each 1G subfile independently) + +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend +-- +Hannu Krosing + +From pgsql-performance-owner@postgresql.org Tue Mar 22 11:29:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 11FB3569C2 + for ; + Tue, 22 Mar 2005 11:29:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88112-02 + for ; + Tue, 22 Mar 2005 11:29:34 +0000 (GMT) +Received: from fuji.krosing.net (joltid-gw.joltid.org [195.50.194.24]) + by svr1.postgresql.org (Postfix) with ESMTP id DF38D563E9 + for ; + Tue, 22 Mar 2005 11:29:33 +0000 (GMT) +Received: from fuji.krosing.net (localhost [127.0.0.1]) + by fuji.krosing.net (8.13.1/8.13.1) with ESMTP id j2LIQPC6005831; + Mon, 21 Mar 2005 20:26:26 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.13.1/8.13.1/Submit) id j2LIQPT8005830; + Mon, 21 Mar 2005 20:26:25 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: What needs to be done for real Partitioning? +From: Hannu Krosing +To: PFC +Cc: Josh Berkus , pgsql-performance@postgresql.org +In-Reply-To: +References: <200503191202.38089.josh@agliodbs.com> + <2092.1111273359@sss.pgh.pa.us> + +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Mon, 21 Mar 2005 20:26:24 +0200 +Message-Id: <1111429584.4675.40.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-1) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/435 +X-Sequence-Number: 11140 + +On P, 2005-03-20 at 00:52 +0100, PFC wrote: +> > tableoid would accomplish that already, assuming that the "partitioned +> > table" is effectively a view on separate physical tables. +> > +> > regards, tom lane +> +> Very good. +> +> Also note the possibility to mark a partition READ ONLY. Or even a table. +> It does not seem very useful but just think that for instance the "1999", +> "2000" ... "2004" partitions of a big archive probably never change. +> READLONY means we're sure they never change, thus no need to backup them +> every time. Keeping the example of some DB arranged by years / current +> year / current month, Just backup the "current month" part every day and +> the "current year" every month when you switch partitions. +> This could be achieved also by storing the time of last modification of a +> table somewhere. + +Would we still need regular VACUUMing of read-only table to avoid +OID-wraparound ? + +-- +Hannu Krosing + +From pgsql-performance-owner@postgresql.org Tue Mar 22 11:29:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D1BC356471 + for ; + Tue, 22 Mar 2005 11:29:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88038-06 + for ; + Tue, 22 Mar 2005 11:29:24 +0000 (GMT) +Received: from fuji.krosing.net (joltid-gw.joltid.org [195.50.194.24]) + by svr1.postgresql.org (Postfix) with ESMTP id 4AAC8563E9 + for ; + Tue, 22 Mar 2005 11:29:22 +0000 (GMT) +Received: from fuji.krosing.net (localhost [127.0.0.1]) + by fuji.krosing.net (8.13.1/8.13.1) with ESMTP id j2LIW5XN005843; + Mon, 21 Mar 2005 20:32:05 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.13.1/8.13.1/Submit) id j2LIVxLn005842; + Mon, 21 Mar 2005 20:31:59 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: What needs to be done for real Partitioning? +From: Hannu Krosing +To: Josh Berkus +Cc: Stacy White , Tom Lane , + Greg Stark , Alvaro Herrera , + PFC , pgsql-performance@postgresql.org +In-Reply-To: <200503210955.03083.josh@agliodbs.com> +References: <200503191202.38089.josh@agliodbs.com> + <871xa9fyn4.fsf@stark.xeocode.com> + <007401c52dd8$73395450$0200a8c0@grownups> + <200503210955.03083.josh@agliodbs.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Mon, 21 Mar 2005 20:31:58 +0200 +Message-Id: <1111429918.4675.45.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-1) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/433 +X-Sequence-Number: 11138 + +On E, 2005-03-21 at 09:55 -0800, Josh Berkus wrote: +> Stacy, +> +> > Luckily they that had the chance to work with a truly fantastic DBA (the +> > author of an Oracle Press performance tuning book even) before they could +> > switch back. He convinced them to make some of their indexes global. +> > Performance dramatically improved (compared with both the unpartitioned +> > schema, and the partitioned-and-locally-indexed schema), and they've since +> > stayed with partitioned tables and a mix of local and global indexes. +> +> Hmmm. Wouldn't Greg's suggestion of a bitmap index which holds information on +> what values are found in what partition also solve this? Without 1/2 of +> the overhead imposed by global indexes? +> +> I can actually see such a bitmap as being universally useful to the +> partitioning concept ... for one, it would resolve the whole "partition on +> {value}" issue. + +I once (maybe about a year ago) tried to elaborate using bitmap +index(es) with page granularity as a tool for simultaneous clustering +and lookup for data warehousing using postgres. the main idea was to +determine storage location from AND of all "clustered" bitmap indexes +and corresponding fast and clustered lookups. + +This could/should/maybe :) possibly be combined with clustering as well. + +-- +Hannu Krosing + +From pgsql-performance-owner@postgresql.org Mon Mar 21 22:07:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9477A5666F + for ; + Mon, 21 Mar 2005 22:07:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90865-04 + for ; + Mon, 21 Mar 2005 22:07:46 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 147705660C + for ; + Mon, 21 Mar 2005 22:07:45 +0000 (GMT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id CDAE715258; Mon, 21 Mar 2005 16:07:45 -0600 (CST) +Date: Mon, 21 Mar 2005 16:07:45 -0600 +From: "Jim C. Nasby" +To: Josh Berkus +Cc: Stacy White , Tom Lane , + Greg Stark , Alvaro Herrera , + PFC , pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +Message-ID: <20050321220745.GS51784@decibel.org> +References: <200503191202.38089.josh@agliodbs.com> + <871xa9fyn4.fsf@stark.xeocode.com> + <007401c52dd8$73395450$0200a8c0@grownups> + <200503210955.03083.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200503210955.03083.josh@agliodbs.com> +X-Operating-System: FreeBSD 4.11-RELEASE i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.025 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/423 +X-Sequence-Number: 11128 + +On Mon, Mar 21, 2005 at 09:55:03AM -0800, Josh Berkus wrote: +> Stacy, +> +> > Luckily they that had the chance to work with a truly fantastic DBA (the +> > author of an Oracle Press performance tuning book even) before they could +> > switch back. He convinced them to make some of their indexes global. +> > Performance dramatically improved (compared with both the unpartitioned +> > schema, and the partitioned-and-locally-indexed schema), and they've since +> > stayed with partitioned tables and a mix of local and global indexes. +> +> Hmmm. Wouldn't Greg's suggestion of a bitmap index which holds information on +> what values are found in what partition also solve this? Without 1/2 of +> the overhead imposed by global indexes? +> +> I can actually see such a bitmap as being universally useful to the +> partitioning concept ... for one, it would resolve the whole "partition on +> {value}" issue. + +I suspect both will have their uses. I've read quite a bit about global +v. local indexs in Oracle, and there are definately cases where global +is much better than local. Granted, there's some things with how Oracle +handles their catalog, etc. that might make local indexes more expensive +for them than they would be for PostgreSQL. It's also not clear how much +a 'partition bitmap' index would help. + +As for the 'seqscan individual partitions' argument, that's not going to +work well at all for a case where you need to hit a relatively small +percentage of rows in a relatively large number of partitions. SELECT +... WHERE customer_id = 1 would be a good example of such a query +(assuming the table is partitioned on something like invoice_date). +-- +Jim C. Nasby, Database Consultant decibel@decibel.org +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 Mar 21 22:11:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 07794566C4 + for ; + Mon, 21 Mar 2005 22:11:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92384-05 + for ; + Mon, 21 Mar 2005 22:11:07 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FA19566A0 + for ; + Mon, 21 Mar 2005 22:11:07 +0000 (GMT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 37C3815258; Mon, 21 Mar 2005 16:11:09 -0600 (CST) +Date: Mon, 21 Mar 2005 16:11:09 -0600 +From: "Jim C. Nasby" +To: Tom Lane +Cc: Alvaro Herrera , + PFC , Josh Berkus , + pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +Message-ID: <20050321221109.GT51784@decibel.org> +References: <200503191202.38089.josh@agliodbs.com> + <20050319225624.GA8467@dcc.uchile.cl> + <3404.1111277153@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3404.1111277153@sss.pgh.pa.us> +X-Operating-System: FreeBSD 4.11-RELEASE i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/424 +X-Sequence-Number: 11129 + +On Sat, Mar 19, 2005 at 07:05:53PM -0500, Tom Lane wrote: +> Alvaro Herrera writes: +> > We probably also need multi-table indexes. +> +> As Josh says, that seems antithetical to the main point of partitioning, +> which is to be able to rapidly remove (and add) partitions of a table. +> If you have to do index cleaning before you can drop a partition, what's +> the point of partitioning? + +Why would you need to do index cleaning first? Presumably the code that +goes to check a heap tuple that an index pointed at to ensure that it +was visible in the current transaction would be able to recognize if the +partition that tuple was in had been removed, and just ignore that index +entry. Granted, you'd need to clean the index up at some point +(presumably via vacuum), but it doesn't need to occur at partition drop +time. +-- +Jim C. Nasby, Database Consultant decibel@decibel.org +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 Mar 21 23:51:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 91D1556B65 + for ; + Mon, 21 Mar 2005 23:49:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48163-03 + for ; + Mon, 21 Mar 2005 23:49:17 +0000 (GMT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CF6356B43 + for ; + Mon, 21 Mar 2005 23:49:17 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [67.100.216.10]) + by svr4.postgresql.org (Postfix) with ESMTP id 3FF7A5AF925 + for ; + Mon, 21 Mar 2005 23:03:11 +0000 (GMT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 862DA15266; Mon, 21 Mar 2005 16:58:03 -0600 (CST) +Date: Mon, 21 Mar 2005 16:58:03 -0600 +From: "Jim C. Nasby" +To: Josh Berkus +Cc: pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +Message-ID: <20050321225803.GU51784@decibel.org> +References: <200503191202.38089.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200503191202.38089.josh@agliodbs.com> +X-Operating-System: FreeBSD 4.11-RELEASE i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.023 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/426 +X-Sequence-Number: 11131 + +I think Greg's email did a good job of putting this on track. Phase 1 +should be manual, low-level type of support. Oracle has had partitioning +for years now, and IF they've added automated partition management, it's +only happened in 10g which is pretty recent. + +For inserts that don't currently have a defined partition to fit in, the +Oracle model might be better than tossing an error: a partitioned table +in Oracle also contains a default partition. Any rows that don't match a +defined partition go into the default partition. For many cases you'll +never have anything in the default partition, but sometimes you'll have +some partition values that occur infrequenttly enough in the table so as +not to warrant their own partition. + +There's also another partitioning application that I think is often +overlooked. I have a table with about 130M rows that is +'pseudo-partitioned' by project_id. Right now, there are 5 different +project IDs that account for the bulk of those 130M rows. Oracle +provides a means to partition on discreet values. When you do this, +there's not actually any reason to even store the partition field in the +partition tables, since it will be the same for every row in the +partition. In my case, since the smallint project ID is being aligned to +a 4 byte boundary, having this feature would save ~120M rows * 4 bytes = +480MB in the table. Granted, 480MB isn't anything for today's disk +sizes, but it makes a huge difference when you look at it from an I/O +standpoint. Knowing that a partition contains only one value of a field +or set of fields also means you can drop those fields from local indexes +without losing any effectiveness. In my case, I have 2 indexes I could +drop project_id from. Does each node in a B-tree index have the full +index key? If so, then there would be substantial I/O gains to be had +there, as well. Even if each node doesn't store the full key, there +could still be faster to handle a narrower index. + +I realize this might be a more difficult case to support. It probably +couldn't be done using inheritance, though I don't know if inheritence +or a union view is better for partitioning. In either case, this case +might not be a good candidate for phase 1, but I think partitioning +should be designed with it in mind. +-- +Jim C. Nasby, Database Consultant decibel@decibel.org +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 Mar 21 23:44:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E622B566A9 + for ; + Mon, 21 Mar 2005 23:43:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46454-04 + for ; + Mon, 21 Mar 2005 23:43:55 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C8CD56B88 + for ; + Mon, 21 Mar 2005 23:43:10 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7152260; Mon, 21 Mar 2005 14:57:12 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Thomas F.O'Connell +Subject: Re: What about utility to calculate planner cost constants? +Date: Mon, 21 Mar 2005 14:59:56 -0800 +User-Agent: KMail/1.7.1 +Cc: "Tambet Matiisen" , pgsql-performance@postgresql.org +References: + <200503210951.06044.josh@agliodbs.com> + <11322edfb476c82809712b9796f78a5f@sitening.com> +In-Reply-To: <11322edfb476c82809712b9796f78a5f@sitening.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200503211459.56243.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.051 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/425 +X-Sequence-Number: 11130 + +Thomas, + +> If by not practical you mean, "no one has implemented a multivariable +> testing approach," I'll agree with you. But multivariable testing is +> definitely a valid statistical approach to solving just such problems. + +Well, not practical as in: "would take either $10 million in equipment or +10,000 hours or both" + +--Josh + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Mar 22 04:43:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C93A656926 + for ; + Tue, 22 Mar 2005 04:42:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25748-09 + for ; + Tue, 22 Mar 2005 04:42:58 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 95CAE56923 + for ; + Tue, 22 Mar 2005 04:42:57 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DDbEA-0005mY-00; Mon, 21 Mar 2005 23:42:50 -0500 +To: Josh Berkus +Cc: "Tambet Matiisen" , + +Subject: Re: What about utility to calculate planner cost constants? +References: + <200503210951.06044.josh@agliodbs.com> +In-Reply-To: <200503210951.06044.josh@agliodbs.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 21 Mar 2005 23:42:50 -0500 +Message-ID: <87acowcmut.fsf@stark.xeocode.com> +Lines: 48 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.014 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/427 +X-Sequence-Number: 11132 + +Josh Berkus writes: + +> > Otherwise it could just collect statements, run EXPLAIN ANALYZE for all +> > of them and then play with planner cost constants to get the estimated +> > values as close as possible to actual values. Something like Goal Seek +> > in Excel, if you pardon my reference to MS :). +> +> That's not really practical. There are currently 5 major query tuning +> parameters, not counting the memory adjustments which really can't be left +> out. You can't realistically test all combinations of 6 variables. + +I don't think it would be very hard at all actually. + +It's just a linear algebra problem with a bunch of independent variables and a +system of equations. Solving for values for all of them is a straightforward +problem. + +Of course in reality these variables aren't actually independent because the +costing model isn't perfect. But that wouldn't be a problem, it would just +reduce the accuracy of the results. + +What's needed is for the explain plan to total up the costing penalties +independently. So the result would be something like + +1000 * random_page_cost + 101 * sequential_page_cost + 2000 * index_tuple_cost ++ ... + +In other words a tuple like <1000,101,2000,...> + +And explain analyze would produce the above tuple along with the resulting +time. + +Some program would have to gather these values from the log or stats data and +gather them up into a large linear system and solve for values that minimize +the divergence from the observed times. + + + +(costs penalties are currently normalized to sequential_page_cost being 1. +That could be maintained, or it could be changed to be normalized to an +expected 1ms.) + +(Also, currently explain analyze has overhead that makes this impractical. +Ideally it could subtract out its overhead so the solutions would be accurate +enough to be useful) + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 08:35:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 59B0452A4F + for ; + Tue, 22 Mar 2005 08:35:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89155-08 + for ; + Tue, 22 Mar 2005 08:35:28 +0000 (GMT) +Received: from cmailm2.svr.pol.co.uk (cmailm2.svr.pol.co.uk [195.92.193.210]) + by svr1.postgresql.org (Postfix) with ESMTP id D3B5E5650D + for ; + Tue, 22 Mar 2005 08:35:23 +0000 (GMT) +Received: from modem-2299.llama.dialup.pol.co.uk ([217.135.184.251] + helo=192.168.0.102) by cmailm2.svr.pol.co.uk with esmtp (Exim 4.41) + id 1DDerA-0005g9-LJ; Tue, 22 Mar 2005 08:35:21 +0000 +Subject: Re: What needs to be done for real Partitioning? +From: Simon Riggs +To: Greg Stark +Cc: Josh Berkus , pgsql-performance@postgresql.org +In-Reply-To: <87br9ehmja.fsf@stark.xeocode.com> +References: <200503191202.38089.josh@agliodbs.com> + <87br9ehmja.fsf@stark.xeocode.com> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Tue, 22 Mar 2005 08:34:22 +0000 +Message-Id: <1111480462.11750.510.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/428 +X-Sequence-Number: 11133 + +On Sun, 2005-03-20 at 01:14 -0500, Greg Stark wrote: +> Josh Berkus writes: +> +> > -- INSERT INTO should automatically create new partitions where necessary +> > ---- new tables should automatically inherit all constraints, indexes, +> > keys of "parent" table +> +> I think you're going about this backwards. + +Certainly, there are two schools of thought here. I have been in two +minds about which those two designs previously, and indeed here which +one to support. + +> Phase I should be an entirely manual system where you add and remove +> partitions manually and create and drop indexes you want manually. You need +> these low level interfaces anyways for a complete system, it doesn't make +> sense to have everything automatic and then later try to wedge in a low level +> interface. Only once you have that do you then start offering options to do +> these things automatically. + +Maybe its just me, but ISTM that implementing an automatic system is +actually easier to begin with. No commands, no syntax etc. You're right, +you need the low level interfaces anyway... + +> From my experience with Oracle I think there's one big concept that makes the +> whole system make a lot more sense: individual partitions are really tables. +> The partitioned tables themselves are just meta-objects like views. + +Hmmm. Oracle provides a very DBA-intensive implementation that as Stacy +points out, many people still do not understand. It does work, well. And +has many of the wrinkles ironed out, even if not all of them are easy to +understand why they exist at first glance. + +I think it most likely that Phase I should be a simplified blend of both +ideas, with a clear view towards minimum impact and implementability, +otherwise it may not make the cut for 8.1 + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 09:23:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C94DF56999 + for ; + Tue, 22 Mar 2005 09:23:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24328-09 + for ; + Tue, 22 Mar 2005 09:22:49 +0000 (GMT) +Received: from moonfactory.co.jp (0.moonfactory.co.jp [211.5.120.193]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F997569A7 + for ; + Tue, 22 Mar 2005 09:22:28 +0000 (GMT) +Received: from benjamindon (192.168.133.146) by moonfactory.co.jp with + ESMTP (Eudora Internet Mail Server 3.0.3) for + ; Tue, 22 Mar 2005 18:22:27 +0900 +Message-ID: <007301c52ec0$a8f64ec0$9285a8c0@moonfactory.co.jp> +From: "Layet Benjamin" +To: +Subject: best practices with index on varchar column +Date: Tue, 22 Mar 2005 18:22:24 +0900 +Organization: Moonfactory +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_006F_01C52F0C.18A24D50" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2900.2180 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.119 tagged_above=0 required=5 tests=AWL, HTML_50_60, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200503/429 +X-Sequence-Number: 11134 + +This is a multi-part message in MIME format. + +------=_NextPart_000_006F_01C52F0C.18A24D50 +Content-Type: text/plain; + charset="iso-2022-jp" +Content-Transfer-Encoding: 7bit + +Hi everyone, +I hope it is the correct newsletter for this question. + +Can I use an index on a varchar column to optimize the SELECT queries that +use " column LIKE 'header%' "? +If yes what is the best tree algotithm to use ? + +I don't care about optimising INSERT, DELETE and UPDATE queries, as they are +only done at night when the load is very low. +Thank you very much for any help, +Benjamin Layet + + +------=_NextPart_000_006F_01C52F0C.18A24D50 +Content-Type: text/html; + charset="iso-2022-jp" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi everyone,
+
I hope it is the correct newsletter for this question.
+
 
+
Can I use an index on a varchar column to optimize the SELECT = +queries that=20 +use " column LIKE 'header%'  "?
+
If yes what is the best tree algotithm to use ?
+
 
+
I don't care about optimising INSERT, DELETE and UPDATE queries, as = +they=20 +are only done at night when the load is very low.
+
Thank you very much for any help,
+
Benjamin Layet
+
 
+
 
+ +------=_NextPart_000_006F_01C52F0C.18A24D50-- + + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 09:49:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 98C9B564DA + for ; + Tue, 22 Mar 2005 09:49:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41606-01 + for ; + Tue, 22 Mar 2005 09:49:25 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.193]) + by svr1.postgresql.org (Postfix) with ESMTP id A557A56439 + for ; + Tue, 22 Mar 2005 09:49:23 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id y7so1229212rne + for ; + Tue, 22 Mar 2005 01:49:26 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=Kxiz56uBhdsQYgGHnmwEiRulDeYh0HO9X7D7g4e4Eh9/nkqLqle+i5ZnfiK9vx2WzY262tfxAiEqZ96OBlIj3wSaNUTSlORiOaPhpIrZzhPYgIVF5MalOHUC0b/qkL0wCbRkWuywpXcROWBboiJ9cjpLOvK/h+8TKca7f8SjMEU= +Received: by 10.38.65.20 with SMTP id n20mr6158813rna; + Tue, 22 Mar 2005 01:49:25 -0800 (PST) +Received: by 10.38.101.75 with HTTP; Tue, 22 Mar 2005 01:49:25 -0800 (PST) +Message-ID: <758d5e7f050322014953c311fe@mail.gmail.com> +Date: Tue, 22 Mar 2005 10:49:25 +0100 +From: Dawid Kuroczko +Reply-To: Dawid Kuroczko +To: pgsql-performance@postgresql.org +Subject: Re: best practices with index on varchar column +In-Reply-To: <007301c52ec0$a8f64ec0$9285a8c0@moonfactory.co.jp> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +References: <007301c52ec0$a8f64ec0$9285a8c0@moonfactory.co.jp> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.738 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, FROM_ENDS_IN_NUMS, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/430 +X-Sequence-Number: 11135 + +On Tue, 22 Mar 2005 18:22:24 +0900, Layet Benjamin + wrote: +> Can I use an index on a varchar column to optimize the SELECT queries that +> use " column LIKE 'header%' "? +> If yes what is the best tree algotithm to use ? + +Yes, that is the correct place. The best tree algorithm is B-Tree, +which is the default. So no need for giving 'USING ...' to CREATE INDEX. + +The other types of indexes are either not trees (HASH), different +and more complex (GiST, RTREE) kinds of trees which are there +for different kinds of data (spatial, full text, etc). + +Remember to VACUUM ANALYZE this table from time to time, +so the planner can judge efficiently whether to use this new +index or not. + +Use EXPLAIN ANALYZE SELECT .... to see whether the index +is really used. + +> I don't care about optimising INSERT, DELETE and UPDATE queries, as they are +> only done at night when the load is very low. +> Thank you very much for any help, + +Oh, they can benefit from the index anyhow. :) + + Regards, + Dawid + +From pgsql-performance-owner@postgresql.org Tue Mar 22 09:58:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EA7E563C0 + for ; + Tue, 22 Mar 2005 09:58:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45291-03 + for ; + Tue, 22 Mar 2005 09:58:41 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.195]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DC4D52A62 + for ; + Tue, 22 Mar 2005 09:58:40 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id y7so1231152rne + for ; + Tue, 22 Mar 2005 01:58:43 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=NtjMmC2fnW6Ds+fRaQ3/iZfiQSHDvFBynauuq9ioXgzeeI6Uh/XmPO0Cj6sSWyo5sSnFMjcmhOGxFSp9rWhshOLce4oMsb4LpJqjpwi84cWquZMSfr2RZQXMPJBKzOyRg6mJsNg0Nh6acyA3dc3w0Clc7eDefyx1IG2ELPPOlgU= +Received: by 10.38.99.16 with SMTP id w16mr6157662rnb; + Tue, 22 Mar 2005 01:58:43 -0800 (PST) +Received: by 10.38.101.75 with HTTP; Tue, 22 Mar 2005 01:58:43 -0800 (PST) +Message-ID: <758d5e7f0503220158cec718e@mail.gmail.com> +Date: Tue, 22 Mar 2005 10:58:43 +0100 +From: Dawid Kuroczko +Reply-To: Dawid Kuroczko +To: pgsql-performance@postgresql.org +Subject: Re: What about utility to calculate planner cost constants? +In-Reply-To: <200503211459.56243.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +References: + <200503210951.06044.josh@agliodbs.com> + <11322edfb476c82809712b9796f78a5f@sitening.com> + <200503211459.56243.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.741 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, FROM_ENDS_IN_NUMS, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/431 +X-Sequence-Number: 11136 + +On Mon, 21 Mar 2005 14:59:56 -0800, Josh Berkus wrote: +> > If by not practical you mean, "no one has implemented a multivariable +> > testing approach," I'll agree with you. But multivariable testing is +> > definitely a valid statistical approach to solving just such problems. +> Well, not practical as in: "would take either $10 million in equipment or +> 10,000 hours or both" + +I think you don't need EXPLAIN ANALYZE each query with different GUCs, +you would only need EXPLAIN most of the times (which is way quicker). +Once you get 'near' actual values, you would do EXECUTE ANALYZE to +verify the variables. + + Regards, + Dawid + +From pgsql-performance-owner@postgresql.org Tue Mar 22 10:49:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6FC8E564BD + for ; + Tue, 22 Mar 2005 10:49:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67402-07 + for ; + Tue, 22 Mar 2005 10:49:36 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 36B14563F1 + for ; + Tue, 22 Mar 2005 10:49:35 +0000 (GMT) +Received: (qmail 19256 invoked from network); 22 Mar 2005 11:49:46 +0100 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 22 Mar 2005 11:49:46 +0100 +To: "Layet Benjamin" , + pgsql-performance@postgresql.org +Subject: Re: best practices with index on varchar column +References: <007301c52ec0$a8f64ec0$9285a8c0@moonfactory.co.jp> +Message-ID: +Date: Tue, 22 Mar 2005 11:49:36 +0100 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <007301c52ec0$a8f64ec0$9285a8c0@moonfactory.co.jp> +User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/432 +X-Sequence-Number: 11137 + + +> Can I use an index on a varchar column to optimize the SELECT queries +> that +> use " column LIKE 'header%' "? + + Yes + +> If yes what is the best tree algotithm to use ? + + Btree + + Note that if you want case insensitive matching you need to make an index +on lower(column) and SELECT WHERE lower(column) LIKE 'header%' + + Locales may bite you. + +From pgsql-performance-owner@postgresql.org Tue Mar 22 11:56:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 713B456471 + for ; + Tue, 22 Mar 2005 11:56:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97235-09 + for ; + Tue, 22 Mar 2005 11:56:33 +0000 (GMT) +Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net + [194.217.242.92]) + by svr1.postgresql.org (Postfix) with ESMTP id 938E4569CB + for ; + Tue, 22 Mar 2005 11:56:31 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-34.mail.demon.net with esmtp (Exim 4.42) + id 1DDhzq-000I1E-Du; Tue, 22 Mar 2005 11:56:33 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id E9D19158FC; Tue, 22 Mar 2005 11:56:25 +0000 (GMT) +Message-ID: <424007E8.1020700@archonet.com> +Date: Tue, 22 Mar 2005 11:56:24 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: Josh Berkus , Tambet Matiisen , + pgsql-performance@postgresql.org +Subject: Re: What about utility to calculate planner cost constants? +References: + <200503210951.06044.josh@agliodbs.com> + <87acowcmut.fsf@stark.xeocode.com> +In-Reply-To: <87acowcmut.fsf@stark.xeocode.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/438 +X-Sequence-Number: 11143 + +Greg Stark wrote: +> Josh Berkus writes: +>>That's not really practical. There are currently 5 major query tuning +>>parameters, not counting the memory adjustments which really can't be left +>>out. You can't realistically test all combinations of 6 variables. +> +> I don't think it would be very hard at all actually. +[snip] +> What's needed is for the explain plan to total up the costing penalties +> independently. So the result would be something like +> +> 1000 * random_page_cost + 101 * sequential_page_cost + 2000 * index_tuple_cost +> + ... +> +> In other words a tuple like <1000,101,2000,...> + > +> And explain analyze would produce the above tuple along with the resulting +> time. +> +> Some program would have to gather these values from the log or stats data and +> gather them up into a large linear system and solve for values that minimize +> the divergence from the observed times. + +You'd only need to log them if they diverged from expected anyway. That +should result in fairly low activity pretty quickly (or we're wasting +our time). Should they go to the stats collector rather than logs? + +> (Also, currently explain analyze has overhead that makes this impractical. +> Ideally it could subtract out its overhead so the solutions would be accurate +> enough to be useful) + +Don't we only need the top-level figures though? There's no need to +record timings for each stage, just work completed. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Mar 22 12:28:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B4AD566A6 + for ; + Tue, 22 Mar 2005 12:28:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08850-08 + for ; + Tue, 22 Mar 2005 12:28:08 +0000 (GMT) +Received: from mx1.rockingstone.nl (mx1.rockingstone.nl [82.94.241.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 41170566D0 + for ; + Tue, 22 Mar 2005 12:28:07 +0000 (GMT) +Received: from localhost (web1 [127.0.0.1]) + by mx1.rockingstone.nl (Postfix) with ESMTP id 19B6FFB093 + for ; + Tue, 22 Mar 2005 13:34:14 +0100 (CET) +Received: from mx1.rockingstone.nl ([127.0.0.1]) + by localhost (web1 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 29206-15 for ; + Tue, 22 Mar 2005 13:34:13 +0100 (CET) +Received: from [10.10.20.219] (217-19-26-53.dsl.cambrium.nl [217.19.26.53]) + by mx1.rockingstone.nl (Postfix) with ESMTP id 315C6FB081 + for ; + Tue, 22 Mar 2005 13:34:13 +0100 (CET) +Message-ID: <42400F57.3040604@rockingstone.nl> +Date: Tue, 22 Mar 2005 13:28:07 +0100 +From: Rick Jansen +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Tsearch2 performance on big database +X-Enigmail-Version: 0.90.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at rockingstone.nl +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/439 +X-Sequence-Number: 11144 + +Hi, + +I'm looking for a *fast* solution to search thru ~ 4 million records of +book descriptions. I've installed PostgreSQL 8.0.1 on a dual opteron +server with 8G of memory, running Linux 2.6. I haven't done a lot of +tuning on PostgreSQL itself, but here's the settings I have changed so far: + +shared_buffers = 2000 (anything much bigger says the kernel doesnt allow + it, still have to look into that) +effective_cache_size = 32768 + +Here's my table: + +ilab=# \d books + Table "public.books" + Column | Type | Modifiers +---------------+------------------------+---------------------------------------------------------- + recordnumber | integer | not null default +nextval('books_recordnumber_seq'::text) + membernumber | integer | not null default 0 + booknumber | character varying(20) | not null default +''::character varying + author | character varying(60) | not null default +''::character varying + titel | text | not null + description | character varying(100) | not null default +''::character varying + descriprest | text | not null + price | bigint | not null default 0::bigint + keywords | character varying(100) | not null default +''::character varying + dollarprice | bigint | not null default 0::bigint + countrynumber | smallint | not null default 0::smallint + entrydate | date | not null + status | smallint | not null default 0::smallint + recordtype | smallint | not null default 0::smallint + bookflags | smallint | not null default 0::smallint + year | smallint | not null default 0::smallint + firstedition | smallint | not null default 0::smallint + dustwrapper | smallint | not null default 0::smallint + signed | smallint | not null default 0::smallint + cover | smallint | not null default 0::smallint + specialfield | smallint | not null default 0::smallint + idxfti | tsvector | +Indexes: + "recordnumber_idx" unique, btree (recordnumber) + "idxfti_idx" gist (idxfti) + +idxfti is a tsvector of concatenated description and descriprest. + +ilab=# select +avg(character_length(description)),avg(character_length(descriprest)) +from books; + avg | avg +---------------------+---------------------- + 89.1596992873947218 | 133.0468689304200538 + +Queries take forever to run. Right now we run a MySQL server, on which +we maintain our own indices (we split the description fields by word and +have different tables for words and the bookdescriptions they appear in). + +For example, a query for the word 'terminology' on our MySQL search +takes 5.8 seconds and returns 375 results. The same query on postgresql +using the tsearch2 index takes 30802.105 ms and returns 298 results. + +How do I speed this up? Should I change settings, add or change indexes +or.. what? + +Rick Jansen +-- +Systems Administrator for Rockingstone IT +http://www.rockingstone.com +http://www.megabooksearch.com - Search many book listing sites at once + +From pgsql-performance-owner@postgresql.org Tue Mar 22 12:36:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DF01F56704 + for ; + Tue, 22 Mar 2005 12:36:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11859-04 + for ; + Tue, 22 Mar 2005 12:36:17 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E1930566DE + for ; + Tue, 22 Mar 2005 12:36:09 +0000 (GMT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id j2MCaB5Q028585; + Tue, 22 Mar 2005 15:36:11 +0300 (MSK) +Date: Tue, 22 Mar 2005 15:36:11 +0300 (MSK) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Rick Jansen +Cc: pgsql-performance@postgresql.org +Subject: Re: Tsearch2 performance on big database +In-Reply-To: <42400F57.3040604@rockingstone.nl> +Message-ID: +References: <42400F57.3040604@rockingstone.nl> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.344 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/440 +X-Sequence-Number: 11145 + +On Tue, 22 Mar 2005, Rick Jansen wrote: + +> Hi, +> +> I'm looking for a *fast* solution to search thru ~ 4 million records of book +> descriptions. I've installed PostgreSQL 8.0.1 on a dual opteron server with +> 8G of memory, running Linux 2.6. I haven't done a lot of tuning on PostgreSQL +> itself, but here's the settings I have changed so far: +> +> shared_buffers = 2000 (anything much bigger says the kernel doesnt allow it, +> still have to look into that) + +use something like +echo "150000000" > /proc/sys/kernel/shmmax +to increase shared memory. In your case you could dedicate much more +memory. + + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Tue Mar 22 12:48:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C6ADE564E7 + for ; + Tue, 22 Mar 2005 12:48:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15748-05 + for ; + Tue, 22 Mar 2005 12:48:04 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.196]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B3EE56704 + for ; + Tue, 22 Mar 2005 12:48:03 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id j1so1158708rnf + for ; + Tue, 22 Mar 2005 04:48:06 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=giFn5o5DbtdqYzkXme9xQSi0e/aBaoW//izd1nmUcNQa2X5xibyFaf5jaHMCHn7JNJwKOTPWedY3BTELt1Y3F/VixETUIUS4VOYsTGL+E+IRM8Ryje9YpqMNYX2a3zhi3M6RkDOqqsDTXIRFI8FTBR+s/o45IhNYN+J1A2CzeDs= +Received: by 10.39.2.13 with SMTP id e13mr6309550rni; + Tue, 22 Mar 2005 04:48:06 -0800 (PST) +Received: by 10.38.126.9 with HTTP; Tue, 22 Mar 2005 04:48:06 -0800 (PST) +Message-ID: +Date: Tue, 22 Mar 2005 12:48:06 +0000 +From: Mike Rylander +Reply-To: Mike Rylander +To: Oleg Bartunov +Subject: Re: Tsearch2 performance on big database +Cc: Rick Jansen , + pgsql-performance@postgresql.org +In-Reply-To: +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +References: <42400F57.3040604@rockingstone.nl> + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.244 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/441 +X-Sequence-Number: 11146 + +On Tue, 22 Mar 2005 15:36:11 +0300 (MSK), Oleg Bartunov wrote: +> On Tue, 22 Mar 2005, Rick Jansen wrote: +> +> > Hi, +> > +> > I'm looking for a *fast* solution to search thru ~ 4 million records of book +> > descriptions. I've installed PostgreSQL 8.0.1 on a dual opteron server with +> > 8G of memory, running Linux 2.6. I haven't done a lot of tuning on PostgreSQL +> > itself, but here's the settings I have changed so far: +> > +> > shared_buffers = 2000 (anything much bigger says the kernel doesnt allow it, +> > still have to look into that) +> +> use something like +> echo "150000000" > /proc/sys/kernel/shmmax +> to increase shared memory. In your case you could dedicate much more +> memory. +> +> Regards, +> Oleg + +And Oleg should know. Unless I'm mistaken, he (co)wrote tsearch2. +Other than shared buffers, I can't imagine what could be causing that +kind of slowness. EXPLAIN ANALYZE, please? + +As an example of what I think you *should* be seeing, I have a similar +box (4 procs, but that doesn't matter for one query) and I can search +a column with tens of millions of rows in around a second. + +-- +Mike Rylander +mrylander@gmail.com +GPLS -- PINES Development +Database Developer +http://open-ils.org + +From pgsql-performance-owner@postgresql.org Tue Mar 22 13:50:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B8AB5672F + for ; + Tue, 22 Mar 2005 13:50:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31964-07 + for ; + Tue, 22 Mar 2005 13:50:04 +0000 (GMT) +Received: from floppy.pyrenet.fr (unknown [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1282D56725 + for ; + Tue, 22 Mar 2005 13:50:02 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 5384F30EA1; Tue, 22 Mar 2005 14:50:06 +0100 (MET) +From: Christopher Browne +X-Newsgroups: pgsql.performance +Subject: Re: What about utility to calculate planner cost constants? +Date: Tue, 22 Mar 2005 08:09:40 -0500 +Organization: cbbrowne Computing Inc +Lines: 30 +Message-ID: +References: + <200503210951.06044.josh@agliodbs.com> + <87acowcmut.fsf@stark.xeocode.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:3jySrWgNBkD6H+Cc4uyWWtUk074= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.396 tagged_above=0 required=5 tests=AWL, INFO_TLD +X-Spam-Level: +X-Archive-Number: 200503/445 +X-Sequence-Number: 11150 + +Martha Stewart called it a Good Thing when gsstark@mit.edu (Greg Stark) wrote: +> I don't think it would be very hard at all actually. +> +> It's just a linear algebra problem with a bunch of independent +> variables and a system of equations. Solving for values for all of +> them is a straightforward problem. +> +> Of course in reality these variables aren't actually independent +> because the costing model isn't perfect. But that wouldn't be a +> problem, it would just reduce the accuracy of the results. + +Are you certain it's a linear system? I'm not. If it was a matter of +minimizing a linear expression subject to some set of linear +equations, then we could model this as a Linear Program for which +there are some perfectly good solvers available. (Few with BSD-style +licenses, but we could probably get some insight out of running for a +while with something that's there...) + +I think there's good reason to consider it to be distinctly +NON-linear, which makes it way more challenging to solve the problem. + +There might well be some results to be gotten out of a linear +approximation; the Grand Challenge is to come up with the model in the +first place... +-- +wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','gmail.com'). +http://linuxdatabases.info/info/or.html +"Tom Christiansen asked me, "Chip, is there anything that you like +that isn't big and complicated?" C++, EMACS, Perl, Unix, English-no, I +guess not." -- Chip Salzenberg, when commenting on Perl6/C++ + +From pgsql-performance-owner@postgresql.org Tue Mar 22 13:10:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D2F45654E + for ; + Tue, 22 Mar 2005 13:10:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18826-09 + for ; + Tue, 22 Mar 2005 13:10:14 +0000 (GMT) +Received: from sunsite.dcc.uchile.cl (sunsite.dcc.uchile.cl [192.80.24.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BD39F56440 + for ; + Tue, 22 Mar 2005 13:10:12 +0000 (GMT) +Received: from anakena.dcc.uchile.cl (anakena [192.80.24.6]) + by sunsite.dcc.uchile.cl (8.12.11/8.12.11) with ESMTP id j2MDA0IP018802; + Tue, 22 Mar 2005 09:10:00 -0400 (CLT) +Received: by anakena.dcc.uchile.cl (Postfix, from userid 4151) + id 77BCB52A14; Tue, 22 Mar 2005 09:10:00 -0400 (CLT) +Date: Tue, 22 Mar 2005 09:10:00 -0400 +From: Alvaro Herrera +To: Hannu Krosing +Cc: PFC , + Josh Berkus , pgsql-performance@postgresql.org +Subject: Re: What needs to be done for real Partitioning? +Message-ID: <20050322131000.GA15881@dcc.uchile.cl> +References: <200503191202.38089.josh@agliodbs.com> + <2092.1111273359@sss.pgh.pa.us> + + <1111429584.4675.40.camel@fuji.krosing.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1111429584.4675.40.camel@fuji.krosing.net> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.35 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/442 +X-Sequence-Number: 11147 + +On Mon, Mar 21, 2005 at 08:26:24PM +0200, Hannu Krosing wrote: +> On P, 2005-03-20 at 00:52 +0100, PFC wrote: + +> > Also note the possibility to mark a partition READ ONLY. Or even a table. + +> Would we still need regular VACUUMing of read-only table to avoid +> OID-wraparound ? + +You could VACUUM FREEZE the table or partition, so you wouldn't need to +vacuum it again. + +-- +Alvaro Herrera () +"Someone said that it is at least an order of magnitude more work to do +production software than a prototype. I think he is wrong by at least +an order of magnitude." (Brian Kernighan) + +From pgsql-performance-owner@postgresql.org Tue Mar 22 13:24:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 24E8156717 + for ; + Tue, 22 Mar 2005 13:24:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27012-01 + for ; + Tue, 22 Mar 2005 13:24:29 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9FDA452A62 + for ; + Tue, 22 Mar 2005 13:24:21 +0000 (GMT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id j2MDOG5Q000110; + Tue, 22 Mar 2005 16:24:16 +0300 (MSK) +Date: Tue, 22 Mar 2005 16:24:16 +0300 (MSK) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Mike Rylander +Cc: Rick Jansen , + pgsql-performance@postgresql.org +Subject: Re: Tsearch2 performance on big database +In-Reply-To: +Message-ID: +References: <42400F57.3040604@rockingstone.nl> + + +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.344 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/443 +X-Sequence-Number: 11148 + +On Tue, 22 Mar 2005, Mike Rylander wrote: + +> +> And Oleg should know. Unless I'm mistaken, he (co)wrote tsearch2. + +You're not mistaken :) + +> Other than shared buffers, I can't imagine what could be causing that +> kind of slowness. EXPLAIN ANALYZE, please? +> + +tsearch2 config's also are very important. I've seen a lot of +mistakes in configs ! + + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Tue Mar 22 13:25:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D3BAF564E7 + for ; + Tue, 22 Mar 2005 13:25:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26238-03 + for ; + Tue, 22 Mar 2005 13:25:18 +0000 (GMT) +Received: from mx1.rockingstone.nl (mx1.rockingstone.nl [82.94.241.100]) + by svr1.postgresql.org (Postfix) with ESMTP id BFAE856529 + for ; + Tue, 22 Mar 2005 13:25:17 +0000 (GMT) +Received: from localhost (web1 [127.0.0.1]) + by mx1.rockingstone.nl (Postfix) with ESMTP id 07186FB0A8; + Tue, 22 Mar 2005 14:31:25 +0100 (CET) +Received: from mx1.rockingstone.nl ([127.0.0.1]) + by localhost (web1 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 05839-14; Tue, 22 Mar 2005 14:31:23 +0100 (CET) +Received: from [10.10.20.219] (217-19-26-53.dsl.cambrium.nl [217.19.26.53]) + by mx1.rockingstone.nl (Postfix) with ESMTP id C8F49FB069; + Tue, 22 Mar 2005 14:31:23 +0100 (CET) +Message-ID: <42401CBF.50403@rockingstone.nl> +Date: Tue, 22 Mar 2005 14:25:19 +0100 +From: Rick Jansen +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Mike Rylander +Cc: Oleg Bartunov , pgsql-performance@postgresql.org +Subject: Re: Tsearch2 performance on big database +References: <42400F57.3040604@rockingstone.nl> + + +In-Reply-To: +X-Enigmail-Version: 0.90.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at rockingstone.nl +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/444 +X-Sequence-Number: 11149 + +Mike Rylander wrote: +> On Tue, 22 Mar 2005 15:36:11 +0300 (MSK), Oleg Bartunov wrote: +>> +>>use something like +>>echo "150000000" > /proc/sys/kernel/shmmax +>>to increase shared memory. In your case you could dedicate much more +>>memory. +>> +>> Regards, +>> Oleg + + +Thanks, I'll check that out. + +> And Oleg should know. Unless I'm mistaken, he (co)wrote tsearch2. +> Other than shared buffers, I can't imagine what could be causing that +> kind of slowness. EXPLAIN ANALYZE, please? +> + +ilab=# explain analyze select count(titel) from books where idxfti @@ +to_tsquery('default', 'buckingham | palace'); + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=35547.99..35547.99 rows=1 width=56) (actual +time=125968.119..125968.120 rows=1 loops=1) + -> Index Scan using idxfti_idx on books (cost=0.00..35525.81 +rows=8869 width=56) (actual time=0.394..125958.245 rows=3080 loops=1) + Index Cond: (idxfti @@ '\'buckingham\' | \'palac\''::tsquery) + Total runtime: 125968.212 ms +(4 rows) + +Time: 125969.264 ms +ilab=# + + > As an example of what I think you *should* be seeing, I have a similar + > box (4 procs, but that doesn't matter for one query) and I can search + > a column with tens of millions of rows in around a second. + > + +That sounds very promising, I'd love to get those results.. could you +tell me what your settings are, howmuch memory you have and such? Thanks. + +Rick + + +-- +Systems Administrator for Rockingstone IT +http://www.rockingstone.com +http://www.megabooksearch.com - Search many book listing sites at once + +From pgsql-performance-owner@postgresql.org Sun Mar 27 16:28:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CE21F5672C + for ; + Tue, 22 Mar 2005 14:00:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38662-01 + for ; + Tue, 22 Mar 2005 14:00:50 +0000 (GMT) +Received: from is.rice.edu (is.rice.edu [128.42.42.24]) + by svr1.postgresql.org (Postfix) with ESMTP id 5583C5672B + for ; + Tue, 22 Mar 2005 14:00:49 +0000 (GMT) +Received: from localhost (localhost [127.0.0.1]) + by is.rice.edu (Postfix) with ESMTP id 4B6CB41963; + Tue, 22 Mar 2005 08:00:53 -0600 (CST) +Received: from is.rice.edu ([127.0.0.1]) + by localhost (it.is.rice.edu [127.0.0.1]) (amavisd-new, + port 10024) with LMTP + id 14626-01-89; Tue, 22 Mar 2005 08:00:50 -0600 (CST) +Received: by is.rice.edu (Postfix, from userid 18612) + id 77C3B4188D; Tue, 22 Mar 2005 08:00:50 -0600 (CST) +Date: Tue, 22 Mar 2005 08:00:50 -0600 +From: Kenneth Marshall +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: What about utility to calculate planner cost constants? +Message-ID: <20050322140050.GQ3087@it.is.rice.edu> +References: + <200503210951.06044.josh@agliodbs.com> + <87acowcmut.fsf@stark.xeocode.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.4.2i +X-Virus-Scanned: by amavis-2.2.1 at is.rice.edu +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/599 +X-Sequence-Number: 11304 + +On Tue, Mar 22, 2005 at 08:09:40AM -0500, Christopher Browne wrote: +> Martha Stewart called it a Good Thing when gsstark@mit.edu (Greg Stark) wrote: +> > I don't think it would be very hard at all actually. +> > +> > It's just a linear algebra problem with a bunch of independent +> > variables and a system of equations. Solving for values for all of +> > them is a straightforward problem. +> > +> > Of course in reality these variables aren't actually independent +> > because the costing model isn't perfect. But that wouldn't be a +> > problem, it would just reduce the accuracy of the results. +> +> Are you certain it's a linear system? I'm not. If it was a matter of +> minimizing a linear expression subject to some set of linear +> equations, then we could model this as a Linear Program for which +> there are some perfectly good solvers available. (Few with BSD-style +> licenses, but we could probably get some insight out of running for a +> while with something that's there...) +> +> I think there's good reason to consider it to be distinctly +> NON-linear, which makes it way more challenging to solve the problem. +> +Non-linear optimization works very well in many cases. Issues such +as local minima can be addressed. In a sense, the planner output +can be treated as a blackbox function and the "goodness" of the +solution is how well it approximates the actual query times. In this +case, it will be imperative to constrain some of the values to prevent +"crazy" configurations. + +Ken + +From pgsql-admin-owner@postgresql.org Tue Mar 22 18:28:33 2005 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 96A815668E + for ; + Tue, 22 Mar 2005 18:27:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25098-10 + for ; + Tue, 22 Mar 2005 18:27:11 +0000 (GMT) +Received: from svr2.postgresql.org (unknown [65.19.161.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E3BD563F5 + for ; Tue, 22 Mar 2005 18:27:11 +0000 (GMT) +Received: from ceroriesgo.co.cr (unknown [200.91.71.251]) + by svr2.postgresql.org (Postfix) with ESMTP id E73F0F17F4 + for ; Tue, 22 Mar 2005 15:15:43 +0000 (GMT) +Received: from [192.168.0.110] by ceroriesgo.co.cr (MDaemon.PRO.v7.2.3.R) + with ESMTP id md50000015393.msg + for ; Tue, 22 Mar 2005 08:23:39 -0800 +Message-ID: <42402A4B.70703@ceroriesgo.co.cr> +Date: Tue, 22 Mar 2005 08:23:07 -0600 +From: Sabio - PSQL +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PostgreSQL Admin +Subject: Too slow +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Authenticated-Sender: slopez@ceroriesgo.co.cr +X-Spam-Processed: ceroriesgo.co.cr, Tue, 22 Mar 2005 08:23:39 -0800 + (not processed: message from valid local sender) +X-MDRemoteIP: 192.168.0.110 +X-Return-Path: slopez_pg@ceroriesgo.co.cr +X-MDaemon-Deliver-To: pgsql-admin@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.311 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/349 +X-Sequence-Number: 16847 + +How can I improve speed on my queries. For example this query takes one +day executing itself and it has not finalized !!! +"create table tmp_partes as select * from partes where identificacion +not in (select cedula from sujetos)" + +partes have 1888000 rows, an index on identificacion +sujetos have 5500000 rows, an index on cedula + + + + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 14:56:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5EC40563E9 + for ; + Tue, 22 Mar 2005 14:56:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54286-10 + for ; + Tue, 22 Mar 2005 14:55:59 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C3DF56737 + for ; + Tue, 22 Mar 2005 14:55:58 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 70so1793533wra + for ; + Tue, 22 Mar 2005 06:56:02 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; + b=LOA/9SzkFCscQLEaPcLwCgGnfEQuw6qYzSBEb3BHyK4LsdUhNhvH7ABHvHbtY9+DFXmoXTXwtcXmIq6d7m3/U2XRTX97S8a99zJiHgXfhPjp9NesarQVMesKkEGxX6vNUVORYIF945iEKvIQYiKKLUqzEjD32Ic9297O+SgfEbA= +Received: by 10.54.30.77 with SMTP id d77mr1447889wrd; + Tue, 22 Mar 2005 06:56:02 -0800 (PST) +Received: by 10.54.86.16 with HTTP; Tue, 22 Mar 2005 06:56:02 -0800 (PST) +Message-ID: <33c6269f05032206565ca4f9f1@mail.gmail.com> +Date: Tue, 22 Mar 2005 09:56:02 -0500 +From: Alex Turner +Reply-To: Alex Turner +To: "pgsql-performance@postgresql.org" +Subject: Planner issue +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.471 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP, TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200503/446 +X-Sequence-Number: 11151 + +I get the following output from explain analyze on a certain subset of +a large query I'm doing. + + From the looks of it, I need to increase how often postgres uses an +index over a seq scan, but I'm not sure how to do that. I looked +through the run-time configuration docs on the website, but didn't see +anything pertaining to index selectivity. + +Thanks, + +Alex Turner +netEconomist + + +trendmls=# explain analyze select listnum from propmain where +listprice<=300000 and listprice>=220000; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------- + Seq Scan on propmain (cost=0.00..15556.05 rows=6228 width=4) (actual +time=0.093..506.730 rows=5671 loops=1) + Filter: ((listprice <= 300000::numeric) AND (listprice >= 220000::numeric)) + Total runtime: 510.482 ms +(3 rows) + +trendmls=# explain analyze select listnum from propmain where +listprice<=300000 and listprice>=250000; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ + Index Scan using propmain_listprice_i on propmain +(cost=0.00..12578.65 rows=3486 width=4) (actual time=0.103..16.418 +rows=3440 loops=1) + Index Cond: ((listprice <= 300000::numeric) AND (listprice >= +250000::numeric)) + Total runtime: 18.528 ms +(3 rows) + +From pgsql-performance-owner@postgresql.org Tue Mar 22 15:00:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 501B456712 + for ; + Tue, 22 Mar 2005 15:00:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56601-10 + for ; + Tue, 22 Mar 2005 15:00:43 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 442F856536 + for ; + Tue, 22 Mar 2005 15:00:40 +0000 (GMT) +Received: (qmail 5581 invoked by uid 500); 22 Mar 2005 15:17:07 -0000 +Date: Tue, 22 Mar 2005 09:17:07 -0600 +From: Bruno Wolff III +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: What about utility to calculate planner cost constants? +Message-ID: <20050322151707.GA5486@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Christopher Browne , + pgsql-performance@postgresql.org +References: + <200503210951.06044.josh@agliodbs.com> + <87acowcmut.fsf@stark.xeocode.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/447 +X-Sequence-Number: 11152 + +On Tue, Mar 22, 2005 at 08:09:40 -0500, + Christopher Browne wrote: +> +> Are you certain it's a linear system? I'm not. If it was a matter of +> minimizing a linear expression subject to some set of linear +> equations, then we could model this as a Linear Program for which +> there are some perfectly good solvers available. (Few with BSD-style +> licenses, but we could probably get some insight out of running for a +> while with something that's there...) + +For less than 100 equations and 100 unknowns, you should be able to use +naive solvers. After that you don't get very accurate answers without +being more careful. I still have my numerical analysis text books around +and can look algorithms up for doing this without too much trouble. + +From pgsql-performance-owner@postgresql.org Tue Mar 22 15:30:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 75AA1564AB + for ; + Tue, 22 Mar 2005 15:30:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68186-08 + for ; + Tue, 22 Mar 2005 15:30:00 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.197]) + by svr1.postgresql.org (Postfix) with ESMTP id CA636563E9 + for ; + Tue, 22 Mar 2005 15:29:58 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id j1so1207766rnf + for ; + Tue, 22 Mar 2005 07:30:03 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=o0V3IsI+LGS6B8nOT8uJwt1eMg/joeMPStV6KmpP9MvBpm6oqdnzvY8zRVR4/YtPNg/ADsognsgEqmgEJz98eGkUJIE7JMbM9ba+UPar7AFGemIymP5GLn76mPwvvyzVL3rCULPXwQdAqUl6JUJ/mCynKlvkf/4/K07pHvu+HhE= +Received: by 10.38.150.65 with SMTP id x65mr186604rnd; + Tue, 22 Mar 2005 07:30:03 -0800 (PST) +Received: by 10.38.126.9 with HTTP; Tue, 22 Mar 2005 07:30:03 -0800 (PST) +Message-ID: +Date: Tue, 22 Mar 2005 10:30:03 -0500 +From: Mike Rylander +Reply-To: Mike Rylander +To: Rick Jansen +Subject: Re: Tsearch2 performance on big database +Cc: Oleg Bartunov , pgsql-performance@postgresql.org +In-Reply-To: <42401CBF.50403@rockingstone.nl> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +References: <42400F57.3040604@rockingstone.nl> + + + <42401CBF.50403@rockingstone.nl> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.245 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/448 +X-Sequence-Number: 11153 + +On Tue, 22 Mar 2005 14:25:19 +0100, Rick Jansen wrote: +> +> ilab=# explain analyze select count(titel) from books where idxfti @@ +> to_tsquery('default', 'buckingham | palace'); +> QUERY PLAN +> ---------------------------------------------------------------------------------------------------------------------------------------- +> Aggregate (cost=35547.99..35547.99 rows=1 width=56) (actual +> time=125968.119..125968.120 rows=1 loops=1) +> -> Index Scan using idxfti_idx on books (cost=0.00..35525.81 +> rows=8869 width=56) (actual time=0.394..125958.245 rows=3080 loops=1) +> Index Cond: (idxfti @@ '\'buckingham\' | \'palac\''::tsquery) +> Total runtime: 125968.212 ms +> (4 rows) +> +> Time: 125969.264 ms +> ilab=# + +Ahh... I should have qualified my claim. I am creating a google-esqe +search interface and almost every query uses '&' as the term joiner. +'AND' queries and one-term queries are orders of magnitude faster than +'OR' queries, and fortunately are the expected default for most users. + (Think, "I typed in these words, therefore I want to match these +words"...) An interesting test may be to time multiple queries +independently, one for each search term, and see if the combined cost +is less than a single 'OR' search. If so, you could use UNION to join +the results. + +However, the example you originally gave ('terminology') should be +very fast. On a comparable query ("select count(value) from +metabib.full_rec where index_vector @@ to_tsquery('default','jane');") +I get 12ms. + +Oleg, do you see anything else on the surface here? + +Try: + +EXPLAIN ANALYZE + SELECT titel FROM books WHERE idxfti @@ + to_tsquery('default', 'buckingham') + UNION + SELECT titel FROM books WHERE idxfti @@ + to_tsquery('default', 'palace'); + +and see if using '&' instead of '|' where you can helps out. I +imagine you'd be surprised by the speed of: + + SELECT titel FROM books WHERE idxfti @@ + to_tsquery('default', 'buckingham&palace'); + + +> +> > As an example of what I think you *should* be seeing, I have a similar +> > box (4 procs, but that doesn't matter for one query) and I can search +> > a column with tens of millions of rows in around a second. +> > +> +> That sounds very promising, I'd love to get those results.. could you +> tell me what your settings are, howmuch memory you have and such? + +16G of RAM on a dedicated machine. + + +shared_buffers = 15000 # min 16, at least max_connections*2, 8KB each +work_mem = 10240 # min 64, size in KB +maintenance_work_mem = 1000000 # min 1024, size in KB +# big m_w_m for loading data... + +random_page_cost = 2.5 # units are one sequential page fetch cost +# fast drives, and tons of RAM + + +-- +Mike Rylander +mrylander@gmail.com +GPLS -- PINES Development +Database Developer +http://open-ils.org + +From pgsql-performance-owner@postgresql.org Tue Mar 22 15:45:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A342A52D42 + for ; + Tue, 22 Mar 2005 15:45:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73208-04 + for ; + Tue, 22 Mar 2005 15:45:31 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 31809568E3 + for ; + Tue, 22 Mar 2005 15:45:23 +0000 (GMT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id j2MFjH5Q004138; + Tue, 22 Mar 2005 18:45:17 +0300 (MSK) +Date: Tue, 22 Mar 2005 18:45:17 +0300 (MSK) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Mike Rylander +Cc: Rick Jansen , + pgsql-performance@postgresql.org +Subject: Re: Tsearch2 performance on big database +In-Reply-To: +Message-ID: +References: <42400F57.3040604@rockingstone.nl> + + + <42401CBF.50403@rockingstone.nl> + +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.344 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/449 +X-Sequence-Number: 11154 + +Mike, + +no comments before Rick post tsearch configs and increased buffers ! +Union shouldn't be faster than (term1|term2). +tsearch2 internals description might help you understanding tsearch2 limitations. +See http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_internals +Also, don't miss my notes: +http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes + +Oleg +On Tue, 22 Mar 2005, Mike Rylander wrote: + +> On Tue, 22 Mar 2005 14:25:19 +0100, Rick Jansen wrote: +>> +>> ilab=# explain analyze select count(titel) from books where idxfti @@ +>> to_tsquery('default', 'buckingham | palace'); +>> QUERY PLAN +>> ---------------------------------------------------------------------------------------------------------------------------------------- +>> Aggregate (cost=35547.99..35547.99 rows=1 width=56) (actual +>> time=125968.119..125968.120 rows=1 loops=1) +>> -> Index Scan using idxfti_idx on books (cost=0.00..35525.81 +>> rows=8869 width=56) (actual time=0.394..125958.245 rows=3080 loops=1) +>> Index Cond: (idxfti @@ '\'buckingham\' | \'palac\''::tsquery) +>> Total runtime: 125968.212 ms +>> (4 rows) +>> +>> Time: 125969.264 ms +>> ilab=# +> +> Ahh... I should have qualified my claim. I am creating a google-esqe +> search interface and almost every query uses '&' as the term joiner. +> 'AND' queries and one-term queries are orders of magnitude faster than +> 'OR' queries, and fortunately are the expected default for most users. +> (Think, "I typed in these words, therefore I want to match these +> words"...) An interesting test may be to time multiple queries +> independently, one for each search term, and see if the combined cost +> is less than a single 'OR' search. If so, you could use UNION to join +> the results. +> +> However, the example you originally gave ('terminology') should be +> very fast. On a comparable query ("select count(value) from +> metabib.full_rec where index_vector @@ to_tsquery('default','jane');") +> I get 12ms. +> +> Oleg, do you see anything else on the surface here? +> +> Try: +> +> EXPLAIN ANALYZE +> SELECT titel FROM books WHERE idxfti @@ +> to_tsquery('default', 'buckingham') +> UNION +> SELECT titel FROM books WHERE idxfti @@ +> to_tsquery('default', 'palace'); +> +> and see if using '&' instead of '|' where you can helps out. I +> imagine you'd be surprised by the speed of: +> +> SELECT titel FROM books WHERE idxfti @@ +> to_tsquery('default', 'buckingham&palace'); +> +> +>> +>> > As an example of what I think you *should* be seeing, I have a similar +>> > box (4 procs, but that doesn't matter for one query) and I can search +>> > a column with tens of millions of rows in around a second. +>> > +>> +>> That sounds very promising, I'd love to get those results.. could you +>> tell me what your settings are, howmuch memory you have and such? +> +> 16G of RAM on a dedicated machine. +> +> +> shared_buffers = 15000 # min 16, at least max_connections*2, 8KB each +> work_mem = 10240 # min 64, size in KB +> maintenance_work_mem = 1000000 # min 1024, size in KB +> # big m_w_m for loading data... +> +> random_page_cost = 2.5 # units are one sequential page fetch cost +> # fast drives, and tons of RAM +> +> +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Tue Mar 22 15:59:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D7E4569B5 + for ; + Tue, 22 Mar 2005 15:59:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77103-08 + for ; + Tue, 22 Mar 2005 15:59:22 +0000 (GMT) +Received: from fuji.krosing.net (joltid-gw.joltid.org [195.50.194.24]) + by svr1.postgresql.org (Postfix) with ESMTP id F112F569B2 + for ; + Tue, 22 Mar 2005 15:59:20 +0000 (GMT) +Received: from fuji.krosing.net (localhost [127.0.0.1]) + by fuji.krosing.net (8.13.1/8.13.1) with ESMTP id j2MFxHqK006020; + Tue, 22 Mar 2005 17:59:17 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.13.1/8.13.1/Submit) id j2MFxG0K006019; + Tue, 22 Mar 2005 17:59:16 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: What needs to be done for real Partitioning? +From: Hannu Krosing +To: Alvaro Herrera +Cc: PFC , + Josh Berkus , pgsql-performance@postgresql.org +In-Reply-To: <20050322131000.GA15881@dcc.uchile.cl> +References: <200503191202.38089.josh@agliodbs.com> + <2092.1111273359@sss.pgh.pa.us> + + <1111429584.4675.40.camel@fuji.krosing.net> + <20050322131000.GA15881@dcc.uchile.cl> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Date: Tue, 22 Mar 2005 17:59:16 +0200 +Message-Id: <1111507156.5724.1.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-1) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/450 +X-Sequence-Number: 11155 + +On T, 2005-03-22 at 09:10 -0400, Alvaro Herrera wrote: +> On Mon, Mar 21, 2005 at 08:26:24PM +0200, Hannu Krosing wrote: +> > On P, 2005-03-20 at 00:52 +0100, PFC wrote: +> +> > > Also note the possibility to mark a partition READ ONLY. Or even a table. +> +> > Would we still need regular VACUUMing of read-only table to avoid +> > OID-wraparound ? +> +> You could VACUUM FREEZE the table or partition, so you wouldn't need to +> vacuum it again. + +But when I do just VACUUM; will this know to avoid vacuuming VACUUM +FREEZE'd partitions ? + +Or could this be somehow liked to READ ONLY + VACUUM FREEZE state ? + +-- +Hannu Krosing + +From pgsql-performance-owner@postgresql.org Tue Mar 22 16:06:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E668569B0 + for ; + Tue, 22 Mar 2005 16:06:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81067-01 + for ; + Tue, 22 Mar 2005 16:06:00 +0000 (GMT) +Received: from mx1.rockingstone.nl (mx1.rockingstone.nl [82.94.241.100]) + by svr1.postgresql.org (Postfix) with ESMTP id BACA85670A + for ; + Tue, 22 Mar 2005 16:05:58 +0000 (GMT) +Received: from localhost (web1 [127.0.0.1]) + by mx1.rockingstone.nl (Postfix) with ESMTP id BBF56FB0AB; + Tue, 22 Mar 2005 17:12:01 +0100 (CET) +Received: from mx1.rockingstone.nl ([127.0.0.1]) + by localhost (web1 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 26739-11; Tue, 22 Mar 2005 17:12:00 +0100 (CET) +Received: from [10.10.20.219] (217-19-26-53.dsl.cambrium.nl [217.19.26.53]) + by mx1.rockingstone.nl (Postfix) with ESMTP id 02890FB074; + Tue, 22 Mar 2005 17:11:59 +0100 (CET) +Message-ID: <42404263.40604@rockingstone.nl> +Date: Tue, 22 Mar 2005 17:05:55 +0100 +From: Rick Jansen +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Oleg Bartunov +Cc: Mike Rylander , + pgsql-performance@postgresql.org +Subject: Re: Tsearch2 performance on big database +References: <42400F57.3040604@rockingstone.nl> + + + <42401CBF.50403@rockingstone.nl> + + +In-Reply-To: +X-Enigmail-Version: 0.90.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at rockingstone.nl +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/451 +X-Sequence-Number: 11156 + +Oleg Bartunov wrote: +> Mike, +> +> no comments before Rick post tsearch configs and increased buffers ! +> Union shouldn't be faster than (term1|term2). +> tsearch2 internals description might help you understanding tsearch2 +> limitations. +> See http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_internals +> Also, don't miss my notes: +> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes +> +> Oleg + +Thanks Oleg, i've seen those pages before :) I've set shared_buffers to +45000 now (yes thats probably very much, isn't it?) and it already seems +a lot quicker. + +How do I find out what my tsearch config is? I followed the intro +(http://www.sai.msu.su/~megera/oddmuse/index.cgi/tsearch-v2-intro) and +applied it to our books table, thats all, didnt change anything else +about configs. + + +> On Tue, 22 Mar 2005, Mike Rylander wrote: +>> Ahh... I should have qualified my claim. I am creating a google-esqe +>> search interface and almost every query uses '&' as the term joiner. +>> 'AND' queries and one-term queries are orders of magnitude faster than +>> 'OR' queries, and fortunately are the expected default for most users. +>> (Think, "I typed in these words, therefore I want to match these +>> words"...) An interesting test may be to time multiple queries +>> independently, one for each search term, and see if the combined cost +>> is less than a single 'OR' search. If so, you could use UNION to join +>> the results. + +Well I just asked my colleges and OR queries arent used by us anyway, so +I'll test for AND queries instead. + +>> However, the example you originally gave ('terminology') should be +>> very fast. On a comparable query ("select count(value) from +>> metabib.full_rec where index_vector @@ to_tsquery('default','jane');") +>> I get 12ms. + +ilab=# select count(*) from books where idxfti @@ to_tsquery('default', +'jane'); + count +------- + 4093 +(1 row) +Time: 217395.820 ms + +:( + +ilab=# explain analyze select count(*) from books where idxfti @@ +to_tsquery('default', 'jane'); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=16591.95..16591.95 rows=1 width=0) (actual +time=4634.931..4634.932 rows=1 loops=1) + -> Index Scan using idxfti_idx on books (cost=0.00..16581.69 +rows=4102 width=0) (actual time=0.395..4631.454 rows=4093 loops=1) + Index Cond: (idxfti @@ '\'jane\''::tsquery) + Total runtime: 4635.023 ms +(4 rows) + +Time: 4636.028 ms +ilab=# + +>> 16G of RAM on a dedicated machine. +>> +>> +>> shared_buffers = 15000 # min 16, at least max_connections*2, +>> 8KB each +>> work_mem = 10240 # min 64, size in KB +>> maintenance_work_mem = 1000000 # min 1024, size in KB +>> # big m_w_m for loading data... +>> +>> random_page_cost = 2.5 # units are one sequential page fetch +>> cost +>> # fast drives, and tons of RAM +>> + +Right.. well I'll try copying these settings, see how that works out, +thanks :) + +Rick +-- +Systems Administrator for Rockingstone IT +http://www.rockingstone.com +http://www.megabooksearch.com - Search many book listing sites at once + +From pgsql-performance-owner@postgresql.org Tue Mar 22 16:20:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BBAE4566FB + for ; + Tue, 22 Mar 2005 16:20:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85265-01 + for ; + Tue, 22 Mar 2005 16:19:58 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id A518F569AC + for ; + Tue, 22 Mar 2005 16:19:54 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DDm6X-0007w4-00; Tue, 22 Mar 2005 11:19:41 -0500 +To: Richard Huxton +Cc: Greg Stark , Josh Berkus , + Tambet Matiisen , pgsql-performance@postgresql.org +Subject: Re: What about utility to calculate planner cost constants? +References: + <200503210951.06044.josh@agliodbs.com> + <87acowcmut.fsf@stark.xeocode.com> <424007E8.1020700@archonet.com> +In-Reply-To: <424007E8.1020700@archonet.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 22 Mar 2005 11:19:40 -0500 +Message-ID: <87y8cfbqlf.fsf@stark.xeocode.com> +Lines: 25 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.014 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/452 +X-Sequence-Number: 11157 + +Richard Huxton writes: + +> You'd only need to log them if they diverged from expected anyway. That should +> result in fairly low activity pretty quickly (or we're wasting our time). +> Should they go to the stats collector rather than logs? + +I think you need to log them all. Otherwise when you go to analyze the numbers +and come up with ideal values you're going to be basing your optimization on a +skewed subset. + +I don't know whether the stats collector or the logs is better suited to this. + +> > (Also, currently explain analyze has overhead that makes this impractical. +> > Ideally it could subtract out its overhead so the solutions would be accurate +> > enough to be useful) +> +> Don't we only need the top-level figures though? There's no need to record +> timings for each stage, just work completed. + +I guess you only need top level values. But you also might want some flag if +the row counts for any node were far off. In that case perhaps you would want +to discard the data point. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 16:23:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B25E55DC4 + for ; + Tue, 22 Mar 2005 16:23:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84150-08 + for ; + Tue, 22 Mar 2005 16:23:02 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F84656727 + for ; + Tue, 22 Mar 2005 16:23:01 +0000 (GMT) +Received: from [127.0.0.1] (clbb-248.saw.net [64.146.135.248]) + (authenticated bits=0) + by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id + j2MGKGkh006826; Tue, 22 Mar 2005 08:20:17 -0800 +Message-ID: <42404663.2010504@commandprompt.com> +Date: Tue, 22 Mar 2005 08:22:59 -0800 +From: "Joshua D. Drake" +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alex Turner +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Planner issue +References: <33c6269f05032206565ca4f9f1@mail.gmail.com> +In-Reply-To: <33c6269f05032206565ca4f9f1@mail.gmail.com> +Content-Type: multipart/mixed; boundary="------------030506020405060507040501" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.04 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/453 +X-Sequence-Number: 11158 + +This is a multi-part message in MIME format. +--------------030506020405060507040501 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Alex Turner wrote: + +>I get the following output from explain analyze on a certain subset of +>a large query I'm doing. +> +> +> +Try increases the statistics on the listprice column with alter +table and then re-run analyze. + +alter table foo alter column set statistics + +Sincerely, + +Joshua D. Drake + + +>>From the looks of it, I need to increase how often postgres uses an +>index over a seq scan, but I'm not sure how to do that. I looked +>through the run-time configuration docs on the website, but didn't see +>anything pertaining to index selectivity. +> +>Thanks, +> +>Alex Turner +>netEconomist +> +> +>trendmls=# explain analyze select listnum from propmain where +>listprice<=300000 and listprice>=220000; +> QUERY PLAN +>-------------------------------------------------------------------------------------------------------------- +> Seq Scan on propmain (cost=0.00..15556.05 rows=6228 width=4) (actual +>time=0.093..506.730 rows=5671 loops=1) +> Filter: ((listprice <= 300000::numeric) AND (listprice >= 220000::numeric)) +> Total runtime: 510.482 ms +>(3 rows) +> +>trendmls=# explain analyze select listnum from propmain where +>listprice<=300000 and listprice>=250000; +> QUERY PLAN +>------------------------------------------------------------------------------------------------------------------------------------------ +> Index Scan using propmain_listprice_i on propmain +>(cost=0.00..12578.65 rows=3486 width=4) (actual time=0.103..16.418 +>rows=3440 loops=1) +> Index Cond: ((listprice <= 300000::numeric) AND (listprice >= +>250000::numeric)) +> Total runtime: 18.528 ms +>(3 rows) +> +>---------------------------(end of broadcast)--------------------------- +>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +> +> + + +-- +Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC +Postgresql support, programming shared hosting and dedicated hosting. ++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com +PostgreSQL Replicator -- production quality replication for PostgreSQL + + +--------------030506020405060507040501 +Content-Type: text/x-vcard; charset=utf-8; + name="jd.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="jd.vcf" + +begin:vcard +fn:Joshua Drake +n:Drake;Joshua +org:Command Prompt, Inc. +adr:;;PO Box 215 ;Cascade Locks;OR;97014;US +email;internet:jd@commandprompt.com +title:Consultant +tel;work:503-667-4564 +tel;fax:503-210-0334 +x-mozilla-html:FALSE +url:http://www.commandprompt.com +version:2.1 +end:vcard + + +--------------030506020405060507040501-- + +From pgsql-performance-owner@postgresql.org Tue Mar 22 16:38:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A05F56440 + for ; + Tue, 22 Mar 2005 16:38:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91559-01 + for ; + Tue, 22 Mar 2005 16:38:25 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A4BC52D42 + for ; + Tue, 22 Mar 2005 16:38:17 +0000 (GMT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id j2MGc55Q005475; + Tue, 22 Mar 2005 19:38:06 +0300 (MSK) +Date: Tue, 22 Mar 2005 19:38:05 +0300 (MSK) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Rick Jansen +Cc: Mike Rylander , + pgsql-performance@postgresql.org +Subject: Re: Tsearch2 performance on big database +In-Reply-To: <42404263.40604@rockingstone.nl> +Message-ID: +References: <42400F57.3040604@rockingstone.nl> + + + <42401CBF.50403@rockingstone.nl> + + + <42404263.40604@rockingstone.nl> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.343 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/454 +X-Sequence-Number: 11159 + +On Tue, 22 Mar 2005, Rick Jansen wrote: + +> Oleg Bartunov wrote: +>> Mike, +>> +>> no comments before Rick post tsearch configs and increased buffers ! +>> Union shouldn't be faster than (term1|term2). +>> tsearch2 internals description might help you understanding tsearch2 +>> limitations. +>> See http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_internals +>> Also, don't miss my notes: +>> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes +>> +>> Oleg +> +> Thanks Oleg, i've seen those pages before :) I've set shared_buffers to 45000 +> now (yes thats probably very much, isn't it?) and it already seems a lot +> quicker. +> +> How do I find out what my tsearch config is? I followed the intro +> (http://www.sai.msu.su/~megera/oddmuse/index.cgi/tsearch-v2-intro) and +> applied it to our books table, thats all, didnt change anything else about +> configs. + +Hmm, default configuration is too eager, you index every lexem using +simple dictionary) ! Probably, it's too much. Here is what I have for my +russian configuration in dictionary database: + + default_russian | lword | {en_ispell,en_stem} + default_russian | lpart_hword | {en_ispell,en_stem} + default_russian | lhword | {en_ispell,en_stem} + default_russian | nlword | {ru_ispell,ru_stem} + default_russian | nlpart_hword | {ru_ispell,ru_stem} + default_russian | nlhword | {ru_ispell,ru_stem} + +Notice, I index only russian and english words, no numbers, url, etc. +You may just delete unwanted rows in pg_ts_cfgmap for your configuration, +but I'd recommend just update them setting dict_name to NULL. +For example, to not indexing integers: + +update pg_ts_cfgmap set dict_name=NULL where ts_name='default_russian' +and tok_alias='int'; + +voc=# select token,dict_name,tok_type,tsvector from ts_debug('Do you have +70000 bucks'); + token | dict_name | tok_type | tsvector +--------+---------------------+----------+---------- + Do | {en_ispell,en_stem} | lword | + you | {en_ispell,en_stem} | lword | + have | {en_ispell,en_stem} | lword | + +70000 | | int | + bucks | {en_ispell,en_stem} | lword | 'buck' + +Only 'bucks' gets indexed :) +Hmm, probably I should add this into documentation. + +What about word statistics (# of unique words, for example). + + + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Tue Mar 22 17:02:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EE01A564C6 + for ; + Tue, 22 Mar 2005 17:02:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97372-08 + for ; + Tue, 22 Mar 2005 17:01:57 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 4EDD3569D6 + for ; + Tue, 22 Mar 2005 17:01:56 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7155173; Tue, 22 Mar 2005 09:03:46 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Hannu Krosing +Subject: Re: What needs to be done for real Partitioning? +Date: Tue, 22 Mar 2005 09:01:23 -0800 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <200503191202.38089.josh@agliodbs.com> + <1111422773.4675.33.camel@fuji.krosing.net> +In-Reply-To: <1111422773.4675.33.camel@fuji.krosing.net> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200503220901.23481.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/455 +X-Sequence-Number: 11160 + +Hannu, + +> If you don't get it, contact me as there is a small possibility that I +> know a company interested enough to fund (some) of it :) + +Enough people have been interested in this that if we get our acts together, +we may do it as multi-funded. Easier on our budget ... + +> As these are already discussed in this thread, I'll try to outline a +> method of providing a global index (unique or not) in a way that will +> still make it possible to quickly remove (and not-quite-so-quickly add) +> a partition. + +> To repeat - the global index over partitioned table should have te same +> structure as our current b-tree index, only with added map of 128k index +> partitions to 1G subfiles of (possibly different) tables. This map will +> be quite small - for 1Tb of data it will be only 1k entries - this will +> fit in cache on all modern processors and thus should add only tiny +> slowdown from current direct tid.page/128k method + +I think this is a cool idea. It would need to be linked to clustering, so +that each partition can be an iteration of the clustered index instead of a +specifc # of bytes. But it would give us the "fully automated partitioning" +which is one fork of the two we want. + +Plus I'm keen on any idea that presents an alternative to aping Oracle. + +How difficult would your proposal be to code? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Mar 22 17:30:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AD0DC568E5 + for ; + Tue, 22 Mar 2005 17:30:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08521-01 + for ; + Tue, 22 Mar 2005 17:30:15 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 2432E56714 + for ; + Tue, 22 Mar 2005 17:30:14 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DDnCf-00089n-00; Tue, 22 Mar 2005 12:30:05 -0500 +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: What about utility to calculate planner cost constants? +References: + <200503210951.06044.josh@agliodbs.com> + <87acowcmut.fsf@stark.xeocode.com> + +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 22 Mar 2005 12:30:05 -0500 +Message-ID: <87hdj3bnc2.fsf@stark.xeocode.com> +Lines: 42 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/456 +X-Sequence-Number: 11161 + + +Christopher Browne writes: + +> Are you certain it's a linear system? + +If you just consider the guc parameters that tell postgres how long various +real world operations take (all the *_cost parameters) then it's a linear +system. It has to be. The resulting time is just a sum of the times for some +number of each of these real world operations. + +If you include parameters like the geqo_* parameters or the hypothetical +parameter that controls what selectivity to assume for clauses with unknown +selectivity then no, it wouldn't be. + +But if you assume the estimated row counts are correct and you're just trying +to solve for the parameters to come up with the most accurate cost for the +current hardware then I think you're golden. + +> There might well be some results to be gotten out of a linear +> approximation; the Grand Challenge is to come up with the model in the +> first place... + +Indeed. The model's not perfect now of course, and it'll never really be +perfect since some of the parameters represent operations that aren't always a +consistent cost. But you should be able to solve for the values that result in +the most accurate totals the most often. There may be some tradeoffs (and +therefore new guc variables :) + +PS + +It occurs to me that there's no reason to use the unreliable EXPLAIN counts of +the costs. You may as well account accurately for them and use the actual +values used in performing the query. This means there's no reason to discard +inaccurately estimated data points. + +Moreover, the overhead issue a non-issue. Since you only need the total time, +and the total costs. You would have the overhead of performing lots of +increments on those costs, but you only have to do two gettimeofdays. Once at +the beginning and once at the end. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 17:53:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AA35956525 + for ; + Tue, 22 Mar 2005 17:53:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14353-06 + for ; + Tue, 22 Mar 2005 17:53:08 +0000 (GMT) +Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net + [194.217.242.88]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E8AA56A30 + for ; + Tue, 22 Mar 2005 17:53:07 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-30.mail.demon.net with esmtp (Exim 4.42) + id 1DDnYw-000Iyw-0Y; Tue, 22 Mar 2005 17:53:06 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 95296175D9; Tue, 22 Mar 2005 17:53:05 +0000 (GMT) +Message-ID: <42405B81.20107@archonet.com> +Date: Tue, 22 Mar 2005 17:53:05 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: Josh Berkus , Tambet Matiisen , + pgsql-performance@postgresql.org +Subject: Re: What about utility to calculate planner cost constants? +References: + <200503210951.06044.josh@agliodbs.com> <87acowcmut.fsf@stark.xeocode.com> + <424007E8.1020700@archonet.com> <87y8cfbqlf.fsf@stark.xeocode.com> +In-Reply-To: <87y8cfbqlf.fsf@stark.xeocode.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/457 +X-Sequence-Number: 11162 + +Greg Stark wrote: +> Richard Huxton writes: +> +>>You'd only need to log them if they diverged from expected anyway. That should +>>result in fairly low activity pretty quickly (or we're wasting our time). +>>Should they go to the stats collector rather than logs? +> +> I think you need to log them all. Otherwise when you go to analyze the numbers +> and come up with ideal values you're going to be basing your optimization on a +> skewed subset. + +I can see your thinking, I must admit I was thinking of a more iterative +process: estimate deltas, change config, check, repeat. I'm not +convinced there are "ideal" values with a changing workload - for +example, random_page_cost will presumably vary depending on how much +contention there is for random seeks. Certainly, effective_cache size +could vary. + +> I don't know whether the stats collector or the logs is better suited to this. +> +>>>(Also, currently explain analyze has overhead that makes this impractical. +>>>Ideally it could subtract out its overhead so the solutions would be accurate +>>>enough to be useful) +>> +>>Don't we only need the top-level figures though? There's no need to record +>>timings for each stage, just work completed. +> +> I guess you only need top level values. But you also might want some flag if +> the row counts for any node were far off. In that case perhaps you would want +> to discard the data point. + +I think you'd need to adjust work-estimates by actual-rows / estimated-rows. + +I _was_ trying to think of a clever way of using row mis-estimates to +correct statistics automatically. This was triggered by the discussion a +few weeks ago about hints to the planner and the recent talk about plan +cacheing. Some sort of feedback loop so the planner would know its +estimates were off should be a big win from an ease-of-use point of +view. Didn't look easy to do though :-( + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Mar 22 18:08:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CDD6856A45 + for ; + Tue, 22 Mar 2005 18:08:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18144-07 + for ; + Tue, 22 Mar 2005 18:08:19 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 011C156A0D + for ; + Tue, 22 Mar 2005 18:08:18 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2MI8EDd010503; + Tue, 22 Mar 2005 13:08:14 -0500 (EST) +To: PFC +Cc: "Layet Benjamin" , + pgsql-performance@postgresql.org +Subject: Re: best practices with index on varchar column +In-reply-to: +References: <007301c52ec0$a8f64ec0$9285a8c0@moonfactory.co.jp> + +Comments: In-reply-to PFC + message dated "Tue, 22 Mar 2005 11:49:36 +0100" +Date: Tue, 22 Mar 2005 13:08:14 -0500 +Message-ID: <10502.1111514894@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/458 +X-Sequence-Number: 11163 + +PFC writes: +>> Can I use an index on a varchar column to optimize the SELECT queries +>> that use " column LIKE 'header%' "? + +> Yes + +> Note that if you want case insensitive matching you need to make an index +> on lower(column) and SELECT WHERE lower(column) LIKE 'header%' + +> Locales may bite you. + +Yes. If your database locale is not "C" then the default btree index +behavior does not match up with what LIKE needs. In that case you need +a special index using the appropriate "pattern_ops" opclass, eg + +CREATE INDEX test_index ON test_table (col varchar_pattern_ops); + +or if you want case insensitive matching + +CREATE INDEX test_index ON test_table (lower(col) varchar_pattern_ops); + +and then write the queries with lower() as PFC illustrates. *Don't* use +ILIKE --- it basically can't use indexes at all. + +For more info see +http://www.postgresql.org/docs/8.0/static/indexes-opclass.html + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 22 18:09:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6EF1F52A4F + for ; + Tue, 22 Mar 2005 18:09:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18144-09 + for ; + Tue, 22 Mar 2005 18:08:53 +0000 (GMT) +Received: from felix.adpcl.com (felix.adpcl.com [194.98.137.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E35056741 + for ; + Tue, 22 Mar 2005 18:08:50 +0000 (GMT) +Received: from PCPATRICK (unknown [150.175.11.40]) + by felix.adpcl.com (Postfix) with SMTP id 73FC97806 + for ; + Tue, 22 Mar 2005 19:11:49 +0100 (NFT) +Message-ID: <002601c52f0a$2312a4d0$280baf96@PCPATRICK> +From: "Patrick Vedrines" +To: "performance pgsql" +Subject: CPU 0.1% IOWAIT 99% for decisonnal queries +Date: Tue, 22 Mar 2005 19:08:23 +0100 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0023_01C52F12.84BCCE10" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.163 tagged_above=0 required=5 tests=AWL, HTML_50_60, + HTML_MESSAGE +X-Spam-Level: * +X-Archive-Number: 200503/459 +X-Sequence-Number: 11164 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0023_01C52F12.84BCCE10 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi everyone, + +I'm developping a web decisonnal application based on=20 +-Red Hat 3 ES +-Postgresql 8.0.1=20 +-Dell poweredge 2850, Ram 2Gb, 2 procs, 3 Ghz, 1Mb cache and 4 disks = +ext3 10,000 r/mn +I am alone in the box and there is not any crontab. + +I have 2 databases (A and B) with exactly the same schemas:=20 +-one main table called "aggregate" having no indexes and supporting only = +SELECT statements (loaded one time a month with a new bundle of datas). = +Row size # 200 bytes (50 columns of type char(x) or integer)=20 +-and several small 'reference' tables not shown by the following example = +for clarity reasons. +-Database A : aggregate contains 2,300,000 records ( 500 Mb) +-Database B : aggregate contains 9,000,000 records ( 2 Gb) + +There is no index on the aggregate table since the criterias, their = +number and their scope are freely choosen by the customers. + +The query : + select sum(ca) =20 + from aggregate =20 + where (issue_date >=3D '2004-01' and issue_date <=3D '2004-02' = +); +takes 5s on database A ( 5mn30s* the first time, probably to fill the = +cache)=20 +and 21mn* on database B (whatever it is the first time or not). + +explain shows sequential scan of course: + Aggregate (cost=3D655711.85..655711.85 rows=3D1 width=3D4) + -> Seq Scan on "aggregate" (cost=3D0.00..647411.70 rows=3D3320060 = +width=3D4) + Filter: ((issue_date >=3D '2004-01'::bpchar) AND (issue_date = +<=3D '2004-02'::bpchar)) + +*Here is the 'top' display for these response times: +91 processes: 90 sleeping, 1 running, 0 zombie, 0 stopped +CPU states: cpu user nice system irq softirq iowait idle + total 0,0% 0,0% 0,2% 0,1% 0,0% 48,6% 51,0% + cpu00 0,0% 0,0% 0,0% 0,0% 0,0% 0,0% 100,0% + cpu01 0,0% 0,0% 1,0% 0,0% 0,0% 99,0% 0,0% + cpu02 0,0% 0,0% 0,0% 0,5% 0,0% 0,0% 99,5% + cpu03 0,0% 0,0% 0,0% 0,0% 0,0% 95,5% 4,5% +Mem: 2061424k av, 2043944k used, 17480k free, 0k shrd, 6104k = +buff + 1551692k actv, 172496k in_d, 30452k in_c +Swap: 2096440k av, 0k used, 2096440k free 1792852k = +cached + PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU = +COMMAND +21983 postgres 20 0 9312 9312 8272 D 0,2 0,4 0:00 1 = +postmaster + 1 root 15 0 488 488 432 S 0,0 0,0 0:06 2 init + 2 root RT 0 0 0 0 SW 0,0 0,0 0:00 0 = +migration/0 + +For the 5s response time, the 'top' command shows 0% iowait and 25% cpu. + + +- I guess this is a cache issue but how can I manage/control it ?=20 +Is Postgres managing it's own cache or does it use the OS cache ? + +- Is using the cache is a good approach?=20 +It does not seem to work for large databases : I tryed several different = +values for postgres.conf and /proc/sys/kernel/shmmax without detecting = +any response time enhancement (For example : shared_buffers =3D 190000 , = +sort_mem =3D 4096 , effective_cache_size =3D 37000 and = +kernel/shmmax=3D1200000000 ) +Do I have to upgrade the RAM to 6Gb or/and buy faster HD (of what type?) = +? +Moreover, a query on database B will destroy the cache previously build = +for database A, increasing the response time for the next query on = +database A. And I have in fact 15 databases ! + +- In my case, what should be the best parameters combination between = +postgres.conf and /proc/sys/kernel/shmmax ? + +- is there a way to reduce the size of the "aggregate" table files (1Gb = ++ 1Gb + 1 Gb + 0.8Gb =3D 3.8Gb for the "aggregate" table instead of 2Gb = +=3D 200 * 9,000,000 records) by playing with the data types or others = +parameters (fillfactor ?).=20 +Vacuum (even full) seems to be useless since the aggregate table = +supports only 'copy aggregate from' and 'select'. + +- is it possible to define a sort of RAM filesystem (as it exists in = +DOS/Windows) which I could create and populate my databases into ? = +...since the databases does not support updates for this application. + +Sorry for my naive questions and my poor english but any help or advise = +will be greatly appreciated ! + +Patrick Vedrines + +PS (maybe of interest for some users like me) :=20 +I created a partition on a new similar disk but on the last cylinders = +(near the periphery) and copied the database B into it: the response = +time is 25% faster (i.e. 15mn instead of 21mn). But 15 mn is still too = +long for my customers (5 mn would be nice). + + + + +------=_NextPart_000_0023_01C52F12.84BCCE10 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi everyone,
+
 
+
I'm developping a web decisonnal = +application based=20 +on
+
-Red Hat 3 ES
+
-Postgresql 8.0.1
+
-Dell poweredge 2850, Ram 2Gb, 2 procs, = +3 Ghz, 1Mb=20 +cache and 4 disks ext3 10,000 r/mn
+
I am alone in the box and there is not = +any=20 +crontab.
+
 
+
I have 2 databases (A and B) with = +exactly the same=20 +schemas:
+
-one main table called "aggregate" = +having no=20 +indexes and supporting only SELECT statements (loaded one time a month = +with a=20 +new bundle of datas). Row size # 200 bytes (50 columns of type char(x) = +or=20 +integer) 
+
-and several small 'reference' tables = +not shown by=20 +the following example for clarity reasons.
+
-Database A : aggregate contains = +2,300,000 records=20 +( 500 Mb)
+
+
-Database B : aggregate contains = +9,000,000=20 +records ( 2 Gb)
+
 
+
There is no index on the aggregate = +table since the=20 +criterias, their number and their scope are freely choosen by the=20 +customers.
+
 
+
The query :
+
        = +select =20 +sum(ca) 
        from=20 +aggregate   
       =20 +where  (issue_date >=3D '2004-01' and issue_date <=3D = +'2004-02'=20 +)
;
+
takes 5s on database A ( 5mn30s* the = +first time,=20 +probably to fill the cache)
+
and  21mn* on=20 +database B (whatever it is the first time or not).
+
 
+
explain shows sequential scan of=20 +course:
+
 Aggregate =20 +(cost=3D655711.85..655711.85 rows=3D1 width=3D4)
   = +->  Seq Scan=20 +on "aggregate"  (cost=3D0.00..647411.70 rows=3D3320060=20 +width=3D4)
         Filter:=20 +((issue_date >=3D '2004-01'::bpchar) AND (issue_date <=3D=20 +'2004-02'::bpchar))
+
 
+
*Here is the 'top' display for these = +response=20 +times:
+
91 processes: 90 sleeping, 1 running, = +0 zombie, 0=20 +stopped
CPU states:  cpu    = +user   =20 +nice  system    irq  softirq =20 +iowait   =20 +idle
          =20 +total    0,0%    0,0%   =20 +0,2%   0,1%     0,0%   = +48,6%  =20 +51,0%
          =20 +cpu00    0,0%    0,0%   =20 +0,0%   0,0%     0,0%    = +0,0% =20 +100,0%
          =20 +cpu01    0,0%    0,0%   =20 +1,0%   0,0%     0,0%   = +99,0%
   =20 +0,0%
          =20 +cpu02    0,0%    0,0%   =20 +0,0%   0,5%     0,0%   =20 +0,0%  =20 +99,5%
          =20 +cpu03    0,0%    0,0%   =20 +0,0%   0,0%     0,0%   = +95,5%    = +4,5%
Mem: =20 +2061424k av, 2043944k used,   17480k=20 +free,       0k shrd,    = +6104k=20 +buff
           = +;       =20 +1551692k actv,  172496k in_d,   30452k in_c
Swap: = +2096440k=20 +av,       0k used, 2096440k=20 +free           &nb= +sp;    =20 +1792852k cached
+
  PID = +USER     PRI =20 +NI  SIZE  RSS SHARE STAT %CPU %MEM   TIME CPU=20 +COMMAND
21983 postgres  20   0  9312 9312  = +8272=20 +D     0,2 =20 +0,4   0:00   1 postmaster
    1=20 +root      15   0   = +488 =20 +488   432 S     0,0  0,0  =20 +0:06   2 init
    2=20 +root      RT   = +0    =20 +0    0     0 SW    = +0,0 =20 +0,0   0:00   0 migration/0
+
+
For the 5s response time, the 'top' = +command shows=20 +0% iowait and 25% cpu.
+
 
+
 
+
- I guess this is a cache issue but how = +can I=20 +manage/control it ?
+
Is Postgres managing it's own cache or does it use the OS cache = +?
+
 
+
- Is using the cache is a good approach?
+
It does not seem to work for large databases : I tryed several = +different=20 +values for postgres.conf and /proc/sys/kernel/shmmax without detecting = +any=20 +response time enhancement (For example : shared_buffers =3D = +190000 , sort_mem=20 +=3D 4096 , effective_cache_size =3D 37000 = +and kernel/shmmax=3D1200000000=20 +)
+
Do I have to upgrade the RAM to 6Gb or/and buy faster HD (of = +what=20 +type?) ?
+
Moreover, a query on database B will destroy the cache previously = +build for=20 +database A, increasing the response time for the next query on database = +A. And I=20 +have in fact 15 databases !
+
 
+
+
- In my case, what should be the best parameters combination = +between=20 +postgres.conf and /proc/sys/kernel/shmmax ?
+
 
+
- is there a way to reduce the size of the "aggregate" table files = +(1Gb +=20 +1Gb + 1 Gb + 0.8Gb =3D 3.8Gb for the "aggregate" table instead of 2Gb = +=3D 200 *=20 +9,000,000 records) by playing with the data types or others parameters=20 +(fillfactor ?).
+
Vacuum (even full) seems to be useless since the aggregate table = +supports=20 +only 'copy aggregate from' and 'select'.
+
 
+
- is it possible to define a sort of RAM filesystem (as = +it exists=20 +in DOS/Windows) which I could create and populate my databases into=20 +? ...since the databases does not support updates for this=20 +application.
+
 
+
Sorry for my naive questions and my poor english but any help or = +advise=20 +will be greatly appreciated !
+
 
+
Patrick Vedrines
+
 
+
PS (maybe of interest for some users like me) :
+
I created a partition on a new similar disk but on the last = +cylinders (near=20 +the periphery) and copied the database B into it: the response = +time is 25%=20 +faster (i.e. 15mn instead of 21mn). But 15 mn is still too long for my = +customers=20 +(5 mn would be nice).
+
 
+
 
+
 
+
 
+ +------=_NextPart_000_0023_01C52F12.84BCCE10-- + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 18:29:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A4980565FF + for ; + Tue, 22 Mar 2005 18:29:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25186-09 + for ; + Tue, 22 Mar 2005 18:29:09 +0000 (GMT) +Received: from planae.com.br (nat.planae.com.br [200.210.129.190]) + by svr1.postgresql.org (Postfix) with SMTP id DF90756002 + for ; + Tue, 22 Mar 2005 18:29:05 +0000 (GMT) +Received: (qmail 43799 invoked by uid 1004); 22 Mar 2005 18:28:55 -0000 +Received: from 192.168.0.215 by mercurio.planae.com.br (envelope-from + , uid 0) with qmail-scanner-1.23 + (uvscan: v4.3.20/v4451. Clear:RC:1(192.168.0.215):. + Processed in 1.65102 secs); 22 Mar 2005 18:28:55 -0000 +X-Qmail-Scanner-Mail-From: gfnobrega@planae.com.br via mercurio.planae.com.br +X-Qmail-Scanner: 1.23 (Clear:RC:1(192.168.0.215):. Processed in 1.65102 secs) +Received: from unknown (HELO ?192.168.0.215?) (gfnobrega@192.168.0.215) + by 192.168.0.3 with SMTP; 22 Mar 2005 18:28:53 -0000 +Message-ID: <424063BC.3050206@planae.com.br> +Date: Tue, 22 Mar 2005 15:28:12 -0300 +From: Gustavo F Nobrega - Planae +User-Agent: Mozilla Thunderbird 0.8 (X11/20041020) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Patrick Vedrines +Cc: performance pgsql +Subject: Re: CPU 0.1% IOWAIT 99% for decisonnal queries +References: <002601c52f0a$2312a4d0$280baf96@PCPATRICK> +In-Reply-To: <002601c52f0a$2312a4d0$280baf96@PCPATRICK> +Content-Type: multipart/alternative; + boundary="------------090702000000040404020104" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.089 tagged_above=0 required=5 tests=AWL, HTML_50_60, + HTML_MESSAGE, HTML_TITLE_EMPTY, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/460 +X-Sequence-Number: 11165 + +This is a multi-part message in MIME format. +--------------090702000000040404020104 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit + +Hi Patrick, + + How is configured your disk array? Do you have a Perc 4? + +Tip: Use reiserfs instead ext3, raid 0+1 and deadline I/O scheduler in +kernel linux 2.6 + +Atenciosamente, + +Gustavo Franklin N�brega +Infra-Estrutura e Banco de Dados +Planae Tecnologia da Informa��o +(+55) 14 3224-3066 Ramal 209 +www.planae.com.br + + + +Patrick Vedrines wrote: + +> Hi everyone, +> +> I'm developping a web decisonnal application based on +> -Red Hat 3 ES +> -Postgresql 8.0.1 +> -Dell poweredge 2850, Ram 2Gb, 2 procs, 3 Ghz, 1Mb cache and 4 disks +> ext3 10,000 r/mn +> I am alone in the box and there is not any crontab. +> +> I have 2 databases (A and B) with exactly the same schemas: +> -one main table called "aggregate" having no indexes and supporting +> only SELECT statements (loaded one time a month with a new bundle of +> datas). Row size # 200 bytes (50 columns of type char(x) or integer) +> -and several small 'reference' tables not shown by the following +> example for clarity reasons. +> -Database A : aggregate contains 2,300,000 records ( 500 Mb) +> -Database B : aggregate contains 9,000,000 records ( 2 Gb) +> +> There is no index on the aggregate table since the criterias, their +> number and their scope are freely choosen by the customers. +> +> The query : +> select sum(ca) +> from aggregate +> where (issue_date >= '2004-01' and issue_date <= '2004-02' ); +> takes 5s on database A ( 5mn30s* the first time, probably to fill the +> cache) +> and 21mn* on database B (whatever it is the first time or not). +> +> explain shows sequential scan of course: +> Aggregate (cost=655711.85..655711.85 rows=1 width=4) +> -> Seq Scan on "aggregate" (cost=0.00..647411.70 rows=3320060 +> width=4) +> Filter: ((issue_date >= '2004-01'::bpchar) AND (issue_date <= +> '2004-02'::bpchar)) +> +> *Here is the 'top' display for these response times: +> 91 processes: 90 sleeping, 1 running, 0 zombie, 0 stopped +> CPU states: cpu user nice system irq softirq iowait idle +> total 0,0% 0,0% 0,2% 0,1% 0,0% 48,6% 51,0% +> cpu00 0,0% 0,0% 0,0% 0,0% 0,0% 0,0% 100,0% +> cpu01 0,0% 0,0% 1,0% 0,0% 0,0% *99,0%* 0,0% +> cpu02 0,0% 0,0% 0,0% 0,5% 0,0% 0,0% 99,5% +> cpu03 0,0% 0,0% 0,0% 0,0% 0,0% *95,5%* 4,5% +> Mem: 2061424k av, 2043944k used, 17480k free, 0k shrd, +> 6104k buff +> 1551692k actv, 172496k in_d, 30452k in_c +> Swap: 2096440k av, 0k used, 2096440k free +> 1792852k cached +> PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND +> 21983 postgres 20 0 9312 9312 8272 D *0,2* 0,4 0:00 1 +> postmaster +> 1 root 15 0 488 488 432 S 0,0 0,0 0:06 2 init +> 2 root RT 0 0 0 0 SW 0,0 0,0 0:00 0 +> migration/0 +> For the 5s response time, the 'top' command shows 0% iowait and 25% cpu. +> +> +> - I guess this is a cache issue but how can I manage/control it ? +> Is Postgres managing it's own cache or does it use the OS cache ? +> +> - Is using the cache is a good approach? +> It does not seem to work for large databases : I tryed several +> different values for postgres.conf and /proc/sys/kernel/shmmax without +> detecting any response time enhancement (For example : shared_buffers +> = 190000 , sort_mem = 4096 , effective_cache_size = 37000 +> and kernel/shmmax=1200000000 ) +> Do I have to upgrade the RAM to 6Gb or/and buy faster HD (of what type?) ? +> Moreover, a query on database B will destroy the cache previously +> build for database A, increasing the response time for the next query +> on database A. And I have in fact 15 databases ! +> +> - In my case, what should be the best parameters combination between +> postgres.conf and /proc/sys/kernel/shmmax ? +> +> - is there a way to reduce the size of the "aggregate" table files +> (1Gb + 1Gb + 1 Gb + 0.8Gb = 3.8Gb for the "aggregate" table instead of +> 2Gb = 200 * 9,000,000 records) by playing with the data types or +> others parameters (fillfactor ?). +> Vacuum (even full) seems to be useless since the aggregate table +> supports only 'copy aggregate from' and 'select'. +> +> - is it possible to define a sort of RAM filesystem (as it exists in +> DOS/Windows) which I could create and populate my databases into +> ? ...since the databases does not support updates for this application. +> +> Sorry for my naive questions and my poor english but any help or +> advise will be greatly appreciated ! +> +> Patrick Vedrines +> +> PS (maybe of interest for some users like me) : +> I created a partition on a new similar disk but on the last cylinders +> (near the periphery) and copied the database B into it: the response +> time is 25% faster (i.e. 15mn instead of 21mn). But 15 mn is still too +> long for my customers (5 mn would be nice). +> +> +> +> + + +--------------090702000000040404020104 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + + +Hi Patrick,
+
+    How is configured your disk array? Do you have a Perc 4?
+
+Tip: Use reiserfs instead ext3, raid 0+1 and deadline I/O scheduler in +kernel linux 2.6
+
Atenciosamente,
+
+Gustavo Franklin Nóbrega
+Infra-Estrutura e Banco de Dados
+Planae Tecnologia da Informação
+(+55) 14 3224-3066 Ramal 209
+www.planae.com.br
+
+
+
+Patrick Vedrines wrote: +
+ + + +
Hi everyone,
+
 
+
I'm developping a web decisonnal +application based on
+
-Red Hat 3 ES
+
-Postgresql 8.0.1
+
-Dell poweredge 2850, Ram 2Gb, 2 +procs, 3 Ghz, 1Mb cache and 4 disks ext3 10,000 r/mn
+
I am alone in the box and there is +not any crontab.
+
 
+
I have 2 databases (A and B) with +exactly the same schemas:
+
-one main table called "aggregate" +having no indexes and supporting only SELECT statements (loaded one +time a month with a new bundle of datas). Row size # 200 bytes (50 +columns of type char(x) or integer) 
+
-and several small 'reference' +tables not shown by the following example for clarity reasons.
+
-Database A : aggregate contains +2,300,000 records ( 500 Mb)
+
+
-Database B : aggregate contains +9,000,000 records ( 2 Gb)
+
+
 
+
There is no index on the aggregate +table since the criterias, their number and their scope are freely +choosen by the customers.
+
 
+
The query :
+
        select  sum(ca) 
+        from aggregate   
+        where  (issue_date >= '2004-01' and issue_date <= +'2004-02' )
;
+
takes 5s on database A ( 5mn30s* the +first time, probably to fill the cache)
+
and  21mn* on database B (whatever it is the first time or not).
+
 
+
explain shows sequential scan of +course:
+
 Aggregate  +(cost=655711.85..655711.85 rows=1 width=4)
+   ->  Seq Scan on "aggregate"  (cost=0.00..647411.70 rows=3320060 +width=4)
+         Filter: ((issue_date >= '2004-01'::bpchar) AND (issue_date +<= '2004-02'::bpchar))
+
 
+
*Here is the 'top' display for these +response times:
+
91 processes: 90 sleeping, 1 +running, 0 zombie, 0 stopped
+CPU states:  cpu    user    nice  system    irq  softirq  iowait    idle
+           total    0,0%    0,0%    0,2%   0,1%     0,0%   48,6%   51,0%
+           cpu00    0,0%    0,0%    0,0%   0,0%     0,0%    0,0%  100,0%
+           cpu01    0,0%    0,0%    1,0%   0,0%     0,0%   99,0%    0,0%
+           cpu02    0,0%    0,0%    0,0%   0,5%     0,0%    0,0%   99,5%
+           cpu03    0,0%    0,0%    0,0%   0,0%     0,0%   95,5%    4,5%
+Mem:  2061424k av, 2043944k used,   17480k free,       0k shrd,    +6104k buff
+                   1551692k actv,  172496k in_d,   30452k in_c
+Swap: 2096440k av,       0k used, 2096440k free                 +1792852k cached
+
  PID USER     PRI  NI  SIZE  RSS +SHARE STAT %CPU %MEM   TIME CPU COMMAND
+21983 postgres  20   0  9312 9312  8272 D     0,2  0,4   0:00   1 postmaster
+    1 root      15   0   488  488   432 S     0,0  0,0   0:06   2 init
+    2 root      RT   0     0    0     0 SW    0,0  0,0   0:00   0 +migration/0
+
+
+
For the 5s response time, the 'top' +command shows 0% iowait and 25% cpu.
+
 
+
 
+
- I guess this is a cache issue but +how can I manage/control it ?
+
Is Postgres managing it's own cache or does it use the OS cache ?
+
 
+
- Is using the cache is a good approach?
+
It does not seem to work for large databases : I tryed several +different values for postgres.conf and /proc/sys/kernel/shmmax without +detecting any response time enhancement (For example : shared_buffers = +190000 , sort_mem = 4096 , effective_cache_size = 37000 +and kernel/shmmax=1200000000 )
+
Do I have to upgrade the RAM to 6Gb or/and buy faster HD (of +what type?) ?
+
Moreover, a query on database B will destroy the cache +previously build for database A, increasing the response time for the +next query on database A. And I have in fact 15 databases !
+
 
+
+
- In my case, what should be the best parameters combination +between postgres.conf and /proc/sys/kernel/shmmax ?
+
+
 
+
- is there a way to reduce the size of the "aggregate" table +files (1Gb + 1Gb + 1 Gb + 0.8Gb = 3.8Gb for the "aggregate" table +instead of 2Gb = 200 * 9,000,000 records) by playing with the data +types or others parameters (fillfactor ?).
+
Vacuum (even full) seems to be useless since the aggregate table +supports only 'copy aggregate from' and 'select'.
+
 
+
- is it possible to define a sort of RAM filesystem (as +it exists in DOS/Windows) which I could create and populate my +databases into ? ...since the databases does not support updates for +this application.
+
 
+
Sorry for my naive questions and my poor english but any help or +advise will be greatly appreciated !
+
 
+
Patrick Vedrines
+
 
+
PS (maybe of interest for some users like me) :
+
I created a partition on a new similar disk but on the last +cylinders (near the periphery) and copied the database B into it: the +response time is 25% faster (i.e. 15mn instead of 21mn). But 15 mn is +still too long for my customers (5 mn would be nice).
+
 
+
 
+
 
+
+
 
+
+ + + +--------------090702000000040404020104-- + +From pgsql-performance-owner@postgresql.org Tue Mar 22 18:34:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DCB995664E + for ; + Tue, 22 Mar 2005 18:34:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27355-07 + for ; + Tue, 22 Mar 2005 18:34:41 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id D484B552D6 + for ; + Tue, 22 Mar 2005 18:34:40 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2MIYbsc010760; + Tue, 22 Mar 2005 13:34:39 -0500 (EST) +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: What about utility to calculate planner cost constants? +In-reply-to: +References: + <200503210951.06044.josh@agliodbs.com> + <87acowcmut.fsf@stark.xeocode.com> + +Comments: In-reply-to Christopher Browne + message dated "Tue, 22 Mar 2005 08:09:40 -0500" +Date: Tue, 22 Mar 2005 13:34:37 -0500 +Message-ID: <10759.1111516477@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/461 +X-Sequence-Number: 11166 + +Christopher Browne writes: +> Martha Stewart called it a Good Thing when gsstark@mit.edu (Greg Stark) wrote: +>> It's just a linear algebra problem with a bunch of independent +>> variables and a system of equations. Solving for values for all of +>> them is a straightforward problem. + +> Are you certain it's a linear system? I'm not. + +I'm quite certain it isn't a linear system, because the planner's cost +models include nonlinear equations. + +While I don't have a whole lot of hard evidence to back this up, my +belief is that our worst problems stem not from bad parameter values +but from wrong models. In particular we *know* that the cost model for +nestloop-inner-indexscan joins is wrong, because it doesn't account for +cacheing effects across repeated scans. There are some other obvious +weak spots as well. It could be argued that we ought to allow the +system to assume index cacheing even for standalone queries, on the +grounds that if you are doing a query often enough to care about it, +there was probably a recent use of the same query that pulled in the +upper index levels. The current cost models all assume starting from +ground zero with empty caches for each query, and that is surely not +reflective of many real-world cases. + +I've looked at fixing this a couple times, but so far my attempts +to devise a more believable index access cost estimator have come +out with numbers higher than the current estimates ... not the +direction we want it to go :-( + +Anyway, I see little point in trying to build an automatic parameter +optimizer until we have cost models whose parameters are more stable +than the current ones. + + regards, tom lane + +From pgsql-admin-owner@postgresql.org Tue Mar 22 18:48:41 2005 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F1A67566CF + for ; + Tue, 22 Mar 2005 18:48:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32118-10 + for ; + Tue, 22 Mar 2005 18:48:32 +0000 (GMT) +Received: from mail.astudios.com (ns1.astudios.com [66.49.77.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 055CE566C7 + for ; Tue, 22 Mar 2005 18:48:30 +0000 (GMT) +thread-index: AcUvEBGQBmW61W/tTd2KgI4h2pONmA== +Received: from [10.4.13.50] ([66.194.26.150]) by mail.astudios.com with + Microsoft SMTPSVC(6.0.3790.211); Tue, 22 Mar 2005 13:50:50 -0500 +Content-Class: urn:content-classes:message +Importance: normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181 +Message-ID: <424068B0.8090101@sermonaudio.com> +Date: Tue, 22 Mar 2005 13:49:20 -0500 +From: "Chris Hoover" +User-Agent: Mozilla Thunderbird 0.8 (X11/20040913) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Sabio - PSQL" +Cc: "PostgreSQL Admin" +Subject: Re: Too slow +References: <42402A4B.70703@ceroriesgo.co.cr> +In-Reply-To: <42402A4B.70703@ceroriesgo.co.cr> +Content-Type: text/plain; + format=flowed; + charset="ISO-8859-1" +Content-Transfer-Encoding: quoted-printable +X-OriginalArrivalTime: 22 Mar 2005 18:50:51.0015 (UTC) + FILETIME=[1189C170:01C52F10] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/352 +X-Sequence-Number: 16850 + +Sabio - PSQL wrote: + +> How can I improve speed on my queries. For example this query takes=20 +> one day executing itself and it has not finalized !!! +> "create table tmp_partes as select * from partes where identificacion=20 +> not in (select cedula from sujetos)" +> +> partes have 1888000 rows, an index on identificacion +> sujetos have 5500000 rows, an index on cedula +> +> +> +> +> +> ---------------------------(end of = +broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +> +> +> +try create table tmp_partes as select * from partes where not exists=20 +(select cedula from sujetos where cedula =3D partes.identificacion); + +The "not in (subselect)" is very slow in postgresql. + +HTH, + +chris + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 18:51:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 67830566C7 + for ; + Tue, 22 Mar 2005 18:50:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33009-08 + for ; + Tue, 22 Mar 2005 18:50:31 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id F3DA55654C + for ; + Tue, 22 Mar 2005 18:50:30 +0000 (GMT) +Received: (qmail 28504 invoked from network); 22 Mar 2005 18:50:30 -0000 +Received: from w080.z064003242.bna-tn.dsl.cnc.net (HELO ?192.168.1.22?) + (64.3.242.80) by 0 with SMTP; 22 Mar 2005 18:50:30 -0000 +In-Reply-To: <42402A4B.70703@ceroriesgo.co.cr> +References: <42402A4B.70703@ceroriesgo.co.cr> +Mime-Version: 1.0 (Apple Message framework v619.2) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <8a80660373bf9494ae545525a4e60bcf@sitening.com> +Content-Transfer-Encoding: 7bit +Cc: PgSQL - Performance +From: Thomas F.O'Connell +Subject: Re: [ADMIN] Too slow +Date: Tue, 22 Mar 2005 12:50:29 -0600 +To: Sabio - PSQL +X-Mailer: Apple Mail (2.619.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/462 +X-Sequence-Number: 11167 + +Please post the results of that query as run through EXPLAIN ANALYZE. + +Also, I'm going to reply to this on pgsql-performance, which is +probably where it better belongs. + +-tfo + +-- +Thomas F. O'Connell +Co-Founder, Information Architect +Sitening, LLC +http://www.sitening.com/ +110 30th Avenue North, Suite 6 +Nashville, TN 37203-6320 +615-260-0005 + +On Mar 22, 2005, at 8:23 AM, Sabio - PSQL wrote: + +> How can I improve speed on my queries. For example this query takes +> one day executing itself and it has not finalized !!! +> "create table tmp_partes as select * from partes where identificacion +> not in (select cedula from sujetos)" +> +> partes have 1888000 rows, an index on identificacion +> sujetos have 5500000 rows, an index on cedula + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 18:57:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5564854D24 + for ; + Tue, 22 Mar 2005 18:57:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36982-04 + for ; + Tue, 22 Mar 2005 18:57:33 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C21AD566D1 + for ; + Tue, 22 Mar 2005 18:57:32 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2MIuAlQ010951; + Tue, 22 Mar 2005 13:56:10 -0500 (EST) +To: Greg Stark +Cc: Christopher Browne , + pgsql-performance@postgresql.org +Subject: Re: What about utility to calculate planner cost constants? +In-reply-to: <87hdj3bnc2.fsf@stark.xeocode.com> +References: + <200503210951.06044.josh@agliodbs.com> + <87acowcmut.fsf@stark.xeocode.com> + + <87hdj3bnc2.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "22 Mar 2005 12:30:05 -0500" +Date: Tue, 22 Mar 2005 13:56:10 -0500 +Message-ID: <10950.1111517770@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/464 +X-Sequence-Number: 11169 + +Greg Stark writes: +> Christopher Browne writes: +>> Are you certain it's a linear system? + +> If you just consider the guc parameters that tell postgres how long various +> real world operations take (all the *_cost parameters) then it's a linear +> system. It has to be. + +No it doesn't. Think caching effects for instance. We do have cache +effects in the cost models, even though they are wrong as per my nearby +rant... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 22 18:57:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DD19C52A62 + for ; + Tue, 22 Mar 2005 18:57:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36579-05 + for ; + Tue, 22 Mar 2005 18:57:38 +0000 (GMT) +Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net + [194.217.242.88]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D13B52A4F + for ; + Tue, 22 Mar 2005 18:57:37 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-30.mail.demon.net with esmtp (Exim 4.42) + id 1DDoZN-0001Om-02; Tue, 22 Mar 2005 18:57:38 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 0047A175F1; Tue, 22 Mar 2005 18:57:35 +0000 (GMT) +Message-ID: <42406A9F.9040404@archonet.com> +Date: Tue, 22 Mar 2005 18:57:35 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Patrick Vedrines +Cc: performance pgsql +Subject: Re: CPU 0.1% IOWAIT 99% for decisonnal queries +References: <002601c52f0a$2312a4d0$280baf96@PCPATRICK> +In-Reply-To: <002601c52f0a$2312a4d0$280baf96@PCPATRICK> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/463 +X-Sequence-Number: 11168 + +Patrick Vedrines wrote: +> Hi everyone, +> +> I'm developping a web decisonnal application based on -Red Hat 3 ES +> -Postgresql 8.0.1 -Dell poweredge 2850, Ram 2Gb, 2 procs, 3 Ghz, 1Mb +> cache and 4 disks ext3 10,000 r/mn I am alone in the box and there is +> not any crontab. +> +> I have 2 databases (A and B) with exactly the same schemas: -one main +> table called "aggregate" having no indexes and supporting only SELECT +> statements (loaded one time a month with a new bundle of datas). + +Perhaps look into clustering the tables. + + > Row +> size # 200 bytes (50 columns of type char(x) or integer) -and several +> small 'reference' tables not shown by the following example for +> clarity reasons. -Database A : aggregate contains 2,300,000 records ( +> 500 Mb) -Database B : aggregate contains 9,000,000 records ( 2 Gb) +> +> There is no index on the aggregate table since the criterias, their +> number and their scope are freely choosen by the customers. + +Hmm... not convinced this is a good idea. + +> The query : select sum(ca) from aggregate where (issue_date >= +> '2004-01' and issue_date <= '2004-02' ); takes 5s on database A ( +> 5mn30s* the first time, probably to fill the cache) and 21mn* on +> database B (whatever it is the first time or not). + +Because A fits in the cache and B doesn't. + +> - I guess this is a cache issue but how can I manage/control it ? Is +> Postgres managing it's own cache or does it use the OS cache ? + +Both + +> - Is using the cache is a good approach? It does not seem to work for +> large databases : I tryed several different values for postgres.conf +> and /proc/sys/kernel/shmmax without detecting any response time +> enhancement (For example : shared_buffers = 190000 , sort_mem = 4096 +> , effective_cache_size = 37000 and kernel/shmmax=1200000000 ) Do I +> have to upgrade the RAM to 6Gb or/and buy faster HD (of what type?) ? +> Moreover, a query on database B will destroy the cache previously +> build for database A, increasing the response time for the next query +> on database A. And I have in fact 15 databases ! + +If you don't have any indexes and the table isn't clustered then PG has +no choice but to scan the entire table for every query. As you note, +that's going to destroy your cache. You can increase the RAM but sooner +or later, you'll get the same problem. + +> - In my case, what should be the best parameters combination between +> postgres.conf and /proc/sys/kernel/shmmax ? + +http://www.varlena.com/varlena/GeneralBits/Tidbits/index.php +http://www.powerpostgresql.com/PerfList + +> - is there a way to reduce the size of the "aggregate" table files +> (1Gb + 1Gb + 1 Gb + 0.8Gb = 3.8Gb for the "aggregate" table instead +> of 2Gb = 200 * 9,000,000 records) by playing with the data types or +> others parameters (fillfactor ?). Vacuum (even full) seems to be +> useless since the aggregate table supports only 'copy aggregate from' +> and 'select'. + +You can replace int4 with int2 and so on (where possible) but that will +only delay problems. + +> - is it possible to define a sort of RAM filesystem (as it exists in +> DOS/Windows) which I could create and populate my databases into ? +> ...since the databases does not support updates for this application. + +Won't help - your cache is already doing that. Some things you can do +(in order of effort) + +1. Cluster the large tables +2. Analyse your customers' queries and try a couple of indexes - some +choices will be more common than others. +3. Split your tables into two - common fields, uncommon fields, that way +filtering on the common fields might take less space. +4. Split your tables by date, one table per month or year. Then re-write +your customers' queries on-the-fly to select from the right table. Will +only help with queries on date of course. +5. Place each database on its own machine or virtual machine so they +don't interfere with each other. + +I'd start with items 1,2 and see if that helps though. + +PS - it might make sense to have an unusually large shared_mem for PG, +but I'm not familiar enough with the changes in the cache handling in +8.0 to say for sure. +PPS - there are more changes coming for 8.1, but I know even less about +those. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-admin-owner@postgresql.org Tue Mar 22 19:10:12 2005 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D73052D42 + for ; + Tue, 22 Mar 2005 19:10:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41709-01 + for ; + Tue, 22 Mar 2005 19:10:08 +0000 (GMT) +Received: from ceroriesgo.co.cr (unknown [200.91.71.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BCAC52A62 + for ; Tue, 22 Mar 2005 19:10:07 +0000 (GMT) +Received: from [192.168.0.110] by ceroriesgo.co.cr (MDaemon.PRO.v7.2.3.R) + with ESMTP id md50000015516.msg + for ; Tue, 22 Mar 2005 13:10:41 -0800 +Message-ID: <42406D90.7090501@ceroriesgo.co.cr> +Date: Tue, 22 Mar 2005 13:10:08 -0600 +From: Sabio - PSQL +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PostgreSQL Admin +Subject: Re: Too slow +References: <42402A4B.70703@ceroriesgo.co.cr> + <8a80660373bf9494ae545525a4e60bcf@sitening.com> +In-Reply-To: <8a80660373bf9494ae545525a4e60bcf@sitening.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Authenticated-Sender: slopez@ceroriesgo.co.cr +X-Spam-Processed: ceroriesgo.co.cr, Tue, 22 Mar 2005 13:10:41 -0800 + (not processed: message from valid local sender) +X-MDRemoteIP: 192.168.0.110 +X-Return-Path: slopez_pg@ceroriesgo.co.cr +X-MDaemon-Deliver-To: pgsql-admin@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.187 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/354 +X-Sequence-Number: 16852 + +WITH: select * from partes where cedula not in (select cedula from sujetos) +Seq Scan on partes (cost=0.00..168063925339.69 rows=953831 width=109) + Filter: (NOT (subplan)) + SubPlan + -> Seq Scan on sujetos (cost=0.00..162348.43 rows=5540143 width=15) + +WITH: select * from partes where not exists (select cedula from sujetos +where cedula=partes.cedula) +Seq Scan on partes (cost=0.00..7373076.94 rows=953831 width=109) + Filter: (NOT (subplan)) + SubPlan + -> Index Scan using sujetos_pkey on sujetos (cost=0.00..3.84 +rows=1 width=15) + Index Cond: ((cedula)::text = ($0)::text) + +Thomas F. O'Connell wrote: + +> Please post the results of that query as run through EXPLAIN ANALYZE. +> +> Also, I'm going to reply to this on pgsql-performance, which is +> probably where it better belongs. +> +> -tfo +> +> -- +> Thomas F. O'Connell +> Co-Founder, Information Architect +> Sitening, LLC +> http://www.sitening.com/ +> 110 30th Avenue North, Suite 6 +> Nashville, TN 37203-6320 +> 615-260-0005 +> +> On Mar 22, 2005, at 8:23 AM, Sabio - PSQL wrote: +> +>> How can I improve speed on my queries. For example this query takes +>> one day executing itself and it has not finalized !!! +>> "create table tmp_partes as select * from partes where identificacion +>> not in (select cedula from sujetos)" +>> +>> partes have 1888000 rows, an index on identificacion +>> sujetos have 5500000 rows, an index on cedula +> +> +> +> + + + +From pgsql-admin-owner@postgresql.org Tue Mar 22 19:15:02 2005 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 63C0656793 + for ; + Tue, 22 Mar 2005 19:14:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41032-08 + for ; + Tue, 22 Mar 2005 19:14:41 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id CE88C56795 + for ; Tue, 22 Mar 2005 19:14:40 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2MJEfo6011071; + Tue, 22 Mar 2005 14:14:41 -0500 (EST) +To: "Chris Hoover" +Cc: "Sabio - PSQL" , + "PostgreSQL Admin" +Subject: Re: Too slow +In-reply-to: <424068B0.8090101@sermonaudio.com> +References: <42402A4B.70703@ceroriesgo.co.cr> + <424068B0.8090101@sermonaudio.com> +Comments: In-reply-to "Chris Hoover" + message dated "Tue, 22 Mar 2005 13:49:20 -0500" +Date: Tue, 22 Mar 2005 14:14:41 -0500 +Message-ID: <11070.1111518881@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/356 +X-Sequence-Number: 16854 + +"Chris Hoover" writes: +> The "not in (subselect)" is very slow in postgresql. + +It's OK as long as the subselect result is small enough to hash, but +with 5500000 rows that's not going to happen :-(. + +Another issue is that if there are any NULLs in the subselect then you +will probably not like the results. They are correct per spec but not +very intuitive. + +Personally I'd try ye olde outer join trick: + +select partes.* + from partes left join sujetos on (identificacion = cedula) + where cedula is null; + +A merge join on this would likely be the most effective solution. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 22 19:36:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9AD6F56711 + for ; + Tue, 22 Mar 2005 19:36:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49878-07 + for ; + Tue, 22 Mar 2005 19:36:49 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.203]) + by svr1.postgresql.org (Postfix) with ESMTP id 2ECBF566EE + for ; + Tue, 22 Mar 2005 19:36:46 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 70so1946181wra + for ; + Tue, 22 Mar 2005 11:36:47 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=bkhaXP8whBv38ZRlj4CljTvyuZp+v22aZdnXxnoVJMoMG6iM6Bz1+gfJqW5iPJSBP24TMwF8yc9hl7gHvDsbL80dz2zgM+MTYt0ozT9KAIiROo+ybh3C7RJ3VpgQ9daf4oawjYyejMz52WEMsYY44ad0hgq2p8Frw9syOvzq97s= +Received: by 10.54.51.64 with SMTP id y64mr594996wry; + Tue, 22 Mar 2005 11:36:46 -0800 (PST) +Received: by 10.54.86.16 with HTTP; Tue, 22 Mar 2005 11:36:46 -0800 (PST) +Message-ID: <33c6269f05032211366ce4563b@mail.gmail.com> +Date: Tue, 22 Mar 2005 14:36:46 -0500 +From: Alex Turner +Reply-To: Alex Turner +To: "Joshua D. Drake" +Subject: Re: Planner issue +Cc: "pgsql-performance@postgresql.org" +In-Reply-To: <42404663.2010504@commandprompt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +References: <33c6269f05032206565ca4f9f1@mail.gmail.com> + <42404663.2010504@commandprompt.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.24 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/465 +X-Sequence-Number: 11170 + +This helps a bit when I set it to 1000 - but it's still pretty bad: + +I will use an index 220-300, but not 200-300. + +Alex + +trendmls=# explain analyze select listnum from propmain where +listprice<=300000 and listprice>=200000; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------- + Seq Scan on propmain (cost=0.00..15517.56 rows=6842 width=4) (actual +time=0.039..239.760 rows=6847 loops=1) + Filter: ((listprice <= 300000::numeric) AND (listprice >= 200000::numeric)) + Total runtime: 244.301 ms +(3 rows) + +trendmls=# set enable_seqscan=off; +SET +trendmls=# explain analyze select listnum from propmain where +listprice<=300000 and listprice>=200000; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ + Index Scan using propmain_listprice_i on propmain +(cost=0.00..22395.95 rows=6842 width=4) (actual time=0.084..25.751 +rows=6847 loops=1) + Index Cond: ((listprice <= 300000::numeric) AND (listprice >= +200000::numeric)) + Total runtime: 30.193 ms +(3 rows) + +trendmls=# + + + +On Tue, 22 Mar 2005 08:22:59 -0800, Joshua D. Drake + wrote: +> Alex Turner wrote: +> +> >I get the following output from explain analyze on a certain subset of +> >a large query I'm doing. +> > +> > +> > +> Try increases the statistics on the listprice column with alter +> table and then re-run analyze. +> +> alter table foo alter column set statistics +> +> Sincerely, +> +> Joshua D. Drake +> +> +> >>From the looks of it, I need to increase how often postgres uses an +> >index over a seq scan, but I'm not sure how to do that. I looked +> >through the run-time configuration docs on the website, but didn't see +> >anything pertaining to index selectivity. +> > +> >Thanks, +> > +> >Alex Turner +> >netEconomist +> > +> > +> >trendmls=# explain analyze select listnum from propmain where +> >listprice<=300000 and listprice>=220000; +> > QUERY PLAN +> >-------------------------------------------------------------------------------------------------------------- +> > Seq Scan on propmain (cost=0.00..15556.05 rows=6228 width=4) (actual +> >time=0.093..506.730 rows=5671 loops=1) +> > Filter: ((listprice <= 300000::numeric) AND (listprice >= 220000::numeric)) +> > Total runtime: 510.482 ms +> >(3 rows) +> > +> >trendmls=# explain analyze select listnum from propmain where +> >listprice<=300000 and listprice>=250000; +> > QUERY PLAN +> >------------------------------------------------------------------------------------------------------------------------------------------ +> > Index Scan using propmain_listprice_i on propmain +> >(cost=0.00..12578.65 rows=3486 width=4) (actual time=0.103..16.418 +> >rows=3440 loops=1) +> > Index Cond: ((listprice <= 300000::numeric) AND (listprice >= +> >250000::numeric)) +> > Total runtime: 18.528 ms +> >(3 rows) +> > +> >---------------------------(end of broadcast)--------------------------- +> >TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +> > +> > +> +> -- +> Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC +> Postgresql support, programming shared hosting and dedicated hosting. +> +1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com +> PostgreSQL Replicator -- production quality replication for PostgreSQL +> +> +> + +From pgsql-performance-owner@postgresql.org Tue Mar 22 20:07:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 52D9F56814 + for ; + Tue, 22 Mar 2005 20:07:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60514-05 + for ; + Tue, 22 Mar 2005 20:07:43 +0000 (GMT) +Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) + by svr1.postgresql.org (Postfix) with ESMTP id 6C974567B2 + for ; + Tue, 22 Mar 2005 20:07:41 +0000 (GMT) +Received: from gnari ([157.157.159.208] [157.157.159.208]) by quasar.skima.is + with ESMTP; Tue, 22 Mar 2005 20:07:40 Z +Subject: Re: Planner issue +From: Ragnar =?ISO-8859-1?Q?Hafsta=F0?= +To: Alex Turner +Cc: "Joshua D. Drake" , + "pgsql-performance@postgresql.org" +In-Reply-To: <33c6269f05032211366ce4563b@mail.gmail.com> +References: <33c6269f05032206565ca4f9f1@mail.gmail.com> + <42404663.2010504@commandprompt.com> + <33c6269f05032211366ce4563b@mail.gmail.com> +Content-Type: text/plain +Date: Tue, 22 Mar 2005 20:09:03 +0000 +Message-Id: <1111522143.7726.48.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/466 +X-Sequence-Number: 11171 + +On Tue, 2005-03-22 at 14:36 -0500, Alex Turner wrote: + +> I will use an index 220-300, but not 200-300. +> ... +> Seq Scan on propmain (cost=0.00..15517.56 rows=6842 width=4) (actual +> time=0.039..239.760 rows=6847 loops=1) +> ... +> Index Scan using propmain_listprice_i on propmain +> (cost=0.00..22395.95 rows=6842 width=4) (actual time=0.084..25.751 +> rows=6847 loops=1) + +the rows estimates are accurate, so it is not a question of statistics +anymore. + +first make sure effective_cache_size is correctly set, and then +if that is not enough, you might try to lower random_page_cost a bit + + +gnari + + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 20:44:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 236D7568E5 + for ; + Tue, 22 Mar 2005 20:44:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71143-09 + for ; + Tue, 22 Mar 2005 20:44:24 +0000 (GMT) +Received: from zcars04f.nortelnetworks.com (zcars04f.nortelnetworks.com + [47.129.242.57]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E113568D0 + for ; + Tue, 22 Mar 2005 20:44:22 +0000 (GMT) +Received: from zrtps0m6.us.nortel.com (zrtps0m6.us.nortel.com [47.140.192.58]) + by zcars04f.nortelnetworks.com (Switch-2.2.6/Switch-2.2.0) with + ESMTP id j2MKiJj24585 for ; + Tue, 22 Mar 2005 15:44:20 -0500 (EST) +Received: from cash.rhiamet.com (rhiamet.us.nortel.com [47.103.243.53]) + by zrtps0m6.us.nortel.com (Switch-2.2.6/Switch-2.2.0) with ESMTP id + j2MKiHO10581 for ; + Tue, 22 Mar 2005 15:44:17 -0500 (EST) +Received: from cash.rhiamet.com (bmetcalf@localhost [127.0.0.1]) + by cash.rhiamet.com (8.13.3/8.13.3/Debian-9) with ESMTP id + j2MKiAgd027484 + for ; Tue, 22 Mar 2005 14:44:11 -0600 +Received: from localhost (bmetcalf@localhost) + by cash.rhiamet.com (8.13.3/8.13.3/Submit) with ESMTP id j2MKiAJ6027480 + for ; Tue, 22 Mar 2005 14:44:10 -0600 +X-Authentication-Warning: cash.rhiamet.com: bmetcalf owned process doing -bs +Date: Tue, 22 Mar 2005 14:44:10 -0600 (CST) +From: "Brandon Metcalf" +X-X-Sender: bmetcalf@cash.rhiamet.com +To: pgsql-performance@postgresql.org +Subject: PostgreSQL on Solaris 8 and ufs +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.091 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/467 +X-Sequence-Number: 11172 + +We've recently moved our pgsql installation and DBs to a Solaris 8 +machine with striped and mirrored ufs filesystem that houses the DB +data. We are now seeing terrible performance and the bottleneck is no +doubt disk I/O. + +We've tried modifying a tunables related to ufs, but it doesn't seem +to be helping. + +Is there anything we should be looking at that is specifically related +to ufs filesystems on Solaris 8 or possibly something in general that +would improve performance? + +Thanks. + +-- +Brandon + +From pgsql-performance-owner@postgresql.org Tue Mar 22 21:02:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B0594568E3 + for ; + Tue, 22 Mar 2005 21:02:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79319-03 + for ; + Tue, 22 Mar 2005 21:02:51 +0000 (GMT) +Received: from unicorn.rentec.com (unicorn.rentec.com [216.223.240.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 9566D56899 + for ; + Tue, 22 Mar 2005 21:02:48 +0000 (GMT) +Received: from ram.rentec.com (mailhost [192.5.35.66]) + by unicorn.rentec.com (8.13.1/8.12.1) with ESMTP id j2ML2ddx029313 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); + Tue, 22 Mar 2005 16:02:40 -0500 (EST) +X-Rentec: external +Received: from [172.26.132.145] (hoopoe.rentec.com [172.26.132.145]) + by ram.rentec.com (8.13.1/8.12.1) with ESMTP id j2ML2dpE022680; + Tue, 22 Mar 2005 16:02:39 -0500 (EST) +Message-ID: <424087EF.2070802@rentec.com> +Date: Tue, 22 Mar 2005 16:02:39 -0500 +From: Alan Stange +Reply-To: stange@rentec.com +Organization: Renaissance Technologies Corp. +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Brandon Metcalf +Cc: pgsql-performance@postgresql.org +Subject: Re: PostgreSQL on Solaris 8 and ufs +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Logged: Logged by unicorn.rentec.com as j2ML2ddx029313 at Tue Mar 22 + 16:02:40 2005 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/468 +X-Sequence-Number: 11173 + +Brandon Metcalf wrote: + +>We've recently moved our pgsql installation and DBs to a Solaris 8 +>machine with striped and mirrored ufs filesystem that houses the DB +>data. We are now seeing terrible performance and the bottleneck is no +>doubt disk I/O. +> +>We've tried modifying a tunables related to ufs, but it doesn't seem +>to be helping. +> +>Is there anything we should be looking at that is specifically related +>to ufs filesystems on Solaris 8 or possibly something in general that +>would improve performance? +> +> +Well, Solaris 8 is a bit old now, so I don't remember all the details. +But, if memory servers, Solaris 8 still has some "high water" and "lo +water" tunables related to the amount of IO can be outstanding to a +single file. + +Try setting +set ufs:ufs_WRITES=0 +in /etc/system and rebooting, which basically says "any amount of disk +IO can be outstanding". There's a tunables doc on docs.sun.com that +explains this option. + +Also, logging UFS might help with some of the metadata requirements of +UFS as well. So, use "mount -o logging" or add the relevant entry in +/etc/vfstab. + +Of course, the best thing is Solaris 9 or 10, which would be much better +for this sort of thing. + +Hope this helps. + +-- Alan + +From pgsql-performance-owner@postgresql.org Tue Mar 22 21:03:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EBB8B56899 + for ; + Tue, 22 Mar 2005 21:03:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77851-08 + for ; + Tue, 22 Mar 2005 21:03:46 +0000 (GMT) +Received: from smtp-gw-cl-c.dmv.com (smtp-gw-cl-c.dmv.com [216.240.97.41]) + by svr1.postgresql.org (Postfix) with ESMTP id 63A9F568D8 + for ; + Tue, 22 Mar 2005 21:03:45 +0000 (GMT) +Received: from lanshark.dmv.com (lanshark.dmv.com [216.240.97.46]) + by smtp-gw-cl-c.dmv.com (8.12.10/8.12.10) with ESMTP id j2MLMoEo019689; + Tue, 22 Mar 2005 16:22:50 -0500 (EST) (envelope-from sven@dmv.com) +Subject: Re: PostgreSQL on Solaris 8 and ufs +From: Sven Willenberger +To: Brandon Metcalf +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Date: Tue, 22 Mar 2005 16:03:43 -0500 +Message-Id: <1111525423.9054.16.camel@lanshark.dmv.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 +Content-Transfer-Encoding: 7bit +X-Scanned-By: MIMEDefang 2.39 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.335 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_WHOIS +X-Spam-Level: +X-Archive-Number: 200503/469 +X-Sequence-Number: 11174 + +On Tue, 2005-03-22 at 14:44 -0600, Brandon Metcalf wrote: +> We've recently moved our pgsql installation and DBs to a Solaris 8 +> machine with striped and mirrored ufs filesystem that houses the DB +> data. We are now seeing terrible performance and the bottleneck is no +> doubt disk I/O. +> +> We've tried modifying a tunables related to ufs, but it doesn't seem +> to be helping. +> +> Is there anything we should be looking at that is specifically related +> to ufs filesystems on Solaris 8 or possibly something in general that +> would improve performance? +> +> Thanks. +> + +What are you using to create your raid? You say it is "no doubt disk +I/O" - does iostat confirm this? A lot of performance issues are related +to the size of the stripe you chose for the striped portion of the +array, the actual array configuration, etc. I am assuming you have +looked at system variables such as autoup and the likes? What tweaks +have you done? + +Also, are your pg_xlog and data directories separated onto separate +volumes? Doing so will help immensely. What are you using to measure +performance? + +Sven + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 21:07:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A3CB9568D4 + for ; + Tue, 22 Mar 2005 21:06:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81165-02 + for ; + Tue, 22 Mar 2005 21:06:52 +0000 (GMT) +Received: from zcars04f.nortelnetworks.com (zcars04f.nortelnetworks.com + [47.129.242.57]) + by svr1.postgresql.org (Postfix) with ESMTP id DF7FC568E5 + for ; + Tue, 22 Mar 2005 21:06:51 +0000 (GMT) +Received: from zrtps0m6.us.nortel.com (zrtps0m6.us.nortel.com [47.140.192.58]) + by zcars04f.nortelnetworks.com (Switch-2.2.6/Switch-2.2.0) with + ESMTP id j2ML6oN18192; Tue, 22 Mar 2005 16:06:50 -0500 (EST) +Received: from cash.rhiamet.com (rhiamet.us.nortel.com [47.103.243.53]) + by zrtps0m6.us.nortel.com (Switch-2.2.6/Switch-2.2.0) with ESMTP id + j2ML6l122991; Tue, 22 Mar 2005 16:06:47 -0500 (EST) +Received: from cash.rhiamet.com (bmetcalf@localhost [127.0.0.1]) + by cash.rhiamet.com (8.13.3/8.13.3/Debian-9) with ESMTP id + j2ML6eSH027694; Tue, 22 Mar 2005 15:06:40 -0600 +Received: from localhost (bmetcalf@localhost) + by cash.rhiamet.com (8.13.3/8.13.3/Submit) with ESMTP id j2ML6en7027690; + Tue, 22 Mar 2005 15:06:40 -0600 +X-Authentication-Warning: cash.rhiamet.com: bmetcalf owned process doing -bs +Date: Tue, 22 Mar 2005 15:06:40 -0600 (CST) +From: "Brandon Metcalf" +X-X-Sender: bmetcalf@cash.rhiamet.com +To: Alan Stange +Cc: pgsql-performance@postgresql.org +Subject: Re: PostgreSQL on Solaris 8 and ufs +In-Reply-To: <424087EF.2070802@rentec.com> +Message-ID: +References: + <424087EF.2070802@rentec.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.082 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/470 +X-Sequence-Number: 11175 + +s == stange@rentec.com writes: + + s> Try setting + s> set ufs:ufs_WRITES=0 + s> in /etc/system and rebooting, which basically says "any amount of disk + s> IO can be outstanding". There's a tunables doc on docs.sun.com that + s> explains this option. + + s> Also, logging UFS might help with some of the metadata requirements of + s> UFS as well. So, use "mount -o logging" or add the relevant entry in + s> /etc/vfstab. + +OK. I'll try these out. We do have ufs_WRITES enabled with the +following parameters: + + set ncsize = 257024 + set autoup = 90 + set bufhwm = 15000 + set tune_t_fsflushr = 15 + set ufs:ufs_HW = 16777216 + set ufs:ufs_LW = 8388608 + + +-- +Brandon + +From pgsql-performance-owner@postgresql.org Tue Mar 22 21:23:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 85EC456705 + for ; + Tue, 22 Mar 2005 21:23:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81917-10 + for ; + Tue, 22 Mar 2005 21:23:32 +0000 (GMT) +Received: from zcars04f.nortelnetworks.com (zcars04f.nortelnetworks.com + [47.129.242.57]) + by svr1.postgresql.org (Postfix) with ESMTP id D791956648 + for ; + Tue, 22 Mar 2005 21:23:28 +0000 (GMT) +Received: from zrtps0m6.us.nortel.com (zrtps0m6.us.nortel.com [47.140.192.58]) + by zcars04f.nortelnetworks.com (Switch-2.2.6/Switch-2.2.0) with + ESMTP id j2MLNSN23174; Tue, 22 Mar 2005 16:23:28 -0500 (EST) +Received: from cash.rhiamet.com (rhiamet.us.nortel.com [47.103.243.53]) + by zrtps0m6.us.nortel.com (Switch-2.2.6/Switch-2.2.0) with ESMTP id + j2MLNO109523; Tue, 22 Mar 2005 16:23:25 -0500 (EST) +Received: from cash.rhiamet.com (bmetcalf@localhost [127.0.0.1]) + by cash.rhiamet.com (8.13.3/8.13.3/Debian-9) with ESMTP id + j2MLNIP1027784; Tue, 22 Mar 2005 15:23:18 -0600 +Received: from localhost (bmetcalf@localhost) + by cash.rhiamet.com (8.13.3/8.13.3/Submit) with ESMTP id j2MLNIu7027780; + Tue, 22 Mar 2005 15:23:18 -0600 +X-Authentication-Warning: cash.rhiamet.com: bmetcalf owned process doing -bs +Date: Tue, 22 Mar 2005 15:23:18 -0600 (CST) +From: "Brandon Metcalf" +X-X-Sender: bmetcalf@cash.rhiamet.com +To: Sven Willenberger +Cc: pgsql-performance@postgresql.org +Subject: Re: PostgreSQL on Solaris 8 and ufs +In-Reply-To: <1111525423.9054.16.camel@lanshark.dmv.com> +Message-ID: +References: + <1111525423.9054.16.camel@lanshark.dmv.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.076 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/471 +X-Sequence-Number: 11176 + +s == sven@dmv.com writes: + + s> What are you using to create your raid? + +Hm. I didn't set this up. I'll have to check. + + s> You say it is "no doubt disk + s> I/O" - does iostat confirm this? A lot of performance issues are related + s> to the size of the stripe you chose for the striped portion of the + s> array, the actual array configuration, etc. I am assuming you have + s> looked at system variables such as autoup and the likes? What tweaks + s> have you done? + +I've mainly been using Glance which shows a lot of queued requests for +the disks in question. + +Here's currently what we have in /etc/system related to ufs: + + set ncsize = 257024 + set autoup = 90 + set bufhwm = 15000 + set tune_t_fsflushr = 15 + set ufs:ufs_HW = 16777216 + set ufs:ufs_LW = 8388608 + + s> Also, are your pg_xlog and data directories separated onto separate + s> volumes? Doing so will help immensely. + +No, they are on the same volume. + + s> What are you using to measure + s> performance? + +Nothing too scientific other than the fact that since we have moved +the DB, we consistenly see a large number of postmater processes +(close to 100) where before we did not. + + +-- +Brandon + +From pgsql-performance-owner@postgresql.org Tue Mar 22 21:26:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ACEA8565AA + for ; + Tue, 22 Mar 2005 21:26:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87090-01 + for ; + Tue, 22 Mar 2005 21:26:18 +0000 (GMT) +Received: from linda-1.paradise.net.nz (bm-1a.paradise.net.nz [202.0.58.20]) + by svr1.postgresql.org (Postfix) with ESMTP id D8F365653D + for ; + Tue, 22 Mar 2005 21:26:16 +0000 (GMT) +Received: from smtp-1.paradise.net.nz (smtp-1a.paradise.net.nz [202.0.32.194]) + by linda-1.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0IDR00KDBVJT6W@linda-1.paradise.net.nz> for + pgsql-performance@postgresql.org; Wed, 23 Mar 2005 09:26:18 +1200 (NZST) +Received: from [192.168.1.11] (218-101-14-86.paradise.net.nz [218.101.14.86]) + by smtp-1.paradise.net.nz (Postfix) with ESMTP id 2421E82798; Wed, + 23 Mar 2005 09:26:17 +1200 (NZST) +Date: Wed, 23 Mar 2005 09:26:16 +1200 +From: Mark Kirkwood +Subject: Re: PostgreSQL on Solaris 8 and ufs +In-reply-to: +To: Brandon Metcalf +Cc: pgsql-performance@postgresql.org +Message-id: <42408D78.1020100@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8b) Gecko/20050301 +References: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.053 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/472 +X-Sequence-Number: 11177 + +Brandon Metcalf wrote: +> We've recently moved our pgsql installation and DBs to a Solaris 8 +> machine with striped and mirrored ufs filesystem that houses the DB +> data. We are now seeing terrible performance and the bottleneck is no +> doubt disk I/O. +> +> We've tried modifying a tunables related to ufs, but it doesn't seem +> to be helping. +> +> Is there anything we should be looking at that is specifically related +> to ufs filesystems on Solaris 8 or possibly something in general that +> would improve performance? +> +> Thanks. +> + +I found that mounting the filesystem that contains the PGDATA directory +(probably only the pg_xlog directory in fact) without logging improved +things a great deal (assuming you are using logging that is...). + +In addition changing the postgresql.conf parameter wal_sync_method from +the default of open_datasync to fdatasync improved things a bit more. +However I seem to recall a posting suggesting the opposite! ...so feel +free to experiment and let us know! + +Mark + +P.s : original tests on Solaris 8, +http://archives.postgresql.org/pgsql-performance/2003-12/msg00165.php + +From pgsql-performance-owner@postgresql.org Tue Mar 22 21:28:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 35B7A52A8E + for ; + Tue, 22 Mar 2005 21:28:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87340-02 + for ; + Tue, 22 Mar 2005 21:28:27 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id D38B052A74 + for ; + Tue, 22 Mar 2005 21:28:25 +0000 (GMT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DDqvC-0000LQ-00; Tue, 22 Mar 2005 16:28:18 -0500 +To: Tom Lane +Cc: Christopher Browne , + pgsql-performance@postgresql.org +Subject: Re: What about utility to calculate planner cost constants? +References: + <200503210951.06044.josh@agliodbs.com> + <87acowcmut.fsf@stark.xeocode.com> + + <10759.1111516477@sss.pgh.pa.us> +In-Reply-To: <10759.1111516477@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 22 Mar 2005 16:28:18 -0500 +Message-ID: <87is3j9xql.fsf@stark.xeocode.com> +Lines: 49 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/473 +X-Sequence-Number: 11178 + + +Tom Lane writes: + +> Christopher Browne writes: +> > Martha Stewart called it a Good Thing when gsstark@mit.edu (Greg Stark) wrote: +> >> It's just a linear algebra problem with a bunch of independent +> >> variables and a system of equations. Solving for values for all of +> >> them is a straightforward problem. +> +> > Are you certain it's a linear system? I'm not. +> +> I'm quite certain it isn't a linear system, because the planner's cost +> models include nonlinear equations. + +The equations will all be linear for the *_cost variables. If they weren't +they would be meaningless, the units would be wrong. Things like caching are +just going to be the linear factors that determine how many random page costs +and sequential page costs to charge the query. + +> While I don't have a whole lot of hard evidence to back this up, my +> belief is that our worst problems stem not from bad parameter values +> but from wrong models. + +I think these are orthogonal issues. + +The time spent in real-world operations like random page accesses, sequential +page accesses, cpu operations, index lookups, etc, are all measurable +quantities. They can be directly measured or approximated by looking at the +resulting net times. Measuring these things instead of asking the user to +provide them is just a nicer user experience. + +Separately, plugging these values into more and more accurate model will come +up with better estimates for how many of these operations a query will need to +perform. + +> Anyway, I see little point in trying to build an automatic parameter +> optimizer until we have cost models whose parameters are more stable +> than the current ones. + +Well what people currently do is tweak the physical values until the produce +results for their work load that match reality. It would be neat if postgres +could do this automatically. + +Arguably the more accurate the cost model the less of a motivation for +automatic adjustments there is since you could easily plug in accurate values +from the hardware specs. But actually I think it'll always be a nice feature. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 21:49:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C7FA6565AF + for ; + Tue, 22 Mar 2005 21:48:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93808-04 + for ; + Tue, 22 Mar 2005 21:48:51 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C84352A8E + for ; + Tue, 22 Mar 2005 21:48:50 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2MLmFTn014923; + Tue, 22 Mar 2005 16:48:15 -0500 (EST) +To: Greg Stark +Cc: Christopher Browne , + pgsql-performance@postgresql.org +Subject: Re: What about utility to calculate planner cost constants? +In-reply-to: <87is3j9xql.fsf@stark.xeocode.com> +References: + <200503210951.06044.josh@agliodbs.com> + <87acowcmut.fsf@stark.xeocode.com> + + <10759.1111516477@sss.pgh.pa.us> <87is3j9xql.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "22 Mar 2005 16:28:18 -0500" +Date: Tue, 22 Mar 2005 16:48:15 -0500 +Message-ID: <14922.1111528095@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/474 +X-Sequence-Number: 11179 + +Greg Stark writes: +> The time spent in real-world operations like random page accesses, sequential +> page accesses, cpu operations, index lookups, etc, are all measurable +> quantities. They can be directly measured or approximated by looking at the +> resulting net times. + +That's the theory, all right, and that's why I've been resistant to +lowering random_page_cost just because "it gives better answers". +To the extent that you believe that is a real physical parameter with +a definable value (which is a bit debatable actually, but nevermind) +it should be possible to measure it by experiment. + +The difficulty with the notion of doing that measurement by timing +Postgres operations is that it's a horribly bad experimental setup. +You have no way to isolate the effects of just one variable, or even +a small number of variables, which you really need to do if you want +to estimate with any degree of precision. What's more, there are plenty +of relevant factors that aren't in the model at all (such as the extent +of other load on the machine), and so the noise in the measurements +will be enormous. + +And you can't just dismiss the issue of wrong cost models and say we can +get numbers anyway. We see examples almost every day on this list where +the planner is so far off about indexscan vs seqscan costs that you'd +have to put random_page_cost far below 1 to make its numbers line up +with reality. That's not a matter of tuning the parameter, it's +evidence that the cost model is wrong. If you try to solve for the +"right value" of the parameter by comparing estimated and actual costs, +you'll get garbage, even without any issues about noisy measurements +or numerical instability of your system of equations. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 22 22:17:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37B55565D0 + for ; + Tue, 22 Mar 2005 22:16:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99783-06 + for ; + Tue, 22 Mar 2005 22:16:21 +0000 (GMT) +Received: from asg002.asg.local (smtp2.arrayservicesgrp.com [208.14.218.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B25C565D9 + for ; + Tue, 22 Mar 2005 22:16:20 +0000 (GMT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: What about utility to calculate planner cost constants? +Date: Tue, 22 Mar 2005 16:16:17 -0600 +Message-ID: <49E94D0CFCD4DB43AFBA928DDD20C8F902618481@asg002.asg.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] What about utility to calculate planner cost + constants? +Thread-Index: AcUvKlUqoK1wlX99RjmZS00FJP3OkwAAli0g +From: "Dave Held" +To: "Tom Lane" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.089 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/475 +X-Sequence-Number: 11180 + +> -----Original Message----- +> From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +> Sent: Tuesday, March 22, 2005 3:48 PM +> To: Greg Stark +> Cc: Christopher Browne; pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] What about utility to calculate planner cost +> constants? +> [...] +> The difficulty with the notion of doing that measurement by timing +> Postgres operations is that it's a horribly bad experimental setup. +> You have no way to isolate the effects of just one variable, or even +> a small number of variables, which you really need to do if you want +> to estimate with any degree of precision. What's more, there=20 +> are plenty of relevant factors that aren't in the model at all (such +> as the extent of other load on the machine), and so the noise in the +> measurements will be enormous. +>=20 +> And you can't just dismiss the issue of wrong cost models and say we +> can get numbers anyway. We see examples almost every day on this=20 +> list where the planner is so far off about indexscan vs seqscan costs +> that you'd have to put random_page_cost far below 1 to make its = +numbers +> line up with reality. That's not a matter of tuning the parameter, +> it's evidence that the cost model is wrong. If you try to solve for +> the "right value" of the parameter by comparing estimated and actual +> costs, you'll get garbage, even without any issues about noisy +> measurements or numerical instability of your system of equations. + +Then instead of building a fixed cost model, why not evolve an adaptive +model using an ANN or GA? I can't say that I'm remotely familiar with +how the planner does its business, but perhaps we should throw away all +these tunable cost parameters and let a neural network create them +implicitly, if they really exist in any meaningful form. I suppose the +inputs to the network would be the available scan types, the actual and +estimated rows, correlations, etc. The outputs would be query plans, is +that right? So we pick several representative data points in the query +space and train the network on those, to "bootstrap" it. With any luck, +the network will generalize the training inputs and do a halfway decent +job on real-world values. If a user is unhappy with the way the network +is operating, they can switch on a training mode whereby the network=20 +tries some different plans for a given query and uses the execution time = + +to judge which plans worked the best. The alternative plans can be +suggested by built-in heuristics or perhaps built randomly. Of course, +such training would only be practical for smaller data sets, but perhaps +there would be a way to let the network perform a query on a subset of +the data and then extrapolate the behavior of a plan over the full data +set. + +__ +David B. Held +Software Engineer/Array Services Group +200 14th Ave. East, Sartell, MN 56377 +320.534.3637 320.253.7800 800.752.8129 + +From pgsql-performance-owner@postgresql.org Tue Mar 22 22:19:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6C1FB5655F + for ; + Tue, 22 Mar 2005 22:19:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02754-04 + for ; + Tue, 22 Mar 2005 22:19:12 +0000 (GMT) +Received: from cmailm4.svr.pol.co.uk (cmailm4.svr.pol.co.uk [195.92.193.211]) + by svr1.postgresql.org (Postfix) with ESMTP id D4D09564E7 + for ; + Tue, 22 Mar 2005 22:19:11 +0000 (GMT) +Received: from modem-2890.lynx.dialup.pol.co.uk ([217.135.203.74] + helo=192.168.0.102) by cmailm4.svr.pol.co.uk with esmtp (Exim 4.41) + id 1DDriS-00015N-GZ; Tue, 22 Mar 2005 22:19:12 +0000 +Subject: Re: CPU 0.1% IOWAIT 99% for decisonnal queries +From: Simon Riggs +To: Patrick Vedrines +Cc: performance pgsql +In-Reply-To: <002601c52f0a$2312a4d0$280baf96@PCPATRICK> +References: <002601c52f0a$2312a4d0$280baf96@PCPATRICK> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Tue, 22 Mar 2005 22:18:11 +0000 +Message-Id: <1111529891.11750.577.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/476 +X-Sequence-Number: 11181 + +On Tue, 2005-03-22 at 19:08 +0100, Patrick Vedrines wrote: +> I have 2 databases (A and B) with exactly the same schemas: +> -one main table called "aggregate" having no indexes and supporting +> only SELECT statements (loaded one time a month with a new bundle of +> datas). Row size # 200 bytes (50 columns of type char(x) or integer) +> -and several small 'reference' tables not shown by the following +> example for clarity reasons. +> -Database A : aggregate contains 2,300,000 records ( 500 Mb) +> -Database B : aggregate contains 9,000,000 records ( 2 Gb) + +> (For example : shared_buffers = 190000 , sort_mem = 4096 , +> effective_cache_size = 37000 and kernel/shmmax=1200000000 ) +> Do I have to upgrade the RAM to 6Gb or/and buy faster HD (of what +> type?) ? + +Setting shared_buffers that high will do you no good at all, as Richard +suggests. + +You've got 1.5Gb of shared_buffers and > 2Gb data. In 8.0, the scan will +hardly use the cache at all, nor will it ever, since the data is bigger +than the cache. Notably, the scan of B should NOT spoil the cache for +A... + +Priming the cache is quite hard...but not impossible. + +What will kill you on a shared_buffers that big is the bgwriter, which +you should turn off by setting bgwriter_maxpages = 0 + +> PS (maybe of interest for some users like me) : +> I created a partition on a new similar disk but on the last cylinders +> (near the periphery) and copied the database B into it: the response +> time is 25% faster (i.e. 15mn instead of 21mn). But 15 mn is still too +> long for my customers (5 mn would be nice). + +Sounds like your disks/layout/something is pretty sick. You don't +mention I/O bandwidth, controller or RAID, so you should look more into +those topics. + +On the other hand...just go for more RAM, as you suggest...but you +should create a RAMdisk, rather than use too large +shared_buffers....that way your data is always in RAM, rather than maybe +in RAM. + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 22:35:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A6BB565D3 + for ; + Tue, 22 Mar 2005 22:35:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07662-02 + for ; + Tue, 22 Mar 2005 22:35:25 +0000 (GMT) +Received: from asg002.asg.local (smtp2.arrayservicesgrp.com [208.14.218.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 61AF8565EF + for ; + Tue, 22 Mar 2005 22:35:22 +0000 (GMT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: What about utility to calculate planner cost constants? +Date: Tue, 22 Mar 2005 16:33:41 -0600 +Message-ID: <49E94D0CFCD4DB43AFBA928DDD20C8F902618482@asg002.asg.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] What about utility to calculate planner cost + constants? +Thread-Index: AcUvKlUqoK1wlX99RjmZS00FJP3OkwAAli0gAABx84A= +From: "Dave Held" +To: "Tom Lane" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.086 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/477 +X-Sequence-Number: 11182 + +> -----Original Message----- +> From: Dave Held=20 +> Sent: Tuesday, March 22, 2005 4:16 PM +> To: Tom Lane +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] What about utility to calculate planner cost +> constants? +> [...] +> Then instead of building a fixed cost model, why not evolve=20 +> an adaptive model using an ANN or GA? +> [...] + +Another advantage to an adaptive planner is that for those who +can afford to duplicate/replicate their hardware/db, they can +perhaps dedicate a backup server to plan optimization where the=20 +db just runs continuously in a learning mode trying out different +plans for a core set of important queries. Then those network +parameters can get replicated back to the primary server(s),=20 +hopefully improving query planning on the production dbs. And +perhaps people could make those parameters public, with the hope +that someone with a similar setup could benefit from a pre- +learned network. + +__ +David B. Held +Software Engineer/Array Services Group +200 14th Ave. East, Sartell, MN 56377 +320.534.3637 320.253.7800 800.752.8129 + +From pgsql-performance-owner@postgresql.org Tue Mar 22 22:58:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D899565F6 + for ; + Tue, 22 Mar 2005 22:58:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13988-01 + for ; + Tue, 22 Mar 2005 22:58:22 +0000 (GMT) +Received: from ylpvm15.prodigy.net (ylpvm15-ext.prodigy.net [207.115.57.46]) + by svr1.postgresql.org (Postfix) with ESMTP id 21A19565F5 + for ; + Tue, 22 Mar 2005 22:58:21 +0000 (GMT) +Received: from one (adsl-69-105-230-85.dsl.pltn13.pacbell.net [69.105.230.85]) + by ylpvm15.prodigy.net (8.12.10 outbound/8.12.10) with ESMTP id + j2MMsLba003973; Tue, 22 Mar 2005 17:54:21 -0500 +Received: from [192.168.5.100] (unknown [192.168.5.100]) + by one (Postfix) with ESMTP id 692C7F1D0E; + Tue, 22 Mar 2005 14:58:20 -0800 (PST) +Message-ID: <4240A360.1030904@cheapcomplexdevices.com> +Date: Tue, 22 Mar 2005 14:59:44 -0800 +From: Ron Mayer +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane , pgsql-performance@postgresql.org, + Ron Mayer +Subject: Re: What about utility to calculate planner cost constants? +References: + <200503210951.06044.josh@agliodbs.com> + <87acowcmut.fsf@stark.xeocode.com> + + <10759.1111516477@sss.pgh.pa.us> <87is3j9xql.fsf@stark.xeocode.com> + <14922.1111528095@sss.pgh.pa.us> +In-Reply-To: <14922.1111528095@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/478 +X-Sequence-Number: 11183 + +Tom Lane wrote: +> +> And you can't just dismiss the issue of wrong cost models and say we can +> get numbers anyway. + +Is there a way to see more details about the cost estimates. +EXPLAIN ANALYZE seems to show the total time and rows; but not +information like how many disk pages were accessed. + +I get the feeling that sometimes the number of rows is estimated +very well, but the amount of disk I/O is way off. + +Sometimes the number of pages read/written is grossly +overestimated (if tables lave a lot of locally clustered data) +or underestimated if a sort barely exceeds sort_mem. + + +Perhaps an EXPLAN ANALYZE VERBOSE that would add info like this: + + Index scan ([...]estimated 1000 pages read) (actual[...] 10 pages read) + +would help track those down? + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 23:08:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 90D68566E3 + for ; + Tue, 22 Mar 2005 23:07:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16363-01 + for ; + Tue, 22 Mar 2005 23:07:15 +0000 (GMT) +Received: from floppy.pyrenet.fr (unknown [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 99D415664E + for ; + Tue, 22 Mar 2005 23:07:14 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 0B8E430EA1; Wed, 23 Mar 2005 00:07:17 +0100 (MET) +From: Ron Mayer +X-Newsgroups: pgsql.performance +Subject: Re: Planner issue +Date: Tue, 22 Mar 2005 15:08:39 -0800 +Organization: Hub.Org Networking Services +Lines: 25 +Message-ID: <4240A577.6070806@cheapcomplexdevices.com> +References: <33c6269f05032206565ca4f9f1@mail.gmail.com> + <42404663.2010504@commandprompt.com> + <33c6269f05032211366ce4563b@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +To: Alex Turner +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +In-Reply-To: <33c6269f05032211366ce4563b@mail.gmail.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/479 +X-Sequence-Number: 11184 + + +I'm guessing your data is actually more "clustered" than the +"correlation" stastic thinks it is. + +Alex Turner wrote: + > trendmls=# explain analyze select listnum from propmain where + > listprice<=300000 and listprice>=200000; + + +Is that a database of properties like land/houses? + +If your table is clustered geographically (by zip code, etc), +the index scan might do quite well because all houses in a +neighborhood may have similar prices (and therefore live on +just a few disk pages). However since high-priced neighborhoods +are scattered across the country, the optimizer would see +a very low "correlation" and not notice this clustering. + + +If this is the cause, one thing you could do is +CLUSTER your table on propmain_listprice_i. I'm quite +confident it'll fix this particular query - but might +slow down other queries. + + + +From pgsql-performance-owner@postgresql.org Tue Mar 22 23:09:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B94D6565FF + for ; + Tue, 22 Mar 2005 23:08:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15996-07 + for ; + Tue, 22 Mar 2005 23:08:14 +0000 (GMT) +Received: from floppy.pyrenet.fr (unknown [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5CCAC52A4F + for ; + Tue, 22 Mar 2005 23:08:12 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 8B38D30EA1; Wed, 23 Mar 2005 00:08:12 +0100 (MET) +From: Ron Mayer +X-Newsgroups: pgsql.performance +Subject: Re: Planner issue +Date: Tue, 22 Mar 2005 15:09:35 -0800 +Organization: Hub.Org Networking Services +Lines: 25 +Message-ID: <4240A5AF.4010901@cheapcomplexdevices.com> +References: <33c6269f05032206565ca4f9f1@mail.gmail.com> + <42404663.2010504@commandprompt.com> + <33c6269f05032211366ce4563b@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +To: Alex Turner +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +In-Reply-To: <33c6269f05032211366ce4563b@mail.gmail.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/480 +X-Sequence-Number: 11185 + + +I'm guessing your data is actually more "clustered" than the +"correlation" statistic thinks it is. + +Alex Turner wrote: + > trendmls=# explain analyze select listnum from propmain where + > listprice<=300000 and listprice>=200000; + + +Is that a database of properties like land/houses? + +If your table is clustered geographically (by zip code, etc), +the index scan might do quite well because all houses in a +neighborhood may have similar prices (and therefore live on +just a few disk pages). However since high-priced neighborhoods +are scattered across the country, the optimizer would see +a very low "correlation" and not notice this clustering. + + +If this is the cause, one thing you could do is +CLUSTER your table on propmain_listprice_i. I'm quite +confident it'll fix this particular query - but might +slow down other queries. + + + +From pgsql-performance-owner@postgresql.org Wed Mar 23 00:04:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E2C7C56784 + for ; + Wed, 23 Mar 2005 00:04:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28773-09 + for ; + Wed, 23 Mar 2005 00:04:03 +0000 (GMT) +Received: from floppy.pyrenet.fr (unknown [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BFF635678F + for ; + Wed, 23 Mar 2005 00:04:00 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id DA09430EA1; Wed, 23 Mar 2005 01:04:03 +0100 (MET) +From: Chris Browne +X-Newsgroups: pgsql.performance +Subject: Re: What about utility to calculate planner cost constants? +Date: Tue, 22 Mar 2005 18:30:14 -0500 +Organization: cbbrowne Computing Inc +Lines: 90 +Message-ID: <607jjztg1l.fsf@dba2.int.libertyrms.com> +References: <49E94D0CFCD4DB43AFBA928DDD20C8F902618481@asg002.asg.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux) +Cancel-Lock: sha1:KKL1Jv7jpQoM29MxLLsDhRvFz64= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.165 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/481 +X-Sequence-Number: 11186 + +dave.held@arrayservicesgrp.com ("Dave Held") writes: +>> -----Original Message----- +>> From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +>> Sent: Tuesday, March 22, 2005 3:48 PM +>> To: Greg Stark +>> Cc: Christopher Browne; pgsql-performance@postgresql.org +>> Subject: Re: [PERFORM] What about utility to calculate planner cost +>> constants? +>> [...] +>> The difficulty with the notion of doing that measurement by timing +>> Postgres operations is that it's a horribly bad experimental setup. +>> You have no way to isolate the effects of just one variable, or even +>> a small number of variables, which you really need to do if you want +>> to estimate with any degree of precision. What's more, there +>> are plenty of relevant factors that aren't in the model at all (such +>> as the extent of other load on the machine), and so the noise in the +>> measurements will be enormous. +>> +>> And you can't just dismiss the issue of wrong cost models and say we +>> can get numbers anyway. We see examples almost every day on this +>> list where the planner is so far off about indexscan vs seqscan costs +>> that you'd have to put random_page_cost far below 1 to make its numbers +>> line up with reality. That's not a matter of tuning the parameter, +>> it's evidence that the cost model is wrong. If you try to solve for +>> the "right value" of the parameter by comparing estimated and actual +>> costs, you'll get garbage, even without any issues about noisy +>> measurements or numerical instability of your system of equations. +> +> Then instead of building a fixed cost model, why not evolve an adaptive +> model using an ANN or GA? I can't say that I'm remotely familiar with +> how the planner does its business, but perhaps we should throw away all +> these tunable cost parameters and let a neural network create them +> implicitly, if they really exist in any meaningful form. I suppose the +> inputs to the network would be the available scan types, the actual and +> estimated rows, correlations, etc. The outputs would be query plans, is +> that right? So we pick several representative data points in the query +> space and train the network on those, to "bootstrap" it. With any luck, +> the network will generalize the training inputs and do a halfway decent +> job on real-world values. If a user is unhappy with the way the network +> is operating, they can switch on a training mode whereby the network +> tries some different plans for a given query and uses the execution time +> to judge which plans worked the best. The alternative plans can be +> suggested by built-in heuristics or perhaps built randomly. Of course, +> such training would only be practical for smaller data sets, but perhaps +> there would be a way to let the network perform a query on a subset of +> the data and then extrapolate the behavior of a plan over the full data +> set. + +This strikes me as an interesting approach for trying to determine the +proper shape of the cost model. I'd also want to consider simulated +annealing (SA) (e.g. - perhaps Lester Ingber's ASA code...). + +We take such a network, perhaps assuming some small degree polynomial +set of parameters, train it based on some reasonably sizable set of +queries, and then see which of those parameters wind up being treated +as strong/not. + +That would provide results that would allow improving the model. + +I wouldn't assume that an untuned ANN/GA/SA would provide useful results +in general. + +It would certainly be pretty cool if we could get this approach into a +production query optimizer; we would hope that this would, in effect, +tune itself, over time. + +And I suppose that actually is somewhat plausible... Each query plan +that comes thru winds up having some "expected cost", and after +executing that plan, we have an "actual cost" which could be used as +feedback to the effect that the estimate was either pretty right or +pretty wrong. + +We'd presumably start by taking our "traditional cost estimate" as +being the way to go; when it gets sufficiently clear that the ANN/GA +network is providing a more accurate cost, it would make sense to make +the jump... + +What would also be very interesting would be to see the degree to +which analytical results could be taken out of this. For instance, +some cost factors might turn out to be pretty universally true, and we +might discover that most of the benefit can come from using a pretty +static network of parameters. +-- +(format nil "~S@~S" "cbbrowne" "cbbrowne.com") +http://www3.sympatico.ca/cbbrowne/or.html +"The present need for security products far exceeds the number of +individuals capable of designing secure systems. Consequently, +industry has resorted to employing folks and purchasing "solutions" +from vendors that shouldn't be let near a project involving securing a +system." -- Lucky Green + +From pgsql-performance-owner@postgresql.org Wed Mar 23 01:25:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C182565AF + for ; + Wed, 23 Mar 2005 01:25:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53280-09 + for ; + Wed, 23 Mar 2005 01:25:04 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) + by svr1.postgresql.org (Postfix) with ESMTP id 27E72565A6 + for ; + Wed, 23 Mar 2005 01:25:03 +0000 (GMT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id j2N1P5C18372; + Tue, 22 Mar 2005 20:25:05 -0500 (EST) +From: Bruce Momjian +Message-Id: <200503230125.j2N1P5C18372@candle.pha.pa.us> +Subject: Re: What needs to be done for real Partitioning? +In-Reply-To: <200503220901.23481.josh@agliodbs.com> +To: Josh Berkus +Date: Tue, 22 Mar 2005 20:25:05 -0500 (EST) +Cc: Hannu Krosing , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.012 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/482 +X-Sequence-Number: 11187 + + +Added to TODO: + +* Support table partitioning that allows a single table to be stored + in subtables that are partitioned based on the primary key or a WHERE + clause + + +--------------------------------------------------------------------------- + +Josh Berkus wrote: +> Hannu, +> +> > If you don't get it, contact me as there is a small possibility that I +> > know a company interested enough to fund (some) of it :) +> +> Enough people have been interested in this that if we get our acts together, +> we may do it as multi-funded. Easier on our budget ... +> +> > As these are already discussed in this thread, I'll try to outline a +> > method of providing a global index (unique or not) in a way that will +> > still make it possible to quickly remove (and not-quite-so-quickly add) +> > a partition. +> +> > To repeat - the global index over partitioned table should have te same +> > structure as our current b-tree index, only with added map of 128k index +> > partitions to 1G subfiles of (possibly different) tables. This map will +> > be quite small - for 1Tb of data it will be only 1k entries - this will +> > fit in cache on all modern processors and thus should add only tiny +> > slowdown from current direct tid.page/128k method +> +> I think this is a cool idea. It would need to be linked to clustering, so +> that each partition can be an iteration of the clustered index instead of a +> specifc # of bytes. But it would give us the "fully automated partitioning" +> which is one fork of the two we want. +> +> Plus I'm keen on any idea that presents an alternative to aping Oracle. +> +> How difficult would your proposal be to code? +> +> -- +> Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings +> + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Wed Mar 23 01:32:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 17F2C52A74 + for ; + Wed, 23 Mar 2005 01:32:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55232-07 + for ; + Wed, 23 Mar 2005 01:31:59 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 97A0B565AA + for ; + Wed, 23 Mar 2005 01:31:58 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 70so2061778wra + for ; + Tue, 22 Mar 2005 17:32:02 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; + b=mmBpllBp12l7sBoj2LxmabQz9iC20uCxZQvhhxw9ANRIKKrFjfG3y5QHqVxEolCN98XxKXhy2s3jrFhRgQyvRPP746uHZQsWjKA8r9Gr+unBdzd0Ntmp5kh0J+CCfq6lJlVseOVsLlfojx0ehdgzv7zg2HJXB4Wljt8fPrJHVFM= +Received: by 10.54.96.14 with SMTP id t14mr152841wrb; + Tue, 22 Mar 2005 17:32:02 -0800 (PST) +Received: by 10.54.84.15 with HTTP; Tue, 22 Mar 2005 17:32:02 -0800 (PST) +Message-ID: <8d04ce990503221732772ec09e@mail.gmail.com> +Date: Tue, 22 Mar 2005 17:32:02 -0800 +From: Junaili Lie +Reply-To: Junaili Lie +To: pgsql-performance@postgresql.org +Subject: Hardware questions +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.211 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/483 +X-Sequence-Number: 11188 + +Hi guys, +We are in the process of buying a new dell server. +Here is what we need to be able to do: +- we need to be able to do queries on tables that has 10-20 millions +of records (around 40-60 bytes each row) in less than 5-7 seconds. +We also need the hardware to be able to handle up to 50 millions +records on a few tables (5 tables in the DB). + +Here is what we are thinking: +- Dual Xeon 2.8 Ghz +- 4GB DDR2 400 Mhz Dual Ranked DIMMS (is dual ranked or single ranked +makes any differences in terms of performance?). Do you guys think 4GB +is reasonably enough? +- 73 GB 15k RPM Ultra 320 SCSI Hard Drive +- Dual on-board NICS (is this enough, or Gigabit network adapter will help?) + +Any input or suggestions is greatly appreciated. +Thank you, + + +Jun + +From pgsql-performance-owner@postgresql.org Wed Mar 23 02:17:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DA8EA56650 + for ; + Wed, 23 Mar 2005 02:17:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69969-03 + for ; + Wed, 23 Mar 2005 02:17:29 +0000 (GMT) +Received: from mailgate2.nau.edu (mailgate2.nau.edu [134.114.96.59]) + by svr1.postgresql.org (Postfix) with ESMTP id D36345666A + for ; + Wed, 23 Mar 2005 02:17:27 +0000 (GMT) +Received: from CONVERSION-DAEMON.mailgate2.nau.edu by mailgate2.nau.edu + (PMDF V6.2-X17 #30770) id <0IDS00C01915X4@mailgate2.nau.edu> for + pgsql-performance@postgresql.org; Tue, 22 Mar 2005 19:17:30 -0700 (MST) +Received: from k2.cet.nau.edu (net9-213.cet.nau.edu [134.114.9.213]) + by mailgate2.nau.edu (PMDF V6.2-X17 #30770) + with ESMTP id <0IDS007B49151L@mailgate2.nau.edu>; Tue, + 22 Mar 2005 19:17:29 -0700 (MST) +Date: Tue, 22 Mar 2005 19:21:06 -0700 +From: Karim Nassar +Subject: Re: Hardware questions +In-reply-to: <8d04ce990503221732772ec09e@mail.gmail.com> +To: Junaili Lie +Cc: pgsql-performance@postgresql.org +Message-id: <1111544466.9086.36.camel@k2.cet.nau.edu> +MIME-version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-type: text/plain +Content-transfer-encoding: 7BIT +References: <8d04ce990503221732772ec09e@mail.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/484 +X-Sequence-Number: 11189 + +On Tue, 2005-03-22 at 17:32 -0800, Junaili Lie wrote: +> Here is what we are thinking: +> - Dual Xeon 2.8 Ghz +> - 4GB DDR2 400 Mhz Dual Ranked DIMMS (is dual ranked or single ranked +> makes any differences in terms of performance?). Do you guys think 4GB +> is reasonably enough? +> - 73 GB 15k RPM Ultra 320 SCSI Hard Drive +> - Dual on-board NICS (is this enough, or Gigabit network adapter will help?) + +Purely based on price alone, you could get a Sun V20z with similar +config for $400 (list) less... but I don't know what discounts etc you +get. + +AMD's processor/memory architecture has a higher throughput, and the +size of the data and speeds you are asking about will need it. + +There is still some talk about the context-switching issue with +multi-xeons. I am under the impression that it still gets some people. + +You will likely want more disks as well. + +Some recent threads on this topic: +http://archives.postgresql.org/pgsql-performance/2005-03/msg00177.php +http://archives.postgresql.org/pgsql-performance/2005-03/msg00238.php +http://archives.postgresql.org/pgsql-performance/2005-03/msg00406.php + +HTH, + +-- +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=- Mobile: (928) 699-9221 + + +From pgsql-performance-owner@postgresql.org Wed Mar 23 09:16:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AEB4A5355B + for ; + Wed, 23 Mar 2005 09:16:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96943-10 + for ; + Wed, 23 Mar 2005 09:16:18 +0000 (GMT) +Received: from mail.census.gov.ph (mail.census.gov.ph [203.172.28.120]) + by svr1.postgresql.org (Postfix) with ESMTP id B559A53551 + for ; + Wed, 23 Mar 2005 09:16:01 +0000 (GMT) +Received: from notnot ([192.168.1.70]) + by mail.census.gov.ph (8.13.1/8.13.1) with ESMTP id j2N42ax1022249 + for ; Wed, 23 Mar 2005 12:02:36 +0800 +Message-Id: <200503230402.j2N42ax1022249@mail.census.gov.ph> +From: "Michael Ryan S. Puncia" +To: +Subject: Re: best practices with index on varchar column +Date: Wed, 23 Mar 2005 12:11:56 +0800 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +In-Reply-To: +Thread-Index: AcUuzPGCUiY9hn5hSmiI4tDc+4rTygAkQb9Q +X-NSO-MailScanner: Found to be clean by NSO MailScanner. +X-MailScanner-From: mpuncia@census.gov.ph +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.137 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/486 +X-Sequence-Number: 11191 + + +I have an experience using LIKE in a VARCHAR column and select statement +suffers a lot so I decided to go back in CHAR + +Note: my database has about 50 millions records a b tree index + + + +> Can I use an index on a varchar column to optimize the SELECT queries +> that +> use " column LIKE 'header%' "? + + Yes + +> If yes what is the best tree algotithm to use ? + + Btree + + Note that if you want case insensitive matching you need to make an +index +on lower(column) and SELECT WHERE lower(column) LIKE 'header%' + + Locales may bite you. + +---------------------------(end of broadcast)--------------------------- +TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org + +__________ NOD32 1.1023 (20050310) Information __________ + +This message was checked by NOD32 Antivirus System. +http://www.nod32.com + + + +From pgsql-bugs-owner@postgresql.org Wed Mar 23 08:41:48 2005 +X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4AB5D53545 + for ; + Wed, 23 Mar 2005 08:41:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77865-10 + for ; + Wed, 23 Mar 2005 08:41:34 +0000 (GMT) +Received: from cmailm1.svr.pol.co.uk (cmailm1.svr.pol.co.uk [195.92.193.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 82AB353537 + for ; Wed, 23 Mar 2005 08:41:32 +0000 (GMT) +Received: from modem-1740.lynx.dialup.pol.co.uk ([217.135.198.204] + helo=192.168.0.102) by cmailm1.svr.pol.co.uk with esmtp (Exim 4.41) + id 1DE1Qi-0007BB-BH; Wed, 23 Mar 2005 08:41:32 +0000 +Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 +From: Simon Riggs +To: Brian O'Reilly +Cc: pgsql-bugs@postgresql.org +In-Reply-To: <20050318232102.08FA0F0E5D@svr2.postgresql.org> +References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Wed, 23 Mar 2005 08:40:30 +0000 +Message-Id: <1111567230.11750.596.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/197 +X-Sequence-Number: 11317 + +On Fri, 2005-03-18 at 23:21 +0000, Brian O'Reilly wrote: +> The following bug has been logged online: +> +> Bug reference: 1552 +> Logged by: Brian O'Reilly +> Email address: fade@deepsky.com +> PostgreSQL version: 8.0.1 +> Operating system: Linux 2.6.11 +> Description: massive performance hit between 7.4 and 8.0.1 +> Details: +> +> When doing a lot of inserts to an empty table with a foreign key to another +> table, there is an incredible performance degredation issue on 8.0.1. I have +> a program that is inserting rows in an iterative loop, and in this form it +> inserts about 110,000 rows. On postgresql 7.4 on a debian machine it takes a +> shade over 2 minutes to complete. On an amd64 box running gentoo, it takes +> over an hour and fourty minutes to complete. The query plan on the debian +> host that completes quickly follows: +> + +This may be a bug, thanks for filing it. + +However, we can't tell at the moment from what you've said. + +The EXPLAINs you've enclosed are for SELECTs, yet your bug report +describes INSERTs as being the things that are slow. +[You may find better performance from using COPY] + +Also, your tests have compared two systems, so it might be that the +hardware or configuration of one system is different from the other. + +If you could repeat the test on one single system, then this would +assist in the diagnosis of this bug report. Also, if you could describe +the workload that is giving you a problem more exactly, that would help. +Specifically, can you confirm that you have run ANALYZE on the tables, +and also give us some idea of numbers of rows in each table at the time +you first run your programs. + +> the query optimiser seems to be setting a default strategy of doing +> sequential scans on an empty table, which is a fast strategy when the table +> is empty and not particularly full, but obviously on a large table the +> performance is O(N^2). + +> This is clearly a bug. + +There is clearly a problem, but it is not yet clearly a bug. If it is a +bug, we're interested in solving it as much as you. + +> Please let me know if I can +> provide any more information. + +Yes, all of the above, plus more. + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Wed Mar 23 08:52:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 20C1953546 + for ; + Wed, 23 Mar 2005 08:52:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87957-05 + for ; + Wed, 23 Mar 2005 08:52:30 +0000 (GMT) +Received: from mx1.rockingstone.nl (mx1.rockingstone.nl [82.94.241.100]) + by svr1.postgresql.org (Postfix) with ESMTP id D81D353537 + for ; + Wed, 23 Mar 2005 08:52:29 +0000 (GMT) +Received: from localhost (web1 [127.0.0.1]) + by mx1.rockingstone.nl (Postfix) with ESMTP id 5CB20FB0B1; + Wed, 23 Mar 2005 09:58:33 +0100 (CET) +Received: from mx1.rockingstone.nl ([127.0.0.1]) + by localhost (web1 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 17323-07; Wed, 23 Mar 2005 09:58:32 +0100 (CET) +Received: from [10.10.20.219] (217-19-26-53.dsl.cambrium.nl [217.19.26.53]) + by mx1.rockingstone.nl (Postfix) with ESMTP id EC41EFB0A8; + Wed, 23 Mar 2005 09:58:31 +0100 (CET) +Message-ID: <42412E4B.4010407@rockingstone.nl> +Date: Wed, 23 Mar 2005 09:52:27 +0100 +From: Rick Jansen +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Oleg Bartunov +Cc: Mike Rylander , + pgsql-performance@postgresql.org +Subject: Re: Tsearch2 performance on big database +References: <42400F57.3040604@rockingstone.nl> + + + <42401CBF.50403@rockingstone.nl> + + + <42404263.40604@rockingstone.nl> + +In-Reply-To: +X-Enigmail-Version: 0.90.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at rockingstone.nl +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/485 +X-Sequence-Number: 11190 + +Oleg Bartunov wrote: +> On Tue, 22 Mar 2005, Rick Jansen wrote: +> +> Hmm, default configuration is too eager, you index every lexem using +> simple dictionary) ! Probably, it's too much. Here is what I have for my +> russian configuration in dictionary database: +> +> default_russian | lword | {en_ispell,en_stem} +> default_russian | lpart_hword | {en_ispell,en_stem} +> default_russian | lhword | {en_ispell,en_stem} +> default_russian | nlword | {ru_ispell,ru_stem} +> default_russian | nlpart_hword | {ru_ispell,ru_stem} +> default_russian | nlhword | {ru_ispell,ru_stem} +> +> Notice, I index only russian and english words, no numbers, url, etc. +> You may just delete unwanted rows in pg_ts_cfgmap for your configuration, +> but I'd recommend just update them setting dict_name to NULL. +> For example, to not indexing integers: +> +> update pg_ts_cfgmap set dict_name=NULL where ts_name='default_russian' +> and tok_alias='int'; +> +> voc=# select token,dict_name,tok_type,tsvector from ts_debug('Do you +> have +70000 bucks'); +> token | dict_name | tok_type | tsvector +> --------+---------------------+----------+---------- +> Do | {en_ispell,en_stem} | lword | +> you | {en_ispell,en_stem} | lword | +> have | {en_ispell,en_stem} | lword | +> +70000 | | int | +> bucks | {en_ispell,en_stem} | lword | 'buck' +> +> Only 'bucks' gets indexed :) +> Hmm, probably I should add this into documentation. +> +> What about word statistics (# of unique words, for example). +> + +I'm now following the guide to add the ispell dictionary and I've +updated most of the rows setting dict_name to NULL: + + ts_name | tok_alias | dict_name +-----------------+--------------+----------- + default | lword | {en_stem} + default | nlword | {simple} + default | word | {simple} + default | part_hword | {simple} + default | nlpart_hword | {simple} + default | lpart_hword | {en_stem} + default | hword | {simple} + default | lhword | {en_stem} + default | nlhword | {simple} + +These are left, but I have no idea what a 'hword' or 'nlhword' or any +other of these tokens are. + +Anyway, how do I find out the number of unique words or other word +statistics? + +Rick +-- +Systems Administrator for Rockingstone IT +http://www.rockingstone.com +http://www.megabooksearch.com - Search many book listing sites at once + +From pgsql-performance-owner@postgresql.org Wed Mar 23 09:35:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C267D5335E + for ; + Wed, 23 Mar 2005 09:35:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02822-02 + for ; + Wed, 23 Mar 2005 09:35:47 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 16ED153237 + for ; + Wed, 23 Mar 2005 09:35:46 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id j1so116323rnf + for ; + Wed, 23 Mar 2005 01:35:48 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=FFt+mxq/yEp2bs9AjUyVvyZWAe57EglH+14d6E+2C3dfNbTawmiy4wvsCvlpOfmHzpPo9tafD4pWqCG0mokGdi3VmPN4JlS/FN79kbYQOkOUgWGc0BE2Dw0p3gQfA5UdiWnbBxnlZyXV2zDJzoQY2p4weg1QXPfrtAss1gwjl3o= +Received: by 10.38.78.1 with SMTP id a1mr412868rnb; + Wed, 23 Mar 2005 01:35:48 -0800 (PST) +Received: by 10.38.101.75 with HTTP; Wed, 23 Mar 2005 01:35:48 -0800 (PST) +Message-ID: <758d5e7f05032301351b685c44@mail.gmail.com> +Date: Wed, 23 Mar 2005 10:35:48 +0100 +From: Dawid Kuroczko +Reply-To: Dawid Kuroczko +To: pgsql-performance@postgresql.org +Subject: Re: best practices with index on varchar column +In-Reply-To: <200503230402.j2N42ax1022249@mail.census.gov.ph> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +References: + <200503230402.j2N42ax1022249@mail.census.gov.ph> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.743 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, FROM_ENDS_IN_NUMS, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/487 +X-Sequence-Number: 11192 + +On Wed, 23 Mar 2005 12:11:56 +0800, Michael Ryan S. Puncia + wrote: +> +> I have an experience using LIKE in a VARCHAR column and select statement +> suffers a lot so I decided to go back in CHAR +> +> Note: my database has about 50 millions records a b tree index + +Strange... + +According to the PostgreSQL's documentation: + + Tip: There are no performance differences between these three types, +apart from the increased storage size when using the blank-padded type. +While character(n) has performance advantages in some other database +systems, it has no such advantages in PostgreSQL. In most situations text +or character varying should be used instead. + + +To my best knowledge char and varchar are stored in a same way +(4-byte length plus textual value), so using char should make tables +bigger in your case. Then again, having each row exactly the same +size makes it easier to delete and then later insert a new row in +a same spot. Am I thinking correct? Is it a case where using char(n) +makes that table avoid hmm fragmentation of some sort? + + Regards, + Dawid + +From pgsql-performance-owner@postgresql.org Wed Mar 23 09:40:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F0CA55335E + for ; + Wed, 23 Mar 2005 09:40:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03833-05 + for ; + Wed, 23 Mar 2005 09:40:23 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5715D5322D + for ; + Wed, 23 Mar 2005 09:40:15 +0000 (GMT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id j2N9e35Q001772; + Wed, 23 Mar 2005 12:40:03 +0300 (MSK) +Date: Wed, 23 Mar 2005 12:40:03 +0300 (MSK) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Rick Jansen +Cc: Mike Rylander , + pgsql-performance@postgresql.org +Subject: Re: Tsearch2 performance on big database +In-Reply-To: <42412E4B.4010407@rockingstone.nl> +Message-ID: +References: <42400F57.3040604@rockingstone.nl> + + + <42401CBF.50403@rockingstone.nl> + + + <42404263.40604@rockingstone.nl> + + <42412E4B.4010407@rockingstone.nl> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.342 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/488 +X-Sequence-Number: 11193 + +On Wed, 23 Mar 2005, Rick Jansen wrote: + +> Oleg Bartunov wrote: +>> On Tue, 22 Mar 2005, Rick Jansen wrote: +>> +>> Hmm, default configuration is too eager, you index every lexem using simple +>> dictionary) ! Probably, it's too much. Here is what I have for my russian +>> configuration in dictionary database: +>> +>> default_russian | lword | {en_ispell,en_stem} +>> default_russian | lpart_hword | {en_ispell,en_stem} +>> default_russian | lhword | {en_ispell,en_stem} +>> default_russian | nlword | {ru_ispell,ru_stem} +>> default_russian | nlpart_hword | {ru_ispell,ru_stem} +>> default_russian | nlhword | {ru_ispell,ru_stem} +>> +>> Notice, I index only russian and english words, no numbers, url, etc. +>> You may just delete unwanted rows in pg_ts_cfgmap for your configuration, +>> but I'd recommend just update them setting dict_name to NULL. +>> For example, to not indexing integers: +>> +>> update pg_ts_cfgmap set dict_name=NULL where ts_name='default_russian' and +>> tok_alias='int'; +>> +>> voc=# select token,dict_name,tok_type,tsvector from ts_debug('Do you have +>> +70000 bucks'); +>> token | dict_name | tok_type | tsvector +>> --------+---------------------+----------+---------- +>> Do | {en_ispell,en_stem} | lword | +>> you | {en_ispell,en_stem} | lword | +>> have | {en_ispell,en_stem} | lword | +>> +70000 | | int | +>> bucks | {en_ispell,en_stem} | lword | 'buck' +>> +>> Only 'bucks' gets indexed :) +>> Hmm, probably I should add this into documentation. +>> +>> What about word statistics (# of unique words, for example). +>> +> +> I'm now following the guide to add the ispell dictionary and I've updated +> most of the rows setting dict_name to NULL: +> +> ts_name | tok_alias | dict_name +> -----------------+--------------+----------- +> default | lword | {en_stem} +> default | nlword | {simple} +> default | word | {simple} +> default | part_hword | {simple} +> default | nlpart_hword | {simple} +> default | lpart_hword | {en_stem} +> default | hword | {simple} +> default | lhword | {en_stem} +> default | nlhword | {simple} +> +> These are left, but I have no idea what a 'hword' or 'nlhword' or any other +> of these tokens are. + +from my notes http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes + I've asked how to know token types supported by parser. Actually, there is function token_type(parser), so you just use: + + select * from token_type(); + +> +> Anyway, how do I find out the number of unique words or other word +> statistics? + + +from my notes http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes + +It's usefull to see words statistics, for example, to check how good your +dictionaries work or how did you configure pg_ts_cfgmap. Also, you may notice +probable stop words relevant for your collection. +Tsearch provides stat() function: + +....................... + +Don't hesitate to read it and if you find some bugs or know better wording +I'd be glad to improve my notes. + +> +> Rick +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Wed Mar 23 10:03:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3021953374 + for ; + Wed, 23 Mar 2005 10:03:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11204-05 + for ; + Wed, 23 Mar 2005 10:03:28 +0000 (GMT) +Received: from ns.aprote.ee (ns.aprote.ee [80.235.78.106]) + by svr1.postgresql.org (Postfix) with ESMTP id 8852B53237 + for ; + Wed, 23 Mar 2005 10:03:25 +0000 (GMT) +Received: Message by Barricade ns.aprote.ee with ESMTP id j2NA4VKA006213 + for ; Wed, 23 Mar 2005 12:04:31 +0200 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6556.0 +Subject: SQL function inlining (was: View vs function) +Date: Wed, 23 Mar 2005 12:03:26 +0200 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: SQL function inlining (was: View vs function) +Thread-Index: AcUvj44MLFQwQHpRQ8CCCzw9jx1i9A== +From: "Tambet Matiisen" +To: "Neil Conway" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/489 +X-Sequence-Number: 11194 + +I observed slowdowns when I declared SQL function as strict. There were +no slowdowns, when I implmented the same function in plpgsql, in fact it +got faster with strict, if parameters where NULL. Could it be +side-effect of SQL function inlining? Is there CASE added around the +function to not calculate it, when one of the parameters is NULL? + +The functions: + +create or replace function keskmine_omahind(kogus, raha) returns raha + language sql + immutable + strict +as ' + SELECT CASE WHEN $1 > 0 THEN $2 / $1 ELSE NULL END::raha; +'; + +create or replace function keskmine_omahind2(kogus, raha) returns raha + language plpgsql + immutable + strict +as ' +BEGIN + RETURN CASE WHEN $1 > 0 THEN $2 / $1 ELSE NULL END::raha; +END; +'; + +With strict: + +epos=3D# select count(keskmine_omahind(laokogus, laosumma)) from kaubad; + count +------- + 9866 +(1 row) + +Time: 860,495 ms + +epos=3D# select count(keskmine_omahind2(laokogus, laosumma)) from = +kaubad; + count +------- + 9866 +(1 row) + +Time: 178,922 ms + +Without strict: + +epos=3D# select count(keskmine_omahind(laokogus, laosumma)) from kaubad; + count +------- + 9866 +(1 row) + +Time: 88,151 ms + +epos=3D# select count(keskmine_omahind2(laokogus, laosumma)) from = +kaubad; + count +------- + 9866 +(1 row) + +Time: 178,383 ms + +epos=3D# select version(); + version +------------------------------------------------------------------------ +------------------------------ + PostgreSQL 7.4.5 on i386-pc-linux-gnu, compiled by GCC i386-linux-gcc +(GCC) 3.3.4 (Debian 1:3.3.4-9) + + Tambet + +> -----Original Message----- +> From: Neil Conway [mailto:neilc@samurai.com]=20 +> Sent: Monday, March 21, 2005 7:13 AM +> To: Bruno Wolff III +> Cc: Keith Worthington; pgsql-performance@postgresql.org +> Subject: Re: View vs function +>=20 +>=20 +> Bruno Wolff III wrote: +> > Functions are just black boxes to the planner. +>=20 +> ... unless the function is a SQL function that is trivial=20 +> enough for the=20 +> planner to inline it into the plan of the invoking query.=20 +> Currently, we=20 +> won't inline set-returning SQL functions that are used in the query's=20 +> rangetable, though. This would be worth doing, I think -- I'm=20 +> not sure=20 +> how much work it would be, though. +>=20 +> -Neil +>=20 + +From pgsql-performance-owner@postgresql.org Wed Mar 23 11:31:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 236E6533BE + for ; + Wed, 23 Mar 2005 11:31:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38824-05 + for ; + Wed, 23 Mar 2005 11:31:28 +0000 (GMT) +Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net + [194.217.242.89]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C218533B8 + for ; + Wed, 23 Mar 2005 11:31:27 +0000 (GMT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-31.mail.demon.net with esmtp (Exim 4.42) + id 1DE42z-000DON-4R; Wed, 23 Mar 2005 11:29:13 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 9BFAF177C5; Wed, 23 Mar 2005 11:31:28 +0000 (GMT) +Message-ID: <42415390.8030208@archonet.com> +Date: Wed, 23 Mar 2005 11:31:28 +0000 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Dawid Kuroczko +Cc: pgsql-performance@postgresql.org +Subject: Re: best practices with index on varchar column +References: + <200503230402.j2N42ax1022249@mail.census.gov.ph> + <758d5e7f05032301351b685c44@mail.gmail.com> +In-Reply-To: <758d5e7f05032301351b685c44@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/490 +X-Sequence-Number: 11195 + +Dawid Kuroczko wrote: +> On Wed, 23 Mar 2005 12:11:56 +0800, Michael Ryan S. Puncia +> wrote: +> +>>I have an experience using LIKE in a VARCHAR column and select statement +>>suffers a lot so I decided to go back in CHAR + +> According to the PostgreSQL's documentation: +> +> Tip: There are no performance differences between these three types, +> apart from the increased storage size when using the blank-padded type. +> While character(n) has performance advantages in some other database +> systems, it has no such advantages in PostgreSQL. In most situations text +> or character varying should be used instead. +> +> +> To my best knowledge char and varchar are stored in a same way +> (4-byte length plus textual value), so using char should make tables +> bigger in your case. Then again, having each row exactly the same +> size makes it easier to delete and then later insert a new row in +> a same spot. Am I thinking correct? Is it a case where using char(n) +> makes that table avoid hmm fragmentation of some sort? + +There aren't any noticeable differences between char and varchar. MVCC +doesn't overwrite rows anyway, so static size is irrelevant. In any +case, PG's toast setup splits out large text fields and compresses them +- so it's not that simple. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Sun Mar 27 16:27:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F5CA5336E + for ; + Wed, 23 Mar 2005 12:53:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65317-01 + for ; + Wed, 23 Mar 2005 12:53:14 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id AFDBA5336A + for ; + Wed, 23 Mar 2005 12:53:12 +0000 (GMT) +Received: (qmail 10688 invoked from network); 23 Mar 2005 12:52:08 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 23 Mar 2005 12:52:08 -0000 +Message-ID: <424166B6.2080507@fastcrypt.com> +Date: Wed, 23 Mar 2005 07:53:10 -0500 +From: Dave Cramer +Reply-To: dave@fastcrypt.com +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Junaili Lie +Cc: pgsql-performance@postgresql.org +Subject: Re: Hardware questions +References: <8d04ce990503221732772ec09e@mail.gmail.com> +In-Reply-To: <8d04ce990503221732772ec09e@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/598 +X-Sequence-Number: 11303 + +Junaili, + +I'd suggest you don't buy a dell. The aren't particularly good performers. +Dave + +Junaili Lie wrote: + +>Hi guys, +>We are in the process of buying a new dell server. +>Here is what we need to be able to do: +>- we need to be able to do queries on tables that has 10-20 millions +>of records (around 40-60 bytes each row) in less than 5-7 seconds. +>We also need the hardware to be able to handle up to 50 millions +>records on a few tables (5 tables in the DB). +> +>Here is what we are thinking: +>- Dual Xeon 2.8 Ghz +>- 4GB DDR2 400 Mhz Dual Ranked DIMMS (is dual ranked or single ranked +>makes any differences in terms of performance?). Do you guys think 4GB +>is reasonably enough? +>- 73 GB 15k RPM Ultra 320 SCSI Hard Drive +>- Dual on-board NICS (is this enough, or Gigabit network adapter will help?) +> +>Any input or suggestions is greatly appreciated. +>Thank you, +> +> +>Jun +> +>---------------------------(end of broadcast)--------------------------- +>TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> +> +> +> + +From pgsql-performance-owner@postgresql.org Wed Mar 23 16:55:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F9F753554 + for ; + Wed, 23 Mar 2005 16:55:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46118-07 + for ; + Wed, 23 Mar 2005 16:55:40 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DF1653558 + for ; + Wed, 23 Mar 2005 16:55:40 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2NGtSZB007636; + Wed, 23 Mar 2005 11:55:28 -0500 (EST) +To: "Tambet Matiisen" +Cc: "Neil Conway" , + pgsql-performance@postgresql.org +Subject: Re: SQL function inlining (was: View vs function) +In-reply-to: +References: +Comments: In-reply-to "Tambet Matiisen" + message dated "Wed, 23 Mar 2005 12:03:26 +0200" +Date: Wed, 23 Mar 2005 11:55:28 -0500 +Message-ID: <7635.1111596928@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/491 +X-Sequence-Number: 11196 + +"Tambet Matiisen" writes: +> I observed slowdowns when I declared SQL function as strict. There were +> no slowdowns, when I implmented the same function in plpgsql, in fact it +> got faster with strict, if parameters where NULL. Could it be +> side-effect of SQL function inlining? Is there CASE added around the +> function to not calculate it, when one of the parameters is NULL? + +IIRC we will not inline a STRICT SQL function if the resulting +expression would not behave strict-ly. This is clearly a necessary rule +because inlining would change the behavior otherwise. But the test for +it is pretty simplistic: CASEs are considered not strict, period. So I +think you are measuring the difference between inlined and not-inlined. + +I'd suggest just leaving off the STRICT if you are writing a SQL +function you hope to have inlined. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 23 16:58:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4EB9153379 + for ; + Wed, 23 Mar 2005 16:58:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47400-06 + for ; + Wed, 23 Mar 2005 16:58:11 +0000 (GMT) +Received: from smtp101.rog.mail.re2.yahoo.com (smtp101.rog.mail.re2.yahoo.com + [206.190.36.79]) + by svr1.postgresql.org (Postfix) with SMTP id C2B675357B + for ; + Wed, 23 Mar 2005 16:58:09 +0000 (GMT) +Received: from unknown (HELO phlogiston.dydns.org) + (a.sullivan@rogers.com@216.75.167.195 with login) + by smtp101.rog.mail.re2.yahoo.com with SMTP; 23 Mar 2005 16:58:08 -0000 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id A092D3D2F; Wed, 23 Mar 2005 11:58:07 -0500 (EST) +Date: Wed, 23 Mar 2005 11:58:07 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: PostgreSQL on Solaris 8 and ufs +Message-ID: <20050323165807.GB26236@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <1111525423.9054.16.camel@lanshark.dmv.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.6+20040907i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.025 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/492 +X-Sequence-Number: 11197 + +On Tue, Mar 22, 2005 at 03:23:18PM -0600, Brandon Metcalf wrote: +> s> What are you using to measure +> s> performance? +> +> Nothing too scientific other than the fact that since we have moved +> the DB, we consistenly see a large number of postmater processes +> (close to 100) where before we did not. + +What did you move from? The Solaris ps (not in ucb, which is the +BSD-style ps) shows the parent process name, so everything shows up +as "postmaster" rather than "postgres". There's always one back end +per connection. + +If you are in fact using more connections, by the way, I can tell you +that Solaris 8, in my experience, is _very bad_ at managing context +switches. So you may not be merely I/O bound (although your other +reports seem to indicate that you are). + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +The whole tendency of modern prose is away from concreteness. + --George Orwell + +From pgsql-performance-owner@postgresql.org Wed Mar 23 17:16:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D171C533BB + for ; + Wed, 23 Mar 2005 17:16:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55185-04 + for ; + Wed, 23 Mar 2005 17:16:47 +0000 (GMT) +Received: from zcars04f.nortelnetworks.com (zcars04f.nortelnetworks.com + [47.129.242.57]) + by svr1.postgresql.org (Postfix) with ESMTP id 470245294B + for ; + Wed, 23 Mar 2005 17:16:44 +0000 (GMT) +Received: from zrtps0m6.us.nortel.com (zrtps0m6.us.nortel.com [47.140.192.58]) + by zcars04f.nortelnetworks.com (Switch-2.2.6/Switch-2.2.0) with + ESMTP id j2NHGen14651; Wed, 23 Mar 2005 12:16:40 -0500 (EST) +Received: from cash.rhiamet.com (rhiamet.us.nortel.com [47.103.243.53]) + by zrtps0m6.us.nortel.com (Switch-2.2.6/Switch-2.2.0) with ESMTP id + j2NHGbJ00351; Wed, 23 Mar 2005 12:16:37 -0500 (EST) +Received: from cash.rhiamet.com (bmetcalf@localhost [127.0.0.1]) + by cash.rhiamet.com (8.13.3/8.13.3/Debian-9) with ESMTP id + j2NHGTpp000860; Wed, 23 Mar 2005 11:16:29 -0600 +Received: from localhost (bmetcalf@localhost) + by cash.rhiamet.com (8.13.3/8.13.3/Submit) with ESMTP id j2NHGTDb000856; + Wed, 23 Mar 2005 11:16:29 -0600 +X-Authentication-Warning: cash.rhiamet.com: bmetcalf owned process doing -bs +Date: Wed, 23 Mar 2005 11:16:29 -0600 (CST) +From: "Brandon Metcalf" +X-X-Sender: bmetcalf@cash.rhiamet.com +To: Andrew Sullivan +Cc: pgsql-performance@postgresql.org +Subject: Re: PostgreSQL on Solaris 8 and ufs +In-Reply-To: <20050323165807.GB26236@phlogiston.dyndns.org> +Message-ID: +References: + <1111525423.9054.16.camel@lanshark.dmv.com> + + <20050323165807.GB26236@phlogiston.dyndns.org> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.072 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/493 +X-Sequence-Number: 11198 + +a == ajs@crankycanuck.ca writes: + + a> On Tue, Mar 22, 2005 at 03:23:18PM -0600, Brandon Metcalf wrote: + a> > s> What are you using to measure + a> > s> performance? + a> > + a> > Nothing too scientific other than the fact that since we have moved + a> > the DB, we consistenly see a large number of postmater processes + a> > (close to 100) where before we did not. + + a> What did you move from? The Solaris ps (not in ucb, which is the + a> BSD-style ps) shows the parent process name, so everything shows up + a> as "postmaster" rather than "postgres". There's always one back end + a> per connection. + + a> If you are in fact using more connections, by the way, I can tell you + a> that Solaris 8, in my experience, is _very bad_ at managing context + a> switches. So you may not be merely I/O bound (although your other + a> reports seem to indicate that you are). + + +We moved from an HP-UX 10.20 box where the pgsql installation and data +were on a vxfs fileystem. + +And we're definitely seeing more connections at a time which indicates +that each process is taking longer to complete. + + +-- +Brandon + +From pgsql-performance-owner@postgresql.org Wed Mar 23 17:33:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0190753374 + for ; + Wed, 23 Mar 2005 17:33:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60977-01 + for ; + Wed, 23 Mar 2005 17:32:57 +0000 (GMT) +Received: from mail.jobflash.com (mail.jobflash.com [64.62.211.41]) + by svr1.postgresql.org (Postfix) with ESMTP id 0088153565 + for ; + Wed, 23 Mar 2005 17:32:56 +0000 (GMT) +Received: from [192.168.2.22] (user-2ivfmp8.dialup.mindspring.com + [165.247.219.40]) + by mail.jobflash.com (Postfix) with ESMTP id 3D9AD42002; + Wed, 23 Mar 2005 09:32:54 -0800 (PST) +Message-ID: <4241A817.30805@jobflash.com> +Date: Wed, 23 Mar 2005 09:32:07 -0800 +From: Tom Arthurs +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Brandon Metcalf +Cc: Andrew Sullivan , + pgsql-performance@postgresql.org +Subject: Re: PostgreSQL on Solaris 8 and ufs +References: + <1111525423.9054.16.camel@lanshark.dmv.com> + + <20050323165807.GB26236@phlogiston.dyndns.org> + +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/494 +X-Sequence-Number: 11199 + +On the context switching issue, we've found that this setting in /etc/system helps: + +set rechoose_interval=30 + +this sets the minimum time that a process is eligible to be switched to another cpu. (the default is 3). + +You can monitor context switching with the cs column in vmstat. We've found that high context switching seems to be more a symptom, +rather than a cause of problems -- for example we had an issue with column statistics and some really bad queries, and the cpu's start +context switching like crazy. (20,000 - 50,000 or more in a 5 second period, normally < 5000 per 5 second period under heavy load.) + +Brandon Metcalf wrote: + +> a == ajs@crankycanuck.ca writes: +> +> a> On Tue, Mar 22, 2005 at 03:23:18PM -0600, Brandon Metcalf wrote: +> a> > s> What are you using to measure +> a> > s> performance? +> a> > +> a> > Nothing too scientific other than the fact that since we have moved +> a> > the DB, we consistenly see a large number of postmater processes +> a> > (close to 100) where before we did not. +> +> a> What did you move from? The Solaris ps (not in ucb, which is the +> a> BSD-style ps) shows the parent process name, so everything shows up +> a> as "postmaster" rather than "postgres". There's always one back end +> a> per connection. +> +> a> If you are in fact using more connections, by the way, I can tell you +> a> that Solaris 8, in my experience, is _very bad_ at managing context +> a> switches. So you may not be merely I/O bound (although your other +> a> reports seem to indicate that you are). +> +> +> We moved from an HP-UX 10.20 box where the pgsql installation and data +> were on a vxfs fileystem. +> +> And we're definitely seeing more connections at a time which indicates +> that each process is taking longer to complete. +> +> + +From pgsql-performance-owner@postgresql.org Wed Mar 23 17:55:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A7BD53385 + for ; + Wed, 23 Mar 2005 17:55:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67152-04 + for ; + Wed, 23 Mar 2005 17:55:11 +0000 (GMT) +Received: from smtp102.rog.mail.re2.yahoo.com (smtp102.rog.mail.re2.yahoo.com + [206.190.36.80]) + by svr1.postgresql.org (Postfix) with SMTP id 9A8725294B + for ; + Wed, 23 Mar 2005 17:55:09 +0000 (GMT) +Received: from unknown (HELO phlogiston.dydns.org) + (a.sullivan@rogers.com@216.75.167.195 with login) + by smtp102.rog.mail.re2.yahoo.com with SMTP; 23 Mar 2005 17:55:09 -0000 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 85B593F9C; Wed, 23 Mar 2005 12:55:07 -0500 (EST) +Date: Wed, 23 Mar 2005 12:55:07 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: PostgreSQL on Solaris 8 and ufs +Message-ID: <20050323175507.GC26236@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <1111525423.9054.16.camel@lanshark.dmv.com> + + <20050323165807.GB26236@phlogiston.dyndns.org> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.6+20040907i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/495 +X-Sequence-Number: 11200 + +On Wed, Mar 23, 2005 at 11:16:29AM -0600, Brandon Metcalf wrote: +> +> We moved from an HP-UX 10.20 box where the pgsql installation and data +> were on a vxfs fileystem. + +My best guess, then, is that ufs tuning really is your issue. We +always used vxfs for our Sun database servers (which was a nightmare +all on its own, BTW, so I don't actually recommend this), so I don't +have any real ufs tuning advice. + +The Packer Solaris database book (Packer, Allan N., _Configuring & +Tuning Databases on the Solaris Platform_. Palo Alto: Sun +Microsystems P, 2002. ISBN 0-13-083417-3) does suggest mounting the +filesystems with forcedirectio; I dimly recall using this for the wal +partition on one test box, and STR that it helped. Also, you want to +make sure you use the right fsync method; if it's still set to +"fsync" in the config file, you'll want to change that. I remember +finding that fsync was something like 3 times slower than everything +else. I don't have any more Solaris boxes to check, but I believe we +were using open_datasync as our method. You'll want to run some +tests. + +You also should enable priority paging, but expect that this will +give you really strange po numbers from vmstat and friends. Priority +paging, I found, makes things look like you're swapping when you +aren't. Procmem is useful, but if you really want the goods on +what's going on, you need the SE toolkit. Just be careful using it +as root -- in some cases it'll modify kernel parameters behind the +scenes. In my case, I didn't have superuser access, so there wasn't +a danger; but I've heard sysadmins complain about this. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +This work was visionary and imaginative, and goes to show that visionary +and imaginative work need not end up well. + --Dennis Ritchie + +From pgsql-performance-owner@postgresql.org Wed Mar 23 17:59:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F1C95357B + for ; + Wed, 23 Mar 2005 17:59:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67566-09 + for ; + Wed, 23 Mar 2005 17:59:01 +0000 (GMT) +Received: from smtp102.rog.mail.re2.yahoo.com (smtp102.rog.mail.re2.yahoo.com + [206.190.36.80]) + by svr1.postgresql.org (Postfix) with SMTP id B114553554 + for ; + Wed, 23 Mar 2005 17:59:00 +0000 (GMT) +Received: from unknown (HELO phlogiston.dydns.org) + (a.sullivan@rogers.com@216.75.167.195 with login) + by smtp102.rog.mail.re2.yahoo.com with SMTP; 23 Mar 2005 17:59:00 -0000 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 774C83F9C; Wed, 23 Mar 2005 12:58:59 -0500 (EST) +Date: Wed, 23 Mar 2005 12:58:59 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: PostgreSQL on Solaris 8 and ufs +Message-ID: <20050323175859.GD26236@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <1111525423.9054.16.camel@lanshark.dmv.com> + + <20050323165807.GB26236@phlogiston.dyndns.org> + + <4241A817.30805@jobflash.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4241A817.30805@jobflash.com> +User-Agent: Mutt/1.5.6+20040907i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.049 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/496 +X-Sequence-Number: 11201 + +On Wed, Mar 23, 2005 at 09:32:07AM -0800, Tom Arthurs wrote: +> found that high context switching seems to be more a symptom, + +Yes, that's a good point. It usually _is_ a symptom; but it might be +a symptom that you've got an expensive query, and Solaris's foot-gun +approach to handling such cases is a little painful. (We didn't give +up on Solaris because of cs problems, BTW; but I have to say that AIX +seems to be a little less prone to self-DOS on this front than +Solaris was. If you really want to hear me rant, ask me some time +about ecache and Sun support.) + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +The plural of anecdote is not data. + --Roger Brinner + +From pgsql-bugs-owner@postgresql.org Wed Mar 23 19:22:13 2005 +X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2860452A2E + for ; + Wed, 23 Mar 2005 19:22:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93192-07 + for ; + Wed, 23 Mar 2005 19:22:09 +0000 (GMT) +Received: from deepsky.com (outrider.deepsky.com [66.207.216.43]) + by svr1.postgresql.org (Postfix) with SMTP id 5A5295295D + for ; Wed, 23 Mar 2005 19:22:08 +0000 (GMT) +Received: (qmail 2599 invoked from network); 23 Mar 2005 19:22:08 -0000 +Received: from unknown (HELO ?127.0.0.1?) (66.207.216.43) + by outrider.deepsky.com with SMTP; 23 Mar 2005 19:22:08 -0000 +Message-ID: <4241C1DF.2020000@deepsky.com> +Date: Wed, 23 Mar 2005 14:22:07 -0500 +From: Keith Browne +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Simon Riggs , pgsql-bugs@postgresql.org +Cc: Brian O'Reilly +Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 +References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> + <1111567230.11750.596.camel@localhost.localdomain> +In-Reply-To: <1111567230.11750.596.camel@localhost.localdomain> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/203 +X-Sequence-Number: 11323 + +Simon Riggs wrote: + +> The EXPLAINs you've enclosed are for SELECTs, yet your bug report +> describes INSERTs as being the things that are slow. +> [You may find better performance from using COPY] + +Simon, + +Brian and I are working together on this problem. + +We're starting with an empty database, creating four tables, and +populating those tables with a total of 180,000-200,000 rows. Each +table has a primary key, and several of the tables reference foreign +keys in other tables. We've written a Python script, using psycopg, +which executes all the queries to create the tables and insert the rows. + The database is running on the same machine where the script runs. + +I've seen similar performance when issuing a COMMIT after each +insertion, and also after batching insertions in blocks of 250 per +COMMIT, so batching the commits is not helping much. I've looked at the +possibility of using COPY, but in our production environment it will be +prohibitive to build a flat file with all this data. I'd rather +generate it on the fly, as we've been able to do with PostgreSQL 7.4. + +> Also, your tests have compared two systems, so it might be that the +> hardware or configuration of one system is different from the other. + +When running with PostgreSQL 7.4 on a dual-CPU Athlon MP2400+ machine +with a gigabyte of RAM, running Debian Linux version 2.6.8.1, we were +able to insert all this data in 5-7 minutes. It's taken a while to +install Postgres 8.0.1 on the same machine, but now I have, and it's +taking 40-45 minutes to run the same insert script. This is similar to +the performance we saw on another machine, a fast single-CPU AMD64 box +running Gentoo. + +I don't think it's a hardware issue. I dug around a bit, and found +suggestions that this sort of problem could be worked around by breaking +the database connection and restarting it after the tables had been +partially filled. I modified our script to break and re-establish the +database connection when each table first has 4,000 records inserted, +and the performance is greatly improved; it now takes only about 3.5 +minutes to insert 180,000+ rows. + +I've since modified this script to build and populate a fifth table with +over 1.3 million rows. The fifth table has no primary key, but lists a +foreign key into one of the first four tables. With the above +modification (break and re-build the DB connection after 4,000 rows have +been inserted), the whole database can be populated in about 15 minutes. + I wouldn't have dared try to build a one-million-plus-row table until +I found this speed-up. + +> If you could repeat the test on one single system, then this would +> assist in the diagnosis of this bug report. Also, if you could describe +> the workload that is giving you a problem more exactly, that would help. +> Specifically, can you confirm that you have run ANALYZE on the tables, +> and also give us some idea of numbers of rows in each table at the time +> you first run your programs. + +Just to see if it would help, I tried modifying the script to run an +ANALYZE against each table after 4,000 insertions, instead of breaking +and re-establishing the DB connection. I still saw ~45-minute times to +insert 180,000 rows. I then tried running ANALYZE against each table +after *each* 4,000 rows inserted, and again, it took about 45 minutes to +run the insert. + +Each table is empty when I first run the program. I am dropping and +re-creating the database for each test run. + +> There is clearly a problem, but it is not yet clearly a bug. If it is a +> bug, we're interested in solving it as much as you. + +I'd be happy to run further tests or provide more details, if they'll +help. We now have a workaround which is allowing us to proceed with our +project, but I'd like to know if there's another way to do this. While +I understand that large or complex databases require careful tuning, I +was surprised to see a six- or seven-fold increase in run times between +PostgreSQL 7.4 and 8.0.1 on the same hardware, on an operation which +seems fairly straightforward: populating an empty table. + +One other thing which puzzled me: as a test, I tried modifying our +script to spit out raw SQL statements instead of connecting to the +database and performing the inserts itself. Normally, our script +populates two tables in one pass, and then populates the third and +fourth tables in a second pass. I massaged the SQL by hand to group the +inserts together by table, so that the first table would be entirely +populated, then the second, etc. When I ran this SQL script by piping +it straight into psql, it finished in about four minutes. This is +comparable to the time it takes to run my modified script which breaks +and re-establishes the connection to the database. + +It would appear that psql is doing something right here which we have +had to go out of our way to get with psycopg. + +Keith Browne +tuxedo@deepsky.com + +From pgsql-bugs-owner@postgresql.org Wed Mar 23 19:47:14 2005 +X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4467953237 + for ; + Wed, 23 Mar 2005 19:47:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99762-09 + for ; + Wed, 23 Mar 2005 19:46:53 +0000 (GMT) +Received: from floppy.pyrenet.fr (unknown [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B2875336E + for ; Wed, 23 Mar 2005 19:46:52 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id E940430EA1; Wed, 23 Mar 2005 20:46:53 +0100 (MET) +From: Andrew - Supernews +X-Newsgroups: pgsql.bugs +Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 +Date: Wed, 23 Mar 2005 19:46:50 -0000 +Organization: http://www.supernews.com - all your nntp are belong to us +Message-ID: +References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> + <1111567230.11750.596.camel@localhost.localdomain> + <4241C1DF.2020000@deepsky.com> +Reply-To: andrew@supernews.com +User-Agent: slrn/0.9.8.0 (FreeBSD) +X-Complaints-To: abuse@supernews.com +Lines: 20 +To: pgsql-bugs@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/204 +X-Sequence-Number: 11324 + +On 2005-03-23, Keith Browne wrote: +> One other thing which puzzled me: as a test, I tried modifying our +> script to spit out raw SQL statements instead of connecting to the +> database and performing the inserts itself. Normally, our script +> populates two tables in one pass, and then populates the third and +> fourth tables in a second pass. I massaged the SQL by hand to group the +> inserts together by table, so that the first table would be entirely +> populated, then the second, etc. When I ran this SQL script by piping +> it straight into psql, it finished in about four minutes. + +Changing the order so that the referenced table is fully populated, or at +least populated with more than a handful of pages of rows, before doing +_any_ insert on a referencing table in the same session will avoid the +misplan of the FK trigger queries, because when the first insert happens +on a referencing table, there will be no reason for the planner to prefer +a sequential scan. So this result is not surprising at all. + +-- +Andrew, Supernews +http://www.supernews.com - individual and corporate NNTP services + +From pgsql-bugs-owner@postgresql.org Wed Mar 23 20:12:57 2005 +X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CF9053598 + for ; + Wed, 23 Mar 2005 20:12:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10592-02 + for ; + Wed, 23 Mar 2005 20:12:43 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5041D535A6 + for ; Wed, 23 Mar 2005 20:12:42 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2NKChl9013842; + Wed, 23 Mar 2005 15:12:43 -0500 (EST) +To: andrew@supernews.com +Cc: pgsql-bugs@postgresql.org, Keith Browne , + "Brian O'Reilly" +Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 +In-reply-to: +References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> + <1111567230.11750.596.camel@localhost.localdomain> + <4241C1DF.2020000@deepsky.com> + +Comments: In-reply-to Andrew - Supernews + message dated "Wed, 23 Mar 2005 19:46:50 +0000" +Date: Wed, 23 Mar 2005 15:12:43 -0500 +Message-ID: <13841.1111608763@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/208 +X-Sequence-Number: 11328 + +Andrew - Supernews writes: +> Changing the order so that the referenced table is fully populated, or at +> least populated with more than a handful of pages of rows, before doing +> _any_ insert on a referencing table in the same session will avoid the +> misplan of the FK trigger queries, because when the first insert happens +> on a referencing table, there will be no reason for the planner to prefer +> a sequential scan. So this result is not surprising at all. + +I'm still looking for an example that demonstrates why this is a common +problem that we need to worry about. ISTM that if an FK reference is +hit when there are still zero entries in the referenced table, that +insertion will fail anyway, and so people wouldn't try to load data in +such an order. + +In the long term it would be good to replan the FK plans when the +referenced tables have grown so much that the plan ought to change. +Once we have the plan invalidation machinery that Neil is working on, +it might be fairly practical to do that; but no such thing is going +to appear in existing release branches of course. + +We could band-aid this in 8.0 as previously suggested (have the planner +assume > 0 pages when it sees actually 0 pages) but without seeing a +concrete example I can't tell if that will fix the complaint or not. + + regards, tom lane + +From pgsql-bugs-owner@postgresql.org Wed Mar 23 20:55:14 2005 +X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D84753578 + for ; + Wed, 23 Mar 2005 20:55:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22728-06 + for ; + Wed, 23 Mar 2005 20:55:09 +0000 (GMT) +Received: from deepsky.com (outrider.deepsky.com [66.207.216.43]) + by svr1.postgresql.org (Postfix) with SMTP id 40D6D533AA + for ; Wed, 23 Mar 2005 20:55:08 +0000 (GMT) +Received: (qmail 24872 invoked from network); 23 Mar 2005 20:55:09 -0000 +Received: from unknown (HELO ?127.0.0.1?) (66.207.216.43) + by outrider.deepsky.com with SMTP; 23 Mar 2005 20:55:09 -0000 +Message-ID: <4241D7AB.4030607@deepsky.com> +Date: Wed, 23 Mar 2005 15:55:07 -0500 +From: Keith Browne +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane , pgsql-bugs@postgresql.org +Cc: andrew@supernews.com, Brian O'Reilly +Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 +References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> + <1111567230.11750.596.camel@localhost.localdomain> + <4241C1DF.2020000@deepsky.com> + + <13841.1111608763@sss.pgh.pa.us> +In-Reply-To: <13841.1111608763@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/211 +X-Sequence-Number: 11331 + +Tom Lane wrote: + +> I'm still looking for an example that demonstrates why this is a common +> problem that we need to worry about. ISTM that if an FK reference is +> hit when there are still zero entries in the referenced table, that +> insertion will fail anyway, and so people wouldn't try to load data in +> such an order. + +Tom, + +We're filling pairs of tables with rows having nearly a one-to-one +mapping; very rarely, the second table will have multiple rows +corresponding to one row in the first table. When we insert the first +row in the second table, therefore, we've just put the corresponding row +into the first table, so the foreign key constraint is satisfied. + +I can't say how common this sort of thing will be. It appears to me +that BUG #1541 is similar to what we're seeing, and a search of the +mailing lists also turns up this message: + +http://archives.postgresql.org/pgsql-performance/2004-11/msg00416.php + +which also describes symptoms similar to what I'm seeing. + +> We could band-aid this in 8.0 as previously suggested (have the planner +> assume > 0 pages when it sees actually 0 pages) but without seeing a +> concrete example I can't tell if that will fix the complaint or not. + +It sounds like this could work for us, if it would disable sequential +searches into a table which grows from 0 to >60,000 rows in one session. + Is breaking and re-establishing the database session the best +workaround, or is there a better way to provide a hint to the planner? + +Regards, + +Keith Browne +tuxedo@deepsky.com + +From pgsql-bugs-owner@postgresql.org Wed Mar 23 21:27:11 2005 +X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C1C35362F + for ; + Wed, 23 Mar 2005 21:27:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34880-08 + for ; + Wed, 23 Mar 2005 21:27:00 +0000 (GMT) +Received: from floppy.pyrenet.fr (unknown [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DFC215362B + for ; Wed, 23 Mar 2005 21:26:54 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 1594530EA2; Wed, 23 Mar 2005 22:26:56 +0100 (MET) +From: Andrew - Supernews +X-Newsgroups: pgsql.bugs +Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 +Date: Wed, 23 Mar 2005 21:26:55 -0000 +Organization: http://www.supernews.com - all your nntp are belong to us +Message-ID: +References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> + <1111567230.11750.596.camel@localhost.localdomain> + <4241C1DF.2020000@deepsky.com> + + <13841.1111608763@sss.pgh.pa.us> +Reply-To: andrew@supernews.com +User-Agent: slrn/0.9.8.0 (FreeBSD) +X-Complaints-To: abuse@supernews.com +Lines: 31 +To: pgsql-bugs@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/219 +X-Sequence-Number: 11339 + +On 2005-03-23, Tom Lane wrote: +> Andrew - Supernews writes: +>> Changing the order so that the referenced table is fully populated, or at +>> least populated with more than a handful of pages of rows, before doing +>> _any_ insert on a referencing table in the same session will avoid the +>> misplan of the FK trigger queries, because when the first insert happens +>> on a referencing table, there will be no reason for the planner to prefer +>> a sequential scan. So this result is not surprising at all. +> +> I'm still looking for an example that demonstrates why this is a common +> problem that we need to worry about. ISTM that if an FK reference is +> hit when there are still zero entries in the referenced table, that +> insertion will fail anyway, and so people wouldn't try to load data in +> such an order. + +Think "1 row", not "0 rows". + +It is not reasonable to assume that _all_ cases of data loading (other than +perhaps the very largest) will be done by loading entire tables at a time, +especially when importing from external sources where the data is +differently structured. + +> We could band-aid this in 8.0 as previously suggested (have the planner +> assume > 0 pages when it sees actually 0 pages) but without seeing a +> concrete example I can't tell if that will fix the complaint or not. + +It won't; the problem is with 1 page, not 0. + +-- +Andrew, Supernews +http://www.supernews.com - individual and corporate NNTP services + +From pgsql-bugs-owner@postgresql.org Wed Mar 23 22:13:50 2005 +X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DCCAE534F4 + for ; + Wed, 23 Mar 2005 22:13:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47570-09 + for ; + Wed, 23 Mar 2005 22:13:40 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F8D9534F3 + for ; Wed, 23 Mar 2005 22:13:39 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2NMDesK014847; + Wed, 23 Mar 2005 17:13:40 -0500 (EST) +To: Keith Browne +Cc: pgsql-bugs@postgresql.org, andrew@supernews.com, + "Brian O'Reilly" +Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 +In-reply-to: <4241D7AB.4030607@deepsky.com> +References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> + <1111567230.11750.596.camel@localhost.localdomain> + <4241C1DF.2020000@deepsky.com> + + <13841.1111608763@sss.pgh.pa.us> <4241D7AB.4030607@deepsky.com> +Comments: In-reply-to Keith Browne + message dated "Wed, 23 Mar 2005 15:55:07 -0500" +Date: Wed, 23 Mar 2005 17:13:40 -0500 +Message-ID: <14846.1111616020@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/225 +X-Sequence-Number: 11345 + +Keith Browne writes: +> Tom Lane wrote: +>> I'm still looking for an example that demonstrates why this is a common +>> problem that we need to worry about. + +> We're filling pairs of tables with rows having nearly a one-to-one +> mapping; very rarely, the second table will have multiple rows +> corresponding to one row in the first table. When we insert the first +> row in the second table, therefore, we've just put the corresponding row +> into the first table, so the foreign key constraint is satisfied. + +Hmm ... + +>> We could band-aid this in 8.0 as previously suggested (have the planner +>> assume > 0 pages when it sees actually 0 pages) but without seeing a +>> concrete example I can't tell if that will fix the complaint or not. + +> It sounds like this could work for us, + +No, it wouldn't, because by the time you do the first FK trigger you'd +have one row/one page in the referenced table, so it'd still look like a +seqscan situation to the planner. The only way we could make that work +is to effectively disable seqscans entirely, by *always* pretending the +table size is large enough to trigger an indexscan, even when the +planner can plainly see that it's not. This is not an acceptable answer +IMHO. + +[ thinks for a bit... ] The reason 7.4 and before worked reasonably +for you is that they assumed the 10/1000 statistics for any +never-yet-vacuumed table, whether it is empty or not. (This worked fine +for your problem but shot a lot of other people in the foot, because +that's what the estimate would stay at even if the table grew vastly +larger, so long as it wasn't vacuuumed.) Maybe we could +put in a hack that detects whether a table has yet been vacuumed, and +sets 10/1000 as the minimum stats --- not fixed values, but minimum +values that can be overridden when the table is actually larger --- +until it has been vacuumed. I'm not sure if this is workable. It looks +to me like we'd have to approximate the "never vacuumed" condition by +checking whether pg_class.reltuples and relpages are both zero, which +is the initial condition all right but would also arise after a vacuum +finds nothing in the table. So basically the planner would never +optimize the entirely-empty-table condition properly, even after vacuum. +Maybe this is the least bad alternative for 8.0.*. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 23 23:35:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B452952A61 + for ; + Wed, 23 Mar 2005 23:35:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70910-06 + for ; + Wed, 23 Mar 2005 23:34:58 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id E45AC5295D + for ; + Wed, 23 Mar 2005 23:34:56 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [67.103.45.218] (account josh@agliodbs.com HELO + [192.168.1.122]) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7160514; Wed, 23 Mar 2005 15:36:49 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Andrew Sullivan +Subject: Re: PostgreSQL on Solaris 8 and ufs +Date: Wed, 23 Mar 2005 15:39:34 -0800 +User-Agent: KMail/1.7.1 +Cc: pgsql-performance@postgresql.org +References: + + <20050323175507.GC26236@phlogiston.dyndns.org> +In-Reply-To: <20050323175507.GC26236@phlogiston.dyndns.org> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200503231539.34978.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/497 +X-Sequence-Number: 11202 + +Andrew, + +> The Packer Solaris database book (Packer, Allan N., _Configuring & +> Tuning Databases on the Solaris Platform_. =A0Palo Alto: Sun +> Microsystems P, 2002. =A0ISBN 0-13-083417-3) does suggest mounting the +> filesystems with forcedirectio; I dimly recall using this for the wal +> partition on one test box, and STR that it helped. + +This is a good idea for a WAL partition, but is NOT a good idea for the=20 +database. + +You pay want to look into setting segmap_percent to 70% or something. On= +=20 +Solaris 10 at least, the OS by default only uses 10% of memory for disk=20 +buffers. =20 + +=2D-=20 +=2D-Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-bugs-owner@postgresql.org Thu Mar 24 09:14:42 2005 +X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4748552A05 + for ; + Thu, 24 Mar 2005 09:14:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36022-09 + for ; + Thu, 24 Mar 2005 09:14:32 +0000 (GMT) +Received: from floppy.pyrenet.fr (unknown [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F3FA352956 + for ; Thu, 24 Mar 2005 09:14:31 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 121A030EA1; Thu, 24 Mar 2005 10:14:28 +0100 (MET) +From: Andrew - Supernews +X-Newsgroups: pgsql.bugs +Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 +Date: Thu, 24 Mar 2005 09:14:25 -0000 +Organization: http://www.supernews.com - all your nntp are belong to us +Message-ID: +References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> + <1111567230.11750.596.camel@localhost.localdomain> + <4241C1DF.2020000@deepsky.com> + + <13841.1111608763@sss.pgh.pa.us> <4241D7AB.4030607@deepsky.com> + <14846.1111616020@sss.pgh.pa.us> +Reply-To: andrew@supernews.com +User-Agent: slrn/0.9.8.0 (FreeBSD) +X-Complaints-To: abuse@supernews.com +Lines: 20 +To: pgsql-bugs@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/254 +X-Sequence-Number: 11374 + +On 2005-03-23, Tom Lane wrote: +> No, it wouldn't, because by the time you do the first FK trigger you'd +> have one row/one page in the referenced table, so it'd still look like a +> seqscan situation to the planner. The only way we could make that work +> is to effectively disable seqscans entirely, by *always* pretending the +> table size is large enough to trigger an indexscan, even when the +> planner can plainly see that it's not. This is not an acceptable answer +> IMHO. + +I'm not yet convinced the planner is right to _ever_ choose a seqscan for +FK triggers. The idea that a seqscan is faster on small tables is +traditional, and it has some justification in the case where nothing is +in the cache (since index scan will touch the disk twice in that case), +but I'm finding that for tables of the order of 50 rows (easily fitting in +one page) that index scans are as fast as or faster than seqscans for +doing simple one-row lookups provided the tables are in cache. + +-- +Andrew, Supernews +http://www.supernews.com - individual and corporate NNTP services + +From pgsql-performance-owner@postgresql.org Thu Mar 24 09:35:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7908053657 + for ; + Thu, 24 Mar 2005 09:35:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42542-07 + for ; + Thu, 24 Mar 2005 09:35:02 +0000 (GMT) +Received: from felix.adpcl.com (felix.adpcl.com [194.98.137.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 5345C533FD + for ; + Thu, 24 Mar 2005 09:34:59 +0000 (GMT) +Received: from pcpatrickxp (unknown [150.175.11.30]) + by felix.adpcl.com (Postfix) with SMTP + id 127247804; Thu, 24 Mar 2005 10:38:04 +0100 (NFT) +Message-ID: <004d01c53054$965583e0$1e0baf96@pcpatrickxp> +From: "Patrick Vedrines" +To: "Gustavo F Nobrega - Planae" +Cc: "performance pgsql" +References: <002601c52f0a$2312a4d0$280baf96@PCPATRICK> + <424063BC.3050206@planae.com.br> +Subject: Re: CPU 0.1% IOWAIT 99% for decisonnal queries +Date: Thu, 24 Mar 2005 10:33:50 +0100 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_004A_01C5305C.F7FD3C20" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.474 tagged_above=0 required=5 tests=AWL, HTML_50_60, + HTML_MESSAGE, HTML_TITLE_EMPTY +X-Spam-Level: +X-Archive-Number: 200503/498 +X-Sequence-Number: 11203 + +This is a multi-part message in MIME format. + +------=_NextPart_000_004A_01C5305C.F7FD3C20 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hello Gustavo, + +Your question seems to say that you suspect a disk issue, and a few = +hours later, Simon told me "Sounds like your disks/layout/something is = +pretty sick". +To be clear in my own mind about it, I've just copyed (time cp) the = +"aggregate" table files (4 Gb) from one disk to an another one: it takes = +22 mn !(3 Mb/s). +That seems to demonstrate that Postgres is not the cause of this issue.=20 +I've just untrusted to my system engineer the analysis of my disks... + +In case I would have to change my disks, do you have any performance = +figures related to the types you mentionned (reiserfs vs ext3) ? +I don't use RAID since the security is not a concern. + +Thank a lot for your help ! + +Patrick + + Hi Patrick, + + How is configured your disk array? Do you have a Perc 4? + + Tip: Use reiserfs instead ext3, raid 0+1 and deadline I/O scheduler in = +kernel linux 2.6 + + +------=_NextPart_000_004A_01C5305C.F7FD3C20 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
+
Hello Gustavo,
+
 
+
Your question seems to say that you = +suspect a disk=20 +issue, and a few hours later, Simon told me "Sounds like your=20 +disks/layout/something is pretty sick".
+
To be clear in my own mind about it, = +I've just=20 +copyed (time cp) the "aggregate" table files (4 Gb) from one disk to an = +another=20 +one: it takes 22 mn !(3 Mb/s).
+
That seems to demonstrate that Postgres = +is not the=20 +cause of this issue.
+
I've just untrusted to my system = +engineer the=20 +analysis of my disks...
+
 
+
In case I would have to change my = +disks, do you=20 +have any performance figures related to the types you mentionned = +(reiserfs=20 +vs ext3) ?
+
I don't use RAID since the security is = +not a=20 +concern.
+
 
+
Thank a lot for your help = +!
+
 
+
Patrick
+
+
 
Hi=20 + Patrick,

    How is configured your disk array? = +Do you=20 + have a Perc 4?

Tip: Use reiserfs instead ext3, raid 0+1 and = +deadline=20 + I/O scheduler in kernel linux 2.6
 
+ +------=_NextPart_000_004A_01C5305C.F7FD3C20-- + + +From pgsql-performance-owner@postgresql.org Thu Mar 24 09:49:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0268453641 + for ; + Thu, 24 Mar 2005 09:49:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48689-02 + for ; + Thu, 24 Mar 2005 09:49:42 +0000 (GMT) +Received: from felix.adpcl.com (felix.adpcl.com [194.98.137.100]) + by svr1.postgresql.org (Postfix) with ESMTP id DA55E53643 + for ; + Thu, 24 Mar 2005 09:49:41 +0000 (GMT) +Received: from pcpatrickxp (unknown [150.175.11.30]) + by felix.adpcl.com (Postfix) with SMTP + id 976267804; Thu, 24 Mar 2005 10:52:46 +0100 (NFT) +Message-ID: <006801c53056$a4585420$1e0baf96@pcpatrickxp> +From: "Patrick Vedrines" +To: "Simon Riggs" +Cc: "performance pgsql" +References: <002601c52f0a$2312a4d0$280baf96@PCPATRICK> + <1111529891.11750.577.camel@localhost.localdomain> +Subject: Re: CPU 0.1% IOWAIT 99% for decisonnal queries +Date: Thu, 24 Mar 2005 10:48:33 +0100 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0065_01C5305F.06073850" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.314 tagged_above=0 required=5 tests=AWL, HTML_40_50, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200503/499 +X-Sequence-Number: 11204 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0065_01C5305F.06073850 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hello Simon, + +> Sounds like your disks/layout/something is pretty sick. You don't +> mention I/O bandwidth, controller or RAID, so you should look more = +into +> those topics. +Well seen ! (as we say in France). +As I said to Gustavo, your last suspicion took me into a simple disk = +test: I've just copyed (time cp) the "aggregate" table files (4 Gb) from = +one disk to an another one: it takes 22 mn !(3 Mb/s). +That seems to demonstrate that Postgres is not the cause of this issue.=20 +I've just untrusted to my system engineer the analysis of my disks... + +> Setting shared_buffers that high will do you no good at all, as = +Richard +> suggests. +I (and my own tests) agree my you. + +> You've got 1.5Gb of shared_buffers and > 2Gb data. In 8.0, the scan = +will +> hardly use the cache at all, nor will it ever, since the data is = +bigger +> than the cache. Notably, the scan of B should NOT spoil the cache for = +A +Are you sure of that ? Is Postgres able to say to OS: "don't use the = +cache for this query"? + +> Priming the cache is quite hard...but not impossible. +> What will kill you on a shared_buffers that big is the bgwriter, which +> you should turn off by setting bgwriter_maxpages =3D 0 +Is bgwriter concerned as my application applyes only SELECT ? + +>=20 +> On the other hand...just go for more RAM, as you suggest...but you +> should create a RAMdisk, rather than use too large +> shared_buffers....that way your data is always in RAM, rather than = +maybe +> in RAM. +I am not an Linux expert: Is it possible (and how) to create a RAMdisk ? + + + + +Thank a lot for your help ! + +Patrick +------=_NextPart_000_0065_01C5305F.06073850 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
+
+
Hello Simon,
+
 
+
> Sounds like your = +disks/layout/something is=20 +pretty sick. You don't
> mention I/O bandwidth, controller or = +RAID, so you=20 +should look more into
> those topics.
Well seen ! (as we say in = + +France).
+
As I said to Gustavo, your last = +suspicion took me=20 +into a simple disk test: I've just copyed (time cp) the "aggregate" = +table files=20 +(4 Gb) from one disk to an another one: it takes 22 mn !(3 = +Mb/s).
+
That seems to demonstrate that Postgres = +is not the=20 +cause of this issue.
+
I've just untrusted to my system = +engineer the=20 +analysis of my disks...
+
 
+
> Setting shared_buffers that high = +will do you=20 +no good at all, as Richard
> suggests.
I (and my own tests) = +agree my=20 +you.
+

> You've got 1.5Gb of = +shared_buffers and=20 +> 2Gb data. In 8.0, the scan will
> hardly use the cache at = +all, nor=20 +will it ever, since the data is bigger
> than the cache. Notably, = +the scan=20 +of B should NOT spoil the cache for A
Are you sure of that ? Is = +Postgres able=20 +to say to OS: "don't use the cache for this query"?
+

> Priming the cache is quite = +hard...but not=20 +impossible.
> What will kill you on a shared_buffers that big is = +the=20 +bgwriter, which
> you should turn off by setting bgwriter_maxpages = +=3D=20 +0
+
Is bgwriter concerned as my application = +applyes=20 +only SELECT ?
+

>
> On the other = +hand...just go for=20 +more RAM, as you suggest...but you
> should create a RAMdisk, = +rather than=20 +use too large
> shared_buffers....that way your data is always in = +RAM,=20 +rather than maybe
> in RAM.
I am not an Linux expert: Is it = +possible=20 +(and how) to create a RAMdisk ?
+
 
+
 
+

+
Thank a lot for your help = +!
+
 
+
Patrick
+ +------=_NextPart_000_0065_01C5305F.06073850-- + + +From pgsql-performance-owner@postgresql.org Thu Mar 24 10:10:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C794953407 + for ; + Thu, 24 Mar 2005 10:10:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52701-09 + for ; + Thu, 24 Mar 2005 10:10:04 +0000 (GMT) +Received: from felix.adpcl.com (felix.adpcl.com [194.98.137.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B471533FC + for ; + Thu, 24 Mar 2005 10:10:03 +0000 (GMT) +Received: from pcpatrickxp (unknown [150.175.11.30]) + by felix.adpcl.com (Postfix) with SMTP + id 81BDB7804; Thu, 24 Mar 2005 11:13:08 +0100 (NFT) +Message-ID: <007a01c53059$7ca13750$1e0baf96@pcpatrickxp> +From: "Patrick Vedrines" +To: "Richard Huxton" +Cc: "performance pgsql" +References: <002601c52f0a$2312a4d0$280baf96@PCPATRICK> + <42406A9F.9040404@archonet.com> +Subject: Re: CPU 0.1% IOWAIT 99% for decisonnal queries +Date: Thu, 24 Mar 2005 11:08:55 +0100 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.206 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/500 +X-Sequence-Number: 11205 + +Hello Richard, + +> Perhaps look into clustering the tables. +Good idea : I will try to go further into this way. + +> > There is no index on the aggregate table since the criterias, their +> > number and their scope are freely choosen by the customers. +> +> Hmm... not convinced this is a good idea. +Long days ago, when my application used Informix, I've try to index the +aggregate table: It was a nightmare to manage all these indexes (and their +volume) for a uncertain benefit. + +> If you don't have any indexes and the table isn't clustered then PG has +> no choice but to scan the entire table for every query. As you note, +> that's going to destroy your cache. You can increase the RAM but sooner +> or later, you'll get the same problem. +I agree with you : You remarks take me not to rely to the cache features. + +> 3. Split your tables into two - common fields, uncommon fields, that way +> filtering on the common fields might take less space. +> 4. Split your tables by date, one table per month or year. Then re-write +> your customers' queries on-the-fly to select from the right table. Will +> only help with queries on date of course. +That forces me to rewrite my query generator which is already a very complex +program (in fact the heart of the system) + +> 5. Place each database on its own machine or virtual machine so they +> don't interfere with each other. +I'm afraid I don't have the money for that. As Simon and Gustavo suggested, +I will check my SCSI disks first. + + +Thank a lot for your advises ! + +Amicalement, + +Patrick + + + +From pgsql-performance-owner@postgresql.org Sun Mar 27 16:26:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B363B53418 + for ; + Thu, 24 Mar 2005 10:27:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59370-03 + for ; + Thu, 24 Mar 2005 10:27:18 +0000 (GMT) +Received: from floppy.pyrenet.fr (unknown [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 80EF652955 + for ; + Thu, 24 Mar 2005 10:27:17 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 60A4130EA1; Thu, 24 Mar 2005 11:27:19 +0100 (MET) +From: Hannes Dorbath +X-Newsgroups: pgsql.performance +Subject: Query Optimizer Failure / Possible Bug +Date: Thu, 24 Mar 2005 11:31:11 +0100 +Organization: Hub.Org Networking Services +Lines: 45 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/597 +X-Sequence-Number: 11302 + +The query and the corresponding EXPLAIN is at + +http://hannes.imos.net/query.txt + +I'd like to use the column q.replaced_serials for multiple calculations +in the SELECT clause, but every time it is referenced there in some way +the whole query in the FROM clause returning q is executed again. + +This doesn't make sense to me at all and eats performance. + +If this wasn't clear enough, for every + +q.replaced_serials AS some_column + +in the SELECT clause there is new block of + +--------------------------------------------------------------- +-> Aggregate (cost=884.23..884.23 rows=1 width=0) + -> Nested Loop (cost=0.00..884.23 rows=1 width=0) + -> Index Scan using ix_rma_ticket_serials_replace on + + rma_ticket_serials rts (cost=0.00..122.35 + rows=190 width=4) + Index Cond: ("replace" = false) + -> Index Scan using pk_serials on serials s + (cost=0.00..3.51 rows=1 width=4) + Index Cond: (s.serial_id = "outer".serial_id) + Filter: ((article_no = $0) AND (delivery_id = $1)) +--------------------------------------------------------------- + +in the EXPLAIN result. + +For those who wonder why I do this FROM (SELECT...). I was searching for +a way to use the result of an subselect for multiple calculations in the +SELECT clause and return that calculation results as individual columns. + +I tested a bit further and found out that PG behaves the same in case q +is a view. This makes me wonder how efficient the optimizer can work +with views - or even worse - nested views. + +Tested and reproduced on PG 7.4.1 linux and 8.0.0 win32. + + +Thanks in advance, +Hannes Dorbath + +From pgsql-performance-owner@postgresql.org Thu Mar 24 10:41:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A9F8353674 + for ; + Thu, 24 Mar 2005 10:41:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63200-05 + for ; + Thu, 24 Mar 2005 10:41:09 +0000 (GMT) +Received: from mx1.rockingstone.nl (mx1.rockingstone.nl [82.94.241.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 82D3653669 + for ; + Thu, 24 Mar 2005 10:41:06 +0000 (GMT) +Received: from localhost (web1 [127.0.0.1]) + by mx1.rockingstone.nl (Postfix) with ESMTP id 06A5CFB0FB; + Thu, 24 Mar 2005 11:47:11 +0100 (CET) +Received: from mx1.rockingstone.nl ([127.0.0.1]) + by localhost (web1 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 26892-17; Thu, 24 Mar 2005 11:47:09 +0100 (CET) +Received: from [10.10.20.219] (217-19-26-53.dsl.cambrium.nl [217.19.26.53]) + by mx1.rockingstone.nl (Postfix) with ESMTP id 8CC45FB077; + Thu, 24 Mar 2005 11:47:08 +0100 (CET) +Message-ID: <42429940.8040607@rockingstone.nl> +Date: Thu, 24 Mar 2005 11:41:04 +0100 +From: Rick Jansen +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Oleg Bartunov +Cc: Mike Rylander , + pgsql-performance@postgresql.org +Subject: Re: Tsearch2 performance on big database +References: <42400F57.3040604@rockingstone.nl> + + + <42401CBF.50403@rockingstone.nl> + + + <42404263.40604@rockingstone.nl> + + <42412E4B.4010407@rockingstone.nl> + +In-Reply-To: +X-Enigmail-Version: 0.90.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at rockingstone.nl +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/501 +X-Sequence-Number: 11206 + +Oleg Bartunov wrote: + > from my notes + > http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes + > + > It's usefull to see words statistics, for example, to check how good + > your dictionaries work or how did you configure pg_ts_cfgmap. Also, you + > may notice probable stop words relevant for your collection. Tsearch + > provides stat() function: + > + > ....................... + > + > Don't hesitate to read it and if you find some bugs or know better +wording + > I'd be glad to improve my notes. + > + +Thanks, but that stat() query takes way too long.. I let it run for like +4 hours and still nothing. The database I am testing tsearch2 on is also +the production database (mysql) server so I have to be careful not to +use too many resources :o + +Anyway, here's my pg_ts_cfgmap now (well the relevant bits): + +default_english | lhword | {en_ispell,en_stem} +default_english | lpart_hword | {en_ispell,en_stem} +default_english | lword | {en_ispell,en_stem} + +Is it normal that queries for single words (or perhaps they are words +that are common) take a really long time? Like this: + +ilab=# explain analyze select count(*) from books where description_fti +@@ to_tsquery('default', 'hispanic'); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------ + Aggregate (cost=20369.81..20369.81 rows=1 width=0) (actual +time=261512.031..261512.031 rows=1 loops=1) + -> Index Scan using idxfti_idx on books (cost=0.00..20349.70 +rows=8041 width=0) (actual time=45777.760..261509.288 rows=674 loops=1) + Index Cond: (description_fti @@ '\'hispan\''::tsquery) + Total runtime: 261518.529 ms +(4 rows) + +ilab=# explain analyze select titel from books where description_fti @@ +to_tsquery('default', 'buckingham & palace'); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------ + Index Scan using idxfti_idx on books (cost=0.00..20349.70 rows=8041 +width=57) (actual time=18992.045..48863.385 rows=185 loops=1) + Index Cond: (description_fti @@ '\'buckingham\' & \'palac\''::tsquery) + Total runtime: 48863.874 ms +(3 rows) + + +I dont know what happened, these queries were a lot faster 2 days +ago..what the feck is going on?! + +Rick + +-- +Systems Administrator for Rockingstone IT +http://www.rockingstone.com +http://www.megabooksearch.com - Search many book listing sites at once + +From pgsql-performance-owner@postgresql.org Thu Mar 24 10:52:01 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D57E5367A + for ; + Thu, 24 Mar 2005 10:52:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66913-02 + for ; + Thu, 24 Mar 2005 10:51:58 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 892D153641 + for ; + Thu, 24 Mar 2005 10:51:50 +0000 (GMT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id j2OApg5Q011395; + Thu, 24 Mar 2005 13:51:42 +0300 (MSK) +Date: Thu, 24 Mar 2005 13:51:42 +0300 (MSK) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Rick Jansen +Cc: Mike Rylander , + pgsql-performance@postgresql.org +Subject: Re: Tsearch2 performance on big database +In-Reply-To: <42429940.8040607@rockingstone.nl> +Message-ID: +References: <42400F57.3040604@rockingstone.nl> + + + <42401CBF.50403@rockingstone.nl> + + + <42404263.40604@rockingstone.nl> + + <42412E4B.4010407@rockingstone.nl> + + <42429940.8040607@rockingstone.nl> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.341 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/502 +X-Sequence-Number: 11207 + +On Thu, 24 Mar 2005, Rick Jansen wrote: + +> Oleg Bartunov wrote: +>> from my notes +>> http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes +>> +>> It's usefull to see words statistics, for example, to check how good +>> your dictionaries work or how did you configure pg_ts_cfgmap. Also, you +>> may notice probable stop words relevant for your collection. Tsearch +>> provides stat() function: +>> +>> ....................... +>> +>> Don't hesitate to read it and if you find some bugs or know better wording +>> I'd be glad to improve my notes. +>> +> +> Thanks, but that stat() query takes way too long.. I let it run for like +> 4 hours and still nothing. The database I am testing tsearch2 on is also +> the production database (mysql) server so I have to be careful not to +> use too many resources :o + +stat() is indeed a bigdog, it was designed for developers needs, +so we recommend to save results in table. + +> +> Anyway, here's my pg_ts_cfgmap now (well the relevant bits): +> +> default_english | lhword | {en_ispell,en_stem} +> default_english | lpart_hword | {en_ispell,en_stem} +> default_english | lword | {en_ispell,en_stem} +> +> Is it normal that queries for single words (or perhaps they are words +> that are common) take a really long time? Like this: +> + +'hispanic' isn't common, I see you get only 674 rows and +'buckingham & palace' returns 185 rows. Did you run 'vacuum analyze' ? +I see a big discrepancy between estimated rows (8041) and actual rows. + + + +> ilab=# explain analyze select count(*) from books where description_fti @@ +> to_tsquery('default', 'hispanic'); +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------------------------ +> Aggregate (cost=20369.81..20369.81 rows=1 width=0) (actual +> time=261512.031..261512.031 rows=1 loops=1) +> -> Index Scan using idxfti_idx on books (cost=0.00..20349.70 rows=8041 +> width=0) (actual time=45777.760..261509.288 rows=674 loops=1) +> Index Cond: (description_fti @@ '\'hispan\''::tsquery) +> Total runtime: 261518.529 ms +> (4 rows) +> +> ilab=# explain analyze select titel from books where description_fti @@ +> to_tsquery('default', 'buckingham & palace'); +> QUERY PLAN +> ------------------------------------------------------------------------------------------------------------------------------------ +> Index Scan using idxfti_idx on books (cost=0.00..20349.70 rows=8041 +> width=57) (actual time=18992.045..48863.385 rows=185 loops=1) +> Index Cond: (description_fti @@ '\'buckingham\' & \'palac\''::tsquery) +> Total runtime: 48863.874 ms +> (3 rows) +> +> +> I dont know what happened, these queries were a lot faster 2 days ago..what +> the feck is going on?! +> +> Rick +> +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Thu Mar 24 10:58:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CDDF5341F + for ; + Thu, 24 Mar 2005 10:58:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66935-08 + for ; + Thu, 24 Mar 2005 10:58:04 +0000 (GMT) +Received: from mx1.rockingstone.nl (mx1.rockingstone.nl [82.94.241.100]) + by svr1.postgresql.org (Postfix) with ESMTP id D3EA35321F + for ; + Thu, 24 Mar 2005 10:58:03 +0000 (GMT) +Received: from localhost (web1 [127.0.0.1]) + by mx1.rockingstone.nl (Postfix) with ESMTP id A0485FB0FB; + Thu, 24 Mar 2005 12:04:08 +0100 (CET) +Received: from mx1.rockingstone.nl ([127.0.0.1]) + by localhost (web1 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 27444-18; Thu, 24 Mar 2005 12:04:07 +0100 (CET) +Received: from [10.10.20.219] (217-19-26-53.dsl.cambrium.nl [217.19.26.53]) + by mx1.rockingstone.nl (Postfix) with ESMTP id A37D4FB077; + Thu, 24 Mar 2005 12:04:07 +0100 (CET) +Message-ID: <42429D3C.9000509@rockingstone.nl> +Date: Thu, 24 Mar 2005 11:58:04 +0100 +From: Rick Jansen +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Oleg Bartunov +Cc: Mike Rylander , + pgsql-performance@postgresql.org +Subject: Re: Tsearch2 performance on big database +References: <42400F57.3040604@rockingstone.nl> + + + <42401CBF.50403@rockingstone.nl> + + + <42404263.40604@rockingstone.nl> + + <42412E4B.4010407@rockingstone.nl> + + <42429940.8040607@rockingstone.nl> + +In-Reply-To: +X-Enigmail-Version: 0.90.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at rockingstone.nl +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/503 +X-Sequence-Number: 11208 + +Oleg Bartunov wrote: +> +> stat() is indeed a bigdog, it was designed for developers needs, +> so we recommend to save results in table. +> +>> +>> Anyway, here's my pg_ts_cfgmap now (well the relevant bits): +>> +>> default_english | lhword | {en_ispell,en_stem} +>> default_english | lpart_hword | {en_ispell,en_stem} +>> default_english | lword | {en_ispell,en_stem} +>> +>> Is it normal that queries for single words (or perhaps they are words +>> that are common) take a really long time? Like this: +>> +> +> 'hispanic' isn't common, I see you get only 674 rows and 'buckingham & +> palace' returns 185 rows. Did you run 'vacuum analyze' ? +> I see a big discrepancy between estimated rows (8041) and actual rows. +> +> + +Yes, I did a vacuum analyze right before executing these queries. + +I'm going to recreate the gist index now, and do a vacuum full analyze +after that.. see if that makes a difference. + +Rick + +-- +Systems Administrator for Rockingstone IT +http://www.rockingstone.com +http://www.megabooksearch.com - Search many book listing sites at once + +From pgsql-performance-owner@postgresql.org Thu Mar 24 11:53:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A71E5369B + for ; + Thu, 24 Mar 2005 11:53:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84243-02 + for ; + Thu, 24 Mar 2005 11:53:06 +0000 (GMT) +Received: from planae.com.br (nat.planae.com.br [200.210.129.190]) + by svr1.postgresql.org (Postfix) with SMTP id 1531253699 + for ; + Thu, 24 Mar 2005 11:53:01 +0000 (GMT) +Received: (qmail 13425 invoked by uid 1004); 24 Mar 2005 11:53:03 -0000 +Received: from 192.168.0.215 by mercurio.planae.com.br (envelope-from + , uid 0) with qmail-scanner-1.23 + (uvscan: v4.3.20/v4453. Clear:RC:1(192.168.0.215):. + Processed in 2.270893 secs); 24 Mar 2005 11:53:02 -0000 +X-Qmail-Scanner-Mail-From: gfnobrega@planae.com.br via mercurio.planae.com.br +X-Qmail-Scanner: 1.23 (Clear:RC:1(192.168.0.215):. Processed in 2.270893 secs) +Received: from unknown (HELO ?192.168.0.215?) (gfnobrega@192.168.0.215) + by 192.168.0.3 with SMTP; 24 Mar 2005 11:53:00 -0000 +Message-ID: <4242A9EF.7070005@planae.com.br> +Date: Thu, 24 Mar 2005 08:52:15 -0300 +From: =?ISO-8859-1?Q?Gustavo_Franklin_N=F3brega_-_Planae?= + +User-Agent: Mozilla Thunderbird 0.9 (X11/20041127) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Patrick Vedrines +Cc: performance pgsql +Subject: Re: CPU 0.1% IOWAIT 99% for decisonnal queries +References: <002601c52f0a$2312a4d0$280baf96@PCPATRICK> + <424063BC.3050206@planae.com.br> + <004d01c53054$965583e0$1e0baf96@pcpatrickxp> +In-Reply-To: <004d01c53054$965583e0$1e0baf96@pcpatrickxp> +Content-Type: multipart/alternative; + boundary="------------090400000606040200090705" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.106 tagged_above=0 required=5 tests=AWL, HTML_50_60, + HTML_MESSAGE, HTML_TITLE_EMPTY, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/504 +X-Sequence-Number: 11209 + +This is a multi-part message in MIME format. +--------------090400000606040200090705 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit + +Good day Patrick! + + I can help you to design you disk layout for better perform and +security. Please, tell me how many disks (and some specs, like capacity +and RPM). + + If you want to know more, there is a very interesting article abou +benckmark filesystem ( http://linuxgazette.net/102/piszcz.html ). In +this article, ReiserFS 3.6, JFS and XFS are in the same level at top +depending your application, and ext3 is more slow than others. I believe +that version 4 of the ReiserFS is better that version 3.6, but I could +not still test it. + + Raid0 (striping, more at +http://www.pcguide.com/ref/hdd/perf/raid/levels/singleLevel0-c.html) or +Raid 0+1 (stripping + mirror, more at +http://www.pcguide.com/ref/hdd/perf/raid/levels/multLevel01-c.html) is +very insteresting to postgresql. Raid0 provides only performance, and +Raid 0+1 provides performance and security. Take a look at this articles +and think about to use Raid (http://www.pcguide.com/ref/hdd/perf/raid/). + + I'm glad to help. Best regards! + +Atenciosamente, + +Gustavo Franklin N�brega +Infraestrutura e Banco de Dados +Planae Tecnologia da Informa��o +(+55) 14 3106-3514 +http://www.planae.com.br + + + + +Patrick Vedrines wrote: + +> Hello Gustavo, +> +> Your question seems to say that you suspect a disk issue, and a few +> hours later, Simon told me "Sounds like your disks/layout/something is +> pretty sick". +> To be clear in my own mind about it, I've just copyed (time cp) the +> "aggregate" table files (4 Gb) from one disk to an another one: it +> takes 22 mn !(3 Mb/s). +> That seems to demonstrate that Postgres is not the cause of this issue. +> I've just untrusted to my system engineer the analysis of my disks... +> +> In case I would have to change my disks, do you have any performance +> figures related to the types you mentionned (reiserfs vs ext3) ? +> I don't use RAID since the security is not a concern. +> +> Thank a lot for your help ! +> +> Patrick +> +> +> Hi Patrick, +> +> How is configured your disk array? Do you have a Perc 4? +> +> Tip: Use reiserfs instead ext3, raid 0+1 and deadline I/O +> scheduler in kernel linux 2.6 +> +> +> + +--------------090400000606040200090705 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + + +Good day Patrick!
+   
+    I can help you to design you disk layout for better perform and +security. Please, tell me how many disks (and some specs, like capacity +and RPM).
+
+    If you want to know more, there is a very interesting article abou +benckmark filesystem ( http://linuxgazette.net/102/piszcz.html ). In +this article, ReiserFS 3.6, JFS and XFS are in the same level at top +depending your application, and ext3 is more slow than others. I +believe that version 4 of the ReiserFS is better that version 3.6, but +I could not still test it.
+
+    Raid0 (striping, more at +http://www.pcguide.com/ref/hdd/perf/raid/levels/singleLevel0-c.html) or +Raid 0+1 (stripping + mirror, more at +http://www.pcguide.com/ref/hdd/perf/raid/levels/multLevel01-c.html) is +very insteresting to postgresql. Raid0 provides only performance, and +Raid 0+1 provides performance and security. Take a look at this +articles and think about to use Raid +(http://www.pcguide.com/ref/hdd/perf/raid/).
+
+    I'm glad to help. Best regards!
+
Atenciosamente,
+
+Gustavo Franklin Nóbrega
+Infraestrutura e Banco de Dados
+Planae Tecnologia da Informação
+(+55) 14 3106-3514
+http://www.planae.com.br
+
+
+
+
+Patrick Vedrines wrote: +
+ + + + +
+
Hello Gustavo,
+
 
+
Your question seems to say that you +suspect a disk issue, and a few hours later, Simon told me "Sounds like +your disks/layout/something is pretty sick".
+
To be clear in my own mind about it, +I've just copyed (time cp) the "aggregate" table files (4 Gb) from one +disk to an another one: it takes 22 mn !(3 Mb/s).
+
That seems to demonstrate that +Postgres is not the cause of this issue.
+
I've just untrusted to my system +engineer the analysis of my disks...
+
 
+
In case I would have to change my +disks, do you have any performance figures related to the types you +mentionned (reiserfs vs ext3) ?
+
I don't use RAID since the security +is not a concern.
+
 
+
Thank a lot for your help !
+
 
+
Patrick
+
+
+
 
+Hi Patrick,
+
+    How is configured your disk array? Do you have a Perc 4?
+
+Tip: Use reiserfs instead ext3, raid 0+1 and deadline I/O scheduler in +kernel linux 2.6
+
 
+
+
+ + + +--------------090400000606040200090705-- + +From pgsql-performance-owner@postgresql.org Thu Mar 24 13:32:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 75E4253544 + for ; + Thu, 24 Mar 2005 13:32:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15522-07 + for ; + Thu, 24 Mar 2005 13:32:47 +0000 (GMT) +Received: from metux.de (seven.metux.de [193.16.1.1]) + by svr1.postgresql.org (Postfix) with ESMTP id B7EBE535AB + for ; + Thu, 24 Mar 2005 13:32:45 +0000 (GMT) +Received: (from weigelt@localhost) + by metux.de (8.12.10/8.12.10) id j2ODWmh7027278 + for pgsql-performance@postgresql.org; Thu, 24 Mar 2005 14:32:48 +0100 +Date: Thu, 24 Mar 2005 14:32:48 +0100 +From: Enrico Weigelt +To: pgsql-performance@postgresql.org +Subject: clear function cache (WAS: SQL function inlining) +Message-ID: <20050324133248.GB31203@nibiru.borg.metux.de> +Reply-To: weigelt@metux.de +References: + <7635.1111596928@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <7635.1111596928@sss.pgh.pa.us> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/505 +X-Sequence-Number: 11210 + +* Tom Lane wrote: + + + +BTW: is it possible to explicitly clear the cache for immutable +functions ? + +I'd like to use immutable functions for really often lookups like +fetching a username by uid and vice versa. The queried tables +change very rarely, but when they change is quite unpredictable. + + +thx +-- +--------------------------------------------------------------------- + Enrico Weigelt == metux IT service + + phone: +49 36207 519931 www: http://www.metux.de/ + fax: +49 36207 519932 email: contact@metux.de + cellphone: +49 174 7066481 +--------------------------------------------------------------------- + -- DSL ab 0 Euro. -- statische IP -- UUCP -- Hosting -- Webshops -- +--------------------------------------------------------------------- + +From pgsql-performance-owner@postgresql.org Thu Mar 24 13:42:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D867652A50 + for ; + Thu, 24 Mar 2005 13:42:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18964-04 + for ; + Thu, 24 Mar 2005 13:42:41 +0000 (GMT) +Received: from sunsite.dcc.uchile.cl (sunsite.dcc.uchile.cl [192.80.24.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E90A53422 + for ; + Thu, 24 Mar 2005 13:42:40 +0000 (GMT) +Received: from anakena.dcc.uchile.cl (anakena [192.80.24.6]) + by sunsite.dcc.uchile.cl (8.12.11/8.12.11) with ESMTP id j2ODgefs022425; + Thu, 24 Mar 2005 09:42:41 -0400 (CLT) +Received: by anakena.dcc.uchile.cl (Postfix, from userid 4151) + id 67AF852D0F; Thu, 24 Mar 2005 09:42:40 -0400 (CLT) +Date: Thu, 24 Mar 2005 09:42:40 -0400 +From: Alvaro Herrera +To: Enrico Weigelt +Cc: pgsql-performance@postgresql.org +Subject: Re: clear function cache (WAS: SQL function inlining) +Message-ID: <20050324134240.GD20726@dcc.uchile.cl> +References: + <7635.1111596928@sss.pgh.pa.us> + <20050324133248.GB31203@nibiru.borg.metux.de> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: <20050324133248.GB31203@nibiru.borg.metux.de> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.349 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/506 +X-Sequence-Number: 11211 + +On Thu, Mar 24, 2005 at 02:32:48PM +0100, Enrico Weigelt wrote: + +> BTW: is it possible to explicitly clear the cache for immutable +> functions ? + +What cache? There is no caching of function results. + +> I'd like to use immutable functions for really often lookups like +> fetching a username by uid and vice versa. The queried tables +> change very rarely, but when they change is quite unpredictable. + +Maybe you should use a stable function if you fear we'll having function +result caching without you noticing. + +-- +Alvaro Herrera () +"Aprende a avergonzarte m�s ante ti que ante los dem�s" (Dem�crito) + +From pgsql-performance-owner@postgresql.org Thu Mar 24 13:48:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DB29253432 + for ; + Thu, 24 Mar 2005 13:48:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21306-07 + for ; + Thu, 24 Mar 2005 13:48:04 +0000 (GMT) +Received: from metux.de (seven.metux.de [193.16.1.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B9E852A50 + for ; + Thu, 24 Mar 2005 13:48:02 +0000 (GMT) +Received: (from weigelt@localhost) + by metux.de (8.12.10/8.12.10) id j2ODm5bu030161 + for pgsql-performance@postgresql.org; Thu, 24 Mar 2005 14:48:05 +0100 +Date: Thu, 24 Mar 2005 14:48:05 +0100 +From: Enrico Weigelt +To: pgsql-performance@postgresql.org +Subject: Re: View columns calculated +Message-ID: <20050324134805.GC31203@nibiru.borg.metux.de> +Reply-To: weigelt@metux.de +References: + <26711.1081891416@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <26711.1081891416@sss.pgh.pa.us> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/507 +X-Sequence-Number: 11212 + +* Tom Lane wrote: +> "Peter Darley" writes: +> > I have a question about views: I want to have a fairly wide view (lots of +> > columns) where most of the columns have some heavyish calculations in them, +> > but I'm concerned that it will have to calculate every column even when I'm +> > not selecting them. So, the question is, if I have 5 columns in a view but +> > only select 1 column, is the system smart enough to not calculate the unused +> > columns, +> +> It depends on what the rest of your view looks like. If the view is +> simple enough to be "flattened" into the parent query then the unused +> columns will disappear into the ether. If it's not flattenable then +> they will get evaluated. You can check by seeing whether an EXPLAIN +> shows a separate "subquery scan" node corresponding to the view. +> (Without bothering to look at the code, an unflattenable view is one +> that uses GROUP BY, DISTINCT, aggregates, ORDER BY, LIMIT, UNION, +> INTERSECT, EXCEPT, probably a couple other things.) + +What about functions ? +I'm using several (immutable) functions for mapping IDs to names, etc. + + +cu +-- +--------------------------------------------------------------------- + Enrico Weigelt == metux IT service + + phone: +49 36207 519931 www: http://www.metux.de/ + fax: +49 36207 519932 email: contact@metux.de + cellphone: +49 174 7066481 +--------------------------------------------------------------------- + -- DSL ab 0 Euro. -- statische IP -- UUCP -- Hosting -- Webshops -- +--------------------------------------------------------------------- + +From pgsql-performance-owner@postgresql.org Thu Mar 24 14:05:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C3F3535C1 + for ; + Thu, 24 Mar 2005 14:05:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25882-08 + for ; + Thu, 24 Mar 2005 14:05:18 +0000 (GMT) +Received: from felix.adpcl.com (felix.adpcl.com [194.98.137.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 953AD535A3 + for ; + Thu, 24 Mar 2005 14:05:16 +0000 (GMT) +Received: from pcpatrickxp (unknown [150.175.11.30]) + by felix.adpcl.com (Postfix) with SMTP + id 31DB17812; Thu, 24 Mar 2005 15:08:22 +0100 (NFT) +Message-ID: <013501c5307a$58bea680$1e0baf96@pcpatrickxp> +From: "Patrick Vedrines" +To: =?iso-8859-1?Q?Gustavo_Franklin_N=F3brega_-_Planae?= + +Cc: "performance pgsql" +References: <002601c52f0a$2312a4d0$280baf96@PCPATRICK> + <424063BC.3050206@planae.com.br> + <004d01c53054$965583e0$1e0baf96@pcpatrickxp> + <4242A9EF.7070005@planae.com.br> +Subject: Re: CPU 0.1% IOWAIT 99% for decisonnal queries +Date: Thu, 24 Mar 2005 15:04:08 +0100 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0132_01C53082.BA68F6D0" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.23 tagged_above=0 required=5 tests=AWL, HTML_50_60, + HTML_MESSAGE, HTML_TITLE_EMPTY +X-Spam-Level: +X-Archive-Number: 200503/508 +X-Sequence-Number: 11213 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0132_01C53082.BA68F6D0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Great ! + +I'm not an expert but as far as I know, my 15 databases are spread over = +4 SCSI RAID disks 73 GB 10K RPM mounted under ext3 mode.=20 +I remember that they where provided by DELL under RAID5 and I asked my = +system engineer for switching them to standard SCSI because I don't care = +about security but only about speed and capacity ( maybe this switch was = +not set properly at this time...). + +Thank you for these interesting links: I 've sent them to my system = +engineer with my two hands ! + +Amicalement + +Patrick + ----- Original Message -----=20 + From: Gustavo Franklin N=F3brega - Planae=20 + To: Patrick Vedrines=20 + Cc: performance pgsql=20 + Sent: Thursday, March 24, 2005 12:52 PM + Subject: Re: [PERFORM] CPU 0.1% IOWAIT 99% for decisonnal queries + + + Good day Patrick! + =20 + I can help you to design you disk layout for better perform and = +security. Please, tell me how many disks (and some specs, like capacity = +and RPM). + + If you want to know more, there is a very interesting article abou = +benckmark filesystem ( http://linuxgazette.net/102/piszcz.html ). In = +this article, ReiserFS 3.6, JFS and XFS are in the same level at top = +depending your application, and ext3 is more slow than others. I believe = +that version 4 of the ReiserFS is better that version 3.6, but I could = +not still test it. + + Raid0 (striping, more at = +http://www.pcguide.com/ref/hdd/perf/raid/levels/singleLevel0-c.html) or = +Raid 0+1 (stripping + mirror, more at = +http://www.pcguide.com/ref/hdd/perf/raid/levels/multLevel01-c.html) is = +very insteresting to postgresql. Raid0 provides only performance, and = +Raid 0+1 provides performance and security. Take a look at this articles = +and think about to use Raid (http://www.pcguide.com/ref/hdd/perf/raid/). + + I'm glad to help. Best regards! + +Atenciosamente, + +Gustavo Franklin N=F3brega +Infraestrutura e Banco de Dados +Planae Tecnologia da Informa=E7=E3o +(+55) 14 3106-3514 +http://www.planae.com.br + + + + Patrick Vedrines wrote:=20 + Hello Gustavo, + + Your question seems to say that you suspect a disk issue, and a few = +hours later, Simon told me "Sounds like your disks/layout/something is = +pretty sick". + To be clear in my own mind about it, I've just copyed (time cp) the = +"aggregate" table files (4 Gb) from one disk to an another one: it takes = +22 mn !(3 Mb/s). + That seems to demonstrate that Postgres is not the cause of this = +issue.=20 + I've just untrusted to my system engineer the analysis of my = +disks... + + In case I would have to change my disks, do you have any performance = +figures related to the types you mentionned (reiserfs vs ext3) ? + I don't use RAID since the security is not a concern. + + Thank a lot for your help ! + + Patrick + + Hi Patrick, + + How is configured your disk array? Do you have a Perc 4? + + Tip: Use reiserfs instead ext3, raid 0+1 and deadline I/O = +scheduler in kernel linux 2.6 + + +------=_NextPart_000_0132_01C53082.BA68F6D0 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +
Great !
+
 
+
I'm not an expert but as far as I know, = +my 15=20 +databases are spread over 4 SCSI RAID disks 73 GB 10K RPM mounted under = +ext3=20 +mode. 
+
I remember that they where provided by = +DELL under=20 +RAID5 and I asked my system engineer for switching them to standard = +SCSI=20 +because I don't care about security but only about speed and capacity ( = +maybe=20 +this switch was not set properly at this time...).
+
 
+
Thank you for these interesting links: = +I 've sent=20 +them to my system engineer with my two hands !
+
 
+
Amicalement
+
 
+
Patrick
+
+
----- Original Message -----
+ From:=20 + Gustavo=20 + Franklin N=F3brega - Planae + +
Cc: performance pgsql = +
+
Sent: Thursday, March 24, 2005 = +12:52=20 + PM
+
Subject: Re: [PERFORM] CPU 0.1% = +IOWAIT=20 + 99% for decisonnal queries
+

Good day Patrick!
    = +
   =20 + I can help you to design you disk layout for better perform and = +security.=20 + Please, tell me how many disks (and some specs, like capacity and=20 + RPM).

    If you want to know more, there is a = +very=20 + interesting article abou benckmark filesystem ( http://linuxgazette.net/= +102/piszcz.html=20 + ). In this article, ReiserFS 3.6, JFS and XFS are in the same level at = +top=20 + depending your application, and ext3 is more slow than others. I = +believe that=20 + version 4 of the ReiserFS is better that version 3.6, but I could not = +still=20 + test it.

    Raid0 (striping, more at http://www.pcguide.com/ref/hdd/perf/raid/levels/singleLevel0-c.html)=20 + or Raid 0+1 (stripping + mirror, more at http://www.pcguide.com/ref/hdd/perf/raid/levels/multLevel01-c.html= +)=20 + is very insteresting to postgresql. Raid0 provides only performance, = +and Raid=20 + 0+1 provides performance and security. Take a look at this articles = +and think=20 + about to use Raid (http://www.pcguide.com= +/ref/hdd/perf/raid/).

   =20 + I'm glad to help. Best regards!
Atenciosamente,
+
+Gustavo Franklin N=F3brega
+Infraestrutura e Banco de Dados
+Planae Tecnologia da Informa=E7=E3o
+(+55) 14 3106-3514
+http://www.planae.com.br
+
+


Patrick Vedrines wrote:=20 +
+ + + +
+
Hello Gustavo,
+
 
+
Your question seems to say that you = +suspect a=20 + disk issue, and a few hours later, Simon told me "Sounds like your=20 + disks/layout/something is pretty sick".
+
To be clear in my own mind about = +it, I've just=20 + copyed (time cp) the "aggregate" table files (4 Gb) from one disk to = +an=20 + another one: it takes 22 mn !(3 Mb/s).
+
That seems to demonstrate that = +Postgres is not=20 + the cause of this issue.
+
I've just untrusted to my system=20 + engineer the analysis of my disks...
+
 
+
In case I would have to change my = +disks, do you=20 + have any performance figures related to the types you = +mentionned=20 + (reiserfs vs ext3) ?
+
I don't use RAID since the security = +is not a=20 + concern.
+
 
+
Thank a lot for your help = +!
+
 
+
Patrick
+
+  Hi=20 + Patrick,

    How is configured your disk = +array? Do=20 + you have a Perc 4?

Tip: Use reiserfs instead ext3, raid 0+1 = +and=20 + deadline I/O scheduler in kernel linux 2.6
 
+ +------=_NextPart_000_0132_01C53082.BA68F6D0-- + + +From pgsql-performance-owner@postgresql.org Thu Mar 24 14:12:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F74853422 + for ; + Thu, 24 Mar 2005 14:12:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29608-06 + for ; + Thu, 24 Mar 2005 14:12:32 +0000 (GMT) +Received: from metux.de (seven.metux.de [193.16.1.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 2BAAC535C1 + for ; + Thu, 24 Mar 2005 14:12:30 +0000 (GMT) +Received: (from weigelt@localhost) + by metux.de (8.12.10/8.12.10) id j2OECYPW002648 + for pgsql-performance@postgresql.org; Thu, 24 Mar 2005 15:12:34 +0100 +Date: Thu, 24 Mar 2005 15:12:33 +0100 +From: Enrico Weigelt +To: pgsql-performance@postgresql.org +Subject: Re: clear function cache (WAS: SQL function inlining) +Message-ID: <20050324141233.GA933@nibiru.borg.metux.de> +Reply-To: weigelt@metux.de +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <7635.1111596928@sss.pgh.pa.us> + <20050324133248.GB31203@nibiru.borg.metux.de> + <20050324134240.GD20726@dcc.uchile.cl> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20050324134240.GD20726@dcc.uchile.cl> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/509 +X-Sequence-Number: 11214 + +* Alvaro Herrera wrote: +> On Thu, Mar 24, 2005 at 02:32:48PM +0100, Enrico Weigelt wrote: +> +> > BTW: is it possible to explicitly clear the cache for immutable +> > functions ? +> +> What cache? There is no caching of function results. + +Not ? So what's immutable for ? + + +> > I'd like to use immutable functions for really often lookups like +> > fetching a username by uid and vice versa. The queried tables +> > change very rarely, but when they change is quite unpredictable. +> +> Maybe you should use a stable function if you fear we'll having function +> result caching without you noticing. + +hmm, this makes more real evaluations necessary than w/ immuatable. +AFAIK stable functions have to be evaluated once per query, and the +results are not cached between several queries. + + +cu +-- +--------------------------------------------------------------------- + Enrico Weigelt == metux IT service + + phone: +49 36207 519931 www: http://www.metux.de/ + fax: +49 36207 519932 email: contact@metux.de + cellphone: +49 174 7066481 +--------------------------------------------------------------------- + -- DSL ab 0 Euro. -- statische IP -- UUCP -- Hosting -- Webshops -- +--------------------------------------------------------------------- + +From pgsql-performance-owner@postgresql.org Thu Mar 24 14:29:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2815F53461 + for ; + Thu, 24 Mar 2005 14:29:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34000-10 + for ; + Thu, 24 Mar 2005 14:29:16 +0000 (GMT) +Received: from planae.com.br (nat.planae.com.br [200.210.129.190]) + by svr1.postgresql.org (Postfix) with SMTP id 2F7D953432 + for ; + Thu, 24 Mar 2005 14:29:12 +0000 (GMT) +Received: (qmail 41286 invoked by uid 1004); 24 Mar 2005 14:29:17 -0000 +Received: from 192.168.0.215 by mercurio.planae.com.br (envelope-from + , uid 0) with qmail-scanner-1.23 + (uvscan: v4.3.20/v4453. Clear:RC:1(192.168.0.215):. + Processed in 1.97883 secs); 24 Mar 2005 14:29:17 -0000 +X-Qmail-Scanner-Mail-From: gfnobrega@planae.com.br via mercurio.planae.com.br +X-Qmail-Scanner: 1.23 (Clear:RC:1(192.168.0.215):. Processed in 1.97883 secs) +Received: from unknown (HELO ?192.168.0.215?) (gfnobrega@192.168.0.215) + by 192.168.0.3 with SMTP; 24 Mar 2005 14:29:15 -0000 +Message-ID: <4242CE8E.7060900@planae.com.br> +Date: Thu, 24 Mar 2005 11:28:30 -0300 +From: =?ISO-8859-1?Q?Gustavo_Franklin_N=F3brega_-_Planae?= + +User-Agent: Mozilla Thunderbird 0.9 (X11/20041127) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Patrick Vedrines +Cc: performance pgsql +Subject: Re: CPU 0.1% IOWAIT 99% for decisonnal queries +References: <002601c52f0a$2312a4d0$280baf96@PCPATRICK> + <424063BC.3050206@planae.com.br> + <004d01c53054$965583e0$1e0baf96@pcpatrickxp> + <4242A9EF.7070005@planae.com.br> + <013501c5307a$58bea680$1e0baf96@pcpatrickxp> +In-Reply-To: <013501c5307a$58bea680$1e0baf96@pcpatrickxp> +Content-Type: multipart/alternative; + boundary="------------040004090102080601060001" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.117 tagged_above=0 required=5 tests=AWL, HTML_50_60, + HTML_MESSAGE, HTML_TITLE_EMPTY, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/510 +X-Sequence-Number: 11215 + +This is a multi-part message in MIME format. +--------------040004090102080601060001 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit + +Hi! + + I have a Dell PowerEdge 2600 with a Perc 4/DI and 4 scsi disks 35GB. +I have made a array raid 0+1 with 4 disks, because is mission critical +application. But, for your, you can configure a raid0, thats is faster +than raid5 for 4 disks. + + Ask to your system enginner what is distribution of Linux is used, +kernel version and if he does a kernel tuning for your hardware and +application. + +Best regards. + +Atenciosamente, + +Gustavo Franklin N�brega +Infraestrutura e Banco de Dados +Planae Tecnologia da Informa��o +(+55) 14 3106-3514 +http://www.planae.com.br + + + + +Patrick Vedrines wrote: + +> Great ! +> +> I'm not an expert but as far as I know, my 15 databases are spread +> over 4 SCSI RAID disks 73 GB 10K RPM mounted under ext3 mode. +> I remember that they where provided by DELL under RAID5 and I asked my +> system engineer for switching them to standard SCSI because I don't +> care about security but only about speed and capacity ( maybe this +> switch was not set properly at this time...). +> +> Thank you for these interesting links: I 've sent them to my system +> engineer with my two hands ! +> +> Amicalement +> +> Patrick +> +> ----- Original Message ----- +> *From:* Gustavo Franklin N�brega - Planae +> +> *To:* Patrick Vedrines +> *Cc:* performance pgsql +> *Sent:* Thursday, March 24, 2005 12:52 PM +> *Subject:* Re: [PERFORM] CPU 0.1% IOWAIT 99% for decisonnal queries +> +> Good day Patrick! +> +> I can help you to design you disk layout for better perform +> and security. Please, tell me how many disks (and some specs, like +> capacity and RPM). +> +> If you want to know more, there is a very interesting article +> abou benckmark filesystem ( +> http://linuxgazette.net/102/piszcz.html ). In this article, +> ReiserFS 3.6, JFS and XFS are in the same level at top depending +> your application, and ext3 is more slow than others. I believe +> that version 4 of the ReiserFS is better that version 3.6, but I +> could not still test it. +> +> Raid0 (striping, more at +> http://www.pcguide.com/ref/hdd/perf/raid/levels/singleLevel0-c.html) +> or Raid 0+1 (stripping + mirror, more at +> http://www.pcguide.com/ref/hdd/perf/raid/levels/multLevel01-c.html) +> is very insteresting to postgresql. Raid0 provides only +> performance, and Raid 0+1 provides performance and security. Take +> a look at this articles and think about to use Raid +> (http://www.pcguide.com/ref/hdd/perf/raid/). +> +> I'm glad to help. Best regards! +> +>Atenciosamente, +> +>Gustavo Franklin N�brega +>Infraestrutura e Banco de Dados +>Planae Tecnologia da Informa��o +>(+55) 14 3106-3514 +>http://www.planae.com.br +> +> +> +> +> +> Patrick Vedrines wrote: +> +>> Hello Gustavo, +>> +>> Your question seems to say that you suspect a disk issue, and a +>> few hours later, Simon told me "Sounds like your +>> disks/layout/something is pretty sick". +>> To be clear in my own mind about it, I've just copyed (time cp) +>> the "aggregate" table files (4 Gb) from one disk to an another +>> one: it takes 22 mn !(3 Mb/s). +>> That seems to demonstrate that Postgres is not the cause of this +>> issue. +>> I've just untrusted to my system engineer the analysis of my disks... +>> +>> In case I would have to change my disks, do you have any +>> performance figures related to the types you mentionned (reiserfs +>> vs ext3) ? +>> I don't use RAID since the security is not a concern. +>> +>> Thank a lot for your help ! +>> +>> Patrick +>> +>> +>> Hi Patrick, +>> +>> How is configured your disk array? Do you have a Perc 4? +>> +>> Tip: Use reiserfs instead ext3, raid 0+1 and deadline I/O +>> scheduler in kernel linux 2.6 +>> +>> +>> + +--------------040004090102080601060001 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + + +Hi!
+
+    I have a Dell PowerEdge 2600 with a Perc 4/DI and 4 scsi disks +35GB. I have made a array raid 0+1 with 4 disks, because is mission +critical application. But, for your,  you can configure a raid0, thats +is faster than raid5 for 4 disks.
+
+    Ask to your system enginner what is distribution of Linux is used, +kernel version and if he does a kernel tuning for your hardware and +application.
+
+Best regards.
+
Atenciosamente,
+
+Gustavo Franklin Nóbrega
+Infraestrutura e Banco de Dados
+Planae Tecnologia da Informação
+(+55) 14 3106-3514
+http://www.planae.com.br
+
+
+
+
+Patrick Vedrines wrote: +
+ + + +
Great !
+
 
+
I'm not an expert but as far as I +know, my 15 databases are spread over 4 SCSI RAID disks 73 GB 10K RPM +mounted under ext3 mode. 
+
I remember that they where provided +by DELL under RAID5 and I asked my system engineer for switching them +to standard SCSI because I don't care about security but only about +speed and capacity ( maybe this switch was not set properly at this +time...).
+
 
+
Thank you for these interesting +links: I 've sent them to my system engineer with my two hands !
+
 
+
Amicalement
+
 
+
Patrick
+
+
----- +Original Message -----
+ + + +
Sent: +Thursday, March 24, 2005 12:52 PM
+
Subject: +Re: [PERFORM] CPU 0.1% IOWAIT 99% for decisonnal queries
+

+
+Good day Patrick!
+   
+    I can help you to design you disk layout for better perform and +security. Please, tell me how many disks (and some specs, like capacity +and RPM).
+
+    If you want to know more, there is a very interesting article abou +benckmark filesystem ( http://linuxgazette.net/102/piszcz.html +). In this article, ReiserFS 3.6, JFS and XFS are in the same level at +top depending your application, and ext3 is more slow than others. I +believe that version 4 of the ReiserFS is better that version 3.6, but +I could not still test it.
+
+    Raid0 (striping, more at http://www.pcguide.com/ref/hdd/perf/raid/levels/singleLevel0-c.html) +or Raid 0+1 (stripping + mirror, more at http://www.pcguide.com/ref/hdd/perf/raid/levels/multLevel01-c.html) +is very insteresting to postgresql. Raid0 provides only performance, +and Raid 0+1 provides performance and security. Take a look at this +articles and think about to use Raid (http://www.pcguide.com/ref/hdd/perf/raid/).
+
+    I'm glad to help. Best regards!
+
Atenciosamente,
+
+Gustavo Franklin Nóbrega
+Infraestrutura e Banco de Dados
+Planae Tecnologia da Informação
+(+55) 14 3106-3514
+http://www.planae.com.br
+
+    
+
+
+Patrick Vedrines wrote: +
+ + +
+
Hello Gustavo,
+
 
+
Your question seems to say that +you suspect a disk issue, and a few hours later, Simon told me "Sounds +like your disks/layout/something is pretty sick".
+
To be clear in my own mind about +it, I've just copyed (time cp) the "aggregate" table files (4 Gb) from +one disk to an another one: it takes 22 mn !(3 Mb/s).
+
That seems to demonstrate that +Postgres is not the cause of this issue.
+
I've just untrusted to my system +engineer the analysis of my disks...
+
 
+
In case I would have to change +my disks, do you have any performance figures related to the types you +mentionned (reiserfs vs ext3) ?
+
I don't use RAID since the +security is not a concern.
+
 
+
Thank a lot for your help !
+
 
+
Patrick
+
+
+
 
+Hi Patrick,
+
+    How is configured your disk array? Do you have a Perc 4?
+
+Tip: Use reiserfs instead ext3, raid 0+1 and deadline I/O scheduler in +kernel linux 2.6
+
 
+
+
+
+
+ + + +--------------040004090102080601060001-- + +From pgsql-performance-owner@postgresql.org Thu Mar 24 14:58:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9CDBA535FA + for ; + Thu, 24 Mar 2005 14:58:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45534-06 + for ; + Thu, 24 Mar 2005 14:58:31 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id EF64B53514 + for ; + Thu, 24 Mar 2005 14:58:30 +0000 (GMT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 5FCC935488; Thu, 24 Mar 2005 06:58:34 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 58F4035390; Thu, 24 Mar 2005 06:58:34 -0800 (PST) +Date: Thu, 24 Mar 2005 06:58:34 -0800 (PST) +From: Stephan Szabo +To: Enrico Weigelt +Cc: pgsql-performance@postgresql.org +Subject: Re: clear function cache (WAS: SQL function inlining) +In-Reply-To: <20050324141233.GA933@nibiru.borg.metux.de> +Message-ID: <20050324065516.P34192@megazone.bigpanda.com> +References: + <7635.1111596928@sss.pgh.pa.us> + <20050324133248.GB31203@nibiru.borg.metux.de> + <20050324134240.GD20726@dcc.uchile.cl> + <20050324141233.GA933@nibiru.borg.metux.de> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/511 +X-Sequence-Number: 11216 + + +On Thu, 24 Mar 2005, Enrico Weigelt wrote: + +> * Alvaro Herrera wrote: +> > On Thu, Mar 24, 2005 at 02:32:48PM +0100, Enrico Weigelt wrote: +> > +> > > BTW: is it possible to explicitly clear the cache for immutable +> > > functions ? +> > +> > What cache? There is no caching of function results. +> +> Not ? So what's immutable for ? + +For knowing that you can do things like use it in a functional index and +I think for things like constant folding in a prepared plan. + +From pgsql-performance-owner@postgresql.org Thu Mar 24 18:19:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B855A53447 + for ; + Thu, 24 Mar 2005 18:19:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17413-05 + for ; + Thu, 24 Mar 2005 18:18:51 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CC078533F5 + for ; + Thu, 24 Mar 2005 18:18:50 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id AFCB130EA1; Thu, 24 Mar 2005 19:18:49 +0100 (MET) +From: "Otto Blomqvist" +X-Newsgroups: pgsql.performance +Subject: pg_autovacuum not having enough suction ? +Date: Thu, 24 Mar 2005 10:17:06 -0800 +Organization: Hub.Org Networking Services +Lines: 90 +Message-ID: +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/512 +X-Sequence-Number: 11217 + +Hello ! + +I'm running pg_autovacuum on a 1GHz, 80Gig, 512Mhz machine. The database is +about 30MB tarred. We have about 50000 Updates/Inserts/Deletes per day. It +runs beautifully for ~4 days. Then the HDD activity and the Postmaster CPU +usage goes up ALOT. Even though I have plenty (?) of FSM (2 million) pages. +I perform a vacuum and everything is back to normal for another 4 days. I +could schedule a manual vacuum each day but the util is not called +pg_SemiAutoVacuum so I'm hoping this is not necessary. The same user that +ran the manual vacuum is running pg_autovacuum. The normal CPU usage is +about 10% w/ little HD activity. + +Im running autovacuum with the following flags -d 3 -v 300 -V 0.1 -s 180 -S +0.1 -a 200 -A 0.1 + +Below are some snipplets regarding vacuuming from the busiest table + +This is the last VACUUM ANALYZE performed by pg_autovacuum before I ran the +manual vacuum + +[2005-03-24 02:05:43 EST] DEBUG: Performing: VACUUM ANALYZE +"public"."file_92" +[2005-03-24 02:05:52 EST] INFO: table name: secom."public"."file_92" +[2005-03-24 02:05:52 EST] INFO: relid: 9384219; relisshared: 0 +[2005-03-24 02:05:52 EST] INFO: reltuples: 106228.000000; relpages: +9131 +[2005-03-24 02:05:52 EST] INFO: curr_analyze_count: 629121; +curr_vacuum_count: 471336 +[2005-03-24 02:05:52 EST] INFO: last_analyze_count: 629121; +last_vacuum_count: 471336 +[2005-03-24 02:05:52 EST] INFO: analyze_threshold: 10822; +vacuum_threshold: 10922 + +This is the last pg_autovacuum debug output before I ran the manual vacuum + +[2005-03-24 09:18:44 EST] INFO: table name: secom."public"."file_92" +[2005-03-24 09:18:44 EST] INFO: relid: 9384219; relisshared: 0 +[2005-03-24 09:18:44 EST] INFO: reltuples: 106228.000000; relpages: +9131 +[2005-03-24 09:18:44 EST] INFO: curr_analyze_count: 634119; +curr_vacuum_count: 476095 +[2005-03-24 09:18:44 EST] INFO: last_analyze_count: 629121; +last_vacuum_count: 471336 +[2005-03-24 09:18:44 EST] INFO: analyze_threshold: 10822; +vacuum_threshold: 10922 + +file_92 had about 10000 Inserts/Deletes between 02:05 and 9:20 + +Then i Ran a vacuum verbose + +23 Mar 05 - 9:20 AM +INFO: vacuuming "public.file_92" +INFO: index "file_92_record_number_key" now contains 94 row versions in +2720 pages +DETAIL: 107860 index row versions were removed. +2712 index pages have been deleted, 2060 are currently reusable. +CPU 0.22s/0.64u sec elapsed 8.45 sec. +INFO: "file_92": removed 107860 row versions in 9131 pages +DETAIL: CPU 1.13s/4.27u sec elapsed 11.75 sec. +INFO: "file_92": found 107860 removable, 92 nonremovable row versions in +9131 pages +DETAIL: 91 dead row versions cannot be removed yet. +There were 303086 unused item pointers. +0 pages are entirely empty. +CPU 1.55s/5.00u sec elapsed 20.86 sec. +INFO: "file_92": truncated 9131 to 8423 pages +DETAIL: CPU 0.65s/0.03u sec elapsed 5.80 sec. +INFO: free space map: 57 relations, 34892 pages stored; 34464 total pages +needed +DETAIL: Allocated FSM size: 1000 relations + 2000000 pages = 11784 kB +shared memory. + +Also, file_92 is just a temporary storage area, for records waiting to be +processed. Records are in there typically ~10 sec. + +Over 100'000 Index Rows removed, 300'000 unused item pointers ? How could +autovacuum let this happen ? I would estimate the table had about 10000 +inserts/deletes between the last pg_autovacuum "Vacuum analyze" and my +manual vacuum verbose. + +It is like the suction is not strong enough ;) + +Any ideas ? It would be greatly appreciated as this is taking me one step +closer to the looney bin. + +Thanks + +/Otto Blomqvist + + + +From pgsql-performance-owner@postgresql.org Thu Mar 24 19:08:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AA9625343F + for ; + Thu, 24 Mar 2005 19:08:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32082-07 + for ; + Thu, 24 Mar 2005 19:07:52 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 61A6D5345A + for ; + Thu, 24 Mar 2005 19:07:51 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id f1so892965rne + for ; + Thu, 24 Mar 2005 11:07:45 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:reply-to:from:to:subject:date:mime-version:content-type:content-transfer-encoding:x-mailer:thread-index:x-mimeole:message-id; + b=FK9ylkBNp0EeKMkSZgvH8FSpUnw4MlI9tHuuE6RTc2LVvnEuHSNhMrs4sTz2+CCU8ZVhIchN8adZYvzTQbsk6QdUZg1fECXTOTBtZkgx7GwRoHGMBDLSitSRzQS09ks2KA/5qANdG9E3Gg02v37zcpPhkmk2IINZg3oVih2rZAI= +Received: by 10.38.9.54 with SMTP id 54mr1847691rni; + Thu, 24 Mar 2005 11:07:45 -0800 (PST) +Received: from MATTSPC ([12.216.69.41]) + by mx.gmail.com with ESMTP id 63sm636225rna.2005.03.24.11.07.44; + Thu, 24 Mar 2005 11:07:45 -0800 (PST) +Reply-To: +From: "Matthew Nuzum" +To: +Subject: Preventing query from hogging server +Date: Thu, 24 Mar 2005 13:07:39 -0600 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +Thread-Index: AcUwpL85DCG5JW2MS6OX5puytpNpHA== +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Message-ID: <42431001.36c6643c.1b4b.ffffd505@mx.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.398 tagged_above=0 required=5 + tests=DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/513 +X-Sequence-Number: 11218 + +I've got a report that is starting to take too long to run. I'm going to +create a lookup table that should speed up the results, but first I've got +to create the lookup table. + +I honestly don't care how long the query takes to run, I just want to run it +without causing a major performance impact on other operations. The query +seems to take forever even when I limit the results to just 10, so I don't +know if I can get good results by splitting the query into groups of queries +(for example, for a years worth of data do 12 queries, one for each month or +maybe 365 queries, one for each day) or if there is a psql equivalent to +"nice." + +I've tried `nice psql` in the past and I don't think that had much impact, +but I haven't tried it on this query. + +Here is the query (BTW, there will be a corresponding "max" version of this +query as well): +INSERT INTO usage_sessions_min (accountid,atime,sessionid) +select accountid, min(atime) as atime, sessionid from usage_access +group by accountid,sessionid; + +atime is a timestamptz, accountis is varchar(12) and sessionid is int. + +I've tried to do an explain analyze of this query, but its been running for +hours already and I don't know when it will finish. + +-- +Matthew Nuzum +www.followers.net - Makers of "Elite Content Management System" +View samples of Elite CMS in action by visiting +http://www.elitecms.com/ + + + +From pgsql-bugs-owner@postgresql.org Thu Mar 24 19:22:30 2005 +X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E182A52A50 + for ; + Thu, 24 Mar 2005 19:22:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36823-04 + for ; + Thu, 24 Mar 2005 19:22:23 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id CB46F5343F + for ; Thu, 24 Mar 2005 19:22:22 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2OJMMA8004842; + Thu, 24 Mar 2005 14:22:22 -0500 (EST) +To: Keith Browne , pgsql-bugs@postgresql.org, + andrew@supernews.com, "Brian O'Reilly" +Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 +In-reply-to: <14846.1111616020@sss.pgh.pa.us> +References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> + <1111567230.11750.596.camel@localhost.localdomain> + <4241C1DF.2020000@deepsky.com> + + <13841.1111608763@sss.pgh.pa.us> <4241D7AB.4030607@deepsky.com> + <14846.1111616020@sss.pgh.pa.us> +Comments: In-reply-to Tom Lane + message dated "Wed, 23 Mar 2005 17:13:40 -0500" +Date: Thu, 24 Mar 2005 14:22:22 -0500 +Message-ID: <4841.1111692142@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/259 +X-Sequence-Number: 11379 + +I wrote: +> ... Maybe we could +> put in a hack that detects whether a table has yet been vacuumed, and +> sets 10/1000 as the minimum stats --- not fixed values, but minimum +> values that can be overridden when the table is actually larger --- +> until it has been vacuumed. + +For lack of any better suggestions, I've done this in HEAD and 8.0 +branches. It proved simplest to just limit the page estimate to be +at least 10 pages when relpages == 0. The tuple estimate will be +derived from that using pre-existing code that estimates the average +tuple size. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 24 19:24:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 12D505340C + for ; + Thu, 24 Mar 2005 19:24:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37586-03 + for ; + Thu, 24 Mar 2005 19:24:12 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.192]) + by svr1.postgresql.org (Postfix) with ESMTP id EFEBD53205 + for ; + Thu, 24 Mar 2005 19:24:11 +0000 (GMT) +Received: by wproxy.gmail.com with SMTP id 36so683605wra + for ; + Thu, 24 Mar 2005 11:24:12 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=ulBBqPoDdvN+pDkVnoT3X+uiK6YsMd4SfMZW9l3Zvh2Tnyz8tnJP/qzVfzIxmS2mv/GELwBlLqv9GDbHbYTv1q14hZsnoYW0zrCEG/yKW/jFDAbyFI6qEdB6nY1+OO0sL19beeZWO2HPinOfDeXgG/OVTntnZNjZcyGrwG9nu8g= +Received: by 10.54.27.51 with SMTP id a51mr440448wra; + Thu, 24 Mar 2005 11:24:12 -0800 (PST) +Received: by 10.54.11.61 with HTTP; Thu, 24 Mar 2005 11:24:12 -0800 (PST) +Message-ID: <37d451f7050324112414d7c9b5@mail.gmail.com> +Date: Thu, 24 Mar 2005 13:24:12 -0600 +From: Rosser Schwarz +Reply-To: Rosser Schwarz +To: matt@followers.net +Subject: Re: Preventing query from hogging server +Cc: pgsql-performance@postgresql.org +In-Reply-To: <42431001.36c6643c.1b4b.ffffd505@mx.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +References: <42431001.36c6643c.1b4b.ffffd505@mx.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.211 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/514 +X-Sequence-Number: 11219 + +while you weren't looking, Matthew Nuzum wrote: + +> select accountid, min(atime) as atime, sessionid from usage_access +> group by accountid,sessionid; + +Try something along the lines of: + +select ua.accountid + , (select atime + from usage_access + where sessionid = ua.sessionid + and accountid = ua.accountid + order by atime asc + limit 1 + ) as atime + , ua.sessionid + from usage_access ua + group by accountid + , sessionid + +min() and max() currently do table scans, which, on large tables, or +even moderately sized tables with large numbers of accounts/sessions, +can add up. You'll need to replace asc with desc in the subquery for +the max() version. + +This form cheats a bit and uses the index to find the highest and +lowest values, provided you've created the appropriate indices. + +This is, IIRC, in the FAQ. + +/rls + +-- +:wq + +From pgsql-performance-owner@postgresql.org Thu Mar 24 19:33:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D3779533F6 + for ; + Thu, 24 Mar 2005 19:33:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40208-05 + for ; + Thu, 24 Mar 2005 19:32:58 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 67AA052D93 + for ; + Thu, 24 Mar 2005 19:32:58 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2OJWxbm004934; + Thu, 24 Mar 2005 14:32:59 -0500 (EST) +To: "Otto Blomqvist" +Cc: pgsql-performance@postgresql.org +Subject: Re: pg_autovacuum not having enough suction ? +In-reply-to: +References: +Comments: In-reply-to "Otto Blomqvist" + message dated "Thu, 24 Mar 2005 10:17:06 -0800" +Date: Thu, 24 Mar 2005 14:32:59 -0500 +Message-ID: <4933.1111692779@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/515 +X-Sequence-Number: 11220 + +"Otto Blomqvist" writes: +> Over 100'000 Index Rows removed, 300'000 unused item pointers ? How could +> autovacuum let this happen ? + +What PG version is this? + +(The earlier autovacuum releases had some bugs with large tables, thus +the question...) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 24 19:43:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CD275346A + for ; + Thu, 24 Mar 2005 19:43:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44183-01 + for ; + Thu, 24 Mar 2005 19:43:16 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C26953457 + for ; + Thu, 24 Mar 2005 19:43:15 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2OJhFor005051; + Thu, 24 Mar 2005 14:43:15 -0500 (EST) +To: matt@followers.net +Cc: pgsql-performance@postgresql.org +Subject: Re: Preventing query from hogging server +In-reply-to: <42431001.36c6643c.1b4b.ffffd505@mx.gmail.com> +References: <42431001.36c6643c.1b4b.ffffd505@mx.gmail.com> +Comments: In-reply-to "Matthew Nuzum" + message dated "Thu, 24 Mar 2005 13:07:39 -0600" +Date: Thu, 24 Mar 2005 14:43:15 -0500 +Message-ID: <5050.1111693395@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/516 +X-Sequence-Number: 11221 + +"Matthew Nuzum" writes: +> Here is the query (BTW, there will be a corresponding "max" version of this +> query as well): +> INSERT INTO usage_sessions_min (accountid,atime,sessionid) +> select accountid, min(atime) as atime, sessionid from usage_access +> group by accountid,sessionid; + +How many rows in usage_access? How many groups do you expect? +(Approximate answers are fine.) What PG version is this, and +what's your sort_mem setting? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 27 16:23:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8EA1353205 + for ; + Thu, 24 Mar 2005 19:46:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45142-06 + for ; + Thu, 24 Mar 2005 19:46:48 +0000 (GMT) +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 08C22534AB + for ; + Thu, 24 Mar 2005 19:46:47 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 30A9C30EA1; Thu, 24 Mar 2005 20:46:42 +0100 (MET) +From: Reid Thompson +X-Newsgroups: pgsql.performance +Subject: Configuration/Tuning of server/DB +Date: Thu, 24 Mar 2005 14:46:41 -0500 +Organization: Hub.Org Networking Services +Lines: 14 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/592 +X-Sequence-Number: 11297 + +Using information found on the web, I've come up with some configuration +and tuning parameters for a server/db that we will be implementing. I +was wondering if I could generate some feedback as to configuration and +tuning so that I could compare my estimations with those of others. + +Host is AIX 5.1 with 4 cpu's and 4 GB ram. Postgresql will be sharing +this machine with other processes. Storage is an EMC storage array. +The DB itself is very simple. Two tables, one with 40-45 columns ( +largest column will likely contain no more than 32 chars of data ), the +other with less than 5 columns ( largest column will contain no more +than 20 chars data ). Expected transactions will be along the order of +~600K +- 100K inserts and ~600K +-200K updates per week. + +Thanks + +From pgsql-performance-owner@postgresql.org Thu Mar 24 19:53:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C07945348D + for ; + Thu, 24 Mar 2005 19:53:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46865-08 + for ; + Thu, 24 Mar 2005 19:53:42 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 8921553475 + for ; + Thu, 24 Mar 2005 19:53:41 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id j1so583080rnf + for ; + Thu, 24 Mar 2005 11:53:43 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:reply-to:from:to:cc:subject:date:mime-version:content-type:content-transfer-encoding:x-mailer:in-reply-to:thread-index:x-mimeole:message-id; + b=oESR5+TLTvn3J/7wNWTGI1gfIIDwNFf98wS3raLai3lWyBO+8WFP7xRfqKPUrWXim2WlZqewiZSUnqAi+qi0Anc4un+FmT7WY3vUG/vuP7aTcNqQTmoeRCNZgSECnn1Ig03cOZ+6GA7XozYkRN4a7uVcmbpHd1wtP1BWRzicBbc= +Received: by 10.38.181.47 with SMTP id d47mr1881215rnf; + Thu, 24 Mar 2005 11:53:43 -0800 (PST) +Received: from MATTSPC ([12.216.69.41]) + by mx.gmail.com with ESMTP id h19sm626341rnb.2005.03.24.11.53.42; + Thu, 24 Mar 2005 11:53:42 -0800 (PST) +Reply-To: +From: "Matthew Nuzum" +To: "'Tom Lane'" +Cc: +Subject: Re: Preventing query from hogging server +Date: Thu, 24 Mar 2005 13:53:37 -0600 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +In-Reply-To: <5050.1111693395@sss.pgh.pa.us> +Thread-Index: AcUwqbx/GU33eBYDRwmNhg/1AK79RAAAKvtg +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Message-ID: <42431ac6.29dd6143.2b52.ffffbf08@mx.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.304 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/517 +X-Sequence-Number: 11222 + + +> How many rows in usage_access? How many groups do you expect? +> (Approximate answers are fine.) What PG version is this, and +> what's your sort_mem setting? +> +> regards, tom lane + +I believe there are about 40,000,000 rows, I expect there to be about +10,000,000 groups. PostgreSQL version is 7.3.2 and the sort_mem is at the +default setting. + +(I know that's an old version. We've been testing with 7.4 now and are +nearly ready to upgrade.) + +-- +Matthew Nuzum +www.followers.net - Makers of "Elite Content Management System" +View samples of Elite CMS in action by visiting +http://www.followers.net/portfolio/ + + +From pgsql-performance-owner@postgresql.org Thu Mar 24 19:55:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B856E534B5 + for ; + Thu, 24 Mar 2005 19:55:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47339-07 + for ; + Thu, 24 Mar 2005 19:55:37 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.197]) + by svr1.postgresql.org (Postfix) with ESMTP id 4ED885348D + for ; + Thu, 24 Mar 2005 19:55:36 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id f1so909101rne + for ; + Thu, 24 Mar 2005 11:55:37 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:reply-to:from:to:cc:subject:date:mime-version:content-type:content-transfer-encoding:x-mailer:in-reply-to:thread-index:x-mimeole:message-id; + b=g29l7QOV12n+SaDrRKobaHXFlusDw0jtORmXQfjT+zRniqQQiPKubPV9/OiJc4Rq5iJj7SIAp+WsaCpD4RXy4gatP+1vMTWj4b638kzJa10vfaJ1o7dmlo8+dtD95/gmaRfhscYMYoIYWotMSRFwoN1rkId6+POW7tmGtIm3r94= +Received: by 10.38.160.51 with SMTP id i51mr1885631rne; + Thu, 24 Mar 2005 11:55:37 -0800 (PST) +Received: from MATTSPC ([12.216.69.41]) + by mx.gmail.com with ESMTP id 63sm654890rna.2005.03.24.11.55.37; + Thu, 24 Mar 2005 11:55:37 -0800 (PST) +Reply-To: +From: "Matthew Nuzum" +To: "'Tom Lane'" +Cc: +Subject: Re: Preventing query from hogging server +Date: Thu, 24 Mar 2005 13:55:32 -0600 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +In-Reply-To: <5050.1111693395@sss.pgh.pa.us> +Thread-Index: AcUwqbx/GU33eBYDRwmNhg/1AK79RAAAYHbg +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Message-ID: <42431b39.16b65c96.1b4b.ffffd9b6@mx.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.336 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/518 +X-Sequence-Number: 11223 + +> How many rows in usage_access? + +Oh, I just got my explain analyze: + QUERY +PLAN +---------------------------------------------------------------------------- +-------------------------------------------------------------------------- + Subquery Scan "*SELECT*" (cost=9499707.90..9856491.74 rows=3567838 +width=28) (actual time=11443537.58..12470835.17 rows=1198141 loops=1) + -> Aggregate (cost=9499707.90..9856491.74 rows=3567838 width=28) +(actual time=11443537.56..12466550.25 rows=1198141 loops=1) + -> Group (cost=9499707.90..9767295.78 rows=35678384 width=28) +(actual time=11443537.10..12408372.26 rows=35678383 loops=1) + -> Sort (cost=9499707.90..9588903.86 rows=35678384 +width=28) (actual time=11443537.07..12035366.31 rows=35678383 loops=1) + Sort Key: accountid, sessionid + -> Seq Scan on usage_access (cost=0.00..1018901.84 +rows=35678384 width=28) (actual time=8.13..416580.35 rows=35678383 loops=1) + Total runtime: 12625498.84 msec +(7 rows) + +-- +Matthew Nuzum +www.followers.net - Makers of "Elite Content Management System" +View samples of Elite CMS in action by visiting +http://www.followers.net/portfolio/ + + +From pgsql-performance-owner@postgresql.org Thu Mar 24 20:02:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 05694534A1 + for ; + Thu, 24 Mar 2005 20:02:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49220-10 + for ; + Thu, 24 Mar 2005 20:02:18 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id B8A1D53494 + for ; + Thu, 24 Mar 2005 20:02:15 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2OK2Gxi005247; + Thu, 24 Mar 2005 15:02:16 -0500 (EST) +To: matt@followers.net +Cc: pgsql-performance@postgresql.org +Subject: Re: Preventing query from hogging server +In-reply-to: <42431ac6.29dd6143.2b52.ffffbf08@mx.gmail.com> +References: <42431ac6.29dd6143.2b52.ffffbf08@mx.gmail.com> +Comments: In-reply-to "Matthew Nuzum" + message dated "Thu, 24 Mar 2005 13:53:37 -0600" +Date: Thu, 24 Mar 2005 15:02:15 -0500 +Message-ID: <5246.1111694535@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/519 +X-Sequence-Number: 11224 + +"Matthew Nuzum" writes: +> I believe there are about 40,000,000 rows, I expect there to be about +> 10,000,000 groups. PostgreSQL version is 7.3.2 and the sort_mem is at the +> default setting. + +Okay. I doubt that the nearby suggestion to convert the min()s to +indexscans will help at all, given those numbers --- there aren't enough +rows per group to make it a win. + +I think you've just gotta put up with the sorting required to bring the +groups together. LIMIT or subdividing the query will not make it +faster, because the sort step is the expensive part. You could probably +improve matters by increasing sort_mem as much as you can stand --- +maybe something like 10M to 100M (instead of the default 1M). Obviously +you don't want to make it a big fraction of your available RAM, or it +will hurt the concurrent processing, but on modern machines I would +think you could give this a few tens of MB without any problem. (Note +that you want to just SET sort_mem in this one session, not increase it +globally.) + +I would strongly suggest doing the min and max calculations together: + + select groupid, min(col), max(col) from ... + +because if you do them in two separate queries 90% of the effort will be +duplicated. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 24 20:13:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 750C65342F + for ; + Thu, 24 Mar 2005 20:13:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52473-08 + for ; + Thu, 24 Mar 2005 20:13:05 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.204]) + by svr1.postgresql.org (Postfix) with ESMTP id 8640153433 + for ; + Thu, 24 Mar 2005 20:13:05 +0000 (GMT) +Received: by rproxy.gmail.com with SMTP id a36so1006082rnf + for ; + Thu, 24 Mar 2005 12:13:06 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:reply-to:from:to:cc:subject:date:mime-version:content-type:content-transfer-encoding:x-mailer:in-reply-to:thread-index:x-mimeole:message-id; + b=RFHhwPJygOkpro+kKgIvvma0CwpY2Ca+HaRf2RNvFmpuzHiZ0NcBqub9h7mI/0jeTt3IfUEg5tOAKhz13uyAJiNSbLG0lkU7XCDnAe9lnhLEpLPOdBWxd3XLpVeFfCRpJiIKNAXp+KPpluNPexhb9Ay+RBz7aJFGWpptscIRY8U= +Received: by 10.39.2.36 with SMTP id e36mr1538448rni; + Thu, 24 Mar 2005 12:13:06 -0800 (PST) +Received: from MATTSPC ([12.216.69.41]) + by mx.gmail.com with ESMTP id k4sm671136rnd.2005.03.24.12.13.06; + Thu, 24 Mar 2005 12:13:06 -0800 (PST) +Reply-To: +From: "Matthew Nuzum" +To: "'Tom Lane'" +Cc: +Subject: Re: Preventing query from hogging server +Date: Thu, 24 Mar 2005 14:13:01 -0600 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.6353 +In-Reply-To: <5246.1111694535@sss.pgh.pa.us> +Thread-Index: AcUwrGIzF4GD3amnTLaSi/voC0d0ggAAJGmg +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +Message-ID: <42431f52.4700af57.2963.ffffe2b8@mx.gmail.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.304 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/520 +X-Sequence-Number: 11225 + + +> I would strongly suggest doing the min and max calculations together: +> +> select groupid, min(col), max(col) from ... +> +> because if you do them in two separate queries 90% of the effort will be +> duplicated. +> +> regards, tom lane + +Thanks. Other than avoiding using too much sort mem, is there anything else +I can do to ensure this query doesn't starve other processes for resources? + +Doing the explain analyze only increases my server load by 1 and seems to +readily relinquish CPU time, but previously when I had been running a test +query my server load rose to unacceptable levels. + +FWIW, the explain was run from psql running on the db server, the test query +the other day was run from one of the webservers. Should I run this on the +db server to minimize load? + +-- +Matthew Nuzum +www.followers.net - Makers of "Elite Content Management System" +View samples of Elite CMS in action by visiting +http://www.followers.net/portfolio/ + + +From pgsql-performance-owner@postgresql.org Thu Mar 24 20:19:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BCD053474 + for ; + Thu, 24 Mar 2005 20:19:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55149-06 + for ; + Thu, 24 Mar 2005 20:19:02 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id DBB0952D93 + for ; + Thu, 24 Mar 2005 20:19:01 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2OKJ2k8005370; + Thu, 24 Mar 2005 15:19:02 -0500 (EST) +To: matt@followers.net +Cc: pgsql-performance@postgresql.org +Subject: Re: Preventing query from hogging server +In-reply-to: <42431f52.4700af57.2963.ffffe2b8@mx.gmail.com> +References: <42431f52.4700af57.2963.ffffe2b8@mx.gmail.com> +Comments: In-reply-to "Matthew Nuzum" + message dated "Thu, 24 Mar 2005 14:13:01 -0600" +Date: Thu, 24 Mar 2005 15:19:02 -0500 +Message-ID: <5369.1111695542@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/521 +X-Sequence-Number: 11226 + +"Matthew Nuzum" writes: +> Thanks. Other than avoiding using too much sort mem, is there anything else +> I can do to ensure this query doesn't starve other processes for resources? + +Not a lot. + +> Doing the explain analyze only increases my server load by 1 and seems to +> readily relinquish CPU time, but previously when I had been running a test +> query my server load rose to unacceptable levels. + +Interesting. EXPLAIN ANALYZE is going to cause a bunch of +gettimeofday() calls to be inserted ... maybe your kernel takes those as +process preemption points? Seems unlikely, but ... + +> FWIW, the explain was run from psql running on the db server, the test query +> the other day was run from one of the webservers. Should I run this on the +> db server to minimize load? + +Since it's an insert/select, psql isn't participating in the data flow. +It's not going to matter where the psql process is. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 27 16:26:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 60D92533F6 + for ; + Thu, 24 Mar 2005 20:25:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56459-10 + for ; + Thu, 24 Mar 2005 20:25:54 +0000 (GMT) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id E74A353245 + for ; + Thu, 24 Mar 2005 20:25:52 +0000 (GMT) +Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] + helo=[192.168.0.66]) + by outbound.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) + (Exim 4.44) id 1DEYtt-000DRO-SJ + for pgsql-performance@postgresql.org; Thu, 24 Mar 2005 15:25:53 -0500 +Message-ID: <4243224C.8060102@tocr.com> +Date: Thu, 24 Mar 2005 15:25:48 -0500 +From: "Matthew T. O'Connor" +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: pg_autovacuum not having enough suction ? +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Originating-IP: 67.80.199.173 +X-Report-Abuse-To: abuse@dyndns.org (see + http://www.mailhop.org/outbound/abuse.html for abuse reporting + information) +X-MHO-User: zeut +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/596 +X-Sequence-Number: 11301 + +Well the simple answer is that pg_autovacuum didn't see 10,000 inserts +updates or deletes. +pg_autovacuum saw: 476095 - 471336 = 4759 U/D's relevant for +vacuuming and + 634119 - 629121 = 4998 I/U/D's relevant for performing analyze. + +The tough question is why is pg_autovacuum not seeing all the updates. +Since autovacuum depends on the stats system for it's numbers, the most +likely answer is that the stats system is not able to keep up with the +workload, and is ignoring some of the updates. Would you check to see +what the stats system is reporting for numbers of I/U/D's for the +file_92 table? The query pg_autovacuum uses is: + +select a.oid,a.relname,a.relnamespace,a.relpages,a.relisshared,a.reltuples, + b.schemaname,b.n_tup_ins,b.n_tup_upd,b.n_tup_del +from pg_class a, pg_stat_all_tables b +where a.oid=b.relid and a.relkind = 'r' + +Take a look at the n_tup_ins, upd, del numbers before and see if they +are keeping up with the actual number if I/U/D's that you are +performing. If they are, then it's a pg_autovacuum problem that I will +look into further, if they are not, then it's a stats system problem +that I can't really help with. + +Good luck, + +Matthew + + +Otto Blomqvist wrote: + +>Hello ! +> +>I'm running pg_autovacuum on a 1GHz, 80Gig, 512Mhz machine. The database is +>about 30MB tarred. We have about 50000 Updates/Inserts/Deletes per day. It +>runs beautifully for ~4 days. Then the HDD activity and the Postmaster CPU +>usage goes up ALOT. Even though I have plenty (?) of FSM (2 million) pages. +>I perform a vacuum and everything is back to normal for another 4 days. I +>could schedule a manual vacuum each day but the util is not called +>pg_SemiAutoVacuum so I'm hoping this is not necessary. The same user that +>ran the manual vacuum is running pg_autovacuum. The normal CPU usage is +>about 10% w/ little HD activity. +> +>Im running autovacuum with the following flags -d 3 -v 300 -V 0.1 -s 180 -S +>0.1 -a 200 -A 0.1 +> +>Below are some snipplets regarding vacuuming from the busiest table +> +>This is the last VACUUM ANALYZE performed by pg_autovacuum before I ran the +>manual vacuum +> +>[2005-03-24 02:05:43 EST] DEBUG: Performing: VACUUM ANALYZE +>"public"."file_92" +>[2005-03-24 02:05:52 EST] INFO: table name: secom."public"."file_92" +>[2005-03-24 02:05:52 EST] INFO: relid: 9384219; relisshared: 0 +>[2005-03-24 02:05:52 EST] INFO: reltuples: 106228.000000; relpages: +>9131 +>[2005-03-24 02:05:52 EST] INFO: curr_analyze_count: 629121; +>curr_vacuum_count: 471336 +>[2005-03-24 02:05:52 EST] INFO: last_analyze_count: 629121; +>last_vacuum_count: 471336 +>[2005-03-24 02:05:52 EST] INFO: analyze_threshold: 10822; +>vacuum_threshold: 10922 +> +>This is the last pg_autovacuum debug output before I ran the manual vacuum +> +>[2005-03-24 09:18:44 EST] INFO: table name: secom."public"."file_92" +>[2005-03-24 09:18:44 EST] INFO: relid: 9384219; relisshared: 0 +>[2005-03-24 09:18:44 EST] INFO: reltuples: 106228.000000; relpages: +>9131 +>[2005-03-24 09:18:44 EST] INFO: curr_analyze_count: 634119; +>curr_vacuum_count: 476095 +>[2005-03-24 09:18:44 EST] INFO: last_analyze_count: 629121; +>last_vacuum_count: 471336 +>[2005-03-24 09:18:44 EST] INFO: analyze_threshold: 10822; +>vacuum_threshold: 10922 +> +>file_92 had about 10000 Inserts/Deletes between 02:05 and 9:20 +> +>Then i Ran a vacuum verbose +> +>23 Mar 05 - 9:20 AM +>INFO: vacuuming "public.file_92" +>INFO: index "file_92_record_number_key" now contains 94 row versions in +>2720 pages +>DETAIL: 107860 index row versions were removed. +>2712 index pages have been deleted, 2060 are currently reusable. +>CPU 0.22s/0.64u sec elapsed 8.45 sec. +>INFO: "file_92": removed 107860 row versions in 9131 pages +>DETAIL: CPU 1.13s/4.27u sec elapsed 11.75 sec. +>INFO: "file_92": found 107860 removable, 92 nonremovable row versions in +>9131 pages +>DETAIL: 91 dead row versions cannot be removed yet. +>There were 303086 unused item pointers. +>0 pages are entirely empty. +>CPU 1.55s/5.00u sec elapsed 20.86 sec. +>INFO: "file_92": truncated 9131 to 8423 pages +>DETAIL: CPU 0.65s/0.03u sec elapsed 5.80 sec. +>INFO: free space map: 57 relations, 34892 pages stored; 34464 total pages +>needed +>DETAIL: Allocated FSM size: 1000 relations + 2000000 pages = 11784 kB +>shared memory. +> +>Also, file_92 is just a temporary storage area, for records waiting to be +>processed. Records are in there typically ~10 sec. +> +>Over 100'000 Index Rows removed, 300'000 unused item pointers ? How could +>autovacuum let this happen ? I would estimate the table had about 10000 +>inserts/deletes between the last pg_autovacuum "Vacuum analyze" and my +>manual vacuum verbose. +> +>It is like the suction is not strong enough ;) +> +>Any ideas ? It would be greatly appreciated as this is taking me one step +>closer to the looney bin. +> +>Thanks +> +>/Otto Blomqvist +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> +> +> + +-- +Matthew O'Connor +V.P. of Operations +Terrie O'Connor Realtors +201-934-4900 x27 + + +From pgsql-performance-owner@postgresql.org Thu Mar 24 21:57:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DAD135370E + for ; + Thu, 24 Mar 2005 21:57:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82037-06 + for ; + Thu, 24 Mar 2005 21:57:05 +0000 (GMT) +Received: from cmailm1.svr.pol.co.uk (cmailm1.svr.pol.co.uk [195.92.193.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 1367D52A76 + for ; + Thu, 24 Mar 2005 21:57:04 +0000 (GMT) +Received: from modem-3062.python.dialup.pol.co.uk ([217.134.219.246] + helo=192.168.0.102) by cmailm1.svr.pol.co.uk with esmtp (Exim 4.41) + id 1DEaK9-0003Cb-8e; Thu, 24 Mar 2005 21:57:05 +0000 +Subject: Re: CPU 0.1% IOWAIT 99% for decisonnal queries +From: Simon Riggs +To: Patrick Vedrines +Cc: performance pgsql +In-Reply-To: <006801c53056$a4585420$1e0baf96@pcpatrickxp> +References: <002601c52f0a$2312a4d0$280baf96@PCPATRICK> + <1111529891.11750.577.camel@localhost.localdomain> + <006801c53056$a4585420$1e0baf96@pcpatrickxp> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Thu, 24 Mar 2005 21:55:56 +0000 +Message-Id: <1111701356.11750.683.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.062 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/522 +X-Sequence-Number: 11227 + +On Thu, 2005-03-24 at 10:48 +0100, Patrick Vedrines wrote: +> > You've got 1.5Gb of shared_buffers and > 2Gb data. In 8.0, the scan +> will +> > hardly use the cache at all, nor will it ever, since the data is +> bigger +> > than the cache. Notably, the scan of B should NOT spoil the cache +> for A +> Are you sure of that ? Is Postgres able to say to OS: "don't use the +> cache for this query"? + +PostgreSQL 8.0 has the ARC algorithm which prevents cache spoiling of +the shared_buffers, but has no direct influence over the OS cache. + +> > Priming the cache is quite hard...but not impossible. +> > What will kill you on a shared_buffers that big is the bgwriter, +> which +> > you should turn off by setting bgwriter_maxpages = 0 +> Is bgwriter concerned as my application applyes only SELECT ? + +With very large shared_buffers the bgwriter's default settings are a +problem. You don't need it, so I suggest turning it off. + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Thu Mar 24 23:00:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C954E53777 + for ; + Thu, 24 Mar 2005 23:00:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98728-04 + for ; + Thu, 24 Mar 2005 23:00:27 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 57F4853766 + for ; + Thu, 24 Mar 2005 23:00:25 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 58A6F30EA1; Fri, 25 Mar 2005 00:00:26 +0100 (MET) +From: "Otto Blomqvist" +X-Newsgroups: pgsql.performance +Subject: Re: pg_autovacuum not having enough suction ? +Date: Thu, 24 Mar 2005 15:04:24 -0800 +Organization: Hub.Org Networking Services +Lines: 24 +Message-ID: +References: <4933.1111692779@sss.pgh.pa.us> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.547 tagged_above=0 required=5 tests=AWL, + PRIORITY_NO_NAME +X-Spam-Level: +X-Archive-Number: 200503/523 +X-Sequence-Number: 11228 + +Sorry about that. I'm Running 8.0.0 on Linux Redhat 8.0 + + +"Tom Lane" wrote in message +news:4933.1111692779@sss.pgh.pa.us... +> "Otto Blomqvist" writes: +> > Over 100'000 Index Rows removed, 300'000 unused item pointers ? How +could +> > autovacuum let this happen ? +> +> What PG version is this? +> +> (The earlier autovacuum releases had some bugs with large tables, thus +> the question...) +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: Have you searched our list archives? +> +> http://archives.postgresql.org +> + + + +From pgsql-performance-owner@postgresql.org Thu Mar 24 23:40:57 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 86A5D53404 + for ; + Thu, 24 Mar 2005 23:40:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09260-02 + for ; + Thu, 24 Mar 2005 23:40:48 +0000 (GMT) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 172AB53237 + for ; + Thu, 24 Mar 2005 23:40:47 +0000 (GMT) +Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] + helo=[192.168.0.66]) + by outbound.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) + (Exim 4.44) id 1DEbwX-000GIc-OL; Thu, 24 Mar 2005 18:40:49 -0500 +Message-ID: <42434FFC.10105@zeut.net> +Date: Thu, 24 Mar 2005 18:40:44 -0500 +From: "Matthew T. O'Connor" +Organization: Terrie O'Connor Realtors +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Otto Blomqvist +Cc: pgsql-performance@postgresql.org +Subject: Re: pg_autovacuum not having enough suction ? +References: <4933.1111692779@sss.pgh.pa.us> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Originating-IP: 67.80.199.173 +X-Report-Abuse-To: abuse@dyndns.org (see + http://www.mailhop.org/outbound/abuse.html for abuse reporting + information) +X-MHO-User: zeut +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/524 +X-Sequence-Number: 11229 + +The version that shipped with 8.0 should be fine. The only version that +had the problem Tom referred to are in the early 7.4.x releases. + +Did you get my other message about information from the stats system +(I'm not sure why my other post has yet to show up on the performance +list). + +Matthew + + +Otto Blomqvist wrote: + +>Sorry about that. I'm Running 8.0.0 on Linux Redhat 8.0 +> +> +>"Tom Lane" wrote in message +>news:4933.1111692779@sss.pgh.pa.us... +> +> +>>"Otto Blomqvist" writes: +>> +>> +>>>Over 100'000 Index Rows removed, 300'000 unused item pointers ? How +>>> +>>> +>could +> +> +>>>autovacuum let this happen ? +>>> +>>> +>>What PG version is this? +>> +>>(The earlier autovacuum releases had some bugs with large tables, thus +>>the question...) +>> +>>regards, tom lane +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 6: Have you searched our list archives? +>> +>> http://archives.postgresql.org +>> +>> +>> +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 7: don't forget to increase your free space map settings +> +> +> + +From pgsql-performance-owner@postgresql.org Thu Mar 24 23:58:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 65012534D4 + for ; + Thu, 24 Mar 2005 23:58:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12828-03 + for ; + Thu, 24 Mar 2005 23:58:04 +0000 (GMT) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 17907534A4 + for ; + Thu, 24 Mar 2005 23:58:03 +0000 (GMT) +Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] + helo=[192.168.0.66]) + by outbound.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) + (Exim 4.44) id 1DEcDG-000Idd-79; Thu, 24 Mar 2005 18:58:06 -0500 +Message-ID: <42435408.30303@zeut.net> +Date: Thu, 24 Mar 2005 18:58:00 -0500 +From: "Matthew T. O'Connor" +Organization: Terrie O'Connor Realtors +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Otto Blomqvist , + "pgsql-performance@postgresql.org" +Subject: Re: pg_autovacuum not having enough suction ? +References: <42430FA0.9080204@zeut.net> + <002b01c530c5$ad5a1620$e602a8c0@blomqvist> +In-Reply-To: <002b01c530c5$ad5a1620$e602a8c0@blomqvist> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Originating-IP: 67.80.199.173 +X-Report-Abuse-To: abuse@dyndns.org (see + http://www.mailhop.org/outbound/abuse.html for abuse reporting + information) +X-MHO-User: zeut +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.009 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/525 +X-Sequence-Number: 11230 + +I would rather keep this on list since other people can chime in. + +Otto Blomqvist wrote: + +>It does not seem to be a Stats collector problem. +> +> oid | relname | relnamespace | relpages | relisshared | reltuples | +>schemaname | n_tup_ins | n_tup_upd | n_tup_del +>---------+---------+--------------+----------+-------------+-----------+---- +>--------+-----------+-----------+----------- +> 9384219 | file_92 | 2200 | 8423 | f | 49837 | +>public | 158176 | 318527 | 158176 +>(1 row) +> +>I insert 50000 records +> +>secom=# select createfile_92records(1, 50000); <--- this is a pg script +>that inserts records 1 threw 50000. +> createfile_92records +>---------------------- +> 0 +> +> +> oid | relname | relnamespace | relpages | relisshared | reltuples | +>schemaname | n_tup_ins | n_tup_upd | n_tup_del +>---------+---------+--------------+----------+-------------+-----------+---- +>--------+-----------+-----------+----------- +> 9384219 | file_92 | 2200 | 8423 | f | 49837 | +>public | 208179 | 318932 | 158377 +>(1 row) +> +>reltuples does not change ? Hmm. n_tup_ins looks fine. +> +> + +That is expected, reltuples only gets updated by a vacuum or an analyze. + +>This table is basically a queue full of records waiting to get transfered +>over from our 68030 system to the PG database. The records are then moved +>into folders (using a trigger) like file_92_myy depending on what month the +>record was created on the 68030. During normal operations there should not +>be more than 10 records at a time in the table, although during the course +>of a day a normal system will get about 50k records. I create 50000 records +>to simulate incoming traffic, since we don't have much traffic in the test +>lab. +> +>After a few hours we have +> +>secom=# select count(*) from file_92; +> count +>------- +> 42072 +> +>So we have sent over approx 8000 Records. +> +> oid | relname | relnamespace | relpages | relisshared | reltuples | +>schemaname | n_tup_ins | n_tup_upd | n_tup_del +>---------+---------+--------------+----------+-------------+-----------+---- +>--------+-----------+-----------+----------- +> 9384219 | file_92 | 2200 | 8423 | f | 49837 | +>public | 208218 | 334521 | 166152 +>(1 row) +> +> +>n_tup_upd: 318932 + (50000-42072)*2 = 334788 pretty close. (Each record +>gets updated twice, then moved) +>n_tup_del: 158377 + (50000-42072) = 166305 pretty close. (there are also +>minor background traffic going on) +> +> +>I could send over the full vacuum verbose capture as well as the autovacuum +>capture if that is of interest. +> + +That might be helpful. I don't see a stats system problem here, but I +also haven't heard of any autovac problems recently, so this might be +something new. + +Thanks, + +Matthew O'Connor + + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 00:07:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AAB3153784 + for ; + Fri, 25 Mar 2005 00:07:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16010-09 + for ; + Fri, 25 Mar 2005 00:07:24 +0000 (GMT) +Received: from mailgate1.nau.edu (mailgate1.nau.edu [134.114.96.58]) + by svr1.postgresql.org (Postfix) with ESMTP id 4BB09534D6 + for ; + Fri, 25 Mar 2005 00:07:23 +0000 (GMT) +Received: from CONVERSION-DAEMON.mailgate1.nau.edu by mailgate1.nau.edu + (PMDF V6.2-X17 #30770) id <0IDV00N01SCC0Y@mailgate1.nau.edu> for + pgsql-performance@postgresql.org; Thu, 24 Mar 2005 17:07:25 -0700 (MST) +Received: from k2.cet.nau.edu (net9-213.cet.nau.edu [134.114.9.213]) + by mailgate1.nau.edu (PMDF V6.2-X17 #30770) + with ESMTP id <0IDV006CRSCCB1@mailgate1.nau.edu> for + pgsql-performance@postgresql.org; Thu, 24 Mar 2005 17:07:24 -0700 (MST) +Date: Thu, 24 Mar 2005 17:10:57 -0700 +From: Karim Nassar +Subject: Delete query takes exorbitant amount of time +To: pgsql-performance@postgresql.org +Message-id: <1111709457.9085.127.camel@k2.cet.nau.edu> +MIME-version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-type: text/plain +Content-transfer-encoding: 7BIT +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/526 +X-Sequence-Number: 11231 + +v8.0.1 on a Sun v20Z running gentoo linux, 1 cpu, 1GB Ram, 1 10k scsi +disk + +I have a (fairly) newly rebuilt database. In the last month it has +undergone extensive testing, hence thousands of inserts and deletes in +the table in question. After each mass unload/load cycle, I vacuum full +analyze verbose. + +I tried to build a test case to isolate the issue, but the problem does +not manifest itself, so I think I have somehow made postgresql angry. I +could drop the whole db and start over, but I am interested in not +reproducing this issue. + +Here is the statement: + +orfs=# explain analyze DELETE FROM int_sensor_meas_type WHERE +id_meas_type IN (SELECT * FROM meas_type_ids); + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=11.53..42.06 rows=200 width=6) (actual +time=1.564..2.840 rows=552 loops=1) + Hash Cond: ("outer".id_meas_type = "inner".id_meas_type) + -> Seq Scan on int_sensor_meas_type (cost=0.00..25.36 rows=636 +width=10) (actual time=0.005..0.828 rows=748 loops=1) + -> Hash (cost=11.03..11.03 rows=200 width=4) (actual +time=1.131..1.131 rows=0 loops=1) + -> HashAggregate (cost=11.03..11.03 rows=200 width=4) (actual +time=0.584..0.826 rows=552 loops=1) + -> Seq Scan on meas_type_ids (cost=0.00..9.42 rows=642 +width=4) (actual time=0.002..0.231 rows=552 loops=1) + Total runtime: 2499616.216 ms +(7 rows) + +Yes, that's *40 minutes*. It drives cpu (as viewed in top) to 99%+ for +the entire duration of the query, but %mem hangs at 1% or lower. + +meas_type_ids is a temp table with the id's I want to nuke. Here is a +similar query behaving as expected: + +orfs=# explain analyze DELETE FROM int_station_sensor WHERE id_sensor +IN (SELECT * FROM sensor_ids); + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=4.18..21.13 rows=272 width=6) (actual +time=0.479..0.847 rows=169 loops=1) + Hash Cond: ("outer".id_sensor = "inner".id_sensor) + -> Seq Scan on int_station_sensor (cost=0.00..11.49 rows=549 +width=10) (actual time=0.007..0.265 rows=267 loops=1) + -> Hash (cost=3.68..3.68 rows=200 width=4) (actual +time=0.325..0.325 rows=0 loops=1) + -> HashAggregate (cost=3.68..3.68 rows=200 width=4) (actual +time=0.177..0.256 rows=169 loops=1) + -> Seq Scan on sensor_ids (cost=0.00..3.14 rows=214 +width=4) (actual time=0.003..0.057 rows=169 loops=1) + Total runtime: 1.340 ms +(7 rows) + + +I have posted my tables, data and test cases here: +http://ccl.cens.nau.edu/~kan4/testing/long-delete + + +Where do I go from here? + + +Thanks in advance, +-- +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=- Mobile: (928) 699-9221 + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 00:52:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AE157536CE + for ; + Fri, 25 Mar 2005 00:52:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27309-01 + for ; + Fri, 25 Mar 2005 00:52:07 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E3CCA536C8 + for ; + Fri, 25 Mar 2005 00:52:06 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2P0q7IP002631; + Thu, 24 Mar 2005 19:52:07 -0500 (EST) +To: Karim Nassar +Cc: pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <1111709457.9085.127.camel@k2.cet.nau.edu> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> +Comments: In-reply-to Karim Nassar + message dated "Thu, 24 Mar 2005 17:10:57 -0700" +Date: Thu, 24 Mar 2005 19:52:07 -0500 +Message-ID: <2630.1111711927@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/527 +X-Sequence-Number: 11232 + +Karim Nassar writes: +> Here is the statement: + +> orfs=# explain analyze DELETE FROM int_sensor_meas_type WHERE +> id_meas_type IN (SELECT * FROM meas_type_ids); +> QUERY PLAN +> ----------------------------------------------------------------------------------------------------------------------------- +> Hash Join (cost=11.53..42.06 rows=200 width=6) (actual +> time=1.564..2.840 rows=552 loops=1) +> ... +> Total runtime: 2499616.216 ms +> (7 rows) + +Notice that the actual join is taking 2.8 ms. The other ~40 minutes is +in operations that we cannot see in this plan, but we can surmise are ON +DELETE triggers. + +> Where do I go from here? + +Look at what your triggers are doing. My private bet is that you have +unindexed foreign keys referencing this table, and so each deletion +forces a seqscan of some other, evidently very large, table(s). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 25 01:25:41 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 83AA1536D1 + for ; + Fri, 25 Mar 2005 01:25:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34220-10 + for ; + Fri, 25 Mar 2005 01:25:24 +0000 (GMT) +Received: from mir3-fs.mir3.com (unknown [216.74.11.46]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E8665341B + for ; + Fri, 25 Mar 2005 01:25:23 +0000 (GMT) +Received: from amateljan.mirlogic.com ([172.16.2.68]) by mir3-fs.mir3.com with + Microsoft SMTPSVC(5.0.2195.5329); Thu, 24 Mar 2005 17:25:18 -0800 +Subject: Re: Delete query takes exorbitant amount of time +From: Mark Lewis +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <2630.1111711927@sss.pgh.pa.us> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> +Content-Type: text/plain +Organization: MIR3, Inc. +Message-Id: <1111713798.23412.3.camel@amateljan.mirlogic.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.4 (1.4.4-3) +Date: Thu, 24 Mar 2005 17:23:19 -0800 +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 25 Mar 2005 01:25:18.0635 (UTC) + FILETIME=[815D77B0:01C530D9] +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/528 +X-Sequence-Number: 11233 + +Tom, + +I've got a similar problem with deletes taking a very long time. I know +that there are lots of foreign keys referencing this table, and other +foreign keys referencing those tables, etc. I've been curious, is there +a way to find out how long the foreign key checks take for each +dependent table? + +-- Mark Lewis + +On Thu, 2005-03-24 at 16:52, Tom Lane wrote: +> Karim Nassar writes: +> > Here is the statement: +> +> > orfs=# explain analyze DELETE FROM int_sensor_meas_type WHERE +> > id_meas_type IN (SELECT * FROM meas_type_ids); +> > QUERY PLAN +> > ----------------------------------------------------------------------------------------------------------------------------- +> > Hash Join (cost=11.53..42.06 rows=200 width=6) (actual +> > time=1.564..2.840 rows=552 loops=1) +> > ... +> > Total runtime: 2499616.216 ms +> > (7 rows) +> +> Notice that the actual join is taking 2.8 ms. The other ~40 minutes is +> in operations that we cannot see in this plan, but we can surmise are ON +> DELETE triggers. +> +> > Where do I go from here? +> +> Look at what your triggers are doing. My private bet is that you have +> unindexed foreign keys referencing this table, and so each deletion +> forces a seqscan of some other, evidently very large, table(s). +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 01:45:08 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CD72053492 + for ; + Fri, 25 Mar 2005 01:44:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38051-09 + for ; + Fri, 25 Mar 2005 01:44:48 +0000 (GMT) +Received: from mailgate2.nau.edu (mailgate2.nau.edu [134.114.96.59]) + by svr1.postgresql.org (Postfix) with ESMTP id D00FF52A76 + for ; + Fri, 25 Mar 2005 01:44:47 +0000 (GMT) +Received: from CONVERSION-DAEMON.mailgate2.nau.edu by mailgate2.nau.edu + (PMDF V6.2-X17 #30770) id <0IDV00H01WUQAW@mailgate2.nau.edu> for + pgsql-performance@postgresql.org; Thu, 24 Mar 2005 18:44:50 -0700 (MST) +Received: from k2.cet.nau.edu (net9-213.cet.nau.edu [134.114.9.213]) + by mailgate2.nau.edu (PMDF V6.2-X17 #30770) + with ESMTP id <0IDV00C9ZWUPR7@mailgate2.nau.edu> for + pgsql-performance@postgresql.org; Thu, 24 Mar 2005 18:44:49 -0700 (MST) +Date: Thu, 24 Mar 2005 18:48:24 -0700 +From: Karim Nassar +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <2630.1111711927@sss.pgh.pa.us> +To: pgsql-performance@postgresql.org +Message-id: <1111715304.9089.179.camel@k2.cet.nau.edu> +MIME-version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-type: text/plain +Content-transfer-encoding: 7BIT +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/529 +X-Sequence-Number: 11234 + + +On Thu, 2005-03-24 at 19:52 -0500, Tom Lane wrote: +> Karim Nassar writes: +> > Here is the statement: +> +> > orfs=# explain analyze DELETE FROM int_sensor_meas_type WHERE +> > id_meas_type IN (SELECT * FROM meas_type_ids); +> > QUERY PLAN +> > +----------------------------------------------------------------------------------------------------------------------------- +> > Hash Join (cost=11.53..42.06 rows=200 width=6) (actual +> > time=1.564..2.840 rows=552 loops=1) +> > ... +> > Total runtime: 2499616.216 ms +> > (7 rows) +> +> Notice that the actual join is taking 2.8 ms. The other ~40 minutes +is +> in operations that we cannot see in this plan, but we can surmise are +ON +> DELETE triggers. + +There are no DELETE triggers (that I have created). + +> > Where do I go from here? +> +> Look at what your triggers are doing. My private bet is that you have +> unindexed foreign keys referencing this table, and so each deletion +> forces a seqscan of some other, evidently very large, table(s). + +Almost. I have a large table (6.3 million rows) with a foreign key +reference to this one (which has 749 rows), however it is indexed. + +I deleted the fk, ran the delete, then recreated the foreign key in +about 15 seconds. Thanks! + +Problem now is: this referencing table I expect to grow to about 110 +million rows in the next 2 months, then by 4 million rows per month +thereafter. I expect that the time for recreating the foreign key will +grow linearly with size. + +Is this just the kind of thing I need to watch out for? Any other +suggestions for dealing with tables of this size? What can I do to my +indexes to make them mo' betta? + +-- +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=- Mobile: (928) 699-9221 + + + + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 01:48:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A35852A37 + for ; + Fri, 25 Mar 2005 01:48:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40886-04 + for ; + Fri, 25 Mar 2005 01:48:41 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D66552A3D + for ; + Fri, 25 Mar 2005 01:48:40 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2P1mcmC003751; + Thu, 24 Mar 2005 20:48:38 -0500 (EST) +To: Karim Nassar +Cc: pgsql-performance@postgreSQL.org +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <1111715131.9085.174.camel@k2.cet.nau.edu> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> +Comments: In-reply-to Karim Nassar + message dated "Thu, 24 Mar 2005 18:45:31 -0700" +Date: Thu, 24 Mar 2005 20:48:38 -0500 +Message-ID: <3750.1111715318@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/530 +X-Sequence-Number: 11235 + +Karim Nassar writes: +>> Look at what your triggers are doing. My private bet is that you have +>> unindexed foreign keys referencing this table, and so each deletion +>> forces a seqscan of some other, evidently very large, table(s). + +> Almost. I have a large table (6.3 million rows) with a foreign key +> reference to this one (which has 749 rows), however it is indexed. + +In that case there's a datatype mismatch between the referencing and +referenced columns, which prevents the index from being used for the +FK check. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 25 02:35:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A0E645371F + for ; + Fri, 25 Mar 2005 02:33:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48153-09 + for ; + Fri, 25 Mar 2005 02:32:54 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C5A835371D + for ; + Fri, 25 Mar 2005 02:32:52 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2P2WuYR004010; + Thu, 24 Mar 2005 21:32:56 -0500 (EST) +To: Mark Lewis +Cc: pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <1111713798.23412.3.camel@amateljan.mirlogic.com> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111713798.23412.3.camel@amateljan.mirlogic.com> +Comments: In-reply-to Mark Lewis + message dated "Thu, 24 Mar 2005 17:23:19 -0800" +Date: Thu, 24 Mar 2005 21:32:56 -0500 +Message-ID: <4009.1111717976@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/531 +X-Sequence-Number: 11236 + +Mark Lewis writes: +> I've got a similar problem with deletes taking a very long time. I know +> that there are lots of foreign keys referencing this table, and other +> foreign keys referencing those tables, etc. I've been curious, is there +> a way to find out how long the foreign key checks take for each +> dependent table? + +There is not any easy way at the moment. + +Hmm ... I wonder how hard it would be to teach EXPLAIN ANALYZE to show +the runtime expended in each trigger when the statement is of a kind +that has triggers. We couldn't break down the time *within* the +triggers, but even this info would help a lot in terms of finger +pointing ... + + Seq Scan on ... (nn.nnn ms) + Trigger foo: nn.mmm ms + Trigger bar: nn.mmm ms + Total time: nn.mmm ms + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 27 16:23:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6242E53483 + for ; + Fri, 25 Mar 2005 02:55:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53512-07 + for ; + Fri, 25 Mar 2005 02:55:04 +0000 (GMT) +Received: from mailgate2.nau.edu (mailgate2.nau.edu [134.114.96.59]) + by svr1.postgresql.org (Postfix) with ESMTP id 1BA055371D + for ; + Fri, 25 Mar 2005 02:55:03 +0000 (GMT) +Received: from CONVERSION-DAEMON.mailgate2.nau.edu by mailgate2.nau.edu + (PMDF V6.2-X17 #30770) id <0IDW0010103VSV@mailgate2.nau.edu> for + pgsql-performance@postgresql.org; Thu, 24 Mar 2005 19:55:07 -0700 (MST) +Received: from k2.cet.nau.edu (net9-213.cet.nau.edu [134.114.9.213]) + by mailgate2.nau.edu (PMDF V6.2-X17 #30770) + with ESMTP id <0IDW00HA803U8C@mailgate2.nau.edu>; Thu, + 24 Mar 2005 19:55:06 -0700 (MST) +Date: Thu, 24 Mar 2005 19:58:40 -0700 +From: Karim Nassar +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <3750.1111715318@sss.pgh.pa.us> +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Message-id: <1111719520.9085.190.camel@k2.cet.nau.edu> +MIME-version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-type: text/plain +Content-transfer-encoding: 7BIT +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/593 +X-Sequence-Number: 11298 + +On Thu, 2005-03-24 at 20:48 -0500, Tom Lane wrote: +> In that case there's a datatype mismatch between the referencing and +> referenced columns, which prevents the index from being used for the +> FK check. + +Can I have more words on this? Here is how I created the tables: + +CREATE TABLE int_sensor_meas_type( + id_int_sensor_meas_type SERIAL PRIMARY KEY, + id_sensor integer NOT NULL REFERENCES sensor, + id_meas_type integer NOT NULL REFERENCES meas_type UNIQUE); + + +CREATE TABLE measurement ( + id_measurement SERIAL PRIMARY KEY, + id_int_sensor_meas_type integer NOT NULL REFERENCES int_sensor_meas_type, + datetime timestamp WITH TIME ZONE NOT NULL, + value numeric(15,5) NOT NULL, + created timestamp with time zone NOT NULL DEFAULT now(), + created_by TEXT NOT NULL REFERENCES public.person(id_person)); + +CREATE INDEX measurement__id_int_sensor_meas_type_idx ON measurement(id_int_sensor_meas_type); + +Do I need to cast the id_int_sensor_meas_type column when creating the +index? Both referrer and referenced look like INTEGER to me... + +http://www.postgresql.org/docs/8.0/interactive/datatype.html#DATATYPE-SERIAL +says: "The type names serial and serial4 are equivalent: both create +integer columns" + +TIA, + +-- +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=- Mobile: (928) 699-9221 + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 03:37:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 78460537B7 + for ; + Fri, 25 Mar 2005 03:37:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66791-08 + for ; + Fri, 25 Mar 2005 03:37:10 +0000 (GMT) +Received: from vscan02.westnet.com.au (vscan02.westnet.com.au [203.10.1.132]) + by svr1.postgresql.org (Postfix) with ESMTP id AA8A4537B1 + for ; + Fri, 25 Mar 2005 03:37:06 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by localhost (Postfix) with ESMTP id 7A30511C69D; + Fri, 25 Mar 2005 11:36:26 +0800 (WST) +Received: from vscan02.westnet.com.au ([127.0.0.1]) + by localhost (vscan02.westnet.com.au [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 25536-12; Fri, 25 Mar 2005 11:36:26 +0800 (WST) +Received: from [202.72.133.22] (dsl-202-72-133-22.wa.westnet.com.au + [202.72.133.22]) + by vscan02.westnet.com.au (Postfix) with ESMTP id C79DE11C6AF; + Fri, 25 Mar 2005 11:36:25 +0800 (WST) +Message-ID: <42438763.1090101@familyhealth.com.au> +Date: Fri, 25 Mar 2005 11:37:07 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Mark Lewis +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111713798.23412.3.camel@amateljan.mirlogic.com> +In-Reply-To: <1111713798.23412.3.camel@amateljan.mirlogic.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/532 +X-Sequence-Number: 11237 + +Watch your pg_stats_* views before and after the delete and check what +related tables have had lots of seqscans. + +Chris + +Mark Lewis wrote: +> Tom, +> +> I've got a similar problem with deletes taking a very long time. I know +> that there are lots of foreign keys referencing this table, and other +> foreign keys referencing those tables, etc. I've been curious, is there +> a way to find out how long the foreign key checks take for each +> dependent table? +> +> -- Mark Lewis +> +> On Thu, 2005-03-24 at 16:52, Tom Lane wrote: +> +>>Karim Nassar writes: +>> +>>>Here is the statement: +>> +>>>orfs=# explain analyze DELETE FROM int_sensor_meas_type WHERE +>>>id_meas_type IN (SELECT * FROM meas_type_ids); +>>> QUERY PLAN +>>>----------------------------------------------------------------------------------------------------------------------------- +>>> Hash Join (cost=11.53..42.06 rows=200 width=6) (actual +>>>time=1.564..2.840 rows=552 loops=1) +>>>... +>>> Total runtime: 2499616.216 ms +>>>(7 rows) +>> +>>Notice that the actual join is taking 2.8 ms. The other ~40 minutes is +>>in operations that we cannot see in this plan, but we can surmise are ON +>>DELETE triggers. +>> +>> +>>>Where do I go from here? +>> +>>Look at what your triggers are doing. My private bet is that you have +>>unindexed foreign keys referencing this table, and so each deletion +>>forces a seqscan of some other, evidently very large, table(s). +>> +>> regards, tom lane +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 7: don't forget to increase your free space map settings +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: the planner will ignore your desire to choose an index scan if your +> joining column's datatypes do not match + +From pgsql-performance-owner@postgresql.org Fri Mar 25 03:38:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 86105537B2 + for ; + Fri, 25 Mar 2005 03:38:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68377-06 + for ; + Fri, 25 Mar 2005 03:38:02 +0000 (GMT) +Received: from vscan01.westnet.com.au (vscan01.westnet.com.au [203.10.1.131]) + by svr1.postgresql.org (Postfix) with ESMTP id BDF1D537AD + for ; + Fri, 25 Mar 2005 03:38:00 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by localhost (Postfix) with ESMTP id 35E1E14E212; + Fri, 25 Mar 2005 11:37:23 +0800 (WST) +Received: from vscan01.westnet.com.au ([127.0.0.1]) + by localhost (vscan01.westnet.com.au [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 15212-15; Fri, 25 Mar 2005 11:37:23 +0800 (WST) +Received: from [202.72.133.22] (dsl-202-72-133-22.wa.westnet.com.au + [202.72.133.22]) + by vscan01.westnet.com.au (Postfix) with ESMTP id CCE8E14E09C; + Fri, 25 Mar 2005 11:37:22 +0800 (WST) +Message-ID: <4243879B.10200@familyhealth.com.au> +Date: Fri, 25 Mar 2005 11:38:03 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Karim Nassar , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> +In-Reply-To: <3750.1111715318@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/533 +X-Sequence-Number: 11238 + +> In that case there's a datatype mismatch between the referencing and +> referenced columns, which prevents the index from being used for the +> FK check. + +Is creating such a foreign key a WARNING yet? + +Chris + +From pgsql-performance-owner@postgresql.org Fri Mar 25 03:38:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37A5C537B4 + for ; + Fri, 25 Mar 2005 03:38:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69303-02 + for ; + Fri, 25 Mar 2005 03:38:34 +0000 (GMT) +Received: from vscan02.westnet.com.au (vscan02.westnet.com.au [203.10.1.132]) + by svr1.postgresql.org (Postfix) with ESMTP id D0BFB537AE + for ; + Fri, 25 Mar 2005 03:38:33 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by localhost (Postfix) with ESMTP id 6EE0611C6B2; + Fri, 25 Mar 2005 11:37:55 +0800 (WST) +Received: from vscan02.westnet.com.au ([127.0.0.1]) + by localhost (vscan02.westnet.com.au [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 25726-11; Fri, 25 Mar 2005 11:37:55 +0800 (WST) +Received: from [202.72.133.22] (dsl-202-72-133-22.wa.westnet.com.au + [202.72.133.22]) + by vscan02.westnet.com.au (Postfix) with ESMTP id EE90411C674; + Fri, 25 Mar 2005 11:37:54 +0800 (WST) +Message-ID: <424387BD.3070909@familyhealth.com.au> +Date: Fri, 25 Mar 2005 11:38:37 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Mark Lewis , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111713798.23412.3.camel@amateljan.mirlogic.com> + <4009.1111717976@sss.pgh.pa.us> +In-Reply-To: <4009.1111717976@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/534 +X-Sequence-Number: 11239 + +> Hmm ... I wonder how hard it would be to teach EXPLAIN ANALYZE to show +> the runtime expended in each trigger when the statement is of a kind +> that has triggers. We couldn't break down the time *within* the +> triggers, but even this info would help a lot in terms of finger +> pointing ... +> +> Seq Scan on ... (nn.nnn ms) +> Trigger foo: nn.mmm ms +> Trigger bar: nn.mmm ms +> Total time: nn.mmm ms + +That would be really cool... + +From pgsql-performance-owner@postgresql.org Fri Mar 25 03:56:46 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 88D06537AF + for ; + Fri, 25 Mar 2005 03:56:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07962-02 + for ; + Fri, 25 Mar 2005 03:56:34 +0000 (GMT) +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by svr1.postgresql.org (Postfix) with ESMTP id CA7965379F + for ; + Fri, 25 Mar 2005 03:56:30 +0000 (GMT) +Received: from [192.168.1.4] (pcp04418836pcs.nrockv01.md.comcast.net + [69.140.110.248]) + by yertle.kcilink.com (Postfix) with ESMTP id B96FCB80A + for ; + Thu, 24 Mar 2005 22:56:34 -0500 (EST) +Mime-Version: 1.0 (Apple Message framework v619.2) +In-Reply-To: <4243879B.10200@familyhealth.com.au> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> + <4243879B.10200@familyhealth.com.au> +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: Delete query takes exorbitant amount of time +Date: Thu, 24 Mar 2005 22:56:34 -0500 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.619.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/535 +X-Sequence-Number: 11240 + + +On Mar 24, 2005, at 10:38 PM, Christopher Kings-Lynne wrote: + +>> In that case there's a datatype mismatch between the referencing and +>> referenced columns, which prevents the index from being used for the +>> FK check. +> +> Is creating such a foreign key a WARNING yet? +> + +I recall getting such a warning when importing my schema from a 7.4 to +8.0 server. I had one table with char and the other with varchar. + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 05:25:36 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B97DE537D6 + for ; + Fri, 25 Mar 2005 05:25:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46445-06 + for ; + Fri, 25 Mar 2005 05:25:04 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id E2631537DF + for ; + Fri, 25 Mar 2005 05:25:03 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7165492; Thu, 24 Mar 2005 21:26:53 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Karim Nassar +Subject: Re: Delete query takes exorbitant amount of time +Date: Thu, 24 Mar 2005 21:24:39 -0800 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715304.9089.179.camel@k2.cet.nau.edu> +In-Reply-To: <1111715304.9089.179.camel@k2.cet.nau.edu> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200503242124.39558.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/536 +X-Sequence-Number: 11241 + +Karim, + +> Problem now is: this referencing table I expect to grow to about 110 +> million rows in the next 2 months, then by 4 million rows per month +> thereafter. I expect that the time for recreating the foreign key will +> grow linearly with size. +> +> Is this just the kind of thing I need to watch out for? Any other +> suggestions for dealing with tables of this size? What can I do to my +> indexes to make them mo' betta? + +How about getting some decent disk support? A single 10K SCSI disk is a bit +sub-par for a database with 100's of millions of records. Too bad you didn't +get a v40z ... + +Beyond that, you'll want to do the same thing whenever you purge the +referencing table; drop keys, delete, re-create keys. Or think about why it +is you need to delete batches of records from this FKed table at all. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sun Mar 27 16:26:15 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5949C53522 + for ; + Fri, 25 Mar 2005 05:32:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50567-02 + for ; + Fri, 25 Mar 2005 05:32:23 +0000 (GMT) +Received: from mailgate3.nau.edu (mailgate3.nau.edu [134.114.96.145]) + by svr1.postgresql.org (Postfix) with ESMTP id 97F9753475 + for ; + Fri, 25 Mar 2005 05:32:22 +0000 (GMT) +Received: from CONVERSION-DAEMON.mailgate3.nau.edu by mailgate3.nau.edu + (PMDF V6.2-X17 #30845) id <0IDW00I017DXN7@mailgate3.nau.edu> for + pgsql-performance@postgresql.org; Thu, 24 Mar 2005 22:32:22 -0700 (MST) +Received: from k2.cet.nau.edu (net9-213.cet.nau.edu [134.114.9.213]) + by mailgate3.nau.edu (PMDF V6.2-X17 #30845) + with ESMTP id <0IDW0046R7DXGA@mailgate3.nau.edu>; Thu, + 24 Mar 2005 22:32:21 -0700 (MST) +Date: Thu, 24 Mar 2005 22:35:55 -0700 +From: Karim Nassar +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <200503242124.39558.josh@agliodbs.com> +To: Josh Berkus +Cc: pgsql-performance@postgresql.org +Message-id: <1111728955.9085.238.camel@k2.cet.nau.edu> +MIME-version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-type: text/plain +Content-transfer-encoding: 7BIT +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715304.9089.179.camel@k2.cet.nau.edu> + <200503242124.39558.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/595 +X-Sequence-Number: 11300 + +On Thu, 2005-03-24 at 21:24 -0800, Josh Berkus wrote: +> Karim, +> How about getting some decent disk support? A single 10K SCSI disk is a bit +> sub-par for a database with 100's of millions of records. Too bad you didn't +> get a v40z ... + +Hehe. I have one I am setting up that will be dedicated to postgresql, +hence my question about a week ago about disk partitioning/striping :-) + + +> Beyond that, you'll want to do the same thing whenever you purge the +> referencing table; drop keys, delete, re-create keys. Or think about why it +> is you need to delete batches of records from this FKed table at all. + +The database is for weather data from multiple sources. When adding a +new dataset, I have to create/test/delete/recreate the config in the +FKed table. Users don't have this power, but I need it. +Drop/delete/recreate is a totally acceptable solution for this scenario. + +I guess I was wondering if there is other general tuning advice for such +large table indexes such as increasing statistics, etc. + +Thanks, +-- +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=- Mobile: (928) 699-9221 + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 05:38:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E92E53522 + for ; + Fri, 25 Mar 2005 05:38:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51023-06 + for ; + Fri, 25 Mar 2005 05:38:45 +0000 (GMT) +Received: from ra.sai.msu.su (ra.sai.msu.su [158.250.29.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C5629537D8 + for ; + Fri, 25 Mar 2005 05:38:44 +0000 (GMT) +Received: from ra (ra [158.250.29.2]) + by ra.sai.msu.su (8.12.10/8.12.10) with ESMTP id j2P5cY5Q007029; + Fri, 25 Mar 2005 08:38:34 +0300 (MSK) +Date: Fri, 25 Mar 2005 08:38:33 +0300 (MSK) +From: Oleg Bartunov +X-X-Sender: megera@ra.sai.msu.su +To: Tom Lane +Cc: Mark Lewis , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-Reply-To: <4009.1111717976@sss.pgh.pa.us> +Message-ID: +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111713798.23412.3.camel@amateljan.mirlogic.com> + <4009.1111717976@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.34 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/537 +X-Sequence-Number: 11242 + +On Thu, 24 Mar 2005, Tom Lane wrote: + +> Mark Lewis writes: +>> I've got a similar problem with deletes taking a very long time. I know +>> that there are lots of foreign keys referencing this table, and other +>> foreign keys referencing those tables, etc. I've been curious, is there +>> a way to find out how long the foreign key checks take for each +>> dependent table? +> +> There is not any easy way at the moment. +> +> Hmm ... I wonder how hard it would be to teach EXPLAIN ANALYZE to show +> the runtime expended in each trigger when the statement is of a kind +> that has triggers. We couldn't break down the time *within* the +> triggers, but even this info would help a lot in terms of finger +> pointing ... +> +> Seq Scan on ... (nn.nnn ms) +> Trigger foo: nn.mmm ms +> Trigger bar: nn.mmm ms +> Total time: nn.mmm ms + +and if you add + + Index foo_idx: nn.mm ss + Heap foo_tbl: nn.mm ss + + +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> + + Regards, + Oleg +_____________________________________________________________ +Oleg Bartunov, sci.researcher, hostmaster of AstroNet, +Sternberg Astronomical Institute, Moscow University (Russia) +Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/ +phone: +007(095)939-16-83, +007(095)939-23-83 + +From pgsql-performance-owner@postgresql.org Fri Mar 25 06:15:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CEB1A53617 + for ; + Fri, 25 Mar 2005 06:15:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60035-05 + for ; + Fri, 25 Mar 2005 06:15:29 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 56A2E53613 + for ; + Fri, 25 Mar 2005 06:15:28 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2P6FHtx020492; + Fri, 25 Mar 2005 01:15:17 -0500 (EST) +To: Christopher Kings-Lynne +Cc: Mark Lewis , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <4243A2B8.6020903@familyhealth.com.au> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111713798.23412.3.camel@amateljan.mirlogic.com> + <4009.1111717976@sss.pgh.pa.us> + <4243A2B8.6020903@familyhealth.com.au> +Comments: In-reply-to Christopher Kings-Lynne + message dated "Fri, 25 Mar 2005 13:33:44 +0800" +Date: Fri, 25 Mar 2005 01:15:17 -0500 +Message-ID: <20491.1111731317@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/538 +X-Sequence-Number: 11243 + +Christopher Kings-Lynne writes: +>> Hmm ... I wonder how hard it would be to teach EXPLAIN ANALYZE to show +>> the runtime expended in each trigger when the statement is of a kind +>> that has triggers. + +> Could SPI "know" that an explain analyze is being run and add their +> output and timings to the output? + +If it did, we'd be double-counting the time. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 25 06:58:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 748D35362C + for ; + Fri, 25 Mar 2005 06:58:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70082-06 + for ; + Fri, 25 Mar 2005 06:58:27 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C92153629 + for ; + Fri, 25 Mar 2005 06:58:26 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2P6wKjA020846; + Fri, 25 Mar 2005 01:58:20 -0500 (EST) +To: Christopher Kings-Lynne +Cc: Karim Nassar , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <4243879B.10200@familyhealth.com.au> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> + <4243879B.10200@familyhealth.com.au> +Comments: In-reply-to Christopher Kings-Lynne + message dated "Fri, 25 Mar 2005 11:38:03 +0800" +Date: Fri, 25 Mar 2005 01:58:20 -0500 +Message-ID: <20845.1111733900@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/539 +X-Sequence-Number: 11244 + +Christopher Kings-Lynne writes: +>> In that case there's a datatype mismatch between the referencing and +>> referenced columns, which prevents the index from being used for the +>> FK check. + +> Is creating such a foreign key a WARNING yet? + +I believe so as of 8.0. It's a bit tricky since 8.0 does allow some +cross-type cases to be indexed, but IIRC we have a test that understands +about that... + + regards, tom lane + +From pgsql-bugs-owner@postgresql.org Fri Mar 25 10:19:53 2005 +X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BBFF35366D; + Fri, 25 Mar 2005 10:19:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24949-07; Fri, 25 Mar 2005 10:19:49 +0000 (GMT) +Received: from cmailg3.svr.pol.co.uk (cmailg3.svr.pol.co.uk [195.92.195.173]) + by svr1.postgresql.org (Postfix) with ESMTP id 78A7C53634; + Fri, 25 Mar 2005 10:19:48 +0000 (GMT) +Received: from modem-983.lynx.dialup.pol.co.uk ([217.135.195.215] + helo=192.168.0.102) by cmailg3.svr.pol.co.uk with esmtp (Exim 4.41) + id 1DEluu-00056N-3U; Fri, 25 Mar 2005 10:19:49 +0000 +Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 +From: Simon Riggs +To: Keith Browne +Cc: pgsql-bugs@postgresql.org, Brian O'Reilly , + pgsql-performance@postgresql.org +In-Reply-To: <4241C1DF.2020000@deepsky.com> +References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> + <1111567230.11750.596.camel@localhost.localdomain> + <4241C1DF.2020000@deepsky.com> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Fri, 25 Mar 2005 10:18:37 +0000 +Message-Id: <1111745917.11750.713.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/265 +X-Sequence-Number: 11385 + +On Wed, 2005-03-23 at 14:22 -0500, Keith Browne wrote: +> Simon Riggs wrote: +> +> > The EXPLAINs you've enclosed are for SELECTs, yet your bug report +> > describes INSERTs as being the things that are slow. +> > [You may find better performance from using COPY] + +> We're starting with an empty database, creating four tables, and +> populating those tables with a total of 180,000-200,000 rows. Each +> table has a primary key, and several of the tables reference foreign +> keys in other tables. We've written a Python script, using psycopg, +> which executes all the queries to create the tables and insert the rows. +> The database is running on the same machine where the script runs. +> +> I've seen similar performance when issuing a COMMIT after each +> insertion, and also after batching insertions in blocks of 250 per +> COMMIT, so batching the commits is not helping much. I've looked at the +> possibility of using COPY, but in our production environment it will be +> prohibitive to build a flat file with all this data. I'd rather +> generate it on the fly, as we've been able to do with PostgreSQL 7.4. +> +> > Also, your tests have compared two systems, so it might be that the +> > hardware or configuration of one system is different from the other. +> +> When running with PostgreSQL 7.4 on a dual-CPU Athlon MP2400+ machine +> with a gigabyte of RAM, running Debian Linux version 2.6.8.1, we were +> able to insert all this data in 5-7 minutes. It's taken a while to +> install Postgres 8.0.1 on the same machine, but now I have, and it's +> taking 40-45 minutes to run the same insert script. This is similar to +> the performance we saw on another machine, a fast single-CPU AMD64 box +> running Gentoo. +> +> I don't think it's a hardware issue. I dug around a bit, and found +> suggestions that this sort of problem could be worked around by breaking +> the database connection and restarting it after the tables had been +> partially filled. I modified our script to break and re-establish the +> database connection when each table first has 4,000 records inserted, +> and the performance is greatly improved; it now takes only about 3.5 +> minutes to insert 180,000+ rows. +> +> I've since modified this script to build and populate a fifth table with +> over 1.3 million rows. The fifth table has no primary key, but lists a +> foreign key into one of the first four tables. With the above +> modification (break and re-build the DB connection after 4,000 rows have +> been inserted), the whole database can be populated in about 15 minutes. +> I wouldn't have dared try to build a one-million-plus-row table until +> I found this speed-up. +> +> > If you could repeat the test on one single system, then this would +> > assist in the diagnosis of this bug report. Also, if you could describe +> > the workload that is giving you a problem more exactly, that would help. +> > Specifically, can you confirm that you have run ANALYZE on the tables, +> > and also give us some idea of numbers of rows in each table at the time +> > you first run your programs. +> +> Just to see if it would help, I tried modifying the script to run an +> ANALYZE against each table after 4,000 insertions, instead of breaking +> and re-establishing the DB connection. I still saw ~45-minute times to +> insert 180,000 rows. I then tried running ANALYZE against each table +> after *each* 4,000 rows inserted, and again, it took about 45 minutes to +> run the insert. +> +> Each table is empty when I first run the program. I am dropping and +> re-creating the database for each test run. +> +> > There is clearly a problem, but it is not yet clearly a bug. If it is a +> > bug, we're interested in solving it as much as you. +> +> I'd be happy to run further tests or provide more details, if they'll +> help. We now have a workaround which is allowing us to proceed with our +> project, but I'd like to know if there's another way to do this. While +> I understand that large or complex databases require careful tuning, I +> was surprised to see a six- or seven-fold increase in run times between +> PostgreSQL 7.4 and 8.0.1 on the same hardware, on an operation which +> seems fairly straightforward: populating an empty table. +> +> One other thing which puzzled me: as a test, I tried modifying our +> script to spit out raw SQL statements instead of connecting to the +> database and performing the inserts itself. Normally, our script +> populates two tables in one pass, and then populates the third and +> fourth tables in a second pass. I massaged the SQL by hand to group the +> inserts together by table, so that the first table would be entirely +> populated, then the second, etc. When I ran this SQL script by piping +> it straight into psql, it finished in about four minutes. This is +> comparable to the time it takes to run my modified script which breaks +> and re-establishes the connection to the database. + +OK. Not-a-bug. + +Your situation is covered in the manual with some sage advice +http://www.postgresql.org/docs/8.0/static/populate.html +It doesn't go into great lengths about all the reasons why those +recommendations are good ones - but they are clear. + +There isn't anything in there (yet) that says, "turn off Referential +Integrity too" and perhaps it should... + +The tables you are loading all refer to one another with referential +constraints? Possibly a master-detail relationship, or two major +entities joined via an associative one. The plan is bad because your FKs +point to what are initially empty tables. The best thing to do would be +to add the RI constraints after the tables are loaded, rather than +adding them before. + +Your program is issuing a Prepare statement, then followed by thousands +of Execute statements. This reduces much of the overhead of +optimization, since the plan is cached early in that sequence of +executes. The plan thus remains the same all the way through, though as +you observe, that isn't optimal. The initial plan saw an empty table, +though it didn't stay empty long. Breaking the connection and +reattaching forces the plan to be reevaluated; when this is performed +after the point at which a more optimal plan will be generated, your +further inserts use the better plan and work continues as fast as +before. + +psql doesn't suffer from this problem because it doesn't use Prepared +statements. That means you pay the cost of compiling each SQL statement +at execution time, though gain the benefit of an immediate plan change +at the optimal moment. + +I think we should spawn a TODO item from this: + +* Coerce FK lookups to always use an available index + +but that in itself isn't a certain fix and might cause other +difficulties elsewhere. + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Sun Mar 27 16:25:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AFA435366D + for ; + Fri, 25 Mar 2005 10:47:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31219-05 + for ; + Fri, 25 Mar 2005 10:47:03 +0000 (GMT) +Received: from mailgate3.nau.edu (mailgate3.nau.edu [134.114.96.145]) + by svr1.postgresql.org (Postfix) with ESMTP id 292475365D + for ; + Fri, 25 Mar 2005 10:47:02 +0000 (GMT) +Received: from CONVERSION-DAEMON.mailgate3.nau.edu by mailgate3.nau.edu + (PMDF V6.2-X17 #30845) id <0IDW00001LYGQS@mailgate3.nau.edu> for + pgsql-performance@postgresql.org; Fri, 25 Mar 2005 03:47:05 -0700 (MST) +Received: from k2.cet.nau.edu (net9-213.cet.nau.edu [134.114.9.213]) + by mailgate3.nau.edu (PMDF V6.2-X17 #30845) + with ESMTP id <0IDW0000OLYGKE@mailgate3.nau.edu>; Fri, + 25 Mar 2005 03:47:04 -0700 (MST) +Date: Fri, 25 Mar 2005 03:50:36 -0700 +From: Karim Nassar +Subject: Re: [BUGS] BUG #1552: massive performance hit between 7.4 +In-reply-to: <1111745917.11750.713.camel@localhost.localdomain> +To: Simon Riggs +Cc: Keith Browne , + Brian O'Reilly , pgsql-performance@postgresql.org +Message-id: <1111747837.898.19.camel@k2.cet.nau.edu> +MIME-version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-type: text/plain +Content-transfer-encoding: 7BIT +References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> + <1111567230.11750.596.camel@localhost.localdomain> + <4241C1DF.2020000@deepsky.com> + <1111745917.11750.713.camel@localhost.localdomain> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/594 +X-Sequence-Number: 11299 + +On Fri, 2005-03-25 at 10:18 +0000, Simon Riggs wrote: +> > When running with PostgreSQL 7.4 on a dual-CPU Athlon MP2400+ machine +> > with a gigabyte of RAM, running Debian Linux version 2.6.8.1, we were +> > able to insert all this data in 5-7 minutes. It's taken a while to +> > install Postgres 8.0.1 on the same machine, but now I have, and it's +> > taking 40-45 minutes to run the same insert script. + + + +> OK. Not-a-bug. +> +> Your situation is covered in the manual with some sage advice +> http://www.postgresql.org/docs/8.0/static/populate.html +> It doesn't go into great lengths about all the reasons why those +> recommendations are good ones - but they are clear. + + +Simon, this begs the question: what changed from 7.4->8.0 to require he +modify his script? + + +TIA, +-- +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=- Mobile: (928) 699-9221 + + +From pgsql-bugs-owner@postgresql.org Fri Mar 25 14:41:12 2005 +X-Original-To: pgsql-bugs-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AEF8D53632; + Fri, 25 Mar 2005 14:41:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89876-02; Fri, 25 Mar 2005 14:41:08 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 8366B533AA; + Fri, 25 Mar 2005 14:41:07 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2PEf9PD023229; + Fri, 25 Mar 2005 09:41:09 -0500 (EST) +To: Simon Riggs +Cc: Keith Browne , pgsql-bugs@postgresql.org, + "Brian O'Reilly" , pgsql-performance@postgresql.org +Subject: Re: BUG #1552: massive performance hit between 7.4 and 8.0.1 +In-reply-to: <1111745917.11750.713.camel@localhost.localdomain> +References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> + <1111567230.11750.596.camel@localhost.localdomain> + <4241C1DF.2020000@deepsky.com> + <1111745917.11750.713.camel@localhost.localdomain> +Comments: In-reply-to Simon Riggs + message dated "Fri, 25 Mar 2005 10:18:37 +0000" +Date: Fri, 25 Mar 2005 09:41:09 -0500 +Message-ID: <23228.1111761669@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/266 +X-Sequence-Number: 11386 + +Simon Riggs writes: +> I think we should spawn a TODO item from this: +> * Coerce FK lookups to always use an available index + +No, we aren't doing that. + +The correct TODO item is "Replan cached plans when table size has +changed a lot" which of course depends on having a framework to do +replanning at all. I intend to take a look at that once Neil has +created such a framework ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 25 15:12:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 368D0537EC + for ; + Fri, 25 Mar 2005 15:12:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98647-01 + for ; + Fri, 25 Mar 2005 15:12:02 +0000 (GMT) +Received: from cmailg1.svr.pol.co.uk (cmailg1.svr.pol.co.uk [195.92.195.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 979835369F + for ; + Fri, 25 Mar 2005 15:12:01 +0000 (GMT) +Received: from modem-1391.llama.dialup.pol.co.uk ([217.135.181.111] + helo=192.168.0.102) by cmailg1.svr.pol.co.uk with esmtp (Exim 4.14) + id 1DEqTf-0006Sg-U7; Fri, 25 Mar 2005 15:12:00 +0000 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Tom Lane , Karim Nassar +Cc: Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: <20845.1111733900@sss.pgh.pa.us> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> <4243879B.10200@familyhealth.com.au> + <20845.1111733900@sss.pgh.pa.us> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Fri, 25 Mar 2005 15:10:48 +0000 +Message-Id: <1111763448.11750.730.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/542 +X-Sequence-Number: 11247 + +On Fri, 2005-03-25 at 01:58 -0500, Tom Lane wrote: +> Christopher Kings-Lynne writes: +> >> In that case there's a datatype mismatch between the referencing and +> >> referenced columns, which prevents the index from being used for the +> >> FK check. +> +> > Is creating such a foreign key a WARNING yet? +> +> I believe so as of 8.0. It's a bit tricky since 8.0 does allow some +> cross-type cases to be indexed, but IIRC we have a test that understands +> about that... + +src/backend/commands/tablecmds.c, line 3966 in CVSTIP +/* + * Check that the found operator is compatible with the PK index, + * and generate a warning if not, since otherwise costly seqscans + * will be incurred to check FK validity. +*/ +if (!op_in_opclass(oprid(o), opclasses[i])) + ereport(WARNING, + (errmsg("foreign key constraint \"%s\" " + "will require costly sequential scans", + fkconstraint->constr_name), + errdetail("Key columns \"%s\" and \"%s\" " + "are of different types: %s and %s.", + strVal(list_nth(fkconstraint->fk_attrs, i)), + strVal(list_nth(fkconstraint->pk_attrs, i)), + format_type_be(fktypoid[i]), + format_type_be(pktypoid[i])))); + +So, yes to the WARNING. Not sure about the cross-type cases... + +Karim: Did this happen? If not, can you drop and re-create and confirm +that you get the WARNING? If not, we have problems. + +I vote to make this an ERROR in 8.1 - I see little benefit in allowing +this situation to continue. If users do create a FK like this, it just +becomes another performance problem on list... + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 15:12:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D24F553875 + for ; + Fri, 25 Mar 2005 15:12:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95341-09 + for ; + Fri, 25 Mar 2005 15:12:06 +0000 (GMT) +Received: from rgmail.regenstrief.org (rgmail.regenstrief.org [134.68.31.125]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A9C7537A4 + for ; + Fri, 25 Mar 2005 15:12:03 +0000 (GMT) +Received: from [172.31.0.53] ([172.31.0.53]) + by rgmail.regenstrief.org (8.12.8/8.12.8) with ESMTP id j2PFC5cX017753; + Fri, 25 Mar 2005 10:12:06 -0500 +Subject: Script for getting a table of reponse-time breakdown +From: Jack Xue +To: jxue@regenstrief.org +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Organization: +Message-Id: <1111763525.18036.15.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) +Date: 25 Mar 2005 10:12:05 -0500 +Content-Transfer-Encoding: 7bit +X-Antivirus: Scanned by Vexira Antivirus 1.0.5 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/543 +X-Sequence-Number: 11248 + +Hi, + +I am thinking about how to continuously monitor the performance of a +PostgreSQL 8 database. I am interested in two things: (1) the growth of +tables with TOAST and indexes; and (2) the respond time breakdown for a +query. + +In Chapters 23 and 24 of the big manual, I found enough materials to +teach me how to do the 1st job. But I have difficulty with the 2nd one. +I found some script for Oracle +(http://www.ixora.com.au/scripts/waits.htm). + +Do we have something that can do the same job for PostgreSQL 8? + +Thanks. + +-Jack + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 15:17:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E5ECE53777 + for ; + Fri, 25 Mar 2005 15:17:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00615-01 + for ; + Fri, 25 Mar 2005 15:17:23 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 774FD5377A + for ; + Fri, 25 Mar 2005 15:17:23 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2PFHHUG023516; + Fri, 25 Mar 2005 10:17:17 -0500 (EST) +To: Simon Riggs +Cc: Karim Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <1111763448.11750.730.camel@localhost.localdomain> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> + <4243879B.10200@familyhealth.com.au> + <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> +Comments: In-reply-to Simon Riggs + message dated "Fri, 25 Mar 2005 15:10:48 +0000" +Date: Fri, 25 Mar 2005 10:17:17 -0500 +Message-ID: <23515.1111763837@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/544 +X-Sequence-Number: 11249 + +Simon Riggs writes: +> I vote to make this an ERROR in 8.1 - I see little benefit in allowing +> this situation to continue. + +Other than spec compliance, you mean? SQL99 says + + ... The declared type of each referencing column shall be + comparable to the declared type of the corresponding referenced + column. + +It doesn't say that it has to be indexable, and most definitely not that +there has to be an index. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 25 15:39:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 95ED75377B + for ; + Fri, 25 Mar 2005 15:39:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07619-01 + for ; + Fri, 25 Mar 2005 15:39:34 +0000 (GMT) +Received: from cmailg3.svr.pol.co.uk (cmailg3.svr.pol.co.uk [195.92.195.173]) + by svr1.postgresql.org (Postfix) with ESMTP id 67B88536EC + for ; + Fri, 25 Mar 2005 15:39:33 +0000 (GMT) +Received: from modem-1391.llama.dialup.pol.co.uk ([217.135.181.111] + helo=192.168.0.102) by cmailg3.svr.pol.co.uk with esmtp (Exim 4.41) + id 1DEquO-0002Ts-Ey; Fri, 25 Mar 2005 15:39:36 +0000 +Subject: Re: [BUGS] BUG #1552: massive performance hit +From: Simon Riggs +To: Karim Nassar +Cc: Keith Browne , + Brian O'Reilly , pgsql-performance@postgresql.org +In-Reply-To: <1111747837.898.19.camel@k2.cet.nau.edu> +References: <20050318232102.08FA0F0E5D@svr2.postgresql.org> + <1111567230.11750.596.camel@localhost.localdomain> + <4241C1DF.2020000@deepsky.com> + <1111745917.11750.713.camel@localhost.localdomain> + <1111747837.898.19.camel@k2.cet.nau.edu> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Fri, 25 Mar 2005 15:38:25 +0000 +Message-Id: <1111765105.11750.749.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/545 +X-Sequence-Number: 11250 + +On Fri, 2005-03-25 at 03:50 -0700, Karim Nassar wrote: +> On Fri, 2005-03-25 at 10:18 +0000, Simon Riggs wrote: +> > > When running with PostgreSQL 7.4 on a dual-CPU Athlon MP2400+ machine +> > > with a gigabyte of RAM, running Debian Linux version 2.6.8.1, we were +> > > able to insert all this data in 5-7 minutes. It's taken a while to +> > > install Postgres 8.0.1 on the same machine, but now I have, and it's +> > > taking 40-45 minutes to run the same insert script. +> +> +> +> > OK. Not-a-bug. +> > +> > Your situation is covered in the manual with some sage advice +> > http://www.postgresql.org/docs/8.0/static/populate.html +> > It doesn't go into great lengths about all the reasons why those +> > recommendations are good ones - but they are clear. + +> Simon, this begs the question: what changed from 7.4->8.0 to require he +> modify his script? + +Good question. Clearly, some combination of stats-plus-index-selection +code changed but I suspect this is a case of more, not less accuracy, +affecting us here. + +The FK code literally generates SQL statements, then prepares them. +AFAICS it should be possible to add more code to +src/backend/utils/adt/ritrigger.c to force the prepare of FK code to +avoid seq scans by executing "SET enable_seqscan = off;" +I'll have a play.... + +But, the wider point raised by this is whether Prepare should be more +conservative in the plan it generates. When we Execute a single query, +it is perfectly OK to go for the "best" plan, since it is being executed +only this once and we can tell, right now, which one the "best" is. + +With a Prepared query, it is clearly going to be executed many times and +so we should consider that the optimal plan may change over time. + +Index access has more overhead for small tables, but increases by (I +think) only logN as the number of rows in a table, N, increases. +Sequential scan access varies by N. Thus, as N increases from zero, +first of all Seq Scan is the best plan - but only marginally better than +Index access, then this changes at some value of N, then after that +index access is the best plan. As N increases, Seq Scan access clearly +diverges badly from Indexed access. + +The conservative choice for unknown, or varying N would be index access, +rather than the best plan available when the query is prepared. + +I propose a more general TODO item: + +* Make Prepared queries always use indexed access, if it is available + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 16:02:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 40BBA5360E + for ; + Fri, 25 Mar 2005 16:02:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12773-05 + for ; + Fri, 25 Mar 2005 16:02:32 +0000 (GMT) +Received: from cmailg1.svr.pol.co.uk (cmailg1.svr.pol.co.uk [195.92.195.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 3DEEA53551 + for ; + Fri, 25 Mar 2005 16:02:31 +0000 (GMT) +Received: from modem-1391.llama.dialup.pol.co.uk ([217.135.181.111] + helo=192.168.0.102) by cmailg1.svr.pol.co.uk with esmtp (Exim 4.14) + id 1DErGX-00087K-Eb; Fri, 25 Mar 2005 16:02:29 +0000 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Tom Lane +Cc: Karim Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: <23515.1111763837@sss.pgh.pa.us> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> <4243879B.10200@familyhealth.com.au> + <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <23515.1111763837@sss.pgh.pa.us> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Fri, 25 Mar 2005 16:01:18 +0000 +Message-Id: <1111766478.11750.762.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/546 +X-Sequence-Number: 11251 + +On Fri, 2005-03-25 at 10:17 -0500, Tom Lane wrote: +> Simon Riggs writes: +> > I vote to make this an ERROR in 8.1 - I see little benefit in allowing +> > this situation to continue. +> +> Other than spec compliance, you mean? SQL99 says +> +> ... The declared type of each referencing column shall be +> comparable to the declared type of the corresponding referenced +> column. +> +> It doesn't say that it has to be indexable, and most definitely not that +> there has to be an index. + +specs at dawn, eh? + +Well, SQL:2003 Foundation, p.550 clause 3a) states that the the + in the referencing table must match a unique +constraint on the referenced table, or the PRIMARY KEY if the columns +are not specified. Either way, the referenced columns are a unique +constraint (which makes perfect sense from a logical data perspective). + +We implement unique constraints via an index, so for PostgreSQL the +clause implies that it must refer to an index. + +touche, Monsieur Lane and Happy Easter :-) + +But even without that, there is little benefit in allowing it... + +WARNING -> ERROR, please. + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Sat Mar 26 00:24:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 059A5536A4 + for ; + Sat, 26 Mar 2005 00:24:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17059-01 + for ; + Sat, 26 Mar 2005 00:24:13 +0000 (GMT) +Received: from mail.tecarta.com (66.238.115.135.ptr.us.xo.net + [66.238.115.135]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E34053691 + for ; + Sat, 26 Mar 2005 00:24:12 +0000 (GMT) +Received: from mail pickup service by mail.tecarta.com with Microsoft SMTPSVC; + Fri, 25 Mar 2005 16:27:10 -0800 +Received: from mail.tecarta.com ([192.168.160.2]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Fri, 25 Mar 2005 16:27:09 -0800 +Received: from barracuda.tecarta.com ([192.168.160.200]) + by mail.tecarta.com (SAVSMTP 3.1.0.29) with SMTP id + M2005032516270814647 + for ; + Fri, 25 Mar 2005 16:27:08 -0800 +X-ASG-Debug-ID: 1111796654-2762-3-0 +X-Barracuda-URL: http://192.168.160.200:8000/cgi-bin/mark.cgi +Received: from mail2 (mail2.hq.corp [192.168.160.6]) + by barracuda.tecarta.com (Spam Firewall) with SMTP id 281F42003DC6 + for ; + Fri, 25 Mar 2005 16:24:14 -0800 (PST) +Received: from [192.168.0.13] ([63.206.203.145]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Fri, 25 Mar 2005 16:27:04 -0800 +Message-ID: <42443863.4040302@sfnet.cc> +Date: Fri, 25 Mar 2005 16:12:19 +0000 +From: Steve Poe +User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: performance pgsql +X-ASG-Orig-Subj: How to improve db performance with $7K? +Subject: How to improve db performance with $7K? +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 26 Mar 2005 00:27:04.0504 (UTC) + FILETIME=[891D2380:01C5319A] +X-Virus-Scanned: by Barracuda Spam Firewall at tecarta.com +X-Barracuda-Spam-Score: 0.85 +X-Barracuda-Spam-Status: No, SCORE=0.85 using global scores of TAG_LEVEL=4.0 + QUARANTINE_LEVEL=1000.0 KILL_LEVEL=7.0 tests=DATE_IN_PAST_06_12 +X-Barracuda-Spam-Report: Code version 2.64, rules version 2.1.2137 + Rule breakdown below pts rule name description + ---- ---------------------- ------------------------------------------- + 0.85 DATE_IN_PAST_06_12 Date: is 6 to 12 hours before Received: date +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.267 tagged_above=0 required=5 tests=AWL, + DATE_IN_PAST_06_12, FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/575 +X-Sequence-Number: 11280 + +Situation: An 24/7 animal hospital (100 employees) runs their business +on Centos 3.3 (RHEL 3) Postgres 7.4.2 (because they have to) off a 2-CPU +Xeon 2.8MHz, 4GB of RAM, (3) SCSI disks RAID 0 (zcav value 35MB per +sec). The databse is 11GB comprised over 100 tables and indexes from 1MB +to 2GB in size. + +I recently told the hospital management team worst-case scenerio they +need to get the database on its own drive array since the RAID0 is a +disaster wating to happen. I said ideally a new dual AMD server with +6/7-disk configuration would be ideal for safety and performance, but +they don't have $15K. I said a seperate drive array offer the balance +of safety and performance. + +I have been given budget of $7K to accomplish a safer/faster database +through hardware upgrades. The objective is to get a drive array, but I +can use the budget any way I see fit to accomplish the goal. + +Since I am a dba novice, I did not physically build this server, nor did +I write the application the hospital runs on, but I have the opportunity +to make it better, I'd thought I should seek some advice from those who +have been down this road before. Suggestions/ideas anyone? + +Thanks. + +Steve Poe + +From pgsql-performance-owner@postgresql.org Fri Mar 25 16:23:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A971453783 + for ; + Fri, 25 Mar 2005 16:23:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18636-02 + for ; + Fri, 25 Mar 2005 16:23:22 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id B557A52955 + for ; + Fri, 25 Mar 2005 16:23:21 +0000 (GMT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 4F0F835622; Fri, 25 Mar 2005 08:23:19 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 4D53F3561E; Fri, 25 Mar 2005 08:23:19 -0800 (PST) +Date: Fri, 25 Mar 2005 08:23:19 -0800 (PST) +From: Stephan Szabo +To: Simon Riggs +Cc: Tom Lane , Karim Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-Reply-To: <1111766478.11750.762.camel@localhost.localdomain> +Message-ID: <20050325082101.G4358@megazone.bigpanda.com> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> + <4243879B.10200@familyhealth.com.au> <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <23515.1111763837@sss.pgh.pa.us> + <1111766478.11750.762.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/547 +X-Sequence-Number: 11252 + + +On Fri, 25 Mar 2005, Simon Riggs wrote: + +> On Fri, 2005-03-25 at 10:17 -0500, Tom Lane wrote: +> > Simon Riggs writes: +> > > I vote to make this an ERROR in 8.1 - I see little benefit in allowing +> > > this situation to continue. +> > +> > Other than spec compliance, you mean? SQL99 says +> > +> > ... The declared type of each referencing column shall be +> > comparable to the declared type of the corresponding referenced +> > column. +> > +> > It doesn't say that it has to be indexable, and most definitely not that +> > there has to be an index. +> +> specs at dawn, eh? +> +> Well, SQL:2003 Foundation, p.550 clause 3a) states that the the +> in the referencing table must match a unique +> constraint on the referenced table, or the PRIMARY KEY if the columns +> are not specified. Either way, the referenced columns are a unique +> constraint (which makes perfect sense from a logical data perspective). +> +> We implement unique constraints via an index, so for PostgreSQL the +> clause implies that it must refer to an index. + +IMHO, that reference is irrrelevant. Yes, there must be an index due to +our implementation, however that doesn't imply that the types must be the +same, nor even that the index must be usable for the cross table +comparison. + + +From pgsql-performance-owner@postgresql.org Sat Mar 26 01:32:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D9B552A48 + for ; + Sat, 26 Mar 2005 01:31:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30043-08 + for ; + Sat, 26 Mar 2005 01:31:49 +0000 (GMT) +Received: from mail.tecarta.com (66.238.115.135.ptr.us.xo.net + [66.238.115.135]) + by svr1.postgresql.org (Postfix) with ESMTP id 48598533E3 + for ; + Sat, 26 Mar 2005 01:31:48 +0000 (GMT) +Received: from mail pickup service by mail.tecarta.com with Microsoft SMTPSVC; + Fri, 25 Mar 2005 17:34:47 -0800 +Received: from mail.tecarta.com ([192.168.160.2]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Fri, 25 Mar 2005 17:34:43 -0800 +Received: from barracuda.tecarta.com ([192.168.160.200]) + by mail.tecarta.com (SAVSMTP 3.1.0.29) with SMTP id + M2005032517344314778 + for ; + Fri, 25 Mar 2005 17:34:43 -0800 +X-ASG-Debug-ID: 1111800708-6378-1-0 +X-Barracuda-URL: http://192.168.160.200:8000/cgi-bin/mark.cgi +Received: from mail2 (mail2.hq.corp [192.168.160.6]) + by barracuda.tecarta.com (Spam Firewall) with SMTP id 836672003DD6 + for ; + Fri, 25 Mar 2005 17:31:48 -0800 (PST) +Received: from [192.168.0.13] ([63.206.203.145]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Fri, 25 Mar 2005 17:34:40 -0800 +Message-ID: <4244483B.8020401@sfnet.cc> +Date: Fri, 25 Mar 2005 17:19:55 +0000 +From: Steve Poe +User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: performance pgsql +X-ASG-Orig-Subj: Re: [PERFORM] How to improve db performance with $7K? +Subject: Re: How to improve db performance with $7K? +References: <42443863.4040302@sfnet.cc> <20356.1111798757@sss.pgh.pa.us> +In-Reply-To: <20356.1111798757@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 26 Mar 2005 01:34:40.0583 (UTC) + FILETIME=[FAB9AD70:01C531A3] +X-Virus-Scanned: by Barracuda Spam Firewall at tecarta.com +X-Barracuda-Spam-Score: 0.84 +X-Barracuda-Spam-Status: No, SCORE=0.84 using global scores of TAG_LEVEL=4.0 + QUARANTINE_LEVEL=1000.0 KILL_LEVEL=7.0 tests=BAYES_44, + DATE_IN_PAST_06_12 +X-Barracuda-Spam-Report: Code version 2.64, rules version 2.1.2139 + Rule breakdown below pts rule name description + ---- ---------------------- ------------------------------------------- + -0.00 BAYES_44 BODY: Bayesian spam probability is 44 to 50% + [score: 0.4977] + 0.85 DATE_IN_PAST_06_12 Date: is 6 to 12 hours before Received: date +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.816 tagged_above=0 required=5 tests=AWL, + DATE_IN_PAST_06_12, FORGED_RCVD_HELO, NO_DNS_FOR_FROM +X-Spam-Level: +X-Archive-Number: 200503/579 +X-Sequence-Number: 11284 + +Tom, + + From what I understand, the vendor used ProIV for development, when +they attempted to use 7.4.3, they had ODBC issues and something else I +honestly don't know, but I was told that data was not coming through +properly. Their somewhat at the mercy of the ProIV people to give them +the stamp of approval, then the vendor will tell us what they support. + +Thanks. + +Steve Poe + +Tom Lane wrote: + +>Steve Poe writes: +> +> +>>Situation: An 24/7 animal hospital (100 employees) runs their business +>>on Centos 3.3 (RHEL 3) Postgres 7.4.2 (because they have to) +>> +>> +> +>[ itch... ] Surely they could at least move to 7.4.7 without pain. +>There are serious data-loss bugs known in 7.4.2. +> +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 7: don't forget to increase your free space map settings +> +> +> + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 17:39:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B4F853676 + for ; + Fri, 25 Mar 2005 17:39:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37940-01 + for ; + Fri, 25 Mar 2005 17:38:56 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 099ED53492 + for ; + Fri, 25 Mar 2005 17:38:55 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7167080; Fri, 25 Mar 2005 09:40:47 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Karim Nassar +Subject: Re: Delete query takes exorbitant amount of time +Date: Fri, 25 Mar 2005 09:38:28 -0800 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <200503242124.39558.josh@agliodbs.com> + <1111728955.9085.238.camel@k2.cet.nau.edu> +In-Reply-To: <1111728955.9085.238.camel@k2.cet.nau.edu> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200503250938.28896.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/548 +X-Sequence-Number: 11253 + +Karim, + +> I guess I was wondering if there is other general tuning advice for such +> large table indexes such as increasing statistics, etc. + +Well, your index use problem is being explained by Tom, Stephan and Simon; +basically your FKed data types are incompatible for index use purposes so the +system *can't* use an index while loading. + +If you're going with the drop/load/recreate option, then I'd suggest +increasing work_mem for the duration. Hmmm ... or maintenance_work_mem? +What gets used for FK checks? Simon? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Mar 25 17:41:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9FA2C536C3 + for ; + Fri, 25 Mar 2005 17:41:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37203-07 + for ; + Fri, 25 Mar 2005 17:41:25 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id B817C5388B + for ; + Fri, 25 Mar 2005 17:41:24 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7167085; Fri, 25 Mar 2005 09:43:17 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Jack Xue +Subject: Re: Script for getting a table of reponse-time breakdown +Date: Fri, 25 Mar 2005 09:40:59 -0800 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: + <1111763525.18036.15.camel@localhost.localdomain> +In-Reply-To: <1111763525.18036.15.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200503250940.59062.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/549 +X-Sequence-Number: 11254 + +Jack, + +> I am thinking about how to continuously monitor the performance of a +> PostgreSQL 8 database. I am interested in two things: (1) the growth of +> tables with TOAST and indexes; + +This is queryable from the system tables, if you don't mind an approximate. + +> and (2) the respond time breakdown for a +> query. + +The what? You mean EXPLAIN ANALYZE? + +> In Chapters 23 and 24 of the big manual, I found enough materials to +> teach me how to do the 1st job. But I have difficulty with the 2nd one. +> I found some script for Oracle +> (http://www.ixora.com.au/scripts/waits.htm). + +Life's too short for reading Oracle docs. Can you just explain, in +step-by-step detail, what you want? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Mar 25 18:00:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8327953864 + for ; + Fri, 25 Mar 2005 18:00:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40714-07 + for ; + Fri, 25 Mar 2005 18:00:15 +0000 (GMT) +Received: from rgmail.regenstrief.org (rgmail.regenstrief.org [134.68.31.125]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C4645385E + for ; + Fri, 25 Mar 2005 18:00:14 +0000 (GMT) +Received: from [172.31.0.53] ([172.31.0.53]) + by rgmail.regenstrief.org (8.12.8/8.12.8) with ESMTP id j2PI07cX028120; + Fri, 25 Mar 2005 13:00:07 -0500 +Subject: Re: Script for getting a table of reponse-time breakdown +From: Jack Xue +To: Josh Berkus +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200503250940.59062.josh@agliodbs.com> +References: + <1111763525.18036.15.camel@localhost.localdomain> + <200503250940.59062.josh@agliodbs.com> +Content-Type: text/plain +Organization: +Message-Id: <1111773606.18036.19.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) +Date: 25 Mar 2005 13:00:06 -0500 +Content-Transfer-Encoding: 7bit +X-Antivirus: Scanned by Vexira Antivirus 1.0.5 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/550 +X-Sequence-Number: 11255 + +Josh, + +The description of the Oracle script is: + +This script can be used to focus tuning attention on the most important +issues. It reports a breakdown of total foreground response time into +four major categories: CPU usage, disk I/O, resource waits, and routine +latencies. These categories are broken down further into sub-categories, +and the component wait events are shown. + +The 8.1.6 version of the script uses the ratio_to_report analytic +function to calculate percentages. The 8.1.5 version can be used if +percentages are not required. The 8.1.5 version of the script should +work on Oracle8 also, but has not yet been tested. + +The print out of this script is: +SQL> @response_time_breakdown + +MAJOR MINOR WAIT_EVENT SECONDS PCT +-------- ------------- ---------------------------------------- -------- ------ +CPU time parsing n/a 497 .57% + reloads n/a 13 .01% + execution n/a 52618 59.99% + +disk I/O normal I/O db file sequential read 21980 25.06% + full scans db file scattered read 9192 10.48% + direct I/O direct path read 1484 1.69% + direct path write 354 .40% + other I/O log file sequential read 9 .01% + db file parallel read 0 .00% + control file sequential read 0 .00% + control file parallel write 0 .00% + +waits DBWn writes rdbms ipc reply 143 .16% + free buffer waits 36 .04% + checkpoint completed 31 .04% + LGWR writes log file switch completion 698 .80% + other locks latch free 496 .57% + sort segment request 108 .12% + +latency commits log file sync 6 .01% + network SQL*Net break/reset to client 18 .02% + SQL*Net more data to client 8 .01% + SQL*Net message to client 7 .01% + SQL*Net more data from client 3 .00% + file ops file open 4 .01% + file identify 1 .00% + misc instance state change 0 .00% + + +The script is pretty long: + +------------------------------------------------------------------------------- +-- +-- Script: response_time_breakdown.sql +-- Purpose: to report the components of foreground response time in % terms +-- For: 8.0 to 8.1.5 +-- +-- Copyright: (c) Ixora Pty Ltd +-- Author: Steve Adams +-- +------------------------------------------------------------------------------- +@save_sqlplus_settings + +column major format a8 +column wait_event format a40 trunc +column seconds format 9999999 +column pct justify right +break on major skip 1 on minor + +select + substr(n_major, 3) major, + substr(n_minor, 3) minor, + wait_event, + round(time/100) seconds +from + ( + select /*+ ordered use_hash(b) */ + '1 CPU time' n_major, + decode(t.ksusdnam, + 'redo size', '2 reloads', + 'parse time cpu', '1 parsing', + '3 execution' + ) n_minor, + 'n/a' wait_event, + decode(t.ksusdnam, + 'redo size', nvl(r.time, 0), + 'parse time cpu', t.ksusgstv - nvl(b.time, 0), + t.ksusgstv - nvl(b.time, 0) - nvl(r.time, 0) + ) time + from + sys.x_$ksusgsta t, + ( + select /*+ ordered use_nl(s) */ -- star query: few rows from d and b + s.ksusestn, -- statistic# + sum(s.ksusestv) time -- time used by backgrounds + from + sys.x_$ksusd d, -- statname + sys.x_$ksuse b, -- session + sys.x_$ksbdp p, -- background process + sys.x_$ksusesta s -- sesstat + where + d.ksusdnam in ( + 'parse time cpu', + 'CPU used when call started') and + b.ksspaown = p.ksbdppro and + s.ksusestn = d.indx and + s.indx = b.indx + group by + s.ksusestn + ) b, + ( + select /*+ no_merge */ + ksusgstv * -- parse cpu time * + kglstrld / -- SQL AREA reloads / + (1 + kglstget - kglstght) -- SQL AREA misses + time + from + sys.x_$kglst k, + sys.x_$ksusgsta g + where + k.indx = 0 and + g.ksusdnam = 'parse time cpu' + ) r + where + t.ksusdnam in ( + 'redo size', -- arbitrary: to get a row to replace + 'parse time cpu', -- with the 'reload cpu time' + 'CPU used when call started') and + b.ksusestn (+) = t.indx + union all + select + decode(n_minor, + '1 normal I/O', '2 disk I/O', + '2 full scans', '2 disk I/O', + '3 direct I/O', '2 disk I/O', + '4 BFILE reads', '2 disk I/O', + '5 other I/O', '2 disk I/O', + '1 DBWn writes', '3 waits', + '2 LGWR writes', '3 waits', + '3 ARCn writes', '3 waits', + '4 enqueue locks', '3 waits', + '5 PCM locks', '3 waits', + '6 other locks', '3 waits', + '1 commits', '4 latency', + '2 network', '4 latency', + '3 file ops', '4 latency', + '4 process ctl', '4 latency', + '5 global locks', '4 latency', + '6 misc', '4 latency' + ) n_major, + n_minor, + wait_event, + time + from + ( + select /*+ ordered use_hash(b) use_nl(d) */ + decode( + d.kslednam, + -- disk I/O + 'db file sequential read', '1 normal I/O', + 'db file scattered read', '2 full scans', + 'BFILE read', '4 BFILE reads', + 'KOLF: Register LFI read', '4 BFILE reads', + 'log file sequential read', '5 other I/O', + 'log file single write', '5 other I/O', + -- resource waits + 'checkpoint completed', '1 DBWn writes', + 'free buffer waits', '1 DBWn writes', + 'write complete waits', '1 DBWn writes', + 'local write wait', '1 DBWn writes', + 'log file switch (checkpoint incomplete)', '1 DBWn writes', + 'rdbms ipc reply', '1 DBWn writes', + 'log file switch (archiving needed)', '3 ARCn writes', + 'enqueue', '4 enqueue locks', + 'buffer busy due to global cache', '5 PCM locks', + 'global cache cr request', '5 PCM locks', + 'global cache lock cleanup', '5 PCM locks', + 'global cache lock null to s', '5 PCM locks', + 'global cache lock null to x', '5 PCM locks', + 'global cache lock s to x', '5 PCM locks', + 'lock element cleanup', '5 PCM locks', + 'checkpoint range buffer not saved', '6 other locks', + 'dupl. cluster key', '6 other locks', + 'PX Deq Credit: free buffer', '6 other locks', + 'PX Deq Credit: need buffer', '6 other locks', + 'PX Deq Credit: send blkd', '6 other locks', + 'PX qref latch', '6 other locks', + 'Wait for credit - free buffer', '6 other locks', + 'Wait for credit - need buffer to send', '6 other locks', + 'Wait for credit - send blocked', '6 other locks', + 'global cache freelist wait', '6 other locks', + 'global cache lock busy', '6 other locks', + 'index block split', '6 other locks', + 'lock element waits', '6 other locks', + 'parallel query qref latch', '6 other locks', + 'pipe put', '6 other locks', + 'rdbms ipc message block', '6 other locks', + 'row cache lock', '6 other locks', + 'sort segment request', '6 other locks', + 'transaction', '6 other locks', + 'unbound tx', '6 other locks', + -- routine waits + 'log file sync', '1 commits', + 'name-service call wait', '2 network', + 'Test if message present', '4 process ctl', + 'process startup', '4 process ctl', + 'read SCN lock', '5 global locks', + decode(substr(d.kslednam, 1, instr(d.kslednam, ' ')), + -- disk I/O + 'direct ', '3 direct I/O', + 'control ', '5 other I/O', + 'db ', '5 other I/O', + -- resource waits + 'log ', '2 LGWR writes', + 'buffer ', '6 other locks', + 'free ', '6 other locks', + 'latch ', '6 other locks', + 'library ', '6 other locks', + 'undo ', '6 other locks', + -- routine waits + 'SQL*Net ', '2 network', + 'BFILE ', '3 file ops', + 'KOLF: ', '3 file ops', + 'file ', '3 file ops', + 'KXFQ: ', '4 process ctl', + 'KXFX: ', '4 process ctl', + 'PX ', '4 process ctl', + 'Wait ', '4 process ctl', + 'inactive ', '4 process ctl', + 'multiple ', '4 process ctl', + 'parallel ', '4 process ctl', + 'DFS ', '5 global locks', + 'batched ', '5 global locks', + 'on-going ', '5 global locks', + 'global ', '5 global locks', + 'wait ', '5 global locks', + 'writes ', '5 global locks', + '6 misc' + ) + ) n_minor, + d.kslednam wait_event, -- event name + i.kslestim - nvl(b.time, 0) time -- non-background time + from + sys.x_$kslei i, -- system events + ( + select /*+ ordered use_hash(e) */ -- no fixed index on e + e.kslesenm, -- event number + sum(e.kslestim) time -- time waited by backgrounds + from + sys.x_$ksuse s, -- sessions + sys.x_$ksbdp b, -- backgrounds + sys.x_$ksles e -- session events + where + s.ksspaown = b.ksbdppro and -- background session + e.kslessid = s.indx + group by + e.kslesenm + having + sum(e.kslestim) > 0 + ) b, + sys.x_$ksled d + where + i.kslestim > 0 and + b.kslesenm (+) = i.indx and + nvl(b.time, 0) < i.kslestim and + d.indx = i.indx and + d.kslednam not in ( + 'Null event', + 'KXFQ: Dequeue Range Keys - Slave', + 'KXFQ: Dequeuing samples', + 'KXFQ: kxfqdeq - dequeue from specific qref', + 'KXFQ: kxfqdeq - normal deqeue', + 'KXFX: Execution Message Dequeue - Slave', + 'KXFX: Parse Reply Dequeue - Query Coord', + 'KXFX: Reply Message Dequeue - Query Coord', + 'PAR RECOV : Dequeue msg - Slave', + 'PAR RECOV : Wait for reply - Query Coord', + 'Parallel Query Idle Wait - Slaves', + 'PL/SQL lock timer', + 'PX Deq: Execute Reply', + 'PX Deq: Execution Msg', + 'PX Deq: Index Merge Execute', + 'PX Deq: Index Merge Reply', + 'PX Deq: Par Recov Change Vector', + 'PX Deq: Par Recov Execute', + 'PX Deq: Par Recov Reply', + 'PX Deq: Parse Reply', + 'PX Deq: Table Q Get Keys', + 'PX Deq: Table Q Normal', + 'PX Deq: Table Q Sample', + 'PX Deq: Table Q qref', + 'PX Deq: Txn Recovery Reply', + 'PX Deq: Txn Recovery Start', + 'PX Deque wait', + 'PX Idle Wait', + 'Replication Dequeue', + 'Replication Dequeue ', + 'SQL*Net message from client', + 'SQL*Net message from dblink', + 'debugger command', + 'dispatcher timer', + 'parallel query dequeue wait', + 'pipe get', + 'queue messages', + 'rdbms ipc message', + 'secondary event', + 'single-task message', + 'slave wait', + 'virtual circuit status' + ) and + d.kslednam not like 'resmgr:%' + ) + ) +order by + n_major, + n_minor, + time desc +/ + +@restore_sqlplus_settings + +Do we have some similar for Postgres? + +Thanks. + +-Jack + + +On Fri, 2005-03-25 at 12:40, Josh Berkus wrote: +> Jack, +> +> > I am thinking about how to continuously monitor the performance of a +> > PostgreSQL 8 database. I am interested in two things: (1) the growth of +> > tables with TOAST and indexes; +> +> This is queryable from the system tables, if you don't mind an approximate. +> +> > and (2) the respond time breakdown for a +> > query. +> +> The what? You mean EXPLAIN ANALYZE? +> +> > In Chapters 23 and 24 of the big manual, I found enough materials to +> > teach me how to do the 1st job. But I have difficulty with the 2nd one. +> > I found some script for Oracle +> > (http://www.ixora.com.au/scripts/waits.htm). +> +> Life's too short for reading Oracle docs. Can you just explain, in +> step-by-step detail, what you want? + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 18:07:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E602538B2 + for ; + Fri, 25 Mar 2005 18:07:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45643-04 + for ; + Fri, 25 Mar 2005 18:07:39 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 5913A538B8 + for ; + Fri, 25 Mar 2005 18:07:38 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7167162; Fri, 25 Mar 2005 10:09:32 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Jack Xue +Subject: Re: Script for getting a table of reponse-time breakdown +Date: Fri, 25 Mar 2005 10:07:13 -0800 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: + <200503250940.59062.josh@agliodbs.com> + <1111773606.18036.19.camel@localhost.localdomain> +In-Reply-To: <1111773606.18036.19.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Message-Id: <200503251007.13520.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/551 +X-Sequence-Number: 11256 + +Jack, + +> This script can be used to focus tuning attention on the most important +> issues. It reports a breakdown of total foreground response time into +> four major categories: CPU usage, disk I/O, resource waits, and routine +> latencies. These categories are broken down further into sub-categories, +> and the component wait events are shown. + +This would be very nice. And very, very hard to build. + +No, we don't have anything similar. You can, of course, use profiling tools. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Mar 25 18:26:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F88352A3D + for ; + Fri, 25 Mar 2005 18:26:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48517-05 + for ; + Fri, 25 Mar 2005 18:25:55 +0000 (GMT) +Received: from cmailg1.svr.pol.co.uk (cmailg1.svr.pol.co.uk [195.92.195.171]) + by svr1.postgresql.org (Postfix) with ESMTP id F253952A5D + for ; + Fri, 25 Mar 2005 18:25:54 +0000 (GMT) +Received: from modem-844.leopard.dialup.pol.co.uk ([217.135.147.76] + helo=192.168.0.102) by cmailg1.svr.pol.co.uk with esmtp (Exim 4.14) + id 1DEtUz-0005eB-0m; Fri, 25 Mar 2005 18:25:33 +0000 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Stephan Szabo +Cc: Tom Lane , Karim Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: <20050325082101.G4358@megazone.bigpanda.com> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> <4243879B.10200@familyhealth.com.au> + <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <23515.1111763837@sss.pgh.pa.us> + <1111766478.11750.762.camel@localhost.localdomain> + <20050325082101.G4358@megazone.bigpanda.com> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Fri, 25 Mar 2005 18:24:10 +0000 +Message-Id: <1111775050.11750.790.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/553 +X-Sequence-Number: 11258 + +On Fri, 2005-03-25 at 08:23 -0800, Stephan Szabo wrote: +> On Fri, 25 Mar 2005, Simon Riggs wrote: +> +> > On Fri, 2005-03-25 at 10:17 -0500, Tom Lane wrote: +> > > Simon Riggs writes: +> > > > I vote to make this an ERROR in 8.1 - I see little benefit in allowing +> > > > this situation to continue. +> > > +> > > Other than spec compliance, you mean? SQL99 says +> > > +> > > ... The declared type of each referencing column shall be +> > > comparable to the declared type of the corresponding referenced +> > > column. +> > > +> > > It doesn't say that it has to be indexable, and most definitely not that +> > > there has to be an index. +> > +> > specs at dawn, eh? +> > +> > Well, SQL:2003 Foundation, p.550 clause 3a) states that the the +> > in the referencing table must match a unique +> > constraint on the referenced table, or the PRIMARY KEY if the columns +> > are not specified. Either way, the referenced columns are a unique +> > constraint (which makes perfect sense from a logical data perspective). +> > +> > We implement unique constraints via an index, so for PostgreSQL the +> > clause implies that it must refer to an index. +> +> IMHO, that reference is irrrelevant. + +Tom had said SQL99 required this; I have pointed out SQL:2003, which +supercedes the SQL99 standard, does not require this. + +Leading us back to my original point - what is the benefit of continuing +with having a WARNING when that leads people into trouble later? + +> Yes, there must be an index due to +> our implementation, however that doesn't imply that the types must be the +> same + +No, it doesn't imply it, but what benefit do you see from the +interpretation that they are allowed to differ? That interpretation +currently leads to many mistakes leading to poor performance. + +There is clear benefit from forcing them to be the same. In logical data +terms, they *should* be the same. I don't check fruit.apple_grade +against fruit_type.orange_grade. When would I want to make a check of +that nature? If there is a reason, thats great, lets keep status quo +then. + +I respect the effort and thought that has already gone into the +implementation; I seek only to offer a very minor improvement based upon +recent list issues. + +> nor even that the index must be usable for the cross table +> comparison. + +Thats a separate discussion, possibly the next one. + +Best Regards, Simon Riggs + + + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 18:25:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 35E7E52A3D + for ; + Fri, 25 Mar 2005 18:25:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48517-04 + for ; + Fri, 25 Mar 2005 18:25:26 +0000 (GMT) +Received: from ylpvm15.prodigy.net (ylpvm15-ext.prodigy.net [207.115.57.46]) + by svr1.postgresql.org (Postfix) with ESMTP id 9440E52A50 + for ; + Fri, 25 Mar 2005 18:25:25 +0000 (GMT) +Received: from blomqvist (adsl-64-167-95-140.dsl.lsan03.pacbell.net + [64.167.95.140]) + by ylpvm15.prodigy.net (8.12.10 outbound/8.12.10) with SMTP id + j2PILPba002855; Fri, 25 Mar 2005 13:21:25 -0500 +Message-ID: <00f201c53168$96903480$e602a8c0@blomqvist> +From: "Otto Blomqvist" +To: "Matthew T. O'Connor" +Cc: , + "Tom Lane" +References: <42430FA0.9080204@zeut.net> + <002b01c530c5$ad5a1620$e602a8c0@blomqvist> + <42435408.30303@zeut.net> +Subject: Re: pg_autovacuum not having enough suction ? +Date: Fri, 25 Mar 2005 10:29:30 -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-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/552 +X-Sequence-Number: 11257 + +It looks like the reltuples-values are screwed up. Even though rows are +constantly being removed from the table the reltuples keep going up. If I +understand correctly that also makes the Vacuum threshold go up and we end +up in a vicious circle. Right after pg_autovacuum performed a vacuum analyze +on the table it actually had 31000 records, but reltuples reports over 100k. +I'm not sure if this means anything But i thought i would pass it along. + +PG version 8.0.0, 31MB tarred DB. + +[2005-03-25 09:16:14 EST] INFO: dbname: testing +[2005-03-25 09:16:14 EST] INFO: oid: 9383816 +[2005-03-25 09:16:14 EST] INFO: username: (null) +[2005-03-25 09:16:14 EST] INFO: password: (null) +[2005-03-25 09:16:14 EST] INFO: conn is null, (not connected) +[2005-03-25 09:16:14 EST] INFO: default_analyze_threshold: 1000 +[2005-03-25 09:16:14 EST] INFO: default_vacuum_threshold: 500 + + +[2005-03-25 09:05:12 EST] INFO: table name: secom."public"."file_92" +[2005-03-25 09:05:12 EST] INFO: relid: 9384219; relisshared: 0 +[2005-03-25 09:05:12 EST] INFO: reltuples: 49185.000000; relpages: +8423 +[2005-03-25 09:05:12 EST] INFO: curr_analyze_count: 919274; +curr_vacuum_count: 658176 +[2005-03-25 09:05:12 EST] INFO: last_analyze_count: 899272; +last_vacuum_count: 560541 +[2005-03-25 09:05:12 EST] INFO: analyze_threshold: 49685; +vacuum_threshold: 100674 + + +[2005-03-25 09:10:12 EST] DEBUG: Performing: VACUUM ANALYZE +"public"."file_92" +[2005-03-25 09:10:33 EST] INFO: table name: secom."public"."file_92" +[2005-03-25 09:10:33 EST] INFO: relid: 9384219; relisshared: 0 +[2005-03-25 09:10:33 EST] INFO: reltuples: 113082.000000; relpages: +6624 +[2005-03-25 09:10:33 EST] INFO: curr_analyze_count: 923820; +curr_vacuum_count: 662699 +[2005-03-25 09:10:33 EST] INFO: last_analyze_count: 923820; +last_vacuum_count: 662699 +[2005-03-25 09:10:33 EST] INFO: analyze_threshold: 113582; +vacuum_threshold: 227164 + + +[2005-03-25 09:16:14 EST] INFO: table name: secom."public"."file_92" +[2005-03-25 09:16:14 EST] INFO: relid: 9384219; relisshared: 0 +[2005-03-25 09:16:14 EST] INFO: reltuples: 113082.000000; relpages: +6624 <-- Actually has 31k rows +[2005-03-25 09:16:14 EST] INFO: curr_analyze_count: 923820; +curr_vacuum_count: 662699 +[2005-03-25 09:16:14 EST] INFO: last_analyze_count: 923820; +last_vacuum_count: 662699 +[2005-03-25 09:16:14 EST] INFO: analyze_threshold: 113582; +vacuum_threshold: 227164 + +DETAIL: Allocated FSM size: 1000 relations + 2000000 pages = 11784 kB +shared memory. + + + + +----- Original Message ----- +From: "Matthew T. O'Connor" +To: "Otto Blomqvist" ; + +Sent: Thursday, March 24, 2005 3:58 PM +Subject: Re: [PERFORM] pg_autovacuum not having enough suction ? + + +> I would rather keep this on list since other people can chime in. +> +> Otto Blomqvist wrote: +> +> >It does not seem to be a Stats collector problem. +> > +> > oid | relname | relnamespace | relpages | relisshared | reltuples | +> >schemaname | n_tup_ins | n_tup_upd | n_tup_del +> +>---------+---------+--------------+----------+-------------+-----------+--- +- +> >--------+-----------+-----------+----------- +> > 9384219 | file_92 | 2200 | 8423 | f | 49837 | +> >public | 158176 | 318527 | 158176 +> >(1 row) +> > +> >I insert 50000 records +> > +> >secom=# select createfile_92records(1, 50000); <--- this is a pg +script +> >that inserts records 1 threw 50000. +> > createfile_92records +> >---------------------- +> > 0 +> > +> > +> > oid | relname | relnamespace | relpages | relisshared | reltuples | +> >schemaname | n_tup_ins | n_tup_upd | n_tup_del +> +>---------+---------+--------------+----------+-------------+-----------+--- +- +> >--------+-----------+-----------+----------- +> > 9384219 | file_92 | 2200 | 8423 | f | 49837 | +> >public | 208179 | 318932 | 158377 +> >(1 row) +> > +> >reltuples does not change ? Hmm. n_tup_ins looks fine. +> > +> > +> +> That is expected, reltuples only gets updated by a vacuum or an analyze. +> +> >This table is basically a queue full of records waiting to get transfered +> >over from our 68030 system to the PG database. The records are then moved +> >into folders (using a trigger) like file_92_myy depending on what month +the +> >record was created on the 68030. During normal operations there should +not +> >be more than 10 records at a time in the table, although during the +course +> >of a day a normal system will get about 50k records. I create 50000 +records +> >to simulate incoming traffic, since we don't have much traffic in the +test +> >lab. +> > +> >After a few hours we have +> > +> >secom=# select count(*) from file_92; +> > count +> >------- +> > 42072 +> > +> >So we have sent over approx 8000 Records. +> > +> > oid | relname | relnamespace | relpages | relisshared | reltuples | +> >schemaname | n_tup_ins | n_tup_upd | n_tup_del +> +>---------+---------+--------------+----------+-------------+-----------+--- +- +> >--------+-----------+-----------+----------- +> > 9384219 | file_92 | 2200 | 8423 | f | 49837 | +> >public | 208218 | 334521 | 166152 +> >(1 row) +> > +> > +> >n_tup_upd: 318932 + (50000-42072)*2 = 334788 pretty close. (Each record +> >gets updated twice, then moved) +> >n_tup_del: 158377 + (50000-42072) = 166305 pretty close. (there are also +> >minor background traffic going on) +> > +> > +> >I could send over the full vacuum verbose capture as well as the +autovacuum +> >capture if that is of interest. +> > +> +> That might be helpful. I don't see a stats system problem here, but I +> also haven't heard of any autovac problems recently, so this might be +> something new. +> +> Thanks, +> +> Matthew O'Connor +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: Have you searched our list archives? +> +> http://archives.postgresql.org +> + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 18:47:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E265053490 + for ; + Fri, 25 Mar 2005 18:47:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54975-02 + for ; + Fri, 25 Mar 2005 18:47:35 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A74AC52A48 + for ; + Fri, 25 Mar 2005 18:47:35 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2PIlMLs028058; + Fri, 25 Mar 2005 13:47:22 -0500 (EST) +To: Simon Riggs +Cc: Stephan Szabo , + Karim Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <1111775050.11750.790.camel@localhost.localdomain> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> + <4243879B.10200@familyhealth.com.au> + <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <23515.1111763837@sss.pgh.pa.us> + <1111766478.11750.762.camel@localhost.localdomain> + <20050325082101.G4358@megazone.bigpanda.com> + <1111775050.11750.790.camel@localhost.localdomain> +Comments: In-reply-to Simon Riggs + message dated "Fri, 25 Mar 2005 18:24:10 +0000" +Date: Fri, 25 Mar 2005 13:47:22 -0500 +Message-ID: <28057.1111776442@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/554 +X-Sequence-Number: 11259 + +Simon Riggs writes: +> On Fri, 2005-03-25 at 10:17 -0500, Tom Lane wrote: +>>> Other than spec compliance, you mean? SQL99 says +>>> +>>> ... The declared type of each referencing column shall be +>>> comparable to the declared type of the corresponding referenced +>>> column. + +> Tom had said SQL99 required this; I have pointed out SQL:2003, which +> supercedes the SQL99 standard, does not require this. + +You're reading the wrong part of SQL:2003. 11.8 syntax rule 9 still has the text I quoted. + +> Leading us back to my original point - what is the benefit of continuing +> with having a WARNING when that leads people into trouble later? + +Accepting spec-compliant schemas. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 25 19:46:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 18DC3535AB + for ; + Fri, 25 Mar 2005 19:46:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69421-09 + for ; + Fri, 25 Mar 2005 19:45:49 +0000 (GMT) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 72367535E6 + for ; + Fri, 25 Mar 2005 19:45:48 +0000 (GMT) +Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] + helo=[192.168.0.66]) + by outbound.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) + (Exim 4.44) id 1DEukf-000Hxm-DP; Fri, 25 Mar 2005 14:45:49 -0500 +Message-ID: <42446A66.6010504@zeut.net> +Date: Fri, 25 Mar 2005 14:45:42 -0500 +From: "Matthew T. O'Connor" +Organization: Terrie O'Connor Realtors +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Otto Blomqvist +Cc: pgsql-performance@postgresql.org, Tom Lane +Subject: Re: pg_autovacuum not having enough suction ? +References: <42430FA0.9080204@zeut.net> + <002b01c530c5$ad5a1620$e602a8c0@blomqvist> + <42435408.30303@zeut.net> + <00f201c53168$96903480$e602a8c0@blomqvist> +In-Reply-To: <00f201c53168$96903480$e602a8c0@blomqvist> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Originating-IP: 67.80.199.173 +X-Report-Abuse-To: abuse@dyndns.org (see + http://www.mailhop.org/outbound/abuse.html for abuse reporting + information) +X-MHO-User: zeut +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/555 +X-Sequence-Number: 11260 + +hmm.... the value in reltuples should be accurate after a vacuum (or +vacuum analyze) if it's not it's a vacuum bug or something is going on +that isn't understood. If you or pg_autovacuum are running plain +analyze commands, that could explain the invalid reltules numbers. + +Was reltuples = 113082 correct right after the vacuum? + +Matthew + + +Otto Blomqvist wrote: + +>It looks like the reltuples-values are screwed up. Even though rows are +>constantly being removed from the table the reltuples keep going up. If I +>understand correctly that also makes the Vacuum threshold go up and we end +>up in a vicious circle. Right after pg_autovacuum performed a vacuum analyze +>on the table it actually had 31000 records, but reltuples reports over 100k. +>I'm not sure if this means anything But i thought i would pass it along. +> +>PG version 8.0.0, 31MB tarred DB. +> +>[2005-03-25 09:16:14 EST] INFO: dbname: testing +>[2005-03-25 09:16:14 EST] INFO: oid: 9383816 +>[2005-03-25 09:16:14 EST] INFO: username: (null) +>[2005-03-25 09:16:14 EST] INFO: password: (null) +>[2005-03-25 09:16:14 EST] INFO: conn is null, (not connected) +>[2005-03-25 09:16:14 EST] INFO: default_analyze_threshold: 1000 +>[2005-03-25 09:16:14 EST] INFO: default_vacuum_threshold: 500 +> +> +>[2005-03-25 09:05:12 EST] INFO: table name: secom."public"."file_92" +>[2005-03-25 09:05:12 EST] INFO: relid: 9384219; relisshared: 0 +>[2005-03-25 09:05:12 EST] INFO: reltuples: 49185.000000; relpages: +>8423 +>[2005-03-25 09:05:12 EST] INFO: curr_analyze_count: 919274; +>curr_vacuum_count: 658176 +>[2005-03-25 09:05:12 EST] INFO: last_analyze_count: 899272; +>last_vacuum_count: 560541 +>[2005-03-25 09:05:12 EST] INFO: analyze_threshold: 49685; +>vacuum_threshold: 100674 +> +> +>[2005-03-25 09:10:12 EST] DEBUG: Performing: VACUUM ANALYZE +>"public"."file_92" +>[2005-03-25 09:10:33 EST] INFO: table name: secom."public"."file_92" +>[2005-03-25 09:10:33 EST] INFO: relid: 9384219; relisshared: 0 +>[2005-03-25 09:10:33 EST] INFO: reltuples: 113082.000000; relpages: +>6624 +>[2005-03-25 09:10:33 EST] INFO: curr_analyze_count: 923820; +>curr_vacuum_count: 662699 +>[2005-03-25 09:10:33 EST] INFO: last_analyze_count: 923820; +>last_vacuum_count: 662699 +>[2005-03-25 09:10:33 EST] INFO: analyze_threshold: 113582; +>vacuum_threshold: 227164 +> +> +>[2005-03-25 09:16:14 EST] INFO: table name: secom."public"."file_92" +>[2005-03-25 09:16:14 EST] INFO: relid: 9384219; relisshared: 0 +>[2005-03-25 09:16:14 EST] INFO: reltuples: 113082.000000; relpages: +>6624 <-- Actually has 31k rows +>[2005-03-25 09:16:14 EST] INFO: curr_analyze_count: 923820; +>curr_vacuum_count: 662699 +>[2005-03-25 09:16:14 EST] INFO: last_analyze_count: 923820; +>last_vacuum_count: 662699 +>[2005-03-25 09:16:14 EST] INFO: analyze_threshold: 113582; +>vacuum_threshold: 227164 +> +>DETAIL: Allocated FSM size: 1000 relations + 2000000 pages = 11784 kB +>shared memory. +> +> +> +> +>----- Original Message ----- +>From: "Matthew T. O'Connor" +>To: "Otto Blomqvist" ; +> +>Sent: Thursday, March 24, 2005 3:58 PM +>Subject: Re: [PERFORM] pg_autovacuum not having enough suction ? +> +> +> +> +>>I would rather keep this on list since other people can chime in. +>> +>>Otto Blomqvist wrote: +>> +>> +>> +>>>It does not seem to be a Stats collector problem. +>>> +>>> oid | relname | relnamespace | relpages | relisshared | reltuples | +>>>schemaname | n_tup_ins | n_tup_upd | n_tup_del +>>> +>>> +>>---------+---------+--------------+----------+-------------+-----------+--- +>> +>> +>- +> +> +>>>--------+-----------+-----------+----------- +>>>9384219 | file_92 | 2200 | 8423 | f | 49837 | +>>>public | 158176 | 318527 | 158176 +>>>(1 row) +>>> +>>>I insert 50000 records +>>> +>>>secom=# select createfile_92records(1, 50000); <--- this is a pg +>>> +>>> +>script +> +> +>>>that inserts records 1 threw 50000. +>>>createfile_92records +>>>---------------------- +>>> 0 +>>> +>>> +>>> oid | relname | relnamespace | relpages | relisshared | reltuples | +>>>schemaname | n_tup_ins | n_tup_upd | n_tup_del +>>> +>>> +>>---------+---------+--------------+----------+-------------+-----------+--- +>> +>> +>- +> +> +>>>--------+-----------+-----------+----------- +>>>9384219 | file_92 | 2200 | 8423 | f | 49837 | +>>>public | 208179 | 318932 | 158377 +>>>(1 row) +>>> +>>>reltuples does not change ? Hmm. n_tup_ins looks fine. +>>> +>>> +>>> +>>> +>>That is expected, reltuples only gets updated by a vacuum or an analyze. +>> +>> +>> +>>>This table is basically a queue full of records waiting to get transfered +>>>over from our 68030 system to the PG database. The records are then moved +>>>into folders (using a trigger) like file_92_myy depending on what month +>>> +>>> +>the +> +> +>>>record was created on the 68030. During normal operations there should +>>> +>>> +>not +> +> +>>>be more than 10 records at a time in the table, although during the +>>> +>>> +>course +> +> +>>>of a day a normal system will get about 50k records. I create 50000 +>>> +>>> +>records +> +> +>>>to simulate incoming traffic, since we don't have much traffic in the +>>> +>>> +>test +> +> +>>>lab. +>>> +>>>After a few hours we have +>>> +>>>secom=# select count(*) from file_92; +>>>count +>>>------- +>>>42072 +>>> +>>>So we have sent over approx 8000 Records. +>>> +>>> oid | relname | relnamespace | relpages | relisshared | reltuples | +>>>schemaname | n_tup_ins | n_tup_upd | n_tup_del +>>> +>>> +>>---------+---------+--------------+----------+-------------+-----------+--- +>> +>> +>- +> +> +>>>--------+-----------+-----------+----------- +>>>9384219 | file_92 | 2200 | 8423 | f | 49837 | +>>>public | 208218 | 334521 | 166152 +>>>(1 row) +>>> +>>> +>>>n_tup_upd: 318932 + (50000-42072)*2 = 334788 pretty close. (Each record +>>>gets updated twice, then moved) +>>>n_tup_del: 158377 + (50000-42072) = 166305 pretty close. (there are also +>>>minor background traffic going on) +>>> +>>> +>>>I could send over the full vacuum verbose capture as well as the +>>> +>>> +>autovacuum +> +> +>>>capture if that is of interest. +>>> +>>> +>>> +>>That might be helpful. I don't see a stats system problem here, but I +>>also haven't heard of any autovac problems recently, so this might be +>>something new. +>> +>>Thanks, +>> +>>Matthew O'Connor +>> +>> +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 6: Have you searched our list archives? +>> +>> http://archives.postgresql.org +>> +>> +>> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 8: explain analyze is your friend +> +> +> + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 19:55:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 75A27535EF + for ; + Fri, 25 Mar 2005 19:55:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73060-03 + for ; + Fri, 25 Mar 2005 19:55:27 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C6D4353598 + for ; + Fri, 25 Mar 2005 19:55:26 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2PJtRml011992; + Fri, 25 Mar 2005 14:55:27 -0500 (EST) +To: "Matthew T. O'Connor" +Cc: Otto Blomqvist , + pgsql-performance@postgresql.org +Subject: Re: pg_autovacuum not having enough suction ? +In-reply-to: <42446A66.6010504@zeut.net> +References: <42430FA0.9080204@zeut.net> + <002b01c530c5$ad5a1620$e602a8c0@blomqvist> + <42435408.30303@zeut.net> + <00f201c53168$96903480$e602a8c0@blomqvist> + <42446A66.6010504@zeut.net> +Comments: In-reply-to "Matthew T. O'Connor" + message dated "Fri, 25 Mar 2005 14:45:42 -0500" +Date: Fri, 25 Mar 2005 14:55:27 -0500 +Message-ID: <11991.1111780527@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/556 +X-Sequence-Number: 11261 + +"Matthew T. O'Connor" writes: +> hmm.... the value in reltuples should be accurate after a vacuum (or +> vacuum analyze) if it's not it's a vacuum bug or something is going on +> that isn't understood. If you or pg_autovacuum are running plain +> analyze commands, that could explain the invalid reltules numbers. + +> Was reltuples = 113082 correct right after the vacuum? + +Another thing to check is whether the reltuples (and relpages!) that +autovacuum is reporting are the same as what's actually in the pg_class +row for the relation. I'm wondering if this could be a similar issue +to the old autovac bug where it wasn't reading the value correctly. + +If they are the same then it seems like it must be a backend issue. + +One thing that is possibly relevant here is that in 8.0 a plain VACUUM +doesn't set reltuples to the exactly correct number, but to an +interpolated value that reflects our estimate of the "steady state" +average between vacuums. I wonder if that code is wrong, or if it's +operating as designed but is confusing autovac. + +Can autovac be told to run the vacuums in VERBOSE mode? It would be +useful to compare what VERBOSE has to say to the changes in +reltuples/relpages. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Fri Mar 25 20:22:59 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B3262535E6; + Fri, 25 Mar 2005 20:22:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90220-06; Fri, 25 Mar 2005 20:22:49 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id CAB6153608; + Fri, 25 Mar 2005 20:22:48 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2PKMn9N012122; + Fri, 25 Mar 2005 15:22:49 -0500 (EST) +To: "Matthew T. O'Connor" +Cc: pgsql-hackers@postgreSQL.org, Otto Blomqvist , + pgsql-performance@postgreSQL.org +Subject: lazy_update_relstats considered harmful (was Re: [PERFORM] + pg_autovacuum not having enough suction ?) +In-reply-to: <11991.1111780527@sss.pgh.pa.us> +References: <42430FA0.9080204@zeut.net> + <002b01c530c5$ad5a1620$e602a8c0@blomqvist> + <42435408.30303@zeut.net> + <00f201c53168$96903480$e602a8c0@blomqvist> + <42446A66.6010504@zeut.net> <11991.1111780527@sss.pgh.pa.us> +Comments: In-reply-to Tom Lane + message dated "Fri, 25 Mar 2005 14:55:27 -0500" +Date: Fri, 25 Mar 2005 15:22:49 -0500 +Message-ID: <12121.1111782169@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/905 +X-Sequence-Number: 65707 + +I wrote: +> One thing that is possibly relevant here is that in 8.0 a plain VACUUM +> doesn't set reltuples to the exactly correct number, but to an +> interpolated value that reflects our estimate of the "steady state" +> average between vacuums. I wonder if that code is wrong, or if it's +> operating as designed but is confusing autovac. + +Now that I think it over, I'm thinking that I must have been suffering +severe brain fade the day I wrote lazy_update_relstats() (see +vacuumlazy.c). The numbers that that routine is averaging are the pre- +and post-vacuum physical tuple counts. But the difference between them +consists of known-dead tuples, and we shouldn't be factoring dead tuples +into reltuples. The planner has always considered reltuples to count +only live tuples, and I think this is correct on two grounds: + +1. The numbers of tuples estimated to be returned by scans certainly +shouldn't count dead ones. + +2. Dead tuples don't have that much influence on scan costs either, at +least not once they are marked as known-dead. Certainly they shouldn't +be charged at full freight. + +It's possible that there'd be some value in adding a column to pg_class +to record dead tuple count, but given what we have now, the calculation +in lazy_update_relstats is totally wrong. + +The idea I was trying to capture is that the tuple density is at a +minimum right after VACUUM, and will increase as free space is filled +in until the next VACUUM, so that recording the exact tuple count +underestimates the number of tuples that will be seen on-the-average. +But I'm not sure that idea really holds water. The only way that a +table can be at "steady state" over a long period is if the number of +live tuples remains roughly constant (ie, inserts balance deletes). +What actually increases and decreases over a VACUUM cycle is the density +of *dead* tuples ... but per the above arguments this isn't something +we should adjust reltuples for. + +So I'm thinking lazy_update_relstats should be ripped out and we should +go back to recording just the actual stats. + +Sound reasonable? Or was I right the first time and suffering brain +fade today? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 25 20:20:55 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2080E53642 + for ; + Fri, 25 Mar 2005 20:20:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89492-07 + for ; + Fri, 25 Mar 2005 20:20:50 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 842B35360B + for ; + Fri, 25 Mar 2005 20:20:49 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 31E7830959; Fri, 25 Mar 2005 21:20:50 +0100 (MET) +From: "Otto Blomqvist" +X-Newsgroups: pgsql.performance +Subject: Re: pg_autovacuum not having enough suction ? +Date: Fri, 25 Mar 2005 12:24:51 -0800 +Organization: Hub.Org Networking Services +Lines: 282 +Message-ID: +References: <42430FA0.9080204@zeut.net> + <002b01c530c5$ad5a1620$e602a8c0@blomqvist> + <42435408.30303@zeut.net> + <00f201c53168$96903480$e602a8c0@blomqvist> + <42446A66.6010504@zeut.net> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.802 tagged_above=0 required=5 tests=AWL, + PRIORITY_NO_NAME +X-Spam-Level: +X-Archive-Number: 200503/557 +X-Sequence-Number: 11262 + +> Was reltuples = 113082 correct right after the vacuum? + +No, There where about 31000 rows after the vacuum. I'm no expert but tuples += rows, right ? + +This is not a "normal" table though, in the sence that it is only a +temporary holding ground as I explained earlier. I create 50000 records and +these get sent over from our custom 68030 system, to tables like +file_92_myy, depending on the date of the record. A pl/pgsql script is used +as a trigger to move the records after they get data from the 68030. Don't +know if that is of interest or not. I could post the trigger if you'd like. + + +""Matthew T. O'Connor"" wrote in message +news:42446A66.6010504@zeut.net... +> hmm.... the value in reltuples should be accurate after a vacuum (or +> vacuum analyze) if it's not it's a vacuum bug or something is going on +> that isn't understood. If you or pg_autovacuum are running plain +> analyze commands, that could explain the invalid reltules numbers. +> +> Was reltuples = 113082 correct right after the vacuum? +> +> Matthew +> +> +> Otto Blomqvist wrote: +> +> >It looks like the reltuples-values are screwed up. Even though rows are +> >constantly being removed from the table the reltuples keep going up. If I +> >understand correctly that also makes the Vacuum threshold go up and we +end +> >up in a vicious circle. Right after pg_autovacuum performed a vacuum +analyze +> >on the table it actually had 31000 records, but reltuples reports over +100k. +> >I'm not sure if this means anything But i thought i would pass it along. +> > +> >PG version 8.0.0, 31MB tarred DB. +> > +> >[2005-03-25 09:16:14 EST] INFO: dbname: testing +> >[2005-03-25 09:16:14 EST] INFO: oid: 9383816 +> >[2005-03-25 09:16:14 EST] INFO: username: (null) +> >[2005-03-25 09:16:14 EST] INFO: password: (null) +> >[2005-03-25 09:16:14 EST] INFO: conn is null, (not connected) +> >[2005-03-25 09:16:14 EST] INFO: default_analyze_threshold: 1000 +> >[2005-03-25 09:16:14 EST] INFO: default_vacuum_threshold: 500 +> > +> > +> >[2005-03-25 09:05:12 EST] INFO: table name: secom."public"."file_92" +> >[2005-03-25 09:05:12 EST] INFO: relid: 9384219; relisshared: 0 +> >[2005-03-25 09:05:12 EST] INFO: reltuples: 49185.000000; +relpages: +> >8423 +> >[2005-03-25 09:05:12 EST] INFO: curr_analyze_count: 919274; +> >curr_vacuum_count: 658176 +> >[2005-03-25 09:05:12 EST] INFO: last_analyze_count: 899272; +> >last_vacuum_count: 560541 +> >[2005-03-25 09:05:12 EST] INFO: analyze_threshold: 49685; +> >vacuum_threshold: 100674 +> > +> > +> >[2005-03-25 09:10:12 EST] DEBUG: Performing: VACUUM ANALYZE +> >"public"."file_92" +> >[2005-03-25 09:10:33 EST] INFO: table name: secom."public"."file_92" +> >[2005-03-25 09:10:33 EST] INFO: relid: 9384219; relisshared: 0 +> >[2005-03-25 09:10:33 EST] INFO: reltuples: 113082.000000; +relpages: +> >6624 +> >[2005-03-25 09:10:33 EST] INFO: curr_analyze_count: 923820; +> >curr_vacuum_count: 662699 +> >[2005-03-25 09:10:33 EST] INFO: last_analyze_count: 923820; +> >last_vacuum_count: 662699 +> >[2005-03-25 09:10:33 EST] INFO: analyze_threshold: 113582; +> >vacuum_threshold: 227164 +> > +> > +> >[2005-03-25 09:16:14 EST] INFO: table name: secom."public"."file_92" +> >[2005-03-25 09:16:14 EST] INFO: relid: 9384219; relisshared: 0 +> >[2005-03-25 09:16:14 EST] INFO: reltuples: 113082.000000; +relpages: +> >6624 <-- Actually has 31k rows +> >[2005-03-25 09:16:14 EST] INFO: curr_analyze_count: 923820; +> >curr_vacuum_count: 662699 +> >[2005-03-25 09:16:14 EST] INFO: last_analyze_count: 923820; +> >last_vacuum_count: 662699 +> >[2005-03-25 09:16:14 EST] INFO: analyze_threshold: 113582; +> >vacuum_threshold: 227164 +> > +> >DETAIL: Allocated FSM size: 1000 relations + 2000000 pages = 11784 kB +> >shared memory. +> > +> > +> > +> > +> >----- Original Message ----- +> >From: "Matthew T. O'Connor" +> >To: "Otto Blomqvist" ; +> > +> >Sent: Thursday, March 24, 2005 3:58 PM +> >Subject: Re: [PERFORM] pg_autovacuum not having enough suction ? +> > +> > +> > +> > +> >>I would rather keep this on list since other people can chime in. +> >> +> >>Otto Blomqvist wrote: +> >> +> >> +> >> +> >>>It does not seem to be a Stats collector problem. +> >>> +> >>> oid | relname | relnamespace | relpages | relisshared | reltuples | +> >>>schemaname | n_tup_ins | n_tup_upd | n_tup_del +> >>> +> >>> +> +>>---------+---------+--------------+----------+-------------+-----------+-- +- +> >> +> >> +> >- +> > +> > +> >>>--------+-----------+-----------+----------- +> >>>9384219 | file_92 | 2200 | 8423 | f | 49837 | +> >>>public | 158176 | 318527 | 158176 +> >>>(1 row) +> >>> +> >>>I insert 50000 records +> >>> +> >>>secom=# select createfile_92records(1, 50000); <--- this is a pg +> >>> +> >>> +> >script +> > +> > +> >>>that inserts records 1 threw 50000. +> >>>createfile_92records +> >>>---------------------- +> >>> 0 +> >>> +> >>> +> >>> oid | relname | relnamespace | relpages | relisshared | reltuples | +> >>>schemaname | n_tup_ins | n_tup_upd | n_tup_del +> >>> +> >>> +> +>>---------+---------+--------------+----------+-------------+-----------+-- +- +> >> +> >> +> >- +> > +> > +> >>>--------+-----------+-----------+----------- +> >>>9384219 | file_92 | 2200 | 8423 | f | 49837 | +> >>>public | 208179 | 318932 | 158377 +> >>>(1 row) +> >>> +> >>>reltuples does not change ? Hmm. n_tup_ins looks fine. +> >>> +> >>> +> >>> +> >>> +> >>That is expected, reltuples only gets updated by a vacuum or an analyze. +> >> +> >> +> >> +> >>>This table is basically a queue full of records waiting to get +transfered +> >>>over from our 68030 system to the PG database. The records are then +moved +> >>>into folders (using a trigger) like file_92_myy depending on what month +> >>> +> >>> +> >the +> > +> > +> >>>record was created on the 68030. During normal operations there should +> >>> +> >>> +> >not +> > +> > +> >>>be more than 10 records at a time in the table, although during the +> >>> +> >>> +> >course +> > +> > +> >>>of a day a normal system will get about 50k records. I create 50000 +> >>> +> >>> +> >records +> > +> > +> >>>to simulate incoming traffic, since we don't have much traffic in the +> >>> +> >>> +> >test +> > +> > +> >>>lab. +> >>> +> >>>After a few hours we have +> >>> +> >>>secom=# select count(*) from file_92; +> >>>count +> >>>------- +> >>>42072 +> >>> +> >>>So we have sent over approx 8000 Records. +> >>> +> >>> oid | relname | relnamespace | relpages | relisshared | reltuples | +> >>>schemaname | n_tup_ins | n_tup_upd | n_tup_del +> >>> +> >>> +> +>>---------+---------+--------------+----------+-------------+-----------+-- +- +> >> +> >> +> >- +> > +> > +> >>>--------+-----------+-----------+----------- +> >>>9384219 | file_92 | 2200 | 8423 | f | 49837 | +> >>>public | 208218 | 334521 | 166152 +> >>>(1 row) +> >>> +> >>> +> >>>n_tup_upd: 318932 + (50000-42072)*2 = 334788 pretty close. (Each +record +> >>>gets updated twice, then moved) +> >>>n_tup_del: 158377 + (50000-42072) = 166305 pretty close. (there are +also +> >>>minor background traffic going on) +> >>> +> >>> +> >>>I could send over the full vacuum verbose capture as well as the +> >>> +> >>> +> >autovacuum +> > +> > +> >>>capture if that is of interest. +> >>> +> >>> +> >>> +> >>That might be helpful. I don't see a stats system problem here, but I +> >>also haven't heard of any autovac problems recently, so this might be +> >>something new. +> >> +> >>Thanks, +> >> +> >>Matthew O'Connor +> >> +> >> +> >> +> >>---------------------------(end of broadcast)--------------------------- +> >>TIP 6: Have you searched our list archives? +> >> +> >> http://archives.postgresql.org +> >> +> >> +> >> +> > +> > +> >---------------------------(end of broadcast)--------------------------- +> >TIP 8: explain analyze is your friend +> > +> > +> > +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: the planner will ignore your desire to choose an index scan if your +> joining column's datatypes do not match +> + + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 20:30:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 60519535E6 + for ; + Fri, 25 Mar 2005 20:30:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93866-05 + for ; + Fri, 25 Mar 2005 20:30:13 +0000 (GMT) +Received: from cmailm1.svr.pol.co.uk (cmailm1.svr.pol.co.uk [195.92.193.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F3505360A + for ; + Fri, 25 Mar 2005 20:30:12 +0000 (GMT) +Received: from modem-2520.lion.dialup.pol.co.uk ([217.135.169.216] + helo=192.168.0.102) by cmailm1.svr.pol.co.uk with esmtp (Exim 4.41) + id 1DEvRR-0004ci-MJ; Fri, 25 Mar 2005 20:30:02 +0000 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Tom Lane +Cc: Stephan Szabo , + Karim Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: <28057.1111776442@sss.pgh.pa.us> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> <4243879B.10200@familyhealth.com.au> + <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <23515.1111763837@sss.pgh.pa.us> + <1111766478.11750.762.camel@localhost.localdomain> + <20050325082101.G4358@megazone.bigpanda.com> + <1111775050.11750.790.camel@localhost.localdomain> + <28057.1111776442@sss.pgh.pa.us> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Fri, 25 Mar 2005 20:28:49 +0000 +Message-Id: <1111782529.11750.815.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/559 +X-Sequence-Number: 11264 + +On Fri, 2005-03-25 at 13:47 -0500, Tom Lane wrote: +> Simon Riggs writes: +> > On Fri, 2005-03-25 at 10:17 -0500, Tom Lane wrote: +> >>> Other than spec compliance, you mean? SQL99 says +> >>> +> >>> ... The declared type of each referencing column shall be +> >>> comparable to the declared type of the corresponding referenced +> >>> column. +> +> > Tom had said SQL99 required this; I have pointed out SQL:2003, which +> > supercedes the SQL99 standard, does not require this. +> +> You're reading the wrong part of SQL:2003. 11.8 definition> syntax rule 9 still has the text I quoted. + +So, we have this from SQL:2003 section 11.8 p.550 +- 3a) requires us to have an index +- 9) requires the data types to be "comparable" + +In the name of spec-compliance we wish to accept an interpretation of +the word "comparable" that means we will accept two datatypes that are +not actually the same. + +So we are happy to enforce having the index, but not happy to ensure the +index is actually usable for the task? + +> > Leading us back to my original point - what is the benefit of continuing +> > with having a WARNING when that leads people into trouble later? +> +> Accepting spec-compliant schemas. + +I definitely want this too - as you know I have worked on documenting +compliance previously. + +Is the word "comparable" defined elsewhere in the standard? + +Currently, datatypes with similar type categories are comparable and yet +(in 8.0) will now use the index. So, we are taking comparable to include +fairly radically different datatypes? + +Could it be that because PostgreSQL has a very highly developed sense of +datatype comparison that we might be taking this to extremes? Would any +other RDBMS consider two different datatypes to be comparable? + +Please consider this. + +Best Regards, Simon Riggs + + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 20:31:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CE13E5363A + for ; + Fri, 25 Mar 2005 20:31:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94917-05 + for ; + Fri, 25 Mar 2005 20:31:00 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A9A053637 + for ; + Fri, 25 Mar 2005 20:30:59 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id A31B730959; Fri, 25 Mar 2005 21:30:57 +0100 (MET) +From: "Otto Blomqvist" +X-Newsgroups: pgsql.performance +Subject: Re: pg_autovacuum not having enough suction ? +Date: Fri, 25 Mar 2005 12:35:00 -0800 +Organization: Hub.Org Networking Services +Lines: 63 +Message-ID: +References: <42430FA0.9080204@zeut.net> + <002b01c530c5$ad5a1620$e602a8c0@blomqvist> + <42435408.30303@zeut.net> + <00f201c53168$96903480$e602a8c0@blomqvist> + <42446A66.6010504@zeut.net> <11991.1111780527@sss.pgh.pa.us> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.912 tagged_above=0 required=5 tests=AWL, + PRIORITY_NO_NAME +X-Spam-Level: +X-Archive-Number: 200503/560 +X-Sequence-Number: 11265 + + +> Another thing to check is whether the reltuples (and relpages!) that +> autovacuum is reporting are the same as what's actually in the pg_class +> row for the relation. I'm wondering if this could be a similar issue +> to the old autovac bug where it wasn't reading the value correctly. + +These values where extracted at roughly the same time. + + relname | relnamespace | reltype | relowner | relam | relfilenode | +reltablespace | relpages | reltuples | reltoastrelid | reltoastidxid | +relhasindex | relisshared | relkind | relnatts | relchecks | reltriggers | +relukeys | relfkeys | relrefs | relhasoids | relhaspkey | relhasrules | +relhassubclass | relacl +---------+--------------+---------+----------+-------+-------------+-------- +-------+----------+-----------+---------------+---------------+------------- ++-------------+---------+----------+-----------+-------------+----------+--- +-------+---------+------------+------------+-------------+----------------+- +------- + file_92 | 2200 | 9384220 | 100 | 0 | 9384219 | +0 | 6624 | 113082 | 0 | 0 | t | f +| r | 23 | 0 | 1 | 0 | 0 | +0 | t | f | f | f | +(1 row) + +secom=# select count(*) from file_92; + count +------- + 17579 +(1 row) + +[2005-03-25 12:16:32 EST] INFO: table name: secom."public"."file_92" +[2005-03-25 12:16:32 EST] INFO: relid: 9384219; relisshared: 0 +[2005-03-25 12:16:32 EST] INFO: reltuples: 113082.000000; relpages: +6624 +[2005-03-25 12:16:32 EST] INFO: curr_analyze_count: 993780; +curr_vacuum_count: 732470 +[2005-03-25 12:16:32 EST] INFO: last_analyze_count: 923820; +last_vacuum_count: 662699 +[2005-03-25 12:16:32 EST] INFO: analyze_threshold: 113582; +vacuum_threshold: 227164 + + +Hope this helps, if there is anything else I can do please let me know. + + +> If they are the same then it seems like it must be a backend issue. +> +> One thing that is possibly relevant here is that in 8.0 a plain VACUUM +> doesn't set reltuples to the exactly correct number, but to an +> interpolated value that reflects our estimate of the "steady state" +> average between vacuums. I wonder if that code is wrong, or if it's +> operating as designed but is confusing autovac. + + +This average steady state value might be hard to interpolete in this case +since this is only a temporary holding place for the records ..? Normaly the +table has < 10 records in it at the same time. In the lab we create a +"lump-traffic" by sending over 50000 Records. It takes about 20 hours to +transfer over all of the 50k records. + + + + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 21:04:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 115CE536AB + for ; + Fri, 25 Mar 2005 21:04:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60827-09 + for ; + Fri, 25 Mar 2005 21:04:32 +0000 (GMT) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 3F4CD536A9 + for ; + Fri, 25 Mar 2005 21:04:31 +0000 (GMT) +Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] + helo=[192.168.0.66]) + by outbound.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) + (Exim 4.44) id 1DEvyq-00014a-Kp; Fri, 25 Mar 2005 16:04:32 -0500 +Message-ID: <42447CD9.9050509@zeut.net> +Date: Fri, 25 Mar 2005 16:04:25 -0500 +From: "Matthew T. O'Connor" +Organization: Terrie O'Connor Realtors +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Otto Blomqvist , + pgsql-performance@postgresql.org +Subject: Re: pg_autovacuum not having enough suction ? +References: <42430FA0.9080204@zeut.net> + <002b01c530c5$ad5a1620$e602a8c0@blomqvist> + <42435408.30303@zeut.net> + <00f201c53168$96903480$e602a8c0@blomqvist> + <42446A66.6010504@zeut.net> <11991.1111780527@sss.pgh.pa.us> +In-Reply-To: <11991.1111780527@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Originating-IP: 67.80.199.173 +X-Report-Abuse-To: abuse@dyndns.org (see + http://www.mailhop.org/outbound/abuse.html for abuse reporting + information) +X-MHO-User: zeut +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/561 +X-Sequence-Number: 11266 + +Tom Lane wrote: + +>"Matthew T. O'Connor" writes: +> +> +>>hmm.... the value in reltuples should be accurate after a vacuum (or +>>vacuum analyze) if it's not it's a vacuum bug or something is going on +>>that isn't understood. If you or pg_autovacuum are running plain +>>analyze commands, that could explain the invalid reltules numbers. +>> +>> +>>Was reltuples = 113082 correct right after the vacuum? +>> +>> +> +>Another thing to check is whether the reltuples (and relpages!) that +>autovacuum is reporting are the same as what's actually in the pg_class +>row for the relation. I'm wondering if this could be a similar issue +>to the old autovac bug where it wasn't reading the value correctly. +> +> + +I don't think so, as he did some manual selects from pg_class and +pg_stat_all in one of the emails he sent that were showing similar +numbers to what autovac was reporting. + +>If they are the same then it seems like it must be a backend issue. +> +>One thing that is possibly relevant here is that in 8.0 a plain VACUUM +>doesn't set reltuples to the exactly correct number, but to an +>interpolated value that reflects our estimate of the "steady state" +>average between vacuums. I wonder if that code is wrong, or if it's +>operating as designed but is confusing autovac. +> +> + +Ahh.... Now that you mention it, I do remember the discussion during +8.0 development. This sounds very much like the cause of the problem. +Autovac is not vacuuming often enough for this table because reltuples +is telling autovac that there are alot more tuples in this table than +there really are. + +Really this is just another case of the more general problem with +autovac as it stands now. That is, you can't set vacuum thresholds on a +per table basis, and databases like this can't survive with a one size +fits all threshold. I would suggest that Otto perform regular cron +based vacuums of this one table in addition to autovac, that is what +several people I have heard from in the field are doing. + +Come hell or high water I'm gonna get autovac integrated into 8.1, at +which point per table thresholds would be easy todo. + +>Can autovac be told to run the vacuums in VERBOSE mode? It would be +>useful to compare what VERBOSE has to say to the changes in +>reltuples/relpages. +> +Not as it stands now. That would be an interesting feature for +debugging purposes though. + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 21:10:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CF31536EC + for ; + Fri, 25 Mar 2005 21:10:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63660-09 + for ; + Fri, 25 Mar 2005 21:10:51 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id AECCA536AA + for ; + Fri, 25 Mar 2005 21:10:49 +0000 (GMT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id BCCE63566D; Fri, 25 Mar 2005 13:10:51 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id BAB343562E; Fri, 25 Mar 2005 13:10:51 -0800 (PST) +Date: Fri, 25 Mar 2005 13:10:51 -0800 (PST) +From: Stephan Szabo +To: Simon Riggs +Cc: Tom Lane , Karim Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-Reply-To: <1111782529.11750.815.camel@localhost.localdomain> +Message-ID: <20050325130124.U15470@megazone.bigpanda.com> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> + <4243879B.10200@familyhealth.com.au> <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <23515.1111763837@sss.pgh.pa.us> + <1111766478.11750.762.camel@localhost.localdomain> + <20050325082101.G4358@megazone.bigpanda.com> + <1111775050.11750.790.camel@localhost.localdomain> + <28057.1111776442@sss.pgh.pa.us> + <1111782529.11750.815.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/562 +X-Sequence-Number: 11267 + + +On Fri, 25 Mar 2005, Simon Riggs wrote: + +> On Fri, 2005-03-25 at 13:47 -0500, Tom Lane wrote: +> > Simon Riggs writes: +> > > On Fri, 2005-03-25 at 10:17 -0500, Tom Lane wrote: +> > >>> Other than spec compliance, you mean? SQL99 says +> > >>> +> > >>> ... The declared type of each referencing column shall be +> > >>> comparable to the declared type of the corresponding referenced +> > >>> column. +> > +> > > Tom had said SQL99 required this; I have pointed out SQL:2003, which +> > > supercedes the SQL99 standard, does not require this. +> > +> > You're reading the wrong part of SQL:2003. 11.8 > definition> syntax rule 9 still has the text I quoted. +> +> So, we have this from SQL:2003 section 11.8 p.550 +> - 3a) requires us to have an index +> - 9) requires the data types to be "comparable" +> +> In the name of spec-compliance we wish to accept an interpretation of +> the word "comparable" that means we will accept two datatypes that are +> not actually the same. +> +> So we are happy to enforce having the index, but not happy to ensure the +> index is actually usable for the task? + +The indexes "usability" only applies to the purpose of guaranteeing +uniqueness which doesn't depend on the referencing type AFAICS. + +> > > Leading us back to my original point - what is the benefit of continuing +> > > with having a WARNING when that leads people into trouble later? +> > +> > Accepting spec-compliant schemas. +> +> I definitely want this too - as you know I have worked on documenting +> compliance previously. +> +> Is the word "comparable" defined elsewhere in the standard? + +Yes. And at least in SQL99, there's a bunch of statements in 4.* about +what are comparable. + +> Currently, datatypes with similar type categories are comparable and yet +> (in 8.0) will now use the index. So, we are taking comparable to include +> fairly radically different datatypes? + +Not entirely. I believe a referenced column of int, and a referencing +column of numeric currently displays that warning, but appears to be +allowed by the spec (as the numeric types are considered mutually +comparable). + +> Could it be that because PostgreSQL has a very highly developed sense of +> datatype comparison that we might be taking this to extremes? Would any +> other RDBMS consider two different datatypes to be comparable? + +We do have a broader comparable than the spec. However, if we were to +limit it to the spec then many of the implicit casts and cross-type +comparison operators we have would be invalid as well since the comparison +between those types would have to fail as well unless we treat the +comparable used by differently. + +From pgsql-hackers-owner@postgresql.org Fri Mar 25 21:12:40 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C5F4E536AC; + Fri, 25 Mar 2005 21:12:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64303-08; Fri, 25 Mar 2005 21:12:35 +0000 (GMT) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 65CCA536FD; + Fri, 25 Mar 2005 21:12:33 +0000 (GMT) +Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] + helo=[192.168.0.66]) + by outbound.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) + (Exim 4.44) id 1DEw6c-0001vF-P8; Fri, 25 Mar 2005 16:12:34 -0500 +Message-ID: <42447EBB.20905@zeut.net> +Date: Fri, 25 Mar 2005 16:12:27 -0500 +From: "Matthew T. O'Connor" +Organization: Terrie O'Connor Realtors +User-Agent: Mozilla Thunderbird 1.0RC1 (Windows/20041201) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-hackers@postgresql.org, Otto Blomqvist , + pgsql-performance@postgresql.org +Subject: Re: lazy_update_relstats considered harmful (was Re: [PERFORM] +References: <42430FA0.9080204@zeut.net> + <002b01c530c5$ad5a1620$e602a8c0@blomqvist> + <42435408.30303@zeut.net> + <00f201c53168$96903480$e602a8c0@blomqvist> + <42446A66.6010504@zeut.net> <11991.1111780527@sss.pgh.pa.us> + <12121.1111782169@sss.pgh.pa.us> +In-Reply-To: <12121.1111782169@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Originating-IP: 67.80.199.173 +X-Report-Abuse-To: abuse@dyndns.org (see + http://www.mailhop.org/outbound/abuse.html for abuse reporting + information) +X-MHO-User: zeut +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/909 +X-Sequence-Number: 65711 + +Tom Lane wrote: + +>I wrote: +> +> +>>One thing that is possibly relevant here is that in 8.0 a plain VACUUM +>>doesn't set reltuples to the exactly correct number, but to an +>>interpolated value that reflects our estimate of the "steady state" +>>average between vacuums. I wonder if that code is wrong, or if it's +>>operating as designed but is confusing autovac. +>> +>> +> +>Now that I think it over, I'm thinking that I must have been suffering +>severe brain fade the day I wrote lazy_update_relstats() (see +>vacuumlazy.c). The numbers that that routine is averaging are the pre- +>and post-vacuum physical tuple counts. But the difference between them +>consists of known-dead tuples, and we shouldn't be factoring dead tuples +>into reltuples. The planner has always considered reltuples to count +>only live tuples, and I think this is correct on two grounds: +> +>1. The numbers of tuples estimated to be returned by scans certainly +>shouldn't count dead ones. +> +>2. Dead tuples don't have that much influence on scan costs either, at +>least not once they are marked as known-dead. Certainly they shouldn't +>be charged at full freight. +> +>It's possible that there'd be some value in adding a column to pg_class +>to record dead tuple count, but given what we have now, the calculation +>in lazy_update_relstats is totally wrong. +> +>The idea I was trying to capture is that the tuple density is at a +>minimum right after VACUUM, and will increase as free space is filled +>in until the next VACUUM, so that recording the exact tuple count +>underestimates the number of tuples that will be seen on-the-average. +>But I'm not sure that idea really holds water. The only way that a +>table can be at "steady state" over a long period is if the number of +>live tuples remains roughly constant (ie, inserts balance deletes). +>What actually increases and decreases over a VACUUM cycle is the density +>of *dead* tuples ... but per the above arguments this isn't something +>we should adjust reltuples for. +> +>So I'm thinking lazy_update_relstats should be ripped out and we should +>go back to recording just the actual stats. +> +>Sound reasonable? Or was I right the first time and suffering brain +>fade today? +> + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 21:25:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 966E85334D + for ; + Fri, 25 Mar 2005 21:25:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67462-07 + for ; + Fri, 25 Mar 2005 21:25:23 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5EFB55335F + for ; + Fri, 25 Mar 2005 21:25:22 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2PLP9fA012832; + Fri, 25 Mar 2005 16:25:09 -0500 (EST) +To: Stephan Szabo +Cc: Simon Riggs , Karim Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <20050325130124.U15470@megazone.bigpanda.com> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> + <4243879B.10200@familyhealth.com.au> + <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <23515.1111763837@sss.pgh.pa.us> + <1111766478.11750.762.camel@localhost.localdomain> + <20050325082101.G4358@megazone.bigpanda.com> + <1111775050.11750.790.camel@localhost.localdomain> + <28057.1111776442@sss.pgh.pa.us> + <1111782529.11750.815.camel@localhost.localdomain> + <20050325130124.U15470@megazone.bigpanda.com> +Comments: In-reply-to Stephan Szabo + message dated "Fri, 25 Mar 2005 13:10:51 -0800" +Date: Fri, 25 Mar 2005 16:25:09 -0500 +Message-ID: <12831.1111785909@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/564 +X-Sequence-Number: 11269 + +Stephan Szabo writes: +> On Fri, 25 Mar 2005, Simon Riggs wrote: +>> Could it be that because PostgreSQL has a very highly developed sense of +>> datatype comparison that we might be taking this to extremes? Would any +>> other RDBMS consider two different datatypes to be comparable? + +> We do have a broader comparable than the spec. + +However, the set of comparisons that we can presently support *with +indexes* is narrower than the spec, so rejecting nonindexable cases +would be a problem. + +It's worth noting also that the test being discussed checks whether the +PK index is usable for testing the RI constraint. In the problem that +started this thread, the difficulty is lack of a usable index on the FK +column, not the PK (because that's the table that has to be searched to +do a delete in the PK table). We cannot enforce that there be a usable +index on the FK column (since indexes on the FK table may not have been +built yet when the constraint is declared), and shouldn't anyway because +there are reasonable usage patterns where you don't need one. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 25 21:44:18 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E173E5323D + for ; + Fri, 25 Mar 2005 21:44:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74109-08 + for ; + Fri, 25 Mar 2005 21:44:13 +0000 (GMT) +Received: from mailgate2.nau.edu (mailgate2.nau.edu [134.114.96.59]) + by svr1.postgresql.org (Postfix) with ESMTP id 6DDF352A66 + for ; + Fri, 25 Mar 2005 21:44:12 +0000 (GMT) +Received: from CONVERSION-DAEMON.mailgate2.nau.edu by mailgate2.nau.edu + (PMDF V6.2-X17 #30770) id <0IDX00H01GDOBO@mailgate2.nau.edu> for + pgsql-performance@postgresql.org; Fri, 25 Mar 2005 14:44:13 -0700 (MST) +Received: from k2.cet.nau.edu (net9-213.cet.nau.edu [134.114.9.213]) + by mailgate2.nau.edu (PMDF V6.2-X17 #30770) + with ESMTP id <0IDX00J66GDOZW@mailgate2.nau.edu>; Fri, + 25 Mar 2005 14:44:12 -0700 (MST) +Date: Fri, 25 Mar 2005 14:47:44 -0700 +From: Karim Nassar +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <1111763448.11750.730.camel@localhost.localdomain> +To: Simon Riggs +Cc: Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Message-id: <1111787264.9168.7.camel@k2.cet.nau.edu> +MIME-version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-type: text/plain +Content-transfer-encoding: 7BIT +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> <4243879B.10200@familyhealth.com.au> + <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.103 tagged_above=0 required=5 tests=AWL, + UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200503/565 +X-Sequence-Number: 11270 + +On Fri, 2005-03-25 at 15:10 +0000, Simon Riggs wrote: +> Karim: Did this happen? If not, can you drop and re-create and confirm +> that you get the WARNING? If not, we have problems. + +No. Nor do I think that I should. SERIAL is shortcut for INTEGER, no? I +think there is some other (TBD) problem causing my big seq scan. + +orfs=# ALTER TABLE measurement DROP CONSTRAINT measurement_id_int_sensor_meas_type_fkey; +ALTER TABLE +orfs=# ALTER TABLE ONLY measurement ADD CONSTRAINT measurement_id_int_sensor_meas_type_fkey +orfs-# FOREIGN KEY (id_int_sensor_meas_type) REFERENCES int_sensor_meas_type(id_int_sensor_meas_type); +ALTER TABLE +orfs=# + +The add constraint statement comes directly from a pg_dump. + +For clarity, the table/indexes were created as such: + +CREATE TABLE int_sensor_meas_type( + id_int_sensor_meas_type SERIAL PRIMARY KEY, + id_sensor integer NOT NULL REFERENCES sensor, + id_meas_type integer NOT NULL REFERENCES meas_type UNIQUE); + +CREATE TABLE measurement ( + id_measurement SERIAL PRIMARY KEY, + id_int_sensor_meas_type integer NOT NULL REFERENCES int_sensor_meas_type, + datetime timestamp WITH TIME ZONE NOT NULL, + value numeric(15,5) NOT NULL, + created timestamp with time zone NOT NULL DEFAULT now(), + created_by TEXT NOT NULL REFERENCES public.person(id_person)); + +CREATE INDEX measurement__id_int_sensor_meas_type_idx ON measurement(id_int_sensor_meas_type); + +Regards, +-- +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=- Mobile: (928) 699-9221 + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 21:51:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A64853363 + for ; + Fri, 25 Mar 2005 21:51:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78407-01 + for ; + Fri, 25 Mar 2005 21:51:26 +0000 (GMT) +Received: from cmailg4.svr.pol.co.uk (cmailg4.svr.pol.co.uk [195.92.195.174]) + by svr1.postgresql.org (Postfix) with ESMTP id 435265336E + for ; + Fri, 25 Mar 2005 21:51:25 +0000 (GMT) +Received: from modem-850.lemur.dialup.pol.co.uk ([217.135.131.82] + helo=192.168.0.102) by cmailg4.svr.pol.co.uk with esmtp (Exim 4.41) + id 1DEwi4-0005U4-Gy; Fri, 25 Mar 2005 21:51:17 +0000 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Tom Lane +Cc: Stephan Szabo , + Karim Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: <12831.1111785909@sss.pgh.pa.us> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> <4243879B.10200@familyhealth.com.au> + <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <23515.1111763837@sss.pgh.pa.us> + <1111766478.11750.762.camel@localhost.localdomain> + <20050325082101.G4358@megazone.bigpanda.com> + <1111775050.11750.790.camel@localhost.localdomain> + <28057.1111776442@sss.pgh.pa.us> + <1111782529.11750.815.camel@localhost.localdomain> + <20050325130124.U15470@megazone.bigpanda.com> + <12831.1111785909@sss.pgh.pa.us> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Fri, 25 Mar 2005 21:50:04 +0000 +Message-Id: <1111787404.11750.825.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/566 +X-Sequence-Number: 11271 + +On Fri, 2005-03-25 at 16:25 -0500, Tom Lane wrote: +> Stephan Szabo writes: +> > On Fri, 25 Mar 2005, Simon Riggs wrote: +> >> Could it be that because PostgreSQL has a very highly developed sense of +> >> datatype comparison that we might be taking this to extremes? Would any +> >> other RDBMS consider two different datatypes to be comparable? +> +> > We do have a broader comparable than the spec. +> +> However, the set of comparisons that we can presently support *with +> indexes* is narrower than the spec, so rejecting nonindexable cases +> would be a problem. + +OK. Can we have a TODO item then? + +* Ensure that all SQL:2003 comparable datatypes are also indexable when +compared + +...or something like that + +> It's worth noting also that the test being discussed checks whether the +> PK index is usable for testing the RI constraint. In the problem that +> started this thread, the difficulty is lack of a usable index on the FK +> column, not the PK (because that's the table that has to be searched to +> do a delete in the PK table). We cannot enforce that there be a usable +> index on the FK column (since indexes on the FK table may not have been +> built yet when the constraint is declared), and shouldn't anyway because +> there are reasonable usage patterns where you don't need one. + +Yes, I agree for CASCADE we wouldn't always want an index. + +Alright then, time to leave it there. + +I want to write up some additional comments for performance tips: +- Consider defining RI constraints after tables have been loaded +- Remember to add an index on the referencing table if the constraint is +defined as CASCADEing + +Have a good Easter, all, wherever you are and whatever you believe in. + +Best Regards, Simon Riggs + + +From pgsql-hackers-owner@postgresql.org Fri Mar 25 22:21:53 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6340C533AA; + Fri, 25 Mar 2005 22:21:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85436-04; Fri, 25 Mar 2005 22:21:41 +0000 (GMT) +Received: from cmailg3.svr.pol.co.uk (cmailg3.svr.pol.co.uk [195.92.195.173]) + by svr1.postgresql.org (Postfix) with ESMTP id 57E5E53363; + Fri, 25 Mar 2005 22:21:40 +0000 (GMT) +Received: from modem-3142.lynx.dialup.pol.co.uk ([217.135.204.70] + helo=192.168.0.102) by cmailg3.svr.pol.co.uk with esmtp (Exim 4.41) + id 1DExBU-0004Zi-Cf; Fri, 25 Mar 2005 22:21:40 +0000 +Subject: Re: lazy_update_relstats considered harmful (was Re: [PERFORM] +From: Simon Riggs +To: Tom Lane +Cc: "Matthew T. O'Connor" , pgsql-hackers@postgreSQL.org, + Otto Blomqvist , + pgsql-performance@postgreSQL.org +In-Reply-To: <12121.1111782169@sss.pgh.pa.us> +References: <42430FA0.9080204@zeut.net> + <002b01c530c5$ad5a1620$e602a8c0@blomqvist> <42435408.30303@zeut.net> + <00f201c53168$96903480$e602a8c0@blomqvist> <42446A66.6010504@zeut.net> + <11991.1111780527@sss.pgh.pa.us> <12121.1111782169@sss.pgh.pa.us> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Fri, 25 Mar 2005 22:20:23 +0000 +Message-Id: <1111789223.11750.839.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/912 +X-Sequence-Number: 65714 + +On Fri, 2005-03-25 at 15:22 -0500, Tom Lane wrote: +> 2. Dead tuples don't have that much influence on scan costs either, at +> least not once they are marked as known-dead. Certainly they shouldn't +> be charged at full freight. + +Yes, minor additional CPU time, but the main issue is when the dead +tuples force additional I/O. + +> It's possible that there'd be some value in adding a column to pg_class +> to record dead tuple count, but given what we have now, the calculation +> in lazy_update_relstats is totally wrong. + +Yes, thats the way. We can record the (averaged?) dead tuple count, but +also record the actual row count in reltuples. + +We definitely need to record the physical and logical tuple counts, +since each of them have different contributions to run-times. + +For comparing seq scan v index, we need to look at the physical tuples +count * avg row size, whereas when we calculate number of rows returned +we should look at fractions of the logical row count. + +> The idea I was trying to capture is that the tuple density is at a +> minimum right after VACUUM, and will increase as free space is filled +> in until the next VACUUM, so that recording the exact tuple count +> underestimates the number of tuples that will be seen on-the-average. +> But I'm not sure that idea really holds water. The only way that a +> table can be at "steady state" over a long period is if the number of +> live tuples remains roughly constant (ie, inserts balance deletes). +> What actually increases and decreases over a VACUUM cycle is the density +> of *dead* tuples ... but per the above arguments this isn't something +> we should adjust reltuples for. +> +> So I'm thinking lazy_update_relstats should be ripped out and we should +> go back to recording just the actual stats. +> +> Sound reasonable? Or was I right the first time and suffering brain +> fade today? + +Well, I think the original idea had some validity, but clearly +lazy_update_relstats isn't the way to do it even though we thought so at +the time. + +Best Regards, Simon Riggs + + + +From pgsql-hackers-owner@postgresql.org Fri Mar 25 22:36:13 2005 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3AC77533DE + for ; + Fri, 25 Mar 2005 22:36:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88833-02 + for ; + Fri, 25 Mar 2005 22:35:57 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id F0D7F533D9 + for ; + Fri, 25 Mar 2005 22:35:56 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2PMZwrg014074; + Fri, 25 Mar 2005 17:35:58 -0500 (EST) +To: Simon Riggs +Cc: "Matthew T. O'Connor" , pgsql-hackers@postgreSQL.org, + Otto Blomqvist , + pgsql-performance@postgreSQL.org +Subject: Re: lazy_update_relstats considered harmful (was Re: [PERFORM] + pg_autovacuum not having enough suction ?) +In-reply-to: <1111789223.11750.839.camel@localhost.localdomain> +References: <42430FA0.9080204@zeut.net> + <002b01c530c5$ad5a1620$e602a8c0@blomqvist> + <42435408.30303@zeut.net> + <00f201c53168$96903480$e602a8c0@blomqvist> + <42446A66.6010504@zeut.net> <11991.1111780527@sss.pgh.pa.us> + <12121.1111782169@sss.pgh.pa.us> + <1111789223.11750.839.camel@localhost.localdomain> +Comments: In-reply-to Simon Riggs + message dated "Fri, 25 Mar 2005 22:20:23 +0000" +Date: Fri, 25 Mar 2005 17:35:58 -0500 +Message-ID: <14073.1111790158@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/913 +X-Sequence-Number: 65715 + +Simon Riggs writes: +> On Fri, 2005-03-25 at 15:22 -0500, Tom Lane wrote: +>> 2. Dead tuples don't have that much influence on scan costs either, at +>> least not once they are marked as known-dead. Certainly they shouldn't +>> be charged at full freight. + +> Yes, minor additional CPU time, but the main issue is when the dead +> tuples force additional I/O. + +I/O costs are mostly estimated off relpages, though, not reltuples. +The only time you really pay through the nose for a dead tuple is when +an indexscan visits it, but with the known-dead marking we now do in +btree indexes, I'm pretty sure that path is seldom taken. + +>> It's possible that there'd be some value in adding a column to pg_class +>> to record dead tuple count, but given what we have now, the calculation +>> in lazy_update_relstats is totally wrong. + +> Yes, thats the way. We can record the (averaged?) dead tuple count, but +> also record the actual row count in reltuples. + +What I'd be inclined to record is the actual number of dead rows removed +by the most recent VACUUM. Any math on that is best done in the +planner, since we can change the logic more easily than the database +contents. It'd probably be reasonable to take half of that number as +the estimate of the average number of dead tuples. + +But in any case, that's for the future; we can't have it in 8.0.*, and +right at the moment I'm focusing on what to push out for 8.0.2. + +> We definitely need to record the physical and logical tuple counts, +> since each of them have different contributions to run-times. + +There isn't any difference, if you are talking about fully dead tuples. +It would be possible for VACUUM to also count the number of +not-committed-but-not-removable tuples (ie, new from still-open +transactions, plus dead-but-still-visible-to-somebody), but I'm not sure +that it would be useful to do so, because that sort of count is hugely +transient. The stat would be irrelevant moments after it was taken. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 25 23:06:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 80A7B53488 + for ; + Fri, 25 Mar 2005 23:06:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96172-03 + for ; + Fri, 25 Mar 2005 23:06:02 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id AB36953486 + for ; + Fri, 25 Mar 2005 23:06:00 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2PN63gv016055; + Fri, 25 Mar 2005 18:06:03 -0500 (EST) +To: "Matthew T. O'Connor" +Cc: Otto Blomqvist , + "pgsql-performance@postgresql.org" +Subject: Re: pg_autovacuum not having enough suction ? +In-reply-to: <42435408.30303@zeut.net> +References: <42430FA0.9080204@zeut.net> + <002b01c530c5$ad5a1620$e602a8c0@blomqvist> + <42435408.30303@zeut.net> +Comments: In-reply-to "Matthew T. O'Connor" + message dated "Thu, 24 Mar 2005 18:58:00 -0500" +Date: Fri, 25 Mar 2005 18:06:02 -0500 +Message-ID: <16054.1111791962@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/569 +X-Sequence-Number: 11274 + +> Otto Blomqvist wrote: +>> This table is basically a queue full of records waiting to get transfered +>> over from our 68030 system to the PG database. The records are then moved +>> into folders (using a trigger) like file_92_myy depending on what month the +>> record was created on the 68030. During normal operations there should not +>> be more than 10 records at a time in the table, although during the course +>> of a day a normal system will get about 50k records. I create 50000 records +>> to simulate incoming traffic, since we don't have much traffic in the test +>> lab. + +Really the right way to do housekeeping for a table like that is to +VACUUM FULL (or better yet, TRUNCATE, if possible) immediately after +discarding a batch of records. The VACUUM FULL will take very little +time if it only has to repack <10 records. Plain VACUUM is likely to +leave the table nearly empty but physically sizable, which is bad news +from a statistical point of view: as the table fills up again, it won't +get physically larger, thereby giving the planner no clue that it +doesn't still have <10 records. This means the queries that process +the 50K-record patch are going to get horrible plans :-( + +I'm not sure if autovacuum could be taught to do that --- it could +perhaps launch a vacuum as soon as it notices a large fraction of the +table got deleted, but do we really want to authorize it to launch +VACUUM FULL? It'd be better to issue the vacuum synchronously +as part of the batch updating script, I feel. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 25 23:13:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CC39B534C8 + for ; + Fri, 25 Mar 2005 23:13:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96228-07 + for ; + Fri, 25 Mar 2005 23:13:13 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E1F053490 + for ; + Fri, 25 Mar 2005 23:13:12 +0000 (GMT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id j2PNDFA24795; + Fri, 25 Mar 2005 18:13:15 -0500 (EST) +From: Bruce Momjian +Message-Id: <200503252313.j2PNDFA24795@candle.pha.pa.us> +Subject: Re: pg_autovacuum not having enough suction ? +In-Reply-To: <16054.1111791962@sss.pgh.pa.us> +To: Tom Lane +Date: Fri, 25 Mar 2005 18:13:15 -0500 (EST) +Cc: "Matthew T. O'Connor" , + Otto Blomqvist , + "pgsql-performance@postgresql.org" +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/570 +X-Sequence-Number: 11275 + +Tom Lane wrote: +> > Otto Blomqvist wrote: +> >> This table is basically a queue full of records waiting to get transfered +> >> over from our 68030 system to the PG database. The records are then moved +> >> into folders (using a trigger) like file_92_myy depending on what month the +> >> record was created on the 68030. During normal operations there should not +> >> be more than 10 records at a time in the table, although during the course +> >> of a day a normal system will get about 50k records. I create 50000 records +> >> to simulate incoming traffic, since we don't have much traffic in the test +> >> lab. +> +> Really the right way to do housekeeping for a table like that is to +> VACUUM FULL (or better yet, TRUNCATE, if possible) immediately after +> discarding a batch of records. The VACUUM FULL will take very little +> time if it only has to repack <10 records. Plain VACUUM is likely to +> leave the table nearly empty but physically sizable, which is bad news +> from a statistical point of view: as the table fills up again, it won't +> get physically larger, thereby giving the planner no clue that it +> doesn't still have <10 records. This means the queries that process +> the 50K-record patch are going to get horrible plans :-( +> +> I'm not sure if autovacuum could be taught to do that --- it could +> perhaps launch a vacuum as soon as it notices a large fraction of the +> table got deleted, but do we really want to authorize it to launch +> VACUUM FULL? It'd be better to issue the vacuum synchronously +> as part of the batch updating script, I feel. + +I added this to the TODO section for autovacuum: + + o Do VACUUM FULL if table is nearly empty? + +I don't think autovacuum is every going to be smart enough to recycle +during the delete, especially since the rows can't be reused until the +transaction completes. + +One problem with VACUUM FULL would be autovacuum waiting for an +exclusive lock on the table. Anyway, it is documented now as a possible +issue. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Fri Mar 25 23:17:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 591FC5341B + for ; + Fri, 25 Mar 2005 23:17:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97230-08 + for ; + Fri, 25 Mar 2005 23:17:16 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 34C8B52A69 + for ; + Fri, 25 Mar 2005 23:17:15 +0000 (GMT) +Received: from 192.168.1.52 (fc1smp [66.93.38.87]) + by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id + j2PNE6kh022250; Fri, 25 Mar 2005 15:14:06 -0800 +Subject: Re: pg_autovacuum not having enough suction ? +From: "Joshua D. Drake" +Reply-To: jd@commandprompt.com +To: Bruce Momjian +Cc: Tom Lane , "Matthew T. O'Connor" , + Otto Blomqvist , + "pgsql-performance@postgresql.org" +In-Reply-To: <200503252313.j2PNDFA24795@candle.pha.pa.us> +References: <200503252313.j2PNDFA24795@candle.pha.pa.us> +Content-Type: text/plain +Organization: Joshua D. Drake +Date: Fri, 25 Mar 2005 15:17:06 -0800 +Message-Id: <1111792626.5783.11.camel@jd2.commandprompt.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.036 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/571 +X-Sequence-Number: 11276 + + +> > I'm not sure if autovacuum could be taught to do that --- it could +> > perhaps launch a vacuum as soon as it notices a large fraction of the +> > table got deleted, but do we really want to authorize it to launch +> > VACUUM FULL? It'd be better to issue the vacuum synchronously +> > as part of the batch updating script, I feel. +> +> I added this to the TODO section for autovacuum: +> +> o Do VACUUM FULL if table is nearly empty? + +We should never automatically launch a vacuum full. That seems like a +really bad idea. + +Sincerely, + +Joshua D. Drake + + +> +> I don't think autovacuum is every going to be smart enough to recycle +> during the delete, especially since the rows can't be reused until the +> transaction completes. +> +> One problem with VACUUM FULL would be autovacuum waiting for an +> exclusive lock on the table. Anyway, it is documented now as a possible +> issue. +> +-- +Command Prompt, Inc., Your PostgreSQL solutions company. 503-667-4564 +Custom programming, 24x7 support, managed services, and hosting +Open Source Authors: plPHP, pgManage, Co-Authors: plPerlNG +Reliable replication, Mammoth Replicator - http://www.commandprompt.com/ + + +From pgsql-performance-owner@postgresql.org Fri Mar 25 23:18:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 06E0E5348C + for ; + Fri, 25 Mar 2005 23:18:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98954-03 + for ; + Fri, 25 Mar 2005 23:18:11 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A30595341B + for ; + Fri, 25 Mar 2005 23:18:10 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2PNID1W016181; + Fri, 25 Mar 2005 18:18:13 -0500 (EST) +To: Bruce Momjian +Cc: "Matthew T. O'Connor" , + Otto Blomqvist , + "pgsql-performance@postgresql.org" +Subject: Re: pg_autovacuum not having enough suction ? +In-reply-to: <200503252313.j2PNDFA24795@candle.pha.pa.us> +References: <200503252313.j2PNDFA24795@candle.pha.pa.us> +Comments: In-reply-to Bruce Momjian + message dated "Fri, 25 Mar 2005 18:13:15 -0500" +Date: Fri, 25 Mar 2005 18:18:13 -0500 +Message-ID: <16180.1111792693@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/572 +X-Sequence-Number: 11277 + +Bruce Momjian writes: +> Tom Lane wrote: +>> I'm not sure if autovacuum could be taught to do that --- it could +>> perhaps launch a vacuum as soon as it notices a large fraction of the +>> table got deleted, but do we really want to authorize it to launch +>> VACUUM FULL? + +> One problem with VACUUM FULL would be autovacuum waiting for an +> exclusive lock on the table. Anyway, it is documented now as a possible +> issue. + +I don't care too much about autovacuum waiting awhile to get a lock. +I do care about other processes getting queued up behind it, though. + +Perhaps it would be possible to alter the normal lock queuing semantics +for this case, so that autovacuum's request doesn't block later +arrivals, and it can only get the lock when no one is interested in the +table. Of course, that might never happen, or by the time it does +there's no point in VACUUM FULL anymore :-( + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 25 23:21:30 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D98E15348A + for ; + Fri, 25 Mar 2005 23:21:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99847-07 + for ; + Fri, 25 Mar 2005 23:21:22 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) + by svr1.postgresql.org (Postfix) with ESMTP id 40C28534DE + for ; + Fri, 25 Mar 2005 23:21:21 +0000 (GMT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id j2PNLO826150; + Fri, 25 Mar 2005 18:21:24 -0500 (EST) +From: Bruce Momjian +Message-Id: <200503252321.j2PNLO826150@candle.pha.pa.us> +Subject: Re: pg_autovacuum not having enough suction ? +In-Reply-To: <16180.1111792693@sss.pgh.pa.us> +To: Tom Lane +Date: Fri, 25 Mar 2005 18:21:24 -0500 (EST) +Cc: "Matthew T. O'Connor" , + Otto Blomqvist , + "pgsql-performance@postgresql.org" +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/573 +X-Sequence-Number: 11278 + +Tom Lane wrote: +> Bruce Momjian writes: +> > Tom Lane wrote: +> >> I'm not sure if autovacuum could be taught to do that --- it could +> >> perhaps launch a vacuum as soon as it notices a large fraction of the +> >> table got deleted, but do we really want to authorize it to launch +> >> VACUUM FULL? +> +> > One problem with VACUUM FULL would be autovacuum waiting for an +> > exclusive lock on the table. Anyway, it is documented now as a possible +> > issue. +> +> I don't care too much about autovacuum waiting awhile to get a lock. +> I do care about other processes getting queued up behind it, though. +> +> Perhaps it would be possible to alter the normal lock queuing semantics +> for this case, so that autovacuum's request doesn't block later +> arrivals, and it can only get the lock when no one is interested in the +> table. Of course, that might never happen, or by the time it does +> there's no point in VACUUM FULL anymore :-( + +Can we issue a LOCK TABLE with a statement_timeout, and only do the +VACUUM FULL if we can get a lock quickly? That seems like a plan. + +The only problem is that you can't VACUUM FULL in a transaction: + + test=> create table test (x int); + CREATE TABLE + test=> insert into test values (1); + INSERT 0 1 + test=> begin; + BEGIN + test=> lock table test; + LOCK TABLE + test=> vacuum full; + ERROR: VACUUM cannot run inside a transaction block + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Fri Mar 25 23:31:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F01CC52A5D + for ; + Fri, 25 Mar 2005 23:31:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00928-07 + for ; + Fri, 25 Mar 2005 23:31:35 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D14653476 + for ; + Fri, 25 Mar 2005 23:31:33 +0000 (GMT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id C304830959; Sat, 26 Mar 2005 00:31:36 +0100 (MET) +From: "Otto Blomqvist" +X-Newsgroups: pgsql.performance +Subject: Re: pg_autovacuum not having enough suction ? +Date: Fri, 25 Mar 2005 15:34:00 -0800 +Organization: Hub.Org Networking Services +Lines: 49 +Message-ID: +References: <42430FA0.9080204@zeut.net> + <002b01c530c5$ad5a1620$e602a8c0@blomqvist> + <42435408.30303@zeut.net> <16054.1111791962@sss.pgh.pa.us> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.972 tagged_above=0 required=5 tests=AWL, + PRIORITY_NO_NAME +X-Spam-Level: +X-Archive-Number: 200503/574 +X-Sequence-Number: 11279 + +ok, Thanks a lot for your time guys ! I guess my table is pretty unusual +and thats why this problem has not surfaced until now. Better late then +never ;) I'll cron a "manual" vacuum full on the table. + + + +"Tom Lane" wrote in message +news:16054.1111791962@sss.pgh.pa.us... +> > Otto Blomqvist wrote: +> >> This table is basically a queue full of records waiting to get +transfered +> >> over from our 68030 system to the PG database. The records are then +moved +> >> into folders (using a trigger) like file_92_myy depending on what month +the +> >> record was created on the 68030. During normal operations there should +not +> >> be more than 10 records at a time in the table, although during the +course +> >> of a day a normal system will get about 50k records. I create 50000 +records +> >> to simulate incoming traffic, since we don't have much traffic in the +test +> >> lab. +> +> Really the right way to do housekeeping for a table like that is to +> VACUUM FULL (or better yet, TRUNCATE, if possible) immediately after +> discarding a batch of records. The VACUUM FULL will take very little +> time if it only has to repack <10 records. Plain VACUUM is likely to +> leave the table nearly empty but physically sizable, which is bad news +> from a statistical point of view: as the table fills up again, it won't +> get physically larger, thereby giving the planner no clue that it +> doesn't still have <10 records. This means the queries that process +> the 50K-record patch are going to get horrible plans :-( +> +> I'm not sure if autovacuum could be taught to do that --- it could +> perhaps launch a vacuum as soon as it notices a large fraction of the +> table got deleted, but do we really want to authorize it to launch +> VACUUM FULL? It'd be better to issue the vacuum synchronously +> as part of the batch updating script, I feel. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> + + + +From pgsql-performance-owner@postgresql.org Sat Mar 26 08:25:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 069985398C + for ; + Sat, 26 Mar 2005 08:25:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82486-03 + for ; + Sat, 26 Mar 2005 08:25:03 +0000 (GMT) +Received: from mail.tecarta.com (66.238.115.135.ptr.us.xo.net + [66.238.115.135]) + by svr1.postgresql.org (Postfix) with ESMTP id B7C8153988 + for ; + Sat, 26 Mar 2005 08:25:00 +0000 (GMT) +Received: from mail pickup service by mail.tecarta.com with Microsoft SMTPSVC; + Sat, 26 Mar 2005 00:27:55 -0800 +Received: from mail.tecarta.com ([192.168.160.2]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Sat, 26 Mar 2005 00:27:50 -0800 +Received: from barracuda.tecarta.com ([192.168.160.200]) + by mail.tecarta.com (SAVSMTP 3.1.0.29) with SMTP id + M2005032600275015232 + for ; + Sat, 26 Mar 2005 00:27:50 -0800 +X-ASG-Debug-ID: 1111825495-24092-0-0 +X-Barracuda-URL: http://192.168.160.200:8000/cgi-bin/mark.cgi +Received: from mail2 (mail2.hq.corp [192.168.160.6]) + by barracuda.tecarta.com (Spam Firewall) with SMTP id 26F092003DDA + for ; + Sat, 26 Mar 2005 00:24:55 -0800 (PST) +Received: from [192.168.0.13] ([63.206.203.145]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Sat, 26 Mar 2005 00:27:45 -0800 +Message-ID: <4244A90B.2030200@sfnet.cc> +Date: Sat, 26 Mar 2005 00:12:59 +0000 +From: Steve Poe +User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Joshua D. Drake" +Cc: performance pgsql +X-ASG-Orig-Subj: Re: [PERFORM] How to improve db performance with $7K? +Subject: Re: How to improve db performance with $7K? +References: <42443863.4040302@sfnet.cc> <4244B744.6020908@commandprompt.com> +In-Reply-To: <4244B744.6020908@commandprompt.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 26 Mar 2005 08:27:45.0959 (UTC) + FILETIME=[AFF5EB70:01C531DD] +X-Virus-Scanned: by Barracuda Spam Firewall at tecarta.com +X-Barracuda-Spam-Score: 0.84 +X-Barracuda-Spam-Status: No, SCORE=0.84 using global scores of TAG_LEVEL=4.0 + QUARANTINE_LEVEL=1000.0 KILL_LEVEL=7.0 tests=BAYES_44, + DATE_IN_PAST_06_12 +X-Barracuda-Spam-Report: Code version 2.64, rules version 2.1.2146 + Rule breakdown below pts rule name description + ---- ---------------------- ------------------------------------------- + -0.00 BAYES_44 BODY: Bayesian spam probability is 44 to 50% + [score: 0.4936] + 0.85 DATE_IN_PAST_06_12 Date: is 6 to 12 hours before Received: date +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.298 tagged_above=0 required=5 tests=AWL, + DATE_IN_PAST_06_12, FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/581 +X-Sequence-Number: 11286 + +You could build a dual opteron with 4 GB of ram, 12 10k raptor SATA +drives with a battery backed cache for about 7k or less. + +Okay. You trust SATA drives? I've been leary of them for a production +database. Pardon my ignorance, but what is a "battery backed cache"? I +know the drives have a built-in cache but I don't if that's the same. +Are the 12 drives internal or an external chasis? Could you point me to +a place that this configuration exist? + +> +> Or if they are not CPU bound just IO bound you could easily just +> add an external 12 drive array (even if scsi) for less than 7k. +> +I don't believe it is CPU bound. At our busiest hour, the CPU is idle +about 70% on average down to 30% idle at its heaviest. Context switching +averages about 4-5K per hour with momentary peaks to 25-30K for a +minute. Overall disk performance is poor (35mb per sec). + +Thanks for your input. + +Steve Poe + + + + + + +From pgsql-performance-owner@postgresql.org Sat Mar 26 00:59:24 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EDB35345E + for ; + Sat, 26 Mar 2005 00:59:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22574-05 + for ; + Sat, 26 Mar 2005 00:59:14 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E1855341F + for ; + Sat, 26 Mar 2005 00:59:13 +0000 (GMT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2Q0xHxa020357; + Fri, 25 Mar 2005 19:59:17 -0500 (EST) +To: Steve Poe +Cc: performance pgsql +Subject: Re: How to improve db performance with $7K? +In-reply-to: <42443863.4040302@sfnet.cc> +References: <42443863.4040302@sfnet.cc> +Comments: In-reply-to Steve Poe + message dated "Fri, 25 Mar 2005 16:12:19 +0000" +Date: Fri, 25 Mar 2005 19:59:17 -0500 +Message-ID: <20356.1111798757@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/576 +X-Sequence-Number: 11281 + +Steve Poe writes: +> Situation: An 24/7 animal hospital (100 employees) runs their business +> on Centos 3.3 (RHEL 3) Postgres 7.4.2 (because they have to) + +[ itch... ] Surely they could at least move to 7.4.7 without pain. +There are serious data-loss bugs known in 7.4.2. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Mar 26 01:03:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 71E5853358 + for ; + Sat, 26 Mar 2005 01:03:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24404-03 + for ; + Sat, 26 Mar 2005 01:03:10 +0000 (GMT) +Received: from mail.ofsloans.com (mail.ofsloans.com [208.187.153.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 5303F5334D + for ; + Sat, 26 Mar 2005 01:03:09 +0000 (GMT) +Message-ID: <4244B4C8.8010909@lashell.net> +Date: Fri, 25 Mar 2005 18:03:04 -0700 +From: Will LaShell +MIME-Version: 1.0 +To: Steve Poe +Cc: performance pgsql +Subject: Re: How to improve db performance with $7K? +References: <42443863.4040302@sfnet.cc> +In-Reply-To: <42443863.4040302@sfnet.cc> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/577 +X-Sequence-Number: 11282 + +You can purchase a whole new dual opteron 740, with 6 gigs of ram, a +case to match and 6 74 gig ultra320 sca drives for about $7k + +I know because that's what I bought one for 2 weeks ago. Using Tyan's +dual board. + +If you need some details and are willing to go that route, let me know +and I'll get you the information. + +Sincerely, + +Will LaShell + +Steve Poe wrote: + +> Situation: An 24/7 animal hospital (100 employees) runs their +> business on Centos 3.3 (RHEL 3) Postgres 7.4.2 (because they have to) +> off a 2-CPU Xeon 2.8MHz, 4GB of RAM, (3) SCSI disks RAID 0 (zcav value +> 35MB per sec). The databse is 11GB comprised over 100 tables and +> indexes from 1MB to 2GB in size. +> +> I recently told the hospital management team worst-case scenerio they +> need to get the database on its own drive array since the RAID0 is a +> disaster wating to happen. I said ideally a new dual AMD server with +> 6/7-disk configuration would be ideal for safety and performance, but +> they don't have $15K. I said a seperate drive array offer the balance +> of safety and performance. +> +> I have been given budget of $7K to accomplish a safer/faster database +> through hardware upgrades. The objective is to get a drive array, but +> I can use the budget any way I see fit to accomplish the goal. +> +> Since I am a dba novice, I did not physically build this server, nor +> did I write the application the hospital runs on, but I have the +> opportunity to make it better, I'd thought I should seek some advice +> from those who have been down this road before. Suggestions/ideas +> anyone? +> +> Thanks. +> +> Steve Poe +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend + + + +From pgsql-performance-owner@postgresql.org Sat Mar 26 01:13:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 38C9053358 + for ; + Sat, 26 Mar 2005 01:13:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25961-09 + for ; + Sat, 26 Mar 2005 01:13:37 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 25511534CE + for ; + Sat, 26 Mar 2005 01:13:37 +0000 (GMT) +Received: from [127.0.0.1] (clbb-248.saw.net [64.146.135.248]) + (authenticated bits=0) + by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id + j2Q1Ackh029964; Fri, 25 Mar 2005 17:10:39 -0800 +Message-ID: <4244B744.6020908@commandprompt.com> +Date: Fri, 25 Mar 2005 17:13:40 -0800 +From: "Joshua D. Drake" +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Steve Poe +Cc: performance pgsql +Subject: Re: How to improve db performance with $7K? +References: <42443863.4040302@sfnet.cc> +In-Reply-To: <42443863.4040302@sfnet.cc> +Content-Type: multipart/mixed; boundary="------------090105010705070105060205" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.04 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/578 +X-Sequence-Number: 11283 + +This is a multi-part message in MIME format. +--------------090105010705070105060205 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Steve Poe wrote: + +> Situation: An 24/7 animal hospital (100 employees) runs their +> business on Centos 3.3 (RHEL 3) Postgres 7.4.2 (because they have to) +> off a 2-CPU Xeon 2.8MHz, 4GB of RAM, (3) SCSI disks RAID 0 (zcav value +> 35MB per sec). The databse is 11GB comprised over 100 tables and +> indexes from 1MB to 2GB in size. +> +> I recently told the hospital management team worst-case scenerio they +> need to get the database on its own drive array since the RAID0 is a +> disaster wating to happen. I said ideally a new dual AMD server with +> 6/7-disk configuration would be ideal for safety and performance, but +> they don't have $15K. I said a seperate drive array offer the balance +> of safety and performance. +> +> I have been given budget of $7K to accomplish a safer/faster database +> through hardware upgrades. The objective is to get a drive array, but +> I can use the budget any way I see fit to accomplish the goal. + + +You could build a dual opteron with 4 GB of ram, 12 10k raptor SATA +drives with a battery backed cache for about 7k or less. + +Or if they are not CPU bound just IO bound you could easily just +add an external 12 drive array (even if scsi) for less than 7k. + + +Sincerely, + +Joshua D. Drake + + +> +> Since I am a dba novice, I did not physically build this server, nor +> did I write the application the hospital runs on, but I have the +> opportunity to make it better, I'd thought I should seek some advice +> from those who have been down this road before. Suggestions/ideas +> anyone? +> +> Thanks. +> +> Steve Poe +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend + + + +-- +Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC +Postgresql support, programming shared hosting and dedicated hosting. ++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com +PostgreSQL Replicator -- production quality replication for PostgreSQL + + +--------------090105010705070105060205 +Content-Type: text/x-vcard; charset=utf-8; + name="jd.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="jd.vcf" + +begin:vcard +fn:Joshua Drake +n:Drake;Joshua +org:Command Prompt, Inc. +adr:;;PO Box 215 ;Cascade Locks;OR;97014;US +email;internet:jd@commandprompt.com +title:Consultant +tel;work:503-667-4564 +tel;fax:503-210-0334 +x-mozilla-html:FALSE +url:http://www.commandprompt.com +version:2.1 +end:vcard + + +--------------090105010705070105060205-- + +From pgsql-performance-owner@postgresql.org Sun Mar 27 16:23:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EB47E534B9 + for ; + Sat, 26 Mar 2005 03:21:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37832-03 + for ; + Sat, 26 Mar 2005 03:21:13 +0000 (GMT) +Received: from r163ip.btv.lv (r163ip.btv.lv [217.198.224.163]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B5625341B + for ; + Sat, 26 Mar 2005 03:21:12 +0000 (GMT) +Received: from p4 (pIV.homenet [192.168.88.4]) + by r163ip.btv.lv (8.12.9/8.12.6) with ESMTP id j2Q3LGmv009749 + for ; + Sat, 26 Mar 2005 05:21:16 +0200 (EET) + (envelope-from postgres@bilteks.com) +From: "Alexander Kirpa" +To: pgsql-performance@postgresql.org +Date: Sat, 26 Mar 2005 05:21:25 +0200 +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Subject: Re: How to improve db performance with $7K? +Message-ID: <4244F155.6661.82A056DE@localhost> +X-mailer: Pegasus Mail for Win32 (v3.12c) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/591 +X-Sequence-Number: 11296 + +1. Buy for empty PCI-X Slot - 1 or dual channel SCSI-320 +hardware RAID controller, like MegaRAID SCSI 320-2X +(don't forget check driver for your OS) +plus battery backup +plus (optional) expand RAM to Maximum 256MB - approx $1K +2. Buy new MAXTOR drives - Atlas 15K II (4x36.7GB) - approx 4x$400. +3. SCSI 320 Cable set. +4. Old drives (2) use for OS (optional DB log) files in RAID1 mode, +possible over one channel of MegaRAID. +5. New drives (4+) in RAID10 mode for DB +6. Start tuning Postres + OS: more shared RAM etc. + +Best regards, + Alexander Kirpa + +From pgsql-performance-owner@postgresql.org Sat Mar 26 06:34:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AC34C52A9A + for ; + Sat, 26 Mar 2005 06:34:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56717-09 + for ; + Sat, 26 Mar 2005 06:34:01 +0000 (GMT) +Received: from vscan01.westnet.com.au (vscan01.westnet.com.au [203.10.1.131]) + by svr1.postgresql.org (Postfix) with ESMTP id 6FFA25392C + for ; + Sat, 26 Mar 2005 06:34:00 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by localhost (Postfix) with ESMTP id 867CA14CDCC; + Sat, 26 Mar 2005 14:33:15 +0800 (WST) +Received: from vscan01.westnet.com.au ([127.0.0.1]) + by localhost (vscan01.westnet.com.au [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 15605-01; Sat, 26 Mar 2005 14:31:14 +0800 (WST) +Received: from [202.72.133.22] (dsl-202-72-133-22.wa.westnet.com.au + [202.72.133.22]) + by vscan01.westnet.com.au (Postfix) with ESMTP id 3419A542AD; + Sat, 26 Mar 2005 14:31:13 +0800 (WST) +Message-ID: <424501DE.5010603@familyhealth.com.au> +Date: Sat, 26 Mar 2005 14:31:58 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Simon Riggs +Cc: Stephan Szabo , + Tom Lane , Karim Nassar , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> + <4243879B.10200@familyhealth.com.au> + <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <23515.1111763837@sss.pgh.pa.us> + <1111766478.11750.762.camel@localhost.localdomain> + <20050325082101.G4358@megazone.bigpanda.com> + <1111775050.11750.790.camel@localhost.localdomain> +In-Reply-To: <1111775050.11750.790.camel@localhost.localdomain> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/580 +X-Sequence-Number: 11285 + +> There is clear benefit from forcing them to be the same. In logical data +> terms, they *should* be the same. I don't check fruit.apple_grade +> against fruit_type.orange_grade. When would I want to make a check of +> that nature? If there is a reason, thats great, lets keep status quo +> then. +> +> I respect the effort and thought that has already gone into the +> implementation; I seek only to offer a very minor improvement based upon +> recent list issues. + +The main problem would be people getting errors when upgrading their +databases, or restoring from a backup, say. + +Chris + +From pgsql-performance-owner@postgresql.org Sat Mar 26 09:59:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 77FC15354F + for ; + Sat, 26 Mar 2005 09:59:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01565-07 + for ; + Sat, 26 Mar 2005 09:59:33 +0000 (GMT) +Received: from ns1.turtle-entertainment.de (ns1.turtle-entertainment.de + [193.41.200.20]) + by svr1.postgresql.org (Postfix) with ESMTP id AC13C538A7 + for ; + Sat, 26 Mar 2005 09:59:32 +0000 (GMT) +Received: from ip96.85.1311c-cud12k-02.ish.de ([62.143.85.96] + helo=mail.office.turtle-entertainment.de) + by ns1.turtle-entertainment.de with asmtp (Exim 3.22 #3 (Debian)) + id 1DF84c-0007AT-00; Sat, 26 Mar 2005 10:59:18 +0100 +Received: from ip19.1.1411j-cud12k-02.ish.de ([62.143.1.19] + helo=[192.168.100.5]) + by mail.office.turtle-entertainment.de with asmtp (Exim 3.22 #7 + (Debian)) id 1DF84b-0005oS-00; Sat, 26 Mar 2005 10:59:17 +0100 +Message-ID: <42453273.2060509@turtle-entertainment.de> +Date: Sat, 26 Mar 2005 10:59:15 +0100 +From: Bjoern Metzdorf +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Steve Poe +Cc: performance pgsql +Subject: Re: How to improve db performance with $7K? +References: <42443863.4040302@sfnet.cc> <4244B744.6020908@commandprompt.com> + <4244A90B.2030200@sfnet.cc> +In-Reply-To: <4244A90B.2030200@sfnet.cc> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.889 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO, NORMAL_HTTP_TO_IP, RCVD_IN_NJABL_DUL, + RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200503/582 +X-Sequence-Number: 11287 + +Hi Steve, + +> Okay. You trust SATA drives? I've been leary of them for a production +> database. Pardon my ignorance, but what is a "battery backed cache"? I +> know the drives have a built-in cache but I don't if that's the same. +> Are the 12 drives internal or an external chasis? Could you point me to +> a place that this configuration exist? + +Get 12 or 16 x 74GB Western Digital Raptor S-ATA drives, one 3ware +9500S-12 or two 3ware 9500S-8 raid controllers with a battery backup +unit (in case of power loss the controller saves unflushed data), a +decent tyan board for the existing dual xeon with 2 pci-x slots and a +matching 3U case for 12 drives (12 drives internal). + +Here in Germany chassis by Chenbro are quite popular, a matching one for +your needs would be the chenbro RM312 or RM414 +(http://61.30.15.60/product/product_preview.php?pid=90 and +http://61.30.15.60/product/product_preview.php?pid=95 respectively). + +Take 6 or 10 drives for Raid 10 pgdata, 2-drive Raid 1 for Transaction +logs (xlog), 2-drive Raid 1 for OS and Swap, and 2 spare disks. + +That should give you about 250 mb/s reads and 70 mb/s sustained write +rate with xfs. + +Regards, +Bjoern + +From pgsql-performance-owner@postgresql.org Sat Mar 26 21:16:48 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BE2A5392D + for ; + Sat, 26 Mar 2005 21:16:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42086-09 + for ; + Sat, 26 Mar 2005 21:16:43 +0000 (GMT) +Received: from mail.tecarta.com (66.238.115.135.ptr.us.xo.net + [66.238.115.135]) + by svr1.postgresql.org (Postfix) with ESMTP id 35592539B0 + for ; + Sat, 26 Mar 2005 21:16:42 +0000 (GMT) +Received: from mail pickup service by mail.tecarta.com with Microsoft SMTPSVC; + Sat, 26 Mar 2005 13:19:39 -0800 +Received: from mail.tecarta.com ([192.168.160.2]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Sat, 26 Mar 2005 13:19:37 -0800 +Received: from barracuda.tecarta.com ([192.168.160.200]) + by mail.tecarta.com (SAVSMTP 3.1.0.29) with SMTP id + M2005032613193715845 + for ; + Sat, 26 Mar 2005 13:19:37 -0800 +X-ASG-Debug-ID: 1111871802-32331-0-0 +X-Barracuda-URL: http://192.168.160.200:8000/cgi-bin/mark.cgi +Received: from mail2 (mail2.hq.corp [192.168.160.6]) + by barracuda.tecarta.com (Spam Firewall) with SMTP id 392CF20048E2 + for ; + Sat, 26 Mar 2005 13:16:42 -0800 (PST) +Received: from [192.168.0.13] ([63.206.203.145]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Sat, 26 Mar 2005 13:19:32 -0800 +Message-ID: <42455DEC.2080301@sfnet.cc> +Date: Sat, 26 Mar 2005 13:04:44 +0000 +From: Steve Poe +User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Josh Berkus +Cc: Bjoern Metzdorf , + performance pgsql +X-ASG-Orig-Subj: Re: [PERFORM] How to improve db performance with $7K? +Subject: Re: How to improve db performance with $7K? +References: <42443863.4040302@sfnet.cc> <4244A90B.2030200@sfnet.cc> + <42453273.2060509@turtle-entertainment.de> + <200503261255.59007.josh@agliodbs.com> +In-Reply-To: <200503261255.59007.josh@agliodbs.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 26 Mar 2005 21:19:32.0713 (UTC) + FILETIME=[80EFD590:01C53249] +X-Virus-Scanned: by Barracuda Spam Firewall at tecarta.com +X-Barracuda-Spam-Score: 0.84 +X-Barracuda-Spam-Status: No, SCORE=0.84 using global scores of TAG_LEVEL=4.0 + QUARANTINE_LEVEL=1000.0 KILL_LEVEL=7.0 tests=BAYES_44, + DATE_IN_PAST_06_12 +X-Barracuda-Spam-Report: Code version 2.64, rules version 2.1.2158 + Rule breakdown below pts rule name description + ---- ---------------------- ------------------------------------------- + -0.00 BAYES_44 BODY: Bayesian spam probability is 44 to 50% + [score: 0.4985] + 0.85 DATE_IN_PAST_06_12 Date: is 6 to 12 hours before Received: date +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.844 tagged_above=0 required=5 tests=AWL, + DATE_IN_PAST_06_12, FORGED_RCVD_HELO, NO_DNS_FOR_FROM +X-Spam-Level: +X-Archive-Number: 200503/586 +X-Sequence-Number: 11291 + +>Steve, can we clarify that you are not currently having any performance +>issues, you're just worried about failure? Recommendations should be based +>on whether improving applicaiton speed is a requirement ... + +Josh, + +The priorities are: 1)improve safety/failure-prevention, 2) improve +performance. + +The owner of the company wants greater performance (and, I concure to +certain degree), but the owner's vote is only 1/7 of the managment team. +And, the rest of the management team is not as focused on performance. +They all agree in safety/failure-prevention. + +Steve + + + + + + + +From pgsql-performance-owner@postgresql.org Sat Mar 26 21:31:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2923B534C8 + for ; + Sat, 26 Mar 2005 21:31:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47693-01 + for ; + Sat, 26 Mar 2005 21:31:18 +0000 (GMT) +Received: from mail.tecarta.com (66.238.115.135.ptr.us.xo.net + [66.238.115.135]) + by svr1.postgresql.org (Postfix) with ESMTP id D73D75343E + for ; + Sat, 26 Mar 2005 21:31:17 +0000 (GMT) +Received: from mail pickup service by mail.tecarta.com with Microsoft SMTPSVC; + Sat, 26 Mar 2005 13:34:14 -0800 +Received: from mail.tecarta.com ([192.168.160.2]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Sat, 26 Mar 2005 13:34:12 -0800 +Received: from barracuda.tecarta.com ([192.168.160.200]) + by mail.tecarta.com (SAVSMTP 3.1.0.29) with SMTP id + M2005032613341215857 + for ; + Sat, 26 Mar 2005 13:34:12 -0800 +X-ASG-Debug-ID: 1111872677-1796-0-0 +X-Barracuda-URL: http://192.168.160.200:8000/cgi-bin/mark.cgi +Received: from mail2 (mail2.hq.corp [192.168.160.6]) + by barracuda.tecarta.com (Spam Firewall) with SMTP id 2A79720048E1 + for ; + Sat, 26 Mar 2005 13:31:17 -0800 (PST) +Received: from [192.168.0.13] ([63.206.203.145]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Sat, 26 Mar 2005 13:34:08 -0800 +Message-ID: <42456158.3090404@sfnet.cc> +Date: Sat, 26 Mar 2005 13:19:20 +0000 +From: Steve Poe +User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Josh Berkus +Cc: performance pgsql +X-ASG-Orig-Subj: Re: [PERFORM] How to improve db performance with $7K? +Subject: Re: How to improve db performance with $7K? +References: <42443863.4040302@sfnet.cc> <4244A90B.2030200@sfnet.cc> + <42453273.2060509@turtle-entertainment.de> + <200503261255.59007.josh@agliodbs.com> +In-Reply-To: <200503261255.59007.josh@agliodbs.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 26 Mar 2005 21:34:08.0263 (UTC) + FILETIME=[8ACE2970:01C5324B] +X-Virus-Scanned: by Barracuda Spam Firewall at tecarta.com +X-Barracuda-Spam-Score: -0.58 +X-Barracuda-Spam-Status: No, SCORE=-0.58 using global scores of TAG_LEVEL=4.0 + QUARANTINE_LEVEL=1000.0 KILL_LEVEL=7.0 tests=BAYES_20, + DATE_IN_PAST_06_12 +X-Barracuda-Spam-Report: Code version 2.64, rules version 2.1.2159 + Rule breakdown below pts rule name description + ---- ---------------------- ------------------------------------------- + -1.43 BAYES_20 BODY: Bayesian spam probability is 20 to 30% + [score: 0.2298] + 0.85 DATE_IN_PAST_06_12 Date: is 6 to 12 hours before Received: date +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.867 tagged_above=0 required=5 tests=AWL, + DATE_IN_PAST_06_12, FORGED_RCVD_HELO, NO_DNS_FOR_FROM +X-Spam-Level: +X-Archive-Number: 200503/587 +X-Sequence-Number: 11292 + + +>The Chenbros are nice, but kinda pricey ($800) if Steve doesn't need the +>machine to be rackable. +> +>If your primary goal is redundancy, you may wish to consider the possibility +>of building a brand-new machine for $7k (you can do a lot of machine for +>$7000 if it doesn't have to be rackable) and re-configuring the old machine +>and using it as a replication or PITR backup. This would allow you to +>configure the new machine with only a moderate amount of hardware redundancy +>while still having 100% confidence in staying running. +> +> +> +Our servers are not racked, so a new one does not have to be. *If* it is +possible, I'd like to replace the main server with a new one. I could +tweak the new one the way I need it and work with the vendor to make +sure everything works well. In either case, I'll still need to test how +positioning of the tables/indexes across a raid10 will perform. I am +also waiting onProIV developers feedback. If their ProvIV modules will +not run under AMD64, or take advantage of the processor, then I'll stick +with the server we have. + +Steve Poe + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Sat Mar 26 15:55:45 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 23BA053730 + for ; + Sat, 26 Mar 2005 15:55:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73980-10 + for ; + Sat, 26 Mar 2005 15:55:35 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 879B6539F9 + for ; + Sat, 26 Mar 2005 15:55:35 +0000 (GMT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id A56413558E; Sat, 26 Mar 2005 07:55:39 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id A1B1C3558D; Sat, 26 Mar 2005 07:55:39 -0800 (PST) +Date: Sat, 26 Mar 2005 07:55:39 -0800 (PST) +From: Stephan Szabo +To: Karim Nassar +Cc: Simon Riggs , Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-Reply-To: <1111787264.9168.7.camel@k2.cet.nau.edu> +Message-ID: <20050326075020.P63597@megazone.bigpanda.com> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> + <4243879B.10200@familyhealth.com.au> <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <1111787264.9168.7.camel@k2.cet.nau.edu> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.108 tagged_above=0 required=5 tests=AWL, + UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200503/583 +X-Sequence-Number: 11288 + + +On Fri, 25 Mar 2005, Karim Nassar wrote: + +> On Fri, 2005-03-25 at 15:10 +0000, Simon Riggs wrote: +> > Karim: Did this happen? If not, can you drop and re-create and confirm +> > that you get the WARNING? If not, we have problems. +> +> No. Nor do I think that I should. SERIAL is shortcut for INTEGER, no? I +> think there is some other (TBD) problem causing my big seq scan. +> +> orfs=# ALTER TABLE measurement DROP CONSTRAINT measurement_id_int_sensor_meas_type_fkey; +> ALTER TABLE +> orfs=# ALTER TABLE ONLY measurement ADD CONSTRAINT measurement_id_int_sensor_meas_type_fkey +> orfs-# FOREIGN KEY (id_int_sensor_meas_type) REFERENCES int_sensor_meas_type(id_int_sensor_meas_type); +> ALTER TABLE +> orfs=# +> +> The add constraint statement comes directly from a pg_dump. +> +> For clarity, the table/indexes were created as such: +> +> CREATE TABLE int_sensor_meas_type( +> id_int_sensor_meas_type SERIAL PRIMARY KEY, +> id_sensor integer NOT NULL REFERENCES sensor, +> id_meas_type integer NOT NULL REFERENCES meas_type UNIQUE); +> +> CREATE TABLE measurement ( +> id_measurement SERIAL PRIMARY KEY, +> id_int_sensor_meas_type integer NOT NULL REFERENCES int_sensor_meas_type, +> datetime timestamp WITH TIME ZONE NOT NULL, +> value numeric(15,5) NOT NULL, +> created timestamp with time zone NOT NULL DEFAULT now(), +> created_by TEXT NOT NULL REFERENCES public.person(id_person)); +> +> CREATE INDEX measurement__id_int_sensor_meas_type_idx ON measurement(id_int_sensor_meas_type); + +That seems like it should be okay, hmm, what does something like: + +PREPARE test(int) AS SELECT 1 from measurement where +id_int_sensor_meas_type = $1 FOR UPDATE; +EXPLAIN ANALYZE EXECUTE TEST(1); + +give you as the plan? + +From pgsql-performance-owner@postgresql.org Sat Mar 26 19:33:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E7CF53920 + for ; + Sat, 26 Mar 2005 19:33:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21231-03 + for ; + Sat, 26 Mar 2005 19:32:59 +0000 (GMT) +Received: from mailgate2.nau.edu (mailgate2.nau.edu [134.114.96.59]) + by svr1.postgresql.org (Postfix) with ESMTP id DA62B53930 + for ; + Sat, 26 Mar 2005 19:32:57 +0000 (GMT) +Received: from CONVERSION-DAEMON.mailgate2.nau.edu by mailgate2.nau.edu + (PMDF V6.2-X17 #30770) id <0IDZ002014YX2P@mailgate2.nau.edu> for + pgsql-performance@postgresql.org; Sat, 26 Mar 2005 12:32:58 -0700 (MST) +Received: from k2.cet.nau.edu (net9-213.cet.nau.edu [134.114.9.213]) + by mailgate2.nau.edu (PMDF V6.2-X17 #30770) + with ESMTP id <0IDZ009DK4YXNW@mailgate2.nau.edu>; Sat, + 26 Mar 2005 12:32:57 -0700 (MST) +Date: Sat, 26 Mar 2005 12:36:28 -0700 +From: Karim Nassar +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <20050326075020.P63597@megazone.bigpanda.com> +To: Stephan Szabo +Cc: Simon Riggs , Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Message-id: <1111865788.9172.13.camel@k2.cet.nau.edu> +MIME-version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-type: text/plain +Content-transfer-encoding: 7BIT +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> <4243879B.10200@familyhealth.com.au> + <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <1111787264.9168.7.camel@k2.cet.nau.edu> + <20050326075020.P63597@megazone.bigpanda.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/584 +X-Sequence-Number: 11289 + +On Sat, 2005-03-26 at 07:55 -0800, Stephan Szabo wrote: +> That seems like it should be okay, hmm, what does something like: +> +> PREPARE test(int) AS SELECT 1 from measurement where +> id_int_sensor_meas_type = $1 FOR UPDATE; +> EXPLAIN ANALYZE EXECUTE TEST(1); +> +> give you as the plan? + + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------- + Seq Scan on measurement (cost=0.00..164559.16 rows=509478 width=6) + (actual time=11608.402..11608.402 rows=0 loops=1) + Filter: (id_int_sensor_meas_type = $1) + Total runtime: 11608.441 ms +(3 rows) + + +-- +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=- Mobile: (928) 699-9221 + + +From pgsql-performance-owner@postgresql.org Sat Mar 26 20:56:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7DE23537A4 + for ; + Sat, 26 Mar 2005 20:56:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37911-07 + for ; + Sat, 26 Mar 2005 20:56:37 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 6AA485379C + for ; + Sat, 26 Mar 2005 20:56:36 +0000 (GMT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7170307; Sat, 26 Mar 2005 12:58:30 -0800 +From: Josh Berkus +Organization: Aglio Database Solutions +To: Bjoern Metzdorf +Subject: Re: How to improve db performance with $7K? +Date: Sat, 26 Mar 2005 12:55:58 -0800 +User-Agent: KMail/1.6.2 +Cc: Steve Poe , + performance pgsql +References: <42443863.4040302@sfnet.cc> <4244A90B.2030200@sfnet.cc> + <42453273.2060509@turtle-entertainment.de> +In-Reply-To: <42453273.2060509@turtle-entertainment.de> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200503261255.59007.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, + NORMAL_HTTP_TO_IP +X-Spam-Level: +X-Archive-Number: 200503/585 +X-Sequence-Number: 11290 + +Bjoern, Josh, Steve, + +> Get 12 or 16 x 74GB Western Digital Raptor S-ATA drives, one 3ware +> 9500S-12 or two 3ware 9500S-8 raid controllers with a battery backup +> unit (in case of power loss the controller saves unflushed data), a +> decent tyan board for the existing dual xeon with 2 pci-x slots and a +> matching 3U case for 12 drives (12 drives internal). + +Based on both my testing and feedback from one of the WD Raptor engineers, +Raptors are still only optimal for 90% read applications. This makes them a +great buy for web applications (which are 95% read usually) but a bad choice +for OLTP applicaitons which sounds more like what Steve's describing. For +those, it would be better to get 6 quality SCSI drives than 12 Raptors. + +The reason for this is that SATA still doesn't do bi-directional traffic very +well (simultaneous read and write) and OSes and controllers simply haven't +caught up with the drive spec and features. WD hopes that in a year they +will be able to offer a Raptor that performs all operations as well as a 10K +SCSI drive, for 25% less ... but that's in the next generation of drives, +controllers and drivers. + +Steve, can we clarify that you are not currently having any performance +issues, you're just worried about failure? Recommendations should be based +on whether improving applicaiton speed is a requirement ... + +> Here in Germany chassis by Chenbro are quite popular, a matching one for +> your needs would be the chenbro RM312 or RM414 +> (http://61.30.15.60/product/product_preview.php?pid=90 and +> http://61.30.15.60/product/product_preview.php?pid=95 respectively). + +The Chenbros are nice, but kinda pricey ($800) if Steve doesn't need the +machine to be rackable. + +If your primary goal is redundancy, you may wish to consider the possibility +of building a brand-new machine for $7k (you can do a lot of machine for +$7000 if it doesn't have to be rackable) and re-configuring the old machine +and using it as a replication or PITR backup. This would allow you to +configure the new machine with only a moderate amount of hardware redundancy +while still having 100% confidence in staying running. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sat Mar 26 23:18:19 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DBDBE538BF + for ; + Sat, 26 Mar 2005 23:18:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70840-01 + for ; + Sat, 26 Mar 2005 23:18:16 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id AC781538DE + for ; + Sat, 26 Mar 2005 23:18:16 +0000 (GMT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 3238F358B9; Sat, 26 Mar 2005 15:18:16 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 307DA3537A; Sat, 26 Mar 2005 15:18:16 -0800 (PST) +Date: Sat, 26 Mar 2005 15:18:16 -0800 (PST) +From: Stephan Szabo +To: Karim Nassar +Cc: Simon Riggs , Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-Reply-To: <1111865788.9172.13.camel@k2.cet.nau.edu> +Message-ID: <20050326151658.D82144@megazone.bigpanda.com> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> + <4243879B.10200@familyhealth.com.au> <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <1111787264.9168.7.camel@k2.cet.nau.edu> + <20050326075020.P63597@megazone.bigpanda.com> + <1111865788.9172.13.camel@k2.cet.nau.edu> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/588 +X-Sequence-Number: 11293 + +On Sat, 26 Mar 2005, Karim Nassar wrote: + +> On Sat, 2005-03-26 at 07:55 -0800, Stephan Szabo wrote: +> > That seems like it should be okay, hmm, what does something like: +> > +> > PREPARE test(int) AS SELECT 1 from measurement where +> > id_int_sensor_meas_type = $1 FOR UPDATE; +> > EXPLAIN ANALYZE EXECUTE TEST(1); +> > +> > give you as the plan? +> +> QUERY PLAN +> ----------------------------------------------------------------------------------------------------------------------- +> Seq Scan on measurement (cost=0.00..164559.16 rows=509478 width=6) +> (actual time=11608.402..11608.402 rows=0 loops=1) +> Filter: (id_int_sensor_meas_type = $1) +> Total runtime: 11608.441 ms +> (3 rows) + +Hmm, has measurement been analyzed recently? You might want to see if +raising the statistics target on measurement.id_int_sensor_meas_type and +reanalyzing changes the estimated rows down from 500k. + + +From pgsql-performance-owner@postgresql.org Sun Mar 27 00:42:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CD4052A7A + for ; + Sun, 27 Mar 2005 00:42:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85306-10 + for ; + Sun, 27 Mar 2005 00:42:04 +0000 (GMT) +Received: from mailgate3.nau.edu (mailgate3.nau.edu [134.114.96.145]) + by svr1.postgresql.org (Postfix) with ESMTP id 7502B52A68 + for ; + Sun, 27 Mar 2005 00:42:03 +0000 (GMT) +Received: from CONVERSION-DAEMON.mailgate3.nau.edu by mailgate3.nau.edu + (PMDF V6.2-X17 #30845) id <0IDZ00201JA2GS@mailgate3.nau.edu> for + pgsql-performance@postgresql.org; Sat, 26 Mar 2005 17:42:06 -0700 (MST) +Received: from k2.cet.nau.edu (net9-213.cet.nau.edu [134.114.9.213]) + by mailgate3.nau.edu (PMDF V6.2-X17 #30845) + with ESMTP id <0IDZ008DRJ8S2A@mailgate3.nau.edu>; Sat, + 26 Mar 2005 17:41:16 -0700 (MST) +Date: Sat, 26 Mar 2005 17:44:47 -0700 +From: Karim Nassar +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <20050326151658.D82144@megazone.bigpanda.com> +To: Stephan Szabo +Cc: Simon Riggs , Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Message-id: <1111884288.27481.6.camel@k2.cet.nau.edu> +MIME-version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-type: text/plain +Content-transfer-encoding: 7BIT +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> <4243879B.10200@familyhealth.com.au> + <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <1111787264.9168.7.camel@k2.cet.nau.edu> + <20050326075020.P63597@megazone.bigpanda.com> + <1111865788.9172.13.camel@k2.cet.nau.edu> + <20050326151658.D82144@megazone.bigpanda.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/589 +X-Sequence-Number: 11294 + +On Sat, 2005-03-26 at 15:18 -0800, Stephan Szabo wrote: +> On Sat, 26 Mar 2005, Karim Nassar wrote: +> +> > On Sat, 2005-03-26 at 07:55 -0800, Stephan Szabo wrote: +> > > That seems like it should be okay, hmm, what does something like: +> > > +> > > PREPARE test(int) AS SELECT 1 from measurement where +> > > id_int_sensor_meas_type = $1 FOR UPDATE; +> > > EXPLAIN ANALYZE EXECUTE TEST(1); +> > > +> > > give you as the plan? +> > +> > QUERY PLAN +> > ----------------------------------------------------------------------------------------------------------------------- +> > Seq Scan on measurement (cost=0.00..164559.16 rows=509478 width=6) +> > (actual time=11608.402..11608.402 rows=0 loops=1) +> > Filter: (id_int_sensor_meas_type = $1) +> > Total runtime: 11608.441 ms +> > (3 rows) +> +> Hmm, has measurement been analyzed recently? You might want to see if +> raising the statistics target on measurement.id_int_sensor_meas_type and +> reanalyzing changes the estimated rows down from 500k. + +orfs=# ALTER TABLE measurement ALTER COLUMN id_int_sensor_meas_type SET STATISTICS 1000; +ALTER TABLE +orfs=# VACUUM FULL ANALYZE VERBOSE; + +INFO: free space map: 52 relations, 13501 pages stored; 9760 total pages needed +DETAIL: Allocated FSM size: 1000 relations + 300000 pages = 1864 kB shared memory. +VACUUM +orfs=# PREPARE test(int) AS SELECT 1 from measurement where +orfs-# id_int_sensor_meas_type = $1 FOR UPDATE; +PREPARE +orfs=# EXPLAIN ANALYZE EXECUTE TEST(1); + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------- + Seq Scan on measurement (cost=0.00..164559.16 rows=509478 width=6) (actual time=8948.452..8948.452 rows=0 loops=1) + Filter: (id_int_sensor_meas_type = $1) + Total runtime: 8948.494 ms +(3 rows) + +orfs=# EXPLAIN ANALYZE EXECUTE TEST(1); + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------- + Seq Scan on measurement (cost=0.00..164559.16 rows=509478 width=6) (actual time=3956.616..3956.616 rows=0 loops=1) + Filter: (id_int_sensor_meas_type = $1) + Total runtime: 3956.662 ms +(3 rows) + + + +Some improvement. Even better once it's cached. Row estimate didn't +change. Is this the best I can expect? Is there any other optimizations +I am missing? + +TIA, + +-- +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=- Mobile: (928) 699-9221 + + +From pgsql-performance-owner@postgresql.org Sun Mar 27 16:05:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 422B153488 + for ; + Sun, 27 Mar 2005 16:05:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35392-03 + for ; + Sun, 27 Mar 2005 15:05:37 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 510CB5348A + for ; + Sun, 27 Mar 2005 16:05:36 +0100 (BST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id F08AD36330; Sun, 27 Mar 2005 07:05:38 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id EE8FE3632F; Sun, 27 Mar 2005 07:05:38 -0800 (PST) +Date: Sun, 27 Mar 2005 07:05:38 -0800 (PST) +From: Stephan Szabo +To: Karim Nassar +Cc: Simon Riggs , Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-Reply-To: <1111884288.27481.6.camel@k2.cet.nau.edu> +Message-ID: <20050327070313.K29183@megazone.bigpanda.com> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> + <4243879B.10200@familyhealth.com.au> <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <1111787264.9168.7.camel@k2.cet.nau.edu> + <20050326075020.P63597@megazone.bigpanda.com> + <1111865788.9172.13.camel@k2.cet.nau.edu> + <20050326151658.D82144@megazone.bigpanda.com> + <1111884288.27481.6.camel@k2.cet.nau.edu> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/590 +X-Sequence-Number: 11295 + + +On Sat, 26 Mar 2005, Karim Nassar wrote: + +> On Sat, 2005-03-26 at 15:18 -0800, Stephan Szabo wrote: +> > On Sat, 26 Mar 2005, Karim Nassar wrote: +> > +> > > On Sat, 2005-03-26 at 07:55 -0800, Stephan Szabo wrote: +> > > > That seems like it should be okay, hmm, what does something like: +> > > > +> > > > PREPARE test(int) AS SELECT 1 from measurement where +> > > > id_int_sensor_meas_type = $1 FOR UPDATE; +> > > > EXPLAIN ANALYZE EXECUTE TEST(1); +> > > > +> > > > give you as the plan? +> > > +> > > QUERY PLAN +> > > ----------------------------------------------------------------------------------------------------------------------- +> > > Seq Scan on measurement (cost=0.00..164559.16 rows=509478 width=6) +> > > (actual time=11608.402..11608.402 rows=0 loops=1) +> > > Filter: (id_int_sensor_meas_type = $1) +> > > Total runtime: 11608.441 ms +> > > (3 rows) +> > +> > Hmm, has measurement been analyzed recently? You might want to see if +> > raising the statistics target on measurement.id_int_sensor_meas_type and +> > reanalyzing changes the estimated rows down from 500k. +> +> orfs=# ALTER TABLE measurement ALTER COLUMN id_int_sensor_meas_type SET STATISTICS 1000; +> ALTER TABLE +> orfs=# VACUUM FULL ANALYZE VERBOSE; +> +> INFO: free space map: 52 relations, 13501 pages stored; 9760 total pages needed +> DETAIL: Allocated FSM size: 1000 relations + 300000 pages = 1864 kB shared memory. +> VACUUM +> orfs=# PREPARE test(int) AS SELECT 1 from measurement where +> orfs-# id_int_sensor_meas_type = $1 FOR UPDATE; +> PREPARE +> orfs=# EXPLAIN ANALYZE EXECUTE TEST(1); +> QUERY PLAN +> --------------------------------------------------------------------------------------------------------------------- +> Seq Scan on measurement (cost=0.00..164559.16 rows=509478 width=6) (actual time=8948.452..8948.452 rows=0 loops=1) +> Filter: (id_int_sensor_meas_type = $1) +> Total runtime: 8948.494 ms +> (3 rows) +> +> orfs=# EXPLAIN ANALYZE EXECUTE TEST(1); +> QUERY PLAN +> --------------------------------------------------------------------------------------------------------------------- +> Seq Scan on measurement (cost=0.00..164559.16 rows=509478 width=6) (actual time=3956.616..3956.616 rows=0 loops=1) +> Filter: (id_int_sensor_meas_type = $1) +> Total runtime: 3956.662 ms +> (3 rows) +> +> +> +> Some improvement. Even better once it's cached. Row estimate didn't +> change. Is this the best I can expect? Is there any other optimizations +> I am missing? + +I'm not sure, really. Running a seq scan for each removed row in the +referenced table doesn't seem like a particularly good plan in general +though, especially if the average number of rows being referenced isn't +on the order of 500k per value. I don't know what to look at next though. + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 11:22:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3DCBE529D4 + for ; + Mon, 28 Mar 2005 11:22:47 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98494-08 + for ; + Mon, 28 Mar 2005 10:22:38 +0000 (GMT) +Received: from cmailm1.svr.pol.co.uk (cmailm1.svr.pol.co.uk [195.92.193.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 3266353B77 + for ; + Mon, 28 Mar 2005 11:22:37 +0100 (BST) +Received: from modem-4021.llama.dialup.pol.co.uk ([217.135.191.181] + helo=192.168.0.102) by cmailm1.svr.pol.co.uk with esmtp (Exim 4.41) + id 1DFrO5-0000W2-Ju; Mon, 28 Mar 2005 11:22:25 +0100 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Stephan Szabo +Cc: Karim Nassar , Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: <20050327070313.K29183@megazone.bigpanda.com> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111715131.9085.174.camel@k2.cet.nau.edu> + <3750.1111715318@sss.pgh.pa.us> <4243879B.10200@familyhealth.com.au> + <20845.1111733900@sss.pgh.pa.us> + <1111763448.11750.730.camel@localhost.localdomain> + <1111787264.9168.7.camel@k2.cet.nau.edu> + <20050326075020.P63597@megazone.bigpanda.com> + <1111865788.9172.13.camel@k2.cet.nau.edu> + <20050326151658.D82144@megazone.bigpanda.com> + <1111884288.27481.6.camel@k2.cet.nau.edu> + <20050327070313.K29183@megazone.bigpanda.com> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Mon, 28 Mar 2005 11:21:03 +0100 +Message-Id: <1112005263.11750.886.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/600 +X-Sequence-Number: 11305 + +On Sun, 2005-03-27 at 07:05 -0800, Stephan Szabo wrote: +> On Sat, 26 Mar 2005, Karim Nassar wrote: +> > Some improvement. Even better once it's cached. Row estimate didn't +> > change. Is this the best I can expect? Is there any other optimizations +> > I am missing? +> +> I'm not sure, really. Running a seq scan for each removed row in the +> referenced table doesn't seem like a particularly good plan in general +> though, especially if the average number of rows being referenced isn't +> on the order of 500k per value. I don't know what to look at next though. +> + +Karim, please... + +run the EXPLAIN after doing + SET enable_seqscan = off + +Thanks, + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 21:24:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 583DB53360 + for ; + Mon, 28 Mar 2005 21:24:13 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68782-03 + for ; + Mon, 28 Mar 2005 20:24:04 +0000 (GMT) +Received: from mail.tecarta.com (66.238.115.135.ptr.us.xo.net + [66.238.115.135]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A74553351 + for ; + Mon, 28 Mar 2005 21:24:03 +0100 (BST) +Received: from mail pickup service by mail.tecarta.com with Microsoft SMTPSVC; + Mon, 28 Mar 2005 12:27:00 -0800 +Received: from mail.tecarta.com ([192.168.160.2]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Mon, 28 Mar 2005 12:26:55 -0800 +Received: from barracuda.tecarta.com ([192.168.160.200]) + by mail.tecarta.com (SAVSMTP 3.1.0.29) with SMTP id + M2005032812265518764 + for ; + Mon, 28 Mar 2005 12:26:55 -0800 +X-ASG-Debug-ID: 1112041440-7339-0-0 +X-Barracuda-URL: http://192.168.160.200:8000/cgi-bin/mark.cgi +Received: from mail2 (mail2.hq.corp [192.168.160.6]) + by barracuda.tecarta.com (Spam Firewall) with SMTP id F008D2004907 + for ; + Mon, 28 Mar 2005 12:24:00 -0800 (PST) +Received: from [192.168.0.13] ([63.206.203.145]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Mon, 28 Mar 2005 12:26:51 -0800 +Message-ID: <4247F48F.8090308@sfnet.cc> +Date: Mon, 28 Mar 2005 12:11:59 +0000 +From: Steve Poe +User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: Merlin Moncure , + alex@neteconomist.com, pgsql-performance@postgresql.org +X-ASG-Orig-Subj: Re: [PERFORM] which dual-CPU hardware/OS is fastest for + PostgreSQL? +Subject: Re: which dual-CPU hardware/OS is fastest for PostgreSQL? +References: <6EE64EF3AB31D5448D0007DD34EEB3412A75B4@Herge.rcsinc.local> + <8764zb353a.fsf@stark.xeocode.com> +In-Reply-To: <8764zb353a.fsf@stark.xeocode.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 28 Mar 2005 20:26:51.0923 (UTC) + FILETIME=[79C90E30:01C533D4] +X-Virus-Scanned: by Barracuda Spam Firewall at tecarta.com +X-Barracuda-Spam-Score: -2.65 +X-Barracuda-Spam-Status: No, SCORE=-2.65 using global scores of TAG_LEVEL=4.0 + QUARANTINE_LEVEL=1000.0 KILL_LEVEL=7.0 tests=BAYES_01, + DATE_IN_PAST_06_12 +X-Barracuda-Spam-Report: Code version 2.64, rules version 2.1.2208 + Rule breakdown below pts rule name description + ---- ---------------------- ------------------------------------------- + -3.50 BAYES_01 BODY: Bayesian spam probability is 1 to 10% + [score: 0.0214] + 0.85 DATE_IN_PAST_06_12 Date: is 6 to 12 hours before Received: date +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.336 tagged_above=0 required=5 tests=AWL, + DATE_IN_PAST_06_12, FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/611 +X-Sequence-Number: 11316 + +Greg Stark wrote: + +>"Merlin Moncure" writes: +> +> +> +>>Alex wrote: +>> +>> +>>>Without starting too much controvesy I hope, I would seriously +>>>recommend you evaluate the AMCC Escalade 9500S SATA controller. +>>> +>>> +>. +> +> +>>At the risk of shaming myself with another 'me too' post, I'd like to +>>say that my experiences back this up 100%. The Escalade controllers are +>>excellent and the Raptor drives are fast and reliable (so far). +>> +>> +>. +> +>I assume AMCC == 3ware now? +> +>Has anyone verified that fsync is safe on these controllers? Ie, that they +>aren't caching writes and "lying" about the write completing like IDE +>drives oft +> +> + +For those who speak highly of the Escalade controllers and/Raptor SATA +drives, how is the database being utilized, OLTP or primarily read +access? This is good information I am learning, but I also see the need +to understand the context of how the hardware is being used. + +Steve Poe + + +From pgsql-performance-owner@postgresql.org Sun Apr 3 03:44:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 69FDA53A98 + for ; + Mon, 28 Mar 2005 15:14:56 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56566-06 + for ; + Mon, 28 Mar 2005 14:14:46 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6796D53A7C + for ; + Mon, 28 Mar 2005 15:14:45 +0100 (BST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 2937C30952; Mon, 28 Mar 2005 16:14:48 +0200 (MET DST) +From: Hannes Dorbath +X-Newsgroups: pgsql.performance +Subject: Re: Query Optimizer Failure / Possible Bug +Date: Mon, 28 Mar 2005 16:14:44 +0200 +Organization: Hub.Org Networking Services +Lines: 58 +Message-ID: +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +In-Reply-To: +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200504/33 +X-Sequence-Number: 11430 + +hm, a few days and not a single reply :| + +any more information needed? test data? simplified test case? anything? + + +thanks + + +Hannes Dorbath wrote: +> The query and the corresponding EXPLAIN is at +> +> http://hannes.imos.net/query.txt +> +> I'd like to use the column q.replaced_serials for multiple calculations +> in the SELECT clause, but every time it is referenced there in some way +> the whole query in the FROM clause returning q is executed again. +> +> This doesn't make sense to me at all and eats performance. +> +> If this wasn't clear enough, for every +> +> q.replaced_serials AS some_column +> +> in the SELECT clause there is new block of +> +> --------------------------------------------------------------- +> -> Aggregate (cost=884.23..884.23 rows=1 width=0) +> -> Nested Loop (cost=0.00..884.23 rows=1 width=0) +> -> Index Scan using ix_rma_ticket_serials_replace on +> rma_ticket_serials rts (cost=0.00..122.35 +> rows=190 width=4) +> Index Cond: ("replace" = false) +> -> Index Scan using pk_serials on serials s +> (cost=0.00..3.51 rows=1 width=4) +> Index Cond: (s.serial_id = "outer".serial_id) +> Filter: ((article_no = $0) AND (delivery_id = $1)) +> --------------------------------------------------------------- +> +> in the EXPLAIN result. +> +> For those who wonder why I do this FROM (SELECT...). I was searching for +> a way to use the result of an subselect for multiple calculations in the +> SELECT clause and return that calculation results as individual columns. +> +> I tested a bit further and found out that PG behaves the same in case q +> is a view. This makes me wonder how efficient the optimizer can work +> with views - or even worse - nested views. +> +> Tested and reproduced on PG 7.4.1 linux and 8.0.0 win32. +> +> +> Thanks in advance, +> Hannes Dorbath + +-- +imos Gesellschaft fuer Internet-Marketing und Online-Services mbH +Alfons-Feifel-Str. 9 // D-73037 Goeppingen // Stauferpark Ost +Tel: 07161 93339-14 // Fax: 07161 93339-99 // Internet: www.imos.net + +From pgsql-performance-owner@postgresql.org Mon Mar 28 16:34:52 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3541852954 + for ; + Mon, 28 Mar 2005 16:34:51 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80590-07 + for ; + Mon, 28 Mar 2005 15:34:42 +0000 (GMT) +Received: from mail.tpgi.com.au (mail5.tpgi.com.au [203.12.160.101]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A27553376 + for ; + Mon, 28 Mar 2005 16:34:40 +0100 (BST) +Received: from [192.168.1.1] (220-245-99-226-qld-pppoe.tpgi.com.au + [220.245.99.226]) (authenticated bits=0) + by mail.tpgi.com.au (8.12.10/8.12.10) with ESMTP id j2SFYc99010542 + for ; Tue, 29 Mar 2005 01:34:38 +1000 +Message-ID: <4248240E.7030805@wildcash.com> +Date: Tue, 29 Mar 2005 01:34:38 +1000 +From: Rudi Starcevic +Reply-To: tech@wildcash.com +Organization: Internet Media Productions +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.7.5) Gecko/20050105 Debian/1.7.5-1 +X-Accept-Language: en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: NFS RAID 0/5 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-TPG-Antivirus: Passed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.365 tagged_above=0 required=5 tests=SUBJ_ALL_CAPS +X-Spam-Level: +X-Archive-Number: 200503/601 +X-Sequence-Number: 11306 + +Hi, + +I have a web app using PostgreSQL which indexes, searches and +streams/downloads online movies. +I think I have a problem with NFS and RAID, it is not strictly +PostgreSQL but closely linked and I know +many people on this list are experienced with this technology. Apologies +if it is off topic. +Sometimes it is hard to not be the Developer, Database and System +Administrator all rolled into one. + +I have a FreeBSD box with 1TB disk space RAID 5, 800GB is used. +This is mount via NFS onto Debian Linux running Apache/PHP/PostgreSQL. + +I have a script which loads the directory structure etc. into the database. +As users surf the site web pages are generated by selecting from the +database as per a standard web app. +The server is on a 100mbit link and has reached up to 80mbits/s in the +past not using NFS or RAID. + +The problem is when users start to stream/download the content the load +averages go through the roof. +Sometimes as high as 300. + +I can only see mostly Apache processes running, up to 2000 is the max. +limit. +Even after 200 Apache connections the load avg. is over 10. + +Could it be that using RAID 5 and NFS is causing the high load avg. on +the Linux web servers? +I have a machine with RAID 0 but not ready for a day or so. + +I will soon need to move the databases onto the NFS partition and am +concerned it will increase my problem. + +Any advise much appreciated. +Thank you. +Regards, +Rudi + + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 16:44:56 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 409F35336F + for ; + Mon, 28 Mar 2005 16:44:55 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82979-10 + for ; + Mon, 28 Mar 2005 15:44:46 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id 18BF453376 + for ; + Mon, 28 Mar 2005 16:44:45 +0100 (BST) +Received: (qmail 26641 invoked from network); 28 Mar 2005 15:44:50 -0000 +Received: from host-209.149.56.238.nashville.net (HELO ?10.0.1.2?) + (209.149.56.238) by 0 with SMTP; 28 Mar 2005 15:44:50 -0000 +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v619.2) +Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed +Message-Id: <85e32fe05043b0bc0e94258bd9160024@sitening.com> +Content-Transfer-Encoding: quoted-printable +Cc: pgsql-performance@postgresql.org +From: Thomas F.O'Connell +Subject: Re: Configuration/Tuning of server/DB +Date: Mon, 28 Mar 2005 09:44:49 -0600 +To: Reid Thompson +X-Mailer: Apple Mail (2.619.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/602 +X-Sequence-Number: 11307 + +Reid, + +There are a few very valuable tuning documents that are part of the =20 +established PostgreSQL-related literature. You don't mention which =20 +version of postgres you'll be running, but here are the documents =20 +you'll find useful: + +postgresql.conf +7.4: =20 +http://www.varlena.com/varlena/GeneralBits/Tidbits/=20 +annotated_conf_e.html +8.0: http://www.powerpostgresql.com/Downloads/annotated_conf_80.html + +general tuning +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +-tfo + +-- +Thomas F. O'Connell +Co-Founder, Information Architect +Sitening, LLC + +Strategic Open Source =97 Open Your i=99 + +http://www.sitening.com/ +110 30th Avenue North, Suite 6 +Nashville, TN 37203-6320 +615-260-0005 + +On Mar 24, 2005, at 1:46 PM, Reid Thompson wrote: + +> Using information found on the web, I've come up with some =20 +> configuration and tuning parameters for a server/db that we will be =20= + +> implementing. I was wondering if I could generate some feedback as to = +=20 +> configuration and tuning so that I could compare my estimations with =20= + +> those of others. +> +> Host is AIX 5.1 with 4 cpu's and 4 GB ram. Postgresql will be sharing = +=20 +> this machine with other processes. Storage is an EMC storage array. =20= + +> The DB itself is very simple. Two tables, one with 40-45 columns ( =20= + +> largest column will likely contain no more than 32 chars of data ), =20= + +> the other with less than 5 columns ( largest column will contain no =20= + +> more than 20 chars data ). Expected transactions will be along the =20= + +> order of ~600K +- 100K inserts and ~600K +-200K updates per week. +> +> Thanks +> +> ---------------------------(end of =20 +> broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to =20 +> majordomo@postgresql.org + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 17:27:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 69F4F53377 + for ; + Mon, 28 Mar 2005 17:27:43 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98115-01 + for ; + Mon, 28 Mar 2005 16:27:42 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id E9FA15332C + for ; + Mon, 28 Mar 2005 17:27:39 +0100 (BST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 6A79735BDB; Mon, 28 Mar 2005 08:27:36 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 6896435BD0; Mon, 28 Mar 2005 08:27:36 -0800 (PST) +Date: Mon, 28 Mar 2005 08:27:36 -0800 (PST) +From: Stephan Szabo +To: Karim A Nassar +Cc: Simon Riggs , Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-Reply-To: +Message-ID: <20050328082645.X95787@megazone.bigpanda.com> +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/603 +X-Sequence-Number: 11308 + +On Mon, 28 Mar 2005, Karim A Nassar wrote: + +> On Mon, 28 Mar 2005, Simon Riggs wrote: +> > run the EXPLAIN after doing +> > SET enable_seqscan = off +> +> The results I previously supplied were searching for a non-existent +> value, so I have provided output for both cases. +> +> *** +> *** Searching for non-existent value +> *** +> +> orfs=# PREPARE test2(int) AS SELECT 1 from measurement where +> orfs-# id_int_sensor_meas_type = $1 FOR UPDATE; +> PREPARE +> orfs=# EXPLAIN ANALYZE EXECUTE TEST2(1); +> QUERY PLAN +> -------------------------------------------------------------------------- +> Seq Scan on measurement +> (cost=0.00..164559.16 rows=509478 width=6) +> (actual time=6421.849..6421.849 rows=0 loops=1) +> Filter: (id_int_sensor_meas_type = $1) +> Total runtime: 6421.917 ms +> (3 rows) +> +> orfs=# SET enable_seqscan = off; + +I think you have to prepare with enable_seqscan=off, because it effects +how the query is planned and prepared. + + +From pgsql-performance-owner@postgresql.org Sun Apr 3 03:47:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 168D1533DD + for ; + Mon, 28 Mar 2005 17:37:13 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00732-01 + for ; + Mon, 28 Mar 2005 16:37:04 +0000 (GMT) +Received: from mailgate2.nau.edu (mailgate2.nau.edu [134.114.96.59]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A9FC533E4 + for ; + Mon, 28 Mar 2005 17:37:03 +0100 (BST) +Received: from CONVERSION-DAEMON.mailgate2.nau.edu by mailgate2.nau.edu + (PMDF V6.2-X17 #30770) id <0IE200H01M5QXM@mailgate2.nau.edu> for + pgsql-performance@postgresql.org; Mon, 28 Mar 2005 09:37:03 -0700 (MST) +Received: from dagobah.cet.nau.edu (dagobah.cet.nau.edu [134.114.64.8]) + by mailgate2.nau.edu (PMDF V6.2-X17 #30770) + with ESMTP id <0IE2005FSM5Q4J@mailgate2.nau.edu>; Mon, + 28 Mar 2005 09:37:02 -0700 (MST) +Received: from coruscant (coruscant [134.114.64.2]) + by dagobah.cet.nau.edu (8.11.7p1+Sun/8.11.6) with ESMTP id j2SGawV18175; + Mon, 28 Mar 2005 09:36:58 -0700 (MST) +Date: Mon, 28 Mar 2005 09:37:01 -0700 (MST) +From: Karim A Nassar +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <20050328082645.X95787@megazone.bigpanda.com> +To: Stephan Szabo +Cc: Karim A Nassar , + Simon Riggs , Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Message-id: +MIME-version: 1.0 +Content-type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200504/36 +X-Sequence-Number: 11433 + +On Mon, 28 Mar 2005, Stephan Szabo wrote: +> > On Mon, 28 Mar 2005, Simon Riggs wrote: +> > > run the EXPLAIN after doing +> > > SET enable_seqscan = off + +... + +> I think you have to prepare with enable_seqscan=off, because it +> effects how the query is planned and prepared. + +orfs=# SET enable_seqscan = off; +SET +orfs=# PREPARE test2(int) AS SELECT 1 from measurement where +orfs-# id_int_sensor_meas_type = $1 FOR UPDATE; +PREPARE +orfs=# EXPLAIN ANALYZE EXECUTE TEST2(1); -- non-existent + +QUERY PLAN +------------------------------------------------------------------------- + Index Scan using measurement__id_int_sensor_meas_type_idx on measurement + (cost=0.00..883881.49 rows=509478 width=6) + (actual time=29.207..29.207 rows=0 loops=1) + Index Cond: (id_int_sensor_meas_type = $1) + Total runtime: 29.277 ms +(3 rows) + +orfs=# EXPLAIN ANALYZE EXECUTE TEST2(197); -- existing value + +QUERY PLAN +------------------------------------------------------------------------- + Index Scan using measurement__id_int_sensor_meas_type_idx on measurement + (cost=0.00..883881.49 rows=509478 width=6) + (actual time=12.903..37478.167 rows=509478 loops=1) + Index Cond: (id_int_sensor_meas_type = $1) + Total runtime: 38113.338 ms +(3 rows) + +-- +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=- Mobile: (928) 699-9221 + + + + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 18:36:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A342552A5F + for ; + Mon, 28 Mar 2005 18:36:52 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18341-07 + for ; + Mon, 28 Mar 2005 17:36:49 +0000 (GMT) +Received: from mir3-fs.mir3.com (unknown [216.74.11.46]) + by svr1.postgresql.org (Postfix) with ESMTP id F296452A3E + for ; + Mon, 28 Mar 2005 18:36:46 +0100 (BST) +Received: from amateljan.mirlogic.com ([172.16.2.68]) by mir3-fs.mir3.com with + Microsoft SMTPSVC(5.0.2195.5329); Mon, 28 Mar 2005 09:37:51 -0800 +Subject: Re: Delete query takes exorbitant amount of time +From: Mark Lewis +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <4009.1111717976@sss.pgh.pa.us> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <2630.1111711927@sss.pgh.pa.us> + <1111713798.23412.3.camel@amateljan.mirlogic.com> + <4009.1111717976@sss.pgh.pa.us> +Content-Type: text/plain +Organization: MIR3, Inc. +Message-Id: <1112031350.23412.131.camel@amateljan.mirlogic.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.4 (1.4.4-3) +Date: Mon, 28 Mar 2005 09:35:50 -0800 +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 28 Mar 2005 17:37:52.0130 (UTC) + FILETIME=[DDFF6E20:01C533BC] +X-Virus-Scanned: by amavisd-new at hub.org +X-Archive-Number: 200503/604 +X-Sequence-Number: 11309 + +Tom Lane Wrote: +> Hmm ... I wonder how hard it would be to teach EXPLAIN ANALYZE to show +> the runtime expended in each trigger when the statement is of a kind +> that has triggers. We couldn't break down the time *within* the +> triggers, but even this info would help a lot in terms of finger +> pointing ... +> +> Seq Scan on ... (nn.nnn ms) +> Trigger foo: nn.mmm ms +> Trigger bar: nn.mmm ms +> Total time: nn.mmm ms + + +So I got the latest from CVS on Friday night to see how hard it would be +to implement this, but it turns out that Tom has already committed the +improvement, so I'm in Tom's fan club today. I imported my test dataset +and was almost immediately able to track down the cause of my +performance problem. + +Thanks! +Mark Lewis + + +From pgsql-performance-owner@postgresql.org Tue Mar 29 05:31:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9680D5363E + for ; + Tue, 29 Mar 2005 05:31:45 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91281-08 + for ; + Tue, 29 Mar 2005 04:31:36 +0000 (GMT) +Received: from mail.tecarta.com (66.238.115.135.ptr.us.xo.net + [66.238.115.135]) + by svr1.postgresql.org (Postfix) with ESMTP id 65A1D53313 + for ; + Tue, 29 Mar 2005 05:31:35 +0100 (BST) +Received: from mail pickup service by mail.tecarta.com with Microsoft SMTPSVC; + Mon, 28 Mar 2005 20:34:30 -0800 +Received: from mail.tecarta.com ([192.168.160.2]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Mon, 28 Mar 2005 20:34:28 -0800 +Received: from barracuda.tecarta.com ([192.168.160.200]) + by mail.tecarta.com (SAVSMTP 3.1.0.29) with SMTP id + M2005032820342719796 + for ; + Mon, 28 Mar 2005 20:34:27 -0800 +X-ASG-Debug-ID: 1112070542-3425-4-0 +X-Barracuda-URL: http://192.168.160.200:8000/cgi-bin/mark.cgi +Received: from mail2 (mail2.hq.corp [192.168.160.6]) + by barracuda.tecarta.com (Spam Firewall) with SMTP id 7C73D2029F3D + for ; + Mon, 28 Mar 2005 20:29:02 -0800 (PST) +Received: from [192.168.0.13] ([63.206.203.145]) by mail.tecarta.com with + Microsoft SMTPSVC(6.0.3790.0); Mon, 28 Mar 2005 17:51:39 -0800 +Message-ID: <424840AE.3050200@sfnet.cc> +Date: Mon, 28 Mar 2005 17:36:46 +0000 +From: Steve Poe +User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Cott Lang +Cc: pgsql-performance@postgresql.org +X-ASG-Orig-Subj: Re: [PERFORM] How to improve db performance with $7K? +Subject: Re: How to improve db performance with $7K? +References: <42443863.4040302@sfnet.cc> <4244A90B.2030200@sfnet.cc> + <42453273.2060509@turtle-entertainment.de> + <200503261255.59007.josh@agliodbs.com> <42455DEC.2080301@sfnet.cc> + <1112049794.23284.29.camel@localhost.localdomain> +In-Reply-To: <1112049794.23284.29.camel@localhost.localdomain> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 29 Mar 2005 01:51:39.0381 (UTC) + FILETIME=[D9372A50:01C53401] +X-Virus-Scanned: by Barracuda Spam Firewall at tecarta.com +X-Barracuda-Spam-Score: -4.55 +X-Barracuda-Spam-Status: No, SCORE=-4.55 using global scores of TAG_LEVEL=4.0 + QUARANTINE_LEVEL=1000.0 KILL_LEVEL=7.0 tests=BAYES_00, + DATE_IN_PAST_06_12 +X-Barracuda-Spam-Report: Code version 2.64, rules version 2.1.2212 + Rule breakdown below pts rule name description + ---- ---------------------- ------------------------------------------- + -5.40 BAYES_00 BODY: Bayesian spam probability is 0 to 1% + [score: 0.0011] + 0.85 DATE_IN_PAST_06_12 Date: is 6 to 12 hours before Received: date +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.33 tagged_above=0 required=5 tests=AWL, + DATE_IN_PAST_06_12, FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/623 +X-Sequence-Number: 11328 + +Cott Lang wrote: + +>Have you already considered application/database tuning? Adding +>indexes? shared_buffers large enough? etc. +> +>Your database doesn't seem that large for the hardware you've already +>got. I'd hate to spend $7k and end up back in the same boat. :) +> +> +Cott, + +I agree with you. Unfortunately, I am not the developer of the +application. The vendor uses ProIV which connects via ODBC. The vendor +could certain do some tuning and create more indexes where applicable. I +am encouraging the vendor to take a more active role and we work +together on this. + +With hardware tuning, I am sure we can do better than 35Mb per sec. Also +moving the top 3 or 5 tables and indexes to their own slice of a RAID10 +and moving pg_xlog to its own drive will help too. + +Since you asked about tuned settings, here's what we're using: + +kernel.shmmax = 1073741824 +shared_buffers = 10000 +sort_mem = 8192 +vacuum_mem = 65536 +effective_cache_size = 65536 + + +Steve Poe + + + + + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 19:22:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 340A45296A + for ; + Mon, 28 Mar 2005 19:22:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34780-02 + for ; + Mon, 28 Mar 2005 18:22:02 +0000 (GMT) +Received: from fdd00lnhub.fds.com (external.fds.com [208.15.90.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 27139531C6 + for ; + Mon, 28 Mar 2005 19:22:00 +0100 (BST) +Subject: Sluggish server performance +To: pgsql-performance@postgresql.org +X-Mailer: Lotus Notes Release 6.5 September 18, 2003 +Message-ID: + +From: Patrick Hatcher +Date: Mon, 28 Mar 2005 10:20:54 -0800 +X-MIMETrack: Serialize by Router on FDD00LNHUB/FSG/SVR/FDD(Release 6.5.2|June + 01, 2004) at 03/28/2005 01:20:27 PM +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.421 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/605 +X-Sequence-Number: 11310 + + + + + +Pg: 7.4.5 +RH 7.3 +Raid 0+1 (200G 15k RPM) +Quad Xeon +8G ram + +95% Read-only +5% - read-write + +I'm experiencing extreme load issues on my machine anytime I have more than +40 users connected to the database. The majority of the users appear to be +in an idle state according TOP, but if more than3 or more queries are ran +the system slows to a crawl. The queries don't appear to the root cause +because they run fine when the load drops. I also doing routine vacuuming +on the tables. + +Is there some place I need to start looking for the issues bogging down the +server? + + +Here are some of my settings. I can provide more as needed: + + +cat /proc/sys/kernel/shmmax +175013888 + +max_connections = 100 + +#--------------------------------------------------------------------------- +# RESOURCE USAGE (except WAL) +#--------------------------------------------------------------------------- + +# - Memory - + +shared_buffers = 2000 # min 16, at least max_connections*2, 8KB +each +sort_mem = 12288 # min 64, size in KB +#vacuum_mem = 8192 # min 1024, size in KB + +# - Free Space Map - + +max_fsm_pages = 3000000 # min max_fsm_relations*16, 6 bytes each +max_fsm_relations = 500 # min 100, ~50 bytes each + + +#--------------------------------------------------------------------------- +# WRITE AHEAD LOG +#--------------------------------------------------------------------------- + +# - Settings - + +#fsync = true # turns forced synchronization on or off +#wal_sync_method = fsync # the default varies across platforms: + # fsync, fdatasync, open_sync, or +open_datasync +wal_buffers = 32 # min 4, 8KB each + +# - Checkpoints - + +checkpoint_segments = 50 # in logfile segments, min 1, 16MB each +checkpoint_timeout = 1800 # range 30-3600, in seconds + + +# - Planner Cost Constants - + +effective_cache_size = 262144 # typically 8KB each +#effective_cache_size = 625000 # typically 8KB each +random_page_cost = 2 # units are one sequential page fetch cost +#cpu_tuple_cost = 0.01 # (same) +#cpu_index_tuple_cost = 0.001 # (same) +#cpu_operator_cost = 0.0025 # (same) + + +Patrick Hatcher + + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 19:39:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0418553208 + for ; + Mon, 28 Mar 2005 19:39:50 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37749-07 + for ; + Mon, 28 Mar 2005 18:39:40 +0000 (GMT) +Received: from mars.interactivemediafactory.net (mars.imfeurope.net + [194.2.222.161]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D11053202 + for ; + Mon, 28 Mar 2005 19:39:36 +0100 (BST) +Received: from JC-8600.directinfos.com (localhost [127.0.0.1]) + by mars.interactivemediafactory.net (8.12.11/8.12.11) with ESMTP id + j2SIdVRf061164; Mon, 28 Mar 2005 20:39:32 +0200 (CEST) + (envelope-from jc@directinfos.com) +Message-Id: + <6.2.0.14.0.20050328203405.052aa7c0@pop.interactivemediafactory.net> +X-Mailer: QUALCOMM Windows Eudora Version 6.2.0.14 +Date: Mon, 28 Mar 2005 20:39:21 +0200 +To: Patrick Hatcher +From: Jacques Caron +Subject: Re: Sluggish server performance +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: + +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/606 +X-Sequence-Number: 11311 + +Hi, + +At 20:20 28/03/2005, Patrick Hatcher wrote: +>I'm experiencing extreme load issues on my machine anytime I have more than +>40 users connected to the database. The majority of the users appear to be +>in an idle state according TOP, but if more than3 or more queries are ran +>the system slows to a crawl. The queries don't appear to the root cause +>because they run fine when the load drops. I also doing routine vacuuming +>on the tables. +> +>Is there some place I need to start looking for the issues bogging down the +>server? + +Check that your queries use optimal plans, which usually (but not always) +means they should use indexes rather than sequential scans. You can check +for this by using EXPLAIN or EXPLAIN ANALYZE . You can also +check the pg_stat_* and pg_statio_* tables to get a feel of what kind of +accesses are done. You also might want to find out if your system is +limited by IO or by the CPU. Most probably the former. + +You can also check the "performance tips" section of the manual. + +Also you shared_buffers setting seems to be pretty low given your +configuration. + +Hope that helps, + +Jacques. + + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 19:39:58 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DAFFE53234 + for ; + Mon, 28 Mar 2005 19:39:53 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38277-05 + for ; + Mon, 28 Mar 2005 18:39:51 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id D7B9953230 + for ; + Mon, 28 Mar 2005 19:39:49 +0100 (BST) +Received: from 192.168.1.52 (fc1smp [66.93.38.87]) + by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id + j2SIaWkh032444; Mon, 28 Mar 2005 10:36:32 -0800 +Subject: Re: Sluggish server performance +From: "Joshua D. Drake" +Reply-To: jd@commandprompt.com +To: Patrick Hatcher +Cc: pgsql-performance@postgresql.org +In-Reply-To: + +References: + +Content-Type: text/plain +Organization: Joshua D. Drake +Date: Mon, 28 Mar 2005 10:39:48 -0800 +Message-Id: <1112035188.26232.28.camel@jd2.commandprompt.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.036 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/607 +X-Sequence-Number: 11312 + +On Mon, 2005-03-28 at 10:20 -0800, Patrick Hatcher wrote: +> +> +> +> Pg: 7.4.5 +> RH 7.3 +> Raid 0+1 (200G 15k RPM) +> Quad Xeon +> 8G ram +> +> 95% Read-only +> 5% - read-write +> +> I'm experiencing extreme load issues on my machine anytime I have more than +> 40 users connected to the database. The majority of the users appear to be +> in an idle state according TOP, but if more than3 or more queries are ran +> the system slows to a crawl. The queries don't appear to the root cause +> because they run fine when the load drops. I also doing routine vacuuming +> on the tables. +> +> Is there some place I need to start looking for the issues bogging down the +> server? + + +Well your shared buffers seems a little low but beyond that you may have +a couple of queries that run fine until you get into a highly concurrent +situation. + +I would turn on statement, duration and pid logging. See if there is +a query that takes say 400ms, if that query needs to be executed before +a bunch of other queries then you will get immediately slow down in a +highly concurrent environment. + +Also I didn't see your statistics target listed... What level is that +at? + +Lastly you may be able to get away with a lower random_page_cost. + +Sincerely, + +Joshua D. Drake + + +> +> +> Here are some of my settings. I can provide more as needed: +> +> +> cat /proc/sys/kernel/shmmax +> 175013888 +> +> max_connections = 100 +> +> #--------------------------------------------------------------------------- +> # RESOURCE USAGE (except WAL) +> #--------------------------------------------------------------------------- +> +> # - Memory - +> +> shared_buffers = 2000 # min 16, at least max_connections*2, 8KB +> each +> sort_mem = 12288 # min 64, size in KB +> #vacuum_mem = 8192 # min 1024, size in KB +> +> # - Free Space Map - +> +> max_fsm_pages = 3000000 # min max_fsm_relations*16, 6 bytes each +> max_fsm_relations = 500 # min 100, ~50 bytes each +> +> +> #--------------------------------------------------------------------------- +> # WRITE AHEAD LOG +> #--------------------------------------------------------------------------- +> +> # - Settings - +> +> #fsync = true # turns forced synchronization on or off +> #wal_sync_method = fsync # the default varies across platforms: +> # fsync, fdatasync, open_sync, or +> open_datasync +> wal_buffers = 32 # min 4, 8KB each +> +> # - Checkpoints - +> +> checkpoint_segments = 50 # in logfile segments, min 1, 16MB each +> checkpoint_timeout = 1800 # range 30-3600, in seconds +> +> +> # - Planner Cost Constants - +> +> effective_cache_size = 262144 # typically 8KB each +> #effective_cache_size = 625000 # typically 8KB each +> random_page_cost = 2 # units are one sequential page fetch cost +> #cpu_tuple_cost = 0.01 # (same) +> #cpu_index_tuple_cost = 0.001 # (same) +> #cpu_operator_cost = 0.0025 # (same) +> +> +> Patrick Hatcher +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +-- +Command Prompt, Inc., Your PostgreSQL solutions company. 503-667-4564 +Custom programming, 24x7 support, managed services, and hosting +Open Source Authors: plPHP, pgManage, Co-Authors: plPerlNG +Reliable replication, Mammoth Replicator - http://www.commandprompt.com/ + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 20:27:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C20D25331D + for ; + Mon, 28 Mar 2005 20:27:39 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50593-08 + for ; + Mon, 28 Mar 2005 19:27:32 +0000 (GMT) +Received: from cmailg1.svr.pol.co.uk (cmailg1.svr.pol.co.uk [195.92.195.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 7728353321 + for ; + Mon, 28 Mar 2005 20:27:30 +0100 (BST) +Received: from modem-2351.lynx.dialup.pol.co.uk ([217.135.201.47] + helo=192.168.0.102) by cmailg1.svr.pol.co.uk with esmtp (Exim 4.14) + id 1DFztN-0000zU-KB; Mon, 28 Mar 2005 20:27:17 +0100 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Karim A Nassar +Cc: Stephan Szabo , + Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Mon, 28 Mar 2005 20:25:54 +0100 +Message-Id: <1112037954.11750.903.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/608 +X-Sequence-Number: 11313 + +On Mon, 2005-03-28 at 09:37 -0700, Karim A Nassar wrote: +> On Mon, 28 Mar 2005, Stephan Szabo wrote: +> > > On Mon, 28 Mar 2005, Simon Riggs wrote: +> > > > run the EXPLAIN after doing +> > > > SET enable_seqscan = off +> +> ... +> +> > I think you have to prepare with enable_seqscan=off, because it +> > effects how the query is planned and prepared. +> +> orfs=# SET enable_seqscan = off; +> SET +> orfs=# PREPARE test2(int) AS SELECT 1 from measurement where +> orfs-# id_int_sensor_meas_type = $1 FOR UPDATE; +> PREPARE +> orfs=# EXPLAIN ANALYZE EXECUTE TEST2(1); -- non-existent +> +> QUERY PLAN +> ------------------------------------------------------------------------- +> Index Scan using measurement__id_int_sensor_meas_type_idx on measurement +> (cost=0.00..883881.49 rows=509478 width=6) +> (actual time=29.207..29.207 rows=0 loops=1) +> Index Cond: (id_int_sensor_meas_type = $1) +> Total runtime: 29.277 ms +> (3 rows) +> +> orfs=# EXPLAIN ANALYZE EXECUTE TEST2(197); -- existing value +> +> QUERY PLAN +> ------------------------------------------------------------------------- +> Index Scan using measurement__id_int_sensor_meas_type_idx on measurement +> (cost=0.00..883881.49 rows=509478 width=6) +> (actual time=12.903..37478.167 rows=509478 loops=1) +> Index Cond: (id_int_sensor_meas_type = $1) +> Total runtime: 38113.338 ms +> (3 rows) +> + +"That process starts upon the supposition that when you have eliminated +all which is impossible, then whatever remains, however improbable, must +be the truth." - Sherlock Holmes + +Well, based upon the evidence so far, the Optimizer got it right: + +Normal +SeqScan, value=1 elapsed= 6.4s cost=164559 +SeqScan, value=197 elapsed=28.1s cost=164559 + +SeqScan=off +IndexScan, value=1 elapsed= 29ms cost=883881 +IndexScan, value=197 elapsed=38.1s cost=883881 + +With SeqScan=off the index is used, proving that it has been correctly +defined for use in queries. + +The FK CASCADE delete onto measurement will only be triggered by the +deletion of a real row, so the actual value will be the time taken. This +is longer than a SeqScan, so the Optimizer is correct. + +My guess is that Measurement has a greatly non-uniform distribution of +values and that 197 is one of the main values. Other values exist in the +lookup table, but are very infrequently occurring in the larger table. + +Karim, +Please do: + +select id_int_sensor_meas_type, count(*) +from measurement +group by id_int_sensor_meas_type +order by count(*) desc; + +Best Regards, Simon Riggs + + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 20:46:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 407A752A7A + for ; + Mon, 28 Mar 2005 20:46:35 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58423-06 + for ; + Mon, 28 Mar 2005 19:46:33 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id C6E8752A43 + for ; + Mon, 28 Mar 2005 20:46:32 +0100 (BST) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [64.81.245.111] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7175592; Mon, 28 Mar 2005 11:48:26 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Hannes Dorbath +Subject: Re: Query Optimizer Failure / Possible Bug +Date: Mon, 28 Mar 2005 11:51:17 -0800 +User-Agent: KMail/1.7.1 +Cc: pgsql-performance@postgresql.org +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200503281151.17344.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/609 +X-Sequence-Number: 11314 + +Hannes, + +> The query and the corresponding EXPLAIN is at +> +> http://hannes.imos.net/query.txt + +The problem is that you're using a complex corellated sub-select in the SELECT +clause: + + SELECT + d.delivery_id, + da.article_no, + da.amount, + ( + SELECT + COUNT(*) + FROM + serials s + INNER JOIN rma_ticket_serials rts ON ( + s.serial_id = rts.serial_id + ) + WHERE + s.article_no = da.article_no AND + s.delivery_id = d.delivery_id AND + rts.replace = FALSE + ) AS replaced_serials + +This means that the planner pretty much has to iterate over the subquery, +running it once for each row in the result set. If you want the optimizer +to use a JOIN structure instead, put the subselect in the FROM clause. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sun Apr 3 03:47:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CE7C52AA7 + for ; + Mon, 28 Mar 2005 21:03:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61005-07 + for ; + Mon, 28 Mar 2005 20:03:20 +0000 (GMT) +Received: from mailgate3.nau.edu (mailgate3.nau.edu [134.114.96.145]) + by svr1.postgresql.org (Postfix) with ESMTP id ED1B452A7C + for ; + Mon, 28 Mar 2005 21:03:19 +0100 (BST) +Received: from CONVERSION-DAEMON.mailgate3.nau.edu by mailgate3.nau.edu + (PMDF V6.2-X17 #30845) id <0IE200C01VPGY8@mailgate3.nau.edu> for + pgsql-performance@postgresql.org; Mon, 28 Mar 2005 13:03:19 -0700 (MST) +Received: from dagobah.cet.nau.edu (dagobah.cet.nau.edu [134.114.64.8]) + by mailgate3.nau.edu (PMDF V6.2-X17 #30845) + with ESMTP id <0IE200079VPE6R@mailgate3.nau.edu>; Mon, + 28 Mar 2005 13:03:15 -0700 (MST) +Received: from coruscant (coruscant [134.114.64.2]) + by dagobah.cet.nau.edu (8.11.7p1+Sun/8.11.6) with ESMTP id j2SK39824059; + Mon, 28 Mar 2005 13:03:09 -0700 (MST) +Date: Mon, 28 Mar 2005 13:03:12 -0700 (MST) +From: Karim A Nassar +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <1112037954.11750.903.camel@localhost.localdomain> +To: Simon Riggs +Cc: Karim A Nassar , + Stephan Szabo , Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Message-id: +MIME-version: 1.0 +Content-type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200504/35 +X-Sequence-Number: 11432 + +> Well, based upon the evidence so far, the Optimizer got it right: + +Agreed. So, this means that the answer to my original question is "that +delete gonna take a long time"? + +Seems that there is still something wrong. From what I can tell from +everyones questions, the FK constraint on measurement is causing multiple +seq scans for each value deleted from int_sensor_meas_type. However, when +deleting a single value, the FK check should use the index, so my ~190 +deletes *should* be fast, no? + +> IndexScan, value=1 elapsed= 29ms cost=883881 + +190 * 29ms is much less than 40 minutes. What am I missing here? + + +> Karim, +> Please do: +> +> select id_int_sensor_meas_type, count(*) +> from measurement +> group by id_int_sensor_meas_type +> order by count(*) desc; + +id_int_sensor_meas_type | count +-------------------------+-------- + 31 | 509478 + 30 | 509478 + 206 | 509478 + 205 | 509478 + 204 | 509478 + 40 | 509478 + 39 | 509478 + 197 | 509478 + 35 | 509478 + 34 | 509478 + 33 | 509478 + 32 | 509478 + 41 | 509477 + +This sample dataset has 13 measurements from a weather station over 3 +years, hence the even distribution. + + +Continued thanks, +-- +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=- Mobile: (928) 699-9221 + + + + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 21:09:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FE1353351 + for ; + Mon, 28 Mar 2005 21:09:42 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63032-09 + for ; + Mon, 28 Mar 2005 20:09:38 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BF595331E + for ; + Mon, 28 Mar 2005 21:09:37 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DG0YD-0005sp-00; Mon, 28 Mar 2005 15:09:29 -0500 +To: "Merlin Moncure" +Cc: , +Subject: Re: which dual-CPU hardware/OS is fastest for PostgreSQL? +References: <6EE64EF3AB31D5448D0007DD34EEB3412A75B4@Herge.rcsinc.local> +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A75B4@Herge.rcsinc.local> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 28 Mar 2005 15:09:29 -0500 +Message-ID: <8764zb353a.fsf@stark.xeocode.com> +Lines: 20 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/610 +X-Sequence-Number: 11315 + + +"Merlin Moncure" writes: + +> Alex wrote: +> > Without starting too much controvesy I hope, I would seriously +> > recommend you evaluate the AMCC Escalade 9500S SATA controller. +... +> At the risk of shaming myself with another 'me too' post, I'd like to +> say that my experiences back this up 100%. The Escalade controllers are +> excellent and the Raptor drives are fast and reliable (so far). +... + +I assume AMCC == 3ware now? + +Has anyone verified that fsync is safe on these controllers? Ie, that they +aren't caching writes and "lying" about the write completing like IDE +drives often do by default? + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 21:57:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 008AA5322E + for ; + Mon, 28 Mar 2005 21:57:28 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79662-02 + for ; + Mon, 28 Mar 2005 20:57:18 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 31AAA52A5F + for ; + Mon, 28 Mar 2005 21:57:17 +0100 (BST) +Received: from 192.168.1.52 (fc1smp [66.93.38.87]) + by hosting.commandprompt.com (8.12.8/8.12.8) with ESMTP id + j2SKrqkh015951; Mon, 28 Mar 2005 12:53:52 -0800 +Subject: Re: which dual-CPU hardware/OS is fastest for PostgreSQL? +From: "Joshua D. Drake" +Reply-To: jd@commandprompt.com +To: Greg Stark +Cc: Merlin Moncure , + alex@neteconomist.com, pgsql-performance@postgresql.org +In-Reply-To: <8764zb353a.fsf@stark.xeocode.com> +References: <6EE64EF3AB31D5448D0007DD34EEB3412A75B4@Herge.rcsinc.local> + <8764zb353a.fsf@stark.xeocode.com> +Content-Type: text/plain +Organization: Joshua D. Drake +Date: Mon, 28 Mar 2005 12:57:08 -0800 +Message-Id: <1112043428.26232.43.camel@jd2.commandprompt.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.035 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/612 +X-Sequence-Number: 11317 + + +> I assume AMCC == 3ware now? +> +> Has anyone verified that fsync is safe on these controllers? Ie, that they +> aren't caching writes and "lying" about the write completing like IDE +> drives often do by default? + +The higher end AMCC/3ware controllers actually warn you about using +write-cache. You have to explicitly turn it on within the controller +bios. + +They also have optional battery backed cache. + +Sincerely, + +Joshua D. Drake + + + +> +-- +Command Prompt, Inc., Your PostgreSQL solutions company. 503-667-4564 +Custom programming, 24x7 support, managed services, and hosting +Open Source Authors: plPHP, pgManage, Co-Authors: plPerlNG +Reliable replication, Mammoth Replicator - http://www.commandprompt.com/ + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 22:06:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C74C53487 + for ; + Mon, 28 Mar 2005 22:05:59 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78869-10 + for ; + Mon, 28 Mar 2005 21:05:58 +0000 (GMT) +Received: from flake.decibel.org (natpool.bovine.net [67.100.216.14]) + by svr1.postgresql.org (Postfix) with ESMTP id 389905322E + for ; + Mon, 28 Mar 2005 22:05:57 +0100 (BST) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 9D40B1548D; Mon, 28 Mar 2005 15:05:59 -0600 (CST) +Date: Mon, 28 Mar 2005 15:05:59 -0600 +From: "Jim C. Nasby" +To: matt@followers.net +Cc: pgsql-performance@postgresql.org +Subject: Re: Preventing query from hogging server +Message-ID: <20050328210559.GC51784@decibel.org> +References: <42431001.36c6643c.1b4b.ffffd505@mx.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <42431001.36c6643c.1b4b.ffffd505@mx.gmail.com> +X-Operating-System: FreeBSD 4.11-RELEASE i386 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.057 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/613 +X-Sequence-Number: 11318 + +On Thu, Mar 24, 2005 at 01:07:39PM -0600, Matthew Nuzum wrote: +> I've tried `nice psql` in the past and I don't think that had much impact, +> but I haven't tried it on this query. + +On linux, nice will only help if the query is CPU-bound. On FreeBSD, +nice affects I/O scheduling, as well as CPU, so it's a more effective +means of limiting the impact of large queries. I don't know how other +OS's handle this. +-- +Jim C. Nasby, Database Consultant decibel@decibel.org +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 Mar 28 22:09:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B863752A76 + for ; + Mon, 28 Mar 2005 22:09:03 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82207-04 + for ; + Mon, 28 Mar 2005 21:08:59 +0000 (GMT) +Received: from cmailg1.svr.pol.co.uk (cmailg1.svr.pol.co.uk [195.92.195.171]) + by svr1.postgresql.org (Postfix) with ESMTP id F22F352A5F + for ; + Mon, 28 Mar 2005 22:08:58 +0100 (BST) +Received: from modem-2674.llama.dialup.pol.co.uk ([217.135.186.114] + helo=192.168.0.102) by cmailg1.svr.pol.co.uk with esmtp (Exim 4.14) + id 1DG1Td-0000IM-92; Mon, 28 Mar 2005 22:08:49 +0100 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Karim A Nassar +Cc: Stephan Szabo , + Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Mon, 28 Mar 2005 22:07:25 +0100 +Message-Id: <1112044045.11750.919.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/614 +X-Sequence-Number: 11319 + +On Mon, 2005-03-28 at 13:03 -0700, Karim A Nassar wrote: +> > Well, based upon the evidence so far, the Optimizer got it right: +> +> Agreed. So, this means that the answer to my original question is "that +> delete gonna take a long time"? +> +> Seems that there is still something wrong. From what I can tell from +> everyones questions, the FK constraint on measurement is causing multiple +> seq scans for each value deleted from int_sensor_meas_type. However, when +> deleting a single value, the FK check should use the index, so my ~190 +> deletes *should* be fast, no? + +No. + +> > IndexScan, value=1 elapsed= 29ms cost=883881 +> +> 190 * 29ms is much less than 40 minutes. What am I missing here? + +It all depends upon your data. + +There are *no* values in *your* table that take 29ms to delete... + +> > Karim, +> > Please do: +> > +> > select id_int_sensor_meas_type, count(*) +> > from measurement +> > group by id_int_sensor_meas_type +> > order by count(*) desc; +> +> id_int_sensor_meas_type | count +> -------------------------+-------- +> 31 | 509478 +> 30 | 509478 +> 206 | 509478 +> 205 | 509478 +> 204 | 509478 +> 40 | 509478 +> 39 | 509478 +> 197 | 509478 +> 35 | 509478 +> 34 | 509478 +> 33 | 509478 +> 32 | 509478 +> 41 | 509477 +> +> This sample dataset has 13 measurements from a weather station over 3 +> years, hence the even distribution. + +Each value has 1/13th of the table, which is too many rows per value to +make an IndexScan an efficient way of deleting rows from the table. + +Thats it. + +If you have more values when measurement is bigger, the delete will +eventually switch plans (if you reconnect) and use the index. But not +yet. + +There's a few ways to (re)design around it, but the distribution of your +data is not *currently* conducive to the using an index. + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 22:36:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E9F695321A + for ; + Mon, 28 Mar 2005 22:36:23 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87650-06 + for ; + Mon, 28 Mar 2005 21:36:14 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id E24CE53205 + for ; + Mon, 28 Mar 2005 22:36:13 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DG1u3-0006IG-00; Mon, 28 Mar 2005 16:36:07 -0500 +To: jd@commandprompt.com +Cc: Greg Stark , + Merlin Moncure , alex@neteconomist.com, + pgsql-performance@postgresql.org +Subject: Re: which dual-CPU hardware/OS is fastest for PostgreSQL? +References: <6EE64EF3AB31D5448D0007DD34EEB3412A75B4@Herge.rcsinc.local> + <8764zb353a.fsf@stark.xeocode.com> + <1112043428.26232.43.camel@jd2.commandprompt.com> +In-Reply-To: <1112043428.26232.43.camel@jd2.commandprompt.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 28 Mar 2005 16:36:06 -0500 +Message-ID: <87wtrr1mih.fsf@stark.xeocode.com> +Lines: 21 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/615 +X-Sequence-Number: 11320 + +"Joshua D. Drake" writes: + +> > I assume AMCC == 3ware now? +> > +> > Has anyone verified that fsync is safe on these controllers? Ie, that they +> > aren't caching writes and "lying" about the write completing like IDE +> > drives often do by default? +> +> The higher end AMCC/3ware controllers actually warn you about using +> write-cache. You have to explicitly turn it on within the controller +> bios. + +Well that's a good sign. + +But if they're using SATA drives my concern is that the drives themselves may +be doing some caching on their own. Has anyone verified that the controllers +are disabling the drive cache or issuing flushes or doing something else to be +sure to block the drives from caching writes? + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 23:43:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2471C5332F + for ; + Mon, 28 Mar 2005 23:43:33 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06613-05 + for ; + Mon, 28 Mar 2005 22:43:23 +0000 (GMT) +Received: from jinx.internetstaff.com (unknown [63.214.174.241]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D01653B08 + for ; + Mon, 28 Mar 2005 23:43:22 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by jinx.internetstaff.com (Postfix) with ESMTP + id 050BE4BC29F; Mon, 28 Mar 2005 15:43:25 -0700 (MST) +Received: from jinx.internetstaff.com ([127.0.0.1]) + by localhost (jinx [127.0.0.1]) (amavisd-new, port 10024) with LMTP + id 14842-01-48; Mon, 28 Mar 2005 15:43:19 -0700 (MST) +Received: from [10.10.3.133] (unknown [65.161.175.207]) + by jinx.internetstaff.com (Postfix) with ESMTP + id BBA3F4BC2BB; Mon, 28 Mar 2005 15:43:14 -0700 (MST) +Subject: Re: How to improve db performance with $7K? +From: Cott Lang +To: Steve Poe +Cc: pgsql-performance@postgresql.org +In-Reply-To: <42455DEC.2080301@sfnet.cc> +References: <42443863.4040302@sfnet.cc> <4244A90B.2030200@sfnet.cc> + <42453273.2060509@turtle-entertainment.de> + <200503261255.59007.josh@agliodbs.com> <42455DEC.2080301@sfnet.cc> +Content-Type: text/plain +Date: Mon, 28 Mar 2005 15:43:14 -0700 +Message-Id: <1112049794.23284.29.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-1) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at internetstaff.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/616 +X-Sequence-Number: 11321 + +Have you already considered application/database tuning? Adding +indexes? shared_buffers large enough? etc. + +Your database doesn't seem that large for the hardware you've already +got. I'd hate to spend $7k and end up back in the same boat. :) + + +On Sat, 2005-03-26 at 13:04 +0000, Steve Poe wrote: +> >Steve, can we clarify that you are not currently having any performance +> >issues, you're just worried about failure? Recommendations should be based +> >on whether improving applicaiton speed is a requirement ... +> +> Josh, +> +> The priorities are: 1)improve safety/failure-prevention, 2) improve +> performance. +> +> The owner of the company wants greater performance (and, I concure to +> certain degree), but the owner's vote is only 1/7 of the managment team. +> And, the rest of the management team is not as focused on performance. +> They all agree in safety/failure-prevention. +> +> Steve +> +> +> +> +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org + + +From pgsql-performance-owner@postgresql.org Mon Mar 28 23:59:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 661F453B00 + for ; + Mon, 28 Mar 2005 23:59:07 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08259-09 + for ; + Mon, 28 Mar 2005 22:58:58 +0000 (GMT) +Received: from asg002.asg.local (smtp2.arrayservicesgrp.com [208.14.218.254]) + by svr1.postgresql.org (Postfix) with ESMTP id E1F335323A + for ; + Mon, 28 Mar 2005 23:58:56 +0100 (BST) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: JDBC best practice +Date: Mon, 28 Mar 2005 16:58:55 -0600 +Message-ID: <49E94D0CFCD4DB43AFBA928DDD20C8F90261848E@asg002.asg.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] which dual-CPU hardware/OS is fastest for PostgreSQL? +Thread-Index: AcUz3qYdmgCwnAn3SRGlTlOHBiA/8gACfRuQ +From: "Dave Held" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.081 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/617 +X-Sequence-Number: 11322 + +I'm using a Postgres table as the data source for a JTable=20 +in a Java app. As a first approximation, I'm implementing +AbstractTableModel.getValueAt() like so: + + public Object getValueAt(int row, int col) + { + try + { + rs_.absolute(row + 1); + return rs_.getObject(col + 1); + } + catch (Exception e) + { + ... + } + return null; + } + +Where rs_ is a RecordSet object. What I'm wondering is +whether it's better to call absolute() or relative() or +next()/previous(). If absolute() is the slowest call, +then I can cache the last row fetched and move relative +to that. + +My suspicion is that next()/previous() is much faster +than absolute() when the record to be fetched is very near +the last record fetched. I haven't actually tried it, but +I'd like some insight if others can already answer this +question based on knowledge of the server side and/or the +JDBC driver. + +__ +David B. Held +Software Engineer/Array Services Group +200 14th Ave. East, Sartell, MN 56377 +320.534.3637 320.253.7800 800.752.8129 + +From pgsql-performance-owner@postgresql.org Tue Mar 29 00:01:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3DC1253B12 + for ; + Tue, 29 Mar 2005 00:00:43 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09374-06 + for ; + Mon, 28 Mar 2005 23:00:39 +0000 (GMT) +Received: from cmailg1.svr.pol.co.uk (cmailg1.svr.pol.co.uk [195.92.195.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 0968A53B0B + for ; + Tue, 29 Mar 2005 00:00:35 +0100 (BST) +Received: from modem-2582.leopard.dialup.pol.co.uk ([217.135.154.22] + helo=192.168.0.102) by cmailg1.svr.pol.co.uk with esmtp (Exim 4.14) + id 1DG3Dm-0005qX-KR; Tue, 29 Mar 2005 00:00:34 +0100 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Josh Berkus +Cc: Karim Nassar , + pgsql-performance@postgresql.org +In-Reply-To: <200503250938.28896.josh@agliodbs.com> +References: <1111709457.9085.127.camel@k2.cet.nau.edu> + <200503242124.39558.josh@agliodbs.com> + <1111728955.9085.238.camel@k2.cet.nau.edu> + <200503250938.28896.josh@agliodbs.com> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Mon, 28 Mar 2005 23:59:11 +0100 +Message-Id: <1112050751.11750.924.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/618 +X-Sequence-Number: 11323 + +On Fri, 2005-03-25 at 09:38 -0800, Josh Berkus wrote: +> > I guess I was wondering if there is other general tuning advice for such +> > large table indexes such as increasing statistics, etc. +> + +> If you're going with the drop/load/recreate option, then I'd suggest +> increasing work_mem for the duration. Hmmm ... or maintenance_work_mem? +> What gets used for FK checks? Simon? +> + +In 8.0, maintenance_work_mem is used for index creation, vacuum and +initial check of FK checks at time of creation. Everything else uses +work_mem as the limit. + +Best Regards, Simon Riggs + + + + +From pgsql-performance-owner@postgresql.org Tue Mar 29 00:38:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B2C3B53947 + for ; + Tue, 29 Mar 2005 00:38:06 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17634-09 + for ; + Mon, 28 Mar 2005 23:38:04 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [64.139.89.126]) + by svr1.postgresql.org (Postfix) with ESMTP id 155D253806 + for ; + Tue, 29 Mar 2005 00:38:03 +0100 (BST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id j2SNbsH03747; + Mon, 28 Mar 2005 18:37:54 -0500 (EST) +From: Bruce Momjian +Message-Id: <200503282337.j2SNbsH03747@candle.pha.pa.us> +Subject: Re: which dual-CPU hardware/OS is fastest for PostgreSQL? +In-Reply-To: <87wtrr1mih.fsf@stark.xeocode.com> +To: Greg Stark +Date: Mon, 28 Mar 2005 18:37:54 -0500 (EST) +Cc: jd@commandprompt.com, + Merlin Moncure , alex@neteconomist.com, + pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/619 +X-Sequence-Number: 11324 + +Greg Stark wrote: +> "Joshua D. Drake" writes: +> +> > > I assume AMCC == 3ware now? +> > > +> > > Has anyone verified that fsync is safe on these controllers? Ie, that they +> > > aren't caching writes and "lying" about the write completing like IDE +> > > drives often do by default? +> > +> > The higher end AMCC/3ware controllers actually warn you about using +> > write-cache. You have to explicitly turn it on within the controller +> > bios. +> +> Well that's a good sign. +> +> But if they're using SATA drives my concern is that the drives themselves may +> be doing some caching on their own. Has anyone verified that the controllers +> are disabling the drive cache or issuing flushes or doing something else to be +> sure to block the drives from caching writes? + +I asked 3ware this at the Linuxworld Boston show and they said their +controller keeps the information in cache until they are sure it is on +the platters and not just in the disk cache, but that is far from a 100% +reliable report. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Sun Apr 3 03:44:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B044F5394B + for ; + Tue, 29 Mar 2005 01:15:07 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28853-10 + for ; + Tue, 29 Mar 2005 00:15:05 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C43D553575 + for ; + Tue, 29 Mar 2005 01:15:04 +0100 (BST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id E9C4230952; Tue, 29 Mar 2005 02:15:03 +0200 (MET DST) +From: Hannes Dorbath +X-Newsgroups: pgsql.performance +Subject: Re: Query Optimizer Failure / Possible Bug +Date: Tue, 29 Mar 2005 02:15:01 +0200 +Organization: Hub.Org Networking Services +Lines: 42 +Message-ID: +References: + <200503281151.17344.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +In-Reply-To: <200503281151.17344.josh@agliodbs.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200504/32 +X-Sequence-Number: 11429 + +Thank you very much for your reply. I'll try to modify it. + + +Josh Berkus wrote: +> Hannes, +> +> +>>The query and the corresponding EXPLAIN is at +>> +>>http://hannes.imos.net/query.txt +> +> +> The problem is that you're using a complex corellated sub-select in the SELECT +> clause: +> +> SELECT +> d.delivery_id, +> da.article_no, +> da.amount, +> ( +> SELECT +> COUNT(*) +> FROM +> serials s +> INNER JOIN rma_ticket_serials rts ON ( +> s.serial_id = rts.serial_id +> ) +> WHERE +> s.article_no = da.article_no AND +> s.delivery_id = d.delivery_id AND +> rts.replace = FALSE +> ) AS replaced_serials +> +> This means that the planner pretty much has to iterate over the subquery, +> running it once for each row in the result set. If you want the optimizer +> to use a JOIN structure instead, put the subselect in the FROM clause. +> + +-- +imos Gesellschaft fuer Internet-Marketing und Online-Services mbH +Alfons-Feifel-Str. 9 // D-73037 Goeppingen // Stauferpark Ost +Tel: 07161 93339-14 // Fax: 07161 93339-99 // Internet: www.imos.net + +From pgsql-performance-owner@postgresql.org Tue Mar 29 01:39:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B9CA5332F + for ; + Tue, 29 Mar 2005 01:39:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33715-07 + for ; + Tue, 29 Mar 2005 00:39:01 +0000 (GMT) +Received: from mailhub2.une.edu.au (mailhub2.une.edu.au [129.180.1.142]) + by svr1.postgresql.org (Postfix) with ESMTP id 6C93553242 + for ; + Tue, 29 Mar 2005 01:38:59 +0100 (BST) +Received: from icarus.une.edu.au (icarus.une.edu.au [129.180.47.120]) + by mailhub2.une.edu.au (Postfix) with ESMTP id 01B037F64 + for ; + Tue, 29 Mar 2005 10:39:03 +1000 (EST) +Received: from kgb ([129.180.47.225]) + by icarus.une.edu.au (8.12.8/8.12.8) with SMTP id j2T0d2G7015711 + for ; Tue, 29 Mar 2005 10:39:02 +1000 +Date: Tue, 29 Mar 2005 10:40:45 +1000 +From: Klint Gore +To: pgsql-performance@postgresql.org +Subject: Re: which dual-CPU hardware/OS is fastest for PostgreSQL? +In-Reply-To: <200503282337.j2SNbsH03747@candle.pha.pa.us> +References: <87wtrr1mih.fsf@stark.xeocode.com> + <200503282337.j2SNbsH03747@candle.pha.pa.us> +Message-Id: <4248A40D49.7F3FKG@129.180.47.120> +MIME-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Mailer: Becky! ver 1.25.06 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/620 +X-Sequence-Number: 11325 + +Anyone using power5 platform? something like an ibm eserver p5 520 +running red hat linux. +(http://www-1.ibm.com/servers/eserver/pseries/hardware/entry/520.html)? + +klint. + ++---------------------------------------+-----------------+ +: Klint Gore : "Non rhyming : +: EMail : kg@kgb.une.edu.au : slang - the : +: Snail : A.B.R.I. : possibilities : +: Mail University of New England : are useless" : +: Armidale NSW 2351 Australia : L.J.J. : +: Fax : +61 2 6772 5376 : : ++---------------------------------------+-----------------+ + +From pgsql-performance-owner@postgresql.org Tue Mar 29 01:51:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D79C53242 + for ; + Tue, 29 Mar 2005 01:51:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37823-08 + for ; + Tue, 29 Mar 2005 00:51:09 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id CBE3F53202 + for ; + Tue, 29 Mar 2005 01:51:08 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DG4wf-00075I-00; Mon, 28 Mar 2005 19:51:01 -0500 +To: Bruce Momjian +Cc: Greg Stark , jd@commandprompt.com, + Merlin Moncure , alex@neteconomist.com, + pgsql-performance@postgresql.org +Subject: Re: which dual-CPU hardware/OS is fastest for PostgreSQL? +References: <200503282337.j2SNbsH03747@candle.pha.pa.us> +In-Reply-To: <200503282337.j2SNbsH03747@candle.pha.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 28 Mar 2005 19:51:01 -0500 +Message-ID: <87oed31dhm.fsf@stark.xeocode.com> +Lines: 13 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/621 +X-Sequence-Number: 11326 + +Bruce Momjian writes: + +> I asked 3ware this at the Linuxworld Boston show and they said their +> controller keeps the information in cache until they are sure it is on +> the platters and not just in the disk cache, but that is far from a 100% +> reliable report. + +Hm. Well, keeping it in cache is one thing. But what it needs to do is not +confirm the write to the host OS. Unless they want to sell their battery +backed unit which is an expensive add-on... + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Mar 29 03:53:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AAC8A52D45 + for ; + Tue, 29 Mar 2005 03:53:15 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65360-05 + for ; + Tue, 29 Mar 2005 02:53:07 +0000 (GMT) +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by svr1.postgresql.org (Postfix) with ESMTP id 0DCF8534C5 + for ; + Tue, 29 Mar 2005 03:53:06 +0100 (BST) +Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) + by svr4.postgresql.org (Postfix) with SMTP id 683D75AF5D0 + for ; + Tue, 29 Mar 2005 02:53:08 +0000 (GMT) +Received: (qmail 26198 invoked by uid 1112); 29 Mar 2005 02:52:36 -0000 +Date: Mon, 28 Mar 2005 21:52:36 -0500 (EST) +From: Kris Jurka +X-X-Sender: books@leary.csoft.net +To: Dave Held +Cc: pgsql-performance@postgresql.org +Subject: Re: JDBC best practice +In-Reply-To: <49E94D0CFCD4DB43AFBA928DDD20C8F90261848E@asg002.asg.local> +Message-ID: +References: <49E94D0CFCD4DB43AFBA928DDD20C8F90261848E@asg002.asg.local> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/622 +X-Sequence-Number: 11327 + + + +On Mon, 28 Mar 2005, Dave Held wrote: + +> I'm using a Postgres table as the data source for a JTable in a Java +> app. Where rs_ is a RecordSet object. What I'm wondering is whether +> it's better to call absolute() or relative() or next()/previous(). If +> absolute() is the slowest call, then I can cache the last row fetched +> and move relative to that. +> +> My suspicion is that next()/previous() is much faster than absolute() +> when the record to be fetched is very near the last record fetched. I +> haven't actually tried it, but I'd like some insight if others can +> already answer this question based on knowledge of the server side +> and/or the JDBC driver. + +There are two types of ResultSets that can be returned by the JDBC driver. +One is backed by a cursor and can only be used for TYPE_FORWARD_ONLY +ResultSets so it is not really applicable to you. The other method +retrieves all results at once and stashes them in a Vector. This makes +next, absolute, and relative positioning all equal cost. + +Kris Jurka + +From pgsql-performance-owner@postgresql.org Sun Apr 3 03:44:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 43DF95294D + for ; + Tue, 29 Mar 2005 09:48:57 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59136-07 + for ; + Tue, 29 Mar 2005 08:48:52 +0000 (GMT) +Received: from mailgate2.nau.edu (mailgate2.nau.edu [134.114.96.59]) + by svr1.postgresql.org (Postfix) with ESMTP id 138A6533BE + for ; + Tue, 29 Mar 2005 09:48:51 +0100 (BST) +Received: from CONVERSION-DAEMON.mailgate2.nau.edu by mailgate2.nau.edu + (PMDF V6.2-X17 #30770) id <0IE300901V5FNV@mailgate2.nau.edu> for + pgsql-performance@postgresql.org; Tue, 29 Mar 2005 01:48:52 -0700 (MST) +Received: from dagobah.cet.nau.edu (dagobah.cet.nau.edu [134.114.64.8]) + by mailgate2.nau.edu (PMDF V6.2-X17 #30770) + with ESMTP id <0IE30047QV5F2X@mailgate2.nau.edu>; Tue, + 29 Mar 2005 01:48:51 -0700 (MST) +Received: from coruscant (coruscant [134.114.64.2]) + by dagobah.cet.nau.edu (8.11.7p1+Sun/8.11.6) with ESMTP id j2T8mms08043; + Tue, 29 Mar 2005 01:48:48 -0700 (MST) +Date: Tue, 29 Mar 2005 01:48:48 -0700 (MST) +From: Karim A Nassar +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <1112044045.11750.919.camel@localhost.localdomain> +To: Simon Riggs +Cc: Stephan Szabo , + Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Message-id: +MIME-version: 1.0 +Content-type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200504/34 +X-Sequence-Number: 11431 + +> Each value has 1/13th of the table, which is too many rows per value to +> make an IndexScan an efficient way of deleting rows from the table. + +But, the original question was that the delete that was taking a long time +was on a different table. I tried to delete 150 rows from a table with 750 +rows, which is FK referenced from this large table. If I understand +correctly, Tom suggested that the length of time was due to a sequential +scan being done on the large table for each value being deleted from the +small one. + +(I have no formal training in database administration nor database theory, +so please excuse me if I am being dumb.) + +For this FK check, there only need be one referring id to invalidate the +delete. ISTM that for any delete with a FK reference, the index could +always be used to search for a single value in the referring table +(excepting very small tables). Why then must a sequential scan be +performed in this case, and/or in general? + +-- +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=- Mobile: (928) 699-9221 + + + +From pgsql-performance-owner@postgresql.org Tue Mar 29 10:50:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1180B53410 + for ; + Tue, 29 Mar 2005 10:50:04 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77224-02 + for ; + Tue, 29 Mar 2005 09:49:58 +0000 (GMT) +Received: from boutiquenumerique.com (unknown [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 939B453406 + for ; + Tue, 29 Mar 2005 10:49:54 +0100 (BST) +Received: (qmail 17931 invoked from network); 29 Mar 2005 11:48:49 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 29 Mar 2005 11:48:49 +0200 +Date: Tue, 29 Mar 2005 11:48:34 +0200 +From: PFC +To: "Steve Poe" , "Cott Lang" +Subject: Re: How to improve db performance with $7K? +Cc: pgsql-performance@postgresql.org +References: <42443863.4040302@sfnet.cc> <4244A90B.2030200@sfnet.cc> + <42453273.2060509@turtle-entertainment.de> + <200503261255.59007.josh@agliodbs.com> <42455DEC.2080301@sfnet.cc> + <1112049794.23284.29.camel@localhost.localdomain> + <424840AE.3050200@sfnet.cc> +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <4244A90B.2030200@sfnet.cc> +User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/624 +X-Sequence-Number: 11329 + + +> With hardware tuning, I am sure we can do better than 35Mb per sec. Also + + WTF ? + + My Laptop does 19 MB/s (reading <10 KB files, reiser4) ! + + A recent desktop 7200rpm IDE drive +# hdparm -t /dev/hdc1 +/dev/hdc1: + Timing buffered disk reads: 148 MB in 3.02 seconds = 49.01 MB/sec + +# ll "DragonBall 001.avi" +-r--r--r-- 1 peufeu users 218M mar 9 20:07 DragonBall 001.avi + +# time cat "DragonBall 001.avi" >/dev/null +real 0m4.162s +user 0m0.020s +sys 0m0.510s + +(the file was not in the cache) + => about 52 MB/s (reiser3.6) + + So, you have a problem with your hardware... + +From pgsql-performance-owner@postgresql.org Sun Apr 3 03:52:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CF9C53443 + for ; + Tue, 29 Mar 2005 12:21:24 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05000-03 + for ; + Tue, 29 Mar 2005 11:21:20 +0000 (GMT) +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B297553407 + for ; + Tue, 29 Mar 2005 12:21:19 +0100 (BST) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id E60BA30952; Tue, 29 Mar 2005 13:21:17 +0200 (MET DST) +From: "AL� �EL�K" +X-Newsgroups: pgsql.performance +Subject: coalesce alternative +Date: Tue, 29 Mar 2005 14:21:13 +0300 +Organization: Hub.Org Networking Services +Lines: 6 +Message-ID: +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 +X-RFC2646: Format=Flowed; Original +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Amavis-Alert: BAD HEADER Non-encoded 8-bit data (char DD hex) in message + header 'From': From: "AL\335 \307EL\335K" ; + Tue, 29 Mar 2005 12:31:30 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08562-01 + for ; + Tue, 29 Mar 2005 11:31:25 +0000 (GMT) +Received: from cmailm3.svr.pol.co.uk (cmailm3.svr.pol.co.uk [195.92.193.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 43E1C52952 + for ; + Tue, 29 Mar 2005 12:31:24 +0100 (BST) +Received: from modem-2903.lion.dialup.pol.co.uk ([217.135.171.87] + helo=192.168.0.102) by cmailm3.svr.pol.co.uk with esmtp (Exim 4.41) + id 1DGEw7-0002VQ-3L; Tue, 29 Mar 2005 12:31:07 +0100 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Karim A Nassar , + Stephan Szabo , Tom Lane +Cc: Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Tue, 29 Mar 2005 12:29:36 +0100 +Message-Id: <1112095776.11750.958.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/625 +X-Sequence-Number: 11330 + +On Tue, 2005-03-29 at 01:48 -0700, Karim A Nassar wrote: +> > Each value has 1/13th of the table, which is too many rows per value to +> > make an IndexScan an efficient way of deleting rows from the table. +> +> But, the original question was that the delete that was taking a long time +> was on a different table. I tried to delete 150 rows from a table with 750 +> rows, which is FK referenced from this large table. If I understand +> correctly, Tom suggested that the length of time was due to a sequential +> scan being done on the large table for each value being deleted from the +> small one. + +> For this FK check, there only need be one referring id to invalidate the +> delete. ISTM that for any delete with a FK reference, the index could +> always be used to search for a single value in the referring table +> (excepting very small tables). Why then must a sequential scan be +> performed in this case, and/or in general? + +My understanding was that you were doing a DELETE on the smaller table +and that this was doing a DELETE on the measurement table because you +had the FK defined as ON DELETE CASCADE. You are right - only a single +row is sufficient to RESTRICT the DELETE. But for an ON UPDATE/DELETE +action of CASCADE then you will want to touch all rows referenced, so a +SeqScan is a perfectly valid consequence of such actions. +I think now that you are using the default action, rather than +specifically requesting CASCADE? + +Stephan, Tom: +The SQL generated for RI checking by the RI triggers currently applies a +limit at execution time, not at prepare time. i.e. there is no LIMIT +clause in the SQL. + +We know whether the check will be limit 1 or limit 0 at prepare time, so +why not add a LIMIT clause to the SQL so it changes the plan, not just +the number of rows returned when the check query executes? +(I note that PREPARE does allow you to supply a LIMIT 1 clause). + +That is *ought* to have some effect on the plan used by the RI check +queries. In costsize.c:cost_index we would have tuples_fetched==1 and it +would be hard (but not impossible) for the index cost to ever be more +than the cost of a SeqScan. + +...but, I see no way for OidFunctionCall8 to ever return an answer of +"always just 1 row, no matter how big the relation"...so tuples_fetched +is always proportional to the size of the relation. Are unique indexes +treated just as very-low-selectivity indexes? - they're a very similar +situation in terms of forcing an absolute, not relative, number of rows +returned. + +Best Regards, Simon Riggs + + + +From pgsql-performance-owner@postgresql.org Sun Apr 3 03:52:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2739A53409 + for ; + Tue, 29 Mar 2005 13:15:13 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20351-07 + for ; + Tue, 29 Mar 2005 12:15:08 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id F0E1C533BD + for ; + Tue, 29 Mar 2005 13:15:07 +0100 (BST) +Received: (qmail 23007 invoked from network); 29 Mar 2005 12:13:59 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 29 Mar 2005 12:13:59 -0000 +Message-ID: <424946C8.6020003@fastcrypt.com> +Date: Tue, 29 Mar 2005 07:15:04 -0500 +From: Dave Cramer +Reply-To: dave@fastcrypt.com +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PFC +Cc: Steve Poe , Cott Lang , + pgsql-performance@postgresql.org +Subject: Re: How to improve db performance with $7K? +References: <42443863.4040302@sfnet.cc> <4244A90B.2030200@sfnet.cc> + <42453273.2060509@turtle-entertainment.de> + <200503261255.59007.josh@agliodbs.com> <42455DEC.2080301@sfnet.cc> + <1112049794.23284.29.camel@localhost.localdomain> + <424840AE.3050200@sfnet.cc> +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200504/38 +X-Sequence-Number: 11435 + +Yeah, 35Mb per sec is slow for a raid controller, the 3ware mirrored is +about 50Mb/sec, and striped is about 100 + +Dave + +PFC wrote: + +> +>> With hardware tuning, I am sure we can do better than 35Mb per sec. Also +> +> +> WTF ? +> +> My Laptop does 19 MB/s (reading <10 KB files, reiser4) ! +> +> A recent desktop 7200rpm IDE drive +> # hdparm -t /dev/hdc1 +> /dev/hdc1: +> Timing buffered disk reads: 148 MB in 3.02 seconds = 49.01 MB/sec +> +> # ll "DragonBall 001.avi" +> -r--r--r-- 1 peufeu users 218M mar 9 20:07 DragonBall +> 001.avi +> +> # time cat "DragonBall 001.avi" >/dev/null +> real 0m4.162s +> user 0m0.020s +> sys 0m0.510s +> +> (the file was not in the cache) +> => about 52 MB/s (reiser3.6) +> +> So, you have a problem with your hardware... +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings +> +> + +From pgsql-performance-owner@postgresql.org Tue Mar 29 13:17:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B07553A62 + for ; + Tue, 29 Mar 2005 13:17:13 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21493-08 + for ; + Tue, 29 Mar 2005 12:17:08 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 83D9653459 + for ; + Tue, 29 Mar 2005 13:17:07 +0100 (BST) +Received: (qmail 23039 invoked from network); 29 Mar 2005 12:16:00 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 29 Mar 2005 12:16:00 -0000 +Message-ID: <42494741.7060806@fastcrypt.com> +Date: Tue, 29 Mar 2005 07:17:05 -0500 +From: Dave Cramer +Reply-To: pg@fastcrypt.com +Organization: Postgres International +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +Cc: pgsql-performance@postgresql.org +Subject: Re: How to improve db performance with $7K? +References: <42443863.4040302@sfnet.cc> <4244A90B.2030200@sfnet.cc> + <42453273.2060509@turtle-entertainment.de> + <200503261255.59007.josh@agliodbs.com> <42455DEC.2080301@sfnet.cc> + <1112049794.23284.29.camel@localhost.localdomain> + <424840AE.3050200@sfnet.cc> +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-15; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.034 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/626 +X-Sequence-Number: 11331 + +Yeah, 35Mb per sec is slow for a raid controller, the 3ware mirrored is +about 50Mb/sec, and striped is about 100 + +Dave + +PFC wrote: + +> +>> With hardware tuning, I am sure we can do better than 35Mb per sec. Also +> +> +> WTF ? +> +> My Laptop does 19 MB/s (reading <10 KB files, reiser4) ! +> +> A recent desktop 7200rpm IDE drive +> # hdparm -t /dev/hdc1 +> /dev/hdc1: +> Timing buffered disk reads: 148 MB in 3.02 seconds = 49.01 MB/sec +> +> # ll "DragonBall 001.avi" +> -r--r--r-- 1 peufeu users 218M mar 9 20:07 DragonBall +> 001.avi +> +> # time cat "DragonBall 001.avi" >/dev/null +> real 0m4.162s +> user 0m0.020s +> sys 0m0.510s +> +> (the file was not in the cache) +> => about 52 MB/s (reiser3.6) +> +> So, you have a problem with your hardware... +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings +> +> + + +-- +Dave Cramer +http://www.postgresintl.com +519 939 0336 +ICQ#14675561 + +From pgsql-performance-owner@postgresql.org Tue Mar 29 14:50:44 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EE4035341F + for ; + Tue, 29 Mar 2005 14:50:43 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50076-06 + for ; + Tue, 29 Mar 2005 13:50:42 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 43E675341D + for ; + Tue, 29 Mar 2005 14:50:41 +0100 (BST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id F1317361CE; Tue, 29 Mar 2005 05:50:42 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id EF6C836153; Tue, 29 Mar 2005 05:50:42 -0800 (PST) +Date: Tue, 29 Mar 2005 05:50:42 -0800 (PST) +From: Stephan Szabo +To: Simon Riggs +Cc: Karim A Nassar , Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-Reply-To: <1112095776.11750.958.camel@localhost.localdomain> +Message-ID: <20050329054714.V50612@megazone.bigpanda.com> +References: + <1112095776.11750.958.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/627 +X-Sequence-Number: 11332 + +On Tue, 29 Mar 2005, Simon Riggs wrote: + +> On Tue, 2005-03-29 at 01:48 -0700, Karim A Nassar wrote: +> > > Each value has 1/13th of the table, which is too many rows per value to +> > > make an IndexScan an efficient way of deleting rows from the table. +> > +> > But, the original question was that the delete that was taking a long time +> > was on a different table. I tried to delete 150 rows from a table with 750 +> > rows, which is FK referenced from this large table. If I understand +> > correctly, Tom suggested that the length of time was due to a sequential +> > scan being done on the large table for each value being deleted from the +> > small one. +> +> > For this FK check, there only need be one referring id to invalidate the +> > delete. ISTM that for any delete with a FK reference, the index could +> > always be used to search for a single value in the referring table +> > (excepting very small tables). Why then must a sequential scan be +> > performed in this case, and/or in general? +> +> My understanding was that you were doing a DELETE on the smaller table +> and that this was doing a DELETE on the measurement table because you +> had the FK defined as ON DELETE CASCADE. You are right - only a single +> row is sufficient to RESTRICT the DELETE. But for an ON UPDATE/DELETE +> action of CASCADE then you will want to touch all rows referenced, so a +> SeqScan is a perfectly valid consequence of such actions. +> I think now that you are using the default action, rather than +> specifically requesting CASCADE? +> +> Stephan, Tom: +> The SQL generated for RI checking by the RI triggers currently applies a +> limit at execution time, not at prepare time. i.e. there is no LIMIT +> clause in the SQL. +> +> We know whether the check will be limit 1 or limit 0 at prepare time, so +> why not add a LIMIT clause to the SQL so it changes the plan, not just +> the number of rows returned when the check query executes? + +Because IIRC, FOR UPDATE and LIMIT at least historically didn't play +nicely together, so you could sometimes get a result where if the first +row was locked, the FOR UPDATE would wait on it, but if it was deleted by +the other transaction you could get 0 rows back in the trigger. + + +From pgsql-performance-owner@postgresql.org Tue Mar 29 15:20:26 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B3E3B5324C + for ; + Tue, 29 Mar 2005 15:20:25 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60060-07 + for ; + Tue, 29 Mar 2005 14:20:24 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E9EA53220 + for ; + Tue, 29 Mar 2005 15:20:21 +0100 (BST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id C5D8E35A8E; Tue, 29 Mar 2005 06:20:25 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id C10E13596E; Tue, 29 Mar 2005 06:20:25 -0800 (PST) +Date: Tue, 29 Mar 2005 06:20:25 -0800 (PST) +From: Stephan Szabo +To: Simon Riggs +Cc: Karim A Nassar , Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-Reply-To: <20050329054714.V50612@megazone.bigpanda.com> +Message-ID: <20050329061837.A51620@megazone.bigpanda.com> +References: + <1112095776.11750.958.camel@localhost.localdomain> + <20050329054714.V50612@megazone.bigpanda.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/628 +X-Sequence-Number: 11333 + +On Tue, 29 Mar 2005, Stephan Szabo wrote: + +> On Tue, 29 Mar 2005, Simon Riggs wrote: +> +> > On Tue, 2005-03-29 at 01:48 -0700, Karim A Nassar wrote: +> > > > Each value has 1/13th of the table, which is too many rows per value to +> > > > make an IndexScan an efficient way of deleting rows from the table. +> > > +> > > But, the original question was that the delete that was taking a long time +> > > was on a different table. I tried to delete 150 rows from a table with 750 +> > > rows, which is FK referenced from this large table. If I understand +> > > correctly, Tom suggested that the length of time was due to a sequential +> > > scan being done on the large table for each value being deleted from the +> > > small one. +> > +> > > For this FK check, there only need be one referring id to invalidate the +> > > delete. ISTM that for any delete with a FK reference, the index could +> > > always be used to search for a single value in the referring table +> > > (excepting very small tables). Why then must a sequential scan be +> > > performed in this case, and/or in general? +> > +> > My understanding was that you were doing a DELETE on the smaller table +> > and that this was doing a DELETE on the measurement table because you +> > had the FK defined as ON DELETE CASCADE. You are right - only a single +> > row is sufficient to RESTRICT the DELETE. But for an ON UPDATE/DELETE +> > action of CASCADE then you will want to touch all rows referenced, so a +> > SeqScan is a perfectly valid consequence of such actions. +> > I think now that you are using the default action, rather than +> > specifically requesting CASCADE? +> > +> > Stephan, Tom: +> > The SQL generated for RI checking by the RI triggers currently applies a +> > limit at execution time, not at prepare time. i.e. there is no LIMIT +> > clause in the SQL. +> > +> > We know whether the check will be limit 1 or limit 0 at prepare time, so +> > why not add a LIMIT clause to the SQL so it changes the plan, not just +> > the number of rows returned when the check query executes? +> +> Because IIRC, FOR UPDATE and LIMIT at least historically didn't play +> nicely together, so you could sometimes get a result where if the first +> row was locked, the FOR UPDATE would wait on it, but if it was deleted by +> the other transaction you could get 0 rows back in the trigger. + +If there were some way to pass a "limit" into SPI_prepare that was treated +similarly to a LIMIT clause for planning purposes but didn't actually +change the output plan to only return that number of rows, we could use +that. + +From pgsql-performance-owner@postgresql.org Tue Mar 29 15:29:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0ADA953220 + for ; + Tue, 29 Mar 2005 15:29:39 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62539-08 + for ; + Tue, 29 Mar 2005 14:29:29 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id EDACC52AA2 + for ; + Tue, 29 Mar 2005 15:29:28 +0100 (BST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2TETKT7021385; + Tue, 29 Mar 2005 09:29:20 -0500 (EST) +To: Stephan Szabo +Cc: Simon Riggs , + Karim A Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <20050329054714.V50612@megazone.bigpanda.com> +References: + <1112095776.11750.958.camel@localhost.localdomain> + <20050329054714.V50612@megazone.bigpanda.com> +Comments: In-reply-to Stephan Szabo + message dated "Tue, 29 Mar 2005 05:50:42 -0800" +Date: Tue, 29 Mar 2005 09:29:20 -0500 +Message-ID: <21384.1112106560@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/629 +X-Sequence-Number: 11334 + +Stephan Szabo writes: +> On Tue, 29 Mar 2005, Simon Riggs wrote: +>> The SQL generated for RI checking by the RI triggers currently applies a +>> limit at execution time, not at prepare time. i.e. there is no LIMIT +>> clause in the SQL. +>> +>> We know whether the check will be limit 1 or limit 0 at prepare time, so +>> why not add a LIMIT clause to the SQL so it changes the plan, not just +>> the number of rows returned when the check query executes? + +> Because IIRC, FOR UPDATE and LIMIT at least historically didn't play +> nicely together, so you could sometimes get a result where if the first +> row was locked, the FOR UPDATE would wait on it, but if it was deleted by +> the other transaction you could get 0 rows back in the trigger. + +Yeah, this is still true. It would probably be a good idea to change it +but I haven't looked into exactly what would be involved. The basic +problem is that the FOR UPDATE filter needs to execute before LIMIT +instead of after, so presumably the FOR UPDATE shenanigans in execMain.c +would need to be pushed into a separate plan node that could go +underneath the LIMIT node. + +Originally this would have led to even more broken behavior --- locks +taken on rows that weren't returned --- because the original coding of +the LIMIT node tended to pull one more row from the lower plan than it +would actually return. But we fixed that. + +I think having such a node might allow us to support FOR UPDATE in +subqueries, as well, but I haven't looked at the details. (Whether that +is a good idea is another question --- the problem of pulling rows that +aren't nominally necessary, and thereby locking them, would apply in +spades.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 29 15:41:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CE5A052AA2 + for ; + Tue, 29 Mar 2005 15:41:05 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69457-05 + for ; + Tue, 29 Mar 2005 14:41:03 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id E9DC75364E + for ; + Tue, 29 Mar 2005 15:41:02 +0100 (BST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2TEevMk021462; + Tue, 29 Mar 2005 09:40:57 -0500 (EST) +To: Simon Riggs +Cc: Karim A Nassar , + Stephan Szabo , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <1112095776.11750.958.camel@localhost.localdomain> +References: + <1112095776.11750.958.camel@localhost.localdomain> +Comments: In-reply-to Simon Riggs + message dated "Tue, 29 Mar 2005 12:29:36 +0100" +Date: Tue, 29 Mar 2005 09:40:57 -0500 +Message-ID: <21461.1112107257@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/630 +X-Sequence-Number: 11335 + +Simon Riggs writes: +> ...but, I see no way for OidFunctionCall8 to ever return an answer of +> "always just 1 row, no matter how big the relation"...so tuples_fetched +> is always proportional to the size of the relation. Are unique indexes +> treated just as very-low-selectivity indexes? + +Yeah. It is not the job of amcostestimate to estimate the number of +rows, only the index access cost. (IIRC there is someplace in the +planner that explicitly considers unique indexes as a part of developing +selectivity estimates ... but it's not that part.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 29 15:53:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D3102533A2 + for ; + Tue, 29 Mar 2005 15:53:02 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74922-04 + for ; + Tue, 29 Mar 2005 14:53:01 +0000 (GMT) +Received: from jinx.internetstaff.com (unknown [63.214.174.241]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A06A52AA2 + for ; + Tue, 29 Mar 2005 15:53:00 +0100 (BST) +Received: from localhost (localhost [127.0.0.1]) + by jinx.internetstaff.com (Postfix) with ESMTP + id BC8FF4BC2B3; Tue, 29 Mar 2005 07:53:04 -0700 (MST) +Received: from jinx.internetstaff.com ([127.0.0.1]) + by localhost (jinx [127.0.0.1]) (amavisd-new, port 10024) with LMTP + id 18457-05-68; Tue, 29 Mar 2005 07:52:59 -0700 (MST) +Subject: Re: How to improve db performance with $7K? +From: Cott Lang +To: Steve Poe +Cc: pgsql-performance@postgresql.org +In-Reply-To: <424840AE.3050200@sfnet.cc> +References: <42443863.4040302@sfnet.cc> <4244A90B.2030200@sfnet.cc> + <42453273.2060509@turtle-entertainment.de> + <200503261255.59007.josh@agliodbs.com> <42455DEC.2080301@sfnet.cc> + <1112049794.23284.29.camel@localhost.localdomain> + <424840AE.3050200@sfnet.cc> +Content-Type: text/plain +Date: Tue, 29 Mar 2005 07:52:54 -0700 +Message-Id: <1112107974.7903.28.camel@sixtyfour.internetstaff.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at internetstaff.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/631 +X-Sequence-Number: 11336 + +On Mon, 2005-03-28 at 17:36 +0000, Steve Poe wrote: + +> I agree with you. Unfortunately, I am not the developer of the +> application. The vendor uses ProIV which connects via ODBC. The vendor +> could certain do some tuning and create more indexes where applicable. I +> am encouraging the vendor to take a more active role and we work +> together on this. + +I've done a lot browsing through pg_stat_activity, looking for queries +that either hang around for a while or show up very often, and using +explain to find out if they can use some assistance. + +You may also find that a dump and restore with a reconfiguration to +mirrored drives speeds you up a lot - just from the dump and restore. + +> With hardware tuning, I am sure we can do better than 35Mb per sec. Also +> moving the top 3 or 5 tables and indexes to their own slice of a RAID10 +> and moving pg_xlog to its own drive will help too. + +If your database activity involves a lot of random i/o, 35Mb per second +wouldn't be too bad. + +While conventional wisdom is that pg_xlog on its own drives (I know you +meant plural :) ) is a big boost, in my particular case I could never +get a a measurable boost that way. Obviously, YMMV. + + + + +From pgsql-performance-owner@postgresql.org Tue Mar 29 15:56:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ECA5553917 + for ; + Tue, 29 Mar 2005 15:56:52 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77801-01 + for ; + Tue, 29 Mar 2005 14:56:49 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E85D538D5 + for ; + Tue, 29 Mar 2005 15:56:48 +0100 (BST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2TEufSh021617; + Tue, 29 Mar 2005 09:56:41 -0500 (EST) +To: Stephan Szabo +Cc: Simon Riggs , + Karim A Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <20050329061837.A51620@megazone.bigpanda.com> +References: + <1112095776.11750.958.camel@localhost.localdomain> + <20050329054714.V50612@megazone.bigpanda.com> + <20050329061837.A51620@megazone.bigpanda.com> +Comments: In-reply-to Stephan Szabo + message dated "Tue, 29 Mar 2005 06:20:25 -0800" +Date: Tue, 29 Mar 2005 09:56:41 -0500 +Message-ID: <21616.1112108201@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/632 +X-Sequence-Number: 11337 + +Stephan Szabo writes: +> If there were some way to pass a "limit" into SPI_prepare that was treated +> similarly to a LIMIT clause for planning purposes but didn't actually +> change the output plan to only return that number of rows, we could use +> that. + +Hmm ... the planner does have the ability to do that sort of thing (we +use it for cursors). SPI_prepare doesn't expose the capability. +Perhaps adding a SPI_prepare variant that does expose it would be the +quickest route to a solution. + +I get a headache every time I look at the RI triggers ;-). Do they +always know at the time of preparing a plan which way it will be used? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 29 16:21:59 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F2ECB5350D + for ; + Tue, 29 Mar 2005 16:21:58 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82923-08 + for ; + Tue, 29 Mar 2005 15:21:50 +0000 (GMT) +Received: from cmailg3.svr.pol.co.uk (cmailg3.svr.pol.co.uk [195.92.195.173]) + by svr1.postgresql.org (Postfix) with ESMTP id 009EF5347E + for ; + Tue, 29 Mar 2005 16:21:49 +0100 (BST) +Received: from modem-2151.llama.dialup.pol.co.uk ([217.135.184.103] + helo=192.168.0.102) by cmailg3.svr.pol.co.uk with esmtp (Exim 4.41) + id 1DGIX6-0004XW-7Y; Tue, 29 Mar 2005 16:21:32 +0100 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Stephan Szabo +Cc: Karim A Nassar , Tom Lane , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: <20050329054714.V50612@megazone.bigpanda.com> +References: + <1112095776.11750.958.camel@localhost.localdomain> + <20050329054714.V50612@megazone.bigpanda.com> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Tue, 29 Mar 2005 16:20:02 +0100 +Message-Id: <1112109602.11750.972.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/633 +X-Sequence-Number: 11338 + +On Tue, 2005-03-29 at 05:50 -0800, Stephan Szabo wrote: +> On Tue, 29 Mar 2005, Simon Riggs wrote: +> +> > On Tue, 2005-03-29 at 01:48 -0700, Karim A Nassar wrote: +> > > > Each value has 1/13th of the table, which is too many rows per value to +> > > > make an IndexScan an efficient way of deleting rows from the table. +> > > +> > > But, the original question was that the delete that was taking a long time +> > > was on a different table. I tried to delete 150 rows from a table with 750 +> > > rows, which is FK referenced from this large table. If I understand +> > > correctly, Tom suggested that the length of time was due to a sequential +> > > scan being done on the large table for each value being deleted from the +> > > small one. +> > +> > > For this FK check, there only need be one referring id to invalidate the +> > > delete. ISTM that for any delete with a FK reference, the index could +> > > always be used to search for a single value in the referring table +> > > (excepting very small tables). Why then must a sequential scan be +> > > performed in this case, and/or in general? +> > +> > My understanding was that you were doing a DELETE on the smaller table +> > and that this was doing a DELETE on the measurement table because you +> > had the FK defined as ON DELETE CASCADE. You are right - only a single +> > row is sufficient to RESTRICT the DELETE. But for an ON UPDATE/DELETE +> > action of CASCADE then you will want to touch all rows referenced, so a +> > SeqScan is a perfectly valid consequence of such actions. +> > I think now that you are using the default action, rather than +> > specifically requesting CASCADE? +> > +> > Stephan, Tom: +> > The SQL generated for RI checking by the RI triggers currently applies a +> > limit at execution time, not at prepare time. i.e. there is no LIMIT +> > clause in the SQL. +> > +> > We know whether the check will be limit 1 or limit 0 at prepare time, so +> > why not add a LIMIT clause to the SQL so it changes the plan, not just +> > the number of rows returned when the check query executes? +> +> Because IIRC, FOR UPDATE and LIMIT at least historically didn't play +> nicely together, so you could sometimes get a result where if the first +> row was locked, the FOR UPDATE would wait on it, but if it was deleted by +> the other transaction you could get 0 rows back in the trigger. +> + +Well, sorry to ask more... + +...but surely we only need FOR UPDATE clause if we are performing a +CASCADE action? whereas we only want the LIMIT 1 clause if we are NOT +performing a CASCADE action? That way the two clauses are mutually +exclusive and the problem you outline should never (need to) occur. + +The current code doesn't seem to vary the check query according to the +requested FK action... + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Tue Mar 29 16:26:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 66A4553659 + for ; + Tue, 29 Mar 2005 16:26:13 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85476-04 + for ; + Tue, 29 Mar 2005 15:26:10 +0000 (GMT) +Received: from cmailm4.svr.pol.co.uk (cmailm4.svr.pol.co.uk [195.92.193.211]) + by svr1.postgresql.org (Postfix) with ESMTP id E8BDD533A2 + for ; + Tue, 29 Mar 2005 16:26:09 +0100 (BST) +Received: from modem-2151.llama.dialup.pol.co.uk ([217.135.184.103] + helo=192.168.0.102) by cmailm4.svr.pol.co.uk with esmtp (Exim 4.41) + id 1DGIbW-00072J-Lv; Tue, 29 Mar 2005 16:26:07 +0100 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Tom Lane +Cc: Stephan Szabo , + Karim A Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: <21616.1112108201@sss.pgh.pa.us> +References: + <1112095776.11750.958.camel@localhost.localdomain> + <20050329054714.V50612@megazone.bigpanda.com> + <20050329061837.A51620@megazone.bigpanda.com> + <21616.1112108201@sss.pgh.pa.us> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Tue, 29 Mar 2005 16:24:40 +0100 +Message-Id: <1112109880.11750.977.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/634 +X-Sequence-Number: 11339 + +On Tue, 2005-03-29 at 09:56 -0500, Tom Lane wrote: +> Stephan Szabo writes: +> > If there were some way to pass a "limit" into SPI_prepare that was treated +> > similarly to a LIMIT clause for planning purposes but didn't actually +> > change the output plan to only return that number of rows, we could use +> > that. +> +> Hmm ... the planner does have the ability to do that sort of thing (we +> use it for cursors). SPI_prepare doesn't expose the capability. +> Perhaps adding a SPI_prepare variant that does expose it would be the +> quickest route to a solution. +> +> I get a headache every time I look at the RI triggers ;-). Do they +> always know at the time of preparing a plan which way it will be used? + +If action is NO ACTION or RESTRICT then + we need to SELECT at most 1 row that matches the criteria + which means we can use LIMIT 1 + +If action is CASCADE, SET NULL, SET DEFAULT then + we need to UPDATE or DELETE all rows that match the criteria + which means we musnt use LIMIT and need to use FOR UPDATE + +We know that at CONSTRAINT creation time, which always occurs before +plan preparation time. + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Tue Mar 29 16:32:00 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4652B53465 + for ; + Tue, 29 Mar 2005 16:31:59 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88107-04 + for ; + Tue, 29 Mar 2005 15:31:57 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id A576553425 + for ; + Tue, 29 Mar 2005 16:31:56 +0100 (BST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2TFVonD022528; + Tue, 29 Mar 2005 10:31:50 -0500 (EST) +To: Simon Riggs +Cc: Stephan Szabo , + Karim A Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <1112109880.11750.977.camel@localhost.localdomain> +References: + <1112095776.11750.958.camel@localhost.localdomain> + <20050329054714.V50612@megazone.bigpanda.com> + <20050329061837.A51620@megazone.bigpanda.com> + <21616.1112108201@sss.pgh.pa.us> + <1112109880.11750.977.camel@localhost.localdomain> +Comments: In-reply-to Simon Riggs + message dated "Tue, 29 Mar 2005 16:24:40 +0100" +Date: Tue, 29 Mar 2005 10:31:50 -0500 +Message-ID: <22527.1112110310@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/635 +X-Sequence-Number: 11340 + +Simon Riggs writes: +> If action is NO ACTION or RESTRICT then +> we need to SELECT at most 1 row that matches the criteria +> which means we can use LIMIT 1 + +> If action is CASCADE, SET NULL, SET DEFAULT then +> we need to UPDATE or DELETE all rows that match the criteria +> which means we musnt use LIMIT and need to use FOR UPDATE + +Huh? UPDATE/DELETE don't use FOR UPDATE. I think you have failed +to break down the cases sufficiently. In particular it matters which +side of the RI constraint you are working from ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 29 17:03:13 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 202D653918 + for ; + Tue, 29 Mar 2005 17:03:12 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97505-06 + for ; + Tue, 29 Mar 2005 16:03:08 +0000 (GMT) +Received: from cmailg2.svr.pol.co.uk (cmailg2.svr.pol.co.uk [195.92.195.172]) + by svr1.postgresql.org (Postfix) with ESMTP id 6017C538AD + for ; + Tue, 29 Mar 2005 17:03:05 +0100 (BST) +Received: from modem-2006.porcupine.dialup.pol.co.uk ([217.134.199.214] + helo=192.168.0.102) by cmailg2.svr.pol.co.uk with esmtp (Exim 4.14) + id 1DGJB7-0005QO-Jj; Tue, 29 Mar 2005 17:02:53 +0100 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Tom Lane +Cc: Stephan Szabo , + Karim A Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: <22527.1112110310@sss.pgh.pa.us> +References: + <1112095776.11750.958.camel@localhost.localdomain> + <20050329054714.V50612@megazone.bigpanda.com> + <20050329061837.A51620@megazone.bigpanda.com> + <21616.1112108201@sss.pgh.pa.us> + <1112109880.11750.977.camel@localhost.localdomain> + <22527.1112110310@sss.pgh.pa.us> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Tue, 29 Mar 2005 17:01:27 +0100 +Message-Id: <1112112087.11750.984.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.062 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/636 +X-Sequence-Number: 11341 + +On Tue, 2005-03-29 at 10:31 -0500, Tom Lane wrote: +> Simon Riggs writes: +> > If action is NO ACTION or RESTRICT then +> > we need to SELECT at most 1 row that matches the criteria +> > which means we can use LIMIT 1 +> +> > If action is CASCADE, SET NULL, SET DEFAULT then +> > we need to UPDATE or DELETE all rows that match the criteria +> > which means we musnt use LIMIT and need to use FOR UPDATE +> +> Huh? UPDATE/DELETE don't use FOR UPDATE. I think you have failed +> to break down the cases sufficiently. In particular it matters which +> side of the RI constraint you are working from ... + +OK... too quick, sorry. I'll hand over to Stephan for a better and more +exhaustive explanation/analysis... but AFAICS we *can* always know the +correct formulation of the query prepare time, whether or not we do +currently. + +Best Regards, Simon Riggs + + + + +From pgsql-performance-owner@postgresql.org Tue Mar 29 17:33:28 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BB0C533B7 + for ; + Tue, 29 Mar 2005 17:33:27 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08117-03 + for ; + Tue, 29 Mar 2005 16:33:25 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id AE44A52A86 + for ; + Tue, 29 Mar 2005 17:33:21 +0100 (BST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 923E4354B1; Tue, 29 Mar 2005 08:33:20 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 8299D3547F; Tue, 29 Mar 2005 08:33:20 -0800 (PST) +Date: Tue, 29 Mar 2005 08:33:20 -0800 (PST) +From: Stephan Szabo +To: Simon Riggs +Cc: Tom Lane , Karim A Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-Reply-To: <1112112087.11750.984.camel@localhost.localdomain> +Message-ID: <20050329083027.I58020@megazone.bigpanda.com> +References: + <1112095776.11750.958.camel@localhost.localdomain> + <20050329054714.V50612@megazone.bigpanda.com> + <20050329061837.A51620@megazone.bigpanda.com> + <21616.1112108201@sss.pgh.pa.us> + <1112109880.11750.977.camel@localhost.localdomain> + <22527.1112110310@sss.pgh.pa.us> + <1112112087.11750.984.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/637 +X-Sequence-Number: 11342 + + +On Tue, 29 Mar 2005, Simon Riggs wrote: + +> On Tue, 2005-03-29 at 10:31 -0500, Tom Lane wrote: +> > Simon Riggs writes: +> > > If action is NO ACTION or RESTRICT then +> > > we need to SELECT at most 1 row that matches the criteria +> > > which means we can use LIMIT 1 +> > +> > > If action is CASCADE, SET NULL, SET DEFAULT then +> > > we need to UPDATE or DELETE all rows that match the criteria +> > > which means we musnt use LIMIT and need to use FOR UPDATE +> > +> > Huh? UPDATE/DELETE don't use FOR UPDATE. I think you have failed +> > to break down the cases sufficiently. In particular it matters which +> > side of the RI constraint you are working from ... +> +> OK... too quick, sorry. I'll hand over to Stephan for a better and more +> exhaustive explanation/analysis... but AFAICS we *can* always know the +> correct formulation of the query prepare time, whether or not we do +> currently. + +We currently use FOR UPDATE on the NO ACTION check, because otherwise we +might get back a row that's already marked for deletion by a concurrent +transaction. I think that's intended to wait and succeed, not fail. + + +From pgsql-performance-owner@postgresql.org Tue Mar 29 17:38:40 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ABC7A533BB + for ; + Tue, 29 Mar 2005 17:38:39 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10882-01 + for ; + Tue, 29 Mar 2005 16:38:29 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 7898552A65 + for ; + Tue, 29 Mar 2005 17:38:29 +0100 (BST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 9AB07354B1; Tue, 29 Mar 2005 08:38:28 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 88B223547F; Tue, 29 Mar 2005 08:38:28 -0800 (PST) +Date: Tue, 29 Mar 2005 08:38:28 -0800 (PST) +From: Stephan Szabo +To: Tom Lane +Cc: Simon Riggs , + Karim A Nassar , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-Reply-To: <21616.1112108201@sss.pgh.pa.us> +Message-ID: <20050329083336.G58020@megazone.bigpanda.com> +References: + <1112095776.11750.958.camel@localhost.localdomain> + <20050329054714.V50612@megazone.bigpanda.com> + <20050329061837.A51620@megazone.bigpanda.com> + <21616.1112108201@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/638 +X-Sequence-Number: 11343 + +On Tue, 29 Mar 2005, Tom Lane wrote: + +> Stephan Szabo writes: +> > If there were some way to pass a "limit" into SPI_prepare that was treated +> > similarly to a LIMIT clause for planning purposes but didn't actually +> > change the output plan to only return that number of rows, we could use +> > that. +> +> Hmm ... the planner does have the ability to do that sort of thing (we +> use it for cursors). SPI_prepare doesn't expose the capability. +> Perhaps adding a SPI_prepare variant that does expose it would be the +> quickest route to a solution. +> +> I get a headache every time I look at the RI triggers ;-). Do they + +Me too, honestly. + +> always know at the time of preparing a plan which way it will be used? + +I believe so. I think each saved plan pretty much lives for a single +trigger type/argument set and is basically used in only one place. + +From pgsql-performance-owner@postgresql.org Tue Mar 29 18:19:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EB5155352A + for ; + Tue, 29 Mar 2005 18:19:36 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23160-04 + for ; + Tue, 29 Mar 2005 17:19:27 +0000 (GMT) +Received: from cmailg2.svr.pol.co.uk (cmailg2.svr.pol.co.uk [195.92.195.172]) + by svr1.postgresql.org (Postfix) with ESMTP id 1AB33534A3 + for ; + Tue, 29 Mar 2005 18:19:25 +0100 (BST) +Received: from modem-2006.porcupine.dialup.pol.co.uk ([217.134.199.214] + helo=192.168.0.102) by cmailg2.svr.pol.co.uk with esmtp (Exim 4.14) + id 1DGKMy-0003l7-8U; Tue, 29 Mar 2005 18:19:12 +0100 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Tom Lane +Cc: Karim A Nassar , + Stephan Szabo , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: <21461.1112107257@sss.pgh.pa.us> +References: + <1112095776.11750.958.camel@localhost.localdomain> + <21461.1112107257@sss.pgh.pa.us> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Tue, 29 Mar 2005 18:17:45 +0100 +Message-Id: <1112116665.11750.1017.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/639 +X-Sequence-Number: 11344 + +On Tue, 2005-03-29 at 09:40 -0500, Tom Lane wrote: +> Simon Riggs writes: +> > ...but, I see no way for OidFunctionCall8 to ever return an answer of +> > "always just 1 row, no matter how big the relation"...so tuples_fetched +> > is always proportional to the size of the relation. Are unique indexes +> > treated just as very-low-selectivity indexes? +> +> Yeah. It is not the job of amcostestimate to estimate the number of +> rows, only the index access cost. (IIRC there is someplace in the +> planner that explicitly considers unique indexes as a part of developing +> selectivity estimates ... but it's not that part.) + +Well, I mention this because costsize.c:cost_index *does* calculate the +number of rows returned. If unique indexes are handled elsewhere then +this would not cause problems for them...but for LIMIT queries..? + +cost_index gets the selectivity then multiplies that by number of tuples +in the relation to calc tuples_fetched, so it can use that in the +Mackert & Lohman formula. There's no consideration of the query limits. + +That implies to me that LIMIT queries are not considered correctly in +the M&L formula and thus we are more likely to calculate a too-high cost +for using an index in those circumstances....and thus more likely to +SeqScan for medium sized relations? + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Tue Mar 29 18:32:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F9E9537F0 + for ; + Tue, 29 Mar 2005 18:32:06 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26957-08 + for ; + Tue, 29 Mar 2005 17:31:59 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 36F715372F + for ; + Tue, 29 Mar 2005 18:31:58 +0100 (BST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2THVnOW003341; + Tue, 29 Mar 2005 12:31:49 -0500 (EST) +To: Simon Riggs +Cc: Karim A Nassar , + Stephan Szabo , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: Delete query takes exorbitant amount of time +In-reply-to: <1112116665.11750.1017.camel@localhost.localdomain> +References: + <1112095776.11750.958.camel@localhost.localdomain> + <21461.1112107257@sss.pgh.pa.us> + <1112116665.11750.1017.camel@localhost.localdomain> +Comments: In-reply-to Simon Riggs + message dated "Tue, 29 Mar 2005 18:17:45 +0100" +Date: Tue, 29 Mar 2005 12:31:49 -0500 +Message-ID: <3340.1112117509@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/640 +X-Sequence-Number: 11345 + +Simon Riggs writes: +> That implies to me that LIMIT queries are not considered correctly in +> the M&L formula and thus we are more likely to calculate a too-high cost +> for using an index in those circumstances....and thus more likely to +> SeqScan for medium sized relations? + +You misunderstand how LIMIT is handled. The plan structure is + + LIMIT ... + regular plan ... + +and so the strategy is to plan and cost the regular plan as though it +would be carried out in full, and then take an appropriate fraction +of that at the LIMIT stage. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 29 19:11:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 968FB53527 + for ; + Tue, 29 Mar 2005 19:11:22 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37301-05 + for ; + Tue, 29 Mar 2005 18:11:12 +0000 (GMT) +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by svr1.postgresql.org (Postfix) with ESMTP id B6BE553459 + for ; + Tue, 29 Mar 2005 19:11:11 +0100 (BST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1DGLBA-0001sa-00; Tue, 29 Mar 2005 13:11:04 -0500 +To: pg@fastcrypt.com +Cc: pgsql-performance@postgresql.org +Subject: Re: How to improve db performance with $7K? +References: <42443863.4040302@sfnet.cc> <4244A90B.2030200@sfnet.cc> + <42453273.2060509@turtle-entertainment.de> + <200503261255.59007.josh@agliodbs.com> <42455DEC.2080301@sfnet.cc> + <1112049794.23284.29.camel@localhost.localdomain> + <424840AE.3050200@sfnet.cc> + <42494741.7060806@fastcrypt.com> +In-Reply-To: <42494741.7060806@fastcrypt.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 29 Mar 2005 13:11:04 -0500 +Message-ID: <87ekdyz5jb.fsf@stark.xeocode.com> +Lines: 28 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/641 +X-Sequence-Number: 11346 + + +Dave Cramer writes: + +> PFC wrote: +> > +> > My Laptop does 19 MB/s (reading <10 KB files, reiser4) ! +> +> Yeah, 35Mb per sec is slow for a raid controller, the 3ware mirrored is +> about 50Mb/sec, and striped is about 100 + +Well you're comparing apples and oranges here. A modern 7200rpm drive should +be capable of doing 40-50MB/s depending on the location of the data on the +disk. + +But that's only doing sequential access of data using something like dd and +without other processes intervening and causing seeks. In practice it seems a +busy databases see random_page_costs of about 4 which for a drive with 10ms +seek time translates to only about 3.2MB/s. + +I think the first order of business is getting pg_xlog onto its own device. +That alone should remove a lot of the seeking. If it's an ext3 device I would +also consider moving the journal to a dedicated drive as well. (or if they're +scsi drives or you're sure the raid controller is safe from write caching then +just switch file systems to something that doesn't journal data.) + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Mar 29 19:33:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3F5CE53848 + for ; + Tue, 29 Mar 2005 19:33:26 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45530-02 + for ; + Tue, 29 Mar 2005 18:33:24 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.200]) + by svr1.postgresql.org (Postfix) with ESMTP id BFE72533E9 + for ; + Tue, 29 Mar 2005 19:33:23 +0100 (BST) +Received: by wproxy.gmail.com with SMTP id 68so676617wra + for ; + Tue, 29 Mar 2005 10:33:24 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; + b=kyS9YP2UysK13lsh9nzRkrlpGNsXaSz/L+uFG3mRa/H1dFn3mKdj7IMNKTn/sAw1/UwWypQMt0ehfeyCjsyw4v4crruw5rEVpgrFDTHjpBu59xLbHe4ZOjoHu+jKzXo2pGGdIuTbzuSEQf12XAJGoC5q3UhC6D0Zt34N/X5JuEs= +Received: by 10.54.27.4 with SMTP id a4mr1136593wra; + Tue, 29 Mar 2005 10:33:24 -0800 (PST) +Received: by 10.54.54.69 with HTTP; Tue, 29 Mar 2005 10:33:24 -0800 (PST) +Message-ID: +Date: Tue, 29 Mar 2005 15:33:24 -0300 +From: Vinicius Bernardi +Reply-To: Vinicius Bernardi +To: pgsql-performance@postgresql.org +Subject: Million of rows +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.398 tagged_above=0 required=5 + tests=DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/642 +X-Sequence-Number: 11347 + +Hi everybody... + +I'm new hear, and I will try to explain my problem, and maybe I can +get a help... + +I'm writing a software for 3 years, and this software has the position +GPS from vehicles, and other informations. + +My problem starts when I had to store all the data about the vehicles, +about 1 or 2 months. + +Actually I had a table called DADO_LIDO, that I write all information +and the primary key is DATA (GPS DAY+HOUR) and the VEHICLE IDENTIFY. + +Each vehicle trasmit 1 position by 30 seconds, so I have something +like 2000 rows per vehicle/day. I already has 2 clients one with 4000 +vehicles, and the other with 500 vehicles. + +My application was made in delphi using ZEOS that's permit me testing +in mysql and postgres. + +I allready has the two databases. + +But now the problem starts when I has to select data from this +vehicles about the history ( I store only 2 months ) something like 40 +or 50 millions of data about 500 vehicles. + +Using the keys VEHICLE_ID and GPS_TIME, the perfomance is very low... + +I need some ideas for a better perfomance in this table + +using selects by +PERIOD / VEHICLE +PERIOD / VEHICLES +PERIOD / VEHICLE / ( a bit test in 3 integer columns using logical operators ) + +Thanks for any help + +Vinicius Marques De Bernardi + +From pgsql-performance-owner@postgresql.org Tue Mar 29 19:55:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A3CD538D9 + for ; + Tue, 29 Mar 2005 19:55:07 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52302-01 + for ; + Tue, 29 Mar 2005 18:54:59 +0000 (GMT) +Received: from cmailg2.svr.pol.co.uk (cmailg2.svr.pol.co.uk [195.92.195.172]) + by svr1.postgresql.org (Postfix) with ESMTP id 8EF3B538D5 + for ; + Tue, 29 Mar 2005 19:54:59 +0100 (BST) +Received: from modem-2253.llama.dialup.pol.co.uk ([217.135.184.205] + helo=192.168.0.102) by cmailg2.svr.pol.co.uk with esmtp (Exim 4.14) + id 1DGLrZ-0005Uo-4S; Tue, 29 Mar 2005 19:54:53 +0100 +Subject: Re: Delete query takes exorbitant amount of time +From: Simon Riggs +To: Tom Lane +Cc: Karim A Nassar , + Stephan Szabo , + Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: <3340.1112117509@sss.pgh.pa.us> +References: + <1112095776.11750.958.camel@localhost.localdomain> + <21461.1112107257@sss.pgh.pa.us> + <1112116665.11750.1017.camel@localhost.localdomain> + <3340.1112117509@sss.pgh.pa.us> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Tue, 29 Mar 2005 19:53:26 +0100 +Message-Id: <1112122406.11750.1055.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/643 +X-Sequence-Number: 11348 + +On Tue, 2005-03-29 at 12:31 -0500, Tom Lane wrote: +> Simon Riggs writes: +> > That implies to me that LIMIT queries are not considered correctly in +> > the M&L formula and thus we are more likely to calculate a too-high cost +> > for using an index in those circumstances....and thus more likely to +> > SeqScan for medium sized relations? +> +> You misunderstand how LIMIT is handled. + +Huh? Well, not this time. (Though my error rate is admittedly high.) + +> The plan structure is +> +> LIMIT ... +> regular plan ... +> +> and so the strategy is to plan and cost the regular plan as though it +> would be carried out in full, and then take an appropriate fraction +> of that at the LIMIT stage. + +To cost it as if it would be carried out in full and then not execute in +full is the same thing as saying it overestimates the actual execution +cost. Which can lead to selection of SeqScan plan when the IndexScan +would have been cheaper, all things considered. + +...it could work like this + + LIMIT .... + regular plan (plan chosen knowing that LIMIT follows) + +so that the LIMIT would be considered in the M&L formula. + +Not that I am driven by how other systems work, but both DB2 and Oracle +allow this form of optimization. + +There's not a huge benefit in sending LIMIT 1 through on the FK check +queries unless they'd be taken into account in the planning. + +Anyway, I'm not saying I know how to do this yet/ever, just to say it is +possible to use the information available to better effect. + +This looks like a TODO item to me? Thoughts? + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Tue Mar 29 20:08:38 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D72DB538E9 + for ; + Tue, 29 Mar 2005 20:08:36 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56560-02 + for ; + Tue, 29 Mar 2005 19:08:27 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id C975A53465 + for ; + Tue, 29 Mar 2005 20:08:25 +0100 (BST) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j2TJ8F2L001236 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Tue, 29 Mar 2005 12:08:18 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j2TJ8FfD015539; + Tue, 29 Mar 2005 12:08:15 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j2TJ8FIX015538; + Tue, 29 Mar 2005 12:08:15 -0700 (MST) (envelope-from mfuhr) +Date: Tue, 29 Mar 2005 12:08:15 -0700 +From: Michael Fuhr +To: Vinicius Bernardi +Cc: pgsql-performance@postgresql.org +Subject: Re: Million of rows +Message-ID: <20050329190815.GA15447@winnie.fuhr.org> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/644 +X-Sequence-Number: 11349 + +On Tue, Mar 29, 2005 at 03:33:24PM -0300, Vinicius Bernardi wrote: +> +> But now the problem starts when I has to select data from this +> vehicles about the history ( I store only 2 months ) something like 40 +> or 50 millions of data about 500 vehicles. +> +> Using the keys VEHICLE_ID and GPS_TIME, the perfomance is very low... + +Please post an example query and the EXPLAIN ANALYZE output. The +table definition might be useful too. + +> I need some ideas for a better perfomance in this table + +Do you have indexes where you need them? Do you cluster on any of +the indexes? Do you VACUUM and ANALYZE the database regularly? +Have you investigated whether you need to increase the statistics +on any columns? Have you tuned postgresql.conf? What version of +PostgreSQL are you using? + +-- +Michael Fuhr +http://www.fuhr.org/~mfuhr/ + +From pgsql-performance-owner@postgresql.org Tue Mar 29 22:10:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D68F7535CD + for ; + Tue, 29 Mar 2005 22:10:49 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93789-01 + for ; + Tue, 29 Mar 2005 21:10:45 +0000 (GMT) +Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.199]) + by svr1.postgresql.org (Postfix) with ESMTP id F2E5F53603 + for ; + Tue, 29 Mar 2005 22:10:44 +0100 (BST) +Received: by wproxy.gmail.com with SMTP id 68so733549wra + for ; + Tue, 29 Mar 2005 13:10:46 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; + b=CQsMr81v/u3hpa/SunFXQPhYrM9/h59YPJ2DpWzE5/St7xxQFIbG9jpCl9W0dNaUNR/1/3U9tO7qnHT3AVg5f3G+BiB9gCmOkk/fUCvVt8lqaPP39vvl7JAIvgxwc9Kgj2lJKWQakZ0gs3EBLjpX3Y3uGCKd4sCTIg+LLd5G3Ek= +Received: by 10.54.2.72 with SMTP id 72mr66818wrb; + Tue, 29 Mar 2005 13:10:45 -0800 (PST) +Received: by 10.54.54.69 with HTTP; Tue, 29 Mar 2005 13:10:44 -0800 (PST) +Message-ID: +Date: Tue, 29 Mar 2005 18:10:44 -0300 +From: Vinicius Bernardi +Reply-To: Vinicius Bernardi +To: pgsql-performance@postgresql.org +Subject: Re: Million of rows +In-Reply-To: <20050329190815.GA15447@winnie.fuhr.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +References: + <20050329190815.GA15447@winnie.fuhr.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.304 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/645 +X-Sequence-Number: 11350 + +At now I have this system runing in a mysql, all the examples I have +are in mysql, but the biggest client that will start now, we will use +PostgreSQL, so I need a way to do those questions in postgres... +Ideas like TABLESPACES or anothe things... + +Just looking for start ideas... + +Thanks + +Vinicius Marques De Bernardi + + +On Tue, 29 Mar 2005 12:08:15 -0700, Michael Fuhr wrote: +> On Tue, Mar 29, 2005 at 03:33:24PM -0300, Vinicius Bernardi wrote: +> > +> > But now the problem starts when I has to select data from this +> > vehicles about the history ( I store only 2 months ) something like 40 +> > or 50 millions of data about 500 vehicles. +> > +> > Using the keys VEHICLE_ID and GPS_TIME, the perfomance is very low... +> +> Please post an example query and the EXPLAIN ANALYZE output. The +> table definition might be useful too. +> +> > I need some ideas for a better perfomance in this table +> +> Do you have indexes where you need them? Do you cluster on any of +> the indexes? Do you VACUUM and ANALYZE the database regularly? +> Have you investigated whether you need to increase the statistics +> on any columns? Have you tuned postgresql.conf? What version of +> PostgreSQL are you using? +> +> -- +> Michael Fuhr +> http://www.fuhr.org/~mfuhr/ +> + +From pgsql-performance-owner@postgresql.org Wed Mar 30 01:49:39 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C286D536FD + for ; + Wed, 30 Mar 2005 01:49:36 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49548-10 + for ; + Wed, 30 Mar 2005 00:49:29 +0000 (GMT) +Received: from mailgate3.nau.edu (mailgate3.nau.edu [134.114.96.145]) + by svr1.postgresql.org (Postfix) with ESMTP id CDFB6536DD + for ; + Wed, 30 Mar 2005 01:49:28 +0100 (BST) +Received: from CONVERSION-DAEMON.mailgate3.nau.edu by mailgate3.nau.edu + (PMDF V6.2-X17 #30845) id <0IE5007013MIT6@mailgate3.nau.edu> for + pgsql-performance@postgresql.org; Tue, 29 Mar 2005 17:49:31 -0700 (MST) +Received: from k2.cet.nau.edu (net9-213.cet.nau.edu [134.114.9.213]) + by mailgate3.nau.edu (PMDF V6.2-X17 #30845) + with ESMTP id <0IE500DN23MH3V@mailgate3.nau.edu> for + pgsql-performance@postgresql.org; Tue, 29 Mar 2005 17:49:29 -0700 (MST) +Date: Tue, 29 Mar 2005 17:52:58 -0700 +From: Karim Nassar +Subject: VACUUM on duplicate DB gives FSM and total pages discrepancies +To: pgsql-performance@postgresql.org +Message-id: <1112143978.9077.29.camel@k2.cet.nau.edu> +MIME-version: 1.0 +X-Mailer: Evolution 2.0.2 +Content-type: text/plain +Content-transfer-encoding: 7BIT +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/646 +X-Sequence-Number: 11351 + +I recently pg_dumpall'd my DB from a (used for testing) v20z install of +postgresql 8.0.1, and restored it to my production (but not yet in +service) v40z running the same version. The test DB has had multiple +millions of rows created/dropped during testing. The results of VACUUM +VERBOSE are giving me pause: + +* v40z (hardly used after restore): + +orfs=# vacuum full analyze verbose; + +INFO: free space map: 114 relations, 84 pages stored; 1824 total pages needed +DETAIL: Allocated FSM size: 1000 relations + 300000 pages = 1864 kB shared memory. +VACUUM + + +* v20z (after having undergone extensive tweaking, deletes, and inserts): + +orfs=# vacuum full analyze verbose; + +INFO: free space map: 53 relations, 13502 pages stored; 9776 total pages needed +DETAIL: Allocated FSM size: 1000 relations + 300000 pages = 1864 kB shared memory. +VACUUM + +1) Should I be concerned about the total pages needed? ISTM that using +that many more pages can't help but degrade relative performance on my +testing machine. + +2) How is it that my FSM has different numbers of relations? + +3) Are either of these affects normal for an oft-used (or not) DB? + +FWIW: + v40z v20z +maintenance_work_mem 262144 16384 +shared_buffers 30000 1000 + +Thanks, +-- +Karim Nassar +Department of Computer Science +Box 15600, College of Engineering and Natural Sciences +Northern Arizona University, Flagstaff, Arizona 86011 +Office: (928) 523-5868 -=- Mobile: (928) 699-9221 + + +From pgsql-performance-owner@postgresql.org Wed Mar 30 12:03:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AA63453A8F + for ; + Wed, 30 Mar 2005 12:03:06 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46964-06 + for ; + Wed, 30 Mar 2005 11:02:57 +0000 (GMT) +Received: from mx0.ffm0.de.carpe.net (mx0.ffm0.de.carpe.net [212.96.133.12]) + by svr1.postgresql.org (Postfix) with ESMTP id B8E2353A87 + for ; + Wed, 30 Mar 2005 12:02:55 +0100 (BST) +Received: by mx0.ffm0.de.carpe.net (Postfix, from userid 2000) + id 204E75619; Wed, 30 Mar 2005 13:02:52 +0200 (CEST) +Received: from [192.168.0.102] (host-217-159-10-74.satlynx.net + [217.159.10.74]) + by mx0.ffm0.de.carpe.net (Postfix) with ESMTP id CBFAE55E7; + Wed, 30 Mar 2005 13:02:47 +0200 (CEST) +Mime-Version: 1.0 (Apple Message framework v619.2) +Content-Type: text/plain; charset=WINDOWS-1252; format=flowed +Message-Id: +Content-Transfer-Encoding: quoted-printable +From: Marc Burgauer +Subject: Reading recommendations +Date: Wed, 30 Mar 2005 12:07:29 +0100 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.619.2) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/647 +X-Sequence-Number: 11352 + +Hi + +I am looking for some references to literature. While we have used=20 +PostgreSQL in the past for a fair number of smaller projects, we are=20 +now starting to use it on a larger scale and hence need to get into=20 +issues of performance optimisation and tuning. While I am OK with using=20= + +the EXPLAIN features, I am getting quite insecure when facing things=20 +like the options in the postgresql.conf file. For example reading the=20 +man page on fsync option, it tells me to "read the detailed=20 +documentation before using this!" I then read the Admin guide where I=20 +get told that the benefits of this feature are issue of debate, leaving=20= + +me with little help as to how to make up my mind on this issue. So I=20 +turn to this mailing list, but starting reading in the archive realise=20= + +that compared to the knowledge standard here, I am as wise as a baby. + +I have read most of Bruce Momjian's book on PostgreSQL (Can I update my=20= + +2001 edition somehow? ;-) +I have Sams' PostgreSQL Developer's Handbook (which is OK too), but=20 +offers little to nothing on operational issues. +I have read most of the admin (and user) guide, but it does not help me=20= + +really understand the issues: +> CPU_INDEX_TUPLE_COST (floating point) Sets the query optimizer=92s=20 +> estimate of the cost of processing each index tuple during an index=20 +> scan. This is measured as a fraction of the cost of a sequential page=20= + +> fetch. +No idea what this means! (And should I feel bad for it?) + +I am an application programmer with a little UNIX know-how. + +What books or sources are out there that I can buy/download and that I=20= + +should read to get to grips with the more advanced issues of running=20 +PostgreSQL? + +More on what we do (for those interested): +We use PostgreSQL mainly with its PostGIS extension as the database=20 +backend for Zope-based applications. Adding PostGIS features is what=20 +has started to cause noticeable increase in the server load. +We're using the GIS enabled system on this platform: +PostgreSQL 7.3.4 +PostGIS 0.8 +Zope 2.7.5 +Python 2.3.5 +(Database-based functions are written in PL/PGSQL, not python!!) + +on a 2-CPU (450MHz Intel P3) Compaq box (some Proliant flavour) +With a SCSI 4-disk RAID system (mirrored and striped) +SunOS 5.8 (Which I think is Solaris 8) + +The server is administrated by my host (co-located). We cannot easily=20 +upgrade to a newer version of Solaris, because we could not find a=20 +driver for the disk controller used in this server. (And our host did=20 +not manage to write/patch one up.) + +As a business, we are creating and operating on-line communities, (for=20= + +an example go to http://www.theguidlife.net) not only from a technical=20= + +point of view, but also supporting the communities in producing=20 +content. + +BTW. If you are a SQL/python programmer in (or near) Lanarkshire,=20 +Scotland, we have a vacancy. ;-) + +Cheers + +Marc + +-- +Marc Burgauer + +Sharedbase Ltd +http://www.sharedbase.com +Creating and supporting on-line communities= + + +From pgsql-performance-owner@postgresql.org Wed Mar 30 13:37:31 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4EA2953429 + for ; + Wed, 30 Mar 2005 13:37:30 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71660-09 + for ; + Wed, 30 Mar 2005 12:37:21 +0000 (GMT) +Received: from ns.aprote.ee (ns.aprote.ee [80.235.78.106]) + by svr1.postgresql.org (Postfix) with ESMTP id E70415294A + for ; + Wed, 30 Mar 2005 13:37:19 +0100 (BST) +Received: Message by Barricade ns.aprote.ee with ESMTP id j2UCccYC012064 + for ; Wed, 30 Mar 2005 15:38:38 +0300 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6556.0 +Subject: Weird index scan +Date: Wed, 30 Mar 2005 15:37:18 +0300 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Weird index scan +Thread-Index: AcU1JTYt1ORPi3YHQQmAd84/HuG17Q== +From: "Tambet Matiisen" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/648 +X-Sequence-Number: 11353 + + +I'm getting weird results for one of my queries. The actual time of this +index scan doesn't make any sense: + +-> Index Scan using dok_dok_fk_i on dokumendid a (cost=3D0.00..566.24 +rows=3D184 width=3D8) (actual time=3D0.170..420806.563 rows=3D1 = +loops=3D1)=20 + +dok_dok_fk_i is index on dokumendid(dok_dok_id). Currently it contains +mostly NULLs: + +pos1=3D# select dok_dok_id, count(1) from dokumendid group by = +dok_dok_id; + dok_dok_id | count +------------+------- + | 11423 + 8034 | 76 +(2 rows) + +If I drop the index, seq scan + sort is used instead and everything is +fast again. + +The PostgreSQL version: + +pos1=3D# select version(); + version +------------------------------------------------------------------------ +------------------------------ + PostgreSQL 7.4.5 on i386-pc-linux-gnu, compiled by GCC i386-linux-gcc +(GCC) 3.3.4 (Debian 1:3.3.4-9) +(1 row) + +The full EXPLAIN ANALYZE output: + +pos1=3D# explain analyze select * from v_inventuuri_vahed_kaubagrupiti; +=20 +QUERY PLAN =20 +------------------------------------------------------------------------ +------------------------------------------------------------------------ +------------------------------------------------- + Subquery Scan v_inventuuri_vahed_kaubagrupiti = +(cost=3D50896.04..50896.61 +rows=3D46 width=3D128) (actual time=3D437007.670..437007.817 rows=3D45 = +loops=3D1) + -> Sort (cost=3D50896.04..50896.15 rows=3D46 width=3D42) (actual +time=3D437007.664..437007.692 rows=3D45 loops=3D1) + Sort Key: (COALESCE(sum(ir.summa_kmta), 0::numeric))::raha + -> HashAggregate (cost=3D50893.85..50894.77 rows=3D46 = +width=3D42) +(actual time=3D437007.229..437007.488 rows=3D45 loops=3D1) + -> Hash Join (cost=3D5533.44..50807.93 rows=3D5728 +width=3D42) (actual time=3D436226.533..436877.499 rows=3D16271 = +loops=3D1) + Hash Cond: ("outer".kau_kau_id =3D "inner".kau_id) + -> Merge Right Join (cost=3D4759.52..49858.92 +rows=3D15696 width=3D26) (actual time=3D436117.333..436600.653 = +rows=3D16271 +loops=3D1) + Merge Cond: (("outer".dok_dok_id =3D +"inner".dok_id) AND ("outer".kau_kau_id =3D "inner".kau_kau_id)) + -> Index Scan using dor_dok_kau_i on +dokumentide_read ar (cost=3D0.00..42789.44 rows=3D480962 width=3D19) = +(actual +time=3D0.023..7873.117 rows=3D205879 loops=3D1) + -> Sort (cost=3D4759.52..4798.76 = +rows=3D15696 +width=3D19) (actual time=3D428381.719..428392.204 rows=3D16271 = +loops=3D1) + Sort Key: a.dok_id, ir.kau_kau_id + -> Merge Left Join +(cost=3D0.00..3665.65 rows=3D15696 width=3D19) (actual = +time=3D0.245..428279.595 +rows=3D16258 loops=3D1) + Merge Cond: ("outer".dok_id =3D +"inner".dok_dok_id) + -> Nested Loop +(cost=3D0.00..3620.23 rows=3D15696 width=3D19) (actual = +time=3D0.063..7243.529 +rows=3D16258 loops=3D1) + -> Index Scan using dok_pk +on dokumendid i (cost=3D0.00..3.73 rows=3D1 width=3D4) (actual +time=3D0.030..0.035 rows=3D1 loops=3D1) + Index Cond: (dok_id = +=3D +8034) + Filter: (tyyp =3D +'IN'::bpchar) + -> Index Scan using +dor_dok_fk_i on dokumentide_read ir (cost=3D0.00..3459.55 rows=3D15696 +width=3D19) (actual time=3D0.023..7150.257 rows=3D16258 loops=3D1) + Index Cond: (8034 =3D +dok_dok_id) + -> Index Scan using dok_dok_fk_i +on dokumendid a (cost=3D0.00..566.24 rows=3D184 width=3D8) (actual +time=3D0.170..420806.563 rows=3D1 loops=3D1) + Filter: (tyyp =3D +'IA'::bpchar) + -> Hash (cost=3D757.71..757.71 rows=3D6487 = +width=3D24) +(actual time=3D109.178..109.178 rows=3D0 loops=3D1) + -> Hash Join (cost=3D15.56..757.71 = +rows=3D6487 +width=3D24) (actual time=3D1.787..85.554 rows=3D17752 loops=3D1) + Hash Cond: ("outer".kag_kag_id =3D +"inner".a_kag_id) + -> Seq Scan on kaubad k +(cost=3D0.00..588.52 rows=3D17752 width=3D8) (actual = +time=3D0.005..30.952 +rows=3D17752 loops=3D1) + -> Hash (cost=3D15.35..15.35 = +rows=3D83 +width=3D24) (actual time=3D1.770..1.770 rows=3D0 loops=3D1) + -> Hash Join = +(cost=3D5.39..15.35 +rows=3D83 width=3D24) (actual time=3D0.276..1.491 rows=3D227 loops=3D1) + Hash Cond: +("outer".y_kag_id =3D "inner".kag_id) + -> Seq Scan on +kaubagruppide_kaubagrupid gg (cost=3D0.00..7.09 rows=3D409 width=3D8) = +(actual +time=3D0.004..0.405 rows=3D409 loops=3D1) + -> Hash = +(cost=3D5.27..5.27 +rows=3D46 width=3D20) (actual time=3D0.259..0.259 rows=3D0 loops=3D1) + -> Seq Scan on +kaubagrupid g (cost=3D0.00..5.27 rows=3D46 width=3D20) (actual +time=3D0.010..0.206 rows=3D46 loops=3D1) + Filter: +(kag_kag_id IS NULL) + Total runtime: 437011.532 ms +(33 rows) + + Tambet + +From pgsql-performance-owner@postgresql.org Wed Mar 30 16:19:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A7EE533F2 + for ; + Wed, 30 Mar 2005 16:19:11 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25494-10 + for ; + Wed, 30 Mar 2005 15:19:03 +0000 (GMT) +Received: from sunsite.dcc.uchile.cl (sunsite.dcc.uchile.cl [192.80.24.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B630533C9 + for ; + Wed, 30 Mar 2005 16:19:02 +0100 (BST) +Received: from anakena.dcc.uchile.cl (anakena [192.80.24.6]) + by sunsite.dcc.uchile.cl (8.12.11/8.12.11) with ESMTP id j2UFJ3IV012731; + Wed, 30 Mar 2005 11:19:04 -0400 (CLT) +Received: by anakena.dcc.uchile.cl (Postfix, from userid 4151) + id C999D529D3; Wed, 30 Mar 2005 11:19:03 -0400 (CLT) +Date: Wed, 30 Mar 2005 11:19:03 -0400 +From: Alvaro Herrera +To: Karim Nassar +Cc: pgsql-performance@postgresql.org +Subject: Re: VACUUM on duplicate DB gives FSM and total pages discrepancies +Message-ID: <20050330151903.GD32434@dcc.uchile.cl> +References: <1112143978.9077.29.camel@k2.cet.nau.edu> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1112143978.9077.29.camel@k2.cet.nau.edu> +User-Agent: Mutt/1.5.8i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.344 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/649 +X-Sequence-Number: 11354 + +On Tue, Mar 29, 2005 at 05:52:58PM -0700, Karim Nassar wrote: +> I recently pg_dumpall'd my DB from a (used for testing) v20z install of +> postgresql 8.0.1, and restored it to my production (but not yet in +> service) v40z running the same version. The test DB has had multiple +> millions of rows created/dropped during testing. The results of VACUUM +> VERBOSE are giving me pause: + +The FSM only stores pages that have some free space. If the database +has only been through a restore, then probably there aren't many of +those. After you start playing with the data some more pages will need +registering. So the behavior you are seeing is expected. + +-- +Alvaro Herrera () +"We are who we choose to be", sang the goldfinch +when the sun is high (Sandman) + +From pgsql-performance-owner@postgresql.org Wed Mar 30 16:58:32 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 463E452A60 + for ; + Wed, 30 Mar 2005 16:58:31 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39655-01 + for ; + Wed, 30 Mar 2005 15:58:21 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A3FE537F7 + for ; + Wed, 30 Mar 2005 16:58:20 +0100 (BST) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j2UFwL2h002500 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Wed, 30 Mar 2005 08:58:24 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j2UFwLLf035547; + Wed, 30 Mar 2005 08:58:21 -0700 (MST) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j2UFwLA3035546; + Wed, 30 Mar 2005 08:58:21 -0700 (MST) (envelope-from mfuhr) +Date: Wed, 30 Mar 2005 08:58:21 -0700 +From: Michael Fuhr +To: Marc Burgauer +Cc: pgsql-performance@postgresql.org +Subject: Re: Reading recommendations +Message-ID: <20050330155820.GA35510@winnie.fuhr.org> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/650 +X-Sequence-Number: 11355 + +On Wed, Mar 30, 2005 at 12:07:29PM +0100, Marc Burgauer wrote: +> +> What books or sources are out there that I can buy/download and that I +> should read to get to grips with the more advanced issues of running +> PostgreSQL? + +See the Power PostgreSQL Performance & Configuration documents: + +http://www.powerpostgresql.com/Docs/ + +> BTW. If you are a SQL/python programmer in (or near) Lanarkshire, +> Scotland, we have a vacancy. ;-) + +Allow telecommute from across the pond and I might be interested :-) + +-- +Michael Fuhr +http://www.fuhr.org/~mfuhr/ + +From pgsql-performance-owner@postgresql.org Wed Mar 30 17:29:03 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 431B153BA9; + Wed, 30 Mar 2005 17:29:00 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50560-02; Wed, 30 Mar 2005 16:28:55 +0000 (GMT) +Received: from dfw-gate1.raytheon.com (dfw-gate1.raytheon.com + [199.46.199.230]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E76153351; + Wed, 30 Mar 2005 17:28:50 +0100 (BST) +Received: from ds02c00.directory.ray.com (ds02c00.directory.ray.com + [147.25.138.118]) + by dfw-gate1.raytheon.com (8.12.10/8.12.10) with ESMTP id + j2UGShqd016197; Wed, 30 Mar 2005 10:28:44 -0600 (CST) +Received: from ds02c00 (localhost [127.0.0.1]) + by ds02c00.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id + j2UGSWCP027936; Wed, 30 Mar 2005 16:28:37 GMT +Received: from ds02c00.directory.ray.com with LMTP by ds02c00 + (2.0.6/sieved-2-0-build-559); Wed, 30 Mar 2005 16:28:32 +0000 +Received: from notesserver5.ftw.us.ray.com (notesserver5.ftw.us.ray.com + [151.168.145.35]) + by ds02c00.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id + j2UGR8FN027380 sender Richard_D_Levine@raytheon.com; + Wed, 30 Mar 2005 16:27:19 GMT +In-Reply-To: <20050330155820.GA35510@winnie.fuhr.org> +Subject: Re: Reading recommendations +To: Michael Fuhr +Cc: Marc Burgauer , pgsql-performance@postgresql.org, + pgsql-performance-owner@postgresql.org +X-Mailer: Lotus Notes Release 6.5.2 June 01, 2004 +Message-ID: + +From: Richard_D_Levine@Raytheon.com +Date: Wed, 30 Mar 2005 11:27:07 -0500 +X-MIMETrack: Serialize by Router on NotesServer5/HDC(Release 6.5.2|June 01, + 2004) at 03/30/2005 11:27:19 AM +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +X-SPAM: 0.00 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.211 tagged_above=0 required=5 tests=AWL, + NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200503/651 +X-Sequence-Number: 11356 + + + +pgsql-performance-owner@postgresql.org wrote on 03/30/2005 10:58:21 AM: + +> +> Allow telecommute from across the pond and I might be interested :-) + +Please post phone bills to this list. + +> +> -- +> Michael Fuhr +> http://www.fuhr.org/~mfuhr/ +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly + + +From pgsql-performance-owner@postgresql.org Wed Mar 30 17:41:11 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D9B35361D + for ; + Wed, 30 Mar 2005 17:41:09 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51498-10 + for ; + Wed, 30 Mar 2005 16:40:59 +0000 (GMT) +Received: from imail01.arbinet.com (imail.arbinet.com [64.74.47.121]) + by svr1.postgresql.org (Postfix) with ESMTP id AE1F1534F8 + for ; + Wed, 30 Mar 2005 17:40:58 +0100 (BST) +Received: from imail01.arbinet.com (localhost [127.0.0.1]) + by imail01.arbinet.com (8.12.10/8.12.2) with ESMTP id j2UGeklO004047 + for ; Wed, 30 Mar 2005 16:40:46 GMT +Received: from vamail01.TheXchange.com (mailbox.arbinet.com [64.74.47.120]) + by imail01.arbinet.com (8.12.2/8.12.2) with SMTP id j2UGeitP004032 + for ; Wed, 30 Mar 2005 16:40:46 GMT +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Reading recommendations +Date: Wed, 30 Mar 2005 16:39:47 -0000 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Reading recommendations +Thread-Index: AcU1Rhr0dz5ln5q7QcCNXBAl4xWviwAAOC3g +From: "Mohan, Ross" +To: +X-Spam-Details: Hits=-104.9, Required=2, Tests=BAYES_00,USER_IN_WHITELIST +X-Scanned-By: MIMEDefang 2.39 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.57 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/652 +X-Sequence-Number: 11357 + +VOIP over BitTorrent? =20 + +;-) + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org = +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of = +Richard_D_Levine@Raytheon.com +Sent: Wednesday, March 30, 2005 11:27 AM +To: Michael Fuhr +Cc: Marc Burgauer; pgsql-performance@postgresql.org; = +pgsql-performance-owner@postgresql.org +Subject: Re: [PERFORM] Reading recommendations + + + + +pgsql-performance-owner@postgresql.org wrote on 03/30/2005 10:58:21 AM: + +> +> Allow telecommute from across the pond and I might be interested :-) + +Please post phone bills to this list. + +> +> -- +> Michael Fuhr + +From pgsql-performance-owner@postgresql.org Wed Mar 30 17:52:29 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D6EF752D42 + for ; + Wed, 30 Mar 2005 17:52:28 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58269-01 + for ; + Wed, 30 Mar 2005 16:52:26 +0000 (GMT) +Received: from noao.edu (noao.edu [140.252.1.54]) + by svr1.postgresql.org (Postfix) with ESMTP id 74CC05294A + for ; + Wed, 30 Mar 2005 17:52:25 +0100 (BST) +X-TFF-CGPSA-Version: 1.4f1 +X-TFF-CGPSA-Filter: Scanned +Received: from [140.252.14.8] (HELO weaver.tuc.noao.edu) + by noao.edu (CommuniGate Pro SMTP 4.2.10) + with ESMTP-TLS id 17414552; Wed, 30 Mar 2005 09:52:19 -0700 +Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) + by weaver.tuc.noao.edu (8.12.8/8.12.8) with ESMTP id j2UGqDHw019629; + Wed, 30 Mar 2005 09:52:14 -0700 +Message-ID: <424AD93D.30601@noao.edu> +Date: Wed, 30 Mar 2005 09:52:13 -0700 +From: Steve Wampler +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Mohan, Ross" +Cc: pgsql-performance@postgresql.org +Subject: Re: Reading recommendations +References: +In-Reply-To: + +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-noao.edu-MailScanner-Information: Please contact the ISP for more + information +X-noao.edu-MailScanner: Found to be clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/653 +X-Sequence-Number: 11358 + +Mohan, Ross wrote: +> VOIP over BitTorrent? + +Now *that* I want to see. Aught to be at least as interesting +as the "TCP/IP over carrier pigeon" experiment - and more +challenging to boot! + + +-- +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +From pgsql-performance-owner@postgresql.org Wed Mar 30 17:58:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 48D2953473 + for ; + Wed, 30 Mar 2005 17:58:31 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59134-04 + for ; + Wed, 30 Mar 2005 16:58:23 +0000 (GMT) +Received: from imail02.thexchange.com (imail.arbinet.com [64.74.47.121]) + by svr1.postgresql.org (Postfix) with ESMTP id F18775345F + for ; + Wed, 30 Mar 2005 17:58:22 +0100 (BST) +Received: from imail02.thexchange.com (localhost [127.0.0.1]) + by imail02.thexchange.com (8.12.10/8.12.2) with ESMTP id j2UHGYBu003100 + for ; Wed, 30 Mar 2005 17:16:45 GMT +Received: from vamail01.TheXchange.com (mailbox.arbinet.com [64.74.47.120]) + by imail02.thexchange.com (8.12.2/8.12.2) with SMTP id j2UHGUdO003076; + Wed, 30 Mar 2005 17:16:33 GMT +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Reading recommendations +Date: Wed, 30 Mar 2005 16:57:59 -0000 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Reading recommendations +Thread-Index: AcU1SNvkxboyBi1mRMiheg7tPpw2bgAAEICg +From: "Mohan, Ross" +To: +X-Spam-Details: Hits=-104.9, Required=2, Tests=BAYES_00,USER_IN_WHITELIST +X-Scanned-By: MIMEDefang 2.39 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.476 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/654 +X-Sequence-Number: 11359 + +Yea, the upside is that you get better than the 1 byte/hour rate for = +pigeon-net.=20 + +Downside is that simply because you use BiTorrent, the RIAA accuses you = +of=20 +everything from CD piracy to shipping pr*n to cyberterrorism, and you = +spend=20 +the next four years in Gitmo, comparing notes with your cellmates in = +Camp X-Ray,=20 +and watching pigeons fly overhead.=20 + + +-----Original Message----- +From: Steve Wampler [mailto:swampler@noao.edu]=20 +Sent: Wednesday, March 30, 2005 11:52 AM +To: Mohan, Ross +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Reading recommendations + + +Mohan, Ross wrote: +> VOIP over BitTorrent? + +Now *that* I want to see. Aught to be at least as interesting as the = +"TCP/IP over carrier pigeon" experiment - and more challenging to boot! + + +--=20 +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +From pgsql-performance-owner@postgresql.org Wed Mar 30 18:23:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B64AB53685 + for ; + Wed, 30 Mar 2005 18:23:08 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67400-05 + for ; + Wed, 30 Mar 2005 17:22:59 +0000 (GMT) +Received: from mail.99main.com (mail.99main.com [208.28.184.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 379E95294A + for ; + Wed, 30 Mar 2005 18:22:57 +0100 (BST) +Received: from 99main.com (localhost [127.0.0.1]) + by mail.99main.com (8.12.8+Sun/8.12.8) with ESMTP id j2UHMtKq004821 + for ; + Wed, 30 Mar 2005 12:22:55 -0500 (EST) +From: "Keith Worthington" +To: "PostgreSQL Perform" +Reply-To: KeithW@narrowpathinc.com +Subject: Dynamic query perormance +Date: Wed, 30 Mar 2005 12:22:55 -0500 +Message-Id: <20050330170418.M61319@narrowpathinc.com> +X-Mailer: Open WebMail 2.50 20050106 +X-OriginatingIP: 68.235.22.242 (npkeithw) +MIME-Version: 1.0 +Content-Type: text/plain; + charset=iso-8859-1 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.11 tagged_above=0 required=5 tests=AWL, + UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200503/655 +X-Sequence-Number: 11360 + +Hi All, + +I am developing a simple set returning function as my first step towards more +complicated processes. I would like to understand the implications of using +the dynamic query capability. + +I have built two forms of an identically performing function. The first uses +a simple IF-THEN-ELSIF-THEN-ELSE structure to choose which query to run. The +second builds the query dynamically using the FOR-IN-EXECUTE structure and a +CASE statement. + +The documentation +(http://www.postgresql.org/docs/8.0/interactive/plpgsql-control-structures.html#PLPGSQL-RECORDS-ITERATING) +indicates that a dynamic query (EXECUTE) is replanned for every LOOP iteration. + + This is like the previous form, except that the source + SELECT statement is specified as a string expression, + which is evaluated and replanned on each entry to the + FOR loop. This allows the programmer to choose the speed + of a preplanned query or the flexibility of a dynamic + query, just as with a plain EXECUTE statement. + +That seems like a potential performance problem. I don't understand why the +query would be planned for every LOOP iteration when the LOOP is over the +record set. + +Your comments are appreciated. + +Kind Regards, +Keith + + +CREATE OR REPLACE FUNCTION func_item_list("varchar") + RETURNS SETOF VARCHAR AS +$BODY$ + DECLARE + v_status ALIAS FOR $1; + r_item_id RECORD; + BEGIN +-- Build the record set using the appropriate query. + IF lower(v_status) = 'active' THEN + FOR r_item_id IN SELECT tbl_item.id + FROM tbl_item + WHERE NOT tbl_item.inactive + ORDER BY tbl_item.id + LOOP + RETURN NEXT r_item_id; + END LOOP; + ELSIF lower(v_status) = 'inactive' THEN + FOR r_item_id IN SELECT tbl_item.id + FROM tbl_item + WHERE tbl_item.inactive + ORDER BY tbl_item.id + LOOP + RETURN NEXT r_item_id; + END LOOP; + ELSE + FOR r_item_id IN SELECT tbl_item.id + FROM tbl_item + ORDER BY tbl_item.id + LOOP + RETURN NEXT r_item_id; + END LOOP; + END IF; + RETURN; + END; +$BODY$ + LANGUAGE 'plpgsql' VOLATILE; + +SELECT * FROM func_item_list('Active'); + + + +CREATE OR REPLACE FUNCTION func_item_list("varchar") + RETURNS SETOF VARCHAR AS +$BODY$ + DECLARE + v_status ALIAS FOR $1; + r_item_id RECORD; + BEGIN +-- Build the record set using a dynamically built query. + FOR r_item_id IN EXECUTE 'SELECT tbl_item.id + FROM tbl_item' || + CASE WHEN lower(v_status) = 'active' THEN + ' WHERE NOT tbl_item.inactive ' + WHEN lower(v_status) = 'inactive' THEN + ' WHERE tbl_item.inactive ' + ELSE + ' ' + END || + ' ORDER BY tbl_item.id' + LOOP + RETURN NEXT r_item_id; + END LOOP; + RETURN; + END; +$BODY$ + LANGUAGE 'plpgsql' VOLATILE; + +SELECT * FROM func_item_list('AcTiVe'); + + +From pgsql-performance-owner@postgresql.org Wed Mar 30 18:42:33 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E939552960 + for ; + Wed, 30 Mar 2005 18:42:31 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74311-02 + for ; + Wed, 30 Mar 2005 17:42:28 +0000 (GMT) +Received: from honorio.sinectis.com.ar (honorio.sinectis.com.ar + [216.244.192.201]) + by svr1.postgresql.org (Postfix) with ESMTP id 88A1E5294A + for ; + Wed, 30 Mar 2005 18:42:26 +0100 (BST) +Received: by honorio.sinectis.com.ar (Postfix, from userid 99) + id 4AA556C8A3; Wed, 30 Mar 2005 14:42:24 -0300 (GMT+3) +Content-Type: text/plain +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +MIME-Version: 1.0 +X-Mailer: Sinectis Webmail 5.6.16-1.5.1 +From: G u i d o B a r o s i o +To: t.matiisen@aprote.ee, pgsql-performance@postgresql.org +Subject: Re: Weird index scan +Reply-To: gbarosio@uolsinectis.com.ar +Message-Id: <20050330174224.4AA556C8A3@honorio.sinectis.com.ar> +Date: Wed, 30 Mar 2005 14:42:24 -0300 (GMT+3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.28 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE +X-Spam-Level: +X-Archive-Number: 200503/656 +X-Sequence-Number: 11361 + +Hi, + +1) seems that the table is a view, I am wrong? If this is true, please +give a query to that table, and try to guess if there is already a bottleneck there. + +2) Add to the query an order by and try to find if it works better. + +3) If you drop the index, and no other index exists, it will always use a seqscan or other method to gather the rows. No other index is plausible to be used there? (perhaps order by indexedcolumn may help). + +A hint, drop that index, identify a usable index, and set enable_seqscan to off; on your session (or as a global value on the conf file) + +Best wishes, +Guido + +> +> I'm getting weird results for one of my queries. The actual time of this +> index scan doesn't make any sense: +> +> -> Index Scan using dok_dok_fk_i on dokumendid a (cost=0.00..566.24 +> rows=184 width=8) (actual time=0.170..420806.563 rows=1 loops=1) +> +> dok_dok_fk_i is index on dokumendid(dok_dok_id). Currently it contains +> mostly NULLs: +> +> pos1=# select dok_dok_id, count(1) from dokumendid group by dok_dok_id; +> dok_dok_id | count +> ------------+------- +> | 11423 +> 8034 | 76 +> (2 rows) +> +> If I drop the index, seq scan + sort is used instead and everything is +> fast again. +> +> The PostgreSQL version: +> +> pos1=# select version(); +> version +> ------------------------------------------------------------------------ +> ------------------------------ +> PostgreSQL 7.4.5 on i386-pc-linux-gnu, compiled by GCC i386-linux-gcc +> (GCC) 3.3.4 (Debian 1:3.3.4-9) +> (1 row) +> +> The full EXPLAIN ANALYZE output: +> +> pos1=# explain analyze select * from v_inventuuri_vahed_kaubagrupiti; +> +> QUERY PLAN +> ------------------------------------------------------------------------ +> ------------------------------------------------------------------------ +> ------------------------------------------------- +> Subquery Scan v_inventuuri_vahed_kaubagrupiti (cost=50896.04..50896.61 +> rows=46 width=128) (actual time=437007.670..437007.817 rows=45 loops=1) +> -> Sort (cost=50896.04..50896.15 rows=46 width=42) (actual +> time=437007.664..437007.692 rows=45 loops=1) +> Sort Key: (COALESCE(sum(ir.summa_kmta), 0::numeric))::raha +> -> HashAggregate (cost=50893.85..50894.77 rows=46 width=42) +> (actual time=437007.229..437007.488 rows=45 loops=1) +> -> Hash Join (cost=5533.44..50807.93 rows=5728 +> width=42) (actual time=436226.533..436877.499 rows=16271 loops=1) +> Hash Cond: ("outer".kau_kau_id = "inner".kau_id) +> -> Merge Right Join (cost=4759.52..49858.92 +> rows=15696 width=26) (actual time=436117.333..436600.653 rows=16271 +> loops=1) +> Merge Cond: (("outer".dok_dok_id = +> "inner".dok_id) AND ("outer".kau_kau_id = "inner".kau_kau_id)) +> -> Index Scan using dor_dok_kau_i on +> dokumentide_read ar (cost=0.00..42789.44 rows=480962 width=19) (actual +> time=0.023..7873.117 rows=205879 loops=1) +> -> Sort (cost=4759.52..4798.76 rows=15696 +> width=19) (actual time=428381.719..428392.204 rows=16271 loops=1) +> Sort Key: a.dok_id, ir.kau_kau_id +> -> Merge Left Join +> (cost=0.00..3665.65 rows=15696 width=19) (actual time=0.245..428279.595 +> rows=16258 loops=1) +> Merge Cond: ("outer".dok_id = +> "inner".dok_dok_id) +> -> Nested Loop +> (cost=0.00..3620.23 rows=15696 width=19) (actual time=0.063..7243.529 +> rows=16258 loops=1) +> -> Index Scan using dok_pk +> on dokumendid i (cost=0.00..3.73 rows=1 width=4) (actual +> time=0.030..0.035 rows=1 loops=1) +> Index Cond: (dok_id = +> 8034) +> Filter: (tyyp = +> 'IN'::bpchar) +> -> Index Scan using +> dor_dok_fk_i on dokumentide_read ir (cost=0.00..3459.55 rows=15696 +> width=19) (actual time=0.023..7150.257 rows=16258 loops=1) +> Index Cond: (8034 = +> dok_dok_id) +> -> Index Scan using dok_dok_fk_i +> on dokumendid a (cost=0.00..566.24 rows=184 width=8) (actual +> time=0.170..420806.563 rows=1 loops=1) +> Filter: (tyyp = +> 'IA'::bpchar) +> -> Hash (cost=757.71..757.71 rows=6487 width=24) +> (actual time=109.178..109.178 rows=0 loops=1) +> -> Hash Join (cost=15.56..757.71 rows=6487 +> width=24) (actual time=1.787..85.554 rows=17752 loops=1) +> Hash Cond: ("outer".kag_kag_id = +> "inner".a_kag_id) +> -> Seq Scan on kaubad k +> (cost=0.00..588.52 rows=17752 width=8) (actual time=0.005..30.952 +> rows=17752 loops=1) +> -> Hash (cost=15.35..15.35 rows=83 +> width=24) (actual time=1.770..1.770 rows=0 loops=1) +> -> Hash Join (cost=5.39..15.35 +> rows=83 width=24) (actual time=0.276..1.491 rows=227 loops=1) +> Hash Cond: +> ("outer".y_kag_id = "inner".kag_id) +> -> Seq Scan on +> kaubagruppide_kaubagrupid gg (cost=0.00..7.09 rows=409 width=8) (actual +> time=0.004..0.405 rows=409 loops=1) +> -> Hash (cost=5.27..5.27 +> rows=46 width=20) (actual time=0.259..0.259 rows=0 loops=1) +> -> Seq Scan on +> kaubagrupid g (cost=0.00..5.27 rows=46 width=20) (actual +> time=0.010..0.206 rows=46 loops=1) +> Filter: +> (kag_kag_id IS NULL) +> Total runtime: 437011.532 ms +> (33 rows) +> +> Tambet +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org + + +From pgsql-performance-owner@postgresql.org Wed Mar 30 19:05:22 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E818D52964 + for ; + Wed, 30 Mar 2005 19:05:20 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81000-06 + for ; + Wed, 30 Mar 2005 18:05:12 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id BDF2F53542 + for ; + Wed, 30 Mar 2005 19:05:10 +0100 (BST) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j2UI4wW0027008; (envelope-from ) Wed, + 30 Mar 2005 12:05:04 -0600 (CST) +Received: from [192.168.1.13] (12-215-118-172.client.mchsi.com + [12.215.118.172]) (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j2UHvoHT018045 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); + (envelope-from ) Wed, + 30 Mar 2005 11:57:52 -0600 (CST) +Message-ID: <424AE89D.6050501@arbash-meinel.com> +Date: Wed, 30 Mar 2005 11:57:49 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: KeithW@narrowpathinc.com +Cc: PostgreSQL Perform +Subject: Re: Dynamic query perormance +References: <20050330170418.M61319@narrowpathinc.com> +In-Reply-To: <20050330170418.M61319@narrowpathinc.com> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig2DF40541C5E82F4251FD0181" +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/658 +X-Sequence-Number: 11363 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig2DF40541C5E82F4251FD0181 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Keith Worthington wrote: + +>Hi All, +> +>I am developing a simple set returning function as my first step towards more +>complicated processes. I would like to understand the implications of using +>the dynamic query capability. +> +>I have built two forms of an identically performing function. The first uses +>a simple IF-THEN-ELSIF-THEN-ELSE structure to choose which query to run. The +>second builds the query dynamically using the FOR-IN-EXECUTE structure and a +>CASE statement. +> +>The documentation +>(http://www.postgresql.org/docs/8.0/interactive/plpgsql-control-structures.html#PLPGSQL-RECORDS-ITERATING) +>indicates that a dynamic query (EXECUTE) is replanned for every LOOP iteration. +> +> This is like the previous form, except that the source +> SELECT statement is specified as a string expression, +> which is evaluated and replanned on each entry to the +> FOR loop. This allows the programmer to choose the speed +> of a preplanned query or the flexibility of a dynamic +> query, just as with a plain EXECUTE statement. +> +>That seems like a potential performance problem. I don't understand why the +>query would be planned for every LOOP iteration when the LOOP is over the +>record set. +> +> +> +Reading the documentation and looking at the example, I don't think +you're query will be re-planned for each entry in the loop. +I think it will be planned each time the FOR loop is started. +If you have the EXECUTE *inside* the LOOP, then it would be re-planned +for each entry. + +At least that is the case for a normal EXECUTE without any for loop. +Each time the function is called, the statement is re-planned. Versus +without EXECUTE when the planning is done at function declaration time. + +I would guess that the FOR .. IN EXECUTE .. LOOP runs the EXECUTE one +time, and generates the results which it then loops over. Because that +is what FOR .. IN SELECT .. LOOP does (you don't re-evaluate the SELECT +for each item in the result set). + +On the other hand, I don't know of any way to test this, unless you have +a query that you know takes a long time to plan, and can compare the +performance of FOR IN EXECUTE versus FOR IN SELECT. +John +=:-> + +>Your comments are appreciated. +> +>Kind Regards, +>Keith +> +> +> + + +--------------enig2DF40541C5E82F4251FD0181 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCSuidJdeBCYSNAAMRAk78AJ4swE0OeNES3oXxX92rsqH3KfhlGACgl+A7 +rrm3KaNqmVtGJXd8FiKZIig= +=vXOw +-----END PGP SIGNATURE----- + +--------------enig2DF40541C5E82F4251FD0181-- + +From pgsql-performance-owner@postgresql.org Wed Mar 30 18:44:04 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BE4BA53533 + for ; + Wed, 30 Mar 2005 18:44:02 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74934-04 + for ; + Wed, 30 Mar 2005 17:44:00 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id D884B5352F + for ; + Wed, 30 Mar 2005 18:43:59 +0100 (BST) +Received: (qmail 18282 invoked by uid 500); 30 Mar 2005 18:00:39 -0000 +Date: Wed, 30 Mar 2005 12:00:39 -0600 +From: Bruno Wolff III +To: "Mohan, Ross" +Cc: pgsql-performance@postgresql.org +Subject: Re: Reading recommendations +Message-ID: <20050330180039.GC17708@wolff.to> +Mail-Followup-To: Bruno Wolff III , + "Mohan, Ross" , 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.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.011 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/657 +X-Sequence-Number: 11362 + +On Wed, Mar 30, 2005 at 16:39:47 -0000, + "Mohan, Ross" wrote: +> VOIP over BitTorrent? + +Plain VOIP shouldn't be a problem. And if you want to do tricky things +you can use Asterisk on both ends. Asterisk is open source (GPL, duel +licensed from Digium) and runs on low powered linux boxes. A card that +talks to your existing analog phones and your existing phone line +costs $200. You don't need special cards if you have IP phones or a headset +connected to your computer and don't use your local phone company for +the calls. + +From pgsql-performance-owner@postgresql.org Wed Mar 30 19:34:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E22975352F + for ; + Wed, 30 Mar 2005 19:34:31 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90999-04 + for ; + Wed, 30 Mar 2005 18:34:30 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 7ECB8534F8 + for ; + Wed, 30 Mar 2005 19:34:29 +0100 (BST) +Received: (qmail 8448 invoked from network); 30 Mar 2005 20:34:45 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 30 Mar 2005 20:34:45 +0200 +To: KeithW@narrowpathinc.com, + "PostgreSQL Perform" +Subject: Re: Dynamic query perormance +References: <20050330170418.M61319@narrowpathinc.com> +Message-ID: +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Date: Wed, 30 Mar 2005 20:34:28 +0200 +In-Reply-To: <20050330170418.M61319@narrowpathinc.com> +User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/659 +X-Sequence-Number: 11364 + + + +> which is evaluated and replanned on each entry to the +> FOR loop. This allows the programmer to choose the speed + + On each entry is not the same as on each iteration. It would means "every +time the loop is started"... + + Regards, + PFC + +From pgsql-performance-owner@postgresql.org Wed Mar 30 21:12:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3EA0453728; + Wed, 30 Mar 2005 21:12:31 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25918-07; Wed, 30 Mar 2005 20:12:27 +0000 (GMT) +Received: from dfw-gate1.raytheon.com (dfw-gate1.raytheon.com + [199.46.199.230]) + by svr1.postgresql.org (Postfix) with ESMTP id B7A1953716; + Wed, 30 Mar 2005 21:12:25 +0100 (BST) +Received: from ds02c00.directory.ray.com (ds02c00.directory.ray.com + [147.25.138.118]) + by dfw-gate1.raytheon.com (8.12.10/8.12.10) with ESMTP id + j2UKCJqn018803; Wed, 30 Mar 2005 14:12:23 -0600 (CST) +Received: from ds02c00 (localhost [127.0.0.1]) + by ds02c00.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id + j2UKC59q001742; Wed, 30 Mar 2005 20:12:08 GMT +Received: from ds02c00.directory.ray.com with LMTP by ds02c00 + (2.0.6/sieved-2-0-build-559); Wed, 30 Mar 2005 20:12:04 +0000 +Received: from notesserver5.ftw.us.ray.com (notesserver5.ftw.us.ray.com + [151.168.145.35]) + by ds02c00.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id + j2UKBP9o001417 sender Richard_D_Levine@raytheon.com; + Wed, 30 Mar 2005 20:11:32 GMT +In-Reply-To: <424AD93D.30601@noao.edu> +Subject: Re: Reading recommendations +To: Steve Wampler +Cc: pgsql-performance@postgresql.org, pgsql-performance-owner@postgresql.org, + "Mohan, Ross" +X-Mailer: Lotus Notes Release 6.5.2 June 01, 2004 +Message-ID: + +From: Richard_D_Levine@raytheon.com +Date: Wed, 30 Mar 2005 15:11:24 -0500 +X-MIMETrack: Serialize by Router on NotesServer5/HDC(Release 6.5.2|June 01, + 2004) at 03/30/2005 03:11:32 PM +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +X-SPAM: 0.00 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.21 tagged_above=0 required=5 tests=AWL, NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200503/660 +X-Sequence-Number: 11365 + +It was very challenging. I worked on the credit window sizing and +retransmission timer estimation algorithms. We took into account weather +patterns, size and age of the bird, feeding times, and the average number +of times a bird circles before determining magnetic north. Interestingly, +packet size had little effect in the final algorithms. + +pgsql-performance-owner@postgresql.org wrote on 03/30/2005 11:52:13 AM: + +> Mohan, Ross wrote: +> > VOIP over BitTorrent? +> +> Now *that* I want to see. Aught to be at least as interesting +> as the "TCP/IP over carrier pigeon" experiment - and more +> challenging to boot! +> + +It was very challenging. I worked on the credit window sizing and +retransmission timer estimation algorithms. We took into account weather +patterns, size and age of the bird, feeding times, and the average number +of times a bird circles before determining magnetic north. Interestingly, +packet size had little effect in the final algorithms. + +I would love to share them with all of you, but they're classified. + +> +> -- +> Steve Wampler -- swampler@noao.edu +> The gods that smiled on your birth are now laughing out loud. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster + + +From pgsql-performance-owner@postgresql.org Wed Mar 30 21:36:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 136A05368E + for ; + Wed, 30 Mar 2005 21:36:53 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32527-07 + for ; + Wed, 30 Mar 2005 20:36:44 +0000 (GMT) +Received: from ylpvm29.prodigy.net (ylpvm29-ext.prodigy.net [207.115.57.60]) + by svr1.postgresql.org (Postfix) with ESMTP id BA85853629 + for ; + Wed, 30 Mar 2005 21:36:42 +0100 (BST) +Received: from one (adsl-68-124-182-149.dsl.pltn13.pacbell.net + [68.124.182.149]) + by ylpvm29.prodigy.net (8.12.10 outbound/8.12.10) with ESMTP id + j2UKaDnr018582 + for ; Wed, 30 Mar 2005 15:36:13 -0500 +Received: from [192.168.5.101] (unknown [192.168.5.101]) + by one (Postfix) with ESMTP id D4170F1A5C + for ; + Wed, 30 Mar 2005 12:36:36 -0800 (PST) +Date: Wed, 30 Mar 2005 12:37:08 -0800 (PST) +From: rm_pg@cheapcomplexdevices.com +X-X-Sender: mayer@greenie.cheapcomplexdevices.com +To: pgsql-performance@postgresql.org +Subject: Left Outer Join much faster than non-outer Join? +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.178 tagged_above=0 required=5 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200503/661 +X-Sequence-Number: 11366 + + +Can anyone please help me make my JOIN find the right index to use? + +It seems strange to me that in the two queries listed below, the +LEFT OUTER JOIN can find the most efficient index to use, while +the unadorned JOIN can not. The result is that my query is +orders of magnitude slower than it seems it should be. + + + +The table "tlid_smaller" (\d and explain analyze shown below) is a +large table contining integer IDs just like the fact table of any +traditional star-schema warehouse. + +The tables *_lookup are simply tables that map strings to IDs, with +unique IDs associating strings to the IDs. + +The table "tlid_smaller" has an index on (streetname_id, city_id) that +is extremely efficient at finding the desired row. When I use a "LEFT +OUTER JOIN", the optimizer happily sees that it can use this index. +This is shown in the first explain analyze below. However when I +simply do a "JOIN" the optimizer does not use this index and rather +does a hash join comparing thousands of rows. + +Note that the cost estimate using the good index is much better +(16.94 vs 29209.16 thousands of times better). Any ideas why +the non-outer join didn't use it? + + + + + + +fli=# explain analyze + select * + from streetname_lookup as sl + join city_lookup as cl on (true) + left outer join tlid_smaller as ts on (sl.geo_streetname_id = ts.geo_streetname_id and cl.geo_city_id=ts.geo_city_id) + where str_name='alamo' and city='san antonio' and state='TX' +; +fli-# fli-# fli-# fli-# fli-# fli-# QUERY PLAN \ + +--------------------------------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop Left Join (cost=0.00..16.94 rows=1 width=74) (actual time=0.115..0.539 rows=78 loops=1) + -> Nested Loop (cost=0.00..9.03 rows=1 width=42) (actual time=0.077..0.084 rows=1 loops=1) + -> Index Scan using streetname_lookup__str_name on streetname_lookup sl (cost=0.00..3.01 rows=1 width=19) (actual time=0.042..0.044 rows=1 loops=1) + Index Cond: (str_name = 'alamo'::text) + -> Index Scan using city_lookup__name on city_lookup cl (cost=0.00..6.01 rows=1 width=23) (actual time=0.026..0.028 rows=1 loops=1) + Index Cond: ((city = 'san antonio'::text) AND (state = 'TX'::text)) + -> Index Scan using tlid_smaller__street_city on tlid_smaller ts (cost=0.00..7.86 rows=3 width=32) (actual time=0.029..0.176 rows=78 loops=1) + Index Cond: (("outer".geo_streetname_id = ts.geo_streetname_id) AND ("outer".geo_city_id = ts.geo_city_id)) + Total runtime: 0.788 ms +(9 rows) + + +fli=# +fli=# explain analyze + select * + from streetname_lookup as sl + join city_lookup as cl on (true) + join tlid_smaller as ts on (sl.geo_streetname_id = ts.geo_streetname_id and cl.geo_city_id=ts.geo_city_id) + where str_name='alamo' and city='san antonio' and state='TX' +; +fli-# fli-# fli-# fli-# fli-# fli-# QUERY PLAN \ + +--------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=6.01..29209.16 rows=1 width=74) (actual time=9.421..28.154 rows=78 loops=1) + Hash Cond: ("outer".geo_city_id = "inner".geo_city_id) + -> Nested Loop (cost=0.00..29202.88 rows=52 width=51) (actual time=0.064..23.296 rows=4151 loops=1) + -> Index Scan using streetname_lookup__str_name on streetname_lookup sl (cost=0.00..3.01 rows=1 width=19) (actual time=0.025..0.032 rows=1 loops=1) + Index Cond: (str_name = 'alamo'::text) + -> Index Scan using tlid_smaller__street_zipint on tlid_smaller ts (cost=0.00..28994.70 rows=16413 width=32) (actual time=0.028..8.153 rows=4151 loops=1) + Index Cond: ("outer".geo_streetname_id = ts.geo_streetname_id) + -> Hash (cost=6.01..6.01 rows=1 width=23) (actual time=0.073..0.073 rows=0 loops=1) + -> Index Scan using city_lookup__name on city_lookup cl (cost=0.00..6.01 rows=1 width=23) (actual time=0.065..0.067 rows=1 loops=1) + Index Cond: ((city = 'san antonio'::text) AND (state = 'TX'::text)) + Total runtime: 28.367 ms +(11 rows) + +fli=# + +fli=# + + + +fli=# \d tlid_smaller + Table "geo.tlid_smaller" + Column | Type | Modifiers +-------------------+---------+----------- + tlid | integer | + geo_streetname_id | integer | + geo_streettype_id | integer | + geo_city_id | integer | + zipint | integer | + tigerfile | integer | + low | integer | + high | integer | +Indexes: + "tlid_smaller__city" btree (geo_city_id) + "tlid_smaller__street_city" btree (geo_streetname_id, geo_city_id) + "tlid_smaller__street_zipint" btree (geo_streetname_id, zipint) + "tlid_smaller__tlid" btree (tlid) + + +From pgsql-performance-owner@postgresql.org Wed Mar 30 21:50:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 069FE537A3 + for ; + Wed, 30 Mar 2005 21:50:15 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39902-01 + for ; + Wed, 30 Mar 2005 20:50:07 +0000 (GMT) +Received: from ylpvm12.prodigy.net (ylpvm12-ext.prodigy.net [207.115.57.43]) + by svr1.postgresql.org (Postfix) with ESMTP id B356B5379E + for ; + Wed, 30 Mar 2005 21:50:06 +0100 (BST) +Received: from pimout6-ext.prodigy.net (pimout6-ext.prodigy.net + [207.115.63.78]) + by ylpvm12.prodigy.net (8.12.10 outbound/8.12.10) with ESMTP id + j2UKo4cm011245 + for ; Wed, 30 Mar 2005 15:50:04 -0500 +X-ORBL: [68.124.182.149] +Received: from one (adsl-68-124-182-149.dsl.pltn13.pacbell.net + [68.124.182.149]) + by pimout6-ext.prodigy.net (8.12.10 milter /8.12.10) with ESMTP id + j2UKnvHY459594; Wed, 30 Mar 2005 15:50:01 -0500 +Received: from [192.168.5.101] (unknown [192.168.5.101]) + by one (Postfix) with ESMTP id EA079F1A5C; + Wed, 30 Mar 2005 12:49:50 -0800 (PST) +Date: Wed, 30 Mar 2005 12:50:23 -0800 (PST) +From: Ron Mayer +X-X-Sender: mayer@greenie.cheapcomplexdevices.com +To: rm_pg@cheapcomplexdevices.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Left Outer Join much faster than non-outer Join? +In-Reply-To: + +Message-ID: +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.089 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/662 +X-Sequence-Number: 11367 + + +Setting join_collapse_limit=1 improves my performance dramatically. + +Even on a query with only 3 tables. + +This surprised me, since there are only 3 tables being joined, I would +have assumed that the optimizer would have done the exhaustive search +and not used geqo stuff - and that this exhaustive search would have +found the good plan. + +Any reason it didn't? Explain analyze results shown below. + + + +On Wed, 30 Mar 2005 rm_pg@cheapcomplexdevices.com wrote: +> +> Can anyone please help me make my JOIN find the right index to use? +> + +fli=# set join_collapse_limit=1; +SET +fli=# explain analyze + select * + from streetname_lookup as sl + join city_lookup as cl on (true) + join tlid_smaller as ts on (sl.geo_streetname_id = ts.geo_streetname_id and cl.geo_city_id=ts.geo_city_id) + where str_name='alamo' and city='san antonio' and state='TX' +; +fli-# fli-# fli-# fli-# fli-# fli-# QUERY PLAN \ + +--------------------------------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..16.94 rows=1 width=74) (actual time=0.116..0.528 rows=78 loops=1) + -> Nested Loop (cost=0.00..9.03 rows=1 width=42) (actual time=0.079..0.086 rows=1 loops=1) + -> Index Scan using streetname_lookup__str_name on streetname_lookup sl (cost=0.00..3.01 rows=1 width=19) (actual time=0.042..0.044 rows=1 loops=1) + Index Cond: (str_name = 'alamo'::text) + -> Index Scan using city_lookup__name on city_lookup cl (cost=0.00..6.01 rows=1 width=23) (actual time=0.026..0.028 rows=1 loops=1) + Index Cond: ((city = 'san antonio'::text) AND (state = 'TX'::text)) + -> Index Scan using tlid_smaller__street_city on tlid_smaller ts (cost=0.00..7.86 rows=3 width=32) (actual time=0.031..0.181 rows=78 loops=1) + Index Cond: (("outer".geo_streetname_id = ts.geo_streetname_id) AND ("outer".geo_city_id = ts.geo_city_id)) + Total runtime: 0.709 ms +(9 rows) + + +--------[with the default join_collapse_limit]----------- +> fli=# explain analyze +> select * +> from streetname_lookup as sl +> join city_lookup as cl on (true) +> join tlid_smaller as ts on (sl.geo_streetname_id = ts.geo_streetname_id and cl.geo_city_id=ts.geo_city_id) +> where str_name='alamo' and city='san antonio' and state='TX' +> ; +> fli-# fli-# fli-# fli-# fli-# fli-# QUERY PLAN \ +> +> --------------------------------------------------------------------------------------------------------------------------------------------------------------------- +> Hash Join (cost=6.01..29209.16 rows=1 width=74) (actual time=9.421..28.154 rows=78 loops=1) +> Hash Cond: ("outer".geo_city_id = "inner".geo_city_id) +> -> Nested Loop (cost=0.00..29202.88 rows=52 width=51) (actual time=0.064..23.296 rows=4151 loops=1) +> -> Index Scan using streetname_lookup__str_name on streetname_lookup sl (cost=0.00..3.01 rows=1 width=19) (actual time=0.025..0.032 rows=1 loops=1) +> Index Cond: (str_name = 'alamo'::text) +> -> Index Scan using tlid_smaller__street_zipint on tlid_smaller ts (cost=0.00..28994.70 rows=16413 width=32) (actual time=0.028..8.153 rows=4151 loops=1) +> Index Cond: ("outer".geo_streetname_id = ts.geo_streetname_id) +> -> Hash (cost=6.01..6.01 rows=1 width=23) (actual time=0.073..0.073 rows=0 loops=1) +> -> Index Scan using city_lookup__name on city_lookup cl (cost=0.00..6.01 rows=1 width=23) (actual time=0.065..0.067 rows=1 loops=1) +> Index Cond: ((city = 'san antonio'::text) AND (state = 'TX'::text)) +> Total runtime: 28.367 ms +> (11 rows) +> + +From pgsql-performance-owner@postgresql.org Wed Mar 30 21:58:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1EED752963 + for ; + Wed, 30 Mar 2005 21:58:33 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41478-10 + for ; + Wed, 30 Mar 2005 20:58:23 +0000 (GMT) +Received: from noao.edu (noao.edu [140.252.1.54]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B7E553320 + for ; + Wed, 30 Mar 2005 21:58:22 +0100 (BST) +X-TFF-CGPSA-Version: 1.4f1 +X-TFF-CGPSA-Filter: Scanned +Received: from [140.252.14.8] (HELO weaver.tuc.noao.edu) + by noao.edu (CommuniGate Pro SMTP 4.2.10) + with ESMTP-TLS id 17419244; Wed, 30 Mar 2005 13:58:16 -0700 +Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) + by weaver.tuc.noao.edu (8.12.8/8.12.8) with ESMTP id j2UKwCKv005156; + Wed, 30 Mar 2005 13:58:13 -0700 +Message-ID: <424B12E4.7000702@noao.edu> +Date: Wed, 30 Mar 2005 13:58:12 -0700 +From: Steve Wampler +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Richard_D_Levine@raytheon.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Reading recommendations +References: + +In-Reply-To: + +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-noao.edu-MailScanner-Information: Please contact the ISP for more + information +X-noao.edu-MailScanner: Found to be clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/663 +X-Sequence-Number: 11368 + +Richard_D_Levine@raytheon.com wrote: + +>>Mohan, Ross wrote: +>> +>>>VOIP over BitTorrent? +>> +>>Now *that* I want to see. Aught to be at least as interesting +>>as the "TCP/IP over carrier pigeon" experiment - and more +>>challenging to boot! +>> +> +> +> It was very challenging. I worked on the credit window sizing and +> retransmission timer estimation algorithms. We took into account weather +> patterns, size and age of the bird, feeding times, and the average number +> of times a bird circles before determining magnetic north. Interestingly, +> packet size had little effect in the final algorithms. +> +> I would love to share them with all of you, but they're classified. + +Ah, but VOIPOBT requires many people all saying the same thing at the +same time. The synchronization alone (since you need to distribute +these people adequately to avoid overloading a trunk line...) is probably +sufficiently hard to make it interesting. Then there are the problems of +different accents, dilects, and languages ;) + +-- +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +From pgsql-performance-owner@postgresql.org Wed Mar 30 22:01:17 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 298B3537A2 + for ; + Wed, 30 Mar 2005 22:01:14 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45222-01 + for ; + Wed, 30 Mar 2005 21:01:11 +0000 (GMT) +Received: from zcars04f.nortelnetworks.com (zcars04f.nortelnetworks.com + [47.129.242.57]) + by svr1.postgresql.org (Postfix) with ESMTP id B649253799 + for ; + Wed, 30 Mar 2005 22:01:09 +0100 (BST) +Received: from zrtps0m6.us.nortel.com (zrtps0m6.us.nortel.com [47.140.192.58]) + by zcars04f.nortelnetworks.com (Switch-2.2.6/Switch-2.2.0) with + ESMTP id j2UL18i24955 for ; + Wed, 30 Mar 2005 16:01:08 -0500 (EST) +Received: from cash.rhiamet.com (rhiamet.us.nortel.com [47.103.243.53]) + by zrtps0m6.us.nortel.com (Switch-2.2.6/Switch-2.2.0) with ESMTP id + j2UL15f25735 for ; + Wed, 30 Mar 2005 16:01:06 -0500 (EST) +Received: from cash.rhiamet.com (bmetcalf@localhost [127.0.0.1]) + by cash.rhiamet.com (8.13.3/8.13.3/Debian-9) with ESMTP id + j2UL0vct028382 + for ; Wed, 30 Mar 2005 15:00:57 -0600 +Received: from localhost (bmetcalf@localhost) + by cash.rhiamet.com (8.13.3/8.13.3/Submit) with ESMTP id j2UL0v1o028378 + for ; Wed, 30 Mar 2005 15:00:57 -0600 +X-Authentication-Warning: cash.rhiamet.com: bmetcalf owned process doing -bs +Date: Wed, 30 Mar 2005 15:00:57 -0600 (CST) +From: "Brandon Metcalf" +X-X-Sender: bmetcalf@cash.rhiamet.com +To: pgsql-performance@postgresql.org +Subject: Re: PostgreSQL on Solaris 8 and ufs +In-Reply-To: <200503231539.34978.josh@agliodbs.com> +Message-ID: +References: + + <20050323175507.GC26236@phlogiston.dyndns.org> + <200503231539.34978.josh@agliodbs.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.069 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/664 +X-Sequence-Number: 11369 + +I just wanted to follow up and let everyone know that the biggest +improvement in performance came from moving the pg_xlog directory to +another filesystem (different set of disks) separate from the data +directory. + +Thanks for the suggestions. + +-- +Brandon + +From pgsql-performance-owner@postgresql.org Thu Mar 31 00:10:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E4B7153460 + for ; + Thu, 31 Mar 2005 00:10:32 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85205-02 + for ; + Wed, 30 Mar 2005 23:10:25 +0000 (GMT) +Received: from imail01.arbinet.com (imail.arbinet.com [64.74.47.121]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D8E552A37 + for ; + Thu, 31 Mar 2005 00:10:24 +0100 (BST) +Received: from imail01.arbinet.com (localhost [127.0.0.1]) + by imail01.arbinet.com (8.12.10/8.12.2) with ESMTP id j2UNAGlS026701 + for ; Wed, 30 Mar 2005 23:10:24 GMT +Received: from vamail01.TheXchange.com (mailbox.arbinet.com [64.74.47.120]) + by imail01.arbinet.com (8.12.2/8.12.2) with SMTP id j2UNAFtL026692; + Wed, 30 Mar 2005 23:10:16 GMT +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Reading recommendations +Date: Wed, 30 Mar 2005 23:09:59 -0000 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Reading recommendations +Thread-Index: AcU1a5UWZzIIujqXRSed4ETMvWR45wAAMTvQ +From: "Mohan, Ross" +To: +X-Spam-Details: Hits=-104.9, Required=2, Tests=BAYES_00,USER_IN_WHITELIST +X-Scanned-By: MIMEDefang 2.39 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.343 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/665 +X-Sequence-Number: 11370 + +I can see that PG'ers have a wicked sense of humor.=20 + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org = +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Steve = +Wampler +Sent: Wednesday, March 30, 2005 3:58 PM +To: Richard_D_Levine@raytheon.com +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Reading recommendations + + +Richard_D_Levine@raytheon.com wrote: + +>>Mohan, Ross wrote: +>> +>>>VOIP over BitTorrent? +>> +>>Now *that* I want to see. Aught to be at least as interesting as the=20 +>>"TCP/IP over carrier pigeon" experiment - and more challenging to=20 +>>boot! +>> +>=20 +>=20 +> It was very challenging. I worked on the credit window sizing and=20 +> retransmission timer estimation algorithms. We took into account=20 +> weather patterns, size and age of the bird, feeding times, and the=20 +> average number of times a bird circles before determining magnetic=20 +> north. Interestingly, packet size had little effect in the final=20 +> algorithms. +>=20 +> I would love to share them with all of you, but they're classified. + +Ah, but VOIPOBT requires many people all saying the same thing at the = +same time. The synchronization alone (since you need to distribute = +these people adequately to avoid overloading a trunk line...) is = +probably sufficiently hard to make it interesting. Then there are the = +problems of different accents, dilects, and languages ;) + +--=20 +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +---------------------------(end of broadcast)--------------------------- +TIP 7: don't forget to increase your free space map settings + +From pgsql-performance-owner@postgresql.org Thu Mar 31 02:50:23 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C7D553435 + for ; + Thu, 31 Mar 2005 02:50:20 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29818-06 + for ; + Thu, 31 Mar 2005 01:50:11 +0000 (GMT) +Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.85]) + by svr1.postgresql.org (Postfix) with ESMTP id 1070852A6A + for ; + Thu, 31 Mar 2005 02:50:09 +0100 (BST) +Received: from andrei.myip.org ([24.6.189.81]) + by comcast.net (rwcrmhc12) with ESMTP + id <2005033101501201400dtnuae>; Thu, 31 Mar 2005 01:50:13 +0000 +Received: from localhost (weiqi.home.local [127.0.0.1]) + by andrei.myip.org (Postfix) with ESMTP id F0C34B4067 + for ; + Wed, 30 Mar 2005 17:50:11 -0800 (PST) +Received: from andrei.myip.org ([127.0.0.1]) + by localhost (weiqi.home.local [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 00315-02 for ; + Wed, 30 Mar 2005 17:50:10 -0800 (PST) +Received: from [192.168.2.6] (unknown [192.168.2.6]) + by andrei.myip.org (Postfix) with ESMTP id 21C34B4063 + for ; + Wed, 30 Mar 2005 17:50:10 -0800 (PST) +Subject: fine tuning for logging server +From: Florin Andrei +Reply-To: pgsql-performance@postgresql.org +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Date: Wed, 30 Mar 2005 17:50:09 -0800 +Message-Id: <1112233809.10313.31.camel@stantz.corp.sgi.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at andrei.myip.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/666 +X-Sequence-Number: 11371 + +Hardware: relatively modern Intel CPU, OS and database each on its own +IDE hard-drive (separate IDE cables). Enough memory, i think, but i +can't add too much (not beyond 1GB). +Software: Linux-2.6, pgsql-8.0.1 + +Function: Essentially a logging server. There are two applications (like +syslog) on the same box that are logging to pgsql, each one to its own +database. There are a few tables in one DB, and exactly one table in the +other. +Most of the time, the apps are just doing mindless INSERTs to the DB. +Every now and then, an admin performs some SELECTs via a PHP interface. + +Objective: Make the DB as fast as possible. Of course i'd like the +SELECTs to be fast, but the INSERTs take precedence. It's gotta be able +to swallow as many messages per second as possible given the hardware. + +Question: What are the pgsql parameters that need to be tweaked? What +are the guidelines for such a situation? + +-- +Florin Andrei + +http://florin.myip.org/ + + +From pgsql-performance-owner@postgresql.org Thu Mar 31 02:59:37 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B3EB5352E + for ; + Thu, 31 Mar 2005 02:59:35 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32489-05 + for ; + Thu, 31 Mar 2005 01:59:33 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 8952A53514 + for ; + Thu, 31 Mar 2005 02:59:29 +0100 (BST) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j2V1xWOX015443 for ; + (envelope-from ) Wed, 30 Mar 2005 19:59:32 + -0600 (CST) +Received: from [192.168.1.13] (12-215-118-172.client.mchsi.com + [12.215.118.172]) (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j2V1xV24011792 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256) + for ; + (envelope-from ) Wed, 30 Mar 2005 19:59:32 + -0600 (CST) +Message-ID: <424B5982.3090809@arbash-meinel.com> +Date: Wed, 30 Mar 2005 19:59:30 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: fine tuning for logging server +References: <1112233809.10313.31.camel@stantz.corp.sgi.com> +In-Reply-To: <1112233809.10313.31.camel@stantz.corp.sgi.com> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigAB399C062623FE0A1E9D2019" +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/667 +X-Sequence-Number: 11372 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigAB399C062623FE0A1E9D2019 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Florin Andrei wrote: + +>Hardware: relatively modern Intel CPU, OS and database each on its own +>IDE hard-drive (separate IDE cables). Enough memory, i think, but i +>can't add too much (not beyond 1GB). +>Software: Linux-2.6, pgsql-8.0.1 +> +>Function: Essentially a logging server. There are two applications (like +>syslog) on the same box that are logging to pgsql, each one to its own +>database. There are a few tables in one DB, and exactly one table in the +>other. +>Most of the time, the apps are just doing mindless INSERTs to the DB. +>Every now and then, an admin performs some SELECTs via a PHP interface. +> +>Objective: Make the DB as fast as possible. Of course i'd like the +>SELECTs to be fast, but the INSERTs take precedence. It's gotta be able +>to swallow as many messages per second as possible given the hardware. +> +>Question: What are the pgsql parameters that need to be tweaked? What +>are the guidelines for such a situation? +> +> +> +Put pg_xlog onto the same drive as the OS, not the drive with the database. + +Do as many inserts per transaction that you can get away with. +100-1000 is pretty good. + +Keep the number of indexes and foreign key references low to keep +INSERTS fast. + +Keep a few indexes around to keep SELECTs reasonable speedy. + +If you are doing lots and lots of logging, need only archival and slow +access for old data, but fast access on new data, consider partitioning +your table, and then using a view to join them back together. + +If you are only having a couple processing accessing the db at any given +time, you can probably increase work_mem and maintenance_work_mem a bit. +If you have 1G ram, maybe around 50M for work_mem. But really this is +only if you have 1-3 selects going on at a time. + +With 2 disks, and fixed hardware, it's a lot more about configuring your +schema and the application. If you want more performance, adding more +disks is probably the first thing to do. + +John +=:-> + + +--------------enigAB399C062623FE0A1E9D2019 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCS1mCJdeBCYSNAAMRArkmAKCT0JJdeTokR5ULUxNiOabH9o28tACguH9d +dYbyOHUGAB57qw5nAuyYnus= +=TVeo +-----END PGP SIGNATURE----- + +--------------enigAB399C062623FE0A1E9D2019-- + +From pgsql-performance-owner@postgresql.org Thu Mar 31 03:03:20 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 86435533CA + for ; + Thu, 31 Mar 2005 03:03:00 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34740-08 + for ; + Thu, 31 Mar 2005 02:02:55 +0000 (GMT) +Received: from sccrmhc14.comcast.net (sccrmhc14.comcast.net [204.127.202.59]) + by svr1.postgresql.org (Postfix) with ESMTP id 3133252A5D + for ; + Thu, 31 Mar 2005 03:02:54 +0100 (BST) +Received: from andrei.myip.org ([24.6.189.81]) + by comcast.net (sccrmhc14) with ESMTP + id <2005033102025701400dln3ce>; Thu, 31 Mar 2005 02:02:57 +0000 +Received: from localhost (weiqi.home.local [127.0.0.1]) + by andrei.myip.org (Postfix) with ESMTP id 4236AB4067 + for ; + Wed, 30 Mar 2005 18:02:56 -0800 (PST) +Received: from andrei.myip.org ([127.0.0.1]) + by localhost (weiqi.home.local [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 00315-08 for ; + Wed, 30 Mar 2005 18:02:55 -0800 (PST) +Received: from [192.168.2.6] (unknown [192.168.2.6]) + by andrei.myip.org (Postfix) with ESMTP id EB9B7B4063 + for ; + Wed, 30 Mar 2005 18:02:54 -0800 (PST) +Subject: Re: fine tuning for logging server +From: Florin Andrei +Reply-To: pgsql-performance@postgresql.org +To: pgsql-performance@postgresql.org +In-Reply-To: <1112233809.10313.31.camel@stantz.corp.sgi.com> +References: <1112233809.10313.31.camel@stantz.corp.sgi.com> +Content-Type: text/plain +Date: Wed, 30 Mar 2005 18:02:54 -0800 +Message-Id: <1112234574.12159.1.camel@stantz.corp.sgi.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at andrei.myip.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.025 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/668 +X-Sequence-Number: 11373 + +On Wed, 2005-03-30 at 17:50 -0800, Florin Andrei wrote: + +> Function: Essentially a logging server. There are two applications (like +> syslog) on the same box that are logging to pgsql, each one to its own +> database. There are a few tables in one DB, and exactly one table in the +> other. +> Most of the time, the apps are just doing mindless INSERTs to the DB. +> Every now and then, an admin performs some SELECTs via a PHP interface. + +For performance reasons, i was thinking to keep the tables append-only, +and simply rotate them out every so often (daily?) and delete those +tables that are too old. Is that a good idea? + +-- +Florin Andrei + +http://florin.myip.org/ + + +From pgsql-performance-owner@postgresql.org Thu Mar 31 03:12:05 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D0A0534CB + for ; + Thu, 31 Mar 2005 03:12:01 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36610-03 + for ; + Thu, 31 Mar 2005 02:11:57 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 64DA55348D + for ; + Thu, 31 Mar 2005 03:11:57 +0100 (BST) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j2V2C1qm015819 for ; + (envelope-from ) Wed, 30 Mar 2005 20:12:01 + -0600 (CST) +Received: from [192.168.1.13] (12-215-118-172.client.mchsi.com + [12.215.118.172]) (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j2V2Bx4l013986 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256) + for ; + (envelope-from ) Wed, 30 Mar 2005 20:12:00 + -0600 (CST) +Message-ID: <424B5C6F.8090609@arbash-meinel.com> +Date: Wed, 30 Mar 2005 20:11:59 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: fine tuning for logging server +References: <1112233809.10313.31.camel@stantz.corp.sgi.com> + <1112234574.12159.1.camel@stantz.corp.sgi.com> +In-Reply-To: <1112234574.12159.1.camel@stantz.corp.sgi.com> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigFC3852802768A3D7D9EEC78C" +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/669 +X-Sequence-Number: 11374 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigFC3852802768A3D7D9EEC78C +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Florin Andrei wrote: + +>On Wed, 2005-03-30 at 17:50 -0800, Florin Andrei wrote: +> +> +> +>>Function: Essentially a logging server. There are two applications (like +>>syslog) on the same box that are logging to pgsql, each one to its own +>>database. There are a few tables in one DB, and exactly one table in the +>>other. +>>Most of the time, the apps are just doing mindless INSERTs to the DB. +>>Every now and then, an admin performs some SELECTs via a PHP interface. +>> +>> +> +>For performance reasons, i was thinking to keep the tables append-only, +>and simply rotate them out every so often (daily?) and delete those +>tables that are too old. Is that a good idea? +> +> +> +If you aren't doing updates, then I'm pretty sure the data stays packed +pretty well. I don't know that you need daily rotations, but you +certainly could consider some sort of rotation schedule. + +The biggest performance improvement, though, is probably to group +inserts into transactions. +I had an application (in a different db, but it should be relevant), +where using a transaction changed the time from 6min -> 6 sec. +It was just thrashing on all the little inserts that it had to fsync to +disk. + +How fast is fast? How many log messages are you expecting? 1/s 100/s 1000/s? +I think the hardware should be capable of the 10-100 range if things are +properly configured. Naturally that depends on all sorts of factors, but +it should give you an idea. + +John +=:-> + + +--------------enigFC3852802768A3D7D9EEC78C +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCS1xvJdeBCYSNAAMRAjWqAJ9vP92bvumQ3PhmzPGtPoQ37NmZTACgzuQ+ +4pzUmCtPvBWkgrGtz1dDYfo= +=ArJ+ +-----END PGP SIGNATURE----- + +--------------enigFC3852802768A3D7D9EEC78C-- + +From pgsql-performance-owner@postgresql.org Thu Mar 31 03:24:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 24C325355E + for ; + Thu, 31 Mar 2005 03:24:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37350-10 + for ; + Thu, 31 Mar 2005 02:24:39 +0000 (GMT) +Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) + by svr1.postgresql.org (Postfix) with ESMTP id C4599534CE + for ; + Thu, 31 Mar 2005 03:24:37 +0100 (BST) +Received: from andrei.myip.org ([24.6.189.81]) + by comcast.net (rwcrmhc11) with ESMTP + id <2005033102244101300do53de>; Thu, 31 Mar 2005 02:24:41 +0000 +Received: from localhost (weiqi.home.local [127.0.0.1]) + by andrei.myip.org (Postfix) with ESMTP id 3BD97B4067 + for ; + Wed, 30 Mar 2005 18:24:41 -0800 (PST) +Received: from andrei.myip.org ([127.0.0.1]) + by localhost (weiqi.home.local [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 00609-02 for ; + Wed, 30 Mar 2005 18:24:39 -0800 (PST) +Received: from [192.168.2.6] (unknown [192.168.2.6]) + by andrei.myip.org (Postfix) with ESMTP id 4AB60B4063 + for ; + Wed, 30 Mar 2005 18:24:39 -0800 (PST) +Subject: Re: fine tuning for logging server +From: Florin Andrei +Reply-To: pgsql-performance@postgresql.org +To: pgsql-performance@postgresql.org +In-Reply-To: <424B5982.3090809@arbash-meinel.com> +References: <1112233809.10313.31.camel@stantz.corp.sgi.com> + <424B5982.3090809@arbash-meinel.com> +Content-Type: text/plain +Date: Wed, 30 Mar 2005 18:24:38 -0800 +Message-Id: <1112235878.12159.22.camel@stantz.corp.sgi.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at andrei.myip.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.031 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/670 +X-Sequence-Number: 11375 + +On Wed, 2005-03-30 at 19:59 -0600, John Arbash Meinel wrote: + +> Put pg_xlog onto the same drive as the OS, not the drive with the database. + +I forgot to mention: the OS drive is purposefully made very slow - the +write cache is turned off and the FS is Ext3 with data=journal. Is then +still ok to put pg_xlog on it? + +The reason: if the power cord is yanked, the OS _must_ boot back up in +good condition. If the DB is corrupted, whatever, nuke it then re- +initialize it. But the OS must survive act-of-god events. + +No, there is no uninterruptible power supply. It sucks, but that's how +it is. I cannot change that. + +-- +Florin Andrei + +http://florin.myip.org/ + + +From pgsql-performance-owner@postgresql.org Thu Mar 31 03:30:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 57A3253573 + for ; + Thu, 31 Mar 2005 03:30:18 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39756-09 + for ; + Thu, 31 Mar 2005 02:30:15 +0000 (GMT) +Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.85]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D3DC5348D + for ; + Thu, 31 Mar 2005 03:30:10 +0100 (BST) +Received: from andrei.myip.org ([24.6.189.81]) + by comcast.net (rwcrmhc12) with ESMTP + id <2005033102301401400dvruqe>; Thu, 31 Mar 2005 02:30:14 +0000 +Received: from localhost (weiqi.home.local [127.0.0.1]) + by andrei.myip.org (Postfix) with ESMTP id 6696DB4067 + for ; + Wed, 30 Mar 2005 18:30:14 -0800 (PST) +Received: from andrei.myip.org ([127.0.0.1]) + by localhost (weiqi.home.local [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 00612-08 for ; + Wed, 30 Mar 2005 18:30:12 -0800 (PST) +Received: from [192.168.2.6] (unknown [192.168.2.6]) + by andrei.myip.org (Postfix) with ESMTP id 9ACA0B4063 + for ; + Wed, 30 Mar 2005 18:30:12 -0800 (PST) +Subject: Re: fine tuning for logging server +From: Florin Andrei +Reply-To: pgsql-performance@postgresql.org +To: pgsql-performance@postgresql.org +In-Reply-To: <424B5C6F.8090609@arbash-meinel.com> +References: <1112233809.10313.31.camel@stantz.corp.sgi.com> + <1112234574.12159.1.camel@stantz.corp.sgi.com> + <424B5C6F.8090609@arbash-meinel.com> +Content-Type: text/plain +Date: Wed, 30 Mar 2005 18:30:12 -0800 +Message-Id: <1112236212.12159.28.camel@stantz.corp.sgi.com> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 (2.0.4-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at andrei.myip.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.033 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/671 +X-Sequence-Number: 11376 + +On Wed, 2005-03-30 at 20:11 -0600, John Arbash Meinel wrote: +> Florin Andrei wrote: +> > +> >For performance reasons, i was thinking to keep the tables append-only, +> >and simply rotate them out every so often (daily?) and delete those +> >tables that are too old. Is that a good idea? +> > +> If you aren't doing updates, then I'm pretty sure the data stays packed +> pretty well. I don't know that you need daily rotations, but you +> certainly could consider some sort of rotation schedule. + +(sorry for re-asking, i'm coming from a mysql mindset and i still have a +lot to learn about pgsql) + +So, it is indeed a bad idea to delete rows from tables, right? Better +just rotate to preserve the performance. + +Daily rotation may simplify the application logic - then i'll know that +each table is one day's worth of data. + +> The biggest performance improvement, though, is probably to group +> inserts into transactions. + +Yes, i know that. I have little control over the apps, though. I'll see +what i can do. + +> How fast is fast? How many log messages are you expecting? 1/s 100/s 1000/s? + +More is better. +I guess i'll put it together and give it a spin and see just how far it +goes. + +I actually have some controls over the data that's being sent (in some +places i can limit the number of events/second), so that might save me +right there. + +-- +Florin Andrei + +http://florin.myip.org/ + + +From pgsql-performance-owner@postgresql.org Thu Mar 31 03:34:50 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 67E0453485 + for ; + Thu, 31 Mar 2005 03:34:48 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40666-07 + for ; + Thu, 31 Mar 2005 02:34:39 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E51952956 + for ; + Thu, 31 Mar 2005 03:34:37 +0100 (BST) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j2V2YgCo016279 for ; + (envelope-from ) Wed, 30 Mar 2005 20:34:42 + -0600 (CST) +Received: from [192.168.1.13] (12-215-118-172.client.mchsi.com + [12.215.118.172]) (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j2V2YdPc018345 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256) + for ; + (envelope-from ) Wed, 30 Mar 2005 20:34:41 + -0600 (CST) +Message-ID: <424B61BF.3010906@arbash-meinel.com> +Date: Wed, 30 Mar 2005 20:34:39 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: fine tuning for logging server +References: <1112233809.10313.31.camel@stantz.corp.sgi.com> + <424B5982.3090809@arbash-meinel.com> + <1112235878.12159.22.camel@stantz.corp.sgi.com> +In-Reply-To: <1112235878.12159.22.camel@stantz.corp.sgi.com> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enigBEF88ABCBD05BB31A8B065F0" +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/672 +X-Sequence-Number: 11377 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enigBEF88ABCBD05BB31A8B065F0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Florin Andrei wrote: + +>On Wed, 2005-03-30 at 19:59 -0600, John Arbash Meinel wrote: +> +> +> +>>Put pg_xlog onto the same drive as the OS, not the drive with the database. +>> +>> +> +>I forgot to mention: the OS drive is purposefully made very slow - the +>write cache is turned off and the FS is Ext3 with data=journal. Is then +>still ok to put pg_xlog on it? +> +>The reason: if the power cord is yanked, the OS _must_ boot back up in +>good condition. If the DB is corrupted, whatever, nuke it then re- +>initialize it. But the OS must survive act-of-god events. +> +>No, there is no uninterruptible power supply. It sucks, but that's how +>it is. I cannot change that. +> +> +> +You don't want write cache for pg_xlog either. And you could always +create a second partition that used reiserfs, or something like that. + +If you have to survine "act-of-god" you probably should consider making +the system into a RAID1 instead of 2 separate drives (software RAID +should be fine). + +'Cause a much worse act-of-god is having a drive crash. No matter what +you do in software, a failed platter will prevent you from booting. RAID +1 at least means 2 drives have to die. + +If you need insert speed, and can't do custom transactions at the +application side, you could try creating a RAM disk for the insert +table, and then create a cron job that bulk pulls it out of that table +and inserts it into the rest of the system. That should let you get a +super-fast insert speed, and the bulk copies should stay reasonably fast. + +Just realize that if your cron job stops running, your machine will +slowly eat up all of it's ram, and really not play nice. I think adding +an extra hard-drive is probably the best way to boost performance and +reliability, but if you have a $0 budget, this is a possibility. + +John +=:-> + + +--------------enigBEF88ABCBD05BB31A8B065F0 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCS2G/JdeBCYSNAAMRAiJbAJ0ZMPOexFgZSC8vuw7j/NdH5oEjLQCfVrGy +3HdPR9BKUB0NuM/wTbkF3kk= +=vQ/f +-----END PGP SIGNATURE----- + +--------------enigBEF88ABCBD05BB31A8B065F0-- + +From pgsql-performance-owner@postgresql.org Thu Mar 31 03:41:54 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EB0F453573 + for ; + Thu, 31 Mar 2005 03:41:49 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45275-05 + for ; + Thu, 31 Mar 2005 02:41:41 +0000 (GMT) +Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu + [128.255.17.47]) + by svr1.postgresql.org (Postfix) with ESMTP id CF96C52956 + for ; + Thu, 31 Mar 2005 03:41:40 +0100 (BST) +Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu + [128.255.17.51]) + by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id + j2V2fjAq016451 for ; + (envelope-from ) Wed, 30 Mar 2005 20:41:45 + -0600 (CST) +Received: from [192.168.1.13] (12-215-118-172.client.mchsi.com + [12.215.118.172]) (authenticated user=jfmeinel) + by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id + j2V2fhcx019683 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256) + for ; + (envelope-from ) Wed, 30 Mar 2005 20:41:44 + -0600 (CST) +Message-ID: <424B6367.8040009@arbash-meinel.com> +Date: Wed, 30 Mar 2005 20:41:43 -0600 +From: John Arbash Meinel +User-Agent: Mozilla Thunderbird 1.0 (Macintosh/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: fine tuning for logging server +References: <1112233809.10313.31.camel@stantz.corp.sgi.com> + <1112234574.12159.1.camel@stantz.corp.sgi.com> + <424B5C6F.8090609@arbash-meinel.com> + <1112236212.12159.28.camel@stantz.corp.sgi.com> +In-Reply-To: <1112236212.12159.28.camel@stantz.corp.sgi.com> +X-Enigmail-Version: 0.89.6.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="------------enig6EC7BA1BE449431FF7EF6949" +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Scanned: ClamAV version 0.83, + clamav-milter version 0.83 on clamav.icaen.uiowa.edu +X-Virus-Status: Clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/673 +X-Sequence-Number: 11378 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--------------enig6EC7BA1BE449431FF7EF6949 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Florin Andrei wrote: + +>On Wed, 2005-03-30 at 20:11 -0600, John Arbash Meinel wrote: +> +> +>>Florin Andrei wrote: +>> +>> +>>>For performance reasons, i was thinking to keep the tables append-only, +>>>and simply rotate them out every so often (daily?) and delete those +>>>tables that are too old. Is that a good idea? +>>> +>>> +>>> +>>If you aren't doing updates, then I'm pretty sure the data stays packed +>>pretty well. I don't know that you need daily rotations, but you +>>certainly could consider some sort of rotation schedule. +>> +>> +> +>(sorry for re-asking, i'm coming from a mysql mindset and i still have a +>lot to learn about pgsql) +> +>So, it is indeed a bad idea to delete rows from tables, right? Better +>just rotate to preserve the performance. +> +> +The only problems are if you get a lot of old tuples in places you don't +want them. If you are always appending new values that are increasing, +and you are deleting from the other side, I think vacuum will do a fine +job at cleaning up. It's deleting/updating every 3rd entry that starts +to cause holes (though probably vacuum still does a pretty good job). + +>Daily rotation may simplify the application logic - then i'll know that +>each table is one day's worth of data. +> +> +> +I don't think it is necessary, but if you like it, go for it. I would +tend to think that you would want a "today" table, and a "everything +else" table, as it simplifies your queries, and lets you have foreign +keys (though if you are from mysql, you may not be used to using them.) + +>>The biggest performance improvement, though, is probably to group +>>inserts into transactions. +>> +>> +> +>Yes, i know that. I have little control over the apps, though. I'll see +>what i can do. +> +> +You could always add a layer inbetween. Or look at my mention of a fast +temp table, with a periodic cron job to pull in the new data. You can +run cron as fast as 1/min which might be just right depending on your needs. +It also means that you could ignore foreign keys and indexes on the temp +table, and only evaluate them on the main table. + +> +> +>>How fast is fast? How many log messages are you expecting? 1/s 100/s 1000/s? +>> +>> +> +>More is better. +>I guess i'll put it together and give it a spin and see just how far it +>goes. +> +>I actually have some controls over the data that's being sent (in some +>places i can limit the number of events/second), so that might save me +>right there. +> +> +> +Good luck. And remember, tuning your queries can be just as important. +(Though if you are doing append only inserts, there probably isn't much +that you can do). + +If all you are doing is append only logging, the fastest thing is +probably just a flat file. You could have something that comes along +later to move it into the database. It doesn't really sound like you are +using any features a database provides. (normalization, foreign keys, +indexes, etc.) + +John +=:-> + + +--------------enig6EC7BA1BE449431FF7EF6949 +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: OpenPGP digital signature +Content-Disposition: attachment; filename="signature.asc" + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (Darwin) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFCS2NnJdeBCYSNAAMRApaUAJkB/Zgs/bGo3G4x0l3YrFrQY4qRHgCfTiIP +ZpBOL0pfeOd1hkM6uR3xR8M= +=snjm +-----END PGP SIGNATURE----- + +--------------enig6EC7BA1BE449431FF7EF6949-- + +From pgsql-performance-owner@postgresql.org Thu Mar 31 05:08:06 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 49E4153B6E + for ; + Thu, 31 Mar 2005 05:08:04 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84831-03 + for ; + Thu, 31 Mar 2005 04:07:54 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 603C453A5E + for ; + Thu, 31 Mar 2005 05:07:53 +0100 (BST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j2V47qt9001756; + Wed, 30 Mar 2005 23:07:52 -0500 (EST) +To: rm_pg@cheapcomplexdevices.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Left Outer Join much faster than non-outer Join? +In-reply-to: + +References: +Comments: In-reply-to rm_pg@cheapcomplexdevices.com + message dated "Wed, 30 Mar 2005 12:37:08 -0800" +Date: Wed, 30 Mar 2005 23:07:52 -0500 +Message-ID: <1755.1112242072@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/674 +X-Sequence-Number: 11379 + +rm_pg@cheapcomplexdevices.com writes: +> select * +> from streetname_lookup as sl +> join city_lookup as cl on (true) +> left outer join tlid_smaller as ts on (sl.geo_streetname_id = ts.geo_streetname_id and cl.geo_city_id=ts.geo_city_id) +> where str_name='alamo' and city='san antonio' and state='TX' +> ; + +That's a fairly odd query; why don't you have any join condition between +streetname_lookup and city_lookup? + +The planner won't consider Cartesian joins unless forced to, which is +why it fails to consider the join order "((sl join cl) join ts)" unless +you have an outer join in the mix. I think that's generally a good +heuristic, and am disinclined to remove it ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 31 08:03:25 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C183E52A3A + for ; + Thu, 31 Mar 2005 08:03:22 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25888-10 + for ; + Thu, 31 Mar 2005 07:03:17 +0000 (GMT) +Received: from ylpvm29.prodigy.net (ylpvm29-ext.prodigy.net [207.115.57.60]) + by svr1.postgresql.org (Postfix) with ESMTP id CA42E52A39 + for ; + Thu, 31 Mar 2005 08:03:15 +0100 (BST) +Received: from one (adsl-68-124-182-149.dsl.pltn13.pacbell.net + [68.124.182.149]) + by ylpvm29.prodigy.net (8.12.10 outbound/8.12.10) with ESMTP id + j2V72jnr031656; Thu, 31 Mar 2005 02:02:45 -0500 +Received: from [192.168.5.103] (unknown [192.168.5.103]) + by one (Postfix) with ESMTP id 79F39F1A5C; + Wed, 30 Mar 2005 23:03:04 -0800 (PST) +Message-ID: <424BA115.8050606@cheapcomplexdevices.com> +Date: Wed, 30 Mar 2005 23:04:53 -0800 +From: Ron Mayer +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: rm_pg@cheapcomplexdevices.com, pgsql-performance@postgresql.org +Subject: Re: Left Outer Join much faster than non-outer Join? +References: + <1755.1112242072@sss.pgh.pa.us> +In-Reply-To: <1755.1112242072@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.044 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/675 +X-Sequence-Number: 11380 + +Tom Lane wrote: +> rm_pg@cheapcomplexdevices.com writes: +> +>> select * +>> from streetname_lookup as sl +>> join city_lookup as cl on (true) +>> left outer join tlid_smaller as ts on (sl.geo_streetname_id = ts.geo_streetname_id and cl.geo_city_id=ts.geo_city_id) +>> where str_name='alamo' and city='san antonio' and state='TX' +>>; +> +> That's a fairly odd query; + +I think it's a very common type of query in data warehousing. + +It's reasonably typical of a traditional star schema where +"streetname_lookup" and "city_lookup" are dimension tables +and "tlid_smaller" is the central fact table. + +> why don't you have any join condition between +> streetname_lookup and city_lookup? + +Those two tables shared no data. They merely get the "id"s +for looking things up in the much larger central table. + +Unique indexes on the city_lookup and street_lookup make the +cartesian join harmless (they each return only 1 value); and +the huge fact table has a multi-column index that takes both +of the ids from those lookups. + + +With the tables I have (shown below), how else could one +efficiently fetch the data for "Main St" "San Francisco"? + + streetname_lookup + (for every street name used in the country) + streetid | name | type + ----------+--------+------ + 1 | Main | St + 2 | 1st | St + + city_lookup + (for every city name used in the country) + cityid | name | state + --------+---------+------ + 1 | Boston | MA + 2 | Alameda| CA + + + tlid_smaller + (containing a record for every city block in the country) + city_id | street_id | addresses | demographics, etc. + --------+------------+-----------+---------------------- + 1 | 1 | 100 block | [lots of columns] + 1 | 1 | 200 block | [lots of columns] + 1 | 1 | 300 block | [lots of columns] + 1 | 2 | 100 block | [lots of columns] + 1 | 2 | 100 block | [lots of columns] + +> The planner won't consider Cartesian joins unless forced to, which is +> why it fails to consider the join order "((sl join cl) join ts)" unless +> you have an outer join in the mix. I think that's generally a good +> heuristic, and am disinclined to remove it ... + +IMHO it's a shame it doesn't even consider it when the estimated +results are very small. I think often joins that merely look up +IDs would be useful to consider for the purpose of making potential +multi-column indexes (as shown in the previous email's explain +analyze result where the cartesian join was 30X faster than the +other approach since it could use the multi-column index on the +very large table). + + Ron + +From pgsql-performance-owner@postgresql.org Thu Mar 31 09:14:34 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 51EF95365F + for ; + Thu, 31 Mar 2005 09:14:18 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46677-03 + for ; + Thu, 31 Mar 2005 08:14:09 +0000 (GMT) +Received: from ylpvm01.prodigy.net (ylpvm01-ext.prodigy.net [207.115.57.32]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BA0D533EF + for ; + Thu, 31 Mar 2005 09:14:08 +0100 (BST) +Received: from one (adsl-68-124-182-149.dsl.pltn13.pacbell.net + [68.124.182.149]) + by ylpvm01.prodigy.net (8.12.10 outbound/8.12.10) with ESMTP id + j2V8E84H003168; Thu, 31 Mar 2005 03:14:08 -0500 +Received: from [192.168.5.103] (unknown [192.168.5.103]) + by one (Postfix) with ESMTP id 112CFF1A5C; + Thu, 31 Mar 2005 00:14:06 -0800 (PST) +Message-ID: <424BB1BB.90304@cheapcomplexdevices.com> +Date: Thu, 31 Mar 2005 00:15:55 -0800 +From: Ron Mayer +User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ron Mayer +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: Left Outer Join much faster than non-outer Join? +References: + <1755.1112242072@sss.pgh.pa.us> + <424BA115.8050606@cheapcomplexdevices.com> +In-Reply-To: <424BA115.8050606@cheapcomplexdevices.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.03 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/676 +X-Sequence-Number: 11381 + +Ron Mayer wrote: +> Tom Lane wrote: +>> rm_pg@cheapcomplexdevices.com writes: +>>> select * +>>> from streetname_lookup as sl +>>> join city_lookup as cl on (true) +>>> left outer join tlid_smaller as ts on (sl.geo_streetname_id = +>>> ts.geo_streetname_id and cl.geo_city_id=ts.geo_city_id) +>>> where str_name='alamo' and city='san antonio' and state='TX' +>>> ; +>> That's a fairly odd query; +> +> +> I think it's a very common type of query in data warehousing. +> +> It's reasonably typical of a traditional star schema where +> "streetname_lookup" and "city_lookup" are dimension tables +> and "tlid_smaller" is the central fact table. + +Although looking again I must admit the query was +written unconventionally. Perhaps those queries are +remnants dating back to a version when you could +force join orders this way? + +Perhaps a more common way of writing it would have been: + + select * from tlid_smaller + where geo_streetname_id in (select geo_streetname_id from streetname_lookup where str_name='$str_name') + and geo_city_id in (select geo_city_id from city_lookup where city='$city' and state='$state'); + +However this query also fails to use the multi-column +index on (geo_streetname_id,geo_city_id). Explain +analyze shown below. + + +In cases where I can be sure only one result will come +from each of the lookup queries I guess I can do this: + + select * from tlid_smaller + where geo_streetname_id = (select geo_streetname_id from streetname_lookup where str_name='$str_name') + and geo_city_id = (select geo_city_id from city_lookup where city='$city' and state='$state'); + +which has the nicest plan of them all (explain analyze +also shown below). + + > With the tables I have (shown below), how else could one + > efficiently fetch the data for "Main St" "San Francisco"? + +I guess I just answered that question myself. Where possible, +I'll write my queries this way. + + Thanks, + Ron + + +fli=# fli=# explain analyze select * from tlid_smaller + where geo_streetname_id in (select geo_streetname_id from streetname_lookup where str_name='alamo') + and geo_city_id in (select geo_city_id from city_lookup where city='san antonio' and state='TX'); +fli-# fli-# QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Hash IN Join (cost=9.03..29209.16 rows=1 width=32) (actual time=76.576..96.605 rows=78 loops=1) + Hash Cond: ("outer".geo_city_id = "inner".geo_city_id) + -> Nested Loop (cost=3.02..29202.88 rows=52 width=32) (actual time=65.877..91.789 rows=4151 loops=1) + -> HashAggregate (cost=3.02..3.02 rows=1 width=4) (actual time=0.039..0.042 rows=1 loops=1) + -> Index Scan using streetname_lookup__str_name on streetname_lookup (cost=0.00..3.01 rows=1 width=4) (actual time=0.025..0.028 rows=1 loops=1) + Index Cond: (str_name = 'alamo'::text) + -> Index Scan using tlid_smaller__street_zipint on tlid_smaller (cost=0.00..28994.70 rows=16413 width=32) (actual time=65.820..81.309 rows=4151 loops=1) + Index Cond: (tlid_smaller.geo_streetname_id = "outer".geo_streetname_id) + -> Hash (cost=6.01..6.01 rows=1 width=4) (actual time=0.054..0.054 rows=0 loops=1) + -> Index Scan using city_lookup__name on city_lookup (cost=0.00..6.01 rows=1 width=4) (actual time=0.039..0.041 rows=1 loops=1) + Index Cond: ((city = 'san antonio'::text) AND (state = 'TX'::text)) + Total runtime: 97.577 ms +(12 rows) + +fli=# + +fli=# explain analyze select * from tlid_smaller + where geo_streetname_id = (select geo_streetname_id from streetname_lookup where str_name='alamo') + and geo_city_id = (select geo_city_id from city_lookup where city='san antonio' and state='TX'); + +fli-# fli-# QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using tlid_smaller__street_city on tlid_smaller (cost=9.02..16.88 rows=3 width=32) (actual time=0.115..0.255 rows=78 loops=1) + Index Cond: ((geo_streetname_id = $0) AND (geo_city_id = $1)) + InitPlan + -> Index Scan using streetname_lookup__str_name on streetname_lookup (cost=0.00..3.01 rows=1 width=4) (actual time=0.044..0.047 rows=1 loops=1) + Index Cond: (str_name = 'alamo'::text) + -> Index Scan using city_lookup__name on city_lookup (cost=0.00..6.01 rows=1 width=4) (actual time=0.028..0.030 rows=1 loops=1) + Index Cond: ((city = 'san antonio'::text) AND (state = 'TX'::text)) + Total runtime: 0.474 ms +(8 rows) + +From pgsql-performance-owner@postgresql.org Thu Mar 31 09:30:16 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A84B3536C5 + for ; + Thu, 31 Mar 2005 09:30:03 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51046-02 + for ; + Thu, 31 Mar 2005 08:29:55 +0000 (GMT) +Received: from felix.adpcl.com (felix.adpcl.com [194.98.137.100]) + by svr1.postgresql.org (Postfix) with ESMTP id BBE775296D + for ; + Thu, 31 Mar 2005 09:29:53 +0100 (BST) +Received: from pcpatrickxp (unknown [150.175.11.30]) + by felix.adpcl.com (Postfix) with SMTP + id 9E3A57811; Thu, 31 Mar 2005 10:33:04 +0200 (DFT) +Message-ID: <008001c535cb$939f48d0$1e0baf96@pcpatrickxp> +From: "Patrick Vedrines" +To: "Ron Mayer" +Cc: +References: + <1755.1112242072@sss.pgh.pa.us> + <424BA115.8050606@cheapcomplexdevices.com> +Subject: Re: Left Outer Join much faster than non-outer Join? +Date: Thu, 31 Mar 2005 10:28:11 +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.1437 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.144 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/677 +X-Sequence-Number: 11382 + +> > rm_pg@cheapcomplexdevices.com writes: +> streetname_lookup +> (for every street name used in the country) +> streetid | name | type +> ----------+--------+------ +> 1 | Main | St +> 2 | 1st | St +> +Afa I'm concerned, I would add the column "city_id" since 2 different +streets in 2 different cities may have the same name. + +Amicalement + +Patrick + + +From pgsql-performance-owner@postgresql.org Thu Mar 31 10:01:12 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D30453929 + for ; + Thu, 31 Mar 2005 10:01:10 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57372-08 + for ; + Thu, 31 Mar 2005 09:01:04 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 6341A5393C + for ; + Thu, 31 Mar 2005 10:01:02 +0100 (BST) +Received: (qmail 30509 invoked from network); 31 Mar 2005 11:01:19 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 31 Mar 2005 11:01:19 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: fine tuning for logging server +References: <1112233809.10313.31.camel@stantz.corp.sgi.com> + <424B5982.3090809@arbash-meinel.com> + <1112235878.12159.22.camel@stantz.corp.sgi.com> +Message-ID: +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Date: Thu, 31 Mar 2005 11:01:01 +0200 +In-Reply-To: <424B5982.3090809@arbash-meinel.com> +User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/678 +X-Sequence-Number: 11383 + + +> The reason: if the power cord is yanked, the OS _must_ boot back up in +> good condition. If the DB is corrupted, whatever, nuke it then re- +> initialize it. But the OS must survive act-of-god events. + + Well, in that case : + - Use reiserfs3 for your disks + - Use MySQL with MyISAM tables + +From pgsql-performance-owner@postgresql.org Thu Mar 31 14:19:47 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BFB552A48 + for ; + Thu, 31 Mar 2005 14:19:46 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27409-03 + for ; + Thu, 31 Mar 2005 13:19:40 +0000 (GMT) +Received: from dfw-gate5.raytheon.com (dfw-gate5.raytheon.com + [199.46.199.234]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A3975350E + for ; + Thu, 31 Mar 2005 14:19:39 +0100 (BST) +Received: from ds02c00.directory.ray.com (ds02c00.directory.ray.com + [147.25.138.118]) + by dfw-gate5.raytheon.com (8.12.10/8.12.10) with ESMTP id + j2VDJdLT011007; Thu, 31 Mar 2005 07:19:42 -0600 (CST) +Received: from ds02c00 (localhost [127.0.0.1]) + by ds02c00.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id + j2VDJaqa026806; Thu, 31 Mar 2005 13:19:37 GMT +Received: from ds02c00.directory.ray.com with LMTP by ds02c00 + (2.0.6/sieved-2-0-build-559); Thu, 31 Mar 2005 13:19:35 +0000 +Received: from notesserver5.ftw.us.ray.com (notesserver5.ftw.us.ray.com + [151.168.145.35]) + by ds02c00.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id + j2VDJGKs026663 sender Richard_D_Levine@raytheon.com; + Thu, 31 Mar 2005 13:19:17 GMT +In-Reply-To: <424B12E4.7000702@noao.edu> +Subject: Re: Reading recommendations +To: Steve Wampler +Cc: pgsql-performance@postgresql.org +X-Mailer: Lotus Notes Release 6.5.2 June 01, 2004 +Message-ID: + +From: Richard_D_Levine@Raytheon.com +Date: Thu, 31 Mar 2005 08:19:15 -0500 +X-MIMETrack: Serialize by Router on NotesServer5/HDC(Release 6.5.2|June 01, + 2004) at 03/31/2005 08:19:17 AM +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +X-SPAM: 0.00 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.209 tagged_above=0 required=5 tests=AWL, + NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200503/679 +X-Sequence-Number: 11384 + + + +Steve Wampler wrote on 03/30/2005 03:58:12 PM: + +> Richard_D_Levine@raytheon.com wrote: +> +> >>Mohan, Ross wrote: +> >> +> >>>VOIP over BitTorrent? +> >> +> >>Now *that* I want to see. Aught to be at least as interesting +> >>as the "TCP/IP over carrier pigeon" experiment - and more +> >>challenging to boot! +> >> +> > +> > +> > It was very challenging. I worked on the credit window sizing and +> > retransmission timer estimation algorithms. We took into account +weather +> > patterns, size and age of the bird, feeding times, and the average +number +> > of times a bird circles before determining magnetic north. +Interestingly, +> > packet size had little effect in the final algorithms. +> > +> > I would love to share them with all of you, but they're classified. +> +> Ah, but VOIPOBT requires many people all saying the same thing at the +> same time. The synchronization alone (since you need to distribute +> these people adequately to avoid overloading a trunk line...) is probably +> sufficiently hard to make it interesting. Then there are the problems of +> different accents, dilects, and languages ;) + +Interestingly, we had a follow on contract to investigate routing +optimization using flooding techniques. Oddly, it was commissioned by a +consortium of local car washes. Work stopped when the park service sued us +for the cost of cleaning all the statuary, and the company went out of +business. We were serving "cornish game hens" at our frequent dinner +parties for months. + +> +> -- +> Steve Wampler -- swampler@noao.edu +> The gods that smiled on your birth are now laughing out loud. + + +From pgsql-performance-owner@postgresql.org Thu Mar 31 14:48:43 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BAAB853559 + for ; + Thu, 31 Mar 2005 14:48:42 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34554-10 + for ; + Thu, 31 Mar 2005 13:48:36 +0000 (GMT) +Received: from viefep12-int.chello.at (viefep12-int.chello.at [213.46.255.25]) + by svr1.postgresql.org (Postfix) with ESMTP id BC78653553 + for ; + Thu, 31 Mar 2005 14:48:32 +0100 (BST) +Received: from [213.47.56.254] by viefep12-int.chello.at + (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP + id <20050331134834.YCPV24824.viefep12-int.chello.at@[213.47.56.254]> + for ; + Thu, 31 Mar 2005 15:48:34 +0200 +Message-ID: <424C01E3.3020605@foo.at> +Date: Thu, 31 Mar 2005 15:57:55 +0200 +From: Stefan Weiss +Organization: Foo Orbital Operations +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Reading recommendations +References: + +In-Reply-To: + +Content-Type: text/plain; charset=ISO-8859-15 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.008 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/680 +X-Sequence-Number: 11385 + +On 2005-03-31 15:19, Richard_D_Levine@Raytheon.com wrote: +>> >>Now *that* I want to see. Aught to be at least as interesting +>> >>as the "TCP/IP over carrier pigeon" experiment - and more +>> >>challenging to boot! +.. +> Interestingly, we had a follow on contract to investigate routing +> optimization using flooding techniques. Oddly, it was commissioned by a +> consortium of local car washes. Work stopped when the park service sued us +> for the cost of cleaning all the statuary, and the company went out of +> business. We were serving "cornish game hens" at our frequent dinner +> parties for months. + +This method might have been safer (and it works great with Apaches): +http://eagle.auc.ca/~dreid/ + +cheers +stefan + +From pgsql-performance-owner@postgresql.org Thu Mar 31 16:01:42 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 193D153AB5 + for ; + Thu, 31 Mar 2005 16:01:41 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57543-08 + for ; + Thu, 31 Mar 2005 15:01:40 +0000 (GMT) +Received: from mail1.panix.com (mail1.panix.com [166.84.1.72]) + by svr1.postgresql.org (Postfix) with ESMTP id D716053AEA + for ; + Thu, 31 Mar 2005 16:01:39 +0100 (BST) +Received: from panix1.panix.com (panix1.panix.com [166.84.1.1]) + by mail1.panix.com (Postfix) with ESMTP id 855D158ABC; + Thu, 31 Mar 2005 10:01:42 -0500 (EST) +Received: (from adler@localhost) + by panix1.panix.com (8.11.6p3/8.8.8/PanixN1.1) id j2VF1gZ12447; + Thu, 31 Mar 2005 10:01:42 -0500 (EST) +Date: Thu, 31 Mar 2005 10:01:37 -0500 +From: Michael Adler +To: John Arbash Meinel +Cc: pgsql-performance@postgresql.org +Subject: Re: fine tuning for logging server +Message-ID: <20050331150137.GB23069@pobox.com> +References: <1112233809.10313.31.camel@stantz.corp.sgi.com> + <1112234574.12159.1.camel@stantz.corp.sgi.com> + <424B5C6F.8090609@arbash-meinel.com> + <1112236212.12159.28.camel@stantz.corp.sgi.com> + <424B6367.8040009@arbash-meinel.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <424B6367.8040009@arbash-meinel.com> +User-Agent: Mutt/1.4.2.1i +X-Hashcash: + 1:20:050331:john@arbash-meinel.com::X5kTwSysg0pB70ff:000000000000000 + 0000000000000000000000003v6E +X-Hashcash: + 1:20:050331:pgsql-performance@postgresql.org::IY19HS+EB5qwDip5:00000 + 000000000000000000000000F0Go +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/681 +X-Sequence-Number: 11386 + +On Wed, Mar 30, 2005 at 08:41:43PM -0600, John Arbash Meinel wrote: +> If all you are doing is append only logging, the fastest thing is +> probably just a flat file. You could have something that comes along +> later to move it into the database. It doesn't really sound like you are +> using any features a database provides. (normalization, foreign keys, +> indexes, etc.) + +Here's two ideas that I don't think have been mentioned yet: Use copy +to bulk load the data instead of individual imports. And if you get +desperate, you can run pg with fsync=false since you don't seem to +care about re-initializing your whole database in the case of +unexpected interruption. + + -Mike + +From pgsql-performance-owner@postgresql.org Thu Mar 31 16:48:21 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6403953511 + for ; + Thu, 31 Mar 2005 16:48:20 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73875-08 + for ; + Thu, 31 Mar 2005 15:48:17 +0000 (GMT) +Received: from noao.edu (noao.edu [140.252.1.54]) + by svr1.postgresql.org (Postfix) with ESMTP id 7BA86534F6 + for ; + Thu, 31 Mar 2005 16:48:16 +0100 (BST) +X-TFF-CGPSA-Version: 1.4f1 +X-TFF-CGPSA-Filter: Scanned +Received: from [140.252.14.8] (HELO weaver.tuc.noao.edu) + by noao.edu (CommuniGate Pro SMTP 4.2.10) + with ESMTP-TLS id 17432134; Thu, 31 Mar 2005 08:48:14 -0700 +Received: from [127.0.0.1] (localhost.localdomain [127.0.0.1]) + by weaver.tuc.noao.edu (8.12.8/8.12.8) with ESMTP id j2VFm9Kv019536; + Thu, 31 Mar 2005 08:48:09 -0700 +Message-ID: <424C1BB9.1060506@noao.edu> +Date: Thu, 31 Mar 2005 08:48:09 -0700 +From: Steve Wampler +User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Stefan Weiss +Cc: pgsql-performance@postgresql.org +Subject: Re: Reading recommendations +References: + + <424C01E3.3020605@foo.at> +In-Reply-To: <424C01E3.3020605@foo.at> +Content-Type: text/plain; charset=ISO-8859-15 +Content-Transfer-Encoding: 7bit +X-noao.edu-MailScanner-Information: Please contact the ISP for more + information +X-noao.edu-MailScanner: Found to be clean +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.01 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/682 +X-Sequence-Number: 11387 + +Stefan Weiss wrote: +> On 2005-03-31 15:19, Richard_D_Levine@Raytheon.com wrote: +> +>>>>>Now *that* I want to see. Aught to be at least as interesting +>>>>>as the "TCP/IP over carrier pigeon" experiment - and more +>>>>>challenging to boot! +> +> .. +> +>>Interestingly, we had a follow on contract to investigate routing +>>optimization using flooding techniques. Oddly, it was commissioned by a +>>consortium of local car washes. Work stopped when the park service sued us +>>for the cost of cleaning all the statuary, and the company went out of +>>business. We were serving "cornish game hens" at our frequent dinner +>>parties for months. +> +> +> This method might have been safer (and it works great with Apaches): +> http://eagle.auc.ca/~dreid/ + +Aha - VOIPOBD as well as VOIPOBT! What more can one want? + +VOIPOCP, I suppose... + + +-- +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +From pgsql-performance-owner@postgresql.org Thu Mar 31 19:03:14 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CB1E9534AC + for ; + Thu, 31 Mar 2005 19:03:12 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12618-03 + for ; + Thu, 31 Mar 2005 18:02:51 +0000 (GMT) +Received: from cmailg4.svr.pol.co.uk (cmailg4.svr.pol.co.uk [195.92.195.174]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E8F2537B4 + for ; + Thu, 31 Mar 2005 19:02:50 +0100 (BST) +Received: from modem-1735.leopard.dialup.pol.co.uk ([217.135.150.199] + helo=192.168.0.102) by cmailg4.svr.pol.co.uk with esmtp (Exim 4.41) + id 1DH40F-0000eK-Kd; Thu, 31 Mar 2005 19:02:48 +0100 +Subject: Re: Left Outer Join much faster than non-outer Join? +From: Simon Riggs +To: Ron Mayer +Cc: Tom Lane , pgsql-performance@postgresql.org +In-Reply-To: <424BB1BB.90304@cheapcomplexdevices.com> +References: + <1755.1112242072@sss.pgh.pa.us> + <424BA115.8050606@cheapcomplexdevices.com> + <424BB1BB.90304@cheapcomplexdevices.com> +Content-Type: text/plain +Organization: 2nd Quadrant +Date: Thu, 31 Mar 2005 19:01:13 +0100 +Message-Id: <1112292073.16721.327.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-3) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.048 tagged_above=0 required=5 tests=AWL, + FORGED_RCVD_HELO +X-Spam-Level: +X-Archive-Number: 200503/683 +X-Sequence-Number: 11388 + +On Thu, 2005-03-31 at 00:15 -0800, Ron Mayer wrote: +> Ron Mayer wrote: +> > Tom Lane wrote: +> >> rm_pg@cheapcomplexdevices.com writes: +> >>> select * +> >>> from streetname_lookup as sl +> >>> join city_lookup as cl on (true) +> >>> left outer join tlid_smaller as ts on (sl.geo_streetname_id = +> >>> ts.geo_streetname_id and cl.geo_city_id=ts.geo_city_id) +> >>> where str_name='alamo' and city='san antonio' and state='TX' +> >>> ; +> >> That's a fairly odd query; +> > +> > +> > I think it's a very common type of query in data warehousing. +> > +> > It's reasonably typical of a traditional star schema where +> > "streetname_lookup" and "city_lookup" are dimension tables +> > and "tlid_smaller" is the central fact table. +> + +Yes, agreed. + +> Although looking again I must admit the query was +> written unconventionally. Perhaps those queries are +> remnants dating back to a version when you could +> force join orders this way? +> +> Perhaps a more common way of writing it would have been: +> +> select * from tlid_smaller +> where geo_streetname_id in (select geo_streetname_id from streetname_lookup where str_name='$str_name') +> and geo_city_id in (select geo_city_id from city_lookup where city='$city' and state='$state'); +> +> However this query also fails to use the multi-column +> index on (geo_streetname_id,geo_city_id). Explain +> analyze shown below. + +...which is my understanding too. + +> In cases where I can be sure only one result will come +> from each of the lookup queries I guess I can do this: +> +> select * from tlid_smaller +> where geo_streetname_id = (select geo_streetname_id from streetname_lookup where str_name='$str_name') +> and geo_city_id = (select geo_city_id from city_lookup where city='$city' and state='$state'); +> +> which has the nicest plan of them all (explain analyze +> also shown below). + +Which is not the case for the generalised star join. + +The general case query here is: + SELECT (whatever) + FROM FACT, DIMENSION1 D1, DIMENSION2 D2, DIMENSION3 D3etc.. + WHERE + FACT.dimension1_pk = D1.dimension1_pk + AND FACT.dimension2_pk = D2.dimension2_pk + AND FACT.dimension3_pk = D3.dimension3_pk + AND D1.dimdescription = 'X' + AND D2.dimdescription = 'Y' + AND D3.dimdescription = 'Z' + ... +with FACT PK=(dimension1_pk, dimension2_pk, dimension3_pk) + +with a more specific example of + SELECT sum(item_price) + FROM Sales, Store, Item, TTime + WHERE + Sales.store_pk = Store.store_pk + AND Store.region = 'UK' + AND Sales.item_pk = Item.item_pk + AND Item.category = 'Cameras' + AND Sales.time_pk = TTime.time_pk + AND TTime.month = 3 + AND TTime.year = 2005 + +A very good plan for solving this, under specific conditions is... + CartesianProduct(Store, Item, TTime) -> Sales.PK + +which accesses the largest table only once. + +As Tom says, the current optimizer won't go near that plan, for good +reason, without specifically tweaking collapse limits. I know full well +that any changes in that direction will need to be strong because that +execution plan is very sensitive to even minor changes in data +distribution. + +The plan requires some fairly extensive checking to be put into place. +The selectivity of requests against the smaller tables needs to be very +well known, so that the upper bound estimate of cardinality of the +cartesian product is feasible AND still low enough to use the index on +Sales. + +This is probably going to need information to be captured on multi- +column index selectivity, to ensure that last part. + +It is likely that the statistics targets on the dimension tables would +need to be higher enough to identify MFVs or at least reduce the upper +bound of selectivity. It is also requires the table sizes to be +examined, to ensure this type of plan is considered pointlessly. +Some other systems that support this join type, turn off checking for it +by default. We could do the same with enable_starjoin = off. + +Anyway, seems like a fair amount of work there... yes? + +Best Regards, Simon Riggs + + + +From pgsql-performance-owner@postgresql.org Thu Mar 31 19:24:49 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C36B8537B9; + Thu, 31 Mar 2005 19:24:47 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17566-08; Thu, 31 Mar 2005 18:24:44 +0000 (GMT) +Received: from dfw-gate1.raytheon.com (dfw-gate1.raytheon.com + [199.46.199.230]) + by svr1.postgresql.org (Postfix) with ESMTP id 642FB537A6; + Thu, 31 Mar 2005 19:24:43 +0100 (BST) +Received: from ds02c00.directory.ray.com (ds02c00.directory.ray.com + [147.25.138.118]) + by dfw-gate1.raytheon.com (8.12.10/8.12.10) with ESMTP id + j2VIOgqb021487; Thu, 31 Mar 2005 12:24:42 -0600 (CST) +Received: from ds02c00 (localhost [127.0.0.1]) + by ds02c00.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id + j2VIOaS0004817; Thu, 31 Mar 2005 18:24:36 GMT +Received: from ds02c00.directory.ray.com with LMTP by ds02c00 + (2.0.6/sieved-2-0-build-559); Thu, 31 Mar 2005 18:24:35 +0000 +Received: from notesserver5.ftw.us.ray.com (notesserver5.ftw.us.ray.com + [151.168.145.35]) + by ds02c00.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id + j2VIOVw6004765 sender Richard_D_Levine@raytheon.com; + Thu, 31 Mar 2005 18:24:32 GMT +In-Reply-To: <424C1BB9.1060506@noao.edu> +Subject: Re: Reading recommendations +To: Steve Wampler +Cc: pgsql-performance@postgresql.org, pgsql-performance-owner@postgresql.org, + Stefan Weiss +X-Mailer: Lotus Notes Release 6.5.2 June 01, 2004 +Message-ID: + +From: Richard_D_Levine@raytheon.com +Date: Thu, 31 Mar 2005 13:24:30 -0500 +X-MIMETrack: Serialize by Router on NotesServer5/HDC(Release 6.5.2|June 01, + 2004) at 03/31/2005 01:24:32 PM +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +X-SPAM: 0.00 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.209 tagged_above=0 required=5 tests=AWL, + NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200503/684 +X-Sequence-Number: 11389 + + + +pgsql-performance-owner@postgresql.org wrote on 03/31/2005 10:48:09 AM: + +> Stefan Weiss wrote: +> > On 2005-03-31 15:19, Richard_D_Levine@Raytheon.com wrote: +> > +> >>>>>Now *that* I want to see. Aught to be at least as interesting +> >>>>>as the "TCP/IP over carrier pigeon" experiment - and more +> >>>>>challenging to boot! +> > +> > .. +> > +> >>Interestingly, we had a follow on contract to investigate routing +> >>optimization using flooding techniques. Oddly, it was commissioned by +a +> >>consortium of local car washes. Work stopped when the park service +sued us +> >>for the cost of cleaning all the statuary, and the company went out of +> >>business. We were serving "cornish game hens" at our frequent dinner +> >>parties for months. +> > +> > +> > This method might have been safer (and it works great with Apaches): +> > http://eagle.auc.ca/~dreid/ +> +> Aha - VOIPOBD as well as VOIPOBT! What more can one want? +> +> VOIPOCP, I suppose... + +Start collecting recipes for small game birds now. We ran out pretty +quickly. Finally came up with "Pigeon Helper" and sold it to homeless +shelters in New York. Sales were slow until we added a wine sauce. + +> +> +> -- +> Steve Wampler -- swampler@noao.edu +> The gods that smiled on your birth are now laughing out loud. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings + + +From pgsql-performance-owner@postgresql.org Thu Mar 31 19:52:53 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C4D9534D3 + for ; + Thu, 31 Mar 2005 19:52:52 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39484-01 + for ; + Thu, 31 Mar 2005 18:52:50 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.193]) + by svr1.postgresql.org (Postfix) with ESMTP id D45B452D44 + for ; + Thu, 31 Mar 2005 19:52:48 +0100 (BST) +Received: by rproxy.gmail.com with SMTP id j1so454428rnf + for ; + Thu, 31 Mar 2005 10:52:49 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; + b=a63Et7LypbyOOGNNcxrmFgd096F7GjGaP9+x81Y3IVDgfFL2AyQGtzUEwS8asCZ2x1zorDiaJHGu88dqkeCil9i3Kxrny2dvkOc8IREEZ1kVvyhplGlWdc8cW1JnjLJ03VtlsA4vTLxJB3NEiXZetqgb8PWueUIbQ6ThsDGrywo= +Received: by 10.38.79.42 with SMTP id c42mr1621512rnb; + Thu, 31 Mar 2005 10:52:49 -0800 (PST) +Received: by 10.38.82.47 with HTTP; Thu, 31 Mar 2005 10:52:48 -0800 (PST) +Message-ID: +Date: Thu, 31 Mar 2005 12:52:48 -0600 +From: Yudie Pg +Reply-To: Yudie Pg +To: pgsql-performance@postgresql.org +Subject: How to speed up word count with tsearch2? +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.235 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/685 +X-Sequence-Number: 11390 + +I've tested several keyword count from 2 millions record book +description table that indexed with tseach2 indexing. +The result is always slow for first query attempt. + +This my sample query: +-- test one phrase -- +SELECT count(*) from table1 +WHEREsearchvector @@ to_tsquery('default' ,'david') limit 100 +:: returns 16824 records match. +:: take 49618.341 ms (1st attempt) +:: take 504.229 ms (2nd attempt) + +-- test two phrase -- +SELECT count(*) from table1 +WHERE searchvector @@ to_tsquery('default' ,'martha&stewart') limit 100 +:: returns 155 records match. +:: take 686.669 ms (1st attempt) +:: take 40.282 ms (2nd attempt) + +I use ordinary aggregate function count(*), Is there other way to count faster? + +From pgsql-performance-owner@postgresql.org Thu Mar 31 20:05:10 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1BC4F539F1 + for ; + Thu, 31 Mar 2005 20:04:19 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48104-03 + for ; + Thu, 31 Mar 2005 19:04:11 +0000 (GMT) +Received: from srv1.alteeve.com (unknown [209.167.86.38]) + by svr1.postgresql.org (Postfix) with ESMTP id 608ED539E4 + for ; + Thu, 31 Mar 2005 20:04:02 +0100 (BST) +Received: from [192.168.1.99] (nabiki.thelinuxexperience.com [209.167.86.34]) + by srv1.alteeve.com (8.12.10/8.12.10) with ESMTP id j2VJNEsm024406 + for ; Thu, 31 Mar 2005 14:23:14 -0500 +Message-ID: <424C49A1.1090003@alteeve.com> +Date: Thu, 31 Mar 2005 14:04:01 -0500 +From: Madison Kelly +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.7.6) Gecko/20050323 Fedora/1.7.6-1.3.2 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Very long time to execute and Update, suggestions? +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/686 +X-Sequence-Number: 11391 + +Hi all, + + I have a table with a little over 200,000 columns in it that I need +to update using a regular expression. I admit that though I am not a +beginner and postgres, I am also far from an expert. :p + + I tried to create an Index that would optimize the UPDATE but I may +have made an error in how I built it. Here is the table structure, the +index I tried to create and an 'EXPLAIN ANALYZE' of the UPDATE (though I + am still just now learning how to use 'EXPLAIN'). + +tle-bu=> \d file_info_3 + Table "public.file_info_3" + Column | Type | Modifiers +-----------------+----------------------+----------------------------------------- + file_group_name | text | not null + file_group_uid | bigint | not null + file_mod_time | bigint | not null + file_name | text | not null + file_parent_dir | text | not null + file_perm | text | not null + file_size | bigint | not null + file_type | character varying(2) | not null default +'f'::character varying + file_user_name | text | not null + file_user_uid | bigint | not null + file_backup | boolean | not null default true + file_display | boolean | not null default false + file_restore | boolean | not null default false +Indexes: + "file_info_3_display_idx" btree (file_type, file_parent_dir, file_name) + + Here is the EXPLAIN: + +tle-bu=> EXPLAIN ANALYZE UPDATE file_info_3 SET file_backup='f' WHERE +file_parent_dir~'^/home' OR (file_parent_dir='/' AND file_name='home'); + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------- + Seq Scan on file_info_3 (cost=0.00..7770.00 rows=1006 width=206) +(actual time=1050.813..5648.462 rows=67835 loops=1) + Filter: ((file_parent_dir ~ '^/home'::text) OR ((file_parent_dir = +'/'::text) AND (file_name = 'home'::text))) + Total runtime: 68498.898 ms +(3 rows) + + I thought that it would have used the index because 'file_parent_dir' +and 'file_name' are in the index but is I am reading the "EXPLAIN" +output right it isn't but is instead doing a sequencial scan. If that is +the case, how would I best built the index? Should I have just used the +'file_parent_dir' and 'file_name'? + + Thanks all!! + +Madison + +-- +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +Madison Kelly (Digimer) +TLE-BU, The Linux Experience; Back Up +http://tle-bu.thelinuxexperience.com +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +From pgsql-performance-owner@postgresql.org Thu Mar 31 20:07:27 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3AF8153A27 + for ; + Thu, 31 Mar 2005 20:07:22 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47781-07 + for ; + Thu, 31 Mar 2005 19:07:20 +0000 (GMT) +Received: from mail.deg.cc (mail.deg.cc [64.139.134.201]) + by svr1.postgresql.org (Postfix) with ESMTP id 8748353A12 + for ; + Thu, 31 Mar 2005 20:07:19 +0100 (BST) +Received: from deg.cc (unknown [205.242.255.66]) + by mail.deg.cc (Postfix) with ESMTP id 9F80C55FB5 + for ; + Thu, 31 Mar 2005 14:07:15 -0500 (EST) +Message-ID: <424C4A66.3050604@deg.cc> +Date: Thu, 31 Mar 2005 14:07:18 -0500 +From: Pallav Kalva +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) Gecko/20040308 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: performance pgsql +Subject: Postgresql.conf setting recommendations for 8.0.1 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/687 +X-Sequence-Number: 11392 + +Hi, + + We are migrating to a new server with more memory and also from +postgres 7.4 to postgres 8.0.1 version. + +Here are my settings on the current 7.4 version: +OS : RedHat 9 +CPUS: 2 hyperthreaded +Memory: 4gig +shared_buffers: 65536 +sort_mem: 16384 +vacuum_mem: 32768 +wal_buffers: 64 +effective_cache_size: 393216 +checkpoint_segments: 3 +checkpoint_timeout: 300 +checkpoint_warning: 30 + +These are settings which I am planning on the new machine with 8.0.1 +version: +OS: Fedora Core 2 +CPUs: 2 hyperthreaded +Memory: 8 gig +shared_buffers: 131072 +work_mem: 32768 +maintanence_work_mem: 65536 +wal_buffers: 64 +effective_cache_size: 786432 +checkpoint_segments: 8 +checkpoint_timeout: 600 +checkpoint_warning: 30 + + The current settings on my 7.4 version gives me very good +performance, so I basically doubled the settings since i will be having +the double the memory in the new machine. What my concern is about the +effective_cache_settings , according the docs its recommends me to set +max to about 2/3 of the total memory and I went little over on top of +it, is that ok ? I went little over on my current 7.4 system too, and +its giving me very good performance so I used the same calculation for +my new system too. + Also, can anyone guide me with the ideal settings for +vacuum_cost_delay, vacuum_cost_page_hit, vacuum_cost_page_miss, +vacuum_cost_page_dirty, vacuum_cost_limit, background_delay, +bgwriter_percent, bgwriter_maxpages settings. I am not sure what +settings should I make to these parameters , are there any ideal +settings for these parameters in a OLTP environment ? + +Thanks! +Pallav + + +From pgsql-performance-owner@postgresql.org Thu Mar 31 20:52:07 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D0535360C + for ; + Thu, 31 Mar 2005 20:52:06 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52666-09 + for ; + Thu, 31 Mar 2005 19:51:56 +0000 (GMT) +Received: from srv1.alteeve.com (unknown [209.167.86.38]) + by svr1.postgresql.org (Postfix) with ESMTP id 141BC534F6 + for ; + Thu, 31 Mar 2005 20:51:55 +0100 (BST) +Received: from [192.168.1.99] (nabiki.thelinuxexperience.com [209.167.86.34]) + by srv1.alteeve.com (8.12.10/8.12.10) with ESMTP id j2VKB5sm024625; + Thu, 31 Mar 2005 15:11:05 -0500 +Message-ID: <424C54D7.5020906@alteeve.com> +Date: Thu, 31 Mar 2005 14:51:51 -0500 +From: Madison Kelly +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.7.6) Gecko/20050323 Fedora/1.7.6-1.3.2 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Philip Hallstrom +Cc: pgsql-performance@postgresql.org +Subject: Re: Very long time to execute and Update, suggestions? +References: <424C49A1.1090003@alteeve.com> + <20050331111709.P55747@wolf.pjkh.com> +In-Reply-To: <20050331111709.P55747@wolf.pjkh.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= +X-Spam-Level: +X-Archive-Number: 200503/688 +X-Sequence-Number: 11393 + +Philip Hallstrom wrote: +> I'm not sure about this which is why I'm replying off list, but your +> index is on file_type, file_parent_dir, and file_name and you're query +> is on file_parent_dir and file_name. +> +> I seem to remember reading that that the index will only get used if the +> columns in the where clause "match up" "in order". +> +> That is um... if you have an index on columns a and b and a where clause +> of "b = 1" it woin't use the index since the index "looks like" +> +> a, b +> a, b +> a, b +> etc... +> +> Does that make any sense? Not sure if that's right or not, but easy +> enough to remove the "file_type" from your index and try it. +> +> post back to the list if that's it. +> +> -philip + +Thanks for the reply! + + I have played around a little more and have created a few different +test Indexes and it looks like it is the regex that is causing it to do +the sequential scan. If I remove the regex and create a +'file_parent_dir', 'file_name' index it will use it. If I create an +Index just for 'file_parent_dir' and change my UPDATE to just look for +the regex '... WHERE file_parent_dir~'^/'...' it will still do the +sequential scan anyway. + + So I need to either find an Index that will work with regexes or +re-write my code to update each subdirectory separately and use simpler +UPDATE statement for each. + + Thanks again! + +Madison + +PS - I cc'ed the list to follow up on what I found out so far. (Hi list!) + + +-- +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +Madison Kelly (Digimer) +TLE-BU, The Linux Experience; Back Up +http://tle-bu.thelinuxexperience.com +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +From pgsql-performance-owner@postgresql.org Thu Mar 31 20:58:35 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A89553AD6 + for ; + Thu, 31 Mar 2005 20:58:34 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56474-06 + for ; + Thu, 31 Mar 2005 19:58:33 +0000 (GMT) +Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.203]) + by svr1.postgresql.org (Postfix) with ESMTP id 2875053A6C + for ; + Thu, 31 Mar 2005 20:58:30 +0100 (BST) +Received: by rproxy.gmail.com with SMTP id j1so469690rnf + for ; + Thu, 31 Mar 2005 11:58:30 -0800 (PST) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; + b=JwqY/8WzORPZ8KKy0YxsZ7knxMvtrzIEuYUi1wBvv31VY+AIi+UJ9pbEKLcyS7ybf18FLUHHGIgHbS1mCA7WCQPZzWolJBkreN92Y91iWn1cN7soJ+xRmJydN6n4ZqefwAyFZ4pUY1NEA0qT1xeRdFMDR6LPr7RVj3zDFLoE6m4= +Received: by 10.38.208.10 with SMTP id f10mr1702645rng; + Thu, 31 Mar 2005 11:58:30 -0800 (PST) +Received: by 10.38.82.47 with HTTP; Thu, 31 Mar 2005 11:58:30 -0800 (PST) +Message-ID: +Date: Thu, 31 Mar 2005 13:58:30 -0600 +From: Yudie Pg +Reply-To: Yudie Pg +To: pgsql-performance@postgresql.org +Subject: How to speed up word count in tsearch2? +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.239 tagged_above=0 required=5 tests=AWL, + DNS_FROM_RFC_ABUSE, RCVD_BY_IP +X-Spam-Level: +X-Archive-Number: 200503/689 +X-Sequence-Number: 11394 + +(It is the 2nd posting, maybe the 1st one didn't goes thru) +I've tested several keyword count from 2 millions record book +description table that indexed with tseach2 indexing. +The result is always slow for first query attempt. + +This my sample query: +-- test one phrase -- +SELECT count(*) from table1 +WHEREsearchvector @@ to_tsquery('default' ,'david') limit 100 +:: returns 16824 records match. +:: take 49618.341 ms (1st attempt) +:: take 504.229 ms (2nd attempt) + +-- test two phrase -- +SELECT count(*) from table1 +WHERE searchvector @@ to_tsquery('default' ,'martha&stewart') limit 100 +:: returns 155 records match. +:: take 686.669 ms (1st attempt) +:: take 40.282 ms (2nd attempt) + +I use ordinary aggregate function count(*), Is there other way to count faster? + +From pgsql-performance-owner@postgresql.org Thu Mar 31 21:46:02 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5CC5C52A5A + for ; + Thu, 31 Mar 2005 21:46:00 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 70890-01 + for ; + Thu, 31 Mar 2005 20:45:56 +0000 (GMT) +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 81EFB529E2 + for ; + Thu, 31 Mar 2005 21:45:55 +0100 (BST) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [67.103.45.218] (account josh@agliodbs.com HELO + [192.168.1.122]) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 7186925; Thu, 31 Mar 2005 12:47:50 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Yudie Pg +Subject: Re: How to speed up word count in tsearch2? +Date: Thu, 31 Mar 2005 12:50:45 -0800 +User-Agent: KMail/1.7.1 +Cc: pgsql-performance@postgresql.org +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200503311250.45932.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/690 +X-Sequence-Number: 11395 + +Yudie, + +> (It is the 2nd posting, maybe the 1st one didn't goes thru) +> I've tested several keyword count from 2 millions record book +> description table that indexed with tseach2 indexing. +> The result is always slow for first query attempt. + +Yes, this is because your tsearch2 index is getting pushed out of RAM. When +the index is cached it's very, very fast but takes a long time to get loaded +from disk. + +You need to look at what else is using RAM on that machine. And maybe buy +more. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Mar 31 22:28:09 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EDE29537FE + for ; + Thu, 31 Mar 2005 22:28:06 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80601-10 + for ; + Thu, 31 Mar 2005 21:28:05 +0000 (GMT) +Received: from boutiquenumerique.com (boutiquenumerique.com [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E0E6537FA + for ; + Thu, 31 Mar 2005 22:28:03 +0100 (BST) +Received: (qmail 6602 invoked from network); 31 Mar 2005 23:28:20 +0200 +Received: from unknown (HELO localhost) (boutiquenumerique-lists@192.168.0.4) + by boutiquenumerique.com with SMTP; 31 Mar 2005 23:28:20 +0200 +To: "Madison Kelly" , + "Philip Hallstrom" +Cc: pgsql-performance@postgresql.org +Subject: Re: Very long time to execute and Update, suggestions? +References: <424C49A1.1090003@alteeve.com> <424C54D7.5020906@alteeve.com> + <20050331111709.P55747@wolf.pjkh.com> +Message-ID: +Date: Thu, 31 Mar 2005 23:28:03 +0200 +From: PFC +Organization: =?iso-8859-15?Q?La_Boutique_Num=E9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <424C54D7.5020906@alteeve.com> +User-Agent: Opera M2(BETA2)/8.0 (Linux, build 987) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL +X-Spam-Level: +X-Archive-Number: 200503/691 +X-Sequence-Number: 11396 + + +> So I need to either find an Index that will work with regexes or +> re-write my code to update each subdirectory separately and use simpler +> UPDATE statement for each. + + Why don't you use a LTREE type to model your directory tree ? It's been +designed specifically for this purpose and has indexed regular expression +search. + +http://www.sai.msu.su/~megera/postgres/gist/ltree/ +http://www.sai.msu.su/~megera/postgres/gist/ + +From pgsql-performance-owner@postgresql.org Thu Mar 31 23:13:51 2005 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D9368534D3 + for ; + Thu, 31 Mar 2005 23:13:48 +0100 (BST) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91949-07 + for ; + Thu, 31 Mar 2005 22:13:40 +0000 (GMT) +Received: from smtp103.rog.mail.re2.yahoo.com (smtp103.rog.mail.re2.yahoo.com + [206.190.36.81]) + by svr1.postgresql.org (Postfix) with SMTP id 6822852D44 + for ; + Thu, 31 Mar 2005 23:13:39 +0100 (BST) +Received: from unknown (HELO phlogiston.dydns.org) + (a.sullivan@rogers.com@216.75.167.195 with login) + by smtp103.rog.mail.re2.yahoo.com with SMTP; 31 Mar 2005 22:13:41 -0000 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id C26923F9C; Thu, 31 Mar 2005 17:13:35 -0500 (EST) +Date: Thu, 31 Mar 2005 17:13:35 -0500 +From: Andrew Sullivan +To: "pgsql-performance@postgresql.org" +Subject: Re: pg_autovacuum not having enough suction ? +Message-ID: <20050331221335.GB19823@phlogiston.dyndns.org> +Mail-Followup-To: "pgsql-performance@postgresql.org" + +References: <16180.1111792693@sss.pgh.pa.us> + <200503252321.j2PNLO826150@candle.pha.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200503252321.j2PNLO826150@candle.pha.pa.us> +User-Agent: Mutt/1.5.6+20040907i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.257 tagged_above=0 required=5 tests=AWL, + TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200503/692 +X-Sequence-Number: 11397 + +On Fri, Mar 25, 2005 at 06:21:24PM -0500, Bruce Momjian wrote: +> +> Can we issue a LOCK TABLE with a statement_timeout, and only do the +> VACUUM FULL if we can get a lock quickly? That seems like a plan. + +I think someone else's remark in this thread is important, though: +autovacuum shouldn't ever block other transactions, and this approach +will definitely run that risk. + +A + + +-- +Andrew Sullivan | ajs@crankycanuck.ca +A certain description of men are for getting out of debt, yet are +against all taxes for raising money to pay it off. + --Alexander Hamilton +