diff --git "a/pgsql-performance.200408" "b/pgsql-performance.200408" new file mode 100644--- /dev/null +++ "b/pgsql-performance.200408" @@ -0,0 +1,46431 @@ +From pgsql-performance-owner@postgresql.org Sun Aug 1 08:42:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D0B9BD1B1B9 + for ; + Sun, 1 Aug 2004 08:42:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81477-06 + for ; + Sun, 1 Aug 2004 11:42:36 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id C48A4D1B17B + for ; + Sun, 1 Aug 2004 08:42:31 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1BrEjZ-00082u-00; Sun, 01 Aug 2004 07:42:33 -0400 +To: pgsql-performance@postgresql.org +Subject: SSD Drives +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 01 Aug 2004 07:42:33 -0400 +Message-ID: <87r7qrnkye.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/1 +X-Sequence-Number: 7637 + + +To the person who was looking for a $5k midlevel SSD drive (sorry, I hit 'd' +too fast): + + http://www.tigicorp.com/tigijet_exp_s.htm + +I found this via this interesting survey of SSD products: + + http://www.storagesearch.com/ssd-buyers-guide.html + +Incidentally it seems the popular Platypus SSD PCI cards are no more, Platypus +appears to have gone out of business. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Fri Aug 6 00:41:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AB319D1B1E0 + for ; + Sun, 1 Aug 2004 16:18:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22229-09 + for ; + Sun, 1 Aug 2004 19:18:01 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D761D1B1B4 + for ; + Sun, 1 Aug 2004 16:17:59 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i71JHwqb025590 + for ; Sun, 1 Aug 2004 19:17:58 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i71JDCLm025097 + for pgsql-performance@postgresql.org; Sun, 1 Aug 2004 19:13:12 GMT +From: "Mischa Sandberg" +X-Newsgroups: comp.databases.postgresql.performance +References: <1091156393.39517b44365bc@mail.coretech.co.nz> + <001f01c4763c$fcef40f0$4e00020a@develavoie> +Subject: Re: my boss want to migrate to ORACLE +Lines: 16 +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 +Message-ID: +Date: Sun, 01 Aug 2004 19:13:12 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 + tests=PRIORITY_NO_NAME +X-Spam-Level: +X-Archive-Number: 200408/70 +X-Sequence-Number: 7706 + +Regarding Raid5 at all, you might want to look at http://www.baarf.com + +""Stephane Tessier"" wrote in message +news:001f01c4763c$fcef40f0$4e00020a@develavoie... +> I think with your help guys I'll do it! +> +> I'm working on it! +> +> I'll work on theses issues: +> +> we have space for more ram(we use 2 gigs on possibility of 3 gigs) +> iowait is very high 98% --> look like postgresql wait for io access +> raid5 -->raid0 if i'm right raid5 use 4 writes(parity,data, etc) for each +.... + + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 05:11:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 42F20D1B1E3 + for ; + Mon, 2 Aug 2004 05:11:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85835-04 + for ; + Mon, 2 Aug 2004 08:11:47 +0000 (GMT) +Received: from mailhost.ics.forth.gr (mailhost.ics.forth.gr [139.91.157.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F840D1B183 + for ; + Mon, 2 Aug 2004 05:11:43 -0300 (ADT) +Received: from mailhost.ics.forth.gr (nemesis.ics.forth.gr [139.91.157.50]) + by mailhost.ics.forth.gr (8.12.10/ICS-FORTH/V10-Server-1.0) with SMTP + id i728BbF0012622 for ; + Mon, 2 Aug 2004 11:11:43 +0300 (EEST) +Received: (from ASSP-nospam [127.0.0.1]) + by mailhost.ics.forth.gr (SAVSMTP 3.1.0.29) with SMTP id + M2004080211114302082 + for ; Mon, 02 Aug 2004 11:11:43 +0300 +Received: from 139.91.157.52 ([139.91.157.52] helo=calliope.ics.forth.gr) + by ASSP-nospam ; 2 Aug 04 08:11:43 -0000 +Received: from localhost (theohari@localhost) + by calliope.ics.forth.gr (8.9.3/ICS-FORTH/V8.2.2C-INTNULL) with ESMTP + id LAA12638 for ; + Mon, 2 Aug 2004 11:11:43 +0300 (EET DST) +X-Authentication-Warning: calliope.ics.forth.gr: theohari owned process doing + -bs +Date: Mon, 2 Aug 2004 11:11:43 +0300 (EET DST) +From: Ioannis Theoharis +To: pgsql-performance@postgresql.org +Subject: Page Miss Hits +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/2 +X-Sequence-Number: 7638 + + + +Hi, i would like to answer if there is any way in postgres to find the +page miss hits caused during a query execution. + + +Is there something like explain analyze with the page miss hits??? + +From pgsql-performance-owner@postgresql.org Mon Aug 2 09:08:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 99ABBD1B17B + for ; + Mon, 2 Aug 2004 09:08:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77186-07 + for ; + Mon, 2 Aug 2004 12:08:55 +0000 (GMT) +Received: from p15110922.pureserver.info (p15110922.pureserver.info + [217.160.165.141]) + by svr1.postgresql.org (Postfix) with ESMTP id C5B71D1B170 + for ; + Mon, 2 Aug 2004 09:08:50 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by p15110922.pureserver.info (Postfix) with ESMTP id 271912202B8 + for ; + Mon, 2 Aug 2004 14:08:52 +0200 (CEST) +Received: from p15110922.pureserver.info ([127.0.0.1]) + by localhost (p15110922 [127.0.0.1]) (amavisd-new, + port 10024) with ESMTP + id 29440-09 for ; + Mon, 2 Aug 2004 14:08:51 +0200 (CEST) +Received: by p15110922.pureserver.info (Postfix, from userid 30) + id B32852202B7; Mon, 2 Aug 2004 14:08:51 +0200 (CEST) +From: mailing@impactmedia.de +To: pgsql-performance@postgresql.org +Subject: No index usage with "left join" +MIME-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Message-Id: <20040802120851.B32852202B7@p15110922.pureserver.info> +Date: Mon, 2 Aug 2004 14:08:51 +0200 (CEST) +X-Virus-Scanned: by amavisd-new at impactmedia.de +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200408/3 +X-Sequence-Number: 7639 + +We have a "companies" and a "contacts" table with about 3000 records +each. + +We run the following SQL-Command which runs about 2 MINUTES !: + +SELECT count(*) FROM contacts LEFT JOIN companies ON contacts.sid =3D +companies.intfield01 + +contacts.sid (type text, b-tree index on it) +companies.intfield01 (type bigint, b-tree index on it) + +comfire=3D> explain analyze SELECT count(*) FROM prg_contacts LEFT JOIN +prg_addresses ON prg_contacts.sid=3Dprg_addresses.intfield01; +NOTICE: QUERY PLAN: + +Aggregate (cost=3D495261.02..495261.02 rows=3D1 width=3D15) (actual +time=3D40939.38..40939.38 rows=3D1 loops=3D1) + -> Nested Loop (cost=3D0.00..495253.81 rows=3D2885 width=3D15) (actual +time=3D0.05..40930.14 rows=3D2866 loops=3D1) + -> Seq Scan on prg_contacts (cost=3D0.00..80.66 rows=3D2866 +width=3D7) (actual time=3D0.01..18.10 rows=3D2866 loops=3D1) + -> Seq Scan on prg_addresses (cost=3D0.00..131.51 rows=3D2751 +width=3D8) (actual time=3D0.03..6.25 rows=3D2751 loops=3D2866) +Total runtime: 40939.52 msec + +EXPLAIN + +Note: +- We need the left join because we need all contacts even if they are +not assigned to a company +- We are not able to change the datatypes of the joined fields +because we use a standard software (btw who cares: SuSE Open Exchange +Server) +- When we use a normal join (without LEFT or a where clause) the SQL +runs immediately using the indexes + +How can I force the usage of the indexes when using "left join". Or +any other SQL construct that does the same !? Can anybody please give +us a hint !? + +Thanks in forward. + +Greetings +Achim + +From pgsql-performance-owner@postgresql.org Mon Aug 2 09:18:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3DFA9D1B171 + for ; + Mon, 2 Aug 2004 09:18:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82884-05 + for ; + Mon, 2 Aug 2004 12:18:16 +0000 (GMT) +Received: from usbb-lacimss3.unisys.com (usbb-lacimss3.unisys.com + [192.63.108.53]) + by svr1.postgresql.org (Postfix) with ESMTP id 2FD6ED1B229 + for ; + Mon, 2 Aug 2004 09:18:11 -0300 (ADT) +Received: from usbb-lacgw1.lac.uis.unisys.com ([129.226.160.21]unverified) by + usbb-lacimss3 with InterScan Messaging Security Suite; + Mon, 02 Aug 2004 08:19:44 -0400 +Received: from usbb-lacgw1.lac.uis.unisys.com ([129.226.160.23]) by + usbb-lacgw1.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Mon, 2 Aug 2004 08:18:12 -0400 +Received: from gbmk-eugw2.eu.uis.unisys.com ([129.221.133.27]) by + usbb-lacgw1.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Mon, 2 Aug 2004 08:18:12 -0400 +Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by + gbmk-eugw2.eu.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Mon, 2 Aug 2004 13:18:02 +0100 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Subject: Re: No index usage with "left join" +Date: Mon, 2 Aug 2004 14:16:41 +0200 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] No index usage with "left join" +Thread-Index: AcR4ieY+jtXJ+B+hTgWklGrx1B2u/QAAKG5w +From: "Leeuw van der, Tim" +To: , +X-OriginalArrivalTime: 02 Aug 2004 12:18:02.0635 (UTC) + FILETIME=[C1DA5DB0:01C4788A] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/4 +X-Sequence-Number: 7640 + +Cannot you do a cast in your query? Does that help with using the indexes? + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]On Behalf Of +mailing@impactmedia.de +Sent: maandag 2 augustus 2004 14:09 +To: pgsql-performance@postgresql.org +Subject: [PERFORM] No index usage with "left join" + + +We have a "companies" and a "contacts" table with about 3000 records +each. + +We run the following SQL-Command which runs about 2 MINUTES !: + +SELECT count(*) FROM contacts LEFT JOIN companies ON contacts.sid =3D +companies.intfield01 + +contacts.sid (type text, b-tree index on it) +companies.intfield01 (type bigint, b-tree index on it) + +comfire=3D> explain analyze SELECT count(*) FROM prg_contacts LEFT JOIN +prg_addresses ON prg_contacts.sid=3Dprg_addresses.intfield01; +NOTICE: QUERY PLAN: + +Aggregate (cost=3D495261.02..495261.02 rows=3D1 width=3D15) (actual +time=3D40939.38..40939.38 rows=3D1 loops=3D1) + -> Nested Loop (cost=3D0.00..495253.81 rows=3D2885 width=3D15) (actual +time=3D0.05..40930.14 rows=3D2866 loops=3D1) + -> Seq Scan on prg_contacts (cost=3D0.00..80.66 rows=3D2866 +width=3D7) (actual time=3D0.01..18.10 rows=3D2866 loops=3D1) + -> Seq Scan on prg_addresses (cost=3D0.00..131.51 rows=3D2751 +width=3D8) (actual time=3D0.03..6.25 rows=3D2751 loops=3D2866) +Total runtime: 40939.52 msec + +EXPLAIN + +Note: +- We need the left join because we need all contacts even if they are +not assigned to a company +- We are not able to change the datatypes of the joined fields +because we use a standard software (btw who cares: SuSE Open Exchange +Server) +- When we use a normal join (without LEFT or a where clause) the SQL +runs immediately using the indexes + +How can I force the usage of the indexes when using "left join". Or +any other SQL construct that does the same !? Can anybody please give +us a hint !? + +Thanks in forward. + +Greetings +Achim + +---------------------------(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 Aug 2 09:21:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 63C5CD1B229 + for ; + Mon, 2 Aug 2004 09:21:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85207-05 + for ; + Mon, 2 Aug 2004 12:21:35 +0000 (GMT) +Received: from obelix.askesis.nl (laudanum.demon.nl [82.161.125.16]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DB2AD1B183 + for ; + Mon, 2 Aug 2004 09:21:29 -0300 (ADT) +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: What kind of performace can I expect and how to measure? +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +content-class: urn:content-classes:message +Date: Mon, 2 Aug 2004 14:21:31 +0200 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: What kind of performace can I expect and how to measure? +Thread-Index: AcR4iz4OjHxaXZb5TuimN1+EbYe3iQ== +From: "Joost Kraaijeveld" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/5 +X-Sequence-Number: 7641 + +Hi all, + +My system is a PostgreSQL 7.4.1 on i686-pc-linux-gnu, compiled by GCC gcc (= +GCC) 20020903 (Red Hat Linux 8.0 3.2-7). It has a Pentium III-733 Mhz with = +512 MB ram. It is connected to my workststation (dual XEON 1700 with 1 Gb R= +AM) with a 100 Mb switched network. + +I have a table with 31 columns, all fixed size datatypes. It contains 88393= + rows. Doing a "select * from table" with PGAdmin III in it's SQL window, i= +t takes a total of 9206 ms query runtime an a 40638 ms data retrievel runti= +me. + +Is this a reasonable time to get 88393 rows from the database? + +If not, what can I do to find the bottleneck (and eventually make it faster= +)? + +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 Aug 2 09:34:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EC8FD1B241 + for ; + Mon, 2 Aug 2004 09:34:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89595-05 + for ; + Mon, 2 Aug 2004 12:34:33 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id B8F3AD1B243 + for ; + Mon, 2 Aug 2004 09:34:28 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: What kind of performace can I expect and how to measure? +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Mon, 2 Aug 2004 08:33:34 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AF15@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] What kind of performace can I expect and how to + measure? +thread-index: AcR4iz4OjHxaXZb5TuimN1+EbYe3iQAAOFjQ +From: "Merlin Moncure" +To: "Joost Kraaijeveld" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/6 +X-Sequence-Number: 7642 + +Joost wrote: +> My system is a PostgreSQL 7.4.1 on i686-pc-linux-gnu, compiled by GCC +gcc +> (GCC) 20020903 (Red Hat Linux 8.0 3.2-7). It has a Pentium III-733 Mhz +> with 512 MB ram. It is connected to my workststation (dual XEON 1700 +with +> 1 Gb RAM) with a 100 Mb switched network. +>=20 +> I have a table with 31 columns, all fixed size datatypes. It contains +> 88393 rows. Doing a "select * from table" with PGAdmin III in it's SQL +> window, it takes a total of 9206 ms query runtime an a 40638 ms data +> retrievel runtime. +>=20 +> Is this a reasonable time to get 88393 rows from the database? +>=20 +> If not, what can I do to find the bottleneck (and eventually make it +> faster)? + +The 9206 ms time is what the database actually spent gathering the data +and sending it to you. This is non-negotiable unless you bump up +hardware, etc, or fetch less data. This time usually scales linearly +(or close to it) with the size of the dataset you fetch. + +The 40638 ms time is pgAdmin putting the data in the grid. This time +spent here is dependant on your client and starts to get really nasty +with large tables. Future versions of pgAdmin might be able to deal +better with large datasets (cursor based fetch is one proposed +solution). In the meantime, I would suggest using queries to refine +your terms a little bit...(do you really need to view all 80k records at +once?). + +Merlin + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 09:40:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 00F2DD1B171 + for ; + Mon, 2 Aug 2004 09:38:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94813-02 + for ; + Mon, 2 Aug 2004 12:38:45 +0000 (GMT) +Received: from tino.sinectis.com.ar (tino.sinectis.com.ar [216.244.192.232]) + by svr1.postgresql.org (Postfix) with ESMTP id B35EFD1B184 + for ; + Mon, 2 Aug 2004 09:38:40 -0300 (ADT) +Received: by tino.sinectis.com.ar (Postfix, from userid 99) + id A10196C8BB; Mon, 2 Aug 2004 09:38:42 -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: tim.leeuwvander@nl.unisys.com, mailing@impactmedia.de, + pgsql-performance@postgresql.org +Subject: Re: No index usage with +Reply-To: gbarosio@uolsinectis.com.ar +Message-Id: <20040802123842.A10196C8BB@tino.sinectis.com.ar> +Date: Mon, 2 Aug 2004 09:38:42 -0300 (GMT+3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/7 +X-Sequence-Number: 7643 + + TIP 9: the planner will ignore your desire to choose an index scan if your + joining column's datatypes do not match + +Greetz, +Guido + +> Cannot you do a cast in your query? Does that help with using the indexes? +> +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of +> mailing@impactmedia.de +> Sent: maandag 2 augustus 2004 14:09 +> To: pgsql-performance@postgresql.org +> Subject: [PERFORM] No index usage with "left join" +> +> +> We have a "companies" and a "contacts" table with about 3000 records +> each. +> +> We run the following SQL-Command which runs about 2 MINUTES !: +> +> SELECT count(*) FROM contacts LEFT JOIN companies ON contacts.sid = +> companies.intfield01 +> +> contacts.sid (type text, b-tree index on it) +> companies.intfield01 (type bigint, b-tree index on it) +> +> comfire=> explain analyze SELECT count(*) FROM prg_contacts LEFT JOIN +> prg_addresses ON prg_contacts.sid=prg_addresses.intfield01; +> NOTICE: QUERY PLAN: +> +> Aggregate (cost=495261.02..495261.02 rows=1 width=15) (actual +> time=40939.38..40939.38 rows=1 loops=1) +> -> Nested Loop (cost=0.00..495253.81 rows=2885 width=15) (actual +> time=0.05..40930.14 rows=2866 loops=1) +> -> Seq Scan on prg_contacts (cost=0.00..80.66 rows=2866 +> width=7) (actual time=0.01..18.10 rows=2866 loops=1) +> -> Seq Scan on prg_addresses (cost=0.00..131.51 rows=2751 +> width=8) (actual time=0.03..6.25 rows=2751 loops=2866) +> Total runtime: 40939.52 msec +> +> EXPLAIN +> +> Note: +> - We need the left join because we need all contacts even if they are +> not assigned to a company +> - We are not able to change the datatypes of the joined fields +> because we use a standard software (btw who cares: SuSE Open Exchange +> Server) +> - When we use a normal join (without LEFT or a where clause) the SQL +> runs immediately using the indexes +> +> How can I force the usage of the indexes when using "left join". Or +> any other SQL construct that does the same !? Can anybody please give +> us a hint !? +> +> Thanks in forward. +> +> Greetings +> Achim +> +> ---------------------------(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 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 Aug 2 09:45:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 69B10D1B183 + for ; + Mon, 2 Aug 2004 09:45:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94705-08 + for ; + Mon, 2 Aug 2004 12:45:26 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A05AD1B170 + for ; + Mon, 2 Aug 2004 09:45:20 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id 7E50C76A3C; Mon, 2 Aug 2004 08:45:24 -0400 (EDT) +Subject: Re: No index usage with "left join" +From: Rod Taylor +To: mailing@impactmedia.de +Cc: Postgresql Performance +In-Reply-To: <20040802120851.B32852202B7@p15110922.pureserver.info> +References: <20040802120851.B32852202B7@p15110922.pureserver.info> +Content-Type: text/plain +Message-Id: <1091450721.36221.104.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 02 Aug 2004 08:45:22 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/8 +X-Sequence-Number: 7644 + +> SELECT count(*) FROM contacts LEFT JOIN companies ON contacts.sid = +> companies.intfield01 +> +> contacts.sid (type text, b-tree index on it) +> companies.intfield01 (type bigint, b-tree index on it) + +> How can I force the usage of the indexes when using "left join". Or +> any other SQL construct that does the same !? Can anybody please give +> us a hint !? + +You really don't need to use indexes since you're fetching all +information from both tables. + +Anyway, we can be fairly sure this isn't PostgreSQL 7.4 (which would +likely choose a far better plan -- hash join rather than nested loop) as +it won't join a bigint to a text field without a cast. + +Try this: + set enable_nestloop = false; + SELECT count(*) FROM contacts LEFT JOIN companies ON + cast(contacts.sid as bigint) = companies.intfield01; + set enable_nestloop = true; + + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 09:47:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 61177D1B252 + for ; + Mon, 2 Aug 2004 09:47:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98005-05 + for ; + Mon, 2 Aug 2004 12:47:42 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E77ED1B243 + for ; + Mon, 2 Aug 2004 09:47:35 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i72ClKL21226; + Mon, 2 Aug 2004 08:47:20 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200408021247.i72ClKL21226@candle.pha.pa.us> +Subject: Re: No index usage with +In-Reply-To: <20040802123842.A10196C8BB@tino.sinectis.com.ar> +To: gbarosio@uolsinectis.com.ar +Date: Mon, 2 Aug 2004 08:47:20 -0400 (EDT) +Cc: tim.leeuwvander@nl.unisys.com, mailing@impactmedia.de, + pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/10 +X-Sequence-Number: 7646 + +G u i d o B a r o s i o wrote: +> TIP 9: the planner will ignore your desire to choose an index scan if your +> joining column's datatypes do not match + +And this is fixed in 7.5/8.0. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Mon Aug 2 09:47:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A9556D1B229 + for ; + Mon, 2 Aug 2004 09:47:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98005-04 + for ; + Mon, 2 Aug 2004 12:47:30 +0000 (GMT) +Received: from obelix.askesis.nl (laudanum.demon.nl [82.161.125.16]) + by svr1.postgresql.org (Postfix) with ESMTP id C4871D1B209 + for ; + Mon, 2 Aug 2004 09:47:25 -0300 (ADT) +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: What kind of performace can I expect and how to measure? +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +content-class: urn:content-classes:message +Date: Mon, 2 Aug 2004 14:47:29 +0200 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] What kind of performace can I expect and how to + measure? +Thread-Index: AcR4iz4OjHxaXZb5TuimN1+EbYe3iQAAOFjQAAB4WbA= +From: "Joost Kraaijeveld" +To: "Merlin Moncure" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/9 +X-Sequence-Number: 7645 + +Hi Merlin, + +> The 9206 ms time is what the database actually spent=20 +> gathering the data and sending it to you. This is non-negotiable unless = +you bump up +> hardware, etc, or fetch less data. This time usually scales linearly +> (or close to it) with the size of the dataset you fetch. +> +> The 40638 ms time is pgAdmin putting the data in the grid. This time +So it take PostgreSQL 9206 ms to get the data AND send it to the client. It= + than takes PGAdmin 40638 ms to display the data? + +> solution). In the meantime, I would suggest using queries to refine +> your terms a little bit...(do you really need to view all 80k=20 +> records at once?). +The application is build in Clarion, a 4 GL environment. We do not have any= + influence over the query it generates and executes. + + +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 Aug 2 11:04:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 50744D1B1CD + for ; + Mon, 2 Aug 2004 11:04:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35607-05 + for ; + Mon, 2 Aug 2004 14:03: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 DE00DD1B184 + for ; + Mon, 2 Aug 2004 11:03:46 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i72E3mqW009717; + Mon, 2 Aug 2004 10:03:48 -0400 (EDT) +To: Rod Taylor +Cc: mailing@impactmedia.de, + Postgresql Performance +Subject: Re: No index usage with "left join" +In-reply-to: <1091450721.36221.104.camel@jester> +References: <20040802120851.B32852202B7@p15110922.pureserver.info> + <1091450721.36221.104.camel@jester> +Comments: In-reply-to Rod Taylor + message dated "Mon, 02 Aug 2004 08:45:22 -0400" +Date: Mon, 02 Aug 2004 10:03:47 -0400 +Message-ID: <9716.1091455427@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/11 +X-Sequence-Number: 7647 + +Rod Taylor writes: +>> How can I force the usage of the indexes when using "left join". + +> Anyway, we can be fairly sure this isn't PostgreSQL 7.4 (which would +> likely choose a far better plan -- hash join rather than nested loop) + +Indeed, the lack of any join-condition line in the EXPLAIN output +implies it's 7.2 or older. IIRC 7.4 is the first release that is +capable of using merge or hash join with a condition more complicated +than plain "Var = Var". In this case, since the two fields are of +different datatypes, the planner sees something like "Var = Var::text" +(ie, there's an inserted cast function). 7.2 will just say "duh, too +complicated for me" and generate a nestloop. With the columns being +of different datatypes, you don't even have a chance for an inner +indexscan in the nestloop. + +In short: change the column datatypes to be the same, or update to +7.4.something. There are no other solutions. + +(Well, if you were really desperate you could create a set of +mergejoinable "text op bigint" comparison operators, and then 7.2 +would be able to cope; but I should think that updating to 7.4 would +be much less work.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 2 11:16:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D7E6D1B18C + for ; + Mon, 2 Aug 2004 11:16:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39303-10 + for ; + Mon, 2 Aug 2004 14:16:04 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 86825D1B183 + for ; + Mon, 2 Aug 2004 11:15:58 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: What kind of performace can I expect and how to measure? +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Mon, 2 Aug 2004 10:14:33 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AF16@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] What kind of performace can I expect and how to + measure? +thread-index: AcR4iz4OjHxaXZb5TuimN1+EbYe3iQAAOFjQAAB4WbAAAvTZAA== +From: "Merlin Moncure" +To: "Joost Kraaijeveld" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/12 +X-Sequence-Number: 7648 + +> Hi Merlin, +>=20 +> > The 9206 ms time is what the database actually spent +> > gathering the data and sending it to you. This is non-negotiable +unless +> you bump up +> > hardware, etc, or fetch less data. This time usually scales +linearly +> > (or close to it) with the size of the dataset you fetch. +> > +> > The 40638 ms time is pgAdmin putting the data in the grid. This +time +> So it take PostgreSQL 9206 ms to get the data AND send it to the +client. +> It than takes PGAdmin 40638 ms to display the data? + +That is correct. This is not a problem with pgAdmin, or postgres, but a +problem with grids. Conceptually, SQL tables are an in an unordered, +infinite space and grids require an ordered, finite space. All 4GLs and +data managers have this problem. The real solution is to refine your +query in a meaningful way (80k rows is more than a human being can deal +with in a practical sense). If you can't do that, install an arbitrary +limit on the result set where performance breaks down, could be 10-100k +depending on various factors. + +To simulate a finite, ordered, dataset, pgAdmin takes all the result +data and puts it in GUI controls are not designed to hold 100k rows +data...this is a design compromise to allow editing. + +Merlin + + + + + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 12:01:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 58A8FD1B19A + for ; + Mon, 2 Aug 2004 12:01:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62647-05 + for ; + Mon, 2 Aug 2004 15:01:10 +0000 (GMT) +Received: from corpmsx.gaiam.com (unknown [12.147.81.200]) + by svr1.postgresql.org (Postfix) with ESMTP id 2F4EED1B181 + for ; + Mon, 2 Aug 2004 12:01:08 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.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: SSD Drives +Date: Mon, 2 Aug 2004 09:02:56 -0600 +Message-ID: <8D36D5916571CB4489C2E4D0CAD6E89304864DF2@corpmsx.gaiam.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] SSD Drives +Thread-Index: AcR3vfG/mln9LuUyT1mk7cOwjZ8gnQA4kwmQ +From: +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200408/13 +X-Sequence-Number: 7649 + +Thanks I found the same info on the tigi and like what I saw. I also +spoke with a consulting firm that has used them and also says good +things, but they have not tried it with postgres. I will post an +analysis of performance once we have the equipment ordered and +installed.=20 + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Greg Stark +Sent: Sunday, August 01, 2004 5:43 AM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] SSD Drives + + +To the person who was looking for a $5k midlevel SSD drive (sorry, I hit +'d' +too fast): + + http://www.tigicorp.com/tigijet_exp_s.htm + +I found this via this interesting survey of SSD products: + + http://www.storagesearch.com/ssd-buyers-guide.html + +Incidentally it seems the popular Platypus SSD PCI cards are no more, +Platypus +appears to have gone out of business. + +--=20 +greg + + +---------------------------(end of broadcast)--------------------------- +TIP 8: explain analyze is your friend + +From pgsql-performance-owner@postgresql.org Mon Aug 2 13:07:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7160AD1B1CD + for ; + Mon, 2 Aug 2004 13:07:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89067-07 + for ; + Mon, 2 Aug 2004 16:07:31 +0000 (GMT) +Received: from mpls-qmqp-03.inet.qwest.net (mpls-qmqp-03.inet.qwest.net + [63.231.195.114]) + by svr1.postgresql.org (Postfix) with SMTP id 44C0ED1B248 + for ; + Mon, 2 Aug 2004 13:07:29 -0300 (ADT) +Received: (qmail 83820 invoked by uid 0); 2 Aug 2004 15:36:06 -0000 +Received: from mpls-pop-03.inet.qwest.net (63.231.195.3) + by mpls-qmqp-03.inet.qwest.net with QMQP; 2 Aug 2004 15:36:06 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-03.inet.qwest.net with SMTP; 2 Aug 2004 16:07:28 -0000 +Date: Mon, 02 Aug 2004 10:08:49 -0600 +Message-Id: <1091462929.27166.29.camel@localhost.localdomain> +From: "Scott Marlowe" +To: mailing@impactmedia.de +Cc: pgsql-performance@postgresql.org +Subject: Re: No index usage with "left join" +In-Reply-To: <20040802120851.B32852202B7@p15110922.pureserver.info> +References: <20040802120851.B32852202B7@p15110922.pureserver.info> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/14 +X-Sequence-Number: 7650 + +On Mon, 2004-08-02 at 06:08, mailing@impactmedia.de wrote: +> We have a "companies" and a "contacts" table with about 3000 records +> each. +> +> We run the following SQL-Command which runs about 2 MINUTES !: +> +> SELECT count(*) FROM contacts LEFT JOIN companies ON contacts.sid = +> companies.intfield01 +> +> contacts.sid (type text, b-tree index on it) +> companies.intfield01 (type bigint, b-tree index on it) +> +> comfire=> explain analyze SELECT count(*) FROM prg_contacts LEFT JOIN +> prg_addresses ON prg_contacts.sid=prg_addresses.intfield01; +> NOTICE: QUERY PLAN: +> +> Aggregate (cost=495261.02..495261.02 rows=1 width=15) (actual +> time=40939.38..40939.38 rows=1 loops=1) +> -> Nested Loop (cost=0.00..495253.81 rows=2885 width=15) (actual +> time=0.05..40930.14 rows=2866 loops=1) +> -> Seq Scan on prg_contacts (cost=0.00..80.66 rows=2866 +> width=7) (actual time=0.01..18.10 rows=2866 loops=1) +> -> Seq Scan on prg_addresses (cost=0.00..131.51 rows=2751 +> width=8) (actual time=0.03..6.25 rows=2751 loops=2866) +> Total runtime: 40939.52 msec +> +> EXPLAIN +> +> Note: +> - We need the left join because we need all contacts even if they are +> not assigned to a company +> - We are not able to change the datatypes of the joined fields +> because we use a standard software (btw who cares: SuSE Open Exchange +> Server) +> - When we use a normal join (without LEFT or a where clause) the SQL +> runs immediately using the indexes +> +> How can I force the usage of the indexes when using "left join". Or +> any other SQL construct that does the same !? Can anybody please give +> us a hint !? + +Why in the world would the database use the index in this case? You're +retrieving every single row, so it may as well hit the data store +directly. By the way, unlike many other databases that can just hit the +index, PostgreSQL always has to go back to the data store anyway to get +the real value, so if it's gonna hit more than some small percentage of +rows, it's usually a win to just seq scan it. Try restricting your +query with a where clause to one or two rows and see what you get. + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 13:10:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 84296D1B19A + for ; + Mon, 2 Aug 2004 13:10:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90792-05 + for ; + Mon, 2 Aug 2004 16:10:28 +0000 (GMT) +Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net + [63.231.195.112]) + by svr1.postgresql.org (Postfix) with SMTP id 55D86D1B18A + for ; + Mon, 2 Aug 2004 13:10:26 -0300 (ADT) +Received: (qmail 5671 invoked by uid 0); 2 Aug 2004 16:10:26 -0000 +Received: from unknown (63.231.195.5) + by mpls-qmqp-01.inet.qwest.net with QMQP; 2 Aug 2004 16:10:26 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-05.inet.qwest.net with SMTP; 2 Aug 2004 16:10:25 -0000 +Date: Mon, 02 Aug 2004 10:11:46 -0600 +Message-Id: <1091463106.27166.33.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Joost Kraaijeveld" +Cc: pgsql-performance@postgresql.org +Subject: Re: What kind of performace can I expect and how to +In-Reply-To: +References: +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/15 +X-Sequence-Number: 7651 + +On Mon, 2004-08-02 at 06:21, Joost Kraaijeveld wrote: +> Hi all, +> +> My system is a PostgreSQL 7.4.1 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 20020903 (Red Hat Linux 8.0 3.2-7). It has a Pentium III-733 Mhz with 512 MB ram. It is connected to my workststation (dual XEON 1700 with 1 Gb RAM) with a 100 Mb switched network. +> +> I have a table with 31 columns, all fixed size datatypes. It contains 88393 rows. Doing a "select * from table" with PGAdmin III in it's SQL window, it takes a total of 9206 ms query runtime an a 40638 ms data retrievel runtime. + +This means it took the backend about 9 seconds to prepare the data, and +40 or so seconds total (including the 9 I believe) for the client to +retrieve and then display it. + +> Is this a reasonable time to get 88393 rows from the database? + +Depends on your row size really. I'm certain you're not CPU bound if +you've only got one hard drive. Put that data on a 20 way RAID5 array +and I'm sure it would come back a little quicker. + +> If not, what can I do to find the bottleneck (and eventually make it faster)? + +The bottleneck is almost always IO to start with. First, as another +drive and mirror it. Then go to RAID 1+0, then add more and more +drives. + +Read this document about performance tuning: + +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + + + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 13:19:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EA099D1B1F8 + for ; + Mon, 2 Aug 2004 13:18:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95406-07 + for ; + Mon, 2 Aug 2004 16:18:08 +0000 (GMT) +Received: from mpls-qmqp-03.inet.qwest.net (mpls-qmqp-03.inet.qwest.net + [63.231.195.114]) + by svr1.postgresql.org (Postfix) with SMTP id DFC33D1B1E3 + for ; + Mon, 2 Aug 2004 13:18:07 -0300 (ADT) +Received: (qmail 3946 invoked by uid 0); 2 Aug 2004 15:46:44 -0000 +Received: from mpls-pop-07.inet.qwest.net (63.231.195.7) + by mpls-qmqp-03.inet.qwest.net with QMQP; 2 Aug 2004 15:46:44 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-07.inet.qwest.net with SMTP; 2 Aug 2004 16:18:07 -0000 +Date: Mon, 02 Aug 2004 10:19:27 -0600 +Message-Id: <1091463567.27166.44.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Ioannis Theoharis" +Cc: pgsql-performance@postgresql.org +Subject: Re: Page Miss Hits +In-Reply-To: +References: +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/16 +X-Sequence-Number: 7652 + +On Mon, 2004-08-02 at 02:11, Ioannis Theoharis wrote: +> Hi, i would like to answer if there is any way in postgres to find the +> page miss hits caused during a query execution. +> +> +> Is there something like explain analyze with the page miss hits??? + +You're making a basic assumption that is (at least currently) untrue, +and that is that PostgreSQL has it's own cache. It doesn't. It has a +buffer that drops buffer back into the free pool when the last +referencing backend concludes and shuts down. So, PostgreSQL currently +relies on the kernel to cache for it. So, what you need is a tool that +monitors the kernel cache usage and its hit rate. I'm not familiar with +any, but I'm sure something out there likely does that. + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 13:48:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2ED88D1B241 + for ; + Mon, 2 Aug 2004 13:48:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11691-01 + for ; + Mon, 2 Aug 2004 16:48:13 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id F2641D1B1FD + for ; + Mon, 2 Aug 2004 13:48:12 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i72GmBqh020684 + for ; Mon, 2 Aug 2004 16:48:12 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i72Gi78S020051 + for pgsql-performance@postgresql.org; Mon, 2 Aug 2004 16:44:07 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Page Miss Hits +Date: Mon, 02 Aug 2004 18:43:32 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 21 +Message-ID: <410E6F34.6040300@bigfoot.com> +References: + <1091463567.27166.44.camel@localhost.localdomain> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Scott Marlowe +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: <1091463567.27166.44.camel@localhost.localdomain> +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/17 +X-Sequence-Number: 7653 + +Scott Marlowe wrote: +> On Mon, 2004-08-02 at 02:11, Ioannis Theoharis wrote: +> +>>Hi, i would like to answer if there is any way in postgres to find the +>>page miss hits caused during a query execution. +>> +>> +>>Is there something like explain analyze with the page miss hits??? +> +> +> You're making a basic assumption that is (at least currently) untrue, +> and that is that PostgreSQL has it's own cache. + +Are you sure of this ? What is the meaning of the ARC recently introduced +then ? + + + +Regards +Gaetano Mendola + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 17:54:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F1AC6D1B181 + for ; + Mon, 2 Aug 2004 17:50:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12601-05 + for ; + Mon, 2 Aug 2004 20:50:56 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id AE1A0D1B171 + for ; + Mon, 2 Aug 2004 17:50:52 -0300 (ADT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i72KoXd25533; + Mon, 2 Aug 2004 22:50:34 +0200 +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 i72KoqZ19759; + Mon, 2 Aug 2004 22:50:52 +0200 +Message-ID: <410EA90C.7030707@bigfoot.com> +Date: Mon, 02 Aug 2004 22:50:20 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Scott Marlowe +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Page Miss Hits +References: + <1091463567.27166.44.camel@localhost.localdomain> + <410E6F34.6040300@bigfoot.com> + <1091468476.27166.48.camel@localhost.localdomain> +In-Reply-To: <1091468476.27166.48.camel@localhost.localdomain> +X-Enigmail-Version: 0.84.2.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/18 +X-Sequence-Number: 7654 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Scott Marlowe wrote: +| On Mon, 2004-08-02 at 10:43, Gaetano Mendola wrote: +| +|>Scott Marlowe wrote: +|> +|>>On Mon, 2004-08-02 at 02:11, Ioannis Theoharis wrote: +|>> +|>> +|>>>Hi, i would like to answer if there is any way in postgres to find the +|>>>page miss hits caused during a query execution. +|>>> +|>>> +|>>>Is there something like explain analyze with the page miss hits??? +|>> +|>> +|>>You're making a basic assumption that is (at least currently) untrue, +|>>and that is that PostgreSQL has it's own cache. +|> +|>Are you sure of this ? What is the meaning of the ARC recently introduced +|>then ? +| +| +| Yes I am. Test it yourself, setup a couple of backends, select * from +| some big tables, then, one at a time, shut down the psql clients and +| when the last one closes, the shared mem goes away. Run another client, +| do select * from the big table, and watch the client size grow from a +| few meg to a size large enough to hold the whole table (or however much +| your shared_buffers will hold.) +| +| While someone may make ARC and the shared buffers act like a cache some +| day (can't be that hard, most of the work is done really) right now it's +| not how it works. +| +| ARC still helps, since it makes sure the shared_buffers don't all get +| flushed from the useful small datasets when a seq scan gets executed. + +I'm still not convinced. Why the last backend alive, have to throw away +bunch of memory copied in the SHM? And again, the ARC is a replacement +policy for a cache, which one ? + + +Regards +Gaetano Mendola + + + + + + + + + + + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBDqkL7UpzwH2SGd4RAsQFAKCWVpCXKgRfE1nc44ZmtEaIrtNaIQCgr4fd +Hx2NiuRzV0UQ3Na9g/zQbzE= +=XWua +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 18:18:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 21D76D1B17B + for ; + Mon, 2 Aug 2004 18:18:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21601-09 + for ; + Mon, 2 Aug 2004 21:18:43 +0000 (GMT) +Received: from asdc003.abovesecurite.lan (unknown [206.162.148.235]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E77BD1B19A + for ; + Mon, 2 Aug 2004 18:18:37 -0300 (ADT) +Received: from develavoie ([206.162.148.230]) by asdc003.abovesecurite.lan + over TLS secured channel with Microsoft SMTPSVC(6.0.3790.0); + Mon, 2 Aug 2004 17:23:45 -0400 +From: "Stephane Tessier" +To: "'Scott Marlowe'" +Cc: , +Subject: Re: my boss want to migrate to ORACLE +Date: Mon, 2 Aug 2004 17:18:38 -0400 +Message-ID: <004b01c478d6$47f46530$4e00020a@develavoie> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook CWS, Build 9.0.6604 (9.0.2911.0) +In-Reply-To: <1091200491.27159.56.camel@localhost.localdomain> +Importance: Normal +x-mimeole: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-OriginalArrivalTime: 02 Aug 2004 21:23:45.0156 (UTC) + FILETIME=[FDEA9440:01C478D6] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/19 +X-Sequence-Number: 7655 + +I checked and we have a 128 megs battery backed cache on the raid +controller... + +-----Original Message----- +From: Scott Marlowe [mailto:smarlowe@qwest.net] +Sent: 30 juillet, 2004 11:15 +To: Stephane Tessier +Cc: markir@coretech.co.nz; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] my boss want to migrate to ORACLE + + +On Fri, 2004-07-30 at 07:56, Stephane Tessier wrote: +> I think with your help guys I'll do it! +> +> I'm working on it! +> +> I'll work on theses issues: +> +> we have space for more ram(we use 2 gigs on possibility of 3 gigs) +> iowait is very high 98% --> look like postgresql wait for io access +> raid5 -->raid0 if i'm right raid5 use 4 writes(parity,data, etc) for each +> write on disk + +Just get battery backed cache on your RAID controller. RAID0 is way too +unreliable for a production environment. One disk dies and all your +data is just gone. + +> use more transactions (we have a lot of insert/update without +transaction). +> cpu look like not running very hard +> +> *php is not running on the same machine +> *redhat enterprise 3.0 ES +> *the version of postgresql is 7.3.4(using RHDB from redhat) +> *pg_autovacuum running at 12 and 24 hour each day +> +> +> +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of +> markir@coretech.co.nz +> Sent: 29 juillet, 2004 23:00 +> To: Stephane Tessier +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] my boss want to migrate to ORACLE +> +> +> A furthur thought or two: +> +> - you are *sure* that it is Postgres that is slow? (could be Php...or your +> machine could be out of some resource - see next 2 points) +> - is your machine running out of cpu or memory? +> - is your machine seeing huge io transfers or long io waits? +> - are you running Php on this machine as well as Postgres? +> - what os (and what release) are you running? (guessing Linux but...) +> +> As an aside, they always say this but: Postgres 7.4 generally performs +> better +> than 7.3...so an upgrade could be worth it - *after* you have +> solved/identified +> the other issues. +> +> best wishes +> +> Mark +> +> Quoting Stephane Tessier : +> +> > Hi everyone, +> > +> > somebody can help me??????? my boss want to migrate to +> > ORACLE................ +> > +> > we have a BIG problem of performance,it's slow.... +> > we use postgres 7.3 for php security application with approximately 4 +> > millions of insertion by day and 4 millions of delete and update +> > and archive db with 40 millions of archived stuff... +> > +> > we have 10 databases for our clients and a centralized database for the +> > general stuff. +> > +> > database specs: +> > +> > double XEON 2.4 on DELL PowerEdge2650 +> > 2 gigs of RAM +> > 5 SCSI Drive RAID 5 15rpm +> > +> > tasks: +> > +> > 4 millions of transactions by day +> > 160 open connection 24 hours by day 7 days by week +> > pg_autovacuum running 24/7 +> > reindex on midnight +> +> +> +> ---------------------------(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 broadcast)--------------------------- +> TIP 8: explain analyze is your friend +> + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 18:26:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DCE92D1B171 + for ; + Mon, 2 Aug 2004 18:26:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25503-10 + for ; + Mon, 2 Aug 2004 21:26:24 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1AAE0D1B181 + for ; + Mon, 2 Aug 2004 18:26:20 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id 9E94876A22; Mon, 2 Aug 2004 17:26:21 -0400 (EDT) +Subject: Re: Page Miss Hits +From: Rod Taylor +To: Gaetano Mendola +Cc: Scott Marlowe , + "pgsql-performance@postgresql.org" +In-Reply-To: <410EA90C.7030707@bigfoot.com> +References: + <1091463567.27166.44.camel@localhost.localdomain> + <410E6F34.6040300@bigfoot.com> + <1091468476.27166.48.camel@localhost.localdomain> + <410EA90C.7030707@bigfoot.com> +Content-Type: text/plain +Message-Id: <1091481975.36221.138.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 02 Aug 2004 17:26:16 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/20 +X-Sequence-Number: 7656 + +> | ARC still helps, since it makes sure the shared_buffers don't all get +> | flushed from the useful small datasets when a seq scan gets executed. +> +> I'm still not convinced. Why the last backend alive, have to throw away +> bunch of memory copied in the SHM? And again, the ARC is a replacement +> policy for a cache, which one ? + +As you know, ARC is a recent addition. I've not seen any benchmarks +demonstrating that the optimal SHARED_BUFFERS setting is different today +than it was in the past. + +We know it's changed, but the old buffer strategy had an equally hard +time with a small buffer as it did a large one. Does that mean the +middle of the curve is still at 15k buffers but the extremes are handled +better? Or something completely different? + +Please feel free to benchmark 7.5 (OSDL folks should be able to help us +as well) and report back. + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 18:31:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 46554D1B184 + for ; + Mon, 2 Aug 2004 18:30:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31678-04 + for ; + Mon, 2 Aug 2004 21:30:55 +0000 (GMT) +Received: from asdc003.abovesecurite.lan (unknown [206.162.148.235]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E288D1B18C + for ; + Mon, 2 Aug 2004 18:30:51 -0300 (ADT) +Received: from develavoie ([206.162.148.230]) by asdc003.abovesecurite.lan + over TLS secured channel with Microsoft SMTPSVC(6.0.3790.0); + Mon, 2 Aug 2004 17:35:59 -0400 +From: "Stephane Tessier" +To: "'James Thornton'" +Cc: "'Scott Marlowe'" , , + +Subject: Re: my boss want to migrate to ORACLE +Date: Mon, 2 Aug 2004 17:30:52 -0400 +Message-ID: <004c01c478d7$fd8944f0$4e00020a@develavoie> +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.6604 (9.0.2911.0) +In-Reply-To: <410EB2E3.6040609@jamesthornton.com> +Importance: Normal +x-mimeole: Produced By Microsoft MimeOLE V6.00.2800.1409 +X-OriginalArrivalTime: 02 Aug 2004 21:35:59.0265 (UTC) + FILETIME=[B37AB910:01C478D8] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/22 +X-Sequence-Number: 7658 + +oups, + +i changed for RAID 10(strip and mirror).... + +-----Original Message----- +From: James Thornton [mailto:james@jamesthornton.com] +Sent: 2 aout, 2004 17:32 +To: Stephane Tessier +Cc: 'Scott Marlowe'; markir@coretech.co.nz; +pgsql-performance@postgresql.org +Subject: Re: [PERFORM] my boss want to migrate to ORACLE + + +Stephane Tessier wrote: + +> I checked and we have a 128 megs battery backed cache on the raid +> controller... + +>>we have space for more ram(we use 2 gigs on possibility of 3 gigs) +>>iowait is very high 98% --> look like postgresql wait for io access +>>raid5 -->raid0 if i'm right raid5 use 4 writes(parity,data, etc) for each +>>write on disk +> +> Just get battery backed cache on your RAID controller. RAID0 is way too +> unreliable for a production environment. One disk dies and all your +> data is just gone. + +I'm the one who sent the e-mail about RAID 5's 4 writes, but I suggested +you look at RAID 10, not RAID 0. + +-- + + James Thornton +______________________________________________________ +Internet Business Consultant, http://jamesthornton.com + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 18:28:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C083DD1B171 + for ; + Mon, 2 Aug 2004 18:27:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30869-03 + for ; + Mon, 2 Aug 2004 21:27:54 +0000 (GMT) +Received: from roam.unifiedmind.com (unifiedmind.com [209.164.72.58]) + by svr1.postgresql.org (Postfix) with SMTP id 04CEBD1B1EC + for ; + Mon, 2 Aug 2004 18:27:50 -0300 (ADT) +Received: (qmail 12194 invoked from network); 2 Aug 2004 21:57:29 -0000 +Received: from unknown (HELO jamesthornton.com) (james@24.175.14.24) + by 0 with SMTP; 2 Aug 2004 21:57:29 -0000 +Message-ID: <410EB2E3.6040609@jamesthornton.com> +Date: Mon, 02 Aug 2004 16:32:19 -0500 +From: James Thornton +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.4) Gecko/20030624 Netscape/7.1 (ax) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Stephane Tessier +Cc: 'Scott Marlowe' , markir@coretech.co.nz, + pgsql-performance@postgresql.org +Subject: Re: my boss want to migrate to ORACLE +References: <004b01c478d6$47f46530$4e00020a@develavoie> +In-Reply-To: <004b01c478d6$47f46530$4e00020a@develavoie> +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.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/21 +X-Sequence-Number: 7657 + +Stephane Tessier wrote: + +> I checked and we have a 128 megs battery backed cache on the raid +> controller... + +>>we have space for more ram(we use 2 gigs on possibility of 3 gigs) +>>iowait is very high 98% --> look like postgresql wait for io access +>>raid5 -->raid0 if i'm right raid5 use 4 writes(parity,data, etc) for each +>>write on disk +> +> Just get battery backed cache on your RAID controller. RAID0 is way too +> unreliable for a production environment. One disk dies and all your +> data is just gone. + +I'm the one who sent the e-mail about RAID 5's 4 writes, but I suggested +you look at RAID 10, not RAID 0. + +-- + + James Thornton +______________________________________________________ +Internet Business Consultant, http://jamesthornton.com + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 19:18:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C210D1B21B + for ; + Mon, 2 Aug 2004 19:18:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47969-08 + for ; + Mon, 2 Aug 2004 22:18:15 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id EFD96D1B16E + for ; + Mon, 2 Aug 2004 19:18:12 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i72MICqb070761 + for ; Mon, 2 Aug 2004 22:18:12 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i72MEM1w070288 + for pgsql-performance@postgresql.org; Mon, 2 Aug 2004 22:14:22 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Page Miss Hits +Date: Tue, 03 Aug 2004 00:13:56 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 54 +Message-ID: <410EBCA4.9000508@bigfoot.com> +References: + <1091463567.27166.44.camel@localhost.localdomain> + <410E6F34.6040300@bigfoot.com> + <1091468476.27166.48.camel@localhost.localdomain> + <410EA90C.7030707@bigfoot.com> <1091481975.36221.138.camel@jester> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Rod Taylor +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: <1091481975.36221.138.camel@jester> +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/23 +X-Sequence-Number: 7659 + +Rod Taylor wrote: +>>| ARC still helps, since it makes sure the shared_buffers don't all get +>>| flushed from the useful small datasets when a seq scan gets executed. +>> +>>I'm still not convinced. Why the last backend alive, have to throw away +>>bunch of memory copied in the SHM? And again, the ARC is a replacement +>>policy for a cache, which one ? +> +> +> As you know, ARC is a recent addition. I've not seen any benchmarks +> demonstrating that the optimal SHARED_BUFFERS setting is different today +> than it was in the past. +> +> We know it's changed, but the old buffer strategy had an equally hard +> time with a small buffer as it did a large one. Does that mean the +> middle of the curve is still at 15k buffers but the extremes are handled +> better? Or something completely different? +> +> Please feel free to benchmark 7.5 (OSDL folks should be able to help us +> as well) and report back. + +I know, I know. + +We were discussing about the fact that postgres use a his own cache or not; +and for the OP pleasure then if is possible retrieve hit and miss information +from that cache. + +For benchmarch may be is better that you look not at the particular implementation +done in postgresql but at the general improvements that the ARC replacement +policy introduce. If I'm not wrong till now postgres was using an LRU, +around you can find some articles like these: + +http://www.almaden.ibm.com/StorageSystems/autonomic_storage/ARC/rj10284.pdf +http://www.almaden.ibm.com/cs/people/dmodha/arcfast.pdf + +where are showns the improvements. + +As you wrote no one did benchmarks on demostrating with the "brute force" that +ARC is better but on the paper should be. + + +Regards +Gaetano Mendola + + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 19:47:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 71C99D1B181 + for ; + Mon, 2 Aug 2004 19:47:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60036-02 + for ; + Mon, 2 Aug 2004 22:47:20 +0000 (GMT) +Received: from mail.coretech.co.nz (coretech.co.nz [202.36.204.41]) + by svr1.postgresql.org (Postfix) with ESMTP id 155E5D1B17B + for ; + Mon, 2 Aug 2004 19:47:16 -0300 (ADT) +Received: (qmail 30963 invoked from network); 2 Aug 2004 22:47:18 -0000 +Received: from localhost (127.0.0.1) by 0 with SMTP; 2 Aug 2004 22:47:18 -0000 +Received: from 203.167.203.141 ([203.167.203.141]) by mail.coretech.co.nz + (Horde) with HTTP for ; Tue, 3 Aug 2004 10:47:18 + +1200 +Message-ID: <1091486838.923c2b71c3ae6@mail.coretech.co.nz> +Date: Tue, 3 Aug 2004 10:47:18 +1200 +From: markir@coretech.co.nz +To: Stephane Tessier +Cc: 'Scott Marlowe' , + pgsql-performance@postgresql.org +Subject: Re: my boss want to migrate to ORACLE +References: <004b01c478d6$47f46530$4e00020a@develavoie> +In-Reply-To: <004b01c478d6$47f46530$4e00020a@develavoie> +MIME-Version: 1.0 +Content-Type: text/plain; charset="ISO-8859-1" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +User-Agent: Internet Messaging Program (IMP) 4.0-cvs +X-Originating-IP: Withheld +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200408/24 +X-Sequence-Number: 7660 + +It may be worth pricing up expansion options e.g. 256M or more. +The other path to consider is changing RAID5 -> RAID10 if your card supports it. + +However, I would recommend reducing that shared_buffers setting and doing your +performance measurements *again* - before changing anything else. This is +because you want to ensure that all your io hammering is not just because you +are making the machine swap (by giving postgres too much memory as Scott +mentioned)! + +Quoting Stephane Tessier : + +> I checked and we have a 128 megs battery backed cache on the raid +> controller... + + + +From pgsql-performance-owner@postgresql.org Mon Aug 2 21:16:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EF9FBD1B184 + for ; + Mon, 2 Aug 2004 21:16:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84194-06 + for ; + Tue, 3 Aug 2004 00:16:02 +0000 (GMT) +Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net + [63.231.195.112]) + by svr1.postgresql.org (Postfix) with SMTP id 5AEF1D1B16E + for ; + Mon, 2 Aug 2004 21:15:58 -0300 (ADT) +Received: (qmail 27656 invoked by uid 0); 3 Aug 2004 00:16:01 -0000 +Received: from unknown (63.231.195.5) + by mpls-qmqp-01.inet.qwest.net with QMQP; 3 Aug 2004 00:16:01 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-05.inet.qwest.net with SMTP; 3 Aug 2004 00:16:01 -0000 +Date: Mon, 02 Aug 2004 18:17:16 -0600 +Message-Id: <1091492236.27166.55.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Stephane Tessier" +Cc: markir@coretech.co.nz, pgsql-performance@postgresql.org +Subject: Re: my boss want to migrate to ORACLE +In-Reply-To: <004b01c478d6$47f46530$4e00020a@develavoie> +References: <004b01c478d6$47f46530$4e00020a@develavoie> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/25 +X-Sequence-Number: 7661 + +Is it set to write back or write through? Also, you may want to look at +lowering the stripe size. The default on many RAID controllers is 128k, +but for PostgreSQL 8k to 32k seems a good choice. But that's not near +as important as the cache setting being write back. + +On Mon, 2004-08-02 at 15:18, Stephane Tessier wrote: +> I checked and we have a 128 megs battery backed cache on the raid +> controller... +> +> -----Original Message----- +> From: Scott Marlowe [mailto:smarlowe@qwest.net] +> Sent: 30 juillet, 2004 11:15 +> To: Stephane Tessier +> Cc: markir@coretech.co.nz; pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] my boss want to migrate to ORACLE +> +> +> On Fri, 2004-07-30 at 07:56, Stephane Tessier wrote: +> > I think with your help guys I'll do it! +> > +> > I'm working on it! +> > +> > I'll work on theses issues: +> > +> > we have space for more ram(we use 2 gigs on possibility of 3 gigs) +> > iowait is very high 98% --> look like postgresql wait for io access +> > raid5 -->raid0 if i'm right raid5 use 4 writes(parity,data, etc) for each +> > write on disk +> +> Just get battery backed cache on your RAID controller. RAID0 is way too +> unreliable for a production environment. One disk dies and all your +> data is just gone. +> +> > use more transactions (we have a lot of insert/update without +> transaction). +> > cpu look like not running very hard +> > +> > *php is not running on the same machine +> > *redhat enterprise 3.0 ES +> > *the version of postgresql is 7.3.4(using RHDB from redhat) +> > *pg_autovacuum running at 12 and 24 hour each day +> > +> > +> > +> > -----Original Message----- +> > From: pgsql-performance-owner@postgresql.org +> > [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of +> > markir@coretech.co.nz +> > Sent: 29 juillet, 2004 23:00 +> > To: Stephane Tessier +> > Cc: pgsql-performance@postgresql.org +> > Subject: Re: [PERFORM] my boss want to migrate to ORACLE +> > +> > +> > A furthur thought or two: +> > +> > - you are *sure* that it is Postgres that is slow? (could be Php...or your +> > machine could be out of some resource - see next 2 points) +> > - is your machine running out of cpu or memory? +> > - is your machine seeing huge io transfers or long io waits? +> > - are you running Php on this machine as well as Postgres? +> > - what os (and what release) are you running? (guessing Linux but...) +> > +> > As an aside, they always say this but: Postgres 7.4 generally performs +> > better +> > than 7.3...so an upgrade could be worth it - *after* you have +> > solved/identified +> > the other issues. +> > +> > best wishes +> > +> > Mark +> > +> > Quoting Stephane Tessier : +> > +> > > Hi everyone, +> > > +> > > somebody can help me??????? my boss want to migrate to +> > > ORACLE................ +> > > +> > > we have a BIG problem of performance,it's slow.... +> > > we use postgres 7.3 for php security application with approximately 4 +> > > millions of insertion by day and 4 millions of delete and update +> > > and archive db with 40 millions of archived stuff... +> > > +> > > we have 10 databases for our clients and a centralized database for the +> > > general stuff. +> > > +> > > database specs: +> > > +> > > double XEON 2.4 on DELL PowerEdge2650 +> > > 2 gigs of RAM +> > > 5 SCSI Drive RAID 5 15rpm +> > > +> > > tasks: +> > > +> > > 4 millions of transactions by day +> > > 160 open connection 24 hours by day 7 days by week +> > > pg_autovacuum running 24/7 +> > > reindex on midnight +> > +> > +> > +> > ---------------------------(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 broadcast)--------------------------- +> > TIP 8: explain analyze is your friend +> > +> +> + + +From pgsql-performance-owner@postgresql.org Tue Aug 3 05:40:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BCEE2D1B2BD + for ; + Tue, 3 Aug 2004 05:40:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65355-04 + for ; + Tue, 3 Aug 2004 08:40:51 +0000 (GMT) +Received: from mta2.rdslink.ro (mta2.rdslink.ro [193.231.236.124]) + by svr1.postgresql.org (Postfix) with ESMTP id 156B3D1B2D9 + for ; + Tue, 3 Aug 2004 05:40:48 -0300 (ADT) +Received: (qmail 22001 invoked from network); 3 Aug 2004 11:35:38 -0000 +Received: from unknown (HELO mail.rdslink.ro) (193.231.236.20) + by mta2.rdslink.ro with DES-CBC3-SHA encrypted SMTP; + 3 Aug 2004 11:35:38 -0000 +Received: (qmail 15830 invoked from network); 3 Aug 2004 08:39:58 -0000 +Received: from unknown (HELO ?81.196.83.211?) (81.196.83.211) + by mail.rdslink.ro with SMTP; 3 Aug 2004 08:39:58 -0000 +Subject: NOT IN query takes forever +From: Marius Andreiana +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Organization: Galuna S.R.L. +Date: Tue, 03 Aug 2004 11:49:02 +0300 +Message-Id: <1091522942.4936.5.camel@marte.biciclete.ro> +Mime-Version: 1.0 +X-Mailer: Evolution 1.5.9.1 (1.5.9.1-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/26 +X-Sequence-Number: 7662 + +Hi + +I have 2 tables like this: +CREATE TABLE query ( + query_id int not null, + dat varchar(64) null , + sub_acc_id int null , + query_ip varchar(64) null , + osd_user_type varchar(64) null +) +; + +CREATE TABLE trans ( + transaction_id varchar(64) not null , + date varchar(64) null , + query_id int not null , + sub_acc_id int null , + reg_acc_id int null +) +; + +CREATE UNIQUE INDEX query_query_id_idx +ON query (query_id) +; + +CREATE INDEX trans_reg_acc_id_idx +ON trans (reg_acc_id) +; + +CREATE INDEX trans_query_id_idx +ON trans(query_id) +; +osd=> select count(*) from trans +osd-> ; + count +-------- + 598809 +(1 row) + +osd=> +osd=> select count(*) from query +osd-> ; + count +-------- + 137042 +(1 row) + +I just vacuum analyse'd the database. + +Trying to run this query: +EXPLAIN ANALYSE +select * FROM trans +WHERE query_id NOT IN (select query_id FROM query) + +but it will remain like that forever (cancelled after 30 min). + +My postgresql.conf is the default: +# - Memory - + +shared_buffers = 1000 # min 16, at least max_connections*2, +8KB each +#sort_mem = 1024 # min 64, size in KB +#vacuum_mem = 8192 # min 1024, size in KB + +Should I adjust something? + +Using postgresql 7.4.2, saw in release notes that IN/NOT IN queries are +at least as faster than EXISTS. + +Thank you! +-- +Marius Andreiana +Galuna - Solutii Linux in Romania +http://www.galuna.ro + + +From pgsql-performance-owner@postgresql.org Tue Aug 3 06:07:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0DF9BD1B341 + for ; + Tue, 3 Aug 2004 06:07:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74445-09 + for ; + Tue, 3 Aug 2004 09:07:31 +0000 (GMT) +Received: from mx2.aftenposten.no (mx2.aftenposten.no [80.91.34.76]) + by svr1.postgresql.org (Postfix) with ESMTP id 296DFD1B2A8 + for ; + Tue, 3 Aug 2004 06:07:28 -0300 (ADT) +Received: from localhost (localhost.aftenposten.no [127.0.0.1]) + by mx2.aftenposten.no (Postfix) with ESMTP id 9E4287F7F1F + for ; + Tue, 3 Aug 2004 11:07:28 +0200 (CEST) +Received: from mx2.aftenposten.no ([127.0.0.1]) + by localhost (mx2.aftenposten.no [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 87180-01-4 for ; + Tue, 3 Aug 2004 11:07:28 +0200 (CEST) +Received: from smtp1.aftenposten.no (unknown [80.91.34.6]) + by mx2.aftenposten.no (Postfix) with ESMTP id 05A397F7EFD + for ; + Tue, 3 Aug 2004 11:07:28 +0200 (CEST) +Received: from telecommail.inpoc.no (unverified) by smtp1.aftenposten.no + (Content Technologies SMTPRS 4.3.12) with ESMTP id + for + ; Tue, 3 Aug 2004 11:09:48 +0200 +Received: by TELECOMMAIL with Internet Mail Service (5.5.2653.19) + id ; Tue, 3 Aug 2004 11:09:27 +0200 +Message-ID: +From: "Lending, Rune" +To: "'pgsql-performance@postgresql.org'" +Subject: pg_autovacuum parameters +Date: Tue, 3 Aug 2004 11:09:26 +0200 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C47939.938C2AB0" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200408/27 +X-Sequence-Number: 7663 + +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_01C47939.938C2AB0 +Content-Type: text/plain + +Hello all. + +I am managing a large database with lots of transactions in different +tables. +The largest tables have around 5-6 millions tuples and around 50000-60000 +inserts and maybe 20000 updates pr day. +While the smalest tables have only a few tuples and a few updates /inserts +pr day. In addition we have small tables with many updates/inserts. So what +I am saying is that there is all kinds of tables and uses of tables in our +database. +This, I think, makes it difficult to set up pg_autovacuum. I am now running +vacuum jobs on different tables in cron. + +What things should I consider when setting but base and threshold values in +pg_autovacuum? Since the running of vacuum and analyze is relative to the +table size, as it must be, I think it is difficult to cover all tables.. + +Are there anyone who have some thoughts around this? + +Regards +Rune + + +------_=_NextPart_001_01C47939.938C2AB0 +Content-Type: text/html + + + + +Melding + + + +
Hello +all.
+
 
+
I am managing a +large database with lots of transactions in different +tables.
+
The largest tables +have around 5-6 millions tuples and around 50000-60000 inserts and maybe 20000 +updates pr day.
+
While the smalest +tables have only a few tuples and a few updates /inserts pr day. In addition we +have small tables with many updates/inserts. So what I am saying is that there +is all kinds of tables and uses of tables in our database.
+
This, I think, makes +it difficult to set up pg_autovacuum. I am now running vacuum jobs on different +tables in cron.
+
 
+
What things should I +consider when setting but base and threshold values in pg_autovacuum? Since the +running of vacuum and analyze is relative to the table size, as it must be, I +think it is difficult to cover all tables..
+
 
+
Are there anyone who +have some thoughts around this?
+
 
+
Regards
+
Rune
+
 
+ +------_=_NextPart_001_01C47939.938C2AB0-- + +From pgsql-performance-owner@postgresql.org Tue Aug 3 09:06:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0FB7DD1B275 + for ; + Tue, 3 Aug 2004 09:06:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57831-07 + for ; + Tue, 3 Aug 2004 12:06:05 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id B8ADFD1B1D2 + for ; + Tue, 3 Aug 2004 09:06:02 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: NOT IN query takes forever +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Tue, 3 Aug 2004 08:05:23 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AF1A@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] NOT IN query takes forever +thread-index: AcR5NyJZJe1lKR+HSKajmM2X8ntV+wAGnwaw +From: "Merlin Moncure" +To: "Marius Andreiana" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/28 +X-Sequence-Number: 7664 + +> Trying to run this query: +> EXPLAIN ANALYSE +> select * FROM trans +> WHERE query_id NOT IN (select query_id FROM query) +>=20 +> but it will remain like that forever (cancelled after 30 min). + +explain analyze actually runs the query to do timings. Just run explain +and see what you come up with. More than likely there is a nestloop in +there which is causing the long query time. + +Try bumping up shared buffers some and sort mem as much as you safely +can. + +Merlin + +From pgsql-performance-owner@postgresql.org Tue Aug 3 11:09:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 701ABD1B2E6 + for ; + Tue, 3 Aug 2004 11:09:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16357-05 + for ; + Tue, 3 Aug 2004 14:06:27 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 7DB28D1B192 + for ; + Tue, 3 Aug 2004 11:03:43 -0300 (ADT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 9D911354F2; Tue, 3 Aug 2004 07:03:31 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 9C28E354F1; Tue, 3 Aug 2004 07:03:31 -0700 (PDT) +Date: Tue, 3 Aug 2004 07:03:31 -0700 (PDT) +From: Stephan Szabo +To: Marius Andreiana +Cc: pgsql-performance@postgresql.org +Subject: Re: NOT IN query takes forever +In-Reply-To: <1091522942.4936.5.camel@marte.biciclete.ro> +Message-ID: <20040803065928.Y88907@megazone.bigpanda.com> +References: <1091522942.4936.5.camel@marte.biciclete.ro> +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.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200408/29 +X-Sequence-Number: 7665 + + +On Tue, 3 Aug 2004, Marius Andreiana wrote: + +> I just vacuum analyse'd the database. +> +> Trying to run this query: +> EXPLAIN ANALYSE +> select * FROM trans +> WHERE query_id NOT IN (select query_id FROM query) +> +> but it will remain like that forever (cancelled after 30 min). +> +> My postgresql.conf is the default: +> # - Memory - +> +> shared_buffers = 1000 # min 16, at least max_connections*2, +> 8KB each +> #sort_mem = 1024 # min 64, size in KB +> #vacuum_mem = 8192 # min 1024, size in KB +> +> Should I adjust something? + +Probably sort_mem. It's probably estimating that it can't hash the result +into the 1MB of sort_mem so it's probably falling back to some sort of +nested execution. + + +From pgsql-performance-owner@postgresql.org Tue Aug 3 11:26:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 785DED1B385 + for ; + Tue, 3 Aug 2004 11:26:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26490-02 + for ; + Tue, 3 Aug 2004 14:25:42 +0000 (GMT) +Received: from outbound.mailhop.org (unknown [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 5944ED1B344 + for ; + Tue, 3 Aug 2004 11:21:06 -0300 (ADT) +Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] + helo=[192.168.0.66]) + by outbound.mailhop.org with asmtp (TLSv1:AES256-SHA:256) (Exim 4.20) + id 1Bs08q-000D1f-6b; Tue, 03 Aug 2004 10:19:48 -0400 +Message-ID: <410F9EF4.1070003@zeut.net> +Date: Tue, 03 Aug 2004 10:19:32 -0400 +From: "Matthew T. O'Connor" +User-Agent: Mozilla Thunderbird 0.7 (Windows/20040616) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Lending, Rune" +Cc: "'pgsql-performance@postgresql.org'" +Subject: Re: pg_autovacuum parameters +References: +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; 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.2 tagged_above=0.0 required=5.0 tests=RCVD_IN_NJABL, + RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/30 +X-Sequence-Number: 7666 + +Lending, Rune wrote: + +> Hello all. +> +> I am managing a large database with lots of transactions in different +> tables. +> The largest tables have around 5-6 millions tuples and around +> 50000-60000 inserts and maybe 20000 updates pr day. +> While the smalest tables have only a few tuples and a few updates +> /inserts pr day. In addition we have small tables with many +> updates/inserts. So what I am saying is that there is all kinds of +> tables and uses of tables in our database. +> This, I think, makes it difficult to set up pg_autovacuum. I am now +> running vacuum jobs on different tables in cron. +> +> What things should I consider when setting but base and threshold values +> in pg_autovacuum? Since the running of vacuum and analyze is relative to +> the table size, as it must be, I think it is difficult to cover all tables.. + +One of the biggest problems with the version of pg_autovacuum in 7.4 +contrib is that you can only specify one set of thresholds, which often +isn't flexible enough. That said the thresholds are based on table +since since you specify both a base value and a scaling factor so +pg_autovacuum -v 1000 -V 1 will vacuum a table with 100 rows every 200 +updates, but will vacuum a table with 1,000,000 rows every 1,000,100 +updates. + +> Are there anyone who have some thoughts around this? + +Basically, you should be able to use pg_autovacuum to do most of the +vacuuming, if there are a few tables that aren't getting vacuumed often +enough, then you can add a vacuum command to cron for those specific tables. + +Matthew + + + +From pgsql-performance-owner@postgresql.org Tue Aug 3 12:00:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 43C5FD1B38E + for ; + Tue, 3 Aug 2004 12:00:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38581-06 + for ; + Tue, 3 Aug 2004 14:59: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 647AED1B37F + for ; + Tue, 3 Aug 2004 11:59:22 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i73ExHPD023046; + Tue, 3 Aug 2004 10:59:17 -0400 (EDT) +To: "Merlin Moncure" +Cc: "Marius Andreiana" , + pgsql-performance@postgresql.org +Subject: Re: NOT IN query takes forever +In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB34101AF1A@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB34101AF1A@Herge.rcsinc.local> +Comments: In-reply-to "Merlin Moncure" + message dated "Tue, 03 Aug 2004 08:05:23 -0400" +Date: Tue, 03 Aug 2004 10:59:17 -0400 +Message-ID: <23045.1091545157@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200408/31 +X-Sequence-Number: 7667 + +"Merlin Moncure" writes: +> Try bumping up shared buffers some and sort mem as much as you safely +> can. + +sort_mem is probably the issue here. The only reasonable way to do NOT +IN is with a hash table, and the default setting of sort_mem is probably +too small to support a 137042-element table. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 3 15:10:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 90312D1B375 + for ; + Tue, 3 Aug 2004 15:10:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22107-02 + for ; + Tue, 3 Aug 2004 18:10:31 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 11EFAD1B785 + for ; + Tue, 3 Aug 2004 13:26:05 -0300 (ADT) +Received: from news.hub.org ([200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i73GN6qb034457 + for ; Tue, 3 Aug 2004 16:25:23 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i73FtfGh030622 + for pgsql-performance@postgresql.org; Tue, 3 Aug 2004 15:55:41 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: pg_autovacuum parameters +Date: Tue, 03 Aug 2004 17:54:44 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 49 +Message-ID: <410FB544.1010403@bigfoot.com> +References: + <410F9EF4.1070003@zeut.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: "Matthew T. O'Connor" +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: <410F9EF4.1070003@zeut.net> +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/34 +X-Sequence-Number: 7670 + +Matthew T. O'Connor wrote: + +> Lending, Rune wrote: +> +>> Hello all. +>> +>> I am managing a large database with lots of transactions in different +>> tables. +>> The largest tables have around 5-6 millions tuples and around +>> 50000-60000 inserts and maybe 20000 updates pr day. +>> While the smalest tables have only a few tuples and a few updates +>> /inserts pr day. In addition we have small tables with many +>> updates/inserts. So what I am saying is that there is all kinds of +>> tables and uses of tables in our database. +>> This, I think, makes it difficult to set up pg_autovacuum. I am now +>> running vacuum jobs on different tables in cron. +>> +>> What things should I consider when setting but base and threshold +>> values in pg_autovacuum? Since the running of vacuum and analyze is +>> relative to the table size, as it must be, I think it is difficult to +>> cover all tables.. +> +> +> One of the biggest problems with the version of pg_autovacuum in 7.4 +> contrib is that you can only specify one set of thresholds, which often +> isn't flexible enough. That said the thresholds are based on table +> since since you specify both a base value and a scaling factor so +> pg_autovacuum -v 1000 -V 1 will vacuum a table with 100 rows every 200 +> updates, but will vacuum a table with 1,000,000 rows every 1,000,100 +> updates. +> +>> Are there anyone who have some thoughts around this? +> +> +> Basically, you should be able to use pg_autovacuum to do most of the +> vacuuming, if there are a few tables that aren't getting vacuumed often +> enough, then you can add a vacuum command to cron for those specific +> tables. + +And in the version 7.5^H^H^H8.0 ( Tom Lane docet :-) ) I think is possible +specify that thresholds per table... + + +Regards +Gateano Mendola + + + + + +From pgsql-performance-owner@postgresql.org Tue Aug 3 12:58:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F0427D1B488 + for ; + Tue, 3 Aug 2004 12:58:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67696-09 + for ; + Tue, 3 Aug 2004 15:57:58 +0000 (GMT) +Received: from mta2.rdslink.ro (mta2.rdslink.ro [193.231.236.124]) + by svr1.postgresql.org (Postfix) with ESMTP id 56F5AD1B541 + for ; + Tue, 3 Aug 2004 12:54:36 -0300 (ADT) +Received: (qmail 16166 invoked from network); 3 Aug 2004 18:49:20 -0000 +Received: from unknown (HELO mail.rdslink.ro) (193.231.236.20) + by mta2.rdslink.ro with DES-CBC3-SHA encrypted SMTP; + 3 Aug 2004 18:49:20 -0000 +Received: (qmail 7674 invoked from network); 3 Aug 2004 15:53:42 -0000 +Received: from unknown (HELO ?81.196.83.211?) (81.196.83.211) + by mail.rdslink.ro with SMTP; 3 Aug 2004 15:53:42 -0000 +Subject: Re: NOT IN query takes forever +From: Marius Andreiana +To: pgsql-performance@postgresql.org +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AF1A@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB34101AF1A@Herge.rcsinc.local> +Content-Type: text/plain +Organization: Galuna S.R.L. +Date: Tue, 03 Aug 2004 19:02:42 +0300 +Message-Id: <1091548963.6915.2.camel@marte.biciclete.ro> +Mime-Version: 1.0 +X-Mailer: Evolution 1.5.9.1 (1.5.9.1-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/32 +X-Sequence-Number: 7668 + +On Tue, 2004-08-03 at 08:05 -0400, Merlin Moncure wrote: +> > Trying to run this query: +> > EXPLAIN ANALYSE +> > select * FROM trans +> > WHERE query_id NOT IN (select query_id FROM query) +> > +> > but it will remain like that forever (cancelled after 30 min). +> +> explain analyze actually runs the query to do timings. Just run explain +> and see what you come up with. More than likely there is a nestloop in +> there which is causing the long query time. +> +> Try bumping up shared buffers some and sort mem as much as you safely +> can. +Thank you, that did it! + +With +shared_buffers = 3000 # min 16, at least max_connections*2, 8KB each +sort_mem = 128000 # min 64, size in KB + +it takes <3 seconds (my hardware is not server-class). + +-- +Marius Andreiana +Galuna - Solutii Linux in Romania +http://www.galuna.ro + + +From pgsql-performance-owner@postgresql.org Tue Aug 3 14:53:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B355ED1B438 + for ; + Tue, 3 Aug 2004 14:53:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03682-10 + for ; + Tue, 3 Aug 2004 17:53:26 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 8820FD1B388 + for ; + Tue, 3 Aug 2004 13:12:45 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: NOT IN query takes forever +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Tue, 3 Aug 2004 12:10:04 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AF1C@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] NOT IN query takes forever +thread-index: AcR5c7RN5rOmntfzRgq6HbLmiUhx0wAACuzg +From: "Merlin Moncure" +To: "Marius Andreiana" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/33 +X-Sequence-Number: 7669 + +> > Try bumping up shared buffers some and sort mem as much as you +safely +> > can. +> Thank you, that did it! +>=20 +> With +> shared_buffers =3D 3000 # min 16, at least max_connections*2, +8KB +> each +> sort_mem =3D 128000 # min 64, size in KB +>=20 +> it takes <3 seconds (my hardware is not server-class). + +Be careful...sort_mem applies to each connection and (IIRC) in some +cases more than once to a connection. Of all the configuration +parameters, sort_mem (IMO) is the most important and the hardest to get +right. 128k (or 128MB) is awfully high unless you have a ton of memory +(you don't) or you are running in single connection scenarios. Do some +experimentation by lowering the value until you get a good balance +between potential memory consumption and speed. + +Merlin + +From pgsql-performance-owner@postgresql.org Tue Aug 3 19:21:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 69492D1B4E5 + for ; + Tue, 3 Aug 2004 19:20:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13972-06 + for ; + Tue, 3 Aug 2004 22:20:47 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id E361BD1CEDC + for ; + Tue, 3 Aug 2004 14:48:25 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i73HmOqb047824 + for ; Tue, 3 Aug 2004 17:48:24 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i73HSw54045070 + for pgsql-performance@postgresql.org; Tue, 3 Aug 2004 17:28:58 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: NOT IN query takes forever +Date: Tue, 03 Aug 2004 19:28:27 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 48 +Message-ID: <410FCB3B.5050300@bigfoot.com> +References: <6EE64EF3AB31D5448D0007DD34EEB34101AF1A@Herge.rcsinc.local> + <1091548963.6915.2.camel@marte.biciclete.ro> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Marius Andreiana +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: <1091548963.6915.2.camel@marte.biciclete.ro> +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/39 +X-Sequence-Number: 7675 + +Marius Andreiana wrote: + +> On Tue, 2004-08-03 at 08:05 -0400, Merlin Moncure wrote: +> +>>>Trying to run this query: +>>>EXPLAIN ANALYSE +>>>select * FROM trans +>>>WHERE query_id NOT IN (select query_id FROM query) +>>> +>>>but it will remain like that forever (cancelled after 30 min). +>> +>>explain analyze actually runs the query to do timings. Just run explain +>>and see what you come up with. More than likely there is a nestloop in +>>there which is causing the long query time. +>> +>>Try bumping up shared buffers some and sort mem as much as you safely +>>can. +> +> Thank you, that did it! +> +> With +> shared_buffers = 3000 # min 16, at least max_connections*2, 8KB each +> sort_mem = 128000 # min 64, size in KB + +128 MB for sort_mem is too much, consider that in this way each backend can +use 128 MB for sort operations... +Also shared_buffers = 3000 means 24MB that is not balanced with the 128MB +needed for sort... +Try to bump up 128 MB for shared_buffer ( may be you need to instruct your +OS to allow that ammount of shared memory usage ) and 24MB for sort_mem. + + + +Regards +Gaetano Mendola + + + + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Tue Aug 3 15:19:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 24311D1B4A2 + for ; + Tue, 3 Aug 2004 15:19:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24907-10 + for ; + Tue, 3 Aug 2004 18:19:26 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 71D75D1B38E + for ; + Tue, 3 Aug 2004 15:18:28 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i73IIRqd052782 + for ; Tue, 3 Aug 2004 18:18:28 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i73I5JA5050772 + for pgsql-performance@postgresql.org; Tue, 3 Aug 2004 18:05:19 GMT +From: Martin Foster +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7) Gecko/20040616 +X-Accept-Language: en-ca, en-gb, en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Performance Bottleneck +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 36 +Message-ID: +Date: Tue, 03 Aug 2004 18:05:04 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/35 +X-Sequence-Number: 7671 + +I run a Perl/CGI driven website that makes extensive use of PostgreSQL +(7.4.3) for everything from user information to formatting and display +of specific sections of the site. The server itself, is a dual +processor AMD Opteron 1.4Ghz w/ 2GB Ram and 2 x 120GB hard drives +mirrored for redundancy running under FreeBSD 5.2.1 (AMD64). + +Recently loads on the site have increased during peak hours to the point +of showing considerable loss in performance. This can be observed +when connections move from the 120 concurrent connections to PostgreSQL +to roughly 175 or more. Essentially, the machine seems to struggle +to keep up with continual requests and slows down respectively as +resources are tied down. + +Code changes have been made to the scripts to essentially back off in +high load working environments which have worked to an extent. +However, as loads continue to increase the database itself is not taking +well to the increased traffic taking place. + +Having taken a look at 'Tuning PostgreSQL for Performance' +(http://www.varlena.com/GeneralBits/Tidbits/perf.html) using it as best +I could in order to set my settings. However, even with statistics +disabled and ever setting tweaked things still consider to deteriorate. + +Is there anything anyone can recommend in order to give the system a +necessary speed boost? It would seem to me that a modest dataset of +roughly a Gig combined with that type of hardware should be able to +handle substantially more load then what it is. Can anyone provide me +with clues as where to pursue? Would disabling 'fsync' provide more +performance if I choose that information may be lost in case of a crash? + +If anyone needs access to logs, settings et cetera. Please ask, I +simply wish to test the waters first on what is needed. Thanks! + + Martin Foster + martin@ethereal-realms.org + + +From pgsql-performance-owner@postgresql.org Tue Aug 3 15:25:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37F4CD1B374 + for ; + Tue, 3 Aug 2004 15:25:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27583-09 + for ; + Tue, 3 Aug 2004 18:25:17 +0000 (GMT) +Received: from mpls-qmqp-04.inet.qwest.net (mpls-qmqp-04.inet.qwest.net + [63.231.195.115]) + by svr1.postgresql.org (Postfix) with SMTP id 1C7DDD1B344 + for ; + Tue, 3 Aug 2004 15:25:14 -0300 (ADT) +Received: (qmail 6619 invoked by uid 0); 3 Aug 2004 18:25:13 -0000 +Received: from mpls-pop-12.inet.qwest.net (63.231.195.12) + by mpls-qmqp-04.inet.qwest.net with QMQP; 3 Aug 2004 18:25:13 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-12.inet.qwest.net with SMTP; 3 Aug 2004 18:25:12 -0000 +Date: Tue, 03 Aug 2004 12:26:28 -0600 +Message-Id: <1091557588.27166.94.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Merlin Moncure" +Cc: "Marius Andreiana" , + pgsql-performance@postgresql.org +Subject: Re: NOT IN query takes forever +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AF1C@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB34101AF1C@Herge.rcsinc.local> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/36 +X-Sequence-Number: 7672 + +On Tue, 2004-08-03 at 10:10, Merlin Moncure wrote: +> > > Try bumping up shared buffers some and sort mem as much as you +> safely +> > > can. +> > Thank you, that did it! +> > +> > With +> > shared_buffers = 3000 # min 16, at least max_connections*2, +> 8KB +> > each +> > sort_mem = 128000 # min 64, size in KB +> > +> > it takes <3 seconds (my hardware is not server-class). +> +> Be careful...sort_mem applies to each connection and (IIRC) in some +> cases more than once to a connection. Of all the configuration +> parameters, sort_mem (IMO) is the most important and the hardest to get +> right. 128k (or 128MB) is awfully high unless you have a ton of memory +> (you don't) or you are running in single connection scenarios. Do some +> experimentation by lowering the value until you get a good balance +> between potential memory consumption and speed. + +Minor nit, sort_mem actually applies to EACH sort individually, so a +query that had to run three sorts could use 3 x sort_mem. + +Note that one can set sort_mem per backend connection with set +sort_mem=128000 if need be so as not to use up all the memory with other +backends. + + +From pgsql-performance-owner@postgresql.org Tue Aug 3 15:39:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 47115D1B34A + for ; + Tue, 3 Aug 2004 15:35:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35166-04 + for ; + Tue, 3 Aug 2004 18:35:41 +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 A8883D1B171 + for ; + Tue, 3 Aug 2004 15:35:36 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 2DDCD8467; Tue, 3 Aug 2004 20:35:36 +0200 (CEST) +Date: Tue, 3 Aug 2004 20:35:36 +0200 (CEST) +From: Dennis Bjorklund +To: Martin Foster +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance Bottleneck +In-Reply-To: +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/37 +X-Sequence-Number: 7673 + +On Tue, 3 Aug 2004, Martin Foster wrote: + +> to roughly 175 or more. Essentially, the machine seems to struggle +> to keep up with continual requests and slows down respectively as +> resources are tied down. + +I suggest you try to find queries that are slow and check to see if the +plans are optimal for those queries. + +There are some logging options for logging quries that run longer then a +user set limit. That can help finding the slow queries. Just doing some +logging for some typical page fetches often show things that can be done +better. For example, it's not uncommon to see the same information beeing +pulled several times by misstake. + +Maybe you can also try something like connection pooling. I'm not sure how +much that can give, but for small queries the connection time is usually +the big part. + +> Would disabling 'fsync' provide more performance if I choose that +> information may be lost in case of a crash? + +I would not do that. In most cases the performance increase is modest and +the data corruption risk after a crash is much bigger so it's not worth +it. + +If you have a lot of small inserts then it might be faster with this, but +if possible it's much better to try to do more work in a transaction then +before. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Tue Aug 3 19:46:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9ADF3D1B1CD + for ; + Tue, 3 Aug 2004 19:36:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15352-10 + for ; + Tue, 3 Aug 2004 22:36:36 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 150D1D1B37D + for ; + Tue, 3 Aug 2004 15:49:05 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i73Imlqb057882 + for ; Tue, 3 Aug 2004 18:48:57 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i73IgaH0057098 + for pgsql-performance@postgresql.org; Tue, 3 Aug 2004 18:42:36 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Performance Bottleneck +Date: Tue, 03 Aug 2004 20:41:23 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 50 +Message-ID: <410FDC53.5080509@bigfoot.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Martin Foster +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/40 +X-Sequence-Number: 7676 + +Martin Foster wrote: + +> I run a Perl/CGI driven website that makes extensive use of PostgreSQL +> (7.4.3) for everything from user information to formatting and display +> of specific sections of the site. The server itself, is a dual +> processor AMD Opteron 1.4Ghz w/ 2GB Ram and 2 x 120GB hard drives +> mirrored for redundancy running under FreeBSD 5.2.1 (AMD64). +> +> Recently loads on the site have increased during peak hours to the point +> of showing considerable loss in performance. This can be observed +> when connections move from the 120 concurrent connections to PostgreSQL +> to roughly 175 or more. Essentially, the machine seems to struggle +> to keep up with continual requests and slows down respectively as +> resources are tied down. +> +> Code changes have been made to the scripts to essentially back off in +> high load working environments which have worked to an extent. However, +> as loads continue to increase the database itself is not taking well to +> the increased traffic taking place. +> +> Having taken a look at 'Tuning PostgreSQL for Performance' +> (http://www.varlena.com/GeneralBits/Tidbits/perf.html) using it as best +> I could in order to set my settings. However, even with statistics +> disabled and ever setting tweaked things still consider to deteriorate. +> +> Is there anything anyone can recommend in order to give the system a +> necessary speed boost? It would seem to me that a modest dataset of +> roughly a Gig combined with that type of hardware should be able to +> handle substantially more load then what it is. Can anyone provide me +> with clues as where to pursue? Would disabling 'fsync' provide more +> performance if I choose that information may be lost in case of a crash? +> +> If anyone needs access to logs, settings et cetera. Please ask, I +> simply wish to test the waters first on what is needed. Thanks! + +Tell us about your tipical queries, show us your configuration file. +The access are only in read only mode or do you have concurrent writers +and readers ? During peak hours your processors are tied to 100% ? +What say the vmstat and the iostat ? + +May be you are not using indexes some where, or may be yes but the +planner is not using it... In two words we needs other informations +in order to help you. + + + +Regards +Gaetano Mendola + + + +From pgsql-performance-owner@postgresql.org Tue Aug 3 16:11:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C281AD1B2E0 + for ; + Tue, 3 Aug 2004 16:11:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41637-10 + for ; + Tue, 3 Aug 2004 19:06:25 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 62E33D1B3CA + for ; + Tue, 3 Aug 2004 15:52:54 -0300 (ADT) +Received: from [192.168.1.51] (dsl093-038-087.pdx1.dsl.speakeasy.net + [66.93.38.87]) (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i73IqKJ18462; + Tue, 3 Aug 2004 11:52:20 -0700 +Message-ID: <410FDEEC.90901@commandprompt.com> +Date: Tue, 03 Aug 2004 11:52:28 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla Thunderbird 0.7.1 (X11/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Martin Foster +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance Bottleneck +References: +In-Reply-To: +Content-Type: multipart/mixed; boundary="------------020502030003010808060900" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/38 +X-Sequence-Number: 7674 + +This is a multi-part message in MIME format. +--------------020502030003010808060900 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Hello, + +It sounds to me like you are IO bound. 2x120GB hard drives just isn't +going to cut it with that many connections (as a general rule). Are you +swapping ? + +Sincerely, + +Joshua D. Drake + + + + + +Martin Foster wrote: +> I run a Perl/CGI driven website that makes extensive use of PostgreSQL +> (7.4.3) for everything from user information to formatting and display +> of specific sections of the site. The server itself, is a dual +> processor AMD Opteron 1.4Ghz w/ 2GB Ram and 2 x 120GB hard drives +> mirrored for redundancy running under FreeBSD 5.2.1 (AMD64). +-- +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 +Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL + +--------------020502030003010808060900 +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 D. Drake +n:Drake;Joshua D. +org:Command Prompt, Inc. +adr:;;PO Box 215;Cascade Locks;Oregon;97014;USA +email;internet:jd@commandprompt.com +title:Consultant +tel;work:503-667-4564 +tel;fax:503-210-0034 +note:Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. +x-mozilla-html:FALSE +url:http://www.commandprompt.com/ +version:2.1 +end:vcard + + +--------------020502030003010808060900-- + +From pgsql-performance-owner@postgresql.org Tue Aug 3 22:31:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 77A98D1B199 + for ; + Tue, 3 Aug 2004 22:31:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59932-01 + for ; + Wed, 4 Aug 2004 01:31:12 +0000 (GMT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D10AD1B1B4 + for ; + Tue, 3 Aug 2004 22:31:05 -0300 (ADT) +Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i741V4Ui090216; Wed, 4 Aug 2004 09:31:06 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <41103CC5.7030207@familyhealth.com.au> +Date: Wed, 04 Aug 2004 09:32:53 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Merlin Moncure +Cc: Marius Andreiana , pgsql-performance@postgresql.org +Subject: Re: NOT IN query takes forever +References: <6EE64EF3AB31D5448D0007DD34EEB34101AF1A@Herge.rcsinc.local> +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB34101AF1A@Herge.rcsinc.local> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/41 +X-Sequence-Number: 7677 + +> explain analyze actually runs the query to do timings. Just run explain +> and see what you come up with. More than likely there is a nestloop in +> there which is causing the long query time. +> +> Try bumping up shared buffers some and sort mem as much as you safely +> can. + +Just use an EXISTS query I suggest. + +Chris + +From pgsql-performance-owner@postgresql.org Wed Aug 4 01:26:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8ECABD1B42F + for ; + Wed, 4 Aug 2004 01:22:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98670-04 + for ; + Wed, 4 Aug 2004 04:21:45 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id A4796D1B29D + for ; + Wed, 4 Aug 2004 01:20:46 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i744JFqb036540 + for ; Wed, 4 Aug 2004 04:19:56 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i743nIYm032744 + for pgsql-performance@postgresql.org; Wed, 4 Aug 2004 03:49:18 GMT +From: Martin Foster +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7) Gecko/20040616 +X-Accept-Language: en-ca, en-gb, en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Performance Bottleneck +References: <410FDC53.5080509@bigfoot.com> +In-Reply-To: <410FDC53.5080509@bigfoot.com> +Content-Type: multipart/mixed; boundary="------------090706020804040907080407" +Lines: 570 +Message-ID: +Date: Wed, 04 Aug 2004 03:49:11 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.2 tagged_above=0.0 required=5.0 + tests=LINES_OF_YELLING, LINES_OF_YELLING_2, NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200408/42 +X-Sequence-Number: 7678 + +This is a multi-part message in MIME format. +--------------090706020804040907080407 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Gaetano Mendola wrote: +> Martin Foster wrote: +> +>> I run a Perl/CGI driven website that makes extensive use of PostgreSQL +>> (7.4.3) for everything from user information to formatting and display +>> of specific sections of the site. The server itself, is a dual +>> processor AMD Opteron 1.4Ghz w/ 2GB Ram and 2 x 120GB hard drives +>> mirrored for redundancy running under FreeBSD 5.2.1 (AMD64). +>> +>> Recently loads on the site have increased during peak hours to the +>> point of showing considerable loss in performance. This can be +>> observed when connections move from the 120 concurrent connections to +>> PostgreSQL to roughly 175 or more. Essentially, the machine seems +>> to struggle to keep up with continual requests and slows down +>> respectively as resources are tied down. +>> +>> Code changes have been made to the scripts to essentially back off in +>> high load working environments which have worked to an extent. +>> However, as loads continue to increase the database itself is not +>> taking well to the increased traffic taking place. +>> +>> Having taken a look at 'Tuning PostgreSQL for Performance' +>> (http://www.varlena.com/GeneralBits/Tidbits/perf.html) using it as +>> best I could in order to set my settings. However, even with +>> statistics disabled and ever setting tweaked things still consider to +>> deteriorate. +>> +>> Is there anything anyone can recommend in order to give the system a +>> necessary speed boost? It would seem to me that a modest dataset of +>> roughly a Gig combined with that type of hardware should be able to +>> handle substantially more load then what it is. Can anyone provide me +>> with clues as where to pursue? Would disabling 'fsync' provide more +>> performance if I choose that information may be lost in case of a crash? +>> +>> If anyone needs access to logs, settings et cetera. Please ask, I +>> simply wish to test the waters first on what is needed. Thanks! +> +> +> Tell us about your tipical queries, show us your configuration file. +> The access are only in read only mode or do you have concurrent writers +> and readers ? During peak hours your processors are tied to 100% ? +> What say the vmstat and the iostat ? +> +> May be you are not using indexes some where, or may be yes but the +> planner is not using it... In two words we needs other informations +> in order to help you. +> +> +> +> Regards +> Gaetano Mendola +> +> + +I included all the files in attachments, which will hopefully cut down +on any replied to Emails. As for things like connection pooling, the +web server makes use of Apache::DBI to pool the connections for the Perl +scripts being driven on that server. For the sake of being thorough, +a quick 'apachectl status' was thrown in when the database was under a +good load. + +Since it would rather slow things down to wait for the servers to really +get bogged down with load averages of 20.00 and more, I opted to choose +a period of time where we are a bit busier then normal. You will be +able to see how the system behaves under a light load and subsequently +reaching 125 or so concurrent connections. + +The queries themselves are simple, normally drawing information from one +table with few conditions or in the most complex cases using joins on +two table or sub queries. These behave very well and always have, the +problem is that these queries take place in rather large amounts due to +the dumb nature of the scripts themselves. + +Over a year ago when I was still using MySQL for the project, the +statistics generated would report well over 65 queries per second under +loads ranging from 130 to 160 at peak but averaged over the weeks of +operation. Looking at the Apache status, one can see that it averages +only roughly 2.5 requests per second giving you a slight indication as +to what is taking place. + +A quick run of 'systat -ifstat' shows the following graph: + + + /0 /1 /2 /3 /4 /5 /6 /7 /8 /9 /10 +Load Average >>>>>>>>>>> + +Interface Traffic Peak Total + lo0 in 0.000 KB/s 0.000 KB/s 37.690 GB + out 0.000 KB/s 0.000 KB/s 37.690 GB + + em0 in 34.638 KB/s 41.986 KB/s 28.998 GB + out 70.777 KB/s 70.777 KB/s 39.553 GB + +Em0 is a full duplexed 100Mbs connection to an internal switch that +supports the servers directly. Load on the loopback was cut down +considerably once I stopped using pg_autovaccum since its performance +benefits under low load were buried under the hindrance it caused when +traffic was high. + +I am sure that there are some places that could benefit from some +optimization. Especially in the case of indexes, however as a whole the +problem seems to be related more to the massive onslaught of queries +then it does anything else. + +Also note that some of these scripts run for longer durations even if +they are web based. Some run as long as 30 minutes, making queries to +the database from periods of wait from five seconds to twenty-five +seconds. Under high duress the timeouts should back out, based on +the time needed for the query to respond, normally averaging 0.008 seconds. + +Does this help at all, or is more detail needed on the matter? + + Martin Foster + martin@ethereal-realms.org + + +--------------090706020804040907080407 +Content-Type: text/plain; + name="postgresql.conf" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline; + filename="postgresql.conf" + +# ----------------------------- +# PostgreSQL configuration file +# ----------------------------- +# +# This file consists of lines of the form: +# +# name = value +# +# (The '=' is optional.) White space may be used. Comments are introduced +# with '#' anywhere on a line. The complete list of option names and +# allowed values can be found in the PostgreSQL documentation. The +# commented-out settings shown in this file represent the default values. +# +# Any option can also be given as a command line switch to the +# postmaster, e.g. 'postmaster -c log_connections=on'. Some options +# can be changed at run-time with the 'SET' SQL command. +# +# This file is read on postmaster startup and when the postmaster +# receives a SIGHUP. If you edit the file on a running system, you have +# to SIGHUP the postmaster for the changes to take effect, or use +# "pg_ctl reload". + + +#--------------------------------------------------------------------------- +# CONNECTIONS AND AUTHENTICATION +#--------------------------------------------------------------------------- + +# - Connection Settings - + +tcpip_socket = true +ssl = false + +max_connections = 512 +superuser_reserved_connections = 2 + +rendezvous_name='io' +port = 5432 + +#unix_socket_directory = '/var/postgres' +#unix_socket_group = 'postgres' +#unix_socket_permissions = 0777 # octal + +# - Security & Authentication - + +authentication_timeout = 20 # 1-600, in seconds +password_encryption = true +db_user_namespace = false + + +#--------------------------------------------------------------------------- +# RESOURCE USAGE (except WAL) +#--------------------------------------------------------------------------- + +# - Memory - + +shared_buffers = 8192 # min 16, at least max_connections*2, 8KB each +sort_mem = 2048 # min 64, size in KB +vacuum_mem = 65536 # min 1024, size in KB + +# - Free Space Map - + +#max_fsm_pages = 20000 # min max_fsm_relations*16, 6 bytes each +#max_fsm_relations = 1000 # min 100, ~50 bytes each + +# - Kernel Resource Usage - + +#max_files_per_process = 1000 # min 25 +#preload_libraries = '' + + +#--------------------------------------------------------------------------- +# WRITE AHEAD LOG +#--------------------------------------------------------------------------- + +# - Settings - + +fsync = true # turns forced synchronization on or off +wal_sync_method = fsync # the default varies across platforms: + # fsync, fdatasync, open_sync, or open_datasync +wal_buffers = 128 # min 4, 8KB each + +# - Checkpoints - + +checkpoint_segments = 24 # in logfile segments, min 1, 16MB each +checkpoint_timeout = 300 # range 30-3600, in seconds +checkpoint_warning = 30 # 0 is off, in seconds +commit_delay = 15000 # range 0-100000, in microseconds +commit_siblings = 64 # range 1-1000 + + +#--------------------------------------------------------------------------- +# QUERY TUNING +#--------------------------------------------------------------------------- + +# - Planner Method Enabling - + +enable_hashagg = true +enable_hashjoin = true +enable_indexscan = true +enable_mergejoin = true +enable_nestloop = true +enable_seqscan = true +enable_sort = true +enable_tidscan = true + +# - Planner Cost Constants - + +effective_cache_size = 16000 # 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) + +# - Genetic Query Optimizer - + +geqo = false +geqo_threshold = 11 +geqo_effort = 1 +geqo_generations = 0 +geqo_pool_size = 0 # default based on tables in statement, + # range 128-1024 +geqo_selection_bias = 2.0 # range 1.5-2.0 + +# - Other Planner Options - + +default_statistics_target = 100 # range 1-1000 +from_collapse_limit = 8 +join_collapse_limit = 8 # 1 disables collapsing of explicit JOINs + + +#--------------------------------------------------------------------------- +# ERROR REPORTING AND LOGGING +#--------------------------------------------------------------------------- + +# - Syslog - + +#syslog = 2 # range 0-2; 0=stdout; 1=both; 2=syslog +#syslog_facility = 'LOCAL0' +#syslog_ident = 'postgres' + +# - When to Log - + +client_min_messages = notice # Values, in order of decreasing detail: + # debug5, debug4, debug3, debug2, debug1, + # log, info, notice, warning, error + +log_min_messages = info # Values, in order of decreasing detail: + # debug5, debug4, debug3, debug2, debug1, + # info, notice, warning, error, log, fatal, + # panic + +log_error_verbosity = default # terse, default, or verbose messages + +log_min_error_statement = panic # Values in order of increasing severity: + # debug5, debug4, debug3, debug2, debug1, + # info, notice, warning, error, panic(off) + +log_min_duration_statement = -1 # Log all statements whose + # execution time exceeds the value, in + # milliseconds. Zero prints all queries. + # Minus-one disables. + +silent_mode = false # DO NOT USE without Syslog! + +# - What to Log - + +#debug_print_parse = false +#debug_print_rewritten = false +#debug_print_plan = false +#debug_pretty_print = false +#log_connections = false +#log_duration = false +#log_pid = false +#log_statement = false +#log_timestamp = false +#log_hostname = false +#log_source_port = false + + +#--------------------------------------------------------------------------- +# RUNTIME STATISTICS +#--------------------------------------------------------------------------- + +# - Statistics Monitoring - + +log_parser_stats = false +log_planner_stats = false +log_executor_stats = false +log_statement_stats = false + +# - Query/Index Statistics Collector - + +stats_start_collector = false +stats_command_string = false +stats_block_level = false +stats_row_level = false +stats_reset_on_server_start = true + + +#--------------------------------------------------------------------------- +# CLIENT CONNECTION DEFAULTS +#--------------------------------------------------------------------------- + +# - Statement Behavior - + +search_path = '$user,public' # schema names +check_function_bodies = true +default_transaction_isolation = 'read committed' +default_transaction_read_only = false +statement_timeout = 25000 # 0 is disabled, in milliseconds + +# - Locale and Formatting - + +datestyle = 'iso, us' +#timezone = unknown # actually, defaults to TZ environment setting +#australian_timezones = false +#extra_float_digits = 0 # min -15, max 2 +#client_encoding = sql_ascii # actually, defaults to database encoding + +# These settings are initialized by initdb -- they may be changed +lc_messages = 'C' # locale for system error message strings +lc_monetary = 'C' # locale for monetary formatting +lc_numeric = 'C' # locale for number formatting +lc_time = 'C' # locale for time formatting + +# - Other Defaults - + +explain_pretty_print = true +#dynamic_library_path = '$libdir' +#max_expr_depth = 10000 # min 10 + + +#--------------------------------------------------------------------------- +# LOCK MANAGEMENT +#--------------------------------------------------------------------------- + +deadlock_timeout = 5000 # in milliseconds +#max_locks_per_transaction = 64 # min 10, ~260*max_connections bytes each + + +#--------------------------------------------------------------------------- +# VERSION/PLATFORM COMPATIBILITY +#--------------------------------------------------------------------------- + +# - Previous Postgres Versions - + +#add_missing_from = true +#regex_flavor = advanced # advanced, extended, or basic +#sql_inheritance = true + +# - Other Platforms & Clients - + +#transform_null_equals = false +--------------090706020804040907080407 +Content-Type: text/plain; + name="apache_load.txt" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline; + filename="apache_load.txt" + +martin@elara ~$ apachectl status + + Apache Server Status for www.ethereal-realms.org + + Server Version: Apache/1.3.29 (Unix) mod_perl/1.27 mod_gzip/1.3.26.1a + mod_ssl/2.8.16 OpenSSL/0.9.7c + Server Built: May 24 2004 00:32:11 + _________________________________________________________________ + + Current Time: Tuesday, 03-Aug-2004 21:34:37 MDT + Restart Time: Tuesday, 03-Aug-2004 03:54:21 MDT + Parent Server Generation: 0 + Server uptime: 17 hours 40 minutes 16 seconds + Total accesses: 168852 - Total Traffic: 406.0 MB + CPU Usage: u283.96 s41.27 cu92.51 cs13.68 - .678% CPU load + 2.65 requests/sec - 6.5 kB/second - 2521 B/request + 127 requests currently being processed, 59 idle servers +W_WWWW_WW.WWKKWK__W._WW_.WK._KK._..K.WW__WK_WW_WWWK_.__WWW_W.WWW +__..__W._W__WWWWWW._WKWW_W_KKW_WWW___K_.WKWW__KWWWWW_WWWWKKKWW.W +__.WK_WW.W_W_WWWW_KWWWWW_KW.WW.W__W_W___W___WWWKW__W_W._.WWW.WWK +W___WKKW.K_W.W...KW....WW_...................................... +................................................................ +................................................................ +................................................................ +................................................................ +................................................................ +................................................................ +................................................................ +................................................................ +................................................................ +................................................................ +................................................................ +................................................................ + + Scoreboard Key: + "_" Waiting for Connection, "S" Starting up, "R" Reading Request, + "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup, + "L" Logging, "G" Gracefully finishing, "." Open slot with no current + process + +--------------090706020804040907080407 +Content-Type: text/plain; + name="pg_load.txt" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline; + filename="pg_load.txt" + +martin@io ~$ vmstat + procs memory page disks faults cpu + r b w avm fre flt re pi po fr sr ad4 ad6 in sy cs us sy id + 0 0 0 498532 122848 3306 0 0 0 740 0 0 0 788 0 1675 16 21 63 + +martin@io ~$ pstat -s +Device 1K-blocks Used Avail Capacity +/dev/ar0s1b 4194304 24 4194280 0% + +martin@io ~$ iostat + tty ad4 ad6 ar0 cpu + tin tout KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s us ni sy in id + 0 17 0.50 0 0.00 0.50 0 0.00 20.28 23 0.45 16 0 20 1 63 + +martin@io ~# ps -U postgres | wc -l + 127 + + +martin@io ~$ ps -uax +USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND +postgres 32084 0.0 0.2 91616 3764 p0- R Mon12PM 4:08.99 /usr/local/bin/postmaster -D /var/postgres (postgres) +postgres 80333 0.0 2.1 94620 44372 ?? S 8:57PM 0:01.00 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 80599 0.0 2.1 94652 44780 ?? S 8:59PM 0:00.97 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 80616 0.0 2.4 94424 50396 ?? S 8:59PM 0:00.89 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 80715 0.0 2.2 94444 46804 ?? S 9:00PM 0:00.68 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 80788 0.0 2.1 94424 43944 ?? S 9:00PM 0:00.93 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 80811 0.0 2.1 94424 43884 ?? S 9:00PM 0:00.94 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 80902 0.0 2.1 94424 43380 ?? S 9:01PM 0:00.76 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 80949 0.0 2.2 94424 45248 ?? S 9:01PM 0:00.67 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 81020 0.0 2.1 94424 42924 ?? S 9:02PM 0:00.74 postmaster: ethereal ethereal 192.168.1.6 idle in trans + + +martin@io ~# date +Tue Aug 3 21:28:53 MDT 2004 +martin@io ~$ systat -vmstat + 1 users Load 4.15 3.76 3.54 Aug 3 21:30 + +Mem:KB REAL VIRTUAL VN PAGER SWAP PAGER + Tot Share Tot Share Free in out in out +Act 293708 4120 482092 6736 132204 count +All 1910640 5224 2462084 17060 pages + Interrupts +Proc:r p d s w Csw Trp Sys Int Sof Flt 212 cow 728 total + 5 139 215023802 3112 1078 58023548 397288 wire 100 0: clk + 295304 act 6: fdc0 +59.6%Sys 0.9%Intr 38.9%User 0.0%Nice 0.6%Idl 1151936 inact 128 8: rtc +| | | | | | | | | | 92748 cache 53 10: bge +==============================>>>>>>>>>>>>>>>>>> 39456 free 447 11: em0 + daefr 14: ata +Namei Name-cache Dir-cache 1345 prcfr + Calls hits % hits % react + 2761 2761 100 pdwake + 1111 zfod pdpgs +Disks ad4 ad6 ar0 fd0 1059 ofod intrn +KB/t 0.00 0.00 16.00 0.00 95 %slo-z 204096 buf +tps 0 0 35 0 1587 tfree 591 dirtybuf +MB/s 0.00 0.00 0.54 0.00 120525 desiredvnodes +% busy 0 0 5 0 30131 numvnodes + 22695 freevnodes + +--------------090706020804040907080407 +Content-Type: text/plain; + name="pg_norm.txt" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline; + filename="pg_norm.txt" + + +martin@io ~$ vmstat + procs memory page disks faults cpu + r b w avm fre flt re pi po fr sr ad4 ad6 in sy cs us sy id + 0 0 0 317216 128932 3121 0 0 0 736 0 0 0 789 0 1682 16 21 63 + +martin@io ~$ pstat -s +Device 1K-blocks Used Avail Capacity +/dev/ar0s1b 4194304 24 4194280 0% + +martin@io ~$ iostat + tty ad4 ad6 ar0 cpu + tin tout KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s us ni sy in id + 0 17 0.50 0 0.00 0.50 0 0.00 20.32 23 0.45 16 0 20 1 63 + + +martin@io ~$ ps -U postgres | wc -l + 72 + + +martin@io ~$ ps -uax +USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND +postgres 32084 0.0 0.2 91616 3764 p0- S Mon12PM 3:17.42 /usr/local/bin/postmaster -D /var/postgres (postgres) +postgres 51100 0.0 1.7 94412 35828 ?? S 3:36PM 0:01.02 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 51134 0.0 1.8 94620 37060 ?? S 3:36PM 0:01.04 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 51147 0.0 1.8 94620 36980 ?? S 3:37PM 0:00.66 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 51240 0.0 1.8 94412 37156 ?? S 3:38PM 0:00.62 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 51276 0.0 0.7 94412 15180 ?? S 3:38PM 0:00.41 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 51277 0.0 1.9 94492 40776 ?? S 3:38PM 0:00.57 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 51287 0.0 1.8 94620 37228 ?? S 3:38PM 0:00.63 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 51368 0.0 1.7 94412 35348 ?? S 3:40PM 0:00.55 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 51493 0.0 1.7 94412 35920 ?? S 3:42PM 0:00.49 postmaster: ethereal ethereal 192.168.1.6 idle in trans +postgres 51495 0.0 1.7 94412 36192 ?? S 3:42PM 0:00.89 postmaster: ethereal ethereal 192.168.1.6 idle in trans + + +martin@io ~$ date +Tue Aug 3 16:09:06 MDT 2004 + +martin@io ~$ systat -vmstat + 1 users Load 0.53 0.54 0.47 Aug 3 16:14 + +Mem:KB REAL VIRTUAL VN PAGER SWAP PAGER + Tot Share Tot Share Free in out in out +Act 205172 4312 326472 6736 120128 count +All 1909516 4944 2215992 11896 pages + Interrupts +Proc:r p d s w Csw Trp Sys Int Sof Flt 197 cow 642 total + 96 177814901 2186 947 20014746 386844 wire 100 0: clk + 206544 act 6: fdc0 +28.8%Sys 0.5%Intr 26.8%User 0.0%Nice 43.9%Idl 1263216 inact 128 8: rtc +| | | | | | | | | | 69644 cache 55 10: bge +==============+>>>>>>>>>>>>> 50484 free 359 11: em0 + daefr 14: ata +Namei Name-cache Dir-cache 1235 prcfr + Calls hits % hits % react + 1709 1709 100 pdwake + 1000 zfod pdpgs +Disks ad4 ad6 ar0 fd0 938 ofod intrn +KB/t 0.00 0.00 16.00 0.00 93 %slo-z 204096 buf +tps 0 0 31 0 1482 tfree 56 dirtybuf +MB/s 0.00 0.00 0.49 0.00 120525 desiredvnodes +% busy 0 0 2 0 30131 numvnodes + 7645 freevnodes + + + + +--------------090706020804040907080407-- + +From pgsql-general-owner@postgresql.org Wed Aug 4 02:36:13 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2FD77D1B17A + for ; + Wed, 4 Aug 2004 02:35:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14425-04 + for ; + Wed, 4 Aug 2004 05:34:23 +0000 (GMT) +Received: from mta2.rdslink.ro (mta2.rdslink.ro [193.231.236.124]) + by svr1.postgresql.org (Postfix) with ESMTP id 60B04D1B1B4 + for ; + Wed, 4 Aug 2004 02:32:48 -0300 (ADT) +Received: (qmail 10695 invoked from network); 4 Aug 2004 08:27:22 -0000 +Received: from unknown (HELO mail.rdslink.ro) (193.231.236.20) + by mta2.rdslink.ro with DES-CBC3-SHA encrypted SMTP; + 4 Aug 2004 08:27:22 -0000 +Received: (qmail 23450 invoked from network); 4 Aug 2004 05:31:44 -0000 +Received: from unknown (HELO ?81.196.83.211?) (81.196.83.211) + by mail.rdslink.ro with SMTP; 4 Aug 2004 05:31:44 -0000 +Subject: Re: [PERFORM] NOT IN query takes forever +From: Marius Andreiana +To: pgsql-general +In-Reply-To: <410FCB3B.5050300@bigfoot.com> +References: <6EE64EF3AB31D5448D0007DD34EEB34101AF1A@Herge.rcsinc.local> + <1091548963.6915.2.camel@marte.biciclete.ro> + <410FCB3B.5050300@bigfoot.com> +Content-Type: text/plain +Organization: Galuna S.R.L. +Date: Wed, 04 Aug 2004 08:40:52 +0300 +Message-Id: <1091598052.2647.7.camel@marte.biciclete.ro> +Mime-Version: 1.0 +X-Mailer: Evolution 1.5.9.1 (1.5.9.1-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200408/73 +X-Sequence-Number: 63628 + +On Tue, 2004-08-03 at 19:28 +0200, Gaetano Mendola wrote: +> > With +> > shared_buffers = 3000 # min 16, at least max_connections*2, 8KB each +> > sort_mem = 128000 # min 64, size in KB +> +> 128 MB for sort_mem is too much, consider that in this way each backend can +> use 128 MB for sort operations... +> Also shared_buffers = 3000 means 24MB that is not balanced with the 128MB +> needed for sort... +> Try to bump up 128 MB for shared_buffer ( may be you need to instruct your +> OS to allow that ammount of shared memory usage ) and 24MB for sort_mem. +Thanks for the advice. I increased shmmax to allow shared_buffers to be +128mb and set sort_mem to 24mb. + +-- +Marius Andreiana +Galuna - Solutii Linux in Romania +http://www.galuna.ro + + +From pgsql-performance-owner@postgresql.org Wed Aug 4 03:39:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BEEFD1B20D + for ; + Wed, 4 Aug 2004 03:39:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32670-01 + for ; + Wed, 4 Aug 2004 06:39:59 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 88994D1B1B6 + for ; + Wed, 4 Aug 2004 03:39:50 -0300 (ADT) +Received: (qmail 23408 invoked from network); 4 Aug 2004 08:39:57 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 4 Aug 2004 08:39:57 +0200 +Date: Wed, 04 Aug 2004 08:40:41 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Performance Bottleneck +References: <410FDC53.5080509@bigfoot.com> + +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: +User-Agent: Opera M2/7.50 (Linux, build 673) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/43 +X-Sequence-Number: 7679 + + + +> The queries themselves are simple, normally drawing information from one +> table with few conditions or in the most complex cases using joins on +> two table or sub queries. These behave very well and always have, the +> problem is that these queries take place in rather large amounts due to +> the dumb nature of the scripts themselves. + + Hum, maybe this "dumb" thing is where to look at ? + + I'm no expert, but I have had the same situation with a very dump PHP +application, namely osCommerce, which averaged about 140 (!!!!!) queries +on a page ! + + I added some traces to queries, and some logging, only to see that the +stupid programmers did something like (pseudo code): + + for id in id_list: + select stuff from database where id=id + + Geee... + + I replaced it by : + + select stuff from database where id in (id_list) + + And this saved about 20 requests... The code was peppered by queries like +that. In the end it went from 140 queries to about 20, which is still way +too much IMHO, but I couldn't go lower without an extensive rewrite. + + If you have a script making many selects, it's worth grouping them, even +using stored procedures. + + For instance using the classical "tree in a table" to store a tree of +product categories : + +create table categories +( + id serial primary key, + parent_id references categories(id), + etc +); + + You basically have these choices in order to display the tree : + + - select for parent_id=0 (root) + - for each element, select its children + - and so on + + OR + + - make a stored procedure which does that. At least 3x faster and a lot +less CPU overhead. + + OR (if you have say 50 rows in the table which was my case) + + - select the entire table and build your tree in the script + It was a little bit faster than the stored procedure. + + Could you give an example of your dumb scripts ? It's good to optimize a +database, but it's even better to remove useless queries... + + + + + + + + + + + + +From pgsql-general-owner@postgresql.org Wed Aug 4 09:00:53 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 07F78D1B34A + for ; + Wed, 4 Aug 2004 09:00:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12765-06 + for ; + Wed, 4 Aug 2004 12:00:52 +0000 (GMT) +Received: from thor.netera.se (thor.netera.se [62.13.47.20]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BC2CD1B257 + for ; + Wed, 4 Aug 2004 09:00:42 -0300 (ADT) +Received: from [127.0.0.1] (unknown [213.212.22.34]) + by thor.netera.se (Postfix) with ESMTP id 6895E13AC050 + for ; + Wed, 4 Aug 2004 14:00:49 +0200 (CEST) +Message-ID: <4110CFE7.9000202@relevanttraffic.se> +Date: Wed, 04 Aug 2004 14:00:39 +0200 +From: Ulrich Wisser +Organization: Relevant Traffic AB +User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-general@postgresql.org +Subject: How to know which queries are to be optimised? +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/77 +X-Sequence-Number: 63632 + +Hello, + +my web application grows slower and slower over time. After some +profiling I came to the conclusion that my SQL queries are the biggest +time spenders (25 seconds). Obviously I need to optimise my queries and +maybe introduce some new indexes. + +The problem is, that my application uses dynamic queries. I therefor can +not determine what are the most common queries. + +I have used the postgresql logging ption before. Is there a tool to +analyze the logfile for the most common and/or most time consuming queries? + +TIA + +Ulrich + + +From pgsql-general-owner@postgresql.org Wed Aug 4 09:43:48 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 10DA0D1B1DF; + Wed, 4 Aug 2004 09:43:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23074-10; Wed, 4 Aug 2004 12:43:48 +0000 (GMT) +Received: from cadillac.meteo.fr (cadillac.meteo.fr [137.129.1.4]) + by svr1.postgresql.org (Postfix) with ESMTP id 246DFD1B199; + Wed, 4 Aug 2004 09:43:37 -0300 (ADT) +Received: from mu.meteo.fr (localhost.meteo.fr [127.0.0.1]) + by cadillac.meteo.fr (8.9.3 (PHNE_28760_binary)/8.9.3) with ESMTP id + MAA07445; Wed, 4 Aug 2004 12:43:45 GMT +Received: from mu.meteo.fr (mu.meteo.fr [137.129.6.129]) + by mu.meteo.fr (8.11.7p1+Sun/8.11.7) with SMTP id i74CihO19344; + Wed, 4 Aug 2004 12:44:43 GMT +Message-Id: <200408041244.i74CihO19344@mu.meteo.fr> +Date: Wed, 4 Aug 2004 12:44:43 +0000 (GMT) +From: Valerie Schneider DSI/DEV +Reply-To: Valerie Schneider DSI/DEV +Subject: Tuning queries on large database +To: pgsql-performance@postgresql.org, pgsql-general@postgresql.org +Cc: Valerie.Schneider@meteo.fr +MIME-Version: 1.0 +Content-Type: TEXT/plain; charset=us-ascii +Content-MD5: 0bPv2QX/0e63cdvamEjQDA== +X-Mailer: dtmail 1.3.0 @(#)CDE Version 1.4.6_06 SunOS 5.8 sun4u sparc +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/80 +X-Sequence-Number: 63635 + +Hi, + +I have some problem of performance on a PG database, and I don't +know how to improve. I Have two questions : one about the storage +of data, one about tuning queries. If possible ! + +My job is to compare Oracle and Postgres. All our operational databases +have been running under Oracle for about fifteen years. Now I try to replace +Oracle by Postgres. + +I have a test platform under linux (Dell server, 4 Gb RAM, bi-processor, +Linux Red Hat 9 (2.4.20-31.9)) with 2 databases, 1 with Oracle +(V8i or V9i it's quite the same), 1 with PG (7.4.2). Both databases +have the same structure, same content, about 100 Gb each. I developped +some benches, representative of our use of databases. My problem +is that I have tables (relations) with more than 100 millions rows, +and each row has about 160 fields and an average size 256 bytes. + +For Oracle I have a SGA size of 500 Mb. +For PG I have a postgresql.conf as : + max_connections = 1500 + shared_buffers = 30000 + sort_mem = 50000 + effective_cache_size = 200000 +and default value for other parameters. + +I have a table named "data" which looks like this : +bench=> \d data + Table "public.data" + Column | Type | Modifiers +------------+-----------------------------+----------- + num_poste | numeric(9,0) | not null + dat | timestamp without time zone | not null + datrecu | timestamp without time zone | not null + rr1 | numeric(5,1) | + qrr1 | numeric(2,0) | ... + ... all numeric fields + ... + Indexes: + "pk_data" primary key, btree (num_poste, dat) + "i_data_dat" btree (dat) + +It contains 1000 different values of "num_poste" and for each one +125000 different values of "dat" (1 row per hour, 15 years). + +I run a vacuum analyze of the table. + +bench=> select * from tailledb ; + schema | relfilenode | table | index | reltuples | size +--------+-------------+------------------+------------+-------------+---------- + public | 125615917 | data | | 1.25113e+08 | 72312040 + public | 251139049 | data | i_data_dat | 1.25113e+08 | 2744400 + public | 250870177 | data | pk_data | 1.25113e+08 | 4395480 + +My first remark is that the table takes a lot of place on disk, about +70 Gb, instead of 35 Gb with oracle. +125 000 000 rows x 256 b = about 32 Gb. This calculation gives an idea +not so bad for oracle. What about for PG ? How data is stored ? + + +The different queries of the bench are "simple" queries (no join, +sub-query, ...) and are using indexes (I "explained" each one to +be sure) : +Q1 select_court : access to about 700 rows : 1 "num_poste" and 1 month + (using PK : num_poste=p1 and dat between p2 and p3) +Q2 select_moy : access to about 7000 rows : 10 "num_poste" and 1 month + (using PK : num_poste between p1 and p1+10 and dat between p2 and p3) +Q3 select_long : about 250 000 rows : 2 "num_poste" + (using PK : num_poste in (p1,p1+2)) +Q4 select_tres_long : about 3 millions rows : 25 "num_poste" + (using PK : num_poste between p1 and p1 + 25) + +The result is that for "short queries" (Q1 and Q2) it runs in a few +seconds on both Oracle and PG. The difference becomes important with +Q3 : 8 seconds with oracle + 80 sec with PG +and too much with Q4 : 28s with oracle + 17m20s with PG ! + +Of course when I run 100 or 1000 parallel queries such as Q3 or Q4, +it becomes a disaster ! +I can't understand these results. The way to execute queries is the +same I think. I've read recommended articles on the PG site. +I tried with a table containing 30 millions rows, results are similar. + +What can I do ? + +Thanks for your help ! + +******************************************************************** +* Les points de vue exprimes sont strictement personnels et * +* n'engagent pas la responsabilite de METEO-FRANCE. * +******************************************************************** +* Valerie SCHNEIDER Tel : +33 (0)5 61 07 81 91 * +* METEO-FRANCE / DSI/DEV Fax : +33 (0)5 61 07 81 09 * +* 42, avenue G. Coriolis Email : Valerie.Schneider@meteo.fr * +* 31057 TOULOUSE Cedex - FRANCE http://www.meteo.fr * +******************************************************************** + + +From pgsql-performance-owner@postgresql.org Wed Aug 4 09:46:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C02BD1B385 + for ; + Wed, 4 Aug 2004 09:45:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27220-02 + for ; + Wed, 4 Aug 2004 12:46:04 +0000 (GMT) +Received: from mail.clockltd.com (unknown [213.219.6.249]) + by svr1.postgresql.org (Postfix) with ESMTP id D9967D1B37D + for ; + Wed, 4 Aug 2004 09:45:53 -0300 (ADT) +Received: from [193.195.120.35] (helo=[10.0.0.113]) + by mail.clockltd.com with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) + (Exim 4.34) id 1BsL9X-0004St-4t + for pgsql-performance@postgresql.org; Wed, 04 Aug 2004 13:45:55 +0100 +Message-ID: <4110DA83.7020505@clockltd.com> +Date: Wed, 04 Aug 2004 13:45:55 +0100 +From: Paul Serby +Organization: Clock +User-Agent: Mozilla Thunderbird 0.7.1 (X11/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: The black art of postgresql.conf tweaking +X-Enigmail-Version: 0.84.2.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Clock-Relay: yes +X-Clock-MailScanner-Information: Please contact the ISP for more information +X-Clock-MailScanner: Found to be clean +X-Clock-MailScanner-SpamCheck: not spam, SpamAssassin (score=0, required 5, + autolearn=not spam) +X-MailScanner-From: paul.serby@clockltd.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/45 +X-Sequence-Number: 7681 + +Can anyone give a good reference site/book for getting the most out of +your postgres server. + +All I can find is contradicting theories on how to work out your settings. + +This is what I followed to setup our db server that serves our web +applications. + +http://www.phpbuilder.com/columns/smith20010821.php3?page=2 + +We have a Dell Poweredge with the following spec. + +CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +Physical Memory: 2077264 kB +Swap Memory: 2048244 kB + +Apache on the Web server can take up to 300 connections and PHP is using + pg_pconnect + +Postgres is set with the following. + +max_connections = 300 +shared_buffers = 38400 +sort_mem = 12000 + +But Apache is still maxing out the non-super user connection limit. + +The machine is under no load and I would like to up the max_connections +but I would like to know more about what you need to consider before +doing so. + +The only other source I've found is this: + +http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html + +But following its method my postgres server locks up straight away as it +recommends setting max_connections to 16 for Web sites? + +Is there a scientific method for optimizing postgres or is it all +'finger in the air' and trial and error. + +From pgsql-performance-owner@postgresql.org Wed Aug 4 10:01:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 25054D1B285 + for ; + Wed, 4 Aug 2004 10:01:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32305-01 + for ; + Wed, 4 Aug 2004 13:01:28 +0000 (GMT) +Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.85]) + by svr1.postgresql.org (Postfix) with ESMTP id 96138D1B257 + for ; + Wed, 4 Aug 2004 10:01:15 -0300 (ADT) +Received: from jefftrout.com ([24.128.241.68]) + by comcast.net (rwcrmhc12) with SMTP + id <2004080413012301400s92rve>; Wed, 4 Aug 2004 13:01:24 +0000 +Received: (qmail 52506 invoked from network); 4 Aug 2004 13:01:23 -0000 +Received: from unknown (HELO ?192.168.0.101?) (10.10.10.20) + by 10.10.10.10 with SMTP; 4 Aug 2004 13:01:23 -0000 +In-Reply-To: <4110DA83.7020505@clockltd.com> +References: <4110DA83.7020505@clockltd.com> +Mime-Version: 1.0 (Apple Message framework v618) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <85562EA8-E616-11D8-A77F-000393D1F76E@torgo.978.org> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Jeff +Subject: Re: The black art of postgresql.conf tweaking +Date: Wed, 4 Aug 2004 09:02:20 -0400 +To: Paul Serby +X-Mailer: Apple Mail (2.618) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/46 +X-Sequence-Number: 7682 + + +On Aug 4, 2004, at 8:45 AM, Paul Serby wrote: +> +> Apache on the Web server can take up to 300 connections and PHP is +> using pg_pconnect +> +> Postgres is set with the following. +> +> max_connections = 300 +> shared_buffers = 38400 +> sort_mem = 12000 +> +> But Apache is still maxing out the non-super user connection limit. +> + +Did you restart PG after making that change? +(you need to restart, reload won't change max_connections) + +Also, you're sort_mem is likely too high (That is the amount of memory +that can be used PER SORT) and you s hould back down on shared_buffers. +(General consensus is don't go over 10k shared buffers) + +Another thing you may want to try is using pgpool and regular +pg_connect - this way you only have a pool of say, 32 connections to +the DB that are shared among all apache instances. This gets rid of +the need to have hundreds of idle postgres' sitting around. +Connecting to pgpool is very fast. We use it in production here and it +works wonderfully. And it is 100% transparent to your application. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Wed Aug 4 10:10:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 94B46D1B34A + for ; + Wed, 4 Aug 2004 10:10:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32590-03 + for ; + Wed, 4 Aug 2004 13:10:46 +0000 (GMT) +Received: from mx.mall.cz (mx.mall.cz [62.168.45.106]) + by svr1.postgresql.org (Postfix) with ESMTP id 86B67D1B1DF + for ; + Wed, 4 Aug 2004 10:10:35 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mx.mall.cz (Postfix) with ESMTP + id 2A9A04810E; Wed, 4 Aug 2004 15:10:43 +0200 (CEST) +Received: from mx.mall.cz ([127.0.0.1]) + by localhost (posta [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 28620-01; Wed, 4 Aug 2004 15:10:34 +0200 (CEST) +Message-ID: <4110E05F.9030404@taborsky.cz> +Date: Wed, 04 Aug 2004 15:10:55 +0200 +From: Michal Taborsky +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Paul Serby +Cc: pgsql-performance@postgresql.org +Subject: Re: The black art of postgresql.conf tweaking +References: <4110DA83.7020505@clockltd.com> +In-Reply-To: <4110DA83.7020505@clockltd.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/47 +X-Sequence-Number: 7683 + +Paul Serby wrote: + +> Apache on the Web server can take up to 300 connections and PHP is using +> pg_pconnect + +> max_connections = 300 +> But Apache is still maxing out the non-super user connection limit. + +Don't forget also that some connections are reserved for superusers +(usually 2), so if you want 300 users, you need to set max_connections +to 300 + superuser_reserved_connections. + +-- +Michal Taborsky +http://www.taborsky.cz + + +From pgsql-general-owner@postgresql.org Wed Aug 4 10:22:02 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 09386D1B1A1; + Wed, 4 Aug 2004 10:22:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36664-01; Wed, 4 Aug 2004 13:22:05 +0000 (GMT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E445D1B257; + Wed, 4 Aug 2004 10:21:52 -0300 (ADT) +Received: from houston.familyhealth.com.au (chriskl@localhost [127.0.0.1]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i74DLpUi006535; Wed, 4 Aug 2004 21:21:51 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Received: from localhost (chriskl@localhost) + by houston.familyhealth.com.au (8.12.9p1/8.12.9/Submit) with ESMTP id + i74DLpqC006532; Wed, 4 Aug 2004 21:21:51 +0800 (WST) +X-Authentication-Warning: houston.familyhealth.com.au: chriskl owned process + doing -bs +Date: Wed, 4 Aug 2004 21:21:51 +0800 (WST) +From: Christopher Kings-Lynne +To: Valerie Schneider DSI/DEV +Cc: pgsql-performance@postgresql.org, +Subject: Re: [PERFORM] Tuning queries on large database +In-Reply-To: <200408041244.i74CihO19344@mu.meteo.fr> +Message-ID: <20040804211849.L3435-100000@houston.familyhealth.com.au> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/83 +X-Sequence-Number: 63638 + +> sort_mem = 50000 + +That is way, way too large. Try more like 5000 or lower. + +> num_poste | numeric(9,0) | not null + +For starters numerics are really, really slow compared to integers. Why +aren't you using an integer for this field since youhave '0' decimal +places. + +> schema | relfilenode | table | index | reltuples | size +> --------+-------------+------------------+------------+-------------+---------- +> public | 125615917 | data | | 1.25113e+08 | 72312040 +> public | 251139049 | data | i_data_dat | 1.25113e+08 | 2744400 +> public | 250870177 | data | pk_data | 1.25113e+08 | 4395480 +> +> My first remark is that the table takes a lot of place on disk, about +> 70 Gb, instead of 35 Gb with oracle. + +Integers will take a lot less space than numerics. + +> The different queries of the bench are "simple" queries (no join, +> sub-query, ...) and are using indexes (I "explained" each one to +> be sure) : +> Q1 select_court : access to about 700 rows : 1 "num_poste" and 1 month +> (using PK : num_poste=p1 and dat between p2 and p3) +> Q2 select_moy : access to about 7000 rows : 10 "num_poste" and 1 month +> (using PK : num_poste between p1 and p1+10 and dat between p2 and p3) +> Q3 select_long : about 250 000 rows : 2 "num_poste" +> (using PK : num_poste in (p1,p1+2)) +> Q4 select_tres_long : about 3 millions rows : 25 "num_poste" +> (using PK : num_poste between p1 and p1 + 25) +> +> The result is that for "short queries" (Q1 and Q2) it runs in a few +> seconds on both Oracle and PG. The difference becomes important with +> Q3 : 8 seconds with oracle +> 80 sec with PG +> and too much with Q4 : 28s with oracle +> 17m20s with PG ! +> +> Of course when I run 100 or 1000 parallel queries such as Q3 or Q4, +> it becomes a disaster ! + +Please reply with the EXPLAIN ANALYZE output of these queries so we can +have some idea of how to help you. + +Chris + + + +From pgsql-performance-owner@postgresql.org Wed Aug 4 10:30:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C15BBD1B1AE + for ; + Wed, 4 Aug 2004 10:30:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38664-02 + for ; + Wed, 4 Aug 2004 13:30:21 +0000 (GMT) +Received: from pw6tiger.de (pw6tiger.de [217.160.140.116]) + by svr1.postgresql.org (Postfix) with SMTP id 4699CD1B1A1 + for ; + Wed, 4 Aug 2004 10:30:08 -0300 (ADT) +Received: (qmail 22959 invoked by uid 505); 4 Aug 2004 13:29:51 -0000 +Received: from vygen@gmx.de by planwerk6 by uid 89 with qmail-scanner-1.14 + (virus scan: Clear:. + Processed in 0.238747 secs); 04 Aug 2004 13:29:51 -0000 +Received: from isi-dial-153-153.isionline-dialin.de (HELO ?192.168.1.10?) + (vygen@planwerk6.de@195.158.153.153) + by pw6tiger.de with SMTP; 4 Aug 2004 13:29:51 -0000 +From: Janning Vygen +To: pgsql-performance@postgresql.org +Subject: Re: The black art of postgresql.conf tweaking +Date: Wed, 4 Aug 2004 15:26:30 +0200 +User-Agent: KMail/1.6.2 +Cc: Paul Serby +References: <4110DA83.7020505@clockltd.com> +In-Reply-To: <4110DA83.7020505@clockltd.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200408041526.30460.vygen@gmx.de> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/50 +X-Sequence-Number: 7686 + +Am Mittwoch, 4. August 2004 14:45 schrieb Paul Serby: +> Apache on the Web server can take up to 300 connections and PHP is using +> pg_pconnect +> +> Postgres is set with the following. +> +> max_connections = 300 +> shared_buffers = 38400 +> sort_mem = 12000 +> +> But Apache is still maxing out the non-super user connection limit. + +for most websites 300 connections is far too much (imagine even 10 request per +second for 10 hours a day ends up to 10.8 Mio pages a month) + +but anyway: you should first focus on closing your http connection to the user +as fast as possible. then you dont need so much concurrent connections which +keep db connections open and uses memory. + +I did the following: +- apache: keepalive off +- apache patch: lingerd (google for it) +- apache mod_gzip +- pg_pconnect + +this keeps your http connection as short as possible, so the apache child is +ready to serve the next client. + +Imagine 5 seconds of keepalive 1 second on lingering half-closed tcp +connections and 4 more seconds for transport of uncompressed content. + +in this scenario your apache child uses memory an your pooled db connection +for 10 seconds while doing nothing! + +in my experience apache in standard configuration can be the main bottleneck. +and teh combination of keepalive off, lingerd and mod_gzip is GREAT and i +didn't found much sites propagating a configuration like this. + +kind regards, +janning + +p.s: sorry for being slightly off topic and talking about apache but when it +comes to performance it is always important to look at the complete system. + +From pgsql-performance-owner@postgresql.org Wed Aug 4 10:26:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E261D1B192 + for ; + Wed, 4 Aug 2004 10:26:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38701-01 + for ; + Wed, 4 Aug 2004 13:26:46 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EBAC4D1B1C8 + for ; + Wed, 4 Aug 2004 10:26:35 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id 5D66276B36; Wed, 4 Aug 2004 09:26:45 -0400 (EDT) +Subject: Re: Tuning queries on large database +From: Rod Taylor +To: Valerie Schneider DSI/DEV +Cc: Postgresql Performance +In-Reply-To: <200408041244.i74CihO19344@mu.meteo.fr> +References: <200408041244.i74CihO19344@mu.meteo.fr> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-nHPhfWiYy5OOuJH9qNB8" +Message-Id: <1091625999.58593.47.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 04 Aug 2004 09:26:42 -0400 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/49 +X-Sequence-Number: 7685 + +--=-nHPhfWiYy5OOuJH9qNB8 +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Wed, 2004-08-04 at 08:44, Valerie Schneider DSI/DEV wrote: +> Hi, +>=20 +> I have some problem of performance on a PG database, and I don't +> know how to improve. I Have two questions : one about the storage +> of data, one about tuning queries. If possible ! +>=20 +> My job is to compare Oracle and Postgres. All our operational databases +> have been running under Oracle for about fifteen years. Now I try to repl= +ace +> Oracle by Postgres. + +You may assume some additional hardware may be required -- this would be +purchased out of the Oracle License budget :) + +> My first remark is that the table takes a lot of place on disk, about +> 70 Gb, instead of 35 Gb with oracle. +> 125 000 000 rows x 256 b =3D about 32 Gb. This calculation gives an idea +> not so bad for oracle. What about for PG ? How data is stored ? + +This is due to the datatype you've selected. PostgreSQL does not convert +NUMERIC into a more appropriate integer format behind the scenes, nor +will it use the faster routines for the math when it is an integer. +Currently it makes the assumption that if you've asked for numeric +rather than integer or float that you are dealing with either large +numbers or require high precision math. + +Changing most of your columns to integer + Check constraint (where +necessary) will give you a large speed boost and reduce disk +requirements a little. + +> The different queries of the bench are "simple" queries (no join, +> sub-query, ...) and are using indexes (I "explained" each one to +> be sure) : + +Care to send us the EXPLAIN ANALYZE output for each of the 4 queries +after you've improved the datatype selection? + +--=20 +Rod Taylor + +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL +PGP Key: http://www.rbt.ca/signature.asc + +--=-nHPhfWiYy5OOuJH9qNB8 +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (FreeBSD) + +iD8DBQBBEOQO6DETLow6vwwRAll7AJ0WFK5XCtJMKSB2/0k2bgp5pxpCDACfXmZO +i6ic30tZ+P81wrwzyP49E6E= +=CuEp +-----END PGP SIGNATURE----- + +--=-nHPhfWiYy5OOuJH9qNB8-- + + +From pgsql-performance-owner@postgresql.org Wed Aug 4 10:44:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 30E15D1B1A1 + for ; + Wed, 4 Aug 2004 10:44:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42070-04 + for ; + Wed, 4 Aug 2004 13:44:12 +0000 (GMT) +Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net + [194.217.242.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C158D1B17B + for ; + Wed, 4 Aug 2004 10:44:02 -0300 (ADT) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BsM3v-000CNx-0b + for pgsql-performance@postgresql.org; Wed, 04 Aug 2004 13:44:11 +0000 +Date: Wed, 4 Aug 2004 14:44:08 +0100 +From: Paul Thomas +To: "pgsql-performance @ postgresql . org" +Subject: Re: The black art of postgresql.conf tweaking +Message-ID: <20040804144408.A17081@bacon> +References: <4110DA83.7020505@clockltd.com> +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: <4110DA83.7020505@clockltd.com>; + from paul.serby@clockltd.com on Wed, Aug 04, 2004 at 13:45:55 + +0100 +X-Mailer: Balsa 1.2.3 +Lines: 87 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/51 +X-Sequence-Number: 7687 + + +On 04/08/2004 13:45 Paul Serby wrote: +> Can anyone give a good reference site/book for getting the most out of +> your postgres server. +> +> All I can find is contradicting theories on how to work out your +> settings. +> +> This is what I followed to setup our db server that serves our web +> applications. +> +> http://www.phpbuilder.com/columns/smith20010821.php3?page=2 +> +> We have a Dell Poweredge with the following spec. +> +> CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +> CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +> CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +> CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +> Physical Memory: 2077264 kB +> Swap Memory: 2048244 kB +> +> Apache on the Web server can take up to 300 connections and PHP is +> using pg_pconnect +> +> Postgres is set with the following. +> +> max_connections = 300 +> shared_buffers = 38400 + +Might be higher that neccessary. Some people reckon that there's no +measurable performance going above ~10,000 buffers + + +> sort_mem = 12000 + +Do you really need 12MB of sort memory? Remember that this is per +connection so you could end up with 300x that being allocated in a worst +case scenario. + +> +> But Apache is still maxing out the non-super user connection limit. +> +> The machine is under no load and I would like to up the max_connections +> but I would like to know more about what you need to consider before +> doing so. + +I can't think why you should be maxing out when under no load. Maybe you +need to investigate this further. + +> +> The only other source I've found is this: +> +> http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html +> +> But following its method my postgres server locks up straight away as it +> recommends setting max_connections to 16 for Web sites? + +I think you've mis-interpreted that. She's talking about using persistent +connections - i.e., connection pooling. + +> +> Is there a scientific method for optimizing postgres or is it all +> 'finger in the air' and trial and error. + +Posting more details of the queries which are giving the performance +problems will enable people to help you. You're vacuum/analyzing regularly +of course ;) People will want to know: + +- PostgreSQL version +- hardware configuration (SCSI or IDE? RAID level?) +- table schemas +- queries together with EXPLAIN ANALYZE output + + +also output from utils like vmstat, top etc may be of use. + +HTH + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Wed Aug 4 11:11:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3AAE8D1B37D + for ; + Wed, 4 Aug 2004 11:11:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50052-04 + for ; + Wed, 4 Aug 2004 14:11:39 +0000 (GMT) +Received: from cadillac.meteo.fr (cadillac.meteo.fr [137.129.1.4]) + by svr1.postgresql.org (Postfix) with ESMTP id A3CB5D1B285 + for ; + Wed, 4 Aug 2004 11:11:27 -0300 (ADT) +Received: from mu.meteo.fr (localhost.meteo.fr [127.0.0.1]) + by cadillac.meteo.fr (8.9.3 (PHNE_28760_binary)/8.9.3) with ESMTP id + OAA13874 + for ; Wed, 4 Aug 2004 14:11:36 GMT +Received: from mu.meteo.fr (mu.meteo.fr [137.129.6.129]) + by mu.meteo.fr (8.11.7p1+Sun/8.11.7) with SMTP id i74ECYO19577 + for ; Wed, 4 Aug 2004 14:12:34 GMT +Message-Id: <200408041412.i74ECYO19577@mu.meteo.fr> +Date: Wed, 4 Aug 2004 14:12:34 +0000 (GMT) +From: Valerie Schneider DSI/DEV +Reply-To: Valerie Schneider DSI/DEV +Subject: Re: Tuning queries on large database +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: TEXT/plain; charset=us-ascii +Content-MD5: 91AJxcJfxQX3viRBZc6njg== +X-Mailer: dtmail 1.3.0 @(#)CDE Version 1.4.6_06 SunOS 5.8 sun4u sparc +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/52 +X-Sequence-Number: 7688 + + +>X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +>X-Authentication-Warning: houston.familyhealth.com.au: chriskl owned process +doing -bs +>Date: Wed, 4 Aug 2004 21:21:51 +0800 (WST) +>From: Christopher Kings-Lynne +>To: Valerie Schneider DSI/DEV +>Cc: pgsql-performance@postgresql.org, +>Subject: Re: [PERFORM] Tuning queries on large database +>MIME-Version: 1.0 +>X-Virus-Scanned: by amavisd-new at hub.org +>X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +>X-Spam-Level: +>X-Mailing-List: pgsql-performance +> +>> sort_mem = 50000 +> +>That is way, way too large. Try more like 5000 or lower. +> +>> num_poste | numeric(9,0) | not null +> +>For starters numerics are really, really slow compared to integers. Why +>aren't you using an integer for this field since youhave '0' decimal +>places. +> +>> schema | relfilenode | table | index | reltuples | size +>> +--------+-------------+------------------+------------+-------------+---------- +>> public | 125615917 | data | | 1.25113e+08 | +72312040 +>> public | 251139049 | data | i_data_dat | 1.25113e+08 | +2744400 +>> public | 250870177 | data | pk_data | 1.25113e+08 | +4395480 +>> +>> My first remark is that the table takes a lot of place on disk, about +>> 70 Gb, instead of 35 Gb with oracle. +> +>Integers will take a lot less space than numerics. +> +>> The different queries of the bench are "simple" queries (no join, +>> sub-query, ...) and are using indexes (I "explained" each one to +>> be sure) : +>> Q1 select_court : access to about 700 rows : 1 "num_poste" and 1 month +>> (using PK : num_poste=p1 and dat between p2 and p3) +>> Q2 select_moy : access to about 7000 rows : 10 "num_poste" and 1 month +>> (using PK : num_poste between p1 and p1+10 and dat between p2 and p3) +>> Q3 select_long : about 250 000 rows : 2 "num_poste" +>> (using PK : num_poste in (p1,p1+2)) +>> Q4 select_tres_long : about 3 millions rows : 25 "num_poste" +>> (using PK : num_poste between p1 and p1 + 25) +>> +>> The result is that for "short queries" (Q1 and Q2) it runs in a few +>> seconds on both Oracle and PG. The difference becomes important with +>> Q3 : 8 seconds with oracle +>> 80 sec with PG +>> and too much with Q4 : 28s with oracle +>> 17m20s with PG ! +>> +>> Of course when I run 100 or 1000 parallel queries such as Q3 or Q4, +>> it becomes a disaster ! +> +>Please reply with the EXPLAIN ANALYZE output of these queries so we can +>have some idea of how to help you. +> +>Chris +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 4: Don't 'kill -9' the postmaster + +Q1 : +bench=> explain analyze select 'Q1',min(td),max(u) from data where +num_poste=1000 and dat between +(date_trunc('month',to_timestamp('31012004','ddmmyyyy')-interval '2000 +days'))::timestamp and +(date_trunc('month',to_timestamp('31012004','ddmmyyyy')-interval '2000 days') + +interval '1 month' - interval '1 hour')::timestamp; + + + QUERY PLAN +-------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- +---------------------------------------------------------------------- + Aggregate (cost=2501.90..2501.90 rows=1 width=21) (actual +time=581.460..581.461 rows=1 loops=1) + -> Index Scan using pk_data on data (cost=0.00..2498.80 rows=619 width=21) +(actual time=92.986..579.089 rows=744 loops=1) + Index Cond: ((num_poste = 1000::numeric) AND (dat >= +(date_trunc('month'::text, (to_timestamp('31012004'::text, 'ddmmyyyy'::text) - +'2000 days'::interval)))::timestamp without time zone) AND (dat <= +(((date_trunc('month'::text, (to_timestamp('31012004'::text, 'ddmmyyyy'::text) - +'2000 days'::interval)) + '1 mon'::interval) - '01:00:00'::interval))::timestamp +without time zone)) + Total runtime: 609.149 ms +(4 rows) + + +Q2 : +bench=> explain analyze select 'Q2',count(*) from data where num_poste between +100 and 100+10 and dat between +(date_trunc('month',to_timestamp('31012004','ddmmyyyy')-interval '3000 +days'))::timestamp and +(date_trunc('month',to_timestamp('31012004','ddmmyyyy')-interval '3000 days') + +interval '1 month' - interval '1 hour')::timestamp; + + + QUERY PLAN +-------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- +---------------------- + Aggregate (cost=23232.05..23232.05 rows=1 width=0) (actual +time=5678.849..5678.850 rows=1 loops=1) + -> Index Scan using pk_data on data (cost=0.00..23217.68 rows=5747 width=0) +(actual time=44.408..5669.387 rows=7920 loops=1) + Index Cond: ((num_poste >= 100::numeric) AND (num_poste <= +110::numeric) AND (dat >= (date_trunc('month'::text, +(to_timestamp('31012004'::text, 'ddmmyyyy'::text) - '3000 +days'::interval)))::timestamp without time zone) AND (dat <= +(((date_trunc('month'::text, (to_timestamp('31012004'::text, 'ddmmyyyy'::text) - +'3000 days'::interval)) + '1 mon'::interval) - '01:00:00'::interval))::timestamp +without time zone)) + Total runtime: 5679.059 ms +(4 rows) + + +Q3 : +bench=> explain analyze select 'Q3',sum(rr1),count(ff) from data where num_poste +in (50,50+2); + QUERY PLAN +-------------------------------------------------------------------------------- +------------------------------------------------------------------ + Aggregate (cost=986770.56..986770.56 rows=1 width=17) (actual +time=75401.030..75401.031 rows=1 loops=1) + -> Index Scan using pk_data, pk_data on data (cost=0.00..985534.43 +rows=247225 width=17) (actual time=35.823..74885.689 rows=250226 loops=1) + Index Cond: ((num_poste = 50::numeric) OR (num_poste = 52::numeric)) + Total runtime: 75405.666 ms +(4 rows) + + +Q4 : +bench=> explain analyze select 'Q4',count(*) from data where num_poste between +600 and 625; + QUERY PLAN +-------------------------------------------------------------------------------- +-------------------------------------------------------------- + Aggregate (cost=12166763.62..12166763.62 rows=1 width=0) (actual +time=1162090.302..1162090.303 rows=1 loops=1) + -> Index Scan using pk_data on data (cost=0.00..12159021.19 rows=3096971 +width=0) (actual time=94.679..1158266.561 rows=3252938 loops=1) + Index Cond: ((num_poste >= 600::numeric) AND (num_poste <= +625::numeric)) + Total runtime: 1162102.217 ms +(4 rows) + + +Now I'm going to recreate my table with integer and real datatype, +and to decrease sort_mem to 5000. +Then I'll try these queries again. +Thanks. + + + +******************************************************************** +* Les points de vue exprimes sont strictement personnels et * +* n'engagent pas la responsabilite de METEO-FRANCE. * +******************************************************************** +* Valerie SCHNEIDER Tel : +33 (0)5 61 07 81 91 * +* METEO-FRANCE / DSI/DEV Fax : +33 (0)5 61 07 81 09 * +* 42, avenue G. Coriolis Email : Valerie.Schneider@meteo.fr * +* 31057 TOULOUSE Cedex - FRANCE http://www.meteo.fr * +******************************************************************** + + +From pgsql-performance-owner@postgresql.org Wed Aug 4 11:51:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 964AFD1B17B + for ; + Wed, 4 Aug 2004 11:51:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61590-02 + for ; + Wed, 4 Aug 2004 14:51:49 +0000 (GMT) +Received: from stubee.d2hosting.net (d2hosting.net [66.70.41.160]) + by svr1.postgresql.org (Postfix) with ESMTP id B94C1D1B1C8 + for ; + Wed, 4 Aug 2004 11:51:37 -0300 (ADT) +Received: from [127.0.0.1] (stubee.d2hosting.net [66.70.41.160]) + by stubee.d2hosting.net (8.11.6/linuxconf) with ESMTP id i74EpJi24735; + Wed, 4 Aug 2004 09:51:19 -0500 +Message-ID: <4110F7E0.4050204@idigx.com> +Date: Wed, 04 Aug 2004 09:51:12 -0500 +From: Thomas Swan +User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Janning Vygen +Cc: pgsql-performance@postgresql.org, + Paul Serby +Subject: Re: The black art of postgresql.conf tweaking +References: <4110DA83.7020505@clockltd.com> <200408041526.30460.vygen@gmx.de> +In-Reply-To: <200408041526.30460.vygen@gmx.de> +X-Enigmail-Version: 0.85.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/53 +X-Sequence-Number: 7689 + +Janning Vygen wrote: + +>Am Mittwoch, 4. August 2004 14:45 schrieb Paul Serby: +> +> +>>Apache on the Web server can take up to 300 connections and PHP is using +>> pg_pconnect +>> +>>Postgres is set with the following. +>> +>>max_connections = 300 +>>shared_buffers = 38400 +>>sort_mem = 12000 +>> +>>But Apache is still maxing out the non-super user connection limit +>> +The number of connections in apache and in postgresql are the keys. + From what you've described, apache can have up to 300 child processes. +If this application uses a different identity or db for different +connects then you may have more than one connection open per process +easily exhausting your available connections. Also, your application +may open multiple connections to postgresql per process. See if +setting max_connections in postgres to a larger works, but you may want +to reduce your sort_mem proportionately to keep from overbooking your +system. + +>for most websites 300 connections is far too much (imagine even 10 request per +>second for 10 hours a day ends up to 10.8 Mio pages a month) +> +>but anyway: you should first focus on closing your http connection to the user +>as fast as possible. then you dont need so much concurrent connections which +>keep db connections open and uses memory. +> +>I did the following: +>- apache: keepalive off +>- apache patch: lingerd (google for it) +>- apache mod_gzip +>- pg_pconnect +> +> +KeepAlive for 2 or 3 seconds is quite sufficient. This keeps the +current number of connections down for those browsers that support it, +and keeps the server from leaving too many open. We found KeepAlive +off caused too many http connections to be opened and closed for our +applications and hardware to keep up. The benefit is facilitating a +rapid succession of requests: page loads, graphics, embedded objects, +frames, etc. + +>p.s: sorry for being slightly off topic and talking about apache but when it +>comes to performance it is always important to look at the complete system. +> +> +Good advice. + +From pgsql-performance-owner@postgresql.org Fri Aug 6 13:11:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 182445E46CB + for ; + Fri, 6 Aug 2004 13:11:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16597-04 + for ; + Fri, 6 Aug 2004 16:11:18 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 959075E46D6 + for ; + Fri, 6 Aug 2004 13:11:09 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i76GB661081375 + for ; Fri, 6 Aug 2004 16:11:16 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i76G1AG1080059 + for pgsql-performance@postgresql.org; Fri, 6 Aug 2004 16:01:10 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Performance Bottleneck +Date: Wed, 04 Aug 2004 17:25:42 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 112 +Message-ID: <4110FFF6.1030001@bigfoot.com> +References: <410FDC53.5080509@bigfoot.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Martin Foster +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/77 +X-Sequence-Number: 7713 + +Martin Foster wrote: + +> Gaetano Mendola wrote: +> +>> Martin Foster wrote: +>> +>>> I run a Perl/CGI driven website that makes extensive use of +>>> PostgreSQL (7.4.3) for everything from user information to formatting +>>> and display of specific sections of the site. The server itself, is +>>> a dual processor AMD Opteron 1.4Ghz w/ 2GB Ram and 2 x 120GB hard +>>> drives mirrored for redundancy running under FreeBSD 5.2.1 (AMD64). +>>> +>>> Recently loads on the site have increased during peak hours to the +>>> point of showing considerable loss in performance. This can be +>>> observed when connections move from the 120 concurrent connections to +>>> PostgreSQL to roughly 175 or more. Essentially, the machine seems +>>> to struggle to keep up with continual requests and slows down +>>> respectively as resources are tied down. +>>> +>>> Code changes have been made to the scripts to essentially back off in +>>> high load working environments which have worked to an extent. +>>> However, as loads continue to increase the database itself is not +>>> taking well to the increased traffic taking place. +>>> +>>> Having taken a look at 'Tuning PostgreSQL for Performance' +>>> (http://www.varlena.com/GeneralBits/Tidbits/perf.html) using it as +>>> best I could in order to set my settings. However, even with +>>> statistics disabled and ever setting tweaked things still consider to +>>> deteriorate. +>>> +>>> Is there anything anyone can recommend in order to give the system a +>>> necessary speed boost? It would seem to me that a modest dataset of +>>> roughly a Gig combined with that type of hardware should be able to +>>> handle substantially more load then what it is. Can anyone provide +>>> me with clues as where to pursue? Would disabling 'fsync' provide +>>> more performance if I choose that information may be lost in case of +>>> a crash? +>>> +>>> If anyone needs access to logs, settings et cetera. Please ask, I +>>> simply wish to test the waters first on what is needed. Thanks! +>> +>> +>> +>> Tell us about your tipical queries, show us your configuration file. +>> The access are only in read only mode or do you have concurrent writers +>> and readers ? During peak hours your processors are tied to 100% ? +>> What say the vmstat and the iostat ? +>> +>> May be you are not using indexes some where, or may be yes but the +>> planner is not using it... In two words we needs other informations +>> in order to help you. +>> +>> +>> +>> Regards +>> Gaetano Mendola +>> +>> +> +> I included all the files in attachments, which will hopefully cut down +> on any replied to Emails. As for things like connection pooling, the +> web server makes use of Apache::DBI to pool the connections for the Perl +> scripts being driven on that server. For the sake of being thorough, +> a quick 'apachectl status' was thrown in when the database was under a +> good load. + +Let start from your postgres configuration: + +shared_buffers = 8192 <==== This is really too small for your configuration +sort_mem = 2048 + +wal_buffers = 128 <==== This is really too small for your configuration + +effective_cache_size = 16000 + +change this values in: + +shared_buffers = 50000 +sort_mem = 16084 + +wal_buffers = 1500 + +effective_cache_size = 32000 + + +to bump up the shm usage you have to configure your OS in order to be +allowed to use that ammount of SHM. + +This are the numbers that I feel good for your HW, the second step now is +analyze your queries + +> The queries themselves are simple, normally drawing information from one +> table with few conditions or in the most complex cases using joins on +> two table or sub queries. These behave very well and always have, the +> problem is that these queries take place in rather large amounts due to +> the dumb nature of the scripts themselves. + +Show us the explain analyze on that queries, how many rows the tables are +containing, the table schema could be also usefull. + + + +regards +Gaetano Mendola + + + + + + + + + +From pgsql-performance-owner@postgresql.org Fri Aug 6 13:17:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 050715E46C2 + for ; + Fri, 6 Aug 2004 13:11:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14467-09 + for ; + Fri, 6 Aug 2004 16:11:09 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 749CC5E46C7 + for ; + Fri, 6 Aug 2004 13:11:00 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i76GB65l081375 + for ; Fri, 6 Aug 2004 16:11:07 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i76G1BxH080061 + for pgsql-performance@postgresql.org; Fri, 6 Aug 2004 16:01:11 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: The black art of postgresql.conf tweaking +Date: Wed, 04 Aug 2004 17:29:48 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 41 +Message-ID: <411100EC.8010802@bigfoot.com> +References: <4110DA83.7020505@clockltd.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Paul Serby +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: <4110DA83.7020505@clockltd.com> +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/78 +X-Sequence-Number: 7714 + +Paul Serby wrote: + +> Can anyone give a good reference site/book for getting the most out of +> your postgres server. +> +> All I can find is contradicting theories on how to work out your settings. +> +> This is what I followed to setup our db server that serves our web +> applications. +> +> http://www.phpbuilder.com/columns/smith20010821.php3?page=2 +> +> We have a Dell Poweredge with the following spec. +> +> CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +> CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +> CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +> CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +> Physical Memory: 2077264 kB +> Swap Memory: 2048244 kB +> +> Apache on the Web server can take up to 300 connections and PHP is using +> pg_pconnect +> +> Postgres is set with the following. +> +> max_connections = 300 +> shared_buffers = 38400 +> sort_mem = 12000 +> +> But Apache is still maxing out the non-super user connection limit. + +Tell us the value MaxClients in your apache configuration + + + + +Regards +Gaetano Mendola + + + +From pgsql-performance-owner@postgresql.org Fri Aug 6 13:11:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4327E5E46DB + for ; + Fri, 6 Aug 2004 13:11:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14423-09 + for ; + Fri, 6 Aug 2004 16:11:14 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id BDF305E46CD + for ; + Fri, 6 Aug 2004 13:11:05 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i76GB65n081375 + for ; Fri, 6 Aug 2004 16:11:08 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i76G1BLs080063 + for pgsql-performance@postgresql.org; Fri, 6 Aug 2004 16:01:11 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Tuning queries on large database +Date: Wed, 04 Aug 2004 17:34:56 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 20 +Message-ID: <41110220.7000006@bigfoot.com> +References: <200408041244.i74CihO19344@mu.meteo.fr> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Valerie Schneider DSI/DEV +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: <200408041244.i74CihO19344@mu.meteo.fr> +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/74 +X-Sequence-Number: 7710 + +Valerie Schneider DSI/DEV wrote: + +> Hi, +> +> I have some problem of performance on a PG database, and I don't +> know how to improve. I Have two questions : one about the storage +> of data, one about tuning queries. If possible ! +> +> My job is to compare Oracle and Postgres. All our operational databases +> have been running under Oracle for about fifteen years. Now I try to replace +> Oracle by Postgres. + +Show us the explain analyze on your queries. + +Regards +Gaetano Mendola + + + + + +From pgsql-performance-owner@postgresql.org Wed Aug 4 12:36:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9846BD1B298 + for ; + Wed, 4 Aug 2004 12:36:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74454-08 + for ; + Wed, 4 Aug 2004 15:36:27 +0000 (GMT) +Received: from mail3.panix.com (mail3.panix.com [166.84.1.74]) + by svr1.postgresql.org (Postfix) with ESMTP id A479DD1B1C8 + for ; + Wed, 4 Aug 2004 12:36:25 -0300 (ADT) +Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) + by mail3.panix.com (Postfix) with ESMTP id A01E0982CC; + Wed, 4 Aug 2004 11:36:24 -0400 (EDT) +Received: (from adler@localhost) + by panix2.panix.com (8.11.6p2-a/8.8.8/PanixN1.1) id i74FaO311313; + Wed, 4 Aug 2004 11:36:24 -0400 (EDT) +Date: Wed, 4 Aug 2004 11:36:24 -0400 +From: Michael Adler +To: Martin Foster +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance Bottleneck +Message-ID: <20040804153624.GA27551@pobox.com> +References: <410FDC53.5080509@bigfoot.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/54 +X-Sequence-Number: 7690 + +On Wed, Aug 04, 2004 at 03:49:11AM +0000, Martin Foster wrote: +> Also note that some of these scripts run for longer durations even if +> they are web based. Some run as long as 30 minutes, making queries to +> the database from periods of wait from five seconds to twenty-five +> seconds. Under high duress the timeouts should back out, based on +> the time needed for the query to respond, normally averaging 0.008 seconds. + +I would start by EXPLAIN ANALYZE'ing those 30 minute queries. + +> martin@io ~$ vmstat +> procs memory page disks faults cpu +> r b w avm fre flt re pi po fr sr ad4 ad6 in sy cs us sy id +> 0 0 0 498532 122848 3306 0 0 0 740 0 0 0 788 0 1675 16 21 63 +> + +vmstat without a "delay" argument (e.g. 'vmstat 1') gives you a +cumulative or average since boot. You'd probably get better +information by doing a real-time sampling of stats during normal and +heavy load. + +> martin@io ~$ ps -uax +> USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND +> postgres 32084 0.0 0.2 91616 3764 p0- R Mon12PM 4:08.99 /usr/local/bin/postmaster -D /var/postgres (postgres) +> postgres 80333 0.0 2.1 94620 44372 ?? S 8:57PM 0:01.00 postmaster: ethereal ethereal 192.168.1.6 idle in trans +> postgres 80599 0.0 2.1 94652 44780 ?? S 8:59PM 0:00.97 postmaster: ethereal ethereal 192.168.1.6 idle in trans +> postgres 80616 0.0 2.4 94424 50396 ?? S 8:59PM 0:00.89 postmaster: ethereal ethereal 192.168.1.6 idle in trans +> postgres 80715 0.0 2.2 94444 46804 ?? S 9:00PM 0:00.68 postmaster: ethereal ethereal 192.168.1.6 idle in trans +> postgres 80788 0.0 2.1 94424 43944 ?? S 9:00PM 0:00.93 postmaster: ethereal ethereal 192.168.1.6 idle in trans +> postgres 80811 0.0 2.1 94424 43884 ?? S 9:00PM 0:00.94 postmaster: ethereal ethereal 192.168.1.6 idle in trans +> postgres 80902 0.0 2.1 94424 43380 ?? S 9:01PM 0:00.76 postmaster: ethereal ethereal 192.168.1.6 idle in trans +> postgres 80949 0.0 2.2 94424 45248 ?? S 9:01PM 0:00.67 postmaster: ethereal ethereal 192.168.1.6 idle in trans +> postgres 81020 0.0 2.1 94424 42924 ?? S 9:02PM 0:00.74 postmaster: ethereal ethereal 192.168.1.6 idle in trans + +All the connections in your email are idle. You may benefit from using +pgpool instead of Apache::DBI (I've never tried). + +http://www.mail-archive.com/pgsql-announce@postgresql.org/msg00760.html + + +From pgsql-performance-owner@postgresql.org Wed Aug 4 12:51:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 81FE6D1B1C8 + for ; + Wed, 4 Aug 2004 12:51:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80565-04 + for ; + Wed, 4 Aug 2004 15:51:00 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 813A8D1B1B4 + for ; + Wed, 4 Aug 2004 12:50:58 -0300 (ADT) +Received: (qmail 5071 invoked from network); 4 Aug 2004 17:50:56 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 4 Aug 2004 17:50:56 +0200 +Date: Wed, 04 Aug 2004 17:50:56 +0200 +To: "Rod Taylor" , + "Valerie Schneider DSI/DEV" +Subject: Re: Tuning queries on large database +Cc: "Postgresql Performance" +References: <200408041244.i74CihO19344@mu.meteo.fr> + <1091625999.58593.47.camel@jester> +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <1091625999.58593.47.camel@jester> +User-Agent: Opera M2/7.50 (Linux, build 673) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/55 +X-Sequence-Number: 7691 + + +>> not so bad for oracle. What about for PG ? How data is stored + + I agree with the datatype issue. Smallint, bigint, integer... add a +constraint... + + Also the way order of the records in the database is very important. As +you seem to have a very large static population in your table, you should +insert it, ordered by your favourite selection index (looks like it's +poste). + + Also, you have a lot of static data which pollutes your table. Why not +create two tables, one for the current year, and one for all the past +years. Use a view to present a merged view. + +From pgsql-performance-owner@postgresql.org Wed Aug 4 12:53:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9CAE5D1B1AA + for ; + Wed, 4 Aug 2004 12:53:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79334-07 + for ; + Wed, 4 Aug 2004 15:53:30 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 322CBD1B1B4 + for ; + Wed, 4 Aug 2004 12:53:28 -0300 (ADT) +Received: (qmail 5166 invoked from network); 4 Aug 2004 17:53:27 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 4 Aug 2004 17:53:27 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Tuning queries on large database +References: <200408041412.i74ECYO19577@mu.meteo.fr> +Message-ID: +Date: Wed, 04 Aug 2004 17:53:27 +0200 +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <200408041412.i74ECYO19577@mu.meteo.fr> +User-Agent: Opera M2/7.50 (Linux, build 673) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/56 +X-Sequence-Number: 7692 + + + You often make sums. Why not use separate tables to cache these sums by +month, by poste, by whatever ? + + Rule on insert on the big table updates the cache tables. + +From pgsql-performance-owner@postgresql.org Wed Aug 4 12:56:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AE42AD1B1C8 + for ; + Wed, 4 Aug 2004 12:56:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79334-09 + for ; + Wed, 4 Aug 2004 15:56:42 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 45DE4D1B199 + for ; + Wed, 4 Aug 2004 12:56:40 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: FW: Tuning queries on large database +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Wed, 4 Aug 2004 11:56:41 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AF20@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Tuning queries on large database +thread-index: AcR6Iae9QRnQrjxYRJyInj9KrC3FYQAAOJgQAAY977A= +From: "Merlin Moncure" +To: "Postgresql Performance" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/57 +X-Sequence-Number: 7693 + +[forwarded to performance]=20 +> The result is that for "short queries" (Q1 and Q2) it runs in a few +> seconds on both Oracle and PG. The difference becomes important with +> Q3 : 8 seconds with oracle +> 80 sec with PG +> and too much with Q4 : 28s with oracle +> 17m20s with PG ! +>=20 +> Of course when I run 100 or 1000 parallel queries such as Q3 or Q4, +> it becomes a disaster ! +> I can't understand these results. The way to execute queries is the +> same I think. I've read recommended articles on the PG site. +> I tried with a table containing 30 millions rows, results are similar. + + +I don't trust the Oracle #s. Lets look at Q4: returns 3 million rows. +Using your #s of 160 fields and 256 bytes, your are asking for a result +set of 160 * 256 * 3M =3D 12 GB! This data has to be gathered by the +disk, assembled, and sent over the network. + +I don't know Oracle, but it probably has some 'smart' result set that +uses a cursor behind the scenes to do the fetching. + +With a 3M row result set, you need to strongly consider using cursors. +Try experimenting with the same query (Q4), declared as a cursor, and +fetch the data in 10k blocks in a loop (fetch 10000), and watch the #s +fly. + +Merlin + + +From pgsql-performance-owner@postgresql.org Wed Aug 4 13:21:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E2E0ED1B373 + for ; + Wed, 4 Aug 2004 13:21:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87396-09 + for ; + Wed, 4 Aug 2004 16:21:36 +0000 (GMT) +Received: from fep3.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 2DD5AD1B347 + for ; + Wed, 4 Aug 2004 13:21:34 -0300 (ADT) +Received: from [127.0.0.1] (d226-86-215.home.cgocable.net [24.226.86.215]) + by fep3.cogeco.net (Postfix) with ESMTP + id AD16C2350; Wed, 4 Aug 2004 12:21:32 -0400 (EDT) +Message-ID: <41110D06.5090900@ethereal-realms.org> +Date: Wed, 04 Aug 2004 12:21:26 -0400 +From: Martin Foster +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7) Gecko/20040616 +X-Accept-Language: en-ca, en-gb, en-us, en +MIME-Version: 1.0 +To: Michael Adler +Cc: PostgreSQL Performance +Subject: Re: Performance Bottleneck +References: <410FDC53.5080509@bigfoot.com> + <20040804153624.GA27551@pobox.com> +In-Reply-To: <20040804153624.GA27551@pobox.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.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/58 +X-Sequence-Number: 7694 + +Michael Adler wrote: + +> On Wed, Aug 04, 2004 at 03:49:11AM +0000, Martin Foster wrote: +> +>>Also note that some of these scripts run for longer durations even if +>>they are web based. Some run as long as 30 minutes, making queries to +>>the database from periods of wait from five seconds to twenty-five +>>seconds. Under high duress the timeouts should back out, based on +>>the time needed for the query to respond, normally averaging 0.008 seconds. +> +> +> I would start by EXPLAIN ANALYZE'ing those 30 minute queries. +> + +The Apache process will run for 30 minutes at a time, not the query +itself. Essentially, while that process is running it will check for +new records in the table at varying intervals, since it will increase +timeouts based on load or lack of activity in order to reduce load to +the database. + +> +>>martin@io ~$ vmstat +>> procs memory page disks faults cpu +>> r b w avm fre flt re pi po fr sr ad4 ad6 in sy cs us sy id +>> 0 0 0 498532 122848 3306 0 0 0 740 0 0 0 788 0 1675 16 21 63 +>> +> +> +> vmstat without a "delay" argument (e.g. 'vmstat 1') gives you a +> cumulative or average since boot. You'd probably get better +> information by doing a real-time sampling of stats during normal and +> heavy load. +> +> +>>martin@io ~$ ps -uax +>>USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND +>>postgres 32084 0.0 0.2 91616 3764 p0- R Mon12PM 4:08.99 /usr/local/bin/postmaster -D /var/postgres (postgres) +>>postgres 80333 0.0 2.1 94620 44372 ?? S 8:57PM 0:01.00 postmaster: ethereal ethereal 192.168.1.6 idle in trans +>>postgres 80599 0.0 2.1 94652 44780 ?? S 8:59PM 0:00.97 postmaster: ethereal ethereal 192.168.1.6 idle in trans +>>postgres 80616 0.0 2.4 94424 50396 ?? S 8:59PM 0:00.89 postmaster: ethereal ethereal 192.168.1.6 idle in trans +>>postgres 80715 0.0 2.2 94444 46804 ?? S 9:00PM 0:00.68 postmaster: ethereal ethereal 192.168.1.6 idle in trans +>>postgres 80788 0.0 2.1 94424 43944 ?? S 9:00PM 0:00.93 postmaster: ethereal ethereal 192.168.1.6 idle in trans +>>postgres 80811 0.0 2.1 94424 43884 ?? S 9:00PM 0:00.94 postmaster: ethereal ethereal 192.168.1.6 idle in trans +>>postgres 80902 0.0 2.1 94424 43380 ?? S 9:01PM 0:00.76 postmaster: ethereal ethereal 192.168.1.6 idle in trans +>>postgres 80949 0.0 2.2 94424 45248 ?? S 9:01PM 0:00.67 postmaster: ethereal ethereal 192.168.1.6 idle in trans +>>postgres 81020 0.0 2.1 94424 42924 ?? S 9:02PM 0:00.74 postmaster: ethereal ethereal 192.168.1.6 idle in trans +> +> +> All the connections in your email are idle. You may benefit from using +> pgpool instead of Apache::DBI (I've never tried). +> +> http://www.mail-archive.com/pgsql-announce@postgresql.org/msg00760.html +> + +I will take a look into pgpool and see if it will serve as the solution +I need. The pre-pooling of children sounds like a good choice, however +since overhead is already a point of worry I almost wonder if I can host +it on another server in order to drop that overhead on the servers directly. + +Anyone have experience with this on running it on the same machine or a +different machine then the database proper? Of course, if this works +as it should, I could easily put an older database server back into +operation provided pgpool does weighted load balancing. + + Martin Foster + Creator/Designer Ethereal Realms + martin@ethereal-realms.org + + + +From pgsql-performance-owner@postgresql.org Wed Aug 4 13:37:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 10220D1B1D1 + for ; + Wed, 4 Aug 2004 13:37:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92121-09 + for ; + Wed, 4 Aug 2004 16:36:59 +0000 (GMT) +Received: from fep4.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EA69D1B19F + for ; + Wed, 4 Aug 2004 13:36:52 -0300 (ADT) +Received: from [127.0.0.1] (d226-86-215.home.cgocable.net [24.226.86.215]) + by fep4.cogeco.net (Postfix) with ESMTP + id 37FA629EE; Wed, 4 Aug 2004 12:36:51 -0400 (EDT) +Message-ID: <4111109D.7020006@ethereal-realms.org> +Date: Wed, 04 Aug 2004 12:36:45 -0400 +From: Martin Foster +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7) Gecko/20040616 +X-Accept-Language: en-ca, en-gb, en-us, en +MIME-Version: 1.0 +To: Gaetano Mendola , + PostgreSQL Performance +Subject: Re: Performance Bottleneck +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> +In-Reply-To: <4110FFF6.1030001@bigfoot.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.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/59 +X-Sequence-Number: 7695 + +Gaetano Mendola wrote: + +> Martin Foster wrote: +> +>> Gaetano Mendola wrote: +>> +>>> Martin Foster wrote: +>>> +>>>> I run a Perl/CGI driven website that makes extensive use of +>>>> PostgreSQL (7.4.3) for everything from user information to +>>>> formatting and display of specific sections of the site. The +>>>> server itself, is a dual processor AMD Opteron 1.4Ghz w/ 2GB Ram and +>>>> 2 x 120GB hard drives mirrored for redundancy running under FreeBSD +>>>> 5.2.1 (AMD64). +>>>> +>>>> Recently loads on the site have increased during peak hours to the +>>>> point of showing considerable loss in performance. This can be +>>>> observed when connections move from the 120 concurrent connections +>>>> to PostgreSQL to roughly 175 or more. Essentially, the machine +>>>> seems to struggle to keep up with continual requests and slows down +>>>> respectively as resources are tied down. +>>>> +>>>> Code changes have been made to the scripts to essentially back off +>>>> in high load working environments which have worked to an extent. +>>>> However, as loads continue to increase the database itself is not +>>>> taking well to the increased traffic taking place. +>>>> +>>>> Having taken a look at 'Tuning PostgreSQL for Performance' +>>>> (http://www.varlena.com/GeneralBits/Tidbits/perf.html) using it as +>>>> best I could in order to set my settings. However, even with +>>>> statistics disabled and ever setting tweaked things still consider +>>>> to deteriorate. +>>>> +>>>> Is there anything anyone can recommend in order to give the system a +>>>> necessary speed boost? It would seem to me that a modest dataset +>>>> of roughly a Gig combined with that type of hardware should be able +>>>> to handle substantially more load then what it is. Can anyone +>>>> provide me with clues as where to pursue? Would disabling 'fsync' +>>>> provide more performance if I choose that information may be lost in +>>>> case of a crash? +>>>> +>>>> If anyone needs access to logs, settings et cetera. Please ask, I +>>>> simply wish to test the waters first on what is needed. Thanks! +>>> +>>> +>>> +>>> +>>> Tell us about your tipical queries, show us your configuration file. +>>> The access are only in read only mode or do you have concurrent writers +>>> and readers ? During peak hours your processors are tied to 100% ? +>>> What say the vmstat and the iostat ? +>>> +>>> May be you are not using indexes some where, or may be yes but the +>>> planner is not using it... In two words we needs other informations +>>> in order to help you. +>>> +>>> +>>> +>>> Regards +>>> Gaetano Mendola +>>> +>>> +>> +>> I included all the files in attachments, which will hopefully cut down +>> on any replied to Emails. As for things like connection pooling, +>> the web server makes use of Apache::DBI to pool the connections for +>> the Perl scripts being driven on that server. For the sake of being +>> thorough, a quick 'apachectl status' was thrown in when the database +>> was under a good load. +> +> +> Let start from your postgres configuration: +> +> shared_buffers = 8192 <==== This is really too small for your +> configuration +> sort_mem = 2048 +> +> wal_buffers = 128 <==== This is really too small for your configuration +> +> effective_cache_size = 16000 +> +> change this values in: +> +> shared_buffers = 50000 +> sort_mem = 16084 +> +> wal_buffers = 1500 +> +> effective_cache_size = 32000 +> +> +> to bump up the shm usage you have to configure your OS in order to be +> allowed to use that ammount of SHM. +> +> This are the numbers that I feel good for your HW, the second step now is +> analyze your queries +> +>> The queries themselves are simple, normally drawing information from +>> one table with few conditions or in the most complex cases using joins +>> on two table or sub queries. These behave very well and always have, +>> the problem is that these queries take place in rather large amounts +>> due to the dumb nature of the scripts themselves. +> +> +> Show us the explain analyze on that queries, how many rows the tables are +> containing, the table schema could be also usefull. +> +> +> +> regards +> Gaetano Mendola +> + +I will look into moving up those values and seeing how they interact +with the system once I get back from work. Since it was requested, I +have a visual representation of an older schema, one that was used under +MySQL. Note that all of the timestamps are now properly set to +LOCALTIME on PostgreSQL. + +http://prdownloads.sourceforge.net/ethereal-realms/ethereal-3_0_0.png?download + +The amount of rows for tables of note are as follows: + Puppeteer 1606 + Puppet 33176 + Realm 83 + Post 36156 + Audit 61961 + +The post table is continually cleared of old information since the +nature of the information is time very critical and archiving would only +hinder performance. As a result, this will vary wildly based on time +of day since users (Puppeteers) tend to post more during peak hours. + +NOTE: The scripts make use of different schema's with the same + information in order to virtualize the script in order + to support more then one site on the same hardware. + +On a side note, this would be a normal post-authentication session once +in realm for getting new posts: + * Script is executed and schema is determined through stored procedure; + * Formatting information is fetched from Tag and RealmDesign as needed; + * Script will retrieve stored parameters in the Param table; + * Script will decode, analyze and authenticate against Puppeteer; + * Script will scan the Puppet and Post tables to generate posts; + * Sub-query to determine ignored puppeteers/users; + * Sub-query to determine ignored puppets/handles; and + * Loop above if necessary until expiry of script delaying + the execution of the script from 5 to 25 seconds. + +This should provide an idea on that portion. of course the flow +changes when one posts, but is handled by a different script instance as +is authentication et cetera. + + Martin Foster + Creator/Designer Ethereal Realms + martin@ethereal-realms.org + + + +From pgsql-performance-owner@postgresql.org Thu Aug 5 03:40:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 27E01D1B1CF + for ; + Thu, 5 Aug 2004 03:40:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30737-07 + for ; + Thu, 5 Aug 2004 06:40:42 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id ADEC5D1B1A1 + for ; + Thu, 5 Aug 2004 03:40:34 -0300 (ADT) +Received: (qmail 10793 invoked from network); 5 Aug 2004 08:40:33 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 5 Aug 2004 08:40:33 +0200 +To: "PostgreSQL Performance" +Subject: Re: Performance Bottleneck +References: <410FDC53.5080509@bigfoot.com> + <20040804153624.GA27551@pobox.com> + <41110D06.5090900@ethereal-realms.org> +Message-ID: +Date: Thu, 05 Aug 2004 08:40:35 +0200 +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <41110D06.5090900@ethereal-realms.org> +User-Agent: Opera M2/7.50 (Linux, build 673) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/60 +X-Sequence-Number: 7696 + + + Apache processes running for 30 minutes ?..... + + My advice : use frames and Javascript ! + + In your webpage, you have two frames : "content" and "refresh". + + "content" starts empty (say, just a title on top of the page). + "refresh" is refreshed every five seconds from a script on your server. +This script generates a javascript which "document.write()'s" new entries +in the "content" frame, thus adding new records in the upper frame. + + Thus, the refreshing uses a new request every 5 seconds, which terminates +very fast, and does not hog an Apache process. + + Turn keepalive timeout down. + +From pgsql-performance-owner@postgresql.org Fri Aug 6 00:58:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B2E4AD1B1AE + for ; + Thu, 5 Aug 2004 04:20:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41865-08 + for ; + Thu, 5 Aug 2004 07:20:40 +0000 (GMT) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 56E1CD1B4AF + for ; + Thu, 5 Aug 2004 04:20:34 -0300 (ADT) +Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1BscYE-0005PA-00 + for ; Thu, 05 Aug 2004 09:20:34 +0200 +Received: from linuxnews.dk ([81.7.132.92]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Thu, 05 Aug 2004 09:20:33 +0200 +Received: from jesper by linuxnews.dk with local (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Thu, 05 Aug 2004 09:20:33 +0200 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +From: Jesper Krogh +Subject: pg_dump performance? +Date: Thu, 5 Aug 2004 07:08:48 +0000 (UTC) +Lines: 16 +Message-ID: +X-Complaints-To: usenet@sea.gmane.org +X-Gmane-NNTP-Posting-Host: linuxnews.dk +User-Agent: slrn/0.9.8.0 (Linux) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/71 +X-Sequence-Number: 7707 + +I have a database that I should migrate from 7.3 -> 7.4.3 but pg_dump | +psql seems to take forever. (Several hours) Is there anything that can I +do to speed it up? + +The databse is primary a table with 300.000 records of about 200Kbytes +each. ~ 60 GB. + +This is becoming an issue with the daily backup too.. (running pg_dump +over night ) + +Jesper + +-- +./Jesper Krogh, jesper@krogh.cc +Jabber ID: jesper@jabbernet.dk + + + +From pgsql-performance-owner@postgresql.org Thu Aug 5 05:16:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D801D1B4AF + for ; + Thu, 5 Aug 2004 05:16:07 -0300 (ADT) +Received: 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-09 + for ; + Thu, 5 Aug 2004 08:16:07 +0000 (GMT) +Received: from cadillac.meteo.fr (cadillac.meteo.fr [137.129.1.4]) + by svr1.postgresql.org (Postfix) with ESMTP id 69DAED1B4EC + for ; + Thu, 5 Aug 2004 05:16:02 -0300 (ADT) +Received: from mu.meteo.fr (localhost.meteo.fr [127.0.0.1]) + by cadillac.meteo.fr (8.9.3 (PHNE_28760_binary)/8.9.3) with ESMTP id + IAA00289; Thu, 5 Aug 2004 08:16:02 GMT +Received: from mu.meteo.fr (mu.meteo.fr [137.129.6.129]) + by mu.meteo.fr (8.11.7p1+Sun/8.11.7) with SMTP id i758GxO21560; + Thu, 5 Aug 2004 08:16:59 GMT +Message-Id: <200408050816.i758GxO21560@mu.meteo.fr> +Date: Thu, 5 Aug 2004 08:16:59 +0000 (GMT) +From: Valerie Schneider DSI/DEV +Reply-To: Valerie Schneider DSI/DEV +Subject: Re: [GENERAL] Tuning queries on large database +To: chriskl@familyhealth.com.au +Cc: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: TEXT/plain; charset=us-ascii +Content-MD5: WW+nfrgJ7X6M2P6HcEvFOw== +X-Mailer: dtmail 1.3.0 @(#)CDE Version 1.4.6_06 SunOS 5.8 sun4u sparc +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/61 +X-Sequence-Number: 7697 + +Hi, +I 've decreased the sort_mem to 5000 instead of 50000. +I recreated ma table using integer and real types instead of +numeric : the result is very improved for the disk space : + + schema | relfilenode | table | index | reltuples | size +--------+-------------+------------------+------------+-------------+---------- + public | 253442696 | data | | 1.25113e+08 | 29760016 + public | 378639579 | data | i_data_dat | 1.25113e+08 | 2744400 + public | 378555698 | data | pk_data | 1.25113e+08 | 3295584 + +so it takes about 28 Gb instead of 68 Gb ! + +For my different queries, it's better but less performant than oracle : + + oracle PG yesterday(numeric) PG today(integer/real) +Q1 <1s <1s <1s +Q2 3s 8s 4s +Q3 8s 1m20s 27s +Q4 28s 17m20s 6m47s + +Result of EXPLAIN ANALYZE : + +Q1 :bench=> explain analyze select 'Q1',min(td),max(u) from data where +num_poste=1000 and dat between +(date_trunc('month',to_timestamp('31012004','ddmmyyyy')-interval '2000 +days'))::timestamp and +(date_trunc('month',to_timestamp('31012004','ddmmyyyy')-interval '2000 days') + +interval '1 month' - interval '1 hour')::timestamp; + + QUERY PLAN +-------------------------------------------------------------------------------- + Aggregate (cost=2466.47..2466.47 rows=1 width=8) (actual time=261.777..261.778 +rows=1 loops=1) + -> Index Scan using pk_data on data (cost=0.00..2463.41 rows=611 width=8) +(actual time=20.106..259.924 rows=744 loops=1) + Index Cond: ((num_poste = 1000) AND (dat >= (date_trunc('month'::text, +(to_timestamp('31012004'::text, 'ddmmyyyy'::text) - '2000 +days'::interval)))::timestamp without time zone) AND (dat <= +(((date_trunc('month'::text, (to_timestamp('31012004'::text, 'ddmmyyyy'::text) - +'2000 days'::interval)) + '1 mon'::interval) - '01:00:00'::interval))::timestamp +without time zone)) + Total runtime: 262.145 ms +(4 rows) + + +Q2 : bench=> explain analyze select 'Q2',count(*) from data where num_poste +between 100 and 100+10 and dat between +(date_trunc('month',to_timestamp('31012004','ddmmyyyy')-interval '3000 +days'))::timestamp and +(date_trunc('month',to_timestamp('31012004','ddmmyyyy')-interval '3000 days') + +interval '1 month' - interval '1 hour')::timestamp; + + QUERY PLAN +-------------------------------------------------------------------------------- + Aggregate (cost=24777.68..24777.68 rows=1 width=0) (actual +time=4253.977..4253.978 rows=1 loops=1) + -> Index Scan using pk_data on data (cost=0.00..24762.34 rows=6138 width=0) +(actual time=46.602..4244.984 rows=7920 loops=1) + Index Cond: ((num_poste >= 100) AND (num_poste <= 110) AND (dat >= +(date_trunc('month'::text, (to_timestamp('31012004'::text, 'ddmmyyyy'::text) - +'3000 days'::interval)))::timestamp without time zone) AND (dat <= +(((date_trunc('month'::text, (to_timestamp('31012004'::text, 'ddmmyyyy'::text) - +'3000 days'::interval)) + '1 mon'::interval) - '01:00:00'::interval))::timestamp +without time zone)) + Total runtime: 4254.233 ms +(4 rows) + + +Q3 : bench=> explain analyze select 'Q3',sum(rr1),count(ff) from data where +num_poste in (50,50+2); + QUERY PLAN +-------------------------------------------------------------------------------- + Aggregate (cost=963455.87..963455.87 rows=1 width=8) (actual +time=27668.666..27668.667 rows=1 loops=1) + -> Index Scan using pk_data, pk_data on data (cost=0.00..962236.31 +rows=243910 width=8) (actual time=16.251..27275.468 rows=250226 loops=1) + Index Cond: ((num_poste = 50) OR (num_poste = 52)) + Total runtime: 27673.837 ms +(4 rows) + + +Q4 : bench=> explain analyze select 'Q4',count(*) from data where num_poste +between 600 and 625; + QUERY PLAN +-------------------------------------------------------------------------------- + Aggregate (cost=14086174.57..14086174.57 rows=1 width=0) (actual +time=428235.024..428235.025 rows=1 loops=1) + -> Index Scan using pk_data on data (cost=0.00..14076910.99 rows=3705431 +width=0) (actual time=45.283..424634.826 rows=3252938 loops=1) + Index Cond: ((num_poste >= 600) AND (num_poste <= 625)) + Total runtime: 428235.224 ms +(4 rows) + +Thanks for all, Valerie. + +>X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +>X-Authentication-Warning: houston.familyhealth.com.au: chriskl owned process +doing -bs +>Date: Wed, 4 Aug 2004 21:21:51 +0800 (WST) +>From: Christopher Kings-Lynne +>To: Valerie Schneider DSI/DEV +>Cc: pgsql-performance@postgresql.org, +>Subject: Re: [GENERAL] [PERFORM] Tuning queries on large database +>MIME-Version: 1.0 +>X-Virus-Scanned: by amavisd-new at hub.org +>X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +>X-Spam-Level: +>X-Mailing-List: pgsql-general +> +>> sort_mem = 50000 +> +>That is way, way too large. Try more like 5000 or lower. +> +>> num_poste | numeric(9,0) | not null +> +>For starters numerics are really, really slow compared to integers. Why +>aren't you using an integer for this field since youhave '0' decimal +>places. +> +>> schema | relfilenode | table | index | reltuples | size +>> +--------+-------------+------------------+------------+-------------+---------- +>> public | 125615917 | data | | 1.25113e+08 | +72312040 +>> public | 251139049 | data | i_data_dat | 1.25113e+08 | +2744400 +>> public | 250870177 | data | pk_data | 1.25113e+08 | +4395480 +>> +>> My first remark is that the table takes a lot of place on disk, about +>> 70 Gb, instead of 35 Gb with oracle. +> +>Integers will take a lot less space than numerics. +> +>> The different queries of the bench are "simple" queries (no join, +>> sub-query, ...) and are using indexes (I "explained" each one to +>> be sure) : +>> Q1 select_court : access to about 700 rows : 1 "num_poste" and 1 month +>> (using PK : num_poste=p1 and dat between p2 and p3) +>> Q2 select_moy : access to about 7000 rows : 10 "num_poste" and 1 month +>> (using PK : num_poste between p1 and p1+10 and dat between p2 and p3) +>> Q3 select_long : about 250 000 rows : 2 "num_poste" +>> (using PK : num_poste in (p1,p1+2)) +>> Q4 select_tres_long : about 3 millions rows : 25 "num_poste" +>> (using PK : num_poste between p1 and p1 + 25) +>> +>> The result is that for "short queries" (Q1 and Q2) it runs in a few +>> seconds on both Oracle and PG. The difference becomes important with +>> Q3 : 8 seconds with oracle +>> 80 sec with PG +>> and too much with Q4 : 28s with oracle +>> 17m20s with PG ! +>> +>> Of course when I run 100 or 1000 parallel queries such as Q3 or Q4, +>> it becomes a disaster ! +> +>Please reply with the EXPLAIN ANALYZE output of these queries so we can +>have some idea of how to help you. +> +>Chris +> +> +> +>---------------------------(end of broadcast)--------------------------- +>TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html + + + +******************************************************************** +* Les points de vue exprimes sont strictement personnels et * +* n'engagent pas la responsabilite de METEO-FRANCE. * +******************************************************************** +* Valerie SCHNEIDER Tel : +33 (0)5 61 07 81 91 * +* METEO-FRANCE / DSI/DEV Fax : +33 (0)5 61 07 81 09 * +* 42, avenue G. Coriolis Email : Valerie.Schneider@meteo.fr * +* 31057 TOULOUSE Cedex - FRANCE http://www.meteo.fr * +******************************************************************** + + +From pgsql-performance-owner@postgresql.org Fri Aug 6 13:11:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4ECB85E46C6 + for ; + Fri, 6 Aug 2004 13:11:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14629-09 + for ; + Fri, 6 Aug 2004 16:11:16 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id A43255E46D0 + for ; + Fri, 6 Aug 2004 13:11:08 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i76GB65r081375 + for ; Fri, 6 Aug 2004 16:11:16 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i76G1bLA080127 + for pgsql-performance@postgresql.org; Fri, 6 Aug 2004 16:01:37 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: [GENERAL] Tuning queries on large database +Date: Thu, 05 Aug 2004 11:53:59 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 36 +Message-ID: <411203B7.8050706@bigfoot.com> +References: <200408050816.i758GxO21560@mu.meteo.fr> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Valerie Schneider DSI/DEV +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: <200408050816.i758GxO21560@mu.meteo.fr> +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/75 +X-Sequence-Number: 7711 + +Valerie Schneider DSI/DEV wrote: + + > Hi, + > I 've decreased the sort_mem to 5000 instead of 50000. + > I recreated ma table using integer and real types instead of + > numeric : the result is very improved for the disk space : + > + > schema | relfilenode | table | index | reltuples | size + > --------+-------------+------------------+------------+-------------+---------- + > public | 253442696 | data | | 1.25113e+08 | 29760016 + > public | 378639579 | data | i_data_dat | 1.25113e+08 | 2744400 + > public | 378555698 | data | pk_data | 1.25113e+08 | 3295584 + > + > so it takes about 28 Gb instead of 68 Gb ! + > + > For my different queries, it's better but less performant than oracle : + > + > oracle PG yesterday(numeric) PG today(integer/real) + > Q1 <1s <1s <1s + > Q2 3s 8s 4s + > Q3 8s 1m20s 27s + > Q4 28s 17m20s 6m47s + + +Are you using the same disk for oracle and PG ? + +Could you post your actual postgresql.conf ? +Try also to mount your partition with the option: noatime +and try again. + + +Regards +Gaetano Mendola + + + + +From pgsql-performance-owner@postgresql.org Thu Aug 5 07:07:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E74DAD1B341 + for ; + Thu, 5 Aug 2004 07:07:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87105-04 + for ; + Thu, 5 Aug 2004 10:07:38 +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 87B6DD1B340 + for ; + Thu, 5 Aug 2004 07:07:34 -0300 (ADT) +Received: from smtp-3.paradise.net.nz (smtp-3b.paradise.net.nz [202.0.32.212]) + by linda-1.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0I1Y002VYXGM5Y@linda-1.paradise.net.nz> for + pgsql-performance@postgresql.org; Thu, 05 Aug 2004 22:07:35 +1200 (NZST) +Received: from coretech.co.nz (218-101-45-230.paradise.net.nz + [218.101.45.230]) + by smtp-3.paradise.net.nz (Postfix) with ESMTP id 15C28AE0F7; Thu, + 05 Aug 2004 22:07:34 +1200 (NZST) +Date: Thu, 05 Aug 2004 22:09:58 +1200 +From: Mark Kirkwood +Subject: Re: [GENERAL] Tuning queries on large database +In-reply-to: <200408050816.i758GxO21560@mu.meteo.fr> +To: Valerie Schneider DSI/DEV +Cc: chriskl@familyhealth.com.au, pgsql-performance@postgresql.org +Message-id: <41120776.4090401@coretech.co.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=us-ascii +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.6) Gecko/20040429 +References: <200408050816.i758GxO21560@mu.meteo.fr> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/62 +X-Sequence-Number: 7698 + +I am guessing that Oracle can satisfy Q4 entirely via index access, +whereas Pg has to visit the table as well. + +Having said that, a few partial indexes may be worth trying out on +data.num_poste (say 10 or so), this won't help the table access but +could lower the index cost. If you combine this with loading the data in +num_poste order (or run CLUSTER), you may get closer to Oracle's time +for this query. + +regards + +Mark + +Valerie Schneider DSI/DEV wrote: + +>For my different queries, it's better but less performant than oracle : +> +> oracle PG yesterday(numeric) PG today(integer/real) +> +>Q4 28s 17m20s 6m47s +> +> +> +>Q4 : bench=> explain analyze select 'Q4',count(*) from data where num_poste +>between 600 and 625; +> QUERY PLAN +>-------------------------------------------------------------------------------- +> Aggregate (cost=14086174.57..14086174.57 rows=1 width=0) (actual +>time=428235.024..428235.025 rows=1 loops=1) +> -> Index Scan using pk_data on data (cost=0.00..14076910.99 rows=3705431 +>width=0) (actual time=45.283..424634.826 rows=3252938 loops=1) +> Index Cond: ((num_poste >= 600) AND (num_poste <= 625)) +> Total runtime: 428235.224 ms +>(4 rows) +> +>Thanks for all, Valerie. +> +> +> + +From pgsql-performance-owner@postgresql.org Thu Aug 5 10:08:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 27E2CD1B1C9 + for ; + Thu, 5 Aug 2004 10:08:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44294-10 + for ; + Thu, 5 Aug 2004 13:08:20 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id E4080D1B171 + for ; + Thu, 5 Aug 2004 10:08:15 -0300 (ADT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i75D7s310555; + Thu, 5 Aug 2004 15:07:54 +0200 +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 i75D8GZ01181; + Thu, 5 Aug 2004 15:08:17 +0200 +Message-ID: <4112311A.2050808@bigfoot.com> +Date: Thu, 05 Aug 2004 15:07:38 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Valerie Schneider DSI/DEV +Cc: "pgsql-performance@postgresql.org" +Subject: Re: [GENERAL] Tuning queries on large database +References: <200408051229.i75CTZO22267@mu.meteo.fr> +In-Reply-To: <200408051229.i75CTZO22267@mu.meteo.fr> +X-Enigmail-Version: 0.84.2.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/63 +X-Sequence-Number: 7699 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Valerie Schneider DSI/DEV wrote: + +| #--------------------------------------------------------------------------- +| # RESOURCE USAGE (except WAL) +| #--------------------------------------------------------------------------- +| +| # - Memory - +| +| shared_buffers = 30000 # min 16, at least max_connections*2, 8KB each +| #sort_mem = 1024 # min 64, size in KB +| sort_mem = 5000 # min 64, size in KB +| #vacuum_mem = 8192 # min 1024, size in KB +| +| # - Free Space Map - +| +| #max_fsm_pages = 20000 # min max_fsm_relations*16, 6 bytes each +| #max_fsm_relations = 1000 # min 100, ~50 bytes each +| +| # - Kernel Resource Usage - +| +| #max_files_per_process = 1000 # min 25 +| #preload_libraries = '' +| +| +| #--------------------------------------------------------------------------- +| # WRITE AHEAD LOG +| #--------------------------------------------------------------------------- +| +| # - Settings - +| +| #fsync = true # turns forced synchronization on or off +| #wal_sync_method = fsync # the default varies across platforms: +| # fsync, fdatasync, open_sync, or open_datasync +| #wal_buffers = 8 # min 4, 8KB each +| +| # - Checkpoints - +| +| #checkpoint_segments = 3 # in logfile segments, min 1, 16MB each +| checkpoint_segments = 30 # in logfile segments, min 1, 16MB each +| #checkpoint_timeout = 300 # range 30-3600, in seconds +| #checkpoint_warning = 30 # 0 is off, in seconds +| #commit_delay = 0 # range 0-100000, in microseconds +| #commit_siblings = 5 # range 1-1000 +| +| +| #--------------------------------------------------------------------------- +| # QUERY TUNING +| #--------------------------------------------------------------------------- +| +| # - Planner Method Enabling - +| +| #enable_hashagg = true +| #enable_hashjoin = true +| #enable_indexscan = true +| #enable_mergejoin = true +| #enable_nestloop = true +| enable_seqscan = false +| #enable_sort = true +| #enable_tidscan = true +| +| # - Planner Cost Constants - +| +| #effective_cache_size = 1000 # typically 8KB each +| effective_cache_size = 200000 # typically 8KB each +| #random_page_cost = 4 # units are one sequential page fetch cost +| 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) +| +| # - Genetic Query Optimizer - +| +| #geqo = true +| #geqo_threshold = 11 +| #geqo_effort = 1 +| #geqo_generations = 0 +| #geqo_pool_size = 0 # default based on tables in statement, +| # range 128-1024 +| #geqo_selection_bias = 2.0 # range 1.5-2.0 + + + +Your wal_buffers is too small try do bump up your wal_buffers to ~3000, +and see the effects. + +why did you disable the sequential_scan (see later) ? + +Try also to lower the cpu_costs: + +cpu_tuple_cost = 0.005 +cpu_index_tuple_cost = 0.0005 # (same) +cpu_operator_cost = 0.0005 # (same) + +this will push the optimizer to choose the index scans. +If not show us the explain with enable_seqscan = false +and with enable_seqscan = true + +*Mount also your partition with the noatime parameter* + + + + +Regards +Gaeatano Mendola + + + + + + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBEjEY7UpzwH2SGd4RAtxnAKDuTtYZvWMXL7zjHWU20VFtm2V1OACg/Y1l +GZuQ5RviMB2nB4M8G6PW17U= +=HxGz +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Thu Aug 5 10:18:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 902C8D1B229 + for ; + Thu, 5 Aug 2004 10:18:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47793-07 + for ; + Thu, 5 Aug 2004 13:18:50 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 08043D1B171 + for ; + Thu, 5 Aug 2004 10:18:45 -0300 (ADT) +Received: from [134.22.68.4] (dyn-68-4.tor.dsl.tht.net [134.22.68.4]) + by tht.net (Postfix) with ESMTP + id 3787976AF2; Thu, 5 Aug 2004 09:18:50 -0400 (EDT) +Subject: Re: [GENERAL] Tuning queries on large database +From: Rod Taylor +To: Valerie Schneider DSI/DEV +Cc: Christopher Kings-Lynne , + Postgresql Performance +In-Reply-To: <200408050816.i758GxO21560@mu.meteo.fr> +References: <200408050816.i758GxO21560@mu.meteo.fr> +Content-Type: text/plain +Message-Id: <1091711927.84496.22.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Thu, 05 Aug 2004 09:18:47 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/64 +X-Sequence-Number: 7700 + +> so it takes about 28 Gb instead of 68 Gb ! + +Huzzah! + +> For my different queries, it's better but less performant than oracle : + +Not surprising. Oracle has a number of optimizations that we don't have +implemented at this point, particularly where aggregates are involved. + +One that PG could use, particularly for Q4, is the ability to execute a +selective sequential scan based on a read of the index -- right now it +pulls in actual data from the table structure while following the index +-- creates unnecessary disk-head movement. + +The only solution to that, at the moment, is to cluster the table by +pk_data. + + +I am curious though, could you run the below query on both systems and +report back times? + + select 'Q4', * from data where num_poste between 600 and 625; + +I'm wondering if Oracle is using a shortcut since the count(*) doesn't +actually require the data -- just knowledge of whether a matching row +exists or not. + + + +From pgsql-performance-owner@postgresql.org Thu Aug 5 10:21:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 311BAD1B171 + for ; + Thu, 5 Aug 2004 10:21:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49336-09 + for ; + Thu, 5 Aug 2004 13:21:38 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id D47D5D1B1B4 + for ; + Thu, 5 Aug 2004 10:21:33 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: [GENERAL] Tuning queries on large database +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Thu, 5 Aug 2004 09:20:17 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AF21@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] [GENERAL] Tuning queries on large database +thread-index: AcR67dZHMvHa/6IsTO2AHzTsoIutawAAIlTw +From: "Merlin Moncure" +To: "Valerie Schneider DSI/DEV" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/65 +X-Sequence-Number: 7701 + +Another question: +How are you benchmarking your queries? Are you running them from within +psql? Do you plan to run these queries from within an application? + +psql introduces some overhead because it has to scan the result set to +determine the widths of the columns for formatting purposes. Try +returning a result set inside the libpq library if you know C and +compare the times. Of course, if you are already using libpq, this +moot. If you do know libpq, try setting up a loop that fetches the data +in 10k block in a loop...I will wager that you can get this to run in +under two minutes (Q4). + +Merlin + + + + + +From pgsql-performance-owner@postgresql.org Thu Aug 5 10:26:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ECDE2D1B373 + for ; + Thu, 5 Aug 2004 10:26:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51732-07 + for ; + Thu, 5 Aug 2004 13:26:29 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 2EBCDD1B1D5 + for ; + Thu, 5 Aug 2004 10:26:24 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: [GENERAL] Tuning queries on large database +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Thu, 5 Aug 2004 09:26:29 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AF22@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] [GENERAL] Tuning queries on large database +thread-index: AcR67dZHMvHa/6IsTO2AHzTsoIutawAAIlTwAABWfSA= +From: "Merlin Moncure" +To: "Valerie Schneider DSI/DEV" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/66 +X-Sequence-Number: 7702 + +I wrote:=20 +> Another question: +> How are you benchmarking your queries? Are you running them from +within +> psql? Do you plan to run these queries from within an application? +>=20 +> psql introduces some overhead because it has to scan the result set to +> determine the widths of the columns for formatting purposes. Try +> returning a result set inside the libpq library if you know C and +compare +> the times. Of course, if you are already using libpq, this moot. If +you +> do know libpq, try setting up a loop that fetches the data in 10k +block in +> a loop...I will wager that you can get this to run in under two +minutes +> (Q4). + +Whoop, didn't see the aggregate...sorry :) + +Merlin + +From pgsql-admin-owner@postgresql.org Thu Aug 5 11:33:28 2004 +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 F4060D1B275; + Thu, 5 Aug 2004 11:33:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73305-06; Thu, 5 Aug 2004 14:33:23 +0000 (GMT) +Received: from tino.sinectis.com.ar (tino.sinectis.com.ar [216.244.192.232]) + by svr1.postgresql.org (Postfix) with ESMTP id B1F15D1B171; + Thu, 5 Aug 2004 11:33:17 -0300 (ADT) +Received: by tino.sinectis.com.ar (Postfix, from userid 99) + id 70E4A6C695; Thu, 5 Aug 2004 11:33:20 -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: pgsql-performance@postgresql.org +Subject: Temporary tables +Cc: pgsql-admin@postgresql.org +Reply-To: gbarosio@uolsinectis.com.ar +Message-Id: <20040805143320.70E4A6C695@tino.sinectis.com.ar> +Date: Thu, 5 Aug 2004 11:33:20 -0300 (GMT+3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/22 +X-Sequence-Number: 14417 + +The box: +Linux 2.4.24-ck1 +8 Intel(R) Xeon(TM) MP CPU 2.80GHz +4 gb RAM. +Postgresql 7.4.2 + +The problem: +Short in disk space. (waiting new hard) + +The real problem: +Developers usually write queries involving the creation of temporary tables. + +The BF question: +Is a good idea to link this tmp tables to another partition? +If so, how can I link this tmp tables to another partition? +Suggestions? + +Thanks in advance! +Guido + + + + +From pgsql-performance-owner@postgresql.org Thu Aug 5 12:04:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 02D9DD1B1C9 + for ; + Thu, 5 Aug 2004 12:04:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81403-10 + for ; + Thu, 5 Aug 2004 15:04:07 +0000 (GMT) +Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) + by svr1.postgresql.org (Postfix) with ESMTP id C18DFD1B17A + for ; + Thu, 5 Aug 2004 12:04:05 -0300 (ADT) +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1Bsjml-0003Px-00 + for ; Thu, 05 Aug 2004 17:04:03 +0200 +Date: Thu, 5 Aug 2004 17:04:03 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Performance Bottleneck +Message-ID: <20040805150403.GA13056@uio.no> +References: <410FDC53.5080509@bigfoot.com> + <20040804153624.GA27551@pobox.com> + <41110D06.5090900@ethereal-realms.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: +X-Operating-System: Linux 2.6.6 on a i686 +User-Agent: Mutt/1.5.6+20040722i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/68 +X-Sequence-Number: 7704 + +On Thu, Aug 05, 2004 at 08:40:35AM +0200, Pierre-Fr�d�ric Caillaud wrote: +> Apache processes running for 30 minutes ?..... +> +> My advice : use frames and Javascript ! + +My advice: Stay out of frames and Javascript if you can avoid it. The first +is severely outdated technology, and the other one might well be disabled at +the client side. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Fri Aug 6 13:11:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6DC7D5E46C7 + for ; + Fri, 6 Aug 2004 13:11:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13919-09 + for ; + Fri, 6 Aug 2004 16:11:16 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 9152F5E46C5 + for ; + Fri, 6 Aug 2004 13:11:08 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i76GB65p081375 + for ; Fri, 6 Aug 2004 16:11:13 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i76G1iS3080137 + for pgsql-performance@postgresql.org; Fri, 6 Aug 2004 16:01:44 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Temporary tables +Date: Thu, 05 Aug 2004 17:37:50 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 30 +Message-ID: <4112544E.2060706@bigfoot.com> +References: <20040805143320.70E4A6C695@tino.sinectis.com.ar> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: G u i d o B a r o s i o +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: <20040805143320.70E4A6C695@tino.sinectis.com.ar> +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/76 +X-Sequence-Number: 7712 + +G u i d o B a r o s i o wrote: + +> The box: +> Linux 2.4.24-ck1 +> 8 Intel(R) Xeon(TM) MP CPU 2.80GHz +> 4 gb RAM. +> Postgresql 7.4.2 +> +> The problem: +> Short in disk space. (waiting new hard) +> +> The real problem: +> Developers usually write queries involving the creation of temporary tables. + +I seen too this behavior, till I explained that this is a valid sql: + +select T.* from ( select * from table t where a = 5 ) AS T join foo using ( bar ); + + +show us a typical function that use temporary tables. + + + +Regards +Gaetano Mendola + + + + + + +From pgsql-performance-owner@postgresql.org Thu Aug 5 12:42:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BB980D1B341 + for ; + Thu, 5 Aug 2004 12:42:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97944-02 + for ; + Thu, 5 Aug 2004 15:42:04 +0000 (GMT) +Received: from sardegna.mbigroup.it (ns1.mbigroup.it [213.188.200.195]) + by svr1.postgresql.org (Postfix) with ESMTP id 290F6D1B229 + for ; + Thu, 5 Aug 2004 12:41:58 -0300 (ADT) +Received: from mailserver.bo.mbigroup.it (localhost.localdomain [127.0.0.1]) + by sardegna.mbigroup.it (8.12.10/8.12.10) with ESMTP id i75FfuPM030689; + Thu, 5 Aug 2004 17:41:56 +0200 +Received: from [127.0.0.1] (acasula.dev.mbigroup.it [192.168.21.15]) + by mailserver.bo.mbigroup.it (8.11.6/8.11.6) with ESMTP id i75Fd0909402; + Thu, 5 Aug 2004 17:39:00 +0200 +Message-ID: <41125519.9090907@bigfoot.com> +Date: Thu, 05 Aug 2004 17:41:13 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: G u i d o B a r o s i o , + "pgsql-performance@postgresql.org" +Subject: Re: Temporary tables +References: <20040805143320.70E4A6C695@tino.sinectis.com.ar> +In-Reply-To: <20040805143320.70E4A6C695@tino.sinectis.com.ar> +X-Enigmail-Version: 0.84.2.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200408/69 +X-Sequence-Number: 7705 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +G u i d o B a r o s i o wrote: + +| The box: +| Linux 2.4.24-ck1 +| 8 Intel(R) Xeon(TM) MP CPU 2.80GHz +| 4 gb RAM. +| Postgresql 7.4.2 +| +| The problem: +| Short in disk space. (waiting new hard) +| +| The real problem: +| Developers usually write queries involving the creation of temporary tables. + +I seen too this behavior, till I explained that this is a valid sql: + +select T.* from ( select * from table t where a = 5 ) AS T join foo using ( bar ); + + +show us a typical function that use temporary tables. + + + +Regards +Gaetano Mendola + + + + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD4DBQFBElSx7UpzwH2SGd4RAhnkAKDABtA1fZSCCF/WAP5TUBJnHdWHYACWLjjQ +LgncGg4+b0lPCQbafXVG6w== +=1f1i +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Mon Aug 9 00:06:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C632E14B287A + for ; + Mon, 9 Aug 2004 00:05:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43184-08 + for ; + Mon, 9 Aug 2004 03:05:11 +0000 (GMT) +Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) + by svr1.postgresql.org (Postfix) with ESMTP id 49B5F14B28BB + for ; + Mon, 9 Aug 2004 00:04:45 -0300 (ADT) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id 3755934E91; Mon, 9 Aug 2004 00:04:37 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id 31286346BC + for ; + Mon, 9 Aug 2004 00:04:37 -0300 (ADT) +X-Return-Path: +X-Received: from localhost ([unix socket]) + by ganymede.hub.org (Cyrus v2.2.6) with LMTPA; + Thu, 05 Aug 2004 15:13:37 -0300 +X-Sieve: CMU Sieve 2.2 +X-Received: from localhost (localhost.hub.org [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id B5D783CBC0 + for ; Thu, 5 Aug 2004 15:11:15 -0300 (ADT) +X-Received: from mail.postgresql.org [200.46.204.71] + by localhost with IMAP (fetchmail-6.2.5) + for scrappy@localhost (single-drop); + Thu, 05 Aug 2004 15:11:15 -0300 (ADT) +X-Received: from svr1.postgresql.org ([unix socket]) + by svr1.postgresql.org (Cyrus v2.2.6) with LMTPA; + Thu, 05 Aug 2004 15:10:09 -0300 +X-Sieve: CMU Sieve 2.2 +X-Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ED4D2D1B252 + for ; Thu, 5 Aug 2004 15:10:08 -0300 (ADT) +X-Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44853-06 for ; + Thu, 5 Aug 2004 18:10:06 +0000 (GMT) +X-Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.193]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D8EED1B1C9 + for ; + Thu, 5 Aug 2004 15:10:02 -0300 (ADT) +X-Received: by mproxy.gmail.com with SMTP id 73so18212rnk + for ; + Thu, 05 Aug 2004 11:10:01 -0700 (PDT) +X-Received: by 10.38.9.22 with SMTP id 22mr62172rni; + Thu, 05 Aug 2004 11:10:01 -0700 (PDT) +Message-ID: <5cfdfaf7040805111013a769af@mail.gmail.com> +Date: Thu, 5 Aug 2004 13:10:01 -0500 +From: Jim Thomason +Reply-To: jim@jimandkoka.com +To: psql-performance@postgresql.org +Subject: performance with column orders +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-DCC: : +X-Spam-Pyzor: +ReSent-Date: Mon, 9 Aug 2004 00:04:31 -0300 (ADT) +Resent-From: "Marc G. Fournier" +Resent-To: pgsql-performance@postgresql.org +ReSent-Subject: performance with column orders +ReSent-Message-ID: <20040809000431.L52647@ganymede.hub.org> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/109 +X-Sequence-Number: 7745 + +I couldn't track down recent info in the archives, so I figured I'd ask here. + +Does the order of columns still have an impact on table speed? Back in +the olden days, it used to be that fixed width columns (integer, +tinyint, etc.) should be the first ("left") columns in the table and +variable width ones should be towards the end ("right"). This allowed +a database to line up the columns better on disk and give you a speed +boost. + +So, does Postgres still care about it? And, if so, how much? The posts +I found were from 2 years ago, and indicated that there is a minor +increase, but not a lot. Incidentally, could anyone quantify that in +any fashion? + +Thanks, + +-Jim.... + +From pgsql-performance-owner@postgresql.org Fri Aug 6 01:43:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D671E5E38A9 + for ; + Fri, 6 Aug 2004 01:43:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31726-08 + for ; + Fri, 6 Aug 2004 04:43:10 +0000 (GMT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A9415E3AB5 + for ; + Fri, 6 Aug 2004 01:42:49 -0300 (ADT) +Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i764geUi012228; Fri, 6 Aug 2004 12:42:41 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <41130D16.7030902@familyhealth.com.au> +Date: Fri, 06 Aug 2004 12:46:14 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jesper Krogh +Cc: pgsql-performance@postgresql.org +Subject: Re: pg_dump performance? +References: +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/72 +X-Sequence-Number: 7708 + +Is it the dump or the restore that's really slow? + +Chris + +Jesper Krogh wrote: + +> I have a database that I should migrate from 7.3 -> 7.4.3 but pg_dump | +> psql seems to take forever. (Several hours) Is there anything that can I +> do to speed it up? +> +> The databse is primary a table with 300.000 records of about 200Kbytes +> each. ~ 60 GB. +> +> This is becoming an issue with the daily backup too.. (running pg_dump +> over night ) +> +> Jesper +> + +From pgsql-performance-owner@postgresql.org Fri Aug 6 02:05:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 893085E3AB3 + for ; + Fri, 6 Aug 2004 02:05:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39828-05 + for ; + Fri, 6 Aug 2004 05:05:17 +0000 (GMT) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id C61995E38A9 + for ; + Fri, 6 Aug 2004 02:05:15 -0300 (ADT) +Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1Bswul-0006Q3-00 + for ; Fri, 06 Aug 2004 07:05:13 +0200 +Received: from linuxnews.dk ([81.7.132.92]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Fri, 06 Aug 2004 07:05:11 +0200 +Received: from jesper by linuxnews.dk with local (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Fri, 06 Aug 2004 07:05:11 +0200 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +From: Jesper Krogh +Subject: Re: pg_dump performance? +Date: Fri, 6 Aug 2004 05:05:08 +0000 (UTC) +Lines: 11 +Message-ID: +References: + <41130D16.7030902@familyhealth.com.au> +X-Complaints-To: usenet@sea.gmane.org +X-Gmane-NNTP-Posting-Host: linuxnews.dk +User-Agent: slrn/0.9.8.0 (Linux) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/73 +X-Sequence-Number: 7709 + +I gmane.comp.db.postgresql.performance, skrev Christopher Kings-Lynne: +> Is it the dump or the restore that's really slow? + +Primarily the dump, it seems to be CPU-bound on the postmaster' process. + +No signs on IO-bottleneck when I try to monitor with iostat or vmstat + +-- +./Jesper Krogh, jesper@krogh.cc +Jabber ID: jesper@jabbernet.dk + + + +From pgsql-performance-owner@postgresql.org Fri Aug 6 13:30:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AA3595E46C6 + for ; + Fri, 6 Aug 2004 13:30:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21616-09 + for ; + Fri, 6 Aug 2004 16:30:03 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id D061A5E40BA + for ; + Fri, 6 Aug 2004 13:29:54 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6006894; Fri, 06 Aug 2004 09:31:16 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Gaetano Mendola , + Paul Serby +Subject: Re: The black art of postgresql.conf tweaking +Date: Fri, 6 Aug 2004 09:29:19 -0700 +User-Agent: KMail/1.4.3 +References: <4110DA83.7020505@clockltd.com> <411100EC.8010802@bigfoot.com> +In-Reply-To: <411100EC.8010802@bigfoot.com> +Cc: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408060929.19840.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/79 +X-Sequence-Number: 7715 + +Paul, + +> > Physical Memory: 2077264 kB + +> > sort_mem = 12000 + +Hmmm. Someone may already have mentioned this, but that looks problematic. +You're allowing up to 12MB per sort, and up to 300 connections. Even if each +concurrent connection averages only one sort (and they can use more) that's +3600MB ... roughly 1.5 times your *total* RAM, leaving out RAM for Apache, +postmaster, shared buffers, etc. + +I strongly suggest that you either decrease your total connections or your +sort_mem, or both. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Aug 6 14:07:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 823F05E46C5 + for ; + Fri, 6 Aug 2004 14:07:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35170-07 + for ; + Fri, 6 Aug 2004 17:07:27 +0000 (GMT) +Received: from mail.academyoflearning.ca (s64-180-138-192.bc.hsia.telus.net + [64.180.138.192]) + by svr1.postgresql.org (Postfix) with ESMTP id B62B25E46C0 + for ; + Fri, 6 Aug 2004 14:07:22 -0300 (ADT) +Received: from [192.168.1.10] (d216-232-247-236.bchsia.telus.net + [216.232.247.236]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by mail.academyoflearning.ca (Postfix) with ESMTP id 6899E34DBC; + Fri, 6 Aug 2004 10:06:53 -0700 (PDT) +Subject: Re: Performance Bottleneck +From: Mike Benoit +To: Gaetano Mendola +Cc: pgsql-performance@postgresql.org +In-Reply-To: <4110FFF6.1030001@bigfoot.com> +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> +Content-Type: text/plain +Date: Fri, 06 Aug 2004 10:06:51 -0700 +Message-Id: <1091812011.7149.25.camel@ipso.snappymail.ca> +Mime-Version: 1.0 +X-Mailer: Evolution 1.5.91-2mdk +Content-Transfer-Encoding: 7bit +X-snappymail-MailScanner-Information: Please contact the ISP for more + information +X-snappymail-MailScanner: Found to be clean +X-snappymail-MailScanner-SpamCheck: not spam, SpamAssassin (score=1.911, + required 5, AWL -0.79, RCVD_IN_DYNABLOCK 2.60, RCVD_IN_SORBS 0.10) +X-snappymail-MailScanner-SpamScore: s +X-MailScanner-From: ipso@snappymail.ca +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/80 +X-Sequence-Number: 7716 + +On Wed, 2004-08-04 at 17:25 +0200, Gaetano Mendola wrote: + +> > The queries themselves are simple, normally drawing information from one +> > table with few conditions or in the most complex cases using joins on +> > two table or sub queries. These behave very well and always have, the +> > problem is that these queries take place in rather large amounts due to +> > the dumb nature of the scripts themselves. +> +> Show us the explain analyze on that queries, how many rows the tables are +> containing, the table schema could be also usefull. +> + +If the queries themselves are optimized as much as they can be, and as +you say, its just the sheer amount of similar queries hitting the +database, you could try using prepared queries for ones that are most +often executed to eliminate some of the overhead. + +I've had relatively good success with this in the past, and it doesn't +take very much code modification. + +-- +Mike Benoit + + +From pgsql-performance-owner@postgresql.org Fri Aug 6 15:30:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 93F8F5E46EA + for ; + Fri, 6 Aug 2004 15:27:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67333-06 + for ; + Fri, 6 Aug 2004 18:27:51 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 574AD5E46E7 + for ; + Fri, 6 Aug 2004 15:27:47 -0300 (ADT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i76IRHe18249; + Fri, 6 Aug 2004 20:27:18 +0200 +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 i76IRgZ06997; + Fri, 6 Aug 2004 20:27:42 +0200 +Message-ID: <4113CD75.2060508@bigfoot.com> +Date: Fri, 06 Aug 2004 20:27:01 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Josh Berkus +Cc: Paul Serby , + pgsql-performance@postgresql.org +Subject: Re: The black art of postgresql.conf tweaking +References: <4110DA83.7020505@clockltd.com> <411100EC.8010802@bigfoot.com> + <200408060929.19840.josh@agliodbs.com> +In-Reply-To: <200408060929.19840.josh@agliodbs.com> +X-Enigmail-Version: 0.84.2.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/81 +X-Sequence-Number: 7717 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Josh Berkus wrote: + +| Paul, +| +| +|>>Physical Memory: 2077264 kB +| +| +|>>sort_mem = 12000 +| +| +| Hmmm. Someone may already have mentioned this, but that looks problematic. +| You're allowing up to 12MB per sort, and up to 300 connections. Even if each +| concurrent connection averages only one sort (and they can use more) that's +| 3600MB ... roughly 1.5 times your *total* RAM, leaving out RAM for Apache, +| postmaster, shared buffers, etc. +| +| I strongly suggest that you either decrease your total connections or your +| sort_mem, or both. + +Of course your are speaking about the "worst case", I aplly in scenarios like +this on the rule 80/20: 80% of connection will perform a sort and 20% will allocate +memory for the sort operation in the same window time: + +300 -- 80% --> 240 --> 20% --> 48 + + +48 * 12MB = 576 MB + +that seems resonable with the total ammount of memory available. + +Am I too optimistic? + + + +Regards +Gaetano Mendola + + + + + + + + + + + + + + + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBE81z7UpzwH2SGd4RAuzzAJ98Ze0HQedKaZ/laT7P1OS44FG0CwCfaWkY +MAR1TEY1+x61PoXjK/K8Q4Y= +=8UmF +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Fri Aug 6 20:01:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CB4935E3AC5 + for ; + Fri, 6 Aug 2004 19:58:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45471-06 + for ; + Fri, 6 Aug 2004 22:58:36 +0000 (GMT) +Received: from fep3.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id AD7815E46C5 + for ; + Fri, 6 Aug 2004 19:58:31 -0300 (ADT) +Received: from [127.0.0.1] (d226-86-215.home.cgocable.net [24.226.86.215]) + by fep3.cogeco.net (Postfix) with ESMTP + id 08C902F0A; Fri, 6 Aug 2004 18:58:35 -0400 (EDT) +Message-ID: <41140D17.7070101@ethereal-realms.org> +Date: Fri, 06 Aug 2004 18:58:31 -0400 +From: Martin Foster +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7.2) Gecko/20040803 +X-Accept-Language: en-ca, en-gb, en-us, en +MIME-Version: 1.0 +To: Gaetano Mendola , + PostgreSQL Performance +Subject: Re: Performance Bottleneck +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> +In-Reply-To: <4110FFF6.1030001@bigfoot.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.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/82 +X-Sequence-Number: 7718 + +Gaetano Mendola wrote: +> +> +> Let start from your postgres configuration: +> +> shared_buffers = 8192 <==== This is really too small for your +> configuration +> sort_mem = 2048 +> +> wal_buffers = 128 <==== This is really too small for your configuration +> +> effective_cache_size = 16000 +> +> change this values in: +> +> shared_buffers = 50000 +> sort_mem = 16084 +> +> wal_buffers = 1500 +> +> effective_cache_size = 32000 +> +> +> to bump up the shm usage you have to configure your OS in order to be +> allowed to use that ammount of SHM. +> +> This are the numbers that I feel good for your HW, the second step now is +> analyze your queries +> + +These changes have yielded some visible improvements, with load averages +rarely going over the anything noticeable. However, I do have a +question on the matter, why do these values seem to be far higher then +what a frequently pointed to document would indicate as necessary? + +http://www.varlena.com/GeneralBits/Tidbits/perf.html + +I am simply curious, as this clearly shows that my understanding of +PostgreSQL is clearly lacking when it comes to tweaking for the hardware. + + Martin Foster + Creator/Designer Ethereal Realms + martin@ethereal-realms.org + + + +From pgsql-performance-owner@postgresql.org Fri Aug 6 20:19:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 715DB5E46C0 + for ; + Fri, 6 Aug 2004 20:18:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49496-08 + for ; + Fri, 6 Aug 2004 23:18:20 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 57D835E46D3 + for ; + Fri, 6 Aug 2004 20:18:15 -0300 (ADT) +Received: from [64.81.245.111] (HELO temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6012012; Fri, 06 Aug 2004 16:19:34 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Gaetano Mendola +Subject: Re: The black art of postgresql.conf tweaking +Date: Fri, 6 Aug 2004 16:18:40 -0700 +User-Agent: KMail/1.5.4 +Cc: Paul Serby , + pgsql-performance@postgresql.org +References: <4110DA83.7020505@clockltd.com> + <200408060929.19840.josh@agliodbs.com> + <4113CD75.2060508@bigfoot.com> +In-Reply-To: <4113CD75.2060508@bigfoot.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200408061618.40047.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/83 +X-Sequence-Number: 7719 + +Gaetano, + +> Of course your are speaking about the "worst case", I aplly in scenarios +like +> this on the rule 80/20: 80% of connection will perform a sort and 20% will +allocate +> memory for the sort operation in the same window time: + +Well, I suppose it depends on how aggresive your connection pooling is. If +you minimize idle connections, then 300 connections can mean 200 concurrent +queries. And since Paul *is* having problems, this is worth looking into. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Aug 6 20:30:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4661C5E46C0 + for ; + Fri, 6 Aug 2004 20:30:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52483-09 + for ; + Fri, 6 Aug 2004 23:30:08 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C6BC5E3AC5 + for ; + Fri, 6 Aug 2004 20:30:03 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i76NU4Sp015840 + for ; Fri, 6 Aug 2004 23:30:04 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i76NIk0p015224 + for pgsql-performance@postgresql.org; Fri, 6 Aug 2004 23:18:46 GMT +From: Martin Foster +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7.2) Gecko/20040803 +X-Accept-Language: en-ca, en-gb, en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Performance Bottleneck +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> + <1091812011.7149.25.camel@ipso.snappymail.ca> +In-Reply-To: <1091812011.7149.25.camel@ipso.snappymail.ca> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 81 +Message-ID: +Date: Fri, 06 Aug 2004 23:18:49 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/84 +X-Sequence-Number: 7720 + +Mike Benoit wrote: + +> On Wed, 2004-08-04 at 17:25 +0200, Gaetano Mendola wrote: +> +> +>>>The queries themselves are simple, normally drawing information from one +>>>table with few conditions or in the most complex cases using joins on +>>>two table or sub queries. These behave very well and always have, the +>>>problem is that these queries take place in rather large amounts due to +>>>the dumb nature of the scripts themselves. +>> +>>Show us the explain analyze on that queries, how many rows the tables are +>>containing, the table schema could be also usefull. +>> +> +> +> If the queries themselves are optimized as much as they can be, and as +> you say, its just the sheer amount of similar queries hitting the +> database, you could try using prepared queries for ones that are most +> often executed to eliminate some of the overhead. +> +> I've had relatively good success with this in the past, and it doesn't +> take very much code modification. +> + +One of the biggest problems is most probably related to the indexes. +Since the performance penalty of logging the information needed to see +which queries are used and which are not is a slight problem, then I +cannot really make use of it for now. + +However, I am curious how one would go about preparing query? Is this +similar to the DBI::Prepare statement with placeholders and simply +changing the values passed on execute? Or is this something database +level such as a view et cetera? + +SELECT + Post.PostIDNumber, + Post.$format, + Post.PuppeteerLogin, + Post.PuppetName, + Post.PostCmd, + Post.PostClass +FROM Post +WHERE Post.PostIDNumber > ?::INT + AND (Post.PostTo='all' OR Post.PostTo=?) + AND (NOT EXISTS (SELECT PuppetIgnore.PuppetLogin + FROM PuppetIgnore + WHERE PuppetIgnore.PuppetIgnore='global' + AND PuppetIgnore.PuppeteerLogin=? + AND PuppetIgnore.PuppetLogin=Post.PuppeteerLogin) + OR Post.PuppeteerLogin IS NULL) + AND (NOT EXISTS (SELECT PuppetIgnore.PuppetName + FROM PuppetIgnore + WHERE PuppetIgnore.PuppetIgnore='single' + AND PuppetIgnore.PuppeteerLogin=? + AND PuppetIgnore.PuppetName=Post.PuppetName) + OR Post.PuppetName IS NULL) +ORDER BY Post.PostIDNumber LIMIT 100 + +The range is determined from the previous run or through a query listed +below. It was determined that using INT was far faster then limiting +by timestamp. + +SELECT MIN(PostIDNumber) +FROM Post +WHERE RealmName=? + AND PostClass IN ('general','play') + AND PostTo='all' + +The above simply provides a starting point, nothing more. Once posts +are pulled the script will throw in the last pulled number as to start +from a fresh point. + +Under MySQL time was an stored as an INT which may have helped it handle +timestamps more efficiently. It also made use of three or more +queries, where two were done to generate an IN statement for the query +actually running at the time. + + Martin Foster + Creator/Designer Ethereal Realms + martin@ethereal-realms.org + +From pgsql-performance-owner@postgresql.org Fri Aug 6 20:30:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 075E85E46C7 + for ; + Fri, 6 Aug 2004 20:30:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54834-02 + for ; + Fri, 6 Aug 2004 23:30:08 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C8ED5E3F15 + for ; + Fri, 6 Aug 2004 20:30:03 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i76NU4Sv015840 + for ; Fri, 6 Aug 2004 23:30:04 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i76NOqHa015597 + for pgsql-performance@postgresql.org; Fri, 6 Aug 2004 23:24:52 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Performance Bottleneck +Date: Sat, 07 Aug 2004 01:24:18 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 65 +Message-ID: <41141322.3010200@bigfoot.com> +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> + <41140D17.7070101@ethereal-realms.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Martin Foster +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: <41140D17.7070101@ethereal-realms.org> +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/85 +X-Sequence-Number: 7721 + +Martin Foster wrote: + +> Gaetano Mendola wrote: +> +>> +>> +>> Let start from your postgres configuration: +>> +>> shared_buffers = 8192 <==== This is really too small for your +>> configuration +>> sort_mem = 2048 +>> +>> wal_buffers = 128 <==== This is really too small for your +>> configuration +>> +>> effective_cache_size = 16000 +>> +>> change this values in: +>> +>> shared_buffers = 50000 +>> sort_mem = 16084 +>> +>> wal_buffers = 1500 +>> +>> effective_cache_size = 32000 +>> +>> +>> to bump up the shm usage you have to configure your OS in order to be +>> allowed to use that ammount of SHM. +>> +>> This are the numbers that I feel good for your HW, the second step now is +>> analyze your queries +>> +> +> These changes have yielded some visible improvements, with load averages +> rarely going over the anything noticeable. However, I do have a +> question on the matter, why do these values seem to be far higher then +> what a frequently pointed to document would indicate as necessary? +> +> http://www.varlena.com/GeneralBits/Tidbits/perf.html +> +> I am simply curious, as this clearly shows that my understanding of +> PostgreSQL is clearly lacking when it comes to tweaking for the hardware. + +Unfortunately there is no a "wizard tuning" for postgres so each one of +us have a own "school". The data I gave you are oversized to be sure +to achieve improvements. Now you can start to decrease these values +( starting from the wal_buffers ) in order to find the good compromise +with your HW. + + + + +Regards +Gaetano Mendola + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Fri Aug 6 20:43:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 03CC45E46D8 + for ; + Fri, 6 Aug 2004 20:42:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58183-02 + for ; + Fri, 6 Aug 2004 23:42:13 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 2057B5E4699 + for ; + Fri, 6 Aug 2004 20:42:08 -0300 (ADT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i76Nfk019452; + Sat, 7 Aug 2004 01:41:46 +0200 +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 i76NgAZ08004; + Sat, 7 Aug 2004 01:42:10 +0200 +Message-ID: <41141728.1050608@bigfoot.com> +Date: Sat, 07 Aug 2004 01:41:28 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Josh Berkus , + "pgsql-performance@postgresql.org" +Subject: Re: The black art of postgresql.conf tweaking +References: <4110DA83.7020505@clockltd.com> + <200408060929.19840.josh@agliodbs.com> + <4113CD75.2060508@bigfoot.com> + <200408061618.40047.josh@agliodbs.com> +In-Reply-To: <200408061618.40047.josh@agliodbs.com> +X-Enigmail-Version: 0.84.2.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/86 +X-Sequence-Number: 7722 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Josh Berkus wrote: + +| Gaetano, +| +| +|>Of course your are speaking about the "worst case", I aplly in scenarios +| +| like +| +|>this on the rule 80/20: 80% of connection will perform a sort and 20% will +| +| allocate +| +|>memory for the sort operation in the same window time: +| +| +| Well, I suppose it depends on how aggresive your connection pooling is. If +| you minimize idle connections, then 300 connections can mean 200 concurrent +| queries. And since Paul *is* having problems, this is worth looking into. + +With 4 CPU ( like Paul have ) there is a lot of space in order to have 200 +concurrent connection running but I don't believe that all 200 togheter are +allocating space for sort, I have not seen the code but I'm quite confident +that the memory for sort is released as soon the sort operation is over, +not at the end of connection. + + + +Regards +Gaetano Mendola + + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBFBcn7UpzwH2SGd4RAuNhAJ0f+NVUlRUszX+gUE6EfYiFYQy5JQCgnaRj +HcguR1U3CgvQiZ4a56PBtVU= +=6Jzo +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Fri Aug 6 21:01:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CF345E4699 + for ; + Fri, 6 Aug 2004 21:00:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60800-08 + for ; + Sat, 7 Aug 2004 00:00: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 721895E4249 + for ; + Fri, 6 Aug 2004 21:00:29 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7700LLt024610; + Fri, 6 Aug 2004 20:00:21 -0400 (EDT) +To: Martin Foster +Cc: Gaetano Mendola , + PostgreSQL Performance +Subject: Re: Performance Bottleneck +In-reply-to: <41140D17.7070101@ethereal-realms.org> +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> + <41140D17.7070101@ethereal-realms.org> +Comments: In-reply-to Martin Foster + message dated "Fri, 06 Aug 2004 18:58:31 -0400" +Date: Fri, 06 Aug 2004 20:00:21 -0400 +Message-ID: <24609.1091836821@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/87 +X-Sequence-Number: 7723 + +Martin Foster writes: +> Gaetano Mendola wrote: +>> change this values in: +>> shared_buffers = 50000 +>> sort_mem = 16084 +>> +>> wal_buffers = 1500 + +This value of wal_buffers is simply ridiculous. + +There isn't any reason to set wal_buffers higher than the amount of +WAL log data that will be generated by a single transaction, because +whatever is in the buffers will be flushed at transaction commit. +If you are mainly dealing with heavy concurrency then it's the mean time +between transaction commits that matters, and that's even less than the +average transaction length. + +Even if you are mainly interested in the performance of large updating +transactions that are not concurrent with anything else (bulk data load, +perhaps), I'm not sure that I see any value in setting wal_buffers so +high. The data will have to go to disk before commit in any case, and +buffering so much of it just means that you are going to have a serious +spike in disk traffic right before commit. It's almost certainly better +to keep wal_buffers conservatively small and let the data trickle out as +the transaction proceeds. I don't actually think there is anything very +wrong with the default value (8) ... perhaps it is too small, but it's +not two orders of magnitude too small. + +In 8.0, the presence of the background writer may make it useful to run +with wal_buffers somewhat higher than before, but I still doubt that +order-of-a-thousand buffers would be useful. The RAM would almost +certainly be better spent on general-purpose disk buffers or kernel +cache. + +Note though that this is just informed opinion, as I've never done or +seen any benchmarks that examine the results of changing wal_buffers +while holding other things constant. Has anyone tried it? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 6 21:30:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6BE0B5E3E30 + for ; + Fri, 6 Aug 2004 21:28:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68710-02 + for ; + Sat, 7 Aug 2004 00:28:40 +0000 (GMT) +Received: from hotmail.com (bay7-f23.bay7.hotmail.com [64.4.11.23]) + by svr1.postgresql.org (Postfix) with ESMTP id E5D025E3AC5 + for ; + Fri, 6 Aug 2004 21:28:34 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Fri, 6 Aug 2004 17:28:39 -0700 +Received: from 200.24.104.55 by by7fd.bay7.hotmail.msn.com with HTTP; + Sat, 07 Aug 2004 00:28:38 GMT +X-Originating-IP: [200.24.104.55] +X-Originating-Email: [mileruiz@hotmail.com] +X-Sender: mileruiz@hotmail.com +From: "sandra ruiz" +To: pgsql-performance@postgresql.org +Subject: Question about Generating Possible Plans by the planner/optimizer +Date: Fri, 06 Aug 2004 19:28:38 -0500 +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1; format=flowed +Message-ID: +X-OriginalArrivalTime: 07 Aug 2004 00:28:39.0193 (UTC) + FILETIME=[7C214890:01C47C15] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/88 +X-Sequence-Number: 7724 + +in the docummentation about the planer it says: + +"It first combines all possible ways of scanning and joining the relations +that appear in a query" + +I would like to know if there's a time limit to do that or if it just scans +ALL the posibilities until it finishes..no matter the time it takes.. + + +thanks in advance. + +_________________________________________________________________ +MSN Amor: busca tu � naranja http://latam.msn.com/amor/ + + +From pgsql-performance-owner@postgresql.org Fri Aug 6 21:56:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 24AF35E40BB + for ; + Fri, 6 Aug 2004 21:55:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74995-02 + for ; + Sat, 7 Aug 2004 00:54:56 +0000 (GMT) +Received: from mpls-qmqp-04.inet.qwest.net (mpls-qmqp-04.inet.qwest.net + [63.231.195.115]) + by svr1.postgresql.org (Postfix) with SMTP id 509F85E4248 + for ; + Fri, 6 Aug 2004 21:54:50 -0300 (ADT) +Received: (qmail 30662 invoked by uid 0); 7 Aug 2004 00:54:55 -0000 +Received: from mpls-pop-04.inet.qwest.net (63.231.195.4) + by mpls-qmqp-04.inet.qwest.net with QMQP; 7 Aug 2004 00:54:55 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-04.inet.qwest.net with SMTP; 7 Aug 2004 00:54:55 -0000 +Date: Fri, 06 Aug 2004 18:56:18 -0600 +Message-Id: <1091840178.27166.255.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Gaetano Mendola" +Cc: "Martin Foster" , + pgsql-performance@postgresql.org +Subject: Re: Performance Bottleneck +In-Reply-To: <41141322.3010200@bigfoot.com> +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> + <41140D17.7070101@ethereal-realms.org> <41141322.3010200@bigfoot.com> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/89 +X-Sequence-Number: 7725 + +On Fri, 2004-08-06 at 17:24, Gaetano Mendola wrote: +> Martin Foster wrote: +> +> > Gaetano Mendola wrote: +> > +> >> +> >> +> >> Let start from your postgres configuration: +> >> +> >> shared_buffers = 8192 <==== This is really too small for your +> >> configuration +> >> sort_mem = 2048 +> >> +> >> wal_buffers = 128 <==== This is really too small for your +> >> configuration +> >> +> >> effective_cache_size = 16000 +> >> +> >> change this values in: +> >> +> >> shared_buffers = 50000 +> >> sort_mem = 16084 +> >> +> >> wal_buffers = 1500 +> >> +> >> effective_cache_size = 32000 +> >> +> >> +> >> to bump up the shm usage you have to configure your OS in order to be +> >> allowed to use that ammount of SHM. +> >> +> >> This are the numbers that I feel good for your HW, the second step now is +> >> analyze your queries +> >> +> > +> > These changes have yielded some visible improvements, with load averages +> > rarely going over the anything noticeable. However, I do have a +> > question on the matter, why do these values seem to be far higher then +> > what a frequently pointed to document would indicate as necessary? +> > +> > http://www.varlena.com/GeneralBits/Tidbits/perf.html +> > +> > I am simply curious, as this clearly shows that my understanding of +> > PostgreSQL is clearly lacking when it comes to tweaking for the hardware. +> +> Unfortunately there is no a "wizard tuning" for postgres so each one of +> us have a own "school". The data I gave you are oversized to be sure +> to achieve improvements. Now you can start to decrease these values +> ( starting from the wal_buffers ) in order to find the good compromise +> with your HW. + +FYI, my school of tuning is to change one thing at a time some +reasonable percentage (shared_buffers from 1000 to 2000) and measure the +change under simulated load. Make another change, test it, chart the +shape of the change line. It should look something like this for most +folks: + +shared_buffers | q/s (more is better) +100 | 20 +200 | 45 +400 | 80 +1000 | 100 +... levels out here... +8000 | 110 +10000 | 108 +20000 | 40 +30000 | 20 + +Note it going back down as we exceed our memory and start swapping +shared_buffers. Where that happens on your machine is determined by +many things like your machine's memory, memory bandwidth, type of load, +etc... but it will happen on most machines and when it does, it often +happens at the worst times, under heavy parallel load. + +Unless testing shows it's faster, 10000 or 25% of mem (whichever is +less) is usually a pretty good setting for shared_buffers. Large data +sets may require more than 10000, but going over 25% on machines with +large memory is usually a mistake, especially servers that do anything +other than just PostgreSQL. + +You're absolutely right about one thing, there's no automatic wizard for +tuning this stuff. + + +From pgsql-performance-owner@postgresql.org Fri Aug 6 22:13:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9797F5E46CA + for ; + Fri, 6 Aug 2004 22:12:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78664-04 + for ; + Sat, 7 Aug 2004 01:11:53 +0000 (GMT) +Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) + by svr1.postgresql.org (Postfix) with ESMTP id F21B95E40BB + for ; + Fri, 6 Aug 2004 22:11:44 -0300 (ADT) +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1BtFkS-0001k1-00 + for ; Sat, 07 Aug 2004 03:11:48 +0200 +Date: Sat, 7 Aug 2004 03:11:48 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Question about Generating Possible Plans by the planner/optimizer +Message-ID: <20040807011148.GA6617@uio.no> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: Linux 2.6.6 on a i686 +User-Agent: Mutt/1.5.6+20040722i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/90 +X-Sequence-Number: 7726 + +On Fri, Aug 06, 2004 at 07:28:38PM -0500, sandra ruiz wrote: +> in the docummentation about the planer it says: +> +> "It first combines all possible ways of scanning and joining the relations +> that appear in a query" +> +> I would like to know if there's a time limit to do that or if it just scans +> ALL the posibilities until it finishes..no matter the time it takes.. + +Depends; if you join a lot of tables, it stops doing an exhaustive search and +goes for genetic optimization instead: + + http://www.postgresql.org/docs/7.4/static/geqo.html + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Sat Aug 7 01:13:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DF6B75E4077 + for ; + Sat, 7 Aug 2004 01:10:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23393-04 + for ; + Sat, 7 Aug 2004 04:10:14 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 2EB405E3F15 + for ; + Sat, 7 Aug 2004 01:10:05 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i774ABiG089171 + for ; Sat, 7 Aug 2004 04:10:11 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7742wmc088371 + for pgsql-performance@postgresql.org; Sat, 7 Aug 2004 04:02:58 GMT +From: Martin Foster +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7.2) Gecko/20040803 +X-Accept-Language: en-ca, en-gb, en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Performance Bottleneck +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> + <41140D17.7070101@ethereal-realms.org> + <41141322.3010200@bigfoot.com> + <1091840178.27166.255.camel@localhost.localdomain> +In-Reply-To: <1091840178.27166.255.camel@localhost.localdomain> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 97 +Message-ID: +Date: Sat, 07 Aug 2004 04:02:58 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/91 +X-Sequence-Number: 7727 + +Scott Marlowe wrote: + +> On Fri, 2004-08-06 at 17:24, Gaetano Mendola wrote: +> +>>Martin Foster wrote: +>> +>> +>>>Gaetano Mendola wrote: +>>> +>>> +>>>> +>>>>Let start from your postgres configuration: +>>>> +>>>>shared_buffers = 8192 <==== This is really too small for your +>>>>configuration +>>>>sort_mem = 2048 +>>>> +>>>>wal_buffers = 128 <==== This is really too small for your +>>>>configuration +>>>> +>>>>effective_cache_size = 16000 +>>>> +>>>>change this values in: +>>>> +>>>>shared_buffers = 50000 +>>>>sort_mem = 16084 +>>>> +>>>>wal_buffers = 1500 +>>>> +>>>>effective_cache_size = 32000 +>>>> +>>>> +>>>>to bump up the shm usage you have to configure your OS in order to be +>>>>allowed to use that ammount of SHM. +>>>> +>>>>This are the numbers that I feel good for your HW, the second step now is +>>>>analyze your queries +>>>> +>>> +>>>These changes have yielded some visible improvements, with load averages +>>>rarely going over the anything noticeable. However, I do have a +>>>question on the matter, why do these values seem to be far higher then +>>>what a frequently pointed to document would indicate as necessary? +>>> +>>>http://www.varlena.com/GeneralBits/Tidbits/perf.html +>>> +>>>I am simply curious, as this clearly shows that my understanding of +>>>PostgreSQL is clearly lacking when it comes to tweaking for the hardware. +>> +>>Unfortunately there is no a "wizard tuning" for postgres so each one of +>>us have a own "school". The data I gave you are oversized to be sure +>>to achieve improvements. Now you can start to decrease these values +>>( starting from the wal_buffers ) in order to find the good compromise +>>with your HW. +> +> +> FYI, my school of tuning is to change one thing at a time some +> reasonable percentage (shared_buffers from 1000 to 2000) and measure the +> change under simulated load. Make another change, test it, chart the +> shape of the change line. It should look something like this for most +> folks: +> +> shared_buffers | q/s (more is better) +> 100 | 20 +> 200 | 45 +> 400 | 80 +> 1000 | 100 +> ... levels out here... +> 8000 | 110 +> 10000 | 108 +> 20000 | 40 +> 30000 | 20 +> +> Note it going back down as we exceed our memory and start swapping +> shared_buffers. Where that happens on your machine is determined by +> many things like your machine's memory, memory bandwidth, type of load, +> etc... but it will happen on most machines and when it does, it often +> happens at the worst times, under heavy parallel load. +> +> Unless testing shows it's faster, 10000 or 25% of mem (whichever is +> less) is usually a pretty good setting for shared_buffers. Large data +> sets may require more than 10000, but going over 25% on machines with +> large memory is usually a mistake, especially servers that do anything +> other than just PostgreSQL. +> +> You're absolutely right about one thing, there's no automatic wizard for +> tuning this stuff. +> + +Which rather points out the crux of the problem. This is a live system, +meaning changes made need to be as informed as possible, and that +changing values for the sake of testing can lead to potential problems +in service. + + Martin Foster + Creator/Designer Ethereal Realms + martin@ethereal-realms.org + +From pgsql-performance-owner@postgresql.org Sat Aug 7 01:38:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C7C55E4075 + for ; + Sat, 7 Aug 2004 01:34:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29299-05 + for ; + Sat, 7 Aug 2004 04:34:52 +0000 (GMT) +Received: from mpls-qmqp-03.inet.qwest.net (mpls-qmqp-03.inet.qwest.net + [63.231.195.114]) + by svr1.postgresql.org (Postfix) with SMTP id 9FD855E46BF + for ; + Sat, 7 Aug 2004 01:34:42 -0300 (ADT) +Received: (qmail 25435 invoked by uid 0); 7 Aug 2004 04:03:10 -0000 +Received: from mpls-pop-03.inet.qwest.net (63.231.195.3) + by mpls-qmqp-03.inet.qwest.net with QMQP; 7 Aug 2004 04:03:10 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-03.inet.qwest.net with SMTP; 7 Aug 2004 04:34:49 -0000 +Date: Fri, 06 Aug 2004 22:36:13 -0600 +Message-Id: <1091853373.27166.260.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Martin Foster" +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance Bottleneck +In-Reply-To: +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> + <41140D17.7070101@ethereal-realms.org> <41141322.3010200@bigfoot.com> + <1091840178.27166.255.camel@localhost.localdomain> + +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/92 +X-Sequence-Number: 7728 + +On Fri, 2004-08-06 at 22:02, Martin Foster wrote: +> Scott Marlowe wrote: +> +> > On Fri, 2004-08-06 at 17:24, Gaetano Mendola wrote: +> > +> >>Martin Foster wrote: +> >> +> >> +> >>>Gaetano Mendola wrote: +> >>> +> >>> +> >>>> +> >>>>Let start from your postgres configuration: +> >>>> +> >>>>shared_buffers = 8192 <==== This is really too small for your +> >>>>configuration +> >>>>sort_mem = 2048 +> >>>> +> >>>>wal_buffers = 128 <==== This is really too small for your +> >>>>configuration +> >>>> +> >>>>effective_cache_size = 16000 +> >>>> +> >>>>change this values in: +> >>>> +> >>>>shared_buffers = 50000 +> >>>>sort_mem = 16084 +> >>>> +> >>>>wal_buffers = 1500 +> >>>> +> >>>>effective_cache_size = 32000 +> >>>> +> >>>> +> >>>>to bump up the shm usage you have to configure your OS in order to be +> >>>>allowed to use that ammount of SHM. +> >>>> +> >>>>This are the numbers that I feel good for your HW, the second step now is +> >>>>analyze your queries +> >>>> +> >>> +> >>>These changes have yielded some visible improvements, with load averages +> >>>rarely going over the anything noticeable. However, I do have a +> >>>question on the matter, why do these values seem to be far higher then +> >>>what a frequently pointed to document would indicate as necessary? +> >>> +> >>>http://www.varlena.com/GeneralBits/Tidbits/perf.html +> >>> +> >>>I am simply curious, as this clearly shows that my understanding of +> >>>PostgreSQL is clearly lacking when it comes to tweaking for the hardware. +> >> +> >>Unfortunately there is no a "wizard tuning" for postgres so each one of +> >>us have a own "school". The data I gave you are oversized to be sure +> >>to achieve improvements. Now you can start to decrease these values +> >>( starting from the wal_buffers ) in order to find the good compromise +> >>with your HW. +> > +> > +> > FYI, my school of tuning is to change one thing at a time some +> > reasonable percentage (shared_buffers from 1000 to 2000) and measure the +> > change under simulated load. Make another change, test it, chart the +> > shape of the change line. It should look something like this for most +> > folks: +> > +> > shared_buffers | q/s (more is better) +> > 100 | 20 +> > 200 | 45 +> > 400 | 80 +> > 1000 | 100 +> > ... levels out here... +> > 8000 | 110 +> > 10000 | 108 +> > 20000 | 40 +> > 30000 | 20 +> > +> > Note it going back down as we exceed our memory and start swapping +> > shared_buffers. Where that happens on your machine is determined by +> > many things like your machine's memory, memory bandwidth, type of load, +> > etc... but it will happen on most machines and when it does, it often +> > happens at the worst times, under heavy parallel load. +> > +> > Unless testing shows it's faster, 10000 or 25% of mem (whichever is +> > less) is usually a pretty good setting for shared_buffers. Large data +> > sets may require more than 10000, but going over 25% on machines with +> > large memory is usually a mistake, especially servers that do anything +> > other than just PostgreSQL. +> > +> > You're absolutely right about one thing, there's no automatic wizard for +> > tuning this stuff. +> > +> +> Which rather points out the crux of the problem. This is a live system, +> meaning changes made need to be as informed as possible, and that +> changing values for the sake of testing can lead to potential problems +> in service. + +But if you make those changes slowly, as I was showing, you should see +the small deleterious effects like I was showing long before they become +catastrophic. To just jump shared_buffers to 50000 is not a good idea, +especially if the sweet spot is likely lower than that. + + +From pgsql-performance-owner@postgresql.org Sat Aug 7 01:45:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 688715E40AC + for ; + Sat, 7 Aug 2004 01:39:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28577-10 + for ; + Sat, 7 Aug 2004 04:39:39 +0000 (GMT) +Received: from fep7.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 859DB5E4077 + for ; + Sat, 7 Aug 2004 01:39:29 -0300 (ADT) +Received: from [127.0.0.1] (d226-86-215.home.cgocable.net [24.226.86.215]) + by fep7.cogeco.net (Postfix) with ESMTP + id 883C221D8; Sat, 7 Aug 2004 00:39:37 -0400 (EDT) +Message-ID: <41145D07.90006@ethereal-realms.org> +Date: Sat, 07 Aug 2004 00:39:35 -0400 +From: Martin Foster +Organization: Ethereal Realms +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7.2) Gecko/20040803 +X-Accept-Language: en-ca, en-gb, en-us, en +MIME-Version: 1.0 +To: Scott Marlowe , + PostgreSQL Performance +Subject: Re: Performance Bottleneck +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> + <41140D17.7070101@ethereal-realms.org> + <41141322.3010200@bigfoot.com> + <1091840178.27166.255.camel@localhost.localdomain> + + <1091853373.27166.260.camel@localhost.localdomain> +In-Reply-To: <1091853373.27166.260.camel@localhost.localdomain> +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.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/93 +X-Sequence-Number: 7729 + +Scott Marlowe wrote: + +> On Fri, 2004-08-06 at 22:02, Martin Foster wrote: +> +>>Scott Marlowe wrote: +>> +>> +>>>On Fri, 2004-08-06 at 17:24, Gaetano Mendola wrote: +>>> +>>> +>>>>Martin Foster wrote: +>>>> +>>>> +>>>> +>>>>>Gaetano Mendola wrote: +>>>>> +>>>>> +>>>>> +>>>>>>Let start from your postgres configuration: +>>>>>> +>>>>>>shared_buffers = 8192 <==== This is really too small for your +>>>>>>configuration +>>>>>>sort_mem = 2048 +>>>>>> +>>>>>>wal_buffers = 128 <==== This is really too small for your +>>>>>>configuration +>>>>>> +>>>>>>effective_cache_size = 16000 +>>>>>> +>>>>>>change this values in: +>>>>>> +>>>>>>shared_buffers = 50000 +>>>>>>sort_mem = 16084 +>>>>>> +>>>>>>wal_buffers = 1500 +>>>>>> +>>>>>>effective_cache_size = 32000 +>>>>>> +>>>>>> +>>>>>>to bump up the shm usage you have to configure your OS in order to be +>>>>>>allowed to use that ammount of SHM. +>>>>>> +>>>>>>This are the numbers that I feel good for your HW, the second step now is +>>>>>>analyze your queries +>>>>>> +>>>>> +>>>>>These changes have yielded some visible improvements, with load averages +>>>>>rarely going over the anything noticeable. However, I do have a +>>>>>question on the matter, why do these values seem to be far higher then +>>>>>what a frequently pointed to document would indicate as necessary? +>>>>> +>>>>>http://www.varlena.com/GeneralBits/Tidbits/perf.html +>>>>> +>>>>>I am simply curious, as this clearly shows that my understanding of +>>>>>PostgreSQL is clearly lacking when it comes to tweaking for the hardware. +>>>> +>>>>Unfortunately there is no a "wizard tuning" for postgres so each one of +>>>>us have a own "school". The data I gave you are oversized to be sure +>>>>to achieve improvements. Now you can start to decrease these values +>>>>( starting from the wal_buffers ) in order to find the good compromise +>>>>with your HW. +>>> +>>> +>>>FYI, my school of tuning is to change one thing at a time some +>>>reasonable percentage (shared_buffers from 1000 to 2000) and measure the +>>>change under simulated load. Make another change, test it, chart the +>>>shape of the change line. It should look something like this for most +>>>folks: +>>> +>>>shared_buffers | q/s (more is better) +>>>100 | 20 +>>>200 | 45 +>>>400 | 80 +>>>1000 | 100 +>>>... levels out here... +>>>8000 | 110 +>>>10000 | 108 +>>>20000 | 40 +>>>30000 | 20 +>>> +>>>Note it going back down as we exceed our memory and start swapping +>>>shared_buffers. Where that happens on your machine is determined by +>>>many things like your machine's memory, memory bandwidth, type of load, +>>>etc... but it will happen on most machines and when it does, it often +>>>happens at the worst times, under heavy parallel load. +>>> +>>>Unless testing shows it's faster, 10000 or 25% of mem (whichever is +>>>less) is usually a pretty good setting for shared_buffers. Large data +>>>sets may require more than 10000, but going over 25% on machines with +>>>large memory is usually a mistake, especially servers that do anything +>>>other than just PostgreSQL. +>>> +>>>You're absolutely right about one thing, there's no automatic wizard for +>>>tuning this stuff. +>>> +>> +>>Which rather points out the crux of the problem. This is a live system, +>>meaning changes made need to be as informed as possible, and that +>>changing values for the sake of testing can lead to potential problems +>>in service. +> +> +> But if you make those changes slowly, as I was showing, you should see +> the small deleterious effects like I was showing long before they become +> catastrophic. To just jump shared_buffers to 50000 is not a good idea, +> especially if the sweet spot is likely lower than that. +> + +While I agree, there are also issues with the fact that getting +consistent results from this site are very much difficult to do, since +it is based on the whims of users visiting one of three sites hosted on +the same hardware. + +Now that being said, having wal_buffers at 8 certainly would not be a +good idea, since the database logs themselves were warning of excessive +writes in that region. I am not hoping for a perfect intermix ratio, +that will solve all my problems. + +But a good idea on a base that will allow me to gain a fair load would +certainly be a good option. Right now, the load being handled is not +much more then a single processor system did with half the memory. +Certainly this architecture should be able to take more of a beating +then this? + + Martin Foster + Creator/Designer Ethereal Realms + martin@ethereal-realms.org + + + +From pgsql-performance-owner@postgresql.org Sat Aug 7 07:04:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 19CE35E3AC5 + for ; + Sat, 7 Aug 2004 07:04:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64405-10 + for ; + Sat, 7 Aug 2004 10:04:34 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A71C5E37CF + for ; + Sat, 7 Aug 2004 07:04:29 -0300 (ADT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i77A42h22217; + Sat, 7 Aug 2004 12:04:03 +0200 +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 i77A4RZ09440; + Sat, 7 Aug 2004 12:04:27 +0200 +Message-ID: <4114A900.5070607@bigfoot.com> +Date: Sat, 07 Aug 2004 12:03:44 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Scott Marlowe , + "pgsql-performance@postgresql.org" +Subject: Re: Performance Bottleneck +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> + <41140D17.7070101@ethereal-realms.org> + <41141322.3010200@bigfoot.com> + <1091840178.27166.255.camel@localhost.localdomain> + + <1091853373.27166.260.camel@localhost.localdomain> +In-Reply-To: <1091853373.27166.260.camel@localhost.localdomain> +X-Enigmail-Version: 0.84.2.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/94 +X-Sequence-Number: 7730 + +Scott Marlowe wrote: +> On Fri, 2004-08-06 at 22:02, Martin Foster wrote: +> +>>Scott Marlowe wrote: +>> +>> +>>>On Fri, 2004-08-06 at 17:24, Gaetano Mendola wrote: +>>> +>>> +>>>>Martin Foster wrote: +>>>> +>>>> +>>>> +>>>>>Gaetano Mendola wrote: +>>>>> +>>>>> +>>>>> +>>>>>>Let start from your postgres configuration: +>>>>>> +>>>>>>shared_buffers = 8192 <==== This is really too small for your +>>>>>>configuration +>>>>>>sort_mem = 2048 +>>>>>> +>>>>>>wal_buffers = 128 <==== This is really too small for your +>>>>>>configuration +>>>>>> +>>>>>>effective_cache_size = 16000 +>>>>>> +>>>>>>change this values in: +>>>>>> +>>>>>>shared_buffers = 50000 +>>>>>>sort_mem = 16084 +>>>>>> +>>>>>>wal_buffers = 1500 +>>>>>> +>>>>>>effective_cache_size = 32000 +>>>>>> +>>>>>> +>>>>>>to bump up the shm usage you have to configure your OS in order to be +>>>>>>allowed to use that ammount of SHM. +>>>>>> +>>>>>>This are the numbers that I feel good for your HW, the second step now is +>>>>>>analyze your queries +>>>>>> +>>>>> +>>>>>These changes have yielded some visible improvements, with load averages +>>>>>rarely going over the anything noticeable. However, I do have a +>>>>>question on the matter, why do these values seem to be far higher then +>>>>>what a frequently pointed to document would indicate as necessary? +>>>>> +>>>>>http://www.varlena.com/GeneralBits/Tidbits/perf.html +>>>>> +>>>>>I am simply curious, as this clearly shows that my understanding of +>>>>>PostgreSQL is clearly lacking when it comes to tweaking for the hardware. +>>>> +>>>>Unfortunately there is no a "wizard tuning" for postgres so each one of +>>>>us have a own "school". The data I gave you are oversized to be sure +>>>>to achieve improvements. Now you can start to decrease these values +>>>>( starting from the wal_buffers ) in order to find the good compromise +>>>>with your HW. +>>> +>>> +>>>FYI, my school of tuning is to change one thing at a time some +>>>reasonable percentage (shared_buffers from 1000 to 2000) and measure the +>>>change under simulated load. Make another change, test it, chart the +>>>shape of the change line. It should look something like this for most +>>>folks: +>>> +>>>shared_buffers | q/s (more is better) +>>>100 | 20 +>>>200 | 45 +>>>400 | 80 +>>>1000 | 100 +>>>... levels out here... +>>>8000 | 110 +>>>10000 | 108 +>>>20000 | 40 +>>>30000 | 20 +>>> +>>>Note it going back down as we exceed our memory and start swapping +>>>shared_buffers. Where that happens on your machine is determined by +>>>many things like your machine's memory, memory bandwidth, type of load, +>>>etc... but it will happen on most machines and when it does, it often +>>>happens at the worst times, under heavy parallel load. +>>> +>>>Unless testing shows it's faster, 10000 or 25% of mem (whichever is +>>>less) is usually a pretty good setting for shared_buffers. Large data +>>>sets may require more than 10000, but going over 25% on machines with +>>>large memory is usually a mistake, especially servers that do anything +>>>other than just PostgreSQL. +>>> +>>>You're absolutely right about one thing, there's no automatic wizard for +>>>tuning this stuff. +>>> +>> +>>Which rather points out the crux of the problem. This is a live system, +>>meaning changes made need to be as informed as possible, and that +>>changing values for the sake of testing can lead to potential problems +>>in service. +> +> +> But if you make those changes slowly, as I was showing, you should see +> the small deleterious effects like I was showing long before they become +> catastrophic. To just jump shared_buffers to 50000 is not a good idea, +> especially if the sweet spot is likely lower than that. + +As you can see 50000 are less then 20% of his total memory and I strongly +fell that 50000 is not oversized for his hardware ( as wal_buffers isn't), +may be could be for his database activity but for sure that value ( values ) +can not be source of problems. + +I'd like to have a wizard that could be run also for hours in order to find the +good compromise for all GUC parameters , may be a genetic algoritm can help. + +Regards +Gaetano Mendola + + + + + + + + + + + + + + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Sat Aug 7 07:12:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C58525E46C4 + for ; + Sat, 7 Aug 2004 07:11:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68395-03 + for ; + Sat, 7 Aug 2004 10:11:50 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E3825E46C1 + for ; + Sat, 7 Aug 2004 07:11:48 -0300 (ADT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i77ABPd22251; + Sat, 7 Aug 2004 12:11:25 +0200 +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 i77ABoZ09457; + Sat, 7 Aug 2004 12:11:50 +0200 +Message-ID: <4114AABD.7050505@bigfoot.com> +Date: Sat, 07 Aug 2004 12:11:09 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane , + "pgsql-performance@postgresql.org" +Subject: Re: Performance Bottleneck +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> + <41140D17.7070101@ethereal-realms.org> + <24609.1091836821@sss.pgh.pa.us> +In-Reply-To: <24609.1091836821@sss.pgh.pa.us> +X-Enigmail-Version: 0.84.2.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/95 +X-Sequence-Number: 7731 + +Tom Lane wrote: + +> Martin Foster writes: +> +>>Gaetano Mendola wrote: +>> +>>>change this values in: +>>>shared_buffers = 50000 +>>>sort_mem = 16084 +>>> +>>>wal_buffers = 1500 +> +> +> This value of wal_buffers is simply ridiculous. + +Instead I think is ridiculous a wal_buffers = 8 ( 64KB ) by default. + +> There isn't any reason to set wal_buffers higher than the amount of +> WAL log data that will be generated by a single transaction, because +> whatever is in the buffers will be flushed at transaction commit. +> If you are mainly dealing with heavy concurrency then it's the mean time +> between transaction commits that matters, and that's even less than the +> average transaction length. + +I partially agree with you, tell me how decide that value without +even now the typical queries, the tipical load ... nothing. +I suggested to OP to keep the wal_buffers so high in order to eliminate one +freedom of degree in his performance problems. You can see from following reply, + + +======================================================================== +Gaetano Mendola wrote: +Unfortunately there is no a "wizard tuning" for postgres so each one of +us have a own "school". The data I gave you are oversized to be sure +to achieve improvements. Now you can start to decrease these values +( starting from the wal_buffers ) in order to find the good compromise +with your HW. +======================================================================== + +However wal_buffers = 1500 means ~12 MB that are not so expensive considering +a server with 2GB of ram and I think that is a good compromise if you are not +starving for RAM. + + +I had a discussion about how fine tuning a postgres server with a client, +my question was: are you planning to have someone that periodically take a +look at your server activities in order to use your hardware at the best? +Easy answer: No, because when the server is overloaded I will buy a bigger +one that is less expensive that pay someone, considering also that shareolders +prefer increase the capex that pay salaries ( if the company close the hardware +can be selled :-( ). + +This is the real world out there. + + + +Regards +Gaetano Mendola + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Sat Aug 7 07:50:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E84B5E3AC5 + for ; + Sat, 7 Aug 2004 07:49:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77971-01 + for ; + Sat, 7 Aug 2004 10:49:48 +0000 (GMT) +Received: from vscan02.westnet.com.au (vscan02.westnet.com.au [203.10.1.132]) + by svr1.postgresql.org (Postfix) with ESMTP id E85EB5E37CF + for ; + Sat, 7 Aug 2004 07:49:47 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by localhost (Postfix) with ESMTP id DF6D3119BE8; + Sat, 7 Aug 2004 18:49:50 +0800 (WST) +Received: from [192.168.1.9] (dsl-202-72-133-22.wa.westnet.com.au + [202.72.133.22]) + by vscan02.westnet.com.au (Postfix) with ESMTP id 65EB4119B02; + Sat, 7 Aug 2004 18:49:50 +0800 (WST) +Message-ID: <4114B3CE.2020504@familyhealth.com.au> +Date: Sat, 07 Aug 2004 18:49:50 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gaetano Mendola +Cc: Tom Lane , + "pgsql-performance@postgresql.org" +Subject: Re: Performance Bottleneck +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> + <41140D17.7070101@ethereal-realms.org> + <24609.1091836821@sss.pgh.pa.us> <4114AABD.7050505@bigfoot.com> +In-Reply-To: <4114AABD.7050505@bigfoot.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/96 +X-Sequence-Number: 7732 + +>> This value of wal_buffers is simply ridiculous. +> +> +> Instead I think is ridiculous a wal_buffers = 8 ( 64KB ) by default. + +There is no point making WAL buffers higher than 8. I have done much +testing of this and it makes not the slightest difference to performance +that I could measure. + +Chris + + +From pgsql-performance-owner@postgresql.org Sat Aug 7 11:21:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 030885E46C1 + for ; + Sat, 7 Aug 2004 11:21:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28596-01 + for ; + Sat, 7 Aug 2004 14:21:06 +0000 (GMT) +Received: from smtp105.mail.sc5.yahoo.com (smtp105.mail.sc5.yahoo.com + [66.163.169.225]) + by svr1.postgresql.org (Postfix) with SMTP id 1DBC65E46C0 + for ; + Sat, 7 Aug 2004 11:21:03 -0300 (ADT) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp105.mail.sc5.yahoo.com with SMTP; 7 Aug 2004 14:21:09 -0000 +Received: from [172.21.8.18] ([192.168.192.101]) (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i77EL23v060896; Sat, 7 Aug 2004 10:21:07 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <4114E54C.7040200@Yahoo.com> +Date: Sat, 07 Aug 2004 10:21:00 -0400 +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: Martin Foster +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance Bottleneck +References: +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.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/97 +X-Sequence-Number: 7733 + +On 8/3/2004 2:05 PM, Martin Foster wrote: + +> I run a Perl/CGI driven website that makes extensive use of PostgreSQL +> (7.4.3) for everything from user information to formatting and display +> of specific sections of the site. The server itself, is a dual +> processor AMD Opteron 1.4Ghz w/ 2GB Ram and 2 x 120GB hard drives +> mirrored for redundancy running under FreeBSD 5.2.1 (AMD64). +> +> Recently loads on the site have increased during peak hours to the point +> of showing considerable loss in performance. This can be observed +> when connections move from the 120 concurrent connections to PostgreSQL +> to roughly 175 or more. Essentially, the machine seems to struggle +> to keep up with continual requests and slows down respectively as +> resources are tied down. + +Have you taken a look at pgpool? I know, it sounds silly to *reduce* the +number of DB connections through a connection pool, but it can help. + + +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 Sun Aug 8 02:41:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DDF745E46C9 + for ; + Sun, 8 Aug 2004 02:40:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47245-02 + for ; + Sun, 8 Aug 2004 05:40:25 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id CDE825E3E30 + for ; + Sun, 8 Aug 2004 02:40:25 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i785eOiG047874 + for ; Sun, 8 Aug 2004 05:40:24 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i785EWUW042041 + for pgsql-performance@postgresql.org; Sun, 8 Aug 2004 05:14:32 GMT +From: Martin Foster +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7.2) Gecko/20040803 +X-Accept-Language: en-ca, en-gb, en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Performance Bottleneck +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> + <41140D17.7070101@ethereal-realms.org> + <24609.1091836821@sss.pgh.pa.us> <4114AABD.7050505@bigfoot.com> + <4114B3CE.2020504@familyhealth.com.au> +In-Reply-To: <4114B3CE.2020504@familyhealth.com.au> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 25 +Message-ID: +Date: Sun, 08 Aug 2004 05:14:32 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/99 +X-Sequence-Number: 7735 + +Christopher Kings-Lynne wrote: + +>>> This value of wal_buffers is simply ridiculous. +>> +>> +>> +>> Instead I think is ridiculous a wal_buffers = 8 ( 64KB ) by default. +> +> +> There is no point making WAL buffers higher than 8. I have done much +> testing of this and it makes not the slightest difference to performance +> that I could measure. +> +> Chris +> + +No point? I had it at 64 if memory serves and logs were warning me that +raising this value would be desired because of excessive IO brought upon +from the logs being filled far too often. + +It would seem to me that 8 is a bit low in at least a few circumstances. + + Martin Foster + Creator/Designer Ethereal Realms + martin@ethereal-realms.org + +From pgsql-performance-owner@postgresql.org Sun Aug 8 02:29:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E0FF5E46C0 + for ; + Sun, 8 Aug 2004 02:29:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44689-02 + for ; + Sun, 8 Aug 2004 05:29:19 +0000 (GMT) +Received: from fep2.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 3FB5C5E46D1 + for ; + Sun, 8 Aug 2004 02:29:19 -0300 (ADT) +Received: from [127.0.0.1] (d226-86-215.home.cgocable.net [24.226.86.215]) + by fep2.cogeco.net (Postfix) with ESMTP + id C0FFD25F6; Sun, 8 Aug 2004 01:29:18 -0400 (EDT) +Message-ID: <4115BA2C.3000900@ethereal-realms.org> +Date: Sun, 08 Aug 2004 01:29:16 -0400 +From: Martin Foster +Organization: Ethereal Realms +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7.2) Gecko/20040803 +X-Accept-Language: en-ca, en-gb, en-us, en +MIME-Version: 1.0 +To: Jan Wieck , + PostgreSQL Performance +Subject: Re: Performance Bottleneck +References: <4114E54C.7040200@Yahoo.com> +In-Reply-To: <4114E54C.7040200@Yahoo.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.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/98 +X-Sequence-Number: 7734 + +Jan Wieck wrote: + +> On 8/3/2004 2:05 PM, Martin Foster wrote: +> +>> I run a Perl/CGI driven website that makes extensive use of PostgreSQL +>> (7.4.3) for everything from user information to formatting and display +>> of specific sections of the site. The server itself, is a dual +>> processor AMD Opteron 1.4Ghz w/ 2GB Ram and 2 x 120GB hard drives +>> mirrored for redundancy running under FreeBSD 5.2.1 (AMD64). +>> +>> Recently loads on the site have increased during peak hours to the +>> point of showing considerable loss in performance. This can be +>> observed when connections move from the 120 concurrent connections to +>> PostgreSQL to roughly 175 or more. Essentially, the machine seems +>> to struggle to keep up with continual requests and slows down +>> respectively as resources are tied down. +> +> +> Have you taken a look at pgpool? I know, it sounds silly to *reduce* the +> number of DB connections through a connection pool, but it can help. +> +> +> Jan +> + +I am currently making use of Apache::DBI which overrides the +DBI::disconnect call and keeps a pool of active connections for use when +need be. Since it offloads the pooling to the webserver, it seems more +advantageous then pgpool which while being able to run on a external +system is not adding another layer of complexity. + +Anyone had any experience with both Apache::DBI and pgpool? For my +needs they seem to do essentially the same thing, simply that one is +invisible to the code while the other requires adding the complexity of +a proxy. + + Martin Foster + Creator/Designer Ethereal Realms + martin@ethereal-realms.org + + + +From pgsql-performance-owner@postgresql.org Sun Aug 8 05:21:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 875495E40AC + for ; + Sun, 8 Aug 2004 05:21:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81696-06 + for ; + Sun, 8 Aug 2004 08:21:48 +0000 (GMT) +Received: from mail.academyoflearning.ca (s64-180-138-192.bc.hsia.telus.net + [64.180.138.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D6B45E3E30 + for ; + Sun, 8 Aug 2004 05:21:46 -0300 (ADT) +Received: from [192.168.1.10] (d216-232-247-236.bchsia.telus.net + [216.232.247.236]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by mail.academyoflearning.ca (Postfix) with ESMTP id 368DC2F90E; + Sun, 8 Aug 2004 01:21:19 -0700 (PDT) +Subject: Re: Performance Bottleneck +From: Mike Benoit +To: Martin Foster +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: <410FDC53.5080509@bigfoot.com> + <4110FFF6.1030001@bigfoot.com> + <1091812011.7149.25.camel@ipso.snappymail.ca> + +Content-Type: text/plain +Date: Sun, 08 Aug 2004 01:21:17 -0700 +Message-Id: <1091953277.11520.3.camel@ipso.snappymail.ca> +Mime-Version: 1.0 +X-Mailer: Evolution 1.5.92.1-1mdk +Content-Transfer-Encoding: 7bit +X-snappymail-MailScanner-Information: Please contact the ISP for more + information +X-snappymail-MailScanner: Found to be clean +X-snappymail-MailScanner-SpamCheck: not spam, SpamAssassin (score=1.911, + required 5, AWL -0.79, RCVD_IN_DYNABLOCK 2.60, RCVD_IN_SORBS 0.10) +X-snappymail-MailScanner-SpamScore: s +X-MailScanner-From: ipso@snappymail.ca +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/100 +X-Sequence-Number: 7736 + +On Fri, 2004-08-06 at 23:18 +0000, Martin Foster wrote: +> Mike Benoit wrote: +> +> > On Wed, 2004-08-04 at 17:25 +0200, Gaetano Mendola wrote: +> > +> > +> >>>The queries themselves are simple, normally drawing information from one +> >>>table with few conditions or in the most complex cases using joins on +> >>>two table or sub queries. These behave very well and always have, the +> >>>problem is that these queries take place in rather large amounts due to +> >>>the dumb nature of the scripts themselves. +> >> +> >>Show us the explain analyze on that queries, how many rows the tables are +> >>containing, the table schema could be also usefull. +> >> +> > +> > +> > If the queries themselves are optimized as much as they can be, and as +> > you say, its just the sheer amount of similar queries hitting the +> > database, you could try using prepared queries for ones that are most +> > often executed to eliminate some of the overhead. +> > +> > I've had relatively good success with this in the past, and it doesn't +> > take very much code modification. +> > +> +> One of the biggest problems is most probably related to the indexes. +> Since the performance penalty of logging the information needed to see +> which queries are used and which are not is a slight problem, then I +> cannot really make use of it for now. +> +> However, I am curious how one would go about preparing query? Is this +> similar to the DBI::Prepare statement with placeholders and simply +> changing the values passed on execute? Or is this something database +> level such as a view et cetera? +> + +Yes, always optimize your queries and GUC settings first and foremost. +Thats where you are likely to gain the most performance. After that if +you still want to push things even further I would try prepared queries. +I'm not familiar with DBI::Prepare at all, but I don't think its what +your looking for. + +This is what you want: +http://www.postgresql.org/docs/current/static/sql-prepare.html + + +-- +Mike Benoit + + +From pgsql-performance-owner@postgresql.org Sun Aug 8 09:10:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3ED455E37CF + for ; + Sun, 8 Aug 2004 09:10:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33436-10 + for ; + Sun, 8 Aug 2004 12:10:15 +0000 (GMT) +Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.85]) + by svr1.postgresql.org (Postfix) with ESMTP id B78565E37CE + for ; + Sun, 8 Aug 2004 09:10:12 -0300 (ADT) +Received: from jefftrout.com ([24.128.241.68]) + by comcast.net (rwcrmhc12) with SMTP + id <20040808121015014004lh81e>; Sun, 8 Aug 2004 12:10:15 +0000 +Received: (qmail 86891 invoked from network); 8 Aug 2004 12:10:15 -0000 +Received: from unknown (HELO ?192.168.0.102?) (10.10.10.20) + by 10.10.10.10 with SMTP; 8 Aug 2004 12:10:15 -0000 +In-Reply-To: <4115BA2C.3000900@ethereal-realms.org> +References: <4114E54C.7040200@Yahoo.com> + <4115BA2C.3000900@ethereal-realms.org> +Mime-Version: 1.0 (Apple Message framework v618) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: PostgreSQL Performance , + Jan Wieck +From: Jeff +Subject: Re: Performance Bottleneck +Date: Sun, 8 Aug 2004 08:10:24 -0400 +To: Martin Foster +X-Mailer: Apple Mail (2.618) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/101 +X-Sequence-Number: 7737 + + +On Aug 8, 2004, at 1:29 AM, Martin Foster wrote: + +> I am currently making use of Apache::DBI which overrides the +> DBI::disconnect call and keeps a pool of active connections for use +> when need be. Since it offloads the pooling to the webserver, it +> seems more advantageous then pgpool which while being able to run on a +> external system is not adding another layer of complexity. +> + +Apache::DBI is not the same sort of a pool as pgpool. DB connections +are not shared among all your apache children (A common misconception). + So if you have 300 apache kids you can have have 300 db connections. +With pgpool connections are shared among all of them so even though +you have 300 kids you only have say 32 db connections. + +> Anyone had any experience with both Apache::DBI and pgpool? For my +> needs they seem to do essentially the same thing, simply that one is +> invisible to the code while the other requires adding the complexity +> of a proxy. +> + +Both are invisible to the app. (With pgpool it thinks it is connecting +to a regular old PG server) + +And I've been running pgpool in production for months. It just sits +there. Doesn't take much to set it up or configure it. Works like a +champ + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Sun Aug 8 10:53:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3470B5E46D5 + for ; + Sun, 8 Aug 2004 10:52:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55546-05 + for ; + Sun, 8 Aug 2004 13:52:15 +0000 (GMT) +Received: from smtp105.mail.sc5.yahoo.com (smtp105.mail.sc5.yahoo.com + [66.163.169.225]) + by svr1.postgresql.org (Postfix) with SMTP id 128D85E46CB + for ; + Sun, 8 Aug 2004 10:52:08 -0300 (ADT) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp105.mail.sc5.yahoo.com with SMTP; 8 Aug 2004 13:52:13 -0000 +Received: from [172.21.8.18] ([192.168.192.101]) (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i78Dq53v064577; Sun, 8 Aug 2004 09:52:05 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <41163001.8040500@Yahoo.com> +Date: Sun, 08 Aug 2004 09:52:01 -0400 +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: Jeff +Cc: Martin Foster , + PostgreSQL Performance +Subject: Re: Performance Bottleneck +References: <4114E54C.7040200@Yahoo.com> + <4115BA2C.3000900@ethereal-realms.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.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/102 +X-Sequence-Number: 7738 + +On 8/8/2004 8:10 AM, Jeff wrote: + +> On Aug 8, 2004, at 1:29 AM, Martin Foster wrote: +> +>> I am currently making use of Apache::DBI which overrides the +>> DBI::disconnect call and keeps a pool of active connections for use +>> when need be. Since it offloads the pooling to the webserver, it +>> seems more advantageous then pgpool which while being able to run on a +>> external system is not adding another layer of complexity. +>> +> +> Apache::DBI is not the same sort of a pool as pgpool. DB connections +> are not shared among all your apache children (A common misconception). +> So if you have 300 apache kids you can have have 300 db connections. +> With pgpool connections are shared among all of them so even though +> you have 300 kids you only have say 32 db connections. + +And this is exactly where the pgpool advantage lies. Especially with the +TPC-W, the Apache is serving a mix of PHP (or whatever CGI technique is +used) and static content like images. Since the 200+ Apache kids serve +any of that content by random and the emulated browsers very much +encourage it to ramp up MaxClients children by using up to 4 concurrent +image connections, one does end up with MaxClients DB connections that +are all relatively low frequently used. In contrast to that the real +pgpool causes lesser, more active DB connections, which is better for +performance. + + +> +>> Anyone had any experience with both Apache::DBI and pgpool? For my +>> needs they seem to do essentially the same thing, simply that one is +>> invisible to the code while the other requires adding the complexity +>> of a proxy. +>> +> +> Both are invisible to the app. (With pgpool it thinks it is connecting +> to a regular old PG server) +> +> And I've been running pgpool in production for months. It just sits +> there. Doesn't take much to set it up or configure it. Works like a +> champ + +And it buys you some extra admin feature people like to forget about it. +One can shut down one pool for one web application only. That gives you +instant single user access to one database without shutting down the +whole webserver or tempering with the pg_hba.conf file. + + +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 Sun Aug 8 11:30:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DF40C5E4699 + for ; + Sun, 8 Aug 2004 11:29:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63246-10 + for ; + Sun, 8 Aug 2004 14:29:39 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id DBCFF5E46C2 + for ; + Sun, 8 Aug 2004 11:29:34 -0300 (ADT) +Received: from solent (82-68-95-1.dsl.in-addr.zen.co.uk [82.68.95.1]) + by bayswater1.ymogen.net (Postfix) with ESMTP + id 4A6ABA55C5; Sun, 8 Aug 2004 15:29:39 +0100 (BST) +Reply-To: +From: "Matt Clark" +To: "'Jan Wieck'" , + "'Jeff'" +Cc: "'Martin Foster'" , + "'PostgreSQL Performance'" +Subject: Re: Performance Bottleneck +Date: Sun, 8 Aug 2004 15:29:39 +0100 +Organization: Ymogen Ltd +Message-ID: <007f01c47d54$233b4bf0$8300a8c0@solent> +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: <41163001.8040500@Yahoo.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/103 +X-Sequence-Number: 7739 + +> And this is exactly where the pgpool advantage lies. +> Especially with the +> TPC-W, the Apache is serving a mix of PHP (or whatever CGI +> technique is +> used) and static content like images. Since the 200+ Apache +> kids serve +> any of that content by random and the emulated browsers very much +> encourage it to ramp up MaxClients children by using up to 4 +> concurrent +> image connections, one does end up with MaxClients DB +> connections that +> are all relatively low frequently used. In contrast to that the real +> pgpool causes lesser, more active DB connections, which is better for +> performance. + +There are two well-worn and very mature techniques for dealing with the +issue of web apps using one DB connection per apache process, both of which +work extremely well and attack the issue at its source. + +1) Use a front-end caching proxy like Squid as an accelerator. Static +content will be served by the accelerator 99% of the time. Additionally, +large pages can be served immediately to the accelerator by Apache, which +can then go on to serve another request without waiting for the end user's +dial-up connection to pull the data down. Massive speedup, fewer apache +processes needed. + +2) Serve static content off an entirely separate apache server than the +dynamic content, but by using separate domains (e.g. 'static.foo.com'). + +Personally I favour number 1. Our last biggish peak saw 6000 open HTTP and +HTTPS connections and only 200 apache children, all of them nice and busy, +not hanging around on street corners looking bored. During quiet times +Apache drops back to its configured minimum of 40 kids. Option 2 has the +advantage that you can use a leaner build for the 'dynamic' apache server, +but with RAM so plentiful these days that's a less useful property. + +Basically this puts the 'pooling' back in the stateless HTTP area where it +truly belongs and can be proven not to have any peculiar side effects +(especially when it comes to transaction safety). Even better, so long as +you use URL parameters for searches and the like, you can have the +accelerator cache those pages for a certain time too so long as slightly +stale results are OK. + +I'm sure pgpool and the like have their place, but being band-aids for +poorly configured websites probably isn't the best use for them. + +M + + +From pgsql-performance-owner@postgresql.org Sun Aug 8 12:49:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 44C4D5E46C4 + for ; + Sun, 8 Aug 2004 12:49:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81193-07 + for ; + Sun, 8 Aug 2004 15:49:19 +0000 (GMT) +Received: from fep2.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id F05235E40BB + for ; + Sun, 8 Aug 2004 12:49:10 -0300 (ADT) +Received: from [127.0.0.1] (d226-86-215.home.cgocable.net [24.226.86.215]) + by fep2.cogeco.net (Postfix) with ESMTP + id 1BC3B2515; Sun, 8 Aug 2004 11:49:17 -0400 (EDT) +Message-ID: <41164B76.1030603@ethereal-realms.org> +Date: Sun, 08 Aug 2004 11:49:10 -0400 +From: Martin Foster +Organization: Ethereal Realms +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7.2) Gecko/20040803 +X-Accept-Language: en-ca, en-gb, en-us, en +MIME-Version: 1.0 +To: Jeff , + PostgreSQL Performance +Subject: Re: Performance Bottleneck +References: <4114E54C.7040200@Yahoo.com> + <4115BA2C.3000900@ethereal-realms.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.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/104 +X-Sequence-Number: 7740 + +Jeff wrote: +> +> On Aug 8, 2004, at 1:29 AM, Martin Foster wrote: +> +>> I am currently making use of Apache::DBI which overrides the +>> DBI::disconnect call and keeps a pool of active connections for use +>> when need be. Since it offloads the pooling to the webserver, it +>> seems more advantageous then pgpool which while being able to run on a +>> external system is not adding another layer of complexity. +>> +> +> Apache::DBI is not the same sort of a pool as pgpool. DB connections +> are not shared among all your apache children (A common misconception). +> So if you have 300 apache kids you can have have 300 db connections. +> With pgpool connections are shared among all of them so even though you +> have 300 kids you only have say 32 db connections. +> + +Seems that you are right, never noticed that from the documentation +before. I always assumed it had something to do with the long +lasting/persistent scripts that would remain in transactions for +extended periods of time. + +Here is an odd question. While the server run 7.4.x, the client +connects with 7.3.x. Would this in itself make a difference in +performance as the protocols are different? At least based from +pgpool's documentation. + + Martin Foster + Creator/Designer Ethereal Realms + martin@ethereal-realms.org + + + +From pgsql-performance-owner@postgresql.org Sun Aug 8 13:03:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DCD8F5E46C3 + for ; + Sun, 8 Aug 2004 13:03:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84368-09 + for ; + Sun, 8 Aug 2004 16:03:16 +0000 (GMT) +Received: from ipact2.infopact.nl (x71.infopact.nl [212.29.160.71]) + by svr1.postgresql.org (Postfix) with ESMTP id BAB775E4699 + for ; + Sun, 8 Aug 2004 13:03:07 -0300 (ADT) +Received: from [127.0.0.1] (154-90.ipact.nl [82.210.90.154]) + by ipact2.infopact.nl (8.12.10/8.12.10) with ESMTP id i78G3Alx014107 + for ; Sun, 8 Aug 2004 18:03:12 +0200 +Message-ID: <41164E98.8030504@vulcanus.its.tudelft.nl> +Date: Sun, 08 Aug 2004 18:02:32 +0200 +From: Arjen van der Meijden +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "'PostgreSQL Performance'" +Subject: Re: Performance Bottleneck +References: <007f01c47d54$233b4bf0$8300a8c0@solent> +In-Reply-To: <007f01c47d54$233b4bf0$8300a8c0@solent> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/105 +X-Sequence-Number: 7741 + +On 8-8-2004 16:29, Matt Clark wrote: +> There are two well-worn and very mature techniques for dealing with the +> issue of web apps using one DB connection per apache process, both of which +> work extremely well and attack the issue at its source. +> +> 1) Use a front-end caching proxy like Squid as an accelerator. Static +> content will be served by the accelerator 99% of the time. Additionally, +> large pages can be served immediately to the accelerator by Apache, which +> can then go on to serve another request without waiting for the end user's +> dial-up connection to pull the data down. Massive speedup, fewer apache +> processes needed. + +Another version of this 1) is to run with a "content accelerator"; our +"favourite" is to run Tux in front of Apache. It takes over the +connection-handling stuff, has a very low memoryprofile (compared to +Apache) and very little overhead. What it does, is to serve up all +"simple" content (although you can have cgi/php/perl and other languages +being processed by it, entirely disabling the need for apache in some +cases) and forwards/proxies everything it doesn't understand to an +Apache/other webserver running at the same machine (which runs on +another port). + +I think there are a few advantages over Squid; since it is partially +done in kernel-space it can be slightly faster in serving up content, +apart from its simplicity which will probably matter even more. You'll +have no caching issues for pages that should not be cached or static +files that change periodically (like every few seconds). Afaik Tux can +handle more than 10 times as much ab-generated requests per second than +a default-compiled Apache on the same machine. +And besides the speed-up, you can do any request you where able to do +before, since Tux will simply forward it to Apache if it didn't +understand it. + +Anyway, apart from all that. Reducing the amount of apache-connections +is nice, but not really the same as reducing the amount of +pooled-connections using a db-pool... You may even be able to run with +1000 http-connections, 40 apache-processes and 10 db-connections. In +case of the non-pooled setup, you'd still have 40 db-connections. + +In a simple test I did, I did feel pgpool had quite some overhead +though. So it should be well tested, to find out where the +turnover-point is where it will be a gain instead of a loss... + +Best regards, + +Arjen van der Meijden + + +From pgsql-performance-owner@postgresql.org Sun Aug 8 15:40:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9407D5E46BF + for ; + Sun, 8 Aug 2004 15:40:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20789-08 + for ; + Sun, 8 Aug 2004 18:40:35 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 59EB35E40AC + for ; + Sun, 8 Aug 2004 15:40:35 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i78IeUiI024976 + for ; Sun, 8 Aug 2004 18:40:32 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i78IIFeX019694 + for pgsql-performance@postgresql.org; Sun, 8 Aug 2004 18:18:15 GMT +From: Martin Foster +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7.2) Gecko/20040803 +X-Accept-Language: en-ca, en-gb, en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Performance Bottleneck +References: <007f01c47d54$233b4bf0$8300a8c0@solent> + <41164E98.8030504@vulcanus.its.tudelft.nl> +In-Reply-To: <41164E98.8030504@vulcanus.its.tudelft.nl> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 74 +Message-ID: +Date: Sun, 08 Aug 2004 18:18:15 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/106 +X-Sequence-Number: 7742 + +Arjen van der Meijden wrote: + +> On 8-8-2004 16:29, Matt Clark wrote: +> +>> There are two well-worn and very mature techniques for dealing with the +>> issue of web apps using one DB connection per apache process, both of +>> which +>> work extremely well and attack the issue at its source. +>> +>> 1) Use a front-end caching proxy like Squid as an accelerator. Static +>> content will be served by the accelerator 99% of the time. Additionally, +>> large pages can be served immediately to the accelerator by Apache, which +>> can then go on to serve another request without waiting for the end +>> user's +>> dial-up connection to pull the data down. Massive speedup, fewer apache +>> processes needed. +> +> +> Another version of this 1) is to run with a "content accelerator"; our +> "favourite" is to run Tux in front of Apache. It takes over the +> connection-handling stuff, has a very low memoryprofile (compared to +> Apache) and very little overhead. What it does, is to serve up all +> "simple" content (although you can have cgi/php/perl and other languages +> being processed by it, entirely disabling the need for apache in some +> cases) and forwards/proxies everything it doesn't understand to an +> Apache/other webserver running at the same machine (which runs on +> another port). +> +> I think there are a few advantages over Squid; since it is partially +> done in kernel-space it can be slightly faster in serving up content, +> apart from its simplicity which will probably matter even more. You'll +> have no caching issues for pages that should not be cached or static +> files that change periodically (like every few seconds). Afaik Tux can +> handle more than 10 times as much ab-generated requests per second than +> a default-compiled Apache on the same machine. +> And besides the speed-up, you can do any request you where able to do +> before, since Tux will simply forward it to Apache if it didn't +> understand it. +> +> Anyway, apart from all that. Reducing the amount of apache-connections +> is nice, but not really the same as reducing the amount of +> pooled-connections using a db-pool... You may even be able to run with +> 1000 http-connections, 40 apache-processes and 10 db-connections. In +> case of the non-pooled setup, you'd still have 40 db-connections. +> +> In a simple test I did, I did feel pgpool had quite some overhead +> though. So it should be well tested, to find out where the +> turnover-point is where it will be a gain instead of a loss... +> +> Best regards, +> +> Arjen van der Meijden +> + +Other then images, there are very few static pages being loaded up by +the user. Since they make up a very small portion of the traffic, it +tends to be an optimization we can forgo for now. + +I attempted to make use of pgpool. At the default 32 connections +pre-forked the webserver almost immediately tapped out the pgpool base +and content stopped being served because no new processes were being +forked to make up for it. + +So I raised it to a higher value (256) and it immediately segfaulted and +dropped the core. So not sure exactly how to proceed, since I rather +need the thing to fork additional servers as load hits and not the other +way around. + +Unless I had it configured oddly, but it seems work differently then an +Apache server would to handle content. + + Martin Foster + Creator/Designer Ethereal Realms + martin@ethereal-realms.org + +From pgsql-performance-owner@postgresql.org Sun Aug 8 22:07:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 82EA514B2867 + for ; + Sun, 8 Aug 2004 22:07:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11103-05 + for ; + Mon, 9 Aug 2004 01:07:03 +0000 (GMT) +Received: from sraigw.sra.co.jp (sraigw.sra.co.jp [202.32.10.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AA46014B2827 + for ; + Sun, 8 Aug 2004 22:07:00 -0300 (ADT) +Received: from srascb.sra.co.jp (srascb [133.137.8.65]) + by sraigw.sra.co.jp (Postfix) with ESMTP + id 5934263041; Mon, 9 Aug 2004 10:07:04 +0900 (JST) +Received: from srascb.sra.co.jp (localhost [127.0.0.1]) + by localhost.sra.co.jp (Postfix) with ESMTP + id 4114610CD05; Mon, 9 Aug 2004 10:07:04 +0900 (JST) +Received: from sranhm.sra.co.jp (sranhm.sra.co.jp [133.137.44.16]) + by srascb.sra.co.jp (Postfix) with ESMTP + id 1448C10CD04; Mon, 9 Aug 2004 10:07:04 +0900 (JST) +Received: from localhost (IDENT:t-ishii@srapc2345.sra.co.jp [133.137.44.184]) + by sranhm.sra.co.jp (8.9.3+3.2W/3.7W-srambox) with ESMTP id KAA29592; + Mon, 9 Aug 2004 10:07:03 +0900 +Date: Mon, 09 Aug 2004 10:09:23 +0900 (JST) +Message-Id: <20040809.100923.26536346.t-ishii@sra.co.jp> +To: martin@ethereal-realms.org +Cc: threshar@torgo.978.org, pgsql-performance@postgresql.org +Subject: Re: Performance Bottleneck +From: Tatsuo Ishii +In-Reply-To: <41164B76.1030603@ethereal-realms.org> +References: <4115BA2C.3000900@ethereal-realms.org> + + <41164B76.1030603@ethereal-realms.org> +X-Mailer: Mew version 2.3 on Emacs 20.7 / Mule 4.1 + =?iso-2022-jp?B?KBskQjAqGyhCKQ==?= +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/107 +X-Sequence-Number: 7743 + +> Jeff wrote: +> > +> > On Aug 8, 2004, at 1:29 AM, Martin Foster wrote: +> > +> >> I am currently making use of Apache::DBI which overrides the +> >> DBI::disconnect call and keeps a pool of active connections for use +> >> when need be. Since it offloads the pooling to the webserver, it +> >> seems more advantageous then pgpool which while being able to run on a +> >> external system is not adding another layer of complexity. +> >> +> > +> > Apache::DBI is not the same sort of a pool as pgpool. DB connections +> > are not shared among all your apache children (A common misconception). +> > So if you have 300 apache kids you can have have 300 db connections. +> > With pgpool connections are shared among all of them so even though you +> > have 300 kids you only have say 32 db connections. +> > +> +> Seems that you are right, never noticed that from the documentation +> before. I always assumed it had something to do with the long +> lasting/persistent scripts that would remain in transactions for +> extended periods of time. +> +> Here is an odd question. While the server run 7.4.x, the client +> connects with 7.3.x. Would this in itself make a difference in +> performance as the protocols are different? At least based from +> pgpool's documentation. + +In this case the server fall back from V3 protocol (employed in 7.4 or +later) to V2 protocol (employed in from 6.4 to 7.3.x). As far as +pgpool concerning, performance difference is significant. Of course +that depends on the implementation though. + +FYI here is the outline of the testing using pgbench. + +H/W: Pentium4 2.4GHz x2/memory 1GB/HDD IDE 80GB (all PCs are same spec) +S/W: RedHat Linux 9/PostgreSQL 7.3.6/7.4.3 + +postgresql.conf: +tcpip_socket = true +max_connections = 512 +shared_buffers = 2048 + +host A: pgbench, host B: pgpool, host C: PostgreSQL 7.3.6 or 7.4.3 +pgbench parameters: -S -c 10 -t 1000 + +result: + TPS ratio(7.4.3) ratio(7.3.6) +---------------------------------------------------------------------------------------------------- +without pgpool 4357.625059 100% 100% +with pgpool(connection pool mode) 4330.290294 99.4% 94.1% +with pgpool(replication mode) 4297.614996 98.6% 87.6% +with pgpoo(replication with strictmode) 4270.223136 98.0% 81.5% +-- +Tatsuo Ishii + +From pgsql-performance-owner@postgresql.org Sun Aug 8 22:09:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 14F4B14B2824 + for ; + Sun, 8 Aug 2004 22:09:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10958-06 + for ; + Mon, 9 Aug 2004 01:09:47 +0000 (GMT) +Received: from sraigw.sra.co.jp (sraigw.sra.co.jp [202.32.10.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 93C3414B2867 + for ; + Sun, 8 Aug 2004 22:09:45 -0300 (ADT) +Received: from srascb.sra.co.jp (srascb [133.137.8.65]) + by sraigw.sra.co.jp (Postfix) with ESMTP + id 77AFC62E6D; Mon, 9 Aug 2004 10:09:48 +0900 (JST) +Received: from srascb.sra.co.jp (localhost [127.0.0.1]) + by localhost.sra.co.jp (Postfix) with ESMTP + id 54B4810CD06; Mon, 9 Aug 2004 10:09:48 +0900 (JST) +Received: from sranhm.sra.co.jp (sranhm.sra.co.jp [133.137.44.16]) + by srascb.sra.co.jp (Postfix) with ESMTP + id 30C6A10CD04; Mon, 9 Aug 2004 10:09:48 +0900 (JST) +Received: from localhost (IDENT:t-ishii@srapc2345.sra.co.jp [133.137.44.184]) + by sranhm.sra.co.jp (8.9.3+3.2W/3.7W-srambox) with ESMTP id KAA29840; + Mon, 9 Aug 2004 10:09:48 +0900 +Date: Mon, 09 Aug 2004 10:12:07 +0900 (JST) +Message-Id: <20040809.101207.98857407.t-ishii@sra.co.jp> +To: martin@ethereal-realms.org +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance Bottleneck +From: Tatsuo Ishii +In-Reply-To: +References: <007f01c47d54$233b4bf0$8300a8c0@solent> + <41164E98.8030504@vulcanus.its.tudelft.nl> + +X-Mailer: Mew version 2.3 on Emacs 20.7 / Mule 4.1 + =?iso-2022-jp?B?KBskQjAqGyhCKQ==?= +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/108 +X-Sequence-Number: 7744 + +> Arjen van der Meijden wrote: +> +> > On 8-8-2004 16:29, Matt Clark wrote: +> > +> >> There are two well-worn and very mature techniques for dealing with the +> >> issue of web apps using one DB connection per apache process, both of +> >> which +> >> work extremely well and attack the issue at its source. +> >> +> >> 1) Use a front-end caching proxy like Squid as an accelerator. Static +> >> content will be served by the accelerator 99% of the time. Additionally, +> >> large pages can be served immediately to the accelerator by Apache, which +> >> can then go on to serve another request without waiting for the end +> >> user's +> >> dial-up connection to pull the data down. Massive speedup, fewer apache +> >> processes needed. +> > +> > +> > Another version of this 1) is to run with a "content accelerator"; our +> > "favourite" is to run Tux in front of Apache. It takes over the +> > connection-handling stuff, has a very low memoryprofile (compared to +> > Apache) and very little overhead. What it does, is to serve up all +> > "simple" content (although you can have cgi/php/perl and other languages +> > being processed by it, entirely disabling the need for apache in some +> > cases) and forwards/proxies everything it doesn't understand to an +> > Apache/other webserver running at the same machine (which runs on +> > another port). +> > +> > I think there are a few advantages over Squid; since it is partially +> > done in kernel-space it can be slightly faster in serving up content, +> > apart from its simplicity which will probably matter even more. You'll +> > have no caching issues for pages that should not be cached or static +> > files that change periodically (like every few seconds). Afaik Tux can +> > handle more than 10 times as much ab-generated requests per second than +> > a default-compiled Apache on the same machine. +> > And besides the speed-up, you can do any request you where able to do +> > before, since Tux will simply forward it to Apache if it didn't +> > understand it. +> > +> > Anyway, apart from all that. Reducing the amount of apache-connections +> > is nice, but not really the same as reducing the amount of +> > pooled-connections using a db-pool... You may even be able to run with +> > 1000 http-connections, 40 apache-processes and 10 db-connections. In +> > case of the non-pooled setup, you'd still have 40 db-connections. +> > +> > In a simple test I did, I did feel pgpool had quite some overhead +> > though. So it should be well tested, to find out where the +> > turnover-point is where it will be a gain instead of a loss... + +I don't know what were the configurations you are using, but I noticed +that UNIX domain sockets are preferred for the connection bwteen +clients and pgpool. When I tested using pgbench -C (involving +connection estblishing for each transaction), +with-pgpool-configuration 10 times faster than without-pgpool-conf if +using UNIX domain sockets, while there is only 3.6 times speed up with +TCP/IP sockets. + +> > Best regards, +> > +> > Arjen van der Meijden +> > +> +> Other then images, there are very few static pages being loaded up by +> the user. Since they make up a very small portion of the traffic, it +> tends to be an optimization we can forgo for now. +> +> I attempted to make use of pgpool. At the default 32 connections +> pre-forked the webserver almost immediately tapped out the pgpool base +> and content stopped being served because no new processes were being +> forked to make up for it. +> +> So I raised it to a higher value (256) and it immediately segfaulted and +> dropped the core. So not sure exactly how to proceed, since I rather +> need the thing to fork additional servers as load hits and not the other +> way around. + +What version of pgpool did you test? I know that certain version +(actually 2.0.2) had such that problem. Can you try again with the +latest verison of pgpool? (it's 2.0.6). +-- +Tatsuo Ishii + +From pgsql-performance-owner@postgresql.org Tue Aug 10 14:33:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3F11014B280D + for ; + Mon, 9 Aug 2004 08:40:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81318-01 + for ; + Mon, 9 Aug 2004 11:40:39 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 49B7314B2800 + for ; + Mon, 9 Aug 2004 08:40:38 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i79BebiG081878 + for ; Mon, 9 Aug 2004 11:40:37 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i79BGFPH074687 + for pgsql-performance@postgresql.org; Mon, 9 Aug 2004 11:16:15 GMT +From: CoL +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: The black art of postgresql.conf tweaking +Date: Mon, 09 Aug 2004 13:16:03 +0200 +Organization: Hub.Org Networking Services +Lines: 44 +Message-ID: +References: <4110DA83.7020505@clockltd.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +In-Reply-To: <4110DA83.7020505@clockltd.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/124 +X-Sequence-Number: 7760 + +hi, + +Paul Serby wrote: + +> Can anyone give a good reference site/book for getting the most out of +> your postgres server. +> +> All I can find is contradicting theories on how to work out your settings. +> +> This is what I followed to setup our db server that serves our web +> applications. +> +> http://www.phpbuilder.com/columns/smith20010821.php3?page=2 +> +> We have a Dell Poweredge with the following spec. +> +> CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +> CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +> CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +> CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +> Physical Memory: 2077264 kB +> Swap Memory: 2048244 kB +> +> Apache on the Web server can take up to 300 connections and PHP is using +> pg_pconnect +> +> Postgres is set with the following. +> +> max_connections = 300 +> shared_buffers = 38400 +> sort_mem = 12000 +> +> But Apache is still maxing out the non-super user connection limit. +> +> The machine is under no load and I would like to up the max_connections +> but I would like to know more about what you need to consider before +> doing so. + +One more: In php.ini, set the pgsql.max_persistent lower then 300 + +; Maximum number of persistent links. -1 means no limit. +pgsql.max_persistent = -1 -> change this + +C. + +From pgsql-performance-owner@postgresql.org Mon Aug 9 11:28:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DB3BE14B2824 + for ; + Mon, 9 Aug 2004 11:28:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34453-10 + for ; + Mon, 9 Aug 2004 14:28:13 +0000 (GMT) +Received: from mail.clockltd.com (unknown [213.219.6.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 2506414B2800 + for ; + Mon, 9 Aug 2004 11:28:10 -0300 (ADT) +Received: from [193.195.120.35] (helo=[10.0.0.113]) + by mail.clockltd.com with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) + (Exim 4.34) id 1BuB82-0000hU-Ja + for pgsql-performance@postgresql.org; Mon, 09 Aug 2004 15:27:58 +0100 +Message-ID: <411789F1.6020305@clockltd.com> +Date: Mon, 09 Aug 2004 15:28:01 +0100 +From: Paul Serby +Organization: Clock +User-Agent: Mozilla Thunderbird 0.7.1 (X11/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: The black art of postgresql.conf tweaking +References: <4110DA83.7020505@clockltd.com> +In-Reply-To: <4110DA83.7020505@clockltd.com> +X-Enigmail-Version: 0.84.2.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Clock-Relay: yes +X-Clock-MailScanner-Information: Please contact the ISP for more information +X-Clock-MailScanner: Found to be clean +X-Clock-MailScanner-SpamCheck: not spam, SpamAssassin (score=0, required 5, + autolearn=not spam) +X-MailScanner-From: paul.serby@clockltd.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/110 +X-Sequence-Number: 7746 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Thanks to everyone for there help. + +I've changed my postgres settings to the following + +max_connections = 500 +shared_buffers = 10000 +sort_mem = 2000 +effective_cache_size = 5000 + +The 'effective_cache_size' is just a guess, but some references suggest +it so I added it. + +Dropping the Apache Keep-alive down to 3 seconds seems to have was a +great tip I now have far less idle connections hanging about. + +I've not maxed out the connections since making the changes, but I'm +still not convinced everything is running as well as it could be. I've +got some big result sets that need sorting and I'm sure I could spare a +bit more sort memory. + +Where does everyone get there information about the settings? I still +can't find anything that helps explain each of the settings and how you +determine there optimal settings. + +If anyone wants interested here is a table schema form one of the most +used tables. + +CREATE TABLE "tblForumMessages" ( +~ "pk_iForumMessagesID" serial, +~ "fk_iParentMessageID" integer DEFAULT 0 NOT NULL, +~ "fk_iAuthorID" integer NOT NULL, +~ "sSubject" character varying(255) NOT NULL, +~ "sBody" text, +~ "fk_iImageID" oid, +~ "dtCreatedOn" timestamp with time zone DEFAULT now(), +~ "iType" integer DEFAULT 0, +~ "bAnonymous" boolean DEFAULT false, +~ "bLocked" boolean DEFAULT false, +~ "dtHidden" timestamp with time zone, +~ "fk_iReplyToID" integer, +~ "iCreateLevel" integer DEFAULT 7 +); + +This is the query that is most called on the server explained + +EXPLAIN ANALYZE SELECT "tblForumMessages".* FROM "tblForumMessages" +WHERE "fk_iParentMessageID" = 90 ORDER BY "dtCreatedOn" DESC + +Which gives the following: + +Sort (cost=8156.34..8161.71 rows=2150 width=223) (actual +time=0.264..0.264 rows=0 loops=1) +~ Sort Key: "dtCreatedOn" +~ -> Index Scan using "fk_iParentMessageID_key" on "tblForumMessages" +~ (cost=0.00..8037.33 rows=2150 width=223) (actual time=0.153..0.153 +rows=0 loops=1) +~ Index Cond: ("fk_iParentMessageID" = 90) +~ Total runtime: 0.323 ms + +SELECT COUNT(*) FROM "tblForumMessages" WHERE "fk_iParentMessageID" = 90 +Returns: 22920 + +SELECT COUNT(*) FROM "tblForumMessages" +Returns: 429913 + +Paul Serby wrote: +| Can anyone give a good reference site/book for getting the most out of +| your postgres server. +| +| All I can find is contradicting theories on how to work out your settings. +| +| This is what I followed to setup our db server that serves our web +| applications. +| +| http://www.phpbuilder.com/columns/smith20010821.php3?page=2 +| +| We have a Dell Poweredge with the following spec. +| +| CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +| CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +| CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +| CPU: Intel(R) Xeon(TM) CPU 3.06GHz (512 KB Cache) +| Physical Memory: 2077264 kB +| Swap Memory: 2048244 kB +| +| Apache on the Web server can take up to 300 connections and PHP is using +| pg_pconnect +| +| Postgres is set with the following. +| +| max_connections = 300 +| shared_buffers = 38400 +| sort_mem = 12000 +| +| But Apache is still maxing out the non-super user connection limit. +| +| The machine is under no load and I would like to up the max_connections +| but I would like to know more about what you need to consider before +| doing so. +| +| The only other source I've found is this: +| +| http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html +| +| But following its method my postgres server locks up straight away as it +| recommends setting max_connections to 16 for Web sites? +| +| Is there a scientific method for optimizing postgres or is it all +| 'finger in the air' and trial and error. +| +| ---------------------------(end of broadcast)--------------------------- +| TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBF4nxp51pUZR6gxsRAi8cAJ9HBfpNMGQR7vurk0wYW+p6KfqZzACfc9NX +k72iabZxK+gku06Pf7NmHfQ= +=Ftv6 +-----END PGP SIGNATURE----- + +From pgsql-performance-owner@postgresql.org Mon Aug 9 11:47:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6177514B2825 + for ; + Mon, 9 Aug 2004 11:47:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43763-03 + for ; + Mon, 9 Aug 2004 14:46:54 +0000 (GMT) +Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) + by svr1.postgresql.org (Postfix) with ESMTP id 14CC714B2800 + for ; + Mon, 9 Aug 2004 11:46:52 -0300 (ADT) +Received: from [203.199.147.2] (port=42122 + helo=ps0499.intranet.persistent.co.in) + by frodo.hserus.net with asmtp + (Cipher TLSv1:RC4-MD5:128) (Exim 4.41 #0) + id 1BuBQM-000CMi-Ak by authid with plain; + Mon, 09 Aug 2004 20:16:54 +0530 +From: Shridhar Daithankar +To: Paul Serby +Subject: Re: The black art of postgresql.conf tweaking +Date: Mon, 9 Aug 2004 20:16:47 +0530 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <4110DA83.7020505@clockltd.com> <411789F1.6020305@clockltd.com> +In-Reply-To: <411789F1.6020305@clockltd.com> +MIME-Version: 1.0 +Content-Disposition: inline +Organization: Persistent Systems Pvt. Ltd. +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200408092016.47304.shridhar@frodo.hserus.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/111 +X-Sequence-Number: 7747 + +On Monday 09 Aug 2004 7:58 pm, Paul Serby wrote: +> I've not maxed out the connections since making the changes, but I'm +> still not convinced everything is running as well as it could be. I've +> got some big result sets that need sorting and I'm sure I could spare a +> bit more sort memory. + +You could set the sort mem for that connection before issuing the query. + +i.e. + +# set sort_mem=20000; +# select * ....; + +And reset it back. Setting it globally is not that good. If you do it +selectively, that would tune it as per your needs.. + +> Where does everyone get there information about the settings? I still +> can't find anything that helps explain each of the settings and how you +> determine there optimal settings. + +http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +HTH + + Shridhar + +From pgsql-performance-owner@postgresql.org Mon Aug 9 12:30:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 49E8314B27FB + for ; + Mon, 9 Aug 2004 12:30:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58454-07 + for ; + Mon, 9 Aug 2004 15:29:58 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 842E314B27FC + for ; + Mon, 9 Aug 2004 12:29:57 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: tablespaces and ramdisks +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Mon, 9 Aug 2004 11:29:57 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB34101AF2C@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: tablespaces and ramdisks +thread-index: AcR+JbnydD6RWPlcQHKi2t/PqHr15g== +From: "Merlin Moncure" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/112 +X-Sequence-Number: 7748 + +If you use tablespaces to put a high-update, non-critical table on a +ramdisk, will updates to that table will still cause the WAL files to +sync? + +I'm looking for a way to turn off syncing completely for a table. +Temporary tables do this, but they can only be accessed from a single +backend. + +Merlin + +From pgsql-performance-owner@postgresql.org Mon Aug 9 13:35:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 14FCF14B2821 + for ; + Mon, 9 Aug 2004 13:35:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81971-04 + for ; + Mon, 9 Aug 2004 16:35: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 04D8914B280B + for ; + Mon, 9 Aug 2004 13:35:20 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i79GZBVB016004; + Mon, 9 Aug 2004 12:35:11 -0400 (EDT) +To: "Merlin Moncure" +Cc: pgsql-performance@postgresql.org +Subject: Re: tablespaces and ramdisks +In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB34101AF2C@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB34101AF2C@Herge.rcsinc.local> +Comments: In-reply-to "Merlin Moncure" + message dated "Mon, 09 Aug 2004 11:29:57 -0400" +Date: Mon, 09 Aug 2004 12:35:10 -0400 +Message-ID: <16003.1092069310@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/113 +X-Sequence-Number: 7749 + +"Merlin Moncure" writes: +> If you use tablespaces to put a high-update, non-critical table on a +> ramdisk, will updates to that table will still cause the WAL files to +> sync? + +Sure. Postgres has no way of knowing that there's anything special +about such a tablespace. + +> I'm looking for a way to turn off syncing completely for a table. + +There isn't one, and I'm not eager to invent one. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 10 14:43:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B46A014B27FC + for ; + Mon, 9 Aug 2004 13:54:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88620-06 + for ; + Mon, 9 Aug 2004 16:54:17 +0000 (GMT) +Received: from pythagoras.zen.co.uk (pythagoras.zen.co.uk [212.23.3.140]) + by svr1.postgresql.org (Postfix) with ESMTP id 1532514B280D + for ; + Mon, 9 Aug 2004 13:54:09 -0300 (ADT) +Received: from [82.68.174.94] (helo=support.intercellsolutions.com) + by pythagoras.zen.co.uk with esmtp (Exim 4.30) id 1BuDPR-0007In-Bt + for pgsql-performance@postgresql.org; Mon, 09 Aug 2004 16:54:05 +0000 +Received: from [192.168.0.233] (82-68-174-94.dsl.in-addr.zen.co.uk + [82.68.174.94]) (authenticated bits=0) + by support.intercellsolutions.com (8.12.8/8.12.8) with ESMTP id + i79GgbS0027346 + for ; Mon, 9 Aug 2004 17:42:37 +0100 +Mime-Version: 1.0 (Apple Message framework v618) +To: pgsql-performance@postgresql.org +Message-Id: +Content-Type: multipart/alternative; boundary=Apple-Mail-10--53392545 +From: Paul Langard +Subject: Slow select, insert, update +Date: Mon, 9 Aug 2004 17:54:00 +0100 +X-Mailer: Apple Mail (2.618) +X-Intercell-MailScanner-Information: Please contact the ISP for more + information +X-Intercell-MailScanner: Found to be clean +X-Intercell-MailScanner-SpamCheck: not spam, SpamAssassin (score=-4.9, + required 4, BAYES_00 -4.90) +X-Originating-Pythagoras-IP: [82.68.174.94] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/125 +X-Sequence-Number: 7761 + +--Apple-Mail-10--53392545 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + format=flowed + +Having trouble with one table (see time to count records below!). + +Fairly new to postgres so any help much appreciated. + +It only contains 9,106 records - as you can see from: + + +select count(id) from project + +count +9106 +1 row(s) +Total runtime: 45,778.813 ms + + +There are only 3 fields: + +id +integer +nextval('id'::text) + +projectnumber +text + +description +text + + +There is one index: + +id_project_ukey +CREATE UNIQUE INDEX id_project_ukey ON project USING btree (id) + +... the database is regularly vaccuumed. +--Apple-Mail-10--53392545 +Content-Transfer-Encoding: 7bit +Content-Type: text/enriched; + charset=US-ASCII + +Having trouble with one table (see time to count records below!). + + +Fairly new to postgres so any help much appreciated. + + +It only contains 9,106 records - as you can see from: + + + +select count(id) from project + + +Arialcount + +Arial9106 + +1 row(s) + +Total runtime: 45,778.813 ms + + + +There are only 3 fields: + + +id + +integer + +nextval('id'::text) + + +projectnumber + +text + + +description + +text + + + +There is one index: + + +id_project_ukey + +CREATE UNIQUE INDEX id_project_ukey ON project USING btree (id) + + +... the database is regularly vaccuumed. +--Apple-Mail-10--53392545-- + + +From pgsql-performance-owner@postgresql.org Mon Aug 9 13:59:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B16E314B27FC + for ; + Mon, 9 Aug 2004 13:57:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87808-09 + for ; + Mon, 9 Aug 2004 16:57:53 +0000 (GMT) +Received: from campbell-lange.net (host0406.cammail.net [217.206.202.27]) + by svr1.postgresql.org (Postfix) with ESMTP id 915E414B2868 + for ; + Mon, 9 Aug 2004 13:57:16 -0300 (ADT) +Received: from [213.78.150.90] (helo=roz) by host0406 with asmtp (Exim 4.34) + id 1BuDYz-0006yk-An + for pgsql-performance@postgresql.org; Mon, 09 Aug 2004 18:03:57 +0100 +Received: from rory by roz with local (Exim 4.34) id 1BuDSD-0003ym-CF + for pgsql-performance@postgresql.org; Mon, 09 Aug 2004 17:56:57 +0100 +Date: Mon, 9 Aug 2004 17:56:57 +0100 +From: Rory Campbell-Lange +To: pgsql-performance@postgresql.org +Subject: Help specifying new machine +Message-ID: <20040809165657.GB15169@campbell-lange.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.5.6+20040722i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/114 +X-Sequence-Number: 7750 + +I'm thinking of upgrading an existing dedicated server and colocating my +own server. + +The server is used for prototype systems running Postgresql, php and +apache. The largest database is presently under 10GB and I haven't had +any major performance problems. We expect to have to host larger data +sets in the next year and anticipate one or two databases reaching the +30GB mark in size. We write a lot of our webapps functionality using +pl/pgsql. + +The present server is a 2GHz Pentium 4/512 KB cache with 2 +software-raided ide disks (Maxtors) and 1GB of RAM. + + +I have been offered the following 1U server which I can just about +afford: + +1U server +Intel Xeon 2.8GHz 512K cache 1 +512MB PC2100 DDR ECC Registered 2 +80Gb SATA HDD 4 +4 port SATA card, 3 ware 8506-4 1 +3 year next-day hardware warranty 1 + +There is an option for dual CPUs. + +I intend to install the system (Debian testing) on the first disk and +run the other 3 disks under RAID5 and ext3. + +I'm fairly ignorant about the issues relating to SATA vs SCSI and what +the best sort of RAM is for ensuring good database performance. I don't +require anything spectacular, just good speedy general performance. + +I imagine dedicating around 25% of RAM to Shared Memory and 2-4% for +Sort memory. + +Comments and advice gratefully received. +Rory + +-- +Rory Campbell-Lange + + + +From pgsql-performance-owner@postgresql.org Mon Aug 9 17:08:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B7BD114B27FF + for ; + Mon, 9 Aug 2004 17:08:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44414-10 + for ; + Mon, 9 Aug 2004 20:08:45 +0000 (GMT) +Received: from snowwhite.lulu.com (mail.lulu.com [66.193.5.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C64214B2800 + for ; + Mon, 9 Aug 2004 17:08:44 -0300 (ADT) +Received: from [10.0.0.32] (meatwad.rdu.lulu.com [10.0.0.32]) + (authenticated bits=0) + by snowwhite.lulu.com (8.12.8/8.12.8) with ESMTP id i79K8UQR022183 + (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); + Mon, 9 Aug 2004 16:08:31 -0400 +Message-ID: <4117D9C8.5030207@lulu.com> +Date: Mon, 09 Aug 2004 16:08:40 -0400 +From: Bill Montgomery +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Rory Campbell-Lange +Cc: pgsql-performance@postgresql.org +Subject: Re: Help specifying new machine +References: <20040809165657.GB15169@campbell-lange.net> +In-Reply-To: <20040809165657.GB15169@campbell-lange.net> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/115 +X-Sequence-Number: 7751 + +Rory, + +Rory Campbell-Lange wrote: + +>I'm thinking of upgrading an existing dedicated server and colocating my +>own server. +> +>The server is used for prototype systems running Postgresql, php and +>apache. The largest database is presently under 10GB and I haven't had +>any major performance problems. We expect to have to host larger data +>sets in the next year and anticipate one or two databases reaching the +>30GB mark in size. We write a lot of our webapps functionality using +>pl/pgsql. +> +>The present server is a 2GHz Pentium 4/512 KB cache with 2 +>software-raided ide disks (Maxtors) and 1GB of RAM. +> +> +>I have been offered the following 1U server which I can just about +>afford: +> +>1U server +>Intel Xeon 2.8GHz 512K cache 1 +>512MB PC2100 DDR ECC Registered 2 +>80Gb SATA HDD 4 +>4 port SATA card, 3 ware 8506-4 1 +>3 year next-day hardware warranty 1 +> +>There is an option for dual CPUs. +> +>I intend to install the system (Debian testing) on the first disk and +>run the other 3 disks under RAID5 and ext3. +> +> +If you are going to spend your money anywhere, spend it on your disk +subsystem. More or less, depending on the application, the bottleneck in +your database performance will be the number of random IO operations per +second (IOPS) your disk subsystem can execute. If you've got the money, +get the largest (i.e. most spindles) RAID 10 (striped and mirrored) you +can buy. If your budget doesn't permit RAID 10, RAID 5 is probably your +next best bet. + +>I'm fairly ignorant about the issues relating to SATA vs SCSI and what +>the best sort of RAM is for ensuring good database performance. I don't +>require anything spectacular, just good speedy general performance. +> +> +Be sure that if you go with SATA over SCSI, the disk firmware does not +lie about fsync(). Most consumer grade IDE disks will report to the OS +that data is written to disk while it is still in the drive's cache. I +don't know much about SATA disks, but I suspect they behave the same +way. The problem with this is that if there is data that PostgreSQL +thinks is written safely to disk, but is really still in the drive +cache, and you lose power at that instant, you can find yourself with an +inconsistent set of data that cannot be recovered from. SCSI disks, +AFAIK, will always be truthful about fsync(), and you will never end up +with data that you *thought* was written to disk, but gets lost on power +failure. + +>I imagine dedicating around 25% of RAM to Shared Memory and 2-4% for +>Sort memory. +> +> +That is probably too much RAM to allocate to shm. Start with 10000 +buffers, benchmark your app, and slowly work up from there. NOTE: This +advice will likely change with the introduction of ARC (adaptive +caching) in 8.0; for now what will happen is that a large read of an +infrequently accessed index or table will blow away all your shared +memory buffers, and you'll end up with 25% of your memory filled with +useless data. Better to let the smarter filesystem cache handle the bulk +of your caching needs. + +>Comments and advice gratefully received. +>Rory +> +> +> +Best Luck, + +Bill Montgomery + +From pgsql-performance-owner@postgresql.org Mon Aug 9 21:06:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FEB414B2820 + for ; + Mon, 9 Aug 2004 21:06:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07984-01 + for ; + Tue, 10 Aug 2004 00:05:58 +0000 (GMT) +Received: from web13121.mail.yahoo.com (web13121.mail.yahoo.com + [216.136.174.83]) + by svr1.postgresql.org (Postfix) with SMTP id 6E27514B27FB + for ; + Mon, 9 Aug 2004 21:05:56 -0300 (ADT) +Message-ID: <20040810000559.91562.qmail@web13121.mail.yahoo.com> +Received: from [63.78.248.48] by web13121.mail.yahoo.com via HTTP; + Mon, 09 Aug 2004 17:05:59 PDT +Date: Mon, 9 Aug 2004 17:05:59 -0700 (PDT) +From: Litao Wu +Subject: insert waits for delete with trigger +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.0 tagged_above=0.0 required=5.0 tests=HOT_NASTY +X-Spam-Level: +X-Archive-Number: 200408/116 +X-Sequence-Number: 7752 + +Hi all, + +We have table q_20040805 and a delete trigger on +it. The delete trigger is: +update table q_summary set count=count-1... + +When we delete from q_20040805, we also insert into +related info q_process within the same +transaction. There is a PK on q_process, but no +trigger on it. No FK on either of the 3 tables. + +Here is info from pg_lock: + relname | pid | mode | +granted | current_query + +-------------------+-------+------------------+---------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + q_process | 14643 | RowExclusiveLock | t | +DELETE FROM q_20040805 WHERE domain_id='20237906' AND +module='spam' + q_summary | 14643 | RowExclusiveLock | t | +DELETE FROM q_20040805 WHERE domain_id='20237906' AND +module='spam' + q_20040805 | 14643 | RowExclusiveLock | t | +DELETE FROM q_20040805 WHERE domain_id='20237906' AND +module='spam' + q_process | 18951 | RowExclusiveLock | t | +INSERT INTO q_process (...) SELECT ... FROM q_20040805 + WHERE domain_id='20237906' AND module='spam' + + From ps command, it is easy to see another +insert is waiting: + +ps -elfww|grep 18951 +040 S postgres 18951 870 0 69 0 - 81274 +semtim 16:34 ? 00:00:00 postgres: postgres mxl +xxx.xxx.x.xxx:49986 INSERT waiting +ps -elfww|grep 14643 +040 S postgres 14643 870 79 70 0 - 81816 +semtim 15:56 ? 00:44:02 postgres: postgres mxl +xxx.xxx.x.xxx:47236 DELETE + +I do not understand why process 18951 (insert) +is waiting (subqery SELECT of INSERT INTO +is not a problem as I know) + +PG version is: 7.3.2 + +Can someone explain? + +Thanks, + + + +__________________________________ +Do you Yahoo!? +New and Improved Yahoo! Mail - Send 10MB messages! +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Mon Aug 9 21:31:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D48D214B2800 + for ; + Mon, 9 Aug 2004 21:31:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14194-01 + for ; + Tue, 10 Aug 2004 00:31: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 8A5F314B27FB + for ; + Mon, 9 Aug 2004 21:31:40 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7A0VhVU022224; + Mon, 9 Aug 2004 20:31:43 -0400 (EDT) +To: Litao Wu +Cc: pgsql-performance@postgresql.org +Subject: Re: insert waits for delete with trigger +In-reply-to: <20040810000559.91562.qmail@web13121.mail.yahoo.com> +References: <20040810000559.91562.qmail@web13121.mail.yahoo.com> +Comments: In-reply-to Litao Wu + message dated "Mon, 09 Aug 2004 17:05:59 -0700" +Date: Mon, 09 Aug 2004 20:31:43 -0400 +Message-ID: <22223.1092097903@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/117 +X-Sequence-Number: 7753 + +Litao Wu writes: +> Here is info from pg_lock: + +All those locks are already granted, so they are not much help in +understanding what PID 18951 is waiting for. What row does it have +with granted = 'f' ? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 10 01:36:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4631614B281A + for ; + Tue, 10 Aug 2004 01:35:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34883-03 + for ; + Tue, 10 Aug 2004 04:35:57 +0000 (GMT) +Received: from web13124.mail.yahoo.com (web13124.mail.yahoo.com + [216.136.174.142]) + by svr1.postgresql.org (Postfix) with SMTP id 8344114B280B + for ; + Tue, 10 Aug 2004 01:35:55 -0300 (ADT) +Message-ID: <20040810043555.38371.qmail@web13124.mail.yahoo.com> +Received: from [24.9.238.30] by web13124.mail.yahoo.com via HTTP; + Mon, 09 Aug 2004 21:35:55 PDT +Date: Mon, 9 Aug 2004 21:35:55 -0700 (PDT) +From: Litao Wu +Subject: Re: insert waits for delete with trigger +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <22223.1092097903@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.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/118 +X-Sequence-Number: 7754 + +Hi Tom, + +No row has granted='f'. +The result shown in the original email is from: +select c.relname, l.pid, l.mode, l.granted, +current_query +from pg_locks l, pg_class c, pg_stat_activity a +where relation is not null + AND l.relation = c.oid + AND l.pid = a.procpid + AND l.mode != 'AccessShareLock' +order by l.pid; + +After the above result, I went to OS +to get ps status. + +Did I miss something? + +Since the lock was granted to pid (18951), that +cause me confuse why OS ps shows it is waiting. + +Also, I ntoiced that insert will be finished +almost immediately after delete is done. + +Thanks, + + +--- Tom Lane wrote: + +> Litao Wu writes: +> > Here is info from pg_lock: +> +> All those locks are already granted, so they are not +> much help in +> understanding what PID 18951 is waiting for. What +> row does it have +> with granted = 'f' ? +> +> regards, tom lane +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map +> settings +> + + + + +__________________________________ +Do you Yahoo!? +Yahoo! Mail is new and improved - Check it out! +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Tue Aug 10 01:41:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 53ED114B281B + for ; + Tue, 10 Aug 2004 01:41:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60323-01 + for ; + Tue, 10 Aug 2004 04:41: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 4846514B280D + for ; + Tue, 10 Aug 2004 01:41:33 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7A4fXcW024198; + Tue, 10 Aug 2004 00:41:33 -0400 (EDT) +To: Litao Wu +Cc: pgsql-performance@postgresql.org +Subject: Re: insert waits for delete with trigger +In-reply-to: <20040810043555.38371.qmail@web13124.mail.yahoo.com> +References: <20040810043555.38371.qmail@web13124.mail.yahoo.com> +Comments: In-reply-to Litao Wu + message dated "Mon, 09 Aug 2004 21:35:55 -0700" +Date: Tue, 10 Aug 2004 00:41:33 -0400 +Message-ID: <24197.1092112893@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/119 +X-Sequence-Number: 7755 + +Litao Wu writes: +> Did I miss something? + +Your join omits all transaction locks. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 10 10:39:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F34B214B2806 + for ; + Tue, 10 Aug 2004 10:39:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79926-09 + for ; + Tue, 10 Aug 2004 13:39:24 +0000 (GMT) +Received: from snowwhite.lulu.com (mail.lulu.com [66.193.5.50]) + by svr1.postgresql.org (Postfix) with ESMTP id B043814B27FF + for ; + Tue, 10 Aug 2004 10:39:20 -0300 (ADT) +Received: from [10.0.0.32] (meatwad.rdu.lulu.com [10.0.0.32]) + (authenticated bits=0) + by snowwhite.lulu.com (8.12.8/8.12.8) with ESMTP id i7ADdBQR003010 + (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) + for ; Tue, 10 Aug 2004 09:39:11 -0400 +Message-ID: <4118D008.1070606@lulu.com> +Date: Tue, 10 Aug 2004 09:39:20 -0400 +From: Bill Montgomery +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Column order performance +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/120 +X-Sequence-Number: 7756 + +Does the order of columns of varying size have any effect on +SELECT/INSERT/UPDATE/and/or/DELETE performance? Take the example where +an integer primary key is listed first in the table and alternatively +listed after some large varchar or text columns? For example, is this +different performance-wise: + +CREATE TABLE foo +( + foo_id serial, + foo_data varchar(8000), + primary key (foo_id) +); + +from this? + +CREATE TABLE bar +( + bar_data varchar(8000), + bar_id serial, + primary key (bar_id) +); + +My suspicion is it would never make a difference since the index will be +searched when querying "WHERE [foo|bar]_id=?" (as long as the planner +decides to use the index). + +What about a case where a sequential scan _must_ be performed? Could the +order of columns make a difference in the number of pages read/written +if there is a mix of small and large columns? + +Thanks for your help. + +Best Regards, + +Bill Montgomery + +From pgsql-performance-owner@postgresql.org Tue Aug 10 12:45:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 550A214B280B + for ; + Tue, 10 Aug 2004 11:35:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05005-09 + for ; + Tue, 10 Aug 2004 14:35:43 +0000 (GMT) +Received: from sphinx.mythic-beasts.com (sphinx.mythic-beasts.com + [212.69.37.6]) + by svr1.postgresql.org (Postfix) with ESMTP id D7FB414B281D + for ; + Tue, 10 Aug 2004 11:35:31 -0300 (ADT) +Received: from xelah (helo=localhost) + by sphinx.mythic-beasts.com with local-esmtp (Exim 3.33 #3) + id 1BuXit-0006so-00 + for pgsql-performance@postgresql.org; Tue, 10 Aug 2004 15:35:31 +0100 +Date: Tue, 10 Aug 2004 15:35:31 +0100 (BST) +From: Alex Hayward +X-X-Sender: xelah@sphinx.mythic-beasts.com +To: 'PostgreSQL Performance' +Subject: Re: Performance Bottleneck +In-Reply-To: <007f01c47d54$233b4bf0$8300a8c0@solent> +Message-ID: +References: <007f01c47d54$233b4bf0$8300a8c0@solent> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/122 +X-Sequence-Number: 7758 + +On Sun, 8 Aug 2004, Matt Clark wrote: + +> > And this is exactly where the pgpool advantage lies. +> > Especially with the +> > TPC-W, the Apache is serving a mix of PHP (or whatever CGI +> > technique is +> > used) and static content like images. Since the 200+ Apache +> > kids serve +> > any of that content by random and the emulated browsers very much +> > encourage it to ramp up MaxClients children by using up to 4 +> > concurrent +> > image connections, one does end up with MaxClients DB +> > connections that +> > are all relatively low frequently used. In contrast to that the real +> > pgpool causes lesser, more active DB connections, which is better for +> > performance. +> +> There are two well-worn and very mature techniques for dealing with the +> issue of web apps using one DB connection per apache process, both of which +> work extremely well and attack the issue at its source. +> +> 1) Use a front-end caching proxy like Squid as an accelerator. Static +> content will be served by the accelerator 99% of the time. Additionally, +> large pages can be served immediately to the accelerator by Apache, which +> can then go on to serve another request without waiting for the end user's +> dial-up connection to pull the data down. Massive speedup, fewer apache +> processes needed. + +Squid also takes away the work of doing SSL (presuming you're running it +on a different machine). Unfortunately it doesn't support HTTP/1.1 which +means that most generated pages (those that don't set Content-length) end +up forcing squid to close and then reopen the connection to the web +server. + +Because you no longer need to worry about keeping Apache processes around +to dribble data to people on the wrong end of modems you can reduce +MaxClients quite a bit (to, say, 10 or 20 per web server). This keeps the +number of PostgreSQL connections down. I'd guess that above some point +you're going to reduce performance by increasing MaxClients and running +queries in parallel rather than queueing the request and doing them +serially. + +I've also had some problems when Squid had a large number of connections +open (several thousand); though that may have been because of my +half_closed_clients setting. Squid 3 coped a lot better when I tried it +(quite a few months ago now - and using FreeBSD and the special kqueue +system call) but crashed under some (admittedly synthetic) conditions. + +> I'm sure pgpool and the like have their place, but being band-aids for +> poorly configured websites probably isn't the best use for them. + +You still have periods of time when the web servers are busy using their +CPUs to generate HTML rather than waiting for database queries. This is +especially true if you cache a lot of data somewhere on the web servers +themselves (which, in my experience, reduces the database load a great +deal). If you REALLY need to reduce the number of connections (because you +have a large number of web servers doing a lot of computation, say) then +it might still be useful. + +From pgsql-performance-owner@postgresql.org Tue Aug 10 11:54:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A64314B281A + for ; + Tue, 10 Aug 2004 11:48:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07206-07 + for ; + Tue, 10 Aug 2004 14:48:44 +0000 (GMT) +Received: from web13126.mail.yahoo.com (web13126.mail.yahoo.com + [216.136.174.163]) + by svr1.postgresql.org (Postfix) with SMTP id 9155314B2825 + for ; + Tue, 10 Aug 2004 11:48:37 -0300 (ADT) +Message-ID: <20040810144838.72955.qmail@web13126.mail.yahoo.com> +Received: from [63.78.248.48] by web13126.mail.yahoo.com via HTTP; + Tue, 10 Aug 2004 07:48:38 PDT +Date: Tue, 10 Aug 2004 07:48:38 -0700 (PDT) +From: Litao Wu +Subject: Re: insert waits for delete with trigger +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <24197.1092112893@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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/121 +X-Sequence-Number: 7757 + +Thank you. + +How about: + +select c.relname, l.pid, l.mode, l.granted, +a.current_query +from pg_locks l, pg_class c, pg_stat_activity a +where + l.relation = c.oid + AND l.pid = a.procpid +order by l.granted, l.pid; + + + relname | pid | +mode | granted | + + current_query + +-----------------------------------+-------+------------------+---------+----------------------------------------------- +------------------------------------------------------------------------------------------------------------------------ +--------------------------------------------------------------------------------- + q_20040810 | 488 | AccessShareLock +| t | + q_20040810 | 488 | RowExclusiveLock +| t | + q_process | 3729 | AccessShareLock +| t | DELETE FROM q_20040805 WHERE domain_id +='2005761066' AND module='spam' + q_process | 3729 | RowExclusiveLock +| t | DELETE FROM q_20040805 WHERE domain_id +='2005761066' AND module='spam' + q_20040805 | 3729 | AccessShareLock +| t | DELETE FROM q_20040805 WHERE domain_id +='2005761066' AND module='spam' + q_20040805 | 3729 | RowExclusiveLock +| t | DELETE FROM q_20040805 WHERE domain_id +='2005761066' AND module='spam' + q_summary | 3729 | AccessShareLock +| t | DELETE FROM q_20040805 WHERE domain_id +='2005761066' AND module='spam' + q_summary | 3729 | RowExclusiveLock +| t | DELETE FROM q_20040805 WHERE domain_id +='2005761066' AND module='spam' + q_summary_did_dir_idx | 3729 | AccessShareLock +| t | DELETE FROM q_20040805 WHERE domain_id +='2005761066' AND module='spam' + pg_shadow | 7660 | +AccessShareLock | t | + pg_locks | 7660 | +AccessShareLock | t | + pg_database | 7660 | +AccessShareLock | t | + pg_class | 7660 | +AccessShareLock | t | + pg_stat_activity | 7660 | +AccessShareLock | t | + pg_class_oid_index | 7660 | +AccessShareLock | t | + q_process | 8593 | AccessShareLock +| t | DELETE FROM q_20040810 WHERE domain_id +='2002300623' AND module='spam' + q_process | 8593 | RowExclusiveLock +| t | DELETE FROM q_20040810 WHERE domain_id +='2002300623' AND module='spam' + q_20040810 | 8593 | AccessShareLock +| t | DELETE FROM q_20040810 WHERE domain_id +='2002300623' AND module='spam' + q_20040810 | 8593 | RowExclusiveLock +| t | DELETE FROM q_20040810 WHERE domain_id +='2002300623' AND module='spam' + q_summary | 8593 | AccessShareLock +| t | DELETE FROM q_20040810 WHERE domain_id +='2002300623' AND module='spam' + q_summary | 8593 | RowExclusiveLock +| t | DELETE FROM q_20040810 WHERE domain_id +='2002300623' AND module='spam' + q_summary_did_dir_idx | 8593 | AccessShareLock +| t | DELETE FROM q_20040810 WHERE domain_id +='2002300623' AND module='spam' + q_process | 19027 | AccessShareLock +| t | INSERT INTO q_process (...) SELECT ... +FROM q_20040805 WHERE domain_id='2005761066' AND +module='spam' + q_process | 19027 | RowExclusiveLock +| t | INSERT INTO q_process (...) SELECT ... +FROM q_20040805 WHERE domain_id='2005761066' AND +module='spam' + q_20040805 | 19027 | AccessShareLock +| t | INSERT INTO q_process (...) SELECT ... +FROM q_20040805 WHERE domain_id='2005761066' AND +module='spam' + q_did_mod_dir_20040805_idx | 19027 | AccessShareLock +| t | INSERT INTO q_process (...) SELECT ... +FROM q_20040805 WHERE domain_id='2005761066' AND +module='spam' +(26 rows) + + +ps -elfww|grep 19027 +040 S postgres 19027 870 1 69 0 - 81290 +semtim 07:31 ? 00:00:51 postgres: postgres mxl +192.168.0.177:38266 INSERT waiting + +--- Tom Lane wrote: + +> Litao Wu writes: +> > Did I miss something? +> +> Your join omits all transaction locks. +> +> regards, tom lane +> + + + + +__________________________________ +Do you Yahoo!? +Yahoo! Mail - 50x more storage than other providers! +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Tue Aug 10 13:31:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 496C614B27FC + for ; + Tue, 10 Aug 2004 12:26:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24261-01 + for ; + Tue, 10 Aug 2004 15:25:58 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 275FC14B2820 + for ; + Tue, 10 Aug 2004 12:25:51 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: [HACKERS] fsync vs open_sync +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Tue, 10 Aug 2004 11:25:15 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A7446@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [HACKERS] fsync vs open_sync +thread-index: AcR+PTvsPyd0oLNMSpuRU9Hwk6sV/gAsMMOQ +From: "Merlin Moncure" +To: +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/123 +X-Sequence-Number: 7759 + +> Anyway, with fsync enabled using standard fsync(), I get roughly +300-400 +> inserts per second. With fsync disabled, I get about 7000 inserts per +> second. When I re-enable fsync but use the open_sync option, I can get +> about 2500 inserts per second. + +You are getting 300-400 inserts/sec with fsync on? If you don't mind me +asking, what's your hardware? (also, have you checked fsync on #s with +the new bgwriter in 7.5?) + +Merlin + + + +From pgsql-performance-owner@postgresql.org Tue Aug 10 14:46:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37EA614B281B + for ; + Tue, 10 Aug 2004 12:37:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27846-06 + for ; + Tue, 10 Aug 2004 15:37:52 +0000 (GMT) +Received: from outland.mohawksoft.com (unknown [64.46.156.80]) + by svr1.postgresql.org (Postfix) with ESMTP id 92FF114B281A + for ; + Tue, 10 Aug 2004 12:37:47 -0300 (ADT) +Received: (from mohawk@localhost) + by outland.mohawksoft.com (8.11.6/8.11.6) id i7AFsSO09616; + Tue, 10 Aug 2004 11:54:28 -0400 +From: pgsql@mohawksoft.com +X-Authentication-Warning: outland.mohawksoft.com: mohawk set sender to + pgsql@mohawksoft.com using -f +Received: from 64.119.142.34 (SquirrelMail authenticated user pgsql) + by mail.mohawksoft.com with HTTP; + Tue, 10 Aug 2004 11:54:28 -0400 (EDT) +Message-ID: <15691.64.119.142.34.1092153268.squirrel@mail.mohawksoft.com> +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A7446@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3412A7446@Herge.rcsinc.local> +Date: Tue, 10 Aug 2004 11:54:28 -0400 (EDT) +Subject: Re: [HACKERS] fsync vs open_sync +To: "Merlin Moncure" +Cc: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.2 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME, + PRIORITY_NO_NAME +X-Spam-Level: * +X-Archive-Number: 200408/126 +X-Sequence-Number: 7762 + +>> Anyway, with fsync enabled using standard fsync(), I get roughly +> 300-400 +>> inserts per second. With fsync disabled, I get about 7000 inserts per +>> second. When I re-enable fsync but use the open_sync option, I can get +>> about 2500 inserts per second. +> +> You are getting 300-400 inserts/sec with fsync on? If you don't mind me +> asking, what's your hardware? (also, have you checked fsync on #s with +> the new bgwriter in 7.5?) +> + +300 inserts persecond with fsync on using fdatasync. 2500 inserts per +second with fsync on using open_sync. + +[mwoodward@penguin-021 mwoodward]$ cat /proc/cpuinfo +processor : 0 +vendor_id : GenuineIntel +cpu family : 15 +model : 2 +model name : Intel(R) Xeon(TM) CPU 2.40GHz +stepping : 5 +cpu MHz : 2399.373 +cache size : 512 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 pae mce cx8 apic sep mtrr pge mca +cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid +bogomips : 4784.12 + +Linux node1 2.4.25 #1 Mon Mar 22 13:33:41 EST 2004 i686 i686 i386 GNU/Linux + + ide2: BM-DMA at 0xc400-0xc407, BIOS settings: hde:pio, hdf:pio +hde: Maxtor 6Y200P0, ATA DISK drive +hde: attached ide-disk driver. +hde: host protected area => 1 +hde: 398297088 sectors (203928 MB) w/7936KiB Cache, CHS=24792/255/63, +UDMA(100) + +PDC20268: IDE controller at PCI slot 06:05.0 + + +From pgsql-performance-owner@postgresql.org Tue Aug 10 21:38:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B4A1414B281C + for ; + Tue, 10 Aug 2004 13:53:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42082-01 + for ; + Tue, 10 Aug 2004 16:53: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 5D80814B2820 + for ; + Tue, 10 Aug 2004 13:53:11 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7AGrA0k029339; + Tue, 10 Aug 2004 12:53:10 -0400 (EDT) +To: Litao Wu +Cc: pgsql-performance@postgresql.org +Subject: Re: insert waits for delete with trigger +In-reply-to: <20040810144838.72955.qmail@web13126.mail.yahoo.com> +References: <20040810144838.72955.qmail@web13126.mail.yahoo.com> +Comments: In-reply-to Litao Wu + message dated "Tue, 10 Aug 2004 07:48:38 -0700" +Date: Tue, 10 Aug 2004 12:53:10 -0400 +Message-ID: <29338.1092156790@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/135 +X-Sequence-Number: 7771 + +Litao Wu writes: +> How about: + +> select c.relname, l.pid, l.mode, l.granted, +> a.current_query +> from pg_locks l, pg_class c, pg_stat_activity a +> where +> l.relation = c.oid +> AND l.pid = a.procpid +> order by l.granted, l.pid; + +You can't join to pg_class without eliminating the transaction lock rows +(because they have NULLs in the relation field). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 10 21:05:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 149ED14B281C + for ; + Tue, 10 Aug 2004 14:19:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66847-07 + for ; + Tue, 10 Aug 2004 17:18:59 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 669AE14B281A + for ; + Tue, 10 Aug 2004 14:18:51 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6042550; Tue, 10 Aug 2004 10:20:02 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Merlin Moncure" , + +Subject: Re: [HACKERS] fsync vs open_sync +Date: Tue, 10 Aug 2004 10:18:32 -0700 +User-Agent: KMail/1.4.3 +Cc: +References: <6EE64EF3AB31D5448D0007DD34EEB3412A7446@Herge.rcsinc.local> +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A7446@Herge.rcsinc.local> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408101018.32327.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/134 +X-Sequence-Number: 7770 + +Guys, just so you know: + +OSDL did some testing and found Ext3 to be perhaps the worst FS for PostgreSQL +-- although this testing was with the default options. Ext3 involved an +almost 40% write performance penalty compared with Ext2, whereas the penalty +for ReiserFS and JFS was less than 10%. + +This concurs with my personal experience. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Aug 10 21:05:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A564014B281A + for ; + Tue, 10 Aug 2004 14:23:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78011-07 + for ; + Tue, 10 Aug 2004 17:23:46 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BC6014B2800 + for ; + Tue, 10 Aug 2004 14:23:44 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6042583; Tue, 10 Aug 2004 10:24:57 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Bill Montgomery , + pgsql-performance@postgresql.org +Subject: Re: Column order performance +Date: Tue, 10 Aug 2004 10:23:28 -0700 +User-Agent: KMail/1.4.3 +References: <4118D008.1070606@lulu.com> +In-Reply-To: <4118D008.1070606@lulu.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408101023.28084.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/133 +X-Sequence-Number: 7769 + +Bill, + +> Does the order of columns of varying size have any effect on +> SELECT/INSERT/UPDATE/and/or/DELETE performance? Take the example where +> an integer primary key is listed first in the table and alternatively +> listed after some large varchar or text columns? + +No, the "order" of the columns in the table makes no difference. They are not +physically stored in the metadata order, anyway; on the data pages, +fixed-length fields (e.g. INT, BOOLEAN, etc.) are stored first and +variable-length fields (CHAR, TEXT, NUMERIC) after them, AFAIK. + +The only thing I have seen elusive reports of is that *display* speed can be +afffected by column order (e.g. when you call the query to the command line +with many rows) but I've not seen this proven in a test case. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Aug 13 12:37:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A748514B281E + for ; + Tue, 10 Aug 2004 14:48:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43532-03 + for ; + Tue, 10 Aug 2004 17:48:19 +0000 (GMT) +Received: from outland.mohawksoft.com (unknown [64.46.156.80]) + by svr1.postgresql.org (Postfix) with ESMTP id CCA2D14B2827 + for ; + Tue, 10 Aug 2004 14:48:12 -0300 (ADT) +Received: (from mohawk@localhost) + by outland.mohawksoft.com (8.11.6/8.11.6) id i7AI4rQ11357; + Tue, 10 Aug 2004 14:04:53 -0400 +From: pgsql@mohawksoft.com +X-Authentication-Warning: outland.mohawksoft.com: mohawk set sender to + pgsql@mohawksoft.com using -f +Received: from 64.119.142.34 (SquirrelMail authenticated user pgsql) + by mail.mohawksoft.com with HTTP; + Tue, 10 Aug 2004 14:04:52 -0400 (EDT) +Message-ID: <33646.64.119.142.34.1092161092.squirrel@mail.mohawksoft.com> +In-Reply-To: <200408101018.32327.josh@agliodbs.com> +References: <6EE64EF3AB31D5448D0007DD34EEB3412A7446@Herge.rcsinc.local> + <200408101018.32327.josh@agliodbs.com> +Date: Tue, 10 Aug 2004 14:04:52 -0400 (EDT) +Subject: Re: [HACKERS] fsync vs open_sync +To: "Josh Berkus" +Cc: "Merlin Moncure" , + pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.2 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME, + PRIORITY_NO_NAME +X-Spam-Level: * +X-Archive-Number: 200408/207 +X-Sequence-Number: 7843 + +> Guys, just so you know: +> +> OSDL did some testing and found Ext3 to be perhaps the worst FS for +> PostgreSQL +> -- although this testing was with the default options. Ext3 involved an +> almost 40% write performance penalty compared with Ext2, whereas the +> penalty +> for ReiserFS and JFS was less than 10%. +> +> This concurs with my personal experience. + +I had exactly the same experience + +From pgsql-performance-owner@postgresql.org Tue Aug 10 20:54:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CFD6C14B281C + for ; + Tue, 10 Aug 2004 15:18:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 00633-09 + for ; + Tue, 10 Aug 2004 18:18: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 C700B14B2821 + for ; + Tue, 10 Aug 2004 15:18:07 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7AII64P000182; + Tue, 10 Aug 2004 14:18:06 -0400 (EDT) +To: Paul Langard +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow select, insert, update +In-reply-to: +References: +Comments: In-reply-to Paul Langard + message dated "Mon, 09 Aug 2004 17:54:00 +0100" +Date: Tue, 10 Aug 2004 14:18:05 -0400 +Message-ID: <181.1092161885@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/132 +X-Sequence-Number: 7768 + +Paul Langard writes: +> select count(id) from project +> count +> 9106 +> 1 row(s) +> Total runtime: 45,778.813 ms + +Yipes. The only explanation I can think of is tremendous table bloat. +What do you get from "vacuum verbose project" --- in particular, how +many pages in the table? + +> ... the database is regularly vaccuumed. + +Not regularly enough, perhaps ... or else you need to increase the free +space map size parameters. In any case you'll probably need to do one +round of "vacuum full" to get this table back within bounds. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 10 20:20:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A327C14B2804 + for ; + Tue, 10 Aug 2004 15:49:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28439-09 + for ; + Tue, 10 Aug 2004 18:49:39 +0000 (GMT) +Received: from snowwhite.lulu.com (mail.lulu.com [66.193.5.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 7935B14B2800 + for ; + Tue, 10 Aug 2004 15:49:33 -0300 (ADT) +Received: from [10.0.0.32] (meatwad.rdu.lulu.com [10.0.0.32]) + (authenticated bits=0) + by snowwhite.lulu.com (8.12.8/8.12.8) with ESMTP id i7AInKQR007314 + (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) + for ; Tue, 10 Aug 2004 14:49:20 -0400 +Message-ID: <411918B9.9000707@lulu.com> +Date: Tue, 10 Aug 2004 14:49:29 -0400 +From: Bill Montgomery +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Column order performance +References: <4118D008.1070606@lulu.com> <200408101023.28084.josh@agliodbs.com> +In-Reply-To: <200408101023.28084.josh@agliodbs.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/131 +X-Sequence-Number: 7767 + +Josh Berkus wrote: + +>>Does the order of columns of varying size have any effect on +>>SELECT/INSERT/UPDATE/and/or/DELETE performance? Take the example where +>>an integer primary key is listed first in the table and alternatively +>>listed after some large varchar or text columns? +>> +>> +> +>No, the "order" of the columns in the table makes no difference. They are not +>physically stored in the metadata order, anyway; on the data pages, +>fixed-length fields (e.g. INT, BOOLEAN, etc.) are stored first and +>variable-length fields (CHAR, TEXT, NUMERIC) after them, AFAIK. +> +> + +Is this true even after a table is altered to "append" say, an integer +column, after there are already variable-length columns in the table? + +-Bill + +From pgsql-performance-owner@postgresql.org Tue Aug 10 20:12:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D593114B2800 + for ; + Tue, 10 Aug 2004 15:56:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30228-08 + for ; + Tue, 10 Aug 2004 18:56:35 +0000 (GMT) +Received: from snowwhite.lulu.com (mail.lulu.com [66.193.5.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CA2A14B2869 + for ; + Tue, 10 Aug 2004 15:56:32 -0300 (ADT) +Received: from [10.0.0.32] (meatwad.rdu.lulu.com [10.0.0.32]) + (authenticated bits=0) + by snowwhite.lulu.com (8.12.8/8.12.8) with ESMTP id i7AIuJQR007420 + (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); + Tue, 10 Aug 2004 14:56:19 -0400 +Message-ID: <41191A5C.7020409@lulu.com> +Date: Tue, 10 Aug 2004 14:56:28 -0400 +From: Bill Montgomery +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Paul Langard +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow select, insert, update +References: +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/130 +X-Sequence-Number: 7766 + +Paul, + +Paul Langard wrote: + +> Having trouble with one table (see time to count records below!). +> +> Fairly new to postgres so any help much appreciated. +> +> It only contains 9,106 records - as you can see from: +> +> +> select count(id) from project +> +> *count +> *9106 +> 1 row(s) +> Total runtime: 45,778.813 ms + + + +> ... the database is regularly vaccuumed. + + +Have you tried doing a VACUUM FULL, CLUSTER, or drop/restore on the +table? This sounds symptomatic of a table with a bunch of dead tuples +not in the FSM (free space map). Only tuples in the FSM are reclaimed by +a regular VACUUM. If your FSM parameters in postgresql.conf are not big +enough for your ratio of UPDATE/DELETE operations to VACUUM frequency, +you will end up with dead tuples that will only be reclaimed by a VACUUM +FULL. + +To prevent this problem in the future, look at increasing your FSM size +and possibly vacuuming more frequently or using pg_autovacuum. + +Good Luck, + +Bill Montgomery + +From pgsql-performance-owner@postgresql.org Tue Aug 10 19:53:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 99B5514B280B + for ; + Tue, 10 Aug 2004 16:17:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35908-10 + for ; + Tue, 10 Aug 2004 19:17:37 +0000 (GMT) +Received: from mail.gotfrag.com (g01.gotfrag.com [66.208.110.11]) + by svr1.postgresql.org (Postfix) with ESMTP id A7B2814B2806 + for ; + Tue, 10 Aug 2004 16:17:31 -0300 (ADT) +Received: from jcoene2 (roc-66-66-149-175.rochester.rr.com [66.66.149.175]) + by mail.gotfrag.com (8.12.10/8.12.8) with ESMTP id i7AJHR0E064106; + Tue, 10 Aug 2004 15:17:27 -0400 (EDT) + (envelope-from jcoene@gotfrag.com) +Message-Id: <200408101917.i7AJHR0E064106@mail.gotfrag.com> +From: "Jason Coene" +To: +Subject: Hardware upgrade for a high-traffic database +Date: Tue, 10 Aug 2004 15:17:32 -0400 +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.2096 +Thread-Index: AcR/DohI0d8i83OnRFGAWtmzaprLpg== +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/129 +X-Sequence-Number: 7765 + +Hi All, + +We're currently running Postgres 7.4.1 on FreeBSD 5.2, a Dual Xeon 2.4, 2GB +ECC, 3Ware Serial ATA RAID 5 w/ 4 disks (SLOW!!). + +Our database is about 20GB on disk, we have some quite large tables - 2M +rows with TEXT fields in a sample table, accessed constantly. We average +about 4,000 - 5,000 queries per second - all from web traffic. As you can +imagine, we're quite disk limited and checkpoints can be killer. +Additionally, we see queries and connections getting serialized due to +queries that take a long time (5 sec or so) while waiting on disk access. +No fun at all. + +We've tweaked everything long and hard, and at the end of the day, the disk +is killing us. + +We're looking to upgrade our server - or rather, replace it as it has no +upgrade path to SCSI. I'm considering going Opteron (though right now we +don't need more CPU time), and am looking for suggestions on what an optimal +RAID configuration may look like (disks, controller, cache setting). We're +in the market to buy right now - any good vendor suggestions? + +I'd appreciate any input, thanks! + +Jason + + +From pgsql-performance-owner@postgresql.org Tue Aug 10 19:01:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 85E1314B2804 + for ; + Tue, 10 Aug 2004 17:05:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52260-04 + for ; + Tue, 10 Aug 2004 20:05:03 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D2B614B27FF + for ; + Tue, 10 Aug 2004 17:04:58 -0300 (ADT) +Received: by bayswater1.ymogen.net (Postfix, from userid 99) + id 765C2A607F; Tue, 10 Aug 2004 21:04:56 +0100 (BST) +Received: from 82.68.132.233 (SquirrelMail authenticated user matt@ymogen.net) + by webmail.ymogen.com with HTTP; + Tue, 10 Aug 2004 21:04:56 +0100 (BST) +Message-ID: <4995.82.68.132.233.1092168296.squirrel@webmail.ymogen.com> +In-Reply-To: +References: <007f01c47d54$233b4bf0$8300a8c0@solent> + +Date: Tue, 10 Aug 2004 21:04:56 +0100 (BST) +Subject: Re: Performance Bottleneck +From: matt@ymogen.net +To: "Alex Hayward" +Cc: "'PostgreSQL Performance'" +User-Agent: SquirrelMail/1.4.2-0.1.7.x +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME, + PRIORITY_NO_NAME +X-Spam-Level: * +X-Archive-Number: 200408/128 +X-Sequence-Number: 7764 + + +> Squid also takes away the work of doing SSL (presuming you're running it +> on a different machine). Unfortunately it doesn't support HTTP/1.1 which +> means that most generated pages (those that don't set Content-length) end +> up forcing squid to close and then reopen the connection to the web +> server. + +It is true that it doesn't support http/1.1, but 'most generated pages'? +Unless they are actually emitted progressively they should have a +perfectly good content-length header. + +> I've also had some problems when Squid had a large number of connections +> open (several thousand); though that may have been because of my +> half_closed_clients setting. Squid 3 coped a lot better when I tried it +> (quite a few months ago now - and using FreeBSD and the special kqueue +> system call) but crashed under some (admittedly synthetic) conditions. + +It runs out of the box with a very conservative setting for max open file +descriptors - this may or may not be the cause of the problems you have +seen. Certainly I ran squid with >16,000 connections back in 1999... + +> You still have periods of time when the web servers are busy using their +> CPUs to generate HTML rather than waiting for database queries. This is +> especially true if you cache a lot of data somewhere on the web servers +> themselves (which, in my experience, reduces the database load a great +> deal). If you REALLY need to reduce the number of connections (because you +> have a large number of web servers doing a lot of computation, say) then +> it might still be useful. + +Aha, a postgres related topic in this thread! What you say is very true, +but then given that the connection overhead is so vanishingly small, why +not simply run without a persistent DB connection in this case? I would +maintain that if your webservers are holding open idle DB connections for +so long that it's a problem, then simply close the connections! + +M + +From pgsql-performance-owner@postgresql.org Tue Aug 10 18:13:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E172714B2806 + for ; + Tue, 10 Aug 2004 17:48:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66814-04 + for ; + Tue, 10 Aug 2004 20:48:12 +0000 (GMT) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id CADC414B281D + for ; + Tue, 10 Aug 2004 17:48:06 -0300 (ADT) +Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1BudXQ-0001Ja-00 + for ; Tue, 10 Aug 2004 22:48:04 +0200 +Received: from sp-260-1.net4.netcentrix.net ([4.21.254.118]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Tue, 10 Aug 2004 22:48:04 +0200 +Received: from doug by sp-260-1.net4.netcentrix.net with local (Gmexim 0.1 + (Debian)) id 1AlnuQ-0007hv-00 + for ; Tue, 10 Aug 2004 22:48:04 +0200 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +From: Doug McNaught +Subject: Re: Slow select, insert, update +Date: Tue, 10 Aug 2004 16:48:01 -0400 +Lines: 29 +Message-ID: <87r7qeg1oe.fsf@asmodeus.mcnaught.org> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@sea.gmane.org +X-Gmane-NNTP-Posting-Host: sp-260-1.net4.netcentrix.net +User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (gnu/linux) +Cancel-Lock: sha1:wCwlQc8Kq7L2XH8Q0rFIhdsDwdc= +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/127 +X-Sequence-Number: 7763 + +Paul Langard writes: + +> Having trouble with one table (see time to count records below!). +> +> Fairly new to postgres so any help much appreciated. +> +> It only contains 9,106 records - as you can see from: +> +> +> select count(id) from project +> +> count +> 9106 +> 1 row(s) +> Total runtime: 45,778.813 ms + +> ... the database is regularly vaccuumed. + +Hmm. You might try a VACUUM FULL and a REINDEX on the table (you +don't say what version you are running--REINDEX is sometimes needed on +7.3 and below). + +Also, use EXPLAIN ANALYZE on your query and post the result--that's +helpful diagnostic information. + +-Doug +-- +Let us cross over the river, and rest under the shade of the trees. + --T. J. Jackson, 1863 + + +From pgsql-performance-owner@postgresql.org Tue Aug 10 23:23:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id ABD4A14B281D + for ; + Tue, 10 Aug 2004 18:44:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90224-04 + for ; + Tue, 10 Aug 2004 21:44:01 +0000 (GMT) +Received: from web13123.mail.yahoo.com (web13123.mail.yahoo.com + [216.136.174.141]) + by svr1.postgresql.org (Postfix) with SMTP id 91F9914B27FF + for ; + Tue, 10 Aug 2004 18:43:58 -0300 (ADT) +Message-ID: <20040810214400.55597.qmail@web13123.mail.yahoo.com> +Received: from [63.78.248.48] by web13123.mail.yahoo.com via HTTP; + Tue, 10 Aug 2004 14:44:00 PDT +Date: Tue, 10 Aug 2004 14:44:00 -0700 (PDT) +From: Litao Wu +Subject: Re: Slow select, insert, update +To: Doug McNaught , + pgsql-performance@postgresql.org +In-Reply-To: <87r7qeg1oe.fsf@asmodeus.mcnaught.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/140 +X-Sequence-Number: 7776 + +Does that mean reindex is not needed +for PG version 7.4? + +In what kind situations under PG 7.4, +reindex is worthwhile? + +Thanks, + + +Here is doc from 7.3: +PostgreSQL is unable to reuse B-tree index pages in +certain cases. The problem is that if indexed rows are +deleted, those index pages can only be reused by rows +with similar values. For example, if indexed rows are +deleted and newly inserted/updated rows have much +higher values, the new rows can't use the index space +made available by the deleted rows. Instead, such new +rows must be placed on new index pages. In such cases, +disk space used by the index will grow indefinitely, +even if VACUUM is run frequently. + +As a solution, you can use the REINDEX command +periodically to discard pages used by deleted rows. +There is also contrib/reindexdb which can reindex an +entire database. + +The counterpart of 7.4 is: +In some situations it is worthwhile to rebuild indexes +periodically with the REINDEX command. (There is also +contrib/reindexdb which can reindex an entire +database.) However, PostgreSQL 7.4 has substantially +reduced the need for this activity compared to earlier +releases. + + +--- Doug McNaught wrote: + +> Paul Langard writes: +> +> > Having trouble with one table (see time to count +> records below!). +> > +> > Fairly new to postgres so any help much +> appreciated. +> > +> > It only contains 9,106 records - as you can see +> from: +> > +> > +> > select count(id) from project +> > +> > count +> > 9106 +> > 1 row(s) +> > Total runtime: 45,778.813 ms +> +> > ... the database is regularly vaccuumed. +> +> Hmm. You might try a VACUUM FULL and a REINDEX on +> the table (you +> don't say what version you are running--REINDEX is +> sometimes needed on +> 7.3 and below). +> +> Also, use EXPLAIN ANALYZE on your query and post the +> result--that's +> helpful diagnostic information. +> +> -Doug +> -- +> Let us cross over the river, and rest under the +> shade of the trees. +> --T. J. Jackson, 1863 +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 8: explain analyze is your friend +> + + + + +__________________________________ +Do you Yahoo!? +Read only the mail you want - Yahoo! Mail SpamGuard. +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Tue Aug 10 22:46:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 92E9A14B281E + for ; + Tue, 10 Aug 2004 20:06:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11447-09 + for ; + Tue, 10 Aug 2004 23:06:18 +0000 (GMT) +Received: from diablo.OntheNet.com.au (diablo.OntheNet.com.au [203.10.89.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D6B714B281D + for ; + Tue, 10 Aug 2004 20:06:16 -0300 (ADT) +Received: from [192.168.0.114] (imp3.dsl.onthenet.net [203.144.21.139]) + by diablo.OntheNet.com.au (8.12.10/8.12.10) with ESMTP id + i7AN6H4G066145 for ; + Wed, 11 Aug 2004 09:06:18 +1000 (EST) +Message-ID: <41195462.9090303@wildcash.com> +Date: Wed, 11 Aug 2004 09:04:02 +1000 +From: Rudi Starcevic +Reply-To: tech@wildcash.com +Organization: Internet Media Productions +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7) Gecko/20040616 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Bulk Insert and Index use +X-Enigmail-Version: 0.85.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/139 +X-Sequence-Number: 7775 + +Hi, + +I have a question on bulk checking, inserting into a table and +how best to use an index for performance. + +The data I have to work with is a monthly CD Rom csv data dump of +300,000 property owners from one area/shire. + +So every CD has 300,000 odd lines, each line of data which fills the +'property' table. + +Beginning with the first CD each line should require one SELECT and +one INSERT as it will be the first property with this address. + +The SELECT uses fields like 'street' and 'suburb', to check for an +existing property, +so I have built an index on those fields. + +My question is does each INSERT rebuild the index on the 'street' and +'suburb' fields? +I believe it does but I'm asking to be sure. + +If this is the case I guess performance will suffer when I have, say, +200,000 +rows in the table. + +Would it be like: + +a) Use index to search on 'street' and 'suburb' +b) No result? Insert new record +c) Rebuild index on 'street' and 'suburb' + +for each row? +Would this mean that after 200,000 rows each INSERT will require +the index of 000's of rows to be re-indexed? + +So far I believe my only options are to use either and index +or sequential scan and see which is faster. + +A minute for your thoughts and/or suggestions would be great. + +Thanks. +Regards, +Rudi. + + +From pgsql-performance-owner@postgresql.org Tue Aug 10 22:43:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B962314B2806 + for ; + Tue, 10 Aug 2004 20:06:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13472-03 + for ; + Tue, 10 Aug 2004 23:06:52 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 148C214B27FF + for ; + Tue, 10 Aug 2004 20:06:51 -0300 (ADT) +Received: from [134.22.70.202] (dyn-70-202.tor.dsl.tht.net [134.22.70.202]) + by tht.net (Postfix) with ESMTP + id 81DE076A54; Tue, 10 Aug 2004 19:06:58 -0400 (EDT) +Subject: Re: Hardware upgrade for a high-traffic database +From: Rod Taylor +To: Jason Coene +Cc: Postgresql Performance +In-Reply-To: <200408101917.i7AJHR0E064106@mail.gotfrag.com> +References: <200408101917.i7AJHR0E064106@mail.gotfrag.com> +Content-Type: text/plain +Message-Id: <1092179211.11635.30.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 10 Aug 2004 19:06:52 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/138 +X-Sequence-Number: 7774 + +> Our database is about 20GB on disk, we have some quite large tables - 2M +> rows with TEXT fields in a sample table, accessed constantly. We average +> about 4,000 - 5,000 queries per second - all from web traffic. As you can + +99% is reads? and probably the same data over and over again? You might +want to think about a small code change to cache sections of page output +in memory for the most commonly generated pages (there are usually 3 or +4 that account for 25% to 50% of web traffic -- starting pages). + +The fact you're getting 5k queries/second off IDE drives tells me most +of the active data is in memory -- so your actual working data set is +probably quite small (less than 10% of the 20GB). + + +If the above is all true (mostly reads, smallish dataset, etc.) and the +database is not growing very quickly, you might want to look into RAM +and RAM bandwidth over disk. An Opteron with 8GB ram using the same old +IDE drives. Get a mobo with a SCSI raid controller in it, so the disk +component can be upgraded in the future (when necessary). + + + +From pgsql-performance-owner@postgresql.org Tue Aug 10 22:30:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F37BE14B2800 + for ; + Tue, 10 Aug 2004 20:58:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29023-01 + for ; + Tue, 10 Aug 2004 23:58:35 +0000 (GMT) +Received: from mpls-qmqp-04.inet.qwest.net (mpls-qmqp-04.inet.qwest.net + [63.231.195.115]) + by svr1.postgresql.org (Postfix) with SMTP id 3E21E14B27FF + for ; + Tue, 10 Aug 2004 20:58:32 -0300 (ADT) +Received: (qmail 64577 invoked by uid 0); 10 Aug 2004 23:58:35 -0000 +Received: from mpls-pop-08.inet.qwest.net (63.231.195.8) + by mpls-qmqp-04.inet.qwest.net with QMQP; 10 Aug 2004 23:58:35 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-08.inet.qwest.net with SMTP; 10 Aug 2004 23:58:35 -0000 +Date: Tue, 10 Aug 2004 18:00:01 -0600 +Message-Id: <1092182401.27166.348.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Jason Coene" +Cc: pgsql-performance@postgresql.org +Subject: Re: Hardware upgrade for a high-traffic database +In-Reply-To: <200408101917.i7AJHR0E064106@mail.gotfrag.com> +References: <200408101917.i7AJHR0E064106@mail.gotfrag.com> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/137 +X-Sequence-Number: 7773 + +On Tue, 2004-08-10 at 13:17, Jason Coene wrote: +> Hi All, +> +> We're currently running Postgres 7.4.1 on FreeBSD 5.2, a Dual Xeon 2.4, 2GB +> ECC, 3Ware Serial ATA RAID 5 w/ 4 disks (SLOW!!). +> +> Our database is about 20GB on disk, we have some quite large tables - 2M +> rows with TEXT fields in a sample table, accessed constantly. We average +> about 4,000 - 5,000 queries per second - all from web traffic. As you can +> imagine, we're quite disk limited and checkpoints can be killer. +> Additionally, we see queries and connections getting serialized due to +> queries that take a long time (5 sec or so) while waiting on disk access. +> No fun at all. +> +> We've tweaked everything long and hard, and at the end of the day, the disk +> is killing us. +> +> We're looking to upgrade our server - or rather, replace it as it has no +> upgrade path to SCSI. I'm considering going Opteron (though right now we +> don't need more CPU time), and am looking for suggestions on what an optimal +> RAID configuration may look like (disks, controller, cache setting). We're +> in the market to buy right now - any good vendor suggestions? + +I've had very good luck with LSI MegaRAID controllers with battery +backed cache. The amount of cache doesn't seem as important as having +it, and having it set for write back. + +After that, 2 gigs or more of memory is the next improvement. + +After that, the speed of the memory. + + + +From pgsql-performance-owner@postgresql.org Tue Aug 10 22:10:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 49D4D14B2881 + for ; + Tue, 10 Aug 2004 22:06:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48137-02 + for ; + Wed, 11 Aug 2004 01:06:53 +0000 (GMT) +Received: from mail.gotfrag.com (unknown [66.208.110.11]) + by svr1.postgresql.org (Postfix) with ESMTP id A4BDC14B2878 + for ; + Tue, 10 Aug 2004 22:06:44 -0300 (ADT) +Received: from jcoene2 (roc-66-66-149-175.rochester.rr.com [66.66.149.175]) + by mail.gotfrag.com (8.12.10/8.12.8) with ESMTP id i7B16b0E072661; + Tue, 10 Aug 2004 21:06:37 -0400 (EDT) + (envelope-from jcoene@gotfrag.com) +Message-Id: <200408110106.i7B16b0E072661@mail.gotfrag.com> +From: "Jason Coene" +To: "'Rod Taylor'" +Cc: "'Postgresql Performance'" +Subject: Re: Hardware upgrade for a high-traffic database +Date: Tue, 10 Aug 2004 21:06:37 -0400 +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.2096 +In-Reply-To: <1092179211.11635.30.camel@jester> +Thread-Index: AcR/Lr47tKJaxYJUST64s429yuXv/gADnnNw +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/136 +X-Sequence-Number: 7772 + +Hi Rod, + +Actually, we're already using a substantial caching system in code for +nearly all pages delivered - we've exhausted that option. Our system uses a +login/session table for about 1/8 of our page views (those visitors who are +logged in), and has tracking features. While I'd love to scrap them and +give the database server a vacation, it's a requirement for us. + +You're correct about the query caching (stored in memory) being used - most +of our queries are run once and then come from memory (or, based on speed of +consecutive executions, that seems to be the case). Once a user hits a page +for the first time in an hour or so, it seems to cache their session query. + +The issue that I think we're seeing is that the performance on the 3Ware +RAID is quite bad, watching FreeBSD systat will show it at "100% busy" at +around "3.5 MB/s". When it needs to seek across a table (for, say, an +aggregate function - typically a COUNT()), it slows the entire server down +while working on the disk. Additionally, VACUUM's make the server +practically useless. We have indexes on everything that's used in queries, +and the planner is using them. + +The server has 2GB of physical memory, however it's only uses between 130MB +and 200MB of it. Postgres is the only application running on the server. + +Our pertinent settings look like this: + +max_connections = 512 + +shared_buffers = 20000 +sort_mem = 2000 +vacuum_mem = 20000 +effective_cache_size = 300000 + +fsync = false +wal_sync_method = fsync +wal_buffers = 32 + +checkpoint_segments = 2 +checkpoint_timeout = 30 +commit_delay = 10000 + +Typically, we don't use anywhere near the 512 connections - however there +are peak hours where we come close, and other times that we eclipse it and +run out (should some connections become serialized due to a slowdown). It's +not something that we can comfortably lower. + +The non-standard checkpoint settings have helped making it less likely that +a large (in disk time) query will conflict with a checkpoint write. + +I'm a programmer - definitely not a DBA by any stretch - though I am forced +into the role. From reading this list, it seems to me that our settings are +reasonable given our usage, and that a disk upgrade is likely in order. + +I'd love to hear any suggestions. + +Thanks, + +Jason + +-----Original Message----- +From: Rod Taylor [mailto:pg@rbt.ca] +Sent: Tuesday, August 10, 2004 7:07 PM +To: Jason Coene +Cc: Postgresql Performance +Subject: Re: [PERFORM] Hardware upgrade for a high-traffic database + +> Our database is about 20GB on disk, we have some quite large tables - 2M +> rows with TEXT fields in a sample table, accessed constantly. We average +> about 4,000 - 5,000 queries per second - all from web traffic. As you can + +99% is reads? and probably the same data over and over again? You might +want to think about a small code change to cache sections of page output +in memory for the most commonly generated pages (there are usually 3 or +4 that account for 25% to 50% of web traffic -- starting pages). + +The fact you're getting 5k queries/second off IDE drives tells me most +of the active data is in memory -- so your actual working data set is +probably quite small (less than 10% of the 20GB). + + +If the above is all true (mostly reads, smallish dataset, etc.) and the +database is not growing very quickly, you might want to look into RAM +and RAM bandwidth over disk. An Opteron with 8GB ram using the same old +IDE drives. Get a mobo with a SCSI raid controller in it, so the disk +component can be upgraded in the future (when necessary). + + + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 00:53:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3DE3F14B2824 + for ; + Wed, 11 Aug 2004 00:11:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77310-03 + for ; + Wed, 11 Aug 2004 03:11:05 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 384AA14B2825 + for ; + Wed, 11 Aug 2004 00:11:03 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7B3B3iG078513 + for ; Wed, 11 Aug 2004 03:11:03 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7B2nv6S066003 + for pgsql-performance@postgresql.org; Wed, 11 Aug 2004 02:49:57 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Bulk Insert and Index use +Date: Tue, 10 Aug 2004 22:24:31 -0400 +Organization: cbbrowne Computing Inc +Lines: 22 +Message-ID: +References: <41195462.9090303@wildcash.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.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through + Obscurity, + linux) +Cancel-Lock: sha1:u/B7c0mLYN+Z0weWz32cEutc6Hs= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/144 +X-Sequence-Number: 7780 + +In an attempt to throw the authorities off his trail, tech@wildcash.com (Rudi Starcevic) transmitted: +> A minute for your thoughts and/or suggestions would be great. + +Could you give a more concrete example? E.g. - the DDL for the +table(s), most particularly. + +At first guess, I think you're worrying about a nonissue. Each insert +will lead to a _modification_ of the various indices, which costs +_something_, but which is WAY less expensive than creating each index +from scratch. + +But perhaps I'm misreading things; DDL for the intended tables and +indices would be real handy. +-- +output = ("cbbrowne" "@" "cbbrowne.com") +http://www.ntlug.org/~cbbrowne/linux.html +Rules of the Evil Overlord #21. "I will hire a talented fashion +designer to create original uniforms for my Legions of Terror, as +opposed to some cheap knock-offs that make them look like Nazi +stormtroopers, Roman footsoldiers, or savage Mongol hordes. All were +eventually defeated and I want my troops to have a more positive +mind-set." + +From pgsql-performance-owner@postgresql.org Tue Aug 10 23:55:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6ED1714B2879 + for ; + Tue, 10 Aug 2004 23:27:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39878-02 + for ; + Wed, 11 Aug 2004 02:27:50 +0000 (GMT) +Received: from loki.globexplorer.com (unknown [208.35.14.101]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F76314B2825 + for ; + Tue, 10 Aug 2004 23:27:43 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="Windows-1252" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Bulk Insert and Index use +Date: Tue, 10 Aug 2004 19:27:48 -0700 +Message-ID: + <71E37EF6B7DCC1499CEA0316A256832801057DE3@loki.wc.globexplorer.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Bulk Insert and Index use +Thread-Index: AcR/RapGzA5gUW+EScWUjqvJE4OhUgABJVEz +From: "Gregory S. Williamson" +To: , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/142 +X-Sequence-Number: 7778 + + +Usualy any bulk load is faster with indexes dropped and the rebuilt ... fai= +ling that (like you really need the indexes while loading, say into a "hot"= + table) be sure to wrap all the SQL into one transaction (BEGIN;...COMMIT;)= + ... if any data failes it all fails, which is usually easier to deal with = +than partial data loads, and it is *much* faster than having each insert be= +ing its own transaction. + +HTH, + +Greg Williamson +DBA +GlobeXplorer LLC + +-----Original Message----- +From: Rudi Starcevic [mailto:tech@wildcash.com] +Sent: Tue 8/10/2004 4:04 PM +To: pgsql-performance@postgresql.org +Cc:=09 +Subject: [PERFORM] Bulk Insert and Index use +Hi, + +I have a question on bulk checking, inserting into a table and +how best to use an index for performance. + +The data I have to work with is a monthly CD Rom csv data dump of +300,000 property owners from one area/shire. + +So every CD has 300,000 odd lines, each line of data which fills the=20 +'property' table. + +Beginning with the first CD each line should require one SELECT and +one INSERT as it will be the first property with this address. + +The SELECT uses fields like 'street' and 'suburb', to check for an=20 +existing property, +so I have built an index on those fields. + +My question is does each INSERT rebuild the index on the 'street' and=20 +'suburb' fields? +I believe it does but I'm asking to be sure. + +If this is the case I guess performance will suffer when I have, say,=20 +200,000 +rows in the table. + +Would it be like: + +a) Use index to search on 'street' and 'suburb' +b) No result? Insert new record +c) Rebuild index on 'street' and 'suburb' + +for each row? +Would this mean that after 200,000 rows each INSERT will require +the index of 000's of rows to be re-indexed? + +So far I believe my only options are to use either and index +or sequential scan and see which is faster. + +A minute for your thoughts and/or suggestions would be great. + +Thanks. +Regards, +Rudi. + + +---------------------------(end of broadcast)--------------------------- +TIP 4: Don't 'kill -9' the postmaster + + + + +From pgsql-performance-owner@postgresql.org Tue Aug 10 23:54:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4470C14B281F + for ; + Tue, 10 Aug 2004 23:31:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53761-02 + for ; + Wed, 11 Aug 2004 02:31:30 +0000 (GMT) +Received: from smtp.gvtc.com (smtp.gvtc.com [216.177.160.80]) + by svr1.postgresql.org (Postfix) with ESMTP id 6FF4D14B281E + for ; + Tue, 10 Aug 2004 23:31:13 -0300 (ADT) +Received: from [192.168.1.102] (unknown [12.181.66.221]) + by smtp.gvtc.com (Postfix) with ESMTP id 6DAC91939C3 + for ; + Tue, 10 Aug 2004 21:31:17 -0500 (CDT) +Message-ID: <41198514.1020103@gvtc.com> +Date: Tue, 10 Aug 2004 21:31:48 -0500 +From: Jim J +User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Bulk Insert and Index use +References: <41195462.9090303@wildcash.com> +In-Reply-To: <41195462.9090303@wildcash.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/141 +X-Sequence-Number: 7777 + +If the bulk load has the possibility of duplicating data, then you need +to change methods. Try bulk loading into a temp table, index it like +the original, eliminate the dups and merge the tables. + +It is also possible to do an insert from the temp table into the final +table like: +insert into original (x,x,x) (select temp.1, temp.2, etc from temp left +join original on temp.street=original.street where original.street is null) + +Good Luck +Jim + +Rudi Starcevic wrote: + +> Hi, +> +> I have a question on bulk checking, inserting into a table and +> how best to use an index for performance. +> +> The data I have to work with is a monthly CD Rom csv data dump of +> 300,000 property owners from one area/shire. +> +> So every CD has 300,000 odd lines, each line of data which fills the +> 'property' table. +> +> Beginning with the first CD each line should require one SELECT and +> one INSERT as it will be the first property with this address. +> +> The SELECT uses fields like 'street' and 'suburb', to check for an +> existing property, +> so I have built an index on those fields. +> +> My question is does each INSERT rebuild the index on the 'street' and +> 'suburb' fields? +> I believe it does but I'm asking to be sure. +> +> If this is the case I guess performance will suffer when I have, say, +> 200,000 +> rows in the table. +> +> Would it be like: +> +> a) Use index to search on 'street' and 'suburb' +> b) No result? Insert new record +> c) Rebuild index on 'street' and 'suburb' +> +> for each row? +> Would this mean that after 200,000 rows each INSERT will require +> the index of 000's of rows to be re-indexed? +> +> So far I believe my only options are to use either and index +> or sequential scan and see which is faster. +> +> A minute for your thoughts and/or suggestions would be great. +> +> Thanks. +> Regards, +> Rudi. +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +> +> + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 00:41:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 658F614B2869 + for ; + Wed, 11 Aug 2004 00:36:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95343-09 + for ; + Wed, 11 Aug 2004 03:36:03 +0000 (GMT) +Received: from diablo.OntheNet.com.au (diablo.OntheNet.com.au [203.10.89.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F59814B2827 + for ; + Wed, 11 Aug 2004 00:35:59 -0300 (ADT) +Received: from [192.168.0.114] (imp3.dsl.onthenet.net [203.144.21.139]) + by diablo.OntheNet.com.au (8.12.10/8.12.10) with ESMTP id + i7B3Zn4G012260 for ; + Wed, 11 Aug 2004 13:35:50 +1000 (EST) +Message-ID: <4119938D.6000609@wildcash.com> +Date: Wed, 11 Aug 2004 13:33:33 +1000 +From: Rudi Starcevic +Reply-To: tech@wildcash.com +Organization: Internet Media Productions +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7) Gecko/20040616 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Bulk Insert and Index use +References: <41195462.9090303@wildcash.com> <41198514.1020103@gvtc.com> +In-Reply-To: <41198514.1020103@gvtc.com> +X-Enigmail-Version: 0.85.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/143 +X-Sequence-Number: 7779 + +Hi Jim, + +Thanks for your time. + + > If the bulk load has the possibility of duplicating data + +Yes, each row will require either: + +a) One SELECT + One INSERT +or +b) One SELECT + One UPDATE + +I did think of using more than one table, ie. temp table. +As each month worth of data is added I expect to see +a change from lots of INSERTS to lots of UPDATES. + +Perhaps when the UPDATES become more dominant it would +be best to start using Indexes. + +While INSERTS are more prevelant perhaps a seq. scan is better. + +I guess of all the options available it boils down to which +is quicker for my data: index or sequential scan. + +Many thanks. + +Jim J wrote: + +> If the bulk load has the possibility of duplicating data, then you need +> to change methods. Try bulk loading into a temp table, index it like +> the original, eliminate the dups and merge the tables. +> +> It is also possible to do an insert from the temp table into the final +> table like: +> insert into original (x,x,x) (select temp.1, temp.2, etc from temp left +> join original on temp.street=original.street where original.street is null) +> +> Good Luck +> Jim +> +> Rudi Starcevic wrote: +> +>> Hi, +>> +>> I have a question on bulk checking, inserting into a table and +>> how best to use an index for performance. +>> +>> The data I have to work with is a monthly CD Rom csv data dump of +>> 300,000 property owners from one area/shire. +>> +>> So every CD has 300,000 odd lines, each line of data which fills the +>> 'property' table. +>> +>> Beginning with the first CD each line should require one SELECT and +>> one INSERT as it will be the first property with this address. +>> +>> The SELECT uses fields like 'street' and 'suburb', to check for an +>> existing property, +>> so I have built an index on those fields. +>> +>> My question is does each INSERT rebuild the index on the 'street' and +>> 'suburb' fields? +>> I believe it does but I'm asking to be sure. +>> +>> If this is the case I guess performance will suffer when I have, say, +>> 200,000 +>> rows in the table. +>> +>> Would it be like: +>> +>> a) Use index to search on 'street' and 'suburb' +>> b) No result? Insert new record +>> c) Rebuild index on 'street' and 'suburb' +>> +>> for each row? +>> Would this mean that after 200,000 rows each INSERT will require +>> the index of 000's of rows to be re-indexed? +>> +>> So far I believe my only options are to use either and index +>> or sequential scan and see which is faster. +>> +>> A minute for your thoughts and/or suggestions would be great. +>> +>> Thanks. +>> Regards, +>> Rudi. +>> +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 4: Don't 'kill -9' the postmaster +>> +>> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> +> + + +-- + + +Regards, +Rudi. + +Internet Media Productions + +From pgsql-performance-owner@postgresql.org Wed Aug 11 01:15:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A28614B27FF + for ; + Wed, 11 Aug 2004 00:53:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98548-06 + for ; + Wed, 11 Aug 2004 03:53:14 +0000 (GMT) +Received: from loki.globexplorer.com (unknown [208.35.14.101]) + by svr1.postgresql.org (Postfix) with ESMTP id E742E14B281D + for ; + Wed, 11 Aug 2004 00:53:11 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="Windows-1252" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Bulk Insert and Index use +Date: Tue, 10 Aug 2004 20:53:11 -0700 +Message-ID: + <71E37EF6B7DCC1499CEA0316A256832801057DE5@loki.wc.globexplorer.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Bulk Insert and Index use +Thread-Index: AcR/VbSjdfgqG3vyTu6v1DCcYxTeTwAANAQC +From: "Gregory S. Williamson" +To: , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/145 +X-Sequence-Number: 7781 + +If it has to read a majority (or even a good percentage) of the rows in que= +stion a sequential scan is probably faster ... and as Jim pointed out, a te= +mp table can often be a useful medium for getting speed in a load and then = +allowing you to clean/alter data for a final (easy) push. + +G +-----Original Message----- +From: Rudi Starcevic [mailto:tech@wildcash.com] +Sent: Tue 8/10/2004 8:33 PM +To: pgsql-performance@postgresql.org +Cc:=09 +Subject: Re: [PERFORM] Bulk Insert and Index use +Hi Jim, + +Thanks for your time. + + > If the bulk load has the possibility of duplicating data + +Yes, each row will require either: + +a) One SELECT + One INSERT +or +b) One SELECT + One UPDATE + +I did think of using more than one table, ie. temp table. +As each month worth of data is added I expect to see +a change from lots of INSERTS to lots of UPDATES. + +Perhaps when the UPDATES become more dominant it would +be best to start using Indexes. + +While INSERTS are more prevelant perhaps a seq. scan is better. + +I guess of all the options available it boils down to which +is quicker for my data: index or sequential scan. + +Many thanks. + +Jim J wrote: + +> If the bulk load has the possibility of duplicating data, then you need= +=20 +> to change methods. Try bulk loading into a temp table, index it like=20 +> the original, eliminate the dups and merge the tables. +>=20 +> It is also possible to do an insert from the temp table into the final=20 +> table like: +> insert into original (x,x,x) (select temp.1, temp.2, etc from temp left= +=20 +> join original on temp.street=3Doriginal.street where original.street is n= +ull) +>=20 +> Good Luck +> Jim +>=20 +> Rudi Starcevic wrote: +>=20 +>> Hi, +>> +>> I have a question on bulk checking, inserting into a table and +>> how best to use an index for performance. +>> +>> The data I have to work with is a monthly CD Rom csv data dump of +>> 300,000 property owners from one area/shire. +>> +>> So every CD has 300,000 odd lines, each line of data which fills the=20 +>> 'property' table. +>> +>> Beginning with the first CD each line should require one SELECT and +>> one INSERT as it will be the first property with this address. +>> +>> The SELECT uses fields like 'street' and 'suburb', to check for an=20 +>> existing property, +>> so I have built an index on those fields. +>> +>> My question is does each INSERT rebuild the index on the 'street' and=20 +>> 'suburb' fields? +>> I believe it does but I'm asking to be sure. +>> +>> If this is the case I guess performance will suffer when I have, say,=20 +>> 200,000 +>> rows in the table. +>> +>> Would it be like: +>> +>> a) Use index to search on 'street' and 'suburb' +>> b) No result? Insert new record +>> c) Rebuild index on 'street' and 'suburb' +>> +>> for each row? +>> Would this mean that after 200,000 rows each INSERT will require +>> the index of 000's of rows to be re-indexed? +>> +>> So far I believe my only options are to use either and index +>> or sequential scan and see which is faster. +>> +>> A minute for your thoughts and/or suggestions would be great. +>> +>> Thanks. +>> Regards, +>> Rudi. +>> +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 4: Don't 'kill -9' the postmaster +>> +>> +>=20 +>=20 +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +>=20 +> http://www.postgresql.org/docs/faqs/FAQ.html +>=20 +>=20 + + +--=20 + + +Regards, +Rudi. + +Internet Media Productions + +---------------------------(end of broadcast)--------------------------- +TIP 6: Have you searched our list archives? + + http://archives.postgresql.org + + + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 01:25:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4762014B281C + for ; + Wed, 11 Aug 2004 01:13:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67717-08 + for ; + Wed, 11 Aug 2004 04:13:12 +0000 (GMT) +Received: from diablo.OntheNet.com.au (diablo.OntheNet.com.au [203.10.89.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ECB9B14B2824 + for ; + Wed, 11 Aug 2004 01:13:10 -0300 (ADT) +Received: from [192.168.0.114] (imp3.dsl.onthenet.net [203.144.21.139]) + by diablo.OntheNet.com.au (8.12.10/8.12.10) with ESMTP id + i7B4D84G018093 for ; + Wed, 11 Aug 2004 14:13:09 +1000 (EST) +Message-ID: <41199C4C.9040308@wildcash.com> +Date: Wed, 11 Aug 2004 14:10:52 +1000 +From: Rudi Starcevic +Reply-To: tech@wildcash.com +Organization: Internet Media Productions +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7) Gecko/20040616 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Bulk Insert and Index use +References: <41195462.9090303@wildcash.com> + +In-Reply-To: +X-Enigmail-Version: 0.85.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/146 +X-Sequence-Number: 7782 + +Hi, + +> In an attempt to throw the authorities off his trail, tech@wildcash.com (Rudi Starcevic) transmitted: +> A minute for your thoughts and/or suggestions would be great. + +Heh heh .... + +> Could you give a more concrete example? E.g. - the DDL for the +> table(s), most particularly. + +Thanks, I didn't add the DDL as I though it may make my question too +long. I have the DDL at another office so I'll pick up this email +thread when I get there in a couple hours. + +> At first guess, I think you're worrying about a nonissue. Each insert +> will lead to a _modification_ of the various indices, which costs +> _something_, but which is WAY less expensive than creating each index +> from scratch. + +Very interesting, modification and creation. +I will post another email later today. + +Many thanks. + +-- + +Regards, +Rudi. + +Internet Media Productions + +From pgsql-performance-owner@postgresql.org Wed Aug 11 02:41:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6582514B2825 + for ; + Wed, 11 Aug 2004 02:41:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 41042-04 + for ; + Wed, 11 Aug 2004 05:41: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 2775E14B281E + for ; + Wed, 11 Aug 2004 02:41:25 -0300 (ADT) +Received: from paramonga.terra.com.br (paramonga.terra.com.br + [200.154.55.133]) + by linares.terra.com.br (Postfix) with ESMTP id 84EEADDC2BD + for ; + Wed, 11 Aug 2004 02:41:25 -0300 (BRT) +Received: from [200.176.35.99] (cm-net-poa-C8B02363.brdterra.com.br + [200.176.35.99]) (authenticated user erabbott) + by paramonga.terra.com.br (Postfix) with ESMTP id 52FCE3C016 + for ; + Wed, 11 Aug 2004 02:41:25 -0300 (BRT) +Message-ID: <4119B1C9.2010800@galvao.eti.br> +Date: Wed, 11 Aug 2004 02:42:33 -0300 +From: =?ISO-8859-1?Q?Er_Galv=E3o_Abbott?= +Reply-To: galvao@galvao.eti.br +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: NUMERIC x VARCHAR +X-Priority: 1 (Highest) +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=3.8 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_MESSAGE, HTML_TITLE_EMPTY, MIME_HTML_ONLY, PRIORITY_NO_NAME, + RCVD_IN_NJABL, RCVD_IN_NJABL_PROXY, RCVD_IN_SORBS, X_PRIORITY_HIGH +X-Spam-Level: *** +X-Archive-Number: 200408/147 +X-Sequence-Number: 7783 + + + + + + + + +Greetings.
+
+I have a question regarding performance of certain datatypes:
+
+I have a field where I will store my clients phone numbers. I know that +this field will never exceed 15 characters, and I will store only +numbers here (no dashes, dots, etc...), so I was wondering:
+
+Wich type is faster: NUMERIC(15,0) or VARCHAR(15)? Are there any +storage differences between them?
+
+TIA,
+
+
-- 
+Er Galvão Abbott
+Desenvolvedor Web
+http://www.galvao.eti.br/
+galvao@galvao.eti.br
+ + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 03:20:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2ECAE14B286F + for ; + Wed, 11 Aug 2004 03:20:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52533-08 + for ; + Wed, 11 Aug 2004 06:20:30 +0000 (GMT) +Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net + [63.231.195.112]) + by svr1.postgresql.org (Postfix) with SMTP id AC26D14B286A + for ; + Wed, 11 Aug 2004 03:20:26 -0300 (ADT) +Received: (qmail 2404 invoked by uid 0); 11 Aug 2004 06:20:27 -0000 +Received: from unknown (63.231.195.5) + by mpls-qmqp-01.inet.qwest.net with QMQP; 11 Aug 2004 06:20:27 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-05.inet.qwest.net with SMTP; 11 Aug 2004 06:20:26 -0000 +Date: Wed, 11 Aug 2004 00:21:48 -0600 +Message-Id: <1092205308.27166.358.camel@localhost.localdomain> +From: "Scott Marlowe" +To: galvao@galvao.eti.br +Cc: pgsql-performance@postgresql.org +Subject: Re: NUMERIC x VARCHAR +In-Reply-To: <4119B1C9.2010800@galvao.eti.br> +References: <4119B1C9.2010800@galvao.eti.br> +Content-Type: text/plain; charset=utf-8 +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/148 +X-Sequence-Number: 7784 + +On Tue, 2004-08-10 at 23:42, Er Galvão Abbott wrote: +> Greetings. +> +> I have a question regarding performance of certain datatypes: +> +> I have a field where I will store my clients phone numbers. I know +> that this field will never exceed 15 characters, and I will store only +> numbers here (no dashes, dots, etc...), so I was wondering: +> +> Wich type is faster: NUMERIC(15,0) or VARCHAR(15)? Are there any +> storage differences between them? + +Since numerics are stored as text strings, the storage would be +similar. Numerics, however, may be slower since they have more +constraints built in. If you throw a check constraint on the +varchar(15) then it will likely be about the same speed for updating. + +text type with a check contraint it what i'd use. That way if you want +to change it at a later date you just drop and recreate your constraint. + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 03:43:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5707514B281C + for ; + Wed, 11 Aug 2004 03:43:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60496-06 + for ; + Wed, 11 Aug 2004 06:43:36 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id E182714B2806 + for ; + Wed, 11 Aug 2004 03:43:34 -0300 (ADT) +Received: (qmail 22277 invoked from network); 11 Aug 2004 08:43:39 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 11 Aug 2004 08:43:39 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Hardware upgrade for a high-traffic database +References: <200408101917.i7AJHR0E064106@mail.gotfrag.com> +Message-ID: +Date: Wed, 11 Aug 2004 08:43:36 +0200 +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <200408101917.i7AJHR0E064106@mail.gotfrag.com> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/149 +X-Sequence-Number: 7785 + + +> We're currently running Postgres 7.4.1 on FreeBSD 5.2, a Dual Xeon 2.4, +> 2GB +> ECC, 3Ware Serial ATA RAID 5 w/ 4 disks (SLOW!!). + + Cheap solution while you look for another server : + + Try to use something other than RAID5. + You have 4 disks, so you could use a striping+mirroring RAID which would +boost performance. + You can switch with a minimum downtime (copy files to other HDD, change +RAID parameters, copy again...) maybe 1 hour ? + If your hardware supports it of course. + And tell us how it works ! + +From pgsql-performance-owner@postgresql.org Wed Aug 11 03:47:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3406914B281C + for ; + Wed, 11 Aug 2004 03:47:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62381-07 + for ; + Wed, 11 Aug 2004 06:47:08 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 808FD14B2806 + for ; + Wed, 11 Aug 2004 03:47:07 -0300 (ADT) +Received: (qmail 22397 invoked from network); 11 Aug 2004 08:47:12 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 11 Aug 2004 08:47:12 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: NUMERIC x VARCHAR +References: <4119B1C9.2010800@galvao.eti.br> +Message-ID: +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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, 11 Aug 2004 08:47:10 +0200 +In-Reply-To: <4119B1C9.2010800@galvao.eti.br> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/150 +X-Sequence-Number: 7786 + + +Numeric won't store that : + + (+33) 4 01 23 45 67 + +On Wed, 11 Aug 2004 02:42:33 -0300, Er Galv�o Abbott + wrote: + +> Greetings. +> +> I have a question regarding performance of certain datatypes: +> +> I have a field where I will store my clients phone numbers. I know that +> this +> field will never exceed 15 characters, and I will store only numbers +> here (no +> dashes, dots, etc...), so I was wondering: +> +> Wich type is faster: NUMERIC(15,0) or VARCHAR(15)? Are there any storage +> differences between them? +> +> TIA, +> + + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 04:26:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C7C6E14B27FF + for ; + Wed, 11 Aug 2004 04:26:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74112-10 + for ; + Wed, 11 Aug 2004 07:26:25 +0000 (GMT) +Received: from itapoa.terra.com.br (itapoa.terra.com.br [200.154.55.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 16C7314B287E + for ; + Wed, 11 Aug 2004 04:26:21 -0300 (ADT) +Received: from talara.terra.com.br (talara.terra.com.br [200.154.55.136]) + by itapoa.terra.com.br (Postfix) with ESMTP id 93A27DD430F + for ; + Wed, 11 Aug 2004 04:26:22 -0300 (BRT) +Received: from [200.176.35.99] (cm-net-poa-C8B02363.brdterra.com.br + [200.176.35.99]) (authenticated user erabbott) + by talara.terra.com.br (Postfix) with ESMTP id 5720C3C002 + for ; + Wed, 11 Aug 2004 04:26:22 -0300 (BRT) +Message-ID: <4119CA63.8050307@galvao.eti.br> +Date: Wed, 11 Aug 2004 04:27:31 -0300 +From: =?ISO-8859-15?Q?Er_Galv=E3o_Abbott?= +Reply-To: galvao@galvao.eti.br +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: NUMERIC x VARCHAR +References: <4119B1C9.2010800@galvao.eti.br> +In-Reply-To: +Content-Type: text/html; charset=ISO-8859-15 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.4 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_MESSAGE, HTML_TITLE_EMPTY, MIME_HTML_ONLY, RCVD_IN_NJABL, + RCVD_IN_NJABL_PROXY, RCVD_IN_SORBS +X-Spam-Level: ** +X-Archive-Number: 200408/151 +X-Sequence-Number: 7787 + + + + + + + + +It will. As I've said I wont be storing any +symbols.
+
+
+
-- 
+Er Galv�o Abbott
+Desenvolvedor Web
+http://www.galvao.eti.br/
+galvao@galvao.eti.br
+
+
+Pierre-Fr�d�ric Caillaud wrote:
+

+Numeric won't store that : +
+
+����(+33) 4 01 23 45 67 +
+
+On Wed, 11 Aug 2004 02:42:33 -0300, Er Galv�o Abbott� +<galvao@galvao.eti.br> wrote: +
+
+
Greetings. +
+
+I have a question regarding performance of certain datatypes: +
+
+I have a field where I will store my clients phone numbers. I know +that� this +
+field will never exceed 15 characters, and I will store only numbers� +here (no +
+dashes, dots, etc...), so I was wondering: +
+
+Wich type is faster: NUMERIC(15,0) or VARCHAR(15)? Are there any +storage +
+differences between them? +
+
+TIA, +
+
+
+
+
+
+---------------------------(end of +broadcast)--------------------------- +
+TIP 6: Have you searched our list archives? +
+
+������������� http://archives.postgresql.org +
+
+
+
+
+
+
+ + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 04:42:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A81FE14B281E + for ; + Wed, 11 Aug 2004 04:42:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79273-07 + for ; + Wed, 11 Aug 2004 07:41:57 +0000 (GMT) +Received: from laughter.local (unknown [61.115.206.98]) + by svr1.postgresql.org (Postfix) with ESMTP id 0071B14B2806 + for ; + Wed, 11 Aug 2004 04:41:56 -0300 (ADT) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by laughter.local (Postfix) with ESMTP + id 44B3A29BA54; Wed, 11 Aug 2004 16:41:26 +0900 (JST) +In-Reply-To: <4119CA63.8050307@galvao.eti.br> +References: <4119B1C9.2010800@galvao.eti.br> + <4119CA63.8050307@galvao.eti.br> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Message-Id: +Content-Transfer-Encoding: quoted-printable +Cc: pgsql-performance@postgresql.org +From: Michael Glaesemann +Subject: Re: NUMERIC x VARCHAR +Date: Wed, 11 Aug 2004 16:41:25 +0900 +To: galvao@galvao.eti.br +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/152 +X-Sequence-Number: 7788 + + +On Aug 11, 2004, at 4:27 PM, Er Galv=E3o Abbott wrote: + +> It will. As I've said I wont be storing any symbols. + +It won't store leading zeros, however. This may or may not be an issue=20 +for you. + + +test=3D# create table tel (name_id integer not null, tel_numeric=20 +numeric(15) not null, tel_varchar varchar(15) not null); +CREATE TABLE +test=3D# insert into tel (name_id, tel_numeric, tel_varchar) values=20 +(1,012345678911234, '012345678911234'); +INSERT 17153 1 +test=3D# select * from tel; + name_id | tel_numeric | tel_varchar +---------+----------------+----------------- + 1 | 12345678911234 | 012345678911234 +(1 row) + +I would do as another poster suggested: create a telephone number=20 +domain as text with the check constraints you desire. + +Michael Glaesemann +grzm myrealbox com + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 09:22:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CAD4214B2876 + for ; + Wed, 11 Aug 2004 09:22:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64964-08 + for ; + Wed, 11 Aug 2004 12:22:20 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 751DA14B287A + for ; + Wed, 11 Aug 2004 09:22:17 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Hardware upgrade for a high-traffic database +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Wed, 11 Aug 2004 08:21:33 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A7449@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Hardware upgrade for a high-traffic database +thread-index: AcR/Lr47tKJaxYJUST64s429yuXv/gADnnNwABef6VA= +From: "Merlin Moncure" +To: "Jason Coene" +Cc: "Postgresql Performance" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/153 +X-Sequence-Number: 7789 + +> The issue that I think we're seeing is that the performance on the +3Ware +> RAID is quite bad, watching FreeBSD systat will show it at "100% busy" +at +> around "3.5 MB/s". When it needs to seek across a table (for, say, an +> aggregate function - typically a COUNT()), it slows the entire server +down +> while working on the disk. Additionally, VACUUM's make the server +> practically useless. We have indexes on everything that's used in +> queries, +> and the planner is using them. + +It sounds to me like your application is CPU bound, except when +vacuuming...then your server is just overloaded. A higher performance +i/o system will help when vacuuming and checkpointing but will not solve +the overall problem.=20=20 + +With a (good & well supported) battery backed raid controller you can +turn fsync back on which will help you with your i/o storm issues (plus +the safety issue). This will be particularly important if you follow +my next suggestion. + +One thing you might consider is materialized views. Your aggregate +functions are killing you...try to avoid using them (except min/max on +an index). Just watch out for mutable functions like now(). + +http://www.varlena.com/varlena/GeneralBits/Tidbits/matviews.html + +An application specific approach is to use triggers to keep the data you +need in as close to query form as possible...you can reap enormous +savings particularly if your queries involve 3 or more tables or have +large aggregate scans. + +Merlin + +=20 + +From pgsql-performance-owner@postgresql.org Wed Aug 11 11:49:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 046AD14B281F + for ; + Wed, 11 Aug 2004 11:29:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10752-05 + for ; + Wed, 11 Aug 2004 14:29:49 +0000 (GMT) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C0DD14B280B + for ; + Wed, 11 Aug 2004 11:29:48 -0300 (ADT) +Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1Buu6w-0007AX-00 + for ; Wed, 11 Aug 2004 16:29:53 +0200 +Received: from linuxnews.dk ([81.7.132.92]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Wed, 11 Aug 2004 16:29:50 +0200 +Received: from jesper by linuxnews.dk with local (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Wed, 11 Aug 2004 16:29:50 +0200 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +From: Jesper Krogh +Subject: Storing binary data. +Date: Wed, 11 Aug 2004 14:29:46 +0000 (UTC) +Lines: 28 +Message-ID: +X-Complaints-To: usenet@sea.gmane.org +X-Gmane-NNTP-Posting-Host: linuxnews.dk +User-Agent: slrn/0.9.8.0 (Linux) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/154 +X-Sequence-Number: 7790 + +Hi. + +Please be a bit patient.. I'm quite new to PostgreSQL. + +I'd like some advise on storing binary data in the database. + +Currently I have about 300.000 320.000 Bytes "Bytea" records in the +database. It works quite well but I have a feeling that it actually is +slowing the database down on queries only related to the surrounding +attributes. + +The "common" solution, I guess would be to store them in the filesystem +instead, but I like to have them just in the database it is nice clean +database and application design and if I can get PostgreSQL to "not +cache" them then it should be excactly as fast i assume. + +The binary data is not a part of most queries in the database only a few +explicitly written to fetch them and they are not accessed very often. + +What do people normally do? + + +Thanks, Jesper + +-- +./Jesper Krogh, jesper@krogh.cc +Jabber ID: jesper@jabbernet.dk + + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 12:33:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 07AF314B27FC + for ; + Wed, 11 Aug 2004 12:13:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93715-01 + for ; + Wed, 11 Aug 2004 15:13:03 +0000 (GMT) +Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) + by svr1.postgresql.org (Postfix) with ESMTP id EF54514B281C + for ; + Wed, 11 Aug 2004 12:13:02 -0300 (ADT) +Received: from [203.199.147.2] (port=32982 + helo=ps0499.intranet.persistent.co.in) + by frodo.hserus.net with asmtp + (Cipher TLSv1:RC4-MD5:128) (Exim 4.41 #0) + id 1Buume-0004Ep-Gp by authid with plain; + Wed, 11 Aug 2004 20:42:56 +0530 +From: Shridhar Daithankar +To: Jesper Krogh +Subject: Re: Storing binary data. +Date: Wed, 11 Aug 2004 20:42:50 +0530 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Disposition: inline +Organization: Persistent Systems Pvt. Ltd. +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200408112042.50356.shridhar@frodo.hserus.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/155 +X-Sequence-Number: 7791 + +On Wednesday 11 Aug 2004 7:59 pm, Jesper Krogh wrote: +> The "common" solution, I guess would be to store them in the filesystem +> instead, but I like to have them just in the database it is nice clean +> database and application design and if I can get PostgreSQL to "not +> cache" them then it should be excactly as fast i assume. + +You can normalize them so that a table contains an id and a bytea column only. +Te main table will contain all the other attributes and a mapping id. That +way you will have only the main table cached. + +You don't have to go to filesystem for this, I hope. + +HTH + + Shridhar + +From pgsql-performance-owner@postgresql.org Wed Aug 11 13:23:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8481514B281B + for ; + Wed, 11 Aug 2004 12:55:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05940-03 + for ; + Wed, 11 Aug 2004 15:55:26 +0000 (GMT) +Received: from gawab.com (v2.gawab.com [204.97.230.42]) + by svr1.postgresql.org (Postfix) with SMTP id A2C7214B2820 + for ; + Wed, 11 Aug 2004 12:55:23 -0300 (ADT) +Received: (qmail 30538 invoked by uid 1004); 11 Aug 2004 15:55:21 -0000 +Received: from unknown (HELO ?192.168.200.2?) (skpobox@202.164.39.130) + by gawab.com with SMTP; 11 Aug 2004 15:55:21 -0000 +Subject: Re: Hardware upgrade for a high-traffic database +From: Sanjay Arora +Reply-To: skpobox@gawab.com +To: Postgresql Performance +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A7449@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3412A7449@Herge.rcsinc.local> +Content-Type: text/plain +Organization: Transcontinental Impex Pvt. Ltd. +Message-Id: <1092239230.2277.5.camel@Sewak.Asr.Lan> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 11 Aug 2004 21:17:10 +0530 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=3.6 tagged_above=0.0 required=5.0 tests=RCVD_IN_DSBL, + RCVD_IN_NJABL, RCVD_IN_NJABL_PROXY, RCVD_IN_RFCI, RCVD_IN_SORBS, + RCVD_IN_SORBS_HTTP +X-Spam-Level: *** +X-Archive-Number: 200408/156 +X-Sequence-Number: 7792 + +On Wed, 2004-08-11 at 17:51, Merlin Moncure wrote: + +> One thing you might consider is materialized views. Your aggregate +> functions are killing you...try to avoid using them (except min/max on +> an index). Just watch out for mutable functions like now(). +> +> http://www.varlena.com/varlena/GeneralBits/Tidbits/matviews.html +> +> An application specific approach is to use triggers to keep the data you +> need in as close to query form as possible...you can reap enormous +> savings particularly if your queries involve 3 or more tables or have +> large aggregate scans. + +I thought materialized views support in pgsql was experimental as yet. +Are the pg mat-view code upto production servers? Also, do you have to +delete mat-views before you dump the db or does dump automatically not +dump the mat-views data? + +Sanjay. + + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 13:47:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B5B914B281A + for ; + Wed, 11 Aug 2004 13:06:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10324-09 + for ; + Wed, 11 Aug 2004 16:06: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 824F214B280B + for ; + Wed, 11 Aug 2004 13:06:40 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7BG6cVR006089; + Wed, 11 Aug 2004 12:06:38 -0400 (EDT) +To: Jesper Krogh +Cc: pgsql-performance@postgresql.org +Subject: Re: Storing binary data. +In-reply-to: +References: +Comments: In-reply-to Jesper Krogh + message dated "Wed, 11 Aug 2004 14:29:46 -0000" +Date: Wed, 11 Aug 2004 12:06:38 -0400 +Message-ID: <6088.1092240398@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/158 +X-Sequence-Number: 7794 + +Jesper Krogh writes: +> I'd like some advise on storing binary data in the database. + +> Currently I have about 300.000 320.000 Bytes "Bytea" records in the +> database. It works quite well but I have a feeling that it actually is +> slowing the database down on queries only related to the surrounding +> attributes. + +> The "common" solution, I guess would be to store them in the filesystem +> instead, but I like to have them just in the database it is nice clean +> database and application design and if I can get PostgreSQL to "not +> cache" them then it should be excactly as fast i assume. + +> The binary data is not a part of most queries in the database only a few +> explicitly written to fetch them and they are not accessed very often. + +> What do people normally do? + +Nothing. If the bytea values are large enough to be worth splitting +out, Postgres will actually do that for you automatically. Wide field +values get pushed into a separate "toast" table, and are not fetched by +a query unless the value is specifically demanded. + +You can control this behavior to some extent by altering the storage +option for the bytea column (see ALTER TABLE), but the default choice +is usually fine. + +If you just want to see whether anything is happening, do a VACUUM +VERBOSE on that table and note the amount of storage in the toast table +as compared to the main table. + + regards, tom lane + +From pgsql-general-owner@postgresql.org Wed Aug 11 13:28:34 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C84AB14B281F + for ; + Wed, 11 Aug 2004 13:18:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15626-01 + for ; + Wed, 11 Aug 2004 16:18:56 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id DEC6114B27FF + for ; + Wed, 11 Aug 2004 13:18:54 -0300 (ADT) +Received: (qmail 10232 invoked by uid 500); 11 Aug 2004 16:27:01 -0000 +Date: Wed, 11 Aug 2004 11:27:01 -0500 +From: Bruno Wolff III +To: Ulrich Wisser +Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: How to know which queries are to be optimised? +Message-ID: <20040811162701.GA9992@wolff.to> +Mail-Followup-To: pgsql-performance@postgresql.org, + ulrich.wisser@relevanttraffic.se +References: <4110CFE7.9000202@relevanttraffic.se> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4110CFE7.9000202@relevanttraffic.se> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/459 +X-Sequence-Number: 64014 + +On Wed, Aug 04, 2004 at 14:00:39 +0200, + Ulrich Wisser wrote: + +This topic really belongs on the performance list. I have copied that +list and set followups to go there and copy you. + +> +> my web application grows slower and slower over time. After some +> profiling I came to the conclusion that my SQL queries are the biggest +> time spenders (25 seconds). Obviously I need to optimise my queries and +> maybe introduce some new indexes. + +This sounds like you aren't doing proper maintainance. You need to be +vacuuming with a large enough FSM setting. + +> The problem is, that my application uses dynamic queries. I therefor can +> not determine what are the most common queries. +> +> I have used the postgresql logging ption before. Is there a tool to +> analyze the logfile for the most common and/or most time consuming queries? + +You can log queries that run for at least a specified amount of time. +This will be useful in finding what the long running queries are. +You can then use explain analyse to see why they are long running. + +From pgsql-performance-owner@postgresql.org Wed Aug 11 15:02:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A1BC14B281D + for ; + Wed, 11 Aug 2004 13:40:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20945-06 + for ; + Wed, 11 Aug 2004 16:40:31 +0000 (GMT) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 0831B14B281C + for ; + Wed, 11 Aug 2004 13:40:27 -0300 (ADT) +Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1Buw9L-0002BW-00 + for ; Wed, 11 Aug 2004 18:40:27 +0200 +Received: from linuxnews.dk ([81.7.132.92]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Wed, 11 Aug 2004 18:40:26 +0200 +Received: from jesper by linuxnews.dk with local (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Wed, 11 Aug 2004 18:40:26 +0200 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +From: Jesper Krogh +Subject: Re: Storing binary data. +Date: Wed, 11 Aug 2004 16:29:33 +0000 (UTC) +Lines: 32 +Message-ID: +References: + <200408112042.50356.shridhar@frodo.hserus.net> +X-Complaints-To: usenet@sea.gmane.org +X-Gmane-NNTP-Posting-Host: linuxnews.dk +User-Agent: slrn/0.9.8.0 (Linux) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/161 +X-Sequence-Number: 7797 + +I gmane.comp.db.postgresql.performance, skrev Shridhar Daithankar: +> On Wednesday 11 Aug 2004 7:59 pm, Jesper Krogh wrote: +> > The "common" solution, I guess would be to store them in the filesystem +> > instead, but I like to have them just in the database it is nice clean +> > database and application design and if I can get PostgreSQL to "not +> > cache" them then it should be excactly as fast i assume. +> +> You can normalize them so that a table contains an id and a bytea column only. +> Te main table will contain all the other attributes and a mapping id. That +> way you will have only the main table cached. +> +> You don't have to go to filesystem for this, I hope. + +Further benchmarking. + +I tried to create a table with the excact same attributes but without +the binary attribute. It didn't change anything, so my idea that it +should be the binary-stuff that sloved it down was wrong. + +I have a timestamp column in the table that I sort on. Data is ordered +over the last 4 years and I select based on a timerange, I cannot make +the query-planner use the index on the timestamp by itself but if I "set +enable_seqscan = false" the query time drops by 1/3 (from 1.200 msec to +about 400 msec). + +I cannot figure out why the query-planner chooses wrong. +NB: It's postgresql 7.4.3 + +-- +./Jesper Krogh, jesper@krogh.cc +Jabber ID: jesper@jabbernet.dk + + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 15:05:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CB9214B281C + for ; + Wed, 11 Aug 2004 13:37:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19349-07 + for ; + Wed, 11 Aug 2004 16:37:12 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 0141114B281A + for ; + Wed, 11 Aug 2004 13:37:09 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: fsync vs open_sync +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Wed, 11 Aug 2004 12:37:10 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A744B@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] fsync vs open_sync +thread-index: AcR/N0QD6n5P9YRnQlSbjUd+CYyiTgAiD5kQ +From: "Merlin Moncure" +To: "Josh Berkus" +Cc: , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/162 +X-Sequence-Number: 7798 + +> OSDL did some testing and found Ext3 to be perhaps the worst FS for +> PostgreSQL +> -- although this testing was with the default options. Ext3 involved +an +> almost 40% write performance penalty compared with Ext2, whereas the +> penalty +> for ReiserFS and JFS was less than 10%. +>=20 +> This concurs with my personal experience. + +I'm really curious to see if you guys have compared insert performance +results between 7.4 and 8.0. As you probably know the system sync() +call was replaced with a looping fsync on open file handles. This may +have some interesting interactions with the WAL sync method. + +What caught my attention initially was the 300+/sec insert performance. +On 8.0/NTFS/fsync=3Don, I can't break 100/sec on a 10k rpm ATA disk. My +hardware seems to be more or less in the same league as psql's, so I was +naturally curious if this was a NT/Unix issue, a 7.4/8.0 issue, or a +combination of both. + +A 5ms seek time disk would be limited to 200 transaction commits/sec if +each transaction commit has at least 1 seek. Are there some +circumstances where a transaction commit does not generate a physical +seek?=20=20 + +Maybe ext3 is not the worst filesystem after all! + +Merlin + +From pgsql-performance-owner@postgresql.org Wed Aug 11 14:43:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C0B014B2800 + for ; + Wed, 11 Aug 2004 14:04:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28623-02 + for ; + Wed, 11 Aug 2004 17:04:00 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 48E5F14B281A + for ; + Wed, 11 Aug 2004 14:03:59 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Hardware upgrade for a high-traffic database +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Wed, 11 Aug 2004 13:04:00 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A744C@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Hardware upgrade for a high-traffic database +thread-index: AcR/wKM/SPJYFARuSzmW5ua1WlF1TwAAaVgQ +From: "Merlin Moncure" +To: +Cc: "Postgresql Performance" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/160 +X-Sequence-Number: 7796 + +> On Wed, 2004-08-11 at 17:51, Merlin Moncure wrote: +>=20 +> > One thing you might consider is materialized views. Your aggregate +> > functions are killing you...try to avoid using them (except min/max +on +> > an index). Just watch out for mutable functions like now(). +> > +> > http://www.varlena.com/varlena/GeneralBits/Tidbits/matviews.html +> > +> > An application specific approach is to use triggers to keep the data +you +> > need in as close to query form as possible...you can reap enormous +> > savings particularly if your queries involve 3 or more tables or +have +> > large aggregate scans. +>=20 +> I thought materialized views support in pgsql was experimental as yet. +> Are the pg mat-view code upto production servers? Also, do you have to +> delete mat-views before you dump the db or does dump automatically not +> dump the mat-views data? + +I think you are thinking about 100% 'true' materialized views. In that +case the answer is no, the server does not have them. The GeneralBits +article describes how to emulate them through pl/sql triggers. I just +bumped into the article yesterday and was very impressed by it...I have +to admin though Note: I have never tried the method, but it should work. +I cc'd the author who perhaps might chime in and tell you more about +them. + +Materialized views can give performance savings so good that the tpc +people had to ban them from benchmarks because they skewed results...:) +In postgres, they can help a lot with aggregates...there are many +gotchas tho, for example keeping a count() up to date can get kind of +tricky. If you can get them to work, the filesystem cache efficiency +will rocket upwards...YMMV. + +Getting back on topic, I missed the original post where the author +stated his problems were i/o related, not cpu (contrary to my +speculation). I wonder what his insert/update load is? + +Merlin + + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 14:41:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4131C14B281A + for ; + Wed, 11 Aug 2004 14:12:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29938-06 + for ; + Wed, 11 Aug 2004 17:12:44 +0000 (GMT) +Received: from loncoche.terra.com.br (loncoche.terra.com.br [200.154.55.229]) + by svr1.postgresql.org (Postfix) with ESMTP id DEFB614B2825 + for ; + Wed, 11 Aug 2004 14:12:38 -0300 (ADT) +Received: from potosi.terra.com.br (potosi.terra.com.br [200.154.55.131]) + by loncoche.terra.com.br (Postfix) with ESMTP id 27917E78BBA + for ; + Wed, 11 Aug 2004 14:12:35 -0300 (BRT) +Received: from [200.176.35.99] (cm-net-poa-C8B02363.brdterra.com.br + [200.176.35.99]) (authenticated user erabbott) + by potosi.terra.com.br (Postfix) with ESMTP id 08DE137008E + for ; + Wed, 11 Aug 2004 14:12:35 -0300 (BRT) +Message-ID: <411A53CB.8030209@galvao.eti.br> +Date: Wed, 11 Aug 2004 14:13:47 -0300 +From: =?ISO-8859-1?Q?Er_Galv=E3o_Abbott?= +Reply-To: galvao@galvao.eti.br +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: NUMERIC x VARCHAR +References: <4119B1C9.2010800@galvao.eti.br> + <4119CA63.8050307@galvao.eti.br> + +In-Reply-To: +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=2.4 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_MESSAGE, HTML_TITLE_EMPTY, MIME_HTML_ONLY, RCVD_IN_NJABL, + RCVD_IN_NJABL_PROXY, RCVD_IN_SORBS +X-Spam-Level: ** +X-Archive-Number: 200408/159 +X-Sequence-Number: 7795 + + + + + + + + +Thanks, Michael.
+
+You and "Evil Azrael" (lol) got me. Never thought about leading zeros.
+
+Varchar it is!
+
+Thanks a lot,

+
-- 
+Er Galvão Abbott
+Desenvolvedor Web
+http://www.galvao.eti.br/
+galvao@galvao.eti.br
+
+
+Michael Glaesemann wrote:
+

+On Aug 11, 2004, at 4:27 PM, Er Galvão Abbott wrote: +
+
+
It will. As I've said I wont be storing any +symbols. +
+
+
+It won't store leading zeros, however. This may or may not be an issue +for you. +
+
+
+test=# create table tel (name_id integer not null, tel_numeric +numeric(15) not null, tel_varchar varchar(15) not null); +
+CREATE TABLE +
+test=# insert into tel (name_id, tel_numeric, tel_varchar) values +(1,012345678911234, '012345678911234'); +
+INSERT 17153 1 +
+test=# select * from tel; +
+ name_id |  tel_numeric   |   tel_varchar +
+---------+----------------+----------------- +
+       1 | 12345678911234 | 012345678911234 +
+(1 row) +
+
+I would do as another poster suggested: create a telephone number +domain as text with the check constraints you desire. +
+
+Michael Glaesemann +
+grzm myrealbox com +
+
+ + + +From pgsql-performance-owner@postgresql.org Fri Aug 13 12:42:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 00A5114B281B + for ; + Wed, 11 Aug 2004 13:57:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25359-08 + for ; + Wed, 11 Aug 2004 16:57:08 +0000 (GMT) +Received: from outland.mohawksoft.com (unknown [64.46.156.80]) + by svr1.postgresql.org (Postfix) with ESMTP id 52A1E14B27FF + for ; + Wed, 11 Aug 2004 13:57:07 -0300 (ADT) +Received: (from mohawk@localhost) + by outland.mohawksoft.com (8.11.6/8.11.6) id i7BHE6G27223; + Wed, 11 Aug 2004 13:14:06 -0400 +From: pgsql@mohawksoft.com +X-Authentication-Warning: outland.mohawksoft.com: mohawk set sender to + pgsql@mohawksoft.com using -f +Received: from 64.119.142.34 (SquirrelMail authenticated user pgsql) + by mail.mohawksoft.com with HTTP; + Wed, 11 Aug 2004 13:14:05 -0400 (EDT) +Message-ID: <42528.64.119.142.34.1092244445.squirrel@mail.mohawksoft.com> +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A744B@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3412A744B@Herge.rcsinc.local> +Date: Wed, 11 Aug 2004 13:14:05 -0400 (EDT) +Subject: Re: fsync vs open_sync +To: "Merlin Moncure" +Cc: "Josh Berkus" , + pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.2 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.1 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME, + PRIORITY_NO_NAME +X-Spam-Level: * +X-Archive-Number: 200408/208 +X-Sequence-Number: 7844 + +>> OSDL did some testing and found Ext3 to be perhaps the worst FS for +>> PostgreSQL +>> -- although this testing was with the default options. Ext3 involved +> an +>> almost 40% write performance penalty compared with Ext2, whereas the +>> penalty +>> for ReiserFS and JFS was less than 10%. +>> +>> This concurs with my personal experience. +> +> I'm really curious to see if you guys have compared insert performance +> results between 7.4 and 8.0. As you probably know the system sync() +> call was replaced with a looping fsync on open file handles. This may +> have some interesting interactions with the WAL sync method. +> +> What caught my attention initially was the 300+/sec insert performance. +> On 8.0/NTFS/fsync=on, I can't break 100/sec on a 10k rpm ATA disk. My +> hardware seems to be more or less in the same league as psql's, so I was +> naturally curious if this was a NT/Unix issue, a 7.4/8.0 issue, or a +> combination of both. + +The system on which I can get 300 inserts per second is a battery backed +up XEON system with 512M RAM, a Promise PDC DMA ATA card, and some fast +disks with write caching enabled. + +(We are not worried about write caching because we have a UPS. Since all +non-redundent systems are evaluated on probability of error, we decided +that the probability of power failure and UPS failure was sufficiently +more rare than system crash with file system corruption or hard disk +failure.) +> +> A 5ms seek time disk would be limited to 200 transaction commits/sec if +> each transaction commit has at least 1 seek. Are there some +> circumstances where a transaction commit does not generate a physical +> seek? +> +> Maybe ext3 is not the worst filesystem after all! +> +> Merlin +> + + +From pgsql-general-owner@postgresql.org Wed Aug 11 15:46:58 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 158BB14B2825 + for ; + Wed, 11 Aug 2004 15:41:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62755-02 + for ; + Wed, 11 Aug 2004 18:41:47 +0000 (GMT) +Received: from web53901.mail.yahoo.com (web53901.mail.yahoo.com + [206.190.36.211]) + by svr1.postgresql.org (Postfix) with SMTP id C5CE214B27FF + for ; + Wed, 11 Aug 2004 15:41:43 -0300 (ADT) +Message-ID: <20040811184143.98784.qmail@web53901.mail.yahoo.com> +Received: from [210.214.122.201] by web53901.mail.yahoo.com via HTTP; + Wed, 11 Aug 2004 11:41:43 PDT +Date: Wed, 11 Aug 2004 11:41:43 -0700 (PDT) +From: Karam Chand +Subject: My admin left the job and I am stuck +To: pgsql-general@postgresql.org +In-Reply-To: <20040811162701.GA9992@wolff.to> +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=3.1 tagged_above=0.0 required=5.0 + tests=FROM_ENDS_IN_NUMS, FROM_HAS_ULINE_NUMS, RCVD_IN_SORBS +X-Spam-Level: *** +X-Archive-Number: 200408/468 +X-Sequence-Number: 64023 + +Hello, + +My linux admin left the job. We had a PostgreSQL +installed under his username. He used to maintain it. +Now I am looking at the Linux box and I am just a +super duper newbie in Linux administration. + +The previosu admin had a database created under his +name coz PostgreSQL dosnt allow root database. + +Now I want to get the data back and use it? I dont +mind if I have to use a different DB? + +I dont even know where he isntalled the PostgreSQL +binaries and data? + +Where can I all this information? + +I am feeling really stupid but thank GOD we dont have +any live databases running? + +Regards, +Karam + + + +__________________________________ +Do you Yahoo!? +Yahoo! Mail - Helps protect you from nasty viruses. +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Wed Aug 11 16:17:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 650E714B2800 + for ; + Wed, 11 Aug 2004 16:09:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69594-10 + for ; + Wed, 11 Aug 2004 19:09:47 +0000 (GMT) +Received: from mail.gotfrag.com (unknown [66.208.110.11]) + by svr1.postgresql.org (Postfix) with ESMTP id E810014B281B + for ; + Wed, 11 Aug 2004 16:09:45 -0300 (ADT) +Received: from vaio (roc-66-66-149-175.rochester.rr.com [66.66.149.175]) + by mail.gotfrag.com (8.12.10/8.12.8) with ESMTP id i7BJ8m0E094620; + Wed, 11 Aug 2004 15:08:48 -0400 (EDT) + (envelope-from jcoene@gotfrag.com) +Message-Id: <200408111908.i7BJ8m0E094620@mail.gotfrag.com> +From: "Jason Coene" +To: "'Merlin Moncure'" +Cc: "'Postgresql Performance'" +Subject: Re: Hardware upgrade for a high-traffic database +Date: Wed, 11 Aug 2004 15:08:42 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A744C@Herge.rcsinc.local> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 +Thread-Index: AcR/wKM/SPJYFARuSzmW5ua1WlF1TwAAaVgQAARCz4A= +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/163 +X-Sequence-Number: 7799 + +Thanks for all the feedback. To clear it up, we are definitely not CPU +bound at the moment. Any slowdown seems to be disk dependant, or from to +serialization due to a long query (due to disk). + +We do have a lot of INSERT/UPDATE calls, specifically on tables that track +user sessions, then of course things like comments, etc (where we'll see +10-30 INSERT's per second, with TEXT field, and hundreds of reads per +second). Additionally, our system does use a lot of aggregate functions. +I'll look into materialized views, it sounds like it may be worth +implementing. + +One question I do have though - you specifically mentioned NOW() as +something to watch out for, in that it's mutable. We typically use COUNT() +as a subselect to retrieve the number of associated rows to the current +query. Additionally, we use NOW a lot, primarily to detect the status of a +date, i.e.: + +SELECT id FROM subscriptions WHERE userid = 11111 AND timeend > NOW(); + +Is there a better way to do this? I was under the impression that NOW() was +pretty harmless, just to return a current timestamp. + +Based on feedback, I'm looking at a minor upgrade of our RAID controller to +a 3ware 9000 series (SATA with cache, battery backup optional), and +re-configuring it for RAID 10. It's a damn cheap upgrade at around $350 and +an hour of downtime, so I figure that it's worth it for us to give it a +shot. + +Thanks, + +Jason + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Merlin Moncure +Sent: Wednesday, August 11, 2004 1:04 PM +To: skpobox@gawab.com +Cc: Postgresql Performance; jgardner@jonathangardner.net +Subject: Re: [PERFORM] Hardware upgrade for a high-traffic database + +> On Wed, 2004-08-11 at 17:51, Merlin Moncure wrote: +> +> > One thing you might consider is materialized views. Your aggregate +> > functions are killing you...try to avoid using them (except min/max +on +> > an index). Just watch out for mutable functions like now(). +> > +> > http://www.varlena.com/varlena/GeneralBits/Tidbits/matviews.html +> > +> > An application specific approach is to use triggers to keep the data +you +> > need in as close to query form as possible...you can reap enormous +> > savings particularly if your queries involve 3 or more tables or +have +> > large aggregate scans. +> +> I thought materialized views support in pgsql was experimental as yet. +> Are the pg mat-view code upto production servers? Also, do you have to +> delete mat-views before you dump the db or does dump automatically not +> dump the mat-views data? + +I think you are thinking about 100% 'true' materialized views. In that +case the answer is no, the server does not have them. The GeneralBits +article describes how to emulate them through pl/sql triggers. I just +bumped into the article yesterday and was very impressed by it...I have +to admin though Note: I have never tried the method, but it should work. +I cc'd the author who perhaps might chime in and tell you more about +them. + +Materialized views can give performance savings so good that the tpc +people had to ban them from benchmarks because they skewed results...:) +In postgres, they can help a lot with aggregates...there are many +gotchas tho, for example keeping a count() up to date can get kind of +tricky. If you can get them to work, the filesystem cache efficiency +will rocket upwards...YMMV. + +Getting back on topic, I missed the original post where the author +stated his problems were i/o related, not cpu (contrary to my +speculation). I wonder what his insert/update load is? + +Merlin + + + +---------------------------(end of broadcast)--------------------------- +TIP 2: you can get off all lists at once with the unregister command + (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 16:33:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CDD814B2821 + for ; + Wed, 11 Aug 2004 16:20:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72563-06 + for ; + Wed, 11 Aug 2004 19:20:13 +0000 (GMT) +Received: from smtp110.mail.sc5.yahoo.com (smtp110.mail.sc5.yahoo.com + [66.163.170.8]) + by svr1.postgresql.org (Postfix) with SMTP id 3734014B2806 + for ; + Wed, 11 Aug 2004 16:20:12 -0300 (ADT) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp110.mail.sc5.yahoo.com with SMTP; 11 Aug 2004 19:20:13 -0000 +Received: from [172.21.8.18] (ismtp.afilias.com [216.217.55.254]) + (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i7BJK2T7001460; Wed, 11 Aug 2004 15:20:02 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <411A715C.70808@Yahoo.com> +Date: Wed, 11 Aug 2004 15:19:56 -0400 +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: Scott Marlowe +Cc: galvao@galvao.eti.br, pgsql-performance@postgresql.org +Subject: Re: NUMERIC x VARCHAR +References: <4119B1C9.2010800@galvao.eti.br> + <1092205308.27166.358.camel@localhost.localdomain> +In-Reply-To: <1092205308.27166.358.camel@localhost.localdomain> +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=2.6 tagged_above=0.0 required=5.0 + tests=RCVD_IN_DYNABLOCK, RCVD_IN_SORBS +X-Spam-Level: ** +X-Archive-Number: 200408/164 +X-Sequence-Number: 7800 + +On 8/11/2004 2:21 AM, Scott Marlowe wrote: + +> On Tue, 2004-08-10 at 23:42, Er Galvão Abbott wrote: +>> Greetings. +>> +>> I have a question regarding performance of certain datatypes: +>> +>> I have a field where I will store my clients phone numbers. I know +>> that this field will never exceed 15 characters, and I will store only +>> numbers here (no dashes, dots, etc...), so I was wondering: +>> +>> Wich type is faster: NUMERIC(15,0) or VARCHAR(15)? Are there any +>> storage differences between them? +> +> Since numerics are stored as text strings, the storage would be +> similar. Numerics, however, may be slower since they have more +> constraints built in. If you throw a check constraint on the +> varchar(15) then it will likely be about the same speed for updating. + +They are stored as an array of signed small integers holding digits in +base-10000, plus a precision, scale and sign. That's somewhat different +from text strings, isn't it? + + +Jan + +> +> text type with a check contraint it what i'd use. That way if you want +> to change it at a later date you just drop and recreate your constraint. +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html + + +-- +#======================================================================# +# 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 Wed Aug 11 16:42:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B234114B286A + for ; + Wed, 11 Aug 2004 16:40:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01144-04 + for ; + Wed, 11 Aug 2004 19:40:03 +0000 (GMT) +Received: from homer.berkhirt.com (homer.berkhirt.com [207.88.49.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 5679014B2884 + for ; + Wed, 11 Aug 2004 16:39:46 -0300 (ADT) +Received: from [10.10.11.3] (homer [127.0.0.1]) (authenticated bits=0) + by homer.berkhirt.com (8.12.10/8.12.10) with ESMTP id i7BJdYjO029386; + Wed, 11 Aug 2004 14:39:35 -0500 +In-Reply-To: <200408111908.i7BJ8m0E094620@mail.gotfrag.com> +References: <200408111908.i7BJ8m0E094620@mail.gotfrag.com> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <2EE5750C-EBCE-11D8-AF1E-000D93AD2E74@mobygames.com> +Content-Transfer-Encoding: 7bit +Cc: "'Merlin Moncure'" , + "'Postgresql Performance'" +From: Brian Hirt +Subject: Re: Hardware upgrade for a high-traffic database +Date: Wed, 11 Aug 2004 13:39:38 -0600 +To: "Jason Coene" +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/165 +X-Sequence-Number: 7801 + +Jason,, + +One suggestion i have, stay away from adaptec ZCR RAID products, we've +been doing testing on them, and they don't perform well at all. + +--brian + +On Aug 11, 2004, at 1:08 PM, Jason Coene wrote: + +> Thanks for all the feedback. To clear it up, we are definitely not CPU +> bound at the moment. Any slowdown seems to be disk dependant, or from +> to +> serialization due to a long query (due to disk). + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 17:02:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F2DDD14B2870 + for ; + Wed, 11 Aug 2004 16:50:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27620-01 + for ; + Wed, 11 Aug 2004 19:50:20 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C9D014B286C + for ; + Wed, 11 Aug 2004 16:50:18 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Hardware upgrade for a high-traffic database +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Wed, 11 Aug 2004 15:49:48 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A744D@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Hardware upgrade for a high-traffic database +thread-index: AcR/wKM/SPJYFARuSzmW5ua1WlF1TwAAaVgQAARCz4AAAab1kA== +From: "Merlin Moncure" +To: "Jason Coene" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/166 +X-Sequence-Number: 7802 + +> We do have a lot of INSERT/UPDATE calls, specifically on tables that +track +> user sessions, then of course things like comments, etc (where we'll +see +> 10-30 INSERT's per second, with TEXT field, and hundreds of reads per +> second). Additionally, our system does use a lot of aggregate +functions. +> I'll look into materialized views, it sounds like it may be worth +> implementing. + +Right. The point is: is your i/o bottle neck on the read side or the +write side. With 10-30 inserts/sec and fsync off, it's definitely on +the read side. What's interesting is that such a low insert load is +causing i/o storm problems. How does your app run with fsync on? + +With read-bound i/o problems, might want to consider upgrading memory +first to get better cache efficiency. You may want to consider Opteron +for > 4GB allocations (yummy!). + +The good news is that read problems are usually solvable by being +clever, whereas write problems require hardware. + +> One question I do have though - you specifically mentioned NOW() as +> something to watch out for, in that it's mutable. We typically use + +This is specifically with regards to materialized views. Mutable +functions cause problems because when they are pushed unto the view, +they are refreshed...something to watch out for. + +The trick with MVs is to increase your filesystem cache efficiency. The +big picture is to keep frequently read data in a single place to make +better benefit of cache. Aggregates naturally read multiple rows to +return a single row's worth of data so you want to target them first. +This all comes at a cost of update I/O time and some application +complexity. + +> as a subselect to retrieve the number of associated rows to the +current +> query. Additionally, we use NOW a lot, primarily to detect the status +of +> a +> date, i.e.: + +Might want to check if your application middleware (php?) exposes +PQntuples()...this is a zero cost way to get the same information. +=20 +> Based on feedback, I'm looking at a minor upgrade of our RAID +controller +> to +> a 3ware 9000 series (SATA with cache, battery backup optional), and +> re-configuring it for RAID 10. It's a damn cheap upgrade at around +$350 +> and +> an hour of downtime, so I figure that it's worth it for us to give it +a +> shot. + +p.s. you can also increase cache efficiency by reducing database size, +for example use int2/int4 vs. numerics. + +Good luck! + +From pgsql-performance-owner@postgresql.org Wed Aug 11 17:52:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A71DF14B280B + for ; + Wed, 11 Aug 2004 17:51:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61576-03 + for ; + Wed, 11 Aug 2004 20:51:36 +0000 (GMT) +Received: from lakermmtao09.cox.net (lakermmtao09.cox.net [68.230.240.30]) + by svr1.postgresql.org (Postfix) with ESMTP id D244F14B27FF + for ; + Wed, 11 Aug 2004 17:51:34 -0300 (ADT) +Received: from [68.12.228.23] by lakermmtao09.cox.net + (InterMail vM.6.01.03.02.01 201-2131-111-104-103-20040709) with ESMTP + id <20040811205119.UCAV20883.lakermmtao09.cox.net@[68.12.228.23]>; + Wed, 11 Aug 2004 16:51:19 -0400 +Subject: Re: [HACKERS] fsync vs open_sync +From: Steve Bergman +To: Josh Berkus +Cc: Merlin Moncure , pgsql@mohawksoft.com, + pgsql-perform +In-Reply-To: <200408101018.32327.josh@agliodbs.com> +References: <6EE64EF3AB31D5448D0007DD34EEB3412A7446@Herge.rcsinc.local> + <200408101018.32327.josh@agliodbs.com> +Content-Type: text/plain +Date: Wed, 11 Aug 2004 15:51:14 -0500 +Message-Id: <1092257474.18945.37.camel@voyager.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 1.5.92.1 (1.5.92.1-1) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/167 +X-Sequence-Number: 7803 + +On Tue, 2004-08-10 at 10:18 -0700, Josh Berkus wrote: +> Guys, just so you know: +> +> OSDL did some testing and found Ext3 to be perhaps the worst FS for PostgreSQL +> -- although this testing was with the default options. Ext3 involved an +> almost 40% write performance penalty compared with Ext2, whereas the penalty +> for ReiserFS and JFS was less than 10%. +> +> This concurs with my personal experience. +> + +Yes, I have been wondering about the relative trade offs between +underlying file systems and pgsql. + +For metadata journalled filesystems, wouldn't fdatasync be a better +option, since the fs is journalling the metadata anyway? + +With its default settings (data=ordered), ext3 is making a guaranty that +after a crash, the filesystem will not only be in a consistent state, +but the files (including the WAL) will not contain garbage, though their +contents may not be the latest. With reiserfs and JFS, files can +contain garbage. (I'm not sure what the implications of all this for +pgsql are.) + +And wouldn't the following comparisons with ext3 be more interesting: + +ext3,data=writeback,fdatasync vs Other_Journalled_FS,fdatasync + +or + +ext3,data=journal,open_sync vs Other_Journalled_FS,fdatasync + +Just wondering. + +-Steve + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 18:18:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C14F14B280B + for ; + Wed, 11 Aug 2004 18:18:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71367-05 + for ; + Wed, 11 Aug 2004 21:18:30 +0000 (GMT) +Received: from mail.gotfrag.com (g01.gotfrag.com [66.208.110.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E26314B27FF + for ; + Wed, 11 Aug 2004 18:18:29 -0300 (ADT) +Received: from jcoene2 (roc-66-66-149-175.rochester.rr.com [66.66.149.175]) + by mail.gotfrag.com (8.12.10/8.12.8) with ESMTP id i7BLIR0E097522; + Wed, 11 Aug 2004 17:18:27 -0400 (EDT) + (envelope-from jcoene@gotfrag.com) +Message-Id: <200408112118.i7BLIR0E097522@mail.gotfrag.com> +From: "Jason Coene" +To: "'Merlin Moncure'" +Cc: +Subject: Re: Hardware upgrade for a high-traffic database +Date: Wed, 11 Aug 2004 17:18:27 -0400 +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.2096 +Thread-Index: AcR/wKM/SPJYFARuSzmW5ua1WlF1TwAAaVgQAARCz4AAAab1kAAC6LSQ +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A744D@Herge.rcsinc.local> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/168 +X-Sequence-Number: 7804 + +> +> Right. The point is: is your i/o bottle neck on the read side or the +> write side. With 10-30 inserts/sec and fsync off, it's definitely on +> the read side. What's interesting is that such a low insert load is +> causing i/o storm problems. How does your app run with fsync on? +> +> With read-bound i/o problems, might want to consider upgrading memory +> first to get better cache efficiency. You may want to consider Opteron +> for > 4GB allocations (yummy!). +> +> The good news is that read problems are usually solvable by being +> clever, whereas write problems require hardware. +> + +The difference with fsync being off makes seems to be that it allows the +server to write in groups instead of scattering our INSERT/UPDATE calls all +over - it helps keep things going. When a checkpoint occurs, reads slow +down there. Normal reads are usually quite fast, aside from some reads. + +A good example, a comments table where users submit TEXT data. A common +query is to find the last 5 comments a user has submitted. The scan, while +using an index, takes a considerable amount of time (> 0.5 sec is about as +good as it gets). Again, it's using an index on the single WHERE clause +(userid = int). The field that's used to ORDER BY (timestamp) is also +indexed. + +I'm wondering why our PG server is using so little memory... The system has +2GB of memory, though only around 200MB of it are used. Is there a PG +setting to force more memory usage towards the cache? Additionally, we use +FreeBSD. I've heard that Linux may manage that memory better, any truth +there? Sorry if I'm grabbing at straws here :) + +> > One question I do have though - you specifically mentioned NOW() as +> > something to watch out for, in that it's mutable. We typically use +> +> This is specifically with regards to materialized views. Mutable +> functions cause problems because when they are pushed unto the view, +> they are refreshed...something to watch out for. +> +> The trick with MVs is to increase your filesystem cache efficiency. The +> big picture is to keep frequently read data in a single place to make +> better benefit of cache. Aggregates naturally read multiple rows to +> return a single row's worth of data so you want to target them first. +> This all comes at a cost of update I/O time and some application +> complexity. +> +> > as a subselect to retrieve the number of associated rows to the +> current +> > query. Additionally, we use NOW a lot, primarily to detect the status +> of +> > a +> > date, i.e.: +> +> Might want to check if your application middleware (php?) exposes +> PQntuples()...this is a zero cost way to get the same information. +> + +Thanks, I'll look into it. We use C and PHP. + +> > Based on feedback, I'm looking at a minor upgrade of our RAID +> controller +> > to +> > a 3ware 9000 series (SATA with cache, battery backup optional), and +> > re-configuring it for RAID 10. It's a damn cheap upgrade at around +> $350 +> > and +> > an hour of downtime, so I figure that it's worth it for us to give it +> a +> > shot. +> +> p.s. you can also increase cache efficiency by reducing database size, +> for example use int2/int4 vs. numerics. +> + +I've gone through and optimized data types as much as possible. I'll see +what else we can do w/o causing downtime once PG 8 is ready to go and we can +change data types on the fly. + +Thanks, + +Jason + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 18:31:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A5CB514B2827 + for ; + Wed, 11 Aug 2004 18:31:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75836-01 + for ; + Wed, 11 Aug 2004 21:31:50 +0000 (GMT) +Received: from homer.berkhirt.com (homer.berkhirt.com [207.88.49.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A50F14B2825 + for ; + Wed, 11 Aug 2004 18:31:47 -0300 (ADT) +Received: from [10.10.11.3] (homer [127.0.0.1]) (authenticated bits=0) + by homer.berkhirt.com (8.12.10/8.12.10) with ESMTP id i7BLVhjO032511; + Wed, 11 Aug 2004 16:31:44 -0500 +In-Reply-To: <200408112118.i7BLIR0E097522@mail.gotfrag.com> +References: <200408112118.i7BLIR0E097522@mail.gotfrag.com> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: "'Postgresql Performance'" +From: Brian Hirt +Subject: Re: Hardware upgrade for a high-traffic database +Date: Wed, 11 Aug 2004 15:31:48 -0600 +To: "Jason Coene" +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/169 +X-Sequence-Number: 7805 + + +On Aug 11, 2004, at 3:18 PM, Jason Coene wrote: +> +> I'm wondering why our PG server is using so little memory... The +> system has +> 2GB of memory, though only around 200MB of it are used. Is there a PG +> setting to force more memory usage towards the cache? Additionally, +> we use +> FreeBSD. I've heard that Linux may manage that memory better, any +> truth +> there? Sorry if I'm grabbing at straws here :) +> + +i don't know about freebsd, but linux is very aggressive about using +unused memory for disk cache. we have dedicated linux box running pg +with 2gb of memory, about 250mb of memory is being used by processes +(system+postgres) and shared memory (postgres only), and there is +1.75gb of disk buffers in use in the kernel. this particular database +is only about 4gb, so a good portion of the db resides in memory, +certainly most of the active set. the disk subsystem is a 6 disk scsi +u160 raid array which performs pretty well when there is io. + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 18:46:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 79BBC14B280B + for ; + Wed, 11 Aug 2004 18:46:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78801-06 + for ; + Wed, 11 Aug 2004 21:46:25 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 99BB414B2800 + for ; + Wed, 11 Aug 2004 18:46:23 -0300 (ADT) +Received: from [134.22.70.202] (dyn-70-202.tor.dsl.tht.net [134.22.70.202]) + by tht.net (Postfix) with ESMTP + id 68C0076A09; Wed, 11 Aug 2004 17:46:30 -0400 (EDT) +Subject: Re: Hardware upgrade for a high-traffic database +From: Rod Taylor +To: Jason Coene +Cc: 'Merlin Moncure' , + Postgresql Performance +In-Reply-To: <200408112118.i7BLIR0E097522@mail.gotfrag.com> +References: <200408112118.i7BLIR0E097522@mail.gotfrag.com> +Content-Type: text/plain +Message-Id: <1092260783.16087.96.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 11 Aug 2004 17:46:24 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/170 +X-Sequence-Number: 7806 + +> I'm wondering why our PG server is using so little memory... The system has +> 2GB of memory, though only around 200MB of it are used. Is there a PG + +This is the second time you've said this. Surely you're not implying +there is 1.8GB Free Memory -- rather than 1.8GB in Buffers or Cache. + +Send output of the below: + +sysctl vm + +sysctl -a | grep buffers + +top | grep -E "(Mem|Swap):" + + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 18:52:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CBFC614B2800 + for ; + Wed, 11 Aug 2004 18:52:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79110-05 + for ; + Wed, 11 Aug 2004 21:51:59 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2652614B280B + for ; + Wed, 11 Aug 2004 18:51:58 -0300 (ADT) +Received: from [134.22.70.202] (dyn-70-202.tor.dsl.tht.net [134.22.70.202]) + by tht.net (Postfix) with ESMTP + id 0DDBD76A5E; Wed, 11 Aug 2004 17:50:15 -0400 (EDT) +Subject: Re: Hardware upgrade for a high-traffic database +From: Rod Taylor +To: Brian Hirt +Cc: Jason Coene , + 'Postgresql Performance' +In-Reply-To: +References: <200408112118.i7BLIR0E097522@mail.gotfrag.com> + +Content-Type: text/plain +Message-Id: <1092261009.16087.101.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 11 Aug 2004 17:50:10 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/171 +X-Sequence-Number: 7807 + +On Wed, 2004-08-11 at 17:31, Brian Hirt wrote: +> On Aug 11, 2004, at 3:18 PM, Jason Coene wrote: +> > +> > I'm wondering why our PG server is using so little memory... The +> > system has +> > 2GB of memory, though only around 200MB of it are used. Is there a PG +> > setting to force more memory usage towards the cache? Additionally, +> > we use +> > FreeBSD. I've heard that Linux may manage that memory better, any +> > truth +> > there? Sorry if I'm grabbing at straws here :) +> > +> +> i don't know about freebsd, but linux is very aggressive about using +> unused memory for disk cache. we have dedicated linux box running pg + +Aggressive indeed.. I'm stuck with the version that has a tendency to +swap out active processes rather than abandon disk cache -- it gets very +annoying! + + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 19:03:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C51E14B2824 + for ; + Wed, 11 Aug 2004 19:03:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82611-06 + for ; + Wed, 11 Aug 2004 22:03:40 +0000 (GMT) +Received: from mail.gotfrag.com (g01.gotfrag.com [66.208.110.11]) + by svr1.postgresql.org (Postfix) with ESMTP id BD91114B2800 + for ; + Wed, 11 Aug 2004 19:03:38 -0300 (ADT) +Received: from jcoene2 (roc-66-66-149-175.rochester.rr.com [66.66.149.175]) + by mail.gotfrag.com (8.12.10/8.12.8) with ESMTP id i7BM3d0E098570; + Wed, 11 Aug 2004 18:03:39 -0400 (EDT) + (envelope-from jcoene@gotfrag.com) +Message-Id: <200408112203.i7BM3d0E098570@mail.gotfrag.com> +From: "Jason Coene" +To: "'Rod Taylor'" , + "'Merlin Moncure'" +Cc: "'Postgresql Performance'" +Subject: Re: Hardware upgrade for a high-traffic database +Date: Wed, 11 Aug 2004 18:03:40 -0400 +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.2096 +Thread-Index: AcR/7Km97XlqC9A3TCSRxYwyPFLXpwAAW9eQ +In-Reply-To: <1092260783.16087.96.camel@jester> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/172 +X-Sequence-Number: 7808 + +> -----Original Message----- +> From: Rod Taylor [mailto:pg@rbt.ca] +> Sent: Wednesday, August 11, 2004 5:46 PM +> To: Jason Coene +> Cc: 'Merlin Moncure'; Postgresql Performance +> Subject: Re: [PERFORM] Hardware upgrade for a high-traffic database +> +> > I'm wondering why our PG server is using so little memory... The system +> has +> > 2GB of memory, though only around 200MB of it are used. Is there a PG +> +> This is the second time you've said this. Surely you're not implying +> there is 1.8GB Free Memory -- rather than 1.8GB in Buffers or Cache. + +Hi Rod, + +I was looking at top and vmstat - which always show under 300MB "Active". +We may hit 400MB at peak. Everything I see (though this isn't my area of +expertise) points to most of the memory simply being unused. Results below, +am I missing something? + +Jason + +> +> Send output of the below: +> +> sysctl vm + +d01> sysctl vm +vm.vmtotal: +System wide totals computed every five seconds: (values in kilobytes) +=============================================== +Processes: (RUNQ: 1 Disk Wait: 0 Page Wait: 0 Sleep: 149) +Virtual Memory: (Total: 2101614K, Active 440212K) +Real Memory: (Total: 2023532K Active 327032K) +Shared Virtual Memory: (Total: 14356K Active: 3788K) +Shared Real Memory: (Total: 4236K Active: 2456K) +Free Memory Pages: 88824K + +vm.loadavg: { 0.46 0.41 0.42 } +vm.v_free_min: 3312 +vm.v_free_target: 13997 +vm.v_free_reserved: 749 +vm.v_inactive_target: 20995 +vm.v_cache_min: 13997 +vm.v_cache_max: 27994 +vm.v_pageout_free_min: 34 +vm.pageout_algorithm: 0 +vm.swap_enabled: 1 +vm.swap_async_max: 4 +vm.dmmax: 32 +vm.nswapdev: 1 +vm.swap_idle_threshold1: 2 +vm.swap_idle_threshold2: 10 +vm.v_free_severe: 2030 +vm.stats.sys.v_swtch: 627853362 +vm.stats.sys.v_trap: 3622664114 +vm.stats.sys.v_syscall: 1638589210 +vm.stats.sys.v_intr: 3250875036 +vm.stats.sys.v_soft: 1930666043 +vm.stats.vm.v_vm_faults: 3197534554 +vm.stats.vm.v_cow_faults: 2999625102 +vm.stats.vm.v_cow_optim: 10093309 +vm.stats.vm.v_zfod: 3603956919 +vm.stats.vm.v_ozfod: 3104475907 +vm.stats.vm.v_swapin: 3353 +vm.stats.vm.v_swapout: 3382 +vm.stats.vm.v_swappgsin: 3792 +vm.stats.vm.v_swappgsout: 7213 +vm.stats.vm.v_vnodein: 14675 +vm.stats.vm.v_vnodeout: 140671 +vm.stats.vm.v_vnodepgsin: 24330 +vm.stats.vm.v_vnodepgsout: 245840 +vm.stats.vm.v_intrans: 3643 +vm.stats.vm.v_reactivated: 35038 +vm.stats.vm.v_pdwakeups: 26984 +vm.stats.vm.v_pdpages: 335769007 +vm.stats.vm.v_dfree: 8 +vm.stats.vm.v_pfree: 1507856856 +vm.stats.vm.v_tfree: 430723755 +vm.stats.vm.v_page_size: 4096 +vm.stats.vm.v_page_count: 512831 +vm.stats.vm.v_free_reserved: 749 +vm.stats.vm.v_free_target: 13997 +vm.stats.vm.v_free_min: 3312 +vm.stats.vm.v_free_count: 968 +vm.stats.vm.v_wire_count: 62039 +vm.stats.vm.v_active_count: 44233 +vm.stats.vm.v_inactive_target: 20995 +vm.stats.vm.v_inactive_count: 343621 +vm.stats.vm.v_cache_count: 21237 +vm.stats.vm.v_cache_min: 13997 +vm.stats.vm.v_cache_max: 27994 +vm.stats.vm.v_pageout_free_min: 34 +vm.stats.vm.v_interrupt_free_min: 2 +vm.stats.vm.v_forks: 45205536 +vm.stats.vm.v_vforks: 74315 +vm.stats.vm.v_rforks: 0 +vm.stats.vm.v_kthreads: 2416 +vm.stats.vm.v_forkpages: 1464383994 +vm.stats.vm.v_vforkpages: 4259727 +vm.stats.vm.v_rforkpages: 0 +vm.stats.vm.v_kthreadpages: 0 +vm.stats.misc.zero_page_count: 709 +vm.stats.misc.cnt_prezero: -972664922 +vm.max_proc_mmap: 34952 +vm.msync_flush_flags: 3 +vm.idlezero_enable: 1 +vm.idlezero_maxrun: 16 +vm.max_launder: 32 +vm.pageout_stats_max: 13997 +vm.pageout_full_stats_interval: 20 +vm.pageout_stats_interval: 5 +vm.pageout_stats_free_max: 5 +vm.swap_idle_enabled: 0 +vm.defer_swapspace_pageouts: 0 +vm.disable_swapspace_pageouts: 0 +vm.pageout_lock_miss: 0 +vm.zone: +ITEM SIZE LIMIT USED FREE REQUESTS + +FFS2 dinode: 256, 0, 30156, 4389, 20093512 +FFS1 dinode: 128, 0, 0, 0, 0 +FFS inode: 140, 0, 30156, 4340, 20093512 +SWAPMETA: 276, 121576, 16, 264, 44599 +ripcb: 180, 32780, 0, 132, 289 +hostcache: 88, 15390, 6, 309, 741 +syncache: 104, 15390, 0, 418, 44592418 +tcptw: 56, 6603, 3, 1204, 224900 +tcpcb: 368, 32769, 136, 4264, 44594153 +inpcb: 180, 32780, 139, 4437, 44594153 +udpcb: 180, 32780, 10, 144, 85953 +unpcb: 140, 32788, 6, 246, 143982 +socket: 240, 32768, 152, 4248, 44824378 +KNOTE: 64, 0, 0, 434, 7561 +PIPE: 172, 0, 8, 222, 352848 +NFSNODE: 460, 0, 1596, 92, 2419 +NFSMOUNT: 424, 0, 1, 17, 1 +DIRHASH: 1024, 0, 238, 86, 287 +L VFS Cache: 291, 0, 165, 160, 11956 +S VFS Cache: 68, 0, 38283, 3430, 3795133 +NAMEI: 1024, 0, 0, 240, 907013101 +VNODEPOLL: 60, 0, 1, 131, 2 +VNODE: 260, 0, 34104, 36, 34104 +g_bio: 136, 0, 0, 5887, 551700514 +VMSPACE: 236, 0, 152, 987, 45279840 +UPCALL: 44, 0, 0, 0, 0 +KSE: 64, 0, 1224, 202, 1224 +KSEGRP: 120, 0, 1224, 109, 1224 +THREAD: 312, 0, 1224, 84, 1224 +PROC: 452, 0, 261, 963, 45282231 +Files: 68, 0, 782, 5413, 719968279 +4096: 4096, 0, 441, 1935, 90066743 +2048: 2048, 0, 237, 423, 25077 +1024: 1024, 0, 23, 157, 448114 +512: 512, 0, 108, 140, 770519 +256: 256, 0, 458, 1102, 70685682 +128: 128, 0, 1904, 1041, 186085712 +64: 64, 0, 5124, 13042, 1404464781 +32: 32, 0, 1281, 1302, 839881182 +16: 16, 0, 842, 1548, 1712031683 +DP fakepg: 72, 0, 0, 0, 0 +PV ENTRY: 28, 2166780, 157829, 769251, 56650653911 +MAP ENTRY: 60, 0, 6716, 33280, 2270740046 +KMAP ENTRY: 60, 65538, 24, 702, 152938 +MAP: 160, 0, 9, 41, 2 +VM OBJECT: 132, 0, 21596, 10654, 1136467083 +128 Bucket: 524, 0, 3115, 0, 0 +64 Bucket: 268, 0, 200, 10, 0 +32 Bucket: 140, 0, 191, 5, 0 +16 Bucket: 76, 0, 49, 3, 0 +UMA Hash: 128, 0, 0, 31, 0 +UMA Slabs: 34, 0, 3095, 95, 0 +UMA Zones: 432, 0, 52, 2, 0 + +vm.kvm_size: 1069543424 +vm.kvm_free: 364900352 + +> +> sysctl -a | grep buffers + +d01 > sysctl -a | grep buffers +vfs.numdirtybuffers: 52 +vfs.lodirtybuffers: 909 +vfs.hidirtybuffers: 1819 +vfs.numfreebuffers: 7146 +vfs.lofreebuffers: 404 +vfs.hifreebuffers: 808 +> +> top | grep -E "(Mem|Swap):" +> + +d01 > top | grep -E "(Mem|Swap):" +Mem: 173M Active, 1346M Inact, 242M Wired, 77M Cache, 112M Buf, 5784K Free +Swap: 4096M Total, 124K Used, 4096M Free + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 19:26:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3EABE14B2825 + for ; + Wed, 11 Aug 2004 19:26:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 90274-10 + for ; + Wed, 11 Aug 2004 22:26:43 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3FF0414B2804 + for ; + Wed, 11 Aug 2004 19:26:39 -0300 (ADT) +Received: from [134.22.70.202] (dyn-70-202.tor.dsl.tht.net [134.22.70.202]) + by tht.net (Postfix) with ESMTP + id 3370376A61; Wed, 11 Aug 2004 18:26:47 -0400 (EDT) +Subject: Re: Hardware upgrade for a high-traffic database +From: Rod Taylor +To: Jason Coene +Cc: 'Merlin Moncure' , + 'Postgresql Performance' +In-Reply-To: <200408112203.i7BM3d0E098570@mail.gotfrag.com> +References: <200408112203.i7BM3d0E098570@mail.gotfrag.com> +Content-Type: text/plain +Message-Id: <1092263200.16087.121.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 11 Aug 2004 18:26:41 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/173 +X-Sequence-Number: 7809 + +On Wed, 2004-08-11 at 18:03, Jason Coene wrote: +> > -----Original Message----- +> > From: Rod Taylor [mailto:pg@rbt.ca] +> > Sent: Wednesday, August 11, 2004 5:46 PM +> > To: Jason Coene +> > Cc: 'Merlin Moncure'; Postgresql Performance +> > Subject: Re: [PERFORM] Hardware upgrade for a high-traffic database +> > +> > > I'm wondering why our PG server is using so little memory... The system +> > has +> > > 2GB of memory, though only around 200MB of it are used. Is there a PG +> > +> > This is the second time you've said this. Surely you're not implying +> > there is 1.8GB Free Memory -- rather than 1.8GB in Buffers or Cache. +> +> Hi Rod, +> +> I was looking at top and vmstat - which always show under 300MB "Active". +> We may hit 400MB at peak. Everything I see (though this isn't my area of +> expertise) points to most of the memory simply being unused. Results below, +> am I missing something? + +This looks fine. The memory is not unused (only 5MB is actually empty) +but is being used for disk cache. + +Active is memory used by programs and would need to be swapped if this +space was needed. + +Inactive is memory that is generally dirty. Disk cache is often here. In +your case, you likely write to the same pages you're reading from -- +which is why this number is so big. It also explains why a checkpoint is +a killer; a large chunk of this memory set needs to be pushed to disk. + +Cache is memory used generally for disk cache that is not dirty. It's +been read from the disk and could be cleared immediately if necessary. + +Wired is memory that cannot be swapped. In your case, Shared Memory is +probably Wired (this is good). There is another sysctl to check and set +whether it is wired or swappable. + + + +Interesting (if dry) read: +http://www.freebsd.org/doc/en_US.ISO8859-1/articles/vm-design/index.html + + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 19:57:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 472DB14B2878 + for ; + Wed, 11 Aug 2004 19:54:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97747-07 + for ; + Wed, 11 Aug 2004 22:53:55 +0000 (GMT) +Received: from mail.gotfrag.com (g01.gotfrag.com [66.208.110.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B1C614B2824 + for ; + Wed, 11 Aug 2004 19:53:52 -0300 (ADT) +Received: from jcoene2 (roc-66-66-149-175.rochester.rr.com [66.66.149.175]) + by mail.gotfrag.com (8.12.10/8.12.8) with ESMTP id i7BMrp0E099853; + Wed, 11 Aug 2004 18:53:52 -0400 (EDT) + (envelope-from jcoene@gotfrag.com) +Message-Id: <200408112253.i7BMrp0E099853@mail.gotfrag.com> +From: "Jason Coene" +To: "'Rod Taylor'" +Cc: "'Merlin Moncure'" , + "'Postgresql Performance'" +Subject: Re: Hardware upgrade for a high-traffic database +Date: Wed, 11 Aug 2004 18:53:52 -0400 +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.2096 +Thread-Index: AcR/8kdnAnsjD+GnRdWhW3jSxkDrgwAAGdOA +In-Reply-To: <1092263200.16087.121.camel@jester> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/174 +X-Sequence-Number: 7810 + +> > Hi Rod, +> > +> > I was looking at top and vmstat - which always show under 300MB +> "Active". +> > We may hit 400MB at peak. Everything I see (though this isn't my area +> of +> > expertise) points to most of the memory simply being unused. Results +> below, +> > am I missing something? +> +> This looks fine. The memory is not unused (only 5MB is actually empty) +> but is being used for disk cache. +> +> Active is memory used by programs and would need to be swapped if this +> space was needed. +> +> Inactive is memory that is generally dirty. Disk cache is often here. In +> your case, you likely write to the same pages you're reading from -- +> which is why this number is so big. It also explains why a checkpoint is +> a killer; a large chunk of this memory set needs to be pushed to disk. +> +> Cache is memory used generally for disk cache that is not dirty. It's +> been read from the disk and could be cleared immediately if necessary. +> +> Wired is memory that cannot be swapped. In your case, Shared Memory is +> probably Wired (this is good). There is another sysctl to check and set +> whether it is wired or swappable. +> +> +> +> Interesting (if dry) read: +> http://www.freebsd.org/doc/en_US.ISO8859-1/articles/vm-design/index.html +> + +Ah, thanks - I didn't know that Inactive was still being used. I'm glad to +know that at least the OS is using up the free memory for disk cache. +Shared memory is Wired, set via sysctl. Thanks for the info! It sounds +like adding more memory would help cache more data - I'll look into the +upgrade. + +Jason + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 20:20:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E1DA614B2869 + for ; + Wed, 11 Aug 2004 20:20:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06433-05 + for ; + Wed, 11 Aug 2004 23:20: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 748F314B2866 + for ; + Wed, 11 Aug 2004 20:20:04 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7BNK5bj021683; + Wed, 11 Aug 2004 19:20:05 -0400 (EDT) +To: "Jason Coene" +Cc: "'Merlin Moncure'" , + pgsql-performance@postgresql.org +Subject: Re: Hardware upgrade for a high-traffic database +In-reply-to: <200408112118.i7BLIR0E097522@mail.gotfrag.com> +References: <200408112118.i7BLIR0E097522@mail.gotfrag.com> +Comments: In-reply-to "Jason Coene" + message dated "Wed, 11 Aug 2004 17:18:27 -0400" +Date: Wed, 11 Aug 2004 19:20:04 -0400 +Message-ID: <21682.1092266404@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/175 +X-Sequence-Number: 7811 + +"Jason Coene" writes: +> A good example, a comments table where users submit TEXT data. A common +> query is to find the last 5 comments a user has submitted. The scan, while +> using an index, takes a considerable amount of time (> 0.5 sec is about as +> good as it gets). Again, it's using an index on the single WHERE clause +> (userid = int). The field that's used to ORDER BY (timestamp) is also +> indexed. + +You mean you are doing + SELECT ... WHERE userid = 42 ORDER BY timestamp DESC LIMIT 5; +and hoping that separate indexes on userid and timestamp will get the +job done? They won't. There are only two possible plans for this, +neither very good: select all of user 42's posts and sort them, or +scan timewise backwards through *all* posts looking for the last 5 from +user 42. + +If you do this enough to justify a specialized index, I would suggest a +two-column index on (userid, timestamp). You will also need to tweak +the query, because the planner is not quite smart enough to deduce that +such an index is applicable to the given sort order: + SELECT ... WHERE userid = 42 ORDER BY userid DESC, timestamp DESC LIMIT 5; +This should generate an index-scan-backwards plan that will execute nigh +instantaneously, because it will only fetch the rows you really want. + +You might or might not be able to drop the separate indexes on userid +and timestamp, depending on what other queries you might have that need +them. But you should be paying attention to what plans you are really +getting (see EXPLAIN) rather than just assuming that some indexes chosen +at random will do what you need. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Aug 11 20:58:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EB55714B281F + for ; + Wed, 11 Aug 2004 20:46:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24965-03 + for ; + Wed, 11 Aug 2004 23:46:12 +0000 (GMT) +Received: from mail.pws.com.au (mail.pws.com.au [210.23.138.139]) + by svr1.postgresql.org (Postfix) with SMTP id 96EA414B2827 + for ; + Wed, 11 Aug 2004 20:46:10 -0300 (ADT) +Received: (qmail 2630 invoked by uid 0); 12 Aug 2004 09:46:11 +1000 +Received: from cpe-203-45-44-212.vic.bigpond.net.au (HELO wizzard.pws.com.au) + (russell@pws.com.au@203.45.44.212) + by mail.pws.com.au with SMTP; 12 Aug 2004 09:46:11 +1000 +From: Russell Smith +To: pgsql-performance@postgresql.org +Subject: Re: Storing binary data. +Date: Thu, 12 Aug 2004 09:44:56 +1000 +User-Agent: KMail/1.6.1 +References: + <200408112042.50356.shridhar@frodo.hserus.net> + +In-Reply-To: +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200408120944.56155.mr-russ@pws.com.au> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/177 +X-Sequence-Number: 7813 + +On Thu, 12 Aug 2004 02:29 am, Jesper Krogh wrote: +> I gmane.comp.db.postgresql.performance, skrev Shridhar Daithankar: +> > On Wednesday 11 Aug 2004 7:59 pm, Jesper Krogh wrote: +> > > The "common" solution, I guess would be to store them in the filesystem +> > > instead, but I like to have them just in the database it is nice clean +> > > database and application design and if I can get PostgreSQL to "not +> > > cache" them then it should be excactly as fast i assume. +> > +> > You can normalize them so that a table contains an id and a bytea column only. +> > Te main table will contain all the other attributes and a mapping id. That +> > way you will have only the main table cached. +> > +> > You don't have to go to filesystem for this, I hope. +> +> Further benchmarking. +> +> I tried to create a table with the excact same attributes but without +> the binary attribute. It didn't change anything, so my idea that it +> should be the binary-stuff that sloved it down was wrong. +> +> I have a timestamp column in the table that I sort on. Data is ordered +> over the last 4 years and I select based on a timerange, I cannot make +> the query-planner use the index on the timestamp by itself but if I "set +> enable_seqscan = false" the query time drops by 1/3 (from 1.200 msec to +> about 400 msec). +> +> I cannot figure out why the query-planner chooses wrong. +> NB: It's postgresql 7.4.3 +> +Please post explain analyze of the query. + +I would guess you are using now() is your query, which is not optimized perfectly +by the planner, so you end up with problems. But if you post explain analyze +people will be able to tell you what the problem is. + +Maybe on with seqscan on, and one with it off. + +Regards + +Russell Smith + +From pgsql-performance-owner@postgresql.org Wed Aug 11 20:56:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5358A14B281F + for ; + Wed, 11 Aug 2004 20:53:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28089-01 + for ; + Wed, 11 Aug 2004 23:53:34 +0000 (GMT) +Received: from mail.pws.com.au (mail.pws.com.au [210.23.138.139]) + by svr1.postgresql.org (Postfix) with SMTP id 16C7C14B2824 + for ; + Wed, 11 Aug 2004 20:53:32 -0300 (ADT) +Received: (qmail 2818 invoked by uid 0); 12 Aug 2004 09:53:35 +1000 +Received: from cpe-203-45-44-212.vic.bigpond.net.au (HELO wizzard.pws.com.au) + (russell@pws.com.au@203.45.44.212) + by mail.pws.com.au with SMTP; 12 Aug 2004 09:53:35 +1000 +From: Russell Smith +To: pgsql-performance@postgresql.org +Subject: Re: Hardware upgrade for a high-traffic database +Date: Thu, 12 Aug 2004 09:52:20 +1000 +User-Agent: KMail/1.6.1 +References: <200408111908.i7BJ8m0E094620@mail.gotfrag.com> +In-Reply-To: <200408111908.i7BJ8m0E094620@mail.gotfrag.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200408120952.20352.mr-russ@pws.com.au> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/176 +X-Sequence-Number: 7812 + +[snip] +> +> One question I do have though - you specifically mentioned NOW() as +> something to watch out for, in that it's mutable. We typically use COUNT() +> as a subselect to retrieve the number of associated rows to the current +> query. Additionally, we use NOW a lot, primarily to detect the status of a +> date, i.e.: +> +> SELECT id FROM subscriptions WHERE userid = 11111 AND timeend > NOW(); +> +> Is there a better way to do this? I was under the impression that NOW() was +> pretty harmless, just to return a current timestamp. +> +NOW() will trigger unnessecary sequence scans. As it is unknown with prepared +query and function when the statement is run, the planner plans the query with +now as a variable. This can push the planner to a seq scan over and index scan. +I have seen this time and time again. + +You can create your own immutable now, but don't use it in functions or prepared queries +or you will get wrong results. + +> Based on feedback, I'm looking at a minor upgrade of our RAID controller to +> a 3ware 9000 series (SATA with cache, battery backup optional), and +> re-configuring it for RAID 10. It's a damn cheap upgrade at around $350 and +> an hour of downtime, so I figure that it's worth it for us to give it a +> shot. +> +> Thanks, +> +> Jason + +Russell Smith + +From pgsql-performance-owner@postgresql.org Wed Aug 11 21:04:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FBBB14B281B + for ; + Wed, 11 Aug 2004 21:02:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29513-05 + for ; + Thu, 12 Aug 2004 00:02:24 +0000 (GMT) +Received: from diablo.OntheNet.com.au (diablo.OntheNet.com.au [203.10.89.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 479A214B281A + for ; + Wed, 11 Aug 2004 21:02:21 -0300 (ADT) +Received: from [192.168.0.114] (imp3.dsl.onthenet.net [203.144.21.139]) + by diablo.OntheNet.com.au (8.12.10/8.12.10) with ESMTP id + i7C02J4G037635 for ; + Thu, 12 Aug 2004 10:02:21 +1000 (EST) +Message-ID: <411AB302.809@wildcash.com> +Date: Thu, 12 Aug 2004 10:00:02 +1000 +From: Rudi Starcevic +Reply-To: tech@wildcash.com +Organization: Internet Media Productions +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7) Gecko/20040616 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Buld Insert and Index use. +X-Enigmail-Version: 0.85.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/178 +X-Sequence-Number: 7814 + +Hi, + +This email is picking up a thread from yesterday on INSERTS and INDEXES. + +In this case the question is to use and index or a sequential scan. + +I have included the db DDL and SELECT query. + +For each month I have a csv data dump of council property data. + +So the First CD will have almost all unique records. + From there most properties will already be in the db. + +Each line of the csv file populates three tables. + +gc_prop +gc_value +gc_owner + +gc_prop has a one to many relationship with gc_value and gc_owner. + +For-each line we first SELECT from the gc_prop table. +If there is no record we INSERT into the gc_prop,gc_value and gc_owner +tables. + +If there is a matching property we do not need to INSERT into the +gc_prop table only the gc_value and gc_owner tables. + +So each row will require either: + +a) One SELECT + three INSERTS +or +b) One SELECT + two INSERTS + +CREATE TABLE gc_prop +( +gc_id serial PRIMARY KEY, +acc_no numeric(9,0), +master_code varchar(32), +no_prop numeric(4,0), +lot_no numeric(9,0), +plan_no varchar(32), +volume_no numeric(8,0), +folio_no numeric(8,0), +street_no varchar(32), +street_name varchar(30), +suburb_name varchar(30), +suburb_postcode numeric(4,0), +address1_txt varchar(80), +address2_txt varchar(80), +address3_txt varchar(80), +address4_txt varchar(80), +address5_txt varchar(80), +address6_txt varchar(80), +owner_postcode text, +planning_zone varchar(80), +waterfront_code varchar(80), +vacant_land varchar(32), +property_area text, +improvemeny_type varchar(20), +bup_indicator varchar(4), +property_name varchar(30), +lot_quantity text, +pool_indicator varchar(32), +owner_occupied varchar(32), +prsh_text varchar(30), +vg_no varchar(20), +property_part varchar(20), +lot_no_txt varchar(32), +plan_qualifier1 varchar(80), +plan_qualifier2 varchar(80), +owner_trans_date date, +legal_entity varchar(32), +"1st_surname_com" varchar(80), +"1st_given_name" varchar(64), +"2nd_surname" varchar(64), +"2nd_given_name" varchar(64), +easement_flag varchar(32), +trans_code varchar(32) +); + +CREATE TABLE gc_value +( +gc_v_id serial PRIMARY KEY, +gc_id integer NOT NULL, -- foreign key to gc_prop table +current_valuation numeric(10,0), +valuation_date date, +last_sale_date date, +annual_rates numeric(7,0), +sale_amount numeric(9,0), +type_sale varchar(32), +date_sale date, +pre_val_date date, +pre_val_amount numeric(10,0), +pre_vg_no varchar(20), +future_val_date varchar(32), +fut_val_amount numeric(10,0), +fut_val_no varchar(32) +); + +CREATE TABLE gc_owner +( +gc_o_id serial PRIMARY KEY, +gc_id integer NOT NULL, -- foreign key to gc_prop table +pre_legal_entity varchar(32), +pre_surname_com varchar(76), +pre_given_name varchar(32), +pre_2nd_surname varchar(40), +pre_2nd_given varchar(32), +orig_lot_no numeric(9,0), +orig_lot_txt varchar(32), +orig_prop_txt text, +orig_plan_qualifier1 varchar(32), +orig_plan_qualifier2 varchar(32), +orig_plan_no varchar(32) +); + +CREATE INDEX gc_prop_check ON gc_prop ( +acc_no,no_prop,lot_no,plan_no,street_no,street_name,suburb_postcode ); + +//check if this property already exists using gc_prop_check index +$sql = " +SELECT +gp.gc_id, +gp.acc_no, +gp.no_prop, +gp.lot_no, +gp.plan_no, +gp.street_no, +gp.street_name, +gp.suburb_postcode, +gp.owner_trans_date +FROM gc_prop gp +WHERE +gp.acc_no = $acc_no, +AND +gp.no_prop = $no_prop, +AND +gp.lot_no = $lot_no +AND +gp.plan_no = '$plan_no' +AND +gp.street_no = '$street_no' +AND +gp.street_name = '$street_name' +AND +gp.suburb_postcode = $suburb_postcode +"; + +Do you think an Index or Seq. scan should be used? + +Thanks. +Regards, +Rudi. + +From pgsql-performance-owner@postgresql.org Wed Aug 11 21:12:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8161C14B280B + for ; + Wed, 11 Aug 2004 21:07:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31167-07 + for ; + Thu, 12 Aug 2004 00:07: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 C1C9814B2824 + for ; + Wed, 11 Aug 2004 21:07:38 -0300 (ADT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i7C06we19437; + Thu, 12 Aug 2004 02:06:59 +0200 +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 i7C07TZ13603; + Thu, 12 Aug 2004 02:07:29 +0200 +Message-ID: <411AB487.1070703@bigfoot.com> +Date: Thu, 12 Aug 2004 02:06:31 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql@mohawksoft.com, + "pgsql-performance@postgresql.org" +Subject: Re: [HACKERS] fsync vs open_sync +References: <6EE64EF3AB31D5448D0007DD34EEB3412A7446@Herge.rcsinc.local> + <15691.64.119.142.34.1092153268.squirrel@mail.mohawksoft.com> +In-Reply-To: <15691.64.119.142.34.1092153268.squirrel@mail.mohawksoft.com> +X-Enigmail-Version: 0.84.2.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/179 +X-Sequence-Number: 7815 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +pgsql@mohawksoft.com wrote: +|>>Anyway, with fsync enabled using standard fsync(), I get roughly +|> +|>300-400 +|> +|>>inserts per second. With fsync disabled, I get about 7000 inserts per +|>>second. When I re-enable fsync but use the open_sync option, I can get +|>>about 2500 inserts per second. +|> +|>You are getting 300-400 inserts/sec with fsync on? If you don't mind me +|>asking, what's your hardware? (also, have you checked fsync on #s with +|>the new bgwriter in 7.5?) +|> +| +| +| 300 inserts persecond with fsync on using fdatasync. 2500 inserts per +| second with fsync on using open_sync. +| +| [mwoodward@penguin-021 mwoodward]$ cat /proc/cpuinfo +| processor : 0 +| vendor_id : GenuineIntel +| cpu family : 15 +| model : 2 +| model name : Intel(R) Xeon(TM) CPU 2.40GHz +| stepping : 5 +| cpu MHz : 2399.373 +| cache size : 512 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 pae mce cx8 apic sep mtrr pge mca +| cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid +| bogomips : 4784.12 +| +| Linux node1 2.4.25 #1 Mon Mar 22 13:33:41 EST 2004 i686 i686 i386 GNU/Linux +| +| ide2: BM-DMA at 0xc400-0xc407, BIOS settings: hde:pio, hdf:pio +| hde: Maxtor 6Y200P0, ATA DISK drive +| hde: attached ide-disk driver. +| hde: host protected area => 1 +| hde: 398297088 sectors (203928 MB) w/7936KiB Cache, CHS=24792/255/63, +| UDMA(100) +| +| PDC20268: IDE controller at PCI slot 06:05.0 + + +I did some experiments too: + +inserting 10000 rows in a table with an integer column: + +fsync=false ====> ~7.5 secs 1300 insert/sec + +wal_sync_method=fsync ====> ~15.5 secs 645 insert/sec +wal_sync_method=fdatasync ====> ~15.5 secs 645 insert/sec +wal_sync_method=open_sync ====> ~10.0 secs 1000 insert/sec +wal_sync_method=open_datasync ====> + + + + + +Test bed: Postgresql 8.0beta1, linux kernel 2.4.22, +~ hda: IC35L060AVVA07-0, ATA DISK drive +~ hda: 120103200 sectors (61493 MB) w/1863KiB Cache, CHS=7476/255/63, UDMA(100) + + +# cat /proc/cpuinfo +processor : 0 +vendor_id : GenuineIntel +cpu family : 6 +model : 8 +model name : Pentium III (Coppermine) +stepping : 6 +cpu MHz : 877.500 +cache size : 256 KB +physical id : 0 +siblings : 1 +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 pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse +runqueue : 0 + +bogomips : 1749.81 + +processor : 1 +vendor_id : GenuineIntel +cpu family : 6 +model : 8 +model name : Pentium III (Coppermine) +stepping : 6 +cpu MHz : 877.500 +cache size : 256 KB +physical id : 0 +siblings : 1 +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 pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse +runqueue : 1 + +bogomips : 1749.81 + + + + +Regards +Gaetano Mendola + + + + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBGrSE7UpzwH2SGd4RAoXnAKCHhuw/pWKgY+OD3JcWYMTPDbmgZwCgyqfT ++OugUEvUF8usYYrWSGDAnn4= +=FAaI +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 21:26:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BAD9414B281C + for ; + Wed, 11 Aug 2004 21:25:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34932-05 + for ; + Thu, 12 Aug 2004 00:25:36 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CCF114B2806 + for ; + Wed, 11 Aug 2004 21:25:33 -0300 (ADT) +Received: from [64.81.245.111] (HELO temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6054861; Wed, 11 Aug 2004 17:26:53 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: tech@wildcash.com, pgsql-performance@postgresql.org +Subject: Re: Buld Insert and Index use. +Date: Wed, 11 Aug 2004 17:25:55 -0700 +User-Agent: KMail/1.5.4 +References: <411AB302.809@wildcash.com> +In-Reply-To: <411AB302.809@wildcash.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200408111725.55270.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/180 +X-Sequence-Number: 7816 + +Rudi, + +> Do you think an Index or Seq. scan should be used? + +That was way too much data for way too simple a question. ;-) +The answer is: depends on how many rows you have. With any significant +number of rows, yes. + +However, you probably only need to index the first 3-5 columns; that's +selective enough. + +-- +-Josh Berkus + "A developer of Very Little Brain" + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 21:29:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F41E114B2820 + for ; + Wed, 11 Aug 2004 21:29:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33426-09 + for ; + Thu, 12 Aug 2004 00:29:01 +0000 (GMT) +Received: from mail.gotfrag.com (g01.gotfrag.com [66.208.110.11]) + by svr1.postgresql.org (Postfix) with ESMTP id DF73214B281C + for ; + Wed, 11 Aug 2004 21:28:59 -0300 (ADT) +Received: from jcoene2 (roc-66-66-149-175.rochester.rr.com [66.66.149.175]) + by mail.gotfrag.com (8.12.10/8.12.8) with ESMTP id i7C0T30E002389; + Wed, 11 Aug 2004 20:29:03 -0400 (EDT) + (envelope-from jcoene@gotfrag.com) +Message-Id: <200408120029.i7C0T30E002389@mail.gotfrag.com> +From: "Jason Coene" +To: "'Tom Lane'" +Cc: "'Merlin Moncure'" , + +Subject: Re: Hardware upgrade for a high-traffic database +Date: Wed, 11 Aug 2004 20:29:04 -0400 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook, Build 11.0.5510 +In-Reply-To: <21682.1092266404@sss.pgh.pa.us> +Thread-Index: AcR/+xk6UgqtdeCcS06Ia+rNDvkG/QABUWLg +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2096 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/181 +X-Sequence-Number: 7817 + +> You mean you are doing +> SELECT ... WHERE userid = 42 ORDER BY timestamp DESC LIMIT 5; +> and hoping that separate indexes on userid and timestamp will get the +> job done? They won't. There are only two possible plans for this, +> neither very good: select all of user 42's posts and sort them, or +> scan timewise backwards through *all* posts looking for the last 5 from +> user 42. + +Wow! I did try the method you state below (including the WHERE restricted +column in the sort by, and creating a two-column index), and it did execute +much faster (even on odd userid's to avoid cached results as much as +possible). + +We have a lot of: + +SELECT whatever + FROM ourtable + WHERE field1 = X + AND field2 = Y + AND field3 = Z + ORDER BY id DESC + LIMIT 5 + +With indexes: + +ourtable(id) +ourtable(field1, field2, field3) + +Is it standard procedure with postgres to include any fields listed in WHERE +in the ORDER BY, and create a single index for only the ORDER BY fields (in +order of appearance, of course)? + +> +> If you do this enough to justify a specialized index, I would suggest a +> two-column index on (userid, timestamp). You will also need to tweak +> the query, because the planner is not quite smart enough to deduce that +> such an index is applicable to the given sort order: +> SELECT ... WHERE userid = 42 ORDER BY userid DESC, timestamp DESC +> LIMIT 5; +> This should generate an index-scan-backwards plan that will execute nigh +> instantaneously, because it will only fetch the rows you really want. +> +> You might or might not be able to drop the separate indexes on userid +> and timestamp, depending on what other queries you might have that need +> them. But you should be paying attention to what plans you are really +> getting (see EXPLAIN) rather than just assuming that some indexes chosen +> at random will do what you need. +> +> regards, tom lane +> + +We do many varied queries on nearly every table - our data is highly +relational, and we have a lot of indexes. I thought the planner would pick +up the right index via constraints and not require them in ORDER BY... +EXPLAIN ANALYZE says that the indexes are being used, ala: + +gf=# EXPLAIN ANALYZE SELECT id FROM comments WHERE userid = 51 ORDER BY +timestamp DESC LIMIT 5; + QUERY PLAN +---------------------------------------------------------------------------- +------------------------------------------------------------------- + Limit (cost=1608.43..1608.45 rows=5 width=8) (actual time=0.292..0.317 +rows=5 loops=1) + -> Sort (cost=1608.43..1609.45 rows=407 width=8) (actual +time=0.287..0.295 rows=5 loops=1) + Sort Key: "timestamp" + -> Index Scan using comments_ix_userid on comments +(cost=0.00..1590.79 rows=407 width=8) (actual time=0.031..0.190 rows=35 +loops=1) + Index Cond: (userid = 51) + Total runtime: 0.375 ms +(6 rows) + +Is this the wrong procedure? Your suggested syntax seems much more +efficient, but I don't quite understand exactly why, as PG is using our +existing indexes... + +gf=# EXPLAIN ANALYZE SELECT id FROM comments WHERE userid = 51 ORDER BY +userid DESC, timestamp DESC LIMIT 5; + +QUERY PLAN +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +---- + Limit (cost=0.00..19.90 rows=5 width=12) (actual time=0.040..0.076 rows=5 +loops=1) + -> Index Scan Backward using comments_ix_userid_timestamp on comments +(cost=0.00..1620.25 rows=407 width=12) (actual time=0.035..0.054 rows=5 +loops=1) + Index Cond: (userid = 51) + Total runtime: 0.134 ms +(4 rows) + +Note: This was done after adding an index on comments (userid, timestamp) + +Regards, + +Jason + + +From pgsql-performance-owner@postgresql.org Wed Aug 11 23:09:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D2EE14B2824 + for ; + Wed, 11 Aug 2004 23:09:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43278-09 + for ; + Thu, 12 Aug 2004 02:09: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 8138914B27FF + for ; + Wed, 11 Aug 2004 23:09:10 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7C29EUa023020; + Wed, 11 Aug 2004 22:09:15 -0400 (EDT) +To: "Jason Coene" +Cc: "'Merlin Moncure'" , + pgsql-performance@postgresql.org +Subject: Re: Hardware upgrade for a high-traffic database +In-reply-to: <200408120029.i7C0T30E002389@mail.gotfrag.com> +References: <200408120029.i7C0T30E002389@mail.gotfrag.com> +Comments: In-reply-to "Jason Coene" + message dated "Wed, 11 Aug 2004 20:29:04 -0400" +Date: Wed, 11 Aug 2004 22:09:14 -0400 +Message-ID: <23019.1092276554@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/182 +X-Sequence-Number: 7818 + +"Jason Coene" writes: +> We have a lot of: + +> SELECT whatever +> FROM ourtable +> WHERE field1 = X +> AND field2 = Y +> AND field3 = Z +> ORDER BY id DESC +> LIMIT 5 + +> With indexes: + +> ourtable(id) +> ourtable(field1, field2, field3) + +> Is it standard procedure with postgres to include any fields listed in WHERE +> in the ORDER BY, and create a single index for only the ORDER BY fields (in +> order of appearance, of course)? + +It depends. If the X/Y/Z constraint is already pretty selective, then +it seems sufficient to me to pick up the matching rows (using the +3-field index), sort them by id, and take the first 5. The case where +the extra-index-column trick is useful is where the WHERE clause *isn't* +real selective and so a lot of rows would have to be sorted. In your +previous example, I imagine you have a lot of prolific posters and so +"all posts by userid 42" can be a nontrivial set. The double-column +index lets you skip the sort and just pull out the required rows by +scanning from the end of the range of userid = 42 entries. + +> gf=# EXPLAIN ANALYZE SELECT id FROM comments WHERE userid = 51 ORDER BY +> timestamp DESC LIMIT 5; +> QUERY PLAN +> ---------------------------------------------------------------------------- +> ------------------------------------------------------------------- +> Limit (cost=1608.43..1608.45 rows=5 width=8) (actual time=0.292..0.317 +> rows=5 loops=1) +> -> Sort (cost=1608.43..1609.45 rows=407 width=8) (actual +> time=0.287..0.295 rows=5 loops=1) +> Sort Key: "timestamp" +> -> Index Scan using comments_ix_userid on comments +> (cost=0.00..1590.79 rows=407 width=8) (actual time=0.031..0.190 rows=35 +> loops=1) +> Index Cond: (userid = 51) +> Total runtime: 0.375 ms +> (6 rows) + +This example looks fine, but since userid 51 evidently only has 35 +posts, there's not much time needed to read 'em all and sort 'em. The +place where the double-column index will win big is on userids with +hundreds of posts. + +You have to keep in mind that each index costs time to maintain during +inserts/updates. So adding an index just because it makes a few queries +a little faster probably isn't a win. You need to make tradeoffs. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Aug 12 03:49:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8AE2D14B2800 + for ; + Thu, 12 Aug 2004 03:49:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85989-05 + for ; + Thu, 12 Aug 2004 06:49:32 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F20614B27FF + for ; + Thu, 12 Aug 2004 03:49:29 -0300 (ADT) +Received: (qmail 13635 invoked from network); 12 Aug 2004 08:49:35 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 12 Aug 2004 08:49:35 +0200 +To: "Jason Coene" , + "'Tom Lane'" +Cc: "'Merlin Moncure'" , + pgsql-performance@postgresql.org +Subject: Re: Hardware upgrade for a high-traffic database +References: <200408120029.i7C0T30E002389@mail.gotfrag.com> +Message-ID: +Date: Thu, 12 Aug 2004 08:49:37 +0200 +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <200408120029.i7C0T30E002389@mail.gotfrag.com> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/183 +X-Sequence-Number: 7819 + +On Wed, 11 Aug 2004 20:29:04 -0400, Jason Coene wrote: + + + + +> gf=# EXPLAIN ANALYZE SELECT id FROM comments WHERE userid = 51 ORDER BY +> timestamp DESC LIMIT 5; +> QUERY +> PLAN +> ---------------------------------------------------------------------------- +> ------------------------------------------------------------------- +> Limit (cost=1608.43..1608.45 rows=5 width=8) (actual time=0.292..0.317 +> rows=5 loops=1) +> -> Sort (cost=1608.43..1609.45 rows=407 width=8) (actual +> time=0.287..0.295 rows=5 loops=1) +> Sort Key: "timestamp" +> -> Index Scan using comments_ix_userid on comments +> (cost=0.00..1590.79 rows=407 width=8) (actual time=0.031..0.190 rows=35 +> loops=1) +> Index Cond: (userid = 51) +> Total runtime: 0.375 ms +> (6 rows) + + Well, you have to read it from the bottom. + - Index Scan using comments_ix_userid : + It selects all records for your user. + rows=407 : there are 407 rows. + + -> Sort (cost=1608.43..1609.45 rows=407 width=8) + It sorts them to find the 5 more recent. + + So basically you grab 407 rows to return only 5, so you do 80x more disk +I/O than necessary. It is likely that posts from all users are interleaved +in the table, so this probably translates directly into 407 page fetches. + + Note : EXPLAIN ANALYZE will only give good results the first time you run +it. The second time, all data is in the cache, so it looks really faster +than it is. + +> gf=# EXPLAIN ANALYZE SELECT id FROM comments WHERE userid = 51 ORDER BY +> userid DESC, timestamp DESC LIMIT 5; +> QUERY PLAN +> ---- +> Limit (cost=0.00..19.90 rows=5 width=12) (actual time=0.040..0.076 +> rows=5 +> loops=1) +> -> Index Scan Backward using comments_ix_userid_timestamp on comments +> (cost=0.00..1620.25 rows=407 width=12) (actual time=0.035..0.054 rows=5 +> loops=1) +> Index Cond: (userid = 51) +> Total runtime: 0.134 ms +> (4 rows) +> +> Note: This was done after adding an index on comments (userid, timestamp) + + Well, this one correctly uses the index, fetches 5 rows, and returns them. + + So, excluding index page hits, your unoptimized query has >400 page +fetches, and your optimized one has 5 page fetches. Still wonder why it's +faster ? + + Seq scan is fast when locality of reference is good. In your case, it's +very bad. + +From pgsql-performance-owner@postgresql.org Thu Aug 12 07:38:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 40F3014B281A + for ; + Thu, 12 Aug 2004 07:37:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49931-08 + for ; + Thu, 12 Aug 2004 10:37:53 +0000 (GMT) +Received: from thor.netera.se (thor.netera.se [62.13.47.20]) + by svr1.postgresql.org (Postfix) with ESMTP id D4A3614B281C + for ; + Thu, 12 Aug 2004 07:37:51 -0300 (ADT) +Received: from [127.0.0.1] (unknown [213.212.22.34]) + by thor.netera.se (Postfix) with ESMTP id 8CC6713AC049; + Thu, 12 Aug 2004 12:37:51 +0200 (CEST) +Message-ID: <411B4878.4090804@relevanttraffic.se> +Date: Thu, 12 Aug 2004 12:37:44 +0200 +From: Ulrich Wisser +Organization: Relevant Traffic AB +User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Cc: bruno@wolff.to +Subject: Re: [GENERAL] How to know which queries are to be optimised? +References: <4110CFE7.9000202@relevanttraffic.se> + <20040811162701.GA9992@wolff.to> +In-Reply-To: <20040811162701.GA9992@wolff.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/184 +X-Sequence-Number: 7820 + +Hi Bruno, + +>>my web application grows slower and slower over time. After some +>>profiling I came to the conclusion that my SQL queries are the biggest +>>time spenders (25 seconds). Obviously I need to optimise my queries and +>>maybe introduce some new indexes. +> +> This sounds like you aren't doing proper maintainance. You need to be +> vacuuming with a large enough FSM setting. + +I do a vacuum full analyze every night. +How can I see if my FSM setting is appropriate? + +>>The problem is, that my application uses dynamic queries. I therefor can +>>not determine what are the most common queries. +>> +>>I have used the postgresql logging ption before. Is there a tool to +>>analyze the logfile for the most common and/or most time consuming queries? +> +> +> You can log queries that run for at least a specified amount of time. +> This will be useful in finding what the long running queries are. +> You can then use explain analyse to see why they are long running. + +But is there a tool that could compile a summary out of the log? The log +grows awefully big after a short time. + +Thanks + +/Ulrich + + + + + + +From pgsql-performance-owner@postgresql.org Thu Aug 12 08:16:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 88FB314B2820 + for ; + Thu, 12 Aug 2004 08:16:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62090-09 + for ; + Thu, 12 Aug 2004 11:16:27 +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 B49E914B280B + for ; + Thu, 12 Aug 2004 08:16:25 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BvDZL-00002N-0W; Thu, 12 Aug 2004 11:16:27 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id B4871183A8; Thu, 12 Aug 2004 12:16:23 +0100 (BST) +Message-ID: <411B5184.6090106@archonet.com> +Date: Thu, 12 Aug 2004 12:16:20 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ulrich Wisser +Cc: pgsql-performance@postgresql.org, bruno@wolff.to +Subject: Re: [GENERAL] How to know which queries are to be optimised? +References: <4110CFE7.9000202@relevanttraffic.se> + <20040811162701.GA9992@wolff.to> + <411B4878.4090804@relevanttraffic.se> +In-Reply-To: <411B4878.4090804@relevanttraffic.se> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/185 +X-Sequence-Number: 7821 + +Ulrich Wisser wrote: +>> You can log queries that run for at least a specified amount of time. +>> This will be useful in finding what the long running queries are. +>> You can then use explain analyse to see why they are long running. +> +> But is there a tool that could compile a summary out of the log? The log +> grows awefully big after a short time. + +You might want to look at the "Practical Query Analyser" - haven't used +it myself yet, but it seems a sensible idea. + +http://pqa.projects.postgresql.org/ + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Thu Aug 12 10:39:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DBC4814B291A + for ; + Thu, 12 Aug 2004 10:39:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05553-07 + for ; + Thu, 12 Aug 2004 13:39:43 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 05D7714B2921 + for ; + Thu, 12 Aug 2004 10:39:40 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Hardware upgrade for a high-traffic database +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Thu, 12 Aug 2004 09:39:46 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A744E@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Hardware upgrade for a high-traffic database +thread-index: AcSAEWDkVoaLKA8KQLW0xzMOWNtIXAAWrkFA +From: "Merlin Moncure" +To: "Tom Lane" +Cc: "Jason Coene" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/186 +X-Sequence-Number: 7822 + +> This example looks fine, but since userid 51 evidently only has 35 +> posts, there's not much time needed to read 'em all and sort 'em. The +> place where the double-column index will win big is on userids with +> hundreds of posts. +>=20 +> You have to keep in mind that each index costs time to maintain during +> inserts/updates. So adding an index just because it makes a few +queries +> a little faster probably isn't a win. You need to make tradeoffs. + +IMNSHO, in Jason's case he needs to do everything possible to get his +frequently run queries going as quick as possible. ISTM he can give up +a little on the update side, especially since he is running fsync=3Dfalse. +A .3-.5 sec query multiplied over 50-100 users running concurrently adds +up quick. Ideally, you are looking up records based on a key that takes +you directly to the first record you want and is pointing to the next +number of records in ascending order. I can't stress enough how +important this is so long as you can deal with the index/update +overhead.=20=20 + +I don't have a huge amount of experience with this in pg, but one of the +tricks we do in the ISAM world is a 'reverse date' system, so that you +can scan forwards on the key to pick up datetimes in descending order. +This is often a win because the o/s cache may assume read/forwards +giving you more cache hits. There are a few different ways to do this, +but imagine: + +create table t +( + id int, + ts timestamp default now(), + iv interval default ('01/01/2050'::timestamp - now()) +); + +create index t_idx on t(id, iv); +select * from t where id =3D k order by id, iv limit 5; + +The above query should do a much better job pulling up data and should +be easier on your cache. A further win might be to cluster the table on +this key if the table is really big. + +note: interval is poor type to do this with, because it's a 12 byte type +(just used it here for demonstration purposes because it's easy). With +a little trickery you can stuff it into a time type or an int4 type +(even better!). If you want to be really clever you can do it without +adding any data to your table at all through functional indexes. + +Since the planner can use the same index in the extraction and ordering, +you get some savings...not much, but worthwhile when applied over a lot +of users. Knowing when and how to apply multiple key/functional indexes +will make you feel like you have 10 times the database you are using +right now. + +Merlin + +From pgsql-performance-owner@postgresql.org Thu Aug 12 11:08:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C15314B281C + for ; + Thu, 12 Aug 2004 11:07:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17378-02 + for ; + Thu, 12 Aug 2004 14:07:52 +0000 (GMT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id D958514B280D + for ; + Thu, 12 Aug 2004 11:07:49 -0300 (ADT) +Received: from houston.familyhealth.com.au (chriskl@localhost [127.0.0.1]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i7CE7kUi083152; Thu, 12 Aug 2004 22:07:46 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Received: from localhost (chriskl@localhost) + by houston.familyhealth.com.au (8.12.9p1/8.12.9/Submit) with ESMTP id + i7CE7jAR083147; Thu, 12 Aug 2004 22:07:45 +0800 (WST) +X-Authentication-Warning: houston.familyhealth.com.au: chriskl owned process + doing -bs +Date: Thu, 12 Aug 2004 22:07:45 +0800 (WST) +From: Christopher Kings-Lynne +To: Ulrich Wisser +Cc: pgsql-performance@postgresql.org, +Subject: Re: [GENERAL] How to know which queries are to be optimised? +In-Reply-To: <411B4878.4090804@relevanttraffic.se> +Message-ID: <20040812220716.J82695-100000@houston.familyhealth.com.au> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/187 +X-Sequence-Number: 7823 + +> I do a vacuum full analyze every night. +> How can I see if my FSM setting is appropriate? + +On a busy website, run vacuum analyze once an hour, or even better, use +contrib/pg_autovacuum + +Chris + + + +From pgsql-performance-owner@postgresql.org Thu Aug 12 11:09:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D403B14B2821 + for ; + Thu, 12 Aug 2004 11:09:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14237-09 + for ; + Thu, 12 Aug 2004 14:09:17 +0000 (GMT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id D7D4514B2880 + for ; + Thu, 12 Aug 2004 11:09:15 -0300 (ADT) +Received: from houston.familyhealth.com.au (chriskl@localhost [127.0.0.1]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i7CE9GUi083748; Thu, 12 Aug 2004 22:09:16 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Received: from localhost (chriskl@localhost) + by houston.familyhealth.com.au (8.12.9p1/8.12.9/Submit) with ESMTP id + i7CE9GS3083745; Thu, 12 Aug 2004 22:09:16 +0800 (WST) +X-Authentication-Warning: houston.familyhealth.com.au: chriskl owned process + doing -bs +Date: Thu, 12 Aug 2004 22:09:16 +0800 (WST) +From: Christopher Kings-Lynne +To: Ulrich Wisser +Cc: pgsql-performance@postgresql.org, +Subject: Re: [GENERAL] How to know which queries are to be optimised? +In-Reply-To: <411B4878.4090804@relevanttraffic.se> +Message-ID: <20040812220822.H82695-100000@houston.familyhealth.com.au> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/188 +X-Sequence-Number: 7824 + +> But is there a tool that could compile a summary out of the log? The log +> grows awefully big after a short time. + +Actually, yes there is. Check out www.pgfoundry.org. I think it's called +pqa or postgres query analyzer or somethign. + +Chris + + +From pgsql-performance-owner@postgresql.org Thu Aug 12 15:10:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C3C1B5E37CB + for ; + Thu, 12 Aug 2004 13:58:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52506-02 + for ; + Thu, 12 Aug 2004 16:58:09 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 77CBC5E46CB + for ; + Thu, 12 Aug 2004 13:58:00 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Hardware upgrade for a high-traffic database +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Thu, 12 Aug 2004 12:58:10 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A7450@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Hardware upgrade for a high-traffic database +thread-index: AcSAEWDkVoaLKA8KQLW0xzMOWNtIXAAWrkFAAAdLJsA= +From: "Merlin Moncure" +To: +Cc: "Jason Coene" , + "Tom Lane" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/190 +X-Sequence-Number: 7826 + +> I don't have a huge amount of experience with this in pg, but one of +the +> tricks we do in the ISAM world is a 'reverse date' system, so that you +> can scan forwards on the key to pick up datetimes in descending order. +> This is often a win because the o/s cache may assume read/forwards +> giving you more cache hits. There are a few different ways to do +this, +> but imagine: + +I've been thinking more about this and there is even a more optimal way +of doing this if you are willing to beat on your data a bit. It +involves the use of sequences. Lets revisit your id/timestamp query +combination for a message board. The assumption is you are using +integer keys for all tables. You probably have something like: + +create table messages +( + user_id int4 references users, + topic_id int4 references topics, + message_id serial, + message_time timestamp default now(), + [...] +); + +The following suggestion works in two principles: one is that instead of +using timestamps for ordering, integers are quicker, and sequences have +a built in ability for reverse-ordering. + +Lets define: +create sequence message_seq increment -1 start 2147483647 minvalue 0 +maxvalue 2147483647; + +now we define our table: +create table messages +( + user_id int4 references users, + topic_id int4 references topics, + message_id int4 default nextval('message_seq') primary key, + message_time timestamp default now(), + [...] +); + +create index user_message_idx on messages(user_id, message_id); +-- optional +cluster user_message_idx messages; + +Since the sequence is in descending order, we don't have to do any +tricks to logically reverse order the table. + +-- return last k posts made by user u in descending order; + +select * from messages where user_id =3D u order by user_id, message_id +limit k; + +-- return last k posts on a topic +create index topic_message_idx on messages(topic_id, user_id); +select * from messages where topic_id =3D t order by topic_id, message_id + +a side benefit of clustering is that there is little penalty for +increasing k because of read ahead optimization whereas in normal +scenarios your read time scales with k (forcing small values for k). If +we tended to pull up messages by topic more frequently than user, we +would cluster on topic_message_idx instead. (if we couldn't decide, we +might cluster on message_id or not at all). + +The crucial point is that we are making this one index run really fast +at the expense of other operations. The other major point is we can use +a sequence in place of a timestamp for ordering. Using int4 vs. +timestamp is a minor efficiency win, if you are worried about > 4B rows, +then stick with timestamp. + +This all boils down to a central unifying principle: organize your +indices around your expected access patterns to the data. Sorry if I'm +bleating on and on about this...I just think there is plenty of +optimization room left in there :) + +Merlin + + +From pgsql-performance-owner@postgresql.org Thu Aug 12 14:50:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AEE465E37D0 + for ; + Thu, 12 Aug 2004 14:09:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50947-10 + for ; + Thu, 12 Aug 2004 17:09:05 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 49C525E37CB + for ; + Thu, 12 Aug 2004 14:09:06 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7CH929v000120; + Thu, 12 Aug 2004 13:09:02 -0400 (EDT) +To: "Merlin Moncure" +Cc: pgsql-performance@postgresql.org, + "Jason Coene" +Subject: Re: Hardware upgrade for a high-traffic database +In-reply-to: <6EE64EF3AB31D5448D0007DD34EEB3412A7450@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3412A7450@Herge.rcsinc.local> +Comments: In-reply-to "Merlin Moncure" + message dated "Thu, 12 Aug 2004 12:58:10 -0400" +Date: Thu, 12 Aug 2004 13:09:02 -0400 +Message-ID: <119.1092330542@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/189 +X-Sequence-Number: 7825 + +"Merlin Moncure" writes: +> The following suggestion works in two principles: one is that instead of +> using timestamps for ordering, integers are quicker, + +The difference would be pretty marginal --- especially if you choose to +use bigints instead of ints. (A timestamp is just a float8 or bigint +under the hood, and is no more expensive to compare than those datatypes. +Timestamps *are* expensive to convert for I/O, but comparison does not +have to do that.) I wouldn't recommend kluging up your data schema just +for that. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Aug 12 16:33:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D27B95E46BF + for ; + Thu, 12 Aug 2004 14:48:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73214-07 + for ; + Thu, 12 Aug 2004 17:48:30 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id CD7545E4249 + for ; + Thu, 12 Aug 2004 14:48:29 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Hardware upgrade for a high-traffic database +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Thu, 12 Aug 2004 13:48:38 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A7451@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Hardware upgrade for a high-traffic database +thread-index: AcSAjxZkA0MevDuiSOmqJZhpTvo9+AAAzHyA +From: "Merlin Moncure" +To: "Tom Lane" +Cc: , + "Jason Coene" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/192 +X-Sequence-Number: 7828 + +Tom Lane wrote: +> The difference would be pretty marginal --- especially if you choose +to +> use bigints instead of ints. (A timestamp is just a float8 or bigint +> under the hood, and is no more expensive to compare than those +datatypes. +> Timestamps *are* expensive to convert for I/O, but comparison does not +> have to do that.) I wouldn't recommend kluging up your data schema +just +> for that. + +Right (int4 use was assumed). I agree, but it's kind of a 'two birds +with one stone' kind of thing, because it's easier to work with reverse +ordering integers than time values. So I claim a measurable win (the +real gainer of course being able to select and sort on the same key, +which works on any type), based on the int4-int8 difference, which is a +33% reduction in key size. + +One claim I don't have the data for is that read-forward is better than +read-back, but my gut tells me he'll get a better cache hit ratio that +way. This will be very difficult to measure. + +As for kludging, using a decrementing sequence is not a bad idea if the +general tendency is to read the table backwards, even if just for +conceptual reasons. The main kludge is the int4 assumption, which (IMO) +isn't so bad. He would just have to rebuild the existing p-key in +reverse order (10$ says his keys are all already int4s), and hopefully +not mess with the application code too much. + +At least, it's what I would try if I was in his shoes :) + +YMMV +Merlin + + + + + + + +From pgsql-general-owner@postgresql.org Thu Aug 12 16:28:38 2004 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 13CC85E46C4 + for ; + Thu, 12 Aug 2004 14:58:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73798-10 + for ; + Thu, 12 Aug 2004 17:58:49 +0000 (GMT) +Received: from mail.winfreeacademy.com (unknown [12.45.130.164]) + by svr1.postgresql.org (Postfix) with ESMTP id D3B665E46CC + for ; + Thu, 12 Aug 2004 14:58:48 -0300 (ADT) +Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) + by mail.winfreeacademy.com (Postfix) with ESMTP id 33AE51C386 + for ; + Thu, 12 Aug 2004 13:08:20 -0500 (CDT) +Received: from mail.winfreeacademy.com (localhost.localdomain [127.0.0.1]) + by localhost.localdomain (VaMailArmor-2.0.1.16) id 02273-14FE1AA3; + Thu, 12 Aug 2004 13:08:20 -0500 +Received: from winfreeacademy.com (ns1.winfreeacademy.com [12.45.130.162]) + by mail.winfreeacademy.com (Postfix) with ESMTP id 1BE441C385 + for ; + Thu, 12 Aug 2004 13:08:20 -0500 (CDT) +Message-ID: <411BB0C8.8040204@winfreeacademy.com> +Date: Thu, 12 Aug 2004 13:02:48 -0500 +From: Laura Vance +Reply-To: vancel@winfreeacademy.com +Organization: WACS +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-general@postgresql.org +Subject: Re: My admin left the job and I am stuck +References: <20040811184143.98784.qmail@web53901.mail.yahoo.com> +In-Reply-To: <20040811184143.98784.qmail@web53901.mail.yahoo.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-AntiVirus: checked by Vexira MailArmor (version: 2.0.1.16; VAE: 6.27.0.4; + VDF: 6.27.0.9; host: mail.winfreeacademy.com) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/528 +X-Sequence-Number: 64083 + +All of the resources you need are at http://www.posgresql.org/ + +But, a quick note on how to connect to the database, you don't need to +really know where it's installed, just that it's running and accepting +connections. Under Linux "netstat -tapn" will show you all of the open +TCP ports and what's listening to each. For Postgres, the default port +is 5432 and the process is called postmaster. You may need to be logged +in as root to see this. + +First thing is that knowing SQL basics is pretty much required before +you can really investigate what he had set up. +Second thing is to connect by using the following command: psql +Without any arguments, it will connect to the local machine and to a +database named for the current user. Once in psql, type \d to see a +list of the user-defined tables. To see a list of databases type \l and +you will be shown a list of databases. + + From there, you can explore until your heart's content. + +Everything is SQL compliant, so if you know SQL, you shouldn't have any +problems. + +As for Linux admin, the most important thing to remember is that +everything is case sensitive. ls != LS + +If you're coming from the MS world, take some time to really learn +Linux... I'm sure you'll like it and eventually you'll prefer it. I use +Linux as my only OS at home, and I finally have a job where I use Linux +at work (they adopted it after I submitted a proposal). + +hope this helps! +Laura + +Karam Chand wrote: + +>Hello, +> +>My linux admin left the job. We had a PostgreSQL +>installed under his username. He used to maintain it. +>Now I am looking at the Linux box and I am just a +>super duper newbie in Linux administration. +> +>The previosu admin had a database created under his +>name coz PostgreSQL dosnt allow root database. +> +>Now I want to get the data back and use it? I dont +>mind if I have to use a different DB? +> +>I dont even know where he isntalled the PostgreSQL +>binaries and data? +> +>Where can I all this information? +> +>I am feeling really stupid but thank GOD we dont have +>any live databases running? +> +>Regards, +>Karam +> +> +-- +Thanks, +Laura Vance +Systems Engineer +Winfree Academy Charter Schools +6221 Riverside Dr. Ste 110 +Irving, Tx 75039 +Web: www.winfreeacademy.com + + + +From pgsql-performance-owner@postgresql.org Thu Aug 12 15:58:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3F8F05E46CF + for ; + Thu, 12 Aug 2004 15:57:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 04093-09 + for ; + Thu, 12 Aug 2004 18:57:23 +0000 (GMT) +Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) + by svr1.postgresql.org (Postfix) with ESMTP id CB1165E3AC5 + for ; + Thu, 12 Aug 2004 15:57:21 -0300 (ADT) +Received: from wp2000 ([157.157.178.195] [157.157.178.195]) by + quasar.skima.is; + Thu, 12 Aug 2004 18:57:20 Z +Message-Id: <001d01c4809e$7e442600$0100000a@wp2000> +From: "gnari" +To: +References: <6EE64EF3AB31D5448D0007DD34EEB3412A7450@Herge.rcsinc.local> +Subject: Re: Hardware upgrade for a high-traffic database +Date: Thu, 12 Aug 2004 18:59:28 -0000 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 5.00.2919.6700 +X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200408/191 +X-Sequence-Number: 7827 + +"Merlin Moncure" wrote: + +-- optional +cluster user_message_idx messages; + +would one not have to repeat this operation regularly, to keep +any advantage of this ? my impression was that this is a relatively +heavy operation on a large table. + +gnari + + + + +From pgsql-performance-owner@postgresql.org Thu Aug 12 17:03:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 064885E46D4 + for ; + Thu, 12 Aug 2004 16:27:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17889-09 + for ; + Thu, 12 Aug 2004 19:27:01 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FB605E40BA + for ; + Thu, 12 Aug 2004 16:27:00 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Hardware upgrade for a high-traffic database +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Thu, 12 Aug 2004 15:27:01 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A7453@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Hardware upgrade for a high-traffic database +thread-index: AcSAn86fM1Q8QoOtQiaNpFH4EEGasAAAK4Ew +From: "Merlin Moncure" +To: "gnari" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/193 +X-Sequence-Number: 7829 + +> would one not have to repeat this operation regularly, to keep +> any advantage of this ? my impression was that this is a relatively +> heavy operation on a large table. + +Yeah, it requires an exclusive lock and a table rebuild. It might be +useful to a message board type database since (one presumes) the reads +would be concentrated over recently created data, entered after the +cluster and losing any benefit. + +As far as table size, bigger tables are a larger operation but take +longer to get all out of whack. Question is: what percentage of the +data turns over between maintenance periods? Plus, there has to be a +maintenance period...nobody does anything while the table is clustering. + +Also, a particular method of reading the table has to really dominate as +far as user usage pattern. So, it's pretty rare to user cluster, but it +can help in some cases. + +Merlin + +From pgsql-benchmarks-owner@postgresql.org Fri Aug 13 12:04:35 2004 +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 C3C005E46CB; + Thu, 12 Aug 2004 17:10:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42792-02; Thu, 12 Aug 2004 20:10:03 +0000 (GMT) +Received: from cbc.ca (gwtor-out.cbc.ca [159.33.1.177]) + by svr1.postgresql.org (Postfix) with ESMTP id 019EB5E46C0; + Thu, 12 Aug 2004 17:10:01 -0300 (ADT) +Received: from GWIADMOUT-MTA by cbc.ca + with Novell_GroupWise; Thu, 12 Aug 2004 16:10:03 -0400 +Message-Id: +X-Mailer: Novell GroupWise Internet Agent 6.5.2 +Date: Thu, 12 Aug 2004 16:09:48 -0400 +From: "Arash Zaryoun" +To: , + , +Subject: Performance Problem With Postgresql! +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/1 +X-Sequence-Number: 14 + +Hi All, + +We are having a performance problem with our database. The problem +exists when we include a constraint in GCTBALLOT. The constraint is as +follows: + +alter table GCTBALLOT + add constraint FK_GCTBALLOT_GCTWEBU foreign key (GCTWEBU_SRL) + references GCTWEBU (SRL) + on delete restrict on update restrict; + +The two tables that we insert into are the following: + +GCTBALLOT: + + Table "cbcca.gctballot" + + Column | Type | + Modifiers +------------------+-----------------------------+----------------------------------------------------------- + srl | integer | not null default +nextval('cbcca.gctballot_srl_seq'::text) + gctbwindow_srl | numeric(12,0) | not null + gctcandidate_srl | numeric(12,0) | not null + gctwebu_srl | numeric(12,0) | + gctphoneu_srl | numeric(12,0) | + ballot_time | timestamp without time zone | not null + ip_addr | character varying(15) | +Indexes: + "pk_gctballot" primary key, btree (srl) + "i1_gctballot_webusrl" btree (gctwebu_srl) +Foreign-key constraints: + "fk_gctbwindow_gctballot" FOREIGN KEY (gctbwindow_srl) REFERENCES +gctbwindow(srl) ON UPDATE RESTRICT ON DELETE RESTRICT + "fk_gctcandidate_gctballot" FOREIGN KEY (gctcandidate_srl) +REFERENCES gctcandidate(srl) ON UPDATE RESTRICT ON DELETE RESTRICT + "fk_gctphoneu_gctballot" FOREIGN KEY (gctphoneu_srl) REFERENCES +gctphoneu(srl) ON UPDATE RESTRICT ON DELETE RESTRICT + +with the extra constraint: + +"fk_gctballot_gctwebu" FOREIGN KEY (gctwebu_srl) REFERENCES +gctwebu(srl) ON UPDATE RESTRICT ON DELETE RESTRICT + + + +GCTWEBU: + + Table "cbcca.gctwebu" + Column | Type | +Modifiers +-----------------+-----------------------------+--------------------------------------------------------- + srl | integer | not null default +nextval('cbcca.gctwebu_srl_seq'::text) + gctlocation_srl | numeric(12,0) | not null + gctagerange_srl | numeric(12,0) | not null + email | character varying(255) | not null + uhash | character varying(255) | not null + sex | character varying(1) | not null + created_time | timestamp without time zone | not null +Indexes: + "pk_gctwebu" primary key, btree (srl) + "i1_gctwebu_email" unique, btree (email) +Foreign-key constraints: + "fk_gctagerang_gctwebu" FOREIGN KEY (gctagerange_srl) REFERENCES +gctagerange(srl) ON UPDATE RESTRICT ON DELETE RESTRICT + "fk_gctwebu_gctlocation" FOREIGN KEY (gctlocation_srl) REFERENCES +gctlocation(srl) ON UPDATE RESTRICT ON DELETE RESTRICT + + +To begin, GCTBALLOT has 6122546 rows and GCTWEBU has 231444 rows. + +Now when we try and insert 100 entries into GCTBALLOT with the extra +constraint it +takes: 37981 milliseconds + +Also, when we try and insert 100 entries into GCTBALLOT with the extra +constraint, +but insert 'null' into the column gctwebu_srl it takes: 286 +milliseconds + +However when we try and insert 100 entries into GCTBALLOT without the +extra constraint (no foreign key between GCTBALLOT & GCTWEBU) +it takes: 471 milliseconds + + +In summary, inserting into GCTBALLOT without the constraint or +inserting null for +gctwebu_srl in GCTBALLOT gives us good performance. However, inserting +into GCTBALLOT +with the constraint and valid gctwebu_srl values gives us poor +performance. + +Also, the insert we use is as follows: + +INSERT INTO GCTBALLOT (gctbwindow_srl, gctcandidate_srl, gctwebu_srl, +gctphoneu_srl, +ballot_time, ip_addr) VALUES (CBCCA.gcf_getlocation(?), ?, +CBCCA.gcf_validvoter(?,?), +null, ?, ?); + +NOTE: "gcf_validvoter" find 'gctweb_srl' value + +" +CREATE OR REPLACE FUNCTION gcf_validvoter (VARCHAR, VARCHAR) + RETURNS NUMERIC AS ' +DECLARE + arg1 ALIAS FOR $1; + arg2 ALIAS FOR $2; + return_val NUMERIC; +BEGIN + SELECT SRL INTO return_val + FROM gctwebu + WHERE EMAIL = arg1 + AND UHASH = arg2; + + RETURN return_val; +END; +' LANGUAGE plpgsql; +" + + +Where the question marks are filled in with values in our java code. + +We are puzzled as to why there is this difference in performance when +inserting b/c we +believe that we have indexed all columns used by this constraint. And +we realize that +inserting 'null' into GCTBALLOT doesn't use this constraint b/c no look +up is necessary. +So this causes good performance. Why is it that when we use this +constraint that +the performance is effected so much? + +Any help would be much appreciated. +Thanks + + +P.S. Even we added an index on 'gctwebu_srl' column and did +1- "Analyzed ALL TABLES" +2- "analyze GCTBALLOT(gctwebu_srl);" + +but still have the same problem! + + +From pgsql-performance-owner@postgresql.org Thu Aug 12 19:41:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 71A915E46C8 + for ; + Thu, 12 Aug 2004 19:41:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77546-09 + for ; + Thu, 12 Aug 2004 22:41:24 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id EB2115E37CE + for ; + Thu, 12 Aug 2004 19:41:22 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7CMfNiG081471 + for ; Thu, 12 Aug 2004 22:41:23 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7CMClqJ075401 + for pgsql-performance@postgresql.org; Thu, 12 Aug 2004 22:12:47 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Help specifying new machine +Date: Thu, 12 Aug 2004 15:12:43 -0700 +Organization: Hub.Org Networking Services +Lines: 23 +Message-ID: +References: <20040809165657.GB15169@campbell-lange.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7b) Gecko/20040421 +X-Accept-Language: en-us, en +In-Reply-To: <20040809165657.GB15169@campbell-lange.net> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/194 +X-Sequence-Number: 7830 + +Rory Campbell-Lange wrote: + +> The present server is a 2GHz Pentium 4/512 KB cache with 2 +> software-raided ide disks (Maxtors) and 1GB of RAM. +> +> +> I have been offered the following 1U server which I can just about +> afford: +> +> 1U server +> Intel Xeon 2.8GHz 512K cache 1 +> 512MB PC2100 DDR ECC Registered 2 +> 80Gb SATA HDD 4 +> 4 port SATA card, 3 ware 8506-4 1 +> 3 year next-day hardware warranty 1 + +You're not getting much of a bump with this server. The CPU is +incrementally faster -- in the absolutely best case scenario where your +queries are 100% cpu-bound, that's about ~25%-30% faster. + +If you could use that money instead to upgrade your current server, +you'd get a much bigger impact. Go for more memory and scsi (raid +controllers w/ battery-backed cache). + +From pgsql-performance-owner@postgresql.org Thu Aug 12 19:52:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6BBEE5E46C8 + for ; + Thu, 12 Aug 2004 19:52:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82974-03 + for ; + Thu, 12 Aug 2004 22:52:41 +0000 (GMT) +Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net + [203.16.214.203]) + by svr1.postgresql.org (Postfix) with ESMTP id 24BE25E46CA + for ; + Thu, 12 Aug 2004 19:52:38 -0300 (ADT) +Received: from [192.168.0.114] (ppp226-68.lns1.bne1.internode.on.net + [203.122.226.68]) + by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id + i7CMqdHY041260 for ; + Fri, 13 Aug 2004 08:22:40 +0930 (CST) +Message-ID: <411BF429.1090106@wildcash.com> +Date: Fri, 13 Aug 2004 08:50:17 +1000 +From: Rudi Starcevic +Reply-To: tech@wildcash.com +Organization: Internet Media Productions +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7) Gecko/20040616 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: [GENERAL] How to know which queries are to be optimised? +References: <4110CFE7.9000202@relevanttraffic.se> + <20040811162701.GA9992@wolff.to> + <411B4878.4090804@relevanttraffic.se> + <411B5184.6090106@archonet.com> +In-Reply-To: <411B5184.6090106@archonet.com> +X-Enigmail-Version: 0.85.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/195 +X-Sequence-Number: 7831 + +Hi, + +>> But is there a tool that could compile a summary out of the log? The +>> log grows awefully big after a short time. + +There's also pg_analyzer to check out. + +http://www.samse.fr/GPL/pg_analyzer/ + +Some of it's features are: written in Perl and produces HTML output. + +> You might want to look at the "Practical Query Analyser" - haven't used +> it myself yet, but it seems a sensible idea. +> +> http://pqa.projects.postgresql.org/ + + +Cheers, +Rudi. + +From pgsql-performance-owner@postgresql.org Fri Aug 13 12:08:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 39D245E46E2 + for ; + Fri, 13 Aug 2004 03:41:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55661-03 + for ; + Fri, 13 Aug 2004 06:41:33 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 397305E46CA + for ; + Fri, 13 Aug 2004 03:41:31 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7D6fUiG057276 + for ; Fri, 13 Aug 2004 06:41:30 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7D6R8Lm053403 + for pgsql-performance@postgresql.org; Fri, 13 Aug 2004 06:27:08 GMT +From: Raoul Buzziol +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Help specifying new machine +Date: Fri, 13 Aug 2004 08:29:15 +0200 +Organization: Hub.Org Networking Services +Lines: 30 +Message-ID: +References: <20040809165657.GB15169@campbell-lange.net> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7Bit +X-Complaints-To: usenet@news.hub.org +User-Agent: KNode/0.7.7 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/206 +X-Sequence-Number: 7842 + +William Yu wrote: + +> Rory Campbell-Lange wrote: +> +>> The present server is a 2GHz Pentium 4/512 KB cache with 2 +>> software-raided ide disks (Maxtors) and 1GB of RAM. +>> +>> +>> I have been offered the following 1U server which I can just about +>> afford: +>> +>> 1U server +>> Intel Xeon 2.8GHz 512K cache 1 +>> 512MB PC2100 DDR ECC Registered 2 +>> 80Gb SATA HDD 4 +>> 4 port SATA card, 3 ware 8506-4 1 +>> 3 year next-day hardware warranty 1 +> +> You're not getting much of a bump with this server. The CPU is +> incrementally faster -- in the absolutely best case scenario where your +> queries are 100% cpu-bound, that's about ~25%-30% faster. + +What about using Dual Athlon MP instead of a Xeon? Would be much less expensive, +but have higher performance (I think). + +> +> If you could use that money instead to upgrade your current server, +> you'd get a much bigger impact. Go for more memory and scsi (raid +> controllers w/ battery-backed cache). + + +From pgsql-performance-owner@postgresql.org Fri Aug 13 04:47:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 05AB55E46CB + for ; + Fri, 13 Aug 2004 04:47:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73391-04 + for ; + Fri, 13 Aug 2004 07:47:19 +0000 (GMT) +Received: from thor.netera.se (thor.netera.se [62.13.47.20]) + by svr1.postgresql.org (Postfix) with ESMTP id A0E3C5E37D0 + for ; + Fri, 13 Aug 2004 04:47:18 -0300 (ADT) +Received: from [127.0.0.1] (unknown [213.212.22.34]) + by thor.netera.se (Postfix) with ESMTP id F3BA313AC0B8 + for ; + Fri, 13 Aug 2004 09:47:18 +0200 (CEST) +Message-ID: <411C7205.1000703@relevanttraffic.se> +Date: Fri, 13 Aug 2004 09:47:17 +0200 +From: Ulrich Wisser +Organization: Relevant Traffic AB +User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: insert +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/196 +X-Sequence-Number: 7832 + +Hi, + +is there anything I can doo to speed up inserts? One of my tables gets +about 100 new rows every five minutes. And somehow the inserts tend to +take more and more time. + +Any suggestions welcome. + +TIA + +Ulrich + + +From pgsql-performance-owner@postgresql.org Fri Aug 13 07:09:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 26D525E46DF + for ; + Fri, 13 Aug 2004 07:08:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08651-09 + for ; + Fri, 13 Aug 2004 10:08:04 +0000 (GMT) +Received: from honorio.sinectis.com.ar (honorio.sinectis.com.ar + [216.244.192.201]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B35E5E37D0 + for ; + Fri, 13 Aug 2004 07:08:00 -0300 (ADT) +Received: by honorio.sinectis.com.ar (Postfix, from userid 99) + id 24FC86C37F; Fri, 13 Aug 2004 07:08:00 -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: ulrich.wisser@relevanttraffic.se, + pgsql-performance@postgresql.org +Subject: Re: insert +Reply-To: gbarosio@uolsinectis.com.ar +Message-Id: <20040813100800.24FC86C37F@honorio.sinectis.com.ar> +Date: Fri, 13 Aug 2004 07:08:00 -0300 (GMT+3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/197 +X-Sequence-Number: 7833 + +Tips! +*Delete indexes and recreate them after the insert. +*Disable auto-commit +*Perform a copy will be faster, sure. + +Best wishes, +Guido + +> Hi, +> +> is there anything I can doo to speed up inserts? One of my tables gets +> about 100 new rows every five minutes. And somehow the inserts tend to +> take more and more time. +> +> Any suggestions welcome. +> +> TIA +> +> Ulrich +> +> +> ---------------------------(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 Aug 13 07:47:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A8BA5E46D7 + for ; + Fri, 13 Aug 2004 07:47:34 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17866-06 + for ; + Fri, 13 Aug 2004 10:47:28 +0000 (GMT) +Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A44B5E37D0 + for ; + Fri, 13 Aug 2004 07:47:25 -0300 (ADT) +Received: from wp2000 ([157.157.178.195] [157.157.178.195]) by + quasar.skima.is; + Fri, 13 Aug 2004 10:46:57 Z +Message-Id: <009c01c48123$270f7760$0100000a@wp2000> +From: "gnari" +To: +References: <20040813100800.24FC86C37F@honorio.sinectis.com.ar> +Subject: Re: insert +Date: Fri, 13 Aug 2004 10:49:05 -0000 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="Windows-1252" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 5.00.2919.6700 +X-MIMEOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/198 +X-Sequence-Number: 7834 + +"G u i d o B a r o s i o" wrote: + +[speeding up 100 inserts every 5 minutes] + +> Tips! +> *Delete indexes and recreate them after the insert. + +sounds a bit extreme, for only 100 inserts + +gnari + + + + + +From pgsql-performance-owner@postgresql.org Fri Aug 13 08:16:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F7745E46C0 + for ; + Fri, 13 Aug 2004 08:16:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25758-02 + for ; + Fri, 13 Aug 2004 11:16:49 +0000 (GMT) +Received: from tino.sinectis.com.ar (tino.sinectis.com.ar [216.244.192.232]) + by svr1.postgresql.org (Postfix) with ESMTP id 2DE135E37D0 + for ; + Fri, 13 Aug 2004 08:16:46 -0300 (ADT) +Received: by tino.sinectis.com.ar (Postfix, from userid 99) + id 7B4116C4F8; Fri, 13 Aug 2004 08:16:49 -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: gnari@simnet.is, pgsql-performance@postgresql.org +Subject: Re: insert +Reply-To: gbarosio@uolsinectis.com.ar +Message-Id: <20040813111649.7B4116C4F8@tino.sinectis.com.ar> +Date: Fri, 13 Aug 2004 08:16:49 -0300 (GMT+3) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/199 +X-Sequence-Number: 7835 + +As I see it's 100 inserts every 5 minutes, not only 100 inserts. + +Sure it's extreme for only 100 inserts. + +Cheers, +Guido + +> "G u i d o B a r o s i o" wrote: +> +> [speeding up 100 inserts every 5 minutes] +> +> > Tips! +> > *Delete indexes and recreate them after the insert. +> +> sounds a bit extreme, for only 100 inserts +> +> gnari +> +> +> +> +> +> ---------------------------(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 Aug 13 08:45:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B2BA5E46C0 + for ; + Fri, 13 Aug 2004 08:45:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31626-03 + for ; + Fri, 13 Aug 2004 11:45:18 +0000 (GMT) +Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) + by svr1.postgresql.org (Postfix) with ESMTP id 653535E46CB + for ; + Fri, 13 Aug 2004 08:45:16 -0300 (ADT) +Received: from wp2000 ([157.157.178.195] [157.157.178.195]) by + quasar.skima.is; + Fri, 13 Aug 2004 11:45:19 Z +Message-Id: <00cc01c4812b$4e7f02e0$0100000a@wp2000> +From: "gnari" +To: , +References: <20040813111649.7B4116C4F8@tino.sinectis.com.ar> +Subject: Re: insert +Date: Fri, 13 Aug 2004 11:47:27 -0000 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="Windows-1252" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 5.00.2919.6700 +X-MIMEOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/200 +X-Sequence-Number: 7836 + +From: "G u i d o B a r o s i o" : + + +> As I see it's 100 inserts every 5 minutes, not only 100 inserts. +> +> Sure it's extreme for only 100 inserts. + +I am sorry, I do not quite grasp what you are saying. +my understanding was that there are constantly new inserts, +coming in bursts of 100 , every 5 minutes. +I imagined that the indexes were needed in between. + +if this is the case, the bunches of 100 inserts should +be done inside a transaction (or by 1 COPY statement) + +if, on the other hand, the inserts happen independently, +at a rate of 100 inserts / 5 minutes, then this will not help + +gnari + + + +> +> Cheers, +> Guido +> +> > "G u i d o B a r o s i o" wrote: +> > +> > [speeding up 100 inserts every 5 minutes] +> > +> > > Tips! +> > > *Delete indexes and recreate them after the insert. +> > +> > sounds a bit extreme, for only 100 inserts +> > +> > gnari +> > +> > +> > +> > +> > +> > ---------------------------(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 broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings +> + + +From pgsql-performance-owner@postgresql.org Fri Aug 13 09:10:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AF15A5E46CC + for ; + Fri, 13 Aug 2004 09:10:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35156-09 + for ; + Fri, 13 Aug 2004 12:10:18 +0000 (GMT) +Received: from thor.netera.se (unknown [212.214.95.20]) + by svr1.postgresql.org (Postfix) with ESMTP id 50A235E46CB + for ; + Fri, 13 Aug 2004 09:10:15 -0300 (ADT) +Received: from [127.0.0.1] (unknown [213.212.22.34]) + by thor.netera.se (Postfix) with ESMTP id E600113AC050; + Fri, 13 Aug 2004 14:10:18 +0200 (CEST) +Message-ID: <411CAFA3.90005@relevanttraffic.se> +Date: Fri, 13 Aug 2004 14:10:11 +0200 +From: Ulrich Wisser +Organization: Relevant Traffic AB +User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: gnari +Cc: pgsql-performance@postgresql.org +Subject: Re: insert +References: <20040813111649.7B4116C4F8@tino.sinectis.com.ar> + <00cc01c4812b$4e7f02e0$0100000a@wp2000> +In-Reply-To: <00cc01c4812b$4e7f02e0$0100000a@wp2000> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/201 +X-Sequence-Number: 7837 + +Hi, + +my inserts are done in one transaction, but due to some foreign key +constraints and five indexes sometimes the 100 inserts will take more +than 5 minutes. + +/Ulrich + + +From pgsql-performance-owner@postgresql.org Fri Aug 13 09:41:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 959965E46CD + for ; + Fri, 13 Aug 2004 09:41:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46824-03 + for ; + Fri, 13 Aug 2004 12:41:21 +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 C050E5E37CB + for ; + Fri, 13 Aug 2004 09:41:16 -0300 (ADT) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BvbN2-0004GF-0X; Fri, 13 Aug 2004 12:41:20 +0000 +Date: Fri, 13 Aug 2004 13:41:15 +0100 +From: Paul Thomas +To: Ulrich Wisser +Cc: "pgsql-performance @ postgresql . org" , + pgsql-performance@postgresql.org +Subject: Re: insert +Message-ID: <20040813134115.A12181@bacon> +References: <20040813111649.7B4116C4F8@tino.sinectis.com.ar> + <00cc01c4812b$4e7f02e0$0100000a@wp2000> + <411CAFA3.90005@relevanttraffic.se> +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: <411CAFA3.90005@relevanttraffic.se>; + from ulrich.wisser@relevanttraffic.se on Fri, Aug 13, 2004 at + 13:10:11 +0100 +X-Mailer: Balsa 1.2.3 +Lines: 24 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/202 +X-Sequence-Number: 7838 + + +On 13/08/2004 13:10 Ulrich Wisser wrote: +> Hi, +> +> my inserts are done in one transaction, but due to some foreign key +> constraints and five indexes sometimes the 100 inserts will take more +> than 5 minutes. + +Two possibilities come to mind: + +a) you need an index on the referenced FK field +b) you have an index but a type mis-match (e.g, an int4 field referencing +an int8 field) + +Either of these will cause a sequential table scan and poor performance. + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Fri Aug 13 09:58:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C04E95E37CE + for ; + Fri, 13 Aug 2004 09:58:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49902-04 + for ; + Fri, 13 Aug 2004 12:57:58 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B8CF75E37CB + for ; + Fri, 13 Aug 2004 09:57:53 -0300 (ADT) +Received: from [134.22.70.202] (dyn-70-202.tor.dsl.tht.net [134.22.70.202]) + by tht.net (Postfix) with ESMTP + id 140D076BD3; Fri, 13 Aug 2004 08:57:59 -0400 (EDT) +Subject: Re: insert +From: Rod Taylor +To: Ulrich Wisser +Cc: gnari , + Postgresql Performance +In-Reply-To: <411CAFA3.90005@relevanttraffic.se> +References: <20040813111649.7B4116C4F8@tino.sinectis.com.ar> + <00cc01c4812b$4e7f02e0$0100000a@wp2000> + <411CAFA3.90005@relevanttraffic.se> +Content-Type: text/plain +Message-Id: <1092401876.16087.236.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Fri, 13 Aug 2004 08:57:56 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/203 +X-Sequence-Number: 7839 + +On Fri, 2004-08-13 at 08:10, Ulrich Wisser wrote: +> Hi, +> +> my inserts are done in one transaction, but due to some foreign key +> constraints and five indexes sometimes the 100 inserts will take more +> than 5 minutes. + +It is likely that you are missing an index on one of those foreign key'd +items. + +Do an EXPLAIN ANALYZE SELECT * FROM foreign_table WHERE foreign_col = +''; + +Fix them until they're quick. + + + +From pgsql-performance-owner@postgresql.org Fri Aug 13 11:44:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 17C115E46D2 + for ; + Fri, 13 Aug 2004 11:44:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 81025-06 + for ; + Fri, 13 Aug 2004 14:44:01 +0000 (GMT) +Received: from cbc.ca (gwtor-out.cbc.ca [159.33.1.177]) + by svr1.postgresql.org (Postfix) with ESMTP id 342455E46CD + for ; + Fri, 13 Aug 2004 11:43:58 -0300 (ADT) +Received: from GWIADMOUT-MTA by cbc.ca + with Novell_GroupWise; Fri, 13 Aug 2004 10:44:04 -0400 +Message-Id: +X-Mailer: Novell GroupWise Internet Agent 6.5.2 +Date: Fri, 13 Aug 2004 10:43:43 -0400 +From: "Arash Zaryoun" +To: +Subject: Weird Database Performance problem! +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/204 +X-Sequence-Number: 7840 + +Hi, + +We are having a performance problem with our database. The problem +exists when we include a constraint in GCTBALLOT. The constraint is as +follows: + +alter table GCTBALLOT + add constraint FK_GCTBALLOT_GCTWEBU foreign key (GCTWEBU_SRL) + references GCTWEBU (SRL) + on delete restrict on update restrict; + +The two tables that we insert into are the following: + +GCTBALLOT: + + Table "cbcca.gctballot" + + Column | Type | + Modifiers +------------------+-----------------------------+----------------------------------------------------------- + srl | integer | not null default +nextval('cbcca.gctballot_srl_seq'::text) + gctbwindow_srl | numeric(12,0) | not null + gctcandidate_srl | numeric(12,0) | not null + gctwebu_srl | numeric(12,0) | + gctphoneu_srl | numeric(12,0) | + ballot_time | timestamp without time zone | not null + ip_addr | character varying(15) | +Indexes: + "pk_gctballot" primary key, btree (srl) + "i1_gctballot_webusrl" btree (gctwebu_srl) +Foreign-key constraints: + "fk_gctbwindow_gctballot" FOREIGN KEY (gctbwindow_srl) REFERENCES +gctbwindow(srl) ON UPDATE RESTRICT ON DELETE RESTRICT + "fk_gctcandidate_gctballot" FOREIGN KEY (gctcandidate_srl) +REFERENCES gctcandidate(srl) ON UPDATE RESTRICT ON DELETE RESTRICT + "fk_gctphoneu_gctballot" FOREIGN KEY (gctphoneu_srl) REFERENCES +gctphoneu(srl) ON UPDATE RESTRICT ON DELETE RESTRICT + +with the extra constraint: + +"fk_gctballot_gctwebu" FOREIGN KEY (gctwebu_srl) REFERENCES +gctwebu(srl) ON UPDATE RESTRICT ON DELETE RESTRICT + + + +GCTWEBU: + + Table "cbcca.gctwebu" + Column | Type | +Modifiers +-----------------+-----------------------------+--------------------------------------------------------- + srl | integer | not null default +nextval('cbcca.gctwebu_srl_seq'::text) + gctlocation_srl | numeric(12,0) | not null + gctagerange_srl | numeric(12,0) | not null + email | character varying(255) | not null + uhash | character varying(255) | not null + sex | character varying(1) | not null + created_time | timestamp without time zone | not null +Indexes: + "pk_gctwebu" primary key, btree (srl) + "i1_gctwebu_email" unique, btree (email) +Foreign-key constraints: + "fk_gctagerang_gctwebu" FOREIGN KEY (gctagerange_srl) REFERENCES +gctagerange(srl) ON UPDATE RESTRICT ON DELETE RESTRICT + "fk_gctwebu_gctlocation" FOREIGN KEY (gctlocation_srl) REFERENCES +gctlocation(srl) ON UPDATE RESTRICT ON DELETE RESTRICT + + +To begin, GCTBALLOT has 6122546 rows and GCTWEBU has 231444 rows. + +Now when we try and insert 100 entries into GCTBALLOT with the extra +constraint it +takes: 37981 milliseconds + +Also, when we try and insert 100 entries into GCTBALLOT with the extra +constraint, +but insert 'null' into the column gctwebu_srl it takes: 286 +milliseconds + +However when we try and insert 100 entries into GCTBALLOT without the +extra constraint (no foreign key between GCTBALLOT & GCTWEBU) +it takes: 471 milliseconds + + +In summary, inserting into GCTBALLOT without the constraint or +inserting null for +gctwebu_srl in GCTBALLOT gives us good performance. However, inserting +into GCTBALLOT +with the constraint and valid gctwebu_srl values gives us poor +performance. + +Also, the insert we use is as follows: + +INSERT INTO GCTBALLOT (gctbwindow_srl, gctcandidate_srl, gctwebu_srl, +gctphoneu_srl, +ballot_time, ip_addr) VALUES (CBCCA.gcf_getlocation(?), ?, +CBCCA.gcf_validvoter(?,?), +null, ?, ?); + +NOTE: "gcf_validvoter" find 'gctweb_srl' value + +" +CREATE OR REPLACE FUNCTION gcf_validvoter (VARCHAR, VARCHAR) + RETURNS NUMERIC AS ' +DECLARE + arg1 ALIAS FOR $1; + arg2 ALIAS FOR $2; + return_val NUMERIC; +BEGIN + SELECT SRL INTO return_val + FROM gctwebu + WHERE EMAIL = arg1 + AND UHASH = arg2; + + RETURN return_val; +END; +' LANGUAGE plpgsql; +" + + +Where the question marks are filled in with values in our java code. + +We are puzzled as to why there is this difference in performance when +inserting b/c we +believe that we have indexed all columns used by this constraint. And +we realize that +inserting 'null' into GCTBALLOT doesn't use this constraint b/c no look +up is necessary. +So this causes good performance. Why is it that when we use this +constraint that +the performance is effected so much? + + +Thanks + + +P.S. Even we added an index on 'gctwebu_srl' column and did +1- "Analyzed ALL TABLES" +2- "analyze GCTBALLOT(gctwebu_srl);" + +but still have the same problem! + + +From pgsql-performance-owner@postgresql.org Fri Aug 13 11:54:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BA7015E37CE + for ; + Fri, 13 Aug 2004 11:54:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84099-05 + for ; + Fri, 13 Aug 2004 14:54:27 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id B79185E3639 + for ; + Fri, 13 Aug 2004 11:54:24 -0300 (ADT) +Received: (qmail 2276 invoked by uid 500); 13 Aug 2004 15:02:43 -0000 +Date: Fri, 13 Aug 2004 10:02:43 -0500 +From: Bruno Wolff III +To: Rod Taylor +Cc: Ulrich Wisser , gnari , + Postgresql Performance +Subject: Re: insert +Message-ID: <20040813150243.GA2004@wolff.to> +Mail-Followup-To: Rod Taylor , + Ulrich Wisser , + gnari , + Postgresql Performance +References: <20040813111649.7B4116C4F8@tino.sinectis.com.ar> + <00cc01c4812b$4e7f02e0$0100000a@wp2000> + <411CAFA3.90005@relevanttraffic.se> + <1092401876.16087.236.camel@jester> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1092401876.16087.236.camel@jester> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/205 +X-Sequence-Number: 7841 + +On Fri, Aug 13, 2004 at 08:57:56 -0400, + Rod Taylor wrote: +> On Fri, 2004-08-13 at 08:10, Ulrich Wisser wrote: +> > Hi, +> > +> > my inserts are done in one transaction, but due to some foreign key +> > constraints and five indexes sometimes the 100 inserts will take more +> > than 5 minutes. +> +> It is likely that you are missing an index on one of those foreign key'd +> items. + +I don't think that is too likely as a foreign key reference must be a +unique key which would have an index. I think the type mismatch +suggestion is probably what the problem is. +The current solution is to make the types match. In 8.0.0 it would probably +work efficiently as is, though it isn't normal for foreign keys to have a type +mismatch and he may want to change that anyway. + +From pgsql-performance-owner@postgresql.org Fri Aug 13 13:00:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 602725E46D9 + for ; + Fri, 13 Aug 2004 12:20:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89519-08 + for ; + Fri, 13 Aug 2004 15:20:13 +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 B253F5E46D7 + for ; + Fri, 13 Aug 2004 12:20:00 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) + id 1Bvdqg-000Dj9-0W; Fri, 13 Aug 2004 15:20:06 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id AF59A16B85; Fri, 13 Aug 2004 16:20:04 +0100 (BST) +Message-ID: <411CDC24.4090706@archonet.com> +Date: Fri, 13 Aug 2004 16:20:04 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Arash Zaryoun +Cc: pgsql-performance@postgresql.org +Subject: Re: Weird Database Performance problem! +References: +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/210 +X-Sequence-Number: 7846 + +Arash Zaryoun wrote: +> Hi, +> +> We are having a performance problem with our database. The problem +> exists when we include a constraint in GCTBALLOT. The constraint is as +> follows: +> +> alter table GCTBALLOT +> add constraint FK_GCTBALLOT_GCTWEBU foreign key (GCTWEBU_SRL) +> references GCTWEBU (SRL) +> on delete restrict on update restrict; +> +> The two tables that we insert into are the following: + +> GCTBALLOT: +> gctwebu_srl | numeric(12,0) | + +> GCTWEBU: +> srl | integer | not null default + +Your types don't match. You have a numeric referencing an integer. PG +probably isn't using the index (it's smarter about this in 8.0 iirc). + +HTH +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Aug 13 15:10:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 21BE65E46CC + for ; + Fri, 13 Aug 2004 13:06:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 01153-10 + for ; + Fri, 13 Aug 2004 16:06:46 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id B579F5E46CB + for ; + Fri, 13 Aug 2004 13:06:37 -0300 (ADT) +Received: (qmail 5346 invoked from network); 13 Aug 2004 18:06:44 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 13 Aug 2004 18:06:44 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: fsync vs open_sync +References: <6EE64EF3AB31D5448D0007DD34EEB3412A744B@Herge.rcsinc.local> + <42528.64.119.142.34.1092244445.squirrel@mail.mohawksoft.com> +Message-ID: +Date: Fri, 13 Aug 2004 18:06:59 +0200 +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <42528.64.119.142.34.1092244445.squirrel@mail.mohawksoft.com> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/214 +X-Sequence-Number: 7850 + + +>> What caught my attention initially was the 300+/sec insert performance. +>> On 8.0/NTFS/fsync=on, I can't break 100/sec on a 10k rpm ATA disk. My +>> hardware seems to be more or less in the same league as psql's, so I was +>> naturally curious if this was a NT/Unix issue, a 7.4/8.0 issue, or a +>> combination of both. + + There is also the fact that NTFS is a very slow filesystem, and Linux is +a lot better than Windows for everything disk, caching and IO related. Try +to copy some files in NTFS and in ReiserFS... + +From pgsql-performance-owner@postgresql.org Fri Aug 13 14:43:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 35AAA5E46CB + for ; + Fri, 13 Aug 2004 13:12:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02156-10 + for ; + Fri, 13 Aug 2004 16:12:21 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 09F475E46C0 + for ; + Fri, 13 Aug 2004 13:12:12 -0300 (ADT) +Received: (qmail 5522 invoked from network); 13 Aug 2004 18:12:20 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 13 Aug 2004 18:12:20 +0200 +Date: Fri, 13 Aug 2004 18:12:34 +0200 +To: pgsql-performance@postgresql.org +Subject: Reiser4 +References: <411CDC24.4090706@archonet.com> +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <411CDC24.4090706@archonet.com> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/213 +X-Sequence-Number: 7849 + + + + ReiserFS 4 is (will be) a filesystem that implements transactions. + + Are there any plans in a future Postgresql version to support a special +fsync method for Reiser4 which will use the filesystem's transaction +engine, instead of an old kludge like fsync(), with a possibility of +vastly enhanced performance ? + + Is there also a possibility to tell Postgres : "I don't care if I lose 30 +seconds of transactions on this table if the power goes out, I just want +to be sure it's still ACID et al. compliant but you can fsync less often +and thus be faster" (with a possibility of setting that on a per-table +basis) ? + + Thanks. + +From pgsql-performance-owner@postgresql.org Fri Aug 13 14:14:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BD915E46E8 + for ; + Fri, 13 Aug 2004 13:17:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 03703-08 + for ; + Fri, 13 Aug 2004 16:17:15 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id ABACF5E46D4 + for ; + Fri, 13 Aug 2004 13:17:06 -0300 (ADT) +Received: from solent (82-68-95-1.dsl.in-addr.zen.co.uk [82.68.95.1]) + by bayswater1.ymogen.net (Postfix) with ESMTP + id 2A95FA5720; Fri, 13 Aug 2004 17:17:11 +0100 (BST) +Reply-To: +From: "Matt Clark" +To: "'Bruno Wolff III'" , "'Rod Taylor'" +Cc: "'Ulrich Wisser'" , + "'gnari'" , + "'Postgresql Performance'" +Subject: Re: insert +Date: Fri, 13 Aug 2004 17:17:10 +0100 +Organization: Ymogen Ltd +Message-ID: <006901c48150$fcfafb10$8300a8c0@solent> +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: <20040813150243.GA2004@wolff.to> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/212 +X-Sequence-Number: 7848 + +> > It is likely that you are missing an index on one of those foreign +> > key'd items. +> +> I don't think that is too likely as a foreign key reference +> must be a unique key which would have an index. + +I think you must be thinking of primary keys, not foreign keys. All +one-to-many relationships have non-unique foreign keys. + + +From pgsql-performance-owner@postgresql.org Fri Aug 13 13:23:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6DE325E37CE + for ; + Fri, 13 Aug 2004 13:23:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08839-09 + for ; + Fri, 13 Aug 2004 16:23:24 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 04BD45E46E1 + for ; + Fri, 13 Aug 2004 13:23:15 -0300 (ADT) +Received: (qmail 3862 invoked by uid 500); 13 Aug 2004 16:31:34 -0000 +Date: Fri, 13 Aug 2004 11:31:34 -0500 +From: Bruno Wolff III +To: Matt Clark +Cc: 'Rod Taylor' , + 'Ulrich Wisser' , + 'gnari' , + 'Postgresql Performance' +Subject: Re: insert +Message-ID: <20040813163134.GA3743@wolff.to> +Mail-Followup-To: Matt Clark , 'Rod Taylor' , + 'Ulrich Wisser' , + 'gnari' , + 'Postgresql Performance' +References: <20040813150243.GA2004@wolff.to> + <006901c48150$fcfafb10$8300a8c0@solent> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <006901c48150$fcfafb10$8300a8c0@solent> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/211 +X-Sequence-Number: 7847 + +On Fri, Aug 13, 2004 at 17:17:10 +0100, + Matt Clark wrote: +> > > It is likely that you are missing an index on one of those foreign +> > > key'd items. +> > +> > I don't think that is too likely as a foreign key reference +> > must be a unique key which would have an index. +> +> I think you must be thinking of primary keys, not foreign keys. All +> one-to-many relationships have non-unique foreign keys. + +The target of the reference needs to have at least a unique index. +I am not sure if it needs to actually be declared as either a unique +or primary key, though that is the intention. + +The records doing the referencing don't need (and normally aren't) +unique. + +From pgsql-benchmarks-owner@postgresql.org Sat Aug 14 17:05:59 2004 +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 C1B7E5E37D0; + Fri, 13 Aug 2004 14:20:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24091-03; Fri, 13 Aug 2004 17:19:56 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 760795E37CE; + Fri, 13 Aug 2004 14:19:55 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6068795; Fri, 13 Aug 2004 10:21:11 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Arash Zaryoun" , , + , +Subject: Re: [PERFORM] Performance Problem With Postgresql! +Date: Fri, 13 Aug 2004 10:19:15 -0700 +User-Agent: KMail/1.4.3 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408131019.15036.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/2 +X-Sequence-Number: 15 + +Arash, + +> We are having a performance problem with our database. The problem +> exists when we include a constraint in GCTBALLOT. The constraint is as +> follows: + +You posted twice, to three different mailing lists each time. This is +discourteous. Please do not do so again, as people may not help you if they +feel you are being rude. + +Richard H has posted the solution to your problem. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Aug 13 15:46:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AD79E5E46CD + for ; + Fri, 13 Aug 2004 15:01:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34680-07 + for ; + Fri, 13 Aug 2004 18:01:39 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id C61195E40BA + for ; + Fri, 13 Aug 2004 15:01:36 -0300 (ADT) +Received: from [64.81.245.111] (HELO temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6069025; Fri, 13 Aug 2004 11:02:52 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: =?iso-8859-15?q?Pierre-Fr=E9d=E9ric=20Caillaud?= + , pgsql-performance@postgresql.org +Subject: Re: Reiser4 +Date: Fri, 13 Aug 2004 11:01:52 -0700 +User-Agent: KMail/1.5.4 +References: <411CDC24.4090706@archonet.com> + +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-15" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200408131101.52788.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/216 +X-Sequence-Number: 7852 + +Pierre, + +> Are there any plans in a future Postgresql version to support a special +> fsync method for Reiser4 which will use the filesystem's transaction +> engine, instead of an old kludge like fsync(), with a possibility of +> vastly enhanced performance ? + +I don't know of any such in progress right now. Why don't you start it? It +would have to be an add-in since we support 28 operating systems and Reiser +is AFAIK Linux-only, but it sounds like an interesting experiment. + +> Is there also a possibility to tell Postgres : "I don't care if I lose 30 +> seconds of transactions on this table if the power goes out, I just want +> to be sure it's still ACID et al. compliant but you can fsync less often +> and thus be faster" (with a possibility of setting that on a per-table +> basis) ? + +Not per-table, no, but otherwise take a look at the Background Writer feature +of 8.0. + +-- +-Josh Berkus + "A developer of Very Little Brain" + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Aug 13 15:44:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8DAB85E40BA + for ; + Fri, 13 Aug 2004 15:02:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35345-02 + for ; + Fri, 13 Aug 2004 18:02: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 693575E37CE + for ; + Fri, 13 Aug 2004 15:02:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7DI1xdx025255; + Fri, 13 Aug 2004 14:01:59 -0400 (EDT) +To: Bruno Wolff III +Cc: Rod Taylor , Ulrich Wisser , + gnari , + Postgresql Performance +Subject: Re: insert +In-reply-to: <20040813150243.GA2004@wolff.to> +References: <20040813111649.7B4116C4F8@tino.sinectis.com.ar> + <00cc01c4812b$4e7f02e0$0100000a@wp2000> + <411CAFA3.90005@relevanttraffic.se> + <1092401876.16087.236.camel@jester> + <20040813150243.GA2004@wolff.to> +Comments: In-reply-to Bruno Wolff III + message dated "Fri, 13 Aug 2004 10:02:43 -0500" +Date: Fri, 13 Aug 2004 14:01:59 -0400 +Message-ID: <25254.1092420119@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/215 +X-Sequence-Number: 7851 + +Bruno Wolff III writes: +> Rod Taylor wrote: +>> It is likely that you are missing an index on one of those foreign key'd +>> items. + +> I don't think that is too likely as a foreign key reference must be a +> unique key which would have an index. I think the type mismatch +> suggestion is probably what the problem is. + +I agree. It is possible to have a lack-of-index problem on the +referencing column (as opposed to the referenced column), but that +normally only hurts you for deletes from the referenced table. + +> The current solution is to make the types match. In 8.0.0 it would probably +> work efficiently as is, though it isn't normal for foreign keys to have a type +> mismatch and he may want to change that anyway. + +8.0 will not fix this particular issue, as I did not add any numeric-vs-int +comparison operators. If we see a lot of complaints we could think +about adding such, but for 8.0 only the more common cases such as +int-vs-bigint are covered. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 13 18:05:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 037A55E46BF + for ; + Fri, 13 Aug 2004 16:24:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58663-03 + for ; + Fri, 13 Aug 2004 19:23:52 +0000 (GMT) +Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net + [194.217.242.86]) + by svr1.postgresql.org (Postfix) with ESMTP id D0E365E37D0 + for ; + Fri, 13 Aug 2004 16:23:51 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BvheZ-000LZa-0b; Fri, 13 Aug 2004 19:23:51 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id A542E1851F; Fri, 13 Aug 2004 20:23:50 +0100 (BST) +Message-ID: <411D1548.20408@archonet.com> +Date: Fri, 13 Aug 2004 20:23:52 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Arash Zaryoun +Cc: Postgresql Performance +Subject: Re: Weird Database Performance problem! +References: +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/219 +X-Sequence-Number: 7855 + +Arash Zaryoun wrote: +> Hi Richard, +> +> Thanks for your prompt reply. It fixed the problem. +> Just one more question: Do I need to create an index for FKs? + +You don't _need_ to, but on the referring side (e.g. table GCTBALLOT in +your example) PostgreSQL won't create one automatically. + +Of course, the primary-key side will already have an index being used as +part of the constraint. + +I've cc:ed the list on this, the question pops up quite commonly. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Aug 13 17:29:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 97AEB5E46C0 + for ; + Fri, 13 Aug 2004 16:58:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63901-10 + for ; + Fri, 13 Aug 2004 19:58:21 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id 66BD95E3F15 + for ; + Fri, 13 Aug 2004 16:58:19 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: fsync vs open_sync +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Fri, 13 Aug 2004 15:58:25 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A745B@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] fsync vs open_sync +thread-index: AcSBYgClh+KM1mTQRmm9nDeFFsXCqQACwtQQ +From: "Merlin Moncure" +To: =?iso-8859-1?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/218 +X-Sequence-Number: 7854 + +> There is also the fact that NTFS is a very slow filesystem, and +> Linux is +> a lot better than Windows for everything disk, caching and IO related. Try +> to copy some files in NTFS and in ReiserFS... + +I'm not so sure I would agree with such a blanket generalization. I find N= +TFS to be very fast, my main complaint is fragmentation issues...I bet NTFS= + is better than ext3 at most things (I do agree with you about the cache, t= +houghO. + +I think in very general sense the open source stuff is higher quality but M= +icrosoft benefits from a very tight vertical integration of the system. Th= +ey added ReadFileScatter and WriteFileScatter to the win32 api specifically= + to make SQL Server run faster and SQL server is indeed very, very good at = +i/o. + +SQL Server keeps a one file database with blocks collected and written asyn= +chronously. It's a very tight system because they have control over every = +layer of the system. + +Know your enemy. + +That said, I think transaction based file I/O is 'the way' and if implement= +ed on Reiser4 faster than I/O methodology than offered on windows/ntfs.=20= +=20 + +Merlin + +From pgsql-performance-owner@postgresql.org Fri Aug 13 18:58:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 55AC85E3F15 + for ; + Fri, 13 Aug 2004 18:40:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92206-02 + for ; + Fri, 13 Aug 2004 21:40:12 +0000 (GMT) +Received: from hotmail.com (bay17-dav19.bay17.hotmail.com [64.4.43.199]) + by svr1.postgresql.org (Postfix) with ESMTP id C7D0C5E37D0 + for ; + Fri, 13 Aug 2004 18:40:10 -0300 (ADT) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Fri, 13 Aug 2004 14:39:47 -0700 +Received: from 142.104.250.115 by bay17-dav19.bay17.hotmail.com with DAV; + Fri, 13 Aug 2004 21:39:46 +0000 +X-Originating-IP: [142.104.250.115] +X-Originating-Email: [borajetta@hotmail.com] +X-Sender: borajetta@hotmail.com +From: "borajetta" +To: +Subject: REINDEX needed because of index corruption need help ASAP +Date: Fri, 13 Aug 2004 14:40:26 -0700 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0034_01C48143.7925F860" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Message-ID: +X-OriginalArrivalTime: 13 Aug 2004 21:39:47.0214 (UTC) + FILETIME=[0DE43AE0:01C4817E] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_20_30, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200408/220 +X-Sequence-Number: 7856 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0034_01C48143.7925F860 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +select count(*) FROM items_2004_07_29 as items WHERE true AND index @@ to_t= +squery('default', '( audiovox)') ; + count=20 +------- + 4 +(1 row) + +aers=3D# reindex index idx_title_2004_07_29; +REINDEX +aers=3D# select count(*) FROM items_2004_07_29 as items WHERE true AND inde= +x @@ to_tsquery('default', '( audiovox)') ; + count=20 +------- + 2342 +(1 row) + + +Here are 2 searches using a gist index, the first one has a gist index whic= +h is not properly created but does not though an error in creation. After = +doing a few searches I noticed the numbers were way off so I reindexed. Th= +e problem was fixed and the search works properly. + +Is there a problem with indexing? Do you know of this problem? +Is there a way to fix it? + +We are getting this error for other index's including primary key indexs wh= +ere we get OID page not found errors and the index corruption as posted abo= +ve. +Sometimes when the index is broken it will cause run away searches which ea= +t up all the memory and the server needs to be restarted. + +Anyways this all looks to be in index problem, vacuum/analyze does not fix = +it only reindexing does. + +Thank you, + +Aaron +------=_NextPart_000_0034_01C48143.7925F860 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
+
+
select count(*) FROM items_2004_07_29 as i= +tems=20 +WHERE true AND index @@ to_tsquery('default', '( audiovox)') ;
 cou= +nt=20 +
-------
     4
(1 row)
+
 
+
aers=3D# reindex index=20 +idx_title_2004_07_29;
REINDEX
aers=3D# select count(*) FROM items_200= +4_07_29=20 +as items WHERE true AND index @@ to_tsquery('default', '( audiovox)')=20 +;
 count
-------
  2342
(1 row)
+
 
+
Here are 2 searches using a gist index, th= +e first=20 +one has a gist index which is not properly created but does not though an e= +rror=20 +in creation.  After doing a few searches I noticed the numbers were wa= +y off=20 +so I reindexed.  The problem was fixed and the search works=20 +properly.
+
 
+
Is there a problem with indexing?  Do= + you know=20 +of this problem?
+
Is there a way to fix it?
+
 
+
We are getting this error for other index's including primary key inde= +xs=20 +where we get OID page not found errors and the index corruption as posted= +=20 +above.
+
Sometimes when the index is broken it will cause run away searches whi= +ch=20 +eat up all the memory and the server needs to be restarted.
+
 
+
Anyways this all looks to be in index problem, vacuum/analyze does not= + fix=20 +it only reindexing does.
+
 
+
Thank you,
+
 
+
Aaron
+ +------=_NextPart_000_0034_01C48143.7925F860-- + +From pgsql-performance-owner@postgresql.org Fri Aug 13 19:41:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AB9FD5E46CE + for ; + Fri, 13 Aug 2004 19:18:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99798-10 + for ; + Fri, 13 Aug 2004 22:18:29 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C4835E46C4 + for ; + Fri, 13 Aug 2004 19:18:27 -0300 (ADT) +Received: from [64.81.245.111] (HELO temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6072709; Fri, 13 Aug 2004 15:19:41 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "borajetta" , + +Subject: Re: REINDEX needed because of index corruption need help ASAP +Date: Fri, 13 Aug 2004 15:18:41 -0700 +User-Agent: KMail/1.5.4 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200408131518.41992.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/222 +X-Sequence-Number: 7858 + +Aaron, + +> We are getting this error for other index's including primary key indexs +where we get OID page not found errors and the index corruption as posted +above. +> Sometimes when the index is broken it will cause run away searches which eat +up all the memory and the server needs to be restarted. + +What version of PostgreSQL are you using? +Do you have frequent power-outs on the machine? +Have you tested for bad hard drive, controller, or memory? + +Corruption of any kind on PostgreSQL is not normal. It's usually indicative +of a hardware problem. + +-- +-Josh Berkus + "A developer of Very Little Brain" + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Aug 13 19:38:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 419615E37D0 + for ; + Fri, 13 Aug 2004 19:25:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02951-08 + for ; + Fri, 13 Aug 2004 22:25: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 5BA2D5E37CB + for ; + Fri, 13 Aug 2004 19:25:12 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7DMNxQS027756; + Fri, 13 Aug 2004 18:23:59 -0400 (EDT) +To: "borajetta" +Cc: pgsql-performance@postgresql.org +Subject: Re: REINDEX needed because of index corruption need help ASAP +In-reply-to: +References: +Comments: In-reply-to "borajetta" + message dated "Fri, 13 Aug 2004 14:40:26 -0700" +Date: Fri, 13 Aug 2004 18:23:59 -0400 +Message-ID: <27755.1092435839@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/221 +X-Sequence-Number: 7857 + +"borajetta" writes: +> We are getting this error for other index's including primary key indexs wh= +> ere we get OID page not found errors and the index corruption as posted abo= +> ve. +> Sometimes when the index is broken it will cause run away searches which ea= +> t up all the memory and the server needs to be restarted. + +It sounds to me like you have got hardware problems. Get out your +memory and disk tests ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 13 22:27:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C78A5E37CB + for ; + Fri, 13 Aug 2004 22:27:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44706-09 + for ; + Sat, 14 Aug 2004 01:27:18 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.207]) + by svr1.postgresql.org (Postfix) with ESMTP id 934125E3639 + for ; + Fri, 13 Aug 2004 22:27:11 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id 76so31740rnl + for ; + Fri, 13 Aug 2004 18:27:04 -0700 (PDT) +Received: by 10.38.70.74 with SMTP id s74mr186332rna; + Fri, 13 Aug 2004 18:27:04 -0700 (PDT) +Message-ID: +Date: Fri, 13 Aug 2004 18:27:04 -0700 +From: Chris Cheston +To: pgsql-performance@postgresql.org +Subject: Replication: Slony-I vs. Mammoth Replicator vs. ? +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/223 +X-Sequence-Number: 7859 + +HI all, I'm trying to implement a highly-scalable, high-performance, +real-time database replication system to back-up my Postgres database +as data gets written. + +So far, Mammoth Replicator is looking pretty good but it costs $1000+ . + +Has anyone tried Slony-I and other replication systems? Slony-I is +pretty new so I'm a little unsure if it's ready for a prime-time +commercial system yet. + +So... wanted to put this out to the experts. Has anyone got any +recommendations or had experiences with real-time database replication +solutions that don't rely on RAID? The reason why I don't want to +rely on a hardware solution is because we are renting dedicated +servers and we don't have access to the boxes, only to software that +gets installed on the boxes. + +Thanks, +Chris + +From pgsql-hackers-owner@postgresql.org Fri Aug 13 22:31:09 2004 +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 3040F5E46C1; + Fri, 13 Aug 2004 22:30:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 46708-03; Sat, 14 Aug 2004 01:30:53 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C76C5E3639; + Fri, 13 Aug 2004 22:30:45 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i7E1Ulf06800; + Fri, 13 Aug 2004 21:30:47 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200408140130.i7E1Ulf06800@candle.pha.pa.us> +Subject: Re: [PERFORM] Reiser4 +In-Reply-To: +To: =?ISO-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +Date: Fri, 13 Aug 2004 21:30:47 -0400 (EDT) +Cc: pgsql-performance@postgresql.org, + PostgreSQL-development +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Content-Type: text/plain; charset=UNKNOWN-8BIT +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/832 +X-Sequence-Number: 57801 + +Pierre-Fr�d�ric Caillaud wrote: +> Is there also a possibility to tell Postgres : "I don't care if I lose 30 +> seconds of transactions on this table if the power goes out, I just want +> to be sure it's still ACID et al. compliant but you can fsync less often +> and thus be faster" (with a possibility of setting that on a per-table +> basis) ? + +I have been thinking about this. Informix calls it buffered logging and +it would be a good feature. + +Added to TODO: + +* Allow buffered WAL writes and fsync + + Instead of guaranteeing recovery of all committed transactions, this + would provide improved performance by delaying WAL writes and fsync + so an abrupt operating system restart might lose a few seconds of + committed transactions but still be consistent. We could perhaps + remove the 'fsync' parameter (which results in an an inconsistent + database) in favor of this capability. + +-- + 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 Aug 13 22:34:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 08EFF5E46CE + for ; + Fri, 13 Aug 2004 22:31:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45918-07 + for ; + Sat, 14 Aug 2004 01:31:44 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id D61D45E46BF + for ; + Fri, 13 Aug 2004 22:31:41 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i7E1VgO06945; + Fri, 13 Aug 2004 21:31:42 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200408140131.i7E1VgO06945@candle.pha.pa.us> +Subject: Re: Reiser4 +In-Reply-To: <200408131101.52788.josh@agliodbs.com> +To: josh@agliodbs.com +Date: Fri, 13 Aug 2004 21:31:42 -0400 (EDT) +Cc: =?ISO-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/225 +X-Sequence-Number: 7861 + +Josh Berkus wrote: +> Pierre, +> +> > Are there any plans in a future Postgresql version to support a special +> > fsync method for Reiser4 which will use the filesystem's transaction +> > engine, instead of an old kludge like fsync(), with a possibility of +> > vastly enhanced performance ? +> +> I don't know of any such in progress right now. Why don't you start it? It +> would have to be an add-in since we support 28 operating systems and Reiser +> is AFAIK Linux-only, but it sounds like an interesting experiment. +> +> > Is there also a possibility to tell Postgres : "I don't care if I lose 30 +> > seconds of transactions on this table if the power goes out, I just want +> > to be sure it's still ACID et al. compliant but you can fsync less often +> > and thus be faster" (with a possibility of setting that on a per-table +> > basis) ? +> +> Not per-table, no, but otherwise take a look at the Background Writer feature +> of 8.0. + +Actually the fsync of WAL is the big performance issue here. I added a +TODO item about it. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Fri Aug 13 22:42:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F3815E46CB + for ; + Fri, 13 Aug 2004 22:42:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49483-02 + for ; + Sat, 14 Aug 2004 01:42:27 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 8FDF15E46BF + for ; + Fri, 13 Aug 2004 22:42:25 -0300 (ADT) +Received: from [192.168.1.51] (dsl093-038-087.pdx1.dsl.speakeasy.net + [66.93.38.87]) (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i7E1dCP13778; + Fri, 13 Aug 2004 18:39:12 -0700 +Message-ID: <411D6D47.5020203@commandprompt.com> +Date: Fri, 13 Aug 2004 18:39:19 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla Thunderbird 0.7.1 (X11/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Chris Cheston +Cc: pgsql-performance@postgresql.org +Subject: Re: Replication: Slony-I vs. Mammoth Replicator vs. ? +References: +In-Reply-To: +Content-Type: multipart/mixed; boundary="------------050809030603050003000301" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/226 +X-Sequence-Number: 7862 + +This is a multi-part message in MIME format. +--------------050809030603050003000301 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Chris Cheston wrote: +> HI all, I'm trying to implement a highly-scalable, high-performance, +> real-time database replication system to back-up my Postgres database +> as data gets written. +> +> So far, Mammoth Replicator is looking pretty good but it costs $1000+ . + +Yes but it includes 30 days of support and 12 months of upgrades/updates :) + + +> Has anyone tried Slony-I and other replication systems? Slony-I is +> pretty new so I'm a little unsure if it's ready for a prime-time +> commercial system yet. + +It really depends on your needs. They are both good systems. Slony-I is +a bit more of a beast to get up and running, and it is a batch +replication system that uses triggers. Once it is up and running it +works well though. + +Mammoth Replicator is easy to setup and is integrated into PostgreSQL. +However replicator is 1000+ and doesn't support promoting of slaves +automatically (you can do it by hand) like Slony does. Replicator is +also live replication. + +Sincerely, + +Joshua D. Drake + + + +> +> So... wanted to put this out to the experts. Has anyone got any +> recommendations or had experiences with real-time database replication +> solutions that don't rely on RAID? The reason why I don't want to +> rely on a hardware solution is because we are renting dedicated +> servers and we don't have access to the boxes, only to software that +> gets installed on the boxes. +> +> Thanks, +> Chris +> +> ---------------------------(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 + + +-- +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 +Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL + +--------------050809030603050003000301 +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 D. Drake +n:Drake;Joshua D. +org:Command Prompt, Inc. +adr:;;PO Box 215;Cascade Locks;Oregon;97014;USA +email;internet:jd@commandprompt.com +title:Consultant +tel;work:503-667-4564 +tel;fax:503-210-0034 +note:Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. +x-mozilla-html:FALSE +url:http://www.commandprompt.com/ +version:2.1 +end:vcard + + +--------------050809030603050003000301-- + +From pgsql-hackers-owner@postgresql.org Sat Aug 14 07:57:55 2004 +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 9EA425E46D5 + for ; + Sat, 14 Aug 2004 07:57:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58038-02 + for ; + Sat, 14 Aug 2004 10:57:45 +0000 (GMT) +Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) + by svr1.postgresql.org (Postfix) with SMTP id 066E05E46D2 + for ; + Sat, 14 Aug 2004 07:57:38 -0300 (ADT) +Received: (qmail 13227 invoked by uid 65534); 14 Aug 2004 10:57:41 -0000 +Received: from dsl-082-082-232-112.arcor-ip.net (EHLO colt.pezone.net) + (82.82.232.112) + by mail.gmx.net (mp020) with SMTP; 14 Aug 2004 12:57:41 +0200 +X-Authenticated: #495269 +From: Peter Eisentraut +To: Bruce Momjian , + =?iso-8859-1?q?Pierre-Fr=E9d=E9ric=20Caillaud?= + +Subject: Re: [PERFORM] Reiser4 +Date: Sat, 14 Aug 2004 12:57:37 +0200 +User-Agent: KMail/1.5.1 +Cc: pgsql-performance@postgresql.org, + PostgreSQL-development +References: <200408140130.i7E1Ulf06800@candle.pha.pa.us> +In-Reply-To: <200408140130.i7E1Ulf06800@candle.pha.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 8bit +Content-Disposition: inline +Message-Id: <200408141257.37201.peter_e@gmx.net> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/850 +X-Sequence-Number: 57819 + +Bruce Momjian wrote: +> Pierre-Fr�d�ric Caillaud wrote: +> > Is there also a possibility to tell Postgres : "I don't care if I +> > lose 30 seconds of transactions on this table if the power goes +> > out, I just want to be sure it's still ACID et al. compliant but +> > you can fsync less often and thus be faster" (with a possibility of +> > setting that on a per-table basis) ? + +Then it would be "ACI" compliant. + +-- +Peter Eisentraut +http://developer.postgresql.org/~petere/ + + +From pgsql-performance-owner@postgresql.org Sat Aug 14 11:41:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B95755E46CA + for ; + Sat, 14 Aug 2004 11:41:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 99139-02 + for ; + Sat, 14 Aug 2004 14:41:44 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id A8A4C5E3F15 + for ; + Sat, 14 Aug 2004 11:41:41 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7EEfhiG000373 + for ; Sat, 14 Aug 2004 14:41:43 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7EEP8K6097482 + for pgsql-performance@postgresql.org; Sat, 14 Aug 2004 14:25:08 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: insert +Date: Sat, 14 Aug 2004 16:24:08 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 20 +Message-ID: +References: <20040813100800.24FC86C37F@honorio.sinectis.com.ar> + <009c01c48123$270f7760$0100000a@wp2000> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: <009c01c48123$270f7760$0100000a@wp2000> +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/227 +X-Sequence-Number: 7863 + +gnari wrote: + +> "G u i d o B a r o s i o" wrote: +> +> [speeding up 100 inserts every 5 minutes] +> +> +>>Tips! +>>*Delete indexes and recreate them after the insert. +> +> +> sounds a bit extreme, for only 100 inserts + +which fsync method are you using ? +change it and see what happen + +Regards +Gaetano Mendola + + + +From pgsql-performance-owner@postgresql.org Sat Aug 14 12:33:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AD0A85E46C4 + for ; + Sat, 14 Aug 2004 12:33:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08700-08 + for ; + Sat, 14 Aug 2004 15:33:38 +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 9CFB75E46E0 + for ; + Sat, 14 Aug 2004 12:33:29 -0300 (ADT) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp104.mail.sc5.yahoo.com with SMTP; 14 Aug 2004 15:33:35 -0000 +Received: from [172.21.8.18] ([192.168.192.101]) (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i7EFXUT7016079; Sat, 14 Aug 2004 11:33:34 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <411E30C4.8020909@Yahoo.com> +Date: Sat, 14 Aug 2004 11:33:24 -0400 +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: "Joshua D. Drake" +Cc: Chris Cheston , + pgsql-performance@postgresql.org +Subject: Re: Replication: Slony-I vs. Mammoth Replicator vs. ? +References: + <411D6D47.5020203@commandprompt.com> +In-Reply-To: <411D6D47.5020203@commandprompt.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/228 +X-Sequence-Number: 7864 + +On 8/13/2004 9:39 PM, Joshua D. Drake wrote: + +> Chris Cheston wrote: +>> HI all, I'm trying to implement a highly-scalable, high-performance, +>> real-time database replication system to back-up my Postgres database +>> as data gets written. +>> +>> So far, Mammoth Replicator is looking pretty good but it costs $1000+ . +> +> Yes but it includes 30 days of support and 12 months of upgrades/updates :) + +The lead developer of Slony (me) is working for a company that has it +deployed in production already and will move more mission critical +systems to it very shortly. Guess what will be my top work priority if +you spot a bug? + +> +> +>> Has anyone tried Slony-I and other replication systems? Slony-I is +>> pretty new so I'm a little unsure if it's ready for a prime-time +>> commercial system yet. +> +> It really depends on your needs. They are both good systems. Slony-I is +> a bit more of a beast to get up and running, and it is a batch +> replication system that uses triggers. Once it is up and running it +> works well though. +> +> Mammoth Replicator is easy to setup and is integrated into PostgreSQL. +> However replicator is 1000+ and doesn't support promoting of slaves +> automatically (you can do it by hand) like Slony does. Replicator is +> also live replication. + +Once again, Joshua, would you please explain what you mean with "batch" +and "live" replication system? Slony does group multiple "master" +transactions into one replication transaction to improve performance +(fewer commits on the slaves). The interval of these groups is +configurable and for high volume DBs it is recommended to use about one +second, which means that all commits that fall into an interval of one +second are replicated in one transaction on the slave. On normal running +systems this results in a replication lag of 600 to 800 milliseconds in +average. On overloaded systems the asynchronous nature of course allows +the slaves to fall behind. + +What is a usual average replication lag of Mammoth Replicator? + +What happens to the other existing slaves when you promote by hand? In +Slony they accept the new master and continue replicating without the +need of rebuilding from scratch. Slony has mechanisms to ensure the new +master will be ahead or equal in the replication process at the time it +takes over and allows client application updates. + +The Slony documentation is an issue at the moment and the administrative +tools around it are immature. The replication engine itself exceeds my +own expectations and performs very robust. + + +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 Sat Aug 14 13:31:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 678405E37D0 + for ; + Sat, 14 Aug 2004 13:31:04 -0300 (ADT) +Received: 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-10 + for ; + Sat, 14 Aug 2004 16:31:08 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B9DC5E3639 + for ; + Sat, 14 Aug 2004 13:31:00 -0300 (ADT) +Received: from commandprompt.com (clbb-248.saw.net [64.146.135.248]) + (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i7EGPjP08276; + Sat, 14 Aug 2004 09:25:45 -0700 +Message-ID: <411E3C3B.5060808@commandprompt.com> +Date: Sat, 14 Aug 2004 09:22:19 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jan Wieck +Cc: Chris Cheston , + pgsql-performance@postgresql.org +Subject: Re: Replication: Slony-I vs. Mammoth Replicator vs. ? +References: + <411D6D47.5020203@commandprompt.com> <411E30C4.8020909@Yahoo.com> +In-Reply-To: <411E30C4.8020909@Yahoo.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/229 +X-Sequence-Number: 7865 + + +> +> Once again, Joshua, would you please explain what you mean with +> "batch" and "live" replication system? Slony does group multiple +> "master" transactions into one replication transaction to improve +> performance (fewer commits on the slaves). The interval of these +> groups is configurable and for high volume DBs it is recommended to +> use about one second, which means that all commits that fall into an +> interval of one second are replicated in one transaction on the slave. +> On normal running systems this results in a replication lag of 600 to +> 800 milliseconds in average. On overloaded systems the asynchronous +> nature of course allows the slaves to fall behind. + + +Your description above is what I considered batch... you are taking a +"batch" of transactions and replicating them versus each transaction. I +am not saying it is bad in any way. I am just saying it is different +that replicator. + +> What is a usual average replication lag of Mammoth Replicator? +> +Obviously it depends on the system, the network connectivity between the +systems etc... In our test systems it takes less than 100 ms to +replicate the data. Again it depends on the size of the transaction (the +data being moved). + +> What happens to the other existing slaves when you promote by hand? + +This is something that Slony has over replicator. Currently the new +master will force a full dump to the slaves. Of course this is already +on the road map, thanks to Slony :) and should be resolved by months end. + +> The Slony documentation is an issue at the moment and the +> administrative tools around it are immature. The replication engine +> itself exceeds my own expectations and performs very robust. +> +I have never suggested otherwise. My only comment about maturity is that +their are actually many companies using replicator in production. We +have already dealt with the 1.0 blues as they say. + +I hope you understand that I, in no way have ever suggested (purposely) +anything negative about Slony. Only that I believe they serve different +technical solutions. + +Sincerely, + +Joshua D. Drake + + + +> +> Jan +> + + +-- +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 Sat Aug 14 14:56:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7360D5E46C8 + for ; + Sat, 14 Aug 2004 14:56:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40516-10 + for ; + Sat, 14 Aug 2004 17:56:50 +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 90A8A5E46BF + for ; + Sat, 14 Aug 2004 14:56:49 -0300 (ADT) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp104.mail.sc5.yahoo.com with SMTP; 14 Aug 2004 17:56:49 -0000 +Received: from [172.21.8.18] ([192.168.192.101]) (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i7EHucT7016549; Sat, 14 Aug 2004 13:56:41 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <411E524F.60709@Yahoo.com> +Date: Sat, 14 Aug 2004 13:56:31 -0400 +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: "Joshua D. Drake" +Cc: Chris Cheston , + pgsql-performance@postgresql.org +Subject: Re: Replication: Slony-I vs. Mammoth Replicator vs. ? +References: + <411D6D47.5020203@commandprompt.com> <411E30C4.8020909@Yahoo.com> + <411E3C3B.5060808@commandprompt.com> +In-Reply-To: <411E3C3B.5060808@commandprompt.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/230 +X-Sequence-Number: 7866 + +On 8/14/2004 12:22 PM, Joshua D. Drake wrote: + +> I hope you understand that I, in no way have ever suggested (purposely) +> anything negative about Slony. Only that I believe they serve different +> technical solutions. + +You know I never took anything you said negative. I think People here +need to know that we two have communicated and collaborated outside of +the public mailing lists, that we still do it and that we do not +consider each other as opponents. There is a natural overlap in the +systems we offer and therefore there is some competition. Software +development is a sport. For some professionals this sport happens to be +the main source of income. But that shall not spoil the spirit here. + + +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 Sat Aug 14 18:11:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 160E35E3F15 + for ; + Sat, 14 Aug 2004 18:11:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86462-03 + for ; + Sat, 14 Aug 2004 21:11:52 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id D4CC25E37D0 + for ; + Sat, 14 Aug 2004 18:11:50 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7ELBniG087324 + for ; Sat, 14 Aug 2004 21:11:49 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7EKnvWJ083309 + for pgsql-performance@postgresql.org; Sat, 14 Aug 2004 20:49:57 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Replication: Slony-I vs. Mammoth Replicator vs. ? +Date: Sat, 14 Aug 2004 15:58:18 -0400 +Organization: cbbrowne Computing Inc +Lines: 26 +Message-ID: +References: + <411D6D47.5020203@commandprompt.com> <411E30C4.8020909@Yahoo.com> + <411E3C3B.5060808@commandprompt.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.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through + Obscurity, + linux) +Cancel-Lock: sha1:0CybtXmfdGTGyDIuvt/yfPEBtWM= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/232 +X-Sequence-Number: 7868 + +Centuries ago, Nostradamus foresaw when jd@commandprompt.com ("Joshua D. Drake") would write: +> I hope you understand that I, in no way have ever suggested +> (purposely) anything negative about Slony. Only that I believe they +> serve different technical solutions. + +Stipulating that I may have some bias ;-), I still don't find it at +all clear what the different situations are "shaped like" that lead to +Mammoth being forcibly preferable to Slony-I. + +(Note that I have a pretty decent understanding about how ERS and +Slony work, so I'm not too frightened of technicalities... I set up +instances of both on Thursday, so I'm pretty up to speed :-).) + +Win32 support may be true at the moment, although I have to discount +that as we only just got the start of a beta release of native Win32 +support for PostgreSQL proper. For that very reason, I had to point +my youngest brother who needed "something better than Access" to +Firebird last Saturday; I played with my niece while he was doing the +install. And there is little reason to think that Slony-I won't be +portable to Win32 given a little interest and effort, particularly +once work to make it play well with "pgxs" gets done. +-- +(format nil "~S@~S" "cbbrowne" "ntlug.org") +http://www3.sympatico.ca/cbbrowne/multiplexor.html +"At Microsoft, it doesn't matter which file you're compiling, only +which flags you #define." -- Colin Plumb + +From pgsql-performance-owner@postgresql.org Sat Aug 14 21:58:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A062E5E46D4 + for ; + Sat, 14 Aug 2004 21:58:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30217-02 + for ; + Sun, 15 Aug 2004 00:58:30 +0000 (GMT) +Received: from hosting.commandprompt.com (128.commandprompt.com + [207.173.200.128]) + by svr1.postgresql.org (Postfix) with ESMTP id 096215E46BF + for ; + Sat, 14 Aug 2004 21:58:28 -0300 (ADT) +Received: from commandprompt.com (clbb-248.saw.net [64.146.135.248]) + (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i7F0wVP24448; + Sat, 14 Aug 2004 17:58:31 -0700 +Message-ID: <411EB469.6020406@commandprompt.com> +Date: Sat, 14 Aug 2004 17:55:05 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Subject: Re: Replication: Slony-I vs. Mammoth Replicator vs. ? +References: + <411D6D47.5020203@commandprompt.com> <411E30C4.8020909@Yahoo.com> + <411E3C3B.5060808@commandprompt.com> + +In-Reply-To: +Content-Type: multipart/alternative; + boundary="------------040508050809090200040805" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.5 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE, + HTML_TITLE_EMPTY +X-Spam-Level: +X-Archive-Number: 200408/233 +X-Sequence-Number: 7869 + +This is a multi-part message in MIME format. +--------------040508050809090200040805 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Christopher Browne wrote: + +>Centuries ago, Nostradamus foresaw when jd@commandprompt.com ("Joshua D. Drake") would write: +> +> +>>I hope you understand that I, in no way have ever suggested +>>(purposely) anything negative about Slony. Only that I believe they +>>serve different technical solutions. +>> +>> +> +>Stipulating that I may have some bias ;-), I still don't find it at +>all clear what the different situations are "shaped like" that lead to +>Mammoth being forcibly preferable to Slony-I. +> +> +I would choose replicator if: + +1. You want ease of setup +2. You want your each transaction to be replicated at time of commit +3. Your database is already laden with triggers +4. You are pushing a very high transactional load* + +* Caveat I have no idea how well Slony performs on a system that does +say 200,000 transactions +an hours that are heavily geared toward updates. Replicator performs +very well in this scenario. + +5. Replicators administrative tools are more mature than Slony (for +example you know exactly what state your slaves are in with Replicator). + +I would choose Slony if: + +1. The fact that it is Open Source matters to you +2. The auto promotion of slaves is important* + +*This will be fixed in a couple of weeks with Replicator + +To be fair, in the real world --- + +It doesn't make a bit of difference which one you choose it really comes +down to this: + +Replicator is dumb simple to setup. Any halfway talented person can +setup replicator +in 30 minutes with a single master / slave configuration. + +Slony is Open Source and thus a little easier on the pocket book initially. + +Command Prompt, will support either one -- so the Replicator is +commercially supported +argument is a little weak here. + +Sincerely, + +Joshua D. Drake + + + + +Sincerely, + +Joshua D. Drake + + + + +>(Note that I have a pretty decent understanding about how ERS and +>Slony work, so I'm not too frightened of technicalities... I set up +>instances of both on Thursday, so I'm pretty up to speed :-).) +> +>Win32 support may be true at the moment, although I have to discount +>that as we only just got the start of a beta release of native Win32 +>support for PostgreSQL proper. For that very reason, I had to point +>my youngest brother who needed "something better than Access" to +>Firebird last Saturday; I played with my niece while he was doing the +>install. And there is little reason to think that Slony-I won't be +>portable to Win32 given a little interest and effort, particularly +>once work to make it play well with "pgxs" gets done. +> +> + + +-- +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 + + +--------------040508050809090200040805 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +Christopher Browne wrote: +
+
Centuries ago, Nostradamus foresaw when jd@commandprompt.com ("Joshua D. Drake") would write:
+  
+
+
I hope you understand that I, in no way have ever suggested
+(purposely) anything negative about Slony. Only that I believe they
+serve different technical solutions.
+    
+
+

+Stipulating that I may have some bias ;-), I still don't find it at
+all clear what the different situations are "shaped like" that lead to
+Mammoth being forcibly preferable to Slony-I.
+  
+
+I would choose replicator if:
+
+1. You want ease of setup
+2. You want your each transaction to be replicated at time of commit
+3. Your database is already laden with triggers
+4. You are pushing a very high transactional load*
+
+* Caveat I have no idea how well Slony performs on a system that does +say 200,000 transactions
+an hours that are heavily geared toward updates. Replicator performs +very well in this scenario.
+
+5. Replicators administrative tools are more mature than Slony (for +example you know exactly what state your slaves are in with Replicator).
+
+I would choose Slony if:
+
+1. The fact that it is Open Source matters to you
+2. The auto promotion of slaves is important*
+
+*This will be fixed in a couple of weeks with Replicator
+
+To be fair, in the real world ---
+
+It doesn't make a bit of difference which one you choose it really +comes down to this:
+
+Replicator is dumb simple to setup. Any halfway talented person can +setup replicator
+in 30 minutes with a single master / slave configuration.
+
+Slony is Open Source and thus a little easier on the pocket book +initially.
+
+Command Prompt, will support either one -- so the Replicator is +commercially supported
+argument is a little weak here.
+
+Sincerely,
+
+Joshua D. Drake
+
+
+
+
+Sincerely,
+
+Joshua D. Drake
+
+
+
+
+
+
+(Note that I have a pretty decent understanding about how ERS and
+Slony work, so I'm not too frightened of technicalities...  I set up
+instances of both on Thursday, so I'm pretty up to speed :-).)
+
+Win32 support may be true at the moment, although I have to discount
+that as we only just got the start of a beta release of native Win32
+support for PostgreSQL proper.  For that very reason, I had to point
+my youngest brother who needed "something better than Access" to
+Firebird last Saturday; I played with my niece while he was doing the
+install.  And there is little reason to think that Slony-I won't be
+portable to Win32 given a little interest and effort, particularly
+once work to make it play well with "pgxs" gets done.
+  
+
+
+
+
-- 
+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
+ + + +--------------040508050809090200040805-- + +From pgsql-performance-owner@postgresql.org Sun Aug 15 00:11:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 236445E46C1 + for ; + Sun, 15 Aug 2004 00:11:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57549-08 + for ; + Sun, 15 Aug 2004 03:11:59 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id A6F3C5E3F15 + for ; + Sun, 15 Aug 2004 00:11:48 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7F3BtiG059658 + for ; Sun, 15 Aug 2004 03:11:55 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7F33VTF057743 + for pgsql-performance@postgresql.org; Sun, 15 Aug 2004 03:03:31 GMT +From: Martin Foster +Organization: Ethereal Realms +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7.2) Gecko/20040803 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Faster with a sub-query then without +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 146 +Message-ID: <4oATc.14571$S55.11652@clgrps12> +Date: Sun, 15 Aug 2004 03:03:28 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/234 +X-Sequence-Number: 7870 + +I thought this could generate some interesting discussion. Essentially, +there are three queries below, two using sub-queries to change the way +the randomized information (works first by author and then by work) and +the original which simply randomizes out of all works available. + +The one not using sub-queries under EXPLAIN ANALYZE proves itself to be +less efficient and have a far higher cost then those with the penalty of +a sub-query. Since this seems to be counter to what I have been told +in the past, I thought I would bring this forward and get some +enlightenment. + + Martin Foster + Creator/Designer Ethereal Realms + martin@ethereal-realms.org + +----------------------------------------------------------------------- + +SELECT + g.GalleryID, + w.WorkID, + w.WorkName, + w.WorkImageThumbnail, + g.GalleryRating, + g.GalleryPenName +FROM ethereal.Work w, ethereal.Gallery g +WHERE w.GalleryID = g.GalleryID + AND g.GalleryPrivacy = 'no' + AND w.WorkImageThumbnail IS NOT NULL + AND g.PuppeteerLogin = (SELECT PuppeteerLogin + FROM ethereal.Gallery + WHERE GalleryType='image' + GROUP BY PuppeteerLogin + ORDER BY RANDOM() LIMIT 1) +ORDER BY RANDOM() LIMIT 1 + + Limit (cost=60.70..60.70 rows=1 width=100) (actual time=1.013..1.013 +rows=0 loops=1) + InitPlan + -> Limit (cost=6.36..6.37 rows=1 width=11) (actual +time=0.711..0.713 rows=1 loops=1) + -> Sort (cost=6.36..6.45 rows=33 width=11) (actual +time=0.708..0.708 rows=1 loops=1) + Sort Key: random() + -> HashAggregate (cost=5.45..5.53 rows=33 width=11) +(actual time=0.420..0.553 rows=46 loops=1) + -> Seq Scan on gallery (cost=0.00..5.30 +rows=60 width=11) (actual time=0.007..0.227 rows=59 loops=1) + Filter: ((gallerytype)::text = 'image'::text) + -> Sort (cost=54.33..54.37 rows=16 width=100) (actual +time=1.009..1.009 rows=0 loops=1) + Sort Key: random() + -> Nested Loop (cost=0.00..54.01 rows=16 width=100) (actual +time=0.981..0.981 rows=0 loops=1) + -> Seq Scan on gallery g (cost=0.00..5.56 rows=2 +width=24) (actual time=0.855..0.888 rows=1 loops=1) + Filter: (((galleryprivacy)::text = 'no'::text) AND +((puppeteerlogin)::text = ($0)::text)) + -> Index Scan using pkwork on "work" w +(cost=0.00..24.10 rows=8 width=80) (actual time=0.080..0.080 rows=0 loops=1) + Index Cond: (w.galleryid = "outer".galleryid) + Filter: (workimagethumbnail IS NOT NULL) + Total runtime: 1.211 ms + +----------------------------------------------------------------------- + +SELECT + g.GalleryID, + w.WorkID, + w.WorkName, + w.WorkImageThumbnail, + g.GalleryRating, + g.GalleryPenName +FROM ethereal.Work w, ethereal.Gallery g +WHERE w.GalleryID = g.GalleryID + AND g.GalleryPrivacy = 'no' + AND w.WorkImageThumbnail IS NOT NULL + AND g.GalleryPenName = (SELECT GalleryPenName + FROM ethereal.Gallery + WHERE GalleryType='image' + GROUP BY GalleryPenName + ORDER BY RANDOM() LIMIT 1) +ORDER BY RANDOM() LIMIT 1 + + Limit (cost=59.92..59.92 rows=1 width=100) (actual time=0.904..0.906 +rows=1 loops=1) + InitPlan + -> Limit (cost=6.69..6.69 rows=1 width=14) (actual +time=0.731..0.733 rows=1 loops=1) + -> Sort (cost=6.69..6.79 rows=42 width=14) (actual +time=0.729..0.729 rows=1 loops=1) + Sort Key: random() + -> HashAggregate (cost=5.45..5.56 rows=42 width=14) +(actual time=0.431..0.568 rows=48 loops=1) + -> Seq Scan on gallery (cost=0.00..5.30 +rows=60 width=14) (actual time=0.011..0.233 rows=59 loops=1) + Filter: ((gallerytype)::text = 'image'::text) + -> Sort (cost=53.23..53.27 rows=16 width=100) (actual +time=0.899..0.899 rows=1 loops=1) + Sort Key: random() + -> Nested Loop (cost=0.00..52.91 rows=16 width=100) (actual +time=0.808..0.862 rows=6 loops=1) + -> Index Scan using idxgallery_pen on gallery g +(cost=0.00..4.45 rows=2 width=24) (actual time=0.767..0.769 rows=1 loops=1) + Index Cond: ((gallerypenname)::text = ($0)::text) + Filter: ((galleryprivacy)::text = 'no'::text) + -> Index Scan using pkwork on "work" w +(cost=0.00..24.10 rows=8 width=80) (actual time=0.020..0.042 rows=6 loops=1) + Index Cond: (w.galleryid = "outer".galleryid) + Filter: (workimagethumbnail IS NOT NULL) + Total runtime: 1.117 ms + +----------------------------------------------------------------------- + +SELECT + g.GalleryID, + w.WorkID, + w.WorkName, + w.WorkImageThumbnail, + g.GalleryRating, + g.GalleryPenName +FROM ethereal.Work w, ethereal.Gallery g +WHERE w.GalleryID = g.GalleryID + AND g.GalleryType = 'image' + AND g.GalleryPrivacy = 'no' + AND w.WorkImageThumbnail IS NOT NULL +ORDER BY RANDOM() LIMIT 1 + +-------- + Limit (cost=111.73..111.73 rows=1 width=100) (actual +time=13.021..13.023 rows=1 loops=1) + -> Sort (cost=111.73..113.70 rows=786 width=100) (actual +time=13.017..13.017 rows=1 loops=1) + Sort Key: random() + -> Hash Join (cost=5.55..73.93 rows=786 width=100) (actual +time=1.081..8.320 rows=803 loops=1) + Hash Cond: ("outer".galleryid = "inner".galleryid) + -> Seq Scan on "work" w (cost=0.00..54.47 rows=817 +width=80) (actual time=0.006..2.207 rows=817 loops=1) + Filter: (workimagethumbnail IS NOT NULL) + -> Hash (cost=5.30..5.30 rows=100 width=24) (actual +time=0.669..0.669 rows=0 loops=1) + -> Seq Scan on gallery g (cost=0.00..5.30 +rows=100 width=24) (actual time=0.020..0.402 rows=100 loops=1) + Filter: ((galleryprivacy)::text = 'no'::text) + Total runtime: 13.252 ms + + +From pgsql-performance-owner@postgresql.org Sun Aug 15 00:55:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CEF2E5E46C8 + for ; + Sun, 15 Aug 2004 00:55:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68017-05 + for ; + Sun, 15 Aug 2004 03:55: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 5BAB95E46CD + for ; + Sun, 15 Aug 2004 00:54:59 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7F3t3LM015918; + Sat, 14 Aug 2004 23:55:04 -0400 (EDT) +To: Martin Foster +Cc: pgsql-performance@postgresql.org +Subject: Re: Faster with a sub-query then without +In-reply-to: <4oATc.14571$S55.11652@clgrps12> +References: <4oATc.14571$S55.11652@clgrps12> +Comments: In-reply-to Martin Foster + message dated "Sun, 15 Aug 2004 03:03:28 +0000" +Date: Sat, 14 Aug 2004 23:55:03 -0400 +Message-ID: <15917.1092542103@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/235 +X-Sequence-Number: 7871 + +Martin Foster writes: +> The one not using sub-queries under EXPLAIN ANALYZE proves itself to be +> less efficient and have a far higher cost then those with the penalty of +> a sub-query. Since this seems to be counter to what I have been told +> in the past, I thought I would bring this forward and get some +> enlightenment. + +The ones with the subqueries are not having to form the full join of W +and G; they just pick a few rows out of G and look up the matching W +rows. + +The "subquery penalty" is nonexistent in this case because the +subqueries are not dependent on any variables from the outer query, and +so they need be evaluated only once, rather than once per outer-query +row which is what I suppose you were expecting. This is reflected in +the EXPLAIN output: notice they are shown as InitPlans not SubPlans. +The outputs of the InitPlans are essentially treated as constants (shown +as $0 in the EXPLAIN output) and the outer plan is approximately what +it would be if you'd written WHERE g.field = 'constant' instead of +WHERE g.field = (select ...) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Aug 15 13:00:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 84E675E3639 + for ; + Sun, 15 Aug 2004 13:00:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18945-07 + for ; + Sun, 15 Aug 2004 16:00:20 +0000 (GMT) +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by svr1.postgresql.org (Postfix) with ESMTP id 384CB5E46DB + for ; + Sun, 15 Aug 2004 13:00:11 -0300 (ADT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.12.11/8.12.11) with ESMTP id i7FG0EOw041064 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) + for ; + Sun, 15 Aug 2004 10:00:17 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.12.11/8.12.11) with ESMTP id i7FG0EEl085302 + for ; + Sun, 15 Aug 2004 10:00:14 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.12.11/8.12.11/Submit) id i7FG0Ert085301 + for pgsql-performance@postgresql.org; + Sun, 15 Aug 2004 10:00:14 -0600 (MDT) (envelope-from mfuhr) +Date: Sun, 15 Aug 2004 10:00:14 -0600 +From: Michael Fuhr +To: pgsql-performance@postgresql.org +Subject: Slow joins against set-returning functions +Message-ID: <20040815160014.GA85211@winnie.fuhr.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/236 +X-Sequence-Number: 7872 + +PostgreSQL versions: 7.4.3, 8.0.0beta1 + +Joins against set-returning functions can be slow. Here's a simple +example (in 8.0.0beta1, the gen_series function can be replaced +with generate_series): + + CREATE FUNCTION gen_series(INTEGER, INTEGER) RETURNS SETOF INTEGER AS ' + DECLARE + xstart ALIAS FOR $1; + xend ALIAS FOR $2; + x INTEGER; + BEGIN + FOR x IN xstart .. xend LOOP + RETURN NEXT x; + END LOOP; + + RETURN; + END; + ' LANGUAGE plpgsql IMMUTABLE STRICT; + + CREATE TABLE stuff ( + id INTEGER NOT NULL PRIMARY KEY, + item VARCHAR(32) NOT NULL + ); + + INSERT INTO stuff (id, item) + SELECT id, 'Item ' || id FROM gen_series(1, 100000) AS f(id); + + ANALYZE stuff; + +Here are two queries; notice how the second query, which uses higher +numbers for the join key, is much slower than the first, apparently +due to an inefficient index scan: + + EXPLAIN ANALYZE + SELECT stuff.* FROM stuff JOIN gen_series(1, 10) AS f(id) USING (id); + + Merge Join (cost=62.33..2544.33 rows=1001 width=17) (actual time=1.398..1.950 rows=10 loops=1) + Merge Cond: ("outer".id = "inner".id) + -> Index Scan using stuff_pkey on stuff (cost=0.00..2217.00 rows=100000 width=17) (actual time=0.667..0.860 rows=11 loops=1) + -> Sort (cost=62.33..64.83 rows=1000 width=4) (actual time=0.646..0.670 rows=10 loops=1) + Sort Key: f.id + -> Function Scan on gen_series f (cost=0.00..12.50 rows=1000 width=4) (actual time=0.403..0.478 rows=10 loops=1) + Total runtime: 2.529 ms + (7 rows) + + EXPLAIN ANALYZE + SELECT stuff.* FROM stuff JOIN gen_series(99991, 100000) AS f(id) USING (id); + + Merge Join (cost=62.33..2544.33 rows=1001 width=17) (actual time=2907.078..2907.618 rows=10 loops=1) + Merge Cond: ("outer".id = "inner".id) + -> Index Scan using stuff_pkey on stuff (cost=0.00..2217.00 rows=100000 width=17) (actual time=0.107..2270.722 rows=100000 loops=1) + -> Sort (cost=62.33..64.83 rows=1000 width=4) (actual time=0.630..0.654 rows=10 loops=1) + Sort Key: f.id + -> Function Scan on gen_series f (cost=0.00..12.50 rows=1000 width=4) (actual time=0.392..0.469 rows=10 loops=1) + Total runtime: 2908.205 ms + (7 rows) + +If I turn off enable_mergejoin then both queries are fast: + + SET enable_mergejoin TO off; + + EXPLAIN ANALYZE + SELECT stuff.* FROM stuff JOIN gen_series(1, 10) AS f(id) USING (id); + + Nested Loop (cost=0.00..3038.50 rows=1001 width=17) (actual time=0.600..1.912 rows=10 loops=1) + -> Function Scan on gen_series f (cost=0.00..12.50 rows=1000 width=4) (actual time=0.395..0.482 rows=10 loops=1) + -> Index Scan using stuff_pkey on stuff (cost=0.00..3.01 rows=1 width=17) (actual time=0.091..0.107 rows=1 loops=10) + Index Cond: (stuff.id = "outer".id) + Total runtime: 2.401 ms + (5 rows) + + EXPLAIN ANALYZE + SELECT stuff.* FROM stuff JOIN gen_series(99991, 100000) AS f(id) USING (id); + + Nested Loop (cost=0.00..3038.50 rows=1001 width=17) (actual time=0.586..1.891 rows=10 loops=1) + -> Function Scan on gen_series f (cost=0.00..12.50 rows=1000 width=4) (actual time=0.394..0.479 rows=10 loops=1) + -> Index Scan using stuff_pkey on stuff (cost=0.00..3.01 rows=1 width=17) (actual time=0.089..0.105 rows=1 loops=10) + Index Cond: (stuff.id = "outer".id) + Total runtime: 2.374 ms + (5 rows) + +Is the planner doing something wrong here? + +Thanks. + +-- +Michael Fuhr +http://www.fuhr.org/~mfuhr/ + +From pgsql-performance-owner@postgresql.org Sun Aug 15 13:01:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8DCD85E46D5 + for ; + Sun, 15 Aug 2004 13:01:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20345-05 + for ; + Sun, 15 Aug 2004 16:01:36 +0000 (GMT) +Received: from fep6.cogeco.net (smtp.cogeco.net [216.221.81.25]) + by svr1.postgresql.org (Postfix) with ESMTP id 7DC705E46C4 + for ; + Sun, 15 Aug 2004 13:01:27 -0300 (ADT) +Received: from [127.0.0.1] (d226-86-215.home.cgocable.net [24.226.86.215]) + by fep6.cogeco.net (Postfix) with ESMTP + id 6D2745EA; Sun, 15 Aug 2004 12:01:32 -0400 (EDT) +Message-ID: <411F88D6.3000300@ethereal-realms.org> +Date: Sun, 15 Aug 2004 12:01:26 -0400 +From: Martin Foster +Organization: Ethereal Realms +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7.2) Gecko/20040803 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: PostgreSQL Performance +Subject: Re: Faster with a sub-query then without +References: <4oATc.14571$S55.11652@clgrps12> <15917.1092542103@sss.pgh.pa.us> +In-Reply-To: <15917.1092542103@sss.pgh.pa.us> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/237 +X-Sequence-Number: 7873 + +Tom Lane wrote: +> Martin Foster writes: +> +>>The one not using sub-queries under EXPLAIN ANALYZE proves itself to be +>>less efficient and have a far higher cost then those with the penalty of +>>a sub-query. Since this seems to be counter to what I have been told +>>in the past, I thought I would bring this forward and get some +>>enlightenment. +> +> +> The ones with the subqueries are not having to form the full join of W +> and G; they just pick a few rows out of G and look up the matching W +> rows. +> +> The "subquery penalty" is nonexistent in this case because the +> subqueries are not dependent on any variables from the outer query, and +> so they need be evaluated only once, rather than once per outer-query +> row which is what I suppose you were expecting. This is reflected in +> the EXPLAIN output: notice they are shown as InitPlans not SubPlans. +> The outputs of the InitPlans are essentially treated as constants (shown +> as $0 in the EXPLAIN output) and the outer plan is approximately what +> it would be if you'd written WHERE g.field = 'constant' instead of +> WHERE g.field = (select ...) +> +> regards, tom lane + +That would explain it overall. Still, it does seem unusual when one +puts in additional code, which most literature warns you about and you +actually gain a speed boost. + +Thanks! + + Martin Foster + Creator/Designer Ethereal Realms + martin@ethereal-realms.org + + + +From pgsql-performance-owner@postgresql.org Sun Aug 15 14:21:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F36915E37CE + for ; + Sun, 15 Aug 2004 14:21:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40359-02 + for ; + Sun, 15 Aug 2004 17:21: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 0522A5E3639 + for ; + Sun, 15 Aug 2004 14:21:35 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7FHLUPl028004; + Sun, 15 Aug 2004 13:21:31 -0400 (EDT) +To: Michael Fuhr +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow joins against set-returning functions +In-reply-to: <20040815160014.GA85211@winnie.fuhr.org> +References: <20040815160014.GA85211@winnie.fuhr.org> +Comments: In-reply-to Michael Fuhr + message dated "Sun, 15 Aug 2004 10:00:14 -0600" +Date: Sun, 15 Aug 2004 13:21:30 -0400 +Message-ID: <28003.1092590490@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/238 +X-Sequence-Number: 7874 + +Michael Fuhr writes: +> Is the planner doing something wrong here? + +Hard to see how it can be very smart with no idea about what the +function is going to return :-(. + +I'd say that the mergejoin plan is actually a good choice given the +limited amount of info, because it has the least degradation when the +input varies from what you expected. Those "better" nestloop plans +could easily be very far worse, if the function returned more than a +trivial number of rows. + +The reason the two mergejoin cases differ so much is that the scan of +the other relation can stop as soon as we've exhausted the function +output. Evidently scanning to key 10 doesn't traverse much of +stuff_pkey while scanning to key 100000 does. The planner is aware of +that effect, but with no information about the maximum key value to be +expected from the function scan, it can't apply the knowledge. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Aug 15 14:48:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B5F795E37CE + for ; + Sun, 15 Aug 2004 14:48:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42428-10 + for ; + Sun, 15 Aug 2004 17:48:00 +0000 (GMT) +Received: from smtp110.tiscali.dk (smtp110.tiscali.dk [62.79.79.110]) + by svr1.postgresql.org (Postfix) with ESMTP id E2BB75E3639 + for ; + Sun, 15 Aug 2004 14:47:59 -0300 (ADT) +Received: from cpmail.dk.tiscali.com (mail.tiscali.dk [212.54.64.159]) + by smtp110.tiscali.dk (8.12.10/8.12.10) with ESMTP id i7FHlvhc011114 + for ; + Sun, 15 Aug 2004 19:47:57 +0200 (CEST) + (envelope-from postgresql.org@tange.dk) +Received: from [192.168.1.2] (62.79.147.194) by cpmail.dk.tiscali.com + (6.7.018) + id 411906E2000FC660 for pgsql-performance@postgresql.org; + Sun, 15 Aug 2004 19:47:57 +0200 +Date: Sun, 15 Aug 2004 19:47:53 +0200 (CEST) +From: Ole Tange +X-X-Sender: tange@tigger.tange.dk +To: pgsql-performance@postgresql.org +Subject: Help interpreting explain analyze output +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/239 +X-Sequence-Number: 7875 + +Using this SQL: + +EXPLAIN ANALYZE +SELECT DISTINCT + sessionid, + '2004-33' AS "yearweek", + nd.niveau +INTO TEMP + distinct_session +FROM + httplog h ,niveaudir nd +WHERE + hitDateTime>('now'::timestamp with time zone-'1440 min'::interval) + and h.hostid=(select hostnameid from hostname where hostname='www.forbrug.dk') + and h.statusid!=404 + and h.pathid=nd.pathid +; + + +I get this output: + +QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Unique (cost=5680.00..5766.70 rows=8670 width=26) (actual +time=17030.802..20044.614 rows=68213 loops=1) + InitPlan + -> Index Scan using hostname_hostname_key on hostname +(cost=0.00..5.42 rows=1 width=4) (actual time=0.101..0.106 rows=1 loops=1) + Index Cond: (hostname = 'www.forbrug.dk'::text) + -> Sort (cost=5674.58..5696.25 rows=8670 width=26) (actual +time=17030.792..17689.650 rows=174714 loops=1) + Sort Key: h.sessionid, '2004-33'::text, nd.niveau + -> Merge Join (cost=4500.70..5107.48 rows=8670 width=26) +(actual time=3226.955..3966.011 rows=174714 loops=1) + Merge Cond: ("outer".pathid = "inner".pathid) + -> Index Scan using niveaudir_pathid on niveaudir nd +(cost=0.00..465.59 rows=22715 width=26) (actual time=0.181..52.248 +rows=22330 loops=1) + -> Sort (cost=4500.70..4522.38 rows=8670 width=8) (actual +time=3226.666..3443.092 rows=174714 loops=1) + Sort Key: h.pathid + -> Index Scan using httplog_hitdatetime on httplog h +(cost=0.00..3933.61 rows=8670 width=8) (actual time=0.425..1048.428 +rows=174714 loops=1) + Index Cond: (hitdatetime > '2004-08-14 +16:41:16.855829+02'::timestamp with time zone) + Filter: ((hostid = $0) AND (statusid <> 404)) + Total runtime: 20478.174 ms +(15 rows) + +As I read it the output tells me what was done during the milliseconds: + +0.101..0.106 +0.181..52.248 +0.425..1048.428 +3226.666..3443.092 +3226.955..3966.011 +17030.792..17689.650 +17030.802..20044.614 + +However, there are a few large gaps. What is happening during: + +1048.428..3226.666 (2 secs) +3966.011..17030.792 (13 secs!) + +This is the major part of the time but this is not accounted for in the +explain analyze output. It seems PostgreSQL is doing stuff that is not +part of the query plan. How do I get to know what this "stuff" is? + + +/Ole + +From pgsql-performance-owner@postgresql.org Sun Aug 15 15:21:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D38765E46ED + for ; + Sun, 15 Aug 2004 15:13:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53549-06 + for ; + Sun, 15 Aug 2004 18: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 EE3CD5E40BA + for ; + Sun, 15 Aug 2004 15:13:39 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7FIDe2v028314; + Sun, 15 Aug 2004 14:13:40 -0400 (EDT) +To: Ole Tange +Cc: pgsql-performance@postgresql.org +Subject: Re: Help interpreting explain analyze output +In-reply-to: +References: +Comments: In-reply-to Ole Tange + message dated "Sun, 15 Aug 2004 19:47:53 +0200" +Date: Sun, 15 Aug 2004 14:13:39 -0400 +Message-ID: <28313.1092593619@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/240 +X-Sequence-Number: 7876 + +Ole Tange writes: +> As I read it the output tells me what was done during the milliseconds: + +No, you have a fundamental misconception here. The notation means that +the first output row from a plan step was delivered after X +milliseconds, and the last row after Y milliseconds. + +The "gap" you are looking at is the time to do the Sort (since a sort +can't deliver the first output row until it's finished the sort). + +It is gonna take a while to sort 175000 rows ... but possibly increasing +sort_mem would help. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Aug 15 15:33:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DEDC5E3639 + for ; + Sun, 15 Aug 2004 15:24:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57935-07 + for ; + Sun, 15 Aug 2004 18:24:13 +0000 (GMT) +Received: from jalapeno.crazydogs.org (jalapeno.jellybean.co.uk + [212.78.70.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C36C5E46CD + for ; + Sun, 15 Aug 2004 15:24:11 -0300 (ADT) +Received: from rp by jalapeno.crazydogs.org with local (Exim 3.36 #1 (Debian)) + id 1BwPfs-0001Y2-00 + for ; Sun, 15 Aug 2004 19:24:08 +0100 +Date: Sun, 15 Aug 2004 19:24:08 +0100 +From: Richard Poole +To: pgsql-performance@postgresql.org +Subject: Re: Help interpreting explain analyze output +Message-ID: <20040815182407.GA21608@guests.deus.net> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/241 +X-Sequence-Number: 7877 + +On Sun, Aug 15, 2004 at 07:47:53PM +0200, Ole Tange wrote: + +> QUERY PLAN +> --------------------------------------------------------------------------------------------------------------------------------------------------------------------- +> Unique (cost=5680.00..5766.70 rows=8670 width=26) (actual +> time=17030.802..20044.614 rows=68213 loops=1) +> InitPlan +> -> Index Scan using hostname_hostname_key on hostname +> (cost=0.00..5.42 rows=1 width=4) (actual time=0.101..0.106 rows=1 loops=1) +> Index Cond: (hostname = 'www.forbrug.dk'::text) +> -> Sort (cost=5674.58..5696.25 rows=8670 width=26) (actual +> time=17030.792..17689.650 rows=174714 loops=1) +> Sort Key: h.sessionid, '2004-33'::text, nd.niveau +> -> Merge Join (cost=4500.70..5107.48 rows=8670 width=26) +> (actual time=3226.955..3966.011 rows=174714 loops=1) +> Merge Cond: ("outer".pathid = "inner".pathid) +> -> Index Scan using niveaudir_pathid on niveaudir nd +> (cost=0.00..465.59 rows=22715 width=26) (actual time=0.181..52.248 +> rows=22330 loops=1) +> -> Sort (cost=4500.70..4522.38 rows=8670 width=8) (actual +> time=3226.666..3443.092 rows=174714 loops=1) +> Sort Key: h.pathid +> -> Index Scan using httplog_hitdatetime on httplog h +> (cost=0.00..3933.61 rows=8670 width=8) (actual time=0.425..1048.428 +> rows=174714 loops=1) +> Index Cond: (hitdatetime > '2004-08-14 +> 16:41:16.855829+02'::timestamp with time zone) +> Filter: ((hostid = $0) AND (statusid <> 404)) +> Total runtime: 20478.174 ms +> (15 rows) +> +> As I read it the output tells me what was done during the milliseconds: + +The first time given is not the time when this stage of the plan starts +to execute, but the time when it returns its first row. So most of the +time in this query is being spent doing the two sorts - in a sort, of +course, most of the work has to be done before any rows can be returned. + + +Richard + +From pgsql-performance-owner@postgresql.org Sun Aug 15 16:08:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 80E835E46C0 + for ; + Sun, 15 Aug 2004 16:08:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 72010-10 + for ; + Sun, 15 Aug 2004 19:08:25 +0000 (GMT) +Received: from smtp230.tiscali.dk (smtp230.tiscali.dk [62.79.79.115]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F9DF5E40BA + for ; + Sun, 15 Aug 2004 16:08:24 -0300 (ADT) +Received: from cpmail.dk.tiscali.com (mail.tiscali.dk [212.54.64.159]) + by smtp230.tiscali.dk (8.12.9p1/8.12.9) with ESMTP id i7FJ8E6q047582 + for ; + Sun, 15 Aug 2004 21:08:23 +0200 (CEST) + (envelope-from postgresql.org@tange.dk) +Received: from [192.168.1.2] (62.79.147.194) by cpmail.dk.tiscali.com + (6.7.018) + id 411900CA001009C4 for pgsql-performance@postgresql.org; + Sun, 15 Aug 2004 21:08:23 +0200 +Date: Sun, 15 Aug 2004 21:08:19 +0200 (CEST) +From: Ole Tange +X-X-Sender: tange@tigger.tange.dk +Cc: pgsql-performance@postgresql.org +Subject: Re: Help interpreting explain analyze output +In-Reply-To: <28313.1092593619@sss.pgh.pa.us> +Message-ID: +References: + <28313.1092593619@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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/242 +X-Sequence-Number: 7878 + +On Sun, 15 Aug 2004, Tom Lane wrote: + +> Ole Tange writes: +> > As I read it the output tells me what was done during the milliseconds: +> +> No, you have a fundamental misconception here. The notation means that +> the first output row from a plan step was delivered after X +> milliseconds, and the last row after Y milliseconds. + +Thanks. For a novice tuner like me it would be nice if you could see more +easily where the time was spent. However, the output is _far_ more +intuitive that MySQL's. + +> It is gonna take a while to sort 175000 rows ... but possibly increasing +> sort_mem would help. + +It didn't. However, I could reformulate the DISTINCT query as a GROUP BY +on all the selected fields and this uses Hash aggregate which is far +faster. + +Now I am curious: Why isn't DISTINCT implemented using a Hash aggregate? + + +/Ole + +From pgsql-performance-owner@postgresql.org Sun Aug 15 16:40:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C90E5E46C1 + for ; + Sun, 15 Aug 2004 16:40:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82300-02 + for ; + Sun, 15 Aug 2004 19:40: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 3B1D55E46BF + for ; + Sun, 15 Aug 2004 16:40:36 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7FJebo4029080; + Sun, 15 Aug 2004 15:40:37 -0400 (EDT) +To: Ole Tange +Cc: pgsql-performance@postgresql.org +Subject: Re: Help interpreting explain analyze output +In-reply-to: +References: + <28313.1092593619@sss.pgh.pa.us> + +Comments: In-reply-to Ole Tange + message dated "Sun, 15 Aug 2004 21:08:19 +0200" +Date: Sun, 15 Aug 2004 15:40:37 -0400 +Message-ID: <29079.1092598837@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/243 +X-Sequence-Number: 7879 + +Ole Tange writes: +> Now I am curious: Why isn't DISTINCT implemented using a Hash aggregate? + +Partly lack of round tuits, partly the fact that it is closely +intertwined with ORDER BY and I'm not sure what side-effects would +arise from separating them. In particular, the DISTINCT ON special +case stops making any sense at all if it's not tied to a sort/uniq +underlying implementation. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Aug 15 17:12:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 330805E46DB + for ; + Sun, 15 Aug 2004 17:12:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89519-05 + for ; + Sun, 15 Aug 2004 20:12:03 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F4135E37CE + for ; + Sun, 15 Aug 2004 17:12:02 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7FKC2iG091452 + for ; Sun, 15 Aug 2004 20:12:02 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7FK9rGE090924 + for pgsql-performance@postgresql.org; Sun, 15 Aug 2004 20:09:53 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Help specifying new machine +Date: Sun, 15 Aug 2004 13:17:13 -0700 +Organization: Hub.Org Networking Services +Lines: 18 +Message-ID: +References: <20040809165657.GB15169@campbell-lange.net> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7b) Gecko/20040421 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/244 +X-Sequence-Number: 7880 + +>>You're not getting much of a bump with this server. The CPU is +>>incrementally faster -- in the absolutely best case scenario where your +>>queries are 100% cpu-bound, that's about ~25%-30% faster. +> +> +> What about using Dual Athlon MP instead of a Xeon? Would be much less expensive, +> but have higher performance (I think). + +You're not going to be able to get a Dual Athlon MP for the same price +as a single Xeon. A few years back, this was the case because Xeon CPUs +& MBs had a huge premium over Athlon. This is no longer true mainly +because the number of people carrying Athlon MP motherboards has dropped +down drastically. Go to pricewatch.com and do a search for 760MPX -- you +get a mere 8 entries. Not surprisingly because who would not want to +spend a few pennies more for a much superior Dual Opteron? The few +sellers you see now just keep stuff in inventory for people who need +replacement parts for emergencies and are willing to pay up the nose +because it is an emergency. + +From pgsql-performance-owner@postgresql.org Mon Aug 16 12:22:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E0B55E3F15 + for ; + Mon, 16 Aug 2004 12:22:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28511-10 + for ; + Mon, 16 Aug 2004 15:22:39 +0000 (GMT) +Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AD7AF5E37CE + for ; + Mon, 16 Aug 2004 12:22:20 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 200B32BD4C + for ; + Mon, 16 Aug 2004 17:12:09 +0200 (SAST) +Received: from ucsns.ucs.co.za ([127.0.0.1]) + by localhost (ucsns.ucs.co.za [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 27719-06 for ; + Mon, 16 Aug 2004 17:11:59 +0200 (SAST) +Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 6B0FF2BD5F + for ; + Mon, 16 Aug 2004 17:11:59 +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 999C5DA300 + for ; + Mon, 16 Aug 2004 17:11:59 +0200 (SAST) +Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) + by jhb.ucs.co.za (Postfix) with SMTP id D9EDA975A0 + for ; + Mon, 16 Aug 2004 17:11:58 +0200 (SAST) +Date: Mon, 16 Aug 2004 17:12:34 +0200 +From: Stef +To: pgsql-performance@postgresql.org +Subject: Strange problems with more memory. +Message-Id: <20040816171234.5a9bac8f@svb.ucs.co.za> +X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) +User-Agent: sillypheed-claws (anti-aliased) +X-Face: GFoC95e6r)_TTG>n~=uFLojP=O~4W@Ms]>:.DMm/')(z3\Mwj^XP@? + Q:3";lD.OM1"^mDu}2NJ@US:)dO:U*iY5EM50&Tx. +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 ucs.co.za +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/246 +X-Sequence-Number: 7882 + +Hi all, + +I'm running postgres 7.3.4 on a quad Xeon 2.8 GHz with +Mem: 1057824768 309108736 748716032 0 12242944 256413696 +Swap: 518053888 8630272 509423616 + +on Linux version 2.4.26-custom + +Data directory is mounted with noatime. + +Nothing else but one 11GB database is running on this machine. +When the database was created, I changed the following defaults : +shared_buffers = 24415 +sort_mem = 5120 +vacuum_mem = 10240 +commit_delay = 5000 +commit_siblings = 100 + +These settings worked fine, but were not optimal, I thought, and processing +stuff on this database was a bit slow. The machine is not nearly used to it's +capacity, and I realized that disk IO is what's slowing me down. So I +decided to give postgres more shared memory and much more sort memory, +as it does a lot of "group by'"s and "order by"'s during the nightly processing. +These were the new settings I tried : +shared_buffers = 61035 +sort_mem = 97657 + +I thought because it's only one process that runs queries exclusively at night, +I should be able to set the sort_mem this high without worrying about running +out of memory. + +It seems I was mistaking, as I started getting these kind of errors in dmesg : +VM: killing process postmaster +__alloc_pages: 0-order allocation failed (gfp=0x1d2/0) +__alloc_pages: 0-order allocation failed (gfp=0x1d2/0) +VM: killing process postmaster + +and I kept on getting these postgres errors : +ERROR: Index ???? is not a btree + +I systematically reduced the shared buffers back down to 24415, and this kept +on happening. As soon as I reduced sort_mem back to under 10000,the problem +stopped. But the database is just as slow as before. (By slow I mean not as fast as it should +be on such a powerful machine compared to much worse machines running the same processes) + +What can I do to make this database run faster on this machine. +Can anyone suggest how I would go about speeding up this database. + +I need to prepare a database three times the size of this one, running the same processes, +and I don't know what improvements I can do on hardware to make this possible. + +On the current machine I can easily get another 1GB or 2GB of memory, but will that help at all? +Without going into the details of exactly the queries that run on this machine, what would be needed to +make postgres run very fast on this machine? + +Please help. + +Kind Regards +Stefan + +From pgsql-performance-owner@postgresql.org Mon Aug 16 12:12:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 115485E46EF + for ; + Mon, 16 Aug 2004 12:12:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28911-01 + for ; + Mon, 16 Aug 2004 15:12:44 +0000 (GMT) +Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 3EAB65E3639 + for ; + Mon, 16 Aug 2004 12:12:33 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id 0D4DF3FC3 + for ; + Mon, 16 Aug 2004 11:12:38 -0400 (EDT) +Received: from lorax.kcilink.com ([127.0.0.1]) + by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 90332-05 for ; + Mon, 16 Aug 2004 11:12:37 -0400 (EDT) +Received: by lorax.kcilink.com (Postfix, from userid 8) + id 914CA3FB4; Mon, 16 Aug 2004 11:12:37 -0400 (EDT) +To: pgsql-performance@postgresql.org +Path: not-for-mail +From: Vivek Khera +Newsgroups: ml.postgres.performance +Subject: Re: Replication: Slony-I vs. Mammoth Replicator vs. ? +Date: Mon, 16 Aug 2004 11:12:37 -0400 +Organization: Khera Communications, Inc., Rockville, MD +Lines: 10 +Message-ID: +References: + <411D6D47.5020203@commandprompt.com> + <411E30C4.8020909@Yahoo.com> <411E3C3B.5060808@commandprompt.com> + + <411EB469.6020406@commandprompt.com> +NNTP-Posting-Host: yertle.kcilink.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Trace: lorax.kcilink.com 1092669157 66288 65.205.34.180 (16 Aug 2004 + 15:12:37 GMT) +X-Complaints-To: daemon@kciLink.com +NNTP-Posting-Date: Mon, 16 Aug 2004 15:12:37 +0000 (UTC) +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + berkeley-unix) +Cancel-Lock: sha1:MvKSrLd7/1AXd92uvTT8ddTpVRk= +X-Virus-Scanned: by amavisd-new at kcilink.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/245 +X-Sequence-Number: 7881 + +One more point for your list: + +Choose Slony if Replicator doesn't support your platform. :-) + + +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +Vivek Khera, Ph.D. Khera Communications, Inc. +Internet: khera@kciLink.com Rockville, MD +1-301-869-4449 x806 +AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ + +From pgsql-performance-owner@postgresql.org Mon Aug 16 12:41:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 23AA85E46C0 + for ; + Mon, 16 Aug 2004 12:41:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40230-04 + for ; + Mon, 16 Aug 2004 15:41:17 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 3DFE55E46C4 + for ; + Mon, 16 Aug 2004 12:41:10 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7GFfGdY014010; + Mon, 16 Aug 2004 11:41:16 -0400 (EDT) +To: Stef +Cc: pgsql-performance@postgresql.org +Subject: Re: Strange problems with more memory. +In-reply-to: <20040816171234.5a9bac8f@svb.ucs.co.za> +References: <20040816171234.5a9bac8f@svb.ucs.co.za> +Comments: In-reply-to Stef + message dated "Mon, 16 Aug 2004 17:12:34 +0200" +Date: Mon, 16 Aug 2004 11:41:16 -0400 +Message-ID: <14009.1092670876@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/247 +X-Sequence-Number: 7883 + +Stef writes: +> It seems I was mistaking, as I started getting these kind of errors in dmesg : +> VM: killing process postmaster +> __alloc_pages: 0-order allocation failed (gfp=0x1d2/0) +> __alloc_pages: 0-order allocation failed (gfp=0x1d2/0) +> VM: killing process postmaster + +This looks like the infamous OOM-kill kernel bug^H^H^Hfeature. Turn off +memory overallocation in your kernel to get more stable behavior when +pushing the limits of available memory. + +> But the database is just as slow as before. (By slow I mean not as +> fast as it should be on such a powerful machine compared to much worse +> machines running the same processes) + +If your concern is with a single nightly process, then that quad Xeon is +doing squat for you, because only one of the processors will be working. +See if you can divide up the processing into several jobs that can run +in parallel. (Of course, if the real problem is that you are disk I/O +bound, nothing will help except better disk hardware. Way too many +people think they should buy a super-fast CPU and attach it to +consumer-grade IDE disks. For database work you're usually better off +spending your money on good disks...) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 16 13:23:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4EF525E46C5 + for ; + Mon, 16 Aug 2004 13:23:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54401-10 + for ; + Mon, 16 Aug 2004 16:22:53 +0000 (GMT) +Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 22A115E46C4 + for ; + Mon, 16 Aug 2004 13:22:44 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 9788B2BD48; + Mon, 16 Aug 2004 18:22:50 +0200 (SAST) +Received: from ucsns.ucs.co.za ([127.0.0.1]) + by localhost (ucsns.ucs.co.za [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 29369-05; Mon, 16 Aug 2004 18:22:40 +0200 (SAST) +Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 61A2B2BD43; + Mon, 16 Aug 2004 18:22:40 +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 226D7D9DFB; Mon, 16 Aug 2004 18:22:40 +0200 (SAST) +Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) + by jhb.ucs.co.za (Postfix) with SMTP + id A601E975A0; Mon, 16 Aug 2004 18:22:39 +0200 (SAST) +Date: Mon, 16 Aug 2004 18:23:14 +0200 +From: Stef +To: pgsql-performance@postgresql.org +Cc: Tom Lane +Subject: Re: Strange problems with more memory. +Message-Id: <20040816182314.24818138@svb.ucs.co.za> +In-Reply-To: <14009.1092670876@sss.pgh.pa.us> +References: <20040816171234.5a9bac8f@svb.ucs.co.za> + <14009.1092670876@sss.pgh.pa.us> +X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) +User-Agent: sillypheed-claws (anti-aliased) +X-Face: GFoC95e6r)_TTG>n~=uFLojP=O~4W@Ms]>:.DMm/')(z3\Mwj^XP@? + Q:3";lD.OM1"^mDu}2NJ@US:)dO:U*iY5EM50&Tx. +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 ucs.co.za +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/248 +X-Sequence-Number: 7884 + +Tom Lane mentioned : +=> Turn off +=> memory overallocation in your kernel to get more stable behavior when +=> pushing the limits of available memory. + +I think this will already help a lot. +Thanks!! + +=> If your concern is with a single nightly process, then that quad Xeon is +=> doing squat for you, because only one of the processors will be working. +=> See if you can divide up the processing into several jobs that can run +=> in parallel. (Of course, if the real problem is that you are disk I/O +=> bound, nothing will help except better disk hardware. Way too many +=> people think they should buy a super-fast CPU and attach it to +=> consumer-grade IDE disks. For database work you're usually better off +=> spending your money on good disks...) + +Got 3 10000 rpm SCSI raid5 on here. I doubt I will get much better than that +without losing both arms and legs... + +I think I'll try and even out the disk IO a bit and get 4 processes running in parallel. +At least I can move forward again. + +Thanks again! + +Kind Regards +Stefan + +From pgsql-performance-owner@postgresql.org Mon Aug 16 20:08:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BD38F5E46C0 + for ; + Mon, 16 Aug 2004 20:08:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95588-01 + for ; + Mon, 16 Aug 2004 23:08:43 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 36FE45E46CD + for ; + Mon, 16 Aug 2004 20:08:41 -0300 (ADT) +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 6097155; Mon, 16 Aug 2004 16:10:00 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Harmon S. Nine" +Subject: Re: Timestamp-based indexing +Date: Mon, 16 Aug 2004 16:09:13 -0700 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <410519F6.5020806@netarx.com> +In-Reply-To: <410519F6.5020806@netarx.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200408161609.13018.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/249 +X-Sequence-Number: 7885 + +Harmon, + +> A "VACUUM FULL ANALYZE" is performed every 3 hours. + +The FULL part should not be necessary if you've set your max_fsm_pages high +enough. + +> Given there are 10080 minutes per week, the planner could, properly +> configured, estimate the number of rows returned by such a query to be: +> +> 10 min/ 10080 min * 400,000 = 0.001 * 400,000 = 400. + +The planner doesn't work that way. + +> monitor=# explain analyze select * from "eventtable" where timestamp > +> CURRENT_TIMESTAMP - INTERVAL '10 minutes'; + +Hmmm. What verison of PostgreSQL are you running? I seem to remember an +issue in one version with selecting comparisons against now(). What +happens when you supply a constant instead of ( current_timestamp - interval +'10 minutes' ) ? + +> Here's something strange. We try to disable sequential scans, but to no +> avail. The estimated cost skyrockets, though: + +That's how "enable_*=false" works in most cases. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Aug 16 20:15:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 993965E46CD + for ; + Mon, 16 Aug 2004 20:15:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96563-04 + for ; + Mon, 16 Aug 2004 23:15:56 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id EBC655E46CC + for ; + Mon, 16 Aug 2004 20:15:55 -0300 (ADT) +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 6097181; Mon, 16 Aug 2004 16:17:15 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Algolist +Subject: Re: Index type +Date: Mon, 16 Aug 2004 16:16:27 -0700 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <20040626222142.5E3D75AF09D@svr4.postgresql.org> + <418482301.20040721014611@manual.ru> +In-Reply-To: <418482301.20040721014611@manual.ru> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200408161616.27768.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/250 +X-Sequence-Number: 7886 + +Ilia, + +> If I create btree index on all columns (A,B,C..), here is what explain +> analyze gives me: +> ----------------------------------------------------------------- +> Index Scan using all_ind on test2 (cost=0.00..4.51 rows=1 width=24) +> (actual ti me=0.000..0.000 rows=5 loops=1) +> Index Cond: ((a >= '2004-07-20 23:50:50'::timestamp without time zone) +> AND (a <= '2004-07-21 23:50:50'::timestamp without time zone) AND (b >= +> '2004-07-20 23 +> +> :50:50'::timestamp without time zone) AND (b <= '2004-07-21 +> : 23:50:50'::timestamp +> +> without time zone) AND (c >= '2004-07-20 23:50:50'::timestamp without time +> zone ) AND (c <= '2004-07-21 23:50:50'::timestamp without time zone)) + +Looks good to me. It's a fully indexed search, which it should be with +BETWEEN. The only thing you need to ask yourself is whether or not you've +selected the columns in the most selective order (e.g. most selective column +first). + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Aug 16 20:25:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AF13A5E46C0 + for ; + Mon, 16 Aug 2004 20:25:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98932-05 + for ; + Mon, 16 Aug 2004 23:25: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 ADC945E3F15 + for ; + Mon, 16 Aug 2004 20:25:43 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7GNPf4a018545; + Mon, 16 Aug 2004 19:25:42 -0400 (EDT) +To: josh@agliodbs.com +Cc: "Harmon S. Nine" , + pgsql-performance@postgresql.org +Subject: Re: Timestamp-based indexing +In-reply-to: <200408161609.13018.josh@agliodbs.com> +References: <410519F6.5020806@netarx.com> + <200408161609.13018.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Mon, 16 Aug 2004 16:09:13 -0700" +Date: Mon, 16 Aug 2004 19:25:41 -0400 +Message-ID: <18544.1092698741@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/251 +X-Sequence-Number: 7887 + +Josh Berkus writes: +>> monitor=# explain analyze select * from "eventtable" where timestamp > +>> CURRENT_TIMESTAMP - INTERVAL '10 minutes'; + +> Hmmm. What verison of PostgreSQL are you running? I seem to remember an +> issue in one version with selecting comparisons against now(). + +I'm also wondering about the exact datatype of the "timestamp" column. +If it's timestamp without timezone, then the above is a cross-datatype +comparison (timestamp vs timestamptz) and hence not indexable before +8.0. This could be fixed easily by using the right current-time +function, viz LOCALTIMESTAMP not CURRENT_TIMESTAMP. (Consistency has +obviously never been a high priority with the SQL committee :-(.) + +Less easily but possibly better in the long run, change the column type +to timestamp with time zone. IMHO, columns representing definable +real-world time instants should always be timestamptz, because the other +way leaves you open to serious confusion about what the time value +really means. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 17 03:24:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8910F5E3F15 + for ; + Tue, 17 Aug 2004 03:24:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23535-02 + for ; + Tue, 17 Aug 2004 06:24:04 +0000 (GMT) +Received: from linda-2.paradise.net.nz (bm-2a.paradise.net.nz [202.0.58.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 523DE5E3633 + for ; + Tue, 17 Aug 2004 03:24:00 -0300 (ADT) +Received: from smtp-2.paradise.net.nz (smtp-2a.paradise.net.nz [202.0.32.195]) + by linda-2.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0I2K00H8HV3WYL@linda-2.paradise.net.nz> for + pgsql-performance@postgresql.org; Tue, 17 Aug 2004 18:23:59 +1200 (NZST) +Received: from [192.168.1.11] + (203-79-100-171.adsl.paradise.net.nz [203.79.100.171]) + by smtp-2.paradise.net.nz (Postfix) with ESMTP id 938559E80F; Tue, + 17 Aug 2004 18:23:43 +1200 (NZST) +Date: Tue, 17 Aug 2004 18:26:15 +1200 +From: Mark Kirkwood +Subject: Re: Strange problems with more memory. +In-reply-to: <20040816182314.24818138@svb.ucs.co.za> +To: Stef +Cc: pgsql-performance@postgresql.org +Message-id: <4121A507.1000704@coretech.co.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8a2) Gecko/20040715 +References: <20040816171234.5a9bac8f@svb.ucs.co.za> + <14009.1092670876@sss.pgh.pa.us> + <20040816182314.24818138@svb.ucs.co.za> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/252 +X-Sequence-Number: 7888 + +If your nightly process is heavily read-only, then raid5 is probably +fine. If however, there is a significant write component then it would +perhaps be worth getting another disk and converting to raid10 +(alternatively - see previous postings about raid cards with on-board +cache). Are you seeing a lot of write activity? + +Note that it is possible for a SELECT only workload to generate +significant write activity - if the resulting datasets are too large for +memory sorting or hashing. I'm *guessing* that with an 11G database and +1G (or was that 2G?) of ram that it is possible to overflow whatever +your sort_mem is set to. + + +cheers + +Mark + +Stef wrote: + +>Got 3 10000 rpm SCSI raid5 on here. I doubt I will get much better than that +>without losing both arms and legs... +> +> +> + +From pgsql-performance-owner@postgresql.org Tue Aug 17 10:30:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A74115E40BB + for ; + Tue, 17 Aug 2004 10:30:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69463-04 + for ; + Tue, 17 Aug 2004 13:30:28 +0000 (GMT) +Received: from mail.aspserveur.com (7.95.39-62.rev.gaoland.net [62.39.95.7]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F4695E3639 + for ; + Tue, 17 Aug 2004 10:30:25 -0300 (ADT) +Received: from saturne ([193.251.84.117]) + by mail.aspserveur.com (ASPSERVEUR Ultimate mail Server) with SMTP id + HUO74536 + for ; Tue, 17 Aug 2004 15:30:55 +0200 +Message-ID: <002901c4845e$5d1dc1c0$0c0101c0@saturne> +From: "olivier HARO" +To: +Subject: General performance problem! +Date: Tue, 17 Aug 2004 15:30:29 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0026_01C4846F.203A1450" +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.9 tagged_above=0.0 required=5.0 tests=HTML_30_40, + HTML_FONTCOLOR_BLUE, HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200408/253 +X-Sequence-Number: 7889 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0026_01C4846F.203A1450 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hello, + +I have a dedicated server for my posgresql database : + +P4 2.4 GHZ +HDD IDE 7200 rpm +512 DDR 2700 + +I have a problem whith one table of my database : + +CREATE SEQUENCE "base_aveugle_seq" START 1; +CREATE TABLE "base_aveugle" ( + "record_id" integer DEFAULT nextval('"base_aveugle_seq"'::text) NOT NULL, + "dunsnumber" integer NOT NULL, + "cp" text NOT NULL, + "tel" text NOT NULL, + "fax" text NOT NULL, + "naf" text NOT NULL, + "siege/ets" text NOT NULL, + "effectif" integer NOT NULL, + "ca" integer NOT NULL, + Constraint "base_aveugle_pkey" Primary Key ("record_id") +); +CREATE INDEX base_aveugle_dunsnumber_key ON base_aveugle USING btree (dunsn= +umber); +CREATE INDEX base_aveugle_cp_key ON base_aveugle USING btree (cp); +CREATE INDEX base_aveugle_naf_key ON base_aveugle USING btree (naf); +CREATE INDEX base_aveugle_effectif_key ON base_aveugle USING btree (effecti= +f); + + +This table contains 5 000 000 records + +I have a PHP application which often makes queries on this table (especiall= +y on the "cp","naf","effectif" fields) + +Querries are like : + select (distint cp) from base_aveugle where cp=3D'201A' and effectif = +between 1 and 150 + select (*) from base_aveugle where naf in ('721A','213F','421K') and = +cp in ('54210','21459','201A') and effectif < 150 + +I think it is possible to optimize the performance of this queries before c= +hanging the hardware (I now I will...) but I don't know how, even after hav= +ing read lot of things about postgresql ... + +Thanks ;)=20 + + +--- +Outgoing mail is certified Virus Free. +Checked by AVG anti-virus system (http://www.grisoft.com). +Version: 6.0.737 / Virus Database: 491 - Release Date: 11/08/2004 +------=_NextPart_000_0026_01C4846F.203A1450 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hello,
+
 
+
I have a dedicated serve= +r for my=20 +posgresql database :
+
 
+
P4 2.4 GHZ
+
HDD IDE 7200 rpm<= +/DIV> +
512 DDR 2700
+
 
+
I have a problem whith o= +ne table of=20 +my database :
+
 
+
CREATE SEQUENCE "base_aveugle_seq" START= +=20 +1;
CREATE TABLE "base_aveugle" (
 "record_id" integer DEFAULT=20 +nextval('"base_aveugle_seq"'::text) NOT NULL,
 "dunsnumber" integer= + NOT=20 +NULL,
 "cp" text NOT NULL,
 "tel" text NOT NULL,
 "= +fax"=20 +text NOT NULL,
 "naf" text NOT NULL,
 "siege/ets" text NOT= +=20 +NULL,
 "effectif" integer NOT NULL,
 "ca" integer NOT=20 +NULL,
 Constraint "base_aveugle_pkey" Primary Key=20 +("record_id")
);
CREATE INDEX base_aveugle_dunsnumber_key ON base_ave= +ugle=20 +USING btree (dunsnumber);
CREATE INDEX base_aveugle_cp_key ON base_aveug= +le=20 +USING btree (cp);
CREATE INDEX base_aveugle_naf_key ON base_aveugle USIN= +G=20 +btree (naf);
CREATE INDEX base_aveugle_effectif_key ON base_aveugle USIN= +G=20 +btree (effectif);
+
 
+
 
+
This table contains 5 00= +0 000=20 +records
+
 
+
I have a PHP application= + which=20 +often makes queries on this table (especially on the "cp","naf","effectif"= +=20 +fields)
+
 
+
Querries are like :
+
    = + =20 +select (distint cp) from base_aveugle where cp=3D'201A' and effectif betwee= +n 1 and=20 +150
+
    = + =20 +select (*) from base_aveugle where naf in ('721A','213F','421K') and cp in= +=20 +('54210','21459','201A') and effectif < 150
+
 
+
I think it is possible t= +o optimize=20 +the performance of this queries before changing the hardware (I now I= +=20 +will...) but I don't know how, even after having read lot of things about= +=20 +postgresql ...
+
 
+
Thanks ;)  +
 
+

---
Outgoing mail= + is=20 +certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.= +0.737 /=20 +Virus Database: 491 - Release Date: 11/08/2004
+ +------=_NextPart_000_0026_01C4846F.203A1450-- + + +From pgsql-performance-owner@postgresql.org Tue Aug 17 11:12:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A11C45E46EF + for ; + Tue, 17 Aug 2004 11:12:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85710-10 + for ; + Tue, 17 Aug 2004 14:12:24 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id BFBA95E46CC + for ; + Tue, 17 Aug 2004 11:12:21 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7HECMiI090585 + for ; Tue, 17 Aug 2004 14:12:22 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7HDmQF7078750 + for pgsql-performance@postgresql.org; Tue, 17 Aug 2004 13:48:26 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: General performance problem! +Date: Tue, 17 Aug 2004 15:48:29 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 62 +Message-ID: <41220CAD.60401@bigfoot.com> +References: <002901c4845e$5d1dc1c0$0c0101c0@saturne> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: olivier HARO +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: <002901c4845e$5d1dc1c0$0c0101c0@saturne> +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/255 +X-Sequence-Number: 7891 + +olivier HARO wrote: + +> Hello, +> +> I have a dedicated server for my posgresql database : +> +> P4 2.4 GHZ +> HDD IDE 7200 rpm +> 512 DDR 2700 +> +> I have a problem whith one table of my database : +> +> CREATE SEQUENCE "base_aveugle_seq" START 1; +> CREATE TABLE "base_aveugle" ( +> "record_id" integer DEFAULT nextval('"base_aveugle_seq"'::text) NOT NULL, +> "dunsnumber" integer NOT NULL, +> "cp" text NOT NULL, +> "tel" text NOT NULL, +> "fax" text NOT NULL, +> "naf" text NOT NULL, +> "siege/ets" text NOT NULL, +> "effectif" integer NOT NULL, +> "ca" integer NOT NULL, +> Constraint "base_aveugle_pkey" Primary Key ("record_id") +> ); +> CREATE INDEX base_aveugle_dunsnumber_key ON base_aveugle USING btree +> (dunsnumber); +> CREATE INDEX base_aveugle_cp_key ON base_aveugle USING btree (cp); +> CREATE INDEX base_aveugle_naf_key ON base_aveugle USING btree (naf); +> CREATE INDEX base_aveugle_effectif_key ON base_aveugle USING btree +> (effectif); +> +> +> This table contains 5 000 000 records +> +> I have a PHP application which often makes queries on this table +> (especially on the "cp","naf","effectif" fields) +> +> Querries are like : +> select (distint cp) from base_aveugle where cp='201A' and effectif +> between 1 and 150 +> select (*) from base_aveugle where naf in ('721A','213F','421K') +> and cp in ('54210','21459','201A') and effectif < 150 +> +> I think it is possible to optimize the performance of this queries +> before changing the hardware (I now I will...) but I don't know how, +> even after having read lot of things about postgresql ... + +Show us a explain analyze for that queries. + + +Regards +Gaetano Mendola + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Tue Aug 17 10:57:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E4295E37CE + for ; + Tue, 17 Aug 2004 10:57:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80061-07 + for ; + Tue, 17 Aug 2004 13:57:31 +0000 (GMT) +Received: from usbb-lacimss3.unisys.com (usbb-lacimss3.unisys.com + [192.63.108.53]) + by svr1.postgresql.org (Postfix) with ESMTP id 882EF5E37CB + for ; + Tue, 17 Aug 2004 10:57:27 -0300 (ADT) +Received: from USBB-LACGW3.na.uis.unisys.com ([129.224.98.43]unverified) by + usbb-lacimss3 with InterScan Messaging Security Suite; + Tue, 17 Aug 2004 09:59:27 -0400 +Received: from USBB-LACGW3.na.uis.unisys.com ([129.224.98.44]) by + USBB-LACGW3.na.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Tue, 17 Aug 2004 09:57:28 -0400 +Received: from gbmk-eugw2.eu.uis.unisys.com ([129.221.133.27]) by + USBB-LACGW3.na.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Tue, 17 Aug 2004 09:57:28 -0400 +Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by + gbmk-eugw2.eu.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Tue, 17 Aug 2004 14:57:25 +0100 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C48462.2017A1BC" +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Subject: Re: General performance problem! +Date: Tue, 17 Aug 2004 15:57:25 +0200 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] General performance problem! +Thread-Index: AcSEXqt1Qqu7d/JVRsur69d01UsjfAAAskMA +From: "Leeuw van der, Tim" +To: "olivier HARO" , +X-OriginalArrivalTime: 17 Aug 2004 13:57:25.0790 (UTC) + FILETIME=[205DDBE0:01C48462] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=HTML_30_40, + HTML_FONTCOLOR_BLUE, HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200408/254 +X-Sequence-Number: 7890 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C48462.2017A1BC +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi, +=20 +Make multi-column indexes, using the columns from your most typical queries= +, putting the most selective columns first (ie; you don't need to make inde= +xes with columns in the same order as they are used in the query). +=20 +For instance, an index on cp, effectif could likely benefit both queries; s= +ame for an index on cp, effectif, naf. (You'd need only one of these indexe= +s I think, not both. Experiment to find out which one gives you most benefi= +t in your queries, vs. the slowdown in inserts). +Perhaps some of the single-column keys can be dropped. +=20 + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owne= +r@postgresql.org]On Behalf Of olivier HARO +Sent: dinsdag 17 augustus 2004 15:30 +To: pgsql-performance@postgresql.org +Subject: [PERFORM] General performance problem! + + +Hello, +=20 +I have a dedicated server for my posgresql database : +=20 +P4 2.4 GHZ +HDD IDE 7200 rpm +512 DDR 2700 +=20 +I have a problem whith one table of my database : +=20 +CREATE SEQUENCE "base_aveugle_seq" START 1; +CREATE TABLE "base_aveugle" ( + "record_id" integer DEFAULT nextval('"base_aveugle_seq"'::text) NOT NULL, + "dunsnumber" integer NOT NULL, + "cp" text NOT NULL, + "tel" text NOT NULL, + "fax" text NOT NULL, + "naf" text NOT NULL, + "siege/ets" text NOT NULL, + "effectif" integer NOT NULL, + "ca" integer NOT NULL, + Constraint "base_aveugle_pkey" Primary Key ("record_id") +); +CREATE INDEX base_aveugle_dunsnumber_key ON base_aveugle USING btree (dunsn= +umber); +CREATE INDEX base_aveugle_cp_key ON base_aveugle USING btree (cp); +CREATE INDEX base_aveugle_naf_key ON base_aveugle USING btree (naf); +CREATE INDEX base_aveugle_effectif_key ON base_aveugle USING btree (effecti= +f); +=20 +=20 +This table contains 5 000 000 records +=20 +I have a PHP application which often makes queries on this table (especiall= +y on the "cp","naf","effectif" fields) +=20 +Querries are like : + select (distint cp) from base_aveugle where cp=3D'201A' and effectif = +between 1 and 150 + select (*) from base_aveugle where naf in ('721A','213F','421K') and = +cp in ('54210','21459','201A') and effectif < 150 +=20 +I think it is possible to optimize the performance of this queries before c= +hanging the hardware (I now I will...) but I don't know how, even after hav= +ing read lot of things about postgresql ... +=20 +Thanks ;)=20 +=20 + +--- +Outgoing mail is certified Virus Free. +Checked by AVG anti-virus system ( http://www.grisoft.com). +Version: 6.0.737 / Virus Database: 491 - Release Date: 11/08/2004 + + +------_=_NextPart_001_01C48462.2017A1BC +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + +
Hi,
+
 
+
Make=20 +multi-column indexes, using the columns from your most typical queries, put= +ting=20 +the most selective columns first (ie; you don't need to make indexes with= +=20 +columns in the same order as they are used in the query). +
 
+
For=20 +instance, an index on cp, effectif could likely benefit both queries; same = +for=20 +an index on cp, effectif, naf. (You'd need only one of these indexes I thin= +k,=20 +not both. Experiment to find out which one gives you most benefit in your= +=20 +queries, vs. the slowdown in inserts).
+
Perhaps some of the single-column keys can be=20 +dropped.
+
 
+
+
-----Original Message-----
From:=20 + pgsql-performance-owner@postgresql.org=20 + [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of olivie= +r=20 + HARO
Sent: dinsdag 17 augustus 2004 15:30
To:=20 + pgsql-performance@postgresql.org
Subject: [PERFORM] General=20 + performance problem!

+
Hello,
+
 
+
I have a dedicated ser= +ver for my=20 + posgresql database :
+
 
+
P4 2.4 GHZ
+
HDD IDE 7200 rpm
+
512 DDR 2700 +
 
+
I have a problem whith= + one table=20 + of my database :
+
 
+
CREATE SEQUENCE "base_aveugle_seq" STA= +RT=20 + 1;
CREATE TABLE "base_aveugle" (
 "record_id" integer DEFAULT= +=20 + nextval('"base_aveugle_seq"'::text) NOT NULL,
 "dunsnumber" integ= +er=20 + NOT NULL,
 "cp" text NOT NULL,
 "tel" text NOT=20 + NULL,
 "fax" text NOT NULL,
 "naf" text NOT=20 + NULL,
 "siege/ets" text NOT NULL,
 "effectif" integer NOT= +=20 + NULL,
 "ca" integer NOT NULL,
 Constraint "base_aveugle_p= +key"=20 + Primary Key ("record_id")
);
CREATE INDEX base_aveugle_dunsnumber_k= +ey ON=20 + base_aveugle USING btree (dunsnumber);
CREATE INDEX base_aveugle_cp_ke= +y ON=20 + base_aveugle USING btree (cp);
CREATE INDEX base_aveugle_naf_key ON=20 + base_aveugle USING btree (naf);
CREATE INDEX base_aveugle_effectif_key= + ON=20 + base_aveugle USING btree (effectif);
+
 
+
 
+
This table contains 5 = +000 000=20 + records
+
 
+
I have a PHP applicati= +on which=20 + often makes queries on this table (especially on the "cp","naf","effectif= +"=20 + fields)
+
 
+
Querries are like :
+
   &nbs= +p; =20 + select (distint cp) from base_aveugle where cp=3D'201A' and effectif betw= +een 1=20 + and 150
+
   &nbs= +p; =20 + select (*) from base_aveugle where naf in ('721A','213F','421K') and cp i= +n=20 + ('54210','21459','201A') and effectif < 150
+
 
+
I think it is possible= + to=20 + optimize the performance of this queries before changing the hardwar= +e (I=20 + now I will...) but I don't know how, even after having read lot of things= +=20 + about postgresql ...
+
 
+
Thanks ;) = +
+
 
+

---
Outgoing ma= +il is=20 + certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: = +6.0.737=20 + / Virus Database: 491 - Release Date:=20 +11/08/2004
+ +------_=_NextPart_001_01C48462.2017A1BC-- + +From pgsql-performance-owner@postgresql.org Tue Aug 17 11:16:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E0F265E46ED + for ; + Tue, 17 Aug 2004 11:16:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91444-03 + for ; + Tue, 17 Aug 2004 14:16:16 +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 312855E46EC + for ; + Tue, 17 Aug 2004 11:16:13 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) + id 1Bx4l8-0002RN-0W; Tue, 17 Aug 2004 14:16:19 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 5608418658; Tue, 17 Aug 2004 15:16:16 +0100 (BST) +Message-ID: <4122132E.80603@archonet.com> +Date: Tue, 17 Aug 2004 15:16:14 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: olivier HARO +Cc: pgsql-performance@postgresql.org +Subject: Re: General performance problem! +References: <002901c4845e$5d1dc1c0$0c0101c0@saturne> +In-Reply-To: <002901c4845e$5d1dc1c0$0c0101c0@saturne> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/256 +X-Sequence-Number: 7892 + +olivier HARO wrote: +> This table contains 5 000 000 records +> +> I have a PHP application which often makes queries on this table (especially on the "cp","naf","effectif" fields) +> +> Querries are like : +> select (distint cp) from base_aveugle where cp='201A' and effectif between 1 and 150 +> select (*) from base_aveugle where naf in ('721A','213F','421K') and cp in ('54210','21459','201A') and effectif < 150 + +We'll need to know what version of PostgreSQL you're using and also what +the output of EXPLAIN ANALYZE shows for your example queries. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Aug 18 12:52:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E6B2B5E4701 + for ; + Tue, 17 Aug 2004 11:23:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94532-04 + for ; + Tue, 17 Aug 2004 14:23:01 +0000 (GMT) +Received: from mail.bluecatnetworks.com (mail.bluecatnetworks.com + [209.167.177.42]) + by svr1.postgresql.org (Postfix) with ESMTP id 157BB5E46F5 + for ; + Tue, 17 Aug 2004 11:22:58 -0300 (ADT) +Received: from [172.18.0.2] ([172.18.0.2]:56988 "EHLO COLOSSUS.dyadem.corp" + ident: "NO-IDENT-SERVICE[2]") by mail.bluecatnetworks.com with ESMTP + id convert rfc822-to-8bit; + Tue, 17 Aug 2004 10:22:59 -0400 +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: 8BIT +Subject: I could not get postgres to utilizy indexes +Date: Tue, 17 Aug 2004 10:22:59 -0400 +Message-ID: <5DEC3FFCDE2F7C4DA45433EE09A4F22C01A3FFCA@colossus.dyadem.corp> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: I could not get postgres to utilizy indexes +Thread-Index: AcSEZbJwv6sR2bdDTJ+eEmRsHloP7w== +From: "Igor Artimenko" +To: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/273 +X-Sequence-Number: 7909 + +Hi verybody! + +I can't make use of indexes even I tried the same test by changing different settings in postgres.conf like geqo to off/on & geqo related parameters, enable_seqscan off/on & so on. Result is the same. + +Here is test itself: + +I've created simplest table test and executed the same statement "explain analyze select id from test where id = 50000;" Few times I added 100,000 records, applied vacuum full; and issued above explain command. +Postgres uses sequential scan instead of index one. +Of cause Time to execute the same statement constantly grows. In my mind index should not allow time to grow so much. + +Why Postgres does not utilizes primary unique index? +What I'm missing? It continue growing even there are 1,200,000 records. It should at least start using index at some point. + + +Details are below: +100,000 records: +QUERY PLAN +---------------------------------------------------------------------------------------------------- + Seq Scan on test (cost=0.00..2427.00 rows=2 width=8) (actual time=99.626..199.835 rows=1 loops=1) + Filter: (id = 50000) + Total runtime: 199.990 ms + +200,000 records: +QUERY PLAN +----------------------------------------------------------------------------------------------------- + Seq Scan on test (cost=0.00..4853.00 rows=2 width=8) (actual time=100.389..402.770 rows=1 loops=1) + Filter: (id = 50000) + Total runtime: 402.926 ms + + +300,000 records: +QUERY PLAN +----------------------------------------------------------------------------------------------------- + Seq Scan on test (cost=0.00..7280.00 rows=1 width=8) (actual time=100.563..616.064 rows=1 loops=1) + Filter: (id = 50000) + Total runtime: 616.224 ms +(3 rows) + +I've created test table by script: + +CREATE TABLE test +( + id int8 NOT NULL DEFAULT nextval('next_id_seq'::text) INIQUE, + description char(50), + CONSTRAINT users_pkey PRIMARY KEY (id) +); + +CREATE SEQUENCE next_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 10000000000 + START 1 + CACHE 5 + CYCLE; + +I use postgres 7.4.2 + + + + +From pgsql-performance-owner@postgresql.org Tue Aug 17 12:35:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 922745E46D7 + for ; + Tue, 17 Aug 2004 12:35:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29380-08 + for ; + Tue, 17 Aug 2004 15:35:58 +0000 (GMT) +Received: from web11901.mail.yahoo.com (web11901.mail.yahoo.com + [216.136.172.185]) + by svr1.postgresql.org (Postfix) with SMTP id C40CA5E46F4 + for ; + Tue, 17 Aug 2004 12:35:49 -0300 (ADT) +Message-ID: <20040817153555.85408.qmail@web11901.mail.yahoo.com> +Received: from [209.167.177.36] by web11901.mail.yahoo.com via HTTP; + Tue, 17 Aug 2004 08:35:55 PDT +Date: Tue, 17 Aug 2004 08:35:55 -0700 (PDT) +From: Artimenko Igor +Subject: Postgres does not utilize indexes. Why? +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/257 +X-Sequence-Number: 7893 + +Hi everybody! + +I can�t make use of indexes even I tried the same test by changing different settings in +postgres.conf like geqo to off/on & geqo related parameters, enable_seqscan off/on & so on. Result +is the same. + +Here is test itself: + +I�ve created simplest table test and executed the same statement �explain analyze select id from +test where id = 50000;� Few times I added 100,000 records, applied vacuum full; and issued above +explain command. +Postgres uses sequential scan instead of index one. +Of cause Time to execute the same statement constantly grows. In my mind index should not allow +time to grow so much. + +Why Postgres does not utilizes primary unique index? +What I�m missing? It continue growing even there are 1,200,000 records. It should at least start +using index at some point. + + +Details are below: +100,000 records: +QUERY PLAN +---------------------------------------------------------------------------------------------------- + Seq Scan on test (cost=0.00..2427.00 rows=2 width=8) (actual time=99.626..199.835 rows=1 +loops=1) + Filter: (id = 50000) + Total runtime: 199.990 ms + +200,000 records: +QUERY PLAN +----------------------------------------------------------------------------------------------------- + Seq Scan on test (cost=0.00..4853.00 rows=2 width=8) (actual time=100.389..402.770 rows=1 +loops=1) + Filter: (id = 50000) + Total runtime: 402.926 ms + + +300,000 records: +QUERY PLAN +----------------------------------------------------------------------------------------------------- + Seq Scan on test (cost=0.00..7280.00 rows=1 width=8) (actual time=100.563..616.064 rows=1 +loops=1) + Filter: (id = 50000) + Total runtime: 616.224 ms +(3 rows) + +I've created test table by script: + +CREATE TABLE test +( + id int8 NOT NULL DEFAULT nextval('next_id_seq'::text) INIQUE, + description char(50), + CONSTRAINT users_pkey PRIMARY KEY (id) +); + +CREATE SEQUENCE next_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 10000000000 + START 1 + CACHE 5 + CYCLE; + +I use postgres 7.4.2 + + + + + + +===== +Thanks a lot +Igor Artimenko +I specialize in +Java, J2EE, Unix, Linux, HP, AIX, Solaris, Progress, Oracle, DB2, Postgres, Data Modeling + + + +__________________________________ +Do you Yahoo!? +New and Improved Yahoo! Mail - Send 10MB messages! +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Tue Aug 17 12:41:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CB73E5E46E9 + for ; + Tue, 17 Aug 2004 12:41:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33456-06 + for ; + Tue, 17 Aug 2004 15:41:45 +0000 (GMT) +Received: from mail.aspserveur.com (7.95.39-62.rev.gaoland.net [62.39.95.7]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FD975E46E2 + for ; + Tue, 17 Aug 2004 12:41:35 -0300 (ADT) +Received: from saturne ([193.251.84.117]) + by mail.aspserveur.com (ASPSERVEUR Ultimate mail Server) with SMTP id + HUO74536 + for ; Tue, 17 Aug 2004 17:42:08 +0200 +Message-ID: <001901c48470$b1b92140$0c0101c0@saturne> +From: "olivier HARO" +To: +Subject: Re: General performance problem! +Date: Tue, 17 Aug 2004 17:41:41 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/258 +X-Sequence-Number: 7894 + +Thanks for the tip for the index on multiple columns ! (I never do inserts +on this table so insert time doesn't matter) + +Mys posgresql version is : PostgreSQL 7.2.1 + +Here are the results of the EXPLAIN ANALYZE you asked me to execute. + + +explain analyse select cp from base_aveugle where cp='69740' and effectif +between 1 and 50; + NOTICE: QUERY PLAN: + Index Scan using base_aveugle_cp_eff on base_aveugle +(cost=0.00..508.69 rows=126 width=32) + (actual time=0.27..11.56 rows=398 loops=1) + Total runtime: 11.77 msec + EXPLAIN + +explain analyse select cp from base_aveugle where cp like '69%' and effectif +between 1 and 50 and naf like '24%' or naf like '25%'; + NOTICE: QUERY PLAN: + Index Scan using base_aveugle_cp_eff_naf, base_aveugle_naf on +base_aveugle (cost=0.00..100001.89 rows=25245 width=32) + (actual time=4.40..353.69 rows=6905 loops=1) + Total runtime: 355.82 msec + EXPLAIN + + +thx ;) + + +--- +Outgoing mail is certified Virus Free. +Checked by AVG anti-virus system (http://www.grisoft.com). +Version: 6.0.737 / Virus Database: 491 - Release Date: 11/08/2004 + + +From pgsql-performance-owner@postgresql.org Tue Aug 17 12:45:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0FED35E46D5 + for ; + Tue, 17 Aug 2004 12:45:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33374-06 + for ; + Tue, 17 Aug 2004 15:45:26 +0000 (GMT) +Received: from mx.mall.cz (mx.mall.cz [62.168.45.106]) + by svr1.postgresql.org (Postfix) with ESMTP id 16E385E46F0 + for ; + Tue, 17 Aug 2004 12:45:16 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mx.mall.cz (Postfix) with ESMTP + id 6E8F948026; Tue, 17 Aug 2004 17:45:22 +0200 (CEST) +Received: from mx.mall.cz ([127.0.0.1]) + by localhost (posta [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 04713-01; Tue, 17 Aug 2004 17:45:12 +0200 (CEST) +Message-ID: <4122281E.1060402@taborsky.cz> +Date: Tue, 17 Aug 2004 17:45:34 +0200 +From: Michal Taborsky +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Artimenko Igor +Cc: pgsql-performance@postgresql.org +Subject: Re: Postgres does not utilize indexes. Why? +References: <20040817153555.85408.qmail@web11901.mail.yahoo.com> +In-Reply-To: <20040817153555.85408.qmail@web11901.mail.yahoo.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/259 +X-Sequence-Number: 7895 + +Artimenko Igor wrote: +> id int8 NOT NULL DEFAULT nextval('next_id_seq'::text) INIQUE, + +ID column is bigint, but '50000' is int, therefore the index does not +match. You need to cast your clause like this: + +select id from test where id = 50000::int8 + +Also, issue VACUUM ANALYZE, so Postgres knows about the structure of the +data. + +-- +Michal Taborsky +http://www.taborsky.cz + + +From pgsql-performance-owner@postgresql.org Tue Aug 17 13:59:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E558F5E40BB + for ; + Tue, 17 Aug 2004 13:59:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62480-10 + for ; + Tue, 17 Aug 2004 16:59:09 +0000 (GMT) +Received: from mailbox.maricopa.gov (mailbox.maricopa.gov [156.42.4.109]) + by svr1.postgresql.org (Postfix) with ESMTP id DA45C5E37CE + for ; + Tue, 17 Aug 2004 13:58:59 -0300 (ADT) +Received: from maricopa_xcng2.maricopa.gov (maricopa_xcng2.maricopa.gov + [156.42.103.174] (may be forged)) + by mailbox.maricopa.gov (8.8.6 (PHNE_17190)/8.8.6) with ESMTP id + JAA05820; Tue, 17 Aug 2004 09:51:47 -0700 (MST) +Received: by maricopa_xcng2 with Internet Mail Service (5.5.2657.72) + id ; Tue, 17 Aug 2004 09:59:00 -0700 +Message-ID: <64EDC403A1417B4299488BAE87CA7CBF01CD0F36@maricopa_xcng0> +From: Duane Lee - EGOVX +To: "'olivier HARO'" , pgsql-performance@postgresql.org +Subject: Re: General performance problem! +Date: Tue, 17 Aug 2004 09:58:59 -0700 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C4847B.7DBF4F30" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=HTML_70_80, + HTML_FONTCOLOR_UNKNOWN, HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200408/260 +X-Sequence-Number: 7896 + +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_01C4847B.7DBF4F30 +Content-Type: text/plain; + charset="iso-8859-1" + +An index on cp and effectif would help your first query. An index on naf, +cp and effectif would help your second query. + +Something like this: + +CREATE INDEX base_aveugle_cp_key2 ON base_aveugle USING btree (cp, +effectif); +CREATE INDEX base_aveugle_naf_key2 ON base_aveugle USING btree (naf, cp, +effectif); + +Another thing, why include "distinct cp" when you are only selecting +"cp='201A'"? You will only retrieve one record regardless of how many may +contain cp='201A'. + +If you could make these UNIQUE indexes that would help also but it's not a +requirement. + +Good luck, +Duane + + +-----Original Message----- +From: olivier HARO [mailto:o.haro@en-compro.com] +Sent: Tuesday, August 17, 2004 6:30 AM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] General performance problem! + +Hello, + +I have a dedicated server for my posgresql database : + +P4 2.4 GHZ +HDD IDE 7200 rpm +512 DDR 2700 + +I have a problem whith one table of my database : + +CREATE SEQUENCE "base_aveugle_seq" START 1; +CREATE TABLE "base_aveugle" ( + "record_id" integer DEFAULT nextval('"base_aveugle_seq"'::text) NOT NULL, + "dunsnumber" integer NOT NULL, + "cp" text NOT NULL, + "tel" text NOT NULL, + "fax" text NOT NULL, + "naf" text NOT NULL, + "siege/ets" text NOT NULL, + "effectif" integer NOT NULL, + "ca" integer NOT NULL, + Constraint "base_aveugle_pkey" Primary Key ("record_id") +); +CREATE INDEX base_aveugle_dunsnumber_key ON base_aveugle USING btree +(dunsnumber); +CREATE INDEX base_aveugle_cp_key ON base_aveugle USING btree (cp); +CREATE INDEX base_aveugle_naf_key ON base_aveugle USING btree (naf); +CREATE INDEX base_aveugle_effectif_key ON base_aveugle USING btree +(effectif); + + +This table contains 5 000 000 records + +I have a PHP application which often makes queries on this table (especially +on the "cp","naf","effectif" fields) + +Querries are like : + select (distint cp) from base_aveugle where cp='201A' and effectif +between 1 and 150 + select (*) from base_aveugle where naf in ('721A','213F','421K') and +cp in ('54210','21459','201A') and effectif < 150 + +I think it is possible to optimize the performance of this queries before +changing the hardware (I now I will...) but I don't know how, even after +having read lot of things about postgresql ... + +Thanks ;) + + +--- +Outgoing mail is certified Virus Free. +Checked by AVG anti-virus system ( http://www.grisoft.com + ). +Version: 6.0.737 / Virus Database: 491 - Release Date: 11/08/2004 + +------_=_NextPart_001_01C4847B.7DBF4F30 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + + + + + + +
+ +

An i= +ndex +on cp and effectif would help your first query.  An index on naf, cp and effectif would help your second +query.

+ +

 

+ +

Some= +thing +like this:

+ +

 

+ +

CREATE INDEX base_aveugle_cp_key2 ON +base_aveugle USING btree (cp, effectif);
+CREATE INDEX base_aveugle_naf_key2 ON base_aveugle USING btree (naf, cp, +effectif);

+ +

 

+ +

<= +span +style=3D'font-size:12.0pt;color:navy'>Another thing, why include “dis= +tinct cp” +when you are only selecting “cp=3D’201A’”?  +You will only retrieve one record regardless of how many may contain= + cp=3D’201A’.

+ +

<= +span +style=3D'font-size:12.0pt;color:navy'> 

+ +

<= +span +style=3D'font-size:12.0pt;color:navy'>If you could make these UNIQUE indexe= +s that +would help also but it’s not a requirement.

+ +

 

+ +

Good= + luck,

+ +

Duan= +e

+ +

 

+ +

 

+ +

-----Original +Message-----
+From: olivier HARO +[mailto:o.haro@en-compro.com]
+Sent: Tuesday, August 17, 20= +04 +6:30 AM
+To: +pgsql-performance@postgresql.org
+Subject: [PERFORM] General +performance problem!

+ +

 <= +/o:p>

+ +

Hello,

+ +

 = +;

+ +

I +have a dedicated server for my posgresql database :

+ +

 = +;

+ +

P4 +2.4 GHZ

+ +

HDD +IDE 7200 rpm

+ +

512 +DDR 2700

+ +

 = +;

+ +

I +have a problem whith one table of my database :

+ +

 = +;

+ +

CREATE +SEQUENCE "base_aveugle_seq" START 1;
+CREATE TABLE "base_aveugle" (
+ "record_id" integer DEFAULT +nextval('"base_aveugle_seq"'::text) NOT NULL,
+ "dunsnumber" integer NOT NULL,
+ "cp" text NOT NULL,
+ "tel" text NOT NULL,
+ "fax" text NOT NULL,
+ "naf" text NOT NULL,
+ "siege/ets" text NOT NULL,
+ "effectif" integer NOT NULL,
+ "ca" integer NOT NULL,
+ Constraint "base_aveugle_pkey" Primary Key +("record_id")
+);
+CREATE INDEX base_aveugle_dunsnumber_key ON base_aveugle USING btree +(dunsnumber);
+CREATE INDEX base_aveugle_cp_key ON base_aveugle USING btree (cp);
+CREATE INDEX base_aveugle_naf_key ON base_aveugle USING btree (naf);
+CREATE INDEX base_aveugle_effectif_key ON base_aveugle USING btree (effecti= +f);

+ +

 = +;

+ +

 = +;

+ +

This +table contains 5 000 000 records

+ +

 = +;

+ +

I +have a PHP application which often makes queries on this table (especially = +on +the "cp","naf","effectif" fields)

+ +

 = +;

+ +

Querries +are like :

+ +

      +select (distint cp) from base_aveugle where cp=3D'201A' and effectif betwee= +n 1 +and 150

+ +

      +select (*) from base_aveugle where naf in ('721A','213F','421K') and cp in +('54210','21459','201A') and effectif < 150

+ +

 = +;

+ +

I +think it is possible to optimize the performance of this queries before +changing the hardware (I now I will...) but I don't know how, even aft= +er +having read lot of things about postgresql ...

+ +

 = +;

+ +

Thanks +;) 

+ +

 = +;

+ +


+---
+Outgoing mail is certified Virus Free.
+Checked by AVG anti-virus system (http:/= +/www.grisoft.com).
+Version: 6.0.737 / Virus Database: 491 - Release Date: 11/08/2004

+ +
+ + + + + +------_=_NextPart_001_01C4847B.7DBF4F30-- + +From pgsql-performance-owner@postgresql.org Tue Aug 17 15:32:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 07B425E46C3 + for ; + Tue, 17 Aug 2004 15:32:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95398-10 + for ; + Tue, 17 Aug 2004 18:32:45 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id F3C5C5E46D5 + for ; + Tue, 17 Aug 2004 15:32:44 -0300 (ADT) +Received: (qmail 4452 invoked from network); 17 Aug 2004 20:32:48 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 17 Aug 2004 20:32:48 +0200 +To: "Artimenko Igor" , + pgsql-performance@postgresql.org +Subject: Re: Postgres does not utilize indexes. Why? +References: <20040817153555.85408.qmail@web11901.mail.yahoo.com> +Message-ID: +From: =?utf-8?Q?Pierre-Fr=C3=A9d=C3=A9ric_Caillaud?= + +Organization: =?utf-8?Q?La_Boutique_Num=C3=A9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Date: Tue, 17 Aug 2004 20:33:21 +0200 +In-Reply-To: <20040817153555.85408.qmail@web11901.mail.yahoo.com> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/261 +X-Sequence-Number: 7897 + +> test where id = 50000;” Few times I added 100,000 records, applied + + cast the 50000 to int8 and it will use the index + +From pgsql-performance-owner@postgresql.org Tue Aug 17 17:03:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BE2FF5E46BF + for ; + Tue, 17 Aug 2004 17:03:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31659-06 + for ; + Tue, 17 Aug 2004 20:03:01 +0000 (GMT) +Received: from sweetwater.com (mail3.sweetwater.com [12.47.0.237]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EC615E46D5 + for ; + Tue, 17 Aug 2004 17:03:00 -0300 (ADT) +Received: from [172.21.22.155] by qm.sweetwater.com + with SMTP (QuickMail Pro Server for Mac 3.0.2); + 17-Aug-2004 15:02:49 -0500 +Mime-Version: 1.0 (Apple Message framework v619) +To: pgsql-performance@postgresql.org +Message-Id: <69FC9F49-F088-11D8-BDD7-000A95A58EA0@sweetwater.com> +Content-Type: multipart/alternative; boundary=Apple-Mail-20-649135890 +From: Joe Lester +Subject: Re: shared_buffers Question +Date: Tue, 17 Aug 2004 15:02:49 -0500 +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200408/262 +X-Sequence-Number: 7898 + +--Apple-Mail-20-649135890 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + format=flowed + +I'm doing a nightly vacuum... so I don't think that's it, although +should I be doing a FULL vacuum instead? The size of my data directory +is only about 389 MB. I'll take a closer look at file sizes going +forward. + +echo "VACUUM ANALYZE VERBOSE;" | /Library/PostgreSQL/bin/psql -U +postgres officelink 2>> vacuum.log + +Thanks. + + +From: "Scott Marlowe" +Your shared buffers are almost certainly not the problem here. 2000 +shared buffers is only 16 Megs of ram, max. More than likely, the +database filled up the data directory / partition because it wasn't +being vacuumed. + +On Sat, 2004-07-31 at 10:25, Joe Lester wrote: + > I've been running a postgres server on a Mac (10.3, 512MB RAM) with +200 + > clients connecting for about 2 months without a crash. However just + > yesterday the database and all the clients hung. When I looked at the + > Mac I'm using as the postgres server it had a window up that said that + > there was no more disk space available to write memory too. I ended up + > having to restart the whole machine. I would like to configure +postgres + > so that is does not rely so heavily on disk-based memory but, rather, + > tries to stay within the scope of the 512MB of physical memory in the + > Mac. + + + + + +--Apple-Mail-20-649135890 +Content-Transfer-Encoding: 7bit +Content-Type: text/enriched; + charset=US-ASCII + +I'm doing a nightly vacuum... so I don't think that's it, although +should I be doing a FULL vacuum instead? The size of my data directory +is only about 389 MB. I'll take a closer look at file sizes going +forward. + + +echo "VACUUM ANALYZE VERBOSE;" | /Library/PostgreSQL/bin/psql -U +postgres officelink 2>> vacuum.log + + +Thanks. + + + +Lucida GrandeFromLucida Grande: +"Scott Marlowe"Courier + +Your shared buffers are almost certainly not the problem here. 2000 + +shared buffers is only 16 Megs of ram, max. More than likely, the + +database filled up the data directory / partition because it wasn't + +being vacuumed. + + + +CourierOn Sat, 2004-07-31 at 10:25, Joe +Lester wrote: + +> I've been running a postgres server on a Mac (10.3, 512MB RAM) with +200 + +> clients connecting for about 2 months without a crash. However just + +> yesterday the database and all the clients hung. When I looked at +the + +> Mac I'm using as the postgres server it had a window up that said +that + +> there was no more disk space available to write memory too. I ended +up + +> having to restart the whole machine. I would like to configure +postgres + +> so that is does not rely so heavily on disk-based memory but, +rather, + +> tries to stay within the scope of the 512MB of physical memory in +the + +> Mac. + + + + + + +--Apple-Mail-20-649135890-- + + + +From pgsql-performance-owner@postgresql.org Tue Aug 17 18:30:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8AB6B5E4249 + for ; + Tue, 17 Aug 2004 18:30:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62563-07 + for ; + Tue, 17 Aug 2004 21:30:08 +0000 (GMT) +Received: from gatefox.foxi.nl (foxi.xs4all.nl [194.109.246.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 7047F5E46C2 + for ; + Tue, 17 Aug 2004 18:30:06 -0300 (ADT) +Received: from techfox.foxi (techfox.foxi [192.168.0.79]) + by gatefox.foxi.nl (8.10.2-20030922/8.10.2) with ESMTP id i7HLTqu13078 + for ; Tue, 17 Aug 2004 23:29:52 +0200 +From: Frank van Vugt +Organization: Foxi Consultants in Technology BV +To: pgsql-performance@postgresql.org +Subject: Why is the number of dead tuples causing the performance of deferred + triggers to degrading so rapidly (exponentionally)? +Date: Tue, 17 Aug 2004 23:29:52 +0200 +User-Agent: KMail/1.5.4 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200408172329.52555.ftm.van.vugt@foxi.nl> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/263 +X-Sequence-Number: 7899 + +Hi, + +I'm seeing the following behaviour with the table and functions given below: + +db=# insert into f select * from full_sequence(1, 1000); +INSERT 0 1000 +Time: 197,507 ms +db=# insert into f select * from full_sequence(1, 1000); +INSERT 0 1000 +Time: 341,880 ms +db=# insert into f select * from full_sequence(1, 1000); +INSERT 0 1000 +Time: 692,603 ms +db=# insert into f select * from full_sequence(1, 1000); +INSERT 0 1000 +Time: 985,253 ms +db=# insert into f select * from full_sequence(1, 1000); +INSERT 0 1000 +Time: 1241,334 ms + +Or even worse (fresh drop/create of the table and functions): + +db=# insert into f select id from full_sequence(1, 10000); +INSERT 0 10000 +Time: 22255,767 ms +db=# insert into f select id from full_sequence(1, 10000); +INSERT 0 10000 +Time: 45398,433 ms +db=# insert into f select id from full_sequence(1, 10000); +INSERT 0 10000 +Time: 67993,476 ms + +Wrapping the commands in a transaction only accumulates the penalty at commit. + +It seems in this case the time needed for a single deferred trigger somehow +depends on the number of dead tuples in the table, because a vacuum of the +table will 'reset' the query-times. However, even if I wanted to, vacuum is +not allowed from within a function. + +What is happening here? And more importantly, what can I do to prevent this? + +NB. My real-world application 'collects' id's in need for deferred work, but +this work is both costly and only needed once per base record. So I use an +'update' table whose content I join with the actual tables in order to do the +work for _all_ the base records involved upon the first execution of the +deferred trigger. At the end of the trigger, this 'update' table is emptied +so any additional deferred triggers on the same table will hardly lose any +time. Or at least, that was the intention.... + +*********** demo script *********** +drop table f cascade; +drop function tr_f_def() cascade; +drop function full_sequence(integer, integer); +drop type full_sequence_type; + +create table f (id int); +create function tr_f_def() RETURNS trigger LANGUAGE 'plpgsql' STABLE STRICT +SECURITY INVOKER AS ' + DECLARE + BEGIN + -- do stuff with all the ids in the table + + -- delete the contents +-- delete from f; + IF EXISTS (SELECT 1 FROM f) THEN + DELETE FROM F; + VACUUM F; + END IF; + + RETURN NULL; + END;'; +create type full_sequence_type as (id int); +create function full_sequence(integer, integer) + RETURNS SETOF full_sequence_type + LANGUAGE 'plpgsql' + IMMUTABLE + STRICT + SECURITY INVOKER + AS ' DECLARE + my_from ALIAS FOR $1; + my_to ALIAS FOR $2; + result full_sequence_type%ROWTYPE; + BEGIN + -- just loop + FOR i IN my_from..my_to LOOP + result.id = i; + RETURN NEXT result; + END LOOP; + + -- finish + RETURN; + END;'; +CREATE CONSTRAINT TRIGGER f_def AFTER INSERT ON f DEFERRABLE INITIALLY +DEFERRED FOR EACH ROW EXECUTE PROCEDURE tr_f_def(); +*********** demo script *********** + +db=# select version(); + version +--------------------------------------------------------------------- + PostgreSQL 7.4.3 on i686-pc-linux-gnu, compiled by GCC egcs-2.91.66 + + + + + +-- +Best, + + + + +Frank. + + +From pgsql-performance-owner@postgresql.org Tue Aug 17 18:34:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A908B5E46C7 + for ; + Tue, 17 Aug 2004 18:34:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67076-04 + for ; + Tue, 17 Aug 2004 21:33:58 +0000 (GMT) +Received: from gatefox.foxi.nl (foxi.xs4all.nl [194.109.246.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F5235E46C5 + for ; + Tue, 17 Aug 2004 18:33:56 -0300 (ADT) +Received: from techfox.foxi (techfox.foxi [192.168.0.79]) + by gatefox.foxi.nl (8.10.2-20030922/8.10.2) with ESMTP id i7HLXgu13142 + for ; Tue, 17 Aug 2004 23:33:42 +0200 +From: Frank van Vugt +Organization: Foxi Consultants in Technology BV +Subject: Why is the number of dead tuples causing the performance of deferred + triggers to degrading so rapidly (exponentionally)? +Date: Tue, 17 Aug 2004 23:33:42 +0200 +User-Agent: KMail/1.5.4 +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200408172333.42561.ftm.van.vugt@foxi.nl> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/264 +X-Sequence-Number: 7900 + +Obviously, + +this part of tr_f_def(): + +****************************** + -- delete the contents +-- delete from f; + IF EXISTS (SELECT 1 FROM f) THEN + DELETE FROM F; + VACUUM F; + END IF; +****************************** + + +should simply read: + +****************************** + -- delete the contents + delete from f; +****************************** + + + +-- +Best, + + + + +Frank. + + +From pgsql-performance-owner@postgresql.org Tue Aug 17 20:03:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C6F875E46BF + for ; + Tue, 17 Aug 2004 20:03:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92032-08 + for ; + Tue, 17 Aug 2004 23:03:34 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D6635E46C4 + for ; + Tue, 17 Aug 2004 20:03:31 -0300 (ADT) +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 6106436; Tue, 17 Aug 2004 16:04:50 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Frank van Vugt +Subject: Re: Why is the number of dead tuples causing the performance of + deferred triggers to degrading so rapidly (exponentionally)? +Date: Tue, 17 Aug 2004 16:03:43 -0700 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <200408172329.52555.ftm.van.vugt@foxi.nl> +In-Reply-To: <200408172329.52555.ftm.van.vugt@foxi.nl> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200408171603.43236.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/265 +X-Sequence-Number: 7901 + +Frank, + +> It seems in this case the time needed for a single deferred trigger somehow +> depends on the number of dead tuples in the table, because a vacuum of the +> table will 'reset' the query-times. However, even if I wanted to, vacuum is +> not allowed from within a function. +> +> What is happening here? And more importantly, what can I do to prevent +> this? + +I'm not clear on all of the work you're doing in the trigger. However, it +seems obvious that you're deleting and/or updating a large number of rows. +The escalating execution times would be consistent with that. + +> NB. My real-world application 'collects' id's in need for deferred work, +> but this work is both costly and only needed once per base record. So I use +> an 'update' table whose content I join with the actual tables in order to +> do the work for _all_ the base records involved upon the first execution of +> the deferred trigger. At the end of the trigger, this 'update' table is +> emptied so any additional deferred triggers on the same table will hardly +> lose any time. Or at least, that was the intention.... + +I think you're doing a lot more than is wise to do in triggers. Deferrable +triggers aren't really intended for running long procedures with the creation +of types and temporary tables (your post got a bit garbled, so pardon me if +I'm misreading it). I'd suggest reconsidering your approach to this +application problem. + +At the very least, increase max_fsm_relations to some high value, which may +help (or not). + +-Josh + +-- +__Aglio Database Solutions_______________ +Josh Berkus Consultant +josh@agliodbs.com www.agliodbs.com +Ph: 415-752-2500 Fax: 415-752-2387 +2166 Hayes Suite 200 San Francisco, CA + +From pgsql-performance-owner@postgresql.org Tue Aug 17 21:44:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 49D835E46C1 + for ; + Tue, 17 Aug 2004 21:44:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23517-09 + for ; + Wed, 18 Aug 2004 00:44:37 +0000 (GMT) +Received: from web54108.mail.yahoo.com (web54108.mail.yahoo.com + [206.190.37.243]) + by svr1.postgresql.org (Postfix) with SMTP id 801205E46BF + for ; + Tue, 17 Aug 2004 21:44:34 -0300 (ADT) +Message-ID: <20040818004438.83822.qmail@web54108.mail.yahoo.com> +Received: from [129.94.6.30] by web54108.mail.yahoo.com via HTTP; + Tue, 17 Aug 2004 17:44:38 PDT +Date: Tue, 17 Aug 2004 17:44:38 -0700 (PDT) +From: my thi ho +Subject: postgresql performance with multimedia +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/266 +X-Sequence-Number: 7902 + +Hi, +I am working on a project which explore postgresql to +store multimedia data. +In details, i am trying to work with the buffer +management part of postgres source code. And try to +improve the performance. I had search on the web but +could not find much usefull information. +It would be great if anyone knows any developer groups +that working on similar things ? or where can i find +more information on this issue? +Thank you very much for your help +regards, +MT Ho + + + +__________________________________ +Do you Yahoo!? +Yahoo! Mail - 50x more storage than other providers! +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Wed Aug 18 05:18:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 855B75E3639 + for ; + Wed, 18 Aug 2004 05:18:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60633-06 + for ; + Wed, 18 Aug 2004 08:18:20 +0000 (GMT) +Received: from ludojad.itpp.pl (ludojad.itpp.pl [193.41.112.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D5B75E3633 + for ; + Wed, 18 Aug 2004 05:18:19 -0300 (ADT) +Received: from [193.41.112.10] (ludojad.itpp.pl [193.41.112.10]) + by ludojad.itpp.pl (Postfix) with ESMTP id A21FF1035FD + for ; + Wed, 18 Aug 2004 10:18:19 +0200 (CEST) +Message-ID: <412310CB.8080908@ludojad.itpp.pl> +Date: Wed, 18 Aug 2004 10:18:19 +0200 +From: eleven +User-Agent: Mozilla Thunderbird 0.7.1 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: high load caused by I/O - a hint +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/267 +X-Sequence-Number: 7903 + +Hello, + +This is not strictly PostgreSQL performance hint, but may be +helpful to someone with problems like mine. + +As I earlier posted, I was experiencing very high load average +on one of my Linux database servers (IBM eServer 345, SCSI disks on LSI +Logic controller) caused by I/O bottleneck. + +INSERTs were really slow, even after many days of +tweaking PostgreSQL configuration. The problem appeared to be +in the Linux kernel itself - using acpi=ht and noapic boot parameters +solved my performance problems. Load average dropped below 1.0 +(before, it was as high as ten in peak) and the database +works much, much faster. + +-- +11. + +From pgsql-performance-owner@postgresql.org Wed Aug 18 05:55:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0755C5E3633 + for ; + Wed, 18 Aug 2004 05:55:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74762-05 + for ; + Wed, 18 Aug 2004 08:55:44 +0000 (GMT) +Received: from mail.najdi.si (elfstone.noviforum.si [193.189.169.107]) + by svr1.postgresql.org (Postfix) with ESMTP id BE0CC5E46DE + for ; + Wed, 18 Aug 2004 05:55:42 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by elfstone.noviforum.si (ESMTP) with ESMTP id 52FDA1B913; + Wed, 18 Aug 2004 10:49:06 +0200 (CEST) +Received: from elbereth.noviforum.si (elbereth.noviforum.si [192.168.2.26]) + by elfstone.noviforum.si (ESMTP) with ESMTP id 22B951B912; + Wed, 18 Aug 2004 10:49:06 +0200 (CEST) +Received: from elbereth.noviforum.si (localhost [127.0.0.1]) + by elbereth.noviforum.si (8.12.10/8.12.10) with ESMTP id i7I8psJ7027558; + Wed, 18 Aug 2004 10:51:54 +0200 +Received: (from gregab@localhost) + by elbereth.noviforum.si (8.12.10/8.12.10/Submit) id i7I8psZA027557; + Wed, 18 Aug 2004 10:51:54 +0200 +Date: Wed, 18 Aug 2004 10:51:54 +0200 +From: Grega Bremec +To: eleven +Cc: pgsql-performance@postgresql.org +Subject: Re: high load caused by I/O - a hint +Message-ID: <20040818085154.GA27512@elbereth.noviforum.si> +References: <412310CB.8080908@ludojad.itpp.pl> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="17pEHd4RhPHOinZp" +Content-Disposition: inline +In-Reply-To: <412310CB.8080908@ludojad.itpp.pl> +User-Agent: Mutt/1.4.2i +Organization: Noviforum, Ltd., Software & Media +X-Virus-Scanned: by Najdi.si +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/268 +X-Sequence-Number: 7904 + +--17pEHd4RhPHOinZp +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +...and on Wed, Aug 18, 2004 at 10:18:19AM +0200, eleven used the keyboard: +> Hello, +>=20 +> This is not strictly PostgreSQL performance hint, but may be +> helpful to someone with problems like mine. +>=20 +> As I earlier posted, I was experiencing very high load average +> on one of my Linux database servers (IBM eServer 345, SCSI disks on LSI= +=20 +> Logic controller) caused by I/O bottleneck. +>=20 +> INSERTs were really slow, even after many days of +> tweaking PostgreSQL configuration. The problem appeared to be +> in the Linux kernel itself - using acpi=3Dht and noapic boot parameters +> solved my performance problems. Load average dropped below 1.0 +> (before, it was as high as ten in peak) and the database +> works much, much faster. + +Hello, + +Did you try with acpi=3Dnoidle? This proved to be of help on many an +occasion before, and you don't have to give up any functionality over +it. It's just that the ACPI BIOS is broken and overloads the system +with idle calls. + +Other than that, general guidelines would be, don't combine APM and +ACPI, and rather use proper SMP code for hyperthreaded machines than +just the ACPI CPU enumeration feature. + +There's also a new option with 2.6.8.1, called CONFIG_SCHED_SMT that +is supposed to handle some cases SMP code had problems with better, +at the cost of slight overhead in other areas. + +My advice would be, if you have an option to choose between APM and +ACPI, go for ACPI. It's the future, it's being developed actively, +it does a whole lot more than APM (that was really only about power +management), and last but not least, I've been using it for four +years on over fifty SMP machines and I never ever had a problem +beyond the scope of what noidle could fix (knocks-on-wood). :) + +HTH, +--=20 + Grega Bremec + Senior Administrator + Noviforum Ltd., Software & Media + http://www.noviforum.si/ + +--17pEHd4RhPHOinZp +Content-Type: application/pgp-signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.3 (GNU/Linux) + +iD8DBQFBIxiqDo/EMYD4+osRAiPpAKCfQ4zAk41JIKNKTBKpDXuAROAUJgCfdphe +hKoDVm4gImW9qNn6rO+ogyU= +=+j70 +-----END PGP SIGNATURE----- + +--17pEHd4RhPHOinZp-- + +From pgsql-performance-owner@postgresql.org Wed Aug 18 06:25:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BBF335E46C4 + for ; + Wed, 18 Aug 2004 06:25:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86991-01 + for ; + Wed, 18 Aug 2004 09:25:18 +0000 (GMT) +Received: from gatefox.foxi.nl (foxi.xs4all.nl [194.109.246.192]) + by svr1.postgresql.org (Postfix) with ESMTP id 082005E46EA + for ; + Wed, 18 Aug 2004 06:25:14 -0300 (ADT) +Received: from techfox.foxi (techfox.foxi [192.168.0.79]) + by gatefox.foxi.nl (8.10.2-20030922/8.10.2) with ESMTP id i7I9Ovu17098; + Wed, 18 Aug 2004 11:24:57 +0200 +From: Frank van Vugt +Organization: Foxi Consultants in Technology BV +To: josh@agliodbs.com +Subject: Re: Why is the number of dead tuples causing the performance of + deferred triggers to degrade so rapidly (exponentionally)? +Date: Wed, 18 Aug 2004 11:24:56 +0200 +User-Agent: KMail/1.5.4 +References: <200408172329.52555.ftm.van.vugt@foxi.nl> + <200408171603.43236.josh@agliodbs.com> +In-Reply-To: <200408171603.43236.josh@agliodbs.com> +Cc: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200408181124.56823.ftm.van.vugt@foxi.nl> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/269 +X-Sequence-Number: 7905 + +Hi Josh, + +> > It seems in this case the time needed for a single deferred trigger +> > somehow depends on the number of dead tuples in the table + +After further investigation I think I have a better grasp of what's going on. + +The thing biting me here is indeed the 'delete from' on a table with a number +of dead rows, possibly made worse in some cases where not everything can be +handled in memory. + +> I'm not clear on all of the work you're doing in the trigger. +> > NB. My real-world application 'collects' id's in need for deferred work +> I think you're doing a lot more than is wise to do in triggers. + +I probably wasn't clear enough on this. I'm not creating types and/or +temporary tables or anything of that kind. + +The ratio is probably explained better by this example: + +- the database has knowledge on 'parts' and 'sets', the sets have a few fields +whose content depend on the parts, but the proper value for these fields can +only be determined by looking at all the parts of the particular set together +(i.e. it's not a plain 'part-count' that one could update by a trigger on the +part) + +- during a transaction, a number of things will happen to various parts of +various sets, so I have after triggers on the parts that will insert the ids +of the sets that need an update into a set_update holding table; in turn, +this set_update table has a deferred trigger + +- upon execution of the deferred triggers, I now know that all the work on the +parts is finished, so the deferred trigger initiates an update for the sets +whose ids are in the update table and it will delete these ids afterwards + +Now, because multiple updates to parts of the same set will result in multiple +inserts in the update table, I want to avoid doing the set-update more that +once. + +Obviously, it would be better to be able to 'cancel' the rest of the calls to +the deferred trigger after it has been executed for the first time, but that +doesn't seem possible. + +Even better would be to use a 'for each statement' trigger on the set_update +holding table instead, but it is not possible to create a deferred 'for each +statement' trigger..... ;( + +So, I seem to be a bit between a rock and a hard place here, I must use +deferred triggers in order to avoid a costly set update on each part update, +but in such a deferred trigger I cannot avoid doing the update multiple +times....(due to the growing cost of a 'delete from' in the trigger) + +Mmm, it seems that by hacking pg_trigger I am able to create a for each +statement trigger that is 'deferrable initially deferred'. + +This probably solves my problem, I will ask on 'general' whether this has any +unforseen side effects and whether or not a 'regular' deferrable for each +statement trigger is incorporated in v8.0. + +Thanks for you reply! + + + +-- +Best, + + + + +Frank. + + +From pgsql-performance-owner@postgresql.org Wed Aug 18 08:12:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E5245E46DE + for ; + Wed, 18 Aug 2004 08:12:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19340-04 + for ; + Wed, 18 Aug 2004 11:12:38 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 848E35E46D5 + for ; + Wed, 18 Aug 2004 08:12:36 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7IBCZiG021373 + for ; Wed, 18 Aug 2004 11:12:35 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7IAsbld015703 + for pgsql-performance@postgresql.org; Wed, 18 Aug 2004 10:54:37 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: high load caused by I/O - a hint +Date: Wed, 18 Aug 2004 12:54:35 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 28 +Message-ID: <4123356B.3020401@bigfoot.com> +References: <412310CB.8080908@ludojad.itpp.pl> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: eleven +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: <412310CB.8080908@ludojad.itpp.pl> +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/270 +X-Sequence-Number: 7906 + +eleven wrote: + +> Hello, +> +> This is not strictly PostgreSQL performance hint, but may be +> helpful to someone with problems like mine. +> +> As I earlier posted, I was experiencing very high load average +> on one of my Linux database servers (IBM eServer 345, SCSI disks on LSI +> Logic controller) caused by I/O bottleneck. +> +> INSERTs were really slow, even after many days of +> tweaking PostgreSQL configuration. The problem appeared to be +> in the Linux kernel itself - using acpi=ht and noapic boot parameters +> solved my performance problems. Load average dropped below 1.0 +> (before, it was as high as ten in peak) and the database +> works much, much faster. + +I suggest you to investigate why noapic did the work for you, do you have +not well supported device ? At your place also I'd try removing the noapic +option and using acpi=noidle + + + +Regards +Gaetano Mendola + + + +From pgsql-performance-owner@postgresql.org Wed Aug 18 10:10:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D76C05E46C5 + for ; + Wed, 18 Aug 2004 10:10:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61372-05 + for ; + Wed, 18 Aug 2004 13:10:16 +0000 (GMT) +Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com + [209.202.205.1]) + by svr1.postgresql.org (Postfix) with SMTP id 5337C5E46D5 + for ; + Wed, 18 Aug 2004 10:10:12 -0300 (ADT) +Received: (qmail 9261 invoked from network); 18 Aug 2004 13:30:34 -0000 +Received: from dhcp-7-69.ma.lycos.com (HELO ?10.124.7.69?) (10.124.7.69) + by dhcp-7-248.ma.lycos.com with SMTP; 18 Aug 2004 13:30:34 -0000 +In-Reply-To: <412310CB.8080908@ludojad.itpp.pl> +References: <412310CB.8080908@ludojad.itpp.pl> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Jeff +Subject: Re: high load caused by I/O - a hint +Date: Wed, 18 Aug 2004 09:10:24 -0400 +To: eleven +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/271 +X-Sequence-Number: 7907 + + +On Aug 18, 2004, at 4:18 AM, eleven wrote: + +> Hello, +> +> This is not strictly PostgreSQL performance hint, but may be +> helpful to someone with problems like mine. +> +> As I earlier posted, I was experiencing very high load average +> on one of my Linux database servers (IBM eServer 345, SCSI disks on +> LSI Logic controller) caused by I/O bottleneck. +> + +We have some 335's (I think they are 335s) and until April or so there +was a bug in the Fusion MPT driver that would cause it to revert to +async narrow mode if hardware RAID was enabled on it. (Performance was +horrible - NFS on a 100meg network was 10x faster than local disk!) And +on the upside, when I originally researched the problem they hadn't +found the bug yet so there were no others around having issues like +mine so trying to figure it out was quite difficult. + +I may see if using that acpi=ht makes any difference as well. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Wed Aug 18 10:10:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B40E85E46D4 + for ; + Wed, 18 Aug 2004 10:10:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58062-05 + for ; + Wed, 18 Aug 2004 13:10:34 +0000 (GMT) +Received: from smtp106.mail.sc5.yahoo.com (smtp106.mail.sc5.yahoo.com + [66.163.169.226]) + by svr1.postgresql.org (Postfix) with SMTP id BCE935E37D0 + for ; + Wed, 18 Aug 2004 10:10:31 -0300 (ADT) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp106.mail.sc5.yahoo.com with SMTP; 18 Aug 2004 13:10:35 -0000 +Received: from [172.21.8.18] (ismtp.afilias.com [216.217.55.254]) + (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i7IDAYT7064136; Wed, 18 Aug 2004 09:10:34 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <41235543.7070303@Yahoo.com> +Date: Wed, 18 Aug 2004 09:10:27 -0400 +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: my thi ho +Cc: pgsql-performance@postgresql.org +Subject: Re: postgresql performance with multimedia +References: <20040818004438.83822.qmail@web54108.mail.yahoo.com> +In-Reply-To: <20040818004438.83822.qmail@web54108.mail.yahoo.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=1.6 tagged_above=0.0 required=5.0 + tests=RCVD_IN_NJABL_DUL, RCVD_IN_SORBS_DUL +X-Spam-Level: * +X-Archive-Number: 200408/272 +X-Sequence-Number: 7908 + +On 8/17/2004 8:44 PM, my thi ho wrote: + +> Hi, +> I am working on a project which explore postgresql to +> store multimedia data. +> In details, i am trying to work with the buffer +> management part of postgres source code. And try to +> improve the performance. I had search on the web but +> could not find much usefull information. + +What version of PostgreSQL are you looking at? Note that the buffer +cache replacement strategy was completely changed for version 8.0, which +is currently in BETA test. A description of the algorithm can be found +in the README file in src/backend/storage/bufmgr. + + +Jan + +> It would be great if anyone knows any developer groups +> that working on similar things ? or where can i find +> more information on this issue? +> Thank you very much for your help +> regards, +> MT Ho +> +> +> +> __________________________________ +> Do you Yahoo!? +> Yahoo! Mail - 50x more storage than other providers! +> http://promotions.yahoo.com/new_mail +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings + + +-- +#======================================================================# +# 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 Wed Aug 18 12:53:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E9145E46DB + for ; + Wed, 18 Aug 2004 12:42:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 23495-10 + for ; + Wed, 18 Aug 2004 15:42:45 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 704A25E46C2 + for ; + Wed, 18 Aug 2004 12:42:34 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7IFgfiG028090 + for ; Wed, 18 Aug 2004 15:42:41 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7IFGbmu016881 + for pgsql-performance@postgresql.org; Wed, 18 Aug 2004 15:16:37 GMT +From: Raoul Buzziol +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Help specifying new machine +Date: Wed, 18 Aug 2004 17:18:23 +0200 +Organization: Hub.Org Networking Services +Lines: 21 +Message-ID: +References: <20040809165657.GB15169@campbell-lange.net> + + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7Bit +X-Complaints-To: usenet@news.hub.org +User-Agent: KNode/0.7.7 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/274 +X-Sequence-Number: 7910 + +> You're not going to be able to get a Dual Athlon MP for the same price +> as a single Xeon. A few years back, this was the case because Xeon CPUs +> & MBs had a huge premium over Athlon. This is no longer true mainly +> because the number of people carrying Athlon MP motherboards has dropped +> down drastically. Go to pricewatch.com and do a search for 760MPX -- you +> get a mere 8 entries. Not surprisingly because who would not want to +> spend a few pennies more for a much superior Dual Opteron? The few +> sellers you see now just keep stuff in inventory for people who need +> replacement parts for emergencies and are willing to pay up the nose +> because it is an emergency. + +I saw pricewatch.com and you're right. + +I looked for some benchmarks, and I would know if I'm right on: +- Dual Opteron 246 have aproximately the same performance of a Dual Xeon 3Gh +(Opteron a little better) +- Opteron system equal or cheeper than Xeon system. + +As I'm not a hardware expert I would know if my impressions were right. + +Thanx, Raoul + +From pgsql-performance-owner@postgresql.org Wed Aug 18 13:13:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 051AF5E46E3 + for ; + Wed, 18 Aug 2004 13:12:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40701-10 + for ; + Wed, 18 Aug 2004 16:12:26 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 03D365E46DE + for ; + Wed, 18 Aug 2004 13:12:18 -0300 (ADT) +Received: from [134.22.71.19] (dyn-71-19.tor.dsl.tht.net [134.22.71.19]) + by tht.net (Postfix) with ESMTP + id D0A4F76A14; Wed, 18 Aug 2004 12:12:27 -0400 (EDT) +Subject: Re: Help specifying new machine +From: Rod Taylor +To: Raoul Buzziol +Cc: Postgresql Performance +In-Reply-To: +References: <20040809165657.GB15169@campbell-lange.net> + + +Content-Type: text/plain +Message-Id: <1092845543.32799.145.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Wed, 18 Aug 2004 12:12:23 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/275 +X-Sequence-Number: 7911 + +On Wed, 2004-08-18 at 11:18, Raoul Buzziol wrote: +> > You're not going to be able to get a Dual Athlon MP for the same price +> > as a single Xeon. A few years back, this was the case because Xeon CPUs +> > & MBs had a huge premium over Athlon. This is no longer true mainly +> > because the number of people carrying Athlon MP motherboards has dropped +> > down drastically. Go to pricewatch.com and do a search for 760MPX -- you +> > get a mere 8 entries. Not surprisingly because who would not want to +> > spend a few pennies more for a much superior Dual Opteron? The few +> > sellers you see now just keep stuff in inventory for people who need +> > replacement parts for emergencies and are willing to pay up the nose +> > because it is an emergency. +> +> I saw pricewatch.com and you're right. +> +> I looked for some benchmarks, and I would know if I'm right on: +> - Dual Opteron 246 have aproximately the same performance of a Dual Xeon 3Gh +> (Opteron a little better) +> - Opteron system equal or cheeper than Xeon system. + +For PostgreSQL, Opteron might be a touch worse than Xeon for single +processor, little better for Dual, and a whole heck of a bunch better +for Quads -- but this depends on your specific work load as memory +bound, cpu bound, lots of float math, etc. work loads will perform +differently. + +In general, an Opteron is a better bet simply because you can shove more +ram onto it (without workarounds), and you can't beat an extra 8GB ram +on an IO bound database (consider your datasize in 1 year). + + + +From pgsql-performance-owner@postgresql.org Wed Aug 18 14:12:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F095C5E46C4 + for ; + Wed, 18 Aug 2004 14:12:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 66809-04 + for ; + Wed, 18 Aug 2004 17:12:22 +0000 (GMT) +Received: from stubee.d2hosting.net (d2hosting.net [66.70.41.160]) + by svr1.postgresql.org (Postfix) with ESMTP id DE41B5E37CB + for ; + Wed, 18 Aug 2004 14:12:12 -0300 (ADT) +Received: from [127.0.0.1] (stubee.d2hosting.net [66.70.41.160]) + by stubee.d2hosting.net (8.11.6/linuxconf) with ESMTP id i7IHCGA27374; + Wed, 18 Aug 2004 12:12:16 -0500 +Message-ID: <41238DFA.1030207@idigx.com> +Date: Wed, 18 Aug 2004 12:12:26 -0500 +From: Thomas Swan +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Igor Artimenko +Cc: pgsql-performance@postgresql.org +Subject: Re: I could not get postgres to utilizy indexes +References: <5DEC3FFCDE2F7C4DA45433EE09A4F22C01A3FFCA@colossus.dyadem.corp> +In-Reply-To: <5DEC3FFCDE2F7C4DA45433EE09A4F22C01A3FFCA@colossus.dyadem.corp> +X-Enigmail-Version: 0.85.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/276 +X-Sequence-Number: 7912 + +Igor Artimenko wrote: + +>Hi verybody! +> +>I can't make use of indexes even I tried the same test by changing different settings in postgres.conf like geqo to off/on & geqo related parameters, enable_seqscan off/on & so on. Result is the same. +> +>Here is test itself: +> +>I've created simplest table test and executed the same statement "explain analyze select id from test where id = 50000;" Few times I added 100,000 records, applied vacuum full; and issued above explain command. +>Postgres uses sequential scan instead of index one. +>Of cause Time to execute the same statement constantly grows. In my mind index should not allow time to grow so much. +> +>Why Postgres does not utilizes primary unique index? +>What I'm missing? It continue growing even there are 1,200,000 records. It should at least start using index at some point. +> +> +> +Igor, you may want to run "vacuum analyze" and see if your results change. + +Thomas + + +From pgsql-performance-owner@postgresql.org Wed Aug 18 14:24:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D3CDE5E46DF + for ; + Wed, 18 Aug 2004 14:24:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71356-03 + for ; + Wed, 18 Aug 2004 17:24:51 +0000 (GMT) +Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) + by svr1.postgresql.org (Postfix) with ESMTP id 42F2E5E46E2 + for ; + Wed, 18 Aug 2004 14:24:41 -0300 (ADT) +Received: from wp2000 ([157.157.178.195] [157.157.178.195]) by + quasar.skima.is; + Wed, 18 Aug 2004 17:24:47 Z +Message-Id: <00e801c48548$8d2c0b70$0100000a@wp2000> +From: "gnari" +To: "Thomas Swan" , + "Igor Artimenko" +Cc: +References: <5DEC3FFCDE2F7C4DA45433EE09A4F22C01A3FFCA@colossus.dyadem.corp> + <41238DFA.1030207@idigx.com> +Subject: Re: I could not get postgres to utilizy indexes +Date: Wed, 18 Aug 2004 17:26:52 -0000 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 5.00.2919.6700 +X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/277 +X-Sequence-Number: 7913 + +"Thomas Swan" says: + + +> Igor Artimenko wrote: +> + +[ snipped question that was almost exactly a repeat + of one we saw yesterday ] + +> > +> > +> Igor, you may want to run "vacuum analyze" and see if your results change. + +Actually, I think it was determined that the problem was due to the +int index + +Michal Taborsky suggested this solution: + + select id from test where id = 50000::int8 + +did this not help ? + +gnari + + + + +From pgsql-performance-owner@postgresql.org Wed Aug 18 14:29:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B67CA5E46E6 + for ; + Wed, 18 Aug 2004 14:29:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 73498-03 + for ; + Wed, 18 Aug 2004 17:29:26 +0000 (GMT) +Received: from quasar.skima.is (quasar.skima.is [212.30.200.205]) + by svr1.postgresql.org (Postfix) with ESMTP id 6089C5E46E2 + for ; + Wed, 18 Aug 2004 14:29:17 -0300 (ADT) +Received: from wp2000 ([157.157.178.195] [157.157.178.195]) by + quasar.skima.is; + Wed, 18 Aug 2004 17:29:20 Z +Message-Id: <00ee01c48549$2f587690$0100000a@wp2000> +From: "gnari" +To: +References: <5DEC3FFCDE2F7C4DA45433EE09A4F22C01A3FFCA@colossus.dyadem.corp> + <41238DFA.1030207@idigx.com> + <00e801c48548$8d2c0b70$0100000a@wp2000> +Subject: Re: I could not get postgres to utilizy indexes +Date: Wed, 18 Aug 2004 17:31:24 -0000 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 5.00.2919.6700 +X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/278 +X-Sequence-Number: 7914 + +I ("gnari" ) miswrote: + +> Actually, I think it was determined that the problem was due to the +> int index + +of course, i meant int8 index + +gnari + + + + +From pgsql-performance-owner@postgresql.org Wed Aug 18 16:39:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E4F635E46C4 + for ; + Wed, 18 Aug 2004 16:39:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25960-01 + for ; + Wed, 18 Aug 2004 19:39:38 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.198]) + by svr1.postgresql.org (Postfix) with ESMTP id AAF375E46C0 + for ; + Wed, 18 Aug 2004 16:39:28 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id 76so167688rnl + for ; + Wed, 18 Aug 2004 12:39:30 -0700 (PDT) +Received: by 10.38.79.23 with SMTP id c23mr480908rnb; + Wed, 18 Aug 2004 12:39:30 -0700 (PDT) +Message-ID: <19ab0ccd040818123936c1cdd3@mail.gmail.com> +Date: Wed, 18 Aug 2004 15:39:29 -0400 +From: Aaron Birkland +Reply-To: apb18@cornell.edu +To: pgsql-performance@postgresql.org +Subject: Array types and loading +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/279 +X-Sequence-Number: 7915 + +Hi, + +I noticed an interesting phenomenon when loding (COPY) some tables +from a file. For some reason, one load was taking longer than I +assumed it would. As it turns out, one of the columns was an array +containing elements that were of a user defined type. Using strace +(on linux) and truss (on solaris), most of the time was spent on +stat64() calls on the shared library that contained the in/out +functions for the user defined type. + +In a nutshell, it looks like whenever COPY is invoked, and when a user +defined type is used in an array, then stat64() will be called for +each row accessed on the shared library relevant for the user defined +type. + +As an example, I created a simple unsigned 2 byte integer type (called +uint2) as follows: +... +typedef uint16 uint2; + +PG_FUNCTION_INFO_V1(uint2_in); +Datum +uint2_in (PG_FUNCTION_ARGS) +{ + int val; + val = atoi(PG_GETARG_CSTRING(0)); + if (val > 65535 || val < 0) + elog (ERROR, "Value %i is not in range for uint2", val); + PG_RETURN_INT16((uint2) val); +} + +PG_FUNCTION_INFO_V1(uint2_out); +Datum +uint2_out (PG_FUNCTION_ARGS) +{ + uint2 e = (uint2) PG_GETARG_INT16(0); + char * ret_string = (char *) palloc(9); + + snprintf(ret_string, 9, "%i", (int) e); + PG_RETURN_CSTRING(ret_string); +} +.... +I compiled this, making shared library uint2.so, and in psql created the type. + +I then created two test tables: + +CREATE TABLE scratch0 (value uint2); +INSERT INTO scratch0 values('1'); +INSERT INTO scratch0 values('2'); +INSERT INTO scratch0 values('3'); +INSERT INTO scratch0 values('4'); + +CREATE TABLE scratch1 (value uint2[]); +INSERT INTO scratch1 values('{1,2,3}'); +INSERT INTO scratch1 values('{10,20,30}'); +INSERT INTO scratch1 values('{100,200,300}'); +INSERT INTO scratch1 values('{1000,2000,300 + +Now, I ran strace (and truss) tattached to the postmaster process +looking for stat64, and here's what I found: + +------ +SELECT * from scratch0 LIMIT 1; +stat64("/pg/lib/postgresql/uint2", 0xFFBFE808) Err#2 ENOENT +stat64("/pg/lib/postgresql/uint2.so", 0xFFBFE808) = 0 + +SELECT * from scratch0 LIMIT 2; +stat64("/pg/lib/postgresql/uint2", 0xFFBFE808) Err#2 ENOENT +stat64("/pg/lib/postgresql/uint2.so", 0xFFBFE808) = 0 + +SELECT * from scratch0 LIMIT 3; +stat64("/pg/lib/postgresql/uint2", 0xFFBFE808) Err#2 ENOENT +stat64("/pg/lib/postgresql/uint2.so", 0xFFBFE808) = 0 +------ +. +.so each SELECT stats the uint2.so file once, regardless of the number +of fows. fair enough. now for the array case: + +------ +SELECT * from scratch1 LIMIT 1; +stat64("/pg/lib/postgresql/uint2", 0xFFBFE808) Err#2 ENOENT +stat64("/pg/lib/postgresql/uint2.so", 0xFFBFE808) = 0 + +SELECT * from scratch1 LIMIT 2; +stat64("/pg/lib/postgresql/uint2", 0xFFBFE808) Err#2 ENOENT +stat64("/pg/lib/postgresql/uint2.so", 0xFFBFE808) = 0 +stat64("/pg/lib/postgresql/uint2", 0xFFBFE808) Err#2 ENOENT +stat64("/pg/lib/postgresql/uint2.so", 0xFFBFE808) = 0 + +SELECT * from scratch1 LIMIT 3; +stat64("/pg/lib/postgresql/uint2", 0xFFBFE808) Err#2 ENOENT +stat64("/pg/lib/postgresql/uint2.so", 0xFFBFE808) = 0 +stat64("/pg/lib/postgresql/uint2", 0xFFBFE808) Err#2 ENOENT +stat64("/pg/lib/postgresql/uint2.so", 0xFFBFE808) = 0 +stat64("/pg/lib/postgresql/uint2", 0xFFBFE808) Err#2 ENOENT +stat64("/pg/lib/postgresql/uint2.so", 0xFFBFE808) = 0 +------ + +..so for *every row* involving an array, a stat64 is called. This is +true for COPY too.. we were loading 2.5 billion rows, so that's quite +a bit of overhead! Now, we used strace (on linux) and truss (on +solaris) to see how much this was actually affecting us.: + +Output from truss COPYING large file with millions of {1,2,3} unint2 arrays: +syscall seconds calls errors +read .055 527 +write 1.507 11358 +close .000 6 +time .000 3 +getpid .000 1 +kill .000 1 +semop .002 116 +fdsync .000 3 +llseek .081 5042 +stat64 24.205 1078764 539382 +open64 .000 6 + -------- ------ ---- +sys totals: 25.853 1095827 539382 +usr time: 21.567 +elapsed: 113.310 + +so in other words, almost 25% of the total time and 50+% of the +execution time time was wasted on stat64. on Linux, the proportion of +time relative to other calls in strace was similar. + +So.. Is this a bug or are the stat64 calls necessary? I doubt arrays +of user-defined types (in C) are common, and I couldn't find anything +that looked relevent in the lists. + +From pgsql-performance-owner@postgresql.org Wed Aug 18 18:39:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D6EAE5E46C3 + for ; + Wed, 18 Aug 2004 18:39:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65455-07 + for ; + Wed, 18 Aug 2004 21:39: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 667F35E3F15 + for ; + Wed, 18 Aug 2004 18:39:12 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7ILdLRO004153; + Wed, 18 Aug 2004 17:39:21 -0400 (EDT) +To: apb18@cornell.edu +Cc: pgsql-performance@postgresql.org +Subject: Re: Array types and loading +In-reply-to: <19ab0ccd040818123936c1cdd3@mail.gmail.com> +References: <19ab0ccd040818123936c1cdd3@mail.gmail.com> +Comments: In-reply-to Aaron Birkland + message dated "Wed, 18 Aug 2004 15:39:29 -0400" +Date: Wed, 18 Aug 2004 17:39:21 -0400 +Message-ID: <4152.1092865161@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/280 +X-Sequence-Number: 7916 + +Aaron Birkland writes: +> In a nutshell, it looks like whenever COPY is invoked, and when a user +> defined type is used in an array, then stat64() will be called for +> each row accessed on the shared library relevant for the user defined +> type. + +Let me guess ... PG 7.3 or older? + +7.4 should avoid the problem because array_in() caches function lookup +information for the element type's input function across multiple calls. + +In 8.0 there's also a cache at the fmgr_info() level to eliminate +repeated searches for a dynamically loaded function. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Aug 18 18:47:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 032AE5E37D0 + for ; + Wed, 18 Aug 2004 18:47:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69336-05 + for ; + Wed, 18 Aug 2004 21:47:53 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.198]) + by svr1.postgresql.org (Postfix) with ESMTP id B40955E46E9 + for ; + Wed, 18 Aug 2004 18:47:41 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id 76so172676rnl + for ; + Wed, 18 Aug 2004 14:47:50 -0700 (PDT) +Received: by 10.38.164.57 with SMTP id m57mr236744rne; + Wed, 18 Aug 2004 14:47:50 -0700 (PDT) +Message-ID: <19ab0ccd04081814473ca44daf@mail.gmail.com> +Date: Wed, 18 Aug 2004 17:47:50 -0400 +From: Aaron Birkland +Reply-To: apb18@cornell.edu +To: Tom Lane +Subject: Re: Array types and loading +Cc: pgsql-performance@postgresql.org +In-Reply-To: <4152.1092865161@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <19ab0ccd040818123936c1cdd3@mail.gmail.com> + <4152.1092865161@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/281 +X-Sequence-Number: 7917 + +You got it.. 7.3 (should have mentioned that). We're planning to +upgrade to 8.0 anyway in the future, so it's good to know. Thanks! + + -Aaron + +On Wed, 18 Aug 2004 17:39:21 -0400, Tom Lane wrote: +> Aaron Birkland writes: +> > In a nutshell, it looks like whenever COPY is invoked, and when a user +> > defined type is used in an array, then stat64() will be called for +> > each row accessed on the shared library relevant for the user defined +> > type. +> +> Let me guess ... PG 7.3 or older? +> +> 7.4 should avoid the problem because array_in() caches function lookup +> information for the element type's input function across multiple calls. +> +> In 8.0 there's also a cache at the fmgr_info() level to eliminate +> repeated searches for a dynamically loaded function. +> +> regards, tom lane +> + +From pgsql-performance-owner@postgresql.org Wed Aug 18 20:03:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DDE965E46C7 + for ; + Wed, 18 Aug 2004 20:03:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89881-05 + for ; + Wed, 18 Aug 2004 23:03:27 +0000 (GMT) +Received: from mail.speedfc.com (66-136-75-131.ded.swbell.net [66.136.75.131]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F9CA5E46C5 + for ; + Wed, 18 Aug 2004 20:03:16 -0300 (ADT) +Received: from [172.25.96.61] (unknown [172.25.96.61]) + by mail.speedfc.com (Postfix) with ESMTP + id 671BD8E3F; Wed, 18 Aug 2004 18:02:06 -0500 (CDT) +Message-ID: <4123DFF0.5090207@speedfc.com> +Date: Wed, 18 Aug 2004 18:02:08 -0500 +From: DeJuan Jackson +User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Frank van Vugt +Cc: josh@agliodbs.com, pgsql-performance@postgresql.org +Subject: Re: Why is the number of dead tuples causing the performance +References: <200408172329.52555.ftm.van.vugt@foxi.nl> + <200408171603.43236.josh@agliodbs.com> + <200408181124.56823.ftm.van.vugt@foxi.nl> +In-Reply-To: <200408181124.56823.ftm.van.vugt@foxi.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/282 +X-Sequence-Number: 7918 + +Since you are updating all of the sets with the specified part number +why not just ensure that a transaction never inserts the same part +number more than once (an INSERT ...SELECT ... WHERE NOT EXISTS(...) +comes to mind), then delete the row before the end of transaction. + +Frank van Vugt wrote: + +>Hi Josh, +> +> +> +>>>It seems in this case the time needed for a single deferred trigger +>>>somehow depends on the number of dead tuples in the table +>>> +>>> +> +>After further investigation I think I have a better grasp of what's going on. +> +>The thing biting me here is indeed the 'delete from' on a table with a number +>of dead rows, possibly made worse in some cases where not everything can be +>handled in memory. +> +> +> +>>I'm not clear on all of the work you're doing in the trigger. +>> +>> +>>>NB. My real-world application 'collects' id's in need for deferred work +>>> +>>> +>>I think you're doing a lot more than is wise to do in triggers. +>> +>> +> +>I probably wasn't clear enough on this. I'm not creating types and/or +>temporary tables or anything of that kind. +> +>The ratio is probably explained better by this example: +> +>- the database has knowledge on 'parts' and 'sets', the sets have a few fields +>whose content depend on the parts, but the proper value for these fields can +>only be determined by looking at all the parts of the particular set together +>(i.e. it's not a plain 'part-count' that one could update by a trigger on the +>part) +> +>- during a transaction, a number of things will happen to various parts of +>various sets, so I have after triggers on the parts that will insert the ids +>of the sets that need an update into a set_update holding table; in turn, +>this set_update table has a deferred trigger +> +>- upon execution of the deferred triggers, I now know that all the work on the +>parts is finished, so the deferred trigger initiates an update for the sets +>whose ids are in the update table and it will delete these ids afterwards +> +>Now, because multiple updates to parts of the same set will result in multiple +>inserts in the update table, I want to avoid doing the set-update more that +>once. +> +>Obviously, it would be better to be able to 'cancel' the rest of the calls to +>the deferred trigger after it has been executed for the first time, but that +>doesn't seem possible. +> +>Even better would be to use a 'for each statement' trigger on the set_update +>holding table instead, but it is not possible to create a deferred 'for each +>statement' trigger..... ;( +> +>So, I seem to be a bit between a rock and a hard place here, I must use +>deferred triggers in order to avoid a costly set update on each part update, +>but in such a deferred trigger I cannot avoid doing the update multiple +>times....(due to the growing cost of a 'delete from' in the trigger) +> +>Mmm, it seems that by hacking pg_trigger I am able to create a for each +>statement trigger that is 'deferrable initially deferred'. +> +>This probably solves my problem, I will ask on 'general' whether this has any +>unforseen side effects and whether or not a 'regular' deferrable for each +>statement trigger is incorporated in v8.0. +> +>Thanks for you reply! +> +> +> +> +> + + +From pgsql-performance-owner@postgresql.org Wed Aug 18 20:11:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9CE7B5E40BA + for ; + Wed, 18 Aug 2004 20:11:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91975-03 + for ; + Wed, 18 Aug 2004 23:11:36 +0000 (GMT) +Received: from web11908.mail.yahoo.com (web11908.mail.yahoo.com + [216.136.172.192]) + by svr1.postgresql.org (Postfix) with SMTP id 39FA65E46C1 + for ; + Wed, 18 Aug 2004 20:11:26 -0300 (ADT) +Message-ID: <20040818231137.66251.qmail@web11908.mail.yahoo.com> +Received: from [67.71.87.114] by web11908.mail.yahoo.com via HTTP; + Wed, 18 Aug 2004 16:11:37 PDT +Date: Wed, 18 Aug 2004 16:11:37 -0700 (PDT) +From: Artimenko Igor +Subject: Re: Postgres does not utilyze indexes +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/283 +X-Sequence-Number: 7919 + +Thanks a lot. This issue has been resolved by casting to int8. I thought Postgres does those casts +up by himself implicitelly. + +===== +Thanks a lot +Igor Artimenko +I specialize in +Java, J2EE, Unix, Linux, HP, AIX, Solaris, Progress, Oracle, DB2, Postgres, Data Modeling + + + +__________________________________ +Do you Yahoo!? +Yahoo! Mail is new and improved - Check it out! +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Thu Aug 19 01:42:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B33D5E46F5 + for ; + Thu, 19 Aug 2004 01:42:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79598-06 + for ; + Thu, 19 Aug 2004 04:42:49 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id F27BC5E46CC + for ; + Thu, 19 Aug 2004 01:42:32 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7J4gmiG080188 + for ; Thu, 19 Aug 2004 04:42:48 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7J4QrmM076509 + for pgsql-performance@postgresql.org; Thu, 19 Aug 2004 04:26:53 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Help specifying new machine +Date: Wed, 18 Aug 2004 21:26:45 -0700 +Organization: Hub.Org Networking Services +Lines: 25 +Message-ID: +References: <20040809165657.GB15169@campbell-lange.net> + + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7b) Gecko/20040421 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/284 +X-Sequence-Number: 7920 + +Raoul Buzziol wrote: +> I looked for some benchmarks, and I would know if I'm right on: +> - Dual Opteron 246 have aproximately the same performance of a Dual Xeon 3Gh +> (Opteron a little better) +> - Opteron system equal or cheeper than Xeon system. + +In terms of general database performance, top of the line dual opteron +will perform roughly the same as top of the line dual xeon. Assuming you +just run in 32-bit mode. Throw in 64-bit mode, NUMA, etc, all bets are off. + +In terms of Postgres database performance, Opteron *may* be the better +CPU for this app but there's not enough data points yet. Here's a recent +review at Anandtech showing Opteron 150 (2.4ghz) versus 64-bit Prescott +3.6hgz with some very simple MySQL and Postgres benchmarks: + +http://www.anandtech.com/linux/showdoc.aspx?i=2163&p=2 + +What is a slight lead in MySQL becomes a blowout in Postgres. Of course, +this is just the 1MB cache model. I'm sure if you went with the 2MB or +4MB models, the Xeons would come up much closer. + +The really good sign in the above numbers though is that somebody +finally included Postgres in their benchmark suite. :) We may be seeing +more and more data points to evaluate hardware for Postgres in the near +future. + +From pgsql-performance-owner@postgresql.org Thu Aug 19 02:49:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A5D6D5E3639 + for ; + Thu, 19 Aug 2004 02:49:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93846-04 + for ; + Thu, 19 Aug 2004 05:49: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 D9BEC5E37CE + for ; + Thu, 19 Aug 2004 02:49:15 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7J5nFeB012078; + Thu, 19 Aug 2004 01:49:15 -0400 (EDT) +To: William Yu +Cc: pgsql-performance@postgresql.org +Subject: Re: Help specifying new machine +In-reply-to: +References: <20040809165657.GB15169@campbell-lange.net> + + + +Comments: In-reply-to William Yu + message dated "Wed, 18 Aug 2004 21:26:45 -0700" +Date: Thu, 19 Aug 2004 01:49:15 -0400 +Message-ID: <12077.1092894555@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/285 +X-Sequence-Number: 7921 + +William Yu writes: +> In terms of Postgres database performance, Opteron *may* be the better +> CPU for this app but there's not enough data points yet. Here's a recent +> review at Anandtech showing Opteron 150 (2.4ghz) versus 64-bit Prescott +> 3.6hgz with some very simple MySQL and Postgres benchmarks: + +> http://www.anandtech.com/linux/showdoc.aspx?i=2163&p=2 + +> What is a slight lead in MySQL becomes a blowout in Postgres. + +This is really interesting. We had previously seen some evidence that +the Xeon sucks at running Postgres, but I thought that the issues only +materialized with multiple CPUs (because what we were concerned about +was the cost of transferring cache lines across CPUs). AFAICS this test +is using single CPUs. Maybe there is more going on than we realized. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Aug 19 04:55:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 739095E4249 + for ; + Thu, 19 Aug 2004 04:55:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27962-08 + for ; + Thu, 19 Aug 2004 07:55:00 +0000 (GMT) +Received: from usbb-lacimss3.unisys.com (usbb-lacimss3.unisys.com + [192.63.108.53]) + by svr1.postgresql.org (Postfix) with ESMTP id 100435E40AC + for ; + Thu, 19 Aug 2004 04:54:58 -0300 (ADT) +Received: from usbb-lacgw1.lac.uis.unisys.com ([129.226.160.21]unverified) by + usbb-lacimss3 with InterScan Messaging Security Suite; + Thu, 19 Aug 2004 03:56:54 -0400 +Received: from usbb-lacgw1.lac.uis.unisys.com ([129.226.160.23]) by + usbb-lacgw1.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Thu, 19 Aug 2004 03:54:52 -0400 +Received: from gbmk-eugw1.eu.uis.unisys.com ([129.221.133.28]) by + usbb-lacgw1.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Thu, 19 Aug 2004 03:54:52 -0400 +Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by + gbmk-eugw1.eu.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.47); + Thu, 19 Aug 2004 08:54:48 +0100 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Subject: Re: I could not get postgres to utilizy indexes +Date: Thu, 19 Aug 2004 09:54:47 +0200 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: I could not get postgres to utilizy indexes +Thread-Index: AcSEZbJwv6sR2bdDTJ+eEmRsHloP7wBW8Nxw +From: "Leeuw van der, Tim" +To: "Igor Artimenko" , + +X-OriginalArrivalTime: 19 Aug 2004 07:54:48.0163 (UTC) + FILETIME=[CCA2F330:01C485C1] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/286 +X-Sequence-Number: 7922 + +Hi, + +You asked the very same question yesterday, and I believe you got some usef= +ul answers. Why do you post the question again? + +You don't even mention your previous post, and you didn't continue the thre= +ad which you started yesterday. + +Did you try out any of the suggestions which you got yesterday? Do you have= + further questions about, for instance, how to do casting of values? If so,= + please continue posting with the previous thread, rather than reposting th= +e same question with a different subject. + +regards, + +--Tim + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Igor +Artimenko +Sent: dinsdag 17 augustus 2004 16:23 +To: pgsql-performance@postgresql.org +Subject: [PERFORM] I could not get postgres to utilizy indexes + + +Hi verybody! + +I can't make use of indexes even I tried the same test by changing differen= +t settings in postgres.conf like geqo to off/on & geqo related parameters, = +enable_seqscan off/on & so on. Result is the same.=20 + +Here is test itself: + +I've created simplest table test and executed the same statement "explain a= +nalyze select id from test where id =3D 50000;" Few times I added 100,000 r= +ecords, applied vacuum full; and issued above explain command.=20 +Postgres uses sequential scan instead of index one.=20 +Of cause Time to execute the same statement constantly grows. In my mind in= +dex should not allow time to grow so much.=20=20 + +Why Postgres does not utilizes primary unique index? +What I'm missing? It continue growing even there are 1,200,000 records. It = +should at least start using index at some point. + + +Details are below: +100,000 records: +QUERY PLAN +---------------------------------------------------------------------------= +------------------------- + Seq Scan on test (cost=3D0.00..2427.00 rows=3D2 width=3D8) (actual time= +=3D99.626..199.835 rows=3D1 loops=3D1) + Filter: (id =3D 50000) + Total runtime: 199.990 ms + +200,000 records: +QUERY PLAN +---------------------------------------------------------------------------= +-------------------------- + Seq Scan on test (cost=3D0.00..4853.00 rows=3D2 width=3D8) (actual time= +=3D100.389..402.770 rows=3D1 loops=3D1) + Filter: (id =3D 50000) + Total runtime: 402.926 ms + + +300,000 records: +QUERY PLAN +---------------------------------------------------------------------------= +-------------------------- + Seq Scan on test (cost=3D0.00..7280.00 rows=3D1 width=3D8) (actual time= +=3D100.563..616.064 rows=3D1 loops=3D1) + Filter: (id =3D 50000) + Total runtime: 616.224 ms +(3 rows) + +I've created test table by script: + +CREATE TABLE test +( + id int8 NOT NULL DEFAULT nextval('next_id_seq'::text) INIQUE, + description char(50), + CONSTRAINT users_pkey PRIMARY KEY (id) +); + +CREATE SEQUENCE next_id_seq + INCREMENT 1 + MINVALUE 1 + MAXVALUE 10000000000 + START 1 + CACHE 5 + CYCLE; + +I use postgres 7.4.2 + + + + +---------------------------(end of broadcast)--------------------------- +TIP 6: Have you searched our list archives? + + http://archives.postgresql.org + +From pgsql-performance-owner@postgresql.org Thu Aug 19 10:15:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 189385E46F4 + for ; + Thu, 19 Aug 2004 10:15:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21927-10 + for ; + Thu, 19 Aug 2004 13:15:46 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 12C445E46CA + for ; + Thu, 19 Aug 2004 10:15:43 -0300 (ADT) +Received: (qmail 1636 invoked from network); 19 Aug 2004 13:15:47 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 19 Aug 2004 13:15:47 -0000 +Subject: help with query +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: perform +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1092921433.1622.569.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Thu, 19 Aug 2004 09:17:13 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/287 +X-Sequence-Number: 7923 + +RT uses a query like: + +SELECT distinct main.oid,main.* FROM Tickets main +WHERE +(main.EffectiveId = main.id) +AND +(main.Status != 'deleted') +AND + ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +AND + ( (main.Queue = '9') ) +AND (( + ( (Links.Type = 'MemberOf') AND (Links.LocalTarget = '17417') AND (main.id = Links.LocalBase) ) + OR + ( (Links.Type = 'MemberOf') AND (Links.LocalBase = '17417') AND (main.id = Links.LocalTarget) ) + or + (main.id = '17417') + ) + ); + + +which produces a query plan: + +Nested Loop (cost=0.00..813.88 rows=1 width=169) + Join Filter: (((("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = 17417)) AND (("inner".localbase = 17417) OR (("inner"."type")::text = 'MemberOf'::text) OR ("outer".id += 17417)) AND (("outer".id = "inner".localtarget) OR (("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = 17417)) AND ((("inner"."type")::text = 'MemberOf'::text) OR ("inner" +.localtarget = 17417) OR ("outer".id = 17417)) AND (("inner".localbase = 17417) OR ("inner".localtarget = 17417) OR ("outer".id = 17417)) AND (("outer".id = "inner".localtarget) OR ( +"inner".localtarget = 17417) OR ("outer".id = 17417)) AND ((("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417)) AND (("inner".loca +lbase = 17417) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417)) AND (("outer".id = "inner".localtarget) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417))) + -> Index Scan using tickets1 on tickets main (cost=0.00..657.61 rows=1 width=169) + Index Cond: (queue = 9) + Filter: ((effectiveid = id) AND ((status)::text <> 'deleted'::text) AND ((("type")::text = 'ticket'::text) OR (("type")::text = 'subticket'::text))) + -> Seq Scan on links (cost=0.00..46.62 rows=1462 width=20) + +If I rewrite the query as: + +SELECT main.* FROM Tickets main +WHERE +(main.EffectiveId = main.id) +AND +(main.Status != 'deleted') +AND + ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +AND + ( (main.Queue = '9') ) +AND ( + 17417 in (select links.localtarget from links where links.type='MemberOf' and main.id=links.localbase) + or + 17417 in ( select links.localbase from links where links.type='MemberOf' and main.id=links.localtarget) + or + main.id = '17417' + ) + ; + +The time for the query goes from 1500ms to 15ms. The two OR clauses + + ( (Links.Type = 'MemberOf') AND (Links.LocalTarget = '17417') AND (main.id = Links.LocalBase) ) + OR + ( (Links.Type = 'MemberOf') AND (Links.LocalBase = '17417') AND (main.id = Links.LocalTarget) ) + +don't contribute to the result set in this particular dataset, which is why the speed increases so dramatically. + +Is there a way to rewrite the top query to get the same results? I have already talked to Best Practical, +and subqueries are not easily embraced. + +Dave +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Thu Aug 19 10:36:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E68C5E46CC + for ; + Thu, 19 Aug 2004 10:36:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32625-02 + for ; + Thu, 19 Aug 2004 13:35:53 +0000 (GMT) +Received: from bugge.potatoe.com (bugge.potatoe.com [216.240.48.15]) + by svr1.postgresql.org (Postfix) with ESMTP id DD37F5E37D0 + for ; + Thu, 19 Aug 2004 10:35:50 -0300 (ADT) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by bugge.potatoe.com (Postfix) with ESMTP + id 1DCC2728418; Thu, 19 Aug 2004 06:38:49 -0700 (PDT) +Message-ID: <4124AD68.8000208@madfish.com> +Date: Thu, 19 Aug 2004 06:38:48 -0700 +From: Brad Bulger +Organization: The Madfish Group +User-Agent: Mozilla Thunderbird 0.7+ (Macintosh/20040715) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pg@fastcrypt.com +Cc: pgsql-performance@postgresql.org +Subject: Re: help with query +References: <1092921433.1622.569.camel@localhost.localdomain> +In-Reply-To: <1092921433.1622.569.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/288 +X-Sequence-Number: 7924 + +You're doing a join except not, is the trouble, looks like. The query is really +"FROM Tickets main, Links", but when Tickets.id is 17417, you've got no join +to the Links table. So you end up getting every row in Links for each row in +Tickets with id = 17417. + +I'd think this wants to be two queries or a union: + +SELECT distinct main.oid,main.* FROM Tickets main +WHERE (main.EffectiveId = main.id) +AND (main.Status != 'deleted') +AND ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +AND ( (main.Queue = '9') ) +AND ( (main.id = '17417')) +union +SELECT distinct main.oid,main.* FROM Tickets main, Links +WHERE (main.EffectiveId = main.id) +AND (main.Status != 'deleted') +AND ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +AND ( (main.Queue = '9') ) +AND ( (Links.Type = 'MemberOf') ) +AND ( (Links.LocalTarget = '17417') ) +AND ( (main.id = Links.LocalBase) ) OR (main.id = Links.LocalTarget) ) +; + +or else, yah, a subquery: + +[...] +AND ( + main.id = '17417' + or + exists( + select true from Links + where Type = 'MemberOf' and LocalTarget = '17417' + and (LocalBase = main.id or LocalTarget = main.id) + ) +) + +Those are the only things I can think of to make it work, anyways. + +Dave Cramer wrote: + +> RT uses a query like: +> +> SELECT distinct main.oid,main.* FROM Tickets main +> WHERE +> (main.EffectiveId = main.id) +> AND +> (main.Status != 'deleted') +> AND +> ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +> AND +> ( (main.Queue = '9') ) +> AND (( +> ( (Links.Type = 'MemberOf') AND (Links.LocalTarget = '17417') AND (main.id = Links.LocalBase) ) +> OR +> ( (Links.Type = 'MemberOf') AND (Links.LocalBase = '17417') AND (main.id = Links.LocalTarget) ) +> or +> (main.id = '17417') +> ) +> ); +> +> +> which produces a query plan: +> +> Nested Loop (cost=0.00..813.88 rows=1 width=169) +> Join Filter: (((("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = 17417)) AND (("inner".localbase = 17417) OR (("inner"."type")::text = 'MemberOf'::text) OR ("outer".id +> = 17417)) AND (("outer".id = "inner".localtarget) OR (("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = 17417)) AND ((("inner"."type")::text = 'MemberOf'::text) OR ("inner" +> .localtarget = 17417) OR ("outer".id = 17417)) AND (("inner".localbase = 17417) OR ("inner".localtarget = 17417) OR ("outer".id = 17417)) AND (("outer".id = "inner".localtarget) OR ( +> "inner".localtarget = 17417) OR ("outer".id = 17417)) AND ((("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417)) AND (("inner".loca +> lbase = 17417) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417)) AND (("outer".id = "inner".localtarget) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417))) +> -> Index Scan using tickets1 on tickets main (cost=0.00..657.61 rows=1 width=169) +> Index Cond: (queue = 9) +> Filter: ((effectiveid = id) AND ((status)::text <> 'deleted'::text) AND ((("type")::text = 'ticket'::text) OR (("type")::text = 'subticket'::text))) +> -> Seq Scan on links (cost=0.00..46.62 rows=1462 width=20) +> +> If I rewrite the query as: +> +> SELECT main.* FROM Tickets main +> WHERE +> (main.EffectiveId = main.id) +> AND +> (main.Status != 'deleted') +> AND +> ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +> AND +> ( (main.Queue = '9') ) +> AND ( +> 17417 in (select links.localtarget from links where links.type='MemberOf' and main.id=links.localbase) +> or +> 17417 in ( select links.localbase from links where links.type='MemberOf' and main.id=links.localtarget) +> or +> main.id = '17417' +> ) +> ; +> +> The time for the query goes from 1500ms to 15ms. The two OR clauses +> +> ( (Links.Type = 'MemberOf') AND (Links.LocalTarget = '17417') AND (main.id = Links.LocalBase) ) +> OR +> ( (Links.Type = 'MemberOf') AND (Links.LocalBase = '17417') AND (main.id = Links.LocalTarget) ) +> +> don't contribute to the result set in this particular dataset, which is why the speed increases so dramatically. +> +> Is there a way to rewrite the top query to get the same results? I have already talked to Best Practical, +> and subqueries are not easily embraced. +> +> Dave + +From pgsql-performance-owner@postgresql.org Thu Aug 19 10:49:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 514825E46CC + for ; + Thu, 19 Aug 2004 10:49:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 35031-07 + for ; + Thu, 19 Aug 2004 13:49:12 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id E26CD5E46DF + for ; + Thu, 19 Aug 2004 10:49:10 -0300 (ADT) +Received: (qmail 7814 invoked from network); 19 Aug 2004 13:49:13 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 19 Aug 2004 13:49:13 -0000 +Subject: Re: help with query +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Brad Bulger +Cc: perform +In-Reply-To: <4124AD68.8000208@madfish.com> +References: <1092921433.1622.569.camel@localhost.localdomain> + <4124AD68.8000208@madfish.com> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1092923438.1544.574.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Thu, 19 Aug 2004 09:50:38 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/289 +X-Sequence-Number: 7925 + +Brad, + +Thanks, that runs on the same order of magnitude as the subqueries. + +DAve +On Thu, 2004-08-19 at 09:38, Brad Bulger wrote: +> You're doing a join except not, is the trouble, looks like. The query is really +> "FROM Tickets main, Links", but when Tickets.id is 17417, you've got no join +> to the Links table. So you end up getting every row in Links for each row in +> Tickets with id = 17417. +> +> I'd think this wants to be two queries or a union: +> +> SELECT distinct main.oid,main.* FROM Tickets main +> WHERE (main.EffectiveId = main.id) +> AND (main.Status != 'deleted') +> AND ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +> AND ( (main.Queue = '9') ) +> AND ( (main.id = '17417')) +> union +> SELECT distinct main.oid,main.* FROM Tickets main, Links +> WHERE (main.EffectiveId = main.id) +> AND (main.Status != 'deleted') +> AND ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +> AND ( (main.Queue = '9') ) +> AND ( (Links.Type = 'MemberOf') ) +> AND ( (Links.LocalTarget = '17417') ) +> AND ( (main.id = Links.LocalBase) ) OR (main.id = Links.LocalTarget) ) +> ; +> +> or else, yah, a subquery: +> +> [...] +> AND ( +> main.id = '17417' +> or +> exists( +> select true from Links +> where Type = 'MemberOf' and LocalTarget = '17417' +> and (LocalBase = main.id or LocalTarget = main.id) +> ) +> ) +> +> Those are the only things I can think of to make it work, anyways. +> +> Dave Cramer wrote: +> +> > RT uses a query like: +> > +> > SELECT distinct main.oid,main.* FROM Tickets main +> > WHERE +> > (main.EffectiveId = main.id) +> > AND +> > (main.Status != 'deleted') +> > AND +> > ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +> > AND +> > ( (main.Queue = '9') ) +> > AND (( +> > ( (Links.Type = 'MemberOf') AND (Links.LocalTarget = '17417') AND (main.id = Links.LocalBase) ) +> > OR +> > ( (Links.Type = 'MemberOf') AND (Links.LocalBase = '17417') AND (main.id = Links.LocalTarget) ) +> > or +> > (main.id = '17417') +> > ) +> > ); +> > +> > +> > which produces a query plan: +> > +> > Nested Loop (cost=0.00..813.88 rows=1 width=169) +> > Join Filter: (((("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = 17417)) AND (("inner".localbase = 17417) OR (("inner"."type")::text = 'MemberOf'::text) OR ("outer".id +> > = 17417)) AND (("outer".id = "inner".localtarget) OR (("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = 17417)) AND ((("inner"."type")::text = 'MemberOf'::text) OR ("inner" +> > .localtarget = 17417) OR ("outer".id = 17417)) AND (("inner".localbase = 17417) OR ("inner".localtarget = 17417) OR ("outer".id = 17417)) AND (("outer".id = "inner".localtarget) OR ( +> > "inner".localtarget = 17417) OR ("outer".id = 17417)) AND ((("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417)) AND (("inner".loca +> > lbase = 17417) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417)) AND (("outer".id = "inner".localtarget) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417))) +> > -> Index Scan using tickets1 on tickets main (cost=0.00..657.61 rows=1 width=169) +> > Index Cond: (queue = 9) +> > Filter: ((effectiveid = id) AND ((status)::text <> 'deleted'::text) AND ((("type")::text = 'ticket'::text) OR (("type")::text = 'subticket'::text))) +> > -> Seq Scan on links (cost=0.00..46.62 rows=1462 width=20) +> > +> > If I rewrite the query as: +> > +> > SELECT main.* FROM Tickets main +> > WHERE +> > (main.EffectiveId = main.id) +> > AND +> > (main.Status != 'deleted') +> > AND +> > ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +> > AND +> > ( (main.Queue = '9') ) +> > AND ( +> > 17417 in (select links.localtarget from links where links.type='MemberOf' and main.id=links.localbase) +> > or +> > 17417 in ( select links.localbase from links where links.type='MemberOf' and main.id=links.localtarget) +> > or +> > main.id = '17417' +> > ) +> > ; +> > +> > The time for the query goes from 1500ms to 15ms. The two OR clauses +> > +> > ( (Links.Type = 'MemberOf') AND (Links.LocalTarget = '17417') AND (main.id = Links.LocalBase) ) +> > OR +> > ( (Links.Type = 'MemberOf') AND (Links.LocalBase = '17417') AND (main.id = Links.LocalTarget) ) +> > +> > don't contribute to the result set in this particular dataset, which is why the speed increases so dramatically. +> > +> > Is there a way to rewrite the top query to get the same results? I have already talked to Best Practical, +> > and subqueries are not easily embraced. +> > +> > Dave +> +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Thu Aug 19 11:16:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 240885E3F15 + for ; + Thu, 19 Aug 2004 11:16:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40476-10 + for ; + Thu, 19 Aug 2004 14:16:24 +0000 (GMT) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 5E0F85E37CE + for ; + Thu, 19 Aug 2004 11:16:21 -0300 (ADT) +Received: (qmail 13634 invoked from network); 19 Aug 2004 14:16:25 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 19 Aug 2004 14:16:25 -0000 +Subject: Re: help with query +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Brad Bulger +Cc: perform +In-Reply-To: <4124AD68.8000208@madfish.com> +References: <1092921433.1622.569.camel@localhost.localdomain> + <4124AD68.8000208@madfish.com> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1092925071.1622.586.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Thu, 19 Aug 2004 10:17:51 -0400 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/290 +X-Sequence-Number: 7926 + +>From what I can figure, queries like this run much quicker on other +databases, is this something that can be improved ? + +Dave +On Thu, 2004-08-19 at 09:38, Brad Bulger wrote: +> You're doing a join except not, is the trouble, looks like. The query is really +> "FROM Tickets main, Links", but when Tickets.id is 17417, you've got no join +> to the Links table. So you end up getting every row in Links for each row in +> Tickets with id = 17417. +> +> I'd think this wants to be two queries or a union: +> +> SELECT distinct main.oid,main.* FROM Tickets main +> WHERE (main.EffectiveId = main.id) +> AND (main.Status != 'deleted') +> AND ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +> AND ( (main.Queue = '9') ) +> AND ( (main.id = '17417')) +> union +> SELECT distinct main.oid,main.* FROM Tickets main, Links +> WHERE (main.EffectiveId = main.id) +> AND (main.Status != 'deleted') +> AND ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +> AND ( (main.Queue = '9') ) +> AND ( (Links.Type = 'MemberOf') ) +> AND ( (Links.LocalTarget = '17417') ) +> AND ( (main.id = Links.LocalBase) ) OR (main.id = Links.LocalTarget) ) +> ; +> +> or else, yah, a subquery: +> +> [...] +> AND ( +> main.id = '17417' +> or +> exists( +> select true from Links +> where Type = 'MemberOf' and LocalTarget = '17417' +> and (LocalBase = main.id or LocalTarget = main.id) +> ) +> ) +> +> Those are the only things I can think of to make it work, anyways. +> +> Dave Cramer wrote: +> +> > RT uses a query like: +> > +> > SELECT distinct main.oid,main.* FROM Tickets main +> > WHERE +> > (main.EffectiveId = main.id) +> > AND +> > (main.Status != 'deleted') +> > AND +> > ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +> > AND +> > ( (main.Queue = '9') ) +> > AND (( +> > ( (Links.Type = 'MemberOf') AND (Links.LocalTarget = '17417') AND (main.id = Links.LocalBase) ) +> > OR +> > ( (Links.Type = 'MemberOf') AND (Links.LocalBase = '17417') AND (main.id = Links.LocalTarget) ) +> > or +> > (main.id = '17417') +> > ) +> > ); +> > +> > +> > which produces a query plan: +> > +> > Nested Loop (cost=0.00..813.88 rows=1 width=169) +> > Join Filter: (((("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = 17417)) AND (("inner".localbase = 17417) OR (("inner"."type")::text = 'MemberOf'::text) OR ("outer".id +> > = 17417)) AND (("outer".id = "inner".localtarget) OR (("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = 17417)) AND ((("inner"."type")::text = 'MemberOf'::text) OR ("inner" +> > .localtarget = 17417) OR ("outer".id = 17417)) AND (("inner".localbase = 17417) OR ("inner".localtarget = 17417) OR ("outer".id = 17417)) AND (("outer".id = "inner".localtarget) OR ( +> > "inner".localtarget = 17417) OR ("outer".id = 17417)) AND ((("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417)) AND (("inner".loca +> > lbase = 17417) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417)) AND (("outer".id = "inner".localtarget) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417))) +> > -> Index Scan using tickets1 on tickets main (cost=0.00..657.61 rows=1 width=169) +> > Index Cond: (queue = 9) +> > Filter: ((effectiveid = id) AND ((status)::text <> 'deleted'::text) AND ((("type")::text = 'ticket'::text) OR (("type")::text = 'subticket'::text))) +> > -> Seq Scan on links (cost=0.00..46.62 rows=1462 width=20) +> > +> > If I rewrite the query as: +> > +> > SELECT main.* FROM Tickets main +> > WHERE +> > (main.EffectiveId = main.id) +> > AND +> > (main.Status != 'deleted') +> > AND +> > ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +> > AND +> > ( (main.Queue = '9') ) +> > AND ( +> > 17417 in (select links.localtarget from links where links.type='MemberOf' and main.id=links.localbase) +> > or +> > 17417 in ( select links.localbase from links where links.type='MemberOf' and main.id=links.localtarget) +> > or +> > main.id = '17417' +> > ) +> > ; +> > +> > The time for the query goes from 1500ms to 15ms. The two OR clauses +> > +> > ( (Links.Type = 'MemberOf') AND (Links.LocalTarget = '17417') AND (main.id = Links.LocalBase) ) +> > OR +> > ( (Links.Type = 'MemberOf') AND (Links.LocalBase = '17417') AND (main.id = Links.LocalTarget) ) +> > +> > don't contribute to the result set in this particular dataset, which is why the speed increases so dramatically. +> > +> > Is there a way to rewrite the top query to get the same results? I have already talked to Best Practical, +> > and subqueries are not easily embraced. +> > +> > Dave +> +> ---------------------------(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 +> +-- +Dave Cramer +519 939 0336 +ICQ # 14675561 + + +From pgsql-performance-owner@postgresql.org Thu Aug 19 11:21:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F05B5E46FA + for ; + Thu, 19 Aug 2004 11:21:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48893-03 + for ; + Thu, 19 Aug 2004 14:21:25 +0000 (GMT) +Received: from simmts12-srv.bellnexxia.net (simmts12.bellnexxia.net + [206.47.199.141]) + by svr1.postgresql.org (Postfix) with ESMTP id 005E65E46F4 + for ; + Thu, 19 Aug 2004 11:21:21 -0300 (ADT) +Received: from localhost ([67.71.24.121]) by simmts12-srv.bellnexxia.net + (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP + id <20040819142039.ONSS1580.simmts12-srv.bellnexxia.net@localhost>; + Thu, 19 Aug 2004 10:20:39 -0400 +Received: from [192.168.250.6] ([192.168.250.6]) + by (8.11.6/8.11.6) with ESMTP id i7JELPg05469; + Thu, 19 Aug 2004 10:21:26 -0400 +Message-ID: <4124B7B5.6050409@sympatico.ca> +Date: Thu, 19 Aug 2004 10:22:45 -0400 +From: Jean-Luc Lachance +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, en-us, en-gb, fr, fr-ca +MIME-Version: 1.0 +To: pg@fastcrypt.com +Cc: Brad Bulger , perform +Subject: Re: help with query +References: <1092921433.1622.569.camel@localhost.localdomain> + <4124AD68.8000208@madfish.com> + <1092923438.1544.574.camel@localhost.localdomain> +In-Reply-To: <1092923438.1544.574.camel@localhost.localdomain> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/291 +X-Sequence-Number: 7927 + +how about: + +SELECT distinct main.oid,main.* FROM Tickets main +WHERE main.EffectiveId = main.id +AND main.Status != 'deleted' +AND ( main.Type = 'ticket' OR main.Type = 'subticket' ) +AND ( main.Queue = '9' ) +AND ( main.id = '17417' + OR main.id IN ( + SELECT DISTINCT LocalTarget from Links + where Type = 'MemberOf' and LocalTarget = '17417') + OR main.id IN ( + SELECT DISTINCT LocalBase from Links + where Type = 'MemberOf' and LocalTarget = '17417')) + + + + +Dave Cramer wrote: + +> Brad, +> +> Thanks, that runs on the same order of magnitude as the subqueries. +> +> DAve +> On Thu, 2004-08-19 at 09:38, Brad Bulger wrote: +> +>>You're doing a join except not, is the trouble, looks like. The query is really +>>"FROM Tickets main, Links", but when Tickets.id is 17417, you've got no join +>>to the Links table. So you end up getting every row in Links for each row in +>>Tickets with id = 17417. +>> +>>I'd think this wants to be two queries or a union: +>> +>>SELECT distinct main.oid,main.* FROM Tickets main +>>WHERE (main.EffectiveId = main.id) +>>AND (main.Status != 'deleted') +>>AND ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +>>AND ( (main.Queue = '9') ) +>>AND ( (main.id = '17417')) +>>union +>>SELECT distinct main.oid,main.* FROM Tickets main, Links +>>WHERE (main.EffectiveId = main.id) +>>AND (main.Status != 'deleted') +>>AND ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +>>AND ( (main.Queue = '9') ) +>>AND ( (Links.Type = 'MemberOf') ) +>>AND ( (Links.LocalTarget = '17417') ) +>>AND ( (main.id = Links.LocalBase) ) OR (main.id = Links.LocalTarget) ) +>>; +>> +>>or else, yah, a subquery: +>> +>>[...] +>>AND ( +>> main.id = '17417' +>> or +>> exists( +>> select true from Links +>> where Type = 'MemberOf' and LocalTarget = '17417' +>> and (LocalBase = main.id or LocalTarget = main.id) +>> ) +>>) +>> +>>Those are the only things I can think of to make it work, anyways. +>> +>>Dave Cramer wrote: +>> +>> +>>>RT uses a query like: +>>> +>>>SELECT distinct main.oid,main.* FROM Tickets main +>>>WHERE +>>>(main.EffectiveId = main.id) +>>>AND +>>>(main.Status != 'deleted') +>>>AND +>>> ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +>>>AND +>>> ( (main.Queue = '9') ) +>>>AND (( +>>> ( (Links.Type = 'MemberOf') AND (Links.LocalTarget = '17417') AND (main.id = Links.LocalBase) ) +>>> OR +>>> ( (Links.Type = 'MemberOf') AND (Links.LocalBase = '17417') AND (main.id = Links.LocalTarget) ) +>>> or +>>> (main.id = '17417') +>>> ) +>>> ); +>>> +>>> +>>>which produces a query plan: +>>> +>>>Nested Loop (cost=0.00..813.88 rows=1 width=169) +>>> Join Filter: (((("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = 17417)) AND (("inner".localbase = 17417) OR (("inner"."type")::text = 'MemberOf'::text) OR ("outer".id +>>>= 17417)) AND (("outer".id = "inner".localtarget) OR (("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = 17417)) AND ((("inner"."type")::text = 'MemberOf'::text) OR ("inner" +>>>.localtarget = 17417) OR ("outer".id = 17417)) AND (("inner".localbase = 17417) OR ("inner".localtarget = 17417) OR ("outer".id = 17417)) AND (("outer".id = "inner".localtarget) OR ( +>>>"inner".localtarget = 17417) OR ("outer".id = 17417)) AND ((("inner"."type")::text = 'MemberOf'::text) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417)) AND (("inner".loca +>>>lbase = 17417) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417)) AND (("outer".id = "inner".localtarget) OR ("outer".id = "inner".localbase) OR ("outer".id = 17417))) +>>> -> Index Scan using tickets1 on tickets main (cost=0.00..657.61 rows=1 width=169) +>>> Index Cond: (queue = 9) +>>> Filter: ((effectiveid = id) AND ((status)::text <> 'deleted'::text) AND ((("type")::text = 'ticket'::text) OR (("type")::text = 'subticket'::text))) +>>> -> Seq Scan on links (cost=0.00..46.62 rows=1462 width=20) +>>> +>>>If I rewrite the query as: +>>> +>>>SELECT main.* FROM Tickets main +>>>WHERE +>>>(main.EffectiveId = main.id) +>>>AND +>>>(main.Status != 'deleted') +>>>AND +>>> ( (main.Type = 'ticket') OR (main.Type = 'subticket') ) +>>>AND +>>> ( (main.Queue = '9') ) +>>>AND ( +>>> 17417 in (select links.localtarget from links where links.type='MemberOf' and main.id=links.localbase) +>>> or +>>> 17417 in ( select links.localbase from links where links.type='MemberOf' and main.id=links.localtarget) +>>> or +>>> main.id = '17417' +>>> ) +>>> ; +>>> +>>>The time for the query goes from 1500ms to 15ms. The two OR clauses +>>> +>>> ( (Links.Type = 'MemberOf') AND (Links.LocalTarget = '17417') AND (main.id = Links.LocalBase) ) +>>> OR +>>> ( (Links.Type = 'MemberOf') AND (Links.LocalBase = '17417') AND (main.id = Links.LocalTarget) ) +>>> +>>>don't contribute to the result set in this particular dataset, which is why the speed increases so dramatically. +>>> +>>>Is there a way to rewrite the top query to get the same results? I have already talked to Best Practical, +>>>and subqueries are not easily embraced. +>>> +>>>Dave +>> + +From pgsql-performance-owner@postgresql.org Thu Aug 19 13:20:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B273E5E40AC + for ; + Thu, 19 Aug 2004 13:20:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94005-01 + for ; + Thu, 19 Aug 2004 16:20:02 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 02E105E46C0 + for ; + Thu, 19 Aug 2004 13:19:53 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6120743; Thu, 19 Aug 2004 09:21:16 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Tom Lane , William Yu +Subject: Re: Help specifying new machine +Date: Thu, 19 Aug 2004 09:18:31 -0700 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgresql.org +References: <20040809165657.GB15169@campbell-lange.net> + <12077.1092894555@sss.pgh.pa.us> +In-Reply-To: <12077.1092894555@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408190918.31797.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/292 +X-Sequence-Number: 7928 + +Tom, + +> This is really interesting. We had previously seen some evidence that +> the Xeon sucks at running Postgres, but I thought that the issues only +> materialized with multiple CPUs (because what we were concerned about +> was the cost of transferring cache lines across CPUs). AFAICS this test +> is using single CPUs. Maybe there is more going on than we realized. + +Aside from the fact that the Xeon architecture is a kludge? + +Intel really screwed up the whole Xeon line through some bad architectural +decisions, and instead of starting over from scratch, "patched" the problem. +The result has been sub-optimal Xeon performance for the last two years. + +This is why AMD is still alive. Better efficiency, lower cost. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Aug 19 14:43:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 52BFF5E46CF + for ; + Thu, 19 Aug 2004 14:43:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20586-06 + for ; + Thu, 19 Aug 2004 17:42:56 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id BB75F5E46C0 + for ; + Thu, 19 Aug 2004 14:42:55 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7JHgsiG024446 + for ; Thu, 19 Aug 2004 17:42:54 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7JHQ7iS019541 + for pgsql-performance@postgresql.org; Thu, 19 Aug 2004 17:26:07 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: using an index worst performances +Date: Thu, 19 Aug 2004 19:26:01 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 27 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/293 +X-Sequence-Number: 7929 + +Hi all, +I'm tring to optimize the following query: + +http://rafb.net/paste/results/YdO9vM69.html + +as you can see from the explain after defining the +index the performance is worst. + +If I raise the default_statistic_target to 200 +then the performance are worst then before: + + +Without index: 1.140 ms +With index: 1.400 ms +With default_statistic_targer = 200: 1.800 ms + + +tought anyone ? + + + +Regards +Gaetano Mendola + + + + + +From pgsql-performance-owner@postgresql.org Tue Aug 24 15:48:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 566BF5E46CE + for ; + Thu, 19 Aug 2004 15:03:11 -0300 (ADT) +Received: 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-01 + for ; + Thu, 19 Aug 2004 18:03:05 +0000 (GMT) +Received: from mail.3gstech.com (ns1.mcdownloads.com [216.239.132.98]) + by svr1.postgresql.org (Postfix) with ESMTP id 5177F5E46C1 + for ; + Thu, 19 Aug 2004 15:03:05 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.3gstech.com (Postfix) with ESMTP id 0DE8C9E7B23 + for ; + Thu, 19 Aug 2004 11:03:04 -0700 (PDT) +Received: from mail.3gstech.com ([127.0.0.1]) + by localhost (fungus [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 11196-09 for ; + Thu, 19 Aug 2004 11:03:04 -0700 (PDT) +Received: from [216.239.128.141] (daniel.omnis.com [216.239.128.141]) + by mail.3gstech.com (Postfix) with ESMTP id EB5F99E7B14 + for ; + Thu, 19 Aug 2004 11:03:03 -0700 (PDT) +Message-ID: <4124EB58.9040102@sh.nu> +Date: Thu, 19 Aug 2004 11:03:04 -0700 +From: Daniel Ceregatti +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.7) Gecko/20040716 MultiZilla/1.6.3.1a +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: What is the best way to do attribute/values? +X-Enigmail-Version: 0.84.1.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/328 +X-Sequence-Number: 7964 + +Hi list, + +I have a database with 1M "people" in it. Each person has about 20 +attributes, such as height, weight, eye color, etc. I need to be able to +search for people based on these attributes. A search can be conducted +on one attribute, all attributes, or any number in between. How would +_you_ do this? + +I have already attempted to answer this. My attempts are detailed here: + +http://sh.nu/email.txt + +This is the email I was originally going to send to this list. Since +it's so large, I decided to link to it instead. If you feel that it +belongs in a post to the list, let me know, and I'll post again. + +I've discussed these attempts with people in #postgresql on +irc.freenode.net. Agliodbs (I presume you know who this is) was very +helpful, but in end was at a loss. I find myself in the same postition +at this time. He suggested I contact this list. + +My ultimate goal is performance. This _must_ be fast. And by fast, I +mean, < 1 second, for every permutation of the number of attributes +searched for. Flexibility would be a bonus, but at this point I'll +settle for something that's harder to maintain if I can get the speed +gain I need. + +Thanks, + +Daniel Ceregatti + +From pgsql-performance-owner@postgresql.org Thu Aug 19 15:10:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E2CF5E46DC + for ; + Thu, 19 Aug 2004 15:10:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31988-01 + for ; + Thu, 19 Aug 2004 18:10:01 +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 3B9035E46D8 + for ; + Thu, 19 Aug 2004 15:10:00 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BxrML-00026w-0V; Thu, 19 Aug 2004 18:09:57 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 1AD9015A0B; Thu, 19 Aug 2004 19:09:55 +0100 (BST) +Message-ID: <4124ECF3.6040901@archonet.com> +Date: Thu, 19 Aug 2004 19:09:55 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gaetano Mendola +Cc: pgsql-performance@postgresql.org +Subject: Re: using an index worst performances +References: +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/294 +X-Sequence-Number: 7930 + +Gaetano Mendola wrote: +> Hi all, +> I'm tring to optimize the following query: +> +> http://rafb.net/paste/results/YdO9vM69.html +> +> as you can see from the explain after defining the +> index the performance is worst. +> +> If I raise the default_statistic_target to 200 +> then the performance are worst then before: +> +> +> Without index: 1.140 ms +> With index: 1.400 ms +> With default_statistic_targer = 200: 1.800 ms + +Can I just check that 1.800ms means 1.8 secs (You're using . as the +thousands separator)? + +If it means 1.8ms then frankly the times are too short to mean anything +without running them 100 times and averaging. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Thu Aug 19 17:13:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AE7065E46C5 + for ; + Thu, 19 Aug 2004 17:13:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68419-04 + for ; + Thu, 19 Aug 2004 20:12:57 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id C37BF5E3631 + for ; + Thu, 19 Aug 2004 17:12:56 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7JKCtiG071519 + for ; Thu, 19 Aug 2004 20:12:55 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7JJuoaf066502 + for pgsql-performance@postgresql.org; Thu, 19 Aug 2004 19:56:50 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: using an index worst performances +Date: Thu, 19 Aug 2004 21:56:38 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 34 +Message-ID: <412505F6.6080000@bigfoot.com> +References: <4124ECF3.6040901@archonet.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +In-Reply-To: <4124ECF3.6040901@archonet.com> +X-Enigmail-Version: 0.84.2.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/295 +X-Sequence-Number: 7931 + +Richard Huxton wrote: + +> Gaetano Mendola wrote: +> +>> Hi all, +>> I'm tring to optimize the following query: +>> +>> http://rafb.net/paste/results/YdO9vM69.html +>> +>> as you can see from the explain after defining the +>> index the performance is worst. +>> +>> If I raise the default_statistic_target to 200 +>> then the performance are worst then before: +>> +>> +>> Without index: 1.140 ms +>> With index: 1.400 ms +>> With default_statistic_targer = 200: 1.800 ms +> +> +> Can I just check that 1.800ms means 1.8 secs (You're using . as the +> thousands separator)? +> +> If it means 1.8ms then frankly the times are too short to mean anything +> without running them 100 times and averaging. + + +It mean 1.8 ms and that execution time is sticky to that value even +with 1000 times. + + +Regards +Gaetano Mendola + +From pgsql-performance-owner@postgresql.org Thu Aug 19 22:37:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9B3625E46C0 + for ; + Thu, 19 Aug 2004 22:37:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77129-01 + for ; + Fri, 20 Aug 2004 01:37:42 +0000 (GMT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 232BB5E3631 + for ; + Thu, 19 Aug 2004 22:37:39 -0300 (ADT) +Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i7K1a8Ui024619; Fri, 20 Aug 2004 09:36:08 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <4125565D.3060008@familyhealth.com.au> +Date: Fri, 20 Aug 2004 09:39:41 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gaetano Mendola +Cc: Richard Huxton , + pgsql-performance@postgresql.org +Subject: Re: using an index worst performances +References: <4124ECF3.6040901@archonet.com> + <412505F6.6080000@bigfoot.com> +In-Reply-To: <412505F6.6080000@bigfoot.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/296 +X-Sequence-Number: 7932 + +>>> Without index: 1.140 ms +>>> With index: 1.400 ms +>>> With default_statistic_targer = 200: 1.800 ms +>> +>> +>> +>> Can I just check that 1.800ms means 1.8 secs (You're using . as the +>> thousands separator)? +>> +>> If it means 1.8ms then frankly the times are too short to mean +>> anything without running them 100 times and averaging. +> +> +> +> It mean 1.8 ms and that execution time is sticky to that value even +> with 1000 times. + +Given the almost irrelvant difference in the speed of those queries, I'd +say that with the stats so high, postgres simply takes longer to check +the statistics to come to the same conclusion. ie. it has to loop over +200 rows instead of just 10. + +Chris + + +From pgsql-performance-owner@postgresql.org Fri Aug 20 06:37:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 127EC5E40AC + for ; + Fri, 20 Aug 2004 06:37:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28474-10 + for ; + Fri, 20 Aug 2004 09:37:35 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id DACAA5E37CE + for ; + Fri, 20 Aug 2004 06:37:33 -0300 (ADT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i7K9asn17294; + Fri, 20 Aug 2004 11:36:54 +0200 +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 i7K9bZJ10993; + Fri, 20 Aug 2004 11:37:35 +0200 +Message-ID: <4125C657.7000702@bigfoot.com> +Date: Fri, 20 Aug 2004 11:37:27 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christopher Kings-Lynne +Cc: Richard Huxton , + pgsql-performance@postgresql.org +Subject: Re: using an index worst performances +References: <4124ECF3.6040901@archonet.com> + <412505F6.6080000@bigfoot.com> + <4125565D.3060008@familyhealth.com.au> +In-Reply-To: <4125565D.3060008@familyhealth.com.au> +X-Enigmail-Version: 0.85.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/297 +X-Sequence-Number: 7933 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Christopher Kings-Lynne wrote: + +|>>> Without index: 1.140 ms +|>>> With index: 1.400 ms +|>>> With default_statistic_targer = 200: 1.800 ms +|>> +|>> +|>> +|>> +|>> Can I just check that 1.800ms means 1.8 secs (You're using . as the +|>> thousands separator)? +|>> +|>> If it means 1.8ms then frankly the times are too short to mean +|>> anything without running them 100 times and averaging. +|> +|> +|> +|> +|> It mean 1.8 ms and that execution time is sticky to that value even +|> with 1000 times. +| +| +| Given the almost irrelvant difference in the speed of those queries, I'd +| say that with the stats so high, postgres simply takes longer to check +| the statistics to come to the same conclusion. ie. it has to loop over +| 200 rows instead of just 10. + +The time increase seems too much. + + +Regards +Gaetano Mendola + + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBJcZW7UpzwH2SGd4RAuiMAJ971EAtr1RrHu2QMi0YYk0kKeuQmACg9bd3 +CFcmq5MRG/Eq3RXdNOdu43Y= +=Bvo8 +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Fri Aug 20 09:55:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B6895E46DF + for ; + Fri, 20 Aug 2004 09:55:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97563-04 + for ; + Fri, 20 Aug 2004 12:55:50 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 593A95E46CF + for ; + Fri, 20 Aug 2004 09:55:46 -0300 (ADT) +Received: from [134.22.71.19] (dyn-71-19.tor.dsl.tht.net [134.22.71.19]) + by tht.net (Postfix) with ESMTP + id 0B9EF76A2B; Fri, 20 Aug 2004 08:55:52 -0400 (EDT) +Subject: Re: using an index worst performances +From: Rod Taylor +To: Gaetano Mendola +Cc: Christopher Kings-Lynne , + Richard Huxton , + Postgresql Performance +In-Reply-To: <4125C657.7000702@bigfoot.com> +References: <4124ECF3.6040901@archonet.com> + <412505F6.6080000@bigfoot.com> <4125565D.3060008@familyhealth.com.au> + <4125C657.7000702@bigfoot.com> +Content-Type: text/plain +Message-Id: <1093006549.75942.61.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Fri, 20 Aug 2004 08:55:49 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/298 +X-Sequence-Number: 7934 + +On Fri, 2004-08-20 at 05:37, Gaetano Mendola wrote: +> -----BEGIN PGP SIGNED MESSAGE----- +> Hash: SHA1 +> +> Christopher Kings-Lynne wrote: +> +> |>>> Without index: 1.140 ms +> |>>> With index: 1.400 ms +> |>>> With default_statistic_targer = 200: 1.800 ms +> |>> +> |>> +> |>> +> |>> +> |>> Can I just check that 1.800ms means 1.8 secs (You're using . as the +> |>> thousands separator)? +> |>> +> |>> If it means 1.8ms then frankly the times are too short to mean +> |>> anything without running them 100 times and averaging. +> |> +> |> +> |> +> |> +> |> It mean 1.8 ms and that execution time is sticky to that value even +> |> with 1000 times. +> | +> | +> | Given the almost irrelvant difference in the speed of those queries, I'd +> | say that with the stats so high, postgres simply takes longer to check +> | the statistics to come to the same conclusion. ie. it has to loop over +> | 200 rows instead of just 10. +> +> The time increase seems too much. + +We can test this. + +What are the times without the index, with the index and with the higher +statistics value when using a prepared query? + + + +From pgsql-performance-owner@postgresql.org Fri Aug 20 09:56:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C10F05E46CA + for ; + Fri, 20 Aug 2004 09:56:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97698-03 + for ; + Fri, 20 Aug 2004 12:55:55 +0000 (GMT) +Received: from smtp-bal.opennet.it (noder32-48.opennet.it [212.110.32.48]) + by svr1.postgresql.org (Postfix) with SMTP id A9CD15E46E1 + for ; + Fri, 20 Aug 2004 09:55:52 -0300 (ADT) +Received: (qmail 23943 invoked from network); 20 Aug 2004 12:42:13 -0000 +Received: from mailer.opennet.it (212.110.32.3) + by 0 with SMTP; 20 Aug 2004 12:42:13 -0000 +Received: from comai04 ([212.110.56.34]) + by mailer.opennet.it (8.10.2/8.10.2) with SMTP id i7KDkM200824 + for ; Fri, 20 Aug 2004 15:46:27 +0200 +Message-ID: <068b01c486b5$7e4e4dc0$0501a8c0@comai04> +From: "Bonnin S." +To: +Subject: pg_restore very slow in 8.0.0beta1 +Date: Fri, 20 Aug 2004 14:59:08 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0688_01C486C6.3E97D140" +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.2 tagged_above=0.0 required=5.0 tests=HTML_50_60, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200408/299 +X-Sequence-Number: 7935 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0688_01C486C6.3E97D140 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi, +I'm migrating data from 7.4.2 to 8.0.0beta1 and the process is slow (10 15 = +tuples per second) + +Can be a type conversion issue? + +RedS +------=_NextPart_000_0688_01C486C6.3E97D140 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi,
+
I'm migrating data from 7.4.2 to 8.0.0beta= +1 and the=20 +process is slow (10 15 tuples per second)
+
 
+
Can be a type conversion issue? +
 
+
RedS
+ +------=_NextPart_000_0688_01C486C6.3E97D140-- + + +From pgsql-performance-owner@postgresql.org Fri Aug 20 10:36:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CB33A5E46C8 + for ; + Fri, 20 Aug 2004 10:36:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 15206-04 + for ; + Fri, 20 Aug 2004 13:36:31 +0000 (GMT) +Received: from email12.aon.at (WARSL404PIP1.highway.telekom.at [195.3.96.112]) + by svr1.postgresql.org (Postfix) with SMTP id 1C75E5E40BB + for ; + Fri, 20 Aug 2004 10:36:28 -0300 (ADT) +Received: (qmail 395630 invoked from network); 20 Aug 2004 13:36:32 -0000 +Received: from m154p024.dipool.highway.telekom.at (HELO PASCAL) ([62.46.9.56]) + (envelope-sender ) + by 172.18.5.235 (qmail-ldap-1.03) with SMTP + for ; 20 Aug 2004 13:36:32 -0000 +From: Manfred Koizar +To: "Leeuw van der, Tim" +Cc: "Igor Artimenko" , + +Subject: Re: I could not get postgres to utilizy indexes +Date: Fri, 20 Aug 2004 15:37:40 +0200 +Message-ID: +References: + +In-Reply-To: + +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/300 +X-Sequence-Number: 7936 + +On Thu, 19 Aug 2004 09:54:47 +0200, "Leeuw van der, Tim" + wrote: +>You asked the very same question yesterday, and I believe you got some useful answers. Why do you post the question again? + +Tim, no need to be rude here. We see this effect from time to time when +a new user sends a message to a mailing list while not subscribed. The +sender gets an automated reply from majordomo, subscribes to the list +and sends his mail again. One or two days later the original message is +approved (by Marc, AFAIK) and forwarded to the list. Look at the +timestamps in these header lines: +|Received: from postgresql.org (svr1.postgresql.org [200.46.204.71]) +| by svr4.postgresql.org (Postfix) with ESMTP id 32B1F5B04F4; +| Wed, 18 Aug 2004 15:54:13 +0000 (GMT) +|Received: from localhost (unknown [200.46.204.144]) +| by svr1.postgresql.org (Postfix) with ESMTP id E6B2B5E4701 +| for ; Tue, 17 Aug 2004 11:23:07 -0300 (ADT) + +>[more instructions] + +And while we are teaching netiquette, could you please stop top-posting +and full-quoting. + +Igor, welcome to the list! Did the suggestions you got solve your +problem? + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Fri Aug 20 10:45:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 69E185E4249 + for ; + Fri, 20 Aug 2004 10:45:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18273-03 + for ; + Fri, 20 Aug 2004 13:45:19 +0000 (GMT) +Received: from usbb-lacimss3.unisys.com (usbb-lacimss3.unisys.com + [192.63.108.53]) + by svr1.postgresql.org (Postfix) with ESMTP id 017885E46CF + for ; + Fri, 20 Aug 2004 10:45:14 -0300 (ADT) +Received: from usbb-lacgw1.lac.uis.unisys.com ([129.226.160.21]unverified) by + usbb-lacimss3 with InterScan Messaging Security Suite; + Fri, 20 Aug 2004 09:47:12 -0400 +Received: from usbb-lacgw1.lac.uis.unisys.com ([129.226.160.23]) by + usbb-lacgw1.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Fri, 20 Aug 2004 09:45:08 -0400 +Received: from gbmk-eugw2.eu.uis.unisys.com ([129.221.133.27]) by + usbb-lacgw1.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Fri, 20 Aug 2004 09:45:08 -0400 +Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by + gbmk-eugw2.eu.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Fri, 20 Aug 2004 14:45:06 +0100 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Subject: Re: I could not get postgres to utilizy indexes +Date: Fri, 20 Aug 2004 15:45:05 +0200 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] I could not get postgres to utilizy indexes +Thread-Index: AcSGurs8mJaFRnNiQrCVefjNVeXl7QAAHgDg +From: "Leeuw van der, Tim" +To: "Manfred Koizar" +Cc: "Igor Artimenko" , + +X-OriginalArrivalTime: 20 Aug 2004 13:45:06.0282 (UTC) + FILETIME=[E6D324A0:01C486BB] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/301 +X-Sequence-Number: 7937 + +Hi all, + +I offered apologies to Igor Artimenko in private mail already; I'll apologi= +ze again here. + +About top-posting: Outlook Exchange teaches bad habits. Can you set Outlook= + Exchange to prefix lines with "> " only when mail is in text-only format b= +ut not when mail arrives in html / rtf format? + +About full quoting: my apologies. + +-----Original Message----- +From: Manfred Koizar [mailto:mkoi-pg@aon.at] +Sent: vrijdag 20 augustus 2004 15:38 +To: Leeuw van der, Tim +Cc: Igor Artimenko; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] I could not get postgres to utilizy indexes + + +On Thu, 19 Aug 2004 09:54:47 +0200, "Leeuw van der, Tim" + wrote: +>You asked the very same question yesterday, and I believe you got some use= +ful answers. Why do you post the question again? + +Tim, no need to be rude here.=20=20 +[...] +>[more instructions] + +And while we are teaching netiquette, could you please stop top-posting +and full-quoting. + +Igor, welcome to the list! Did the suggestions you got solve your +problem? + +Servus + Manfred + +From pgsql-performance-owner@postgresql.org Fri Aug 20 13:13:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D1C95E46CF + for ; + Fri, 20 Aug 2004 13:13:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 77298-04 + for ; + Fri, 20 Aug 2004 16:13:09 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 1DB725E46C0 + for ; + Fri, 20 Aug 2004 13:13:01 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7KGD8iG078962 + for ; Fri, 20 Aug 2004 16:13:08 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7KFqgdw071052 + for pgsql-performance@postgresql.org; Fri, 20 Aug 2004 15:52:42 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: using an index worst performances +Date: Fri, 20 Aug 2004 17:52:33 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 80 +Message-ID: <41261E41.3080204@bigfoot.com> +References: <4124ECF3.6040901@archonet.com> + <412505F6.6080000@bigfoot.com> + <4125565D.3060008@familyhealth.com.au> + <4125C657.7000702@bigfoot.com> <1093006549.75942.61.camel@jester> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Rod Taylor +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +In-Reply-To: <1093006549.75942.61.camel@jester> +X-Enigmail-Version: 0.85.0.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/302 +X-Sequence-Number: 7938 + +Rod Taylor wrote: + +> On Fri, 2004-08-20 at 05:37, Gaetano Mendola wrote: +> +>>-----BEGIN PGP SIGNED MESSAGE----- +>>Hash: SHA1 +>> +>>Christopher Kings-Lynne wrote: +>> +>>|>>> Without index: 1.140 ms +>>|>>> With index: 1.400 ms +>>|>>> With default_statistic_targer = 200: 1.800 ms +>>|>> +>>|>> +>>|>> +>>|>> +>>|>> Can I just check that 1.800ms means 1.8 secs (You're using . as the +>>|>> thousands separator)? +>>|>> +>>|>> If it means 1.8ms then frankly the times are too short to mean +>>|>> anything without running them 100 times and averaging. +>>|> +>>|> +>>|> +>>|> +>>|> It mean 1.8 ms and that execution time is sticky to that value even +>>|> with 1000 times. +>>| +>>| +>>| Given the almost irrelvant difference in the speed of those queries, I'd +>>| say that with the stats so high, postgres simply takes longer to check +>>| the statistics to come to the same conclusion. ie. it has to loop over +>>| 200 rows instead of just 10. +>> +>>The time increase seems too much. +> +> +> We can test this. +> +> What are the times without the index, with the index and with the higher +> statistics value when using a prepared query? + +Using a prepared query: + +Without index and default stat 10 : 1.12 ms +Without index and default stat 1000 : 1.25 ms +With index and default stat 10: 1.35 ms +With index and default stat 1000: 1.6 ms + +that values are the average obtained after the very first one, +on 20 execution. + + + +Regards +Gaetano Mendola + + + + + + + + + + + + + + + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Fri Aug 20 13:19:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BF185E3639 + for ; + Fri, 20 Aug 2004 13:19:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80041-04 + for ; + Fri, 20 Aug 2004 16:19: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 675385E3632 + for ; + Fri, 20 Aug 2004 13:19:20 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7KGJMiC022027; + Fri, 20 Aug 2004 12:19:22 -0400 (EDT) +To: Gaetano Mendola +Cc: Rod Taylor , pgsql-performance@postgresql.org +Subject: Re: using an index worst performances +In-reply-to: <41261E41.3080204@bigfoot.com> +References: <4124ECF3.6040901@archonet.com> + <412505F6.6080000@bigfoot.com> + <4125565D.3060008@familyhealth.com.au> + <4125C657.7000702@bigfoot.com> <1093006549.75942.61.camel@jester> + <41261E41.3080204@bigfoot.com> +Comments: In-reply-to Gaetano Mendola + message dated "Fri, 20 Aug 2004 17:52:33 +0200" +Date: Fri, 20 Aug 2004 12:19:22 -0400 +Message-ID: <22026.1093018762@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/303 +X-Sequence-Number: 7939 + +Gaetano Mendola writes: +> Using a prepared query: + +> Without index and default stat 10 : 1.12 ms +> Without index and default stat 1000 : 1.25 ms +> With index and default stat 10: 1.35 ms +> With index and default stat 1000: 1.6 ms + +Could we see EXPLAIN ANALYZE EXECUTE output for each case? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 20 13:20:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A8C15E46C1 + for ; + Fri, 20 Aug 2004 13:20:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80276-06 + for ; + Fri, 20 Aug 2004 16:20:42 +0000 (GMT) +Received: from hm61.locaweb.com.br (hm61.locaweb.com.br [200.213.197.161]) + by svr1.postgresql.org (Postfix) with SMTP id 69D565E46C0 + for ; + Fri, 20 Aug 2004 13:20:30 -0300 (ADT) +Received: (qmail 4309 invoked from network); 20 Aug 2004 16:19:11 -0000 +Received: from unknown (10.1.10.20) + by hm61.locaweb.com.br with QMTP; 20 Aug 2004 16:19:11 -0000 +Received: (qmail 8378 invoked from network); 20 Aug 2004 16:20:32 -0000 +Received: from unknown (HELO xws08) (dmota@nexen.com.br@201.9.66.167) + by hm20.locaweb.com.br with SMTP; 20 Aug 2004 16:20:32 -0000 +Reply-To: +From: "Danilo Mota" +To: +Subject: Query performance problem +Date: Fri, 20 Aug 2004 13:25:30 -0300 +Organization: Nexen Tecnologia +Message-ID: <002201c486d2$4fbe4420$8afea8c0@nexen.lan> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0023_01C486B9.2A737D20" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2616 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=HTML_70_80, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200408/304 +X-Sequence-Number: 7940 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0023_01C486B9.2A737D20 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +HI All, + +I have a big performance issue concerning a PostgreSQL database. + +I have the following server configuration: + +Pentium 4 2.4 GHz +1 GB RAM +36 GB SCSI + +And the following tables: + TABLES +------------------------------------------------------------------------ +-- +================== r_cliente: 75816 records +============================ +CREATE TABLE "public"."r_cliente" ( + "pkcliente" INTEGER NOT NULL, + "cpfcnpj" VARCHAR(20) NOT NULL, + PRIMARY KEY("pkcliente") +) WITH OIDS; + +CREATE UNIQUE INDEX "un_cliente_cpfcnpj" ON "public"."r_cliente" +USING btree ("cpfcnpj"); + +================== sav_cliente_lg: 65671 records +======================= +CREATE TABLE "public"."sav_cliente_lg" ( + "codigo" INTEGER NOT NULL, + "cpfcnpj" VARCHAR(15) NOT NULL, + PRIMARY KEY("codigo") +) WITH OIDS; + +CREATE INDEX "ix_savclientelg_cpfcnpj" ON "public"."sav_cliente_lg" +USING btree ("cpfcnpj"); + + + +Which I would like to run the following query: + + QUERY +------------------------------------------------------------------------ +-- +SELECT + rc.pkcliente +FROM r_cliente AS rc +INNER JOIN sav_cliente_lg AS sc ON sc.cpfcnpj = sc.cpfcnpj; + + + + +The problem is, it takes a long time to run, I wait up to half an hour +and I get no result. + +So, I executed the explain on the query and got the following results: + + + + + QUERY PLAN +------------------------------------------------------------------------ +-- + Nested Loop (cost=0.00..16696.87 rows=75816 width=4) + -> Seq Scan on sav_cliente_cf sc (cost=0.00..3047.55 rows=1 +width=0) + Filter: ((cpfcnpj)::text = (cpfcnpj)::text) + -> Seq Scan on r_cliente rc (cost=0.00..12891.16 rows=75816 +width=4) + + + + +And made the following modifications on my POSTGRESQL.CONF file: + + POSTGRESQL.CONF +------------------------------------------------------------------------ +-- +### VERSION: Postgresql 7.4.2 ### +shared_buffers = 7800 +sort_mem = 4096 +checkpoint_segments = 5 +effective_cache_size = 12000 +cpu_operator_cost = 0.0015 +stats_start_collector = false + + +Hope you can help me, I really need to get this running faster, and I am +out of ideas. + +Since now, thanks a lot for your attention, + +Danilo Mota + +------=_NextPart_000_0023_01C486B9.2A737D20 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + + + + + + +
+ +

HI All,

+ +

 

+ +

I have a big performance issue concerning a PostgreSQL +database.

+ +

 

+ +

I have the following server configuration:

+ +

 

+ +

Pentium 4 2.4 GHz

+ +

1 GB RAM

+ +

36 GB SCSI

+ +

 <= +/font>

+ +

And the following tables:

+ +

        = +            &nb= +sp;            = +   TABLES

+ +

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

+ +

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D  r_cliente: 75816 records  +=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

+ +

CREATE TABLE "public".&qu= +ot;r_cliente" +(

+ +

  "pkcliente" INTEGER NO= +T NULL,

+ +

  "cpfcnpj" VARCHAR(20) = +NOT +NULL,

+ +

  PRIMARY <= +span +class=3DGramE>KEY("pkcliente")= +

+ +

) WITH OIDS;

+ +

 

+ +

CREATE UNIQUE INDEX "un_cliente_cpfcnpj" ON "public"."r_cliente"

+ +

USING btree ("cpfcnpj");

+ +

 

+ +

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D  sav_cliente_lg: 65671 records  +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= +=3D

+ +

CREATE TABLE "public".&qu= +ot;sav_cliente_lg" +(

+ +

  "codigo" INTEGER NOT N= +ULL,

+ +

  "cpfcnpj" VARCHAR(15) = +NOT +NULL,

+ +

  PRIMARY <= +span +class=3DGramE>KEY("codigo")

+ +

) WITH OIDS;

+ +

 

+ +

CREATE INDEX "ix_savclientelg_cpfcnpj" ON "public"."sav_cliente_lg"

+ +

USING btree ("cpfcnpj");

+ +

 

+ +

 

+ +

 

+ +

Which I would like to run the following query:

+ +

 

+ +

        = +            &nb= +sp;            = +   QUERY

+ +

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

+ +

SELECT

+ +

 rc.pkcliente

+ +

FROM r_cliente AS rc

+ +

INNER JOIN sav_cliente_lg AS= + sc ON +sc.cpfcnpj =3D sc.cpfcnpj<= +/span>;

+ +

 

+ +

 

+ +

 

+ +

 

+ +

The problem is, it takes a long time to run, I wait up to +half an hour and I get no result.

+ +

 

+ +

So, I executed the explain on= + the +query and got the following results:

+ +

 

+ +

 

+ +

 

+ +

 

+ +

        = +            &nb= +sp;           QUER= +Y PLAN

+ +

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

+ +

 Nested Loop  (cost=3D0.00= +..16696.87 +rows=3D75816 width=3D4)

+ +

   ->  Seq Scan on sav_cliente_cf sc&nb= +sp; +(cost=3D0.00..3047.55 rows=3D1 width=3D0) + +

    = +;     Filter: ((cpfcnpj)::text =3D (cpfcnpj)::text)

+ +

   ->  Seq Scan on r_cliente rc  (cost=3D0.00..12891.16 rows=3D7581= +6 width=3D4)

+ +

 

+ +

 

+ +

 

+ +

 

+ +

And made the following modific= +ations +on my POSTGRESQL.CONF file:

+ +

 

+ +

        = +            &nb= +sp;           POST= +GRESQL.CONF

+ +

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

+ +

### VERSION: Postgresql 7.4.= +2 ###

+ +

shared_buffers = +=3D 7800

+ +

sort_mem<= +font +size=3D2 face=3DArial> = +=3D 4096

+ +

checkpoint_segments = +=3D 5 

+ +

effective_cache_size = +=3D 12000

+ +

cpu_operator_cost = +=3D 0.0015

+ +

stats_start_collector = +=3D false

+ +

 

+ +

 

+ +

Hope you can help me, I really need to get this running +faster, and I am out of ideas.

+ +

 

+ +

Since now, thanks a lot for your attention,

+ +

 

+ +

Danilo <= +span +class=3DSpellE>Mota

+ +
+ + + + + +------=_NextPart_000_0023_01C486B9.2A737D20-- + + + +From pgsql-performance-owner@postgresql.org Fri Aug 20 13:34:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 236E15E46D9 + for ; + Fri, 20 Aug 2004 13:34:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84696-07 + for ; + Fri, 20 Aug 2004 16:34: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 334F95E46CF + for ; + Fri, 20 Aug 2004 13:34:43 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7KGYmpE022879; + Fri, 20 Aug 2004 12:34:48 -0400 (EDT) +To: dmota@nexen.com.br +Cc: pgsql-performance@postgresql.org +Subject: Re: Query performance problem +In-reply-to: <002201c486d2$4fbe4420$8afea8c0@nexen.lan> +References: <002201c486d2$4fbe4420$8afea8c0@nexen.lan> +Comments: In-reply-to "Danilo Mota" + message dated "Fri, 20 Aug 2004 13:25:30 -0300" +Date: Fri, 20 Aug 2004 12:34:48 -0400 +Message-ID: <22878.1093019688@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/305 +X-Sequence-Number: 7941 + +"Danilo Mota" writes: +> SELECT +> rc.pkcliente +> FROM r_cliente AS rc +> INNER JOIN sav_cliente_lg AS sc ON sc.cpfcnpj = sc.cpfcnpj; + +Surely you meant + INNER JOIN sav_cliente_lg AS sc ON rc.cpfcnpj = sc.cpfcnpj; + +I would also venture that your statistics are desperately out of date, +because if the planner's estimates are close to reality, even this +unconstrained-cross-product join shouldn't have taken that long. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 20 13:39:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 53C8B5E46D8 + for ; + Fri, 20 Aug 2004 13:39:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86039-08 + for ; + Fri, 20 Aug 2004 16:39:56 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id AC0FD5E3F15 + for ; + Fri, 20 Aug 2004 13:39:45 -0300 (ADT) +Received: (qmail 26987 invoked by uid 500); 20 Aug 2004 16:48:21 -0000 +Date: Fri, 20 Aug 2004 11:48:21 -0500 +From: Bruno Wolff III +To: Danilo Mota +Cc: pgsql-performance@postgresql.org +Subject: Re: Query performance problem +Message-ID: <20040820164821.GA26674@wolff.to> +Mail-Followup-To: Danilo Mota , + pgsql-performance@postgresql.org +References: <002201c486d2$4fbe4420$8afea8c0@nexen.lan> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <002201c486d2$4fbe4420$8afea8c0@nexen.lan> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/306 +X-Sequence-Number: 7942 + +On Fri, Aug 20, 2004 at 13:25:30 -0300, + Danilo Mota wrote: +> +> And the following tables: +> TABLES +> ------------------------------------------------------------------------ +> -- +> ================== r_cliente: 75816 records +> ============================ +> CREATE TABLE "public"."r_cliente" ( +> "pkcliente" INTEGER NOT NULL, +> "cpfcnpj" VARCHAR(20) NOT NULL, +> PRIMARY KEY("pkcliente") +> ) WITH OIDS; +> +> CREATE UNIQUE INDEX "un_cliente_cpfcnpj" ON "public"."r_cliente" +> USING btree ("cpfcnpj"); +> +> ================== sav_cliente_lg: 65671 records +> ======================= +> CREATE TABLE "public"."sav_cliente_lg" ( +> "codigo" INTEGER NOT NULL, +> "cpfcnpj" VARCHAR(15) NOT NULL, +> PRIMARY KEY("codigo") +> ) WITH OIDS; +> +> CREATE INDEX "ix_savclientelg_cpfcnpj" ON "public"."sav_cliente_lg" +> USING btree ("cpfcnpj"); +> +> +> +> Which I would like to run the following query: +> +> QUERY +> ------------------------------------------------------------------------ +> -- +> SELECT +> rc.pkcliente +> FROM r_cliente AS rc +> INNER JOIN sav_cliente_lg AS sc ON sc.cpfcnpj = sc.cpfcnpj; + +I am going to assume that one of the sc.cpfcnpj's above is really rc.cpfcnpj +since that corresponds to the explain below. + +sc.cpfcnpj and rc.cpfcnpj are different length varchars. You made need +an explicit cast to allow the use of indexes. (Unless there is a real +business rule that mandates the limits you have used, you probably want +to make them both type 'text'.) + +Another potential problem is not having analyzed the tables. I don't think +this can be ruled out based on what you have showed us so far. + +> +> So, I executed the explain on the query and got the following results: + +Generally you want to run EXPLAIN ANALYZE results when submitting questions +about performance problems rather than just EXPLAIN results. + +From pgsql-performance-owner@postgresql.org Fri Aug 20 13:50:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B9B3D5E3639 + for ; + Fri, 20 Aug 2004 13:49:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94716-07 + for ; + Fri, 20 Aug 2004 16:50: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 A518C5E3632 + for ; + Fri, 20 Aug 2004 13:49:56 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7KGo11b027337; + Fri, 20 Aug 2004 12:50:02 -0400 (EDT) +To: Bruno Wolff III +Cc: Danilo Mota , + pgsql-performance@postgresql.org +Subject: Re: Query performance problem +In-reply-to: <20040820164821.GA26674@wolff.to> +References: <002201c486d2$4fbe4420$8afea8c0@nexen.lan> + <20040820164821.GA26674@wolff.to> +Comments: In-reply-to Bruno Wolff III + message dated "Fri, 20 Aug 2004 11:48:21 -0500" +Date: Fri, 20 Aug 2004 12:50:01 -0400 +Message-ID: <27336.1093020601@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/307 +X-Sequence-Number: 7943 + +Bruno Wolff III writes: +> I am going to assume that one of the sc.cpfcnpj's above is really rc.cpfcnpj +> since that corresponds to the explain below. + +No, actually the explain plan corresponds to the sc.cpfcnpj = sc.cpfcnpj +condition. I didn't twig to the typo until I started to wonder why the +plan had the condition in the wrong place (attached to the seqscan and +not the join step). + +> sc.cpfcnpj and rc.cpfcnpj are different length varchars. You made need +> an explicit cast to allow the use of indexes. + +AFAIK the cross-type issues only apply to crossing actual types, not +lengths. That does look like an error in the database schema, though. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 20 16:43:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 383345E46C3 + for ; + Fri, 20 Aug 2004 16:43:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59941-06 + for ; + Fri, 20 Aug 2004 19:43:41 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 227A45E46C8 + for ; + Fri, 20 Aug 2004 16:43:39 -0300 (ADT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i7KJgu220915; + Fri, 20 Aug 2004 21:42:56 +0200 +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 i7KJhck02148; + Fri, 20 Aug 2004 21:43:38 +0200 +Message-ID: <4126545C.5020203@bigfoot.com> +Date: Fri, 20 Aug 2004 21:43:24 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane , + "pgsql-performance@postgresql.org" +Subject: Re: using an index worst performances +References: <4124ECF3.6040901@archonet.com> + <412505F6.6080000@bigfoot.com> + <4125565D.3060008@familyhealth.com.au> + <4125C657.7000702@bigfoot.com> <1093006549.75942.61.camel@jester> + <41261E41.3080204@bigfoot.com> <22026.1093018762@sss.pgh.pa.us> +In-Reply-To: <22026.1093018762@sss.pgh.pa.us> +X-Enigmail-Version: 0.85.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/308 +X-Sequence-Number: 7944 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Tom Lane wrote: +| Gaetano Mendola writes: +| +|>Using a prepared query: +| +| +|>Without index and default stat 10 : 1.12 ms + +ariadne=# explain analyze execute test_ariadne; +~ QUERY PLAN +- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +~ Limit (cost=46.15..46.17 rows=1 width=760) (actual time=0.926..1.035 rows=3 loops=1) +~ -> Unique (cost=46.15..46.17 rows=1 width=760) (actual time=0.904..0.969 rows=3 loops=1) +~ -> Sort (cost=46.15..46.15 rows=1 width=760) (actual time=0.891..0.909 rows=3 loops=1) +~ Sort Key: store_nodes.parent, store_nodes.priority, store_nodes."path", store_objects.id, store_objects."type", store_objects.object, date_part('epoch'::text, store_objects.lastchanged), store_objects.vtype +~ -> Hash Join (cost=1.74..46.14 rows=1 width=760) (actual time=0.342..0.825 rows=3 loops=1) +~ Hash Cond: (("outer".vtype)::text = ("inner"."type")::text) +~ -> Nested Loop (cost=0.00..44.38 rows=1 width=760) (actual time=0.198..0.618 rows=3 loops=1) +~ -> Nested Loop (cost=0.00..38.93 rows=1 width=104) (actual time=0.157..0.447 rows=3 loops=1) +~ -> Seq Scan on store_prop_article (cost=0.00..1.75 rows=7 width=8) (actual time=0.030..0.119 rows=7 loops=1) +~ Filter: ((ar_start <= 1092924200) AND (ar_end >= 1092924200) AND ((ar_display)::text = 'default'::text)) +~ -> Index Scan using store_nodes_object on store_nodes (cost=0.00..5.30 rows=1 width=96) (actual time=0.019..0.023 rows=0 loops=7) +~ Index Cond: ("outer".object = store_nodes.object) +~ Filter: (("path")::text ~~ '/sites/broadsat/news/%'::text) +~ -> Index Scan using store_objects_pkey on store_objects (cost=0.00..5.43 rows=1 width=672) (actual time=0.013..0.020 rows=1 loops=3) +~ Index Cond: ("outer".object = store_objects.id) +~ -> Hash (cost=1.74..1.74 rows=2 width=11) (actual time=0.085..0.085 rows=0 loops=1) +~ -> Seq Scan on store_types (cost=0.00..1.74 rows=2 width=11) (actual time=0.038..0.064 rows=1 loops=1) +~ Filter: ((implements)::text = 'particle'::text) +~ Total runtime: 1.199 ms +(19 rows) + + +|>Without index and default stat 1000 : 1.25 ms + +ariadne=# explain analyze execute test_ariadne; +~ QUERY PLAN +- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +~ Limit (cost=46.14..46.16 rows=1 width=760) (actual time=1.027..1.126 rows=3 loops=1) +~ -> Unique (cost=46.14..46.16 rows=1 width=760) (actual time=1.014..1.077 rows=3 loops=1) +~ -> Sort (cost=46.14..46.14 rows=1 width=760) (actual time=1.001..1.019 rows=3 loops=1) +~ Sort Key: store_nodes.parent, store_nodes.priority, store_nodes."path", store_objects.id, store_objects."type", store_objects.object, date_part('epoch'::text, store_objects.lastchanged), store_objects.vtype +~ -> Nested Loop (cost=0.00..46.13 rows=1 width=760) (actual time=0.278..0.933 rows=3 loops=1) +~ Join Filter: (("outer".vtype)::text = ("inner"."type")::text) +~ -> Nested Loop (cost=0.00..44.38 rows=1 width=760) (actual time=0.208..0.591 rows=3 loops=1) +~ -> Nested Loop (cost=0.00..38.93 rows=1 width=104) (actual time=0.168..0.417 rows=3 loops=1) +~ -> Seq Scan on store_prop_article (cost=0.00..1.75 rows=7 width=8) (actual time=0.038..0.118 rows=7 loops=1) +~ Filter: ((ar_start <= 1092924200) AND (ar_end >= 1092924200) AND ((ar_display)::text = 'default'::text)) +~ -> Index Scan using store_nodes_object on store_nodes (cost=0.00..5.30 rows=1 width=96) (actual time=0.016..0.020 rows=0 loops=7) +~ Index Cond: ("outer".object = store_nodes.object) +~ Filter: (("path")::text ~~ '/sites/broadsat/news/%'::text) +~ -> Index Scan using store_objects_pkey on store_objects (cost=0.00..5.43 rows=1 width=672) (actual time=0.012..0.022 rows=1 loops=3) +~ Index Cond: ("outer".object = store_objects.id) +~ -> Seq Scan on store_types (cost=0.00..1.74 rows=1 width=11) (actual time=0.029..0.060 rows=1 loops=3) +~ Filter: ((implements)::text = 'particle'::text) +~ Total runtime: 1.288 ms +(18 rows) + + +|>With index and default stat 10: 1.35 ms + +ariadne=# explain analyze execute test_ariadne; +~ QUERY PLAN +- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +~ Limit (cost=14.95..14.97 rows=1 width=760) (actual time=1.066..1.165 rows=3 loops=1) +~ -> Unique (cost=14.95..14.97 rows=1 width=760) (actual time=1.052..1.116 rows=3 loops=1) +~ -> Sort (cost=14.95..14.95 rows=1 width=760) (actual time=1.036..1.054 rows=3 loops=1) +~ Sort Key: store_nodes.parent, store_nodes.priority, store_nodes."path", store_objects.id, store_objects."type", store_objects.object, date_part('epoch'::text, store_objects.lastchanged), store_objects.vtype +~ -> Hash Join (cost=3.51..14.94 rows=1 width=760) (actual time=0.614..0.968 rows=3 loops=1) +~ Hash Cond: ("outer".id = "inner".object) +~ -> Hash Join (cost=1.74..13.15 rows=1 width=768) (actual time=0.281..0.651 rows=5 loops=1) +~ Hash Cond: (("outer".vtype)::text = ("inner"."type")::text) +~ -> Nested Loop (cost=0.00..11.39 rows=1 width=768) (actual time=0.070..0.406 rows=6 loops=1) +~ -> Index Scan using test_index on store_nodes (cost=0.00..5.95 rows=1 width=96) (actual time=0.027..0.084 rows=6 loops=1) +~ Index Cond: ((("path")::text ~>=~ '/sites/broadsat/news/'::character varying) AND (("path")::text ~<~ '/sites/broadsat/news0'::character varying)) +~ Filter: (("path")::text ~~ '/sites/broadsat/news/%'::text) +~ -> Index Scan using store_objects_pkey on store_objects (cost=0.00..5.43 rows=1 width=672) (actual time=0.012..0.020 rows=1 loops=6) +~ Index Cond: (store_objects.id = "outer".object) +~ -> Hash (cost=1.74..1.74 rows=2 width=11) (actual time=0.093..0.093 rows=0 loops=1) +~ -> Seq Scan on store_types (cost=0.00..1.74 rows=2 width=11) (actual time=0.029..0.054 rows=1 loops=1) +~ Filter: ((implements)::text = 'particle'::text) +~ -> Hash (cost=1.75..1.75 rows=7 width=8) (actual time=0.182..0.182 rows=0 loops=1) +~ -> Seq Scan on store_prop_article (cost=0.00..1.75 rows=7 width=8) (actual time=0.041..0.121 rows=7 loops=1) +~ Filter: ((ar_start <= 1092924200) AND (ar_end >= 1092924200) AND ((ar_display)::text = 'default'::text)) +~ Total runtime: 1.358 ms +(21 rows) + +|>With index and default stat 1000: 1.6 ms + +ariadne=# explain analyze execute test_ariadne; +~ QUERY PLAN +- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ +~ Limit (cost=14.94..14.96 rows=1 width=760) (actual time=1.346..1.445 rows=3 loops=1) +~ -> Unique (cost=14.94..14.96 rows=1 width=760) (actual time=1.329..1.393 rows=3 loops=1) +~ -> Sort (cost=14.94..14.94 rows=1 width=760) (actual time=1.317..1.335 rows=3 loops=1) +~ Sort Key: store_nodes.parent, store_nodes.priority, store_nodes."path", store_objects.id, store_objects."type", store_objects.object, date_part('epoch'::text, store_objects.lastchanged), store_objects.vtype +~ -> Hash Join (cost=1.77..14.93 rows=1 width=760) (actual time=0.663..1.249 rows=3 loops=1) +~ Hash Cond: ("outer".id = "inner".object) +~ -> Nested Loop (cost=0.00..13.14 rows=1 width=768) (actual time=0.268..0.936 rows=5 loops=1) +~ Join Filter: (("outer".vtype)::text = ("inner"."type")::text) +~ -> Nested Loop (cost=0.00..11.39 rows=1 width=768) (actual time=0.070..0.412 rows=6 loops=1) +~ -> Index Scan using test_index on store_nodes (cost=0.00..5.95 rows=1 width=96) (actual time=0.027..0.093 rows=6 loops=1) +~ Index Cond: ((("path")::text ~>=~ '/sites/broadsat/news/'::character varying) AND (("path")::text ~<~ '/sites/broadsat/news0'::character varying)) +~ Filter: (("path")::text ~~ '/sites/broadsat/news/%'::text) +~ -> Index Scan using store_objects_pkey on store_objects (cost=0.00..5.43 rows=1 width=672) (actual time=0.013..0.020 rows=1 loops=6) +~ Index Cond: (store_objects.id = "outer".object) +~ -> Seq Scan on store_types (cost=0.00..1.74 rows=1 width=11) (actual time=0.025..0.051 rows=1 loops=6) +~ Filter: ((implements)::text = 'particle'::text) +~ -> Hash (cost=1.75..1.75 rows=7 width=8) (actual time=0.181..0.181 rows=0 loops=1) +~ -> Seq Scan on store_prop_article (cost=0.00..1.75 rows=7 width=8) (actual time=0.040..0.122 rows=7 loops=1) +~ Filter: ((ar_start <= 1092924200) AND (ar_end >= 1092924200) AND ((ar_display)::text = 'default'::text)) +~ Total runtime: 1.616 ms +(20 rows) + + + +| Could we see EXPLAIN ANALYZE EXECUTE output for each case? +| + +See above. + + +BTW I dont know if this is a known issue: + +After the prepare statement: + +ariadne=# drop index test_index; +DROP INDEX +ariadne=# explain analyze execute test_ariadne; +ERROR: could not open relation with OID 53695 + + + + +Regards +Gaetano Mendola + + + + + + + + + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBJlRb7UpzwH2SGd4RAn+/AJ9QEyedv6ZQNQse5uhhCpasF65dugCfUzW7 +tDuDEVFNgb42NbX2/GJ+joQ= +=gaO/ +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Fri Aug 20 17:04:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B73825E40AC + for ; + Fri, 20 Aug 2004 17:04:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69717-03 + for ; + Fri, 20 Aug 2004 20:04: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 45CEF5E3639 + for ; + Fri, 20 Aug 2004 17:04:23 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7KK41mV001978; + Fri, 20 Aug 2004 16:04:02 -0400 (EDT) +To: Gaetano Mendola +Cc: "pgsql-performance@postgresql.org" +Subject: Re: using an index worst performances +In-reply-to: <4126545C.5020203@bigfoot.com> +References: <4124ECF3.6040901@archonet.com> + <412505F6.6080000@bigfoot.com> + <4125565D.3060008@familyhealth.com.au> + <4125C657.7000702@bigfoot.com> <1093006549.75942.61.camel@jester> + <41261E41.3080204@bigfoot.com> <22026.1093018762@sss.pgh.pa.us> + <4126545C.5020203@bigfoot.com> +Comments: In-reply-to Gaetano Mendola + message dated "Fri, 20 Aug 2004 21:43:24 +0200" +Date: Fri, 20 Aug 2004 16:04:01 -0400 +Message-ID: <1977.1093032241@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/309 +X-Sequence-Number: 7945 + +Gaetano Mendola writes: +> Tom Lane wrote: +> | Could we see EXPLAIN ANALYZE EXECUTE output for each case? + +> [snip] +> See above. + +Okay, so the issue here is choosing between a nestloop or a hash join +that have very nearly equal estimated costs: + +> ~ -> Hash Join (cost=1.74..46.14 rows=1 width=760) (actual time=0.342..0.825 rows=3 loops=1) +> ~ Hash Cond: (("outer".vtype)::text = ("inner"."type")::text) + +> ~ -> Nested Loop (cost=0.00..46.13 rows=1 width=760) (actual time=0.278..0.933 rows=3 loops=1) +> ~ Join Filter: (("outer".vtype)::text = ("inner"."type")::text) + +In the indexed case it's the same choice, but at a different level of joining: + +> ~ -> Hash Join (cost=1.74..13.15 rows=1 width=768) (actual time=0.281..0.651 rows=5 loops=1) +> ~ Hash Cond: (("outer".vtype)::text = ("inner"."type")::text) + +> ~ -> Nested Loop (cost=0.00..13.14 rows=1 width=768) (actual time=0.268..0.936 rows=5 loops=1) +> ~ Join Filter: (("outer".vtype)::text = ("inner"."type")::text) + +With only 0.01 unit of difference in the costs, it's perfectly plausible +for a change in the statistics to change the estimated cost just enough +to give one plan or the other the edge in estimated cost. + +Given that the runtimes are in fact pretty similar, it doesn't bother me +that the planner is estimating them as essentially identical. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Aug 20 20:59:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F4725E40BB + for ; + Fri, 20 Aug 2004 20:59:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39943-06 + for ; + Fri, 20 Aug 2004 23:59:00 +0000 (GMT) +Received: from hm171.locaweb.com.br (hm171.locaweb.com.br [200.234.203.7]) + by svr1.postgresql.org (Postfix) with SMTP id D08705E46D1 + for ; + Fri, 20 Aug 2004 20:58:56 -0300 (ADT) +Received: (qmail 66197 invoked by uid 0); 20 Aug 2004 23:58:30 -0000 +Received: from unknown (10.1.10.141) + by hm171.locaweb.com.br with QMTP; 20 Aug 2004 23:58:30 -0000 +Received: (qmail 11196 invoked from network); 20 Aug 2004 23:58:56 -0000 +Received: from unknown (HELO xws08) (dmota@nexen.com.br@201.9.66.167) + by hm141.locaweb.com.br with SMTP; 20 Aug 2004 23:58:56 -0000 +Reply-To: +From: "Danilo Mota" +To: +Subject: Query Performance +Date: Fri, 20 Aug 2004 21:03:54 -0300 +Organization: Nexen Tecnologia +Message-ID: <000001c48712$599737a0$8afea8c0@nexen.lan> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0001_01C486F9.3449FFA0" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2616 +Importance: Normal +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.1 tagged_above=0.0 required=5.0 tests=HTML_70_80, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200408/310 +X-Sequence-Number: 7946 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0001_01C486F9.3449FFA0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +Hi all, + + the following query is working well without the AND on WHERE clause, so +I need suggestions about how could I rewrite the query to get the same +result with less cost of time and resources. + +I've already created indexes on all foreign key columns. + +Thanks in advance. + +Danilo Mota + +======================================================================== +============ + SELECT + sn.notafiscalnumero, + sn.notafiscalserie, + CASE sn.notafiscaldata WHEN '00000000' THEN NULL ELSE +to_date(sn.notafiscaldata,'YYYYMMDD') END, + sn.modalidade, + rcm.pkclientemarca, + sn.notafiscalvalor/100, + sn.entrada/100, + sn.cliente + FROM r_clientemarca AS rcm + INNER JOIN r_cliente AS rc ON rc.pkcliente = rcm.fkcliente + INNER JOIN sav_cliente_lg AS sc ON sc.cpfcnpj = rc.cpfcnpj + INNER JOIN sav_nota_lg AS sn ON sn.cliente = sc.codigo + WHERE rcm.fkmarca = 1 + AND sn.notafiscalnumero||sn.notafiscalserie||sn.cliente NOT IN ( +SELECT numero||serie||codigo + +FROM r_contrato AS rcon + +WHERE savfonte = 'lg') + +======================================================================== +============ + + + TABLES +------------------------------------------------------------------------ +----------------------------------------------------- +r_cliente: 75820 records +r_clientemarca: 97719 records +r_contrato: 782058 records +sav_cliente_lg: 65671 records +sav_nota_lg: 297329 rcords + MY SERVER +------------------------------------------------------------------------ +----------------------------------------------------- +Pentium 4 2.4 GHz +1 GB RAM +36 GB SCSI +Postgresql 7.4.2 + + POSTGRESQL.CONF +------------------------------------------------------------------------ +----------------------------------------------------- +shared_buffers = 7800 +sort_mem = 4096 +checkpoint_segments = 5 +effective_cache_size = 12000 +cpu_operator_cost = 0.0015 +stats_start_collector = false + + QUERY PLAN +------------------------------------------------------------------------ +----------------------------------------------------- + Hash Join (cost=27149.61..3090289650.24 rows=128765 width=4) + Hash Cond: ("outer".cliente = "inner".codigo) + -> Seq Scan on sav_nota_lg sn (cost=0.00..3090258517.99 rows=148665 +width=8) + Filter: (NOT (subplan)) + SubPlan + -> Seq Scan on r_contrato rcon (cost=0.00..20362.47 +rows=282845 width=19) + Filter: ((savfonte)::text = 'lg'::text) + -> Hash (cost=26869.29..26869.29 rows=56880 width=4) + -> Hash Join (cost=22473.95..26869.29 rows=56880 width=4) + Hash Cond: ("outer".fkcliente = "inner".pkcliente) + -> Index Scan using ix_r_clientemarca_fkmarca on +r_clientemarca rcm (cost=0.00..2244.46 rows=65665 width=4) + Index Cond: (fkmarca = 1) + -> Hash (cost=22118.44..22118.44 rows=65672 width=8) + -> Hash Join (cost=6613.22..22118.44 rows=65672 +width=8) + Hash Cond: (("outer".cpfcnpj)::text = +("inner".cpfcnpj)::text) + -> Seq Scan on r_cliente rc +(cost=0.00..12891.16 rows=75816 width=23) + -> Hash (cost=6129.71..6129.71 rows=65671 +width=23) + -> Seq Scan on sav_cliente_lg sc +(cost=0.00..6129.71 rows=65671 width=23) + + + +------=_NextPart_000_0001_01C486F9.3449FFA0 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + + + + + +
+ +

Hi all,= +

+ +

 <= +/font>

+ +

 th= +e following +query is working well without the AND on WHERE clause, so I need suggestions +about how could I rewrite the query to get the same result with less cost of +time and resources.

+ +

 

+ +

I’ve already created indexes on all foreign key +columns.

+ +

 

+ +

Thanks in advance.

+ +

 

+ +

Danilo <= +span +class=3DSpellE>Mota

+ +

 

+ +

=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=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= +=3D

+ +

    SELECT

+ +

        sn.notafiscalnumero,

+ +

        sn.notafiscalserie,

+ +

        CASE = +sn.notafiscaldata WHEN '00000000' THEN NULL ELSE to_date(sn.notafiscaldata,'YYYYMMDD') END,<= +/font>

+ +

        sn.mo= +dalidade,

+ +

        rcm.p= +kclientemarca,

+ +

        sn.no= +tafiscalvalor/100,

+ +

        sn.entrada/100,

+ +

        sn.cliente

+ +

    FROM r_clientemarca AS= + rcm

+ +

    INNER JOIN = +r_cliente AS rc +ON rc.pkcliente =3D rcm.fk= +cliente

+ +

    +INNER JOIN sav_cliente_lg AS sc ON sc.cpfcnpj =3D rc.cpfcnpj= +

+ +

    INNER +JOIN sav_nota_lg AS sn ON sn.cliente = +=3D sc.codigo

+ +

    WHERE rcm.fkmarca =3D 1 + +

      AND sn.notafiscalnumero||sn.notafiscalserie||sn.cliente N= +OT IN ( SELECT numero||serie||codigo

+ +

        = +            &nb= +sp;            = +            &nb= +sp;            = +            +        = +            &nb= +sp;         FROM +r_contrato AS rcon

+ +

        = +            &nb= +sp;            = +            &nb= +sp;     +        = +                   = +            &nb= +sp;         WHERE +savfonte =3D 'lg')

+ +

 <= +/font>

+ +

=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=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= +=3D

+ +

 <= +/font>

+ +

 

+ +

        = +            &nb= +sp;            = +            &nb= +sp;           +TABLES

+ +

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

+ +

r_cliente: 75820 records<= +o:p>

+ +

r_clientemarca: 97719 rec= +ords

+ +

r_contrato: 782058 record= +s

+ +

sav_cliente_lg: 65671 rec= +ords

+ +

sav_nota_lg: 297329 rcord= +s

+ +

        = +            &nb= +sp;            = +            &nb= +sp;           +MY SERVER

+ +

--------------------------------------------------------= +---------------------------------------------------------------------<= +/o:p>

+ +

Pentium 4 2.4 GHz

+ +

1 GB RAM

+ +

36 GB SCSI

+ +

Postgresql 7.4.2

+ +

 <= +/font>

+ +

        = +            &nb= +sp;            = +            &nb= +sp;           +POSTGRESQL.CONF

+ +

--------------------------------------------------------= +---------------------------------------------------------------------<= +/o:p>

+ +

shared_buffers = +=3D 7800

+ +

sort_mem<= +font +size=3D2 face=3DArial> = +=3D 4096

+ +

checkpoint_segments = +=3D 5 

+ +

effective_cache_size = +=3D 12000

+ +

cpu_operator_cost = +=3D 0.0015

+ +

stats_start_collector = +=3D false

+ +

 

+ +

        = +            &nb= +sp;            = +            &nb= +sp;           +QUERY PLAN

+ +

--------------------------------------------------------= +---------------------------------------------------------------------<= +/o:p>

+ +

 Hash Join  (co= +st=3D27149.61..3090289650.24 +rows=3D128765 width=3D4)

+ +

   Has= +h Cond: ("outer".cliente= + +=3D "inner".codigo)= +

+ +

   ->  Seq Scan on sav_nota_lg sn  +(cost=3D0.00..3090258517.99 rows=3D148665 width=3D8)

+ +

         +Filter: (NOT (subplan))

+ +

         +SubPlan

+ +

        = +   +->  Seq Scan on r_contrato rcon  +(cost=3D0.00..20362.47 rows=3D282845 width=3D19)

+ +

        = +         +Filter: ((savfonte):= +:text +=3D 'lg'::text)

+ +

   ->  Hash  (cost=3D26869.29..26869.29 rows=3D= +56880 +width=3D4)

+ +

         +->  Hash +Join  (cost=3D22473.95..26869.= +29 +rows=3D56880 width=3D4)

+ +

        = +       +Hash Cond: ("o= +uter".fkcliente +=3D "inner".pkcliente)

+ +

        = +       +->  +Index Scan using ix_r_clientemarca_fkmar= +ca +on r_clientemarca rcm  (cost=3D0.00..2244.46 rows=3D65665= + width=3D4)

+ +

        = +             +Index Cond: (fkmarc= +a +=3D 1)

+ +

        = +       +->  Hash  (cost=3D22118.44..22118.44 rows=3D= +65672 +width=3D8)

+ +

               = +      ->  Hash +Join  (cost=3D6613.22..22118.44 +rows=3D65672 width=3D8)

+ +

        = +            &nb= +sp;      +Hash Cond: (("= +outer".cpfcnpj)::text =3D ("inner".cpfc= +npj)::text)

+ +

        = +            &nb= +sp;      +->  Seq Scan on r_cliente rc  +(cost=3D0.00..12891.16 rows=3D75816 width=3D23)

+ +

        = +            &nb= +sp;      +->  Hash  (cost=3D6129.71..6129.71 rows=3D65= +671 +width=3D23)

+ +

        = +            &nb= +sp;            +->  Seq Scan on sav_cliente_l= +g +sc  (cost=3D0.00..6129.71 rows= +=3D65671 +width=3D23)

+ +

 

+ +

 

+ +
+ + + + + +------=_NextPart_000_0001_01C486F9.3449FFA0-- + + + +From pgsql-performance-owner@postgresql.org Fri Aug 20 21:59:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 671155E46BF + for ; + Fri, 20 Aug 2004 21:59:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55195-01 + for ; + Sat, 21 Aug 2004 00:59:49 +0000 (GMT) +Received: from bugge.potatoe.com (bugge.potatoe.com [216.240.48.15]) + by svr1.postgresql.org (Postfix) with ESMTP id C639C5E37CB + for ; + Fri, 20 Aug 2004 21:59:46 -0300 (ADT) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by bugge.potatoe.com (Postfix) with ESMTP + id 59151728DE5; Fri, 20 Aug 2004 18:02:49 -0700 (PDT) +Message-ID: <41269F38.5090305@madfish.com> +Date: Fri, 20 Aug 2004 18:02:48 -0700 +From: Brad Bulger +Organization: The Madfish Group +User-Agent: Mozilla Thunderbird 0.7+ (Macintosh/20040715) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: dmota@nexen.com.br +Cc: pgsql-performance@postgresql.org +Subject: Re: Query Performance +References: <000001c48712$599737a0$8afea8c0@nexen.lan> +In-Reply-To: <000001c48712$599737a0$8afea8c0@nexen.lan> +Content-Type: text/plain; charset=windows-1252; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/311 +X-Sequence-Number: 7947 + +Have you tried + +AND (sn.notafiscalnumero, sn.notafiscalserie, sn.cliente) NOT IN ( + SELECT numero, serie, codigo FROM r_contrato WHERE savfonte = 'lg') + +or + +and not exists(select true from r_contrato where savfonte = 'lg' and numero = +sn.notafiscalnumero and serie = sn.notafiscalserie and codigo = sn.cliente) + + +Danilo Mota wrote: + +> Hi all, +> +> +> +> the following query is working well without the AND on WHERE clause, so +> I need suggestions about how could I rewrite the query to get the same +> result with less cost of time and resources. +> +> +> +> I�ve already created indexes on all foreign key columns. +> +> +> +> Thanks in advance. +> +> +> +> Danilo Mota +> +> +> +> ==================================================================================== +> +> SELECT +> +> sn.notafiscalnumero, +> +> sn.notafiscalserie, +> +> CASE sn.notafiscaldata WHEN '00000000' THEN NULL ELSE +> to_date(sn.notafiscaldata,'YYYYMMDD') END, +> +> sn.modalidade, +> +> rcm.pkclientemarca, +> +> sn.notafiscalvalor/100, +> +> sn.entrada/100, +> +> sn.cliente +> +> FROM r_clientemarca AS rcm +> +> INNER JOIN r_cliente AS rc ON rc.pkcliente = rcm.fkcliente +> +> INNER JOIN sav_cliente_lg AS sc ON sc.cpfcnpj = rc.cpfcnpj +> +> INNER JOIN sav_nota_lg AS sn ON sn.cliente = sc.codigo +> +> WHERE rcm.fkmarca = 1 +> +> AND sn.notafiscalnumero||sn.notafiscalserie||sn.cliente NOT IN ( +> SELECT numero||serie||codigo +> +> +> FROM r_contrato AS rcon +> +> +> WHERE savfonte = 'lg') +> +> +> +> ==================================================================================== +> +> +> +> +> +> TABLES +> +> ----------------------------------------------------------------------------------------------------------------------------- +> +> r_cliente: 75820 records +> +> r_clientemarca: 97719 records +> +> r_contrato: 782058 records +> +> sav_cliente_lg: 65671 records +> +> sav_nota_lg: 297329 rcords +> +> MY SERVER +> +> ----------------------------------------------------------------------------------------------------------------------------- +> +> Pentium 4 2.4 GHz +> +> 1 GB RAM +> +> 36 GB SCSI +> +> Postgresql 7.4.2 +> +> +> +> POSTGRESQL.CONF +> +> ----------------------------------------------------------------------------------------------------------------------------- +> +> shared_buffers = 7800 +> +> sort_mem = 4096 +> +> checkpoint_segments = 5 +> +> effective_cache_size = 12000 +> +> cpu_operator_cost = 0.0015 +> +> stats_start_collector = false +> +> +> +> QUERY PLAN +> +> ----------------------------------------------------------------------------------------------------------------------------- +> +> Hash Join (cost=27149.61..3090289650.24 rows=128765 width=4) +> +> Hash Cond: ("outer".cliente = "inner".codigo) +> +> -> Seq Scan on sav_nota_lg sn (cost=0.00..3090258517.99 rows=148665 +> width=8) +> +> Filter: (NOT (subplan)) +> +> SubPlan +> +> -> Seq Scan on r_contrato rcon (cost=0.00..20362.47 +> rows=282845 width=19) +> +> Filter: ((savfonte)::text = 'lg'::text) +> +> -> Hash (cost=26869.29..26869.29 rows=56880 width=4) +> +> -> Hash Join (cost=22473.95..26869.29 rows=56880 width=4) +> +> Hash Cond: ("outer".fkcliente = "inner".pkcliente) +> +> -> Index Scan using ix_r_clientemarca_fkmarca on +> r_clientemarca rcm (cost=0.00..2244.46 rows=65665 width=4) +> +> Index Cond: (fkmarca = 1) +> +> -> Hash (cost=22118.44..22118.44 rows=65672 width=8) +> +> -> Hash Join (cost=6613.22..22118.44 rows=65672 +> width=8) +> +> Hash Cond: (("outer".cpfcnpj)::text = +> ("inner".cpfcnpj)::text) +> +> -> Seq Scan on r_cliente rc +> (cost=0.00..12891.16 rows=75816 width=23) +> +> -> Hash (cost=6129.71..6129.71 rows=65671 +> width=23) +> +> -> Seq Scan on sav_cliente_lg sc +> (cost=0.00..6129.71 rows=65671 width=23) +> +> +> +> +> + +From pgsql-performance-owner@postgresql.org Sun Aug 22 07:08:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F86D5E46E1 + for ; + Sun, 22 Aug 2004 07:08:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06695-01 + for ; + Sun, 22 Aug 2004 10:08:52 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id EAD365E46CE + for ; + Sun, 22 Aug 2004 07:08:50 -0300 (ADT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i7MA88j32604 + for ; Sun, 22 Aug 2004 12:08:08 +0200 +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 i7MA8qk24222 + for ; Sun, 22 Aug 2004 12:08:52 +0200 +Message-ID: <412870AF.5050202@bigfoot.com> +Date: Sun, 22 Aug 2004 12:08:47 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Subject: Re: using an index worst performances +References: <4124ECF3.6040901@archonet.com> + <412505F6.6080000@bigfoot.com> + <4125565D.3060008@familyhealth.com.au> + <4125C657.7000702@bigfoot.com> <1093006549.75942.61.camel@jester> + <41261E41.3080204@bigfoot.com> <1093019414.75942.81.camel@jester> +In-Reply-To: <1093019414.75942.81.camel@jester> +X-Enigmail-Version: 0.85.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 + tests=TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200408/312 +X-Sequence-Number: 7948 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Rod Taylor wrote: + +|>>What are the times without the index, with the index and with the higher +|>>statistics value when using a prepared query? +|> +|>Using a prepared query: +|> +|>Without index and default stat 10 : 1.12 ms +|>Without index and default stat 1000 : 1.25 ms +|>With index and default stat 10: 1.35 ms +|>With index and default stat 1000: 1.6 ms +|> +|>that values are the average obtained after the very first one, +|>on 20 execution. +| +| +| Most interesting. And the plans chosen with the 2 different default stat +| targets are the same? Sorry if I missed the post indicating they were. +| +| If the plans are the same, it would be interesting to get a profile on +| the 2 different cases with that index in place across 100k iterations of +| the prepared query. + +Do you have an advice on the profiler to use ? + + +Regards +Gaetano Mendola + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBKHBg7UpzwH2SGd4RAmGCAKDOZ3xXNPFhhGSMN89MssR7UZnY3ACg6sAY +mWKo4uAZzv1ZtmBsfQZ2SBc= +=NQf/ +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Mon Aug 23 11:33:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1280E5E46DD + for ; + Mon, 23 Aug 2004 11:33:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28822-07 + for ; + Mon, 23 Aug 2004 14:33:09 +0000 (GMT) +Received: from web54104.mail.yahoo.com (web54104.mail.yahoo.com + [206.190.37.239]) + by svr1.postgresql.org (Postfix) with SMTP id B84AC5E46C1 + for ; + Mon, 23 Aug 2004 11:33:04 -0300 (ADT) +Message-ID: <20040823143310.93307.qmail@web54104.mail.yahoo.com> +Received: from [129.94.6.30] by web54104.mail.yahoo.com via HTTP; + Mon, 23 Aug 2004 07:33:10 PDT +Date: Mon, 23 Aug 2004 07:33:10 -0700 (PDT) +From: my thi ho +Subject: postgresql 8.0 beta - fail to collect statsistic +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/313 +X-Sequence-Number: 7949 + +Hi, +I got this error message: + +LOG: could not create IPv6 socket: Address family not +supported by protocol +LOG: could not bind socket for statistics collector: +Cannot assign requested address +LOG: disabling statistics collector for lack of +working socket +LOG: database system was shut down at 2004-08-24 +00:07:21 EST +LOG: checkpoint record is at 0/A45360 +LOG: redo record is at 0/A45360; undo record is at +0/0; shutdown TRUE +LOG: next transaction ID: 492; next OID: 17228 +LOG: database system is ready + + +I already have a look at pgstat.c but dun know where +to fix it ( with 7.3.1 i just change the line +inet_aton("127.0.0.1", &(pgStatAddr.sin_addr)); +to inet_aton("", &(pgStatAddr.sin_addr)); then +it works +this is the config of the computer: +$ uname -a +Linux grieg 2.4.26-general-64G #1 SMP Tue May 18 +09:31:45 EST 2004 i686 GNU/Linux + +Any help would be really appreciated. +MT + + + + +__________________________________ +Do you Yahoo!? +New and Improved Yahoo! Mail - 100MB free storage! +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Mon Aug 23 16:01:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0439D5E3F15 + for ; + Mon, 23 Aug 2004 16:01:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47170-02 + for ; + Mon, 23 Aug 2004 19:01: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 D45805E37CB + for ; + Mon, 23 Aug 2004 16:01:45 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7NJ1j1v009890; + Mon, 23 Aug 2004 15:01:45 -0400 (EDT) +To: my thi ho +Cc: pgsql-performance@postgresql.org +Subject: Re: postgresql 8.0 beta - fail to collect statsistic +In-reply-to: <20040823143310.93307.qmail@web54104.mail.yahoo.com> +References: <20040823143310.93307.qmail@web54104.mail.yahoo.com> +Comments: In-reply-to my thi ho + message dated "Mon, 23 Aug 2004 07:33:10 -0700" +Date: Mon, 23 Aug 2004 15:01:45 -0400 +Message-ID: <9889.1093287705@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/314 +X-Sequence-Number: 7950 + +my thi ho writes: +> I got this error message: + +> LOG: could not create IPv6 socket: Address family not +> supported by protocol +> LOG: could not bind socket for statistics collector: +> Cannot assign requested address +> LOG: disabling statistics collector for lack of +> working socket + +You have a broken networking setup, or possibly a broken DNS setup. +The machine should accept connections to 127.0.0.1 ... if it does not, +find out why not. + +> I already have a look at pgstat.c but dun know where +> to fix it ( with 7.3.1 i just change the line +> inet_aton("127.0.0.1", &(pgStatAddr.sin_addr)); +> to inet_aton("", &(pgStatAddr.sin_addr)); then +> it works + +You were fixing the symptom and not the problem. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 23 18:52:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DBA345E3631 + for ; + Mon, 23 Aug 2004 18:52:53 -0300 (ADT) +Received: 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-06 + for ; + Mon, 23 Aug 2004 21:52:53 +0000 (GMT) +Received: from fed1rmmtao10.cox.net (fed1rmmtao10.cox.net [68.230.241.29]) + by svr1.postgresql.org (Postfix) with ESMTP id ECFB95E46C4 + for ; + Mon, 23 Aug 2004 18:52:46 -0300 (ADT) +Received: from [68.12.228.23] by fed1rmmtao10.cox.net + (InterMail vM.6.01.03.02.01 201-2131-111-104-103-20040709) with ESMTP + id <20040823215249.KFKY7726.fed1rmmtao10.cox.net@[68.12.228.23]>; + Mon, 23 Aug 2004 17:52:49 -0400 +Subject: Re: postgresql 8.0 beta - fail to collect statsistic +From: Steve Bergman +To: Tom Lane +Cc: my thi ho , + pgsql-perform +In-Reply-To: <9889.1093287705@sss.pgh.pa.us> +References: <20040823143310.93307.qmail@web54104.mail.yahoo.com> + <9889.1093287705@sss.pgh.pa.us> +Content-Type: text/plain +Date: Mon, 23 Aug 2004 16:52:47 -0500 +Message-Id: <1093297967.5512.3.camel@voyager.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 1.5.93 (1.5.93-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/315 +X-Sequence-Number: 7951 + +If IPv6 doesn't work, shouldn't it fall back to IPv4, or check IPv4 +first, or something? Just wondering. + +-Steve Bergman + + +From pgsql-performance-owner@postgresql.org Mon Aug 23 19:30:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id BA1035E46C9 + for ; + Mon, 23 Aug 2004 19:30:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44965-06 + for ; + Mon, 23 Aug 2004 22:30:45 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 54EAC5E46D1 + for ; + Mon, 23 Aug 2004 19:30:43 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7NMUkm1020632; + Mon, 23 Aug 2004 18:30:46 -0400 (EDT) +To: Steve Bergman +Cc: my thi ho , + pgsql-perform +Subject: Re: postgresql 8.0 beta - fail to collect statsistic +In-reply-to: <1093297967.5512.3.camel@voyager.localdomain> +References: <20040823143310.93307.qmail@web54104.mail.yahoo.com> + <9889.1093287705@sss.pgh.pa.us> + <1093297967.5512.3.camel@voyager.localdomain> +Comments: In-reply-to Steve Bergman + message dated "Mon, 23 Aug 2004 16:52:47 -0500" +Date: Mon, 23 Aug 2004 18:30:45 -0400 +Message-ID: <20631.1093300245@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/316 +X-Sequence-Number: 7952 + +Steve Bergman writes: +> If IPv6 doesn't work, shouldn't it fall back to IPv4, + +It does. That was all debugged in 7.4 --- we have not seen any cases +since 7.4 beta in which failures of this kind did not mean a +misconfigured networking setup. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 23 21:02:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 731CF5E37CB + for ; + Mon, 23 Aug 2004 21:02:26 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71565-05 + for ; + Tue, 24 Aug 2004 00:02:18 +0000 (GMT) +Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net + [67.119.5.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 31BB15E3631 + for ; + Mon, 23 Aug 2004 21:02:15 -0300 (ADT) +Received: (from andrew@localhost) + by pillette.com (8.11.6/8.11.6) id i7O02Iq30466; + Mon, 23 Aug 2004 17:02:18 -0700 +Date: Mon, 23 Aug 2004 17:02:18 -0700 +From: andrew@pillette.com +Message-Id: <200408240002.i7O02Iq30466@pillette.com> +Subject: How do I see what triggers are called on cascade? +To: pgsql-performance@postgresql.org +Cc: +X-Originating-IP: 192.168.1.11 +X-Mailer: Webmin 0.940 +MIME-Version: 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200408/317 +X-Sequence-Number: 7953 + +I'm still having trouble with slow cascading DELETEs. What commands can I issue to see the sequence of events that occurs after I execute + +DELETE FROM x WHERE p; + +so that I can see if indexes being used correctly, or I have a constraint I don't want, etc. + +From pgsql-performance-owner@postgresql.org Mon Aug 23 23:50:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C35155E3632 + for ; + Mon, 23 Aug 2004 23:50:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 31737-09 + for ; + Tue, 24 Aug 2004 02:50: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 82D395E40BA + for ; + Mon, 23 Aug 2004 23:50:35 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7O2ofaS027146; + Mon, 23 Aug 2004 22:50:41 -0400 (EDT) +To: andrew@pillette.com +Cc: pgsql-performance@postgresql.org +Subject: Re: How do I see what triggers are called on cascade? +In-reply-to: <200408240002.i7O02Iq30466@pillette.com> +References: <200408240002.i7O02Iq30466@pillette.com> +Comments: In-reply-to andrew@pillette.com + message dated "Mon, 23 Aug 2004 17:02:18 -0700" +Date: Mon, 23 Aug 2004 22:50:41 -0400 +Message-ID: <27145.1093315841@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/318 +X-Sequence-Number: 7954 + +andrew@pillette.com writes: +> I'm still having trouble with slow cascading DELETEs. What commands can I issue to see the sequence of events that occurs after I execute +> DELETE FROM x WHERE p; +> so that I can see if indexes being used correctly, or I have a constraint I don't want, etc. + +I'd suggest starting a fresh backend, turning on log_statement, and then +issuing the DELETE. log_statement will log the queries generated by the +foreign-key triggers ... but only the first time through, because those +triggers cache the query plans. + +The queries you will see will be parameterized (they'll use $1,$2,etc). +You can use PREPARE and EXPLAIN ANALYZE EXECUTE to investigate what sort +of plans result. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 24 02:15:54 2004 +X-Original-To: pgsql-performance@postgresql.org +Received: from web54109.mail.yahoo.com (web54109.mail.yahoo.com + [206.190.37.244]) + by svr1.postgresql.org (Postfix) with SMTP id 82DB95E46FB + for ; + Tue, 24 Aug 2004 02:15:52 -0300 (ADT) +Message-ID: <20040824050842.56287.qmail@web54109.mail.yahoo.com> +Received: from [129.94.6.30] by web54109.mail.yahoo.com via HTTP; + Mon, 23 Aug 2004 22:08:42 PDT +Date: Mon, 23 Aug 2004 22:08:42 -0700 (PDT) +From: my ho +Subject: Re: postgresql performance with multimedia +To: Jan Wieck , my thi ho +Cc: pgsql-performance@postgresql.org +In-Reply-To: <41235543.7070303@Yahoo.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Archive-Number: 200408/319 +X-Sequence-Number: 7955 + + +--- Jan Wieck wrote: + +> On 8/17/2004 8:44 PM, my thi ho wrote: +> +> > Hi, +> > I am working on a project which explore postgresql +> to +> > store multimedia data. +> > In details, i am trying to work with the buffer +> > management part of postgres source code. And try +> to +> > improve the performance. I had search on the web +> but +> > could not find much usefull information. +> +> What version of PostgreSQL are you looking at? Note +> that the buffer +> cache replacement strategy was completely changed +> for version 8.0, which +> is currently in BETA test. A description of the +> algorithm can be found +> in the README file in src/backend/storage/bufmgr. + +oki, Thanks for the information. I have a look at 8.0 +beta, but cannot start the statistic collector. (I had +post this err message before for help, but havent +really got any clue to fix it) +> LOG: could not create IPv6 socket: Address family +not +> supported by protocol +> LOG: could not bind socket for statistics +collector: +> Cannot assign requested address +> LOG: disabling statistics collector for lack of +> working socket + +btw, what i want to ask here is does postgreSQL have +any kind of read-ahead buffer implemented? 'cos it +would be useful in multimedia case when we always scan +the large table for continous data. +Thanks +Ho + + + + + + +__________________________________ +Do you Yahoo!? +New and Improved Yahoo! Mail - 100MB free storage! +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Tue Aug 24 05:33:03 2004 +X-Original-To: pgsql-performance@postgresql.org +Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D90F65E46FE + for ; + Tue, 24 Aug 2004 05:32:49 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 548CD2BD63 + for ; + Tue, 24 Aug 2004 10:32:44 +0200 (SAST) +Received: from ucsns.ucs.co.za ([127.0.0.1]) + by localhost (ucsns.ucs.co.za [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 26247-08 for ; + Tue, 24 Aug 2004 10:32:40 +0200 (SAST) +Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) + by ucsns.ucs.co.za (Postfix) with ESMTP id C5CB22BD5C + for ; + Tue, 24 Aug 2004 10:32:40 +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 913D5DA74E + for ; + Tue, 24 Aug 2004 10:32:40 +0200 (SAST) +Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) + by jhb.ucs.co.za (Postfix) with SMTP id 9D048975A0 + for ; + Tue, 24 Aug 2004 10:32:40 +0200 (SAST) +Date: Tue, 24 Aug 2004 10:32:40 +0200 +From: Stef +To: pgsql-performance@postgresql.org +Subject: Query kills machine. +Message-Id: <20040824103240.4d909777@svb.ucs.co.za> +X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) +User-Agent: sillypheed-claws (anti-aliased) +X-Face: GFoC95e6r)_TTG>n~=uFLojP=O~4W@Ms]>:.DMm/')(z3\Mwj^XP@? + Q:3";lD.OM1"^mDu}2NJ@US:)dO:U*iY5EM50&Tx. +X-Operating-System: sid +X-X-X: _-^-_ +Mime-Version: 1.0 +Content-Type: multipart/mixed; + boundary="Multipart=_Tue__24_Aug_2004_10_32_40_+0200_maLgIszoscYKY=nc" +X-Virus-Scanned: by amavisd-new at ucs.co.za +X-Archive-Number: 200408/320 +X-Sequence-Number: 7956 + +This is a multi-part message in MIME format. + +--Multipart=_Tue__24_Aug_2004_10_32_40_+0200_maLgIszoscYKY=nc +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit + +Hi all, + +I've attached all the query in query.sql + +I'm using postgres 7.3.4 on Linux version 2.4.26-custom +( /proc/sys/vm/overcommit_memory = 0 this time ) + +free : + total used free shared buffers cached +Mem: 1810212 1767384 42828 0 5604 1663908 +-/+ buffers/cache: 97872 1712340 +Swap: 505912 131304 374608 + +After I rebuilt the database, the query was fast (28255.12 msec). +After one night's insertion into the tables that the query select from, +the query all of a sudden uses up all resources , and the kernel +starts swapping, and I haven't seen the query actually finish when +this happens. I did vacuum analyze AND reindex, but that doesn't +help. + +I attached the explain analyze of the query before this happens, and +the explain plan from when it actually happens that the query doesn't finish. + +The one noticeable difference, was that before, it used merge joins, and +after, it used hash joins. + +When the query was slow, I tried to : set enable_hashjoin to off +for this query, and the query finished relatively fast again (316245.16 msec) + +I attached the output of that explain analyze as well, as well as the postgres +settings. + +Can anyone shed some light on what's happening here. I can't figure it out. + +Kind Regards +Stefan + +--Multipart=_Tue__24_Aug_2004_10_32_40_+0200_maLgIszoscYKY=nc +Content-Type: application/octet-stream; + name="query.sql" +Content-Disposition: attachment; + filename="query.sql" +Content-Transfer-Encoding: base64 + +U0VMRUNUIHMuc2t1ICAgICAgICAgICAgICAgICAgQVMgU0tVLAogICAgICAg +cy5zdGt0eXBlX2NvZGUgICAgICAgICBBUyBTVEtUWVBFX0NPREUsCiAgICAg +ICBpLnNrdV9kZXNjciAgICAgICAgICAgIEFTIFNLVV9ERVNDUiwKICAgICAg +IGJyLmNsdXN0ZXJfY29kZSAgICAgICAgQVMgQ0xVU1RFUl9DT0RFLAogICAg +ICAgYnIuY2x1c3Rlcl9kZXNjciAgICAgICBBUyBDTFVTVEVSX0RFU0NSLAog +ICAgICAgTUFYKHMuY3Vycl9yc3BfY3IpICAgICBBUyBQUklDRSwKICAgICAg +IFNVTShzLnF0eV9vbl9oYW5kKSAgICAgQVMgU09ILAogICAgICBTVU0ocy5x +dHlfaW5fZ29vZHMgLSBzLnF0eV9pbl9zdXBwICsgcy5xdHlfb25fcmVwYWly +IAogICAgICApIEFTIFBMVVNfU1RPQ0tfSU4sCiAgICAgIFNVTShzLnF0eV9v +dXRfZ29vZHMpICAgQVMgTEVTU19TVE9DS19PVVQsCiAgICAgIFNVTShzLnF0 +eV9kcCkgICAgICAgICAgQVMgTEVTU19ESVNQTEFZLAogICAgICAoU1VNKHMu +cXR5X29uX2hhbmQpICsgU1VNKHMucXR5X2luX2dvb2RzIC0gcy5xdHlfaW5f +c3VwcCArIHMucXR5X29uX3JlcGFpciAgICAgICkgLSBzdW0ocy5xdHlfb3V0 +X2dvb2RzKSAtIHN1bShzLnF0eV9kcCkKICAgICAgKSBBUyBPVkVSU09MRCwK +ICAgICAgKHNlbGVjdCBjb2FsZXNjZShzdW0ob3V0X3F0eSksMCk6Om51bWVy +aWMgCiAgICAgICBmcm9tIGdpcl9vdXRzdGFuZGluZyAKICAgICAgIHdoZXJl +IGNsdXN0ZXJfYnJuID0gYnIuY2x1c3Rlcl9jb2RlIAogICAgICAgYW5kIHNr +dSA9IHMuc2t1IAogICAgICAgYW5kIHN0a3R5cGVfY29kZSA9IHMuc3RrdHlw +ZV9jb2RlCiAgICAgICkgIEFTIFNDX1NUS19PTl9PUkRFUiwKICAgICAgY2Fz +ZSB3aGVuIChzdW0ocy5xdHlfb25faGFuZCkgKyAKICAgICAgICAgICAgICAg +ICBzdW0ocy5xdHlfaW5fZ29vZHMgLSBzLnF0eV9pbl9zdXBwICsgcy5xdHlf +b25fcmVwYWlyKSAtIAogICAgICAgICAgICAgICAgIHN1bShzLnF0eV9kcCkg +LSAKICAgICAgICAgICAgICAgICBzdW0ocy5xdHlfb3V0X2dvb2RzKSArCgkJ +IChzZWxlY3QgY29hbGVzY2Uoc3VtKG91dF9xdHkpLDApOjpudW1lcmljCgkJ +IGZyb20gZ2lyX291dHN0YW5kaW5nCiAgICAgICAgICAgICAgICAgd2hlcmUg +Y2x1c3Rlcl9icm4gPSBici5jbHVzdGVyX2NvZGUKICAgICAgICAgICAgICAg +ICBhbmQgc2t1ID0gcy5za3UKICAgICAgICAgICAgICAgICBhbmQgc3RrdHlw +ZV9jb2RlID0gcy5zdGt0eXBlX2NvZGUpCiAgICAgICAgICAgICAgICApIDwg +MCAKICAgICAgICAgIHRoZW4gYWJzKHN1bShzLnF0eV9vbl9oYW5kKSArIAog +ICAgICAgICAgICAgICBzdW0ocy5xdHlfaW5fZ29vZHMgLSBzLnF0eV9pbl9z +dXBwICsgcy5xdHlfb25fcmVwYWlyKSAtIAogICAgICAgICAgICAgICBzdW0o +cy5xdHlfZHApIC0gCiAgICAgICAgICAgICAgIHN1bShzLnF0eV9vdXRfZ29v +ZHMpICsKICAgICAgICAgICAgICAgKHNlbGVjdCBjb2FsZXNjZShzdW0ob3V0 +X3F0eSksMCk6Om51bWVyaWMKICAgICAgICAgICAgICAgZnJvbSBnaXJfb3V0 +c3RhbmRpbmcKICAgICAgICAgICAgICAgd2hlcmUgY2x1c3Rlcl9icm4gPSBi +ci5jbHVzdGVyX2NvZGUKICAgICAgICAgICAgICAgYW5kIHNrdSA9IHMuc2t1 +CiAgICAgICAgICAgICAgIGFuZCBzdGt0eXBlX2NvZGUgPSBzLnN0a3R5cGVf +Y29kZSkKCQkgICkgCiAgICAgICAgICBlbHNlIDAgCiAgICAgIGVuZCBBUyBP +UkRFUl9SUVJELAogICAgICAoICAgU0VMRUNUICBjb2FsZXNjZShzdW0oay5x +dHlfb25faGFuZCksMCkKICAgICAgICAgIEZST00gICAgc3Rtc3Rfc2t1IGss +IAogICAgICAgICAgICAgICAgICBtYXN0ZXJfYnJhbmNoX2Rlc2NyIGIKICAg +ICAgICAgIFdIRVJFICAgay5icm5fY29kZSA9IGIuYnJuX2NvZGUKICAgICAg +ICAgIEFORCAgICAgay5za3UgPSBzLnNrdQogICAgICAgICAgQU5EICAgICBr +LnN0a3R5cGVfY29kZSA9IHMuc3RrdHlwZV9jb2RlCiAgICAgICAgICBBTkQg +ICAgIGIuYnJuX2NvZGUgPD4gIGIuY2x1c3Rlcl9jb2RlCiAgICAgICAgICBB +TkQgICAgIGIuY2x1c3Rlcl9jb2RlID0gIGJyLmNsdXN0ZXJfY29kZQogICAg +ICAgICAgQU5EICAgICBrLmZwcF9jb2RlID0gJzIwMDQwOCcKICAgICAgKSBB +UyBCUl9TT0gKRlJPTSAgIHN0bXN0X3NrdSBzLCAKICAgICAgIG1hc3Rlcl9i +cmFuY2hfZGVzY3IgYnIsCiAgICAgICBtYXN0ZXJfc2t1X2Rlc2NyIGksCiAg +ICAgICBvbGRfc2t1IG9zCldIRVJFICBzLnNrdSA9IGkuc2t1CkFORCAgICBz +LmJybl9jb2RlID0gYnIuYnJuX2NvZGUKQU5EICAgIHMuZnBwX2NvZGUgPSAn +MjAwNDA4JwpBTkQgICAgcy5ncm91cF9jb2RlID0gaS5ncm91cF9jb2RlCkFO +RCAgICBpLnNrdSA9IG9zLnNrdQpBTkQgICAgYnIuY2x1c3Rlcl9jb2RlID0g +b3MuY2x1c3Rlcl9icm4KR1JPVVAgQlkgcy5za3UsCiAgICAgICAgIHMuc3Rr +dHlwZV9jb2RlLAogICAgICAgICBpLnNrdV9kZXNjciwKICAgICAgICAgYnIu +Y2x1c3Rlcl9jb2RlLAogICAgICAgICBici5jbHVzdGVyX2Rlc2NyCkhBVklO +RyAoKHN1bShzLnF0eV9vbl9oYW5kKSArIHN1bShzLnF0eV9pbl9nb29kcykg +LSBzdW0ocy5xdHlfZHApIC0gc3VtKHMucXR5X291dF9nb29kcykpIDwgMCk7 +Cg== + +--Multipart=_Tue__24_Aug_2004_10_32_40_+0200_maLgIszoscYKY=nc +Content-Type: text/plain; + name="explain_analyze_before.txt" +Content-Disposition: attachment; + filename="explain_analyze_before.txt" +Content-Transfer-Encoding: 7bit + + Aggregate (cost=87597.84..89421.82 rows=2702 width=484) (actual time=22727.88..28164.74 rows=12040 loops=1) + Filter: ((((sum(qty_on_hand) + sum(qty_in_goods)) - sum(qty_dp)) - sum(qty_out_goods)) < 0::numeric) + -> Group (cost=87597.84..88003.17 rows=27022 width=484) (actual time=22727.45..23242.01 rows=42705 loops=1) + -> Sort (cost=87597.84..87665.40 rows=27022 width=484) (actual time=22727.43..22756.74 rows=42705 loops=1) + Sort Key: s.sku, s.stktype_code, i.sku_descr, br.cluster_code, br.cluster_descr + -> Merge Join (cost=84388.96..85608.78 rows=27022 width=484) (actual time=20303.41..21814.25 rows=42705 loops=1) + Merge Cond: (("outer".group_code = "inner".group_code) AND ("outer".sku = "inner".sku)) + -> Sort (cost=64472.34..64489.67 rows=6930 width=388) (actual time=16503.56..16530.23 rows=42705 loops=1) + Sort Key: s.group_code, os.sku + -> Merge Join (cost=63006.13..64030.25 rows=6930 width=388) (actual time=14394.48..15794.71 rows=42705 loops=1) + Merge Cond: (("outer".cluster_brn = "inner".cluster_code) AND ("outer".sku = "inner".sku)) + -> Index Scan using old_sku_uidx1 on old_sku os (cost=0.00..797.79 rows=17799 width=64) (actual time=0.02..47.66 rows=17799 loops=1) + -> Sort (cost=63006.13..63045.07 rows=15574 width=324) (actual time=14393.77..14556.50 rows=132703 loops=1) + Sort Key: br.cluster_code, s.sku + -> Merge Join (cost=61645.75..61921.64 rows=15574 width=324) (actual time=4862.56..6078.94 rows=132703 loops=1) + Merge Cond: ("outer".brn_code = "inner".brn_code) + -> Sort (cost=61587.79..61626.73 rows=15574 width=228) (actual time=4859.23..5043.43 rows=132703 loops=1) + Sort Key: s.brn_code + -> Index Scan using stmst_sku_idx4 on stmst_sku s (cost=0.00..60503.30 rows=15574 width=228) (actual time=0.07..1078.30 rows=132703 loops=1) + Index Cond: (fpp_code = '200408'::text) + -> Sort (cost=57.96..59.62 rows=667 width=96) (actual time=3.26..91.93 rows=133005 loops=1) + Sort Key: br.brn_code + -> Seq Scan on master_branch_descr br (cost=0.00..26.67 rows=667 width=96) (actual time=0.02..1.13 rows=667 loops=1) + -> Sort (cost=19916.61..20306.53 rows=155968 width=96) (actual time=3797.71..3914.26 rows=184223 loops=1) + Sort Key: i.group_code, i.sku + -> Seq Scan on master_sku_descr i (cost=0.00..6463.68 rows=155968 width=96) (actual time=0.01..293.74 rows=155968 loops=1) + SubPlan + -> Aggregate (cost=6.02..6.02 rows=1 width=8) (actual time=0.04..0.04 rows=1 loops=14456) + -> Index Scan using gir_oustanding_idx1 on gir_outstanding (cost=0.00..6.01 rows=1 width=8) (actual time=0.03..0.03 rows=0 loops=14456) + Index Cond: ((cluster_brn = $0) AND (sku = $1) AND (stktype_code = $2)) + -> Aggregate (cost=6.02..6.02 rows=1 width=8) (actual time=0.04..0.04 rows=1 loops=14456) + -> Index Scan using gir_oustanding_idx1 on gir_outstanding (cost=0.00..6.01 rows=1 width=8) (actual time=0.03..0.03 rows=0 loops=14456) + Index Cond: ((cluster_brn = $0) AND (sku = $1) AND (stktype_code = $2)) + -> Aggregate (cost=6.02..6.02 rows=1 width=8) (actual time=0.03..0.03 rows=1 loops=12031) + -> Index Scan using gir_oustanding_idx1 on gir_outstanding (cost=0.00..6.01 rows=1 width=8) (actual time=0.03..0.03 rows=0 loops=12031) + Index Cond: ((cluster_brn = $0) AND (sku = $1) AND (stktype_code = $2)) + -> Aggregate (cost=11.96..11.96 rows=1 width=82) (actual time=0.16..0.16 rows=1 loops=14456) + -> Nested Loop (cost=0.00..11.95 rows=1 width=82) (actual time=0.08..0.15 rows=3 loops=14456) + -> Index Scan using stmst_sku_idx3 on stmst_sku k (cost=0.00..6.02 rows=1 width=50) (actual time=0.06..0.08 rows=3 loops=14456) + Index Cond: ((fpp_code = '200408'::text) AND (sku = $1) AND (stktype_code = $2)) + -> Index Scan using master_branch_descr_pkey on master_branch_descr b (cost=0.00..5.92 rows=1 width=32) (actual time=0.02..0.02 rows=1 loops=42705) + Index Cond: ("outer".brn_code = b.brn_code) + Filter: ((brn_code <> cluster_code) AND (cluster_code = $0)) + Total runtime: 28255.12 msec +(44 rows) + + +--Multipart=_Tue__24_Aug_2004_10_32_40_+0200_maLgIszoscYKY=nc +Content-Type: text/plain; + name="explain_after.txt" +Content-Disposition: attachment; + filename="explain_after.txt" +Content-Transfer-Encoding: 7bit + + Aggregate (cost=316107.28..316114.91 rows=11 width=322) + Filter: ((((sum(qty_on_hand) + sum(qty_in_goods)) - sum(qty_dp)) - sum(qty_out_goods)) < 0::numeric) + -> Group (cost=316107.28..316108.98 rows=113 width=322) + -> Sort (cost=316107.28..316107.57 rows=113 width=322) + Sort Key: s.sku, s.stktype_code, i.sku_descr, br.cluster_code, br.cluster_descr + -> Hash Join (cost=308622.49..316103.43 rows=113 width=322) + Hash Cond: ("outer".sku = "inner".sku) + Join Filter: ("inner".group_code = "outer".group_code) + -> Seq Scan on master_sku_descr i (cost=0.00..6467.08 rows=156008 width=96) + -> Hash (cost=308618.04..308618.04 rows=1781 width=226) + -> Hash Join (cost=1698.78..308618.04 rows=1781 width=226) + Hash Cond: ("outer".sku = "inner".sku) + Join Filter: ("outer".brn_code = "inner".brn_code) + -> Seq Scan on stmst_sku s (cost=0.00..284677.69 rows=356150 width=106) + Filter: (fpp_code = '200408'::text) + -> Hash (cost=1550.41..1550.41 rows=59347 width=120) + -> Merge Join (cost=57.89..1550.41 rows=59347 width=120) + Merge Cond: ("outer".cluster_brn = "inner".cluster_code) + -> Index Scan using old_sku_uidx1 on old_sku os (cost=0.00..702.79 rows=17822 width=24) + -> Sort (cost=57.89..59.56 rows=666 width=96) + Sort Key: br.cluster_code + -> Seq Scan on master_branch_descr br (cost=0.00..26.66 rows=666 width=96) + SubPlan + -> Aggregate (cost=23.73..23.73 rows=1 width=8) + -> Index Scan using gir_oustanding_idx1 on gir_outstanding (cost=0.00..23.70 rows=6 width=8) + Index Cond: ((cluster_brn = $0) AND (sku = $1) AND (stktype_code = $2)) + -> Aggregate (cost=23.73..23.73 rows=1 width=8) + -> Index Scan using gir_oustanding_idx1 on gir_outstanding (cost=0.00..23.70 rows=6 width=8) + Index Cond: ((cluster_brn = $0) AND (sku = $1) AND (stktype_code = $2)) + -> Aggregate (cost=23.73..23.73 rows=1 width=8) + -> Index Scan using gir_oustanding_idx1 on gir_outstanding (cost=0.00..23.70 rows=6 width=8) + Index Cond: ((cluster_brn = $0) AND (sku = $1) AND (stktype_code = $2)) + -> Aggregate (cost=32.16..32.16 rows=1 width=50) + -> Merge Join (cost=32.11..32.15 rows=1 width=50) + Merge Cond: ("outer".brn_code = "inner".brn_code) + -> Sort (cost=14.38..14.39 rows=3 width=32) + Sort Key: b.brn_code + -> Index Scan using master_branch_descr_idx6 on master_branch_descr b (cost=0.00..14.35 rows=3 width=32) + Index Cond: (cluster_code = $0) + Filter: (brn_code <> cluster_code) + -> Sort (cost=17.73..17.74 rows=4 width=18) + Sort Key: k.brn_code + -> Index Scan using stmst_sku_idx3 on stmst_sku k (cost=0.00..17.69 rows=4 width=18) + Index Cond: ((fpp_code = '200408'::text) AND (sku = $1) AND (stktype_code = $2)) +(44 rows) + +--Multipart=_Tue__24_Aug_2004_10_32_40_+0200_maLgIszoscYKY=nc +Content-Type: text/plain; + name="explain_analyze_after_hashjoin_off.txt" +Content-Disposition: attachment; + filename="explain_analyze_after_hashjoin_off.txt" +Content-Transfer-Encoding: 7bit + + Aggregate (cost=354420.02..354427.65 rows=11 width=322) (actual time=246825.06..316125.53 rows=12050 loops=1) + Filter: ((((sum(qty_on_hand) + sum(qty_in_goods)) - sum(qty_dp)) - sum(qty_out_goods)) < 0::numeric) + -> Group (cost=354420.02..354421.72 rows=113 width=322) (actual time=246701.96..247283.96 rows=42930 loops=1) + -> Sort (cost=354420.02..354420.30 rows=113 width=322) (actual time=246701.94..246736.97 rows=42930 loops=1) + Sort Key: s.sku, s.stktype_code, i.sku_descr, br.cluster_code, br.cluster_descr + -> Merge Join (cost=354298.16..354416.17 rows=113 width=322) (actual time=245205.55..245634.53 rows=42930 loops=1) + Merge Cond: (("outer".brn_code = "inner".brn_code) AND ("outer".cluster_brn = "inner".cluster_code)) + -> Sort (cost=354240.27..354296.76 rows=22595 width=226) (actual time=245179.07..245205.75 rows=42930 loops=1) + Sort Key: s.brn_code, os.cluster_brn + -> Merge Join (cost=348924.92..352606.20 rows=22595 width=226) (actual time=241551.96..244357.21 rows=42930 loops=1) + Merge Cond: ("outer".sku = "inner".sku) + -> Merge Join (cost=348924.92..351824.65 rows=22595 width=202) (actual time=241500.21..243397.42 rows=132883 loops=1) + Merge Cond: (("outer".sku = "inner".sku) AND ("outer".group_code = "inner".group_code)) + -> Sort (cost=329001.17..329891.54 rows=356150 width=106) (actual time=238575.25..238742.16 rows=132883 loops=1) + Sort Key: s.sku, s.group_code + -> Seq Scan on stmst_sku s (cost=0.00..284677.69 rows=356150 width=106) (actual time=219190.28..235315.66 rows=132883 loops=1) + Filter: (fpp_code = '200408'::text) + -> Sort (cost=19923.75..20313.77 rows=156008 width=96) (actual time=2924.57..3048.34 rows=185259 loops=1) + Sort Key: i.sku, i.group_code + -> Seq Scan on master_sku_descr i (cost=0.00..6467.08 rows=156008 width=96) (actual time=1.62..976.63 rows=156008 loops=1) + -> Index Scan using old_sku_idx1 on old_sku os (cost=0.00..398.04 rows=17822 width=24) (actual time=49.45..209.45 rows=46294 loops=1) + -> Sort (cost=57.89..59.56 rows=666 width=96) (actual time=26.41..54.70 rows=43232 loops=1) + Sort Key: br.brn_code, br.cluster_code + -> Seq Scan on master_branch_descr br (cost=0.00..26.66 rows=666 width=96) (actual time=8.04..24.21 rows=666 loops=1) + SubPlan + -> Aggregate (cost=23.73..23.73 rows=1 width=8) (actual time=0.06..0.06 rows=1 loops=14481) + -> Index Scan using gir_oustanding_idx1 on gir_outstanding (cost=0.00..23.70 rows=6 width=8) (actual time=0.04..0.05 rows=0 loops=14481) + Index Cond: ((cluster_brn = $0) AND (sku = $1) AND (stktype_code = $2)) + -> Aggregate (cost=23.73..23.73 rows=1 width=8) (actual time=0.04..0.04 rows=1 loops=14481) + -> Index Scan using gir_oustanding_idx1 on gir_outstanding (cost=0.00..23.70 rows=6 width=8) (actual time=0.03..0.03 rows=0 loops=14481) + Index Cond: ((cluster_brn = $0) AND (sku = $1) AND (stktype_code = $2)) + -> Aggregate (cost=23.73..23.73 rows=1 width=8) (actual time=0.03..0.03 rows=1 loops=12042) + -> Index Scan using gir_oustanding_idx1 on gir_outstanding (cost=0.00..23.70 rows=6 width=8) (actual time=0.03..0.03 rows=0 loops=12042) + Index Cond: ((cluster_brn = $0) AND (sku = $1) AND (stktype_code = $2)) + -> Aggregate (cost=32.16..32.16 rows=1 width=50) (actual time=4.53..4.53 rows=1 loops=14481) + -> Merge Join (cost=32.11..32.15 rows=1 width=50) (actual time=4.45..4.52 rows=3 loops=14481) + Merge Cond: ("outer".brn_code = "inner".brn_code) + -> Sort (cost=14.38..14.39 rows=3 width=32) (actual time=3.84..4.01 rows=271 loops=14481) + Sort Key: b.brn_code + -> Index Scan using master_branch_descr_idx6 on master_branch_descr b (cost=0.00..14.35 rows=3 width=32) (actual time=0.02..2.14 rows=564 loops=14481) + Index Cond: (cluster_code = $0) + Filter: (brn_code <> cluster_code) + -> Sort (cost=17.73..17.74 rows=4 width=18) (actual time=0.14..0.14 rows=3 loops=14481) + Sort Key: k.brn_code + -> Index Scan using stmst_sku_idx3 on stmst_sku k (cost=0.00..17.69 rows=4 width=18) (actual time=0.08..0.11 rows=3 loops=14481) + Index Cond: ((fpp_code = '200408'::text) AND (sku = $1) AND (stktype_code = $2)) + Total runtime: 316245.16 msec +(47 rows) + +--Multipart=_Tue__24_Aug_2004_10_32_40_+0200_maLgIszoscYKY=nc +Content-Type: text/plain; + name="settings.txt" +Content-Disposition: attachment; + filename="settings.txt" +Content-Transfer-Encoding: 7bit + +shared_buffers = 110592 +wal_buffers = 400 +sort_mem = 30720 +vacuum_mem = 10240 +checkpoint_segments = 30 +commit_delay = 5000 +commit_siblings = 100 +effective_cache_size = 201413 + +--Multipart=_Tue__24_Aug_2004_10_32_40_+0200_maLgIszoscYKY=nc +Content-Type: application/octet-stream; + name="stmst_sku.sql" +Content-Disposition: attachment; + filename="stmst_sku.sql" +Content-Transfer-Encoding: base64 + +ICAgICAgICAgICAgICAgICAgVGFibGUgInB1YmxpYy5zdG1zdF9za3UiCiAg +ICAgICAgICBDb2x1bW4gICAgICAgICAgfCAgICAgICAgIFR5cGUgICAgICAg +ICB8IE1vZGlmaWVycyAKLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0rLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLQogZnBwX2NvZGUgICAg +ICAgICAgICAgICAgIHwgdGV4dCAgICAgICAgICAgICAgICAgfCBub3QgbnVs +bAogYnJuX2NvZGUgICAgICAgICAgICAgICAgIHwgdGV4dCAgICAgICAgICAg +ICAgICAgfCBub3QgbnVsbAogc2t1ICAgICAgICAgICAgICAgICAgICAgIHwg +dGV4dCAgICAgICAgICAgICAgICAgfCBub3QgbnVsbAogZ3JvdXBfY29kZSAg +ICAgICAgICAgICAgIHwgdGV4dCAgICAgICAgICAgICAgICAgfCBub3QgbnVs +bAogcXR5X29uX2hhbmQgICAgICAgICAgICAgIHwgbnVtZXJpYygxNiwzKSAg +ICAgICAgfCAKIHF0eV9vbl9pbmQgICAgICAgICAgICAgICB8IG51bWVyaWMo +MTYsMykgICAgICAgIHwgCiBxdHlfb25fcmVwYWlyICAgICAgICAgICAgfCBu +dW1lcmljKDE2LDMpICAgICAgICB8IAogcXR5X29uX2xvYW4gICAgICAgICAg +ICAgIHwgbnVtZXJpYygxNiwzKSAgICAgICAgfCAKIHF0eV9pbl9icm4gICAg +ICAgICAgICAgICB8IG51bWVyaWMoMTYsMykgICAgICAgIHwgCiBxdHlfb3V0 +X2JybiAgICAgICAgICAgICAgfCBudW1lcmljKDE2LDMpICAgICAgICB8IAog +cXR5X2luX2N1cyAgICAgICAgICAgICAgIHwgbnVtZXJpYygxNiwzKSAgICAg +ICAgfCAKIHF0eV9vdXRfY3VzICAgICAgICAgICAgICB8IG51bWVyaWMoMTYs +MykgICAgICAgIHwgCiBxdHlfaW5fc3VwcCAgICAgICAgICAgICAgfCBudW1l +cmljKDE2LDMpICAgICAgICB8IAogcXR5X291dF9zdXBwICAgICAgICAgICAg +IHwgbnVtZXJpYygxNiwzKSAgICAgICAgfCAKIHF0eV9pbl9vdGggICAgICAg +ICAgICAgICB8IG51bWVyaWMoMTYsMykgICAgICAgIHwgCiBxdHlfb3V0X290 +aCAgICAgICAgICAgICAgfCBudW1lcmljKDE2LDMpICAgICAgICB8IAogcXR5 +X2luX2dvb2RzICAgICAgICAgICAgIHwgbnVtZXJpYygxNiwzKSAgICAgICAg +fCAKIHF0eV9vdXRfZ29vZHMgICAgICAgICAgICB8IG51bWVyaWMoMTYsMykg +ICAgICAgIHwgCiBzdGt0eXBlX2NvZGUgICAgICAgICAgICAgfCBjaGFyYWN0 +ZXIgdmFyeWluZygyKSB8IAogdGF4X2NvZGUgICAgICAgICAgICAgICAgIHwg +dGV4dCAgICAgICAgICAgICAgICAgfCAKIGN1cnJfY3N0ICAgICAgICAgICAg +ICAgICB8IG51bWVyaWMoMTYsMykgICAgICAgIHwgCiBjdXJyX2NzdF9sICAg +ICAgICAgICAgICAgfCBudW1lcmljKDE2LDMpICAgICAgICB8IAogY3Vycl9y +c3BfY2EgICAgICAgICAgICAgIHwgbnVtZXJpYygxNiwzKSAgICAgICAgfCAK +IGN1cnJfcnNwX2NhX2wgICAgICAgICAgICB8IG51bWVyaWMoMTYsMykgICAg +ICAgIHwgCiBjdXJyX3JzcF9jciAgICAgICAgICAgICAgfCBudW1lcmljKDE2 +LDMpICAgICAgICB8IAogY3Vycl9yc3BfY3JfbCAgICAgICAgICAgIHwgbnVt +ZXJpYygxNiwzKSAgICAgICAgfCAKIG10aF9zbHNfcXR5ICAgICAgICAgICAg +ICB8IG51bWVyaWMoMTYsMykgICAgICAgIHwgCiBtdGhfc2xzX2NzdCAgICAg +ICAgICAgICAgfCBudW1lcmljKDE2LDMpICAgICAgICB8IAogbXRoX3Nsc19j +c3RfbCAgICAgICAgICAgIHwgbnVtZXJpYygxNiwzKSAgICAgICAgfCAKIG10 +aF9zbHNfZGlzYyAgICAgICAgICAgICB8IG51bWVyaWMoMTYsMykgICAgICAg +IHwgCiBtdGhfc2xzX2Rpc2NfbCAgICAgICAgICAgfCBudW1lcmljKDE2LDMp +ICAgICAgICB8IAogbXRoX3Nsc19uZXR0X2V4Y2wgICAgICAgIHwgbnVtZXJp +YygxNiwzKSAgICAgICAgfCAKIG10aF9zbHNfbmV0dF9leGNsX2wgICAgICB8 +IG51bWVyaWMoMTYsMykgICAgICAgIHwgCiBtYXhfaG9sZF9xdHkgICAgICAg +ICAgICAgfCBudW1lcmljKDE2LDMpICAgICAgICB8IAogbWluX2hvbGRfcXR5 +ICAgICAgICAgICAgIHwgbnVtZXJpYygxNiwzKSAgICAgICAgfCAKIHF0eV9v +bl9ob2xkICAgICAgICAgICAgICB8IG51bWVyaWMoMTYsMykgICAgICAgIHwg +CiBxdHlfZHAgICAgICAgICAgICAgICAgICAgfCBudW1lcmljKDE2LDMpICAg +ICAgICB8IAogbXRoX3Nsc19xdHlfdW5kICAgICAgICAgIHwgbnVtZXJpYygx +NiwzKSAgICAgICAgfCBkZWZhdWx0IDAKIG10aF9zbHNfY3N0X3VuZCAgICAg +ICAgICB8IG51bWVyaWMoMTYsMykgICAgICAgIHwgZGVmYXVsdCAwCiBtdGhf +c2xzX2NzdF9sX3VuZCAgICAgICAgfCBudW1lcmljKDE2LDMpICAgICAgICB8 +IGRlZmF1bHQgMAogbXRoX3Nsc19kaXNjX3VuZCAgICAgICAgIHwgbnVtZXJp +YygxNiwzKSAgICAgICAgfCBkZWZhdWx0IDAKIG10aF9zbHNfZGlzY19sX3Vu +ZCAgICAgICB8IG51bWVyaWMoMTYsMykgICAgICAgIHwgZGVmYXVsdCAwCiBt +dGhfc2xzX25ldHRfZXhjbF91bmQgICAgfCBudW1lcmljKDE2LDMpICAgICAg +ICB8IGRlZmF1bHQgMAogbXRoX3Nsc19uZXR0X2V4Y2xfbF91bmQgIHwgbnVt +ZXJpYygxNiwzKSAgICAgICAgfCBkZWZhdWx0IDAKIHF0eV9pbl9icl9kb21i +ICAgICAgICAgICB8IG51bWVyaWMoMTYsMykgICAgICAgIHwgZGVmYXVsdCAw +CiBxdHlfb3V0X2N1c19icl9vd25fZGVsICAgfCBudW1lcmljKDE2LDMpICAg +ICAgICB8IGRlZmF1bHQgMAogbWF0X3Nsc19xdHkgICAgICAgICAgICAgIHwg +bnVtZXJpYygxNiwzKSAgICAgICAgfCAKIHl0ZF9zbHNfcXR5ICAgICAgICAg +ICAgICB8IG51bWVyaWMoMTYsMykgICAgICAgIHwgCiBtYXRfc2xzX2NzdCAg +ICAgICAgICAgICAgfCBudW1lcmljKDE2LDMpICAgICAgICB8IAogeXRkX3Ns +c19jc3QgICAgICAgICAgICAgIHwgbnVtZXJpYygxNiwzKSAgICAgICAgfCAK +IG1hdF9zbHNfZGlzYyAgICAgICAgICAgICB8IG51bWVyaWMoMTYsMykgICAg +ICAgIHwgCiB5dGRfc2xzX2Rpc2MgICAgICAgICAgICAgfCBudW1lcmljKDE2 +LDMpICAgICAgICB8IAogbWF0X3Nsc19uZXR0X2V4Y2wgICAgICAgIHwgbnVt +ZXJpYygxNiwzKSAgICAgICAgfCAKIHl0ZF9zbHNfbmV0dF9leGNsICAgICAg +ICB8IG51bWVyaWMoMTYsMykgICAgICAgIHwgCiBseV9tdGhfc2xzX25ldHRf +ZXhjbCAgICAgfCBudW1lcmljKDE2LDMpICAgICAgICB8IAogbHlfeXRkX3Ns +c19uZXR0X2V4Y2wgICAgIHwgbnVtZXJpYygxNiwzKSAgICAgICAgfCAKIHN0 +a190dXJuX3F0eV9vbl9oYW5kX2NzdCB8IG51bWVyaWMoMTYsMykgICAgICAg +IHwgCiBub19tdGhzX2hpc3RvcnkgICAgICAgICAgfCBpbnRlZ2VyICAgICAg +ICAgICAgICB8IGRlZmF1bHQgMApJbmRleGVzOiBzdG1zdF9za3VfcGsgcHJp +bWFyeSBrZXkgYnRyZWUgKGZwcF9jb2RlLCBicm5fY29kZSwgc2t1KSwKICAg +ICAgICAgc3Rtc3Rfc2t1X2lkeDUgdW5pcXVlIGJ0cmVlIChmcHBfY29kZSwg +YnJuX2NvZGUsIHNrdSwgZ3JvdXBfY29kZSwgc3RrdHlwZV9jb2RlKSwKICAg +ICAgICAgc3Rtc3RfZmZwX2Jybl9za3VfaWR4IGJ0cmVlIChmcHBfY29kZSwg +YnJuX2NvZGUsIHNrdSksCiAgICAgICAgIHN0bXN0X3NrdV9pZHgxIGJ0cmVl +IChza3UsIGJybl9jb2RlKSwKICAgICAgICAgc3Rtc3Rfc2t1X2lkeDIgYnRy +ZWUgKGZwcF9jb2RlLCBicm5fY29kZSksCiAgICAgICAgIHN0bXN0X3NrdV9p +ZHgzIGJ0cmVlIChmcHBfY29kZSwgc2t1LCBzdGt0eXBlX2NvZGUpLAogICAg +ICAgICBzdG1zdF9za3VfaWR4NCBidHJlZSAoZnBwX2NvZGUpLAogICAgICAg +ICBzdG1zdF9za3VfaWR4NyBidHJlZSAoYnJuX2NvZGUpLAogICAgICAgICBz +dG1zdF9za3VfaWR4OCBidHJlZSAoc3RrdHlwZV9jb2RlKSwKICAgICAgICAg +c3Rtc3Rfc2t1X3VpZHgxIGJ0cmVlIChmcHBfY29kZSwgc2t1LCBicm5fY29k +ZSwgc3RrdHlwZV9jb2RlKQpGb3JlaWduIEtleSBjb25zdHJhaW50czogc3Rt +c3Rfc2t1X2ZrIEZPUkVJR04gS0VZIChncm91cF9jb2RlLCBza3UpIFJFRkVS +RU5DRVMgaXRlbShncm91cF9jb2RlLCBza3UpIE9OIFVQREFURSBOTyBBQ1RJ +T04gT04gREVMRVRFIE5PIEFDVElPTgoKICBjb3VudCAgCi0tLS0tLS0tLQog +MzExNTAxNQooMSByb3cpCgo= + +--Multipart=_Tue__24_Aug_2004_10_32_40_+0200_maLgIszoscYKY=nc +Content-Type: application/octet-stream; + name="old_sku.sql" +Content-Disposition: attachment; + filename="old_sku.sql" +Content-Transfer-Encoding: base64 + +ICAgICBUYWJsZSAicHVibGljLm9sZF9za3UiCiAgIENvbHVtbiAgICB8IFR5 +cGUgfCBNb2RpZmllcnMgCi0tLS0tLS0tLS0tLS0rLS0tLS0tKy0tLS0tLS0t +LS0tCiBjbHVzdGVyX2JybiB8IHRleHQgfCAKIHNrdSAgICAgICAgIHwgdGV4 +dCB8IApJbmRleGVzOiBvbGRfc2t1X3VpZHgxIHVuaXF1ZSBidHJlZSAoY2x1 +c3Rlcl9icm4sIHNrdSksCiAgICAgICAgIG9sZF9za3VfaWR4MSBidHJlZSAo +c2t1KQoKIGNvdW50IAotLS0tLS0tCiAxNzgyMgooMSByb3cpCgo= + +--Multipart=_Tue__24_Aug_2004_10_32_40_+0200_maLgIszoscYKY=nc +Content-Type: application/octet-stream; + name="master_sku_descr.sql" +Content-Disposition: attachment; + filename="master_sku_descr.sql" +Content-Transfer-Encoding: base64 + +ICBUYWJsZSAicHVibGljLm1hc3Rlcl9za3VfZGVzY3IiCiAgICAgQ29sdW1u +ICAgICB8IFR5cGUgfCBNb2RpZmllcnMgCi0tLS0tLS0tLS0tLS0tLS0rLS0t +LS0tKy0tLS0tLS0tLS0tCiBncm91cF9jb2RlICAgICB8IHRleHQgfCAKIHNr +dSAgICAgICAgICAgIHwgdGV4dCB8IAogc2t1X2Rlc2NyICAgICAgfCB0ZXh0 +IHwgCiBkZXBfY29kZSAgICAgICB8IHRleHQgfCAKIGRlcF9kZXNjciAgICAg +IHwgdGV4dCB8IAogY2F0X2NvZGUgICAgICAgfCB0ZXh0IHwgCiBjYXRfZGVz +Y3IgICAgICB8IHRleHQgfCAKIHN1YmNhdF9jb2RlICAgIHwgdGV4dCB8IAog +c3ViY2F0X2Rlc2NyICAgfCB0ZXh0IHwgCiBjb250cm9sX2NvZGUgICB8IHRl +eHQgfCAKIGNvbnRyb2xfZGVzY3IgIHwgdGV4dCB8IAogc3VwcGxpZXJfY29k +ZSAgfCB0ZXh0IHwgCiBzdXBwbGllcl9kZXNjciB8IHRleHQgfCAKSW5kZXhl +czogbWFzdGVyX3NrdV9kZXNjcl91aWR4MSB1bmlxdWUgYnRyZWUgKHNrdSwg +Z3JvdXBfY29kZSksCiAgICAgICAgIG1hc3Rlcl9za3VfZGVzY3JfaWR4MSBi +dHJlZSAoZ3JvdXBfY29kZSwgc2t1LCBjb250cm9sX2NvZGUpLAogICAgICAg +ICBtYXN0ZXJfc2t1X2Rlc2NyX2lkeDEwIGJ0cmVlIChzdWJjYXRfY29kZSks +CiAgICAgICAgIG1hc3Rlcl9za3VfZGVzY3JfaWR4MTEgYnRyZWUgKGNvbnRy +b2xfY29kZSksCiAgICAgICAgIG1hc3Rlcl9za3VfZGVzY3JfaWR4MTIgYnRy +ZWUgKGNvbnRyb2xfZGVzY3IpLAogICAgICAgICBtYXN0ZXJfc2t1X2Rlc2Ny +X2lkeDEzIGJ0cmVlIChzdXBwbGllcl9jb2RlKSwKICAgICAgICAgbWFzdGVy +X3NrdV9kZXNjcl9pZHgxNCBidHJlZSAoc3VwcGxpZXJfZGVzY3IpLAogICAg +ICAgICBtYXN0ZXJfc2t1X2Rlc2NyX2lkeDIgYnRyZWUgKGdyb3VwX2NvZGUs +IHNrdSwgZGVwX2NvZGUsIGNhdF9jb2RlLCBzdWJjYXRfY29kZSwgY29udHJv +bF9jb2RlKSwKICAgICAgICAgbWFzdGVyX3NrdV9kZXNjcl9pZHgzIGJ0cmVl +IChncm91cF9jb2RlKSwKICAgICAgICAgbWFzdGVyX3NrdV9kZXNjcl9pZHg0 +IGJ0cmVlIChza3VfZGVzY3IpLAogICAgICAgICBtYXN0ZXJfc2t1X2Rlc2Ny +X2lkeDUgYnRyZWUgKGRlcF9jb2RlKSwKICAgICAgICAgbWFzdGVyX3NrdV9k +ZXNjcl9pZHg2IGJ0cmVlIChncm91cF9jb2RlLCBza3UpLAogICAgICAgICBt +YXN0ZXJfc2t1X2Rlc2NyX2lkeDcgYnRyZWUgKGRlcF9kZXNjciksCiAgICAg +ICAgIG1hc3Rlcl9za3VfZGVzY3JfaWR4OCBidHJlZSAoY2F0X2NvZGUpLAog +ICAgICAgICBtYXN0ZXJfc2t1X2Rlc2NyX2lkeDkgYnRyZWUgKHN1YmNhdF9k +ZXNjciksCiAgICAgICAgIG1hc3Rlcl9za3VfZGVzY3JfdWlkeDMgYnRyZWUg +KHNrdSkKCiBjb3VudCAgCi0tLS0tLS0tCiAxNTYwMDgKKDEgcm93KQoK + +--Multipart=_Tue__24_Aug_2004_10_32_40_+0200_maLgIszoscYKY=nc +Content-Type: application/octet-stream; + name="master_branch_descr.sql" +Content-Disposition: attachment; + filename="master_branch_descr.sql" +Content-Transfer-Encoding: base64 + +VGFibGUgInB1YmxpYy5tYXN0ZXJfYnJhbmNoX2Rlc2NyIgogICAgIENvbHVt +biAgICAgfCBUeXBlIHwgTW9kaWZpZXJzIAotLS0tLS0tLS0tLS0tLS0tKy0t +LS0tLSstLS0tLS0tLS0tLQogYnJuX2NvZGUgICAgICAgfCB0ZXh0IHwgbm90 +IG51bGwKIGJybl9kZXNjciAgICAgIHwgdGV4dCB8IAogY291bnRyeV9jb2Rl +ICAgfCB0ZXh0IHwgCiBjb3VudHJ5X2Rlc2NyICB8IHRleHQgfCAKIGNsdXN0 +ZXJfY29kZSAgIHwgdGV4dCB8IAogY2x1c3Rlcl9kZXNjciAgfCB0ZXh0IHwg +CiBicmFuZF9jb2RlICAgICB8IHRleHQgfCAKIGJyYW5kX2Rlc2NyICAgIHwg +dGV4dCB8IAogY2hhaW5fY29kZSAgICAgfCB0ZXh0IHwgCiBjaGFpbl9kZXNj +ciAgICB8IHRleHQgfCAKIHNidV9jb2RlICAgICAgIHwgdGV4dCB8IAogc2J1 +X2Rlc2NyICAgICAgfCB0ZXh0IHwgCiBncm91cF9jb2RlICAgICB8IHRleHQg +fCAKIGdyb3VwX2Rlc2NyICAgIHwgdGV4dCB8IAogcmVnaW9uX2NvZGUgICAg +fCB0ZXh0IHwgCiByZWdpb25fZGVzY3IgICB8IHRleHQgfCAKIGRpdmlzaW9u +X2NvZGUgIHwgdGV4dCB8IAogZGl2aXNpb25fZGVzY3IgfCB0ZXh0IHwgCklu +ZGV4ZXM6IG1hc3Rlcl9icmFuY2hfZGVzY3JfcGtleSBwcmltYXJ5IGtleSBi +dHJlZSAoYnJuX2NvZGUpLAogICAgICAgICBtYXN0ZXJfYnJhbmNoX2Rlc2Ny +X3VpZHgxIHVuaXF1ZSBidHJlZSAoYnJuX2NvZGUpLAogICAgICAgICBtYXN0 +ZXJfYnJhbmNoX2Rlc2NyX3VpZHgyIHVuaXF1ZSBidHJlZSAoYnJuX2NvZGUs +IGJybl9kZXNjciksCiAgICAgICAgIG1hc3Rlcl9icmFuY2hfZGVzY3JfaWR4 +MSBidHJlZSAoYnJuX2NvZGUsIGJybl9kZXNjciwgY291bnRyeV9jb2RlLCBj +b3VudHJ5X2Rlc2NyKSwKICAgICAgICAgbWFzdGVyX2JyYW5jaF9kZXNjcl9p +ZHgxMCBidHJlZSAoY2hhaW5fY29kZSwgYnJuX2NvZGUpLAogICAgICAgICBt +YXN0ZXJfYnJhbmNoX2Rlc2NyX2lkeDExIGJ0cmVlIChjaGFpbl9kZXNjciwg +YnJuX2NvZGUpLAogICAgICAgICBtYXN0ZXJfYnJhbmNoX2Rlc2NyX2lkeDEy +IGJ0cmVlIChzYnVfY29kZSwgYnJuX2NvZGUpLAogICAgICAgICBtYXN0ZXJf +YnJhbmNoX2Rlc2NyX2lkeDEzIGJ0cmVlIChzYnVfZGVzY3IsIGJybl9jb2Rl +KSwKICAgICAgICAgbWFzdGVyX2JyYW5jaF9kZXNjcl9pZHgxNCBidHJlZSAo +Z3JvdXBfY29kZSwgYnJuX2NvZGUpLAogICAgICAgICBtYXN0ZXJfYnJhbmNo +X2Rlc2NyX2lkeDE1IGJ0cmVlIChncm91cF9kZXNjciwgYnJuX2NvZGUpLAog +ICAgICAgICBtYXN0ZXJfYnJhbmNoX2Rlc2NyX2lkeDE2IGJ0cmVlIChyZWdp +b25fY29kZSwgYnJuX2NvZGUpLAogICAgICAgICBtYXN0ZXJfYnJhbmNoX2Rl +c2NyX2lkeDE3IGJ0cmVlIChyZWdpb25fZGVzY3IsIGJybl9jb2RlKSwKICAg +ICAgICAgbWFzdGVyX2JyYW5jaF9kZXNjcl9pZHgxOCBidHJlZSAoZGl2aXNp +b25fY29kZSwgYnJuX2NvZGUpLAogICAgICAgICBtYXN0ZXJfYnJhbmNoX2Rl +c2NyX2lkeDE5IGJ0cmVlIChkaXZpc2lvbl9kZXNjciwgYnJuX2NvZGUpLAog +ICAgICAgICBtYXN0ZXJfYnJhbmNoX2Rlc2NyX2lkeDIgYnRyZWUgKGJybl9j +b2RlLCBicm5fZGVzY3IsIGNsdXN0ZXJfY29kZSwgY2x1c3Rlcl9kZXNjciks +CiAgICAgICAgIG1hc3Rlcl9icmFuY2hfZGVzY3JfaWR4MyBidHJlZSAoYnJu +X2Rlc2NyLCBicm5fY29kZSksCiAgICAgICAgIG1hc3Rlcl9icmFuY2hfZGVz +Y3JfaWR4NCBidHJlZSAoY291bnRyeV9jb2RlLCBicm5fY29kZSksCiAgICAg +ICAgIG1hc3Rlcl9icmFuY2hfZGVzY3JfaWR4NSBidHJlZSAoY291bnRyeV9k +ZXNjciwgYnJuX2NvZGUpLAogICAgICAgICBtYXN0ZXJfYnJhbmNoX2Rlc2Ny +X2lkeDYgYnRyZWUgKGNsdXN0ZXJfY29kZSwgYnJuX2NvZGUpLAogICAgICAg +ICBtYXN0ZXJfYnJhbmNoX2Rlc2NyX2lkeDcgYnRyZWUgKGNsdXN0ZXJfZGVz +Y3IsIGJybl9jb2RlKSwKICAgICAgICAgbWFzdGVyX2JyYW5jaF9kZXNjcl9p +ZHg4IGJ0cmVlIChicmFuZF9jb2RlLCBicm5fY29kZSksCiAgICAgICAgIG1h +c3Rlcl9icmFuY2hfZGVzY3JfaWR4OSBidHJlZSAoYnJhbmRfZGVzY3IsIGJy +bl9jb2RlKQoKIGNvdW50IAotLS0tLS0tCiAgIDY2NgooMSByb3cpCgo= + +--Multipart=_Tue__24_Aug_2004_10_32_40_+0200_maLgIszoscYKY=nc +Content-Type: application/octet-stream; + name="gir_outstanding.sql" +Content-Disposition: attachment; + filename="gir_outstanding.sql" +Content-Transfer-Encoding: base64 + +ICAgICAgICAgICAgICBUYWJsZSAicHVibGljLmdpcl9vdXRzdGFuZGluZyIK +ICAgICBDb2x1bW4gICAgIHwgICAgICAgICAgICBUeXBlICAgICAgICAgICAg +IHwgTW9kaWZpZXJzIAotLS0tLS0tLS0tLS0tLS0tKy0tLS0tLS0tLS0tLS0t +LS0tLS0tLS0tLS0tLS0tKy0tLS0tLS0tLS0tCiBzdXBwX2NvZGUgICAgICB8 +IHRleHQgICAgICAgICAgICAgICAgICAgICAgICB8IAogc3VwcF9uYW1lICAg +ICAgfCB0ZXh0ICAgICAgICAgICAgICAgICAgICAgICAgfCAKIHN1cHBfYnJu +ICAgICAgIHwgdGV4dCAgICAgICAgICAgICAgICAgICAgICAgIHwgCiBvcmRf +bm8gICAgICAgICB8IHRleHQgICAgICAgICAgICAgICAgICAgICAgICB8IAog +ZHVlX2RhdGUgICAgICAgfCB0aW1lc3RhbXAgd2l0aG91dCB0aW1lIHpvbmUg +fCAKIHRvX2RhdGUgICAgICAgIHwgdGltZXN0YW1wIHdpdGhvdXQgdGltZSB6 +b25lIHwgCiBncm91cF9jb2RlICAgICB8IHRleHQgICAgICAgICAgICAgICAg +ICAgICAgICB8IAogYnJuX2NvZGUgICAgICAgfCB0ZXh0ICAgICAgICAgICAg +ICAgICAgICAgICAgfCAKIGRlc2Nfc2hvcnQgICAgIHwgdGV4dCAgICAgICAg +ICAgICAgICAgICAgICAgIHwgCiBjbHVzdGVyX2JybiAgICB8IHRleHQgICAg +ICAgICAgICAgICAgICAgICAgICB8IAogY291bnRyeV9jb2RlICAgfCB0ZXh0 +ICAgICAgICAgICAgICAgICAgICAgICAgfCAKIHJlcV9kb2Nfbm8gICAgIHwg +aW50ZWdlciAgICAgICAgICAgICAgICAgICAgIHwgCiBvcHNfY29kZSAgICAg +ICB8IHRleHQgICAgICAgICAgICAgICAgICAgICAgICB8IAogc2t1ICAgICAg +ICAgICAgfCB0ZXh0ICAgICAgICAgICAgICAgICAgICAgICAgfCAKIHN0ZF9k +ZXNjciAgICAgIHwgdGV4dCAgICAgICAgICAgICAgICAgICAgICAgIHwgCiBh +Y2RlX2NvZGUgICAgICB8IHRleHQgICAgICAgICAgICAgICAgICAgICAgICB8 +IAogcmVxX3F0eSAgICAgICAgfCBkb3VibGUgcHJlY2lzaW9uICAgICAgICAg +ICAgfCAKIGdydl9xdHkgICAgICAgIHwgZG91YmxlIHByZWNpc2lvbiAgICAg +ICAgICAgIHwgCiBza3VsX3F0eSAgICAgICB8IGRvdWJsZSBwcmVjaXNpb24g +ICAgICAgICAgICB8IAogcHJlZl9kYXRlICAgICAgfCB0aW1lc3RhbXAgd2l0 +aG91dCB0aW1lIHpvbmUgfCAKIHNrdWxfZ3J2X3F0eSAgIHwgZG91YmxlIHBy +ZWNpc2lvbiAgICAgICAgICAgIHwgCiBvdXRfcXR5ICAgICAgICB8IGRvdWJs +ZSBwcmVjaXNpb24gICAgICAgICAgICB8IAogc2t1bF9vcmRfY29zdCAgfCBu +dW1lcmljKDE2LDIpICAgICAgICAgICAgICAgfCAKIG91dF9jb3N0ICAgICAg +IHwgbnVtZXJpYyAgICAgICAgICAgICAgICAgICAgIHwgCiBzdGt0eXBlX2Nv +ZGUgICB8IGNoYXJhY3RlciB2YXJ5aW5nKDIpICAgICAgICB8IAogZ2lyX3R5 +cGVfY29kZSAgfCB0ZXh0ICAgICAgICAgICAgICAgICAgICAgICAgfCAKIGdp +cl90eXBlX2Rlc2NyIHwgdGV4dCAgICAgICAgICAgICAgICAgICAgICAgIHwg +CkluZGV4ZXM6IGdpcl9vdXN0YW5kaW5nX2lkeDEgYnRyZWUgKGNsdXN0ZXJf +YnJuLCBza3UsIHN0a3R5cGVfY29kZSkKCiBjb3VudCAKLS0tLS0tLQogIDY5 +NTAKKDEgcm93KQoK + +--Multipart=_Tue__24_Aug_2004_10_32_40_+0200_maLgIszoscYKY=nc-- + +From pgsql-performance-owner@postgresql.org Tue Aug 24 06:08:07 2004 +X-Original-To: pgsql-performance@postgresql.org +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 2751E5E4733 + for ; + Tue, 24 Aug 2004 06:08:04 -0300 (ADT) +Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i7O985Ui070850; Tue, 24 Aug 2004 17:08:05 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <412B05A2.8070301@familyhealth.com.au> +Date: Tue, 24 Aug 2004 17:08:50 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Stef +Cc: pgsql-performance@postgresql.org +Subject: Re: Query kills machine. +References: <20040824103240.4d909777@svb.ucs.co.za> +In-Reply-To: <20040824103240.4d909777@svb.ucs.co.za> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200408/321 +X-Sequence-Number: 7957 + +For starters, + + +> ------------------------------------------------------------------------ +> +> shared_buffers = 110592 +> wal_buffers = 400 +> sort_mem = 30720 +> vacuum_mem = 10240 +> checkpoint_segments = 30 +> commit_delay = 5000 +> commit_siblings = 100 +> effective_cache_size = 201413 + +Try more like this: + +shared_buffers = 30000 +wal_buffers = +sort_mem = 4096 +vacuum_mem = 10240 +checkpoint_segments = 30 +commit_delay = +commit_siblings = +effective_cache_size = 100000 + +Chris + + +From pgsql-performance-owner@postgresql.org Tue Aug 24 08:59:51 2004 +X-Original-To: pgsql-performance@postgresql.org +Received: from smtp016.mail.yahoo.com (smtp016.mail.yahoo.com + [216.136.174.113]) + by svr1.postgresql.org (Postfix) with SMTP id 3CBEE5E480D + for ; + Tue, 24 Aug 2004 08:59:49 -0300 (ADT) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp016.mail.yahoo.com with SMTP; 24 Aug 2004 11:59:37 -0000 +Received: from [172.21.8.18] ([192.168.192.101]) (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i7OBxWT7074907; Tue, 24 Aug 2004 07:59:32 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <412B2DE7.6000809@Yahoo.com> +Date: Tue, 24 Aug 2004 08:00:39 -0400 +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: my ho +Cc: pgsql-performance@postgresql.org +Subject: Re: postgresql performance with multimedia +References: <20040824050842.56287.qmail@web54109.mail.yahoo.com> +In-Reply-To: <20040824050842.56287.qmail@web54109.mail.yahoo.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200408/322 +X-Sequence-Number: 7958 + +On 8/24/2004 1:08 AM, my ho wrote: + +> --- Jan Wieck wrote: +> +>> On 8/17/2004 8:44 PM, my thi ho wrote: +>> +>> > Hi, +>> > I am working on a project which explore postgresql +>> to +>> > store multimedia data. +>> > In details, i am trying to work with the buffer +>> > management part of postgres source code. And try +>> to +>> > improve the performance. I had search on the web +>> but +>> > could not find much usefull information. +>> +>> What version of PostgreSQL are you looking at? Note +>> that the buffer +>> cache replacement strategy was completely changed +>> for version 8.0, which +>> is currently in BETA test. A description of the +>> algorithm can be found +>> in the README file in src/backend/storage/bufmgr. +> +> oki, Thanks for the information. I have a look at 8.0 +> beta, but cannot start the statistic collector. (I had +> post this err message before for help, but havent +> really got any clue to fix it) +>> LOG: could not create IPv6 socket: Address family +> not +>> supported by protocol +>> LOG: could not bind socket for statistics +> collector: +>> Cannot assign requested address +>> LOG: disabling statistics collector for lack of +>> working socket + +Tom Lane answered to that question. The code in question does resolve +"localhost" with getaddrinfo() and then tries to create and bind a UDP +socket to all returned addresses. For some reason "localhost" on your +system resolves to an address that is not available for bind(2). + +> +> btw, what i want to ask here is does postgreSQL have +> any kind of read-ahead buffer implemented? 'cos it +> would be useful in multimedia case when we always scan +> the large table for continous data. + +Since there is no mechanism to control that data is stored contiguously +in the tables, what would that be good for? + + +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 Tue Aug 24 10:30:42 2004 +X-Original-To: pgsql-performance@postgresql.org +Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 725E95E472D + for ; + Tue, 24 Aug 2004 10:30:19 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by ucsns.ucs.co.za (Postfix) with ESMTP id F059D2BD58 + for ; + Tue, 24 Aug 2004 15:30:17 +0200 (SAST) +Received: from ucsns.ucs.co.za ([127.0.0.1]) + by localhost (ucsns.ucs.co.za [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 03773-05 for ; + Tue, 24 Aug 2004 15:30:14 +0200 (SAST) +Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 6B6042BD78 + for ; + Tue, 24 Aug 2004 15:30:14 +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 95967D9E29 + for ; + Tue, 24 Aug 2004 15:30:14 +0200 (SAST) +Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) + by jhb.ucs.co.za (Postfix) with SMTP id BEE60975A0 + for ; + Tue, 24 Aug 2004 15:30:14 +0200 (SAST) +Date: Tue, 24 Aug 2004 15:30:14 +0200 +From: Stef +To: pgsql-performance@postgresql.org +Subject: Re: Query kills machine. +Message-Id: <20040824153014.2a11d228@svb.ucs.co.za> +In-Reply-To: <412B05A2.8070301@familyhealth.com.au> +References: <20040824103240.4d909777@svb.ucs.co.za> + <412B05A2.8070301@familyhealth.com.au> +X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) +User-Agent: sillypheed-claws (anti-aliased) +X-Face: GFoC95e6r)_TTG>n~=uFLojP=O~4W@Ms]>:.DMm/')(z3\Mwj^XP@? + Q:3";lD.OM1"^mDu}2NJ@US:)dO:U*iY5EM50&Tx. +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 ucs.co.za +X-Archive-Number: 200408/323 +X-Sequence-Number: 7959 + +Christopher Kings-Lynne mentioned : +=> sort_mem = 4096 + +Reducing sort_mem to 4096 seems to make it run in a reasonable time +again. Any idea why? The database does a whole lot of huge sorts +every day, so I thought upping this parameter would help. + +A couple of queries do seem to run slower now that I reduced +the sort_mem. + +The shared buffers still makes a significant difference when I increase it. + +Kind Regards +Stefan + + +From pgsql-performance-owner@postgresql.org Tue Aug 24 15:48:15 2004 +X-Original-To: pgsql-performance@postgresql.org +Received: from mail2.fbab.net (spectre.fbab.net [212.214.165.139]) + by svr1.postgresql.org (Postfix) with SMTP id 083015E473E + for ; + Tue, 24 Aug 2004 11:08:33 -0300 (ADT) +Received: (qmail 3500 invoked by uid 46); 24 Aug 2004 14:08:37 -0000 +Received: from 212.214.165.129 by mail2.fbab.net (envelope-from + , + uid 133) with qmail-scanner-1.23 (clamdscan: 0.75.1. + Clear:RC:0(212.214.165.129):. + Processed in 0.088411 secs); 24 Aug 2004 14:08:37 -0000 +Received: from unknown (HELO ?10.10.12.248?) (magpool1@212.214.165.129) + by mail2.fbab.net with SMTP; 24 Aug 2004 14:08:37 -0000 +Message-ID: <412B4BE1.8080808@fbab.net> +Date: Tue, 24 Aug 2004 16:08:33 +0200 +From: "Magnus Naeslund(t)" +User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Stef +Cc: pgsql-performance@postgresql.org +Subject: Re: Query kills machine. +References: <20040824103240.4d909777@svb.ucs.co.za> + <412B05A2.8070301@familyhealth.com.au> + <20040824153014.2a11d228@svb.ucs.co.za> +In-Reply-To: <20040824153014.2a11d228@svb.ucs.co.za> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200408/327 +X-Sequence-Number: 7963 + +Stef wrote: + +> Christopher Kings-Lynne mentioned : +> => sort_mem = 4096 +> +> Reducing sort_mem to 4096 seems to make it run in a reasonable time +> again. Any idea why? The database does a whole lot of huge sorts +> every day, so I thought upping this parameter would help. +> +> A couple of queries do seem to run slower now that I reduced +> the sort_mem. +> +> The shared buffers still makes a significant difference when I increase it. +> + +Well you have to take in account that sort_mem is not the total memory +allocated for sorting but per connection and in complex expressions +serveral times that too. + +So if you sort a lot it can push your operating system off the cliff and +it might start reaping things that shouldn't be reaped and start swapping. + +If that happens _everything_ on that box will get slow... + +Shared buffers on the other hand is only allocated once. + +Regards, +Magnus + +From pgsql-performance-owner@postgresql.org Tue Aug 24 11:15:05 2004 +X-Original-To: pgsql-performance@postgresql.org +Received: from mail2.fbab.net (spectre.fbab.net [212.214.165.139]) + by svr1.postgresql.org (Postfix) with SMTP id EB29D5E481E + for ; + Tue, 24 Aug 2004 11:15:03 -0300 (ADT) +Received: (qmail 3818 invoked by uid 46); 24 Aug 2004 14:15:09 -0000 +Received: from 212.214.165.129 by mail2.fbab.net (envelope-from + , uid 133) with qmail-scanner-1.23 + (clamdscan: 0.75.1. Clear:RC:0(212.214.165.129):. + Processed in 0.087933 secs); 24 Aug 2004 14:15:09 -0000 +Received: from unknown (HELO ?10.10.12.248?) (magpool1@212.214.165.129) + by mail2.fbab.net with SMTP; 24 Aug 2004 14:15:08 -0000 +Message-ID: <412B4D6A.8050706@fbab.net> +Date: Tue, 24 Aug 2004 16:15:06 +0200 +From: "Magnus Naeslund(pg)" +User-Agent: Mozilla Thunderbird 0.7.2 (Windows/20040707) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Stef +Cc: pgsql-performance@postgresql.org +Subject: Re: Query kills machine. +References: <20040824103240.4d909777@svb.ucs.co.za> + <412B05A2.8070301@familyhealth.com.au> + <20040824153014.2a11d228@svb.ucs.co.za> +In-Reply-To: <20040824153014.2a11d228@svb.ucs.co.za> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200408/324 +X-Sequence-Number: 7960 + +Stef wrote: + + > Christopher Kings-Lynne mentioned : + > => sort_mem = 4096 + > + > Reducing sort_mem to 4096 seems to make it run in a reasonable time + > again. Any idea why? The database does a whole lot of huge sorts + > every day, so I thought upping this parameter would help. + > + > A couple of queries do seem to run slower now that I reduced + > the sort_mem. + > The shared buffers still makes a significant difference when I +increase it. + > + +Well you have to take in account that sort_mem is not the total memory +allocated for sorting but per connection and in complex expressions +serveral times that too. + +So if you sort a lot it can push your operating system off the cliff and +it might start reaping things that shouldn't be reaped and start swapping. + +If that happens _everything_ on that box will get slow... + +Shared buffers on the other hand is only allocated once. + +Regards, +Magnus + + +From pgsql-performance-owner@postgresql.org Tue Aug 24 12:23:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D5265E46D2 + for ; + Tue, 24 Aug 2004 12:23:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24428-05 + for ; + Tue, 24 Aug 2004 15:23: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 7249E5E46CF + for ; + Tue, 24 Aug 2004 12:23:24 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7OFNVPf004016; + Tue, 24 Aug 2004 11:23:31 -0400 (EDT) +To: Stef +Cc: pgsql-performance@postgresql.org +Subject: Re: Query kills machine. +In-reply-to: <20040824153014.2a11d228@svb.ucs.co.za> +References: <20040824103240.4d909777@svb.ucs.co.za> + <412B05A2.8070301@familyhealth.com.au> + <20040824153014.2a11d228@svb.ucs.co.za> +Comments: In-reply-to Stef + message dated "Tue, 24 Aug 2004 15:30:14 +0200" +Date: Tue, 24 Aug 2004 11:23:31 -0400 +Message-ID: <4015.1093361011@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/325 +X-Sequence-Number: 7961 + +Stef writes: +> Reducing sort_mem to 4096 seems to make it run in a reasonable time +> again. Any idea why? The database does a whole lot of huge sorts +> every day, so I thought upping this parameter would help. + +Not if you haven't got the RAM to support it :-( + +Another thing you might look at is ANALYZEing the tables again after +you've loaded all the new data. The row-count estimates seem way off +in these plans. You might need to increase the statistics target, +too, to get better plans. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 24 13:31:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 18FCC5E46C2 + for ; + Tue, 24 Aug 2004 13:31:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 53097-08 + for ; + Tue, 24 Aug 2004 16:31:25 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C6FA5E46C3 + for ; + Tue, 24 Aug 2004 13:31:16 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7OGVOLq056992 + for ; Tue, 24 Aug 2004 16:31:24 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7OGHWEX050157 + for pgsql-performance@postgresql.org; Tue, 24 Aug 2004 16:17:32 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: [FUN] Performance increase? +Date: Tue, 24 Aug 2004 18:17:29 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 10 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +X-Enigmail-Version: 0.85.0.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/326 +X-Sequence-Number: 7962 + +Do you think that adopting the "chip tuning" product +postgresql could increase the performances as well ? + + + +Regards +Gaetano Mendola + + + + +From pgsql-performance-owner@postgresql.org Tue Aug 24 17:30:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E5FB55E46CE + for ; + Tue, 24 Aug 2004 17:30:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68170-04 + for ; + Tue, 24 Aug 2004 20:30:39 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 577775E46C3 + for ; + Tue, 24 Aug 2004 17:30:38 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6165658; Tue, 24 Aug 2004 13:31:56 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Daniel Ceregatti , pgsql-performance@postgresql.org +Subject: Re: What is the best way to do attribute/values? +Date: Tue, 24 Aug 2004 13:30:32 -0700 +User-Agent: KMail/1.4.3 +References: <4124EB58.9040102@sh.nu> +In-Reply-To: <4124EB58.9040102@sh.nu> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408241330.32484.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/329 +X-Sequence-Number: 7965 + +Folks, + +> I've discussed these attempts with people in #postgresql on +> irc.freenode.net. Agliodbs (I presume you know who this is) was very +> helpful, but in end was at a loss. I find myself in the same postition +> at this time. He suggested I contact this list. + +There's a couple of issues here to attack: + +1) PostgreSQL is not using the most optimal plan. First, it's ignoring the +fact that all referenced columns are indexed and only using the first column, +then filtering based on the other criteria. Second, testing has shown that +a hash join would actually be faster. We've tried upping the statistics, +but it doesn't seem to have an effect on the planner's erroneous estimates. + +2) Even were it using the most optimal plan, it's still to slow. As you can +see from the plan, each merge join takes about 1.5 to 2 seconds. (hash +joins are only about 0.5 seconds slower). Mysteriously, a big chunk of this +time is spent *in bewtween* planner steps, as if there was some hold-up in +retrieving the index or table pages. There may be, but Daniel and I have +not been able to diagnose the cause. It's particularly mysterious since a +filter-and-sort on a *single* criteria set, without join, takes < 400ms. + +Things we've already tried to avoid going over old ground: +1) increasing statistics; +2) increasing sort_mem (to 256MB, which is overkill) +3) testing on 8.0 beta, which does not affect the issue. + +At this point I'm looking for ideas. Suggestions, anyone? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Aug 24 18:00:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 702CA5E46D4 + for ; + Tue, 24 Aug 2004 18:00:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82574-02 + for ; + Tue, 24 Aug 2004 21:00:50 +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 70E9D5E46C3 + for ; + Tue, 24 Aug 2004 18:00:49 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) + id 1BziPS-000PdG-0Y; Tue, 24 Aug 2004 21:00:51 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 190AC16B14; Tue, 24 Aug 2004 22:00:50 +0100 (BST) +Message-ID: <412BAC80.4050507@archonet.com> +Date: Tue, 24 Aug 2004 22:00:48 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Daniel Ceregatti +Cc: pgsql-performance@postgresql.org +Subject: Re: What is the best way to do attribute/values? +References: <4124EB58.9040102@sh.nu> +In-Reply-To: <4124EB58.9040102@sh.nu> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/330 +X-Sequence-Number: 7966 + +Daniel Ceregatti wrote: +> Hi list, +> +> I have a database with 1M "people" in it. Each person has about 20 +> attributes, such as height, weight, eye color, etc. I need to be able to +> search for people based on these attributes. A search can be conducted +> on one attribute, all attributes, or any number in between. How would +> _you_ do this? +> +> I have already attempted to answer this. My attempts are detailed here: +> +> http://sh.nu/email.txt + +Hmm... interesting. + +Shot in the dark - try a tsearch2 full-text index. Your problem could be +translated into searching strings of the form + "hair=black eyes=blue age=117" + +Not pretty, but might give you the speed you want. +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Aug 25 21:50:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D0C25E46CD + for ; + Wed, 25 Aug 2004 02:31:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94014-08 + for ; + Wed, 25 Aug 2004 05:31:45 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 25FE25E46C4 + for ; + Wed, 25 Aug 2004 02:31:45 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7P5VVLq098903 + for ; Wed, 25 Aug 2004 05:31:33 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7P5SgPV097839 + for pgsql-performance@postgresql.org; Wed, 25 Aug 2004 05:28:42 GMT +From: Mischa Sandberg +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Equivalent praxis to CLUSTERED INDEX? +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 13 +Message-ID: +Date: Wed, 25 Aug 2004 05:28:42 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/350 +X-Sequence-Number: 7986 + +Coming from the MSSQL world, I'm used to the first step in optimization +to be, choose your clustered index and choose it well. + +I see that PG has a one-shot CLUSTER command, but doesn't support +continuously-updated clustered indexes. + +What I infer from newsgroup browsing is, such an index is impossible, +given the MVCC versioning of records (happy to learn I'm wrong). + +I'd be curious to know what other people, who've crossed this same +bridge from MSSQL or Oracle or Sybase to PG, have devised, +faced with the same kind of desired performance gain for retrieving +blocks of rows with the same partial key. + +From pgsql-performance-owner@postgresql.org Wed Aug 25 03:54:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C79D5E46D2 + for ; + Wed, 25 Aug 2004 03:54:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25151-01 + for ; + Wed, 25 Aug 2004 06:54:05 +0000 (GMT) +Received: from web54107.mail.yahoo.com (web54107.mail.yahoo.com + [206.190.37.242]) + by svr1.postgresql.org (Postfix) with SMTP id B33BC5E46CC + for ; + Wed, 25 Aug 2004 03:54:04 -0300 (ADT) +Message-ID: <20040825065405.83731.qmail@web54107.mail.yahoo.com> +Received: from [129.94.6.30] by web54107.mail.yahoo.com via HTTP; + Tue, 24 Aug 2004 23:54:05 PDT +Date: Tue, 24 Aug 2004 23:54:05 -0700 (PDT) +From: my ho +Subject: Re: postgresql performance with multimedia +To: pgsql-performance@postgresql.org +Cc: Jan Wieck +In-Reply-To: <412B2DE7.6000809@Yahoo.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/331 +X-Sequence-Number: 7967 + +> Tom Lane answered to that question. The code in +> question does resolve +> "localhost" with getaddrinfo() and then tries to +> create and bind a UDP +> socket to all returned addresses. For some reason +> "localhost" on your +> system resolves to an address that is not available +> for bind(2). + +I tried to put my_ip instead of "localhost" in +bufmng.c and it seems to work (no more complaining). +However i check the pg_statio_all_tables and dont see +any recorded statistic at all. (all the columns are +'0') +some time postmaster shut down with this err msg: +LOG: statistics collector process () +exited with exit code 1 +i starts postmaster with this command: +postmaster -i -p $PORT -D $PGDATA -k $PGDATA -N 32 -B +64 -o -s + +> > btw, what i want to ask here is does postgreSQL +> have +> > any kind of read-ahead buffer implemented? 'cos it +> > would be useful in multimedia case when we always +> scan +> > the large table for continous data. +> +> Since there is no mechanism to control that data is +> stored contiguously +> in the tables, what would that be good for? + +i thought that rows in the table will be stored +contiguously? in that case, if the user is requesting +1 row, we make sure that the continue rows are ready +in the buffer pool so that when they next requested, +they wont be asked to read from disk. For multimedia +data, this is important 'cos data needs to be +presented continuously without any waiting. + +thanks again for your help +MT Ho + + + +__________________________________________________ +Do You Yahoo!? +Tired of spam? Yahoo! Mail has the best spam protection around +http://mail.yahoo.com + +From pgsql-performance-owner@postgresql.org Wed Aug 25 04:14:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D6F45E46D4 + for ; + Wed, 25 Aug 2004 04:14:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29743-06 + for ; + Wed, 25 Aug 2004 07:14:04 +0000 (GMT) +Received: from loki.globexplorer.com (unknown [208.35.14.101]) + by svr1.postgresql.org (Postfix) with ESMTP id D5B9F5E46DD + for ; + Wed, 25 Aug 2004 04:14:00 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="Windows-1252" +Content-Transfer-Encoding: quoted-printable +Subject: Re: postgresql performance with multimedia +Date: Wed, 25 Aug 2004 00:14:01 -0700 +Message-ID: + <71E37EF6B7DCC1499CEA0316A256832801057E9F@loki.wc.globexplorer.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] postgresql performance with multimedia +Thread-Index: AcSKcJFOkOxlIeQ3SpKqe7h0GU/2YAAAb0h8 +From: "Gregory S. Williamson" +To: "my ho" , + +Cc: "Jan Wieck" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/332 +X-Sequence-Number: 7968 + + +Not sure about the overall performance, etc. but I think that in order to c= +ollect statistics you need to set some values in the postgresql.conf config= + file, to wit: +#--------------------------------------------------------------------------- +# RUNTIME STATISTICS +#--------------------------------------------------------------------------- + +# - Statistics Monitoring - + +#log_parser_stats =3D false +#log_planner_stats =3D false +#log_executor_stats =3D false +#log_statement_stats =3D false + +# - Query/Index Statistics Collector - + +stats_start_collector =3D true +stats_command_string =3D true +stats_block_level =3D true +stats_row_level =3D true +#stats_reset_on_server_start =3D true + +If the appropriate values aren't set this could account for why no entries = +are found in the pg_stat tables. The manual has details on these; you'll ne= +ed to reload postgres to make any changes effective. + +Greg + + +-----Original Message----- +From: my ho [mailto:mthoatbanjo@yahoo.com] +Sent: Tue 8/24/2004 11:54 PM +To: pgsql-performance@postgresql.org +Cc: Jan Wieck +Subject: Re: [PERFORM] postgresql performance with multimedia +> Tom Lane answered to that question. The code in +> question does resolve=20 +> "localhost" with getaddrinfo() and then tries to +> create and bind a UDP=20 +> socket to all returned addresses. For some reason +> "localhost" on your=20 +> system resolves to an address that is not available +> for bind(2). + +I tried to put my_ip instead of "localhost" in +bufmng.c and it seems to work (no more complaining). +However i check the pg_statio_all_tables and dont see +any recorded statistic at all. (all the columns are +'0') +some time postmaster shut down with this err msg:=20 +LOG: statistics collector process () +exited with exit code 1 +i starts postmaster with this command: +postmaster -i -p $PORT -D $PGDATA -k $PGDATA -N 32 -B +64 -o -s + +> > btw, what i want to ask here is does postgreSQL +> have +> > any kind of read-ahead buffer implemented? 'cos it +> > would be useful in multimedia case when we always +> scan +> > the large table for continous data. +>=20 +> Since there is no mechanism to control that data is +> stored contiguously=20 +> in the tables, what would that be good for? + +i thought that rows in the table will be stored +contiguously? in that case, if the user is requesting +1 row, we make sure that the continue rows are ready +in the buffer pool so that when they next requested, +they wont be asked to read from disk. For multimedia +data, this is important 'cos data needs to be +presented continuously without any waiting. + +thanks again for your help +MT Ho + + + +__________________________________________________ +Do You Yahoo!? +Tired of spam? Yahoo! Mail has the best spam protection around=20 +http://mail.yahoo.com=20 + +---------------------------(end of broadcast)--------------------------- +TIP 4: Don't 'kill -9' the postmaster + + + + +From pgsql-performance-owner@postgresql.org Wed Aug 25 05:19:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 028D85E46D1 + for ; + Wed, 25 Aug 2004 05:19:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49444-05 + for ; + Wed, 25 Aug 2004 08:19:50 +0000 (GMT) +Received: from linda-2.paradise.net.nz (bm-2a.paradise.net.nz [202.0.58.21]) + by svr1.postgresql.org (Postfix) with ESMTP id EC9FD5E46CE + for ; + Wed, 25 Aug 2004 05:19:48 -0300 (ADT) +Received: from smtp-1.paradise.net.nz (smtp-1b.paradise.net.nz [202.0.32.210]) + by linda-2.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0I2Z004AYTSXUK@linda-2.paradise.net.nz> for + pgsql-performance@postgresql.org; Wed, 25 Aug 2004 20:19:46 +1200 (NZST) +Received: from [192.168.1.11] (218-101-13-189.paradise.net.nz + [218.101.13.189]) + by smtp-1.paradise.net.nz (Postfix) with ESMTP id 93F6282850; Wed, + 25 Aug 2004 20:19:45 +1200 (NZST) +Date: Wed, 25 Aug 2004 20:22:18 +1200 +From: Mark Kirkwood +Subject: Re: What is the best way to do attribute/values? +In-reply-to: <200408241330.32484.josh@agliodbs.com> +To: Josh Berkus +Cc: Daniel Ceregatti , pgsql-performance@postgresql.org +Message-id: <412C4C3A.2030001@coretech.co.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8a2) Gecko/20040715 +References: <4124EB58.9040102@sh.nu> <200408241330.32484.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/333 +X-Sequence-Number: 7969 + + + +Josh Berkus wrote: + +> Things we've already tried to avoid going over old ground: +> +>1) increasing statistics; +>2) increasing sort_mem (to 256MB, which is overkill) +>3) testing on 8.0 beta, which does not affect the issue. +> +>At this point I'm looking for ideas. Suggestions, anyone? +> +> +> +with respect to query design: + +consider instead of: + +select + pav1.person_id +from + person_attributes_vertical pav1, + person_attributes_vertical pav2 +where + pav1.attribute_id = 1 + and pav1.value_id in (2,3) + and pav2.attribute_id = 2 + and pav2.value_id in (2,3) + and pav1.person_id = pav2.person_id + +try: + +select + pav1.person_id +from + person_attributes_vertical pav1 +where + ( pav1.attribute_id = 1 + and pav1.value_id in (2,3)) + or ( pav1.attribute_id = 2 + and pav1.value_id in (2,3)) + +I am gambling that the 'or's' might be less expensive than the multiple self joins (particularly in the more general cases!). + +To make access work well you might want to have *several* concatenated indexes of 2 -> 4 attributes - to work around Pg inability to use more than 1 in a given query. +For this query indexing (attribute_id, value_id) is probably good. + +Consider playing with 'random_page_cost' and maybe 'effective_cache_size' to encourage the planner to use 'em. + +regards + +Mark + + + + + +From pgsql-performance-owner@postgresql.org Wed Aug 25 08:02:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F6745E46C2 + for ; + Wed, 25 Aug 2004 08:02:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07928-04 + for ; + Wed, 25 Aug 2004 11:02:53 +0000 (GMT) +Received: from smtp111.mail.sc5.yahoo.com (smtp111.mail.sc5.yahoo.com + [66.163.170.9]) + by svr1.postgresql.org (Postfix) with SMTP id 933DA5E40AC + for ; + Wed, 25 Aug 2004 08:02:50 -0300 (ADT) +Received: from unknown (HELO jupiter.black-lion.info) (janwieck@68.80.245.191 + with login) + by smtp111.mail.sc5.yahoo.com with SMTP; 25 Aug 2004 11:02:53 -0000 +Received: from [172.21.8.18] ([192.168.192.101]) (authenticated bits=0) + by jupiter.black-lion.info (8.12.10/8.12.9) with ESMTP id + i7PB2qT7099953; Wed, 25 Aug 2004 07:02:52 -0400 (EDT) + (envelope-from JanWieck@Yahoo.com) +Message-ID: <412C71F1.4030902@Yahoo.com> +Date: Wed, 25 Aug 2004 07:03:13 -0400 +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: my ho +Cc: pgsql-performance@postgresql.org +Subject: Re: postgresql performance with multimedia +References: <20040825065405.83731.qmail@web54107.mail.yahoo.com> +In-Reply-To: <20040825065405.83731.qmail@web54107.mail.yahoo.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/334 +X-Sequence-Number: 7970 + +On 8/25/2004 2:54 AM, my ho wrote: +>> Tom Lane answered to that question. The code in +>> question does resolve +>> "localhost" with getaddrinfo() and then tries to +>> create and bind a UDP +>> socket to all returned addresses. For some reason +>> "localhost" on your +>> system resolves to an address that is not available +>> for bind(2). +> +> I tried to put my_ip instead of "localhost" in +> bufmng.c and it seems to work (no more complaining). +> However i check the pg_statio_all_tables and dont see +> any recorded statistic at all. (all the columns are +> '0') + +The block level statistics are disabled by default in the +postgresql.conf file. + +> some time postmaster shut down with this err msg: +> LOG: statistics collector process () +> exited with exit code 1 + +Fix your operating systems network settings instead of curing the +symptoms by breaking PostgreSQL. + +> i starts postmaster with this command: +> postmaster -i -p $PORT -D $PGDATA -k $PGDATA -N 32 -B +> 64 -o -s +> +>> > btw, what i want to ask here is does postgreSQL +>> have +>> > any kind of read-ahead buffer implemented? 'cos it +>> > would be useful in multimedia case when we always +>> scan +>> > the large table for continous data. +>> +>> Since there is no mechanism to control that data is +>> stored contiguously +>> in the tables, what would that be good for? +> +> i thought that rows in the table will be stored +> contiguously? in that case, if the user is requesting +> 1 row, we make sure that the continue rows are ready +> in the buffer pool so that when they next requested, +> they wont be asked to read from disk. For multimedia +> data, this is important 'cos data needs to be +> presented continuously without any waiting. + +They are only stored in that way on initial load and if the load is done +with a single process. And don't you rely on this for the future. Right +now, if you ever update or delete tuples, that order changes already. + +Also keep in mind that large values are not stored inline, but in an +extra "TOAST" relation. + +For your "streaming" purposes I strongly recommend you do it in your +application with the appropriate thread model. A relational database +management system is not a multimedia cache. + + +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 Wed Aug 25 08:26:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B6F245E46C4 + for ; + Wed, 25 Aug 2004 08:26:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18507-03 + for ; + Wed, 25 Aug 2004 11:26:17 +0000 (GMT) +Received: from usbb-lacimss2.unisys.com (usbb-lacimss2.unisys.com + [192.63.108.52]) + by svr1.postgresql.org (Postfix) with ESMTP id EF0AB5E3639 + for ; + Wed, 25 Aug 2004 08:26:14 -0300 (ADT) +Received: from usbb-lacgw2.lac.uis.unisys.com ([129.226.160.22]unverified) by + usbb-lacimss2 with InterScan Messaging Security Suite; + Wed, 25 Aug 2004 07:28:00 -0400 +Received: from usbb-lacgw2.lac.uis.unisys.com ([129.226.160.25]) by + usbb-lacgw2.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.47); + Wed, 25 Aug 2004 07:26:17 -0400 +Received: from gbmk-eugw2.eu.uis.unisys.com ([129.221.133.27]) by + usbb-lacgw2.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.47); + Wed, 25 Aug 2004 07:26:16 -0400 +Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by + gbmk-eugw2.eu.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Wed, 25 Aug 2004 12:26:06 +0100 +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: OT: Network config (WAS: RE: postgresql performance with multimedia) +Date: Wed, 25 Aug 2004 13:26:00 +0200 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] postgresql performance with multimedia +Thread-Index: AcSKk08DfnU6zSyLRpmzepr6Hs7XmgAAsCNA +From: "Leeuw van der, Tim" +To: "my ho" +Cc: +X-OriginalArrivalTime: 25 Aug 2004 11:26:06.0999 (UTC) + FILETIME=[504A4A70:01C48A96] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/335 +X-Sequence-Number: 7971 + +Hi, + +We're now getting very much off-topic about configuration of networking, bu= +t: + +- What is your OS? +- What output do you get when you type 'ping localhost' in any command-prom= +pt? + + +-----Original Message----- + +[...] +> I tried to put my_ip instead of "localhost" in +> bufmng.c and it seems to work (no more complaining). +[...] + +regards, + +--Tim + +From pgsql-performance-owner@postgresql.org Wed Aug 25 09:35:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 036505E46E1 + for ; + Wed, 25 Aug 2004 09:35:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43412-04 + for ; + Wed, 25 Aug 2004 12:35:47 +0000 (GMT) +Received: from dhcp-7-248.ma.lycos.com (waltham-nat.ma.lycos.com + [209.202.205.1]) + by svr1.postgresql.org (Postfix) with SMTP id C05595E46C3 + for ; + Wed, 25 Aug 2004 09:35:44 -0300 (ADT) +Received: (qmail 14912 invoked from network); 25 Aug 2004 12:57:48 -0000 +Received: from dhcp-7-129.ma.lycos.com (HELO ?10.124.7.129?) (10.124.7.129) + by dhcp-7-248.ma.lycos.com with SMTP; 25 Aug 2004 12:57:48 -0000 +In-Reply-To: <412C4C3A.2030001@coretech.co.nz> +References: <4124EB58.9040102@sh.nu> <200408241330.32484.josh@agliodbs.com> + <412C4C3A.2030001@coretech.co.nz> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <564D90B0-F693-11D8-AAA9-000D9366F0C4@torgo.978.org> +Content-Transfer-Encoding: 7bit +Cc: Daniel Ceregatti , pgsql-performance@postgresql.org, + Josh Berkus +From: Jeff +Subject: Re: What is the best way to do attribute/values? +Date: Wed, 25 Aug 2004 08:36:07 -0400 +To: Mark Kirkwood +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/336 +X-Sequence-Number: 7972 + + +On Aug 25, 2004, at 4:22 AM, Mark Kirkwood wrote: + +> select +> pav1.person_id +> from +> person_attributes_vertical pav1 +> where +> ( pav1.attribute_id = 1 +> and pav1.value_id in (2,3)) +> or ( pav1.attribute_id = 2 +> and pav1.value_id in (2,3)) +> + +You know.. +It may help if you toss in a group by +ie + +select pav1.person_id, count(*) from person_attributes_vertical pav1 +where (pav1.attribute_id = 1 and pav1.value_id in (2,3)) or ( ... ) or +(...) +group by pav1.person_id +order by count(*) desc + +that should give you the person_id's that matched the most +criteria........ +I've used similar things before now that I've thought about it. + +If you want an exact match you could put +"having count(*) = $myNumAttributes" in there too.. By definition an +exact match would match that definition.. + +it has an added side effect of producing "closest matches" when an +exact match cannot be found... granted you may not want that for a +dating site : ) + +"You asked for a blond female, blue eyes.. but I couldn't find any... +but I *DID* find a brown haired male with brown eyes! Is that good +enough?" + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Wed Aug 25 10:06:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E81545E46E1 + for ; + Wed, 25 Aug 2004 10:06:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57023-02 + for ; + Wed, 25 Aug 2004 13:06:34 +0000 (GMT) +Received: from usbb-lacimss2.unisys.com (usbb-lacimss2.unisys.com + [192.63.108.52]) + by svr1.postgresql.org (Postfix) with ESMTP id 230E15E46C3 + for ; + Wed, 25 Aug 2004 10:06:31 -0300 (ADT) +Received: from usbb-lacgw1.lac.uis.unisys.com ([129.226.160.21]unverified) by + usbb-lacimss2 with InterScan Messaging Security Suite; + Wed, 25 Aug 2004 09:08:17 -0400 +Received: from usbb-lacgw1.lac.uis.unisys.com ([129.226.160.23]) by + usbb-lacgw1.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Wed, 25 Aug 2004 09:06:26 -0400 +Received: from gbmk-eugw2.eu.uis.unisys.com ([129.221.133.27]) by + usbb-lacgw1.lac.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Wed, 25 Aug 2004 09:06:26 -0400 +Received: from nlshl-exch1.eu.uis.unisys.com ([192.39.239.20]) by + gbmk-eugw2.eu.uis.unisys.com with Microsoft SMTPSVC(6.0.3790.0); + Wed, 25 Aug 2004 14:05:56 +0100 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 +Subject: Re: What is the best way to do attribute/values? +Date: Wed, 25 Aug 2004 15:05:56 +0200 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] What is the best way to do attribute/values? +Thread-Index: AcSKoFAbm0wZ1IG9SsWWW5jFdXBEFgAAx42w +From: "Leeuw van der, Tim" +To: "Daniel Ceregatti" , +X-OriginalArrivalTime: 25 Aug 2004 13:05:56.0891 (UTC) + FILETIME=[428B46B0:01C48AA4] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/337 +X-Sequence-Number: 7973 + +Hi, + +On Aug 25, 2004, at 4:22 AM, Mark Kirkwood wrote: + +> select +> pav1.person_id +> from +> person_attributes_vertical pav1 +> where +> ( pav1.attribute_id =3D 1 +> and pav1.value_id in (2,3)) +> or ( pav1.attribute_id =3D 2 +> and pav1.value_id in (2,3)) +> + +[...] + +Why not combine attribute_id and value_id? Then you have nothing but an OR = +(or IN). + +It should, AFAICS, give you much better selectivity on your indexes: + +There will be a lot of attributes with the same ID; there will also be a lo= +t of attributes with the same value. However, there should be much less att= +ributes with a specific combination of (ID/Value). +Right now I think it will be very hard to determine which field has a bette= +r selectivity: attribute_id or value_id. + + +The combined attribute/value field could be an int8 or so, where the upper = +4 bytes are for attribute_id and the lower 4 bytes for value_id. +Depending on the number of attributes and possible values a smaller datatyp= +e and / or a different split can be made. A smaller datatype will result in= + faster access. + +What difference does that make? + +regards, + +--Tim + +From pgsql-performance-owner@postgresql.org Wed Aug 25 11:31:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 48E625E46E1 + for ; + Wed, 25 Aug 2004 11:31:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88495-09 + for ; + Wed, 25 Aug 2004 14:31:08 +0000 (GMT) +Received: from ucsns.ucs.co.za (ucs.co.za [196.23.43.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D1FC5E46C3 + for ; + Wed, 25 Aug 2004 11:30:58 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 382972BD7A; + Wed, 25 Aug 2004 16:30:49 +0200 (SAST) +Received: from ucsns.ucs.co.za ([127.0.0.1]) + by localhost (ucsns.ucs.co.za [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 19339-01; Wed, 25 Aug 2004 16:30:41 +0200 (SAST) +Received: from ucspost.ucs.co.za (mailgw1.ucs.co.za [196.23.43.253]) + by ucsns.ucs.co.za (Postfix) with ESMTP id 851CC2BD49; + Wed, 25 Aug 2004 16:30:41 +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 D0834D9E25; Wed, 25 Aug 2004 16:30:41 +0200 (SAST) +Received: from svb.ucs.co.za (svb.ucs.co.za [172.31.1.148]) + by jhb.ucs.co.za (Postfix) with SMTP + id 9BFEE97642; Wed, 25 Aug 2004 16:30:41 +0200 (SAST) +Date: Wed, 25 Aug 2004 16:30:41 +0200 +From: Stef +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Query kills machine. +Message-Id: <20040825163041.716d2103@svb.ucs.co.za> +In-Reply-To: <4015.1093361011@sss.pgh.pa.us> +References: <20040824103240.4d909777@svb.ucs.co.za> + <412B05A2.8070301@familyhealth.com.au> + <20040824153014.2a11d228@svb.ucs.co.za> + <4015.1093361011@sss.pgh.pa.us> +X-Mailer: Sylpheed-Claws 0.9.12 (GTK+ 1.2.10; i386-pc-linux-gnu) +User-Agent: sillypheed-claws (anti-aliased) +X-Face: GFoC95e6r)_TTG>n~=uFLojP=O~4W@Ms]>:.DMm/')(z3\Mwj^XP@? + Q:3";lD.OM1"^mDu}2NJ@US:)dO:U*iY5EM50&Tx. +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 ucs.co.za +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/338 +X-Sequence-Number: 7974 + +Tom Lane mentioned : +=> Not if you haven't got the RAM to support it :-( +=> +=> Another thing you might look at is ANALYZEing the tables again after +=> you've loaded all the new data. The row-count estimates seem way off +=> in these plans. You might need to increase the statistics target, +=> too, to get better plans. + +Thanks Tom, Christopher and Magnus! + +I tested this, and found the correct sort_mem setting for my situation. +I'm testing a new default_statistics_target setting. +This is something I never considered. + +Kind Regards +Stefan + +From pgsql-performance-owner@postgresql.org Wed Aug 25 12:06:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 539AE5E3631 + for ; + Wed, 25 Aug 2004 12:06:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 07831-04 + for ; + Wed, 25 Aug 2004 15:06:49 +0000 (GMT) +Received: from imf23aec.mail.bellsouth.net (imf23aec.mail.bellsouth.net + [205.152.59.71]) + by svr1.postgresql.org (Postfix) with ESMTP id 07B155E46EB + for ; + Wed, 25 Aug 2004 12:06:40 -0300 (ADT) +Received: from djprice ([67.33.32.20]) by imf23aec.mail.bellsouth.net + (InterMail vM.5.01.06.08 201-253-122-130-108-20031117) with SMTP + id <20040825150640.DKOR1796.imf23aec.mail.bellsouth.net@djprice> + for ; + Wed, 25 Aug 2004 11:06:40 -0400 +From: "David Price" +To: +Subject: Optimizer Selecting Incorrect Index +Date: Wed, 25 Aug 2004 11:07:27 -0400 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) +Importance: Normal +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/339 +X-Sequence-Number: 7975 + +I have 2 servers both with the exact same data, the same O.S., the same +version of Postgres (7.4.5) and the exact same db schema's (one production +server, one development server). One server is using the correct index for +SQL queries resulting in extremely slow performance, the other server is +properly selecting the index to use and performance is many times better. I +have tried vacuum, but that did not work. I finally resorted to dumping the +data, removing the database completely, creating a new database and +importing the data only to have to problem resurface. The table has +5,000,000+ rows on both the systems. + +When I run 'analyze verbose' on the correctly working system, the following +is displayed: + {INDEXSCAN + :startup_cost 0.00 + :total_cost 465.10 + :plan_rows 44 + :plan_width 118 + :targetlist ( + {TARGETENTRY + :resdom + {RESDOM + :resno 1 + :restype 23 + :restypmod -1 + :resname trn_integer + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 1 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 1 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 1 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 2 + :restype 23 + :restypmod -1 + :resname trn_patno + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 2 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 2 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 2 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 3 + :restype 1042 + :restypmod 5 + :resname trn_bill_inc + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 3 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 3 + :vartype 1042 + :vartypmod 5 + :varlevelsup 0 + :varnoold 1 + :varoattno 3 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 4 + :restype 1043 + :restypmod 13 + :resname trn_userid + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 4 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 4 + :vartype 1043 + :vartypmod 13 + :varlevelsup 0 + :varnoold 1 + :varoattno 4 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 5 + :restype 23 + :restypmod -1 + :resname trn_location + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 5 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 5 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 5 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 6 + :restype 1082 + :restypmod -1 + :resname trn_date + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 6 + :resjunk false + } + :expr + {VAR + :varno 1 + :varattno 6 + :vartype 1082 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 6 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 7 + :restype 23 + :restypmod -1 + :resname trn_sercode + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 7 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 7 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 7 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 8 + :restype 1043 + :restypmod 28 + :resname trn_descr + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 8 + :resjunk false + } + :expr + {VAR + :varno 1 + :varattno 8 + :vartype 1043 + :vartypmod 28 + :varlevelsup 0 + :varnoold 1 + :varoattno 8 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 9 + :restype 23 + :restypmod -1 + :resname trn_employr + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 9 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 9 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 9 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 10 + :restype 23 + :restypmod -1 + :resname trn_prof + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 10 + :resjunk false + } + :expr + {VAR + :varno 1 + :varattno 10 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 10 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 11 + :restype 1700 + :restypmod 720902 + :resname trn_amount + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 11 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 11 + :vartype 1700 + :vartypmod 720902 + :varlevelsup 0 + :varnoold 1 + :varoattno 11 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 12 + :restype 1043 + :restypmod 7 + :resname trn_tooth + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 12 + :resjunk false + } + :expr + {VAR + :varno 1 + :varattno 12 + :vartype 1043 + :vartypmod 7 + :varlevelsup 0 + :varnoold 1 + :varoattno 12 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 13 + :restype 1043 + :restypmod 10 + :resname trn_surface + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 13 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 13 + :vartype 1043 + :vartypmod 10 + :varlevelsup 0 + :varnoold 1 + :varoattno 13 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 14 + :restype 1042 + :restypmod 5 + :resname trn_flag + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 14 + :resjunk false + } + :expr + {VAR + :varno 1 + :varattno 14 + :vartype 1042 + :vartypmod 5 + :varlevelsup 0 + :varnoold 1 + :varoattno 14 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 15 + :restype 23 + :restypmod -1 + :resname trn_counter + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 15 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 15 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 15 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 16 + :restype 23 + :restypmod -1 + :resname trn_guarantr + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 16 + :resjunk false + } + :expr + {VAR + :varno 1 + :varattno 16 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 16 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 17 + :restype 1042 + :restypmod 5 + :resname trn_lab + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 17 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 17 + :vartype 1042 + :vartypmod 5 + :varlevelsup 0 + :varnoold 1 + :varoattno 17 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 18 + :restype 1082 + :restypmod -1 + :resname trn_old_date + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 18 + :resjunk false + } + :expr + {VAR + :varno 1 + :varattno 18 + :vartype 1082 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 18 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 19 + :restype 1042 + :restypmod 5 + :resname trn_hist_flag + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 19 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 19 + :vartype 1042 + :vartypmod 5 + :varlevelsup 0 + :varnoold 1 + :varoattno 19 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 20 + :restype 23 + :restypmod -1 + :resname trn_check_no + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 20 + :resjunk false + } + :expr + {VAR + :varno 1 + :varattno 20 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 20 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 21 + :restype 1043 + :restypmod 7 + :resname trn_commcode + :ressortgroupref 0 + :resorigtbl 789839 + :resorigcol 21 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 21 + :vartype 1043 + :vartypmod 7 + :varlevelsup 0 + :varnoold 1 + :varoattno 21 + } + } + ) + :qual ( + {OPEXPR + :opno 1098 + :opfuncid 1090 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 18 + :vartype 1082 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 18 + } + + {CONST + :consttype 1082 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ 91 -8 -1 -1 ] + } + ) + } + {OPEXPR + :opno 1096 + :opfuncid 1088 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 18 + :vartype 1082 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 18 + } + + {CONST + :consttype 1082 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ -96 6 0 0 ] + } + ) + } + + {OPEXPR + :opno 1054 + :opfuncid 1048 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 3 + :vartype 1042 + :vartypmod 5 + :varlevelsup 0 + :varnoold 1 + :varoattno 3 + } + + {CONST + :consttype 1042 + :constlen -1 + :constbyval false + :constisnull false + :constvalue 5 [ 5 0 0 0 66 ] + } + ) + } + ) + + :lefttree <> + :righttree <> + :initPlan <> + :extParam () + + :allParam () + + :nParamExec 0 + :scanrelid 1 + :indxid ( 7725589) + + :indxqual (( + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 1 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 2 + } + + {CONST + :consttype 23 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ 63 13 3 0 ] + } + ) + } + ) + ) + + :indxqualorig (( + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 2 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 2 + } + + {CONST + :consttype 23 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ 63 13 3 0 ] + } + ) + } + ) + ) + + :indxorderdir 1 + } + + Index Scan using trptserc on trans (cost=0.00..465.10 rows=44 width=118) + Index Cond: (trn_patno = 199999) + Filter: ((trn_old_date >= '1994-08-23'::date) AND (trn_old_date <= +'2004-08-23'::date) AND (trn_bill_inc = 'B'::bpchar)) +(687 rows) + + +Now, when I run 'analyze verbose' on the INCORRECTLY working system, the +following is displayed: + {INDEXSCAN + :startup_cost 0.00 + :total_cost 105165.74 + :plan_rows 1 + :plan_width 143 + :targetlist ( + {TARGETENTRY + :resdom + {RESDOM + :resno 1 + :restype 23 + :restypmod -1 + :resname trn_integer + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 1 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 1 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 1 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 2 + :restype 23 + :restypmod -1 + :resname trn_patno + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 2 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 2 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 2 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 3 + :restype 1042 + :restypmod 5 + :resname trn_bill_inc + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 3 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 3 + :vartype 1042 + :vartypmod 5 + :varlevelsup 0 + :varnoold 1 + :varoattno 3 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 4 + :restype 1043 + :restypmod 13 + :resname trn_userid + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 4 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 4 + :vartype 1043 + :vartypmod 13 + :varlevelsup 0 + :varnoold 1 + :varoattno 4 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 5 + :restype 23 + :restypmod -1 + :resname trn_location + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 5 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 5 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 5 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 6 + :restype 1082 + :restypmod -1 + :resname trn_date + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 6 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 6 + :vartype 1082 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 6 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 7 + :restype 23 + :restypmod -1 + :resname trn_sercode + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 7 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 7 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 7 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 8 + :restype 1043 + :restypmod 28 + :resname trn_descr + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 8 + :resjunk false + } + :expr + {VAR + :varno 1 + :varattno 8 + :vartype 1043 + :vartypmod 28 + :varlevelsup 0 + :varnoold 1 + :varoattno 8 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 9 + :restype 23 + :restypmod -1 + :resname trn_employer + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 9 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 9 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 9 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 10 + :restype 23 + :restypmod -1 + :resname trn_prof + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 10 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 10 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 10 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 11 + :restype 1700 + :restypmod 720902 + :resname trn_amount + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 11 + :resjunk false + } + :expr + {VAR + :varno 1 + :varattno 11 + :vartype 1700 + :vartypmod 720902 + :varlevelsup 0 + :varnoold 1 + :varoattno 11 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 12 + :restype 1043 + :restypmod 7 + :resname trn_tooth + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 12 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 12 + :vartype 1043 + :vartypmod 7 + :varlevelsup 0 + :varnoold 1 + :varoattno 12 + } + } + {TARGETENTRY + :resdom + {RESDOM + :resno 13 + :restype 1043 + :restypmod 10 + :resname trn_surface + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 13 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 13 + :vartype 1043 + :vartypmod 10 + :varlevelsup 0 + :varnoold 1 + :varoattno 13 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 14 + :restype 1042 + :restypmod 5 + :resname trn_flag + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 14 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 14 + :vartype 1042 + :vartypmod 5 + :varlevelsup 0 + :varnoold 1 + :varoattno 14 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 15 + :restype 23 + :restypmod -1 + :resname trn_counter + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 15 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 15 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 15 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 16 + :restype 23 + :restypmod -1 + :resname trn_guarantr + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 16 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 16 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 16 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 17 + :restype 1042 + :restypmod 5 + :resname trn_lab + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 17 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 17 + :vartype 1042 + :vartypmod 5 + :varlevelsup 0 + :varnoold 1 + :varoattno 17 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 18 + :restype 1082 + :restypmod -1 + :resname trn_old_date + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 18 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 18 + :vartype 1082 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 18 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 19 + :restype 1042 + :restypmod 5 + :resname trn_hist_flag + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 19 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 19 + :vartype 1042 + :vartypmod 5 + :varlevelsup 0 + :varnoold 1 + :varoattno 19 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 20 + :restype 23 + :restypmod -1 + :resname trn_check_no + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 20 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 20 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 20 + } + } + + {TARGETENTRY + :resdom + {RESDOM + :resno 21 + :restype 1043 + :restypmod 7 + :resname trn_commcode + :ressortgroupref 0 + :resorigtbl 2487466 + :resorigcol 21 + :resjunk false + } + + :expr + {VAR + :varno 1 + :varattno 21 + :vartype 1043 + :vartypmod 7 + :varlevelsup 0 + :varnoold 1 + :varoattno 21 + } + } + ) + :qual ( + {OPEXPR + :opno 96 + :opfuncid 65 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 2 + :vartype 23 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 2 + } + + {CONST + :consttype 23 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ 63 13 3 0 ] + } + ) + } + + {OPEXPR + :opno 1054 + :opfuncid 1048 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 3 + :vartype 1042 + :vartypmod 5 + :varlevelsup 0 + :varnoold 1 + :varoattno 3 + } + + {CONST + :consttype 1042 + :constlen -1 + :constbyval false + :constisnull false + :constvalue 5 [ 5 0 0 0 66 ] + } + ) + } + ) + + :lefttree <> + :righttree <> + :initPlan <> + :extParam () + + :allParam () + + :nParamExec 0 + :scanrelid 1 + :indxid ( 7762034) + + :indxqual (( + {OPEXPR + :opno 1098 + :opfuncid 1090 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 1 + :vartype 1082 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 18 + } + + {CONST + :consttype 1082 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ 91 -8 -1 -1 ] + } + ) + } + {OPEXPR + :opno 1096 + :opfuncid 1088 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 1 + :vartype 1082 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 18 + } + + {CONST + :consttype 1082 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ -96 6 0 0 ] + } + ) + } + ) + ) + + :indxqualorig (( + {OPEXPR + :opno 1098 + :opfuncid 1090 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 18 + :vartype 1082 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 18 + } + {CONST + :consttype 1082 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ 91 -8 -1 -1 ] + } + ) + } + + {OPEXPR + :opno 1096 + :opfuncid 1088 + :opresulttype 16 + :opretset false + :args ( + {VAR + :varno 1 + :varattno 18 + :vartype 1082 + :vartypmod -1 + :varlevelsup 0 + :varnoold 1 + :varoattno 18 + } + + {CONST + :consttype 1082 + :constlen 4 + :constbyval true + :constisnull false + :constvalue 4 [ -96 6 0 0 ] + } + ) + } + ) + ) + + :indxorderdir 1 + } + + Index Scan using todate on trans (cost=0.00..105165.74 rows=1 width=143) + Index Cond: ((trn_old_date >= '1994-08-23'::date) AND (trn_old_date <= +'2004-08-23'::date)) + Filter: ((trn_patno = 199999) AND (trn_bill_inc = 'B'::bpchar)) +(713 rows) + + +So, you see the query optimizer has choosen different indices the two +systems - one correctly and the other incorrectly on the exact same set of +data???? I can change the query to reduce the number of arguments and then +perform a subquery (in my java code) but I am afraid there is an internal +problem that will crop up somewhere else. + + + +From pgsql-performance-owner@postgresql.org Wed Aug 25 12:47:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 15DC75E46D2 + for ; + Wed, 25 Aug 2004 12:47:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 25319-05 + for ; + Wed, 25 Aug 2004 15:47:29 +0000 (GMT) +Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net + [194.217.242.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D6835E46CD + for ; + Wed, 25 Aug 2004 12:47:20 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) + id 1Bzzzh-000KqW-0b; Wed, 25 Aug 2004 15:47:26 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 674A91760B; Wed, 25 Aug 2004 16:47:19 +0100 (BST) +Message-ID: <412CB487.6060704@archonet.com> +Date: Wed, 25 Aug 2004 16:47:19 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: David Price +Cc: pgsql-performance@postgresql.org +Subject: Re: Optimizer Selecting Incorrect Index +References: +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/340 +X-Sequence-Number: 7976 + +David Price wrote: +> I have 2 servers both with the exact same data, the same O.S., the same +> version of Postgres (7.4.5) and the exact same db schema's (one production +> server, one development server). One server is using the correct index for +> SQL queries resulting in extremely slow performance, the other server is +> properly selecting the index to use and performance is many times better. I +> have tried vacuum, but that did not work. I finally resorted to dumping the +> data, removing the database completely, creating a new database and +> importing the data only to have to problem resurface. The table has +> 5,000,000+ rows on both the systems. +> +> When I run 'analyze verbose' on the correctly working system, the following +> is displayed: + +EXPLAIN ANALYZE is usually considered enough + +> Index Scan using trptserc on trans (cost=0.00..465.10 rows=44 width=118) +> Index Cond: (trn_patno = 199999) +> Filter: ((trn_old_date >= '1994-08-23'::date) AND (trn_old_date <= +> '2004-08-23'::date) AND (trn_bill_inc = 'B'::bpchar)) +> (687 rows) +> +> +> Now, when I run 'analyze verbose' on the INCORRECTLY working system, the +> following is displayed: + +> Index Scan using todate on trans (cost=0.00..105165.74 rows=1 width=143) +> Index Cond: ((trn_old_date >= '1994-08-23'::date) AND (trn_old_date <= +> '2004-08-23'::date)) +> Filter: ((trn_patno = 199999) AND (trn_bill_inc = 'B'::bpchar)) +> (713 rows) + +These queries are different. The first returns 687 rows and the second +713 rows. You need to check your systems if they are supposed to be +identical. + +Things to check: +1. postgresql.conf settings match - different costs could cause this +2. statistics on the two columns (trn_patno,trn_old_date) - if they +differ considerably between systems that would also explain it. + +I suspect the second one, at a wild guess the working system happens to +know 199999 is fairly rare wheras the second just estimates an average. + +If the stats don't help, people are going to want to see the entire +query+plan. Could you repost with the query and explain analyse on both +system. Oh, and some idea on how many rows/unique values are involved in +the important columns. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Aug 25 13:59:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CBC65E46CD + for ; + Wed, 25 Aug 2004 13:59:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52613-07 + for ; + Wed, 25 Aug 2004 16:59:34 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D9025E3631 + for ; + Wed, 25 Aug 2004 13:59:33 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6172708 for pgsql-performance@postgresql.org; + Wed, 25 Aug 2004 10:00:48 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: What is the best way to do attribute/values? +Date: Wed, 25 Aug 2004 09:59:15 -0700 +User-Agent: KMail/1.4.3 +References: <4124EB58.9040102@sh.nu> <200408241330.32484.josh@agliodbs.com> + <412C4C3A.2030001@coretech.co.nz> +In-Reply-To: <412C4C3A.2030001@coretech.co.nz> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408250959.15946.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/341 +X-Sequence-Number: 7977 + +Mark, Tim, + +> select +> pav1.person_id +> from +> person_attributes_vertical pav1 +> where +> ( pav1.attribute_id = 1 +> and pav1.value_id in (2,3)) +> or ( pav1.attribute_id = 2 +> and pav1.value_id in (2,3)) + +Not the same query, sorry. Daniel's query yields all the person_id's which +have criteria A AND criteria B. Yours gives all the person_id's which have +criteria A OR criteria B. + +> There will be a lot of attributes with the same ID; there will also be a +> lot of attributes with the same value. However, there should be much less +> attributes with a specific combination of (ID/Value). Right now I think it +> will be very hard to determine which field has a better selectivity: +> attribute_id or value_id. + +Given that there is already an index on ( attribute_id, value_id ) I don't +quite see what difference this makes. Unless you're suggesting this as a +workaround for the PG Planner's poor use of the index? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Aug 25 16:08:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AE2D25E40AC + for ; + Wed, 25 Aug 2004 16:08:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06636-02 + for ; + Wed, 25 Aug 2004 19:08: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 68CFC5E40BA + for ; + Wed, 25 Aug 2004 16:08:05 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7PJ81NR002138; + Wed, 25 Aug 2004 15:08:02 -0400 (EDT) +To: Richard Huxton +Cc: David Price , + pgsql-performance@postgresql.org +Subject: Re: Optimizer Selecting Incorrect Index +In-reply-to: <412CB487.6060704@archonet.com> +References: + <412CB487.6060704@archonet.com> +Comments: In-reply-to Richard Huxton + message dated "Wed, 25 Aug 2004 16:47:19 +0100" +Date: Wed, 25 Aug 2004 15:08:01 -0400 +Message-ID: <2137.1093460881@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/342 +X-Sequence-Number: 7978 + +Richard Huxton writes: +> Things to check: +> 1. postgresql.conf settings match - different costs could cause this +> 2. statistics on the two columns (trn_patno,trn_old_date) - if they +> differ considerably between systems that would also explain it. + +The different estimated row counts could only come from #2. I suspect +David has forgotten to run ANALYZE on the second system. + +I agree that EXPLAIN VERBOSE output is not helpful... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Aug 25 18:09:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 11FF25E46F2 + for ; + Wed, 25 Aug 2004 18:09:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51264-04 + for ; + Wed, 25 Aug 2004 21:09:38 +0000 (GMT) +Received: from bramble.mmrd.com (bramble.mmrd.com [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id D095E5E46EB + for ; + Wed, 25 Aug 2004 18:09:36 -0300 (ADT) +Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) + by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id i7PJtC9U001422 + for ; Wed, 25 Aug 2004 15:55:12 -0400 +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 i7PL9cm06059 + for ; Wed, 25 Aug 2004 17:09:38 -0400 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id R4AMYGF5; Wed, 25 Aug 2004 17:09:36 -0400 +Subject: Anyone familiar with Apple Xserve RAID +From: Robert Treat +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 25 Aug 2004 17:09:37 -0400 +Message-Id: <1093468177.12331.424.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/343 +X-Sequence-Number: 7979 + +Just curious if folks have ever used this for a postgresql server and if +they used it with OSX/BSD/Linux. Even if you haven't used it, if you +know of something comparable I'd be interested. TIA + +http://store.apple.com/1-800-MY-APPLE/WebObjects/AppleStore.woa/72103/wo/oC2xGlPM9M2i3UsLG0f1PaalTlE/0.0.9.1.0.6.13.0.3.1.3.0.7.12.1.1.0 + + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Wed Aug 25 18:22:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 06B935E37D0 + for ; + Wed, 25 Aug 2004 18:22:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55134-05 + for ; + Wed, 25 Aug 2004 21:22:23 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 157F05E3632 + for ; + Wed, 25 Aug 2004 18:22:22 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6174714; Wed, 25 Aug 2004 14:23:41 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Robert Treat , + pgsql-performance@postgresql.org +Subject: Re: Anyone familiar with Apple Xserve RAID +Date: Wed, 25 Aug 2004 14:22:08 -0700 +User-Agent: KMail/1.4.3 +References: <1093468177.12331.424.camel@camel> +In-Reply-To: <1093468177.12331.424.camel@camel> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408251422.08366.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/344 +X-Sequence-Number: 7980 + +Robert, + +> Just curious if folks have ever used this for a postgresql server and if +> they used it with OSX/BSD/Linux. Even if you haven't used it, if you +> know of something comparable I'd be interested. TIA + +Last I checked Apple was still shipping the XServes with SATA drives and a +PROMISE controller, both very consumer-grade (and not server-grade) hardware. +I can't recommend the XServe as a database platform. SCSI still makes a +difference for databases, more because of the controllers than anything else. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Aug 25 19:48:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A8AB85E46CF + for ; + Wed, 25 Aug 2004 19:48:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83739-01 + for ; + Wed, 25 Aug 2004 22:48:32 +0000 (GMT) +Received: from mx.noos.fr (pm-mx4.mgn.net [195.46.220.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 993715E3F15 + for ; + Wed, 25 Aug 2004 19:48:30 -0300 (ADT) +Received: from localhost (pm-mnet3.mgn.net [195.46.220.218]) + by mx.noos.fr (Postfix) with SMTP id 03BAE26969 + for ; + Thu, 26 Aug 2004 00:48:32 +0200 (MEST) +X-Mailbox-Line: From footcow@noos.fr Thu Aug 26 00:48:32 2004 +Received: from e115.dhcp212-198-145.noos.fr (e115.dhcp212-198-145.noos.fr + [212.198.145.115]) by pm-mnet3.mgn.net with ESMTP; + Thu, 26 Aug 2004 00:48:32 (MEST) +From: =?iso-8859-15?q?Herv=E9_Piedvache?= +To: pgsql-performance@postgresql.org +Subject: TSearch2 and optimisation ... +Date: Thu, 26 Aug 2004 00:48:32 +0200 +User-Agent: KMail/1.6.2 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-15" +Content-Transfer-Encoding: 7bit +Message-Id: <200408260048.32274.footcow@noos.fr> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/345 +X-Sequence-Number: 7981 + +Hi, + +I'm a little beginner with Tsearch2 .... + +I have simples tables like this : + +# \d article + Table "public.article" + Column | Type | +Modifiers +------------+-----------------------------+----------------------------------------------------------------- + id | integer | not null default +nextval('public.article_rss_id_rss_seq'::text) + id_site | integer | not null + title | text | + url | text | + desc | text | + r_date | timestamp without time zone | default now() + r_update | timestamp without time zone | default now() + idxfti | tsvector | +Indexes: + "article_id_key" unique, btree (id) + "idxfti_idx" gist (idxfti) + "ix_article_update" btree (r_update) + "ix_article_url" btree (url) + "ix_id_site" btree (id_site) +Foreign-key constraints: + "$1" FOREIGN KEY (id_site) REFERENCES site (id_site) +Triggers: + tsvectorupdate BEFORE INSERT OR UPDATE ON article FOR EACH ROW EXECUTE +PROCEDURE tsearch2('idxfti', 'title', 'desc') + +# \d site_rss + Table "public.site" + Column | Type | Modifiers +--------------+---------+--------------------------------------------------------------- + id_site | integer | not null default +nextval('public.site_id_site_seq'::text) + site_name | text | + site_url | text | +url | text | + language | text | + datecrea | date | default now() + id_category | integer | + time_refresh | integer | + active | integer | + error | integer | +Indexes: + "site_id_site_key" unique, btree (id_site) + "ix_site_id_category" btree (id_category) + "ix_site_url" btree (url) + +# \d user_choice + Table "public.user_choice" + Column | Type | Modifiers +---------+---------+----------- + id_user | integer | + id_site | integer | +Indexes: + "ix_user_choice_all" unique, btree (id_user, id_site) + +I have done a simple request, looking for title or description having Postgres +inside order by rank and date, like this : +SELECT a.title, a.id, a.url, to_char(a.r_date, 'DD/MM/YYYY HH24:MI:SS') as dt, +s.site_name, s.id_site, case when exists (select id_user from user_choice u +where u.id_site=s.id_site and u.id_user = 1) then 1 else 0 end as bookmarked + FROM article a, site s + WHERE s.id_site = a.id_site + AND idxfti @@ to_tsquery('postgresql') + ORDER BY rank(idxfti, to_tsquery('postgresql')) DESC, a.r_date DESC; + +The request takes about 4 seconds ... I have about 1 400 000 records in +article and 36 000 records in site table ... it's a Bi-Pentium III 933 MHz +server with 1 Gb memory ... I'm using Postgresql 7.4.5 +For me this result is very very slow I really need a quicker result with less +than 1 second ... +The next time I call the same request I have got the result in 439 ms ... but +If I replace "Postgresql" in my find with "Linux" for example I will get the +next result in 5 seconds ... :o( + +Is it a bad use of Tsearch2 ... or a bad table structure ... or from my +request ... ? I have no idea how to optimise this ... + +Explain gives me this result : + QUERY PLAN +----------------------------------------------------------------------------------------------------------- + Sort (cost=10720.91..10724.29 rows=1351 width=191) + Sort Key: rank(a.idxfti, '\'postgresql\''::tsquery), a.r_date + -> Merge Join (cost=4123.09..10650.66 rows=1351 width=191) + Merge Cond: ("outer".id_site = "inner".id_site) + -> Index Scan using site_id_site_key on site s (cost=0.00..2834.96 +rows=35705 width=28) + -> Sort (cost=4123.09..4126.47 rows=1351 width=167) + Sort Key: a.id_site + -> Index Scan using idxfti_idx on article a +(cost=0.00..4052.84 rows=1351 width=167) + Index Cond: (idxfti @@ '\'postgresql\''::tsquery) + Filter: (idxfti @@ '\'postgresql\''::tsquery) + SubPlan + -> Seq Scan on user_choice u (cost=0.00..2.69 rows=1 width=4) + Filter: ((id_site = $0) AND (id_user = 1)) +(13 rows) + +Any idea are well done ;o) + +Regards, +-- +Bill Footcow + + +From pgsql-performance-owner@postgresql.org Wed Aug 25 19:52:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9765A5E46C1 + for ; + Wed, 25 Aug 2004 19:52:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85087-01 + for ; + Wed, 25 Aug 2004 22:52:08 +0000 (GMT) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id D2F3A5E3F15 + for ; + Wed, 25 Aug 2004 19:52:06 -0300 (ADT) +Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1C06cj-0006kj-00 + for ; Thu, 26 Aug 2004 00:52:09 +0200 +Received: from sp-260-1.net4.netcentrix.net ([4.21.254.118]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Thu, 26 Aug 2004 00:52:09 +0200 +Received: from doug by sp-260-1.net4.netcentrix.net with local (Gmexim 0.1 + (Debian)) id 1AlnuQ-0007hv-00 + for ; Thu, 26 Aug 2004 00:52:09 +0200 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +From: Doug McNaught +Subject: Re: Anyone familiar with Apple Xserve RAID +Date: Wed, 25 Aug 2004 18:52:05 -0400 +Lines: 20 +Message-ID: <87657625m2.fsf@asmodeus.mcnaught.org> +References: <1093468177.12331.424.camel@camel> + <200408251422.08366.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@sea.gmane.org +X-Gmane-NNTP-Posting-Host: sp-260-1.net4.netcentrix.net +User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (gnu/linux) +Cancel-Lock: sha1:jJrPYl+p52w72Rsl6T7C7xCvEws= +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/346 +X-Sequence-Number: 7982 + +Josh Berkus writes: + +> Robert, +> +>> Just curious if folks have ever used this for a postgresql server and if +>> they used it with OSX/BSD/Linux. Even if you haven't used it, if you +>> know of something comparable I'd be interested. TIA +> +\> Last I checked Apple was still shipping the XServes with SATA drives +> and a PROMISE controller, both very consumer-grade (and not +> server-grade) hardware. I can't recommend the XServe as a database +> platform. SCSI still makes a difference for databases, more because +> of the controllers than anything else. + +The XServe RAID is fibre-channel. + +-Doug +-- +Let us cross over the river, and rest under the shade of the trees. + --T. J. Jackson, 1863 + + +From pgsql-performance-owner@postgresql.org Wed Aug 25 21:50:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 30F8E5E46CF + for ; + Wed, 25 Aug 2004 19:58:28 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84618-04 + for ; + Wed, 25 Aug 2004 22:58:27 +0000 (GMT) +Received: from cis-computer.com (unknown [161.58.219.53]) + by svr1.postgresql.org (Postfix) with ESMTP id 7119A5E46C1 + for ; + Wed, 25 Aug 2004 19:58:25 -0300 (ADT) +Received: from [192.168.1.209] (p54878C88.dip.t-dialin.net [84.135.140.136]) + by cis-computer.com (8.12.11/8.11.6) with ESMTP id i7PMwOHN000515; + Thu, 26 Aug 2004 00:58:25 +0200 (CEST) +In-Reply-To: <1093468177.12331.424.camel@camel> +References: <1093468177.12331.424.camel@camel> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <44DB74D0-F6EA-11D8-ACDB-000393DB553C@bahn.de> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Ralf Schramm +Subject: Re: Anyone familiar with Apple Xserve RAID +Date: Thu, 26 Aug 2004 00:58:24 +0200 +To: Robert Treat +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/351 +X-Sequence-Number: 7987 + +we checked a XServe/XRaid system some months ago and +especially the relation price/space/performance was OK +compared to a HP/Intel maschine. Tomorrow I'll try to +find the performance charts on my harddisc and post the +links to the list. You get a huge amount of raid-space +for a good price. + +We plan to get one to do our web-statistics there with +about 150 MegaPageImpressions a month. + +Ralf Schramm + + +Am 25.08.2004 um 23:09 schrieb Robert Treat: + +> Just curious if folks have ever used this for a postgresql server and +> if +> they used it with OSX/BSD/Linux. Even if you haven't used it, if you +> know of something comparable I'd be interested. TIA +> +> http://store.apple.com/1-800-MY-APPLE/WebObjects/AppleStore.woa/72103/ +> wo/oC2xGlPM9M2i3UsLG0f1PaalTlE/0.0.9.1.0.6.13.0.3.1.3.0.7.12.1.1.0 +> +> +> Robert Treat +> -- +> Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Wed Aug 25 21:50:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 37D5A5E3F15 + for ; + Wed, 25 Aug 2004 20:04:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85282-06 + for ; + Wed, 25 Aug 2004 23:03:57 +0000 (GMT) +Received: from cis-computer.com (unknown [161.58.219.53]) + by svr1.postgresql.org (Postfix) with ESMTP id 7AF125E46D1 + for ; + Wed, 25 Aug 2004 20:03:56 -0300 (ADT) +Received: from [192.168.1.209] (p54878C88.dip.t-dialin.net [84.135.140.136]) + by cis-computer.com (8.12.11/8.11.6) with ESMTP id i7PN3quD003079; + Thu, 26 Aug 2004 01:03:53 +0200 (CEST) +In-Reply-To: <200408251422.08366.josh@agliodbs.com> +References: <1093468177.12331.424.camel@camel> + <200408251422.08366.josh@agliodbs.com> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <08139423-F6EB-11D8-ACDB-000393DB553C@bahn.de> +Content-Transfer-Encoding: 7bit +Cc: Robert Treat , + pgsql-performance@postgresql.org +From: Ralf Schramm +Subject: Re: Anyone familiar with Apple Xserve RAID +Date: Thu, 26 Aug 2004 01:03:52 +0200 +To: Josh Berkus +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/352 +X-Sequence-Number: 7988 + +the XServe/XRaid comes with FibreChannel + +Here some infos: +http://www.apple.com/xserve/raid/architecture.html +http://www.apple.com/xserve/raid/fibre_channel.html +http://www.apple.com/xserve/architecture.html + +Ralf Schramm + + +Am 25.08.2004 um 23:22 schrieb Josh Berkus: + +> Robert, +> +>> Just curious if folks have ever used this for a postgresql server and +>> if +>> they used it with OSX/BSD/Linux. Even if you haven't used it, if you +>> know of something comparable I'd be interested. TIA +> +> Last I checked Apple was still shipping the XServes with SATA drives +> and a +> PROMISE controller, both very consumer-grade (and not server-grade) +> hardware. +> I can't recommend the XServe as a database platform. SCSI still makes +> a +> difference for databases, more because of the controllers than +> anything else. +> +> -- +> Josh Berkus +> Aglio Database Solutions +> San Francisco + + +From pgsql-performance-owner@postgresql.org Wed Aug 25 20:49:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 96EC35E46C1 + for ; + Wed, 25 Aug 2004 20:49:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 97433-04 + for ; + Wed, 25 Aug 2004 23:49:17 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id A2D5B5E46EC + for ; + Wed, 25 Aug 2004 20:49:15 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6175988; Wed, 25 Aug 2004 16:50:37 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Ralf Schramm +Subject: Re: Anyone familiar with Apple Xserve RAID +Date: Wed, 25 Aug 2004 16:49:02 -0700 +User-Agent: KMail/1.4.3 +Cc: Robert Treat , + pgsql-performance@postgresql.org +References: <1093468177.12331.424.camel@camel> + <200408251422.08366.josh@agliodbs.com> + <08139423-F6EB-11D8-ACDB-000393DB553C@bahn.de> +In-Reply-To: <08139423-F6EB-11D8-ACDB-000393DB553C@bahn.de> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408251649.02932.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/347 +X-Sequence-Number: 7983 + +Guys, + +> the XServe/XRaid comes with FibreChannel + +I stand corrected. That should help things some; it makes it more of a small +tradeoff between performance and storage size for the drives. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Aug 25 20:51:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E3955E46C1 + for ; + Wed, 25 Aug 2004 20:51:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95479-08 + for ; + Wed, 25 Aug 2004 23:51:07 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id DA8865E46EE + for ; + Wed, 25 Aug 2004 20:51:05 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6176004; Wed, 25 Aug 2004 16:52:27 -0700 +Content-Type: text/plain; + charset="iso-8859-15" +From: Josh Berkus +Organization: Aglio Database Solutions +To: =?iso-8859-15?q?Herv=E9=20Piedvache?= , + pgsql-performance@postgresql.org +Subject: Re: TSearch2 and optimisation ... +Date: Wed, 25 Aug 2004 16:50:53 -0700 +User-Agent: KMail/1.4.3 +References: <200408260048.32274.footcow@noos.fr> +In-Reply-To: <200408260048.32274.footcow@noos.fr> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408251650.53233.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/348 +X-Sequence-Number: 7984 + +Herve' + +> The request takes about 4 seconds ... I have about 1 400 000 records in +> article and 36 000 records in site table ... it's a Bi-Pentium III 933 MHz +> server with 1 Gb memory ... I'm using Postgresql 7.4.5 +> For me this result is very very slow I really need a quicker result with +> less than 1 second ... +> The next time I call the same request I have got the result in 439 ms ... +> but If I replace "Postgresql" in my find with "Linux" for example I will +> get the next result in 5 seconds ... :o( + +Hmmm. It sounds like your system is unable to keep all of the data cached in +memory. What else do you have going on on that machine? + +> Explain gives me this result : + +Please do "EXPLAIN ANALYZE" so that we can see where time is actually spent. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Aug 25 21:22:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 662795E3F15 + for ; + Wed, 25 Aug 2004 21:22:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 02701-10 + for ; + Thu, 26 Aug 2004 00:21:57 +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 4A9F45E3631 + for ; + Wed, 25 Aug 2004 21:21:53 -0300 (ADT) +Received: from modem-4024.leopard.dialup.pol.co.uk ([217.135.159.184] + helo=happyplace) by cmailm1.svr.pol.co.uk with smtp (Exim 4.14) + id 1C081b-0000QI-Qd; Thu, 26 Aug 2004 01:21:56 +0100 +From: "Simon Riggs" +To: "Daniel Ceregatti" , +Subject: Re: What is the best way to do attribute/values? +Date: Thu, 26 Aug 2004 01:38:16 +0100 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +Importance: Normal +In-Reply-To: <4124EB58.9040102@sh.nu> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/349 +X-Sequence-Number: 7985 + + +Two more unusual suggestions: + +1. Drop all the indexes and just do sequential scans (full table scans), +aiming as hard as possible to get the whole people table to fit in memory +(size says that should be easy - various ways) - and make sure you're using +8.0 so you have the best cache manager. This will at least give you +consistent performance on whatever attribute values searched on in user +queries. Dropping all the indexes will allow the query to optimize faster, +since it has only one path choice. Work out how many attributes it takes to +reduce the list of candidates to a manageable number, and include only those +factors into the table, effectively vertically partitioning the table, +thereby reducing the volume and increasing scan speed. Then redesign the +user interface so that they see a two-stage process, first stage is top N +common attributes, second stage is to further reduce that down using rarer +attributes, as well as using the output from the first table to index into +the second. Users then won't mind additional wait time. +(Experiment with: Horizontally partition the table into N pieces. Issue N +simultaneous queries to simulate a parallel query. Try N == 2 on your box) + +2. You can try forcing the use of a Star Join optimization here: +Concatenate the attribute values into a single column, then index it. This +will be nearly unique. Cluster the table. +Permute the values of the attributes, to give you a list of concatenated +keys that would match, then join that list to the main table, using a join +via the index. +You can do this permutation by using a reference table per attribute, then +doing an unconstrained product join between all of the attribute tables +(avoid any indexes on them) and assembling the candidate keys into a single +temporary table. Then join the temp table to the main people table. This +will only work effectively if people's attributes are selected with some +discrimination, otherwise this optimisation will fail. You'd need to +constrain the user interface to "pick 20 out of the following 100 attribute +values" or some other heuristic to ensure a relatively low count, or use a +LIMIT on the query into the temp table. +This sounds long winded, but is essentially the route the Oracle optimizer +takes in performing a star join....you clearly know you're Oracle, so look +that up to confirm what I'm saying. (May not work as well if you use a +sub-select on PostgreSQL....) + +Also, I'd categorise the Age, Height, Weight and Salary attributes and +everything else based upon most common ranges, so it will be just an +equality search on an integer assigned to that category, rather than a > +search. Order by the distance, don't search on it, it'll be quicker since +you'll only need to calculate it for the records that match...even if you do +get a few too many, it would be a shame to avoid somebody because they lived +1 mile outside of the stated radius. + +The database sounds < 1 Gb in total logical volume, so 4Gb of RAM should be +easily sufficient. + +Best Regards, Simon Riggs + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Daniel +> Ceregatti +> Sent: 19 August 2004 19:03 +> To: pgsql-performance@postgresql.org +> Subject: [PERFORM] What is the best way to do attribute/values? +> +> +> Hi list, +> +> I have a database with 1M "people" in it. Each person has about 20 +> attributes, such as height, weight, eye color, etc. I need to be able to +> search for people based on these attributes. A search can be conducted +> on one attribute, all attributes, or any number in between. How would +> _you_ do this? +> +> I have already attempted to answer this. My attempts are detailed here: +> +> http://sh.nu/email.txt +> +> This is the email I was originally going to send to this list. Since +> it's so large, I decided to link to it instead. If you feel that it +> belongs in a post to the list, let me know, and I'll post again. +> +> I've discussed these attempts with people in #postgresql on +> irc.freenode.net. Agliodbs (I presume you know who this is) was very +> helpful, but in end was at a loss. I find myself in the same postition +> at this time. He suggested I contact this list. +> +> My ultimate goal is performance. This _must_ be fast. And by fast, I +> mean, < 1 second, for every permutation of the number of attributes +> searched for. Flexibility would be a bonus, but at this point I'll +> settle for something that's harder to maintain if I can get the speed +> gain I need. +> +> Thanks, +> +> Daniel Ceregatti +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster + + +From pgsql-performance-owner@postgresql.org Wed Aug 25 22:13:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4142A5E46F8 + for ; + Wed, 25 Aug 2004 22:13:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21706-10 + for ; + Thu, 26 Aug 2004 01:13:11 +0000 (GMT) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CAF65E3639 + for ; + Wed, 25 Aug 2004 22:13:07 -0300 (ADT) +Received: from [192.168.0.40] (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + i7Q1D8Ui008822; Thu, 26 Aug 2004 09:13:08 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <412D39E1.2040304@familyhealth.com.au> +Date: Thu, 26 Aug 2004 09:16:17 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Mischa Sandberg +Cc: pgsql-performance@postgresql.org +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +References: +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/353 +X-Sequence-Number: 7989 + +> I see that PG has a one-shot CLUSTER command, but doesn't support +> continuously-updated clustered indexes. +> +> What I infer from newsgroup browsing is, such an index is impossible, +> given the MVCC versioning of records (happy to learn I'm wrong). +> +> I'd be curious to know what other people, who've crossed this same +> bridge from MSSQL or Oracle or Sybase to PG, have devised, +> faced with the same kind of desired performance gain for retrieving +> blocks of rows with the same partial key. + +I just run clusterdb each weekend in a cron job... + +Chris + +From pgsql-performance-owner@postgresql.org Thu Aug 26 01:49:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A0B705E3639 + for ; + Thu, 26 Aug 2004 01:49:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88484-05 + for ; + Thu, 26 Aug 2004 04:49:17 +0000 (GMT) +Received: from linda-2.paradise.net.nz (bm-2a.paradise.net.nz [202.0.58.21]) + by svr1.postgresql.org (Postfix) with ESMTP id C99F15E3632 + for ; + Thu, 26 Aug 2004 01:49:08 -0300 (ADT) +Received: from smtp-1.paradise.net.nz (smtp-1b.paradise.net.nz [202.0.32.210]) + by linda-2.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0I3100D0LEQ2DT@linda-2.paradise.net.nz> for + pgsql-performance@postgresql.org; Thu, 26 Aug 2004 16:49:15 +1200 (NZST) +Received: from [192.168.1.11] + (203-79-100-184.adsl.paradise.net.nz [203.79.100.184]) + by smtp-1.paradise.net.nz (Postfix) with ESMTP id 5AF3882A7F; Thu, + 26 Aug 2004 16:49:14 +1200 (NZST) +Date: Thu, 26 Aug 2004 16:51:50 +1200 +From: Mark Kirkwood +Subject: Re: What is the best way to do attribute/values? +In-reply-to: <200408250959.15946.josh@agliodbs.com> +To: Josh Berkus +Cc: pgsql-performance@postgresql.org +Message-id: <412D6C66.2070207@coretech.co.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8a2) Gecko/20040715 +References: <4124EB58.9040102@sh.nu> <200408241330.32484.josh@agliodbs.com> + <412C4C3A.2030001@coretech.co.nz> + <200408250959.15946.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/354 +X-Sequence-Number: 7990 + + +Josh Berkus wrote: + +>Mark, Tim, +> +> +> +>>select +>> pav1.person_id +>>from +>> person_attributes_vertical pav1 +>>where +>> ( pav1.attribute_id = 1 +>> and pav1.value_id in (2,3)) +>> or ( pav1.attribute_id = 2 +>> and pav1.value_id in (2,3)) +>> +>> +> +>Not the same query, sorry. Daniel's query yields all the person_id's which +>have criteria A AND criteria B. Yours gives all the person_id's which have +>criteria A OR criteria B. +> +> +> +Apologies, not thinking clearly enough there... + + +Maybe try out intersection : + + +select + pav1.person_id +from + person_attributes_vertical pav1 +where + ( pav1.attribute_id = 1 + and pav1.value_id in (2,3)) +intersect +select + pav1.person_id +from + person_attributes_vertical pav1 +where ( pav1.attribute_id = 2 + and pav1.value_id in (2,3)) + + +In the advent that is unhelpful, I wonder about simplifying the +situation and investigating how + + +select + pav1.person_id +from + person_attributes_vertical pav1 +where + pav1.attribute_id = 1 + + +performs, compared to + + +select + pav1.person_id +from + person_attributes_vertical pav1 +where + ( pav1.attribute_id = 1 + and pav1.value_id in (2,3)) + + +If the first performs ok and the second does not, It may be possible to +get better times by doing some horrible re-writes :e.g: + + +select + pav1.person_id +from + person_attributes_vertical pav1 +where + ( pav1.attribute_id = 1 + and pav1.value_id||null in (2,3)) + + +etc. + + +regards + +Mark + + + + + +From pgsql-performance-owner@postgresql.org Thu Aug 26 03:16:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E836B5E46E7 + for ; + Thu, 26 Aug 2004 03:15:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 12836-02 + for ; + Thu, 26 Aug 2004 06:15:53 +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 A6D565E46CC + for ; + Thu, 26 Aug 2004 03:15:52 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 4D8038467; Thu, 26 Aug 2004 08:15:52 +0200 (CEST) +Date: Thu, 26 Aug 2004 08:15:52 +0200 (CEST) +From: Dennis Bjorklund +To: Richard Huxton +Cc: David Price , + +Subject: Re: Optimizer Selecting Incorrect Index +In-Reply-To: <412CB487.6060704@archonet.com> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/355 +X-Sequence-Number: 7991 + +On Wed, 25 Aug 2004, Richard Huxton wrote: + +> > Index Scan using trptserc on trans (cost=0.00..465.10 rows=44 width=118) +> > Index Cond: (trn_patno = 199999) +> > Filter: ((trn_old_date >= '1994-08-23'::date) AND (trn_old_date <= +> > '2004-08-23'::date) AND (trn_bill_inc = 'B'::bpchar)) +> > (687 rows) +> +> > Index Scan using todate on trans (cost=0.00..105165.74 rows=1 width=143) +> > Index Cond: ((trn_old_date >= '1994-08-23'::date) AND (trn_old_date <= +> > '2004-08-23'::date)) +> > Filter: ((trn_patno = 199999) AND (trn_bill_inc = 'B'::bpchar)) +> > (713 rows) +> +> These queries are different. The first returns 687 rows and the second +> 713 rows. + +The 687 and 713 are the number of rows in the plan, not the number of rows +the queries return. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Thu Aug 26 04:22:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 91A375E46E7 + for ; + Thu, 26 Aug 2004 04:22:14 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32436-03 + for ; + Thu, 26 Aug 2004 07:22:05 +0000 (GMT) +Received: from mailer.elma.loc (mail.elma.fr [213.41.14.138]) + by svr1.postgresql.org (Postfix) with ESMTP id 03FD35E46C1 + for ; + Thu, 26 Aug 2004 04:22:03 -0300 (ADT) +Received: from mailer.elma.loc (localhost [127.0.0.1]) + by localhost (Postfix) with ESMTP + id 30418EC1C4; Thu, 26 Aug 2004 08:23:39 +0200 (CEST) +Received: from zoot.elma.fr (herve.elma.fr [10.0.1.2]) + by mailer.elma.loc (Postfix) with ESMTP + id 056DBEC15F; Thu, 26 Aug 2004 08:23:39 +0200 (CEST) +From: =?iso-8859-15?q?Herv=E9_Piedvache?= +Organization: Elma =?iso-8859-15?q?Ing=E9nierie?= Informatique +To: pgsql-performance@postgresql.org +Subject: Re: TSearch2 and optimisation ... +Date: Thu, 26 Aug 2004 09:22:01 +0200 +User-Agent: KMail/1.6.2 +Cc: Josh Berkus , + =?iso-8859-15?q?Herv=E9_Piedvache?= +References: <200408260048.32274.footcow@noos.fr> + <200408251650.53233.josh@agliodbs.com> +In-Reply-To: <200408251650.53233.josh@agliodbs.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-15" +Content-Transfer-Encoding: 8bit +Message-Id: <200408260922.01797.herve@elma.fr> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/356 +X-Sequence-Number: 7992 + +Josh, + +Le Jeudi 26 Ao�t 2004 01:50, Josh Berkus a �crit : +> > The request takes about 4 seconds ... I have about 1 400 000 records in +> > article and 36 000 records in site table ... it's a Bi-Pentium III 933 +> > MHz server with 1 Gb memory ... I'm using Postgresql 7.4.5 +> > For me this result is very very slow I really need a quicker result with +> > less than 1 second ... +> > The next time I call the same request I have got the result in 439 ms ... +> > but If I replace "Postgresql" in my find with "Linux" for example I will +> > get the next result in 5 seconds ... :o( +> +> Hmmm. It sounds like your system is unable to keep all of the data cached +> in memory. What else do you have going on on that machine? + +There is an Apache + PHP running in same time ... + +> > Explain gives me this result : +> +> Please do "EXPLAIN ANALYZE" so that we can see where time is actually +> spent. + + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------- + Sort (cost=10740.35..10743.73 rows=1351 width=190) (actual +time=7054.603..7054.707 rows=139 loops=1) + Sort Key: rank(a.idxfti, '\'postgresql\''::tsquery), a.r_date + -> Merge Join (cost=4123.09..10670.10 rows=1351 width=190) (actual +time=5476.749..7052.766 rows=139 loops=1) + Merge Cond: ("outer".id_site = "inner".id_site) + -> Index Scan using site_id_site_key on site s (cost=0.00..2846.52 +rows=35705 width=28) (actual time=43.985..1548.903 rows=34897 loops=1) + -> Sort (cost=4123.09..4126.47 rows=1351 width=166) (actual +time=5416.836..5416.983 rows=139 loops=1) + Sort Key: a.id_site + -> Index Scan using idxfti_idx on article a +(cost=0.00..4052.84 rows=1351 width=166) (actual time=109.766..5415.108 +rows=139 loops=1) + Index Cond: (idxfti @@ '\'postgresql\''::tsquery) + Filter: (idxfti @@ '\'postgresql\''::tsquery) + SubPlan + -> Seq Scan on user_choice u (cost=0.00..2.69 rows=1 width=4) +(actual time=0.146..0.146 rows=0 loops=139) + Filter: ((id_site = $0) AND (id_user = 1)) + Total runtime: 7056.126 ms + +Thanks for your help ... +-- +Herv� Piedvache + +Elma Ing�nierie Informatique +6 rue du Faubourg Saint-Honor� +F-75008 - Paris - France +Pho. 33-144949901 +Fax. 33-144949902 + +From pgsql-performance-owner@postgresql.org Thu Aug 26 07:17:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 51E135E46FE + for ; + Thu, 26 Aug 2004 07:17:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86260-06 + for ; + Thu, 26 Aug 2004 10:17:41 +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 066885E46FA + for ; + Thu, 26 Aug 2004 07:17:32 -0300 (ADT) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) + id 1C0HK2-000Gmh-0X; Thu, 26 Aug 2004 10:17:35 +0000 +Received: from [192.168.1.17] (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 70FD217949; Thu, 26 Aug 2004 11:17:34 +0100 (BST) +Message-ID: <412DB8BE.9060106@archonet.com> +Date: Thu, 26 Aug 2004 11:17:34 +0100 +From: Richard Huxton +User-Agent: Mozilla Thunderbird 0.7 (X11/20040615) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Dennis Bjorklund +Cc: David Price , + pgsql-performance@postgresql.org +Subject: Re: Optimizer Selecting Incorrect Index +References: +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/357 +X-Sequence-Number: 7993 + +Dennis Bjorklund wrote: +> On Wed, 25 Aug 2004, Richard Huxton wrote: +>> +>>These queries are different. The first returns 687 rows and the second +>>713 rows. +> +> +> The 687 and 713 are the number of rows in the plan, not the number of rows +> the queries return. + +D'OH! Thanks Dennis + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Thu Aug 26 08:04:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 65F355E46D1 + for ; + Thu, 26 Aug 2004 08:04:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05180-01 + for ; + Thu, 26 Aug 2004 11:04:31 +0000 (GMT) +Received: from imf20aec.mail.bellsouth.net (imf20aec.mail.bellsouth.net + [205.152.59.68]) + by svr1.postgresql.org (Postfix) with ESMTP id B25675E40BA + for ; + Thu, 26 Aug 2004 08:04:29 -0300 (ADT) +Received: from djprice ([67.33.32.20]) by imf20aec.mail.bellsouth.net + (InterMail vM.5.01.06.08 201-253-122-130-108-20031117) with SMTP + id <20040826110432.TSSW1723.imf20aec.mail.bellsouth.net@djprice>; + Thu, 26 Aug 2004 07:04:32 -0400 +From: "David Price" +To: "Tom Lane" , + "Richard Huxton" +Cc: +Subject: Re: Optimizer Selecting Incorrect Index +Date: Thu, 26 Aug 2004 07:05:26 -0400 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) +In-reply-to: <2137.1093460881@sss.pgh.pa.us> +Importance: Normal +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/358 +X-Sequence-Number: 7994 + +Tom, your suspicions were correct - ANALYZE was not being run. + +I run vacuumdb via a cron script during off hours. After checking the +scripts on both systems, I found that on the system that was not functioning +correctly that the '-z' (analyze) command line option to vacuumdb was +missing. After correcting it and re-running the script, the poorly +performing SQL query takes only a few seconds as opposed to 15 minutes. + +Thank you for your help! +- David + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Tom Lane +Sent: Wednesday, August 25, 2004 3:08 PM +To: Richard Huxton +Cc: David Price; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Optimizer Selecting Incorrect Index + + +Richard Huxton writes: +> Things to check: +> 1. postgresql.conf settings match - different costs could cause this +> 2. statistics on the two columns (trn_patno,trn_old_date) - if they +> differ considerably between systems that would also explain it. + +The different estimated row counts could only come from #2. I suspect +David has forgotten to run ANALYZE on the second system. + +I agree that EXPLAIN VERBOSE output is not helpful... + + regards, tom lane + +---------------------------(end of broadcast)--------------------------- +TIP 3: if posting/reading through Usenet, please send an appropriate + subscribe-nomail command to majordomo@postgresql.org so that your + message can get through to the mailing list cleanly + + + +From pgsql-performance-owner@postgresql.org Thu Aug 26 09:07:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0258A5E46CD + for ; + Thu, 26 Aug 2004 09:07:42 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 24500-05 + for ; + Thu, 26 Aug 2004 12:07:42 +0000 (GMT) +Received: from steelhead.ravensfield.com (unknown [65.222.52.254]) + by svr1.postgresql.org (Postfix) with ESMTP id E1F705E46CF + for ; + Thu, 26 Aug 2004 09:07:39 -0300 (ADT) +Received: from [10.1.1.105] (unknown [10.1.1.105]) + by steelhead.ravensfield.com (Postfix) with ESMTP id B630E66153 + for ; + Thu, 26 Aug 2004 08:07:43 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v618) +In-Reply-To: <87657625m2.fsf@asmodeus.mcnaught.org> +References: <1093468177.12331.424.camel@camel> + <200408251422.08366.josh@agliodbs.com> + <87657625m2.fsf@asmodeus.mcnaught.org> +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <888B2477-F758-11D8-8F2F-000A95C1D2E6@ravensfield.com> +Content-Transfer-Encoding: 7bit +From: Andrew Rawnsley +Subject: Re: Anyone familiar with Apple Xserve RAID +Date: Thu, 26 Aug 2004 08:07:42 -0400 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.618) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/359 +X-Sequence-Number: 7995 + + +Just starting to work with one now, so I'll let people know what I +find. There has been +some talk that the XServe RAID seems more optimized for streaming +applications rather than +heavy random-access type applications, which really wouldn't surprise +me given where they +probably expect to sell most of them (music/film). They gave us a very +good price break, as +we are in an industry they wanted exposure in (financial services). If +you want a pile of +storage at a good price point, its certainly worth considering. + +The unit itself is built very well, and the admin tools are very good +(OS X only, though). It and the +cards that come in the XServes use copper SFP cables/connections, which +is good or +bad depending upon you're point of view. The switch Apple sells off of +their web site +is a Vixel (recently bought by Emulex). + +I have XServes hooked up at the moment, which work fine. My production +DB machine +is a slackware box, which has tested out fine in initial tests with a +QLogic HBA and the stock in-kernel +drivers. They're also 'certified' to work with Emulex cards, but IIRC +Emulex doesn't do copper. +Emulex did open-source their driver code last year (right after I had +to change an client's install +from my beloved Slack to RHAS because Emulex only had version-specific +drivers....). + +More as it happens. + +On Aug 25, 2004, at 6:52 PM, Doug McNaught wrote: + +> Josh Berkus writes: +> +>> Robert, +>> +>>> Just curious if folks have ever used this for a postgresql server +>>> and if +>>> they used it with OSX/BSD/Linux. Even if you haven't used it, if you +>>> know of something comparable I'd be interested. TIA +>> +> \> Last I checked Apple was still shipping the XServes with SATA drives +>> and a PROMISE controller, both very consumer-grade (and not +>> server-grade) hardware. I can't recommend the XServe as a database +>> platform. SCSI still makes a difference for databases, more because +>> of the controllers than anything else. +> +> The XServe RAID is fibre-channel. +> +> -Doug +> -- +> Let us cross over the river, and rest under the shade of the trees. +> --T. J. Jackson, 1863 +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to +> majordomo@postgresql.org +> +-------------------- + +Andrew Rawnsley +President +The Ravensfield Digital Resource Group, Ltd. +(740) 587-0114 +www.ravensfield.com + + +From pgsql-performance-owner@postgresql.org Sun Aug 29 12:16:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D0955E4701 + for ; + Thu, 26 Aug 2004 10:32:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 54966-03 + for ; + Thu, 26 Aug 2004 13:32:56 +0000 (GMT) +Received: from smtp-bal.opennet.it (noder32-48.opennet.it [212.110.32.48]) + by svr1.postgresql.org (Postfix) with SMTP id D534A5E46F2 + for ; + Thu, 26 Aug 2004 10:32:50 -0300 (ADT) +Received: (qmail 24958 invoked from network); 26 Aug 2004 13:32:04 -0000 +Received: from unknown (HELO comai04) (212.110.56.34) + by 0 with SMTP; 26 Aug 2004 13:32:04 -0000 +Message-ID: <008a01c48b71$abd89640$0501a8c0@comai04> +From: "Stefano Bonnin" +To: +Subject: Query performance problem in 8.0.0beta1 +Date: Thu, 26 Aug 2004 15:36:20 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0087_01C48B82.6F3FAD70" +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.8 tagged_above=0.0 required=5.0 tests=HTML_30_40, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200408/423 +X-Sequence-Number: 8059 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0087_01C48B82.6F3FAD70 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi, I have just installed 8.0.0beta1 and I noticed that some query are slow= +er than 7.4.2 queries. + +After a FULL VACUUM ANALYZE + +***With 7.4.2*** + +explain analyze SELECT count(*) FROM "SNS_DATA" WHERE "Data_Arrivo_Campione= +" BETWEEN '2004-01-01 00:00:00' AND '2004-01-31 23:59:59' AND "Cod_Par" =3D= + '17476' + +gives + + Aggregate (cost=3D46817.89..46817.89 rows=3D1 width=3D0) (actual time=3D4= +01.216..401.217 rows=3D1 loops=3D1) + -> Index Scan using snsdata_codpar on "SNS_DATA" (cost=3D0.00..46817.2= +2 rows=3D268 width=3D0) (actual time=3D165.948..400.258 rows=3D744 loops=3D= +1) + Index Cond: (("Cod_Par")::text =3D '17476'::text) + Filter: (("Data_Arrivo_Campione" >=3D '2004-01-01 00:00:00'::times= +tamp without time zone) AND ("Data_Arrivo_Campione" <=3D '2004-01-31 23:59:= +59'::timestamp without time zone)) + Total runtime: 401.302 ms + +***while on 8.0.0*** + +the same query gives + +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +----------------------------------------------------------------------- + Aggregate (cost=3D93932.91..93932.91 rows=3D1 width=3D0) (actual time=3D1= +4916.371..14916.371 rows=3D1 loops=3D1) + -> Seq Scan on "SNS_DATA" (cost=3D0.00..93930.14 rows=3D1108 width=3D0= +) (actual time=3D6297.152..14915.330 rows=3D744 loops=3D1) + Filter: (("Data_Arrivo_Campione" >=3D '2004-01-01 00:00:00'::times= +tamp without time zone) AND ("Data_Arrivo_Campione" <=3D '2004-01-31 23:59:= +59'::timestamp without time zone) AND (("Cod_Par")::text =3D '17476'::text)) + Total runtime: 14916.935 ms + +And I if disable the seqscan +SET enable_seqscan =3D false; + +I get the following Aggregate (cost=3D158603.19..158603.19 rows=3D1 width= +=3D0) (actual time=3D4605.862..4605.863 rows=3D1 loops=3D1) + -> Index Scan using snsdata_codpar on "SNS_DATA" (cost=3D0.00..158600.= +41 rows=3D1108 width=3D0) (actual time=3D2534.422..4604.865 rows=3D744 loop= +s=3D1) + Index Cond: (("Cod_Par")::text =3D '17476'::text) + Filter: (("Data_Arrivo_Campione" >=3D '2004-01-01 00:00:00'::times= +tamp without time zone) AND ("Data_Arrivo_Campione" <=3D '2004-01-31 23:59:= +59'::timestamp without time zone)) + Total runtime: 4605.965 ms + +The total runtime is bigger (x10 !!) than the old one. + +The memory runtime parameters are=20 +shared_buffer =3D 2048 +work_mem =3D sort_mem =3D 2048 + +SNS_DATA shema is the following: + + Table "public.SNS_DATA" + Column | Type | Modifiers +----------------------+-----------------------------+-------------------- + Ordine | integer | not null default 0 + Cod_Par | character varying(100) | not null + Cod_Ana | character varying(100) | not null + Valore | character varying(255) | + Descriz | character varying(512) | + Un_Mis | character varying(70) | + hash | integer | + valid | boolean | default true + alarm | boolean | default false + Cod_Luogo | character varying(30) | + Data_Arrivo_Campione | timestamp without time zone | + site_id | integer | + Cod_Luogo_v | character varying(30) | + repeated_val | boolean | default false +Indexes: + "sns_data2_pkey" PRIMARY KEY, btree ("Ordine", "Cod_Ana", "Cod_Par") + "sns_datacodluogo2" btree ("Cod_Luogo") + "sns_datatimefield2" btree ("Data_Arrivo_Campione") + "sns_siteid2" btree (site_id) + "sns_valid2" btree ("valid") + "snsdata_codana" btree ("Cod_Ana") + "snsdata_codpar" btree ("Cod_Par") +Foreign-key constraints: + "$2" FOREIGN KEY ("Cod_Ana") REFERENCES "SNS_ANA"("Cod_Ana") ON DELETE = +CASCADE +Triggers: + sns_action_tr BEFORE INSERT OR UPDATE ON "SNS_DATA" FOR EACH ROW EXECUT= +E PROCEDURE sns_action() + + +Can it be a datatype conversion problem? +Thanks in advance! +Reds + + + + + +------=_NextPart_000_0087_01C48B82.6F3FAD70 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi, I have just installed 8.0.0beta1 and I= + noticed=20 +that some query are slower than 7.4.2 queries.
+
 
+
After a FULL VACUUM ANALYZE
+
 
+
***With 7.4.2***
+
 
+
explain analyze SELECT count(*) FROM "SNS_= +DATA"=20 +WHERE "Data_Arrivo_Campione" BETWEEN '2004-01-01 00:00:00' AND '2004-01-31= +=20 +23:59:59' AND "Cod_Par" =3D '17476'
+
 
+
gives
+
 
+
 Aggregate  (cost=3D46817.89..46= +817.89=20 +rows=3D1 width=3D0) (actual time=3D401.216..401.217 rows=3D1 loops=3D1)
= +  =20 +->  Index Scan using snsdata_codpar on "SNS_DATA" =20 +(cost=3D0.00..46817.22 rows=3D268 width=3D0) (actual time=3D165.948..400.25= +8 rows=3D744=20 +loops=3D1)
         Index Cond:= +=20 +(("Cod_Par")::text =3D=20 +'17476'::text)
         Filter:= +=20 +(("Data_Arrivo_Campione" >=3D '2004-01-01 00:00:00'::timestamp without t= +ime=20 +zone) AND ("Data_Arrivo_Campione" <=3D '2004-01-31 23:59:59'::timestamp = +without=20 +time zone))
 Total runtime: 401.302 ms
+
 
+
***while on 8.0.0***
+
 
+
the same query gives
+
 
+
------------------------------------------------------------------= +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +-----
 Aggregate =20 +(cost=3D93932.91..93932.91 rows=3D1 width=3D0) (actual time=3D14916.371..14= +916.371=20 +rows=3D1 loops=3D1)
   ->  Seq Scan on "SNS_DATA" = +;=20 +(cost=3D0.00..93930.14 rows=3D1108 width=3D0) (actual time=3D6297.152..1491= +5.330=20 +rows=3D744 loops=3D1)
         F= +ilter:=20 +(("Data_Arrivo_Campione" >=3D '2004-01-01 00:00:00'::timestamp without t= +ime=20 +zone) AND ("Data_Arrivo_Campione" <=3D '2004-01-31 23:59:59'::timestamp = +without=20 +time zone) AND (("Cod_Par")::text =3D '17476'::text))
 Total runtim= +e:=20 +14916.935 ms
+
And I if disable the seqscan
+
SET enable_seqscan =3D false;
+
 
+
I get the following Aggregate =20 +(cost=3D158603.19..158603.19 rows=3D1 width=3D0) (actual time=3D4605.862..4= +605.863=20 +rows=3D1 loops=3D1)
   ->  Index Scan using snsdata_co= +dpar on=20 +"SNS_DATA"  (cost=3D0.00..158600.41 rows=3D1108 width=3D0) (actual=20 +time=3D2534.422..4604.865 rows=3D744=20 +loops=3D1)
         Index Cond:= +=20 +(("Cod_Par")::text =3D=20 +'17476'::text)
         Filter:= +=20 +(("Data_Arrivo_Campione" >=3D '2004-01-01 00:00:00'::timestamp without t= +ime=20 +zone) AND ("Data_Arrivo_Campione" <=3D '2004-01-31 23:59:59'::timestamp = +without=20 +time zone))
 Total runtime: 4605.965 ms
+
The total runtime is bigger (x10 !!) than = +the old=20 +one.
+
 
+
The memory runtime parameters are <= +/DIV> +
shared_buffer =3D 2048
+
work_mem =3D sort_mem =3D 2048
+
 
+
SNS_DATA shema is the following: +
 
+
           = +            &nb= +sp;=20 +Table "public.SNS_DATA"
       =20 +Column       =20 +|           =20 +Type            = +;=20 +|    =20 +Modifiers
----------------------+-----------------------------+---------= +-----------
 Ordine        = +      =20 +|=20 +integer           &n= +bsp;        =20 +| not null default=20 +0
 Cod_Par         &nb= +sp;   =20 +| character varying(100)      | not=20 +null
 Cod_Ana         = +    =20 +| character varying(100)      | not=20 +null
 Valore         &= +nbsp;    =20 +| character varying(255)     =20 +|
 Descriz         &nb= +sp;   =20 +| character varying(512)     =20 +|
 Un_Mis         &nbs= +p;    =20 +| character varying(70)      =20 +|
 hash          = +      =20 +|=20 +integer           &n= +bsp;        =20 +|
 valid          = +;     =20 +|=20 +boolean           &n= +bsp;        =20 +| default=20 +true
 alarm         &n= +bsp;     =20 +|=20 +boolean           &n= +bsp;        =20 +| default=20 +false
 Cod_Luogo        &nb= +sp;  =20 +| character varying(30)      =20 +|
 Data_Arrivo_Campione | timestamp without time zone=20 +|
 site_id         &nb= +sp;   =20 +|=20 +integer           &n= +bsp;        =20 +|
 Cod_Luogo_v         = +; |=20 +character varying(30)      =20 +|
 repeated_val         |= +=20 +boolean           &n= +bsp;        =20 +| default false
Indexes:
    "sns_data2_pkey" PRIMARY = +KEY,=20 +btree ("Ordine", "Cod_Ana", "Cod_Par")
    "sns_datacodlu= +ogo2"=20 +btree ("Cod_Luogo")
    "sns_datatimefield2" btree=20 +("Data_Arrivo_Campione")
    "sns_siteid2" btree=20 +(site_id)
    "sns_valid2" btree=20 +("valid")
    "snsdata_codana" btree=20 +("Cod_Ana")
    "snsdata_codpar" btree=20 +("Cod_Par")
Foreign-key constraints:
    "$2" FOREIGN = +KEY=20 +("Cod_Ana") REFERENCES "SNS_ANA"("Cod_Ana") ON DELETE=20 +CASCADE
Triggers:
    sns_action_tr BEFORE INSERT OR U= +PDATE=20 +ON "SNS_DATA" FOR EACH ROW EXECUTE PROCEDURE sns_action()
+
 
+
 
+
Can it be a datatype conversion=20 +problem?
+
Thanks in advance!
+
Reds
+
 
+
 
+
 
+
 
+
 
+ +------=_NextPart_000_0087_01C48B82.6F3FAD70-- + + +From pgsql-performance-owner@postgresql.org Thu Aug 26 12:13:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B4895E46E1 + for ; + Thu, 26 Aug 2004 12:13:32 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 92356-08 + for ; + Thu, 26 Aug 2004 15:13:35 +0000 (GMT) +Received: from ns1.primar.org (rec.ecc.as [213.162.234.66]) + by svr1.postgresql.org (Postfix) with SMTP id 1D4465E46F8 + for ; + Thu, 26 Aug 2004 12:13:23 -0300 (ADT) +Received: from [159.162.61.72] ([159.162.61.72]) by ns1.primar.org with + Microsoft SMTPSVC(5.0.2195.6713); Thu, 26 Aug 2004 17:13:20 +0200 +Mime-Version: 1.0 (Apple Message framework v619) +In-Reply-To: <888B2477-F758-11D8-8F2F-000A95C1D2E6@ravensfield.com> +References: <1093468177.12331.424.camel@camel> + <200408251422.08366.josh@agliodbs.com> + <87657625m2.fsf@asmodeus.mcnaught.org> + <888B2477-F758-11D8-8F2F-000A95C1D2E6@ravensfield.com> +Content-Type: text/plain; charset=WINDOWS-1252; format=flowed +Message-Id: <7946313C-F772-11D8-8624-000A95CD827E@pvv.ntnu.no> +Content-Transfer-Encoding: quoted-printable +From: Tore Halset +Subject: Re: Anyone familiar with Apple Xserve RAID +Date: Thu, 26 Aug 2004 17:13:24 +0200 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.619) +X-OriginalArrivalTime: 26 Aug 2004 15:13:20.0992 (UTC) + FILETIME=[39324600:01C48B7F] +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/360 +X-Sequence-Number: 7996 + +On Aug 26, 2004, at 14:07, Andrew Rawnsley wrote: + +> The unit itself is built very well, and the admin tools are very good=20 +> (OS X only, though). It and the + +The admin tools are supposed to work cross platform. From Apples=20 +website: "This Java-based application provides an intuitive interface=20 +for creating protected storage volumes, managing preferences and=20 +monitoring storage hardware from any virtually any networked computer=20 +over TCP/IP. That means you don=92t have to use a Mac to administer your=20 +deployment, though, we=92d like you to, of course." + +http://www.apple.com/xserve/raid/management.html + +Regards, + - Tore. + +From pgsql-performance-owner@postgresql.org Thu Aug 26 14:40:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8FAAF5E37D0 + for ; + Thu, 26 Aug 2004 14:40:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 45958-08 + for ; + Thu, 26 Aug 2004 17:40:47 +0000 (GMT) +Received: from steelhead.ravensfield.com (unknown [65.222.52.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 495EB5E3632 + for ; + Thu, 26 Aug 2004 14:40:45 -0300 (ADT) +Received: from [10.1.1.105] (unknown [10.1.1.105]) + by steelhead.ravensfield.com (Postfix) with ESMTP + id 1ACB566153; Thu, 26 Aug 2004 13:40:42 -0400 (EDT) +In-Reply-To: <7946313C-F772-11D8-8624-000A95CD827E@pvv.ntnu.no> +References: <1093468177.12331.424.camel@camel> + <200408251422.08366.josh@agliodbs.com> + <87657625m2.fsf@asmodeus.mcnaught.org> + <888B2477-F758-11D8-8F2F-000A95C1D2E6@ravensfield.com> + <7946313C-F772-11D8-8624-000A95CD827E@pvv.ntnu.no> +Mime-Version: 1.0 (Apple Message framework v618) +Content-Type: text/plain; charset=WINDOWS-1252; format=flowed +Message-Id: <0CB9DFD7-F787-11D8-8F2F-000A95C1D2E6@ravensfield.com> +Content-Transfer-Encoding: quoted-printable +Cc: pgsql-performance@postgresql.org +From: Andrew Rawnsley +Subject: Re: Anyone familiar with Apple Xserve RAID +Date: Thu, 26 Aug 2004 13:40:41 -0400 +To: Tore Halset +X-Mailer: Apple Mail (2.618) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/361 +X-Sequence-Number: 7997 + + +Oops. My bad. + +They must really want to sell those things if they're making them=20 +completely platform independent... + +On Aug 26, 2004, at 11:13 AM, Tore Halset wrote: + +> On Aug 26, 2004, at 14:07, Andrew Rawnsley wrote: +> +>> The unit itself is built very well, and the admin tools are very good=20 +>> (OS X only, though). It and the +> +> The admin tools are supposed to work cross platform. From Apples=20 +> website: "This Java-based application provides an intuitive interface=20 +> for creating protected storage volumes, managing preferences and=20 +> monitoring storage hardware from any virtually any networked computer=20 +> over TCP/IP. That means you don=92t have to use a Mac to administer your= +=20 +> deployment, though, we=92d like you to, of course." +> +> http://www.apple.com/xserve/raid/management.html +> +> Regards, +> - Tore. +> +> ---------------------------(end of=20 +> broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to=20 +> majordomo@postgresql.org +> +-------------------- + +Andrew Rawnsley +President +The Ravensfield Digital Resource Group, Ltd. +(740) 587-0114 +www.ravensfield.com + + +From pgsql-performance-owner@postgresql.org Thu Aug 26 14:49:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 27CA65E37D0 + for ; + Thu, 26 Aug 2004 14:49:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48294-10 + for ; + Thu, 26 Aug 2004 17:49:24 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E5905E3632 + for ; + Thu, 26 Aug 2004 14:49:23 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6183055; Thu, 26 Aug 2004 10:50:39 -0700 +Content-Type: text/plain; + charset="iso-8859-15" +From: Josh Berkus +Organization: Aglio Database Solutions +To: =?iso-8859-15?q?Herv=E9=20Piedvache?= , + pgsql-performance@postgresql.org +Subject: Re: TSearch2 and optimisation ... +Date: Thu, 26 Aug 2004 10:48:58 -0700 +User-Agent: KMail/1.4.3 +Cc: =?iso-8859-15?q?Herv=E9=20Piedvache?= +References: <200408260048.32274.footcow@noos.fr> + <200408251650.53233.josh@agliodbs.com> + <200408260922.01797.herve@elma.fr> +In-Reply-To: <200408260922.01797.herve@elma.fr> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408261048.58726.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/362 +X-Sequence-Number: 7998 + +Herve' + +> (cost=0.00..4052.84 rows=1351 width=166) (actual time=109.766..5415.108 +> rows=139 loops=1) +> Index Cond: (idxfti @@ '\'postgresql\''::tsquery) +> Filter: (idxfti @@ '\'postgresql\''::tsquery) + + From this, it looks like your FTI index isn't fitting in your sort_mem. +What's sort_mem at now? Can you increase it? + +Overall, though, I'm not sure you can get this sub-1s without a faster +machine. Although I'm doing FTI on about 25MB of FTI text on a +single-processor machine, and getting 40ms response times, so maybe we can +... + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Aug 26 14:58:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 79A355E46F4 + for ; + Thu, 26 Aug 2004 14:58:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52747-04 + for ; + Thu, 26 Aug 2004 17:58:35 +0000 (GMT) +Received: from web53703.mail.yahoo.com (web53703.mail.yahoo.com + [206.190.37.24]) + by svr1.postgresql.org (Postfix) with SMTP id 733AB5E46FD + for ; + Thu, 26 Aug 2004 14:58:34 -0300 (ADT) +Message-ID: <20040826175833.32182.qmail@web53703.mail.yahoo.com> +Received: from [199.217.234.6] by web53703.mail.yahoo.com via HTTP; + Thu, 26 Aug 2004 10:58:33 PDT +Date: Thu, 26 Aug 2004 10:58:33 -0700 (PDT) +From: George Essig +Subject: Re: TSearch2 and optimisation ... +To: pgsql-performance@postgresql.org +Cc: footcow@noos.fr +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/363 +X-Sequence-Number: 7999 + +Bill Footcow wrote: + +... +> I have done a simple request, looking for title or description having Postgres +> inside order by rank and date, like this : +> SELECT a.title, a.id, a.url, to_char(a.r_date, 'DD/MM/YYYY HH24:MI:SS') as dt, +> s.site_name, s.id_site, case when exists (select id_user from user_choice u +> where u.id_site=s.id_site and u.id_user = 1) then 1 else 0 end as bookmarked +> FROM article a, site s +> WHERE s.id_site = a.id_site +> AND idxfti @@ to_tsquery('postgresql') +> ORDER BY rank(idxfti, to_tsquery('postgresql')) DESC, a.r_date DESC; +> +> The request takes about 4 seconds ... I have about 1 400 000 records in +> article and 36 000 records in site table ... it's a Bi-Pentium III 933 MHz +> server with 1 Gb memory ... I'm using Postgresql 7.4.5 +> For me this result is very very slow I really need a quicker result with less +> than 1 second ... +> The next time I call the same request I have got the result in 439 ms ... but +... + +The first query is slow because the relevant index pages are not cached in memory. Everyone +experiences this. GiST indexes on tsvector columns can get really big. You have done nothing +wrong. When you have a lot of records, tsearch2 will not run fast without extensive performance +tuning. + +Read the following: + +Optimization +http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/oscon_tsearch2/optimization.html + +stat function +http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_Notes +http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/oscon_tsearch2/stat.html + +Stop words +http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/tsearch-V2-intro.html +http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/oscon_tsearch2/stop_words.html + +Multicolumn GiST index +http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/docs/oscon_tsearch2/multi_column_index.html + +openfts-general mailing list archive +http://sourceforge.net/mailarchive/forum.php?forum=openfts-general + +Try some of things out and let me know how it goes. + +George Essig + + + +From pgsql-performance-owner@postgresql.org Thu Aug 26 15:03:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 64D145E46F4 + for ; + Thu, 26 Aug 2004 15:03:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55428-04 + for ; + Thu, 26 Aug 2004 18:03:06 +0000 (GMT) +Received: from ussmtp02.scigames.com (ussmtp02.scientificgames.com [65.5.3.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 2F3FE5E40AC + for ; + Thu, 26 Aug 2004 15:03:02 -0300 (ADT) +Received: by ussmtp02.scigames.com with XWall v3.30 ; + Thu, 26 Aug 2004 14:09:44 -0400 +From: Neil Cooper +To: "pgsql-performance@postgresql.org" +Subject: Disabling transaction/outdated-tuple behaviour +Date: Thu, 26 Aug 2004 14:02:55 -0400 +X-Assembled-By: XWall v3.30 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Message-ID: <1093543374.16123.38.camel@NCooper> +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 + tests=TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200408/364 +X-Sequence-Number: 8000 + +I am using a simple PostgreSQL 7.3 database in a soft-realtime +application. + +I have a problem where an update on a record within a (fully indexed) +table containing less than ten records needs to occur as fast as +possible. + +Immediately after performing a vaccum, updates take upto 50 milliseconds +to occur, however the update performance degrades over time, such that +after a few hours of continuous updates, each update takes about half a +second. Regular vacuuming improves the performance temporarily, but +during the vacuum operation (which takes upto 2 minutes), performance of +concurrent updates falls below an acceptable level (sometimes > 2 +seconds per update). + +According to the documentation, PostgreSQL keeps the old versions of the +tuples in case of use by other transactions (i.e. each update is +actually extending the table). I believe this behaviour is what is +causing my performance problem. + +Is there a way to disable this behaviour such that an update operation +would overwrite the current record and does not generate an outdated +tuple each time? (My application does not need transactional support). +=20 +I believe this would give me the performance gain I need, and would +eliminate the need for regular vacuuming too. +=20 +Thanks in advance, + +Neil Cooper. + +This communication (including any attachments) is intended for the use of t= +he intended recipient(s) only and may contain information that is confident= +ial, privileged or legally protected. Any unauthorized use or dissemination= + of this communication is strictly prohibited. If you have received this co= +mmunication in error, please immediately notify the sender by return e-mail= + message and delete all copies of the original communication. Thank you for= + your cooperation. + +From pgsql-performance-owner@postgresql.org Thu Aug 26 15:14:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BEB65E46EC + for ; + Thu, 26 Aug 2004 15:14:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 61791-02 + for ; + Thu, 26 Aug 2004 18:14:33 +0000 (GMT) +Received: from mx1.neopolitan.us (mx1.neopolitan.us [65.87.16.224]) + by svr1.postgresql.org (Postfix) with ESMTP id F0E3B5E46F4 + for ; + Thu, 26 Aug 2004 15:14:32 -0300 (ADT) +Received: from [65.87.16.98] (HELO vulture.corp.neopolitan.com) + by mx1.neopolitan.us (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 5615069; Thu, 26 Aug 2004 11:14:32 -0700 +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +From: "J. Andrew Rogers" +To: pgsql-performance@postgresql.org +Cc: mischa.sandberg@telus.net +In-Reply-To: +References: +Content-Type: text/plain +Organization: +Message-Id: <1093544071.349.106.camel@vulture.corp.neopolitan.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 26 Aug 2004 11:14:32 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/365 +X-Sequence-Number: 8001 + +On Tue, 2004-08-24 at 22:28, Mischa Sandberg wrote: +> I see that PG has a one-shot CLUSTER command, but doesn't support +> continuously-updated clustered indexes. +> +> What I infer from newsgroup browsing is, such an index is impossible, +> given the MVCC versioning of records (happy to learn I'm wrong). + + +It is possible to have MVCC and ordered/indexed heaps, but it isn't +something you can just tack onto the currently supported types -- I +looked into this myself. It would take substantial additional code +infrastructure to support it, basically an alternative heap system and +adding support for tables with odd properties to many parts of the +system. Pretty non-trivial. + +This is probably my #1 "I wish postgres had this feature" feature. It +is a serious scalability enhancer for big systems and a pain to work +around not having. + + +> I'd be curious to know what other people, who've crossed this same +> bridge from MSSQL or Oracle or Sybase to PG, have devised, +> faced with the same kind of desired performance gain for retrieving +> blocks of rows with the same partial key. + + +The CLUSTER command is often virtually useless for precisely the kinds +of tables that need to be clustered. My databases are on-line 24x7, and +the tables that are ideal candidates for clustering are in the range of +50-100 million rows. I can afford to lock these tables up for no more +than 5-10 minutes during off-peak in the hopes that no one notices, and +CLUSTER does not work remotely in the ballpark of that fast for tables +of that size. People who can run CLUSTER in a cron job must either have +relatively small tables or regular large maintenance windows. + + +My solution, which may or may not work for you, was to write a table +partitioning system using the natural flexibility and programmability of +postgresql (e.g. table inheritance). From this I automatically get a +roughly ordered heap according to the index I would cluster on, with +only slightly funky SQL access. The end result works much better with +CLUSTER too, though CLUSTER is much less necessary at that point +because, at least for my particular purposes, the rows are mostly +ordered due to how the data was partitioned. + +So there are ways to work around CLUSTER, but you'll have to be clever +and it will require tailoring the solution to your particular +requirements. + + +J. Andrew Rogers + + + + +From pgsql-performance-owner@postgresql.org Thu Aug 26 15:18:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 30D4F5E40BA + for ; + Thu, 26 Aug 2004 15:18:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60497-07 + for ; + Thu, 26 Aug 2004 18:18:55 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id BB3E45E40AC + for ; + Thu, 26 Aug 2004 15:18:54 -0300 (ADT) +Received: from solent (82-68-95-1.dsl.in-addr.zen.co.uk [82.68.95.1]) + by bayswater1.ymogen.net (Postfix) with ESMTP + id DCF3BA6547; Thu, 26 Aug 2004 19:18:52 +0100 (BST) +Reply-To: +From: "Matt Clark" +To: "'Neil Cooper'" , + +Subject: Re: Disabling transaction/outdated-tuple behaviour +Date: Thu, 26 Aug 2004 19:18:52 +0100 +Organization: Ymogen Ltd +Message-ID: <015f01c48b99$24739bf0$8300a8c0@solent> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.6626 +In-Reply-To: <1093543374.16123.38.camel@NCooper> +Importance: Normal +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/366 +X-Sequence-Number: 8002 + +> Immediately after performing a vaccum, updates take upto 50=20 +> milliseconds to occur, however the update performance=20 +> degrades over time, such that after a few hours of continuous=20 +> updates, each update takes about half a second. Regular=20 +> vacuuming improves the performance temporarily, but during=20 +> the vacuum operation (which takes upto 2 minutes),=20 +> performance of concurrent updates falls below an acceptable=20 +> level (sometimes > 2 seconds per update). + +You must be doing an enormous number of updates! You can vacuum as often as +you like, and should usually do so at least as often as the time it takes +for 'all' tuples to be updated. So, in your case, every 10 updates. OK, +that seems unnecessary, how about every 100 updates?=20 + +> According to the documentation, PostgreSQL keeps the old=20 +> versions of the tuples in case of use by other transactions=20 +> (i.e. each update is actually extending the table). I believe=20 +> this behaviour is what is causing my performance problem. + +Yes, it probably is. + +> Is there a way to disable this behaviour such that an update=20 +> operation would overwrite the current record and does not=20 +> generate an outdated tuple each time? (My application does=20 +> not need transactional support). + +No, I don't believe there is. If you really don't need transaction support +then you might want to reconsider whether postgres is really the right tool. + +M + + +From pgsql-performance-owner@postgresql.org Thu Aug 26 15:19:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DD72B5E3632 + for ; + Thu, 26 Aug 2004 15:19:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62328-05 + for ; + Thu, 26 Aug 2004 18:19:06 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 7174B5E46F4 + for ; + Thu, 26 Aug 2004 15:18:57 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i7QIIrr09640; + Thu, 26 Aug 2004 14:18:53 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200408261818.i7QIIrr09640@candle.pha.pa.us> +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +In-Reply-To: <1093544071.349.106.camel@vulture.corp.neopolitan.com> +To: "J. Andrew Rogers" +Date: Thu, 26 Aug 2004 14:18:53 -0400 (EDT) +Cc: pgsql-performance@postgresql.org, mischa.sandberg@telus.net +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/367 +X-Sequence-Number: 8003 + + +How do vendors actually implement auto-clustering? I assume they move +rows around during quiet periods or have lots of empty space in each +value bucket. + +--------------------------------------------------------------------------- + +J. Andrew Rogers wrote: +> On Tue, 2004-08-24 at 22:28, Mischa Sandberg wrote: +> > I see that PG has a one-shot CLUSTER command, but doesn't support +> > continuously-updated clustered indexes. +> > +> > What I infer from newsgroup browsing is, such an index is impossible, +> > given the MVCC versioning of records (happy to learn I'm wrong). +> +> +> It is possible to have MVCC and ordered/indexed heaps, but it isn't +> something you can just tack onto the currently supported types -- I +> looked into this myself. It would take substantial additional code +> infrastructure to support it, basically an alternative heap system and +> adding support for tables with odd properties to many parts of the +> system. Pretty non-trivial. +> +> This is probably my #1 "I wish postgres had this feature" feature. It +> is a serious scalability enhancer for big systems and a pain to work +> around not having. +> +> +> > I'd be curious to know what other people, who've crossed this same +> > bridge from MSSQL or Oracle or Sybase to PG, have devised, +> > faced with the same kind of desired performance gain for retrieving +> > blocks of rows with the same partial key. +> +> +> The CLUSTER command is often virtually useless for precisely the kinds +> of tables that need to be clustered. My databases are on-line 24x7, and +> the tables that are ideal candidates for clustering are in the range of +> 50-100 million rows. I can afford to lock these tables up for no more +> than 5-10 minutes during off-peak in the hopes that no one notices, and +> CLUSTER does not work remotely in the ballpark of that fast for tables +> of that size. People who can run CLUSTER in a cron job must either have +> relatively small tables or regular large maintenance windows. +> +> +> My solution, which may or may not work for you, was to write a table +> partitioning system using the natural flexibility and programmability of +> postgresql (e.g. table inheritance). From this I automatically get a +> roughly ordered heap according to the index I would cluster on, with +> only slightly funky SQL access. The end result works much better with +> CLUSTER too, though CLUSTER is much less necessary at that point +> because, at least for my particular purposes, the rows are mostly +> ordered due to how the data was partitioned. +> +> So there are ways to work around CLUSTER, but you'll have to be clever +> and it will require tailoring the solution to your particular +> requirements. +> +> +> J. Andrew Rogers +> +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: Have you searched our list archives? +> +> http://archives.postgresql.org +> + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Aug 26 15:20:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 385445E37D0 + for ; + Thu, 26 Aug 2004 15:20:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 62328-08 + for ; + Thu, 26 Aug 2004 18:20:45 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id CA8755E3632 + for ; + Thu, 26 Aug 2004 15:20:44 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6183323; Thu, 26 Aug 2004 11:22:01 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Neil Cooper , + "pgsql-performance@postgresql.org" +Subject: Re: Disabling transaction/outdated-tuple behaviour +Date: Thu, 26 Aug 2004 11:20:20 -0700 +User-Agent: KMail/1.4.3 +References: <1093543374.16123.38.camel@NCooper> +In-Reply-To: <1093543374.16123.38.camel@NCooper> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408261120.20890.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/368 +X-Sequence-Number: 8004 + +Neil, + +> I am using a simple PostgreSQL 7.3 database in a soft-realtime +> application. + +Then you're not going to like the answer I have for you, see below. + +> I have a problem where an update on a record within a (fully indexed) +> table containing less than ten records needs to occur as fast as +> possible. + +Have you considered dropping the indexes? On such a small table, they won't +be used, and they are detracting significantly from your update speed. + +> Immediately after performing a vaccum, updates take upto 50 milliseconds +> to occur, however the update performance degrades over time, such that +> after a few hours of continuous updates, each update takes about half a +> second. Regular vacuuming improves the performance temporarily, but +> during the vacuum operation (which takes upto 2 minutes), performance of +> concurrent updates falls below an acceptable level (sometimes > 2 +> seconds per update). + +This is "normal" depending on your platform and concurrent activity. More +frequent vacuums would take less time each. What is your max_fsm_pages set +to? Increasing this may decrease the necessity of vacuums as well as +speeding them up. Also, are you vacuuming the whole DB or just that table? +2 mintues seems like a long time; I can vacuum a 100GB database in less than +4. + +> Is there a way to disable this behaviour such that an update operation +> would overwrite the current record and does not generate an outdated +> tuple each time? (My application does not need transactional support). + +No. Our ACID Transaction compliance depends on "that behaviour" (MVCC). We +don't offer PostgreSQL in a "non-ACID mode". If your application truly does +not need transactional support, you may want to consider an embedded database +instead, such as BerkeleyDB or SQLite. PostgreSQL has a *lot* of "baggage" +associated with having 99.99% incorruptable transactions. + +Alternately, you may also want to take a look at TelegraphCG, a derivative of +PostgreSQL designed to handle "streaming data". They may have already +conquered some of your difficulties for you. +http://telegraph.cs.berkeley.edu/ + +Were I you, I would start with tuning the database first through +PostgreSQL.conf and a careful look at my hardware usage and DB maintenance. +Then I would consider testing 8.0, which has some specific improvements +designed to address some of the problems you are having. Particularly, +Jan's Background Writer and Lazy Vacuum. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Aug 26 15:33:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E4BD85E46E1 + for ; + Thu, 26 Aug 2004 15:32:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68409-02 + for ; + Thu, 26 Aug 2004 18:32:56 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id DC20E5E46EE + for ; + Thu, 26 Aug 2004 15:32:54 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6183409; Thu, 26 Aug 2004 11:34:11 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Bruce Momjian , + "J. Andrew Rogers" +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Date: Thu, 26 Aug 2004 11:32:30 -0700 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgresql.org, mischa.sandberg@telus.net +References: <200408261818.i7QIIrr09640@candle.pha.pa.us> +In-Reply-To: <200408261818.i7QIIrr09640@candle.pha.pa.us> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408261132.30732.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/369 +X-Sequence-Number: 8005 + +Bruce, + +> How do vendors actually implement auto-clustering? I assume they move +> rows around during quiet periods or have lots of empty space in each +> value bucket. + +That's how SQL Server does it. In old versions (6.5) you had to manually +send commands to update the cluster, same as PG. Also, when you create a +cluster (or an index or table for that matter) you can manually set an amount +of "space" to be held open on each data page for updates. + +Also keep in mind that SQL Server, as a "single-user database" has a much +easier time with this. They don't have to hold several versions of an index +in memory and collapse it into a single version at commit time. + +All that being said, we could do a better job of "auto-balancing" clustered +tables. I believe that someone was working on this in Hackers through what +they called "B-Tree Tables". What happened to that? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Aug 26 16:04:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 71F375E46C3 + for ; + Thu, 26 Aug 2004 16:04:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78912-03 + for ; + Thu, 26 Aug 2004 19:04:48 +0000 (GMT) +Received: from mx1.neopolitan.us (mx1.neopolitan.us [65.87.16.224]) + by svr1.postgresql.org (Postfix) with ESMTP id C50055E46DC + for ; + Thu, 26 Aug 2004 16:04:47 -0300 (ADT) +Received: from [65.87.16.98] (HELO vulture.corp.neopolitan.com) + by mx1.neopolitan.us (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 5615852; Thu, 26 Aug 2004 12:04:48 -0700 +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +From: "J. Andrew Rogers" +To: Bruce Momjian +Cc: pgsql-performance@postgresql.org, mischa.sandberg@telus.net +In-Reply-To: <200408261818.i7QIIrr09640@candle.pha.pa.us> +References: <200408261818.i7QIIrr09640@candle.pha.pa.us> +Content-Type: text/plain +Organization: +Message-Id: <1093547088.349.134.camel@vulture.corp.neopolitan.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 26 Aug 2004 12:04:48 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/370 +X-Sequence-Number: 8006 + +On Thu, 2004-08-26 at 11:18, Bruce Momjian wrote: +> How do vendors actually implement auto-clustering? I assume they move +> rows around during quiet periods or have lots of empty space in each +> value bucket. + + +As far as I know, Oracle does it by having a B-Tree organized heap (a +feature introduced around v8 IIRC), basically making the primary key +index and the heap the same physical structure. Any non-index columns +are stored in the index along with the index columns. Implementing it +is slightly weird because searching the index and selecting the rows +from the heap are not separate operations. + +The major caveat to having tables of this type is that you can only have +a primary key index. No other indexes are possible because the "heap" +constantly undergoes local reorganizations if you have a lot of write +traffic, the same kind of reorganization you would normally expect in a +BTree index. + +The performance improvements come from two optimizations. First, you +have to touch significantly fewer blocks to get all the rows, even +compared to a CLUSTERed heap. Second, the footprint is smaller and +plays nicely with the buffer cache. + +When I've used these types of heaps in Oracle 8 on heavily used tables +with tens of millions of rows, we frequently got a 10x or better +performance improvement on queries against those tables. It is only +really useful for tables with vast quantities of relatively small rows, +but it can be a lifesaver in those cases. + + +J. Andrew Rogers + + + +From pgsql-performance-owner@postgresql.org Thu Aug 26 16:10:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B1AB85E46D1 + for ; + Thu, 26 Aug 2004 16:10:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79821-04 + for ; + Thu, 26 Aug 2004 19:10:54 +0000 (GMT) +Received: from mail.speedfc.com (66-136-75-131.ded.swbell.net [66.136.75.131]) + by svr1.postgresql.org (Postfix) with ESMTP id C66CF5E3639 + for ; + Thu, 26 Aug 2004 16:10:53 -0300 (ADT) +Received: from [172.25.96.149] (unknown [172.25.96.149]) + by mail.speedfc.com (Postfix) with ESMTP id 3CBAD8DBF + for ; + Thu, 26 Aug 2004 14:09:31 -0500 (CDT) +Message-ID: <412E34B8.6000708@speedfc.com> +Date: Thu, 26 Aug 2004 14:06:32 -0500 +From: Kevin Barnard +Organization: SpeedFC +User-Agent: Mozilla Thunderbird 0.7.1 (Windows/20040626) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Anyone familiar with Apple Xserve RAID +References: <1093468177.12331.424.camel@camel> + <200408251422.08366.josh@agliodbs.com> + <08139423-F6EB-11D8-ACDB-000393DB553C@bahn.de> + <200408251649.02932.josh@agliodbs.com> +In-Reply-To: <200408251649.02932.josh@agliodbs.com> +Content-Type: multipart/alternative; + boundary="------------010605050705080208010809" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 tests=HTML_20_30, + HTML_MESSAGE, HTML_TITLE_EMPTY +X-Spam-Level: * +X-Archive-Number: 200408/371 +X-Sequence-Number: 8007 + +This is a multi-part message in MIME format. +--------------010605050705080208010809 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Actually you are both are right and wrong. The XRaid uses FibreChannel +to communicate to the host machine(s). The Raid controller is a +FibreChannel controller. After that there is a FibreChannel to UltraATA +conversion for each drive, separate ATA bus for each drive. + +What I am curious about is if this setup gets around ATA fsync problems, +where the drive reports the write before it is actually performed. + + +Josh Berkus wrote: + +>Guys, +> +> +> +>>the XServe/XRaid comes with FibreChannel +>> +>> +> +>I stand corrected. That should help things some; it makes it more of a small +>tradeoff between performance and storage size for the drives. +> +> +> + +-- +Kevin Barnard +Speed Fulfillment and Call Center +kbarnard@speedfc.com +214-258-0120 + + +--------------010605050705080208010809 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +Actually you are both are right and wrong.  The XRaid uses FibreChannel +to communicate to the host machine(s).  The Raid controller is a +FibreChannel controller.  After that there is a FibreChannel to +UltraATA conversion for each drive, separate ATA bus for each drive.
+
+What I am curious about is if this setup gets around ATA fsync +problems, where the drive reports the write before it is actually +performed.
+
+
+Josh Berkus wrote:
+
+
Guys,
+
+  
+
+
the XServe/XRaid comes with FibreChannel
+    
+
+

+I stand corrected.   That should help things some; it makes it more of a small 
+tradeoff between performance and storage size for the drives.
+
+  
+
+
+
-- 
+Kevin Barnard
+Speed Fulfillment and Call Center
+kbarnard@speedfc.com
+214-258-0120
+ + + +--------------010605050705080208010809-- + +From pgsql-performance-owner@postgresql.org Thu Aug 26 16:30:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7BF635E46D1 + for ; + Thu, 26 Aug 2004 16:30:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 83528-08 + for ; + Thu, 26 Aug 2004 19:30:28 +0000 (GMT) +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by svr1.postgresql.org (Postfix) with ESMTP id 8A7155E3639 + for ; + Thu, 26 Aug 2004 16:30:26 -0300 (ADT) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id DC9188F3DF; Thu, 26 Aug 2004 21:30:24 +0200 (CEST) +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Date: Thu, 26 Aug 2004 21:30:24 +0200 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE475B39@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Equivalent praxis to CLUSTERED INDEX? +Thread-Index: AcSLn9xLjJrUfEugTe2RcsZrvCoNkQAAqrAg +From: "Magnus Hagander" +To: "J. Andrew Rogers" , + "Bruce Momjian" +Cc: , +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/372 +X-Sequence-Number: 8008 + +>> How do vendors actually implement auto-clustering? I assume=20 +>they move +>> rows around during quiet periods or have lots of empty space in each +>> value bucket. +> +> +>As far as I know, Oracle does it by having a B-Tree organized heap (a +>feature introduced around v8 IIRC), basically making the primary key +>index and the heap the same physical structure. Any non-index columns +>are stored in the index along with the index columns. Implementing it +>is slightly weird because searching the index and selecting the rows +>from the heap are not separate operations. + +Almost the same for MSSQL. The clustered index is always forced unique. +If you create a non-unique clustered index, SQLServer will internally +pad it with random (or is it sequential? Can't remember right now) data +to make each key unique. The clustered index contains all the data +fields - both the index key and the other columns from the database. + +It does support non-clustered indexes as well on the same table. Any +"secondary index" will then contain the index key and the primary key +value. This means a lookup in a non-clustered index means a two-step +index lookup: First look in the non-clustered index for the clustered +key. Then look in the clustered index for the rest of the data.=20 + +Naturally a non-clustered index needs better selectivity before it's +actually used than a clustered index does. + +IIRC, SQL Server always creates clustered indexes by default for primary +keys. + + +//Magnus + +From pgsql-performance-owner@postgresql.org Thu Aug 26 16:30:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0792C5E46C3 + for ; + Thu, 26 Aug 2004 16:30:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 87496-03 + for ; + Thu, 26 Aug 2004 19:30:47 +0000 (GMT) +Received: from mx.noos.fr (pm-mx3.mgn.net [195.46.220.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 13D5A5E3639 + for ; + Thu, 26 Aug 2004 16:30:44 -0300 (ADT) +Received: from localhost (pm-mnet2.mgn.net [195.46.220.219]) + by mx.noos.fr (Postfix) with SMTP + id D3C6B268F8; Thu, 26 Aug 2004 21:30:41 +0200 (MEST) +X-Mailbox-Line: From footcow@noos.fr Thu Aug 26 21:30:41 2004 +Received: from e115.dhcp212-198-145.noos.fr (e115.dhcp212-198-145.noos.fr + [212.198.145.115]) by pm-mnet2.mgn.net with ESMTP; + Thu, 26 Aug 2004 21:30:41 (MEST) +From: =?iso-8859-15?q?Herv=E9_Piedvache?= +To: pgsql-performance@postgresql.org +Subject: Re: TSearch2 and optimisation ... +Date: Thu, 26 Aug 2004 21:30:40 +0200 +User-Agent: KMail/1.6.2 +Cc: Josh Berkus , + =?iso-8859-15?q?Herv=E9_Piedvache?= +References: <200408260048.32274.footcow@noos.fr> + <200408260922.01797.herve@elma.fr> + <200408261048.58726.josh@agliodbs.com> +In-Reply-To: <200408261048.58726.josh@agliodbs.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-15" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200408262130.40500.footcow@noos.fr> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/373 +X-Sequence-Number: 8009 + +Le Jeudi 26 Ao=FBt 2004 19:48, Josh Berkus a =E9crit : +> Herve' +> +> > (cost=3D0.00..4052.84 rows=3D1351 width=3D166) (actual time=3D109.766..= +5415.108 +> > rows=3D139 loops=3D1) +> > Index Cond: (idxfti @@ '\'postgresql\''::tsquery) +> > Filter: (idxfti @@ '\'postgresql\''::tsquery) +> > +> >From this, it looks like your FTI index isn't fitting in your sort_mem. +> +> What's sort_mem at now? Can you increase it? + +shared_buffers =3D 3000 +sort_mem =3D 10240 + +> Overall, though, I'm not sure you can get this sub-1s without a faster +> machine. Although I'm doing FTI on about 25MB of FTI text on a +> single-processor machine, and getting 40ms response times, so maybe we can +> ... + +Sorry I missed understand what you mean here ...=20 +You tell me to upgrade the hardware but you manage a 25 Mb with a single=20 +processor ?? What you mean ? +My database is about 450 Mb ... + +Regards, +--=20 +Bill Footcow + + +From pgsql-performance-owner@postgresql.org Thu Aug 26 16:48:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C75325E46D4 + for ; + Thu, 26 Aug 2004 16:48:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93962-02 + for ; + Thu, 26 Aug 2004 19:48:49 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DB845E46D1 + for ; + Thu, 26 Aug 2004 16:48:48 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6183909; Thu, 26 Aug 2004 12:50:06 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Magnus Hagander" , + "J. Andrew Rogers" , + "Bruce Momjian" +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Date: Thu, 26 Aug 2004 12:48:25 -0700 +User-Agent: KMail/1.4.3 +Cc: , +References: <6BCB9D8A16AC4241919521715F4D8BCE475B39@algol.sollentuna.se> +In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCE475B39@algol.sollentuna.se> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408261248.25661.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/374 +X-Sequence-Number: 8010 + +Magnus, + +> IIRC, SQL Server always creates clustered indexes by default for primary +> keys. + +I think that's a per-database setting; certainly the ones I admin do not. + +However, since SQL Server orders its data pages, those data pages tend to be +in the order of the primary key regardless if there is no clustered index. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Aug 26 16:54:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 272035E46EE + for ; + Thu, 26 Aug 2004 16:54:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95189-02 + for ; + Thu, 26 Aug 2004 19:54:12 +0000 (GMT) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 2F18A5E46D1 + for ; + Thu, 26 Aug 2004 16:54:08 -0300 (ADT) +Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1C0QK0-0005Lq-00 + for ; Thu, 26 Aug 2004 21:54:08 +0200 +Received: from sp-260-1.net4.netcentrix.net ([4.21.254.118]) + by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) + id 1AlnuQ-0007hv-00 + for ; Thu, 26 Aug 2004 21:54:08 +0200 +Received: from doug by sp-260-1.net4.netcentrix.net with local (Gmexim 0.1 + (Debian)) id 1AlnuQ-0007hv-00 + for ; Thu, 26 Aug 2004 21:54:08 +0200 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +From: Doug McNaught +Subject: Re: Anyone familiar with Apple Xserve RAID +Date: Thu, 26 Aug 2004 15:54:04 -0400 +Lines: 23 +Message-ID: <87hdqpzndv.fsf@asmodeus.mcnaught.org> +References: <1093468177.12331.424.camel@camel> + <200408251422.08366.josh@agliodbs.com> + <08139423-F6EB-11D8-ACDB-000393DB553C@bahn.de> + <200408251649.02932.josh@agliodbs.com> <412E34B8.6000708@speedfc.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@sea.gmane.org +X-Gmane-NNTP-Posting-Host: sp-260-1.net4.netcentrix.net +User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (gnu/linux) +Cancel-Lock: sha1:kh7q2LzTKEdh2PlNnE3dZv6/uqM= +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/375 +X-Sequence-Number: 8011 + +Kevin Barnard writes: + +> Actually you are both are right and wrong. The XRaid uses +> FibreChannel to communicate to the host machine(s). The Raid +> controller is a FibreChannel controller. After that there is a +> FibreChannel to UltraATA conversion for each drive, separate ATA bus +> for each drive. +> What I am curious about is if this setup gets around ATA fsync +> problems, where the drive reports the write before it is actually +> performed. + +Good point. + +(a) The FC<->ATA unit hopefully has a battery-backed cache, which + would make the whole thing more robust against power loss. +(b) Since Apple is the vendor for the drive units, they can buy ATA + drives that don't lie about cache flushes. Whether they do or not + is definitely a question. ;) + +-Doug +-- +Let us cross over the river, and rest under the shade of the trees. + --T. J. Jackson, 1863 + + +From pgsql-performance-owner@postgresql.org Thu Aug 26 17:01:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B92E5E3632 + for ; + Thu, 26 Aug 2004 17:01:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94354-10 + for ; + Thu, 26 Aug 2004 20:01:20 +0000 (GMT) +Received: from wren.rentec.com (wren.rentec.com [65.213.84.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 16A075E3639 + for ; + Thu, 26 Aug 2004 17:01:17 -0300 (ADT) +Received: from [172.26.132.145] (hoopoe.rentec.com [172.26.132.145]) + by wren.rentec.com (8.12.9/8.12.1) with ESMTP id i7QK1HuY010349; + Thu, 26 Aug 2004 16:01:17 -0400 (EDT) +Message-ID: <412E418B.3070103@rentec.com> +Date: Thu, 26 Aug 2004 16:01:15 -0400 +From: Alan Stange +Reply-To: stange@rentec.com +Organization: Renaissance Technologies Corp. +User-Agent: Mozilla Thunderbird 0.7.1 (X11/20040701) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Doug McNaught +Cc: pgsql-performance@postgresql.org +Subject: Re: Anyone familiar with Apple Xserve RAID +References: <1093468177.12331.424.camel@camel> + <200408251422.08366.josh@agliodbs.com> + <08139423-F6EB-11D8-ACDB-000393DB553C@bahn.de> + <200408251649.02932.josh@agliodbs.com> + <412E34B8.6000708@speedfc.com> + <87hdqpzndv.fsf@asmodeus.mcnaught.org> +In-Reply-To: <87hdqpzndv.fsf@asmodeus.mcnaught.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/376 +X-Sequence-Number: 8012 + +Doug McNaught wrote: + +>Kevin Barnard writes: +> +> +> +>> Actually you are both are right and wrong. The XRaid uses +>> FibreChannel to communicate to the host machine(s). The Raid +>> controller is a FibreChannel controller. After that there is a +>> FibreChannel to UltraATA conversion for each drive, separate ATA bus +>> for each drive. +>> What I am curious about is if this setup gets around ATA fsync +>> problems, where the drive reports the write before it is actually +>> performed. +>> +>> +> +>Good point. +> +>(a) The FC<->ATA unit hopefully has a battery-backed cache, which +> would make the whole thing more robust against power loss. +>(b) Since Apple is the vendor for the drive units, they can buy ATA +> drives that don't lie about cache flushes. Whether they do or not +> is definitely a question. ;) +> +> + +FYI: http://developer.apple.com/technotes/tn/pdf/tn1040.pdf a tech +note on write cache flushing. + +A bit dated now, but perhaps some other tech note from Apple has more +recent information. + +-- Alan + +From pgsql-performance-owner@postgresql.org Thu Aug 26 17:12:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 63B675E46DC + for ; + Thu, 26 Aug 2004 17:12:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 96952-10 + for ; + Thu, 26 Aug 2004 20:12:06 +0000 (GMT) +Received: from steelhead.ravensfield.com (unknown [65.222.52.254]) + by svr1.postgresql.org (Postfix) with ESMTP id C49C95E46D4 + for ; + Thu, 26 Aug 2004 17:12:05 -0300 (ADT) +Received: from [10.1.1.105] (unknown [10.1.1.105]) + by steelhead.ravensfield.com (Postfix) with ESMTP id 7A7C866153 + for ; + Thu, 26 Aug 2004 16:12:07 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v618) +In-Reply-To: <87hdqpzndv.fsf@asmodeus.mcnaught.org> +References: <1093468177.12331.424.camel@camel> + <200408251422.08366.josh@agliodbs.com> + <08139423-F6EB-11D8-ACDB-000393DB553C@bahn.de> + <200408251649.02932.josh@agliodbs.com> + <412E34B8.6000708@speedfc.com> + <87hdqpzndv.fsf@asmodeus.mcnaught.org> +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <33FEF898-F79C-11D8-8F2F-000A95C1D2E6@ravensfield.com> +Content-Transfer-Encoding: 7bit +From: Andrew Rawnsley +Subject: Re: Anyone familiar with Apple Xserve RAID +Date: Thu, 26 Aug 2004 16:12:06 -0400 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.618) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/377 +X-Sequence-Number: 8013 + + +On Aug 26, 2004, at 3:54 PM, Doug McNaught wrote: + +> Kevin Barnard writes: +> +>> Actually you are both are right and wrong. The XRaid uses +>> FibreChannel to communicate to the host machine(s). The Raid +>> controller is a FibreChannel controller. After that there is a +>> FibreChannel to UltraATA conversion for each drive, separate ATA +>> bus +>> for each drive. +>> What I am curious about is if this setup gets around ATA fsync +>> problems, where the drive reports the write before it is actually +>> performed. +> +> Good point. +> +> (a) The FC<->ATA unit hopefully has a battery-backed cache, which +> would make the whole thing more robust against power loss. + +Each controller is battery backed (pretty beefy batteries too). +Actually, they are optional, +but if you spend the money for the unit and leave off the battery you +should +have your head examined. + + +> (b) Since Apple is the vendor for the drive units, they can buy ATA +> drives that don't lie about cache flushes. Whether they do or not +> is definitely a question. ;) + +Given what they charge for them I would like to think so...but who +knows... + +The ones in mine are from Hitachi, model #HDS722525VLAT80. + +> +> -Doug +> -- +> Let us cross over the river, and rest under the shade of the trees. +> --T. J. Jackson, 1863 +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 1: subscribe and unsubscribe commands go to +> majordomo@postgresql.org +> +-------------------- + +Andrew Rawnsley +President +The Ravensfield Digital Resource Group, Ltd. +(740) 587-0114 +www.ravensfield.com + + +From pgsql-performance-owner@postgresql.org Thu Aug 26 17:44:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B109B5E46F3 + for ; + Thu, 26 Aug 2004 17:44:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13621-02 + for ; + Thu, 26 Aug 2004 20:44:04 +0000 (GMT) +Received: from mx1.neopolitan.us (mx1.neopolitan.us [65.87.16.224]) + by svr1.postgresql.org (Postfix) with ESMTP id B24E75E46EE + for ; + Thu, 26 Aug 2004 17:44:01 -0300 (ADT) +Received: from [65.87.16.98] (HELO vulture.corp.neopolitan.com) + by mx1.neopolitan.us (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 5617072; Thu, 26 Aug 2004 13:44:03 -0700 +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +From: "J. Andrew Rogers" +To: Magnus Hagander +Cc: Bruce Momjian , + pgsql-performance@postgresql.org, mischa.sandberg@telus.net +In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCE475B39@algol.sollentuna.se> +References: <6BCB9D8A16AC4241919521715F4D8BCE475B39@algol.sollentuna.se> +Content-Type: text/plain +Organization: +Message-Id: <1093553043.349.171.camel@vulture.corp.neopolitan.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 26 Aug 2004 13:44:03 -0700 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/378 +X-Sequence-Number: 8014 + +On Thu, 2004-08-26 at 12:30, Magnus Hagander wrote: +> Almost the same for MSSQL. The clustered index is always forced unique. +> If you create a non-unique clustered index, SQLServer will internally +> pad it with random (or is it sequential? Can't remember right now) data +> to make each key unique. The clustered index contains all the data +> fields - both the index key and the other columns from the database. +> +> It does support non-clustered indexes as well on the same table. Any +> "secondary index" will then contain the index key and the primary key +> value. This means a lookup in a non-clustered index means a two-step +> index lookup: First look in the non-clustered index for the clustered +> key. Then look in the clustered index for the rest of the data. + + +Ah, okay. I see how that would work for a secondary index, though it +would make for a slow secondary index. Neat workaround. For all I +know, current versions of Oracle may support secondary indexes on +index-organized tables; all this Postgres usage over the last couple +years has made my Oracle knowledge rusty. + + +> IIRC, SQL Server always creates clustered indexes by default for primary +> keys. + + +That would surprise me actually. For some types of tables, e.g. ones +with multiple well-used indexes or large rows, index-organizing the heap +could easily give worse performance than a normal index/heap pair +depending on access patterns. It also tends to be more prone to having +locking contention under some access patterns. This is one of those +options that needs to be used knowledgeably; it is not a general +architectural improvement that you would want to apply to every table +all the time. + + +J. Andrew Rogers + + + + +From pgsql-performance-owner@postgresql.org Sun Aug 29 12:15:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B69505E3639 + for ; + Thu, 26 Aug 2004 18:02:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17719-03 + for ; + Thu, 26 Aug 2004 21:01:54 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id E692A5E46D4 + for ; + Thu, 26 Aug 2004 18:01:51 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7QL1oLq020417 + for ; Thu, 26 Aug 2004 21:01:50 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7QL0k0M020102 + for pgsql-performance@postgresql.org; Thu, 26 Aug 2004 21:00:46 GMT +From: Mischa Sandberg +Reply-To: ischamay.andbergsay@activestateway.com +User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +References: <200408261818.i7QIIrr09640@candle.pha.pa.us> + <200408261132.30732.josh@agliodbs.com> +In-Reply-To: <200408261132.30732.josh@agliodbs.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 40 +Message-ID: <3csXc.56326$X12.25148@edtnps84> +Date: Thu, 26 Aug 2004 21:00:47 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200408/417 +X-Sequence-Number: 8053 + +Ummm ... not quite. In MSSQL/Sybase/Oracle, a clustered index maintains +its space saturation as part of each update operation. High activity +does indeed result in less-full pages (typically 60-80% full for tables +with heavy deletions or rowsize changes). To bring the percentage back +up, you run DBCC INDEXDEFRAG, which also does what you'd expect of a +normal file defragmenter -- put related disk pages together on the platter. + +But the performance difference is hardly as severe as I gather it can be +if you neglect to vacuum. + +As for SQL Server being a 'single-user database' ... ummm ... no, I +don't think so. I'm REALLY happy to be shut of the Microsoft world, but +MSSQL 7/2000/2005 is a serious big DB engine. It also has some serious +bright heads behind it. They hired Goetz Graefe and Paul (aka Per-Ake) +Larsen away from academia, and it shows, in the join and aggregate +processing. I'll be a happy camper if I manage to contribute something +to PG that honks the way their stuff does. Happy to discuss, too. + +Josh Berkus wrote: +> Bruce, +> +> +>>How do vendors actually implement auto-clustering? I assume they move +>>rows around during quiet periods or have lots of empty space in each +>>value bucket. +> +> +> That's how SQL Server does it. In old versions (6.5) you had to manually +> send commands to update the cluster, same as PG. Also, when you create a +> cluster (or an index or table for that matter) you can manually set an amount +> of "space" to be held open on each data page for updates. +> +> Also keep in mind that SQL Server, as a "single-user database" has a much +> easier time with this. They don't have to hold several versions of an index +> in memory and collapse it into a single version at commit time. +> +> All that being said, we could do a better job of "auto-balancing" clustered +> tables. I believe that someone was working on this in Hackers through what +> they called "B-Tree Tables". What happened to that? +> + +From pgsql-performance-owner@postgresql.org Thu Aug 26 18:31:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 167615E40AC + for ; + Thu, 26 Aug 2004 18:31:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27046-04 + for ; + Thu, 26 Aug 2004 21:31:51 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 606F65E3F15 + for ; + Thu, 26 Aug 2004 18:31:50 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7QLVoLq030474 + for ; Thu, 26 Aug 2004 21:31:50 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7QL9h9o022953 + for pgsql-performance@postgresql.org; Thu, 26 Aug 2004 21:09:43 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Date: Thu, 26 Aug 2004 23:09:35 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 18 +Message-ID: <412E518F.8090805@bigfoot.com> +References: <1093544071.349.106.camel@vulture.corp.neopolitan.com> + <200408261818.i7QIIrr09640@candle.pha.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Bruce Momjian +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +In-Reply-To: <200408261818.i7QIIrr09640@candle.pha.pa.us> +X-Enigmail-Version: 0.85.0.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/379 +X-Sequence-Number: 8015 + +Bruce Momjian wrote: +> How do vendors actually implement auto-clustering? I assume they move +> rows around during quiet periods or have lots of empty space in each +> value bucket. +> +> --------------------------------------------------------------------------- + +IIRC informix doesn't have it, and you have to recluster periodically +the table. After having clustered the table with an index in order to +recluster the table with another index you have to release the previous +one ( ALTER index TO NOT CLUSTER ), the CLUSTER is an index attribute and +each table can have only one index with that attribute ON. + + +Regards +Gaetano Mendola + + + +From pgsql-performance-owner@postgresql.org Sun Aug 29 12:16:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DF6425E46F8 + for ; + Thu, 26 Aug 2004 19:01:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36240-10 + for ; + Thu, 26 Aug 2004 22:01:51 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id DCFBB5E46F2 + for ; + Thu, 26 Aug 2004 19:01:50 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7QM1oLs039915 + for ; Thu, 26 Aug 2004 22:01:50 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7QLf25N033373 + for pgsql-performance@postgresql.org; Thu, 26 Aug 2004 21:41:02 GMT +From: Mischa Sandberg +Reply-To: ischamay.andbergsay@activestateway.com +User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +References: <6BCB9D8A16AC4241919521715F4D8BCE475B39@algol.sollentuna.se> + <1093553043.349.171.camel@vulture.corp.neopolitan.com> +In-Reply-To: <1093553043.349.171.camel@vulture.corp.neopolitan.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 17 +Message-ID: +Date: Thu, 26 Aug 2004 21:41:04 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200408/422 +X-Sequence-Number: 8058 + +J. Andrew Rogers wrote: +> On Thu, 2004-08-26 at 12:30, Magnus Hagander wrote: +>>IIRC, SQL Server always creates clustered indexes by default for primary +>>keys. +> +> That would surprise me actually. + +Yaz, it should. It doesn't ALWAYS create clustered (unique) index for +primary keys, but clustered is the default if you just specify + +CREATE TABLE Foo (col1, ... + ,PRIMARY KEY(col1, ...) +) + +Saying PRIMARY KEY NONCLUSTERED(...) is how you override the default. + +((Weird to be discussing so much MSSQL here)) + +From pgsql-performance-owner@postgresql.org Sun Aug 29 12:15:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C0B0C5E46EC + for ; + Thu, 26 Aug 2004 19:01:58 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39426-01 + for ; + Thu, 26 Aug 2004 22:01:51 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id E0C3D5E46F3 + for ; + Thu, 26 Aug 2004 19:01:50 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7QM1oLq039915 + for ; Thu, 26 Aug 2004 22:01:50 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7QLkBNP035025 + for pgsql-performance@postgresql.org; Thu, 26 Aug 2004 21:46:11 GMT +From: Mischa Sandberg +Reply-To: ischamay.andbergsay@activestateway.com +User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +References: <200408261818.i7QIIrr09640@candle.pha.pa.us> + <1093547088.349.134.camel@vulture.corp.neopolitan.com> +In-Reply-To: <1093547088.349.134.camel@vulture.corp.neopolitan.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 16 +Message-ID: +Date: Thu, 26 Aug 2004 21:46:13 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200408/420 +X-Sequence-Number: 8056 + +Sheer nitpick here... + +A B-tree is where the records (data) live at all levels of the tree; +B+ tree is where the records are only at the leaf level. +That's what Knuth calls them, anyway. + +Clustered indexes for all known dbs are true B+ trees. +Nonclustered indexes could be B-trees (probably aren't), +since there's no big fanout penalty for storing the little +(heap) row locators everywhere at all levels. + +J. Andrew Rogers wrote: +> As far as I know, Oracle does it by having a B-Tree organized heap (a +> feature introduced around v8 IIRC), basically making the primary key +> index and the heap the same physical structure. +... + +From pgsql-performance-owner@postgresql.org Thu Aug 26 19:36:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4043D5E40AC + for ; + Thu, 26 Aug 2004 19:36:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49437-05 + for ; + Thu, 26 Aug 2004 22:36:26 +0000 (GMT) +Received: from loki.globexplorer.com (unknown [208.35.14.101]) + by svr1.postgresql.org (Postfix) with ESMTP id 6058A5E37D0 + for ; + Thu, 26 Aug 2004 19:36:19 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Date: Thu, 26 Aug 2004 15:36:21 -0700 +Message-ID: + <71E37EF6B7DCC1499CEA0316A256832801D4B6FA@loki.wc.globexplorer.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Equivalent praxis to CLUSTERED INDEX? +Thread-Index: AcSLtF0iLWfopjgTSa69GezGy0M88QACwW/w +From: "Gregory S. Williamson" +To: "Gaetano Mendola" , + "Bruce Momjian" , + +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/380 +X-Sequence-Number: 8016 + +FWIW, + +Informix does allow the fragmentation of data over named dbspaces by round-= +robin and expression; this is autosupporting as long as the dba keeps enoug= +h space available. You may also fragment the index although there are some = +variations depending on type of Informix (XPS, etc.); this is available in = +at least 9.3 ... I have never used the index fragmentation as its own beast= +, but the fragmenting of data works like a charm for spreadling load over m= +ore disks. + +Greg Williamson +DBA +GlobeXplorer LLC + +-----Original Message----- +From: Gaetano Mendola [mailto:mendola@bigfoot.com] +Sent: Thursday, August 26, 2004 2:10 PM +To: Bruce Momjian; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Equivalent praxis to CLUSTERED INDEX? + + +Bruce Momjian wrote: +> How do vendors actually implement auto-clustering? I assume they move +> rows around during quiet periods or have lots of empty space in each +> value bucket. +>=20 +> -------------------------------------------------------------------------= +-- + +IIRC informix doesn't have it, and you have to recluster periodically +the table. After having clustered the table with an index in order to +recluster the table with another index you have to release the previous +one ( ALTER index TO NOT CLUSTER ), the CLUSTER is an index attribute and +each table can have only one index with that attribute ON. + + +Regards +Gaetano Mendola + + + +---------------------------(end of broadcast)--------------------------- +TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org + +From pgsql-performance-owner@postgresql.org Thu Aug 26 22:45:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 33F7D5E3632 + for ; + Thu, 26 Aug 2004 22:45:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 94756-08 + for ; + Fri, 27 Aug 2004 01:45:50 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F3B85E3639 + for ; + Thu, 26 Aug 2004 22:45:47 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i7R1jop04185; + Thu, 26 Aug 2004 21:45:50 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200408270145.i7R1jop04185@candle.pha.pa.us> +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +In-Reply-To: <1093553043.349.171.camel@vulture.corp.neopolitan.com> +To: "J. Andrew Rogers" +Date: Thu, 26 Aug 2004 21:45:50 -0400 (EDT) +Cc: Magnus Hagander , + pgsql-performance@postgresql.org, mischa.sandberg@telus.net +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/381 +X-Sequence-Number: 8017 + + +Updated TODO item: + + o Automatically maintain clustering on a table + + This would require some background daemon to maintain clustering + during periods of low usage. It might also require tables to be only + paritally filled for easier reorganization. It also might require + creating a merged heap/index data file so an index lookup would + automatically access the heap data too. + +--------------------------------------------------------------------------- + +J. Andrew Rogers wrote: +> On Thu, 2004-08-26 at 12:30, Magnus Hagander wrote: +> > Almost the same for MSSQL. The clustered index is always forced unique. +> > If you create a non-unique clustered index, SQLServer will internally +> > pad it with random (or is it sequential? Can't remember right now) data +> > to make each key unique. The clustered index contains all the data +> > fields - both the index key and the other columns from the database. +> > +> > It does support non-clustered indexes as well on the same table. Any +> > "secondary index" will then contain the index key and the primary key +> > value. This means a lookup in a non-clustered index means a two-step +> > index lookup: First look in the non-clustered index for the clustered +> > key. Then look in the clustered index for the rest of the data. +> +> +> Ah, okay. I see how that would work for a secondary index, though it +> would make for a slow secondary index. Neat workaround. For all I +> know, current versions of Oracle may support secondary indexes on +> index-organized tables; all this Postgres usage over the last couple +> years has made my Oracle knowledge rusty. +> +> +> > IIRC, SQL Server always creates clustered indexes by default for primary +> > keys. +> +> +> That would surprise me actually. For some types of tables, e.g. ones +> with multiple well-used indexes or large rows, index-organizing the heap +> could easily give worse performance than a normal index/heap pair +> depending on access patterns. It also tends to be more prone to having +> locking contention under some access patterns. This is one of those +> options that needs to be used knowledgeably; it is not a general +> architectural improvement that you would want to apply to every table +> all the time. +> +> +> J. Andrew Rogers +> +> +> + +-- + 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 Aug 27 00:39:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 88AA85E46CC + for ; + Fri, 27 Aug 2004 00:39:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26895-08 + for ; + Fri, 27 Aug 2004 03:39:58 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 936585E3639 + for ; + Fri, 27 Aug 2004 00:39:50 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1C0XaZ-0000B7-00; Thu, 26 Aug 2004 23:39:43 -0400 +To: Bruce Momjian +Cc: "J. Andrew Rogers" , + Magnus Hagander , + pgsql-performance@postgresql.org, mischa.sandberg@telus.net +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +References: <200408270145.i7R1jop04185@candle.pha.pa.us> +In-Reply-To: <200408270145.i7R1jop04185@candle.pha.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 26 Aug 2004 23:39:42 -0400 +Message-ID: <87pt5dnta9.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/382 +X-Sequence-Number: 8018 + + +Bruce Momjian writes: + +> Updated TODO item: +> +> o Automatically maintain clustering on a table +> +> This would require some background daemon to maintain clustering +> during periods of low usage. It might also require tables to be only +> paritally filled for easier reorganization. It also might require +> creating a merged heap/index data file so an index lookup would +> automatically access the heap data too. + +Fwiw, I would say the first "would" is also a "might". None of the previous +discussions here presumed a maintenance daemon. The discussions before talked +about a mechanism to try to place new tuples as close as possible to the +proper index position. + +I would also suggest making some distinction between a cluster system similar +to what we have now but improved to maintain the clustering continuously, and +an actual index-organized-table where the tuples are actually only stored in a +btree structure. + +They're two different approaches to similar problems. But they might both be +useful to have, and have markedly different implementation details. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Fri Aug 27 01:35:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 663825E3639 + for ; + Fri, 27 Aug 2004 01:35:12 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40367-06 + for ; + Fri, 27 Aug 2004 04:35:16 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 6EE405E46C3 + for ; + Fri, 27 Aug 2004 01:35:06 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i7R4Z7N25250; + Fri, 27 Aug 2004 00:35:07 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200408270435.i7R4Z7N25250@candle.pha.pa.us> +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +In-Reply-To: <87pt5dnta9.fsf@stark.xeocode.com> +To: Greg Stark +Date: Fri, 27 Aug 2004 00:35:07 -0400 (EDT) +Cc: "J. Andrew Rogers" , + Magnus Hagander , + pgsql-performance@postgresql.org, mischa.sandberg@telus.net +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/383 +X-Sequence-Number: 8019 + + +OK, new wording: + + o Automatically maintain clustering on a table + + This might require some background daemon to maintain clustering + during periods of low usage. It might also require tables to be only + paritally filled for easier reorganization. Another idea would + be to create a merged heap/index data file so an index lookup would + automatically access the heap data too. + + +--------------------------------------------------------------------------- + +Greg Stark wrote: +> +> Bruce Momjian writes: +> +> > Updated TODO item: +> > +> > o Automatically maintain clustering on a table +> > +> > This would require some background daemon to maintain clustering +> > during periods of low usage. It might also require tables to be only +> > paritally filled for easier reorganization. It also might require +> > creating a merged heap/index data file so an index lookup would +> > automatically access the heap data too. +> +> Fwiw, I would say the first "would" is also a "might". None of the previous +> discussions here presumed a maintenance daemon. The discussions before talked +> about a mechanism to try to place new tuples as close as possible to the +> proper index position. +> +> I would also suggest making some distinction between a cluster system similar +> to what we have now but improved to maintain the clustering continuously, and +> an actual index-organized-table where the tuples are actually only stored in a +> btree structure. +> +> They're two different approaches to similar problems. But they might both be +> useful to have, and have markedly different implementation details. +> +> -- +> greg +> + +-- + 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 Aug 27 03:27:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1191D5E3632 + for ; + Fri, 27 Aug 2004 03:27:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71267-08 + for ; + Fri, 27 Aug 2004 06:27:18 +0000 (GMT) +Received: from web54106.mail.yahoo.com (web54106.mail.yahoo.com + [206.190.37.241]) + by svr1.postgresql.org (Postfix) with SMTP id 66FAC5E3631 + for ; + Fri, 27 Aug 2004 03:27:16 -0300 (ADT) +Message-ID: <20040827062716.4092.qmail@web54106.mail.yahoo.com> +Received: from [129.94.6.30] by web54106.mail.yahoo.com via HTTP; + Thu, 26 Aug 2004 23:27:16 PDT +Date: Thu, 26 Aug 2004 23:27:16 -0700 (PDT) +From: my ho +Subject: Re: postgresql performance with multimedia +To: Jan Wieck +Cc: pgsql-performance@postgresql.org +In-Reply-To: <412C71F1.4030902@Yahoo.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/384 +X-Sequence-Number: 8020 + +Hi, +> For your "streaming" purposes I strongly recommend +> you do it in your +> application with the appropriate thread model. A +> relational database +> management system is not a multimedia cache. + +That's actually what i plan to do with postgreSQL, +maybe tailor it to suit with a multimedia streaming +database. Well, i could do it in the application level +but i think it's also worth a try with the database +itself. + +> They are only stored in that way on initial load and +> if the load is done +> with a single process. And don't you rely on this +> for the future. Right +> now, if you ever update or delete tuples, that order +> changes already. + +does the buffer manager have any idea what table that +buf belongs to? (can we add 'rel' variable to sbufdesc +in buf_internals.h and update it everytime we add new +entry to the buffer cahe?) And then we take in to +account which relation the data in the buffer belongs +to in the buf replacement algorithm or in the +read-ahead policy. + +> Also keep in mind that large values are not stored +> inline, but in an +> extra "TOAST" relation. +This is how i store my video file: break them in to +small chunks and store each part in a row of a table. + +regards, +MThi + + + + + +__________________________________ +Do you Yahoo!? +New and Improved Yahoo! Mail - 100MB free storage! +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Fri Aug 27 03:54:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 473C65E3639 + for ; + Fri, 27 Aug 2004 03:54:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75409-08 + for ; + Fri, 27 Aug 2004 06:54:18 +0000 (GMT) +Received: from smtp-bal.opennet.it (noder32-48.opennet.it [212.110.32.48]) + by svr1.postgresql.org (Postfix) with SMTP id BA5C45E46C2 + for ; + Fri, 27 Aug 2004 03:54:15 -0300 (ADT) +Received: (qmail 16695 invoked from network); 27 Aug 2004 06:53:23 -0000 +Received: from unknown (HELO comai04) (212.110.56.34) + by 0 with SMTP; 27 Aug 2004 06:53:23 -0000 +Message-ID: <007c01c48c03$269b50c0$0501a8c0@comai04> +From: "Stefano Bonnin" +To: +Subject: Query performance issue with 8.0.0beta1 +Date: Fri, 27 Aug 2004 08:57:43 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0079_01C48C13.E9F01870" +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.8 tagged_above=0.0 required=5.0 tests=HTML_30_40, + HTML_MESSAGE +X-Spam-Level: +X-Archive-Number: 200408/385 +X-Sequence-Number: 8021 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0079_01C48C13.E9F01870 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi, I have just installed 8.0.0beta1 and I noticed that some query are slow= +er than 7.4.2 queries. + +After: +pg_dump my_database >mydb.sql (from 7.4.2) +psql my_new_database Index Scan using snsdata_codpar on "SNS_DATA" (cost=3D0.00..46817.2= +2 rows=3D268 width=3D0) (actual time=3D165.948..400.258 rows=3D744 loops=3D= +1) + Index Cond: (("Cod_Par")::text =3D '17476'::text) + Filter: (("Data_Arrivo_Campione" >=3D '2004-01-01 00:00:00'::times= +tamp without time zone) AND ("Data_Arrivo_Campione" <=3D '2004-01-31 23:59:= +59'::timestamp without time zone)) + Total runtime: 401.302 ms + +***while on 8.0.0*** + +the same query gives + +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +----------------------------------------------------------------------- + Aggregate (cost=3D93932.91..93932.91 rows=3D1 width=3D0) (actual time=3D1= +4916.371..14916.371 rows=3D1 loops=3D1) + -> Seq Scan on "SNS_DATA" (cost=3D0.00..93930.14 rows=3D1108 width=3D0= +) (actual time=3D6297.152..14915.330 rows=3D744 loops=3D1) + Filter: (("Data_Arrivo_Campione" >=3D '2004-01-01 00:00:00'::times= +tamp without time zone) AND ("Data_Arrivo_Campione" <=3D '2004-01-31 23:59:= +59'::timestamp without time zone) AND (("Cod_Par")::text =3D '17476'::text)) + Total runtime: 14916.935 ms + +And I if disable the seqscan +SET enable_seqscan =3D false; + +I get the following: + +Aggregate (cost=3D158603.19..158603.19 rows=3D1 width=3D0) (actual time=3D= +4605.862..4605.863 rows=3D1 loops=3D1) + -> Index Scan using snsdata_codpar on "SNS_DATA" (cost=3D0.00..158600.= +41 rows=3D1108 width=3D0) (actual time=3D2534.422..4604.865 rows=3D744 loop= +s=3D1) + Index Cond: (("Cod_Par")::text =3D '17476'::text) + Filter: (("Data_Arrivo_Campione" >=3D '2004-01-01 00:00:00'::times= +tamp without time zone) AND ("Data_Arrivo_Campione" <=3D '2004-01-31 23:59:= +59'::timestamp without time zone)) + Total runtime: 4605.965 ms + +The total runtime is bigger (x10 !!) than the old one. + +The memory runtime parameters are=20 +shared_buffer =3D 2048 +work_mem =3D sort_mem =3D 2048 + +SNS_DATA shema is the following: + + Table "public.SNS_DATA" + Column | Type | Modifiers +----------------------+-----------------------------+-------------------- + Ordine | integer | not null default 0 + Cod_Par | character varying(100) | not null + Cod_Ana | character varying(100) | not null + Valore | character varying(255) | + Descriz | character varying(512) | + Un_Mis | character varying(70) | + hash | integer | + valid | boolean | default true + alarm | boolean | default false + Cod_Luogo | character varying(30) | + Data_Arrivo_Campione | timestamp without time zone | + site_id | integer | + Cod_Luogo_v | character varying(30) | + repeated_val | boolean | default false +Indexes: + "sns_data2_pkey" PRIMARY KEY, btree ("Ordine", "Cod_Ana", "Cod_Par") + "sns_datacodluogo2" btree ("Cod_Luogo") + "sns_datatimefield2" btree ("Data_Arrivo_Campione") + "sns_siteid2" btree (site_id) + "sns_valid2" btree ("valid") + "snsdata_codana" btree ("Cod_Ana") + "snsdata_codpar" btree ("Cod_Par") +Foreign-key constraints: + "$2" FOREIGN KEY ("Cod_Ana") REFERENCES "SNS_ANA"("Cod_Ana") ON DELETE = +CASCADE +Triggers: + sns_action_tr BEFORE INSERT OR UPDATE ON "SNS_DATA" FOR EACH ROW EXECUT= +E PROCEDURE sns_action() + +The table has 2M of records +Can it be a datatype conversion issue? +Can it be depend on the the type of restore (with COPY commands)? +I have no idea. + +Thanks in advance! +Reds + +------=_NextPart_000_0079_01C48C13.E9F01870 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
+
+
Hi, I have just installed 8.0.0beta1 and I= + noticed=20 +that some query are slower than 7.4.2 queries.
+
 
+
After:
+
pg_dump my_database >mydb.sql (from=20 +7.4.2)
+
psql my_new_database <mydb.sql (to 8.0.0 with COPY instead of=20 +INSERT)
+
FULL VACUUM ANALYZE
+
 
+
***With the old db on 7.4.2***
+
 
+
explain analyze SELECT count(*) FROM "SNS_= +DATA"=20 +WHERE "Data_Arrivo_Campione" BETWEEN '2004-01-01 00:00:00' AND '2004-01-31= +=20 +23:59:59' AND "Cod_Par" =3D '17476'
+
 
+
gives
+
 
+
 Aggregate  (cost=3D46817.89..46= +817.89=20 +rows=3D1 width=3D0) (actual time=3D401.216..401.217 rows=3D1 loops=3D1)
= +  =20 +->  Index Scan using snsdata_codpar on "SNS_DATA" =20 +(cost=3D0.00..46817.22 rows=3D268 width=3D0) (actual time=3D165.948..400.25= +8 rows=3D744=20 +loops=3D1)
         Index Cond:= +=20 +(("Cod_Par")::text =3D=20 +'17476'::text)
         Filter:= +=20 +(("Data_Arrivo_Campione" >=3D '2004-01-01 00:00:00'::timestamp without t= +ime=20 +zone) AND ("Data_Arrivo_Campione" <=3D '2004-01-31 23:59:59'::timestamp = +without=20 +time zone))
 Total runtime: 401.302 ms
+
 
+
***while on 8.0.0***
+
 
+
the same query gives
+
 
+
------------------------------------------------------------------= +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +-----
 Aggregate =20 +(cost=3D93932.91..93932.91 rows=3D1 width=3D0) (actual time=3D14916.371..14= +916.371=20 +rows=3D1 loops=3D1)
   ->  Seq Scan on "SNS_DATA" = +;=20 +(cost=3D0.00..93930.14 rows=3D1108 width=3D0) (actual time=3D6297.152..1491= +5.330=20 +rows=3D744 loops=3D1)
         F= +ilter:=20 +(("Data_Arrivo_Campione" >=3D '2004-01-01 00:00:00'::timestamp without t= +ime=20 +zone) AND ("Data_Arrivo_Campione" <=3D '2004-01-31 23:59:59'::timestamp = +without=20 +time zone) AND (("Cod_Par")::text =3D '17476'::text))
 Total runtim= +e:=20 +14916.935 ms
+
And I if disable the seqscan
+
SET enable_seqscan =3D false;
+
 
+
I get the following:
+
 
+
Aggregate  (cost=3D158603.19..158603.= +19 rows=3D1=20 +width=3D0) (actual time=3D4605.862..4605.863 rows=3D1 loops=3D1)
 &= +nbsp;=20 +->  Index Scan using snsdata_codpar on "SNS_DATA" =20 +(cost=3D0.00..158600.41 rows=3D1108 width=3D0) (actual time=3D2534.422..460= +4.865=20 +rows=3D744 loops=3D1)
         I= +ndex=20 +Cond: (("Cod_Par")::text =3D=20 +'17476'::text)
         Filter:= +=20 +(("Data_Arrivo_Campione" >=3D '2004-01-01 00:00:00'::timestamp without t= +ime=20 +zone) AND ("Data_Arrivo_Campione" <=3D '2004-01-31 23:59:59'::timestamp = +without=20 +time zone))
 Total runtime: 4605.965 ms
+
The total runtime is bigger (x10 !!) than = +the old=20 +one.
+
 
+
The memory runtime parameters are <= +/DIV> +
shared_buffer =3D 2048
+
work_mem =3D sort_mem =3D 2048
+
 
+
SNS_DATA shema is the following: +
 
+
           = +            &nb= +sp;=20 +Table "public.SNS_DATA"
       =20 +Column       =20 +|           =20 +Type            = +;=20 +|    =20 +Modifiers
----------------------+-----------------------------+---------= +-----------
 Ordine        = +      =20 +|=20 +integer           &n= +bsp;        =20 +| not null default=20 +0
 Cod_Par         &nb= +sp;   =20 +| character varying(100)      | not=20 +null
 Cod_Ana         = +    =20 +| character varying(100)      | not=20 +null
 Valore         &= +nbsp;    =20 +| character varying(255)     =20 +|
 Descriz         &nb= +sp;   =20 +| character varying(512)     =20 +|
 Un_Mis         &nbs= +p;    =20 +| character varying(70)      =20 +|
 hash          = +      =20 +|=20 +integer           &n= +bsp;        =20 +|
 valid          = +;     =20 +|=20 +boolean           &n= +bsp;        =20 +| default=20 +true
 alarm         &n= +bsp;     =20 +|=20 +boolean           &n= +bsp;        =20 +| default=20 +false
 Cod_Luogo        &nb= +sp;  =20 +| character varying(30)      =20 +|
 Data_Arrivo_Campione | timestamp without time zone=20 +|
 site_id         &nb= +sp;   =20 +|=20 +integer           &n= +bsp;        =20 +|
 Cod_Luogo_v         = +; |=20 +character varying(30)      =20 +|
 repeated_val         |= +=20 +boolean           &n= +bsp;        =20 +| default false
Indexes:
    "sns_data2_pkey" PRIMARY = +KEY,=20 +btree ("Ordine", "Cod_Ana", "Cod_Par")
    "sns_datacodlu= +ogo2"=20 +btree ("Cod_Luogo")
    "sns_datatimefield2" btree=20 +("Data_Arrivo_Campione")
    "sns_siteid2" btree=20 +(site_id)
    "sns_valid2" btree=20 +("valid")
    "snsdata_codana" btree=20 +("Cod_Ana")
    "snsdata_codpar" btree=20 +("Cod_Par")
Foreign-key constraints:
    "$2" FOREIGN = +KEY=20 +("Cod_Ana") REFERENCES "SNS_ANA"("Cod_Ana") ON DELETE=20 +CASCADE
Triggers:
    sns_action_tr BEFORE INSERT OR U= +PDATE=20 +ON "SNS_DATA" FOR EACH ROW EXECUTE PROCEDURE sns_action()
+
 
+
The table has 2M of records
+
Can it be a datatype conversion issue?
+
Can it be depend on the the type of restore (with COPY commands)?
+
I have no idea.
+
 
+
Thanks in advance!
+
Reds +
 
+ +------=_NextPart_000_0079_01C48C13.E9F01870-- + + +From pgsql-performance-owner@postgresql.org Fri Aug 27 05:32:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AD01B5E46F5 + for ; + Fri, 27 Aug 2004 05:32:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 09725-06 + for ; + Fri, 27 Aug 2004 08:32:01 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 407E55E46F3 + for ; + Fri, 27 Aug 2004 05:31:59 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7R8VuLq012214 + for ; Fri, 27 Aug 2004 08:31:56 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7R8Qa4J010565 + for pgsql-performance@postgresql.org; Fri, 27 Aug 2004 08:26:36 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Date: Fri, 27 Aug 2004 10:26:26 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 49 +Message-ID: +References: <200408270145.i7R1jop04185@candle.pha.pa.us> + <87pt5dnta9.fsf@stark.xeocode.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +In-Reply-To: <87pt5dnta9.fsf@stark.xeocode.com> +X-Enigmail-Version: 0.85.0.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/386 +X-Sequence-Number: 8022 + +Greg Stark wrote: + +> The discussions before talked about a mechanism to try to place new + > tuples as close as possible to the proper index position. + +Means this that an index shall have a "fill factor" property, similar to +Informix one ? + + From the manual: + + +The FILLFACTOR option takes effect only when you build an index on a table +that contains more than 5,000 rows and uses more than 100 table pages, when +you create an index on a fragmented table, or when you create a fragmented +index on a nonfragmented table. +Use the FILLFACTOR option to provide for expansion of an index at a later +date or to create compacted indexes. +When the index is created, the database server initially fills only that +percentage of the nodes specified with the FILLFACTOR value. + +# Providing a Low Percentage Value +If you provide a low percentage value, such as 50, you allow room for growth +in your index. The nodes of the index initially fill to a certain percentage and +contain space for inserts. The amount of available space depends on the +number of keys in each page as well as the percentage value. +For example, with a 50-percent FILLFACTOR value, the page would be half +full and could accommodate doubling in size. A low percentage value can +result in faster inserts and can be used for indexes that you expect to grow. + + +# Providing a High Percentage Value +If you provide a high percentage value, such as 99, your indexes are +compacted, and any new index inserts result in splitting nodes. The +maximum density is achieved with 100 percent. With a 100-percent +FILLFACTOR value, the index has no room available for growth; any +additions to the index result in splitting the nodes. +A 99-percent FILLFACTOR value allows room for at least one insertion per +node. A high percentage value can result in faster selects and can be used for +indexes that you do not expect to grow or for mostly read-only indexes. + + + + +Regards +Gaetano Mendola + + + + + +From pgsql-performance-owner@postgresql.org Fri Aug 27 05:49:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 25D985E3F15 + for ; + Fri, 27 Aug 2004 05:49:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13244-05 + for ; + Fri, 27 Aug 2004 08:49:32 +0000 (GMT) +Received: from mail.pws.com.au (mail.pws.com.au [210.23.138.139]) + by svr1.postgresql.org (Postfix) with SMTP id 2A08C5E3631 + for ; + Fri, 27 Aug 2004 05:49:29 -0300 (ADT) +Received: (qmail 7045 invoked by uid 0); 27 Aug 2004 18:49:27 +1000 +Received: from cpe-203-45-44-212.vic.bigpond.net.au (HELO wizzard.pws.com.au) + (russell@pws.com.au@203.45.44.212) + by mail.pws.com.au with SMTP; 27 Aug 2004 18:49:27 +1000 +From: Russell Smith +To: pgsql-performance@postgresql.org +Subject: Re: Query performance issue with 8.0.0beta1 +Date: Fri, 27 Aug 2004 18:48:08 +1000 +User-Agent: KMail/1.6.1 +References: <007c01c48c03$269b50c0$0501a8c0@comai04> +In-Reply-To: <007c01c48c03$269b50c0$0501a8c0@comai04> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200408271848.08696.mr-russ@pws.com.au> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/387 +X-Sequence-Number: 8023 + +7.4.2 +> Aggregate (cost=46817.89..46817.89 rows=1 width=0) (actual time=401.216..401.217 rows=1 loops=1) +> -> Index Scan using snsdata_codpar on "SNS_DATA" (cost=0.00..46817.22 rows=268 width=0) (actual time=165.948..400.258 rows=744 loops=1) +> Index Cond: (("Cod_Par")::text = '17476'::text) +> Filter: (("Data_Arrivo_Campione" >= '2004-01-01 00:00:00'::timestamp without time zone) AND ("Data_Arrivo_Campione" <= '2004-01-31 23:59:59'::timestamp without time zone)) +> Total runtime: 401.302 ms +> +Row counts are out by a factor of 3, on the low side. so the planner will guess index is better, which it is. + +> ***while on 8.0.0*** +> Aggregate (cost=93932.91..93932.91 rows=1 width=0) (actual time=14916.371..14916.371 rows=1 loops=1) +> -> Seq Scan on "SNS_DATA" (cost=0.00..93930.14 rows=1108 width=0) (actual time=6297.152..14915.330 rows=744 loops=1) +> Filter: (("Data_Arrivo_Campione" >= '2004-01-01 00:00:00'::timestamp without time zone) AND ("Data_Arrivo_Campione" <= '2004-01-31 23:59:59'::timestamp without time zone) AND (("Cod_Par")::text = '17476'::text)) +> Total runtime: 14916.935 ms +Planner guesses that 1108 row should be returned, which is out by less, but on the high side. +Big question is given there are 2M rows, why does returning 1108 rows, less than 1% result in a sequence scan. +Usually the selectivity on the index is bad, try increasing the stats target on the column. + +I know 8.0 has new stats anaylsis code, which could be effecting how it choses the plan. But it would still +require a good amount of stats to get it to guess correctly. + +Increase stats and see if the times improve. + +> +> And I if disable the seqscan +> SET enable_seqscan = false; +> +> I get the following: +> +> Aggregate (cost=158603.19..158603.19 rows=1 width=0) (actual time=4605.862..4605.863 rows=1 loops=1) +> -> Index Scan using snsdata_codpar on "SNS_DATA" (cost=0.00..158600.41 rows=1108 width=0) (actual time=2534.422..4604.865 rows=744 loops=1) +> Index Cond: (("Cod_Par")::text = '17476'::text) +> Filter: (("Data_Arrivo_Campione" >= '2004-01-01 00:00:00'::timestamp without time zone) AND ("Data_Arrivo_Campione" <= '2004-01-31 23:59:59'::timestamp without time zone)) +> Total runtime: 4605.965 ms +> +> The total runtime is bigger (x10 !!) than the old one. +Did you run this multiple times, or is this the first time. If it had to get the data off disk it will be slower. +Are you sure that it's coming from disk in this and the 7.4 case? or both from memory. +If 7.4 is from buffer_cache, or kernel_cache, and 8.0 is from disk you are likely to get A LOT slower. + +> +> The memory runtime parameters are +> shared_buffer = 2048 +> work_mem = sort_mem = 2048 +> +[ snip ] + +> The table has 2M of records +> Can it be a datatype conversion issue? +That should not be an issue in 8.0, at least for the simple type conversions. like int8 to int4. +I'm not 100% sure which ones were added, and which were not, but the query appears to cast everything correctly anyway. + +> Can it be depend on the the type of restore (with COPY commands)? +Shouldn't and VACUUM FULL ANALYZE will make the table as small as possible. The row order may be different +on disk, but the planner won't know that, and it's a bad plan causing the problem. + +> I have no idea. +> +> Thanks in advance! +> Reds +> +Regards + +Russell Smith. + +From pgsql-performance-owner@postgresql.org Fri Aug 27 13:24:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AB10D5E46D2 + for ; + Fri, 27 Aug 2004 13:24:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64666-04 + for ; + Fri, 27 Aug 2004 16:24:03 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 83A775E46CD + for ; + Fri, 27 Aug 2004 13:23:53 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i7RGNvK05464; + Fri, 27 Aug 2004 12:23:57 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200408271623.i7RGNvK05464@candle.pha.pa.us> +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +In-Reply-To: +To: Gaetano Mendola +Date: Fri, 27 Aug 2004 12:23:57 -0400 (EDT) +Cc: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/388 +X-Sequence-Number: 8024 + + +I had FILLFACTOR in the TODO list until just a few months ago, but +because no one had discussed it in 3-4 years, I removed the item. I +have added mention now in the auto-cluster section because that actually +seems like the only good reason for a non-100% fillfactor. I don't +think our ordinary btrees have enough of a penalty for splits to make a +non-full fillfactor worthwhile, but having a non-full fillfactor for +autocluster controls how often items have to be shifted around. + +--------------------------------------------------------------------------- + +Gaetano Mendola wrote: +> Greg Stark wrote: +> +> > The discussions before talked about a mechanism to try to place new +> > tuples as close as possible to the proper index position. +> +> Means this that an index shall have a "fill factor" property, similar to +> Informix one ? +> +> From the manual: +> +> +> The FILLFACTOR option takes effect only when you build an index on a table +> that contains more than 5,000 rows and uses more than 100 table pages, when +> you create an index on a fragmented table, or when you create a fragmented +> index on a nonfragmented table. +> Use the FILLFACTOR option to provide for expansion of an index at a later +> date or to create compacted indexes. +> When the index is created, the database server initially fills only that +> percentage of the nodes specified with the FILLFACTOR value. +> +> # Providing a Low Percentage Value +> If you provide a low percentage value, such as 50, you allow room for growth +> in your index. The nodes of the index initially fill to a certain percentage and +> contain space for inserts. The amount of available space depends on the +> number of keys in each page as well as the percentage value. +> For example, with a 50-percent FILLFACTOR value, the page would be half +> full and could accommodate doubling in size. A low percentage value can +> result in faster inserts and can be used for indexes that you expect to grow. +> +> +> # Providing a High Percentage Value +> If you provide a high percentage value, such as 99, your indexes are +> compacted, and any new index inserts result in splitting nodes. The +> maximum density is achieved with 100 percent. With a 100-percent +> FILLFACTOR value, the index has no room available for growth; any +> additions to the index result in splitting the nodes. +> A 99-percent FILLFACTOR value allows room for at least one insertion per +> node. A high percentage value can result in faster selects and can be used for +> indexes that you do not expect to grow or for mostly read-only indexes. +> +> +> +> +> Regards +> Gaetano Mendola +> +> +> +> +> +> ---------------------------(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 Fri Aug 27 13:31:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 44B375E46F5 + for ; + Fri, 27 Aug 2004 13:31:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 68681-04 + for ; + Fri, 27 Aug 2004 16:31:40 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 6178D5E46F3 + for ; + Fri, 27 Aug 2004 13:31:29 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6191562; Fri, 27 Aug 2004 09:32:53 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Bruce Momjian , + Gaetano Mendola +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Date: Fri, 27 Aug 2004 09:31:06 -0700 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgresql.org +References: <200408271623.i7RGNvK05464@candle.pha.pa.us> +In-Reply-To: <200408271623.i7RGNvK05464@candle.pha.pa.us> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408270931.06191.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/389 +X-Sequence-Number: 8025 + +Bruce, + +What happened to the B-Tree Table patch discussed on Hackers ad nauseum last +winter? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Aug 27 13:32:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C4EA55E46FE + for ; + Fri, 27 Aug 2004 13:32:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 67070-06 + for ; + Fri, 27 Aug 2004 16:32:49 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D3D55E46F3 + for ; + Fri, 27 Aug 2004 13:32:40 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i7RGWh206951; + Fri, 27 Aug 2004 12:32:43 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200408271632.i7RGWh206951@candle.pha.pa.us> +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +In-Reply-To: <200408270931.06191.josh@agliodbs.com> +To: Josh Berkus +Date: Fri, 27 Aug 2004 12:32:43 -0400 (EDT) +Cc: Gaetano Mendola , + pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/390 +X-Sequence-Number: 8026 + +Josh Berkus wrote: +> Bruce, +> +> What happened to the B-Tree Table patch discussed on Hackers ad nauseum last +> winter? + +I don't remember that. The only issue I remember is sorting btree index +by heap tid on creation. We eventually got that into CVS for 8.0. + +-- + 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 Aug 27 13:51:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D2EE35E46E7 + for ; + Fri, 27 Aug 2004 13:51:17 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 74095-03 + for ; + Fri, 27 Aug 2004 16:51:20 +0000 (GMT) +Received: from lists.vasoftware.com (internalmx2.vasoftware.com + [12.152.184.150]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E8045E46CD + for ; + Fri, 27 Aug 2004 13:51:09 -0300 (ADT) +Received: from agni.hdqt.vasoftware.com ([10.2.200.27]:63610) + by lists.vasoftware.com with asmtp + (Cipher TLSv1:RC4-SHA:128) (Exim 4.20 #1 (Debian)) + id 1C0jwZ-0005JY-QK by VAauthid with fixed_plain + for ; Fri, 27 Aug 2004 09:51:15 -0700 +Mime-Version: 1.0 (Apple Message framework v619) +In-Reply-To: +References: <200408270145.i7R1jop04185@candle.pha.pa.us> + <87pt5dnta9.fsf@stark.xeocode.com> +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <4661B1AE-F849-11D8-8B8C-000A95C4BD7A@sf.net> +Content-Transfer-Encoding: 7bit +From: Adi Alurkar +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Date: Fri, 27 Aug 2004 09:51:00 -0700 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.619) +X-EA-Verified: lists.vasoftware.com 1C0jwZ-0005JY-QK + 308cff83d7e69e33cd7ce57f38f01506 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/391 +X-Sequence-Number: 8027 + +Greetings, + +I am not sure if this applies only to clustering but for storage in +general, + +IIRC Oracle has 2 parameters that can be set at table creation : +from Oracle docs + +PCTFREE integer : +Specify the percentage of space in each data block of the table, object +table OID index, or partition reserved for future updates to the +table's rows. The value of PCTFREE must be a value from 0 to 99. A +value of 0 allows the entire block to be filled by inserts of new rows. +The default value is 10. This value reserves 10% of each block for +updates to existing rows and allows inserts of new rows to fill a +maximum of 90% of each block. +PCTFREE has the same function in the PARTITION description and in the +statements that create and alter clusters, indexes, materialized views, +and materialized view logs. The combination of PCTFREE and PCTUSED +determines whether new rows will be inserted into existing data blocks +or into new blocks. + +PCTUSED integer +Specify the minimum percentage of used space that Oracle maintains for +each data block of the table, object table OID index, or +index-organized table overflow data segment. A block becomes a +candidate for row insertion when its used space falls below PCTUSED. +PCTUSED is specified as a positive integer from 0 to 99 and defaults to +40. +PCTUSED has the same function in the PARTITION description and in the +statements that create and alter clusters, materialized views, and +materialized view logs. +PCTUSED is not a valid table storage characteristic for an +index-organized table (ORGANIZATION INDEX). +The sum of PCTFREE and PCTUSED must be equal to or less than 100. You +can use PCTFREE and PCTUSED together to utilize space within a table +more efficiently. + +PostgreSQL could take some hints from the above. + +On Aug 27, 2004, at 1:26 AM, Gaetano Mendola wrote: + +> Greg Stark wrote: +> +>> The discussions before talked about a mechanism to try to place new +> > tuples as close as possible to the proper index position. +> +> Means this that an index shall have a "fill factor" property, similar +> to +> Informix one ? +> +> From the manual: +> +> +> The FILLFACTOR option takes effect only when you build an index on a +> table +> that contains more than 5,000 rows and uses more than 100 table pages, +> when +> you create an index on a fragmented table, or when you create a +> fragmented +> index on a nonfragmented table. +> Use the FILLFACTOR option to provide for expansion of an index at a +> later +> date or to create compacted indexes. +> When the index is created, the database server initially fills only +> that +> percentage of the nodes specified with the FILLFACTOR value. +> +> # Providing a Low Percentage Value +> If you provide a low percentage value, such as 50, you allow room for +> growth +> in your index. The nodes of the index initially fill to a certain +> percentage and +> contain space for inserts. The amount of available space depends on the +> number of keys in each page as well as the percentage value. +> For example, with a 50-percent FILLFACTOR value, the page would be half +> full and could accommodate doubling in size. A low percentage value can +> result in faster inserts and can be used for indexes that you expect +> to grow. +> +> +> # Providing a High Percentage Value +> If you provide a high percentage value, such as 99, your indexes are +> compacted, and any new index inserts result in splitting nodes. The +> maximum density is achieved with 100 percent. With a 100-percent +> FILLFACTOR value, the index has no room available for growth; any +> additions to the index result in splitting the nodes. +> A 99-percent FILLFACTOR value allows room for at least one insertion +> per +> node. A high percentage value can result in faster selects and can be +> used for +> indexes that you do not expect to grow or for mostly read-only indexes. +> +> +> +> +> Regards +> Gaetano Mendola +> +> +> +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings +> +> +-- +Adi Alurkar (DBA sf.NET) +1024D/79730470 A491 5724 74DE 956D 06CB D844 6DF1 B972 7973 0470 + + + +From pgsql-performance-owner@postgresql.org Fri Aug 27 13:52:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 112395E46F3 + for ; + Fri, 27 Aug 2004 13:52:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 75381-02 + for ; + Fri, 27 Aug 2004 16:52:27 +0000 (GMT) +Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net + [67.119.5.202]) + by svr1.postgresql.org (Postfix) with ESMTP id F2A785E46D2 + for ; + Fri, 27 Aug 2004 13:52:17 -0300 (ADT) +Received: (from andrew@localhost) + by pillette.com (8.11.6/8.11.6) id i7RGqFV31987; + Fri, 27 Aug 2004 09:52:15 -0700 +Date: Fri, 27 Aug 2004 09:52:15 -0700 +From: andrew@pillette.com +Message-Id: <200408271652.i7RGqFV31987@pillette.com> +Subject: Re: Query performance issue with 8.0.0beta1 +To: "Stefano Bonnin" +Cc: +X-Originating-IP: 192.168.1.11 +X-Mailer: Webmin 0.940 +MIME-Version: 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME +X-Spam-Level: +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200408/392 +X-Sequence-Number: 8028 + +Is it possible (to mix two threads) that you had CLUSTERed the table on the old database in a way that retrieved the records in this query faster? + +From pgsql-performance-owner@postgresql.org Sun Aug 29 12:16:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 452A45E46CD + for ; + Fri, 27 Aug 2004 14:12:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80886-07 + for ; + Fri, 27 Aug 2004 17:11:54 +0000 (GMT) +Received: from mail.guest-tek.com (unknown [209.82.99.131]) + by svr1.postgresql.org (Postfix) with ESMTP id 911535E46E7 + for ; + Fri, 27 Aug 2004 14:11:53 -0300 (ADT) +Received: from TSDJKERKHOF ([209.82.99.130]) + by mail.guest-tek.com (8.11.6/8.11.6) with SMTP id i7RHDJA06741 + for ; Fri, 27 Aug 2004 11:13:20 -0600 +From: "Jack Kerkhof" +To: +Subject: Why does a simple query not use an obvious index? +Date: Fri, 27 Aug 2004 11:12:13 -0600 +Message-ID: +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0020_01C48C26.B452D5F0" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 tests=HTML_40_50, + HTML_FONTCOLOR_BLUE, HTML_FONTCOLOR_GREEN, HTML_FONTCOLOR_RED, + HTML_FONTCOLOR_UNSAFE, HTML_MESSAGE, HTML_TAG_EXISTS_TBODY +X-Spam-Level: +X-Archive-Number: 200408/421 +X-Sequence-Number: 8057 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0020_01C48C26.B452D5F0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 8bit + +The query: + select count(*) from billing where timestamp > now()-60 + +should obviously use the index + + CREATE INDEX billing_timestamp_idx ON billing USING btree ("timestamp" +timestamp_ops); + +on a table with 1400000 rows. + +But it uses a Seq Scan. If I set enable_seqscan=no, it indicates a queryplan +could not be calculated. + +Why does this simple query not use the timestamp index, and how can I get it +to? + +Thanks, Jack + + Jack Kerkhof + Research & Development + jack.kerkhof@guest-tek.com + www.guest-tek.com + 1.866.509.1010 3480 + +-------------------------------------------------------------------------- + + Guest-Tek is a leading provider of broadband technology solutions for +the hospitality industry. Guest-Tek's GlobalSuite� high-speed Internet +solution enables hotels to offer their guests the convenience of wired +and/or wireless broadband Internet access from guest rooms, meeting rooms +and public areas. + + + +------=_NextPart_000_0020_01C48C26.B452D5F0 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +
The=20 +query:
+
+

    select count(*) from billing where timestamp &g= +t;=20 +now()-60

+

should obvi= +ously use=20 +the index

+

    CREATE INDEX billing_timestamp_idx ON billing USING btree = +("timestamp" timestamp_ops);

+

on a table = +with=20 +1400000 rows.

+

But it uses= + a Seq=20 +Scan. If I set enable_seqscan=3Dno, it indicates a queryplan could not be= +=20 +calculated.

+

Why does this simple query not use the timestamp index, and how ca= +n I get=20 +it to?

+

Thanks, Jack

+ + + + + + +
+
Jack=20 + Kerkhof
Research & Development
jack.kerkhof@guest-tek.com
www.guest-tek.com
1.866.509= +.1010=20 + 3480
+
+ +
+

Guest-Tek is a = +leading=20 + provider of broadband technology solutions for the hospitality indust= +ry.=20 + Guest-Tek's GlobalSuite=99 high-speed Internet solution enables hotel= +s to=20 + offer their guests the convenience of wired and/or wireless broadband= +=20 + Internet access from guest rooms, meeting rooms and public areas.=20 +

+
 
+ +------=_NextPart_000_0020_01C48C26.B452D5F0-- + + +From pgsql-performance-owner@postgresql.org Fri Aug 27 14:15:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A2375E46CD + for ; + Fri, 27 Aug 2004 14:15:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84153-02 + for ; + Fri, 27 Aug 2004 17:15:02 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id F2C7B5E46E7 + for ; + Fri, 27 Aug 2004 14:15:01 -0300 (ADT) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6191852; Fri, 27 Aug 2004 10:16:17 -0700 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Stefano Bonnin" , + +Subject: Re: Query performance issue with 8.0.0beta1 +Date: Fri, 27 Aug 2004 10:14:29 -0700 +User-Agent: KMail/1.4.3 +References: <007c01c48c03$269b50c0$0501a8c0@comai04> +In-Reply-To: <007c01c48c03$269b50c0$0501a8c0@comai04> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200408271014.29619.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/393 +X-Sequence-Number: 8029 + +Stefano, + +> Hi, I have just installed 8.0.0beta1 and I noticed that some query are +> slower than 7.4.2 queries. + +Seems unlikely. How have you configured postgresql.conf? DID you +configure it for the 8.0 database? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Aug 27 14:27:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 660A55E46E7 + for ; + Fri, 27 Aug 2004 14:27:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85386-05 + for ; + Fri, 27 Aug 2004 17:27:32 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 3A53C5E46CD + for ; + Fri, 27 Aug 2004 14:27:31 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i7RHR7Z13191; + Fri, 27 Aug 2004 13:27:07 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200408271727.i7RHR7Z13191@candle.pha.pa.us> +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +In-Reply-To: <4661B1AE-F849-11D8-8B8C-000A95C4BD7A@sf.net> +To: Adi Alurkar +Date: Fri, 27 Aug 2004 13:27:07 -0400 (EDT) +Cc: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/394 +X-Sequence-Number: 8030 + + +But what is the advantage of non-full pages in Oracle? + +--------------------------------------------------------------------------- + +Adi Alurkar wrote: +> Greetings, +> +> I am not sure if this applies only to clustering but for storage in +> general, +> +> IIRC Oracle has 2 parameters that can be set at table creation : +> from Oracle docs +> +> PCTFREE integer : +> Specify the percentage of space in each data block of the table, object +> table OID index, or partition reserved for future updates to the +> table's rows. The value of PCTFREE must be a value from 0 to 99. A +> value of 0 allows the entire block to be filled by inserts of new rows. +> The default value is 10. This value reserves 10% of each block for +> updates to existing rows and allows inserts of new rows to fill a +> maximum of 90% of each block. +> PCTFREE has the same function in the PARTITION description and in the +> statements that create and alter clusters, indexes, materialized views, +> and materialized view logs. The combination of PCTFREE and PCTUSED +> determines whether new rows will be inserted into existing data blocks +> or into new blocks. +> +> PCTUSED integer +> Specify the minimum percentage of used space that Oracle maintains for +> each data block of the table, object table OID index, or +> index-organized table overflow data segment. A block becomes a +> candidate for row insertion when its used space falls below PCTUSED. +> PCTUSED is specified as a positive integer from 0 to 99 and defaults to +> 40. +> PCTUSED has the same function in the PARTITION description and in the +> statements that create and alter clusters, materialized views, and +> materialized view logs. +> PCTUSED is not a valid table storage characteristic for an +> index-organized table (ORGANIZATION INDEX). +> The sum of PCTFREE and PCTUSED must be equal to or less than 100. You +> can use PCTFREE and PCTUSED together to utilize space within a table +> more efficiently. +> +> PostgreSQL could take some hints from the above. +> +> On Aug 27, 2004, at 1:26 AM, Gaetano Mendola wrote: +> +> > Greg Stark wrote: +> > +> >> The discussions before talked about a mechanism to try to place new +> > > tuples as close as possible to the proper index position. +> > +> > Means this that an index shall have a "fill factor" property, similar +> > to +> > Informix one ? +> > +> > From the manual: +> > +> > +> > The FILLFACTOR option takes effect only when you build an index on a +> > table +> > that contains more than 5,000 rows and uses more than 100 table pages, +> > when +> > you create an index on a fragmented table, or when you create a +> > fragmented +> > index on a nonfragmented table. +> > Use the FILLFACTOR option to provide for expansion of an index at a +> > later +> > date or to create compacted indexes. +> > When the index is created, the database server initially fills only +> > that +> > percentage of the nodes specified with the FILLFACTOR value. +> > +> > # Providing a Low Percentage Value +> > If you provide a low percentage value, such as 50, you allow room for +> > growth +> > in your index. The nodes of the index initially fill to a certain +> > percentage and +> > contain space for inserts. The amount of available space depends on the +> > number of keys in each page as well as the percentage value. +> > For example, with a 50-percent FILLFACTOR value, the page would be half +> > full and could accommodate doubling in size. A low percentage value can +> > result in faster inserts and can be used for indexes that you expect +> > to grow. +> > +> > +> > # Providing a High Percentage Value +> > If you provide a high percentage value, such as 99, your indexes are +> > compacted, and any new index inserts result in splitting nodes. The +> > maximum density is achieved with 100 percent. With a 100-percent +> > FILLFACTOR value, the index has no room available for growth; any +> > additions to the index result in splitting the nodes. +> > A 99-percent FILLFACTOR value allows room for at least one insertion +> > per +> > node. A high percentage value can result in faster selects and can be +> > used for +> > indexes that you do not expect to grow or for mostly read-only indexes. +> > +> > +> > +> > +> > Regards +> > Gaetano Mendola +> > +> > +> > +> > +> > +> > ---------------------------(end of +> > broadcast)--------------------------- +> > TIP 7: don't forget to increase your free space map settings +> > +> > +> -- +> Adi Alurkar (DBA sf.NET) +> 1024D/79730470 A491 5724 74DE 956D 06CB D844 6DF1 B972 7973 0470 +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: Have you searched our list archives? +> +> http://archives.postgresql.org +> + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Fri Aug 27 14:39:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CF9C5E46CD + for ; + Fri, 27 Aug 2004 14:39:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91060-05 + for ; + Fri, 27 Aug 2004 17:39:33 +0000 (GMT) +Received: from mail.autorevenue.com (ip-208.178.167.106.gblx.net + [208.178.167.106]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BB825E46F9 + for ; + Fri, 27 Aug 2004 14:39:32 -0300 (ADT) +Received: from jeremydunn ([192.168.1.79]) (authenticated) + by mail.autorevenue.com (8.11.6/8.11.6) with ESMTP id i7RHdVl07359 + for ; Fri, 27 Aug 2004 13:39:31 -0400 +Reply-To: +From: "Jeremy Dunn" +To: +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Date: Fri, 27 Aug 2004 13:39:35 -0400 +Organization: AutoRevenue +Message-ID: <007e01c48c5c$d15f4c60$4f01a8c0@jeremydunn> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +In-Reply-To: <200408271727.i7RHR7Z13191@candle.pha.pa.us> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 +Importance: Normal +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/395 +X-Sequence-Number: 8031 + + + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of +> Bruce Momjian +> Sent: Friday, August 27, 2004 1:27 PM +> To: Adi Alurkar +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] Equivalent praxis to CLUSTERED INDEX? +> +> +> +> But what is the advantage of non-full pages in Oracle? +> + +One advantage has to do with updates of variable-length columns, e.g. +varchars. + +If the block is fully packed with data, an update to a varchar column +that makes the column wider, causes "row-chaining". This means that a +portion of the row is stored in a different data block, which may be +somewhere completely different in the storage array. Retrieving that +row (or even just that column from that row) as a unit may now require +additional disk seek(s). + +Leaving some space for updates in each data block doesn't prevent this +problem completely, but mitigates it to a certain extent. If for +instance a row is typically inserted with a null value for a varchar +column, but the application developer knows it will almost always get +updated with some value later on, then leaving a certain percentage of +empty space in each block allocated to that table makes sense. + +Conversely, if you know that your data is never going to get updated +(e.g. a data warehousing application), you might specify to pack the +blocks as full as possible. This makes for the most efficient data +retrieval performance. + +- Jeremy + + +From pgsql-performance-owner@postgresql.org Fri Aug 27 14:40:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F0B135E46F9 + for ; + Fri, 27 Aug 2004 14:40:00 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89551-09 + for ; + Fri, 27 Aug 2004 17:39:54 +0000 (GMT) +Received: from lists.vasoftware.com (internalmx2.vasoftware.com + [12.152.184.150]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C4C45E46CD + for ; + Fri, 27 Aug 2004 14:39:54 -0300 (ADT) +Received: from agni.hdqt.vasoftware.com ([10.2.200.27]:63719) + by lists.vasoftware.com with asmtp + (Cipher TLSv1:RC4-SHA:128) (Exim 4.20 #1 (Debian)) + id 1C0khd-0003ad-LS by VAauthid with fixed_plain + for ; Fri, 27 Aug 2004 10:39:53 -0700 +Mime-Version: 1.0 (Apple Message framework v619) +In-Reply-To: <200408271727.i7RHR7Z13191@candle.pha.pa.us> +References: <200408271727.i7RHR7Z13191@candle.pha.pa.us> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <118B3D82-F850-11D8-8B8C-000A95C4BD7A@sf.net> +Content-Transfer-Encoding: 7bit +From: Adi Alurkar +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Date: Fri, 27 Aug 2004 10:39:38 -0700 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.619) +X-EA-Verified: lists.vasoftware.com 1C0khd-0003ad-LS + 1c6158dd7033e8882bfebd4c9c4e44ed +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/396 +X-Sequence-Number: 8032 + +IIRC it it to reduce the "overflow" of data or what oracle calls +chained rows. i.e if a table has variable length columns and 10 rows +get inserted into a datapage, if this datapage is full and one of the +variable length field gets updated the row will now "overflow" into +another datapage, but if the datapage is created with an appropriate +amount of free space the updated row will be stored in one single +datapage. + +On Aug 27, 2004, at 10:27 AM, Bruce Momjian wrote: + +> +> But what is the advantage of non-full pages in Oracle? +> +> ----------------------------------------------------------------------- +> ---- +> +> Adi Alurkar wrote: +>> Greetings, +>> +>> I am not sure if this applies only to clustering but for storage in +>> general, +>> +>> IIRC Oracle has 2 parameters that can be set at table creation : +>> from Oracle docs +>> +>> PCTFREE integer : +>> Specify the percentage of space in each data block of the table, +>> object +>> table OID index, or partition reserved for future updates to the +>> table's rows. The value of PCTFREE must be a value from 0 to 99. A +>> value of 0 allows the entire block to be filled by inserts of new +>> rows. +>> The default value is 10. This value reserves 10% of each block for +>> updates to existing rows and allows inserts of new rows to fill a +>> maximum of 90% of each block. +>> PCTFREE has the same function in the PARTITION description and in the +>> statements that create and alter clusters, indexes, materialized +>> views, +>> and materialized view logs. The combination of PCTFREE and PCTUSED +>> determines whether new rows will be inserted into existing data blocks +>> or into new blocks. +>> +>> PCTUSED integer +>> Specify the minimum percentage of used space that Oracle maintains for +>> each data block of the table, object table OID index, or +>> index-organized table overflow data segment. A block becomes a +>> candidate for row insertion when its used space falls below PCTUSED. +>> PCTUSED is specified as a positive integer from 0 to 99 and defaults +>> to +>> 40. +>> PCTUSED has the same function in the PARTITION description and in the +>> statements that create and alter clusters, materialized views, and +>> materialized view logs. +>> PCTUSED is not a valid table storage characteristic for an +>> index-organized table (ORGANIZATION INDEX). +>> The sum of PCTFREE and PCTUSED must be equal to or less than 100. You +>> can use PCTFREE and PCTUSED together to utilize space within a table +>> more efficiently. +>> +>> PostgreSQL could take some hints from the above. +>> +>> On Aug 27, 2004, at 1:26 AM, Gaetano Mendola wrote: +>> +>>> Greg Stark wrote: +>>> +>>>> The discussions before talked about a mechanism to try to place new +>>>> tuples as close as possible to the proper index position. +>>> +>>> Means this that an index shall have a "fill factor" property, similar +>>> to +>>> Informix one ? +>>> +>>> From the manual: +>>> +>>> +>>> The FILLFACTOR option takes effect only when you build an index on a +>>> table +>>> that contains more than 5,000 rows and uses more than 100 table +>>> pages, +>>> when +>>> you create an index on a fragmented table, or when you create a +>>> fragmented +>>> index on a nonfragmented table. +>>> Use the FILLFACTOR option to provide for expansion of an index at a +>>> later +>>> date or to create compacted indexes. +>>> When the index is created, the database server initially fills only +>>> that +>>> percentage of the nodes specified with the FILLFACTOR value. +>>> +>>> # Providing a Low Percentage Value +>>> If you provide a low percentage value, such as 50, you allow room for +>>> growth +>>> in your index. The nodes of the index initially fill to a certain +>>> percentage and +>>> contain space for inserts. The amount of available space depends on +>>> the +>>> number of keys in each page as well as the percentage value. +>>> For example, with a 50-percent FILLFACTOR value, the page would be +>>> half +>>> full and could accommodate doubling in size. A low percentage value +>>> can +>>> result in faster inserts and can be used for indexes that you expect +>>> to grow. +>>> +>>> +>>> # Providing a High Percentage Value +>>> If you provide a high percentage value, such as 99, your indexes are +>>> compacted, and any new index inserts result in splitting nodes. The +>>> maximum density is achieved with 100 percent. With a 100-percent +>>> FILLFACTOR value, the index has no room available for growth; any +>>> additions to the index result in splitting the nodes. +>>> A 99-percent FILLFACTOR value allows room for at least one insertion +>>> per +>>> node. A high percentage value can result in faster selects and can be +>>> used for +>>> indexes that you do not expect to grow or for mostly read-only +>>> indexes. +>>> +>>> +>>> +>>> +>>> Regards +>>> Gaetano Mendola +>>> +>>> +>>> +>>> +>>> +>>> ---------------------------(end of +>>> broadcast)--------------------------- +>>> TIP 7: don't forget to increase your free space map settings +>>> +>>> +>> -- +>> Adi Alurkar (DBA sf.NET) +>> 1024D/79730470 A491 5724 74DE 956D 06CB D844 6DF1 B972 7973 0470 +>> +>> +>> +>> ---------------------------(end of +>> broadcast)--------------------------- +>> TIP 6: Have you searched our list archives? +>> +>> http://archives.postgresql.org +>> +> +> -- +> Bruce Momjian | http://candle.pha.pa.us +> pgman@candle.pha.pa.us | (610) 359-1001 +> + If your life is a hard drive, | 13 Roberts Road +> + Christ can be your backup. | Newtown Square, Pennsylvania +> 19073 +> +> ---------------------------(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 +> +> +-- +Adi Alurkar (DBA sf.NET) +1024D/79730470 A491 5724 74DE 956D 06CB D844 6DF1 B972 7973 0470 + + + +From pgsql-performance-owner@postgresql.org Fri Aug 27 14:49:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A5855E46D2 + for ; + Fri, 27 Aug 2004 14:49:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91524-09 + for ; + Fri, 27 Aug 2004 17:49:29 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 910065E46CD + for ; + Fri, 27 Aug 2004 14:49:22 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i7RHmfJ15766; + Fri, 27 Aug 2004 13:48:41 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200408271748.i7RHmfJ15766@candle.pha.pa.us> +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +In-Reply-To: <118B3D82-F850-11D8-8B8C-000A95C4BD7A@sf.net> +To: Adi Alurkar +Date: Fri, 27 Aug 2004 13:48:41 -0400 (EDT) +Cc: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/397 +X-Sequence-Number: 8033 + +Adi Alurkar wrote: +> IIRC it it to reduce the "overflow" of data or what oracle calls +> chained rows. i.e if a table has variable length columns and 10 rows +> get inserted into a datapage, if this datapage is full and one of the +> variable length field gets updated the row will now "overflow" into +> another datapage, but if the datapage is created with an appropriate +> amount of free space the updated row will be stored in one single +> datapage. + +Agreed. What I am wondering is with our system where every update gets +a new row, how would this help us? I know we try to keep an update on +the same row as the original, but is there any significant performance +benefit to doing that which would offset the compaction advantage? + +-- + 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 Aug 27 15:19:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 117B65E46E1 + for ; + Fri, 27 Aug 2004 15:19:37 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05156-03 + for ; + Fri, 27 Aug 2004 18:19:31 +0000 (GMT) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id EA0535E46F8 + for ; + Fri, 27 Aug 2004 15:19:31 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7RIJTHN001083; + Fri, 27 Aug 2004 14:19:29 -0400 (EDT) +To: Bruce Momjian +Cc: Adi Alurkar , pgsql-performance@postgresql.org +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +In-reply-to: <200408271748.i7RHmfJ15766@candle.pha.pa.us> +References: <200408271748.i7RHmfJ15766@candle.pha.pa.us> +Comments: In-reply-to Bruce Momjian + message dated "Fri, 27 Aug 2004 13:48:41 -0400" +Date: Fri, 27 Aug 2004 14:19:29 -0400 +Message-ID: <1082.1093630769@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/398 +X-Sequence-Number: 8034 + +Bruce Momjian writes: +> Agreed. What I am wondering is with our system where every update gets +> a new row, how would this help us? I know we try to keep an update on +> the same row as the original, but is there any significant performance +> benefit to doing that which would offset the compaction advantage? + +Because Oracle uses overwrite-in-place (undoing from an UNDO log on +transaction abort), while we always write a whole new row, it would take +much larger PCTFREE wastage to get a useful benefit in PG than it does +in Oracle. That wastage translates directly into increased I/O costs, +so I'm a bit dubious that we should assume there is a win to be had here +just because Oracle offers the feature. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Aug 29 12:15:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D6615E46E1 + for ; + Fri, 27 Aug 2004 15:32:18 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 10924-01 + for ; + Fri, 27 Aug 2004 18:32:08 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 8547D5E46C1 + for ; + Fri, 27 Aug 2004 15:32:04 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7RIW3Lq010909 + for ; Fri, 27 Aug 2004 18:32:03 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7RIQh9v008840 + for pgsql-performance@postgresql.org; Fri, 27 Aug 2004 18:26:43 GMT +From: Mischa Sandberg +Reply-To: ischamay.andbergsay@activestateway.com +User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +References: <118B3D82-F850-11D8-8B8C-000A95C4BD7A@sf.net> + <200408271748.i7RHmfJ15766@candle.pha.pa.us> +In-Reply-To: <200408271748.i7RHmfJ15766@candle.pha.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 23 +Message-ID: +Date: Fri, 27 Aug 2004 18:26:39 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200408/418 +X-Sequence-Number: 8054 + +I think you've probably fingered the kicker of why PG doesn't have this +kind of clustering already. Hence perhaps the need for other approaches +to the issue (the disk-IO efficiency of reading groups of rows related +by a common key) that other DB's (with in-place update) address with +synchronous clustering ('heap rebalancing' ?). + +Bruce Momjian wrote: +> Adi Alurkar wrote: +> +>>IIRC it it to reduce the "overflow" of data or what oracle calls +>>chained rows. i.e if a table has variable length columns and 10 rows +>>get inserted into a datapage, if this datapage is full and one of the +>>variable length field gets updated the row will now "overflow" into +>>another datapage, but if the datapage is created with an appropriate +>>amount of free space the updated row will be stored in one single +>>datapage. +> +> +> Agreed. What I am wondering is with our system where every update gets +> a new row, how would this help us? I know we try to keep an update on +> the same row as the original, but is there any significant performance +> benefit to doing that which would offset the compaction advantage? +> + +From pgsql-performance-owner@postgresql.org Fri Aug 27 16:29:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D64B5E3F15 + for ; + Fri, 27 Aug 2004 16:29:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28051-05 + for ; + Fri, 27 Aug 2004 19:29:19 +0000 (GMT) +Received: from web11905.mail.yahoo.com (web11905.mail.yahoo.com + [216.136.172.189]) + by svr1.postgresql.org (Postfix) with SMTP id 392E95E46D4 + for ; + Fri, 27 Aug 2004 16:29:18 -0300 (ADT) +Message-ID: <20040827192911.72205.qmail@web11905.mail.yahoo.com> +Received: from [209.167.177.36] by web11905.mail.yahoo.com via HTTP; + Fri, 27 Aug 2004 12:29:11 PDT +Date: Fri, 27 Aug 2004 12:29:11 -0700 (PDT) +From: Artimenko Igor +Subject: Why those queries do not utilize indexes? +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/399 +X-Sequence-Number: 8035 + +Hi everybody! + +Here is my queries: + +1. explain SELECT * FROM messageinfo WHERE user_id = CAST( 20000 AS BIGINT ) and msgstatus = CAST( +0 AS smallint ); + +2. explain SELECT * FROM messageinfo WHERE messageinfo.user_id = 20000::int8 and msgstatus = +0::smallint; + +In both cases Explain command shows: +1. Sequential search and very high cost if set enable_seqscan to on; +Seq scan on messageinfo ( cost=0.00..24371.30, rows =36802 ) + +2. Index scan but even bigger cost if set enable_seqscan to off; +Index �messagesStatus� on messageinfo ( Cost=0.00..27220.72, rows=36802 ) + +messageinfo table has 200 records which meet this criteria and 662420 in total: + +CREATE TABLE messageinfo +( + user_id int8 NOT NULL, + msgstatus int2 NOT NULL DEFAULT (0)::smallint, + receivedtime timestamp NOT NULL DEFAULT now(), + � + msgread bool DEFAULT false, + � + CONSTRAINT "$1" FOREIGN KEY (user_id) REFERENCES users (id) ON UPDATE CASCADE ON DELETE CASCADE, + ) +WITH OIDS; + +CREATE INDEX msgstatus + ON messageinfo + USING btree + (user_id, msgstatus); + +CREATE INDEX "messagesStatus" + ON messageinfo + USING btree + (msgstatus); + +CREATE INDEX msgread + ON messageinfo + USING btree + (user_id, msgread); + +CREATE INDEX "receivedTime" + ON messageinfo + USING btree + (receivedtime); + + +MY QUESTIONS ARE: + +1. Should I afraid of high cost indexes? Or query will still be very efficient? + +2. Postgres does not use the index I need. For my data sets it�s always msgstatus index is +narrowest compare with �messagesStatus� one. Is any way to �enforce� to use a particular index? +What�s the logic when Postgres chooses one index compare with the other. + +3. I can change db structure to utilize Postgres specifics if you can tell them to me. + +4. Also, originally I had �messagesStatus� index having 2 components ( �msgstatus�, �user_id� ). +But query SELECT * FROM messageinfo WHERE msgstatus = 0 did not utilize indexes in this case. It +only worked if both index components are in WHERE part. So I have to remove 2-nd component +�user_id� from messagesStatus index even I wanted it. Is any way that where clause has only 1-st +component but index is utilized? + +Igor Artimenko + + + +__________________________________ +Do you Yahoo!? +Yahoo! Mail Address AutoComplete - You start. We finish. +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Fri Aug 27 16:31:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 376735E470E + for ; + Fri, 27 Aug 2004 16:31:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 30095-04 + for ; + Fri, 27 Aug 2004 19:31:30 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id E32C85E46EC + for ; + Fri, 27 Aug 2004 16:31:30 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1C0mRW-0002Oq-00; Fri, 27 Aug 2004 15:31:22 -0400 +To: Bruce Momjian +Cc: Adi Alurkar , pgsql-performance@postgresql.org +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +References: <200408271748.i7RHmfJ15766@candle.pha.pa.us> +In-Reply-To: <200408271748.i7RHmfJ15766@candle.pha.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 27 Aug 2004 15:31:22 -0400 +Message-ID: <87fz68ml85.fsf@stark.xeocode.com> +Lines: 35 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/400 +X-Sequence-Number: 8036 + +Bruce Momjian writes: + +> Agreed. What I am wondering is with our system where every update gets +> a new row, how would this help us? I know we try to keep an update on +> the same row as the original, but is there any significant performance +> benefit to doing that which would offset the compaction advantage? + +Hm. Posit a system where all transactions are short updates executed in +autocommit mode. + +In such a system as soon as a transaction commits it would take a very short +time before the previous record was a dead tuple. + +If every backend kept a small list of tuples it had marked deleted and +whenever it was idle checked to see if they were dead yet, it might avoid much +of the need for vacuum. And in such a circumstance I think you wouldn't need +more than a pctfree of 50% even on a busy table. Every tuple would need about +one extra slot. + +This would only be a reasonable idea if a) if the list of potential dead +tuples is short and if it overflows it just forgets them leaving them for +vacuum to deal with. and b) It only checks the potentially dead tuples when +the backend is otherwise idle. + +Even so it would be less efficient than a batch vacuum, and it would be taking +up i/o bandwidth (to maintain indexes even if the heap buffer is in ram), even +if that backend is idle it doesn't mean other backends couldn't have used that +i/o bandwidth. + +But I think it would deal with a lot of the complaints about vacuum and it +would make it more feasible to use a pctfree parameter to make clustering more +effective. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Fri Aug 27 16:35:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 44FA35E40BA + for ; + Fri, 27 Aug 2004 16:35:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28318-10 + for ; + Fri, 27 Aug 2004 19:34:57 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 4148A5E46F2 + for ; + Fri, 27 Aug 2004 16:34:57 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1C0mUz-0002P4-00; Fri, 27 Aug 2004 15:34:57 -0400 +To: Bruce Momjian +Cc: Adi Alurkar , pgsql-performance@postgresql.org +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +References: <200408271748.i7RHmfJ15766@candle.pha.pa.us> +In-Reply-To: <200408271748.i7RHmfJ15766@candle.pha.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 27 Aug 2004 15:34:57 -0400 +Message-ID: <87acwgml26.fsf@stark.xeocode.com> +Lines: 18 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/401 +X-Sequence-Number: 8037 + + +Bruce Momjian writes: + +> but is there any significant performance benefit to doing that which would +> offset the compaction advantage? + +Just as a side comment. Setting PCTFREE 0 PCTUSED 100 on tables that have no +updates on them has an astonishingly big effect on speed. So the penalty for +leaving some space free really is substantial. + +I think the other poster is right. Oracle really needs pctfree because of the +way it handles updates. Postgres doesn't really need as much because it +doesn't try to squeeze the new tuple in the space the old one took up. If it +doesn't fit on the page the worst that happens is it has to store it on some +other page, whereas oracle has to do its strange row chaining thing. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Fri Aug 27 16:43:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8EA635E37D0 + for ; + Fri, 27 Aug 2004 16:43:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 32563-07 + for ; + Fri, 27 Aug 2004 19:43:47 +0000 (GMT) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id AC5615E46F2 + for ; + Fri, 27 Aug 2004 16:43:36 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i7RJgoR03090; + Fri, 27 Aug 2004 15:42:50 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200408271942.i7RJgoR03090@candle.pha.pa.us> +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +In-Reply-To: <87acwgml26.fsf@stark.xeocode.com> +To: Greg Stark +Date: Fri, 27 Aug 2004 15:42:50 -0400 (EDT) +Cc: Adi Alurkar , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/402 +X-Sequence-Number: 8038 + +Greg Stark wrote: +> +> Bruce Momjian writes: +> +> > but is there any significant performance benefit to doing that which would +> > offset the compaction advantage? +> +> Just as a side comment. Setting PCTFREE 0 PCTUSED 100 on tables that have no +> updates on them has an astonishingly big effect on speed. So the penalty for +> leaving some space free really is substantial. +> +> I think the other poster is right. Oracle really needs pctfree because of the +> way it handles updates. Postgres doesn't really need as much because it +> doesn't try to squeeze the new tuple in the space the old one took up. If it +> doesn't fit on the page the worst that happens is it has to store it on some +> other page, whereas oracle has to do its strange row chaining thing. + +Oracle also does that chain thing so moving updates to different pages +might have more of an impact than it does on PostgreSQL. We have chains +too but just for locking. Not sure on Oracle. + +-- + 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 Aug 27 16:49:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A57B95E46D4 + for ; + Fri, 27 Aug 2004 16:49:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33777-08 + for ; + Fri, 27 Aug 2004 19:49:16 +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 106645E40BA + for ; + Fri, 27 Aug 2004 16:49:12 -0300 (ADT) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 3AC5C8467; Fri, 27 Aug 2004 21:49:12 +0200 (CEST) +Date: Fri, 27 Aug 2004 21:49:12 +0200 (CEST) +From: Dennis Bjorklund +To: Artimenko Igor +Cc: pgsql-performance@postgresql.org +Subject: Re: Why those queries do not utilize indexes? +In-Reply-To: <20040827192911.72205.qmail@web11905.mail.yahoo.com> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/403 +X-Sequence-Number: 8039 + +On Fri, 27 Aug 2004, Artimenko Igor wrote: + +> 1. Sequential search and very high cost if set enable_seqscan to on; +> Seq scan on messageinfo ( cost=0.00..24371.30, rows =36802 ) +> +> 2. Index scan but even bigger cost if set enable_seqscan to off; +> Index �messagesStatus� on messageinfo ( Cost=0.00..27220.72, rows=36802 ) + +So pg thinks that a sequential scan will be a little bit faster (The cost +is a little bit smaller). If you compare the actual runtimes maybe you +will see that pg was right. In this case the cost is almost the same so +the runtime is probably almost the same. + +When you have more data pg will start to use the index since then it will +be faster to use an index compared to a seq. scan. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Sun Aug 29 12:15:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C156C5E37D0 + for ; + Fri, 27 Aug 2004 17:03:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 40376-01 + for ; + Fri, 27 Aug 2004 20:03:23 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 4DA1F5E46E1 + for ; + Fri, 27 Aug 2004 17:03:12 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7RK2RLq040515 + for ; Fri, 27 Aug 2004 20:02:47 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7RJoFUi036600 + for pgsql-performance@postgresql.org; Fri, 27 Aug 2004 19:50:15 GMT +From: Mischa Sandberg +Reply-To: ischamay.andbergsay@activestateway.com +User-Agent: Mozilla Thunderbird 0.7.3 (X11/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +References: <200408271748.i7RHmfJ15766@candle.pha.pa.us> + <87acwgml26.fsf@stark.xeocode.com> +In-Reply-To: <87acwgml26.fsf@stark.xeocode.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Lines: 27 +Message-ID: +Date: Fri, 27 Aug 2004 19:50:12 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, + hits=1.1 tagged_above=0.0 required=5.0 tests=NO_DNS_FOR_FROM +X-Spam-Level: * +X-Archive-Number: 200408/419 +X-Sequence-Number: 8055 + +This discussion is starting to sound like the split in HEAP memory +management evolution, into garbage-collecting (e.g. Java) and +non-garbage-collecting (e.g. C++). + +Reclamation by GC's these days has become seriously sophisticated. +CLUSTER resembles the first generation of GC's, which were +single-big-pass hold-everything-else threads. + +Perhaps the latest in incremental GC algorithms would be worth scouting, +for the next step in PG page management. + +Greg Stark wrote: + +> Bruce Momjian writes: +> +>>but is there any significant performance benefit to doing that which would +>>offset the compaction advantage? +> +> Just as a side comment. Setting PCTFREE 0 PCTUSED 100 on tables that have no +> updates on them has an astonishingly big effect on speed. So the penalty for +> leaving some space free really is substantial. +> +> I think the other poster is right. Oracle really needs pctfree because of the +> way it handles updates. Postgres doesn't really need as much because it +> doesn't try to squeeze the new tuple in the space the old one took up. If it +> doesn't fit on the page the worst that happens is it has to store it on some +> other page, whereas oracle has to do its strange row chaining thing. + +From pgsql-performance-owner@postgresql.org Fri Aug 27 17:34:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 799015E46E1 + for ; + Fri, 27 Aug 2004 17:34:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 44697-08 + for ; + Fri, 27 Aug 2004 20:34:29 +0000 (GMT) +Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 83AA45E46D4 + for ; + Fri, 27 Aug 2004 17:34:28 -0300 (ADT) +Received: from localhost (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id A434E3FF6 + for ; + Fri, 27 Aug 2004 16:34:30 -0400 (EDT) +Received: from lorax.kcilink.com ([127.0.0.1]) + by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 41824-02 for ; + Fri, 27 Aug 2004 16:34:30 -0400 (EDT) +Received: by lorax.kcilink.com (Postfix, from userid 8) + id 284F73FE7; Fri, 27 Aug 2004 16:34:30 -0400 (EDT) +To: pgsql-performance@postgresql.org +Path: not-for-mail +From: Vivek Khera +Newsgroups: ml.postgres.performance +Subject: Re: Anyone familiar with Apple Xserve RAID +Date: Fri, 27 Aug 2004 16:34:29 -0400 +Organization: Khera Communications, Inc., Rockville, MD +Lines: 18 +Message-ID: +References: <1093468177.12331.424.camel@camel> + <200408251422.08366.josh@agliodbs.com> + <08139423-F6EB-11D8-ACDB-000393DB553C@bahn.de> + <200408251649.02932.josh@agliodbs.com> +NNTP-Posting-Host: yertle.kcilink.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Trace: lorax.kcilink.com 1093638870 65317 65.205.34.180 (27 Aug 2004 + 20:34:30 GMT) +X-Complaints-To: daemon@kciLink.com +NNTP-Posting-Date: Fri, 27 Aug 2004 20:34:30 +0000 (UTC) +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Security Through + Obscurity, berkeley-unix) +Cancel-Lock: sha1:A0LsegcxGAAJqH/DnVMsbWJcnRk= +X-Virus-Scanned: by amavisd-new at kcilink.com +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/404 +X-Sequence-Number: 8040 + +>>>>> "JB" == Josh Berkus writes: + +JB> Guys, +>> the XServe/XRaid comes with FibreChannel + +JB> I stand corrected. That should help things some; it makes it more +JB> of a small tradeoff between performance and storage size for the +JB> drives. + + +it is fibre channel to the host. the internals are still IDE drives +with possibly multiple controllers inside the enclosure. + +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +Vivek Khera, Ph.D. Khera Communications, Inc. +Internet: khera@kciLink.com Rockville, MD +1-301-869-4449 x806 +AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ + +From pgsql-performance-owner@postgresql.org Fri Aug 27 18:09:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EDA745E46EC + for ; + Fri, 27 Aug 2004 18:09:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 58133-07 + for ; + Fri, 27 Aug 2004 21:08:58 +0000 (GMT) +Received: from web11904.mail.yahoo.com (web11904.mail.yahoo.com + [216.136.172.188]) + by svr1.postgresql.org (Postfix) with SMTP id DF68E5E3F15 + for ; + Fri, 27 Aug 2004 18:08:56 -0300 (ADT) +Message-ID: <20040827210858.16196.qmail@web11904.mail.yahoo.com> +Received: from [209.167.177.36] by web11904.mail.yahoo.com via HTTP; + Fri, 27 Aug 2004 14:08:58 PDT +Date: Fri, 27 Aug 2004 14:08:58 -0700 (PDT) +From: Artimenko Igor +Subject: Re: Why those queries do not utilize indexes? +To: Dennis Bjorklund +In-Reply-To: +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/405 +X-Sequence-Number: 8041 + +I could force Postgres to use the best index by removing condition "msgstatus = CAST( 0 AS +smallint );" from WHERE clause & set enable_seqscan to off; +Total runtime in this case dropped from 1883 ms ( sequential reads ) to 1.598 ms ( best index ). + +But unfortunatelly It does not resolve my problem. I can not remove above condition. I need to +find a way to use whole condition "WHERE user_id = CAST( 20000 AS BIGINT ) and msgstatus = CAST( 0 +AS smallint );" and still utilyze index. + +Yes you are right. Using "messagesStatus" index is even worse for my data set then sequential +scan. + +Igor Artimenko + +--- Dennis Bjorklund wrote: + +> On Fri, 27 Aug 2004, Artimenko Igor wrote: +> +> > 1. Sequential search and very high cost if set enable_seqscan to on; +> > Seq scan on messageinfo ( cost=0.00..24371.30, rows =36802 ) +> > +> > 2. Index scan but even bigger cost if set enable_seqscan to off; +> > Index �messagesStatus� on messageinfo ( Cost=0.00..27220.72, rows=36802 ) +> +> So pg thinks that a sequential scan will be a little bit faster (The cost +> is a little bit smaller). If you compare the actual runtimes maybe you +> will see that pg was right. In this case the cost is almost the same so +> the runtime is probably almost the same. +> +> When you have more data pg will start to use the index since then it will +> be faster to use an index compared to a seq. scan. +> +> -- +> /Dennis Bj�rklund +> +> + + + + +_______________________________ +Do you Yahoo!? +Win 1 of 4,000 free domain names from Yahoo! Enter now. +http://promotions.yahoo.com/goldrush + +From pgsql-performance-owner@postgresql.org Fri Aug 27 22:32:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AF43B5E3F15 + for ; + Fri, 27 Aug 2004 22:32:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26870-09 + for ; + Sat, 28 Aug 2004 01:32:05 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 85CE05E3631 + for ; + Fri, 27 Aug 2004 22:32:02 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7S1W3Lq030595 + for ; Sat, 28 Aug 2004 01:32:03 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7S12uk9023720 + for pgsql-performance@postgresql.org; Sat, 28 Aug 2004 01:02:56 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Date: Sat, 28 Aug 2004 03:02:47 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 51 +Message-ID: <412FD9B7.4080207@bigfoot.com> +References: <200408271748.i7RHmfJ15766@candle.pha.pa.us> + <1082.1093630769@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Tom Lane +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +In-Reply-To: <1082.1093630769@sss.pgh.pa.us> +X-Enigmail-Version: 0.85.0.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/406 +X-Sequence-Number: 8042 + +Tom Lane wrote: + + > Bruce Momjian writes: + > + >>Agreed. What I am wondering is with our system where every update gets + >>a new row, how would this help us? I know we try to keep an update on + >>the same row as the original, but is there any significant performance + >>benefit to doing that which would offset the compaction advantage? + > + > + > Because Oracle uses overwrite-in-place (undoing from an UNDO log on + > transaction abort), while we always write a whole new row, it would take + > much larger PCTFREE wastage to get a useful benefit in PG than it does + > in Oracle. That wastage translates directly into increased I/O costs, + > so I'm a bit dubious that we should assume there is a win to be had here + > just because Oracle offers the feature. + +Mmmm. Consider this scenario: + +ctid datas +(0,1) yyy-xxxxxxxxxxxxxxxxxxx +(0,2) -------- EMPTY -------- +(0,3) -------- EMPTY -------- +(0,4) -------- EMPTY -------- +(0,5) -------- EMPTY -------- +(0,6) yyy-xxxxxxxxxxxxxxxxxxx +(0,7) -------- EMPTY -------- +.... -------- EMPTY -------- +(0,11) yyy-xxxxxxxxxxxxxxxxxxx + + +the row (0,2) --> (0,5) are space available for the (0,1) updates. +This will help a table clustered ( for example ) to mantain his +own correct cluster order. + + + +Regards +Gaetano Mendola + + + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Fri Aug 27 23:08:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0683B5E46E7 + for ; + Fri, 27 Aug 2004 23:08:27 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80302-06 + for ; + Sat, 28 Aug 2004 02:08:19 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 88C7C5E40BA + for ; + Fri, 27 Aug 2004 23:08:16 -0300 (ADT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i7S27Ql09976; + Sat, 28 Aug 2004 04:07:27 +0200 +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 i7S28HV24925; + Sat, 28 Aug 2004 04:08:17 +0200 +Message-ID: <412FE901.3070707@bigfoot.com> +Date: Sat, 28 Aug 2004 04:08:01 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bruce Momjian +Cc: Tom Lane , + "pgsql-performance@postgresql.org" +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +References: <200408280146.i7S1kmB19226@candle.pha.pa.us> +In-Reply-To: <200408280146.i7S1kmB19226@candle.pha.pa.us> +X-Enigmail-Version: 0.85.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/407 +X-Sequence-Number: 8043 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +Bruce Momjian wrote: + +| Gaetano Mendola wrote: +| +|>Tom Lane wrote: +|> +|> > Bruce Momjian writes: +|> > +|> >>Agreed. What I am wondering is with our system where every update gets +|> >>a new row, how would this help us? I know we try to keep an update on +|> >>the same row as the original, but is there any significant performance +|> >>benefit to doing that which would offset the compaction advantage? +|> > +|> > +|> > Because Oracle uses overwrite-in-place (undoing from an UNDO log on +|> > transaction abort), while we always write a whole new row, it would take +|> > much larger PCTFREE wastage to get a useful benefit in PG than it does +|> > in Oracle. That wastage translates directly into increased I/O costs, +|> > so I'm a bit dubious that we should assume there is a win to be had here +|> > just because Oracle offers the feature. +|> +|>Mmmm. Consider this scenario: +|> +|>ctid datas +|>(0,1) yyy-xxxxxxxxxxxxxxxxxxx +|>(0,2) -------- EMPTY -------- +|>(0,3) -------- EMPTY -------- +|>(0,4) -------- EMPTY -------- +|>(0,5) -------- EMPTY -------- +|>(0,6) yyy-xxxxxxxxxxxxxxxxxxx +|>(0,7) -------- EMPTY -------- +|>.... -------- EMPTY -------- +|>(0,11) yyy-xxxxxxxxxxxxxxxxxxx +|> +|> +|>the row (0,2) --> (0,5) are space available for the (0,1) updates. +|>This will help a table clustered ( for example ) to mantain his +|>own correct cluster order. +| +| +| Right. My point was that non-full fill is valuable for us only when +| doing clustering, while for Oracle it is a win even in non-cluster cases +| because of the way they update in place. + +Don't you think this will permit also to avoid extra disk seek and cache +invalidation? If you are updating the row (0,1) I think is less expensive +put the new version in (0,2) instead of thousand line far from that point. + + +Regards +Gaetano Mendola + + + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBL+kA7UpzwH2SGd4RAp6fAJ9rSs5xmTXsy4acUGcnCRTbEUCwrwCgo/o6 +0JPtziuf1E/EGLaqjbPMV44= +=pIgX +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Sat Aug 28 00:55:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 11C755E46E1 + for ; + Sat, 28 Aug 2004 00:55:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63317-06 + for ; + Sat, 28 Aug 2004 03:54:58 +0000 (GMT) +Received: from candle.pha.pa.us (unknown [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 818545E46C2 + for ; + Sat, 28 Aug 2004 00:54:49 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i7S3slb21543; + Fri, 27 Aug 2004 23:54:47 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200408280354.i7S3slb21543@candle.pha.pa.us> +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +In-Reply-To: <412FE901.3070707@bigfoot.com> +To: Gaetano Mendola +Date: Fri, 27 Aug 2004 23:54:47 -0400 (EDT) +Cc: Tom Lane , + "pgsql-performance@postgresql.org" +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/408 +X-Sequence-Number: 8044 + +Gaetano Mendola wrote: +> | Right. My point was that non-full fill is valuable for us only when +> | doing clustering, while for Oracle it is a win even in non-cluster cases +> | because of the way they update in place. +> +> Don't you think this will permit also to avoid extra disk seek and cache +> invalidation? If you are updating the row (0,1) I think is less expensive +> put the new version in (0,2) instead of thousand line far from that point. + +It would, but does that outweigh the decreased I/O by having things more +densely packed? I would think not. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Sat Aug 28 05:15:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C6F275E46CF + for ; + Sat, 28 Aug 2004 05:15:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18404-08 + for ; + Sat, 28 Aug 2004 08:15:15 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id EF59F5E46D1 + for ; + Sat, 28 Aug 2004 05:15:14 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1C0yMY-0003qU-00; Sat, 28 Aug 2004 04:15:02 -0400 +To: Bruce Momjian +Cc: Gaetano Mendola , Tom Lane , + "pgsql-performance@postgresql.org" +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +References: <200408280354.i7S3slb21543@candle.pha.pa.us> +In-Reply-To: <200408280354.i7S3slb21543@candle.pha.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 28 Aug 2004 04:15:01 -0400 +Message-ID: <87k6vjllve.fsf@stark.xeocode.com> +Lines: 30 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/409 +X-Sequence-Number: 8045 + + +Bruce Momjian writes: + +> > Don't you think this will permit also to avoid extra disk seek and cache +> > invalidation? If you are updating the row (0,1) I think is less expensive +> > put the new version in (0,2) instead of thousand line far from that point. + +Well if the other buffer "a thousand lines far from that point" is already in +ram, then no, there's no penalty at the time for storing it there. + +However it destroys the clustering, which was the original point. + +> It would, but does that outweigh the decreased I/O by having things more +> densely packed? I would think not. + +Well the dense packing is worth something. But so is the clustering. There's +definitely a trade-off. + +I always found my largest tables are almost always insert-only tables anyways. +So in Oracle I would have pctused 100 pctfree 0 on them and get the +performance gain. + +The tables that would benefit from this would be tables always accessed by +indexes in index scans of more than one record. The better the clustering the +fewer pages the index scan would have to read in. If the data took 10% more +space but the index scan only needs 1/4 as many buffers it could be a big net +win. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sat Aug 28 05:51:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5CA8C5E46DC + for ; + Sat, 28 Aug 2004 05:51:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 26236-06 + for ; + Sat, 28 Aug 2004 08:50:52 +0000 (GMT) +Received: from vscan02.westnet.com.au (vscan02.westnet.com.au [203.10.1.132]) + by svr1.postgresql.org (Postfix) with ESMTP id 712635E46D1 + for ; + Sat, 28 Aug 2004 05:50:51 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by localhost (Postfix) with ESMTP id 84D5811AA5A; + Sat, 28 Aug 2004 16:50:41 +0800 (WST) +Received: from [192.168.1.3] (dsl-202-72-133-22.wa.westnet.com.au + [202.72.133.22]) + by vscan02.westnet.com.au (Postfix) with ESMTP id DB5FD11AA52; + Sat, 28 Aug 2004 16:50:32 +0800 (WST) +Message-ID: <41304752.3050208@familyhealth.com.au> +Date: Sat, 28 Aug 2004 16:50:26 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Artimenko Igor +Cc: pgsql-performance@postgresql.org +Subject: Re: Why those queries do not utilize indexes? +References: <20040827192911.72205.qmail@web11905.mail.yahoo.com> +In-Reply-To: <20040827192911.72205.qmail@web11905.mail.yahoo.com> +Content-Type: text/plain; charset=windows-1252; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/410 +X-Sequence-Number: 8046 + +First things first: try vacuum full analyze on all the tables involved. + +> 1. Should I afraid of high cost indexes? Or query will still be very efficient? + +Not necessarily. However, EXPLAIN output is pretty much useless for us +for helping you. You need to post EXPLAIN ANALYZE output. + +Then, you need to use explain analyze to check the speed difference +between the index and seq scan versions. Is the seq scan actually slower? + +> 2. Postgres does not use the index I need. For my data sets it�s always msgstatus index is +> narrowest compare with �messagesStatus� one. Is any way to �enforce� to use a particular index? +> What�s the logic when Postgres chooses one index compare with the other. + +It's complicated, but it's based on teh statistics in pg_statistic that +the vacuum analyze command gathers. + +> 3. I can change db structure to utilize Postgres specifics if you can tell them to me. + +I avoid using int8 and int2 in the first place :) In PostgreSQL 8.0, +they will be less troublesome, but I've never seen a need for them! + +> 4. Also, originally I had �messagesStatus� index having 2 components ( �msgstatus�, �user_id� ). +> But query SELECT * FROM messageinfo WHERE msgstatus = 0 did not utilize indexes in this case. It +> only worked if both index components are in WHERE part. So I have to remove 2-nd component +> �user_id� from messagesStatus index even I wanted it. Is any way that where clause has only 1-st +> component but index is utilized? + +So long as your where clause matches a subset of the columns in the +index in left to right order, the index can be used. For example, if +your index is over (a, b, c) then select * where a=1 and b=2; can use +the index. + +Chris + + +From pgsql-performance-owner@postgresql.org Sat Aug 28 08:15:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 763485E46F4 + for ; + Sat, 28 Aug 2004 08:14:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48496-10 + for ; + Sat, 28 Aug 2004 11:14:48 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 601415E3631 + for ; + Sat, 28 Aug 2004 08:14:42 -0300 (ADT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i7SBDoX12211 + for ; Sat, 28 Aug 2004 13:13:50 +0200 +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 i7SBEfV27430 + for ; Sat, 28 Aug 2004 13:14:41 +0200 +Message-ID: <4130691E.7090603@bigfoot.com> +Date: Sat, 28 Aug 2004 13:14:38 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Subject: ill-planned queries inside a stored procedure +X-Enigmail-Version: 0.85.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 + tests=TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200408/411 +X-Sequence-Number: 8047 + +Hi all, +do you know any clean workaround at ill-planned queries inside a stored procedure? +Let me explain with an example: + + +empdb=# select count(*) from user_logs; + count +--------- + 5223837 +(1 row) + +empdb=# select count(*) from user_logs where id_user = 5024; + count +-------- + 239453 +(1 row) + +empdb=# explain analyze select login_time from user_logs where id_user = 5024 order by id_user_log desc limit 1; + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=0.00..22.62 rows=1 width=12) (actual time=3.921..3.922 rows=1 loops=1) + -> Index Scan Backward using user_logs_pkey on user_logs (cost=0.00..5355619.65 rows=236790 width=12) (actual time=3.918..3.918 rows=1 loops=1) + Filter: (id_user = 5024) + Total runtime: 3.963 ms +(4 rows) + + +same select in a prepared query ( I guess the stored procedure use same plan ): + +empdb=# explain analyze execute test(5024); + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=759.60..759.61 rows=1 width=12) (actual time=45065.755..45065.756 rows=1 loops=1) + -> Sort (cost=759.60..760.78 rows=470 width=12) (actual time=45065.748..45065.748 rows=1 loops=1) + Sort Key: id_user_log + -> Index Scan using idx_user_user_logs on user_logs (cost=0.00..738.75 rows=470 width=12) (actual time=8.936..44268.087 rows=239453 loops=1) + Index Cond: (id_user = $1) + Total runtime: 45127.256 ms +(6 rows) + + +There is a way to say: replan this query at execution time ? + + +Regards +Gaetano Mendola + + + + + + +From pgsql-performance-owner@postgresql.org Sat Aug 28 09:02:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 507505E46F9 + for ; + Sat, 28 Aug 2004 09:02:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59493-06 + for ; + Sat, 28 Aug 2004 12:02:15 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E6445E46F3 + for ; + Sat, 28 Aug 2004 09:02:09 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7SC2ALq062108 + for ; Sat, 28 Aug 2004 12:02:10 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7SBdTR8058055 + for pgsql-performance@postgresql.org; Sat, 28 Aug 2004 11:39:29 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Date: Sat, 28 Aug 2004 13:39:31 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 22 +Message-ID: <41306EF3.2030304@bigfoot.com> +References: <200408280354.i7S3slb21543@candle.pha.pa.us> + <87k6vjllve.fsf@stark.xeocode.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +To: Greg Stark +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +In-Reply-To: <87k6vjllve.fsf@stark.xeocode.com> +X-Enigmail-Version: 0.85.0.0 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/412 +X-Sequence-Number: 8048 + +Greg Stark wrote: + +> Bruce Momjian writes: +> +> +>>>Don't you think this will permit also to avoid extra disk seek and cache +>>>invalidation? If you are updating the row (0,1) I think is less expensive +>>>put the new version in (0,2) instead of thousand line far from that point. +> +> +> Well if the other buffer "a thousand lines far from that point" is already in +> ram, then no, there's no penalty at the time for storing it there. + +I was wandering about the cache invalidation, may be the ram is big enough but I +doubt about the cache, the recommendation in this case is to modify adjacent +memory address instead of jumping. + + +Regards +Gaetano Mendola + + + +From pgsql-performance-owner@postgresql.org Sat Aug 28 12:13:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 423635E40BA + for ; + Sat, 28 Aug 2004 12:13:46 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 98818-10 + for ; + Sat, 28 Aug 2004 15:13:44 +0000 (GMT) +Received: from pillette.com (adsl-67-119-5-202.dsl.snfc21.pacbell.net + [67.119.5.202]) + by svr1.postgresql.org (Postfix) with ESMTP id DA3CD5E46C3 + for ; + Sat, 28 Aug 2004 12:13:35 -0300 (ADT) +Received: (from andrew@localhost) + by pillette.com (8.11.6/8.11.6) id i7SFDbh04877; + Sat, 28 Aug 2004 08:13:37 -0700 +Date: Sat, 28 Aug 2004 08:13:37 -0700 +From: andrew@pillette.com +Message-Id: <200408281513.i7SFDbh04877@pillette.com> +Subject: Re: ill-planned queries inside a stored procedure +To: Gaetano Mendola +Cc: "pgsql-performance@postgresql.org" +X-Originating-IP: 64.163.213.183 +X-Mailer: Webmin 0.940 +MIME-Version: 1.0 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.5 tagged_above=0.0 required=5.0 tests=NO_REAL_NAME, + RCVD_IN_DSBL, RCVD_IN_SORBS_MISC +X-Spam-Level: * +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Archive-Number: 200408/413 +X-Sequence-Number: 8049 + +I use "EXECUTE" inside a stored procedure for just this purpose. This is not the same as PREPARE/EXECUTE, it lets you send an arbitrary string as SQL within the procedure. You have to write the query text on the fly in the procedure, which can be a little messy with quoting and escaping. + +Gaetano Mendola wrote .. +> Hi all, +> do you know any clean workaround at ill-planned queries inside a stored +> procedure? + +From pgsql-performance-owner@postgresql.org Sat Aug 28 13:35:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8045C5E46D2 + for ; + Sat, 28 Aug 2004 13:35:30 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16701-09 + for ; + Sat, 28 Aug 2004 16:35:29 +0000 (GMT) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F4FF5E46F2 + for ; + Sat, 28 Aug 2004 13:35:20 -0300 (ADT) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id i7SGYXr13347; + Sat, 28 Aug 2004 18:34:34 +0200 +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 i7SGZOV28763; + Sat, 28 Aug 2004 18:35:24 +0200 +Message-ID: <4130B446.3080006@bigfoot.com> +Date: Sat, 28 Aug 2004 18:35:18 +0200 +From: Gaetano Mendola +User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: andrew@pillette.com +Cc: "pgsql-performance@postgresql.org" +Subject: Re: ill-planned queries inside a stored procedure +References: <200408281513.i7SFDbh04877@pillette.com> +In-Reply-To: <200408281513.i7SFDbh04877@pillette.com> +X-Enigmail-Version: 0.85.0.0 +X-Enigmail-Supports: pgp-inline, pgp-mime +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/414 +X-Sequence-Number: 8050 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +andrew@pillette.com wrote: + +| Gaetano Mendola wrote .. +| +|>Hi all, +|>do you know any clean workaround at ill-planned queries inside a stored +|>procedure? +| I use "EXECUTE" inside a stored procedure for just this purpose. This is +| not the same as PREPARE/EXECUTE, it lets you send an arbitrary string as +| SQL within the procedure. You have to write the query text on the fly in +| the procedure, which can be a little messy with quoting and escaping. +| + +Yes I knew, I wrote "clean workaround" :-) + +I hate write in function piece of code like this: + +~ [...] + +~ my_stm := ''SELECT '' || my_operation || ''( '' || a_id_transaction; +~ my_stm := my_stm || '', '' || a_id_contract; +~ my_stm := my_stm || '', '' || quote_literal(a_date) || '') AS res''; + +~ FOR my_record IN EXECUTE my_stm LOOP +~ IF my_record.res < 0 THEN +~ RETURN my_record.res; +~ END IF; + +~ EXIT; +~ END LOOP; + +~ [...] + +note also that useless loop that is needed to retrieve the value! + + + +Regards +Gaetano Mendola + + + + + + + + + + + + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (MingW32) +Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org + +iD8DBQFBMLRE7UpzwH2SGd4RAv0TAJ9+IokZjaXIhgV5dOH86FCvzSnewQCgwqxD +nuW9joHmPxOnlRWrvhsKaag= +=Axb7 +-----END PGP SIGNATURE----- + + +From pgsql-performance-owner@postgresql.org Sat Aug 28 14:42:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 00B785E46D2 + for ; + Sat, 28 Aug 2004 14:42:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 33324-03 + for ; + Sat, 28 Aug 2004 17:41:53 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.193]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A99F5E46F4 + for ; + Sat, 28 Aug 2004 14:41:53 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id 76so17700rnl + for ; + Sat, 28 Aug 2004 10:41:51 -0700 (PDT) +Received: by 10.38.73.68 with SMTP id v68mr247341rna; + Sat, 28 Aug 2004 10:41:51 -0700 (PDT) +Received: by 10.38.78.18 with HTTP; Sat, 28 Aug 2004 10:41:51 -0700 (PDT) +Message-ID: +Date: Sat, 28 Aug 2004 20:41:51 +0300 +From: Vitaly Belman +Reply-To: Vitaly Belman +To: Postgresql Performance +Subject: Performance hit on loading from HD +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/415 +X-Sequence-Number: 8051 + +I have a problem with certain queries performance. Trouble is that +while their execution plan is pretty good and mostly their execution +is great as well, their FIRST execution time (that is after you mount +the database) is abysmal. + +I realize that it happens due to the loading of data from the HD to +the memory/swap and it wouldn't be too bad if I just could make the +data stay in the memory, sadly, after a few minutes the data is back +on the HD and running the query again results the same bad +performance. + +Here's a query for example, though as I said, this problem occurs in +different queries. + +--------------------------------------------------------------------------------------- + + SELECT * + FROM bv_bookgenres, bv_books + WHERE bv_books.book_id = bv_bookgenres.book_id and genre_id = 987 +ORDER BY vote_avg limit 10 + +--------------------------------------------------------------------------------------- + +--------------------------------------------------------------------------------------- + +QUERY PLAN +Limit (cost=2601.16..2601.18 rows=10 width=193) (actual +time=4735.097..4735.107 rows=10 loops=1) + -> Sort (cost=2601.16..2601.70 rows=219 width=193) (actual +time=4735.092..4735.095 rows=10 loops=1) + Sort Key: bv_books.vote_avg + -> Nested Loop (cost=0.00..2592.64 rows=219 width=193) +(actual time=74.615..4719.147 rows=1877 loops=1) + -> Index Scan using i_bookgenres_genre_id on +bv_bookgenres (cost=0.00..1707.03 rows=218 width=4) (actual +time=74.540..2865.366 rows=1877 loops=1) + Index Cond: (genre_id = 987) + -> Index Scan using bv_books_pkey on bv_books +(cost=0.00..4.05 rows=1 width=193) (actual time=0.968..0.971 rows=1 +loops=1877) + Index Cond: (bv_books.book_id = "outer".book_id) +Total runtime: 4735.726 ms + +--------------------------------------------------------------------------------------- + +If I run the query again after it just finished running I would get +the following timing: + +--------------------------------------------------------------------------------------- + +Limit (cost=3937.82..3937.84 rows=10 width=204) + -> Sort (cost=3937.82..3938.38 rows=223 width=204) + Sort Key: bv_books.vote_avg + -> Nested Loop (cost=0.00..3929.12 rows=223 width=204) + -> Index Scan using i_bookgenres_genre_id on +bv_bookgenres (cost=0.00..1731.94 rows=222 width=8) + Index Cond: (genre_id = 987) + -> Index Scan using bv_books_pkey on bv_books +(cost=0.00..9.88 rows=1 width=196) + Index Cond: (bv_books.book_id = "outer".book_id) + +--------------------------------------------------------------------------------------- + +Before going on, I should say that I am running PostgreSQL on CoLinux +under Windows 2000. From what I read/tested, the CoLinux performance +on CoLinux are matching to the performance of VMWare. Yet, I'm still +wondering if it is a side effect of my development setup or if some of +my settings are indeed wrong. + +With that said, here is the information of the tables: + +--------------------------------------------------------------------------------------- + +CREATE TABLE bv_books +( + book_id serial NOT NULL, + book_name varchar(255) NOT NULL, + series_id int4, + series_index int2, + annotation_desc_id int4, + description_desc_id int4, + book_picture varchar(255) NOT NULL, + reviews_error int4 NOT NULL, + vote_avg float4 NOT NULL, + vote_count int4 NOT NULL, + book_genre int4[], + book_name_fulltext tsearch2.tsvector, + book_name_fulltext2 tsearch2.tsvector, + CONSTRAINT bv_books_pkey PRIMARY KEY (book_id), + CONSTRAINT fk_books_annotation_desc_id FOREIGN KEY +(annotation_desc_id) REFERENCES bv_descriptions (description_id) ON +UPDATE RESTRICT ON DELETE SET NULL, + CONSTRAINT fk_books_description_desc_id FOREIGN KEY +(description_desc_id) REFERENCES bv_descriptions (description_id) ON +UPDATE RESTRICT ON DELETE SET NULL, + CONSTRAINT fk_books_series_id FOREIGN KEY (series_id) REFERENCES +bv_series (series_id) ON UPDATE RESTRICT ON DELETE RESTRICT +) +WITH OIDS; + +CREATE TABLE bv_bookgenres +( + book_id int4 NOT NULL, + genre_id int4 NOT NULL, + CONSTRAINT bv_bookgenres_pkey PRIMARY KEY (book_id, genre_id), + CONSTRAINT fk_bookgenres_book_id FOREIGN KEY (book_id) REFERENCES +bv_books (book_id) ON UPDATE RESTRICT ON DELETE CASCADE, + CONSTRAINT fk_bookgenres_genre_id FOREIGN KEY (genre_id) REFERENCES +bv_genres (genre_id) ON UPDATE RESTRICT ON DELETE RESTRICT +) +WITH OIDS; + +--------------------------------------------------------------------------------------- + +As far as the data is concerned, there are around 170,000 rows in +bv_books and 940,000 in bv_bookgenres. There are also btree index on +all the relevant (to the query) fields. + +I can live up with the fact that the data has to be loaded the first +time it is accessed, but is it possible to make it stick longer in the +memory? Is it the fact that CoLinux gets only 128MB of RAM? Or one of +my settings should be fixed? + +Thanks + +From pgsql-performance-owner@postgresql.org Sat Aug 28 18:33:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 052AD5E46D1 + for ; + Sat, 28 Aug 2004 18:33:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 78809-04 + for ; + Sat, 28 Aug 2004 21:33:43 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id A77315E46C3 + for ; + Sat, 28 Aug 2004 18:33:41 -0300 (ADT) +Received: from [63.195.55.98] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6209364; Sat, 28 Aug 2004 14:35:01 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Vitaly Belman +Subject: Re: Performance hit on loading from HD +Date: Sat, 28 Aug 2004 14:34:23 -0700 +User-Agent: KMail/1.6.2 +Cc: Postgresql Performance +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: <200408281434.23950.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/416 +X-Sequence-Number: 8052 + +Vitaly, + +> I have a problem with certain queries performance. Trouble is that +> while their execution plan is pretty good and mostly their execution +> is great as well, their FIRST execution time (that is after you mount +> the database) is abysmal. + +This is a well-known problem. The general approach to this is to run a +script to do select * queries against all important tables on system +start-up. + +> I realize that it happens due to the loading of data from the HD to +> the memory/swap and it wouldn't be too bad if I just could make the +> data stay in the memory, sadly, after a few minutes the data is back +> on the HD and running the query again results the same bad +> performance. + +This could be for a variety of reasons. On a standard platform (which yours +most definitely is not), this would be due to database vacuuming, commits of +large updates to your data, or another application using most of the system +memory. + +> Before going on, I should say that I am running PostgreSQL on CoLinux +> under Windows 2000. From what I read/tested, the CoLinux performance +> on CoLinux are matching to the performance of VMWare. Yet, I'm still +> wondering if it is a side effect of my development setup or if some of +> my settings are indeed wrong. + +Probably you will continue to get worse-than-normal performance from both. +You simply can't expect performance PostgreSQL running on an emulation +environment. If you could, we wouldn't have bothered with a Windows port. +Speaking of which, have you started testing the Windows port? I'd be +interested in your comparison of it against running on CoLinux. + +> I can live up with the fact that the data has to be loaded the first +> time it is accessed, but is it possible to make it stick longer in the +> memory? Is it the fact that CoLinux gets only 128MB of RAM? Or one of +> my settings should be fixed? + +Well, mostly it's that you should start testing 8.0, and the Windows port. +Not only should running native be better, but 8.0 (thanks to the work of Jan +Wieck) is now able to take advantage of a large chunk of dedicated memory, +which earlier versions were not. Also, "lazy vacuum" and the "background +writer", also features of 8.0 and Jan's work, should prevent PostgreSQL from +cleaning out its own cache completely. You should test this, +*particularly* on Windows where we could use some more performance testing. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sun Aug 29 15:05:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EA27C5E46C2 + for ; + Sun, 29 Aug 2004 15:04:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 13121-01 + for ; + Sun, 29 Aug 2004 18:04:53 +0000 (GMT) +Received: from web41108.mail.yahoo.com (web41108.mail.yahoo.com + [66.218.93.24]) + by svr1.postgresql.org (Postfix) with SMTP id 5BAC15E46CD + for ; + Sun, 29 Aug 2004 15:04:52 -0300 (ADT) +Message-ID: <20040829180448.41247.qmail@web41108.mail.yahoo.com> +Received: from [61.25.53.100] by web41108.mail.yahoo.com via HTTP; + Sun, 29 Aug 2004 11:04:48 PDT +Date: Sun, 29 Aug 2004 11:04:48 -0700 (PDT) +From: Mr Pink +Subject: Re: Why does a simple query not use an obvious index? +To: Jack Kerkhof +Cc: pgsql-performance@postgresql.org +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/424 +X-Sequence-Number: 8060 + +Strangely enough, I don't find that result surprising. + +if the vast bulk of the data is in the past and now()-60 represents a very small slice of the data +we might expect that using an index is optimal, but there could be many reasons why it doesn't get +used. + +AFAIK postgres doesn't peek at values used in a query when optimizing so any query with a ">" type +condition is gonna have a seq scan as the plan since the best guess is that you are gonna match +50% of the table. That's one possible explanation. + +Another is that if the condition data types don't match then an indes won't be used you could try: + + select count(*) from billing where timestamp > (now()-60)::timestamp + +Might make a difference, I dunno, it's a case of testing amd seing what happens. + +You could try lowering the random page cost, it might help, but I don't like your chances. + +If your problem is that you want to access the most recent data from a large table with fast +response, then you could consider: + +1. a "recent" index. If the data is within the "recent" time from set a flag to true, other wise +null. Reset the flags periodically. Nulls aren't indexed so the selectivity of such an index is +much higher. Can work wonders. + +2, duplicate recent data in another table that is purged when data passes the age limit. This is +basic archiving. + +Something like that. Hopefully someone with more knowlege of the optimaizer will have a brighter +suggestion for you. + +What version are you using by the way? + +Regards +Mr Pink + +--- Jack Kerkhof wrote: + +> The query: +> select count(*) from billing where timestamp > now()-60 +> +> should obviously use the index +> +> CREATE INDEX billing_timestamp_idx ON billing USING btree ("timestamp" +> timestamp_ops); +> +> on a table with 1400000 rows. +> +> But it uses a Seq Scan. If I set enable_seqscan=no, it indicates a queryplan +> could not be calculated. +> +> Why does this simple query not use the timestamp index, and how can I get it +> to? +> +> Thanks, Jack +> +> Jack Kerkhof +> Research & Development +> jack.kerkhof@guest-tek.com +> www.guest-tek.com +> 1.866.509.1010 3480 +> +> -------------------------------------------------------------------------- +> +> Guest-Tek is a leading provider of broadband technology solutions for +> the hospitality industry. Guest-Tek's GlobalSuite�Ehigh-speed Internet +> solution enables hotels to offer their guests the convenience of wired +> and/or wireless broadband Internet access from guest rooms, meeting rooms +> and public areas. +> +> +> + + + + +__________________________________ +Do you Yahoo!? +Take Yahoo! Mail with you! Get it on your mobile phone. +http://mobile.yahoo.com/maildemo + +From pgsql-performance-owner@postgresql.org Sun Aug 29 15:27:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E51F5E3F15 + for ; + Sun, 29 Aug 2004 15:27:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 17617-04 + for ; + Sun, 29 Aug 2004 18:27:18 +0000 (GMT) +Received: from mpls-qmqp-04.inet.qwest.net (mpls-qmqp-04.inet.qwest.net + [63.231.195.115]) + by svr1.postgresql.org (Postfix) with SMTP id CC9C15E3631 + for ; + Sun, 29 Aug 2004 15:27:15 -0300 (ADT) +Received: (qmail 18210 invoked by uid 0); 29 Aug 2004 18:27:11 -0000 +Received: from mpls-pop-04.inet.qwest.net (63.231.195.4) + by mpls-qmqp-04.inet.qwest.net with QMQP; 29 Aug 2004 18:27:11 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-04.inet.qwest.net with SMTP; 29 Aug 2004 18:27:11 -0000 +Date: Sun, 29 Aug 2004 12:28:48 -0600 +Message-Id: <1093804128.5493.22.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Jack Kerkhof" +Cc: pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +In-Reply-To: +References: +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/425 +X-Sequence-Number: 8061 + +On Fri, 2004-08-27 at 11:12, Jack Kerkhof wrote: +> The query: +> +> select count(*) from billing where timestamp > now()-60 +> +> should obviously use the index +> +> CREATE INDEX billing_timestamp_idx ON billing USING btree +> ("timestamp" timestamp_ops); +> +> on a table with 1400000 rows. +> +> But it uses a Seq Scan. If I set enable_seqscan=no, it indicates a +> queryplan could not be calculated. + +Have you tried this: + +marlowe=> select now()-60; +ERROR: operator does not exist: timestamp with time zone - integer +HINT: No operator matches the given name and argument type(s). You may +need to add explicit type casts. + +you likely need: + +smarlowe=> select now()-'60 seconds'::interval; + ?column? +------------------------------- + 2004-08-29 12:25:38.249564-06 + +inside there. + +Also, count(*) is likely to always generate a seq scan due to the way +aggregates are implemented currently in pgsql. you might want to try: + +select somefield from sometable where timestampfield > now()-'60 +seconds'::interval + +and count the number of returned rows. If there's a lot, it won't be +any faster, if there's a few, it should be a win. + + +From pgsql-performance-owner@postgresql.org Sun Aug 29 15:57:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C323F5E3F15 + for ; + Sun, 29 Aug 2004 15:57:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22332-03 + for ; + Sun, 29 Aug 2004 18:57:51 +0000 (GMT) +Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) + by svr1.postgresql.org (Postfix) with ESMTP id 58A5C5E3631 + for ; + Sun, 29 Aug 2004 15:57:50 -0300 (ADT) +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1C1UsA-0007s4-00 + for ; Sun, 29 Aug 2004 20:57:50 +0200 +Date: Sun, 29 Aug 2004 20:57:50 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +Message-ID: <20040829185750.GA30018@uio.no> +References: + <20040829180448.41247.qmail@web41108.mail.yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20040829180448.41247.qmail@web41108.mail.yahoo.com> +X-Operating-System: Linux 2.6.6 on a i686 +User-Agent: Mutt/1.5.6+20040818i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/426 +X-Sequence-Number: 8062 + +On Sun, Aug 29, 2004 at 11:04:48AM -0700, Mr Pink wrote: +> Another is that if the condition data types don't match then an indes won't be used you could try: +> +> select count(*) from billing where timestamp > (now()-60)::timestamp + +In fact, I've had success with code like + + select count(*) from billing where timestamp > ( select now() - interval '1 minute' ) + +At least in my case (PostgreSQL 7.2, though), it made PostgreSQL magically do +an index scan. :-) + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Sun Aug 29 15:58:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 66C8C5E3F15 + for ; + Sun, 29 Aug 2004 15:58:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22196-07 + for ; + Sun, 29 Aug 2004 18:58:20 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 0CC4F5E3631 + for ; + Sun, 29 Aug 2004 15:58:20 -0300 (ADT) +Received: from [63.195.55.98] (account josh@agliodbs.com HELO + temoku.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 6220188; Sun, 29 Aug 2004 11:59:37 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: ischamay.andbergsay@activestateway.com +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Date: Sun, 29 Aug 2004 11:59:01 -0700 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <200408261818.i7QIIrr09640@candle.pha.pa.us> + <200408261132.30732.josh@agliodbs.com> + <3csXc.56326$X12.25148@edtnps84> +In-Reply-To: <3csXc.56326$X12.25148@edtnps84> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200408291159.01205.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/427 +X-Sequence-Number: 8063 + +Mishca, + +> Ummm ... not quite. In MSSQL/Sybase/Oracle, a clustered index maintains +> its space saturation as part of each update operation. High activity +> does indeed result in less-full pages (typically 60-80% full for tables +> with heavy deletions or rowsize changes). To bring the percentage back +> up, you run DBCC INDEXDEFRAG, which also does what you'd expect of a +> normal file defragmenter -- put related disk pages together on the platter. + +Sure, it does now, which is a nice thing. It didn't in the first version +(6.5) where this cluster maint needed to be done manually and asynchronously, +as I recall. + +> As for SQL Server being a 'single-user database' ... ummm ... no, I +> don't think so. + +Hmmm ... perhaps it would be better if I said "serial-only database". MSSQL +(like earlier versions of Sybase) handles transactions by spooling everything +out to a serial log, effectively making all transcations SERIAL isolation. +This has some significant benefits in performance for OLAP and data +warehousing, but really kills you on high-concurrency transaction processing. + +> I'm REALLY happy to be shut of the Microsoft world, but +> MSSQL 7/2000/2005 is a serious big DB engine. It also has some serious +> bright heads behind it. They hired Goetz Graefe and Paul (aka Per-Ake) +> Larsen away from academia, and it shows, in the join and aggregate +> processing. I'll be a happy camper if I manage to contribute something +> to PG that honks the way their stuff does. Happy to discuss, too. + +Yeah, they also have very speedy cursor handling. I can do things with +cursors in MSSQL that I wouldn't consider with other DBs. Not that that +makes up for the lack of other functionality, but it is nice when you need +it. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sun Aug 29 18:10:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 518395E46CD + for ; + Sun, 29 Aug 2004 18:10:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50782-03 + for ; + Sun, 29 Aug 2004 21:10:46 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id BF96B5E3631 + for ; + Sun, 29 Aug 2004 18:10:45 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1C1Wwf-0007qa-00; Sun, 29 Aug 2004 17:10:37 -0400 +To: Mr Pink +Cc: Jack Kerkhof , + pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +References: <20040829180448.41247.qmail@web41108.mail.yahoo.com> +In-Reply-To: <20040829180448.41247.qmail@web41108.mail.yahoo.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 29 Aug 2004 17:10:37 -0400 +Message-ID: <87llfxk5v6.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/428 +X-Sequence-Number: 8064 + + +Mr Pink writes: + +> AFAIK postgres doesn't peek at values used in a query when optimizing + +Of course it does. + +However sometimes things don't work perfectly. +To get good answers rather than just guesses we'll need two things: + +. What version of postgres are you using. +. The output of EXPLAIN ANALYZE select ... + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sun Aug 29 18:12:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DA9A15E46FA + for ; + Sun, 29 Aug 2004 18:12:15 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51315-07 + for ; + Sun, 29 Aug 2004 21:12:13 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 778AA5E46F2 + for ; + Sun, 29 Aug 2004 18:12:13 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1C1Wy5-0007qc-00; Sun, 29 Aug 2004 17:12:05 -0400 +To: "Scott Marlowe" +Cc: "Jack Kerkhof" , + pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +References: + <1093804128.5493.22.camel@localhost.localdomain> +In-Reply-To: <1093804128.5493.22.camel@localhost.localdomain> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 29 Aug 2004 17:12:05 -0400 +Message-ID: <87fz65k5sq.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/429 +X-Sequence-Number: 8065 + + +"Scott Marlowe" writes: + +> Also, count(*) is likely to always generate a seq scan due to the way +> aggregates are implemented currently in pgsql. you might want to try: + +Huh? I'm curious to know what you're talking about here. + +> select somefield from sometable where timestampfield > now()-'60 +> seconds'::interval +> +> and count the number of returned rows. If there's a lot, it won't be +> any faster, if there's a few, it should be a win. + +Why would this ever be faster? And how could postgres ever calculate that +without doing a sequential scan when count(*) would force it to do a +sequential scan? + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sun Aug 29 18:36:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 314505E46CC + for ; + Sun, 29 Aug 2004 18:36:25 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 55074-08 + for ; + Sun, 29 Aug 2004 21:36:22 +0000 (GMT) +Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net + [63.231.195.112]) + by svr1.postgresql.org (Postfix) with SMTP id AC4715E46C2 + for ; + Sun, 29 Aug 2004 18:36:20 -0300 (ADT) +Received: (qmail 33338 invoked by uid 0); 29 Aug 2004 21:36:23 -0000 +Received: from unknown (63.231.195.1) + by mpls-qmqp-01.inet.qwest.net with QMQP; 29 Aug 2004 21:36:23 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-01.inet.qwest.net with SMTP; 29 Aug 2004 21:36:22 -0000 +Date: Sun, 29 Aug 2004 15:38:00 -0600 +Message-Id: <1093815480.5493.29.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Greg Stark" +Cc: "Jack Kerkhof" , + pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +In-Reply-To: <87fz65k5sq.fsf@stark.xeocode.com> +References: + <1093804128.5493.22.camel@localhost.localdomain> + <87fz65k5sq.fsf@stark.xeocode.com> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/430 +X-Sequence-Number: 8066 + +On Sun, 2004-08-29 at 15:12, Greg Stark wrote: +> "Scott Marlowe" writes: +> +> > Also, count(*) is likely to always generate a seq scan due to the way +> > aggregates are implemented currently in pgsql. you might want to try: +> +> Huh? I'm curious to know what you're talking about here. + +This has been discussed ad infinitum on the lists in the past. And +explained by better minds than mine, but I'll give it a go. + +PostgreSQL has a "generic" aggregate method. Imagine instead doing a +select count(id1+id2-id3) from table where ... In that instance, it's +not a simple shortcut to just grab the number of rows anymore. Since +PostgreSQL uses a generic aggregate method that can be expanded by the +user with custom aggregates et. al., it has no optimizations to make +simple count(*) fast, like many other databases. + +Add to that the fact that even when postgresql uses an index it still +has to hit the data store to get the actual value of the tuple, and +you've got very few instances in which an index scan of more than some +small percentage of the table is worth while. I.e. a sequential scan +tends to "win" over an index scan quicker in postgresql than in other +databases like Oracle, where the data store is serialized and the +indexes have the correct information along with the application of the +transaction / roll back segments. + +> > select somefield from sometable where timestampfield > now()-'60 +> > seconds'::interval +> > +> > and count the number of returned rows. If there's a lot, it won't be +> > any faster, if there's a few, it should be a win. +> +> Why would this ever be faster? And how could postgres ever calculate that +> without doing a sequential scan when count(*) would force it to do a +> sequential scan? + +Because, count(*) CANNOT use an index. So, if you're hitting, say, +0.01% of the table (let's say 20 out of 20,000,000 rows or something +like that) then the second should be MUCH faster. + + +From pgsql-performance-owner@postgresql.org Sun Aug 29 18:42:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id EF4CB5E46CC + for ; + Sun, 29 Aug 2004 18:42:38 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 57651-04 + for ; + Sun, 29 Aug 2004 21:42:36 +0000 (GMT) +Received: from mpls-qmqp-03.inet.qwest.net (mpls-qmqp-03.inet.qwest.net + [63.231.195.114]) + by svr1.postgresql.org (Postfix) with SMTP id 13F975E46C2 + for ; + Sun, 29 Aug 2004 18:42:35 -0300 (ADT) +Received: (qmail 14319 invoked by uid 0); 29 Aug 2004 21:09:34 -0000 +Received: from mpls-pop-07.inet.qwest.net (63.231.195.7) + by mpls-qmqp-03.inet.qwest.net with QMQP; 29 Aug 2004 21:09:34 -0000 +Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) + by mpls-pop-07.inet.qwest.net with SMTP; 29 Aug 2004 21:42:37 -0000 +Date: Sun, 29 Aug 2004 15:44:15 -0600 +Message-Id: <1093815855.5493.33.camel@localhost.localdomain> +From: "Scott Marlowe" +To: "Greg Stark" +Cc: "Jack Kerkhof" , + pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +In-Reply-To: <1093815480.5493.29.camel@localhost.localdomain> +References: + <1093804128.5493.22.camel@localhost.localdomain> + <87fz65k5sq.fsf@stark.xeocode.com> + <1093815480.5493.29.camel@localhost.localdomain> +Content-Type: text/plain +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/431 +X-Sequence-Number: 8067 + +On Sun, 2004-08-29 at 15:38, Scott Marlowe wrote: +> On Sun, 2004-08-29 at 15:12, Greg Stark wrote: +> > "Scott Marlowe" writes: +> > +> > > Also, count(*) is likely to always generate a seq scan due to the way +> > > aggregates are implemented currently in pgsql. you might want to try: +> > +> > Huh? I'm curious to know what you're talking about here. +> +> This has been discussed ad infinitum on the lists in the past. And +> explained by better minds than mine, but I'll give it a go. +> +> PostgreSQL has a "generic" aggregate method. Imagine instead doing a +> select count(id1+id2-id3) from table where ... + +that should be avg(id1+id2-id3)... doh + + +From pgsql-performance-owner@postgresql.org Sun Aug 29 19:03:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4826D5E46C2 + for ; + Sun, 29 Aug 2004 19:03:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 59438-09 + for ; + Sun, 29 Aug 2004 22:03: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 8FC5A5E40BA + for ; + Sun, 29 Aug 2004 19:03:42 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7TM3hrQ016094; + Sun, 29 Aug 2004 18:03:43 -0400 (EDT) +To: "Jack Kerkhof" +Cc: pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +In-reply-to: <87fz65k5sq.fsf@stark.xeocode.com> +References: + <1093804128.5493.22.camel@localhost.localdomain> + <87fz65k5sq.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "29 Aug 2004 17:12:05 -0400" +Date: Sun, 29 Aug 2004 18:03:43 -0400 +Message-ID: <16093.1093817023@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/432 +X-Sequence-Number: 8068 + +>> select somefield from sometable where timestampfield > now()-'60 +>> seconds'::interval + +This is a FAQ, but since the archives don't seem to be up at the moment, +here's the answer once again: + +The expression "now() - something" is not a constant, so the planner +is faced with "timestampfield > unknownvalue". Its default assumption +about the number of rows that will match is much too high to make an +indexscan look profitable (from memory, I think it guesses that about +a third of the table will match...). + +There are a couple of hacks you can use to deal with this. Plan A +is just "set enable_seqscan = false" for this query. This is ugly and +not really recommended, but you should try it first to verify that you +do get an indexscan that way, just to be sure that lack of statistics +is the problem and not something else. + +Plan B is to add an extra WHERE clause to make the problem look like a +range query, eg + + where timestampfield > now() - ... AND timestampfield <= now(); + +The planner still doesn't know the exact values involved, so it still +can't make use of any statistics, but it can see that this is a range +constraint on timestampfield. The default guess about the selectivity +will be a lot smaller than in the case of the one-sided inequality, +and in most cases you should get an indexscan out of it. This isn't +completely guaranteed though. Also, it's got a severe problem in that +if you sometimes do queries with a large interval, it'll still do an +indexscan even though that may be quite inappropriate. + +Plan C is to fix things so that the compared-to value *does* look like a +constant; then the planner will correctly observe that only a small part +of the table is to be scanned, and do the right thing (given reasonably +up-to-date ANALYZE statistics, anyway). The most trustworthy way of +doing that is to compute the "now() - interval" value on the client side +and send over a timestamp constant. If that's not convenient for some +reason, people frequently use a hack like this: + + create function ago(interval) returns timestamptz as + 'select now() - $1' language sql strict immutable; + + select ... where timestampfield > ago('60 seconds'); + +This is a kluge because you are lying when you say that the result of +ago() is immutable; it obviously isn't. But the planner will believe +you, fold the function call to a constant during planning, and use the +result. CAUTION: this works nicely for interactively-issued SQL +queries, but it will come back to bite you if you try to use ago() in +prepared queries or plpgsql functions, because the premature collapsing +of the now() result will become significant. + +We have speculated about ways to get the planner to treat expressions +involving now() and similar functions as pseudo-constants, so that it +would do the right thing in this sort of situation without any kluges. +It's not been done yet though. + +BTW, the above discussion applies to PG 7.3 and later; if you're dealing +with an old version then there are some different considerations. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Aug 29 19:04:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CC7465E46CC + for ; + Sun, 29 Aug 2004 19:04:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 60274-05 + for ; + Sun, 29 Aug 2004 22:04:14 +0000 (GMT) +Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) + by svr1.postgresql.org (Postfix) with ESMTP id A145D5E46C2 + for ; + Sun, 29 Aug 2004 19:04:11 -0300 (ADT) +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1C1XmX-0000OK-00 + for ; Mon, 30 Aug 2004 00:04:13 +0200 +Date: Mon, 30 Aug 2004 00:04:13 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +Message-ID: <20040829220413.GA1490@uio.no> +References: + <1093804128.5493.22.camel@localhost.localdomain> + <87fz65k5sq.fsf@stark.xeocode.com> + <1093815480.5493.29.camel@localhost.localdomain> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1093815480.5493.29.camel@localhost.localdomain> +User-Agent: Mutt/1.5.6+20040818i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/433 +X-Sequence-Number: 8069 + +On Sun, Aug 29, 2004 at 03:38:00PM -0600, Scott Marlowe wrote: +>>> select somefield from sometable where timestampfield > now()-'60 +>>> seconds'::interval +>>> +>>> and count the number of returned rows. If there's a lot, it won't be +>>> any faster, if there's a few, it should be a win. +>> Why would this ever be faster? And how could postgres ever calculate that +>> without doing a sequential scan when count(*) would force it to do a +>> sequential scan? +> Because, count(*) CANNOT use an index. So, if you're hitting, say, +> 0.01% of the table (let's say 20 out of 20,000,000 rows or something +> like that) then the second should be MUCH faster. + +Of course count(*) can use an index: + +images=# explain analyze select count(*) from images where event='test'; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------ + Aggregate (cost=168.97..168.97 rows=1 width=0) (actual time=68.211..68.215 rows=1 loops=1) + -> Index Scan using unique_filenames on images (cost=0.00..168.81 rows=63 width=0) (actual time=68.094..68.149 rows=8 loops=1) + Index Cond: ((event)::text = 'test'::text) + Total runtime: 68.369 ms +(4 rows) + +However, it cannot rely on an index _alone_; it has to go fetch the relevant +pages, but of course, so must "select somefield from" etc.. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Sun Aug 29 19:10:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 434FB5E46C2 + for ; + Sun, 29 Aug 2004 19:10:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 64325-03 + for ; + Sun, 29 Aug 2004 22:10:06 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 040345E46EC + for ; + Sun, 29 Aug 2004 19:10:04 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1C1XsD-0007yF-00; Sun, 29 Aug 2004 18:10:05 -0400 +To: "Scott Marlowe" +Cc: "Greg Stark" , + "Jack Kerkhof" , + pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +References: + <1093804128.5493.22.camel@localhost.localdomain> + <87fz65k5sq.fsf@stark.xeocode.com> + <1093815480.5493.29.camel@localhost.localdomain> +In-Reply-To: <1093815480.5493.29.camel@localhost.localdomain> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 29 Aug 2004 18:10:05 -0400 +Message-ID: <874qmlk342.fsf@stark.xeocode.com> +Lines: 65 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/434 +X-Sequence-Number: 8070 + + +"Scott Marlowe" writes: + +> PostgreSQL has a "generic" aggregate method. Imagine instead doing a +> select count(id1+id2-id3) from table where ... In that instance, it's +> not a simple shortcut to just grab the number of rows anymore. Since +> PostgreSQL uses a generic aggregate method that can be expanded by the +> user with custom aggregates et. al., it has no optimizations to make +> simple count(*) fast, like many other databases. + +People expect count(*) _without a where clause_ to be cached in a single +global variable. Postgres can't do this, but the reason has everything to do +with MVCC, not with postgres's generalized aggregates. Because of MVCC +Postgres can't just store a single cached value, because there is no single +cached value. It would have to store a complete history back to the oldest +extant transaction. + +However in this case the user has a where clause. No database is going to +cache values of count(*) for random where clauses. But that doesn't stop +Postgres from using an index to fetch the records. + + +> > > select somefield from sometable where timestampfield > now()-'60 +> > > seconds'::interval +> > > +> > > and count the number of returned rows. If there's a lot, it won't be +> > > any faster, if there's a few, it should be a win. +> > +> > Why would this ever be faster? And how could postgres ever calculate that +> > without doing a sequential scan when count(*) would force it to do a +> > sequential scan? +> +> Because, count(*) CANNOT use an index. So, if you're hitting, say, +> 0.01% of the table (let's say 20 out of 20,000,000 rows or something +> like that) then the second should be MUCH faster. + +I think you've applied these past discussions and come up with some bogus +conclusions. + +The problem here has nothing to do with the count(*) and everything to do with +the WHERE clause. To fetch the records satisfying that where clause postgres +has to do exactly the same thing regardless of whether it's going to feed the +data to count(*) or return some or all of it to the client. + +If postgres decides the where clause isn't selective enough it'll choose to +use a sequential scan. However it would do that regardless of whether you're +calling count(*) or not. If the number is records is substantial then you +would get the overhead of the scan plus the time it takes to transfer all that +unnecessary data to the user. + +What you're probably thinking of when you talk about general purpose aggregate +interfaces is the difficulty of making min()/max() use indexes. That's a whole +other case entirely. That's where postgres's generalized aggregates leaves it +without enough information about what records the aggregate functions are +interested in and what index scans might make them faster. + +None of these common cases end up making it a good idea to read the records +into the clients and do the work in the client. The only cases where that +would make sense would be if the function requires doing some manipulation of +the data that's awkward to express in sql. The "top n" type of query is the +usual culprit, but with postgres's new array functions even that becomes +tractable. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sun Aug 29 19:18:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1FDB35E46C2 + for ; + Sun, 29 Aug 2004 19:18:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 65182-07 + for ; + Sun, 29 Aug 2004 22:18:19 +0000 (GMT) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3FFD65E46E7 + for ; + Sun, 29 Aug 2004 19:18:18 -0300 (ADT) +Received: from [134.22.70.99] (dyn-70-99.tor.dsl.tht.net [134.22.70.99]) + by tht.net (Postfix) with ESMTP + id 40D4B76A34; Sun, 29 Aug 2004 18:18:25 -0400 (EDT) +Subject: Re: Why does a simple query not use an obvious index? +From: Rod Taylor +To: Greg Stark +Cc: Scott Marlowe , + Jack Kerkhof , + Postgresql Performance +In-Reply-To: <874qmlk342.fsf@stark.xeocode.com> +References: + <1093804128.5493.22.camel@localhost.localdomain> + <87fz65k5sq.fsf@stark.xeocode.com> + <1093815480.5493.29.camel@localhost.localdomain> + <874qmlk342.fsf@stark.xeocode.com> +Content-Type: text/plain +Message-Id: <1093817899.42199.63.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Sun, 29 Aug 2004 18:18:20 -0400 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/435 +X-Sequence-Number: 8071 + +> People expect count(*) _without a where clause_ to be cached in a single +> global variable. Postgres can't do this, but the reason has everything to do + +Someone should write an approx_count('table') function that reads +reltuples from pg_class and tell them to use it in combination with +autovac. + +I've yet to see someone use count(*) across a table and not round the +result themselves (approx 9 million clients). + + + +From pgsql-performance-owner@postgresql.org Sun Aug 29 19:32:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C79C45E46C3 + for ; + Sun, 29 Aug 2004 19:32:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69580-01 + for ; + Sun, 29 Aug 2004 22:32:52 +0000 (GMT) +Received: from mail.pws.com.au (mail.pws.com.au [210.23.138.139]) + by svr1.postgresql.org (Postfix) with SMTP id E497A5E46C2 + for ; + Sun, 29 Aug 2004 19:32:49 -0300 (ADT) +Received: (qmail 19539 invoked by uid 0); 30 Aug 2004 08:32:49 +1000 +Received: from cpe-203-45-44-212.vic.bigpond.net.au (HELO wizzard.pws.com.au) + (russell@pws.com.au@203.45.44.212) + by mail.pws.com.au with SMTP; 30 Aug 2004 08:32:49 +1000 +From: Russell Smith +To: pgsql-performance@postgresql.org +Subject: Re: Query performance problem in 8.0.0beta1 +Date: Mon, 30 Aug 2004 08:31:30 +1000 +User-Agent: KMail/1.6.1 +References: <008a01c48b71$abd89640$0501a8c0@comai04> +In-Reply-To: <008a01c48b71$abd89640$0501a8c0@comai04> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200408300831.30498.mr-russ@pws.com.au> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/436 +X-Sequence-Number: 8072 + +Hi, + +I assume you have reposted because you have just signed up to the list. + +If this is the case, can you please read the archives or replies to your original post about this question. +It did make it onto the archives and myself and others did reply with a few ideas and questions. + +If you could address those in a reply mail that would help everybody with your problem + +Regards + +Russell Smith + +From pgsql-performance-owner@postgresql.org Sun Aug 29 23:10:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1DB705E46E1 + for ; + Sun, 29 Aug 2004 23:09:59 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08706-04 + for ; + Mon, 30 Aug 2004 02:09:55 +0000 (GMT) +Received: from web41110.mail.yahoo.com (web41110.mail.yahoo.com + [66.218.93.26]) + by svr1.postgresql.org (Postfix) with SMTP id D75A25E46D4 + for ; + Sun, 29 Aug 2004 23:09:53 -0300 (ADT) +Message-ID: <20040830020954.3596.qmail@web41110.mail.yahoo.com> +Received: from [210.230.185.241] by web41110.mail.yahoo.com via HTTP; + Sun, 29 Aug 2004 19:09:54 PDT +Date: Sun, 29 Aug 2004 19:09:54 -0700 (PDT) +From: Mr Pink +Subject: Re: Why does a simple query not use an obvious index? +To: pgsql-performance@postgresql.org +In-Reply-To: <87llfxk5v6.fsf@stark.xeocode.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/437 +X-Sequence-Number: 8073 + + +--- Greg Stark wrote: + +> +> Mr Pink writes: +> +> > AFAIK postgres doesn't peek at values used in a query when optimizing +> +> Of course it does. + +But not ones returned by a function such as now(), or when you use bind variables, as Tom aptly +explained. + +That's what I meant by 'peek'. Interestingly enough Oracle does that, it's inline with their +policy of recommending the use of bind variables. Perhaps postgres could use such a feature some +day. + + + + + +__________________________________ +Do you Yahoo!? +Yahoo! Mail - 50x more storage than other providers! +http://promotions.yahoo.com/new_mail + +From pgsql-performance-owner@postgresql.org Sun Aug 29 23:23:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 365FE5E46C2 + for ; + Sun, 29 Aug 2004 23:23:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11923-05 + for ; + Mon, 30 Aug 2004 02:23: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 0A13C5E46F2 + for ; + Sun, 29 Aug 2004 23:23:50 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7U2NuIH018967; + Sun, 29 Aug 2004 22:23:56 -0400 (EDT) +To: Mr Pink +Cc: pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +In-reply-to: <20040830020954.3596.qmail@web41110.mail.yahoo.com> +References: <20040830020954.3596.qmail@web41110.mail.yahoo.com> +Comments: In-reply-to Mr Pink + message dated "Sun, 29 Aug 2004 19:09:54 -0700" +Date: Sun, 29 Aug 2004 22:23:56 -0400 +Message-ID: <18966.1093832636@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/438 +X-Sequence-Number: 8074 + +Mr Pink writes: +>>> AFAIK postgres doesn't peek at values used in a query when optimizing +>> +>> Of course it does. + +> But not ones returned by a function such as now(), or when you use +> bind variables, as Tom aptly explained. + +FWIW, 8.0 does have the ability to use the values of bind variables for +planning estimation (Oliver Jowett did the work for this). The main +issue in the way of dealing with now() is that whatever we did to now() +would apply to all functions marked "stable", and it's a bit +nervous-making to assume that they should all be treated this way. +Or we could introduce more function volatility categories, but that's +not much fun either. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 30 04:38:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F312C5E46EC + for ; + Mon, 30 Aug 2004 04:38:47 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79559-10 + for ; + Mon, 30 Aug 2004 07:38:38 +0000 (GMT) +Received: from web41108.mail.yahoo.com (web41108.mail.yahoo.com + [66.218.93.24]) + by svr1.postgresql.org (Postfix) with SMTP id 75B475E46D2 + for ; + Mon, 30 Aug 2004 04:38:40 -0300 (ADT) +Message-ID: <20040830073841.30957.qmail@web41108.mail.yahoo.com> +Received: from [210.230.185.241] by web41108.mail.yahoo.com via HTTP; + Mon, 30 Aug 2004 00:38:41 PDT +Date: Mon, 30 Aug 2004 00:38:41 -0700 (PDT) +From: Mr Pink +Subject: Re: Why does a simple query not use an obvious index? +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <18966.1093832636@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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/439 +X-Sequence-Number: 8075 + +Yeah! Bind variable peeking is great news. I did actually read the guff, but forgot about that. + +Version 8 is looking great on paper, I hope I'll get a chance to play wth it soon. + +I can kind of appreciate your point about peeking stable functions, however, I would have thought +that if it was possible to do for bind variables (which could change many times in a transaction) +then it would make even more sense for a stable function which doesn't change for the life of the +transaction. No doubt this is an oversimplification the situation. + +regards +Mr Pink + + + +_______________________________ +Do you Yahoo!? +Win 1 of 4,000 free domain names from Yahoo! Enter now. +http://promotions.yahoo.com/goldrush + +From pgsql-performance-owner@postgresql.org Mon Aug 30 05:20:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id AA4625E3631 + for ; + Mon, 30 Aug 2004 05:20:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 89949-09 + for ; + Mon, 30 Aug 2004 08:19:58 +0000 (GMT) +Received: from mail.esphion.com (mail.esphion.com [202.6.75.178]) + by svr1.postgresql.org (Postfix) with ESMTP id C1C6F5E46C3 + for ; + Mon, 30 Aug 2004 05:20:01 -0300 (ADT) +Received: (qmail 8266 invoked from network); 30 Aug 2004 08:19:31 -0000 +Received: from unknown (HELO conker.?none?) (10.0.1.137) + by mail.esphion.com with SMTP; 30 Aug 2004 08:19:31 -0000 +Received: (nullmailer pid 13919 invoked by uid 10001); + Mon, 30 Aug 2004 08:19:59 -0000 +Date: Mon, 30 Aug 2004 20:19:59 +1200 +From: Guy Thornley +To: pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +Message-ID: <20040830081959.GC3714@conker.esphion.com> +Reply-To: Guy Thornley +References: + <1093804128.5493.22.camel@localhost.localdomain> + <87fz65k5sq.fsf@stark.xeocode.com> <16093.1093817023@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <16093.1093817023@sss.pgh.pa.us> +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/440 +X-Sequence-Number: 8076 + +On Sun, Aug 29, 2004 at 06:03:43PM -0400, Tom Lane wrote: +> >> select somefield from sometable where timestampfield > now()-'60 +> >> seconds'::interval +> +> This is a FAQ, but since the archives don't seem to be up at the moment, +> here's the answer once again: +> +> The expression "now() - something" is not a constant, so the planner +> is faced with "timestampfield > unknownvalue". Its default assumption +> about the number of rows that will match is much too high to make an +> indexscan look profitable (from memory, I think it guesses that about +> a third of the table will match...). + + +Ok; this explains some really wierd stuff I've been seeing. + +However, I'm seeing breakage of the form mentioned by the original poster +even when the query uses a _constant_ timestamp: [Postgres 7.4.3] + + ntais# \d detect.stats + Table "detect.stats" + Column | Type | Modifiers + --------------+--------------------------+------------------------------------------------------------- + anomaly_id | integer | not null + at | timestamp with time zone | not null default ('now'::text)::timestamp(6) with time zone + resolution | real | default 1.0 + values | real[] | + stat_type_id | integer | not null + Indexes: + "stats_pkey" primary key, btree (anomaly_id, stat_type_id, "at") + "stats__ends_at" btree (stats__ends_at("at", resolution, "values")) + Foreign-key constraints: + "$1" FOREIGN KEY (anomaly_id) REFERENCES anomalies(anomaly_id) ON DELETE CASCADE + "$2" FOREIGN KEY (stat_type_id) REFERENCES stat_types(stat_type_id) + + + ntais=# SET enable_seqscan = on; + SET + ntais=# EXPLAIN ANALYZE + SELECT anomaly_id, stat_type_id + FROM detect.stats + WHERE detect.stats__ends_at(at, resolution, values) > '2004-08-30 16:21:09+12'::timestamptz + ORDER BY anomaly_id, stat_type_id + ; + + QUERY PLAN + ----------------------------------------------------------------------------------------------------------------------------- + Sort (cost=602473.59..608576.72 rows=2441254 width=8) (actual time=198577.407..198579.136 rows=6152 loops=1) + Sort Key: anomaly_id, stat_type_id + -> Seq Scan on stats (cost=0.00..248096.42 rows=2441254 width=8) (actual time=198299.685..198551.460 rows=6152 loops=1) + Filter: (stats__ends_at("at", resolution, "values") > '2004-08-30 16:21:09+12'::timestamp with time zone) + Total runtime: 198641.649 ms + (5 rows) + + + ntais=# EXPLAIN ANALYZE + SELECT anomaly_id, stat_type_id + FROM detect.stats + WHERE detect.stats__ends_at(at, resolution, values) > '2004-08-30 + 16:21:09+12'::timestamptz + ORDER BY anomaly_id, stat_type_id + ; + + QUERY PLAN + -------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=10166043.26..10172146.40 rows=2441254 width=8) (actual time=44.710..46.661 rows=6934 loops=1) + Sort Key: anomaly_id, stat_type_id + -> Index Scan using stats__ends_at on stats (cost=0.00..9811666.09 rows=2441254 width=8) (actual time=0.075..24.702 rows=6934 loops=1) + Index Cond: (stats__ends_at("at", resolution, "values") > '2004-08-30 16:21:09+12'::timestamp with time zone) + Total runtime: 50.354 ms + (5 rows) + + + ntais=# SELECT count(*) FROM detect.stats; + count + --------- + 7326151 + (1 row) + +Ive done repeated ANALYZE's, both table-specific and database-wide, and get +the same result every time. + +For us, a global 'enable_seqscan = off' in postgresql.conf is the way to go. +You occasionally see an odd plan while developing a query (eg: scanning an +index with no contraint to simply get ORDER BY). Usually thats a broken +query/index, and I simply fix it. + + +Guy Thornley + +From pgsql-performance-owner@postgresql.org Mon Aug 30 12:41:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 99D075E470E + for ; + Mon, 30 Aug 2004 12:41:03 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 38269-09 + for ; + Mon, 30 Aug 2004 15:41: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 511BF5E4720 + for ; + Mon, 30 Aug 2004 12:40:58 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7UFf3Bb007270; + Mon, 30 Aug 2004 11:41:03 -0400 (EDT) +To: Guy Thornley +Cc: pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +In-reply-to: <20040830081959.GC3714@conker.esphion.com> +References: + <1093804128.5493.22.camel@localhost.localdomain> + <87fz65k5sq.fsf@stark.xeocode.com> <16093.1093817023@sss.pgh.pa.us> + <20040830081959.GC3714@conker.esphion.com> +Comments: In-reply-to Guy Thornley + message dated "Mon, 30 Aug 2004 20:19:59 +1200" +Date: Mon, 30 Aug 2004 11:41:02 -0400 +Message-ID: <7269.1093880462@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/441 +X-Sequence-Number: 8077 + +Guy Thornley writes: +> However, I'm seeing breakage of the form mentioned by the original poster +> even when the query uses a _constant_ timestamp: [Postgres 7.4.3] + +> Indexes: +> "stats_pkey" primary key, btree (anomaly_id, stat_type_id, "at") +> "stats__ends_at" btree (stats__ends_at("at", resolution, "values")) + +> ntais=# EXPLAIN ANALYZE +> SELECT anomaly_id, stat_type_id +> FROM detect.stats +> WHERE detect.stats__ends_at(at, resolution, values) > '2004-08-30 16:21:09+12'::timestamptz +> ORDER BY anomaly_id, stat_type_id +> ; + +Here I'm afraid you're just stuck until 8.0 comes out (or you're feeling +brave enough to use a beta). Releases before 8.0 do not maintain any +statistics about the contents of functional indexes, so the planner is +flying blind here in any case, and you end up with the very same 1/3rd +default assumption no matter what the right-hand side looks like. +You'll have to fall back to Plan A or Plan B to get this case to work +in 7.4. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 30 12:41:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 260975E46CC + for ; + Mon, 30 Aug 2004 12:41:10 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 39321-08 + for ; + Mon, 30 Aug 2004 15:41:13 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 814445E471C + for ; + Mon, 30 Aug 2004 12:41:04 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1C1oHK-0002Dp-00; Mon, 30 Aug 2004 11:41:06 -0400 +To: Guy Thornley +Cc: pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +References: + <1093804128.5493.22.camel@localhost.localdomain> + <87fz65k5sq.fsf@stark.xeocode.com> <16093.1093817023@sss.pgh.pa.us> + <20040830081959.GC3714@conker.esphion.com> +In-Reply-To: <20040830081959.GC3714@conker.esphion.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 30 Aug 2004 11:41:05 -0400 +Message-ID: <87k6vgiqge.fsf@stark.xeocode.com> +Lines: 11 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/442 +X-Sequence-Number: 8078 + + +Guy Thornley writes: + +> "stats__ends_at" btree (stats__ends_at("at", resolution, "values")) + +Postgres 7.4 doesn't have any stats on functional indexes. So it's back to +just guessing at the selectivity of this. 8.0 does gather stats for functional +indexes so it should be better off. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Aug 30 13:02:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B39CD5E46C2 + for ; + Mon, 30 Aug 2004 13:02:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 47810-02 + for ; + Mon, 30 Aug 2004 16:02:32 +0000 (GMT) +Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) + by svr1.postgresql.org (Postfix) with ESMTP id 4DB6D5E46F9 + for ; + Mon, 30 Aug 2004 13:02:22 -0300 (ADT) +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1C1oc0-0004PY-00 + for ; Mon, 30 Aug 2004 18:02:28 +0200 +Date: Mon, 30 Aug 2004 18:02:28 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +Message-ID: <20040830160228.GB16847@uio.no> +References: + <1093804128.5493.22.camel@localhost.localdomain> + <87fz65k5sq.fsf@stark.xeocode.com> <16093.1093817023@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <16093.1093817023@sss.pgh.pa.us> +X-Operating-System: Linux 2.6.6 on a i686 +User-Agent: Mutt/1.5.6+20040818i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/443 +X-Sequence-Number: 8079 + +On Sun, Aug 29, 2004 at 06:03:43PM -0400, Tom Lane wrote: +> The expression "now() - something" is not a constant, so the planner +> is faced with "timestampfield > unknownvalue". Its default assumption +> about the number of rows that will match is much too high to make an +> indexscan look profitable (from memory, I think it guesses that about +> a third of the table will match...). + +Out of curiosity, does the subselect query I presented earlier in the thread +count as "a constant"? It gives the correct query plan, but this could of +course just be correct by accident... + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Mon Aug 30 13:47:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3DFD65E46CC + for ; + Mon, 30 Aug 2004 13:47:31 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 63104-05 + for ; + Mon, 30 Aug 2004 16:47: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 89AB05E46EC + for ; + Mon, 30 Aug 2004 13:47:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7UGlNIG008090; + Mon, 30 Aug 2004 12:47:23 -0400 (EDT) +To: "Steinar H. Gunderson" +Cc: pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +In-reply-to: <20040830160228.GB16847@uio.no> +References: + <1093804128.5493.22.camel@localhost.localdomain> + <87fz65k5sq.fsf@stark.xeocode.com> <16093.1093817023@sss.pgh.pa.us> + <20040830160228.GB16847@uio.no> +Comments: In-reply-to "Steinar H. Gunderson" + message dated "Mon, 30 Aug 2004 18:02:28 +0200" +Date: Mon, 30 Aug 2004 12:47:23 -0400 +Message-ID: <8089.1093884443@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/444 +X-Sequence-Number: 8080 + +"Steinar H. Gunderson" writes: +> On Sun, Aug 29, 2004 at 06:03:43PM -0400, Tom Lane wrote: +>> The expression "now() - something" is not a constant, so the planner +>> is faced with "timestampfield > unknownvalue". + +> Out of curiosity, does the subselect query I presented earlier in the thread +> count as "a constant"? It gives the correct query plan, but this could of +> course just be correct by accident... + +That was on 7.2, wasn't it? I don't remember any longer exactly how 7.2 +does this stuff, but it's different from 7.3 and later (and certainly +not any more "right"). + +You did at one time need to hide now() in a subselect to get the planner +to consider an indexscan at all --- that was before we made the +distinction between immutable and stable functions, and so now() had +to be treated as unsafe to index against (just as random() still is). +I think 7.2 behaved that way but I'm not totally sure. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 30 14:46:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3155F5E46C2 + for ; + Mon, 30 Aug 2004 14:46:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 80392-05 + for ; + Mon, 30 Aug 2004 17:46:39 +0000 (GMT) +Received: from emepe3.com (unknown [69.93.218.52]) + by svr1.postgresql.org (Postfix) with ESMTP id B73D25E46E7 + for ; + Mon, 30 Aug 2004 14:46:39 -0300 (ADT) +Received: from [200.89.130.112] (helo=[192.168.0.101]) + by emepe3.com with asmtp (Exim 3.35 #1 (Debian)) id 1C1qVQ-0007nk-00 + for ; Mon, 30 Aug 2004 13:03:48 -0500 +Subject: seqscan instead of index scan +From: Martin Sarsale +To: pgsql-performance@postgresql.org +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-CNz/VnUoCsQ0YLwj9l6S" +Organization: Emepe3.com Inc +Message-Id: <1093887997.1680.71.camel@kadaif> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 30 Aug 2004 14:46:37 -0300 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/445 +X-Sequence-Number: 8081 + +--=-CNz/VnUoCsQ0YLwj9l6S +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +Dear all: + +Im having a weird problem here. I have a table w/ ~180.000 rows and I +want to select those where c > 0 or d > 0 (there only a few of those on +the table) +I indexed columns c and d (separately) but this query used the slow +seqscan instead of the index scan: + +select * from t where c<>0 or d<>0; + +After playing some time, I noticed that if I change the "or" for an +"and", pg used the fast index scan (but the query w/ 'and' was not what +I as looking for). + +Then, I thought I could do the following: +Creating an index with the expression (c+d) and selecting the rows where +c+d > 0: +select * from t where c + d <> 0; + +Again, this used a seqscan. Asking in #postgresql in freenode, somebody +told me to try to disable seqscan (set enable_seqscan false) and +suprisingly, Pg started using the index scan and it was -fast-. + +Now: I've no idea why it chooses to use a seq scan instead of the index +scan (yes, I've just vacuum analyzed the table before running the +query). + +Some more info: +c and d are both bigint. I've tried the queries casting the constant (0) +to bigint but nothing changed. + +Im using debian's pg 7.4.1-2. + + +Thanks in advance + + +--=-CNz/VnUoCsQ0YLwj9l6S +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) + +iD8DBQBBM2f8hruVGj+ub3MRAqNlAJ0fhruL7t5DLlQW6kHf99jtgzPuuQCgqAN1 +BoC6ca++eVHj89y+X+sEZho= +=Qvza +-----END PGP SIGNATURE----- + +--=-CNz/VnUoCsQ0YLwj9l6S-- + + +From pgsql-performance-owner@postgresql.org Mon Aug 30 14:53:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 237A35E46EE + for ; + Mon, 30 Aug 2004 14:53:44 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 79856-08 + for ; + Mon, 30 Aug 2004 17:53:39 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 4546A5E46E1 + for ; + Mon, 30 Aug 2004 14:53:38 -0300 (ADT) +Received: (qmail 32550 invoked by uid 500); 30 Aug 2004 18:02:27 -0000 +Date: Mon, 30 Aug 2004 13:02:27 -0500 +From: Bruno Wolff III +To: Martin Sarsale +Cc: pgsql-performance@postgresql.org +Subject: Re: seqscan instead of index scan +Message-ID: <20040830180227.GA32520@wolff.to> +Mail-Followup-To: Martin Sarsale , + pgsql-performance@postgresql.org +References: <1093887997.1680.71.camel@kadaif> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1093887997.1680.71.camel@kadaif> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/446 +X-Sequence-Number: 8082 + +On Mon, Aug 30, 2004 at 14:46:37 -0300, + Martin Sarsale wrote: +> Dear all: +> +> Im having a weird problem here. I have a table w/ ~180.000 rows and I +> want to select those where c > 0 or d > 0 (there only a few of those on +> the table) +> I indexed columns c and d (separately) but this query used the slow +> seqscan instead of the index scan: + +Postgres doesn't 'or' bitmaps derived from two indexes. You might have more +luck using a combined index. + +> +> select * from t where c<>0 or d<>0; +> +> After playing some time, I noticed that if I change the "or" for an +> "and", pg used the fast index scan (but the query w/ 'and' was not what +> I as looking for). +> +> Then, I thought I could do the following: +> Creating an index with the expression (c+d) and selecting the rows where +> c+d > 0: +> select * from t where c + d <> 0; +> +> Again, this used a seqscan. Asking in #postgresql in freenode, somebody +> told me to try to disable seqscan (set enable_seqscan false) and +> suprisingly, Pg started using the index scan and it was -fast-. +> +> Now: I've no idea why it chooses to use a seq scan instead of the index +> scan (yes, I've just vacuum analyzed the table before running the +> query). +> +> Some more info: +> c and d are both bigint. I've tried the queries casting the constant (0) +> to bigint but nothing changed. +> +> Im using debian's pg 7.4.1-2. +> +> +> Thanks in advance +> + + + +From pgsql-performance-owner@postgresql.org Mon Aug 30 15:06:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 67B205E46E9 + for ; + Mon, 30 Aug 2004 15:06:56 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85208-09 + for ; + Mon, 30 Aug 2004 18:06:51 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id A0F465E46CD + for ; + Mon, 30 Aug 2004 15:06:50 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +Subject: Re: seqscan instead of index scan +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Mon, 30 Aug 2004 14:06:48 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A748D@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] seqscan instead of index scan +Thread-Index: AcSOuX+HkVPS42ZmQO2FyI5QSwdPSwAAhMfg +From: "Merlin Moncure" +To: "Martin Sarsale" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/447 +X-Sequence-Number: 8083 + +> Im having a weird problem here. I have a table w/ ~180.000 rows and I +> want to select those where c > 0 or d > 0 (there only a few of those +on +> the table) +> I indexed columns c and d (separately) but this query used the slow +> seqscan instead of the index scan: + +create function is_somethingable (ctype, dtype) returns boolean as +' + return case when $1 > 0 and $2 > 0 then true else false end; +' language sql immutable; + +create index t_idx on t(is_somethingable(c,d)); + +analyze t; + +select * from t where is_somethingable(t.c, t.d) =3D true; + +Merlin + + +From pgsql-performance-owner@postgresql.org Mon Aug 30 15:07:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4AA7E5E46CD + for ; + Mon, 30 Aug 2004 15:07:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 85985-09 + for ; + Mon, 30 Aug 2004 18:07:19 +0000 (GMT) +Received: from emepe3.com (unknown [69.93.218.52]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EBA75E46CC + for ; + Mon, 30 Aug 2004 15:07:19 -0300 (ADT) +Received: from [200.89.130.112] (helo=[192.168.0.101]) + by emepe3.com with asmtp (Exim 3.35 #1 (Debian)) + id 1C1qpP-00085w-00; Mon, 30 Aug 2004 13:24:28 -0500 +Subject: Re: seqscan instead of index scan +From: Martin Sarsale +To: Bruno Wolff III +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20040830180227.GA32520@wolff.to> +References: <1093887997.1680.71.camel@kadaif> + <20040830180227.GA32520@wolff.to> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-BzpkraxbnHvJL81BJ7a8" +Organization: Emepe3.com Inc +Message-Id: <1093889235.1680.77.camel@kadaif> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 30 Aug 2004 15:07:15 -0300 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/448 +X-Sequence-Number: 8084 + +--=-BzpkraxbnHvJL81BJ7a8 +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Mon, 2004-08-30 at 15:02, Bruno Wolff III wrote: +> On Mon, Aug 30, 2004 at 14:46:37 -0300, + +> > Im having a weird problem here. I have a table w/ ~180.000 rows and I +> > want to select those where c > 0 or d > 0 (there only a few of those on +> > the table) +> > I indexed columns c and d (separately) but this query used the slow +> > seqscan instead of the index scan: +>=20 +> Postgres doesn't 'or' bitmaps derived from two indexes. You might have mo= +re +> luck using a combined index. + +With combined index, you mean a multiple column index? +From +http://www.postgresql.org/docs/7.4/interactive/indexes-multicolumn.html +=20 +"Multicolumn indexes can only be used if the clauses involving the +indexed columns are joined with AND. For instance, + +SELECT name FROM test2 WHERE major =3D constant OR minor =3D constant; + +cannot make use of the index test2_mm_idx defined above to look up both +columns. (It can be used to look up only the major column, however.) " + +But I need something like: + +select * from t where c<>0 or d<>0; + + + +--=-BzpkraxbnHvJL81BJ7a8 +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) + +iD8DBQBBM2zThruVGj+ub3MRAmboAKCkBK6xUlLrkHcolaRA89Bg9X0C7gCeJEci +KPgkINw1mfoHesdQWu4OjFM= +=iVgM +-----END PGP SIGNATURE----- + +--=-BzpkraxbnHvJL81BJ7a8-- + + +From pgsql-performance-owner@postgresql.org Mon Aug 30 15:17:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D63D5E46E9 + for ; + Mon, 30 Aug 2004 15:17:36 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 91528-02 + for ; + Mon, 30 Aug 2004 18:17:31 +0000 (GMT) +Received: from emepe3.com (unknown [69.93.218.52]) + by svr1.postgresql.org (Postfix) with ESMTP id CA48C5E46C2 + for ; + Mon, 30 Aug 2004 15:17:31 -0300 (ADT) +Received: from [200.89.130.112] (helo=[192.168.0.101]) + by emepe3.com with asmtp (Exim 3.35 #1 (Debian)) id 1C1qzI-0008A5-00 + for ; Mon, 30 Aug 2004 13:34:41 -0500 +Subject: Re: seqscan instead of index scan +From: Martin Sarsale +To: pgsql-performance@postgresql.org +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A748D@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3412A748D@Herge.rcsinc.local> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-Bj0TcJgC3Mt/MwzQ9e8O" +Organization: Emepe3.com Inc +Message-Id: <1093889849.1680.83.camel@kadaif> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Mon, 30 Aug 2004 15:17:29 -0300 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/449 +X-Sequence-Number: 8085 + +--=-Bj0TcJgC3Mt/MwzQ9e8O +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Mon, 2004-08-30 at 15:06, Merlin Moncure wrote: +> create function is_somethingable (ctype, dtype) returns boolean as + +Thanks, but I would prefer a simpler solution. + +I would like to know why this uses a seqscan instead of an index scan: + +create index t_idx on t((c+d)); +select * from t where c+d > 0;=20 + + + +--=-Bj0TcJgC3Mt/MwzQ9e8O +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) + +iD8DBQBBM285hruVGj+ub3MRAvAUAKCX/jDG6Xtz/ZhiBIeiXIhSL9EqFQCgnyfH +p2BvlqoMZjlDw8roQFe6Vyg= +=LMhX +-----END PGP SIGNATURE----- + +--=-Bj0TcJgC3Mt/MwzQ9e8O-- + + +From pgsql-performance-owner@postgresql.org Mon Aug 30 15:29:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 617885E46CD + for ; + Mon, 30 Aug 2004 15:29:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 95784-01 + for ; + Mon, 30 Aug 2004 18:29:24 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id C0BBB5E46EE + for ; + Mon, 30 Aug 2004 15:29:23 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +Subject: Re: seqscan instead of index scan +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Mon, 30 Aug 2004 14:29:24 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A748E@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] seqscan instead of index scan +Thread-Index: AcSOvYYliSyNTFGmRryjBjBPKpYAlQAADghA +From: "Merlin Moncure" +To: "Martin Sarsale" +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/450 +X-Sequence-Number: 8086 + +> On Mon, 2004-08-30 at 15:06, Merlin Moncure wrote: +> > create function is_somethingable (ctype, dtype) returns boolean as +>=20 +> Thanks, but I would prefer a simpler solution. +>=20 +> I would like to know why this uses a seqscan instead of an index scan: +>=20 +> create index t_idx on t((c+d)); +> select * from t where c+d > 0; +>=20 + +hmmm, please define simple.=20=20 + +Using a functional index you can define an index around the way you +access the data. There is no faster or better way to do it...this is a +mathematical truth, not a problem with the planner. Why not use the +right tool for the job? A boolean index is super-efficient both in disk +space and cache utilization. + +Multiple column indexes are useless for 'or' combinations! (however they +are a huge win for 'and' combinations because you don't have to merge). + +With an 'or' expression, the planner must use one index or the other, or +use both and merge the results. When and what the planner uses is an +educated guess based on statistics. + +Also, your function can be changed...why fill all your queries with +Boolean cruft when you can abstract it into the database and reap the +speed savings at the same time? I think it's time to rethink the +concept of 'simple'. + +Constructive criticism all, +Merlin + + + +From pgsql-performance-owner@postgresql.org Mon Aug 30 16:15:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D2C45E46F3 + for ; + Mon, 30 Aug 2004 16:15:29 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 08941-04 + for ; + Mon, 30 Aug 2004 19:15:24 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B2CB5E46C3 + for ; + Mon, 30 Aug 2004 16:15:21 -0300 (ADT) +Received: (qmail 27503 invoked from network); 30 Aug 2004 21:15:35 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 30 Aug 2004 21:15:35 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +References: <20040829180448.41247.qmail@web41108.mail.yahoo.com> +Message-ID: +Date: Mon, 30 Aug 2004 21:17:06 +0200 +From: =?utf-8?Q?Pierre-Fr=C3=A9d=C3=A9ric_Caillaud?= + +Organization: =?utf-8?Q?La_Boutique_Num=C3=A9rique?= +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <20040829180448.41247.qmail@web41108.mail.yahoo.com> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/452 +X-Sequence-Number: 8088 + + + Most likely your table has a SERIAL PRIMARY KEY in it, in this case, do +the following : + + my_limit = select primary_key_field from billing where timestamp > +(now()-60)::timestamp ORDER BY timestamp ASC LIMIT 1; + + then + + SELECT count(*) FROM billing WHERE primary_key_field>=my_limit; + + I don't know if it'll work better, but you can try. + + When you insert records in the table, they are appended at the end, so +this type of recent records query only requires reading the tail of the +table. It should be fast if planned correctly. + +> Strangely enough, I don't find that result surprising. +> +> if the vast bulk of the data is in the past and now()-60 represents a +> very small slice of the data +> we might expect that using an index is optimal, but there could be many +> reasons why it doesn't get +> used. +> +> AFAIK postgres doesn't peek at values used in a query when optimizing so +> any query with a ">" type +> condition is gonna have a seq scan as the plan since the best guess is +> that you are gonna match +> 50% of the table. That's one possible explanation. +> +> Another is that if the condition data types don't match then an indes +> won't be used you could try: +> +> select count(*) from billing where timestamp > (now()-60)::timestamp +> +> Might make a difference, I dunno, it's a case of testing amd seing what +> happens. +> +> You could try lowering the random page cost, it might help, but I don't +> like your chances. +> +> If your problem is that you want to access the most recent data from a +> large table with fast +> response, then you could consider: +> +> 1. a "recent" index. If the data is within the "recent" time from set a +> flag to true, other wise +> null. Reset the flags periodically. Nulls aren't indexed so the +> selectivity of such an index is +> much higher. Can work wonders. +> +> 2, duplicate recent data in another table that is purged when data +> passes the age limit. This is +> basic archiving. +> +> Something like that. Hopefully someone with more knowlege of the +> optimaizer will have a brighter +> suggestion for you. +> +> What version are you using by the way? +> Regards +> Mr Pink +> --- Jack Kerkhof wrote: +> +>> The query: +>> select count(*) from billing where timestamp > now()-60 +>> +>> should obviously use the index +>> +>> CREATE INDEX billing_timestamp_idx ON billing USING btree +>> ("timestamp" +>> timestamp_ops); +>> +>> on a table with 1400000 rows. +>> +>> But it uses a Seq Scan. If I set enable_seqscan=no, it indicates a +>> queryplan +>> could not be calculated. +>> +>> Why does this simple query not use the timestamp index, and how can I +>> get it +>> to? +>> +>> Thanks, Jack +>> +>> Jack Kerkhof +>> Research & Development +>> jack.kerkhof@guest-tek.com +>> www.guest-tek.com +>> 1.866.509.1010 3480 +>> +>> -------------------------------------------------------------------------- +>> +>> Guest-Tek is a leading provider of broadband technology solutions +>> for +>> the hospitality industry. Guest-Tek's GlobalSuite�Ehigh-speed Internet +>> solution enables hotels to offer their guests the convenience of wired +>> and/or wireless broadband Internet access from guest rooms, meeting +>> rooms +>> and public areas. +>> +>> +>> +> +> +> +> +> __________________________________ +> Do you Yahoo!? +> Take Yahoo! Mail with you! Get it on your mobile phone. +> http://mobile.yahoo.com/maildemo +> +> ---------------------------(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 Aug 30 16:09:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 306695E46C1 + for ; + Mon, 30 Aug 2004 16:09:22 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05554-08 + for ; + Mon, 30 Aug 2004 19:09:17 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 305FD5E46CC + for ; + Mon, 30 Aug 2004 16:09:15 -0300 (ADT) +Received: (qmail 1583 invoked by uid 500); 30 Aug 2004 19:18:05 -0000 +Date: Mon, 30 Aug 2004 14:18:05 -0500 +From: Bruno Wolff III +To: Martin Sarsale +Cc: pgsql-performance@postgresql.org +Subject: Re: seqscan instead of index scan +Message-ID: <20040830191805.GA1521@wolff.to> +Mail-Followup-To: Martin Sarsale , + pgsql-performance@postgresql.org +References: <1093887997.1680.71.camel@kadaif> + <20040830180227.GA32520@wolff.to> + <1093889235.1680.77.camel@kadaif> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1093889235.1680.77.camel@kadaif> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/451 +X-Sequence-Number: 8087 + +On Mon, Aug 30, 2004 at 15:07:15 -0300, + Martin Sarsale wrote: +> +> With combined index, you mean a multiple column index? +> From +> http://www.postgresql.org/docs/7.4/interactive/indexes-multicolumn.html + +You are right, a multicolumn index doesn't help for 'or'. + +From pgsql-performance-owner@postgresql.org Mon Aug 30 16:19:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 744A45E3F15 + for ; + Mon, 30 Aug 2004 16:19:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05319-10 + for ; + Mon, 30 Aug 2004 19:19:40 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DB365E46F8 + for ; + Mon, 30 Aug 2004 16:19:40 -0300 (ADT) +Received: (qmail 27663 invoked from network); 30 Aug 2004 21:19:54 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 30 Aug 2004 21:19:54 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +References: + <1093804128.5493.22.camel@localhost.localdomain> + <87fz65k5sq.fsf@stark.xeocode.com> +Message-ID: +Date: Mon, 30 Aug 2004 21:21:26 +0200 +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <87fz65k5sq.fsf@stark.xeocode.com> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/453 +X-Sequence-Number: 8089 + +>> Also, count(*) is likely to always generate a seq scan due to the way +>> aggregates are implemented currently in pgsql. you might want to try: + + + By the way, in an ideal world, count(*) should only read the index on the +timetamp column, not the rows. I guess this is not the case. Would this be +an useful optimization ? + +From pgsql-performance-owner@postgresql.org Mon Aug 30 16:30:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B20F5E46CD + for ; + Mon, 30 Aug 2004 16:30:49 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14601-03 + for ; + Mon, 30 Aug 2004 19:30:43 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id F17F25E46CC + for ; + Mon, 30 Aug 2004 16:30:41 -0300 (ADT) +Received: (qmail 28060 invoked from network); 30 Aug 2004 21:30:55 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 30 Aug 2004 21:30:55 +0200 +Date: Mon, 30 Aug 2004 21:32:28 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +References: + <1093804128.5493.22.camel@localhost.localdomain> + <87fz65k5sq.fsf@stark.xeocode.com> <16093.1093817023@sss.pgh.pa.us> +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <16093.1093817023@sss.pgh.pa.us> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/454 +X-Sequence-Number: 8090 + + + Another primary key trick : + + If you insert records with a serial primary key, and rarely delete them +or update the timestamp, you can use the primary key to compute an +approximate number of rows. + + a := SELECT pkey FROM table WHERE timestamp() > threshold ORDER BY +timestamp ASC LIMIT 1; + b := SELECT pkey FROM table WHERE ORDER BY pkey DESC LIMIT 1; + + (b-a) is an approximate count. + + Performance is great because you only fetch two rows. Index scan is +guaranteed (LIMIT 1). On the downside, you get an approximation, and this +only works for tables where timestamp is a date of INSERT, timestamp +worrelated wiht pkey) not when timestamp is a date of UPDATE (uncorrelated +with pkey). + +From pgsql-performance-owner@postgresql.org Mon Aug 30 16:37:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D825D5E46EE + for ; + Mon, 30 Aug 2004 16:37:35 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 16704-03 + for ; + Mon, 30 Aug 2004 19:37:31 +0000 (GMT) +Received: from boutiquenumerique.com (gailleton-2-82-67-9-10.fbx.proxad.net + [82.67.9.10]) + by svr1.postgresql.org (Postfix) with ESMTP id 187FD5E46CD + for ; + Mon, 30 Aug 2004 16:37:30 -0300 (ADT) +Received: (qmail 28278 invoked from network); 30 Aug 2004 21:37:45 +0200 +Received: from unknown (HELO musicbox) (192.168.0.2) + by gailleton-2-82-67-9-10.fbx.proxad.net with SMTP; + 30 Aug 2004 21:37:45 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: seqscan instead of index scan +References: <6EE64EF3AB31D5448D0007DD34EEB3412A748E@Herge.rcsinc.local> +Message-ID: +Date: Mon, 30 Aug 2004 21:39:17 +0200 +From: =?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= + +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: <6EE64EF3AB31D5448D0007DD34EEB3412A748E@Herge.rcsinc.local> +User-Agent: Opera M2/7.53 (Linux, build 737) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/456 +X-Sequence-Number: 8092 + + +>> create index t_idx on t((c+d)); +>> select * from t where c+d > 0; + + Why not : + + select ((select * from t where c<>0::bigint) UNION (select * from t where +d<>0::bigint)) + group by whatever; + + or someting ? + +From pgsql-performance-owner@postgresql.org Mon Aug 30 16:32:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 769145E46C3 + for ; + Mon, 30 Aug 2004 16:32:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14689-07 + for ; + Mon, 30 Aug 2004 19:32:00 +0000 (GMT) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 214C15E46F3 + for ; + Mon, 30 Aug 2004 16:31:59 -0300 (ADT) +Received: (qmail 1879 invoked by uid 500); 30 Aug 2004 19:40:50 -0000 +Date: Mon, 30 Aug 2004 14:40:50 -0500 +From: Bruno Wolff III +To: =?iso-8859-1?Q?Pierre-Fr=E9d=E9ric?= Caillaud + +Cc: pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +Message-ID: <20040830194050.GA1862@wolff.to> +Mail-Followup-To: =?iso-8859-1?Q?Pierre-Fr=E9d=E9ric?= Caillaud + , + pgsql-performance@postgresql.org +References: + <1093804128.5493.22.camel@localhost.localdomain> + <87fz65k5sq.fsf@stark.xeocode.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/455 +X-Sequence-Number: 8091 + +On Mon, Aug 30, 2004 at 21:21:26 +0200, + Pierre-Fr�d�ric Caillaud wrote: +> >>Also, count(*) is likely to always generate a seq scan due to the way +> >>aggregates are implemented currently in pgsql. you might want to try: +> +> +> By the way, in an ideal world, count(*) should only read the index +> on the timetamp column, not the rows. I guess this is not the case. Would +> this be an useful optimization ? + +It's in the archives. The short answer is that no, postgres has to check +the heap to check tuple visibility to the current transaction. + +From pgsql-performance-owner@postgresql.org Mon Aug 30 17:04:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B6A105E46CC + for ; + Mon, 30 Aug 2004 17:04:09 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 22342-05 + for ; + Mon, 30 Aug 2004 20:04:02 +0000 (GMT) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id DB7A95E46C1 + for ; + Mon, 30 Aug 2004 17:04:01 -0300 (ADT) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id E684B3504A; Mon, 30 Aug 2004 13:04:00 -0700 (PDT) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id E51F135017; Mon, 30 Aug 2004 13:04:00 -0700 (PDT) +Date: Mon, 30 Aug 2004 13:04:00 -0700 (PDT) +From: Stephan Szabo +To: Martin Sarsale +Cc: pgsql-performance@postgresql.org +Subject: Re: seqscan instead of index scan +In-Reply-To: <1093889849.1680.83.camel@kadaif> +Message-ID: <20040830130016.T98089@megazone.bigpanda.com> +References: <6EE64EF3AB31D5448D0007DD34EEB3412A748D@Herge.rcsinc.local> + <1093889849.1680.83.camel@kadaif> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/457 +X-Sequence-Number: 8093 + +On Mon, 30 Aug 2004, Martin Sarsale wrote: + +> On Mon, 2004-08-30 at 15:06, Merlin Moncure wrote: +> > create function is_somethingable (ctype, dtype) returns boolean as +> +> Thanks, but I would prefer a simpler solution. +> +> I would like to know why this uses a seqscan instead of an index scan: +> +> create index t_idx on t((c+d)); +> select * from t where c+d > 0; + +As a geuss, since 7.4 and earlier have no statistics on the distribution +of c+d it has to guess about how likely that is to be true and is probably +overestimating. 8.0beta might handle this better. + +From pgsql-performance-owner@postgresql.org Mon Aug 30 17:18:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F25E35E46CD + for ; + Mon, 30 Aug 2004 17:18:50 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 29656-01 + for ; + Mon, 30 Aug 2004 20:18:46 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 582665E3632 + for ; + Mon, 30 Aug 2004 17:18:45 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1C1sbv-0003IW-00; Mon, 30 Aug 2004 16:18:39 -0400 +To: Mr Pink +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +References: <20040830073841.30957.qmail@web41108.mail.yahoo.com> +In-Reply-To: <20040830073841.30957.qmail@web41108.mail.yahoo.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 30 Aug 2004 16:18:39 -0400 +Message-ID: <87ekloidls.fsf@stark.xeocode.com> +Lines: 61 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/458 +X-Sequence-Number: 8094 + + + +[I'm actually responding to the previous post from Tom Lane, but I've deleted +it and the archives seem to be down again.] + + +The assumption being made is that the first provided result is representative +of all future results. I don't see any reason that making this assumption of +all stable functions should be less scary than making the assumption about +user provided parameters. + +However I have the complementary reaction. I find peeking at the first +bind parameter to be scary as hell. Functions seem slightly less scary. + +On Oracle Peeking at bind parameters is a feature explicitly intended for DSS +data warehouse type systems. The use of placeholders there was purely for +security and programming ease, not efficiency, since the queries are only +planned executed a small number of times per plan. These are systems that +suffered enormously without the parameter values. They often involved full +table scans or bitmap index scans and without the statistics produced awful +plans. + +For OLTP systems peeking at placeholders is more a danger than a benefit. The +query will be executed thousands of times and if it's planned based on a +single unusual value initially the entire system could fail. + +Consider the following scenario which isn't farfetched at all. In fact I think +it well describes my current project: + +I have a table with a few million records. 99% of the time users are working +with only a few hundred records at most. There's an index on the column +they're keying off of. 1% of the key values have an unusually large number of +records. + +Without peeking at placeholders the system should see that virtually all the +key values are well under the threshold for an index scan to be best. So it +always uses an index scan. 1% of the time it takes longer than that it would +have with a sequential scan, but only by a small factor. (On the whole we're +probably still better off avoiding the cache pollution anyways.) + +With peeking at placeholders 99% of the backends would perform the same way. +However 1 backend in 100 sees one of these unusual values for its first query. +This backend will use a sequential scan for *every* request. Executing a +sequential table scan of this big table once a second this backend will drive +the entire system into the ground. + +This means every time I start the system up I stand a small but significant +chance of it just completely failing to perform properly. Worse, apache is +designed to periodically start new processes, so at any given time the system +could just randomly fall over and die. + +I would rather incur a 10% penalty on every query than have a 1% chance of it +keeling over and dieing. Given this I would when I upgrade to 8.0 have to +ensure that my application driver is either not using placeholders at all (at +the protocol level -- I always prefer them at the api level) or ensure that +postgres is *not* peeking at the value. + +I like the feature but I just want to be sure that it's optional. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Aug 30 17:36:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id C52F05E46EE + for ; + Mon, 30 Aug 2004 17:36:39 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34279-04 + for ; + Mon, 30 Aug 2004 20:36:35 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 828575E3632 + for ; + Mon, 30 Aug 2004 17:36:34 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1C1stC-0003Mx-00; Mon, 30 Aug 2004 16:36:30 -0400 +To: Martin Sarsale +Cc: pgsql-performance@postgresql.org +Subject: Re: seqscan instead of index scan +References: <6EE64EF3AB31D5448D0007DD34EEB3412A748D@Herge.rcsinc.local> + <1093889849.1680.83.camel@kadaif> +In-Reply-To: <1093889849.1680.83.camel@kadaif> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 30 Aug 2004 16:36:30 -0400 +Message-ID: <873c24ics1.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/459 +X-Sequence-Number: 8095 + + +Another option here is to use a partial index. You can index on some other +column -- perhaps the column you want the results ordered by where the where +clause is true. + +Something like: + +create index t_idx on t (name) where c>0 and d>0; + +then any select with a matching where clause can use the index: + +select * from t where c>0 and d>0 order by name + +Could scan the index and not even have to sort on name. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Aug 30 17:48:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B3B45E46C3 + for ; + Mon, 30 Aug 2004 17:48:11 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 37643-03 + for ; + Mon, 30 Aug 2004 20:48: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 8E3DF5E3632 + for ; + Mon, 30 Aug 2004 17:48:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7UKm5Xv011310; + Mon, 30 Aug 2004 16:48:05 -0400 (EDT) +To: Martin Sarsale +Cc: pgsql-performance@postgresql.org +Subject: Re: seqscan instead of index scan +In-reply-to: <1093887997.1680.71.camel@kadaif> +References: <1093887997.1680.71.camel@kadaif> +Comments: In-reply-to Martin Sarsale + message dated "Mon, 30 Aug 2004 14:46:37 -0300" +Date: Mon, 30 Aug 2004 16:48:05 -0400 +Message-ID: <11309.1093898885@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/460 +X-Sequence-Number: 8096 + +Martin Sarsale writes: +> I indexed columns c and d (separately) but this query used the slow +> seqscan instead of the index scan: + +> select * from t where c<>0 or d<>0; + +> After playing some time, I noticed that if I change the "or" for an +> "and", pg used the fast index scan (but the query w/ 'and' was not what +> I as looking for). + +I don't think so. <> is not an indexable operator --- it appears +nowhere in the index operator classes. It would help if you showed us +*exactly* what you did instead of a not-very-accurate filtered version. +I'm going to assume that you meant > ... + +> Now: I've no idea why it chooses to use a seq scan instead of the index +> scan (yes, I've just vacuum analyzed the table before running the +> query). + +Because 7.4 doesn't have statistics about expression indexes, so it has +no idea that there are only a few rows with c+d > 0. + +What I'd suggest is + + select * from t where c>0 union select * from t where d>0 + +with separate indexes on c and d. + +Another possibility is a partial index on exactly the condition you +want: + + create index nonzero on t(c) where c>0 or d>0; + +although I'm not certain if 7.4 has enough stats to recognize this as a win. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Aug 30 18:00:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 236155E46F4 + for ; + Mon, 30 Aug 2004 18:00:08 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 42069-02 + for ; + Mon, 30 Aug 2004 21:00: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 CA6995E46F2 + for ; + Mon, 30 Aug 2004 18:00:01 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7UL01jD011439; + Mon, 30 Aug 2004 17:00:01 -0400 (EDT) +To: Greg Stark +Cc: Mr Pink , + pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +In-reply-to: <87ekloidls.fsf@stark.xeocode.com> +References: <20040830073841.30957.qmail@web41108.mail.yahoo.com> + <87ekloidls.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "30 Aug 2004 16:18:39 -0400" +Date: Mon, 30 Aug 2004 17:00:00 -0400 +Message-ID: <11438.1093899600@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/461 +X-Sequence-Number: 8097 + +Greg Stark writes: +> However I have the complementary reaction. I find peeking at the first +> bind parameter to be scary as hell. Functions seem slightly less scary. + +FWIW, we only do it in the context of unnamed parameterized queries. +As the protocol docs say, those are optimized on the assumption that +they will be executed only once. It seems entirely legitimate to me +to use the parameter values in such a case. + +We might in future get braver about using sample parameter values, +but 8.0 is conservative about it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 31 03:00:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 982095E46F9 + for ; + Tue, 31 Aug 2004 03:00:55 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 71234-09 + for ; + Tue, 31 Aug 2004 06:00:44 +0000 (GMT) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 31A7D5E46E9 + for ; + Tue, 31 Aug 2004 03:00:41 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1C21gs-0004xA-00; Tue, 31 Aug 2004 02:00:22 -0400 +To: Tom Lane +Cc: Greg Stark , Mr Pink , + pgsql-performance@postgresql.org +Subject: Re: Why does a simple query not use an obvious index? +References: <20040830073841.30957.qmail@web41108.mail.yahoo.com> + <87ekloidls.fsf@stark.xeocode.com> <11438.1093899600@sss.pgh.pa.us> +In-Reply-To: <11438.1093899600@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 31 Aug 2004 02:00:22 -0400 +Message-ID: <87isazhmo9.fsf@stark.xeocode.com> +Lines: 45 +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/462 +X-Sequence-Number: 8098 + + +Tom Lane writes: + +> Greg Stark writes: +> > However I have the complementary reaction. I find peeking at the first +> > bind parameter to be scary as hell. Functions seem slightly less scary. +> +> FWIW, we only do it in the context of unnamed parameterized queries. + +I knew that. That's why I hadn't been jumping up and down screaming. I was +watching though to insist on an option to disable it if it became more +widespread. + +> As the protocol docs say, those are optimized on the assumption that +> they will be executed only once. It seems entirely legitimate to me +> to use the parameter values in such a case. + +Sure. It's a great feature to have; it means people can be more aggressive +about using placeholders for other reasons without worrying about performance +impacts. + +> We might in future get braver about using sample parameter values, +> but 8.0 is conservative about it. + +If they're used for named parameters I would strongly recommend guc variable +to control the default on a server-wide basis. It could be a variable that +individual sessions could override since there's no security or resource +implications. It's purely a protocol interface issue. + +For that matter, would it be possible for the default selectivity estimates to +be a guc variable? It's something that the DBA -- or even programmer on a +per-session basis -- might be able to provide a better value for his +applications than any hard coded default. + +Or perhaps it would be one valid use of hints to provide selectivity estimates +for blind placeholders. It would be nice to be able to say for example: + + select * from foo where col > $0 /*+ 5% */ AND col2 > $1 /*+ 10% */ + +Would there be any hope of convincing you that this is a justifiable use of +hints; providing information that the optimizer has absolutely no possibility +of ever being able to calculate on its own? + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Aug 31 12:14:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id A93665E46CE + for ; + Tue, 31 Aug 2004 12:14:45 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50172-03 + for ; + Tue, 31 Aug 2004 15:14:45 +0000 (GMT) +Received: from emepe3.com (unknown [69.93.218.52]) + by svr1.postgresql.org (Postfix) with ESMTP id 6AC945E46C2 + for ; + Tue, 31 Aug 2004 12:14:37 -0300 (ADT) +Received: from [200.89.130.112] (helo=[192.168.0.101]) + by emepe3.com with asmtp (Exim 3.35 #1 (Debian)) + id 1C2Ac1-0004cG-00; Tue, 31 Aug 2004 10:31:57 -0500 +Subject: Re: seqscan instead of index scan +From: Martin Sarsale +To: Merlin Moncure +Cc: pgsql-performance@postgresql.org +In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3412A748E@Herge.rcsinc.local> +References: <6EE64EF3AB31D5448D0007DD34EEB3412A748E@Herge.rcsinc.local> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-gY7hOLv6ofADkOdZsLUG" +Organization: Emepe3.com Inc +Message-Id: <1093965277.1680.93.camel@kadaif> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 +Date: Tue, 31 Aug 2004 12:14:37 -0300 +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/463 +X-Sequence-Number: 8099 + +--=-gY7hOLv6ofADkOdZsLUG +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + + +> Using a functional index you can define an index around the way you +> access the data. There is no faster or better way to do it...this is a +> mathematical truth, not a problem with the planner. Why not use the +> right tool for the job? A boolean index is super-efficient both in disk +> space and cache utilization. + +Thanks for your constructive criticism, you're absolutely right. + +I had to modify your "return" for a "select": + +create function rankeable (bigint, bigint) returns boolean as ' + select case when $1 > 0 or $2 > 0 then true else false end;' +language sql immutable; + +and it works great. + + + +--=-gY7hOLv6ofADkOdZsLUG +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (GNU/Linux) + +iD8DBQBBNJXchruVGj+ub3MRAnvaAJ9fbQ+OleKsjajgNBEfOsGVtcCl8gCgyMbU +1K7MaG89SKdCuDSbwMXBvFc= +=7hx6 +-----END PGP SIGNATURE----- + +--=-gY7hOLv6ofADkOdZsLUG-- + + +From pgsql-performance-owner@postgresql.org Tue Aug 31 12:27:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BD285E46F8 + for ; + Tue, 31 Aug 2004 12:27:54 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 52307-09 + for ; + Tue, 31 Aug 2004 15:27:56 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.207]) + by svr1.postgresql.org (Postfix) with ESMTP id D17115E46F3 + for ; + Tue, 31 Aug 2004 12:27:47 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id 73so258073rnl + for ; + Tue, 31 Aug 2004 08:27:42 -0700 (PDT) +Received: by 10.38.6.75 with SMTP id 75mr1510360rnf; + Tue, 31 Aug 2004 08:27:41 -0700 (PDT) +Received: by 10.38.86.41 with HTTP; Tue, 31 Aug 2004 08:27:41 -0700 (PDT) +Message-ID: <4b09a0c04083108274350ae80@mail.gmail.com> +Date: Tue, 31 Aug 2004 17:27:41 +0200 +From: Jean-Max Reymond +Reply-To: Jean-Max Reymond +To: pgsql-performance@postgresql.org +Subject: Performance with Intel Compiler +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/464 +X-Sequence-Number: 8100 + +hi, +has anyone compile Postgres with Intel compiler ? +Does it exist a substantial gain of performance ? + + +-- +Jean-Max Reymond +CKR Solutions +http://www.ckr-solutions.com + +From pgsql-odbc-owner@postgresql.org Tue Aug 31 14:26:56 2004 +X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2AFD65E46D4 + for ; + Tue, 31 Aug 2004 14:26:53 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 88801-07 + for ; + Tue, 31 Aug 2004 17:26:47 +0000 (GMT) +Received: from mail.tvnetwork.hu (zion.tvnetwork.hu [80.95.64.67]) + by svr1.postgresql.org (Postfix) with SMTP id D88DA5E46CC + for ; Tue, 31 Aug 2004 14:26:45 -0300 (ADT) +Received: (qmail 16224 invoked by uid 64014); 31 Aug 2004 17:26:41 -0000 +Received: from istvan.kroh@pomme.hu by zion by uid 64011 with + qmail-scanner-1.20rc3 + (clamuko: 0.60. spamassassin: 2.60. Clear:RC:1:SA:0(0.0/5.0):. + Processed in 0.195051 secs); 31 Aug 2004 17:26:41 -0000 +Received: from unknown (HELO pomme001) (80.95.83.31) + by zion.tvnetwork.hu with SMTP; 31 Aug 2004 17:26:41 -0000 +Message-ID: <005a01c48f7f$9ff8ae70$0102a8c0@pomme001> +From: =?iso-8859-2?Q?Kroh_Istv=E1n?= +To: , +Subject: odbc/ado problems +Date: Tue, 31 Aug 2004 19:26:15 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-2" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/66 +X-Sequence-Number: 4375 + +Hi all! + +I'm new here, so hello to everybody! + +I'm in a deep truble using postgesSQL 7.2.0 on a low-end pc with SUSE 8. I'm +using some databases from that pc through odbc (7.3.200). Until now i had no +problems with this solution, everithing worked fine. But today i wrote a +small app, that converts/copies some data from a database to an other +database. + +During this work i wrote a simple query as follows: +select pers_driving_license from person where pers_id=23456 + +This should return a single varchar(20) field. Running this query over +ADO/ODBC from a Delphi app tooks 50-100 secs. If i run this from pgAdmin II. +it takes some msecs. + +The output of explain is: +Index Scan using person_id_index on person (cost=0.00..3.14 rows=1 width=4) + +Any idea? + +Thanks in advance: steve + + +From pgsql-performance-owner@postgresql.org Tue Aug 31 14:33:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id CB94B5E46CD + for ; + Tue, 31 Aug 2004 14:33:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 93240-06 + for ; + Tue, 31 Aug 2004 17:33:10 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id EE6355E46C3 + for ; + Tue, 31 Aug 2004 14:33:07 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: odbc/ado problems +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Tue, 31 Aug 2004 13:33:07 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A7491@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] odbc/ado problems +Thread-Index: AcSPf+VhtXwlWA1BS9eRPdZRpaCRuAAACqig +From: "Merlin Moncure" +To: =?iso-8859-1?Q?Kroh_Istv=E1n?= +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/466 +X-Sequence-Number: 8102 + +> I'm new here, so hello to everybody! +>=20 +> I'm in a deep truble using postgesSQL 7.2.0 on a low-end pc with SUSE 8. +> I'm +> using some databases from that pc through odbc (7.3.200). Until now i had +> no +> problems with this solution, everithing worked fine. But today i wrote a +> small app, that converts/copies some data from a database to an other +> database. +>=20 +> During this work i wrote a simple query as follows: +> select pers_driving_license from person where pers_id=3D23456 +>=20 +> This should return a single varchar(20) field. Running this query over +> ADO/ODBC from a Delphi app tooks 50-100 secs. If i run this from pgAdmin +> II. +> it takes some msecs. + +Question: what is your Delphi database driver? If you are using the BDE, t= +hat might be your problem. Try installing and using the ZeosLib toolkit. + +http://www.zeoslib.org + +Merlin + +From pgsql-performance-owner@postgresql.org Tue Aug 31 15:09:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C2635E470C + for ; + Tue, 31 Aug 2004 15:09:43 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 05389-01 + for ; + Tue, 31 Aug 2004 18:09:37 +0000 (GMT) +Received: from silmaril.syscor.priv (h24-108-208-253.sbm.shawcable.net + [24.108.208.253]) + by svr1.postgresql.org (Postfix) with ESMTP id 6454E5E46F8 + for ; + Tue, 31 Aug 2004 15:09:35 -0300 (ADT) +Received: from syscor.com (strider.syscor.priv [192.168.1.3]) + by silmaril.syscor.priv (8.12.8/8.12.8) with ESMTP id i7VI9cYe020220 + for ; Tue, 31 Aug 2004 11:09:38 -0700 +Message-ID: <4134BF36.3000504@syscor.com> +Date: Tue, 31 Aug 2004 11:11:02 -0700 +From: Ron St-Pierre +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Table UPDATE is too slow +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/467 +X-Sequence-Number: 8103 + + We have a web based application with data that is updated daily. The +biggest bottleneck occurs when we try to update + one of the tables. This table contains 58,000 rows and 62 columns, and +EVERY column is indexed. Every column is + queryable (?) by the users through the web interface so we are +reluctant to remove the indexes (recreating them would + be time consuming too). The primary key is an INT and the rest of the +columns are a mix of NUMERIC, TEXT, and DATEs. + A typical update is: + UPDATE dataTable SET field01=44.5, field02=44.5, field03='Bob', + field04='foo', ... , field60='2004-08-30', field61='2004-08-29' + WHERE id = 1234; + + Also of note is that the update is run about 10 times per day; we get +blocks of data from 10 different sources, so we pre-process the + data and then update the table. We also run VACUUM FULL ANALYZE on a +nightly basis. + + Does anyone have some idea on how we can increase speed, either by +changing the updates, designing the database + differently, etc, etc? This is currently a big problem for us. + + Other notables: + The UPDATE is run from a within a function: FOR rec IN SELECT ...LOOP +RETURN NEXT rec; UPDATE dataTable..... + Postgres 7.4.3 + debian stable + 2 GB RAM + 80 DB IDE drive (we can't change it) + + shared_buffers = 2048 + sort_mem = 1024 + max_fsm_pages = 40000 + checkpoint_segments = 5 + random_page_cost = 3 + + + Thanks + + Ron + + + +From pgsql-performance-owner@postgresql.org Tue Aug 31 15:16:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id E094B5E4718 + for ; + Tue, 31 Aug 2004 15:16:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06312-04 + for ; + Tue, 31 Aug 2004 18:16:27 +0000 (GMT) +Received: from window.monsterlabs.com (window.monsterlabs.com + [216.183.105.176]) + by svr1.postgresql.org (Postfix) with SMTP id A5F225E4701 + for ; + Tue, 31 Aug 2004 15:16:24 -0300 (ADT) +Received: (qmail 3348 invoked from network); 31 Aug 2004 18:16:25 -0000 +Received: from pcp09180741pcs.nash01.tn.comcast.net (HELO ?192.168.0.106?) + (68.53.156.196) by 0 with SMTP; 31 Aug 2004 18:16:25 -0000 +In-Reply-To: <4134BF36.3000504@syscor.com> +References: <4134BF36.3000504@syscor.com> +Mime-Version: 1.0 (Apple Message framework v619) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Thomas F.O'Connell +Subject: Re: Table UPDATE is too slow +Date: Tue, 31 Aug 2004 13:16:22 -0500 +To: Ron St-Pierre +X-Mailer: Apple Mail (2.619) +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/468 +X-Sequence-Number: 8104 + +What is the datatype of the id column? + +-tfo + +On Aug 31, 2004, at 1:11 PM, Ron St-Pierre wrote: + +> We have a web based application with data that is updated daily. The +> biggest bottleneck occurs when we try to update +> one of the tables. This table contains 58,000 rows and 62 columns, and +> EVERY column is indexed. Every column is +> queryable (?) by the users through the web interface so we are +> reluctant to remove the indexes (recreating them would +> be time consuming too). The primary key is an INT and the rest of the +> columns are a mix of NUMERIC, TEXT, and DATEs. +> A typical update is: +> UPDATE dataTable SET field01=44.5, field02=44.5, field03='Bob', +> field04='foo', ... , field60='2004-08-30', field61='2004-08-29' +> WHERE id = 1234; +> +> Also of note is that the update is run about 10 times per day; we get +> blocks of data from 10 different sources, so we pre-process the +> data and then update the table. We also run VACUUM FULL ANALYZE on a +> nightly basis. +> Does anyone have some idea on how we can increase speed, either by +> changing the updates, designing the database +> differently, etc, etc? This is currently a big problem for us. +> Other notables: +> The UPDATE is run from a within a function: FOR rec IN SELECT +> ...LOOP RETURN NEXT rec; UPDATE dataTable..... +> Postgres 7.4.3 +> debian stable +> 2 GB RAM +> 80 DB IDE drive (we can't change it) +> shared_buffers = 2048 +> sort_mem = 1024 max_fsm_pages = 40000 +> checkpoint_segments = 5 +> random_page_cost = 3 +> Thanks +> Ron + + +From pgsql-performance-owner@postgresql.org Tue Aug 31 15:18:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id B430D5E46C3 + for ; + Tue, 31 Aug 2004 15:18:23 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06934-04 + for ; + Tue, 31 Aug 2004 18:18:17 +0000 (GMT) +Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) + by svr1.postgresql.org (Postfix) with ESMTP id ADF9C5E46F8 + for ; + Tue, 31 Aug 2004 15:18:16 -0300 (ADT) +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1C2DCx-0006M2-00 + for ; Tue, 31 Aug 2004 20:18:15 +0200 +Date: Tue, 31 Aug 2004 20:18:15 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Table UPDATE is too slow +Message-ID: <20040831181815.GB24253@uio.no> +References: <4134BF36.3000504@syscor.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4134BF36.3000504@syscor.com> +X-Operating-System: Linux 2.6.6 on a i686 +User-Agent: Mutt/1.5.6+20040818i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/469 +X-Sequence-Number: 8105 + +On Tue, Aug 31, 2004 at 11:11:02AM -0700, Ron St-Pierre wrote: +> We have a web based application with data that is updated daily. The +> biggest bottleneck occurs when we try to update +> one of the tables. This table contains 58,000 rows and 62 columns, and +> EVERY column is indexed. + +That is usually a very bad idea; for every update, PostgreSQL has to update +62 indexes. Do you really do queries on all those 62 columns? + +> A typical update is: +> UPDATE dataTable SET field01=44.5, field02=44.5, field03='Bob', +> field04='foo', ... , field60='2004-08-30', field61='2004-08-29' +> WHERE id = 1234; + +That looks like poor database normalization, really. Are you sure you don't +want to split this into multiple tables instead of having 62 columns? + +> Other notables: +> The UPDATE is run from a within a function: FOR rec IN SELECT ...LOOP +> RETURN NEXT rec; UPDATE dataTable..... +> Postgres 7.4.3 +> debian stable +> 2 GB RAM +> 80 DB IDE drive (we can't change it) + +Are you doing all this in multiple transactions, or in a sngle one? Wrapping +the FOR loop in a transaction might help speed. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Tue Aug 31 15:22:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EF795E46CD + for ; + Tue, 31 Aug 2004 15:22:19 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 06699-07 + for ; + Tue, 31 Aug 2004 18:22:13 +0000 (GMT) +Received: from silmaril.syscor.priv (h24-108-208-253.sbm.shawcable.net + [24.108.208.253]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BE8F5E46E7 + for ; + Tue, 31 Aug 2004 15:22:12 -0300 (ADT) +Received: from syscor.com (strider.syscor.priv [192.168.1.3]) + by silmaril.syscor.priv (8.12.8/8.12.8) with ESMTP id i7VIMGYe020282; + Tue, 31 Aug 2004 11:22:16 -0700 +Message-ID: <4134C22B.20706@syscor.com> +Date: Tue, 31 Aug 2004 11:23:39 -0700 +From: Ron St-Pierre +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Thomas F. O'Connell" , pgsql-performance@postgresql.org +Subject: Re: Table UPDATE is too slow +References: <4134BF36.3000504@syscor.com> + +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/470 +X-Sequence-Number: 8106 + +Thomas F. O'Connell wrote: + +> What is the datatype of the id column? +> +The id column is INTEGER. + +Ron + + +From pgsql-performance-owner@postgresql.org Tue Aug 31 15:34:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 550BA5E470A + for ; + Tue, 31 Aug 2004 15:34:21 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 11387-07 + for ; + Tue, 31 Aug 2004 18:34:15 +0000 (GMT) +Received: from silmaril.syscor.priv (h24-108-208-253.sbm.shawcable.net + [24.108.208.253]) + by svr1.postgresql.org (Postfix) with ESMTP id CD2C35E4708 + for ; + Tue, 31 Aug 2004 15:34:14 -0300 (ADT) +Received: from syscor.com (strider.syscor.priv [192.168.1.3]) + by silmaril.syscor.priv (8.12.8/8.12.8) with ESMTP id i7VIYEYe020340; + Tue, 31 Aug 2004 11:34:14 -0700 +Message-ID: <4134C4FA.20404@syscor.com> +Date: Tue, 31 Aug 2004 11:35:38 -0700 +From: Ron St-Pierre +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +Subject: Re: Table UPDATE is too slow +References: <4134BF36.3000504@syscor.com> <20040831181815.GB24253@uio.no> +In-Reply-To: <20040831181815.GB24253@uio.no> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/471 +X-Sequence-Number: 8107 + +Steinar H. Gunderson wrote: + +>On Tue, Aug 31, 2004 at 11:11:02AM -0700, Ron St-Pierre wrote: +> +> +>>We have a web based application with data that is updated daily. The +>>biggest bottleneck occurs when we try to update +>>one of the tables. This table contains 58,000 rows and 62 columns, and +>>EVERY column is indexed. +>> +>> +> +>That is usually a very bad idea; for every update, PostgreSQL has to update +>62 indexes. Do you really do queries on all those 62 columns? +> +> +Yes, I know that it's not a very good idea, however queries are allowed +against all of those columns. One option is to disable some or all of the +indexes when we update, run the update, and recreate the indexes, +however it may slow down user queries. Because there are so many indexes, +it is time consuming to recreate them after the update. + +> +> +>>A typical update is: +>> UPDATE dataTable SET field01=44.5, field02=44.5, field03='Bob', +>> field04='foo', ... , field60='2004-08-30', field61='2004-08-29' +>> WHERE id = 1234; +>> +>> +> +>That looks like poor database normalization, really. Are you sure you don't +>want to split this into multiple tables instead of having 62 columns? +> +No, it is properly normalized. The data in this table is stock +fundamentals, stuff like 52 week high, ex-dividend date, etc, etc. + +> +> +> +>>Other notables: +>> The UPDATE is run from a within a function: FOR rec IN SELECT ...LOOP +>>RETURN NEXT rec; UPDATE dataTable..... +>> Postgres 7.4.3 +>> debian stable +>> 2 GB RAM +>> 80 DB IDE drive (we can't change it) +>> +>> +> +>Are you doing all this in multiple transactions, or in a sngle one? Wrapping +>the FOR loop in a transaction might help speed. +> +We're doing it in multiple transactions within the function. Could we do +something like this?: + +.... +BEGIN + FOR rec IN SELECT field01, field02, ... FROM otherTable LOOP + RETURN NEXT rec; + UPDATE dataTable SET field01=rec.field01, field02=rec.field02, rec.field03=field03, ... + WHERE id = rec.id; +COMMIT; +.... + + +If we can do it this way, are there any other gotcha's we should be +aware of? + + +Ron + + +From pgsql-performance-owner@postgresql.org Tue Aug 31 15:46:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 12D665E4700 + for ; + Tue, 31 Aug 2004 15:46:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 14405-05 + for ; + Tue, 31 Aug 2004 18:46:18 +0000 (GMT) +Received: from frank.wiles.org (frank.wiles.org [24.124.39.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A0C85E46FB + for ; + Tue, 31 Aug 2004 15:46:17 -0300 (ADT) +Received: from kungfu (frank.wiles.org [24.124.39.75]) + by frank.wiles.org (8.12.11/8.12.11) with SMTP id i7VIlQOO010642; + Tue, 31 Aug 2004 13:47:27 -0500 +Date: Tue, 31 Aug 2004 13:46:19 -0500 +From: Frank Wiles +To: Ron St-Pierre +Cc: pgsql-performance@postgresql.org +Subject: Re: Table UPDATE is too slow +Message-Id: <20040831134619.4ead03b0.frank@wiles.org> +In-Reply-To: <4134BF36.3000504@syscor.com> +References: <4134BF36.3000504@syscor.com> +X-Mailer: Sylpheed version 0.9.10 (GTK+ 1.2.10; i386-redhat-linux-gnu) +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/472 +X-Sequence-Number: 8108 + +On Tue, 31 Aug 2004 11:11:02 -0700 +Ron St-Pierre wrote: + + +> Postgres 7.4.3 +> debian stable +> 2 GB RAM +> 80 DB IDE drive (we can't change it) +> +> shared_buffers = 2048 +> sort_mem = 1024 +> max_fsm_pages = 40000 +> checkpoint_segments = 5 +> random_page_cost = 3 + + I agree with all of the follow ups that having indexes on every + column is a bad idea. I would remove the indexes from the + least searched upon 10-20 columns, as I'm sure this will help + your performance. + + You mention that not having indexes on some of the columns because it + "may slow down user queries". I think you should investigate this and + make sure they are necessary. I've seen many an application, with far + more rows than you're dealing with, only need 1 or 2 indexes, even + when all (or most) columns could be searched. + + Also, you should consider increasing your shared_buffers and probably + your sort memory a touch as well. This will help your overall + performance. + + --------------------------------- + Frank Wiles + http://www.wiles.org + --------------------------------- + + +From pgsql-performance-owner@postgresql.org Tue Aug 31 15:48:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 93E395E470C + for ; + Tue, 31 Aug 2004 15:48:52 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 18018-02 + for ; + Tue, 31 Aug 2004 18:48:46 +0000 (GMT) +Received: from trofast.sesse.net (trofast.sesse.net [129.241.93.32]) + by svr1.postgresql.org (Postfix) with ESMTP id F27885E470A + for ; + Tue, 31 Aug 2004 15:48:45 -0300 (ADT) +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1C2DgT-0006VF-00 + for ; Tue, 31 Aug 2004 20:48:45 +0200 +Date: Tue, 31 Aug 2004 20:48:45 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Table UPDATE is too slow +Message-ID: <20040831184845.GA24976@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <4134BF36.3000504@syscor.com> <20040831181815.GB24253@uio.no> + <4134C4FA.20404@syscor.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4134C4FA.20404@syscor.com> +X-Operating-System: Linux 2.6.6 on a i686 +User-Agent: Mutt/1.5.6+20040818i +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=1.2 tagged_above=0.0 required=5.0 tests=NO_EXPERIENCE +X-Spam-Level: * +X-Archive-Number: 200408/473 +X-Sequence-Number: 8109 + +On Tue, Aug 31, 2004 at 11:35:38AM -0700, Ron St-Pierre wrote: +> We're doing it in multiple transactions within the function. Could we do +> something like this?: +> +> .... +> BEGIN +> FOR rec IN SELECT field01, field02, ... FROM otherTable LOOP +> RETURN NEXT rec; +> UPDATE dataTable SET field01=rec.field01, field02=rec.field02, +> rec.field03=field03, ... +> WHERE id = rec.id; +> COMMIT; +> .... +> +> +> If we can do it this way, are there any other gotcha's we should be +> aware of? + +AFAIK you should be able to do this, yes (although I have no experience with +PL/SQL); I'm not sure how much it buys you, but you might want to test it, at +least. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Tue Aug 31 15:59:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 932065E46CD + for ; + Tue, 31 Aug 2004 15:59:33 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 19754-10 + for ; + Tue, 31 Aug 2004 18:59:27 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.206]) + by svr1.postgresql.org (Postfix) with ESMTP id 964C85E46C2 + for ; + Tue, 31 Aug 2004 15:59:26 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id 75so165272rnl + for ; + Tue, 31 Aug 2004 11:59:12 -0700 (PDT) +Received: by 10.38.6.75 with SMTP id 75mr1607445rnf; + Tue, 31 Aug 2004 11:59:11 -0700 (PDT) +Received: by 10.38.86.41 with HTTP; Tue, 31 Aug 2004 11:59:11 -0700 (PDT) +Message-ID: <4b09a0c0408311159fa91802@mail.gmail.com> +Date: Tue, 31 Aug 2004 20:59:11 +0200 +From: Jean-Max Reymond +Reply-To: Jean-Max Reymond +To: pgsql-performance@postgresql.org +Subject: Optimizing a request +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.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 +X-Spam-Level: +X-Archive-Number: 200408/474 +X-Sequence-Number: 8110 + +hi, +I have the following structure in my base 7.4.2 + +CREATE TABLE "public"."article" ( + "art_id" INTEGER NOT NULL, + "rub_id" INTEGER DEFAULT '0' NOT NULL, + "art_titre" VARCHAR(100) DEFAULT '' NOT NULL, + "art_texte" TEXT NOT NULL, + "art_date" DATE NOT NULL, + "aut_id" INTEGER, + CONSTRAINT "article_pkey" PRIMARY KEY("art_id") +) WITH OIDS; + +CREATE INDEX "article_art_date_index" ON "public"."article" +USING btree ("art_date"); + + +CREATE INDEX "article_aut_id_index" ON "public"."article" +USING btree ("aut_id"); + + +CREATE INDEX "article_rub_id_index" ON "public"."article" +USING btree ("rub_id"); + + +CREATE INDEX "article_titre" ON "public"."article" +USING btree ("art_id", "art_titre"); + + +CREATE TABLE "public"."auteur" ( + "aut_id" INTEGER NOT NULL, + "aut_name" VARCHAR(100) DEFAULT '' NOT NULL, + CONSTRAINT "auteur_pkey" PRIMARY KEY("aut_id") +) WITH OIDS; + + +CREATE TABLE "public"."rubrique" ( + "rub_id" INTEGER NOT NULL, + "rub_titre" VARCHAR(100) DEFAULT '' NOT NULL, + "rub_parent" INTEGER DEFAULT '0' NOT NULL, + "rub_date" DATE, + CONSTRAINT "rubrique_pkey" PRIMARY KEY("rub_id") +) WITH OIDS; + +CREATE INDEX "rub_rub" ON "public"."rubrique" +USING btree ("rub_parent"); + +CREATE INDEX "rubrique_rub_date_index" ON "public"."rubrique" +USING btree ("rub_date"); + +CREATE INDEX "rubrique_rub_titre_index" ON "public"."rubrique" +USING btree ("rub_titre"); + +I want to optimize the following request and avoid the seq scan on the +table article (10000000 rows). + + + +explain SELECT art_id, art_titre, art_texte, rub_titre +FROM article inner join rubrique on article.rub_id = rubrique.rub_id +where rub_parent = 8; + +Hash Join (cost=8.27..265637.59 rows=25 width=130) + Hash Cond: ("outer".rub_id = "inner".rub_id) + -> Seq Scan on article (cost=0.00..215629.00 rows=10000000 width=108) + -> Hash (cost=8.26..8.26 rows=3 width=22) + -> Index Scan using rubrique_parent on rubrique +(cost=0.00..8.26 rows=3 width=22) + Index Cond: (rub_parent = 8) + + +thanks for your answers, + +-- +Jean-Max Reymond +CKR Solutions +http://www.ckr-solutions.com + +From pgsql-performance-owner@postgresql.org Tue Aug 31 16:00:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2025D5E470A + for ; + Tue, 31 Aug 2004 16:00:04 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 20800-08 + for ; + Tue, 31 Aug 2004 18:59:57 +0000 (GMT) +Received: from bayswater1.ymogen.net (host-154-240-27-217.pobox.net.uk + [217.27.240.154]) + by svr1.postgresql.org (Postfix) with ESMTP id E77485E470C + for ; + Tue, 31 Aug 2004 15:59:56 -0300 (ADT) +Received: from solent (82-68-95-1.dsl.in-addr.zen.co.uk [82.68.95.1]) + by bayswater1.ymogen.net (Postfix) with ESMTP + id 9DE5EA4205; Tue, 31 Aug 2004 19:59:55 +0100 (BST) +Reply-To: +From: "Matt Clark" +To: "'Ron St-Pierre'" , + "'Steinar H. Gunderson'" , + +Subject: Re: Table UPDATE is too slow +Date: Tue, 31 Aug 2004 19:59:55 +0100 +Organization: Ymogen Ltd +Message-ID: <001601c48f8c$b4738700$8300a8c0@solent> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.6626 +In-Reply-To: <4134C4FA.20404@syscor.com> +Importance: Normal +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/475 +X-Sequence-Number: 8111 + +> >That looks like poor database normalization, really. Are you=20 +> sure you=20 +> >don't want to split this into multiple tables instead of having 62=20 +> >columns? +> > +> No, it is properly normalized. The data in this table is stock=20 +> fundamentals, stuff like 52 week high, ex-dividend date, etc, etc. + +Hmm, the two examples you gave there are actually ripe for breaking out into +another table. It's not quite 'normalisation', but if you have data that +changes very rarely, why not group it into a separate table? You could have +the highly volatile data in one table, the semi-volatile stuff in another, +and the pretty static stuff in a third. Looked at another way, if you have +sets of fields that tend to change together, group them into tables +together. That way you will radically reduce the number of indexes that are +affected by each update. + +But as someone else pointed out, you should at the very least wrap your +updates in a big transaction. + +M + + +From pgsql-performance-owner@postgresql.org Tue Aug 31 16:01:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 945065E470E + for ; + Tue, 31 Aug 2004 16:01:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 21732-06 + for ; + Tue, 31 Aug 2004 19:00:55 +0000 (GMT) +Received: from Herge.rcsinc.local (mail.rcsonline.com [205.217.85.91]) + by svr1.postgresql.org (Postfix) with ESMTP id BEE385E46FB + for ; + Tue, 31 Aug 2004 16:00:54 -0300 (ADT) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +Subject: Re: odbc/ado problems +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Date: Tue, 31 Aug 2004 15:00:14 -0400 +Message-ID: <6EE64EF3AB31D5448D0007DD34EEB3412A7492@Herge.rcsinc.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] odbc/ado problems +Thread-Index: AcSPge5IEcByQY/ASPSF80ZyP5kUzwACG+cg +From: "Merlin Moncure" +To: "Pomme Bt." +Cc: +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/476 +X-Sequence-Number: 8112 + +> thanks for the quick answer! My db driver is the native MS ADO, and +from +> Delphi i use the AODExpress components which are wrapper classes to +reach +> the ActiveX components from delhpi. The strange behaviour of that +query +> is, +> that all other queries executed in this environment are running fast, +> except +> this one. First there was any index on that table (appr. 40.000 +records), +> and i thought that maybe this is my problem. Then i made this index, +but +> this hasn't solved my problem. +> Now i think that maybe the odbc driver makes something with my query? +Can +> this happen? + +Possible. I would turn on statement logging on the server and make sure +the query is the way you wrote it in the app. The driver might be doing +something like pulling all the data and attempting a client side filter. +Otherwise you may be looking at a casting problem of some sort. + +To turn on logging, set statement log to 'all' in your postgresql.conf +file. You may need to start the server manually so you can determine +where the log goes (logging to terminal is often the easiest to work +with). + +If you are writing Delphi applications, you really should check out +Zeos. It utilizes native drivers to connect to the database...it's +really, really fast and supports all the Delphi controls (and free!). + +Merlin + +From pgsql-performance-owner@postgresql.org Tue Aug 31 16:33:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DEA245E46C2 + for ; + Tue, 31 Aug 2004 16:33:06 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 34066-02 + for ; + Tue, 31 Aug 2004 19:32:59 +0000 (GMT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 931FA5E46CD + for ; + Tue, 31 Aug 2004 16:32:58 -0300 (ADT) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i7VJWtLq034782 + for ; Tue, 31 Aug 2004 19:32:55 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i7VJMTTW031066 + for pgsql-performance@postgresql.org; Tue, 31 Aug 2004 19:22:29 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Table UPDATE is too slow +Date: Tue, 31 Aug 2004 12:15:22 -0700 +Organization: Hub.Org Networking Services +Lines: 18 +Message-ID: +References: <4134BF36.3000504@syscor.com> <20040831181815.GB24253@uio.no> + <4134C4FA.20404@syscor.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.7.2) Gecko/20040803 +X-Accept-Language: en-us, en +In-Reply-To: <4134C4FA.20404@syscor.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/480 +X-Sequence-Number: 8116 + +Ron St-Pierre wrote: +> Yes, I know that it's not a very good idea, however queries are allowed +> against all of those columns. One option is to disable some or all of the +> indexes when we update, run the update, and recreate the indexes, +> however it may slow down user queries. Because there are so many indexes, +> it is time consuming to recreate them after the update. + +Just because a query can run against any column does not mean all +columns should be indexed. Take a good look at the column types and +their value distribution. + +Let's say I have a table of addresses but every address I collect is in +the 94116 zip code. That would mean indexes on city, state and zip are +not only useless but could decrease performance. + +Also, if a search always includes a unique key (or a column with highly +unique values), eliminating the other indexes would force the planner to +always use that index first. + +From pgsql-performance-owner@postgresql.org Tue Aug 31 16:15:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C4EF5E4716 + for ; + Tue, 31 Aug 2004 16:15:01 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 27732-02 + for ; + Tue, 31 Aug 2004 19:14:54 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 555105E46FB + for ; + Tue, 31 Aug 2004 16:14:52 -0300 (ADT) +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 6237387; Tue, 31 Aug 2004 12:16:11 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Jean-Max Reymond +Subject: Re: Optimizing a request +Date: Tue, 31 Aug 2004 12:15:40 -0700 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +References: <4b09a0c0408311159fa91802@mail.gmail.com> +In-Reply-To: <4b09a0c0408311159fa91802@mail.gmail.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200408311215.40812.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/477 +X-Sequence-Number: 8113 + +Jean, + +> I have the following structure in my base 7.4.2 + +Upgrade to 7.4.5. The version you're using has several known issues with data +restore in the event of system failure. + +> Hash Join (cost=8.27..265637.59 rows=25 width=130) +> Hash Cond: ("outer".rub_id = "inner".rub_id) +> -> Seq Scan on article (cost=0.00..215629.00 rows=10000000 width=108) +> -> Hash (cost=8.26..8.26 rows=3 width=22) +> -> Index Scan using rubrique_parent on rubrique +> (cost=0.00..8.26 rows=3 width=22) +> Index Cond: (rub_parent = 8) + +Those look suspiciously like stock estimates. When was the last time you ran +ANALYZE? + + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Aug 31 16:19:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id DCCD85E4708 + for ; + Tue, 31 Aug 2004 16:19:16 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28311-06 + for ; + Tue, 31 Aug 2004 19:19:10 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.203]) + by svr1.postgresql.org (Postfix) with ESMTP id 44CAE5E46FB + for ; + Tue, 31 Aug 2004 16:19:09 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id 74so187689rnl + for ; + Tue, 31 Aug 2004 12:19:09 -0700 (PDT) +Received: by 10.38.6.75 with SMTP id 75mr1616267rnf; + Tue, 31 Aug 2004 12:19:09 -0700 (PDT) +Received: by 10.38.86.41 with HTTP; Tue, 31 Aug 2004 12:19:09 -0700 (PDT) +Message-ID: <4b09a0c04083112191c2210f3@mail.gmail.com> +Date: Tue, 31 Aug 2004 21:19:09 +0200 +From: Jean-Max Reymond +Reply-To: Jean-Max Reymond +To: josh@agliodbs.com +Subject: Re: Optimizing a request +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200408311215.40812.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <4b09a0c0408311159fa91802@mail.gmail.com> + <200408311215.40812.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/478 +X-Sequence-Number: 8114 + +On Tue, 31 Aug 2004 12:15:40 -0700, Josh Berkus wrote: + +> Those look suspiciously like stock estimates. When was the last time you ran +> ANALYZE? + +the vacuum analyze ran just before the explain + +-- +Jean-Max Reymond +CKR Solutions +http://www.ckr-solutions.com + +From pgsql-performance-owner@postgresql.org Tue Aug 31 16:21:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 795C65E4710 + for ; + Tue, 31 Aug 2004 16:21:48 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 28723-06 + for ; + Tue, 31 Aug 2004 19:21:42 +0000 (GMT) +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id 195625E46F3 + for ; + Tue, 31 Aug 2004 16:21:40 -0300 (ADT) +Received: from gary (unknown [192.168.1.2]) + by server.gpdnet.co.uk (Postfix) with ESMTP id D308EFBEA6 + for ; + Tue, 31 Aug 2004 20:21:46 +0100 (BST) +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Tue, 31 Aug 2004 20:21:49 +0100 +MIME-Version: 1.0 +Subject: Re: Optimizing a request +Message-ID: <4134DDDD.428.4AF67CC@localhost> +In-reply-to: <4b09a0c0408311159fa91802@mail.gmail.com> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: Multipart/Alternative; boundary="Alt-Boundary-12526.78604236" +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.9 tagged_above=0.0 required=5.0 tests=HTML_50_60, + HTML_FONTCOLOR_RED, HTML_FONTCOLOR_UNSAFE, HTML_MESSAGE, + HTML_TITLE_EMPTY +X-Spam-Level: +X-Archive-Number: 200408/479 +X-Sequence-Number: 8115 + +--Alt-Boundary-12526.78604236 +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body + +On 31 Aug 2004 at 20:59, Jean-Max Reymond wrote: + +> hi, +> +> I want to optimize the following request and avoid the seq scan on the +> table article (10000000 rows). +> +> explain SELECT art_id, art_titre, art_texte, rub_titre +> FROM article inner join rubrique on article.rub_id = rubrique.rub_id +> where rub_parent = 8; +> +> Hash Join (cost=8.27..265637.59 rows=25 width=130) +> Hash Cond: ("outer".rub_id = "inner".rub_id) +> -> Seq Scan on article (cost=0.00..215629.00 rows=10000000 width=108) +> -> Hash (cost=8.26..8.26 rows=3 width=22) +> -> Index Scan using rubrique_parent on rubrique +> (cost=0.00..8.26 rows=3 width=22) +> Index Cond: (rub_parent = 8) +> +> +> thanks for your answers, +> +> -- + +Have you run ANALYZE on this database after creating the indexes or +loading the data? + +What percentage of rows in the "article" table are likely to match the +keys selected from the "rubrique" table? + +If it is likely to fetch a high proportion of the rows from article then it +may be best that a seq scan is performed. + +What are your non-default postgresql.conf settings? It may be better to +increase the default_statistics_target (to say 100 to +200) before running ANALYZE and then re-run the +query. + +Cheers, +Gary. + + +--Alt-Boundary-12526.78604236 +Content-type: text/html; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body + + + + + + +
On 31 Aug 2004 at 20:59, Jean-Max Reymond wrote:
+

+
+
> hi,
+
>
+
> I want to optimize the following request and avoid the seq scan on the
+
> table article (10000000 rows).
+
>
+
> explain SELECT art_id, art_titre, art_texte, rub_titre
+
> FROM article inner join rubrique on article.rub_id = rubrique.rub_id
+
> where rub_parent = 8;
+
>
+
> Hash Join  (cost=8.27..265637.59 rows=25 width=130)
+
>   Hash Cond: ("outer".rub_id = "inner".rub_id)
+
>   ->  Seq Scan on article  (cost=0.00..215629.00 rows=10000000 +width=108)
+
>   ->  Hash  (cost=8.26..8.26 rows=3 width=22)
+
>         ->  Index Scan using rubrique_parent +on rubrique
+
> (cost=0.00..8.26 rows=3 width=22)
+
>               Index +Cond: (rub_parent = 8)
+
>
+
>
+
> thanks for your answers,
+
>
+
> --
+

+
Have you run ANALYZE on this database after creating the indexes or +loading the data?
+

+
+
What percentage of rows in the "article" table are likely to match the +keys selected from the "rubrique" table?
+

+
+
If it is likely to fetch a high proportion of the rows from article then it +may be best that a seq scan is performed.
+

+
+
What are your non-default postgresql.conf settings? It may be better to +increase the default_statistics_target (to say 100 to +200) before running ANALYZE and then re-run the +query.
+

+
+
Cheers,
+
Gary.
+
+ + + +--Alt-Boundary-12526.78604236-- + +From pgsql-performance-owner@postgresql.org Tue Aug 31 16:43:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id D9EE55E470C + for ; + Tue, 31 Aug 2004 16:43:02 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 36450-09 + for ; + Tue, 31 Aug 2004 19:42:56 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.197]) + by svr1.postgresql.org (Postfix) with ESMTP id 94E885E46CD + for ; + Tue, 31 Aug 2004 16:42:55 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id 74so175917rnk + for ; + Tue, 31 Aug 2004 12:42:56 -0700 (PDT) +Received: by 10.38.6.75 with SMTP id 75mr1627076rnf; + Tue, 31 Aug 2004 12:42:56 -0700 (PDT) +Received: by 10.38.86.41 with HTTP; Tue, 31 Aug 2004 12:42:56 -0700 (PDT) +Message-ID: <4b09a0c04083112425776ec8c@mail.gmail.com> +Date: Tue, 31 Aug 2004 21:42:56 +0200 +From: Jean-Max Reymond +Reply-To: Jean-Max Reymond +To: Gary Doades +Subject: Re: Optimizing a request +Cc: pgsql-performance@postgresql.org +In-Reply-To: <4134DDDD.428.4AF67CC@localhost> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <4134DDDD.428.4AF67CC@localhost> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/481 +X-Sequence-Number: 8117 + +----- Original Message ----- +From: Gary Doades +Date: Tue, 31 Aug 2004 20:21:49 +0100 +Subject: Re: [PERFORM] Optimizing a request +To: pgsql-performance@postgresql.org + + + +> Have you run ANALYZE on this database after creating the indexes or loading the data? + +the indexes are created and the data loaded and then, I run vacuum analyze. + +>What percentage of rows in the "article" table are likely to match +the keys selected from the "rubrique" table? + +only 1 record. + +If it is likely to fetch a high proportion of the rows from article +then it may be best that a seq scan is performed. + +What are your non-default postgresql.conf settings? It may be better +to increase the default_statistics_target (to say 100 to 200) before +running ANALYZE and then re-run the query. + +yes, default_statistics_target is set to the default_value. +I have just increased shared_buffers and effective_cache_size to give +advantage of 1 Mb RAM + + + + +-- +Jean-Max Reymond +CKR Solutions +http://www.ckr-solutions.com + +From pgsql-performance-owner@postgresql.org Tue Aug 31 17:14:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BE085E470C + for ; + Tue, 31 Aug 2004 17:14:05 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 43878-10 + for ; + Tue, 31 Aug 2004 20:13: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 09EA65E46CD + for ; + Tue, 31 Aug 2004 17:13:58 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7VKDwFK014631; + Tue, 31 Aug 2004 16:13:58 -0400 (EDT) +To: Jean-Max Reymond +Cc: pgsql-performance@postgresql.org +Subject: Re: Optimizing a request +In-reply-to: <4b09a0c0408311159fa91802@mail.gmail.com> +References: <4b09a0c0408311159fa91802@mail.gmail.com> +Comments: In-reply-to Jean-Max Reymond + message dated "Tue, 31 Aug 2004 20:59:11 +0200" +Date: Tue, 31 Aug 2004 16:13:58 -0400 +Message-ID: <14630.1093983238@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/482 +X-Sequence-Number: 8118 + +Jean-Max Reymond writes: +> explain SELECT art_id, art_titre, art_texte, rub_titre +> FROM article inner join rubrique on article.rub_id = rubrique.rub_id +> where rub_parent = 8; + +> Hash Join (cost=8.27..265637.59 rows=25 width=130) +> Hash Cond: ("outer".rub_id = "inner".rub_id) +> -> Seq Scan on article (cost=0.00..215629.00 rows=10000000 width=108) +> -> Hash (cost=8.26..8.26 rows=3 width=22) +> -> Index Scan using rubrique_parent on rubrique +> (cost=0.00..8.26 rows=3 width=22) +> Index Cond: (rub_parent = 8) + +That seems like a very strange plan choice given those estimated row +counts. I'd have expected it to use a nestloop with inner index scan +on article_rub_id_index. You haven't done anything odd like disable +nestloop, have you? + +What plan do you get if you turn off enable_hashjoin? (If it's a merge +join, then turn off enable_mergejoin and try again.) Also, could we see +EXPLAIN ANALYZE not just EXPLAIN output for all these cases? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Aug 31 17:16:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 785E95E4711 + for ; + Tue, 31 Aug 2004 17:16:41 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 48265-05 + for ; + Tue, 31 Aug 2004 20:16:36 +0000 (GMT) +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id E1D075E4708 + for ; + Tue, 31 Aug 2004 17:16:35 -0300 (ADT) +Received: from gary (unknown [192.168.1.2]) + by server.gpdnet.co.uk (Postfix) with ESMTP id C0AFDFBEA6 + for ; + Tue, 31 Aug 2004 21:16:43 +0100 (BST) +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Tue, 31 Aug 2004 21:16:46 +0100 +MIME-Version: 1.0 +Subject: Re: Optimizing a request +Message-ID: <4134EABE.28891.4E1B76A@localhost> +In-reply-to: <4b09a0c04083112425776ec8c@mail.gmail.com> +References: <4134DDDD.428.4AF67CC@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/483 +X-Sequence-Number: 8119 + +On 31 Aug 2004 at 21:42, Jean-Max Reymond wrote: + +> ----- Original Message ----- +> From: Gary Doades +> Date: Tue, 31 Aug 2004 20:21:49 +0100 +> Subject: Re: [PERFORM] Optimizing a request +> To: pgsql-performance@postgresql.org +> +> +> +> > Have you run ANALYZE on this database after creating the indexes or loading the data? +> +> the indexes are created and the data loaded and then, I run vacuum analyze. +> +> >What percentage of rows in the "article" table are likely to match +> the keys selected from the "rubrique" table? +> +> only 1 record. +> +> If it is likely to fetch a high proportion of the rows from article +> then it may be best that a seq scan is performed. +> +> What are your non-default postgresql.conf settings? It may be better +> to increase the default_statistics_target (to say 100 to 200) before +> running ANALYZE and then re-run the query. +> +> yes, default_statistics_target is set to the default_value. +> I have just increased shared_buffers and effective_cache_size to give +> advantage of 1 Mb RAM +> + +I can only presume you mean 1 GB RAM. What exactly are your +settings for shared buffers and effective_cache_size? + +Can you increase default_statistics_target and re-test? It is possible +that with such a large table that the distribution of values is skewed and +postgres does not realise that an index scan would be better. + +It seems very odd otherwise that only on row out of 10,000,000 could +match and postgres does not realise this. + +Can you post an explain analyse (not just explain) for this query? + +Cheers, +Gary. + + +From pgsql-performance-owner@postgresql.org Tue Aug 31 17:24:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 1AB4A5E46F3 + for ; + Tue, 31 Aug 2004 17:24:57 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 50095-08 + for ; + Tue, 31 Aug 2004 20:24:51 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 496595E46CD + for ; + Tue, 31 Aug 2004 17:24:49 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id 73so192573rnk + for ; + Tue, 31 Aug 2004 13:24:51 -0700 (PDT) +Received: by 10.38.3.58 with SMTP id 58mr1213973rnc; + Tue, 31 Aug 2004 13:24:51 -0700 (PDT) +Received: by 10.38.86.41 with HTTP; Tue, 31 Aug 2004 13:24:51 -0700 (PDT) +Message-ID: <4b09a0c04083113243b6198b8@mail.gmail.com> +Date: Tue, 31 Aug 2004 22:24:51 +0200 +From: Jean-Max Reymond +Reply-To: Jean-Max Reymond +To: Gary Doades +Subject: Re: Optimizing a request +Cc: pgsql-performance@postgresql.org +In-Reply-To: <4134EABE.28891.4E1B76A@localhost> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <4134DDDD.428.4AF67CC@localhost> + <4134EABE.28891.4E1B76A@localhost> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/484 +X-Sequence-Number: 8120 + +On Tue, 31 Aug 2004 21:16:46 +0100, Gary Doades wrote: + +> I can only presume you mean 1 GB RAM. What exactly are your +> settings for shared buffers and effective_cache_size? + +for 1 GB RAM, +shared_buffers = 65536 +effective_cache_size = 16384 + +> +> Can you increase default_statistics_target and re-test? It is possible +> that with such a large table that the distribution of values is skewed and +> postgres does not realise that an index scan would be better. + +OK, tomorrow, I'll try with the new value of default_statistics_target + +> It seems very odd otherwise that only on row out of 10,000,000 could +> match and postgres does not realise this. +> +> Can you post an explain analyse (not just explain) for this query? + +yes, of course + + +-- +Jean-Max Reymond +CKR Solutions +http://www.ckr-solutions.com + +From pgsql-performance-owner@postgresql.org Tue Aug 31 17:26:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FEC85E470C + for ; + Tue, 31 Aug 2004 17:26:13 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 49614-08 + for ; + Tue, 31 Aug 2004 20:26:07 +0000 (GMT) +Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.207]) + by svr1.postgresql.org (Postfix) with ESMTP id 72E175E46FB + for ; + Tue, 31 Aug 2004 17:26:03 -0300 (ADT) +Received: by mproxy.gmail.com with SMTP id 73so192658rnk + for ; + Tue, 31 Aug 2004 13:26:05 -0700 (PDT) +Received: by 10.38.76.16 with SMTP id y16mr1650726rna; + Tue, 31 Aug 2004 13:26:05 -0700 (PDT) +Received: by 10.38.86.41 with HTTP; Tue, 31 Aug 2004 13:26:05 -0700 (PDT) +Message-ID: <4b09a0c040831132633b2bce5@mail.gmail.com> +Date: Tue, 31 Aug 2004 22:26:05 +0200 +From: Jean-Max Reymond +Reply-To: Jean-Max Reymond +To: Tom Lane +Subject: Re: Optimizing a request +Cc: pgsql-performance@postgresql.org +In-Reply-To: <14630.1093983238@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +References: <4b09a0c0408311159fa91802@mail.gmail.com> + <14630.1093983238@sss.pgh.pa.us> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/485 +X-Sequence-Number: 8121 + +On Tue, 31 Aug 2004 16:13:58 -0400, Tom Lane wrote: + +> That seems like a very strange plan choice given those estimated row +> counts. I'd have expected it to use a nestloop with inner index scan +> on article_rub_id_index. You haven't done anything odd like disable +> nestloop, have you? +> + +no optimizer disabled. + +> What plan do you get if you turn off enable_hashjoin? (If it's a merge +> join, then turn off enable_mergejoin and try again.) Also, could we see +> EXPLAIN ANALYZE not just EXPLAIN output for all these cases? +> +> regards, tom lane +> + +OK, TOM Thanks for your help + +-- +Jean-Max Reymond +CKR Solutions +http://www.ckr-solutions.com + +From pgsql-performance-owner@postgresql.org Tue Aug 31 17:31:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 2BEAA5E4710 + for ; + Tue, 31 Aug 2004 17:31:40 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 51998-10 + for ; + Tue, 31 Aug 2004 20:31:34 +0000 (GMT) +Received: from server.gpdnet.co.uk (gpdnet.plus.com [212.56.100.243]) + by svr1.postgresql.org (Postfix) with ESMTP id CDA4A5E470C + for ; + Tue, 31 Aug 2004 17:31:33 -0300 (ADT) +Received: from gary (unknown [192.168.1.2]) + by server.gpdnet.co.uk (Postfix) with ESMTP id 3910FFBEA6 + for ; + Tue, 31 Aug 2004 21:31:41 +0100 (BST) +From: "Gary Doades" +To: pgsql-performance@postgresql.org +Date: Tue, 31 Aug 2004 21:31:44 +0100 +MIME-Version: 1.0 +Subject: Re: Optimizing a request +Message-ID: <4134EE40.24471.4EF6928@localhost> +In-reply-to: <4b09a0c04083113243b6198b8@mail.gmail.com> +References: <4134EABE.28891.4E1B76A@localhost> +X-mailer: Pegasus Mail for Windows (v4.12a) +Content-type: text/plain; charset=US-ASCII +Content-transfer-encoding: 7BIT +Content-description: Mail message body +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/486 +X-Sequence-Number: 8122 + +On 31 Aug 2004 at 22:24, Jean-Max Reymond wrote: + +> On Tue, 31 Aug 2004 21:16:46 +0100, Gary Doades wrote: +> +> > I can only presume you mean 1 GB RAM. What exactly are your +> > settings for shared buffers and effective_cache_size? +> +> for 1 GB RAM, +> shared_buffers = 65536 +> effective_cache_size = 16384 + +This seems like the wrong way round also. + +You might try: + +shared_buffers = 10000 +effective_cache_size = 60000 + +Cheers, +Gary. + + +From pgsql-performance-owner@postgresql.org Tue Aug 31 17:41:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 5CD185E46CD + for ; + Tue, 31 Aug 2004 17:41:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 56547-06 + for ; + Tue, 31 Aug 2004 20:41:18 +0000 (GMT) +Received: from mx.noos.fr (pm-mx6.mgn.net [195.46.220.208]) + by svr1.postgresql.org (Postfix) with ESMTP id 370905E3F15 + for ; + Tue, 31 Aug 2004 17:41:17 -0300 (ADT) +Received: from localhost (pm-mnet6.mgn.net [195.46.220.215]) + by mx.noos.fr (Postfix) with SMTP + id F14C8268BA; Tue, 31 Aug 2004 22:41:15 +0200 (MEST) +X-Mailbox-Line: From footcow@noos.fr Tue Aug 31 22:41:15 2004 +Received: from e115.dhcp212-198-145.noos.fr (e115.dhcp212-198-145.noos.fr + [212.198.145.115]) by pm-mnet6.mgn.net with ESMTP; + Tue, 31 Aug 2004 22:41:15 (MEST) +From: =?iso-8859-1?q?Herv=E9_Piedvache?= +To: Jean-Max Reymond +Subject: Re: Optimizing a request +Date: Tue, 31 Aug 2004 22:41:15 +0200 +User-Agent: KMail/1.7 +Cc: pgsql-performance@postgresql.org +References: <4b09a0c0408311159fa91802@mail.gmail.com> +In-Reply-To: <4b09a0c0408311159fa91802@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200408312241.15315.footcow@noos.fr> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/487 +X-Sequence-Number: 8123 + +Hi, + +Le Mardi 31 Ao=FBt 2004 20:59, Jean-Max Reymond a =E9crit : +> explain SELECT art_id, art_titre, art_texte, rub_titre +> FROM article inner join rubrique on article.rub_id =3D rubrique.rub_id +> where rub_parent =3D 8; +> +> Hash Join (cost=3D8.27..265637.59 rows=3D25 width=3D130) +> Hash Cond: ("outer".rub_id =3D "inner".rub_id) +> -> Seq Scan on article (cost=3D0.00..215629.00 rows=3D10000000 width= +=3D108) +> -> Hash (cost=3D8.26..8.26 rows=3D3 width=3D22) +> -> Index Scan using rubrique_parent on rubrique +> (cost=3D0.00..8.26 rows=3D3 width=3D22) +> Index Cond: (rub_parent =3D 8) +> + +What are the values in rub_parent ... is their many disparity in the values= + ? +May be you have most of the value set to 8 ... and may be the optimizer thi= +nk=20 +a seq scan is better than the use of an index ... + +Could you do a simple : +SELECT rub_parent, count(rub_id) + FROM rubrique=20 + GROUP BY rub_parent; + +Just to see the disparity of the values ... + +regards, +--=20 +Bill Footcow + + +From pgsql-performance-owner@postgresql.org Tue Aug 31 18:20:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 97B995E46FB + for ; + Tue, 31 Aug 2004 18:20:51 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 69528-10 + for ; + Tue, 31 Aug 2004 21:20:45 +0000 (GMT) +Received: from smtp813.mail.sc5.yahoo.com (smtp813.mail.sc5.yahoo.com + [66.163.170.83]) + by svr1.postgresql.org (Postfix) with SMTP id 29C605E46F3 + for ; + Tue, 31 Aug 2004 18:20:40 -0300 (ADT) +Received: from unknown (HELO ?192.168.0.2?) (jellej@pacbell.net@67.127.86.222 + with login) + by smtp813.mail.sc5.yahoo.com with SMTP; 31 Aug 2004 21:20:42 -0000 +Date: Tue, 31 Aug 2004 14:20:41 -0700 (PDT) +From: jelle +X-X-Sender: jelle@localhost.localdomain +Reply-To: jellej@pacbell.net +To: pgsql-performance@postgresql.org +Subject: Re: Context Switching issue: Spinlock doesn't fix. +In-Reply-To: <200406021225.25463.josh@agliodbs.com> +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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/488 +X-Sequence-Number: 8124 + + +Hello, + +Is context switching problem resolved in 8.0? + +Can I drop in another Xeon? + +Thanks, +Jelle + + +On Wed, 2 Jun 2004, Josh Berkus wrote: + +> Folks, +> +> I've been testing varying SPINS_PER_DELAY in a client's installation of +> PostgreSQL against a copy of a production database, to test varying this +> statistic as a way of fixing the issue. +> +> It does not seem to work. +> +> I've tested all of the following graduated levels: +> +> 100 (the original) +> 250 +> 500 +> 1000 +> 2000 +> 5000 +> 10000 +> 20000 +> 30000 +> 50000 +> +> None of these quantities seem to make any difference at all in the number of +> context switches -- neither down nor up. Seems to me like this is a dead +> end. Does anyone have test results that show otherwise? +> +> + +-- + +http://www.jibjab.com + + +From pgsql-performance-owner@postgresql.org Tue Aug 31 18:50:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 054CD5E4713 + for ; + Tue, 31 Aug 2004 18:50:20 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 82377-06 + for ; + Tue, 31 Aug 2004 21:50:14 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D67A5E46F3 + for ; + Tue, 31 Aug 2004 18:50:13 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 4EA5A1C8A6; Tue, 31 Aug 2004 16:50:13 -0500 (CDT) +Date: Tue, 31 Aug 2004 16:50:13 -0500 +From: "Jim C. Nasby" +To: "J. Andrew Rogers" +Cc: Bruce Momjian , + pgsql-performance@postgresql.org, mischa.sandberg@telus.net +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Message-ID: <20040831215013.GJ78395@decibel.org> +References: <200408261818.i7QIIrr09640@candle.pha.pa.us> + <1093547088.349.134.camel@vulture.corp.neopolitan.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1093547088.349.134.camel@vulture.corp.neopolitan.com> +X-Operating-System: FreeBSD 4.10-RELEASE-p2 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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/489 +X-Sequence-Number: 8125 + +On Thu, Aug 26, 2004 at 12:04:48PM -0700, J. Andrew Rogers wrote: +> The major caveat to having tables of this type is that you can only have +> a primary key index. No other indexes are possible because the "heap" +> constantly undergoes local reorganizations if you have a lot of write +> traffic, the same kind of reorganization you would normally expect in a +> BTree index. + +This isn't true, at least in 9i. You can create whatever indexes you +want on an index-organized table. I believe that the index stores the PK +value instead of the ROWID. +-- +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 Tue Aug 31 19:02:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id F19C95E37D0 + for ; + Tue, 31 Aug 2004 19:02:24 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 84444-08 + for ; + Tue, 31 Aug 2004 22:02:20 +0000 (GMT) +Received: from davinci.ethosmedia.com (server226.ethosmedia.com + [209.128.84.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 2CC685E46F9 + for ; + Tue, 31 Aug 2004 19:02:15 -0300 (ADT) +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 6238625; Tue, 31 Aug 2004 15:03:36 -0700 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: jellej@pacbell.net +Subject: Re: Context Switching issue: Spinlock doesn't fix. +Date: Tue, 31 Aug 2004 15:03:05 -0700 +User-Agent: KMail/1.6.2 +Cc: pgsql-performance@postgresql.org +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: <200408311503.05881.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at hub.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/490 +X-Sequence-Number: 8126 + +Jellej, + +> Is context switching problem resolved in 8.0? +> +> Can I drop in another Xeon? + +Nope, not solved yet. However, it only affects certain data access patterns. +So don't use it as a reason not to go multi-processor. + +-- +--Josh + +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Aug 31 19:05:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.144]) + by svr1.postgresql.org (Postfix) with ESMTP id 0362D5E470A + for ; + Tue, 31 Aug 2004 19:05:07 -0300 (ADT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) + with ESMTP id 86817-04 + for ; + Tue, 31 Aug 2004 22:05:01 +0000 (GMT) +Received: from flake.decibel.org (flake.decibel.org [66.143.173.58]) + by svr1.postgresql.org (Postfix) with ESMTP id 2FB095E46EE + for ; + Tue, 31 Aug 2004 19:05:00 -0300 (ADT) +Received: by flake.decibel.org (Postfix, from userid 1001) + id 575F61C8A6; Tue, 31 Aug 2004 17:05:03 -0500 (CDT) +Date: Tue, 31 Aug 2004 17:05:03 -0500 +From: "Jim C. Nasby" +To: Greg Stark +Cc: Bruce Momjian , + "J. Andrew Rogers" , + Magnus Hagander , + pgsql-performance@postgresql.org, mischa.sandberg@telus.net +Subject: Re: Equivalent praxis to CLUSTERED INDEX? +Message-ID: <20040831220503.GK78395@decibel.org> +References: <200408270145.i7R1jop04185@candle.pha.pa.us> + <87pt5dnta9.fsf@stark.xeocode.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <87pt5dnta9.fsf@stark.xeocode.com> +X-Operating-System: FreeBSD 4.10-RELEASE-p2 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.0 tagged_above=0.0 required=5.0 tests= +X-Spam-Level: +X-Archive-Number: 200408/491 +X-Sequence-Number: 8127 + +On Thu, Aug 26, 2004 at 11:39:42PM -0400, Greg Stark wrote: +> +> Bruce Momjian writes: +> +> > Updated TODO item: +> > +> > o Automatically maintain clustering on a table +> > +> > This would require some background daemon to maintain clustering +> > during periods of low usage. It might also require tables to be only +> > paritally filled for easier reorganization. It also might require +> > creating a merged heap/index data file so an index lookup would +> > automatically access the heap data too. +> +> Fwiw, I would say the first "would" is also a "might". None of the previous +> discussions here presumed a maintenance daemon. The discussions before talked +> about a mechanism to try to place new tuples as close as possible to the +> proper index position. +> +> I would also suggest making some distinction between a cluster system similar +> to what we have now but improved to maintain the clustering continuously, and +> an actual index-organized-table where the tuples are actually only stored in a +> btree structure. +> +> They're two different approaches to similar problems. But they might both be +> useful to have, and have markedly different implementation details. + +There's a third approach that I think is worth considering. Half of the +benefit to clustered tables is limiting the number of pages you need to +access when scanning the primary key. The order of tuples in the pages +themselves isn't nearly as important as ordering of the pages. This +means you can get most of the benefit of an index-organized table just +by being careful about what page you place a tuple on. What I'm thinking +of is some means to ensure all the tuples on a page are within some PK +range, but not worrying about the exact order within the page since it's +relatively cheap to scan through the page in memory. + +Some pros: +This would probably mean less change to the code that inserts tuples. + +No need for a background daemon. + +No need to create a new B-Tree table structure. + +Ideally, there won't be need to move tuples around, which should mean +that current indexing code doesn't need to change. + +Cons: +Need to have some way to deal with pages that fill up. + +To gain full benefit some means of indicating what range of PK values +are on a page might be needed. + +It's not as beneficial as a true IOT since you don't get the benefit of +storing your tuples inline with your B-Tree. + +I'm sure there's a ton of things I'm missing, especially since I'm not +familiar with the postgresql code, but hopefully others can explore this +further. +-- +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?" +