diff --git "a/pgsql-performance.200312" "b/pgsql-performance.200312" new file mode 100644--- /dev/null +++ "b/pgsql-performance.200312" @@ -0,0 +1,27154 @@ +From pgsql-performance-owner@postgresql.org Mon Dec 1 06:14:41 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B886FD1D3FB + for ; + Mon, 1 Dec 2003 10:14:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 71598-08 + for ; + Mon, 1 Dec 2003 06:14:04 -0400 (AST) +Received: from mail.networkprograms.com (unknown [203.190.139.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 254D7D1D40B + for ; + Mon, 1 Dec 2003 06:14:00 -0400 (AST) +Received: from KAMALR ([192.9.203.78]) + by mail.networkprograms.com (8.12.9/8.12.9) with SMTP id hB1AIDfb018881; + Mon, 1 Dec 2003 15:48:19 +0530 +Message-ID: <01d601c3b7f4$61897f10$4ecb09c0@KAMALR> +Reply-To: "Kamalraj Singh Madhan" +From: "Kamalraj Singh Madhan" +To: "Jason Tishler" +Cc: +References: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> + <3FC54A82.2040605@familyhealth.com.au> + <20031127032831.GA4836@gp.word-to-the-wise.com> + <3FC58097.8090803@familyhealth.com.au> + <20031127051230.GA6212@gp.word-to-the-wise.com> + <20031128050417.GA14227@gp.word-to-the-wise.com> + <3FC6DAB8.4080106@familyhealth.com.au> + <20031128203700.GA19831@gp.word-to-the-wise.com> + <3FC9BC76.2030308@familyhealth.com.au> +Subject: Dump restoration via archive files +Date: Mon, 1 Dec 2003 15:47:47 +0530 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 5.50.4807.1700 +X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 +X-Scanned-By: MIMEDefang 2.35 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=REFERENCES +X-Spam-Level: +X-Archive-Number: 200312/1 +X-Sequence-Number: 4861 + +Hi, + I'am taking dump of a huge database and do not want the restoration of +that dump to take a lot of time as is the case when you take the dump in +text files. I want to take the dump as an archive file and get it restored +in very less time. I'am not able to figure out what is the command for +taking dump of a database in a archive file. Kindly help it's urgent. + +thanks and regards +Kamalraj Singh + + +From pgsql-performance-owner@postgresql.org Mon Dec 1 15:58:41 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DA9CBD1D47A + for ; + Mon, 1 Dec 2003 13:02:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 96749-03 + for ; + Mon, 1 Dec 2003 09:01:53 -0400 (AST) +Received: from mailout02.sul.t-online.com (mailout02.sul.t-online.com + [194.25.134.17]) + by svr1.postgresql.org (Postfix) with ESMTP id C0256D1C526 + for ; + Mon, 1 Dec 2003 09:01:49 -0400 (AST) +Received: from fwd09.aul.t-online.de by mailout02.sul.t-online.com with smtp + id 1AQngV-0001ZW-09; Mon, 01 Dec 2003 14:01:51 +0100 +Received: from router.azrael.de + (rPrT4+Z1oeP6G5n6d-8sO+R3M5AcCy9RHbb3u+fHd1wyh19Ib0mScg@[80.141.228.135]) + by fmrl09.sul.t-online.com + with esmtp id 1AQngB-0lzJB20; Mon, 1 Dec 2003 14:01:31 +0100 +Received: from azrael.azrael.de (azrael.azrael.de [192.168.202.18]) + by router.azrael.de (8.11.4/8.11.4) with ESMTP id hB1D1Lr09223 + for ; Mon, 1 Dec 2003 14:01:22 +0100 +Date: Mon, 1 Dec 2003 14:01:42 +0100 +From: Evil Azrael +Reply-To: Evil Azrael +X-Priority: 3 (Normal) +Message-ID: <1024180491.20031201140142@evilazrael.ath.cx> +To: pgsql-performance@postgresql.org +Subject: Various Questions +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +X-Seen: false +X-ID: rPrT4+Z1oeP6G5n6d-8sO+R3M5AcCy9RHbb3u+fHd1wyh19Ib0mScg@t-dialin.net +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/16 +X-Sequence-Number: 4876 + +Hi! + + +I have 4 question which probably someone can answer. + +1) I have a transaction during which no data was modified, does it +make a difference whether i send COMMIT or ROLLBACK? The effect is the +same, but what�s about the speed? + +2) Is there any general rule when the GEQO will start using an index? +Does he consider the number of tuples in the table or the number of +data pages? Or is it even more complex even if you don�t tweak the +cost setting for the GEQO? + +3) Makes it sense to add a index to a table used for logging? I mean +the table can grow rather large due to many INSERTs, but is also +seldom queried. Does the index slowdown noticable INSERTs? + +4) Temporary tables will always be rather slow as they can�t gain from +ANALYZE runs, correct? + +Thanx in advance for any answer + +Christoph Nelles + + + +-- +Mit freundlichen Gr�ssen +Evil Azrael mailto:root@evilazrael.ath.cx + + +From pgsql-performance-owner@postgresql.org Mon Dec 1 09:10:16 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E242D1C526 + for ; + Mon, 1 Dec 2003 13:09:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92420-10 + for ; + Mon, 1 Dec 2003 09:08:53 -0400 (AST) +Received: from mailout06.sul.t-online.com (mailout06.sul.t-online.com + [194.25.134.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 356A7D1B8B6 + for ; + Mon, 1 Dec 2003 09:08:31 -0400 (AST) +Received: from fwd00.aul.t-online.de by mailout06.sul.t-online.com with smtp + id 1AQnmz-00020G-09; Mon, 01 Dec 2003 14:08:33 +0100 +Received: from router.azrael.de + (Gn9LogZaoeRMfi7Ubrs5eT8Z1KxX37dlF9bZHjeioEU4MIUXBw0X6Z@[80.141.228.135]) + by fmrl00.sul.t-online.com + with esmtp id 1AQnmB-1tmhpg0; Mon, 1 Dec 2003 14:07:43 +0100 +Received: from azrael.azrael.de (azrael.azrael.de [192.168.202.18]) + by router.azrael.de (8.11.4/8.11.4) with ESMTP id hB1D7Sr09265 + for ; Mon, 1 Dec 2003 14:07:34 +0100 +Date: Mon, 1 Dec 2003 14:07:50 +0100 +From: Evil Azrael +X-Priority: 3 (Normal) +Message-ID: <924548300.20031201140750@evilazrael.de> +To: pgsql-performance@postgresql.org +Subject: Various Questions +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +X-Seen: false +X-ID: Gn9LogZaoeRMfi7Ubrs5eT8Z1KxX37dlF9bZHjeioEU4MIUXBw0X6Z@t-dialin.net +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/2 +X-Sequence-Number: 4862 + +Hi! + + +I have 4 question which probably someone can answer. + +1) I have a transaction during which no data was modified, does it +make a difference whether i send COMMIT or ROLLBACK? The effect is the +same, but what�s about the speed? + +2) Is there any general rule when the GEQO will start using an index? +Does he consider the number of tuples in the table or the number of +data pages? Or is it even more complex even if you don�t tweak the +cost setting for the GEQO? + +3) Makes it sense to add a index to a table used for logging? I mean +the table can grow rather large due to many INSERTs, but is also +seldom queried. Does the index slowdown noticable INSERTs? + +4) Temporary tables will always be rather slow as they can�t gain from +ANALYZE runs, correct? + +Thanx in advance for any answer + +Christoph Nelles + +-- +Mit freundlichen Gr�ssen +Evil Azrael mailto:evilazrael@evilazrael.de + + +From pgsql-performance-owner@postgresql.org Mon Dec 1 09:27:20 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A7C5DD1D388 + for ; + Mon, 1 Dec 2003 13:27:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95997-07 + for ; + Mon, 1 Dec 2003 09:26:38 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id 43D90D1B46D + for ; + Mon, 1 Dec 2003 09:26:34 -0400 (AST) +Received: from daithan.intranet.pspl.co.in + shridhar_daithankar@smtp-send.myrealbox.com [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.44 $ on + Novell NetWare via secured & encrypted transport (TLS); + Mon, 01 Dec 2003 06:26:37 -0700 +From: Shridhar Daithankar +To: pgsql-performance@postgresql.org +Subject: Re: Various Questions +Date: Mon, 1 Dec 2003 18:56:03 +0530 +User-Agent: KMail/1.5.4 +References: <924548300.20031201140750@evilazrael.de> +In-Reply-To: <924548300.20031201140750@evilazrael.de> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200312011856.04009.shridhar_daithankar@myrealbox.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/3 +X-Sequence-Number: 4863 + +On Monday 01 December 2003 18:37, Evil Azrael wrote: +> 1) I have a transaction during which no data was modified, does it +> make a difference whether i send COMMIT or ROLLBACK? The effect is the +> same, but what=B4s about the speed? + +It should not matter. Both commit and rollback should take same amount of= +=20 +time.. + +> 2) Is there any general rule when the GEQO will start using an index? +> Does he consider the number of tuples in the table or the number of +> data pages? Or is it even more complex even if you don=B4t tweak the +> cost setting for the GEQO? + +I thought GEQO was triggered by numebr of join clauses. That is what GEQO c= +ost=20 +indicates. It is not triggered by number of tuples in any table etc. + +But correct me if I am wrong. + +> 3) Makes it sense to add a index to a table used for logging? I mean +> the table can grow rather large due to many INSERTs, but is also +> seldom queried. Does the index slowdown noticable INSERTs? + +Yes. It does make a lot of difference. If the table is very seldom queried,= +=20 +you can probably create the index before querying and drop it later. Howeve= +r=20 +even this will cost a seq. scan of table and can be heavy on performance.. + Take your pick + +Shridhar + + +From pgsql-performance-owner@postgresql.org Mon Dec 1 09:45:07 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EC158D1B46D + for ; + Mon, 1 Dec 2003 13:45:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 98413-10 + for ; + Mon, 1 Dec 2003 09:44:33 -0400 (AST) +Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E5ECD1BC62 + for ; + Mon, 1 Dec 2003 09:44:30 -0400 (AST) +Received: from mist.cti.unav.es (mist.cti.unav.es [159.237.12.28]) + by www.postgresql.com (Postfix) with ESMTP id 8EBEDCF72E0 + for ; + Mon, 1 Dec 2003 09:44:28 -0400 (AST) +Received: from norvelle.net ([159.237.106.162]) + by mist.cti.unav.es (8.12.10/8.12.10) with ESMTP id hB1DePnF029510 + for ; Mon, 1 Dec 2003 14:40:25 +0100 +Date: Mon, 1 Dec 2003 14:40:30 +0100 +Mime-Version: 1.0 (Apple Message framework v552) +Content-Type: multipart/alternative; boundary=Apple-Mail-18--362965852 +Subject: My indexes aren't being used (according to EXPLAIN) +From: Erik Norvelle +To: pgsql-performance@postgresql.org +Message-Id: +X-Mailer: Apple Mail (2.552) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/4 +X-Sequence-Number: 4864 + +--Apple-Mail-18--362965852 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + format=flowed + +Greetings: + +Apologies if this question has already been answered, but I was unable +to locate a prior answer in the archives... + +I have a table with approximately 10 million records, called +"indethom", and with an INTEGER column called "clavis" which is set up +as a primary key. When I try to perform a select on the table, +restricting the result to only the first 100 records, PostgreSQL +performs a sequence scan, rather than an index scan (as shown by using +EXPLAIN). Needless to say the sequence scan takes forever. Is there +some way to get PostgreSQL to use my wonderful indexes? Have I somehow +built the indexes incorrectly or something? + +Here's the description of the table: + +====================== PSQL Output Snip ========================= + +it=> \d indethom + Table "public.indethom" + Column | Type | Modifiers +---------------+-----------------------+----------- + numeoper | smallint | not null + nomeoper | character(3) | not null +... (numerous columns skipped) ... + verbum | character varying(22) | not null + poslinop | integer | not null + posverli | smallint | not null + posverop | integer | not null + clavis | integer | not null + articref | integer | + sectref | integer | + query_counter | integer | +Indexes: indethom_pkey primary key btree (clavis), + indethom_articulus_ndx btree (nomeoper, refere1a, refere1b, +refere2a, refere2b, refere3a, refere3b), + indethom_sectio_ndx btree (nomeoper, refere1a, refere1b, +refere2a, refere2b, refere3a, refere3b, refere4a, refere4b), + it_clavis_ndx btree (clavis), + verbum_ndx btree (verbum) + +it=> explain select * from indethom where clavis < 25; + QUERY PLAN +---------------------------------------------------------------------- + Seq Scan on indethom (cost=0.00..1336932.65 rows=3543991 width=236) + Filter: (clavis < 25) +(2 rows) + +================== End Snip ===================== + +Feel free to point me to any FAQ or previous message that already +answers this question. Thanks in advance! + +-Erik Norvelle + +--Apple-Mail-18--362965852 +Content-Transfer-Encoding: 7bit +Content-Type: text/enriched; + charset=US-ASCII + +Courier NewGreetings: + + +Apologies if this question has already been answered, but I was unable +to locate a prior answer in the archives... + + +I have a table with approximately 10 million records, called +"indethom", and with an INTEGER column called "clavis" which is set up +as a primary key. When I try to perform a select on the table, +restricting the result to only the first 100 records, PostgreSQL +performs a sequence scan, rather than an index scan (as shown by using +EXPLAIN). Needless to say the sequence scan takes forever. Is there +some way to get PostgreSQL to use my wonderful indexes? Have I +somehow built the indexes incorrectly or something? + + +Here's the description of the table: + + +====================== PSQL Output Snip ========================= + + +it=> \d indethom + + Table "public.indethom" + + Column | Type | Modifiers + +---------------+-----------------------+----------- + + numeoper | smallint | not null + + nomeoper | character(3) | not null + +... (numerous columns skipped) ... + + verbum | character varying(22) | not null + + poslinop | integer | not null + + posverli | smallint | not null + + posverop | integer | not null + + clavis | integer | not null + + articref | integer | + + sectref | integer | + + query_counter | integer | + +Indexes: indethom_pkey primary key btree (clavis), + + indethom_articulus_ndx btree (nomeoper, refere1a, refere1b, +refere2a, refere2b, refere3a, refere3b), + + indethom_sectio_ndx btree (nomeoper, refere1a, refere1b, +refere2a, refere2b, refere3a, refere3b, refere4a, refere4b), + + it_clavis_ndx btree (clavis), + + verbum_ndx btree (verbum) + + +it=> explain select * from indethom where clavis << 25; + + QUERY PLAN + +---------------------------------------------------------------------- + + Seq Scan on indethom (cost=0.00..1336932.65 rows=3543991 width=236) + + Filter: (clavis << 25) + +(2 rows) + + +================== End Snip ===================== + + +Feel free to point me to any FAQ or previous message that already +answers this question. Thanks in advance! + + +-Erik Norvelle + + +--Apple-Mail-18--362965852-- + + +From pgsql-performance-owner@postgresql.org Mon Dec 1 10:01:57 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 45B17D1B43E + for ; + Mon, 1 Dec 2003 14:01:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03769-09 + for ; + Mon, 1 Dec 2003 10:00:58 -0400 (AST) +Received: from mail.libertyrms.com (unknown [209.167.124.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 046E8D1C941 + for ; + Mon, 1 Dec 2003 10:00:55 -0400 (AST) +Received: from [10.1.2.130] (helo=dba2) + by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) + id 1AQobi-0005yQ-00 + for ; Mon, 01 Dec 2003 09:00:58 -0500 +Received: by dba2 (Postfix, from userid 1019) + id 667C8CC8A; Mon, 1 Dec 2003 09:00:58 -0500 (EST) +Date: Mon, 1 Dec 2003 09:00:58 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: Various Questions +Message-ID: <20031201140058.GA4107@libertyrms.info> +Mail-Followup-To: Andrew Sullivan , + pgsql-performance@postgresql.org +References: <924548300.20031201140750@evilazrael.de> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +In-Reply-To: <924548300.20031201140750@evilazrael.de> +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/5 +X-Sequence-Number: 4865 + +On Mon, Dec 01, 2003 at 02:07:50PM +0100, Evil Azrael wrote: +> 1) I have a transaction during which no data was modified, does it +> make a difference whether i send COMMIT or ROLLBACK? The effect is the +> same, but what�s about the speed? + +It makes no difference. + +> 2) Is there any general rule when the GEQO will start using an index? +> Does he consider the number of tuples in the table or the number of +> data pages? Or is it even more complex even if you don�t tweak the +> cost setting for the GEQO? + +GEQO is not what causes indexscans. You're thinking of the +planner/optimiser. Generally, the optimiser decides what the optimum +plan is to deliver a query. This involves a complicated set of +rules. The real important question is, "Am I really getting the +fastest plan?" You can find out that with EXPLAIN ANALYSE. If you +want to know more about what makes a good plan, I'd start by reading +the docs, and then by reading the comments in the source code. + +> 3) Makes it sense to add a index to a table used for logging? I mean +> the table can grow rather large due to many INSERTs, but is also +> seldom queried. Does the index slowdown noticable INSERTs? + +It does, but you might find that it's worth it. If it is seldom +queried, but you really need the results and the result set is a +small % of the table, then you're probably wise to pay the cost of +the index at insert, update, and VACUUM because doing a seqscan on a +large table to get one or two rows will destroy all your buffers. + +> 4) Temporary tables will always be rather slow as they can�t gain from +> ANALYZE runs, correct? + +No, you can ANALYSE them yourself. Of course, you'll need an index +unless you plan to read the whole table. Note that, if you use temp +tables a lot, you need to be sure to vacuum at least pg_class and +pg_attribute more frequently than you might have thought. + +A + + +-- +---- +Andrew Sullivan 204-4141 Yonge Street +Afilias Canada Toronto, Ontario Canada + M2P 2A8 + +1 416 646 3304 x110 + + +From pgsql-performance-owner@postgresql.org Mon Dec 1 10:04:55 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5054CD1B43E + for ; + Mon, 1 Dec 2003 14:04:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05586-03 + for ; + Mon, 1 Dec 2003 10:04:25 -0400 (AST) +Received: from mail.libertyrms.com (unknown [209.167.124.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 87932D1BC5C + for ; + Mon, 1 Dec 2003 10:04:20 -0400 (AST) +Received: from [10.1.2.130] (helo=dba2) + by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) + id 1AQoep-00061c-00 + for ; Mon, 01 Dec 2003 09:04:11 -0500 +Received: by dba2 (Postfix, from userid 1019) + id EF081CC8A; Mon, 1 Dec 2003 09:04:10 -0500 (EST) +Date: Mon, 1 Dec 2003 09:04:10 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: My indexes aren't being used (according to EXPLAIN) +Message-ID: <20031201140410.GC4107@libertyrms.info> +Mail-Followup-To: Andrew Sullivan , + pgsql-performance@postgresql.org +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/6 +X-Sequence-Number: 4866 + +On Mon, Dec 01, 2003 at 02:40:30PM +0100, Erik Norvelle wrote: +> +> it=> explain select * from indethom where clavis < 25; + +What's the percentage of the table where clavis < 25? Have you +ANALYSEd recently? What does the pg_stats view tell you about this +table? + +> Feel free to point me to any FAQ or previous message that already +> answers this question. Thanks in advance! + +This is a pretty common sort of problem. See the archives of this +list for several fairly recent discussions of these sorts of +problems. + +A + +-- +---- +Andrew Sullivan 204-4141 Yonge Street +Afilias Canada Toronto, Ontario Canada + M2P 2A8 + +1 416 646 3304 x110 + + +From pgsql-performance-owner@postgresql.org Mon Dec 1 10:18:13 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 674ACD1D8B5 + for ; + Mon, 1 Dec 2003 14:17:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05776-07 + for ; + Mon, 1 Dec 2003 10:17:02 -0400 (AST) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id 7DB07D1D5AD + for ; + Mon, 1 Dec 2003 10:16:54 -0400 (AST) +Received: (qmail 6347 invoked from network); 1 Dec 2003 14:16:55 -0000 +Received: from localhost (HELO squeegit) (threshar@127.0.0.1) + by localhost with SMTP; 1 Dec 2003 14:16:55 -0000 +Date: Mon, 1 Dec 2003 09:16:34 -0500 +From: Jeff +To: "Kamalraj Singh Madhan" +Cc: jason@tishler.net, pgsql-performance@postgresql.org +Subject: Re: Dump restoration via archive files +Message-Id: <20031201091634.6f19f28a.threshar@torgo.978.org> +In-Reply-To: <01d601c3b7f4$61897f10$4ecb09c0@KAMALR> +References: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> + <3FC54A82.2040605@familyhealth.com.au> + <20031127032831.GA4836@gp.word-to-the-wise.com> + <3FC58097.8090803@familyhealth.com.au> + <20031127051230.GA6212@gp.word-to-the-wise.com> + <20031128050417.GA14227@gp.word-to-the-wise.com> + <3FC6DAB8.4080106@familyhealth.com.au> + <20031128203700.GA19831@gp.word-to-the-wise.com> + <3FC9BC76.2030308@familyhealth.com.au> + <01d601c3b7f4$61897f10$4ecb09c0@KAMALR> +X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i686-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/7 +X-Sequence-Number: 4867 + +On Mon, 1 Dec 2003 15:47:47 +0530 +"Kamalraj Singh Madhan" wrote: + +> Hi, +> I'am taking dump of a huge database and do not want the +> restoration of +> that dump to take a lot of time as is the case when you take the dump +> in text files. I want to take the dump as an archive file and get it +> restored in very less time. I'am not able to figure out what is the +> command for taking dump of a database in a archive file. Kindly help +> it's urgent. +> + +Fast backups are an area PG needs work in. Currently, PG has no 'archive +file backup'. You do have the following options to get around this: + +1. Take big db offline, copy $PGDATA. Has a restore time of how long it +takes to copy $PGDATA (And optionally untar/gzip), bring db back online + +2. If you are using an LVM, take a snapshot and copy the data. Like #1, +it also has a "0" restore time. + +3. If you are using a pg_dump generated dump, be sure to really jack up +your sort_mem - this will be a HUGE benefit when creating indexes & if +you are using 7.4, adding the foriegn keys. Also turning off fsync +(Don't forget to turn it back on after your restore!) cna give you some +nice speed increases. + +4. If you are not using 7.4 and using pg_dump, there isn't much you can +do about adding foreign keys going stupidly slow :( + + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + +From pgsql-performance-owner@postgresql.org Mon Dec 1 10:29:59 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BDE34D1B437 + for ; + Mon, 1 Dec 2003 14:29:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11618-04 + for ; + Mon, 1 Dec 2003 10:29:22 -0400 (AST) +Received: from penguin.goodinassociates.com (unknown [63.150.225.202]) + by svr1.postgresql.org (Postfix) with ESMTP id B73FCD1B438 + for ; + Mon, 1 Dec 2003 10:29:17 -0400 (AST) +Received: from [192.168.14.183] (bluejay.goodinassociates.com + [192.168.14.183]) + by penguin.goodinassociates.com (8.12.8/linuxconf) with ESMTP id + hB1ET3na005958; Mon, 1 Dec 2003 08:29:06 -0600 +Subject: Re: cross table indexes or something? +From: Jeremiah Jahn +To: Hannu Krosing +Cc: postgres performance +In-Reply-To: <1069885949.3176.57.camel@fuji.krosing.net> +References: <1069877651.22346.13.camel@bluejay.goodinassociates.com> + <1069885949.3176.57.camel@fuji.krosing.net> +Content-Type: text/plain +Message-Id: <1070288942.22346.27.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) +Date: Mon, 01 Dec 2003 08:29:03 -0600 +Content-Transfer-Encoding: 7bit +X-RAVMilter-Version: 8.4.4(snapshot 20030410) (penguin.goodinassociates.com) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/8 +X-Sequence-Number: 4868 + +On Wed, 2003-11-26 at 16:32, Hannu Krosing wrote: +> Jeremiah Jahn kirjutas K, 26.11.2003 kell 22:14: +> > I was wondering if there is something I can do that would act similar to +> > a index over more than one table. +> > +> > I have about 3 million people in my DB at the moment, they all have +> > roles, and many of them have more than one name. +> > +> > for example, a Judge will only have one name, but a Litigant could have +> > multiple aliases. Things go far to slow when I do a query on a judge +> > named smith. +> +> If you dont need all the judges named smith you could try to use LIMIT. +Unfortunately I do need all of the judges named smith. + + +> +> Have you run ANALYZE ? Why does DB think that there is only one judge +> with name like SMITH% ? +I've attached the Analyze below. I have no idea why the db thinks there +is only 1 judge named simth. Is there some what I can inform the DB +about this. In actuality, there aren't any judges named smith at the +moment, but there are 22K people named smith. + + +> +> ------------- +> Hannu +> +> P.S. +> Always send EXPLAIN ANALYZE output if asking for advice on [PERFORM] + EXPLAIN ANALYZE select distinct actor.actor_id,court.id,court.name,role_class_code,full_name from actor,identity,court,event,event_actor where role_class_code = 'Judge' and full_name like 'SMITH%' and identity.actor_id = actor.actor_id and identity.court_ori = actor.court_ori and actor.court_ori = court.id and actor.actor_id = event_actor.actor_id and event_actor.event_id = event.event_id and event_date_time > '20021126' order by full_name; + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Unique (cost=686.42..686.44 rows=1 width=92) (actual time=111923.877..111923.877 rows=0 loops=1) + -> Sort (cost=686.42..686.43 rows=1 width=92) (actual time=111923.873..111923.873 rows=0 loops=1) + Sort Key: identity.full_name, actor.actor_id, court.id, court.name, actor.role_class_code + -> Nested Loop (cost=8.45..686.41 rows=1 width=92) (actual time=111923.836..111923.836 rows=0 loops=1) + -> Nested Loop (cost=8.45..680.57 rows=1 width=144) (actual time=109958.426..111157.822 rows=2449 loops=1) + -> Hash Join (cost=8.45..9.62 rows=1 width=117) (actual time=109945.754..109945.896 rows=6 loops=1) + Hash Cond: (("outer".id)::text = ("inner".court_ori)::text) + -> Seq Scan on court (cost=0.00..1.10 rows=10 width=34) (actual time=0.015..0.048 rows=10 loops=1) + -> Hash (cost=8.45..8.45 rows=1 width=109) (actual time=109940.161..109940.161 rows=0 loops=1) + -> Nested Loop (cost=0.00..8.45 rows=1 width=109) (actual time=10.367..109940.079 rows=7 loops=1) + Join Filter: (("outer".court_ori)::text = ("inner".court_ori)::text) + -> Index Scan using name_speed on identity (cost=0.00..3.01 rows=1 width=59) (actual time=10.202..238.497 rows=22436 loops=1) + Index Cond: (((full_name)::text >= 'SMITH'::character varying) AND ((full_name)::text < 'SMITI'::character varying)) + Filter: ((full_name)::text ~~ 'SMITH%'::text) + -> Index Scan using actor_speed on actor (cost=0.00..5.42 rows=1 width=50) (actual time=4.883..4.883 rows=0 loops=22436) + Index Cond: (("outer".actor_id)::text = (actor.actor_id)::text) + Filter: ((role_class_code)::text = 'Judge'::text) + -> Index Scan using event_actor_speed on event_actor (cost=0.00..655.59 rows=1229 width=73) (actual time=11.815..198.759 rows=408 loops=6) + Index Cond: ((event_actor.actor_id)::text = ("outer".actor_id)::text) + -> Index Scan using event_pkey on event (cost=0.00..5.83 rows=1 width=52) (actual time=0.308..0.308 rows=0 loops=2449) + Index Cond: (("outer".event_id)::text = (event.event_id)::text) + Filter: (event_date_time > '20021126'::bpchar) + Total runtime: 111924.833 ms +(23 rows) + + + +> +> ------------- +> Hannu +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +-- +Jeremiah Jahn + + +From pgsql-performance-owner@postgresql.org Mon Dec 1 11:26:47 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 03A6ED1DA87 + for ; + Mon, 1 Dec 2003 15:11:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 20152-08 + for ; + Mon, 1 Dec 2003 11:11:28 -0400 (AST) +Received: from mist.cti.unav.es (mist.cti.unav.es [159.237.12.28]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F84CD1B465 + for ; + Mon, 1 Dec 2003 11:11:03 -0400 (AST) +Received: from norvelle.net ([159.237.106.162]) + by mist.cti.unav.es (8.12.10/8.12.10) with ESMTP id hB1FB5nF032017 + for ; Mon, 1 Dec 2003 16:11:06 +0100 +Date: Mon, 1 Dec 2003 16:11:11 +0100 +Subject: Re: My indexes aren't being used (according to EXPLAIN) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Mime-Version: 1.0 (Apple Message framework v552) +From: Erik Norvelle +To: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +In-Reply-To: <20031201140410.GC4107@libertyrms.info> +Message-Id: <99468E86-2410-11D8-BDFB-000A9583BF06@norvelle.net> +X-Mailer: Apple Mail (2.552) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/10 +X-Sequence-Number: 4870 + +The ANALYSE did the trick... Thanks! Will also read through the +archives... + +-Erik + +On lunes, dici 1, 2003, at 15:04 Europe/Madrid, Andrew Sullivan wrote: + +> On Mon, Dec 01, 2003 at 02:40:30PM +0100, Erik Norvelle wrote: +>> +>> it=> explain select * from indethom where clavis < 25; +> +> What's the percentage of the table where clavis < 25? Have you +> ANALYSEd recently? What does the pg_stats view tell you about this +> table? +> +>> Feel free to point me to any FAQ or previous message that already +>> answers this question. Thanks in advance! +> +> This is a pretty common sort of problem. See the archives of this +> list for several fairly recent discussions of these sorts of +> problems. +> +> A +> +> -- +> ---- +> Andrew Sullivan 204-4141 Yonge Street +> Afilias Canada Toronto, Ontario Canada +> M2P 2A8 +> +1 416 646 3304 x110 +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 6: Have you searched our list archives? +> +> http://archives.postgresql.org +> + + +From pgsql-performance-owner@postgresql.org Mon Dec 1 11:25:56 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 49C5FD1B465 + for ; + Mon, 1 Dec 2003 15:24:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22872-04 + for ; + Mon, 1 Dec 2003 11:24:08 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 75C84D1B43E + for ; + Mon, 1 Dec 2003 11:24:04 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id A7636355D6; Mon, 1 Dec 2003 07:23:53 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id A3F1E354CA; Mon, 1 Dec 2003 07:23:53 -0800 (PST) +Date: Mon, 1 Dec 2003 07:23:53 -0800 (PST) +From: Stephan Szabo +To: Jeff +Cc: Kamalraj Singh Madhan , + jason@tishler.net, pgsql-performance@postgresql.org +Subject: Re: Dump restoration via archive files +In-Reply-To: <20031201091634.6f19f28a.threshar@torgo.978.org> +Message-ID: <20031201071943.G44545@megazone.bigpanda.com> +References: <4c0ccf4c27ff.4c27ff4c0ccf@jhmimail.jhmi.edu> + <3FC54A82.2040605@familyhealth.com.au> + <20031127032831.GA4836@gp.word-to-the-wise.com> + <3FC58097.8090803@familyhealth.com.au> + <20031127051230.GA6212@gp.word-to-the-wise.com> + <20031128050417.GA14227@gp.word-to-the-wise.com> + <3FC6DAB8.4080106@familyhealth.com.au> + <20031128203700.GA19831@gp.word-to-the-wise.com> + <3FC9BC76.2030308@familyhealth.com.au> + <01d601c3b7f4$61897f10$4ecb09c0@KAMALR> + <20031201091634.6f19f28a.threshar@torgo.978.org> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/9 +X-Sequence-Number: 4869 + + +On Mon, 1 Dec 2003, Jeff wrote: + +> On Mon, 1 Dec 2003 15:47:47 +0530 +> "Kamalraj Singh Madhan" wrote: +> +> 4. If you are not using 7.4 and using pg_dump, there isn't much you can +> do about adding foreign keys going stupidly slow :( + +You can take a schema dump and a separate data only dump where the latter +specifies --disable-triggers which should disable the checks when the data +is being added. + +From pgsql-performance-owner@postgresql.org Mon Dec 1 12:01:54 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B598D1D5A3 + for ; + Mon, 1 Dec 2003 16:00:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27262-09 + for ; + Mon, 1 Dec 2003 12:00:15 -0400 (AST) +Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net + [194.217.242.90]) + by svr1.postgresql.org (Postfix) with ESMTP id 89847D1B45C + for ; + Mon, 1 Dec 2003 11:59:59 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AQqSr-000Gja-0W; Mon, 01 Dec 2003 15:59:57 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 679A816C88; Mon, 1 Dec 2003 15:59:55 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 44A6E1665E; Mon, 1 Dec 2003 15:59:53 +0000 (GMT) +From: Richard Huxton +To: Jeremiah Jahn , + Hannu Krosing +Subject: Re: cross table indexes or something? +Date: Mon, 1 Dec 2003 15:59:52 +0000 +User-Agent: KMail/1.5 +Cc: postgres performance +References: <1069877651.22346.13.camel@bluejay.goodinassociates.com> + <1069885949.3176.57.camel@fuji.krosing.net> + <1070288942.22346.27.camel@bluejay.goodinassociates.com> +In-Reply-To: <1070288942.22346.27.camel@bluejay.goodinassociates.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200312011559.52880.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/11 +X-Sequence-Number: 4871 + +On Monday 01 December 2003 14:29, Jeremiah Jahn wrote: +> On Wed, 2003-11-26 at 16:32, Hannu Krosing wrote: +> > Jeremiah Jahn kirjutas K, 26.11.2003 kell 22:14: +> > > I was wondering if there is something I can do that would act similar +> > > to a index over more than one table. +> > > +> > > I have about 3 million people in my DB at the moment, they all have +> > > roles, and many of them have more than one name. +> > > +> > > for example, a Judge will only have one name, but a Litigant could have +> > > multiple aliases. Things go far to slow when I do a query on a judge +> > > named smith. +> > +> > If you dont need all the judges named smith you could try to use LIMIT. +> +> Unfortunately I do need all of the judges named smith. +> +> > Have you run ANALYZE ? Why does DB think that there is only one judge +> > with name like SMITH% ? +> +> I've attached the Analyze below. I have no idea why the db thinks there +> is only 1 judge named simth. Is there some what I can inform the DB +> about this. In actuality, there aren't any judges named smith at the +> moment, but there are 22K people named smith. + +It's guessing there's approximately 1. I don't think PG measures +cross-correlation of various columns cross-table. + +If role_class_code on table actor? If so, try: + +CREATE INDEX test_judge_idx ON actor (actor_id) WHERE role_class_code = +'Judge'; + +And then similar for the other class-codes (assuming you've not got too many +of them). Or even just an index on (actor_id,role_class_code). + +If role_class_code is on a different table, can you say which one? The problem +is clearly this step: + +> -> Index Scan using actor_speed on +> actor (cost=0.00..5.42 rows=1 width=50) (actual time=4.883..4.883 rows=0 +> loops=22436) +> Index Cond: (("outer".actor_id)::text = +> (actor.actor_id)::text) Filter: ((role_class_code)::text = 'Judge'::text) + +Thats 4.883 * 22436 loops = 109555 milliseconds. +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Mon Dec 1 12:26:42 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E2833D1BC54 + for ; + Mon, 1 Dec 2003 16:25:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33340-04 + for ; + Mon, 1 Dec 2003 12:25:10 -0400 (AST) +Received: from mailhost3.tudelft.nl (mailhost3.tudelft.nl [130.161.180.14]) + by svr1.postgresql.org (Postfix) with ESMTP id 8DC79D1B4AA + for ; + Mon, 1 Dec 2003 12:25:09 -0400 (AST) +Received: from 127.0.0.1 (localhost [127.0.0.1]) + by rav.antivirus (Postfix) with SMTP + id 19872263E; Mon, 1 Dec 2003 17:25:08 +0100 (MET) +Received: from listserv.tudelft.nl (witlab.tudelft.nl [130.161.180.33]) + by mailhost3.tudelft.nl (Postfix) with ESMTP + id 0190927D5; Mon, 1 Dec 2003 17:25:08 +0100 (MET) +Received: from acm (x193056-2.shuis-s.tudelft.nl [145.94.193.58]) + by listserv.tudelft.nl (8.12.10/8.12.8) with ESMTP id hB1GOwQQ025391; + Mon, 1 Dec 2003 17:25:07 +0100 (MET) +From: "Arjen van der Meijden" +To: "'Jeremiah Jahn'" , + "'Hannu Krosing'" +Cc: "'postgres performance'" +Subject: Re: cross table indexes or something? +Date: Mon, 1 Dec 2003 17:24:43 +0100 +Message-ID: <002901c3b827$a48aeff0$3ac15e91@acm> +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: <1070288942.22346.27.camel@bluejay.goodinassociates.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=BAYES_30, + FORGED_RCVD_TRAIL, IN_REP_TO, QUOTED_EMAIL_TEXT +X-Spam-Level: +X-Archive-Number: 200312/12 +X-Sequence-Number: 4872 + +> Jeremiah Jahn wrote: +> +> > Have you run ANALYZE ? Why does DB think that there is only +> one judge +> > with name like SMITH% ? +> I've attached the Analyze below. I have no idea why the db +> thinks there is only 1 judge named simth. Is there some what +> I can inform the DB about this. In actuality, there aren't +> any judges named smith at the moment, but there are 22K +> people named smith. +> + +I think you're mistaking the command EXPLAIN ANALYZE for the command +ANALYZE. +Have you actually run the command ANALYZE or perhaps even better if you +haven't vacuumed before: VACUUM FULL ANALYZE + +If you have no idea what vacuum is, check the manual. If you've already +run such a VACUUM/ANALYZE-command, then ignore this message :) + +Best regards, + +Arjen van der Meijden + + + + +From pgsql-performance-owner@postgresql.org Mon Dec 1 15:58:44 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A482BD1B432 + for ; + Mon, 1 Dec 2003 17:15:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43158-03 + for ; + Mon, 1 Dec 2003 13:14:52 -0400 (AST) +Received: from pcs-1.paccomsys.com (208.225.nwc.net [207.151.225.208]) + by svr1.postgresql.org (Postfix) with ESMTP id 7BA2BD1B46B + for ; + Mon, 1 Dec 2003 13:14:50 -0400 (AST) +Received: from musicreports.com (mail.musicreports.com [64.161.179.34]) + by pcs-1.paccomsys.com (8.12.5/8.12.5) with ESMTP id hB1Gs574031370; + Mon, 1 Dec 2003 08:54:06 -0800 +Message-ID: <3FCB7708.1020305@musicreports.com> +Date: Mon, 01 Dec 2003 09:14:48 -0800 +From: Roger Ging +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.3) Gecko/20030708 Debian/1.3-4.lindows43 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Followup - expression (functional) index use in joins +References: <3FC4F360.2090609@paccomsys.com> + <200311261912.01286.dev@archonet.com> + <3FC51B2C.2030700@paccomsys.com> <18733.1069891765@sss.pgh.pa.us> +In-Reply-To: <18733.1069891765@sss.pgh.pa.us> +Content-Type: multipart/alternative; + boundary="------------060907050500000000060500" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/17 +X-Sequence-Number: 4877 + +This is a multi-part message in MIME format. +--------------060907050500000000060500 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Tom, + +Turning enable_hashjoin off made the query run as it had on v7.3. We +have worked around this by changing the index from a function call to a +direct index on a new column with the results of the function maintained +by a trigger. Would there be performance issues from leaving +enable_hashjoin off, or do you recomend enabling it, and working around +function calls in indices? + +See results below. I was not sure if I was supposed to reply-all, or +just to the list. Sorry if the protocol is incorrect. + + + +ppl=# explain analyse select title from music.program p +ppl-# join music.logfile l on +ppl-# l.program_id = music.fn_mri_id_no_program(p.mri_id_no) +ppl-# where l.air_date = '01/30/2001' +ppl-# and l.station = 'KABC'; + +QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=69.89..19157.06 rows=2322 width=28) (actual +time=500.905..1473.748 rows=242 loops=1) + Hash Cond: ((music.fn_mri_id_no_program("outer".mri_id_no))::text = +("inner".program_id)::text) + -> Seq Scan on program p (cost=0.00..16888.98 rows=173998 width=40) +(actual time=98.371..532.184 rows=173998 loops=1) + -> Hash (cost=69.84..69.84 rows=17 width=9) (actual +time=65.817..65.817 rows=0 loops=1) + -> Index Scan using idx_logfile_station_air_date on logfile l +(cost=0.00..69.84 rows=17 width=9) (actual time=24.499..65.730 rows=32 +loops=1) + Index Cond: (((station)::text = 'KABC'::text) AND +(air_date = '2001-01-30 00:00:00'::timestamp without time zone)) + Total runtime: 1474.067 ms +(7 rows) + +ppl=# set enable_mergejoin = false; +SET +ppl=# explain analyse select title from music.program p +ppl-# join music.logfile l on +ppl-# l.program_id = music.fn_mri_id_no_program(p.mri_id_no) +ppl-# where l.air_date = '01/30/2001' +ppl-# and l.station = 'KABC'; + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=69.89..19157.06 rows=2322 width=28) (actual +time=444.834..1428.815 rows=242 loops=1) + Hash Cond: ((music.fn_mri_id_no_program("outer".mri_id_no))::text = +("inner".program_id)::text) + -> Seq Scan on program p (cost=0.00..16888.98 rows=173998 width=40) +(actual time=105.977..542.870 rows=173998 loops=1) + -> Hash (cost=69.84..69.84 rows=17 width=9) (actual +time=1.197..1.197 rows=0 loops=1) + -> Index Scan using idx_logfile_station_air_date on logfile l +(cost=0.00..69.84 rows=17 width=9) (actual time=0.574..1.151 rows=32 +loops=1) + Index Cond: (((station)::text = 'KABC'::text) AND +(air_date = '2001-01-30 00:00:00'::timestamp without time zone)) + Total runtime: 1429.111 ms +(7 rows) + +ppl=# set enable_hashjoin = false; +SET +ppl=# explain analyse select title from music.program p +ppl-# join music.logfile l on +ppl-# l.program_id = music.fn_mri_id_no_program(p.mri_id_no) +ppl-# where l.air_date = '01/30/2001' +ppl-# and l.station = 'KABC'; + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------ + Nested Loop (cost=0.00..58104.34 rows=2322 width=28) (actual +time=0.480..5.357 rows=242 loops=1) + -> Index Scan using idx_logfile_station_air_date on logfile l +(cost=0.00..69.84 rows=17 width=9) (actual time=0.176..0.754 rows=32 +loops=1) + Index Cond: (((station)::text = 'KABC'::text) AND (air_date = +'2001-01-30 00:00:00'::timestamp without time zone)) + -> Index Scan using idx_program_mri_id_no_program on program p +(cost=0.00..3400.74 rows=870 width=40) (actual time=0.041..0.127 rows=8 +loops=32) + Index Cond: (("outer".program_id)::text = +(music.fn_mri_id_no_program(p.mri_id_no))::text) + Total runtime: 5.637 ms +(6 rows) + + +Tom Lane wrote: + +>Roger Ging writes: +> +> +>>Ran vacuum analyse on both program and logfile tables. Estimates are +>>more in line with reality now, +>> +>> +> +>And they are what now? You really can't expect to get useful help here +>when you're being so miserly with the details ... +> +>FWIW, I suspect you could force 7.4 to generate 7.3's plan by setting +>enable_mergejoin to off (might have to also set enable_hashjoin to off, +>if it then tries for a hash join). 7.3 could not even consider those +>join types in this example, while 7.4 can. The interesting question +>from my perspective is why the planner is guessing wrong about the +>relative costs of the plans. EXPLAIN ANALYZE results with each type of +>join forced would be useful to look at. +> +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> +> + +--------------060907050500000000060500 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +Tom,
+
+Turning enable_hashjoin off made the query run as it had on v7.3.  We +have worked around this by changing the index from a function call to a +direct index on a new column with the results of the function +maintained by a trigger.  Would there be performance issues from +leaving enable_hashjoin off, or do you recomend enabling it, and +working around function calls in indices?
+
+See results below.  I was not sure if I was supposed to reply-all, or +just to the list.  Sorry if the protocol is incorrect.
+
+
+
+ppl=# explain analyse select title from music.program p
+ppl-# join music.logfile l on
+ppl-# l.program_id = music.fn_mri_id_no_program(p.mri_id_no)
+ppl-# where l.air_date = '01/30/2001'
+ppl-# and l.station = 'KABC';
+                                                                       +QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------
+ Hash Join  (cost=69.89..19157.06 rows=2322 width=28) (actual +time=500.905..1473.748 rows=242 loops=1)
+   Hash Cond: ((music.fn_mri_id_no_program("outer".mri_id_no))::text = +("inner".program_id)::text)
+   ->  Seq Scan on program p  (cost=0.00..16888.98 rows=173998 +width=40) (actual time=98.371..532.184 rows=173998 loops=1)
+   ->  Hash  (cost=69.84..69.84 rows=17 width=9) (actual +time=65.817..65.817 rows=0 loops=1)
+         ->  Index Scan using idx_logfile_station_air_date on +logfile l  (cost=0.00..69.84 rows=17 width=9) (actual +time=24.499..65.730 rows=32 loops=1)
+               Index Cond: (((station)::text = 'KABC'::text) AND +(air_date = '2001-01-30 00:00:00'::timestamp without time zone))
+ Total runtime: 1474.067 ms
+(7 rows)
+
+ppl=# set enable_mergejoin = false;
+SET
+ppl=# explain analyse select title from music.program p
+ppl-# join music.logfile l on
+ppl-# l.program_id = music.fn_mri_id_no_program(p.mri_id_no)
+ppl-# where l.air_date = '01/30/2001'
+ppl-# and l.station = 'KABC';
+                                                                      +QUERY PLAN
+-------------------------------------------------------------------------------------------------------------------------------------------------------
+ Hash Join  (cost=69.89..19157.06 rows=2322 width=28) (actual +time=444.834..1428.815 rows=242 loops=1)
+   Hash Cond: ((music.fn_mri_id_no_program("outer".mri_id_no))::text = +("inner".program_id)::text)
+   ->  Seq Scan on program p  (cost=0.00..16888.98 rows=173998 +width=40) (actual time=105.977..542.870 rows=173998 loops=1)
+   ->  Hash  (cost=69.84..69.84 rows=17 width=9) (actual +time=1.197..1.197 rows=0 loops=1)
+         ->  Index Scan using idx_logfile_station_air_date on +logfile l  (cost=0.00..69.84 rows=17 width=9) (actual time=0.574..1.151 +rows=32 loops=1)
+               Index Cond: (((station)::text = 'KABC'::text) AND +(air_date = '2001-01-30 00:00:00'::timestamp without time zone))
+ Total runtime: 1429.111 ms
+(7 rows)
+
+ppl=# set enable_hashjoin = false;
+SET
+ppl=# explain analyse select title from music.program p
+ppl-# join music.logfile l on
+ppl-# l.program_id = music.fn_mri_id_no_program(p.mri_id_no)
+ppl-# where l.air_date = '01/30/2001'
+ppl-# and l.station = 'KABC';
+                                                                      +QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------
+ Nested Loop  (cost=0.00..58104.34 rows=2322 width=28) (actual +time=0.480..5.357 rows=242 loops=1)
+   ->  Index Scan using idx_logfile_station_air_date on logfile l  +(cost=0.00..69.84 rows=17 width=9) (actual time=0.176..0.754 rows=32 +loops=1)
+         Index Cond: (((station)::text = 'KABC'::text) AND (air_date = +'2001-01-30 00:00:00'::timestamp without time zone))
+   ->  Index Scan using idx_program_mri_id_no_program on program p  +(cost=0.00..3400.74 rows=870 width=40) (actual time=0.041..0.127 rows=8 +loops=32)
+         Index Cond: (("outer".program_id)::text = +(music.fn_mri_id_no_program(p.mri_id_no))::text)
+ Total runtime: 5.637 ms
+(6 rows)
+
+
+Tom Lane wrote:
+
+
Roger Ging <rging@paccomsys.com> writes:
+  
+
+
Ran vacuum analyse on both program and logfile tables.  Estimates are 
+more in line with reality now,
+    
+
+

+And they are what now?  You really can't expect to get useful help here
+when you're being so miserly with the details ...
+
+FWIW, I suspect you could force 7.4 to generate 7.3's plan by setting
+enable_mergejoin to off (might have to also set enable_hashjoin to off,
+if it then tries for a hash join).  7.3 could not even consider those
+join types in this example, while 7.4 can.  The interesting question
+from my perspective is why the planner is guessing wrong about the
+relative costs of the plans.  EXPLAIN ANALYZE results with each type of
+join forced would be useful to look at.
+
+			regards, tom lane
+
+---------------------------(end of broadcast)---------------------------
+TIP 5: Have you checked our extensive FAQ?
+
+               http://www.postgresql.org/docs/faqs/FAQ.html
+  
+
+ + + +--------------060907050500000000060500-- + + +From pgsql-performance-owner@postgresql.org Mon Dec 1 13:31:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B1797D1D61F + for ; + Mon, 1 Dec 2003 17:31:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43508-08 + for ; + Mon, 1 Dec 2003 13:31:10 -0400 (AST) +Received: from pcs-1.paccomsys.com (208.225.nwc.net [207.151.225.208]) + by svr1.postgresql.org (Postfix) with ESMTP id CB4E5D1B486 + for ; + Mon, 1 Dec 2003 13:31:07 -0400 (AST) +Received: from paccomsys.com (mail.musicreports.com [64.161.179.34]) + by pcs-1.paccomsys.com (8.12.5/8.12.5) with ESMTP id hB1HAN74031563 + for ; Mon, 1 Dec 2003 09:10:24 -0800 +Message-ID: <3FCB7ADA.8020101@paccomsys.com> +Date: Mon, 01 Dec 2003 09:31:06 -0800 +From: Roger Ging +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.3) Gecko/20030708 Debian/1.3-4.lindows43 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Followup - expression (functional) index use in joins +References: <3FC4F360.2090609@paccomsys.com> + <200311261912.01286.dev@archonet.com> + <3FC51B2C.2030700@paccomsys.com> <18733.1069891765@sss.pgh.pa.us> +In-Reply-To: <18733.1069891765@sss.pgh.pa.us> +Content-Type: multipart/alternative; + boundary="------------080104020701070107090204" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/13 +X-Sequence-Number: 4873 + +This is a multi-part message in MIME format. +--------------080104020701070107090204 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + + +Turning enable_hashjoin off made the query run as it had on v7.3. We +have worked around this by changing the index from a function call to a +direct index on a new column with the results of the function maintained +by a trigger. Would there be performance issues from leaving +enable_hashjoin off, or do you recomend enabling it, and working around +function calls in indices? + +See results below. + + + +ppl=# explain analyse select title from music.program p +ppl-# join music.logfile l on +ppl-# l.program_id = music.fn_mri_id_no_program(p.mri_id_no) +ppl-# where l.air_date = '01/30/2001' +ppl-# and l.station = 'KABC'; + +QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=69.89..19157.06 rows=2322 width=28) (actual +time=500.905..1473.748 rows=242 loops=1) + Hash Cond: ((music.fn_mri_id_no_program("outer".mri_id_no))::text = +("inner".program_id)::text) + -> Seq Scan on program p (cost=0.00..16888.98 rows=173998 width=40) +(actual time=98.371..532.184 rows=173998 loops=1) + -> Hash (cost=69.84..69.84 rows=17 width=9) (actual +time=65.817..65.817 rows=0 loops=1) + -> Index Scan using idx_logfile_station_air_date on logfile l +(cost=0.00..69.84 rows=17 width=9) (actual time=24.499..65.730 rows=32 +loops=1) + Index Cond: (((station)::text = 'KABC'::text) AND +(air_date = '2001-01-30 00:00:00'::timestamp without time zone)) + Total runtime: 1474.067 ms +(7 rows) + +ppl=# set enable_mergejoin = false; +SET +ppl=# explain analyse select title from music.program p +ppl-# join music.logfile l on +ppl-# l.program_id = music.fn_mri_id_no_program(p.mri_id_no) +ppl-# where l.air_date = '01/30/2001' +ppl-# and l.station = 'KABC'; + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=69.89..19157.06 rows=2322 width=28) (actual +time=444.834..1428.815 rows=242 loops=1) + Hash Cond: ((music.fn_mri_id_no_program("outer".mri_id_no))::text = +("inner".program_id)::text) + -> Seq Scan on program p (cost=0.00..16888.98 rows=173998 width=40) +(actual time=105.977..542.870 rows=173998 loops=1) + -> Hash (cost=69.84..69.84 rows=17 width=9) (actual +time=1.197..1.197 rows=0 loops=1) + -> Index Scan using idx_logfile_station_air_date on logfile l +(cost=0.00..69.84 rows=17 width=9) (actual time=0.574..1.151 rows=32 +loops=1) + Index Cond: (((station)::text = 'KABC'::text) AND +(air_date = '2001-01-30 00:00:00'::timestamp without time zone)) + Total runtime: 1429.111 ms +(7 rows) + +ppl=# set enable_hashjoin = false; +SET +ppl=# explain analyse select title from music.program p +ppl-# join music.logfile l on +ppl-# l.program_id = music.fn_mri_id_no_program(p.mri_id_no) +ppl-# where l.air_date = '01/30/2001' +ppl-# and l.station = 'KABC'; + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------ + Nested Loop (cost=0.00..58104.34 rows=2322 width=28) (actual +time=0.480..5.357 rows=242 loops=1) + -> Index Scan using idx_logfile_station_air_date on logfile l +(cost=0.00..69.84 rows=17 width=9) (actual time=0.176..0.754 rows=32 +loops=1) + Index Cond: (((station)::text = 'KABC'::text) AND (air_date = +'2001-01-30 00:00:00'::timestamp without time zone)) + -> Index Scan using idx_program_mri_id_no_program on program p +(cost=0.00..3400.74 rows=870 width=40) (actual time=0.041..0.127 rows=8 +loops=32) + Index Cond: (("outer".program_id)::text = +(music.fn_mri_id_no_program(p.mri_id_no))::text) + Total runtime: 5.637 ms +(6 rows) + + +Tom Lane wrote: + +>Roger Ging writes: +> +> +>>Ran vacuum analyse on both program and logfile tables. Estimates are +>>more in line with reality now, +>> +>> +> +>And they are what now? You really can't expect to get useful help here +>when you're being so miserly with the details ... +> +>FWIW, I suspect you could force 7.4 to generate 7.3's plan by setting +>enable_mergejoin to off (might have to also set enable_hashjoin to off, +>if it then tries for a hash join). 7.3 could not even consider those +>join types in this example, while 7.4 can. The interesting question +>from my perspective is why the planner is guessing wrong about the +>relative costs of the plans. EXPLAIN ANALYZE results with each type of +>join forced would be useful to look at. +> +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> +> + + +Tom Lane wrote: + +>Roger Ging writes: +> +> +>>Ran vacuum analyse on both program and logfile tables. Estimates are +>>more in line with reality now, +>> +>> +> +>And they are what now? You really can't expect to get useful help here +>when you're being so miserly with the details ... +> +>FWIW, I suspect you could force 7.4 to generate 7.3's plan by setting +>enable_mergejoin to off (might have to also set enable_hashjoin to off, +>if it then tries for a hash join). 7.3 could not even consider those +>join types in this example, while 7.4 can. The interesting question +>from my perspective is why the planner is guessing wrong about the +>relative costs of the plans. EXPLAIN ANALYZE results with each type of +>join forced would be useful to look at. +> +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> +> + +--------------080104020701070107090204 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +
+Turning enable_hashjoin off made the query run as it had on v7.3.  We +have worked around this by changing the index from a function call to a +direct index on a new column with the results of the function maintained +by a trigger.  Would there be performance issues from leaving +enable_hashjoin off, or do you recomend enabling it, and working around +function calls in indices?
+
+See results below.
+
+
+
+ppl=# explain analyse select title from music.program p
+ppl-# join music.logfile l on
+ppl-# l.program_id = music.fn_mri_id_no_program(p.mri_id_no)
+ppl-# where l.air_date = '01/30/2001'
+ppl-# and l.station = 'KABC';
+                                                                       +QUERY PLAN
+---------------------------------------------------------------------------------------------------------------------------------------------------------
+ Hash Join  (cost=69.89..19157.06 rows=2322 width=28) (actual +time=500.905..1473.748 rows=242 loops=1)
+   Hash Cond: ((music.fn_mri_id_no_program("outer".mri_id_no))::text = +("inner".program_id)::text)
+   ->  Seq Scan on program p  (cost=0.00..16888.98 rows=173998 +width=40) (actual time=98.371..532.184 rows=173998 loops=1)
+   ->  Hash  (cost=69.84..69.84 rows=17 width=9) (actual +time=65.817..65.817 rows=0 loops=1)
+         ->  Index Scan using idx_logfile_station_air_date on +logfile l  (cost=0.00..69.84 rows=17 width=9) (actual +time=24.499..65.730 rows=32 loops=1)
+               Index Cond: (((station)::text = 'KABC'::text) AND +(air_date = '2001-01-30 00:00:00'::timestamp without time zone))
+ Total runtime: 1474.067 ms
+(7 rows)
+
+ppl=# set enable_mergejoin = false;
+SET
+ppl=# explain analyse select title from music.program p
+ppl-# join music.logfile l on
+ppl-# l.program_id = music.fn_mri_id_no_program(p.mri_id_no)
+ppl-# where l.air_date = '01/30/2001'
+ppl-# and l.station = 'KABC';
+                                                                      +QUERY PLAN
+-------------------------------------------------------------------------------------------------------------------------------------------------------
+ Hash Join  (cost=69.89..19157.06 rows=2322 width=28) (actual +time=444.834..1428.815 rows=242 loops=1)
+   Hash Cond: ((music.fn_mri_id_no_program("outer".mri_id_no))::text = +("inner".program_id)::text)
+   ->  Seq Scan on program p  (cost=0.00..16888.98 rows=173998 +width=40) (actual time=105.977..542.870 rows=173998 loops=1)
+   ->  Hash  (cost=69.84..69.84 rows=17 width=9) (actual +time=1.197..1.197 rows=0 loops=1)
+         ->  Index Scan using idx_logfile_station_air_date on +logfile l  (cost=0.00..69.84 rows=17 width=9) (actual time=0.574..1.151 +rows=32 loops=1)
+               Index Cond: (((station)::text = 'KABC'::text) AND +(air_date = '2001-01-30 00:00:00'::timestamp without time zone))
+ Total runtime: 1429.111 ms
+(7 rows)
+
+ppl=# set enable_hashjoin = false;
+SET
+ppl=# explain analyse select title from music.program p
+ppl-# join music.logfile l on
+ppl-# l.program_id = music.fn_mri_id_no_program(p.mri_id_no)
+ppl-# where l.air_date = '01/30/2001'
+ppl-# and l.station = 'KABC';
+                                                                      +QUERY PLAN
+------------------------------------------------------------------------------------------------------------------------------------------------------
+ Nested Loop  (cost=0.00..58104.34 rows=2322 width=28) (actual +time=0.480..5.357 rows=242 loops=1)
+   ->  Index Scan using idx_logfile_station_air_date on logfile l  +(cost=0.00..69.84 rows=17 width=9) (actual time=0.176..0.754 rows=32 +loops=1)
+         Index Cond: (((station)::text = 'KABC'::text) AND (air_date = +'2001-01-30 00:00:00'::timestamp without time zone))
+   ->  Index Scan using idx_program_mri_id_no_program on program p  +(cost=0.00..3400.74 rows=870 width=40) (actual time=0.041..0.127 rows=8 +loops=32)
+         Index Cond: (("outer".program_id)::text = +(music.fn_mri_id_no_program(p.mri_id_no))::text)
+ Total runtime: 5.637 ms
+(6 rows)
+
+
+Tom Lane wrote:
+
+
Roger Ging <rging@paccomsys.com> writes:
+  
+
+
Ran vacuum analyse on both program and logfile tables.  Estimates are 
+more in line with reality now,
+    
+
+

+And they are what now?  You really can't expect to get useful help here
+when you're being so miserly with the details ...
+
+FWIW, I suspect you could force 7.4 to generate 7.3's plan by setting
+enable_mergejoin to off (might have to also set enable_hashjoin to off,
+if it then tries for a hash join).  7.3 could not even consider those
+join types in this example, while 7.4 can.  The interesting question
+from my perspective is why the planner is guessing wrong about the
+relative costs of the plans.  EXPLAIN ANALYZE results with each type of
+join forced would be useful to look at.
+
+			regards, tom lane
+
+---------------------------(end of broadcast)---------------------------
+TIP 5: Have you checked our extensive FAQ?
+
+               http://www.postgresql.org/docs/faqs/FAQ.html
+  
+
+
+
+Tom Lane wrote:
+
+
Roger Ging <rging@paccomsys.com> writes:
+  
+
+
Ran vacuum analyse on both program and logfile tables.  Estimates are 
+more in line with reality now,
+    
+
+

+And they are what now?  You really can't expect to get useful help here
+when you're being so miserly with the details ...
+
+FWIW, I suspect you could force 7.4 to generate 7.3's plan by setting
+enable_mergejoin to off (might have to also set enable_hashjoin to off,
+if it then tries for a hash join).  7.3 could not even consider those
+join types in this example, while 7.4 can.  The interesting question
+from my perspective is why the planner is guessing wrong about the
+relative costs of the plans.  EXPLAIN ANALYZE results with each type of
+join forced would be useful to look at.
+
+			regards, tom lane
+
+---------------------------(end of broadcast)---------------------------
+TIP 5: Have you checked our extensive FAQ?
+
+               http://www.postgresql.org/docs/faqs/FAQ.html
+  
+
+ + + +--------------080104020701070107090204-- + + +From pgsql-performance-owner@postgresql.org Mon Dec 1 14:05:38 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 32057D1C968 + for ; + Mon, 1 Dec 2003 18:05:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49990-09 + for ; + Mon, 1 Dec 2003 14:05:04 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 1914FD1D9DC + for ; + Mon, 1 Dec 2003 14:05:03 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hB1I5119023865; + Mon, 1 Dec 2003 13:05:01 -0500 (EST) +To: Roger Ging +Cc: pgsql-performance@postgresql.org +Subject: Re: Followup - expression (functional) index use in joins +In-reply-to: <3FCB7ADA.8020101@paccomsys.com> +References: <3FC4F360.2090609@paccomsys.com> + <200311261912.01286.dev@archonet.com> + <3FC51B2C.2030700@paccomsys.com> <18733.1069891765@sss.pgh.pa.us> + <3FCB7ADA.8020101@paccomsys.com> +Comments: In-reply-to Roger Ging + message dated "Mon, 01 Dec 2003 09:31:06 -0800" +Date: Mon, 01 Dec 2003 13:05:01 -0500 +Message-ID: <23864.1070301901@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/14 +X-Sequence-Number: 4874 + +Roger Ging writes: +> See results below. + +Thanks for the report. It seems the issue is that the estimate for the +number of matching rows is way off (870 vs 8): + +> -> Index Scan using idx_program_mri_id_no_program on program p +> (cost=0.00..3400.74 rows=870 width=40) (actual time=0.041..0.127 rows=8 +> loops=32) + +which discourages the planner from using a nestloop. I'm not sure we +can do much about this in the short term. There's been some discussion +of keeping statistics about the values of functional indexes, which +would allow a better estimate to be made in this situation; but that +won't happen before 7.5 at the earliest. + +> Turning enable_hashjoin off made the query run as it had on v7.3. We +> have worked around this by changing the index from a function call to a +> direct index on a new column with the results of the function maintained +> by a trigger. Would there be performance issues from leaving +> enable_hashjoin off, or do you recomend enabling it, and working around +> function calls in indices? + +Turning enable_hashjoin off globally would be a *really bad* idea IMHO. +The workaround with a derived column seems okay, though certainly a pain +in the neck. Can you manage to turn off enable_hashjoin just for this +one query? That might be the best short-term workaround. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Dec 1 15:48:51 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E65FCD1D59B + for ; + Mon, 1 Dec 2003 19:48:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69074-01 + for ; + Mon, 1 Dec 2003 15:48:21 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id C4AE1D1BC54 + for ; + Mon, 1 Dec 2003 15:48:19 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4006945; Mon, 01 Dec 2003 11:49:10 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Jeremiah Jahn , + Hannu Krosing +Subject: Re: cross table indexes or something? +Date: Mon, 1 Dec 2003 11:47:51 -0800 +User-Agent: KMail/1.4.3 +Cc: postgres performance +References: <1069877651.22346.13.camel@bluejay.goodinassociates.com> + <1069885949.3176.57.camel@fuji.krosing.net> + <1070288942.22346.27.camel@bluejay.goodinassociates.com> +In-Reply-To: <1070288942.22346.27.camel@bluejay.goodinassociates.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200312011147.51359.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/15 +X-Sequence-Number: 4875 + +Jeremiah, + +> I've attached the Analyze below. I have no idea why the db thinks there +> is only 1 judge named simth. Is there some what I can inform the DB +> about this. In actuality, there aren't any judges named smith at the +> moment, but there are 22K people named smith. + +No, Hannu meant that you may need to run the following command: + +ANALYZE actor; + +... to update the database statistics on the actors table. That is a +maintainence task that needs to be run periodically. + +If that doesn't fix the bad plan, then the granularity of statistics on the +full_name column needs updating; I suggest: + +ALTER TABLE actor ALTER COLUMN full_name SET STATISTICS 100; +ANALYZE actor; + +And if it's still choosing a slow nested loop, up the stats to 250. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Mon Dec 1 17:44:31 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ED911D1D3A3 + for ; + Mon, 1 Dec 2003 21:44:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94773-08 + for ; + Mon, 1 Dec 2003 17:43:58 -0400 (AST) +Received: from live (64-35-136-226.gohighspeed.com [64.35.136.226]) + by svr1.postgresql.org (Postfix) with ESMTP id F1981D1C9F0 + for ; + Mon, 1 Dec 2003 17:43:46 -0400 (AST) +Received: from [192.168.254.101] (helo=89glass.com) + by live with esmtp (Exim 3.35 #1 (Debian)) id 1AQvpN-0007xh-00 + for ; Mon, 01 Dec 2003 13:43:33 -0800 +Message-ID: <3FCBB639.10409@89glass.com> +Date: Mon, 01 Dec 2003 13:44:25 -0800 +From: Jared Carr +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: A question on the query planner +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/18 +X-Sequence-Number: 4878 + +I am currently working on optimizing some fairly time consuming queries +on a decently large +dataset. + +The Following is the query in question. + +SELECT z.lat, z.lon, z.city, z.state, q.date_time, c.make, c.model, c.year + FROM quotes AS q, zips AS z, cars AS c + WHERE + z.zip = q.zip AND + c.car_id = q.car_id AND + z.state != 'AA' AND + z.state != 'AE' AND + z.state != 'AP' AND + z.state = 'WA' + ORDER BY date_time; + +The tables are as follows. + + Table "public.cars" + Column | Type | Modifiers +---------------+-----------------------+---------------------------------------- + car_id | character varying(10) | not null default ''::character +varying + nags_glass_id | character varying(7) | not null default ''::character +varying + make | character varying(30) | not null default ''::character +varying + model | character varying(30) | not null default ''::character +varying + year | character varying(4) | not null default ''::character +varying + style | character varying(30) | not null default ''::character +varying + price | double precision | not null default (0)::double +precision +Indexes: + "cars_pkey" primary key, btree (car_id) + "cars_car_id_btree_index" btree (car_id) + "make_cars_index" btree (make) + "model_cars_index" btree (model) + "year_cars_index" btree ("year") + + Table "public.quotes" + Column | Type +| Modifiers +-------------------+-----------------------------+--------------------------------------------------------------------- + quote_id | bigint | not null default +nextval('quotes_quote_id_seq'::text) + visitor_id | bigint | not null default +(0)::bigint + date_time | timestamp without time zone | not null default +'0001-01-01 00:00:00'::timestamp without time zone + car_id | character varying(10) | not null default +''::character varying + email | text | not null default ''::text + zip | character varying(5) | not null default +''::character varying + current_referrer | text | not null default ''::text + original_referrer | text | not null default ''::text +Indexes: + "quotes_pkey" primary key, btree (quote_id) + "car_id_quotes_index" btree (car_id) + "visitor_id_quotes_index" btree (visitor_id) + "zip_quotes_index" btree (zip) + + Table "public.zips" + Column | Type | Modifiers +--------+-----------------------+--------------------------------------------------- + zip_id | bigint | not null default +nextval('zips_zip_id_seq'::text) + zip | character varying(5) | not null default ''::character varying + city | character varying(28) | not null default ''::character varying + state | character varying(2) | not null default ''::character varying + lat | character varying(10) | not null default ''::character varying + lon | character varying(10) | not null default ''::character varying +Indexes: + "zips_pkey" primary key, btree (zip_id) + "zip_zips_index" btree (zip) + "zips_state_btree_index" btree (state) + +The above query with the default setting of 10 for +default_statistics_target runs as follows + +(From Explain Analyze) + +--------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=58064.16..58074.20 rows=4015 width=80) (actual +time=2415.060..2421.421 rows=4539 loops=1) + Sort Key: q.date_time + -> Merge Join (cost=57728.02..57823.84 rows=4015 width=80) (actual +time=2254.056..2345.013 rows=4539 loops=1) + Merge Cond: ("outer"."?column7?" = "inner"."?column5?") + -> Sort (cost=56880.61..56890.65 rows=4015 width=62) (actual +time=2054.353..2062.189 rows=4693 loops=1) + Sort Key: (q.car_id)::text + -> Hash Join (cost=1403.91..56640.29 rows=4015 +width=62) (actual time=8.479..1757.126 rows=10151 loops=1) + Hash Cond: (("outer".zip)::text = ("inner".zip)::text) + -> Seq Scan on quotes q (cost=0.00..10657.42 +rows=336142 width=27) (actual time=0.062..657.015 rows=336166 loops=1) + -> Hash (cost=1402.63..1402.63 rows=511 width=52) +(actual time=8.273..8.273 rows=0 loops=1) + -> Index Scan using zips_state_btree_index +on zips z (cost=0.00..1402.63 rows=511 width=52) (actual +time=0.215..6.877 rows=718 loops=1) + Index Cond: ((state)::text = 'WA'::text) + Filter: (((state)::text <> 'AA'::text) +AND ((state)::text <> 'AE'::text) AND ((state)::text <> 'AP'::text)) + -> Sort (cost=847.41..870.91 rows=9401 width=37) (actual +time=199.172..216.354 rows=11922 loops=1) + Sort Key: (c.car_id)::text + -> Seq Scan on cars c (cost=0.00..227.01 rows=9401 +width=37) (actual time=0.104..43.523 rows=9401 loops=1) + Total runtime: 2427.937 ms + +If I set enable_seqscan=off I get the following + +QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=122108.52..122118.62 rows=4039 width=80) (actual +time=701.002..707.442 rows=4541 loops=1) + Sort Key: q.date_time + -> Nested Loop (cost=0.00..121866.59 rows=4039 width=80) (actual +time=0.648..624.134 rows=4541 loops=1) + -> Nested Loop (cost=0.00..102256.36 rows=4039 width=62) +(actual time=0.374..381.440 rows=10153 loops=1) + -> Index Scan using zips_state_btree_index on zips z +(cost=0.00..1413.31 rows=514 width=52) (actual time=0.042..9.043 +rows=718 loops=1) + Index Cond: ((state)::text = 'WA'::text) + Filter: (((state)::text <> 'AA'::text) AND +((state)::text <> 'AE'::text) AND ((state)::text <> 'AP'::text)) + -> Index Scan using zip_quotes_index on quotes q +(cost=0.00..195.59 rows=48 width=27) (actual time=0.039..0.426 rows=14 +loops=718) + Index Cond: (("outer".zip)::text = (q.zip)::text) + -> Index Scan using cars_car_id_btree_index on cars c +(cost=0.00..4.84 rows=1 width=37) (actual time=0.015..0.017 rows=0 +loops=10153) + Index Cond: ((c.car_id)::text = ("outer".car_id)::text) + Total runtime: 711.375 ms + +I can also get a similar plan if I disable both Hash Joins and Merge Joins. + +Furthermore I can get some additional speedup without turning off +sequence scans if I +set the value of default_statistics_target = 1000 then the runtime will +be around 1200 +otoh if I set default_statistics_target = 100 then the runtime will be +around 12000. + +So, my question is is there any way to get the query planner to +recognize the potential +performance increase available by using the indexes that are set up +without specifically +turning off sequential scans before I run this query every time? + +Thanks for the help. + +Jared + + + + + + + + + +From pgsql-performance-owner@postgresql.org Mon Dec 1 18:25:07 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AD5D0D1D916 + for ; + Mon, 1 Dec 2003 22:24:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03195-04 + for ; + Mon, 1 Dec 2003 18:24:25 -0400 (AST) +Received: from jhuml1.jhmi.edu (jhuml1.jhmi.edu [162.129.234.20]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D31AD1D383 + for ; + Mon, 1 Dec 2003 18:24:22 -0400 (AST) +Received: from jhuml1.jhmi.edu (jhuml1.jhmi.edu [162.129.234.20]) + by jhuml1.jhmi.edu (PMDF V6.2-X17 #30839) + with SMTP id <0HP800CBLM7D7X@jhuml1.jhmi.edu> for + pgsql-performance@postgresql.org; Mon, 01 Dec 2003 17:24:23 -0500 (EST) +Received: from jhuml1.jhmi.edu ([162.129.234.20]) + by jhuml1.jhmi.edu (SAVSMTP 3.1.0.29) with SMTP id M2003120117242205892 + for + ; Mon, 01 Dec 2003 17:24:22 -0500 +Received: from jhmimail.jhmi.edu (jhem2.jhmi.edu [162.129.8.23]) + by jhuml1.jhmi.edu (PMDF V6.2-X17 #30839) + with ESMTP id <0HP800CQRM8M7X@jhuml1.jhmi.edu> for + pgsql-performance@postgresql.org; Mon, 01 Dec 2003 17:24:22 -0500 (EST) +Received: from [162.129.178.60] by jhmimail.jhmi.edu (mshttpd); Mon, + 01 Dec 2003 22:27:51 +0000 (GMT) +Date: Mon, 01 Dec 2003 22:27:51 +0000 (GMT) +From: LIANHE SHAO +Subject: Is clustering possible to enhance the performance? +To: pgsql-performance +Message-id: <6b5ba36baf6d.6baf6d6b5ba3@jhmimail.jhmi.edu> +MIME-version: 1.0 +X-Mailer: iPlanet Messenger Express 5.2 HotFix 1.17 (built Jun 23 2003) +Content-type: text/plain; charset=us-ascii +Content-language: en +Content-transfer-encoding: 7bit +Content-disposition: inline +X-Accept-Language: en +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/19 +X-Sequence-Number: 4879 + +Hello, +I am wondering if it is possible to use several +machine as cluster to boost the slow queries. Is +that possible? Anybody have tried that before? + +Initially, I was thinking to use dual CPUS instead +of one. but it is not correct because pgsql is not +multi-threaded. + +Any suggestions are welcome and appreciated, + +Regards, +William + + +From pgsql-performance-owner@postgresql.org Mon Dec 1 18:38:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A84FD1D92C + for ; + Mon, 1 Dec 2003 22:37:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03971-10 + for ; + Mon, 1 Dec 2003 18:37:32 -0400 (AST) +Received: from candle.pha.pa.us (unknown [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 99B49D1DA62 + for ; + Mon, 1 Dec 2003 18:37:28 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hB1MbVF23686; + Mon, 1 Dec 2003 17:37:31 -0500 (EST) +From: Bruce Momjian +Message-Id: <200312012237.hB1MbVF23686@candle.pha.pa.us> +Subject: Re: Is clustering possible to enhance the performance? +In-Reply-To: <6b5ba36baf6d.6baf6d6b5ba3@jhmimail.jhmi.edu> +To: LIANHE SHAO +Date: Mon, 1 Dec 2003 17:37:31 -0500 (EST) +Cc: pgsql-performance +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/20 +X-Sequence-Number: 4880 + +LIANHE SHAO wrote: +> Hello, +> I am wondering if it is possible to use several +> machine as cluster to boost the slow queries. Is +> that possible? Anybody have tried that before? +> +> Initially, I was thinking to use dual CPUS instead +> of one. but it is not correct because pgsql is not +> multi-threaded. + +Dual cpu's allow multiple backends to use different cpu's, but a single +session can't use more than one cpu. + +-- + 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 Dec 1 20:46:01 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 70173D1B4B1 + for ; + Tue, 2 Dec 2003 00:45:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 20740-10 + for ; + Mon, 1 Dec 2003 20:45:31 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 67E86D1B44D + for ; + Mon, 1 Dec 2003 20:45:28 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hB20jT19008533; + Mon, 1 Dec 2003 19:45:30 -0500 (EST) +To: Jared Carr +Cc: pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +In-reply-to: <3FCBB639.10409@89glass.com> +References: <3FCBB639.10409@89glass.com> +Comments: In-reply-to Jared Carr + message dated "Mon, 01 Dec 2003 13:44:25 -0800" +Date: Mon, 01 Dec 2003 19:45:29 -0500 +Message-ID: <8532.1070325929@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/21 +X-Sequence-Number: 4881 + +Jared Carr writes: +> I am currently working on optimizing some fairly time consuming queries +> on a decently large dataset. + +It doesn't look that large from here ;-). I'd suggest experimenting +with reducing random_page_cost, since at least for your test query +it sure looks like everything is in RAM. In theory random_page_cost = 1.0 +is the correct setting for all-in-RAM cases. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Dec 2 11:55:36 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 99E24D1D23B + for ; + Tue, 2 Dec 2003 15:53:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42575-03 + for ; + Tue, 2 Dec 2003 11:53:31 -0400 (AST) +Received: from mist.cti.unav.es (mist.cti.unav.es [159.237.12.28]) + by svr1.postgresql.org (Postfix) with ESMTP id ECE61D1D30D + for ; + Tue, 2 Dec 2003 11:53:09 -0400 (AST) +Received: from norvelle.net ([159.237.106.162]) + by mist.cti.unav.es (8.12.10/8.12.10) with ESMTP id hB2FrCnF006389 + for ; Tue, 2 Dec 2003 16:53:12 +0100 +Date: Tue, 2 Dec 2003 16:53:16 +0100 +Mime-Version: 1.0 (Apple Message framework v552) +Content-Type: multipart/alternative; boundary=Apple-Mail-22--268600658 +Subject: Update performance ... is 200, + 000 updates per hour what I should expect? +From: Erik Norvelle +To: pgsql-performance@postgresql.org +Message-Id: +X-Mailer: Apple Mail (2.552) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/22 +X-Sequence-Number: 4882 + +--Apple-Mail-22--268600658 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/plain; + delsp=yes; + charset=ISO-8859-1; + format=flowed + +Folks: + +I=B4m running a query which is designed to generate a foreign key for a=20= +=20 +table of approx. 10 million records (I've mentioned this in an earlier=20= +=20 +posting). The table is called "indethom", and each row contains a=20=20 +single word from the works of St. Thomas Aquinas, along with=20=20 +grammatical data about the word form, and (most importantly for my=20=20 +current problem) a set of columns identifying the particular=20=20 +work/section/paragraph that the word appears in. + +This database is completely non-normalized, and I'm working on=20=20 +performing some basic normalization, beginning with creating a table=20=20 +called "s2.sectiones" which (naturally) contains a complete listing of=20= +=20 +all of the sections of all the works of St. Thomas. I will then=20=20 +eliminate this information from the original "indethom" table,=20=20 +replacing it with the foreign key I am currently generating. + +** My question has to do with whether or not I am getting maximal speed=20= +=20 +out of PostgreSQL, or whether I need to perform further optimizations.=20= +=20=20 +I am currently getting about 200,000 updates per hour, and updating the=20= +=20 +entire 10 million rows thus requires 50 hours, which seems a bit much. + +Here's the query I am running: +update indethom + set query_counter =3D nextval('s2.query_counter_seq'), -- Just= +=20=20 +for keeping track of how fast the query is running + sectref =3D (select clavis from s2.sectiones where + s2.sectiones.nomeoper =3D indethom.nomeoper + and s2.sectiones.refere1a =3D indethom.refere1a and=20=20 +s2.sectiones.refere1b =3D indethom.refere1b + and s2.sectiones.refere2a =3D indethom.refere2a and=20=20 +s2.sectiones.refere2b =3D indethom.refere2b + and s2.sectiones.refere3a =3D indethom.refere3a and=20=20 +s2.sectiones.refere3b =3D indethom.refere3b + and s2.sectiones.refere4a =3D indethom.refere4a and=20=20 +s2.sectiones.refere4b =3D indethom.refere4b); + +Here=B4s the query plan: + QUERY PLAN +------------------------------------------------------------------------=20 +------------- + Seq Scan on indethom (cost=3D0.00..1310352.72 rows=3D10631972 width=3D21= +2) + SubPlan + -> Index Scan using sectiones_ndx on sectiones (cost=3D0.00..6.03= +=20=20 +rows=3D1 width=3D4) + Index Cond: ((nomeoper =3D $0) AND (refere1a =3D $1) AND=20=20 +(refere1b =3D $2) AND (refere2a =3D $3) AND (refere2b =3D $4) AND (refere3a= + =3D=20=20 +$5) AND (refere3b =3D $6) AND (refere4a =3D $7) AND (refere4b =3D $8)) +(4 rows) + +Note: I have just performed a VACUUM ANALYZE on the indethom table, as=20= +=20 +suggested by this listserve. + +Here's the structure of the s2.sectiones table: +it=3D> \d s2.sectiones + Table "s2.sectiones" + Column | Type | Modifiers +----------+--------------+----------- + nomeoper | character(3) | + refere1a | character(2) | + refere1b | character(2) | + refere2a | character(2) | + refere2b | character(2) | + refere3a | character(2) | + refere3b | character(2) | + refere4a | character(2) | + refere4b | character(2) | + clavis | integer | +Indexes: sectiones_ndx btree (nomeoper, refere1a, refere1b, refere2a,=20=20 +refere2b, refere3a, refere3b, refere4a, refere4b) + +Finally, here is the structure of indethom (some non-relevant columns=20=20 +not shown): +it=3D> \d indethom + Table "public.indethom" + Column | Type | Modifiers +---------------+-----------------------+----------- + numeoper | smallint | not null + nomeoper | character(3) | not null + editcrit | character(1) | + refere1a | character(2) | + refere1b | character(2) | + refere2a | character(2) | + refere2b | character(2) | + refere3a | character(2) | + refere3b | character(2) | + refere4a | character(2) | + refere4b | character(2) | + refere5a | character(2) | not null + refere5b | smallint | not null + referen6 | smallint | not null + ... several columns skipped ... + verbum | character varying(22) | not null + ... other columns skipped ... + poslinop | integer | not null + posverli | smallint | not null + posverop | integer | not null + clavis | integer | not null + articref | integer | + sectref | integer | + query_counter | integer | +Indexes: indethom_pkey primary key btree (clavis), + indethom_articulus_ndx btree (nomeoper, refere1a, refere1b,=20=20 +refere2a, refere2b, refere3a, refere3b), + indethom_sectio_ndx btree (nomeoper, refere1a, refere1b,=20=20 +refere2a, refere2b, refere3a, refere3b, refere4a, refere4b), + verbum_ndx btree (verbum) + +Thanks for your assistance! +-Erik Norvelle +--Apple-Mail-22--268600658 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/enriched; + charset=ISO-8859-1 + +Courier NewFolks: + + +I=B4m running a query which is designed to generate a foreign key for a +table of approx. 10 million records (I've mentioned this in an earlier +posting). The table is called "indethom", and each row contains a +single word from the works of St. Thomas Aquinas, along with +grammatical data about the word form, and (most importantly for my +current problem) a set of columns identifying the particular +work/section/paragraph that the word appears in. + + +This database is completely non-normalized, and I'm working on +performing some basic normalization, beginning with creating a table +called "s2.sectiones" which (naturally) contains a complete listing of +all of the sections of all the works of St. Thomas. I will then +eliminate this information from the original "indethom" table, +replacing it with the foreign key I am currently generating. + + +** My question has to do with whether or not I am getting maximal +speed out of PostgreSQL, or whether I need to perform further +optimizations. I am currently getting about 200,000 updates per hour, +and updating the entire 10 million rows thus requires 50 hours, which +seems a bit much. + + +Here's the query I am running:=20 + +update indethom=20 + + set query_counter =3D nextval('s2.query_counter_seq'), -- +Just for keeping track of how fast the query is running + + sectref =3D (select clavis from s2.sectiones where=20 + + s2.sectiones.nomeoper =3D indethom.nomeoper=20 + + and s2.sectiones.refere1a =3D indethom.refere1a and +s2.sectiones.refere1b =3D indethom.refere1b=20 + + and s2.sectiones.refere2a =3D indethom.refere2a and +s2.sectiones.refere2b =3D indethom.refere2b=20 + + and s2.sectiones.refere3a =3D indethom.refere3a and +s2.sectiones.refere3b =3D indethom.refere3b=20 + + and s2.sectiones.refere4a =3D indethom.refere4a and +s2.sectiones.refere4b =3D indethom.refere4b); + + +Here=B4s the query plan: + + QUERY PLAN=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20 + +---------------------------------------------------------------------------= +---------- + + Seq Scan on indethom (cost=3D0.00..1310352.72 rows=3D10631972 width=3D212) + + SubPlan + + -> Index Scan using sectiones_ndx on sectiones (cost=3D0.00..6.03 +rows=3D1 width=3D4) + + Index Cond: ((nomeoper =3D $0) AND (refere1a =3D $1) AND +(refere1b =3D $2) AND (refere2a =3D $3) AND (refere2b =3D $4) AND (refere3a +=3D $5) AND (refere3b =3D $6) AND (refere4a =3D $7) AND (refere4b =3D $8)) + +(4 rows) + + +Note: I have just performed a VACUUM ANALYZE on the indethom +table, as suggested by this listserve. + + +Here's the structure of the s2.sectiones table: + +it=3D> \d s2.sectiones + + Table "s2.sectiones" + + Column | Type | Modifiers=20 + +----------+--------------+----------- + + nomeoper | character(3) |=20 + + refere1a | character(2) |=20 + + refere1b | character(2) |=20 + + refere2a | character(2) |=20 + + refere2b | character(2) |=20 + + refere3a | character(2) |=20 + + refere3b | character(2) |=20 + + refere4a | character(2) |=20 + + refere4b | character(2) |=20 + + clavis | integer |=20 + +Indexes: sectiones_ndx btree (nomeoper, refere1a, refere1b, refere2a, +refere2b, refere3a, refere3b, refere4a, refere4b) + + +Finally, here is the structure of indethom (some non-relevant columns +not shown): + +it=3D> \d indethom + + Table "public.indethom" + + Column | Type | Modifiers=20 + +---------------+-----------------------+----------- + + numeoper | smallint | not null + + nomeoper | character(3) | not null + + editcrit | character(1) |=20 + + refere1a | character(2) |=20 + + refere1b | character(2) |=20 + + refere2a | character(2) |=20 + + refere2b | character(2) |=20 + + refere3a | character(2) |=20 + + refere3b | character(2) |=20 + + refere4a | character(2) |=20 + + refere4b | character(2) |=20 + + refere5a | character(2) | not null + + refere5b | smallint | not null + + referen6 | smallint | not null + + ... several columns skipped ... + + verbum | character varying(22) | not null + + ... other columns skipped ... + + poslinop | integer | not null + + posverli | smallint | not null + + posverop | integer | not null + + clavis | integer | not null + + articref | integer |=20 + + sectref | integer |=20 + + query_counter | integer |=20 + +Indexes: indethom_pkey primary key btree (clavis), + + indethom_articulus_ndx btree (nomeoper, refere1a, refere1b, +refere2a, refere2b, refere3a, refere3b), + + indethom_sectio_ndx btree (nomeoper, refere1a, refere1b, +refere2a, refere2b, refere3a, refere3b, refere4a, refere4b), + + verbum_ndx btree (verbum) + + +Thanks for your assistance! + +-Erik Norvelle +--Apple-Mail-22--268600658-- + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 12:30:39 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 190C9D1D93E + for ; + Tue, 2 Dec 2003 16:29:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 50317-01 + for ; + Tue, 2 Dec 2003 12:29:14 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 31C85D1D92C + for ; + Tue, 2 Dec 2003 12:29:10 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 4BB53354FA; Tue, 2 Dec 2003 08:29:15 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 4A16A354F8; Tue, 2 Dec 2003 08:29:15 -0800 (PST) +Date: Tue, 2 Dec 2003 08:29:15 -0800 (PST) +From: Stephan Szabo +To: Erik Norvelle +Cc: pgsql-performance@postgresql.org +Subject: Re: Update performance ... is 200,000 updates per hour +In-Reply-To: +Message-ID: <20031202082100.T87630@megazone.bigpanda.com> +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=X-UNKNOWN +Content-Transfer-Encoding: QUOTED-PRINTABLE +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/23 +X-Sequence-Number: 4883 + + +On Tue, 2 Dec 2003, Erik Norvelle wrote: + +> ** My question has to do with whether or not I am getting maximal speed +> out of PostgreSQL, or whether I need to perform further optimizations. +> I am currently getting about 200,000 updates per hour, and updating the +> entire 10 million rows thus requires 50 hours, which seems a bit much. + +Well, it doesn't entirely surprise me much given the presumably 10 million +iterations of the index scan that it's doing. Explain analyze output (even +over a subset of the indethom table by adding a where clause) would +probably help to get better info. + +I'd suggest seeing if something like: +update indethom set query_counter=3D...,sectref=3Ds.clavis + FROM s2.sectiones s where + s2.sectiones.nomeoper =3D indethom.nomeoper and ...; +tries a join that might give a better plan. + + +> Here's the query I am running: +> update indethom +> set query_counter =3D nextval('s2.query_counter_seq'), -- Just +> for keeping track of how fast the query is running +> sectref =3D (select clavis from s2.sectiones where +> s2.sectiones.nomeoper =3D indethom.nomeoper +> and s2.sectiones.refere1a =3D indethom.refere1a and +> s2.sectiones.refere1b =3D indethom.refere1b +> and s2.sectiones.refere2a =3D indethom.refere2a and +> s2.sectiones.refere2b =3D indethom.refere2b +> and s2.sectiones.refere3a =3D indethom.refere3a and +> s2.sectiones.refere3b =3D indethom.refere3b +> and s2.sectiones.refere4a =3D indethom.refere4a and +> s2.sectiones.refere4b =3D indethom.refere4b); +> +> Here=B4s the query plan: +> QUERY PLAN +> ------------------------------------------------------------------------ +> ------------- +> Seq Scan on indethom (cost=3D0.00..1310352.72 rows=3D10631972 width=3D= +212) +> SubPlan +> -> Index Scan using sectiones_ndx on sectiones (cost=3D0.00..6.03 +> rows=3D1 width=3D4) +> Index Cond: ((nomeoper =3D $0) AND (refere1a =3D $1) AND +> (refere1b =3D $2) AND (refere2a =3D $3) AND (refere2b =3D $4) AND (refere= +3a =3D +> $5) AND (refere3b =3D $6) AND (refere4a =3D $7) AND (refere4b =3D $8)) +> (4 rows) + +From pgsql-performance-owner@postgresql.org Tue Dec 2 12:34:28 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C47BD1D92D + for ; + Tue, 2 Dec 2003 16:33:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48233-08 + for ; + Tue, 2 Dec 2003 12:32:38 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id F3696D1D6B9 + for ; + Tue, 2 Dec 2003 12:32:33 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hB2GWV19013346; + Tue, 2 Dec 2003 11:32:31 -0500 (EST) +To: Erik Norvelle +Cc: pgsql-performance@postgresql.org +Subject: Re: Update performance ... is 200, + 000 updates per hour what I should expect? +In-reply-to: +References: +Comments: In-reply-to Erik Norvelle + message dated "Tue, 02 Dec 2003 16:53:16 +0100" +Date: Tue, 02 Dec 2003 11:32:31 -0500 +Message-ID: <13345.1070382751@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/24 +X-Sequence-Number: 4884 + +Erik Norvelle writes: +> update indethom +> set query_counter =3D nextval('s2.query_counter_seq'), -- Just= +> =20=20 +> for keeping track of how fast the query is running +> sectref =3D (select clavis from s2.sectiones where +> s2.sectiones.nomeoper =3D indethom.nomeoper +> and s2.sectiones.refere1a =3D indethom.refere1a and=20=20 +> s2.sectiones.refere1b =3D indethom.refere1b +> and s2.sectiones.refere2a =3D indethom.refere2a and=20=20 +> s2.sectiones.refere2b =3D indethom.refere2b +> and s2.sectiones.refere3a =3D indethom.refere3a and=20=20 +> s2.sectiones.refere3b =3D indethom.refere3b +> and s2.sectiones.refere4a =3D indethom.refere4a and=20=20 +> s2.sectiones.refere4b =3D indethom.refere4b); + +This is effectively forcing a nestloop-with-inner-indexscan join. You +might be better off with + +update indethom + set query_counter = nextval('s2.query_counter_seq'), + sectref = sectiones.clavis +from s2.sectiones +where + s2.sectiones.nomeoper = indethom.nomeoper + and s2.sectiones.refere1a = indethom.refere1a and +s2.sectiones.refere1b = indethom.refere1b + and s2.sectiones.refere2a = indethom.refere2a and +s2.sectiones.refere2b = indethom.refere2b + and s2.sectiones.refere3a = indethom.refere3a and +s2.sectiones.refere3b = indethom.refere3b + and s2.sectiones.refere4a = indethom.refere4a and +s2.sectiones.refere4b = indethom.refere4b; + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Dec 2 12:41:52 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 95624D1D722 + for ; + Tue, 2 Dec 2003 16:41:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49804-08 + for ; + Tue, 2 Dec 2003 12:40:53 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id E4B61D1DAF2 + for ; + Tue, 2 Dec 2003 12:40:47 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 1D99E36CF3; Tue, 2 Dec 2003 11:40:52 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1ARDa0-00046L-00; Tue, 02 Dec 2003 11:40:52 -0500 +To: Erik Norvelle +Cc: pgsql-performance@postgresql.org +Subject: Re: Update performance ... is 200, + 000 updates per hour what I should expect? +References: +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 02 Dec 2003 11:40:51 -0500 +Message-ID: <87u14j9nqk.fsf@stark.dyndns.tv> +Lines: 54 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/25 +X-Sequence-Number: 4885 + +Erik Norvelle writes: + +> Here's the query I am running: +> update indethom +> set query_counter = nextval('s2.query_counter_seq'), -- Just for keeping track of how fast the query is running +> sectref = (select clavis from s2.sectiones where +> s2.sectiones.nomeoper = indethom.nomeoper +> and s2.sectiones.refere1a = indethom.refere1a and s2.sectiones.refere1b = indethom.refere1b +> and s2.sectiones.refere2a = indethom.refere2a and s2.sectiones.refere2b = indethom.refere2b +> and s2.sectiones.refere3a = indethom.refere3a and s2.sectiones.refere3b = indethom.refere3b +> and s2.sectiones.refere4a = indethom.refere4a and s2.sectiones.refere4b = indethom.refere4b); +> +> Here�s the query plan: +> QUERY PLAN +> ------------------------------------------------------------------------------------- +> Seq Scan on indethom (cost=0.00..1310352.72 rows=10631972 width=212) +> SubPlan +> -> Index Scan using sectiones_ndx on sectiones (cost=0.00..6.03 rows=1 width=4) +> Index Cond: ((nomeoper = $0) AND (refere1a = $1) AND (refere1b = $2) AND (refere2a = $3) AND (refere2b = $4) AND (refere3a = $5) AND (refere3b = $6) AND (refere4a = $7) AND (refere4b = $8)) +> (4 rows) + +Firstly, you might try running "vacuum full" on both tables. If there are tons +of extra dead records that are left-over they could be slowing down the +update. + +This isn't the fastest possible plan but it's pretty good. + +You might be able to get it somewhat faster using the non-standard "from" +clause on the update statement. + +update indethom + set sectref = clavis + from sectiones + where sectiones.nomeoper = indethom.nomeoper + and sectiones.refere1a = indethom.refere1a + and sectiones.refere1b = indethom.refere1b + and sectiones.refere2a = indethom.refere2a + and sectiones.refere2b = indethom.refere2b + and sectiones.refere3a = indethom.refere3a + and sectiones.refere3b = indethom.refere3b + and sectiones.refere4a = indethom.refere4a + and sectiones.refere4b = indethom.refere4b + +This might be able to use a merge join which will take longer to get started +because it has to sort both tables, but might finish faster. + +You might also try just paring the index down to just the two or three most +useful columns. Is it common that something matches refere1a and refere1b but +doesn't match the remaining? A 8-column index is a lot of overhead. I'm not +sure how much that effects lookup times but it might be substantial. + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 13:18:38 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C1B3AD1D8BB + for ; + Tue, 2 Dec 2003 17:17:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 54908-09 + for ; + Tue, 2 Dec 2003 13:16:54 -0400 (AST) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 871EED1C96D + for ; + Tue, 2 Dec 2003 13:16:49 -0400 (AST) +Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) + by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id hB2GPqcM003471; + Tue, 2 Dec 2003 11:25:53 -0500 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id hB2HGLl13424; + Tue, 2 Dec 2003 12:16:22 -0500 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id XT87Z43S; Tue, 2 Dec 2003 12:16:19 -0500 +Subject: Re: A question on the query planner +From: Robert Treat +To: Jared Carr +Cc: pgsql-performance@postgresql.org +In-Reply-To: <3FCBB639.10409@89glass.com> +References: <3FCBB639.10409@89glass.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 02 Dec 2003 12:16:21 -0500 +Message-Id: <1070385381.24915.8650.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/26 +X-Sequence-Number: 4886 + +On Mon, 2003-12-01 at 16:44, Jared Carr wrote: +> I am currently working on optimizing some fairly time consuming queries +> on a decently large +> dataset. +> +> The Following is the query in question. +> +> SELECT z.lat, z.lon, z.city, z.state, q.date_time, c.make, c.model, c.year +> FROM quotes AS q, zips AS z, cars AS c +> WHERE +> z.zip = q.zip AND +> c.car_id = q.car_id AND +> z.state != 'AA' AND +> z.state != 'AE' AND +> z.state != 'AP' AND +> z.state = 'WA' +> ORDER BY date_time; +> + +This wont completely solve your problem, but z.state = 'WA' would seem +to be mutually exclusive of the != AA|AE|AP. While it's not much, it is +extra overhead there doesn't seem to be any need for... + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 13:55:41 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 019A4D1D921 + for ; + Tue, 2 Dec 2003 17:55:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64484-04 + for ; + Tue, 2 Dec 2003 13:55:10 -0400 (AST) +Received: from live (64-35-136-226.gohighspeed.com [64.35.136.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 77905D1D59B + for ; + Tue, 2 Dec 2003 13:55:04 -0400 (AST) +Received: from [192.168.254.101] (helo=89glass.com) + by live with esmtp (Exim 3.35 #1 (Debian)) + id 1AREjd-00041X-00; Tue, 02 Dec 2003 09:54:53 -0800 +Message-ID: <3FCCD225.8030609@89glass.com> +Date: Tue, 02 Dec 2003 09:55:49 -0800 +From: Jared Carr +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Robert Treat +Cc: pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +References: <3FCBB639.10409@89glass.com> <1070385381.24915.8650.camel@camel> +In-Reply-To: <1070385381.24915.8650.camel@camel> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/27 +X-Sequence-Number: 4887 + +Robert Treat wrote: + +>On Mon, 2003-12-01 at 16:44, Jared Carr wrote: +> +> +>>I am currently working on optimizing some fairly time consuming queries +>>on a decently large +>>dataset. +>> +>>The Following is the query in question. +>> +>>SELECT z.lat, z.lon, z.city, z.state, q.date_time, c.make, c.model, c.year +>> FROM quotes AS q, zips AS z, cars AS c +>> WHERE +>> z.zip = q.zip AND +>> c.car_id = q.car_id AND +>> z.state != 'AA' AND +>> z.state != 'AE' AND +>> z.state != 'AP' AND +>> z.state = 'WA' +>> ORDER BY date_time; +>> +>> +>> +> +>This wont completely solve your problem, but z.state = 'WA' would seem +>to be mutually exclusive of the != AA|AE|AP. While it's not much, it is +>extra overhead there doesn't seem to be any need for... +> +>Robert Treat +> +> +That is an excellent point, unfortunately it doesn't change the query +plan at all. + +Furthermore noticed that in the following query plan it is doing the +sequential scan on quotes first, and +then doing the sequential on zips. IMHO this should be the other way +around, since the result set for +zips is considerably smaller especially give that we are using a where +clause to limit the number of items +returned from zips, so it would seem that it would be faster to scan +zips then join onto quotes, but perhaps +it needs to do the sequential scan on both regardless. + +Of course still there is the holy grail of getting it to actually use +the indexes. :P + + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=57812.71..57822.86 rows=4058 width=80) (actual +time=2522.826..2529.237 rows=4581 loops=1) + Sort Key: q.date_time + -> Merge Join (cost=57473.20..57569.50 rows=4058 width=80) (actual +time=2360.656..2451.987 rows=4581 loops=1) + Merge Cond: ("outer"."?column7?" = "inner"."?column5?") + -> Sort (cost=56625.79..56635.93 rows=4058 width=62) (actual +time=2077.209..2085.095 rows=4735 loops=1) + Sort Key: (q.car_id)::text + -> Hash Join (cost=1088.19..56382.58 rows=4058 +width=62) (actual time=86.111..1834.682 rows=10193 loops=1) + Hash Cond: (("outer".zip)::text = ("inner".zip)::text) + -> Seq Scan on quotes q (cost=0.00..10664.25 +rows=336525 width=27) (actual time=0.098..658.905 rows=336963 loops=1) + -> Hash (cost=1086.90..1086.90 rows=516 width=52) +(actual time=85.798..85.798 rows=0 loops=1) + -> Seq Scan on zips z (cost=0.00..1086.90 +rows=516 width=52) (actual time=79.532..84.151 rows=718 loops=1) + Filter: ((state)::text = 'WA'::text) + -> Sort (cost=847.41..870.91 rows=9401 width=37) (actual +time=282.896..300.082 rows=11950 loops=1) + Sort Key: (c.car_id)::text + -> Seq Scan on cars c (cost=0.00..227.01 rows=9401 +width=37) (actual time=0.102..43.516 rows=9401 loops=1) + + + +From pgsql-admin-owner@postgresql.org Tue Dec 2 14:12:25 2003 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 14559D1D59B; Tue, 2 Dec 2003 18:12:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 66932-04; Tue, 2 Dec 2003 14:11:51 -0400 (AST) +Received: from THOR.goeci.com (thor.goeci.com [66.28.220.99]) + by svr1.postgresql.org (Postfix) with ESMTP + id 60207D1D930; Tue, 2 Dec 2003 14:11:45 -0400 (AST) +Received: by THOR.goeci.com with Internet Mail Service (5.5.2653.19) + id ; Tue, 2 Dec 2003 13:11:46 -0500 +Message-ID: <2D92FEBFD3BE1346A6C397223A8DD3FC0924C9@THOR.goeci.com> +From: Murthy Kambhampaty +To: "'CLeon@phs.org'" +Cc: pgsql-performance@postgresql.org, pgsql-admin@postgresql.org, + "'linux-xfs@oss.sgi.com'" +Subject: Re: [linux-lvm] RE: [PERFORM] backup/restore - another +Date: Tue, 2 Dec 2003 13:11:45 -0500 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain; + charset="iso-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/12 +X-Sequence-Number: 11520 + +xfs_freeze is a userspace program included in the xfsprogs rpm. It does run +on Redhat 7.3 (the SGI supplied kernels and userspace for RedHat 7.3 are +somewhat dated; I'd suggest patching the 2.4.21 kernel with XFS 1.3.1 +patches and upgrading the userspace programs from the SRPMS). Post to the +linux-xfs mailing list if you need further guidance (lots of people seem to +still run XFS on Redhat 7.3). + +> -----Original Message----- +> From: CLeon@phs.org [mailto:CLeon@phs.org] +> Sent: Thursday, October 30, 2003 12:28 PM +> To: linux-lvm@sistina.com; tgl@sss.pgh.pa.us +> Cc: threshar@torgo.978.org; josh@agliodbs.com; markw@osdl.org; +> pgsql-performance@postgresql.org; pgsql-admin@postgresql.org +> Subject: Re: [linux-lvm] RE: [ADMIN] [PERFORM] backup/restore +> - another +> +> +> Does xfs_freeze work on red hat 7.3? +> +> Cynthia Leon +> +> -----Original Message----- +> From: Murthy Kambhampaty [mailto:murthy.kambhampaty@goeci.com] +> Sent: Friday, October 17, 2003 11:34 AM +> To: 'Tom Lane'; Murthy Kambhampaty +> Cc: 'Jeff'; Josh Berkus; markw@osdl.org; +> pgsql-performance@postgresql.org; linux-lvm@sistina.com; +> pgsql-admin@postgresql.org +> Subject: [linux-lvm] RE: [ADMIN] [PERFORM] backup/restore - another +> area. +> +> +> Friday, October 17, 2003 12:05, Tom Lane +> [mailto:tgl@sss.pgh.pa.us] wrote: +> +> >Murthy Kambhampaty writes: +> >> ... The script handles situations +> >> where (i) the XFS filesystem containing $PGDATA has an +> >external log and (ii) +> >> the postmaster log ($PGDATA/pg_xlog) is written to a +> >filesystem different +> >> than the one containing the $PGDATA folder. +> > +> >It does? How exactly can you ensure snapshot consistency between +> >data files and XLOG if they are on different filesystem +> +> Say, you're setup looks something like this: +> +> mount -t xfs /dev/VG1/LV_data /home/pgdata +> mount -t xfs /dev/VG1/LV_xlog /home/pgdata/pg_xlog +> +> When you want to take the filesystem backup, you do: +> +> Step 1: +> xfs_freeze -f /dev/VG1/LV_xlog +> xfs_freeze -f /dev/VG1/LV_data +> This should finish any checkpoints that were in +> progress, and not +> start any new ones +> till you unfreeze. (writes to an xfs_frozen filesystem +> wait for the +> xfs_freeze -u, +> but reads proceed; see text from xfs_freeze manpage in postcript +> below.) +> +> +> Step2: +> create snapshots of /dev/VG1/LV_xlog and /dev/VG1/LV_xlog +> +> Step 3: +> xfs_freeze -u /dev/VG1/LV_data +> xfs_freeze -u /dev/VG1/LV_xlog +> Unfreezing in this order should assure that checkpoints +> resume where +> they left off, then log writes commence. +> +> +> Step4: +> mount the snapshots taken in Step2 somewhere; e.g. /mnt/snap_data and +> /mnt/snap_xlog. Copy (or rsync or whatever) /mnt/snap_data to +> /mnt/pgbackup/ +> and /mnt/snap_xlog to /mnt/pgbackup/pg_xlog. Upon completion, +> /mnt/pgbackup/ +> looks to the postmaster like /home/pgdata would if the server +> had crashed at +> the moment that Step1 was initiated. As I understand it, +> during recovery +> (startup) the postmaster will roll the database forward to this point, +> "checkpoint-ing" all the transactions that made it into the +> log before the +> crash. +> +> Step5: +> remove the snapshots created in Step2. +> +> The key is +> (i) xfs_freeze allows you to "quiesce" any filesystem at any +> point in time +> and, if I'm not mistaken, the order (LIFO) in which you +> freeze and unfreeze +> the two filesystems: freeze $PGDATA/pg_xlog then $PGDATA; +> unfreeze $PGDATA +> then $PGDATA/pg_xlog. +> (ii) WAL recovery assures consistency after a (file)sytem crash. +> +> Presently, the test server for my backup scripts is set-up +> this way, and the +> backup works flawlessly, AFAICT. (Note that the backup script starts a +> postmaster on the filesystem copy each time, so you get early +> warning of +> problems. Moreover the data in the "production" and "backup" +> copies are +> tested and found to be identical. +> +> Comments? Any suggestions for additional tests? +> +> Thanks, +> Murthy +> +> PS: From the xfs_freeze manpage: +> "xfs_freeze suspends and resumes access to an XFS filesystem (see +> xfs(5)). +> +> xfs_freeze halts new access to the filesystem and creates a +> stable image +> on disk. xfs_freeze is intended to be used with volume managers and +> hardware RAID devices that support the creation of snapshots. +> +> The mount-point argument is the pathname of the directory where the +> filesystem is mounted. The filesystem must be mounted to be +> frozen (see +> mount(8)). +> +> The -f flag requests the specified XFS filesystem to be +> frozen from new +> modifications. When this is selected, all ongoing transactions in the +> filesystem are allowed to complete, new write system calls are halted, +> other calls which modify the filesystem are halted, and all +> dirty data, +> metadata, and log information are written to disk. Any process +> attempting to write to the frozen filesystem will block +> waiting for the +> filesystem to be unfrozen. +> +> Note that even after freezing, the on-disk filesystem can contain +> information on files that are still in the process of unlinking. These +> files will not be unlinked until the filesystem is unfrozen or a clean +> mount of the snapshot is complete. +> +> The -u option is used to un-freeze the filesystem and allow operations +> to continue. Any filesystem modifications that were blocked by the +> freeze are unblocked and allowed to complete." +> +> _______________________________________________ +> linux-lvm mailing list +> linux-lvm@sistina.com +> http://lists.sistina.com/mailman/listinfo/linux-lvm +> read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/ +> +> ============================================================== +> ================ +> --- PRESBYTERIAN HEALTHCARE SERVICES DISCLAIMER --- +> +> This message originates from Presbyterian Healthcare Services +> or one of its +> affiliated organizations. It contains information, which may +> be confidential +> or privileged, and is intended only for the individual or +> entity named above. +> It is prohibited for anyone else to disclose, copy, +> distribute or use the +> contents of this message. All personal messages express views +> solely of the +> sender, which are not to be attributed to Presbyterian +> Healthcare Services or +> any of its affiliated organizations, and may not be +> distributed without this +> disclaimer. If you received this message in error, please notify us +> immediately at postmaster@phs.org. +> ============================================================== +> ================ +> +> +> ---------------------------(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 Tue Dec 2 15:01:39 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 492EDD1BC5C + for ; + Tue, 2 Dec 2003 19:01:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 77317-06 + for ; + Tue, 2 Dec 2003 15:00:49 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 27689D1B445 + for ; + Tue, 2 Dec 2003 15:00:44 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 172AD36E82; Tue, 2 Dec 2003 13:59:57 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1ARFka-0004fq-00; Tue, 02 Dec 2003 13:59:56 -0500 +To: Jared Carr +Cc: Robert Treat , + pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +References: <3FCBB639.10409@89glass.com> <1070385381.24915.8650.camel@camel> + <3FCCD225.8030609@89glass.com> +In-Reply-To: <3FCCD225.8030609@89glass.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 02 Dec 2003 13:59:56 -0500 +Message-ID: <87d6b79har.fsf@stark.dyndns.tv> +Lines: 34 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/28 +X-Sequence-Number: 4888 + +Jared Carr writes: + +> Furthermore noticed that in the following query plan it is doing the +> sequential scan on quotes first, and then doing the sequential on zips. IMHO +> this should be the other way around, since the result set for zips is +> considerably smaller especially give that we are using a where clause to +> limit the number of items returned from zips, so it would seem that it would +> be faster to scan zips then join onto quotes, but perhaps it needs to do the +> sequential scan on both regardless. + +>-> Hash Join (cost=1088.19..56382.58 rows=4058 width=62) (actual time=86.111..1834.682 rows=10193 loops=1) +> Hash Cond: (("outer".zip)::text = ("inner".zip)::text) +> -> Seq Scan on quotes q (cost=0.00..10664.25 rows=336525 width=27) (actual time=0.098..658.905 rows=336963 loops=1) +> -> Hash (cost=1086.90..1086.90 rows=516 width=52) (actual time=85.798..85.798 rows=0 loops=1) +> -> Seq Scan on zips z (cost=0.00..1086.90 rows=516 width=52) (actual time=79.532..84.151 rows=718 loops=1) +> Filter: ((state)::text = 'WA'::text) + +You're misreading it. Hash join is done by reading in one table into a hash +table, then reading the other table looking up entries in the hash table. The +zips are being read into the hash table which is appropriate if it's the +smaller table. + + +> Of course still there is the holy grail of getting it to actually use +> the indexes. :P + +> Merge Cond: ("outer"."?column7?" = "inner"."?column5?") + +Well it looks like you have something strange going on. What data type is +car_id in each table? + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 15:08:54 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DF2CED1B445 + for ; + Tue, 2 Dec 2003 19:08:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 79577-05 + for ; + Tue, 2 Dec 2003 15:08:28 -0400 (AST) +Received: from penguin.goodinassociates.com (unknown [63.150.225.202]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F920D1B437 + for ; + Tue, 2 Dec 2003 15:08:22 -0400 (AST) +Received: from [192.168.14.183] (bluejay.goodinassociates.com + [192.168.14.183]) + by penguin.goodinassociates.com (8.12.8/linuxconf) with ESMTP id + hB2J8Dna011647 + for ; Tue, 2 Dec 2003 13:08:13 -0600 +Subject: Re: cross table indexes or something? +From: Jeremiah Jahn +To: postgres performance +In-Reply-To: <200312011147.51359.josh@agliodbs.com> +References: <1069877651.22346.13.camel@bluejay.goodinassociates.com> + <1069885949.3176.57.camel@fuji.krosing.net> + <1070288942.22346.27.camel@bluejay.goodinassociates.com> + <200312011147.51359.josh@agliodbs.com> +Content-Type: text/plain +Message-Id: <1070392092.22346.43.camel@bluejay.goodinassociates.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) +Date: Tue, 02 Dec 2003 13:08:13 -0600 +Content-Transfer-Encoding: 7bit +X-RAVMilter-Version: 8.4.4(snapshot 20030410) (penguin.goodinassociates.com) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/29 +X-Sequence-Number: 4889 + +Thanks to all, I had already run analyze. But the STATISTICS setting +seems to have worked. I'm just not sure what it did..? Would anyone care +to explain. + + +On Mon, 2003-12-01 at 13:47, Josh Berkus wrote: +> Jeremiah, +> +> > I've attached the Analyze below. I have no idea why the db thinks there +> > is only 1 judge named simth. Is there some what I can inform the DB +> > about this. In actuality, there aren't any judges named smith at the +> > moment, but there are 22K people named smith. +> +> No, Hannu meant that you may need to run the following command: +> +> ANALYZE actor; +> +> ... to update the database statistics on the actors table. That is a +> maintainence task that needs to be run periodically. +> +> If that doesn't fix the bad plan, then the granularity of statistics on the +> full_name column needs updating; I suggest: +> +> ALTER TABLE actor ALTER COLUMN full_name SET STATISTICS 100; +> ANALYZE actor; +> +> And if it's still choosing a slow nested loop, up the stats to 250. +-- +Jeremiah Jahn + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 15:13:52 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E3A99D1B4BC + for ; + Tue, 2 Dec 2003 19:13:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81600-03 + for ; + Tue, 2 Dec 2003 15:13:26 -0400 (AST) +Received: from live (64-35-136-226.gohighspeed.com [64.35.136.226]) + by svr1.postgresql.org (Postfix) with ESMTP id F31FCD1BC54 + for ; + Tue, 2 Dec 2003 15:13:20 -0400 (AST) +Received: from [192.168.254.101] (helo=89glass.com) + by live with esmtp (Exim 3.35 #1 (Debian)) + id 1ARFxb-0004TO-00; Tue, 02 Dec 2003 11:13:23 -0800 +Message-ID: <3FCCE48B.10406@89glass.com> +Date: Tue, 02 Dec 2003 11:14:19 -0800 +From: Jared Carr +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +References: <3FCBB639.10409@89glass.com> + <1070385381.24915.8650.camel@camel> <3FCCD225.8030609@89glass.com> + <87d6b79har.fsf@stark.dyndns.tv> +In-Reply-To: <87d6b79har.fsf@stark.dyndns.tv> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/30 +X-Sequence-Number: 4890 + +Greg Stark wrote: + +> +>> Merge Cond: ("outer"."?column7?" = "inner"."?column5?") +>> +>> +> +>Well it looks like you have something strange going on. What data type is +>car_id in each table? +> +> +> +car_id is a varchar(10) in both tables. + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 15:28:57 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3438CD1B475 + for ; + Tue, 2 Dec 2003 19:28:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84577-01 + for ; + Tue, 2 Dec 2003 15:28:29 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 35932D1B4B3 + for ; + Tue, 2 Dec 2003 15:28:24 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4012391; Tue, 02 Dec 2003 11:29:18 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Jeremiah Jahn , + postgres performance +Subject: Re: cross table indexes or something? +Date: Tue, 2 Dec 2003 11:27:52 -0800 +User-Agent: KMail/1.4.3 +References: <1069877651.22346.13.camel@bluejay.goodinassociates.com> + <200312011147.51359.josh@agliodbs.com> + <1070392092.22346.43.camel@bluejay.goodinassociates.com> +In-Reply-To: <1070392092.22346.43.camel@bluejay.goodinassociates.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200312021127.52839.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/31 +X-Sequence-Number: 4891 + +Jeremiah, + +> Thanks to all, I had already run analyze. But the STATISTICS setting +> seems to have worked. I'm just not sure what it did..? Would anyone care +> to explain. + +The STATISTICS setting improves the granularity of statistics kept by the +query planner on that column; increasing the granularity (i.e. more random +samples) can significantly improve things in cases where you have data whose +distribution is significantly skewed. Certainly whenever you see the query +planner using a slow nestloop becuase of a bad row-return estimate, it is one +of the first things to try. + +Its drawbacks are 4-fold: +1) to keep it working, you will probably need to run ANALZYE more often than +you have been; +2) these ANALYZEs will take longer, and have the annoying side effect of +flooring your CPU while they do; +3) You will have to be sure that your vacuum plan includes vacuuming the +pg_statistic table as the database superuser, as that table will be getting +updated more often. +4) Currently, pg_dump does *not* back up statistics settings. So you will +need to save a script which does this in preparation for having to restore +your database. + +Which is why the stats are set low by default. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Dec 2 16:11:41 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 402B6D1B4B5 + for ; + Tue, 2 Dec 2003 20:11:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89757-07 + for ; + Tue, 2 Dec 2003 16:11:14 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 486D8D1B432 + for ; + Tue, 2 Dec 2003 16:11:08 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 3F34937430; Tue, 2 Dec 2003 15:11:03 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1ARGrP-0005xe-00; Tue, 02 Dec 2003 15:11:03 -0500 +To: Jared Carr +Cc: Greg Stark , pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +References: <3FCBB639.10409@89glass.com> <1070385381.24915.8650.camel@camel> + <3FCCD225.8030609@89glass.com> <87d6b79har.fsf@stark.dyndns.tv> + <3FCCE48B.10406@89glass.com> +In-Reply-To: <3FCCE48B.10406@89glass.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 02 Dec 2003 15:11:02 -0500 +Message-ID: <871xrn9e09.fsf@stark.dyndns.tv> +Lines: 18 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/32 +X-Sequence-Number: 4892 + +Jared Carr writes: + +> Greg Stark wrote: +> +> > +> >> Merge Cond: ("outer"."?column7?" = "inner"."?column5?") +> >> +> > +> >Well it looks like you have something strange going on. What data type is +> > car_id in each table? +> car_id is a varchar(10) in both tables. + +Well for some reason it's being cast to a text to do the merge. + +What version of postgres is this btw? The analyzes look like 7.4? + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 16:28:58 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DDB5D1B452 + for ; + Tue, 2 Dec 2003 20:28:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88959-10 + for ; + Tue, 2 Dec 2003 16:28:28 -0400 (AST) +Received: from live (64-35-136-226.gohighspeed.com [64.35.136.226]) + by svr1.postgresql.org (Postfix) with ESMTP id EF7A3D1B470 + for ; + Tue, 2 Dec 2003 16:28:21 -0400 (AST) +Received: from [192.168.254.101] (helo=89glass.com) + by live with esmtp (Exim 3.35 #1 (Debian)) + id 1ARH89-0004qB-00; Tue, 02 Dec 2003 12:28:21 -0800 +Message-ID: <3FCCF61E.90307@89glass.com> +Date: Tue, 02 Dec 2003 12:29:18 -0800 +From: Jared Carr +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +References: <3FCBB639.10409@89glass.com> + <1070385381.24915.8650.camel@camel> <3FCCD225.8030609@89glass.com> + <87d6b79har.fsf@stark.dyndns.tv> <3FCCE48B.10406@89glass.com> + <871xrn9e09.fsf@stark.dyndns.tv> +In-Reply-To: <871xrn9e09.fsf@stark.dyndns.tv> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/33 +X-Sequence-Number: 4893 + +Greg Stark wrote: + +>Jared Carr writes: +> +> +> +>>Greg Stark wrote: +>> +>> +>> +>>>> Merge Cond: ("outer"."?column7?" = "inner"."?column5?") +>>>> +>>>> +>>>> +>>>Well it looks like you have something strange going on. What data type is +>>>car_id in each table? +>>> +>>> +>>car_id is a varchar(10) in both tables. +>> +>> +> +>Well for some reason it's being cast to a text to do the merge. +> +>What version of postgres is this btw? The analyzes look like 7.4? +> +> +> +Yes, this is 7.4. + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 16:38:23 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 30F3BD1B4B4 + for ; + Tue, 2 Dec 2003 20:38:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94230-05 + for ; + Tue, 2 Dec 2003 16:37:56 -0400 (AST) +Received: from yertle.kcilink.com (yertle.kcilink.com [216.194.193.105]) + by svr1.postgresql.org (Postfix) with ESMTP id 1DB69D1D458 + for ; + Tue, 2 Dec 2003 16:37:50 -0400 (AST) +Received: by yertle.kcilink.com (Postfix, from userid 100) + id 4CE7C2178C; Tue, 2 Dec 2003 15:37:40 -0500 (EST) +From: Vivek Khera +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Message-ID: <16332.63508.196365.801418@yertle.int.kciLink.com> +Date: Tue, 2 Dec 2003 15:37:40 -0500 +To: pgsql-performance@postgresql.org +Subject: autovacuum daemon stops doing work after about an hour +X-Mailer: VM 7.17 under 21.4 (patch 14) "Reasonable Discussion" XEmacs Lucid +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/34 +X-Sequence-Number: 4894 + +I took advantage of last weekend to upgrade from 7.2.4 to 7.4.0 on a +new faster box. + +Now I'm trying to implement pg_autovacuum. It seems to work ok, but +after about an hour or so, it does nothing. The process still is +running, but nothing is sent to the log file. + +I'm running the daemon as distributed with PG 7.4 release as follows: + +pg_autovacuum -d4 -V 0.15 -A 1 -U postgres -L /var/tmp/autovacuum.log -D + +the last few lines of the log are: + +[2003-12-02 11:43:58 AM] VACUUM ANALYZE "public"."msg_recipients" +[2003-12-02 12:24:33 PM] select relfilenode,reltuples,relpages from pg_class where relfilenode=18588239 +[2003-12-02 12:24:33 PM] table name: vkmlm."public"."msg_recipients" +[2003-12-02 12:24:33 PM] relfilenode: 18588239; relisshared: 0 +[2003-12-02 12:24:33 PM] reltuples: 9; relpages: 529132 +[2003-12-02 12:24:33 PM] curr_analyze_count: 1961488; cur_delete_count: 1005040 +[2003-12-02 12:24:33 PM] ins_at_last_analyze: 1961488; del_at_last_vacuum: 1005040 +[2003-12-02 12:24:33 PM] insert_threshold: 509; delete_threshold 1001 +[2003-12-02 12:24:33 PM] Performing: VACUUM ANALYZE "public"."user_list" +[2003-12-02 12:24:33 PM] VACUUM ANALYZE "public"."user_list" +[2003-12-02 12:43:19 PM] select relfilenode,reltuples,relpages from pg_class where relfilenode=18588202 +[2003-12-02 12:43:19 PM] table name: vkmlm."public"."user_list" +[2003-12-02 12:43:19 PM] relfilenode: 18588202; relisshared: 0 +[2003-12-02 12:43:19 PM] reltuples: 9; relpages: 391988 +[2003-12-02 12:43:19 PM] curr_analyze_count: 1159843; cur_delete_count: 1118540 +[2003-12-02 12:43:19 PM] ins_at_last_analyze: 1159843; del_at_last_vacuum: 1118540 +[2003-12-02 12:43:19 PM] insert_threshold: 509; delete_threshold 1001 + +Then it just sits there. I started it at 11:35am, and it is now +3:30pm. + +I did the same last night at about 10:58pm, and it ran and did work until +11:57pm, then sat there until I killed/restarted pg_autovacuum this +morning at 11:35. The process is not using any CPU time. + +I just killed/restarted it and it found work to do on my busy tables +which I'd expect. + +I'm running Postgres 7.4 release on FreeBSD 4.9-RELEASE. + +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +Vivek Khera, Ph.D. Khera Communications, Inc. +Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 +AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ + +From pgsql-performance-owner@postgresql.org Tue Dec 2 17:58:14 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 110BED1D591 + for ; + Tue, 2 Dec 2003 21:58:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06610-04 + for ; + Tue, 2 Dec 2003 17:57:44 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D7C2D1D58F + for ; + Tue, 2 Dec 2003 17:57:34 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 507401E13; Tue, 2 Dec 2003 16:57:27 -0500 (EST) +To: Josh Berkus +Cc: Jeremiah Jahn , + postgres performance +Subject: Re: cross table indexes or something? +From: Neil Conway +In-Reply-To: <200312021127.52839.josh@agliodbs.com> (Josh Berkus's message + of "Tue, 2 Dec 2003 11:27:52 -0800") +References: <1069877651.22346.13.camel@bluejay.goodinassociates.com> + <200312011147.51359.josh@agliodbs.com> + <1070392092.22346.43.camel@bluejay.goodinassociates.com> + <200312021127.52839.josh@agliodbs.com> +Date: Tue, 02 Dec 2003 16:57:27 -0500 +Message-ID: <87llpu288o.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/35 +X-Sequence-Number: 4895 + +Josh Berkus writes: +> 1) to keep it working, you will probably need to run ANALZYE more +> often than you have been; + +I'm not sure why this would be the case -- can you elaborate? + +> 4) Currently, pg_dump does *not* back up statistics settings. + +Yes, it does. + +-Neil + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 18:32:47 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DA75FD1B590 + for ; + Tue, 2 Dec 2003 22:32:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 04544-08 + for ; + Tue, 2 Dec 2003 18:32:12 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 61304D1B4BD + for ; + Tue, 2 Dec 2003 18:32:05 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 15416372CB; Tue, 2 Dec 2003 17:32:12 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1ARJ3z-0006Vz-00; Tue, 02 Dec 2003 17:32:11 -0500 +To: Jared Carr +Cc: Greg Stark , pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +References: <3FCBB639.10409@89glass.com> <1070385381.24915.8650.camel@camel> + <3FCCD225.8030609@89glass.com> <87d6b79har.fsf@stark.dyndns.tv> + <3FCCE48B.10406@89glass.com> <871xrn9e09.fsf@stark.dyndns.tv> + <3FCCF61E.90307@89glass.com> +In-Reply-To: <3FCCF61E.90307@89glass.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 02 Dec 2003 17:32:11 -0500 +Message-ID: <87ptf697h0.fsf@stark.dyndns.tv> +Lines: 62 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/36 +X-Sequence-Number: 4896 + + +Jared Carr writes: + +> Greg Stark wrote: +> +> > Well it looks like you have something strange going on. What data type is +> > car_id in each table? +> > +> car_id is a varchar(10) in both tables. + +Huh. The following shows something strange. It seems joining on two varchars +no longer works well. Instead the optimizer has to convert both columns to +text. + +I know some inter-type comparisons were removed a while ago, but I would not +have thought that would effect varchar-varchar comparisons. I think this is +pretty bad. + + +test=# create table a (x varchar primary key); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "a_pkey" for table "a" +CREATE TABLE +test=# create table b (x varchar primary key); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "b_pkey" for table "b" +CREATE TABLE +test=# select * from a,b where a.x=b.x; + x | x +---+--- +(0 rows) + +test=# explain select * from a,b where a.x=b.x; + QUERY PLAN +------------------------------------------------------------------ + Merge Join (cost=139.66..159.67 rows=1001 width=64) + Merge Cond: ("outer"."?column2?" = "inner"."?column2?") + -> Sort (cost=69.83..72.33 rows=1000 width=32) + Sort Key: (a.x)::text + -> Seq Scan on a (cost=0.00..20.00 rows=1000 width=32) + -> Sort (cost=69.83..72.33 rows=1000 width=32) + Sort Key: (b.x)::text + -> Seq Scan on b (cost=0.00..20.00 rows=1000 width=32) +(8 rows) + +test=# create table a2 (x text primary key); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "a2_pkey" for table "a2" +CREATE TABLE +test=# create table b2 (x text primary key); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "b2_pkey" for table "b2" +CREATE TABLE +test=# explain select * from a2,b2 where a2.x=b2.x; + QUERY PLAN +------------------------------------------------------------------- + Hash Join (cost=22.50..57.51 rows=1001 width=64) + Hash Cond: ("outer".x = "inner".x) + -> Seq Scan on a2 (cost=0.00..20.00 rows=1000 width=32) + -> Hash (cost=20.00..20.00 rows=1000 width=32) + -> Seq Scan on b2 (cost=0.00..20.00 rows=1000 width=32) +(5 rows) + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 18:44:04 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 65E16D1B4D7 + for ; + Tue, 2 Dec 2003 22:43:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 13860-02 + for ; + Tue, 2 Dec 2003 18:43:34 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 42F3CD1B495 + for ; + Tue, 2 Dec 2003 18:43:27 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 1DD4936F21; Tue, 2 Dec 2003 17:43:35 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1ARJF1-0006ZC-00; Tue, 02 Dec 2003 17:43:35 -0500 +To: Greg Stark +Cc: Jared Carr , Greg Stark , + pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +References: <3FCBB639.10409@89glass.com> <1070385381.24915.8650.camel@camel> + <3FCCD225.8030609@89glass.com> <87d6b79har.fsf@stark.dyndns.tv> + <3FCCE48B.10406@89glass.com> <871xrn9e09.fsf@stark.dyndns.tv> + <3FCCF61E.90307@89glass.com> <87ptf697h0.fsf@stark.dyndns.tv> +In-Reply-To: <87ptf697h0.fsf@stark.dyndns.tv> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 02 Dec 2003 17:43:34 -0500 +Message-ID: <87k75e96y1.fsf@stark.dyndns.tv> +Lines: 34 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/37 +X-Sequence-Number: 4897 + + +Greg Stark writes: + +> Huh. The following shows something strange. + +Worse, with enable_hashjoin off it's even more obvious something's broken: + + +test=# set enable_hashjoin = off; +SET +test=# explain select * from a,b where a.x=b.x; + QUERY PLAN +------------------------------------------------------------------ + Merge Join (cost=139.66..159.67 rows=1001 width=64) + Merge Cond: ("outer"."?column2?" = "inner"."?column2?") + -> Sort (cost=69.83..72.33 rows=1000 width=32) + Sort Key: (a.x)::text + -> Seq Scan on a (cost=0.00..20.00 rows=1000 width=32) + -> Sort (cost=69.83..72.33 rows=1000 width=32) + Sort Key: (b.x)::text + -> Seq Scan on b (cost=0.00..20.00 rows=1000 width=32) +(8 rows) + +test=# explain select * from a2,b2 where a2.x=b2.x; + QUERY PLAN +----------------------------------------------------------------------------- + Merge Join (cost=0.00..63.04 rows=1001 width=64) + Merge Cond: ("outer".x = "inner".x) + -> Index Scan using a2_pkey on a2 (cost=0.00..24.00 rows=1000 width=32) + -> Index Scan using b2_pkey on b2 (cost=0.00..24.00 rows=1000 width=32) +(4 rows) + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 19:18:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C8DDD1C951 + for ; + Tue, 2 Dec 2003 23:18:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 09502-10 + for ; + Tue, 2 Dec 2003 19:17:39 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 17647D1B465 + for ; + Tue, 2 Dec 2003 19:17:32 -0400 (AST) +Received: from [66.219.92.2] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4013451; Tue, 02 Dec 2003 15:18:29 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Neil Conway +Subject: Re: cross table indexes or something? +Date: Tue, 2 Dec 2003 15:04:28 -0800 +User-Agent: KMail/1.4.3 +Cc: Jeremiah Jahn , + postgres performance +References: <1069877651.22346.13.camel@bluejay.goodinassociates.com> + <200312021127.52839.josh@agliodbs.com> + <87llpu288o.fsf@mailbox.samurai.com> +In-Reply-To: <87llpu288o.fsf@mailbox.samurai.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200312021504.28020.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/38 +X-Sequence-Number: 4898 + +Neil, + +> > 1) to keep it working, you will probably need to run ANALZYE more +> > often than you have been; +>=20 +> I'm not sure why this would be the case -- can you elaborate? + +For the more granular stats to be useful, they have to be accurate; otherwi= +se=20 +you'll go back to a nestloop as soon as the query planner encounters a valu= +e=20 +that it doens't think is in the table at all.=20 + +>=20 +> > 4) Currently, pg_dump does *not* back up statistics settings. +>=20 +> Yes, it does. + +Oh, good. Was this a 7.4 improvement? I missed that in the changelogs .= +... + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 19:37:42 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 99D50D1B465 + for ; + Tue, 2 Dec 2003 23:37:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21727-07 + for ; + Tue, 2 Dec 2003 19:37:16 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id C7C32D1B437 + for ; + Tue, 2 Dec 2003 19:37:09 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 113FD1EA3; Tue, 2 Dec 2003 18:37:17 -0500 (EST) +To: josh@agliodbs.com +Cc: Jeremiah Jahn , + postgres performance +Subject: Re: cross table indexes or something? +From: Neil Conway +In-Reply-To: <200312021504.28020.josh@agliodbs.com> (Josh Berkus's message + of "Tue, 2 Dec 2003 15:04:28 -0800") +References: <1069877651.22346.13.camel@bluejay.goodinassociates.com> + <200312021127.52839.josh@agliodbs.com> + <87llpu288o.fsf@mailbox.samurai.com> + <200312021504.28020.josh@agliodbs.com> +Date: Tue, 02 Dec 2003 18:37:17 -0500 +Message-ID: <87d6b623ma.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/39 +X-Sequence-Number: 4899 + +Josh Berkus writes: +> Oh, good. Was this a 7.4 improvement? + +No, it was in 7.3 + +-Neil + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 19:51:18 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4771DD1B465 + for ; + Tue, 2 Dec 2003 23:51:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22485-06 + for ; + Tue, 2 Dec 2003 19:50:49 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id DDC00D1B4AA + for ; + Tue, 2 Dec 2003 19:50:41 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hB2Nol19025477; + Tue, 2 Dec 2003 18:50:47 -0500 (EST) +To: Greg Stark +Cc: Jared Carr , pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +In-reply-to: <87ptf697h0.fsf@stark.dyndns.tv> +References: <3FCBB639.10409@89glass.com> <1070385381.24915.8650.camel@camel> + <3FCCD225.8030609@89glass.com> <87d6b79har.fsf@stark.dyndns.tv> + <3FCCE48B.10406@89glass.com> <871xrn9e09.fsf@stark.dyndns.tv> + <3FCCF61E.90307@89glass.com> <87ptf697h0.fsf@stark.dyndns.tv> +Comments: In-reply-to Greg Stark + message dated "02 Dec 2003 17:32:11 -0500" +Date: Tue, 02 Dec 2003 18:50:47 -0500 +Message-ID: <25476.1070409047@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/40 +X-Sequence-Number: 4900 + +Greg Stark writes: +> Huh. The following shows something strange. It seems joining on two varchars +> no longer works well. Instead the optimizer has to convert both columns to +> text. + +Define "no longer works well". varchar doesn't have its own comparison +operators anymore, but AFAIK that makes no difference. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Dec 2 21:33:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D1CED1DA62 + for ; + Wed, 3 Dec 2003 01:33:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 34464-04 + for ; + Tue, 2 Dec 2003 21:33:19 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 098B2D1D400 + for ; + Tue, 2 Dec 2003 21:33:12 -0400 (AST) +Received: from stark.dyndns.tv (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 44A4F36D1B; Tue, 2 Dec 2003 20:33:16 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.dyndns.tv with smtp (Exim 3.36 #1 (Debian)) + id 1ARLtE-00072x-00; Tue, 02 Dec 2003 20:33:16 -0500 +To: Tom Lane +Cc: Greg Stark , Jared Carr , + pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +References: <3FCBB639.10409@89glass.com> <1070385381.24915.8650.camel@camel> + <3FCCD225.8030609@89glass.com> <87d6b79har.fsf@stark.dyndns.tv> + <3FCCE48B.10406@89glass.com> <871xrn9e09.fsf@stark.dyndns.tv> + <3FCCF61E.90307@89glass.com> <87ptf697h0.fsf@stark.dyndns.tv> + <25476.1070409047@sss.pgh.pa.us> +In-Reply-To: <25476.1070409047@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 02 Dec 2003 20:33:15 -0500 +Message-ID: <87znea7kis.fsf@stark.dyndns.tv> +Lines: 34 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/41 +X-Sequence-Number: 4901 + +Tom Lane writes: + +> Define "no longer works well". varchar doesn't have its own comparison +> operators anymore, but AFAIK that makes no difference. + + +Well it seems to completely bar the use of a straight merge join between two +index scans: + + +test=# set enable_seqscan = off; +SET + +test=# explain select * from a,b where a.x=b.x; + QUERY PLAN +--------------------------------------------------------------------------- + Nested Loop (cost=100000000.00..100002188.86 rows=1001 width=64) + -> Seq Scan on a (cost=100000000.00..100000020.00 rows=1000 width=32) + -> Index Scan using b_pkey on b (cost=0.00..2.16 rows=1 width=32) + Index Cond: (("outer".x)::text = (b.x)::text) +(4 rows) + +test=# explain select * from a2,b2 where a2.x=b2.x; + QUERY PLAN +----------------------------------------------------------------------------- + Merge Join (cost=0.00..63.04 rows=1001 width=64) + Merge Cond: ("outer".x = "inner".x) + -> Index Scan using a2_pkey on a2 (cost=0.00..24.00 rows=1000 width=32) + -> Index Scan using b2_pkey on b2 (cost=0.00..24.00 rows=1000 width=32) +(4 rows) + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 21:46:55 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C528D1D3FB + for ; + Wed, 3 Dec 2003 01:46:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 34819-06 + for ; + Tue, 2 Dec 2003 21:46:28 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id C2B90D1D400 + for ; + Tue, 2 Dec 2003 21:46:19 -0400 (AST) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + hB31jNoD000629; Wed, 3 Dec 2003 09:45:23 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <3FCD4170.6060507@familyhealth.com.au> +Date: Wed, 03 Dec 2003 09:50:40 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Josh Berkus +Cc: Jeremiah Jahn , + postgres performance +Subject: Re: cross table indexes or something? +References: <1069877651.22346.13.camel@bluejay.goodinassociates.com> + <200312011147.51359.josh@agliodbs.com> + <1070392092.22346.43.camel@bluejay.goodinassociates.com> + <200312021127.52839.josh@agliodbs.com> +In-Reply-To: <200312021127.52839.josh@agliodbs.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/42 +X-Sequence-Number: 4902 + +> 4) Currently, pg_dump does *not* back up statistics settings. + +Is this a TODO? + +Chris + + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 22:00:59 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A37DBD1D362 + for ; + Wed, 3 Dec 2003 02:00:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31599-07 + for ; + Tue, 2 Dec 2003 22:00:32 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id A3B92D1D94A + for ; + Tue, 2 Dec 2003 22:00:23 -0400 (AST) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + hB31xLoD000771; Wed, 3 Dec 2003 09:59:22 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <3FCD44B7.8000105@familyhealth.com.au> +Date: Wed, 03 Dec 2003 10:04:39 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christopher Kings-Lynne +Cc: Josh Berkus , Jeremiah Jahn , + postgres performance +Subject: Re: cross table indexes or something? +References: <1069877651.22346.13.camel@bluejay.goodinassociates.com> + <200312011147.51359.josh@agliodbs.com> + <1070392092.22346.43.camel@bluejay.goodinassociates.com> + <200312021127.52839.josh@agliodbs.com> + <3FCD4170.6060507@familyhealth.com.au> +In-Reply-To: <3FCD4170.6060507@familyhealth.com.au> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/43 +X-Sequence-Number: 4903 + +>> 4) Currently, pg_dump does *not* back up statistics settings. +> +> +> Is this a TODO? + +Oops - sorry I thought you meant 'pg_dump does not back up statistics'. + Probably still should be a TODO :) + +Chris + + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 22:23:24 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F6BDD1B439 + for ; + Wed, 3 Dec 2003 02:23:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 39445-07 + for ; + Tue, 2 Dec 2003 22:22:57 -0400 (AST) +Received: from necsin-fw.nec.com.sg (necsin-fw.nec.com.sg [203.127.255.1]) + by svr1.postgresql.org (Postfix) with ESMTP id EF097D1CCCD + for ; + Tue, 2 Dec 2003 22:22:47 -0400 (AST) +Received: from kato.nec.com.sg (kato.nec.com.sg [203.127.254.2]) + by necsin-fw.nec.com.sg with ESMTP id hB32MjrE027562 + for ; + Wed, 3 Dec 2003 10:22:46 +0800 (SGT) +Received: from necsind1.nec.com.sg ([203.127.252.220]) + by kato.nec.com.sg with ESMTP id hB32Mju2007470 + for ; + Wed, 3 Dec 2003 10:22:45 +0800 (SGT) +Subject: Minimum hardware requirements for Postgresql db +To: pgsql-performance@postgresql.org +X-Mailer: Lotus Notes Release 5.0.5 September 22, 2000 +Message-ID: +From: CHEWTC@ap.nec.com.sg +Date: Wed, 3 Dec 2003 10:22:51 +0800 +X-MIMETrack: Serialize by Router on NECSIND1/WTC/NECSIN(Release 5.0.12 + |February 13, 2003) at 12/03/2003 10:22:51 AM +MIME-Version: 1.0 +Content-type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=BAYES_30, + NO_REAL_NAME +X-Spam-Level: +X-Archive-Number: 200312/44 +X-Sequence-Number: 4904 + +Dear all + +We would be recommending to our ct. on the use of Postgresql db as compared +to MS SQL Server. We are targetting to use Redhat Linux ES v2.1, Postgresql +v7.3.4 and Postgresql ODBC 07.03.0100. + +We would like to know the minimum specs required for our below target. The +minimum specs is referring to no. of CPU, memory, harddisk capacity, RAID +technology etc. And also the Postgresql parameters and configuration to run +such a system. + +1) We will be running 2 x Postgresql db in the machine. + +2) Total number of connections to be around 100. The connections from the +clients machines will be in ODBC and socket connections. + +3) Estimated number of transactions to be written into the Postgresql db is +around 15000 records per day. + + +The growth rate in terms of number of connections is around 10% per year +and the data retention is kept on average at least for 18 months for the 2 +databases. + +Are there any reference books or sites that I can tap on for the above +requirement? + + +Thank you, +REgards. + + + + + +From pgsql-performance-owner@postgresql.org Tue Dec 2 23:53:57 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D173D1B486 + for ; + Wed, 3 Dec 2003 03:53:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45763-06 + for ; + Tue, 2 Dec 2003 23:53:30 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 05D65D1B44D + for ; + Tue, 2 Dec 2003 23:53:20 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hB33rR19026700; + Tue, 2 Dec 2003 22:53:27 -0500 (EST) +To: Greg Stark +Cc: Jared Carr , pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +In-reply-to: <87znea7kis.fsf@stark.dyndns.tv> +References: <3FCBB639.10409@89glass.com> <1070385381.24915.8650.camel@camel> + <3FCCD225.8030609@89glass.com> <87d6b79har.fsf@stark.dyndns.tv> + <3FCCE48B.10406@89glass.com> <871xrn9e09.fsf@stark.dyndns.tv> + <3FCCF61E.90307@89glass.com> <87ptf697h0.fsf@stark.dyndns.tv> + <25476.1070409047@sss.pgh.pa.us> <87znea7kis.fsf@stark.dyndns.tv> +Comments: In-reply-to Greg Stark + message dated "02 Dec 2003 20:33:15 -0500" +Date: Tue, 02 Dec 2003 22:53:27 -0500 +Message-ID: <26699.1070423607@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/45 +X-Sequence-Number: 4905 + +Greg Stark writes: +> Tom Lane writes: +>> Define "no longer works well". + +> Well it seems to completely bar the use of a straight merge join between two +> index scans: + +Hmmm ... [squints] ... it's not supposed to do that ... [digs] ... yeah, +there's something busted here. Will get back to you ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Dec 3 00:58:38 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C711BD1C941 + for ; + Wed, 3 Dec 2003 04:58:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65370-02 + for ; + Wed, 3 Dec 2003 00:58:05 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id E40EFD1C526 + for ; + Wed, 3 Dec 2003 00:58:04 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hB34w0bI026629 + for ; Wed, 3 Dec 2003 04:58:00 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hB34iPBu024920 + for pgsql-performance@postgresql.org; Wed, 3 Dec 2003 04:44:25 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Minimum hardware requirements for Postgresql db +Date: Tue, 02 Dec 2003 23:44:21 -0500 +Organization: cbbrowne Computing Inc +Lines: 86 +Message-ID: +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:uax1B1VcxmD25T2Hq2Lp1p3MbCc= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/46 +X-Sequence-Number: 4906 + +After takin a swig o' Arrakan spice grog, CHEWTC@ap.nec.com.sg belched out: +> We would be recommending to our ct. on the use of Postgresql db as +> compared to MS SQL Server. We are targetting to use Redhat Linux ES +> v2.1, Postgresql v7.3.4 and Postgresql ODBC 07.03.0100. +> +> We would like to know the minimum specs required for our below +> target. The minimum specs is referring to no. of CPU, memory, +> harddisk capacity, RAID technology etc. And also the Postgresql +> parameters and configuration to run such a system. +> +> 1) We will be running 2 x Postgresql db in the machine. +> +> 2) Total number of connections to be around 100. The connections +> from the clients machines will be in ODBC and socket connections. +> +> 3) Estimated number of transactions to be written into the +> Postgresql db is around 15000 records per day. +> +> The growth rate in terms of number of connections is around 10% per +> year and the data retention is kept on average at least for 18 +> months for the 2 databases. +> +> Are there any reference books or sites that I can tap on for the +> above requirement? + +Perhaps the best reference on detailed performance information is the +"General Bits" documents. + + + + + +These don't point particularly at minimal hardware requirements, but +rather at how to configure the DBMS to best reflect what hardware you +have. But there's some degree to which you can work backwards... + +If you'll need to support 100 concurrent connections, then minimum +shared_buffers is 200, which implies 1600K of RAM required for shared +buffers. + +100 connections probably implies around 100MB of memory for the +backend processes to support the connections. + +That all points to the notion that you'd more than probably get +half-decent performance if you had a mere 256MB of RAM, which is about +$50 worth these days. + +None of it sounds terribly challenging; 15K records per day is 625 +records per hour which represents an INSERT every 6 seconds. Even if +that has to fit into an 8 hour day, that's still not a high number of +transactions per second. That _sounds like_ an application that could +work on old, obsolete hardware. I would imagine that my old Intel +Pentium Pro 200 might cope with the load, in much the way that that +server is more than capable of supporting a web server that would +serve a local workgroup. (I only have 64MB of RAM on that box, which +would be a mite low, but it's an _ancient_ server...) + +The only thing that makes me a little suspicious that there's +something funny about the prescription is your indication of having +100 concurrent users, which is really rather heavyweight in comparison +with the comparatively tiny number of transactions. Is this for some +sort of "departmental application"? Where there's a lot of manual +data entry, so that each user would generate a transaction every 3-4 +minutes? That actually sounds about right... + +Let me suggest that the "cost driver" in this will _not_ be the cost +of the hardware to support the database itself; it will instead be in +having redundant hardware and backup hardware to ensure reliability. + +It would seem likely that just about any sort of modern hardware would +be pretty adequate to the task. You can hardly _buy_ a system with +less than Gigahertz-speed CPUs, 40GB of disk, and 256MB of RAM. +Upgrade to have 2 SCSI disks, 512MB (or more, which is better) of RAM, +and the cost of a suitable system still won't be outrageous. + +Double it, buying a standby server, and the cost still oughtn't be +real scary. And if the application is important, you _should_ have a +standby server, irrespective of what software you might be running. +-- +(reverse (concatenate 'string "moc.enworbbc" "@" "enworbbc")) +http://www3.sympatico.ca/cbbrowne/x.html +Rules of the Evil Overlord #199. "I will not make alliances with those +more powerful than myself. Such a person would only double-cross me in +my moment of glory. I will make alliances with those less powerful +than myself. I will then double-cross them in their moment of glory." + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 13:49:49 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E40E0D1D58F + for ; + Wed, 3 Dec 2003 17:49:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 68173-09 + for ; + Wed, 3 Dec 2003 13:49:15 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id D198BD1B8EA + for ; + Wed, 3 Dec 2003 13:49:11 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hB3Hn719002705; + Wed, 3 Dec 2003 12:49:07 -0500 (EST) +To: Greg Stark , Jared Carr , + pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +In-reply-to: <26699.1070423607@sss.pgh.pa.us> +References: <3FCBB639.10409@89glass.com> <1070385381.24915.8650.camel@camel> + <3FCCD225.8030609@89glass.com> <87d6b79har.fsf@stark.dyndns.tv> + <3FCCE48B.10406@89glass.com> <871xrn9e09.fsf@stark.dyndns.tv> + <3FCCF61E.90307@89glass.com> <87ptf697h0.fsf@stark.dyndns.tv> + <25476.1070409047@sss.pgh.pa.us> <87znea7kis.fsf@stark.dyndns.tv> + <26699.1070423607@sss.pgh.pa.us> +Comments: In-reply-to Tom Lane + message dated "Tue, 02 Dec 2003 22:53:27 -0500" +Date: Wed, 03 Dec 2003 12:49:06 -0500 +Message-ID: <2704.1070473746@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/47 +X-Sequence-Number: 4907 + +> Hmmm ... [squints] ... it's not supposed to do that ... + +The attached patch seems to make it better. + + regards, tom lane + + +Index: src/backend/optimizer/path/costsize.c +=================================================================== +RCS file: /cvsroot/pgsql-server/src/backend/optimizer/path/costsize.c,v +retrieving revision 1.115 +diff -c -r1.115 costsize.c +*** src/backend/optimizer/path/costsize.c 5 Oct 2003 22:44:25 -0000 1.115 +--- src/backend/optimizer/path/costsize.c 3 Dec 2003 17:40:58 -0000 +*************** +*** 1322,1327 **** +--- 1322,1331 ---- + float4 *numbers; + int nnumbers; + ++ /* Ignore any binary-compatible relabeling */ ++ if (var && IsA(var, RelabelType)) ++ var = (Var *) ((RelabelType *) var)->arg; ++ + /* + * Lookup info about var's relation and attribute; if none available, + * return default estimate. +Index: src/backend/optimizer/path/pathkeys.c +=================================================================== +RCS file: /cvsroot/pgsql-server/src/backend/optimizer/path/pathkeys.c,v +retrieving revision 1.53 +diff -c -r1.53 pathkeys.c +*** src/backend/optimizer/path/pathkeys.c 4 Aug 2003 02:40:00 -0000 1.53 +--- src/backend/optimizer/path/pathkeys.c 3 Dec 2003 17:40:58 -0000 +*************** +*** 25,36 **** + #include "optimizer/tlist.h" + #include "optimizer/var.h" + #include "parser/parsetree.h" + #include "parser/parse_func.h" + #include "utils/lsyscache.h" + #include "utils/memutils.h" + + +! static PathKeyItem *makePathKeyItem(Node *key, Oid sortop); + static List *make_canonical_pathkey(Query *root, PathKeyItem *item); + static Var *find_indexkey_var(Query *root, RelOptInfo *rel, + AttrNumber varattno); +--- 25,37 ---- + #include "optimizer/tlist.h" + #include "optimizer/var.h" + #include "parser/parsetree.h" ++ #include "parser/parse_expr.h" + #include "parser/parse_func.h" + #include "utils/lsyscache.h" + #include "utils/memutils.h" + + +! static PathKeyItem *makePathKeyItem(Node *key, Oid sortop, bool checkType); + static List *make_canonical_pathkey(Query *root, PathKeyItem *item); + static Var *find_indexkey_var(Query *root, RelOptInfo *rel, + AttrNumber varattno); +*************** +*** 41,50 **** + * create a PathKeyItem node + */ + static PathKeyItem * +! makePathKeyItem(Node *key, Oid sortop) + { + PathKeyItem *item = makeNode(PathKeyItem); + + item->key = key; + item->sortop = sortop; + return item; +--- 42,70 ---- + * create a PathKeyItem node + */ + static PathKeyItem * +! makePathKeyItem(Node *key, Oid sortop, bool checkType) + { + PathKeyItem *item = makeNode(PathKeyItem); + ++ /* ++ * Some callers pass expressions that are not necessarily of the same ++ * type as the sort operator expects as input (for example when dealing ++ * with an index that uses binary-compatible operators). We must relabel ++ * these with the correct type so that the key expressions will be seen ++ * as equal() to expressions that have been correctly labeled. ++ */ ++ if (checkType) ++ { ++ Oid lefttype, ++ righttype; ++ ++ op_input_types(sortop, &lefttype, &righttype); ++ if (exprType(key) != lefttype) ++ key = (Node *) makeRelabelType((Expr *) key, ++ lefttype, -1, ++ COERCE_DONTCARE); ++ } ++ + item->key = key; + item->sortop = sortop; + return item; +*************** +*** 70,78 **** + { + Expr *clause = restrictinfo->clause; + PathKeyItem *item1 = makePathKeyItem(get_leftop(clause), +! restrictinfo->left_sortop); + PathKeyItem *item2 = makePathKeyItem(get_rightop(clause), +! restrictinfo->right_sortop); + List *newset, + *cursetlink; + +--- 90,100 ---- + { + Expr *clause = restrictinfo->clause; + PathKeyItem *item1 = makePathKeyItem(get_leftop(clause), +! restrictinfo->left_sortop, +! false); + PathKeyItem *item2 = makePathKeyItem(get_rightop(clause), +! restrictinfo->right_sortop, +! false); + List *newset, + *cursetlink; + +*************** +*** 668,674 **** + } + + /* OK, make a sublist for this sort key */ +! item = makePathKeyItem(indexkey, sortop); + cpathkey = make_canonical_pathkey(root, item); + + /* +--- 690,696 ---- + } + + /* OK, make a sublist for this sort key */ +! item = makePathKeyItem(indexkey, sortop, true); + cpathkey = make_canonical_pathkey(root, item); + + /* +*************** +*** 785,791 **** + tle->resdom->restypmod, + 0); + outer_item = makePathKeyItem((Node *) outer_var, +! sub_item->sortop); + /* score = # of mergejoin peers */ + score = count_canonical_peers(root, outer_item); + /* +1 if it matches the proper query_pathkeys item */ +--- 807,814 ---- + tle->resdom->restypmod, + 0); + outer_item = makePathKeyItem((Node *) outer_var, +! sub_item->sortop, +! true); + /* score = # of mergejoin peers */ + score = count_canonical_peers(root, outer_item); + /* +1 if it matches the proper query_pathkeys item */ +*************** +*** 893,899 **** + PathKeyItem *pathkey; + + sortkey = get_sortgroupclause_expr(sortcl, tlist); +! pathkey = makePathKeyItem(sortkey, sortcl->sortop); + + /* + * The pathkey becomes a one-element sublist, for now; +--- 916,922 ---- + PathKeyItem *pathkey; + + sortkey = get_sortgroupclause_expr(sortcl, tlist); +! pathkey = makePathKeyItem(sortkey, sortcl->sortop, true); + + /* + * The pathkey becomes a one-element sublist, for now; +*************** +*** 937,943 **** + { + oldcontext = MemoryContextSwitchTo(GetMemoryChunkContext(restrictinfo)); + key = get_leftop(restrictinfo->clause); +! item = makePathKeyItem(key, restrictinfo->left_sortop); + restrictinfo->left_pathkey = make_canonical_pathkey(root, item); + MemoryContextSwitchTo(oldcontext); + } +--- 960,966 ---- + { + oldcontext = MemoryContextSwitchTo(GetMemoryChunkContext(restrictinfo)); + key = get_leftop(restrictinfo->clause); +! item = makePathKeyItem(key, restrictinfo->left_sortop, false); + restrictinfo->left_pathkey = make_canonical_pathkey(root, item); + MemoryContextSwitchTo(oldcontext); + } +*************** +*** 945,951 **** + { + oldcontext = MemoryContextSwitchTo(GetMemoryChunkContext(restrictinfo)); + key = get_rightop(restrictinfo->clause); +! item = makePathKeyItem(key, restrictinfo->right_sortop); + restrictinfo->right_pathkey = make_canonical_pathkey(root, item); + MemoryContextSwitchTo(oldcontext); + } +--- 968,974 ---- + { + oldcontext = MemoryContextSwitchTo(GetMemoryChunkContext(restrictinfo)); + key = get_rightop(restrictinfo->clause); +! item = makePathKeyItem(key, restrictinfo->right_sortop, false); + restrictinfo->right_pathkey = make_canonical_pathkey(root, item); + MemoryContextSwitchTo(oldcontext); + } +Index: src/backend/utils/cache/lsyscache.c +=================================================================== +RCS file: /cvsroot/pgsql-server/src/backend/utils/cache/lsyscache.c,v +retrieving revision 1.108 +diff -c -r1.108 lsyscache.c +*** src/backend/utils/cache/lsyscache.c 4 Oct 2003 18:22:59 -0000 1.108 +--- src/backend/utils/cache/lsyscache.c 3 Dec 2003 17:40:58 -0000 +*************** +*** 465,470 **** +--- 465,493 ---- + } + + /* ++ * op_input_types ++ * ++ * Returns the left and right input datatypes for an operator ++ * (InvalidOid if not relevant). ++ */ ++ void ++ op_input_types(Oid opno, Oid *lefttype, Oid *righttype) ++ { ++ HeapTuple tp; ++ Form_pg_operator optup; ++ ++ tp = SearchSysCache(OPEROID, ++ ObjectIdGetDatum(opno), ++ 0, 0, 0); ++ if (!HeapTupleIsValid(tp)) /* shouldn't happen */ ++ elog(ERROR, "cache lookup failed for operator %u", opno); ++ optup = (Form_pg_operator) GETSTRUCT(tp); ++ *lefttype = optup->oprleft; ++ *righttype = optup->oprright; ++ ReleaseSysCache(tp); ++ } ++ ++ /* + * op_mergejoinable + * + * Returns the left and right sort operators corresponding to a +Index: src/include/utils/lsyscache.h +=================================================================== +RCS file: /cvsroot/pgsql-server/src/include/utils/lsyscache.h,v +retrieving revision 1.82 +diff -c -r1.82 lsyscache.h +*** src/include/utils/lsyscache.h 4 Oct 2003 18:22:59 -0000 1.82 +--- src/include/utils/lsyscache.h 3 Dec 2003 17:41:00 -0000 +*************** +*** 40,45 **** +--- 40,46 ---- + extern bool opclass_is_hash(Oid opclass); + extern RegProcedure get_opcode(Oid opno); + extern char *get_opname(Oid opno); ++ extern void op_input_types(Oid opno, Oid *lefttype, Oid *righttype); + extern bool op_mergejoinable(Oid opno, Oid *leftOp, Oid *rightOp); + extern void op_mergejoin_crossops(Oid opno, Oid *ltop, Oid *gtop, + RegProcedure *ltproc, RegProcedure *gtproc); + +From pgsql-performance-owner@postgresql.org Wed Dec 3 14:41:59 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3F618D1C976 + for ; + Wed, 3 Dec 2003 18:41:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73995-09 + for ; + Wed, 3 Dec 2003 14:41:27 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 46C2BD1B4E1 + for ; + Wed, 3 Dec 2003 14:41:22 -0400 (AST) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id hB3IdZDW011329; + Wed, 3 Dec 2003 11:39:35 -0700 (MST) +Date: Wed, 3 Dec 2003 11:22:47 -0700 (MST) +From: "scott.marlowe" +To: +Cc: +Subject: Re: Minimum hardware requirements for Postgresql db +In-Reply-To: +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/49 +X-Sequence-Number: 4909 + +On Wed, 3 Dec 2003 CHEWTC@ap.nec.com.sg wrote: + +> Dear all +> +> We would be recommending to our ct. on the use of Postgresql db as compared +> to MS SQL Server. We are targetting to use Redhat Linux ES v2.1, Postgresql +> v7.3.4 and Postgresql ODBC 07.03.0100. +> +> We would like to know the minimum specs required for our below target. The +> minimum specs is referring to no. of CPU, memory, harddisk capacity, RAID +> technology etc. And also the Postgresql parameters and configuration to run +> such a system. +> +> 1) We will be running 2 x Postgresql db in the machine. +> +> 2) Total number of connections to be around 100. The connections from the +> clients machines will be in ODBC and socket connections. +> +> 3) Estimated number of transactions to be written into the Postgresql db is +> around 15000 records per day. +> +> +> The growth rate in terms of number of connections is around 10% per year +> and the data retention is kept on average at least for 18 months for the 2 +> databases. +> +> Are there any reference books or sites that I can tap on for the above +> requirement? + +Like another poster pointed out, this is a walk in the park for +postgresql. My workstation (1.1GHz celeron, 40 gig IDE drive, 512 Meg +memory) could handle this load while still being my workstation. +:-) + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 14:27:33 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 58B54D1B438 + for ; + Wed, 3 Dec 2003 18:27:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 77358-02 + for ; + Wed, 3 Dec 2003 14:26:53 -0400 (AST) +Received: from live (64-35-136-226.gohighspeed.com [64.35.136.226]) + by svr1.postgresql.org (Postfix) with ESMTP id E60DFD1D30D + for ; + Wed, 3 Dec 2003 14:26:51 -0400 (AST) +Received: from [192.168.254.101] (helo=89glass.com) + by live with esmtp (Exim 3.35 #1 (Debian)) + id 1ARbhc-0001Gw-00; Wed, 03 Dec 2003 10:26:20 -0800 +Message-ID: <3FCE2B08.6090606@89glass.com> +Date: Wed, 03 Dec 2003 10:27:20 -0800 +From: Jared Carr +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Greg Stark , pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +References: <3FCBB639.10409@89glass.com> <1070385381.24915.8650.camel@camel> + <3FCCD225.8030609@89glass.com> <87d6b79har.fsf@stark.dyndns.tv> + <3FCCE48B.10406@89glass.com> <871xrn9e09.fsf@stark.dyndns.tv> + <3FCCF61E.90307@89glass.com> <87ptf697h0.fsf@stark.dyndns.tv> + <25476.1070409047@sss.pgh.pa.us> <87znea7kis.fsf@stark.dyndns.tv> + <26699.1070423607@sss.pgh.pa.us> <2704.1070473746@sss.pgh.pa.us> +In-Reply-To: <2704.1070473746@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/48 +X-Sequence-Number: 4908 + +Tom Lane wrote: + +>>Hmmm ... [squints] ... it's not supposed to do that ... +>> +>> +> +>The attached patch seems to make it better. +> +> +> +The patch definitely makes things more consistent...unfortunately it is +more +consistent toward the slower execution times. Of course I am looking at +this +simply from a straight performance standpoint and not a viewpoint of +what *should* +be happening. At any rate here are the query plans with the various +settings. + +Default Settings: + + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=15290.20..15300.34 rows=4058 width=80) (actual +time=2944.650..2951.292 rows=4672 loops=1) + Sort Key: q.date_time + -> Hash Join (cost=13529.79..15046.99 rows=4058 width=80) (actual +time=2678.033..2873.475 rows=4672 loops=1) + Hash Cond: (("outer".car_id)::text = ("inner".car_id)::text) + -> Seq Scan on cars c (cost=0.00..227.01 rows=9401 width=37) +(actual time=19.887..50.971 rows=9401 loops=1) + -> Hash (cost=13475.65..13475.65 rows=4058 width=62) (actual +time=2643.377..2643.377 rows=0 loops=1) + -> Hash Join (cost=1088.19..13475.65 rows=4058 +width=62) (actual time=86.739..2497.558 rows=10284 loops=1) + Hash Cond: (("outer".zip)::text = ("inner".zip)::text) + -> Seq Scan on quotes q (cost=0.00..10664.25 +rows=336525 width=27) (actual time=0.223..1308.561 rows=340694 loops=1) + -> Hash (cost=1086.90..1086.90 rows=516 width=52) +(actual time=84.329..84.329 rows=0 loops=1) + -> Seq Scan on zips z (cost=0.00..1086.90 +rows=516 width=52) (actual time=78.363..82.901 rows=718 loops=1) + Filter: ((state)::text = 'WA'::text) + Total runtime: 2955.366 ms + +SET enable_seqscan=false; + + +QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=103557.82..103567.97 rows=4058 width=80) (actual +time=1015.122..1021.750 rows=4673 loops=1) + Sort Key: q.date_time + -> Merge Join (cost=102734.94..103314.61 rows=4058 width=80) +(actual time=802.908..941.520 rows=4673 loops=1) + Merge Cond: ("outer"."?column7?" = ("inner".car_id)::text) + -> Sort (cost=102734.94..102745.08 rows=4058 width=62) +(actual time=802.112..812.755 rows=4827 loops=1) + Sort Key: (q.car_id)::text + -> Nested Loop (cost=0.00..102491.73 rows=4058 +width=62) (actual time=148.535..555.653 rows=10285 loops=1) + -> Index Scan using zip_zips_index on zips z +(cost=0.00..1272.69 rows=516 width=52) (actual time=148.243..155.577 +rows=718 loops=1) + Filter: ((state)::text = 'WA'::text) + -> Index Scan using zip_quotes_index on quotes q +(cost=0.00..195.55 rows=48 width=27) (actual time=0.042..0.454 rows=14 +loops=718) + Index Cond: (("outer".zip)::text = (q.zip)::text) + -> Index Scan using cars_car_id_btree_index on cars c +(cost=0.00..506.87 rows=9401 width=37) (actual time=0.220..46.910 +rows=12019 loops=1) + Total runtime: 1027.339 ms + +There is still a 3x decrease in execution time here, but it is overall +slower than before the +patch was applied. + +SET enable_mergejoin = false; AND SET enable_seqscan = false; + + +QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=104586.15..104596.29 rows=4058 width=80) (actual +time=887.719..894.358 rows=4673 loops=1) + Sort Key: q.date_time + -> Hash Join (cost=102545.88..104342.94 rows=4058 width=80) (actual +time=593.710..815.541 rows=4673 loops=1) + Hash Cond: (("outer".car_id)::text = ("inner".car_id)::text) + -> Index Scan using cars_car_id_btree_index on cars c +(cost=0.00..506.87 rows=9401 width=37) (actual time=0.182..37.306 +rows=9401 loops=1) + -> Hash (cost=102491.73..102491.73 rows=4058 width=62) +(actual time=593.040..593.040 rows=0 loops=1) + -> Nested Loop (cost=0.00..102491.73 rows=4058 +width=62) (actual time=146.647..551.975 rows=10285 loops=1) + -> Index Scan using zip_zips_index on zips z +(cost=0.00..1272.69 rows=516 width=52) (actual time=146.378..153.767 +rows=718 loops=1) + Filter: ((state)::text = 'WA'::text) + -> Index Scan using zip_quotes_index on quotes q +(cost=0.00..195.55 rows=48 width=27) (actual time=0.044..0.464 rows=14 +loops=718) + Index Cond: (("outer".zip)::text = (q.zip)::text) + Total runtime: 898.438 ms + +Again a decrease in execution time. + +On the other hand: +SET enable_hasdjoin=false; + + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------ + Sort (cost=62829.86..62840.00 rows=4058 width=80) (actual +time=11368.025..11374.629 rows=4673 loops=1) + Sort Key: q.date_time + -> Merge Join (cost=62006.97..62586.65 rows=4058 width=80) (actual +time=11188.371..11295.156 rows=4673 loops=1) + Merge Cond: (("outer".car_id)::text = "inner"."?column7?") + -> Index Scan using cars_car_id_btree_index on cars c +(cost=0.00..506.87 rows=9401 width=37) (actual time=0.167..37.728 +rows=9401 loops=1) + -> Sort (cost=62006.97..62017.12 rows=4058 width=62) (actual +time=11187.581..11196.343 rows=4827 loops=1) + Sort Key: (q.car_id)::text + -> Merge Join (cost=60037.99..61763.76 rows=4058 +width=62) (actual time=10893.572..10975.658 rows=10285 loops=1) + Merge Cond: ("outer"."?column6?" = "inner"."?column4?") + -> Sort (cost=1110.15..1111.44 rows=516 width=52) +(actual time=86.679..87.166 rows=718 loops=1) + Sort Key: (z.zip)::text + -> Seq Scan on zips z (cost=0.00..1086.90 +rows=516 width=52) (actual time=79.023..83.921 rows=718 loops=1) + Filter: ((state)::text = 'WA'::text) + -> Sort (cost=58927.84..59769.15 rows=336525 +width=27) (actual time=9848.479..10319.275 rows=340426 loops=1) + Sort Key: (q.zip)::text + -> Seq Scan on quotes q +(cost=0.00..10664.25 rows=336525 width=27) (actual time=0.227..2171.917 +rows=340740 loops=1) + Total runtime: 11408.120 ms + +Which really is not that surprising. + +And Finally: +set enable_hashjoin=false; enable_seqscan=false; + + +QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=103557.82..103567.97 rows=4058 width=80) (actual +time=1206.168..1212.880 rows=4673 loops=1) + Sort Key: q.date_time + -> Merge Join (cost=102734.94..103314.61 rows=4058 width=80) +(actual time=809.448..949.110 rows=4673 loops=1) + Merge Cond: ("outer"."?column7?" = ("inner".car_id)::text) + -> Sort (cost=102734.94..102745.08 rows=4058 width=62) +(actual time=808.660..819.317 rows=4827 loops=1) + Sort Key: (q.car_id)::text + -> Nested Loop (cost=0.00..102491.73 rows=4058 +width=62) (actual time=151.457..559.886 rows=10285 loops=1) + -> Index Scan using zip_zips_index on zips z +(cost=0.00..1272.69 rows=516 width=52) (actual time=151.179..158.375 +rows=718 loops=1) + Filter: ((state)::text = 'WA'::text) + -> Index Scan using zip_quotes_index on quotes q +(cost=0.00..195.55 rows=48 width=27) (actual time=0.042..0.455 rows=14 +loops=718) + Index Cond: (("outer".zip)::text = (q.zip)::text) + -> Index Scan using cars_car_id_btree_index on cars c +(cost=0.00..506.87 rows=9401 width=37) (actual time=0.213..47.307 +rows=12019 loops=1) + Total runtime: 1218.459 ms + + +Anyway, thanks for the attention to this issue. And I hope that this +helps some. + +Jared + + + + +From pgsql-performance-owner@postgresql.org Tue Dec 9 15:57:27 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 19B5AD1B438 + for ; + Wed, 3 Dec 2003 18:30:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69540-10 + for ; + Wed, 3 Dec 2003 14:29:53 -0400 (AST) +Received: from uhh.alcaron.ee (uhh.alcaron.ee [194.204.62.169]) + by svr1.postgresql.org (Postfix) with ESMTP id 28EC2D1B432 + for ; + Wed, 3 Dec 2003 14:29:52 -0400 (AST) +Received: from iff by uhh.alcaron.ee with local + id 1ARbl2-0000uE-00; Wed, 03 Dec 2003 20:29:52 +0200 +Date: Wed, 3 Dec 2003 20:29:52 +0200 +To: pgsql-performance@postgresql.org +Subject: Slow UPDATE, INSERT OK +Message-ID: <20031203182952.GA3097@alcaron.ee> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.3.28i +From: Ivar Zarans +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/161 +X-Sequence-Number: 5021 + +Hello! + +I am relative newcomer to SQL and PostgreSQL world, so please forgive me +if this question is stupid. + +I am experiencing strange behaviour, where simple UPDATE of one field is +very slow, compared to INSERT into table with multiple indexes. I have +two tables - one with raw data records (about 24000), where one field +contains status information (varchar(10)). First table has no indexes, +only primary key (recid). Second table contains processed records - some +fields are same as first table, others are calculated during processing. +Records are processed by Python script, which uses PyPgSQL for PostgreSQL +access. + +Processing is done by selecting all records from table1 where status +matches certain criteria (import). Each record is processed and results +are inserted into table2, after inserting status field on same record in +table1 is updated with new value (done). Update statement itself is +extremely simple: "update table1 set status = 'done' where recid = ..." + +Most interesting is, that insert takes 0.004 seconds in average, but +update takes 0.255 seconds in average. Processing of 24000 records took +around 1 hour 20 minutes. + +Then i changed processing logic not to update every record in table1 +after processing. Instead i did insert recid value into temporary table +and updated records in table1 after all records were processed and +inserted into table2: +UPDATE table1 SET Status = 'done' WHERE recid IN (SELECT recid FROM temptable) + +This way i got processing time of 24000 records down to about 16 minutes. +About 13 minutes from this took last UPDATE statement. + +Why is UPDATE so slow compared to INSERT? I would expect more or less +similar performance, or slower on insert since table2 has four indexes +in addition to primary key, table1 has only primary key, which is used +on update. Am i doing something wrong or is this normal? + +I am using PostgreSQL 7.3.4, Debian/GNU Linux 3.0 (Woody), +kernel 2.4.21, Python 2.3.2, PyPgSQL 2.4 + +-- +Ivar Zarans + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 15:24:07 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 48DBAD1B445 + for ; + Wed, 3 Dec 2003 19:24:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85877-03 + for ; + Wed, 3 Dec 2003 15:23:35 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 50678D1B446 + for ; + Wed, 3 Dec 2003 15:23:34 -0400 (AST) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 23E5236CB8; Wed, 3 Dec 2003 14:23:33 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1ARcaz-00021S-00; Wed, 03 Dec 2003 14:23:33 -0500 +To: "scott.marlowe" +Cc: , +Subject: Re: Minimum hardware requirements for Postgresql db +References: +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 03 Dec 2003 14:23:32 -0500 +Message-ID: <87smk166yz.fsf@stark.dyndns.tv> +Lines: 26 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/50 +X-Sequence-Number: 4910 + + +"scott.marlowe" writes: + +> > 3) Estimated number of transactions to be written into the Postgresql db is +> > around 15000 records per day. +> > +> > The growth rate in terms of number of connections is around 10% per year +> > and the data retention is kept on average at least for 18 months for the 2 +> > databases. + +> Like another poster pointed out, this is a walk in the park for +> postgresql. My workstation (1.1GHz celeron, 40 gig IDE drive, 512 Meg +> memory) could handle this load while still being my workstation. + +Well there's some info missing. Like what would you actually be _doing_ with +these data? + +15,000 inserts per day is nothing. But after 18 months that's over 5M records +not including the 10% growth rate. 5M records isn't really all that much but +it's enough that it's possible to write slow queries against it. + +If you're doing big batch updates or complex reports against the data that +will be more interesting than the inserts. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 15:32:07 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 87851D1B4E0 + for ; + Wed, 3 Dec 2003 19:32:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 87175-03 + for ; + Wed, 3 Dec 2003 15:31:35 -0400 (AST) +Received: from localhost.localdomain (dsl093-038-087.pdx1.dsl.speakeasy.net + [66.93.38.87]) + by svr1.postgresql.org (Postfix) with ESMTP id 22D19D1BC5C + for ; + Wed, 3 Dec 2003 15:31:34 -0400 (AST) +Received: from commandprompt.com (tacodog [127.0.0.1]) + by localhost.localdomain (8.12.8/8.12.8) with ESMTP id hB3JVQFj027627 + for ; Wed, 3 Dec 2003 11:31:27 -0800 +Message-ID: <3FCE3A0E.8050206@commandprompt.com> +Date: Wed, 03 Dec 2003 11:31:26 -0800 +From: Al Hulaton +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; + rv:1.5) Gecko/20031014 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Minimum hardware requirements for Postgresql db +References: +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/51 +X-Sequence-Number: 4911 + +> 1) We will be running 2 x Postgresql db in the machine. +> +> 2) Total number of connections to be around 100. The connections from the +> clients machines will be in ODBC and socket connections. +> +> 3) Estimated number of transactions to be written into the Postgresql db is +> around 15000 records per day. + +Assuming this server will be dedicated to PostgreSQL only, the needs +outlined above are modest. + +As was pointed out in other posts, a simple sub-ghz machine with 512mb +of ram is more than enough, but I'd slap on a gig only because RAM is +cheaper now. If the database on this server is crucial, I'd look at +setting up a UPS, RAID (at this level, even software-based RAID will do +fine, RAID 5 preferably) and investing in a backup/replicator solution. + +-- +Best, +Al Hulaton | Sr. Account Engineer | Command Prompt, Inc. +503.667.4564 | ahulaton@commandprompt.com +Home of Mammoth Replicator for PostgreSQL +Managed PostgreSQL, Linux services and consulting +Read and Search O'Reilly's 'Practical PostgreSQL' at +http://www.commandprompt.com + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 15:33:22 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D9FAD1B445 + for ; + Wed, 3 Dec 2003 19:33:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88160-01 + for ; + Wed, 3 Dec 2003 15:32:51 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 3681FD1B4D6 + for ; + Wed, 3 Dec 2003 15:32:50 -0400 (AST) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id E4EAF37372; Wed, 3 Dec 2003 14:32:50 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1ARcjy-00022F-00; Wed, 03 Dec 2003 14:32:50 -0500 +To: Jared Carr +Cc: Tom Lane , Greg Stark , + pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +References: <3FCBB639.10409@89glass.com> <1070385381.24915.8650.camel@camel> + <3FCCD225.8030609@89glass.com> <87d6b79har.fsf@stark.dyndns.tv> + <3FCCE48B.10406@89glass.com> <871xrn9e09.fsf@stark.dyndns.tv> + <3FCCF61E.90307@89glass.com> <87ptf697h0.fsf@stark.dyndns.tv> + <25476.1070409047@sss.pgh.pa.us> <87znea7kis.fsf@stark.dyndns.tv> + <26699.1070423607@sss.pgh.pa.us> <2704.1070473746@sss.pgh.pa.us> + <3FCE2B08.6090606@89glass.com> +In-Reply-To: <3FCE2B08.6090606@89glass.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 03 Dec 2003 14:32:50 -0500 +Message-ID: <87k75d66jh.fsf@stark.dyndns.tv> +Lines: 17 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/52 +X-Sequence-Number: 4912 + +Jared Carr writes: + +> The patch definitely makes things more consistent...unfortunately it is more +> consistent toward the slower execution times. Of course I am looking at this +> simply from a straight performance standpoint and not a viewpoint of what +> *should* be happening. At any rate here are the query plans with the various +> settings. + +The optimizer seems to be at least considering reasonable plans now. It seems +from the estimates that you need to rerun analyze. You might try "vacuum full +analyze" to be sure. + +Also, you might try raising effective_cache_size and/or lowering +random_page_size (it looks like something around 2 might help). + +-- +greg + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 17:23:35 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EB37FD1B470 + for ; + Wed, 3 Dec 2003 21:23:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 04772-02 + for ; + Wed, 3 Dec 2003 17:23:03 -0400 (AST) +Received: from web.opentransfer.com (unknown [69.49.227.40]) + by svr1.postgresql.org (Postfix) with ESMTP id D2511D1D0AE + for ; + Wed, 3 Dec 2003 17:22:45 -0400 (AST) +Received: (from httpd@localhost) + by web.opentransfer.com (8.11.6/8.11.6) id hB3LMRX17342 + for pgsql-performance@postgresql.org; Wed, 3 Dec 2003 15:22:27 -0600 +X-Authentication-Warning: web.opentransfer.com: httpd set sender to + erik@norvelle.net using -f +Received: from 212.21.224.151 ( [212.21.224.151]) + as user erik@norvelle.net@69.49.238.2 by 69.49.227.23 with HTTP; + Wed, 3 Dec 2003 15:22:27 -0600 +Message-ID: <1070486547.3fce54135a65d@69.49.227.23> +Date: Wed, 3 Dec 2003 15:22:27 -0600 +From: erik@norvelle.net +To: pgsql-performance@postgresql.org +Subject: Re: Update performance ... Recommended configuration changes? +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.1 +X-Originating-IP: 212.21.224.151 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/53 +X-Sequence-Number: 4913 + + +Thanks to Greg Stark, Tom Lane and Stephan Szabo for their advice on +rewriting my query... the revised query plan claims it should only take +about half the time my original query did. + +Now for a somewhat different question: How might I improve my DB +performance by adjusting the various parameters in postgresql.conf and +kernel config? Again, TKA. + +Here's what I've currently got (hardware, kernel config. and +postgresql.conf) + +Hardware: Mac iBook, G3 900Mhz, 640MB memory (This is my research machine :p +) +OS: OS X 10.2.6 +Postgresql version: 7.3.2 +Kernel Config: + sysctl -w kern.sysv.shmmax=4194304 + sysctl -w kern.sysv.shmmin=1 + sysctl -w kern.sysv.shmmni=32 + sysctl -w kern.sysv.shmseg=8 + sysctl -w kern.sysv.shmall=1024 + +========================= Snip of postgresql.conf ================= + +# +# Shared Memory Size +# +shared_buffers = 128 # min max_connections*2 or 16, 8KB each +max_fsm_relations = 2000 # min 10, fsm is free space map, ~40 bytes +max_fsm_pages = 20000 # min 1000, fsm is free space map, ~6 bytes +max_locks_per_transaction = 128 # min 10 +wal_buffers = 16 # min 4, typically 8KB each +# +# Non-shared Memory Sizes +# +sort_mem = 65535 # min 64, size in KB +vacuum_mem = 8192 # min 1024, size in KB + +# +# Write-ahead log (WAL) +# +#checkpoint_segments = 3 # in logfile segments, min 1, 16MB each +#checkpoint_timeout = 300 # range 30-3600, in seconds +# +#commit_delay = 0 # range 0-100000, in microseconds +#commit_siblings = 5 # range 1-1000 +# +fsync = false +#wal_sync_method = fsync # the default varies across platforms: +# # fsync, fdatasync, open_sync, or open_datasync +#wal_debug = 0 # range 0-16 + +========================== End Snip ======================= + +Saludos, +Erik Norvelle + + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 17:33:42 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C9C9D1B4B3 + for ; + Wed, 3 Dec 2003 21:33:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03934-09 + for ; + Wed, 3 Dec 2003 17:33:10 -0400 (AST) +Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) + by svr1.postgresql.org (Postfix) with SMTP id 5A272D1D306 + for ; + Wed, 3 Dec 2003 17:32:51 -0400 (AST) +Received: (qmail 2744 invoked from network); 3 Dec 2003 21:33:22 -0000 +Received: from unknown (HELO ?192.168.1.199?) (134.22.70.148) + by 205.178.180.9 with SMTP; 3 Dec 2003 21:33:22 -0000 +Subject: Re: Update performance ... Recommended configuration +From: Rod Taylor +To: erik@norvelle.net +Cc: Postgresql Performance +In-Reply-To: <1070486547.3fce54135a65d@69.49.227.23> +References: <1070486547.3fce54135a65d@69.49.227.23> +Content-Type: text/plain +Message-Id: <1070487190.92431.57.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Wed, 03 Dec 2003 16:33:10 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/54 +X-Sequence-Number: 4914 + +> shared_buffers = 128 # min max_connections*2 or 16, 8KB each + +Try 1500. + +> sort_mem = 65535 # min 64, size in KB + +I'd pull this in. You only have 640MB ram, which means about 8 large +sorts to swap. + +How about 16000? + +> fsync = false + +I presume you understand the risks involved with this setting and +dataloss. + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 17:41:18 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 49BA0D1CCCF + for ; + Wed, 3 Dec 2003 21:41:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06226-06 + for ; + Wed, 3 Dec 2003 17:40:48 -0400 (AST) +Received: from swan.mail.pas.earthlink.net (swan.mail.pas.earthlink.net + [207.217.120.123]) + by svr1.postgresql.org (Postfix) with ESMTP id 57283D1BC5C + for ; + Wed, 3 Dec 2003 17:40:46 -0400 (AST) +Received: from dpc6682164065.direcpc.com ([66.82.164.65] helo=earthlink.net) + by swan.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) + id 1AReji-0002nu-00 + for pgsql-performance@postgresql.org; Wed, 03 Dec 2003 13:40:44 -0800 +Message-ID: <3FCE5855.5040403@earthlink.net> +Date: Wed, 03 Dec 2003 16:40:37 -0500 +From: Sean Shanny +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Subject: Has anyone run on the new G5 yet +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/55 +X-Sequence-Number: 4915 + +To all, + +We are building a data warehouse composed of essentially click stream +data. The DB is growing fairly quickly as to be expected, currently at +90GB for one months data. The idea is to keep 6 months detailed data on +line and then start aggregating older data to summary tables. We have 2 +fact tables currently, one with about 68 million rows and the other with +about 210 million rows. Numerous dimension tables ranging from a dozen +rows to millions. + +We are currently running on a Dell 2650 with 2 Xeon 2.8 processors in +hyper-threading mode, 4GB of ram, and 5 SCSI drives in a RAID 0, Adaptec +PERC3/Di, configuration. I believe they are 10k drives. Files system +is EXT3. We are running RH9 Linux kernel 2.4.20-20.9SMP with bigmem +turned on. This box is used only for the warehouse. All the ETL work +is done on this machine as well. DB version is postgreSQL 7.4. + +We are running into issues with IO saturation obviously. Since this +thing is only going to get bigger we are looking for some advice on how +to accommodate DB's of this size. + +First question is do we gain anything by moving the RH Enterprise +version of Linux in terms of performance, mainly in the IO realm as we +are not CPU bound at all? Second and more radical, has anyone run +postgreSQL on the new Apple G5 with an XRaid system? This seems like a +great value combination. Fast CPU, wide bus, Fibre Channel IO, 2.5TB +all for ~17k. + +I keep see references to terabyte postgreSQL installations, I was +wondering if anyone on this list is in charge of one of those and can +offer some advice on how to position ourselves hardware wise. + +Thanks. + +--sean + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 17:54:58 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 83918D1B486 + for ; + Wed, 3 Dec 2003 21:54:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 12089-01 + for ; + Wed, 3 Dec 2003 17:54:26 -0400 (AST) +Received: from swan.mail.pas.earthlink.net (swan.mail.pas.earthlink.net + [207.217.120.123]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F683D1B432 + for ; + Wed, 3 Dec 2003 17:54:24 -0400 (AST) +Received: from dpc6682164065.direcpc.com ([66.82.164.65] helo=earthlink.net) + by swan.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) + id 1AReww-0006mH-00; Wed, 03 Dec 2003 13:54:25 -0800 +Message-ID: <3FCE5B85.9000406@earthlink.net> +Date: Wed, 03 Dec 2003 16:54:13 -0500 +From: Sean Shanny +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Cc: Sean Shanny +Subject: Re: Has anyone run on the new G5 yet +References: <3FCE5855.5040403@earthlink.net> +In-Reply-To: <3FCE5855.5040403@earthlink.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/56 +X-Sequence-Number: 4916 + +I should also add that we have already done a ton of tuning based on the +archives of this list so we are not starting from scratch here. + +Thanks. + +--sean + +Sean Shanny wrote: + +> To all, +> +> We are building a data warehouse composed of essentially click stream +> data. The DB is growing fairly quickly as to be expected, currently +> at 90GB for one months data. The idea is to keep 6 months detailed +> data on line and then start aggregating older data to summary tables. +> We have 2 fact tables currently, one with about 68 million rows and +> the other with about 210 million rows. Numerous dimension tables +> ranging from a dozen rows to millions. +> +> We are currently running on a Dell 2650 with 2 Xeon 2.8 processors in +> hyper-threading mode, 4GB of ram, and 5 SCSI drives in a RAID 0, +> Adaptec PERC3/Di, configuration. I believe they are 10k drives. +> Files system is EXT3. We are running RH9 Linux kernel 2.4.20-20.9SMP +> with bigmem turned on. This box is used only for the warehouse. All +> the ETL work is done on this machine as well. DB version is +> postgreSQL 7.4. +> +> We are running into issues with IO saturation obviously. Since this +> thing is only going to get bigger we are looking for some advice on +> how to accommodate DB's of this size. +> +> First question is do we gain anything by moving the RH Enterprise +> version of Linux in terms of performance, mainly in the IO realm as we +> are not CPU bound at all? Second and more radical, has anyone run +> postgreSQL on the new Apple G5 with an XRaid system? This seems like +> a great value combination. Fast CPU, wide bus, Fibre Channel IO, +> 2.5TB all for ~17k. +> +> I keep see references to terabyte postgreSQL installations, I was +> wondering if anyone on this list is in charge of one of those and can +> offer some advice on how to position ourselves hardware wise. +> +> Thanks. +> +> --sean +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 18:13:01 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DD708D1B554 + for ; + Wed, 3 Dec 2003 22:12:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11205-04 + for ; + Wed, 3 Dec 2003 18:12:29 -0400 (AST) +Received: from main.wiredfool.com (dsl231-055-035.sea1.dsl.speakeasy.net + [216.231.55.35]) + by svr1.postgresql.org (Postfix) with ESMTP id 995E8D1B432 + for ; + Wed, 3 Dec 2003 18:12:11 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by main.wiredfool.com (Postfix) with ESMTP + id 9CF302728E; Wed, 3 Dec 2003 14:07:10 -0800 (PST) +Received: from main.wiredfool.com ([127.0.0.1]) + by localhost (cabbage [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 06031-08; Wed, 3 Dec 2003 14:07:08 -0800 (PST) +Received: from [IPv6:::1] (localhost [127.0.0.1]) + by main.wiredfool.com (Postfix) with ESMTP + id 832EB2728D; Wed, 3 Dec 2003 14:07:08 -0800 (PST) +In-Reply-To: <3FCE5855.5040403@earthlink.net> +References: <3FCE5855.5040403@earthlink.net> +Mime-Version: 1.0 (Apple Message framework v606) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: "pgsql-performance@postgresql.org" +From: Eric Soroos +Subject: Re: Has anyone run on the new G5 yet +Date: Wed, 3 Dec 2003 14:12:08 -0800 +To: Sean Shanny +X-Mailer: Apple Mail (2.606) +X-Virus-Scanned: by amavisd-new-20030616-p3 (Debian) at main.wiredfool.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/57 +X-Sequence-Number: 4917 + +Sean + +> Second and more radical, has anyone run postgreSQL on the new Apple +> G5 with an XRaid system? This seems like a great value combination. +> Fast CPU, wide bus, Fibre Channel IO, 2.5TB all for ~17k. +> +> I keep see references to terabyte postgreSQL installations, I was +> wondering if anyone on this list is in charge of one of those and can +> offer some advice on how to position ourselves hardware wise. + + From my (admittedly low end) OSX experience, you just don't have the +filesystem options on OSX that you have on linux, from the noatime +mount, filesystem types, and the raid options. I also feel that the +software stack is a bit more mature and tested on the linux side of +things. + +I doubt that the g5 hardware is that much faster than what you have +right now. The raid hardware might be a good deal for you even on a +linux platform. There are reports of it 'just working' with x86 linux +hardware. + +eric + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 18:32:57 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BF5EDD1B486 + for ; + Wed, 3 Dec 2003 22:32:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 19449-01 + for ; + Wed, 3 Dec 2003 18:32:20 -0400 (AST) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D3D6D1B479 + for ; + Wed, 3 Dec 2003 18:32:17 -0400 (AST) +Received: from thorn.mmrd.com (thorn.mmrd.com [172.25.10.100]) + by bramble.mmrd.com (8.12.8/8.12.8) with ESMTP id hB3Lg7cM016428 + for ; Wed, 3 Dec 2003 16:42:07 -0500 +Received: from gnvex001.mmrd.com (gnvex001.mmrd.com [192.168.3.55]) + by thorn.mmrd.com (8.11.6/8.11.6) with ESMTP id hB3MWJl14844 + for ; Wed, 3 Dec 2003 17:32:19 -0500 +Received: from camel.mmrd.com ([172.25.5.213]) by gnvex001.mmrd.com with SMTP + (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) + id XT87Z8D2; Wed, 3 Dec 2003 17:32:16 -0500 +Subject: sequence overhead +From: Robert Treat +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 03 Dec 2003 17:32:18 -0500 +Message-Id: <1070490739.25244.10530.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/58 +X-Sequence-Number: 4918 + +Just wondering if anyone has done any testing on the amount of overhead +for insert you might gain by adding a serial column to a table. I'm +thinking of adding a few to some tables that get an average of 30 - 40 +inserts per second, sometimes bursting over 100 inserts per second and +wondering if there will be any noticeable impact. + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 18:35:47 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B485ED1B518 + for ; + Wed, 3 Dec 2003 22:35:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10759-08 + for ; + Wed, 3 Dec 2003 18:35:16 -0400 (AST) +Received: from redhotpenguin.com (c-24-7-81-19.client.comcast.net + [24.7.81.19]) + by svr1.postgresql.org (Postfix) with ESMTP id 38D99D1B486 + for ; + Wed, 3 Dec 2003 18:35:13 -0400 (AST) +Received: (qmail 14413 invoked by uid 506); 3 Dec 2003 22:35:14 -0000 +Received: from fred@redhotpenguin.com by poster.redhotpenguin.com by uid 502 + with qmail-scanner-1.16 + (clamscan: 0.65. spamassassin: 2.44. Clear:SA:0(-1.1/5.0):. + Processed in 1.006262 secs); 03 Dec 2003 22:35:14 -0000 +Received: from c-24-7-81-19.client.comcast.net (HELO harpua) + (fred@redhotpenguin.com@24.7.81.19) + by 192.168.0.2 with RC4-MD5 encrypted SMTP; 3 Dec 2003 22:35:13 -0000 +From: "Fred Moyer" +To: "'Sean Shanny'" , + +Subject: Re: Has anyone run on the new G5 yet +Date: Wed, 3 Dec 2003 14:35:45 -0800 +Message-ID: <000001c3b9ed$cb1bf2a0$0300a8c0@harpua> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2616 +In-Reply-To: <3FCE5B85.9000406@earthlink.net> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/59 +X-Sequence-Number: 4919 + +> We are running into issues with IO saturation obviously. Since this +> thing is only going to get bigger we are looking for some advice on +> how to accommodate DB's of this size. + +> Second and more radical, has anyone run +> postgreSQL on the new Apple G5 with an XRaid system? This seems like +> a great value combination. Fast CPU, wide bus, Fibre Channel IO, +> 2.5TB all for ~17k. + +If you are going for I/O performance you are best off with one of the +Xserve competitors listed at http://www.apple.com/xserve/raid/. The +Xserve is based on IDE drives which have a lower seek time (say 8.9 ms) +compared to scsi (3.6 ms for seagate cheetah). For small random +read/write operations (like databases) this will give you a noticable +improvement in performance over ide drives. Also make sure to get as +many drives as possible, more spindles equals better I/O performance. + +> I keep see references to terabyte postgreSQL installations, I was +> wondering if anyone on this list is in charge of one of those and can +> offer some advice on how to position ourselves hardware wise. + +I've gone to about half terabyte size and all I can say is you should +plan for at least one quarter to one half a rack of drivespace (assuming +14 drives per 4u that's 42 to 84 drives). Do yourself a favor and get +more rather than less, you will really appreciate it. I averaged about +2 mb/s average per drive via the raid controller stats on 14 drive array +during I/O bound seek and update operations in 2 raid 10 arrays (half +xlogs and half data). That comes out to around 2 hours for a terabyte +with 70 drives assuming a constant scaling. You may be able to get more +or less depending on your setup and query workload. + +> Thanks. +> +> --sean +> +> +> ---------------------------(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 +> + + +---------------------------(end of broadcast)--------------------------- +TIP 5: Have you checked our extensive FAQ? + + http://www.postgresql.org/docs/faqs/FAQ.html + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 19:18:23 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 769D3D1B47F + for ; + Wed, 3 Dec 2003 23:18:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22389-07 + for ; + Wed, 3 Dec 2003 19:17:50 -0400 (AST) +Received: from candle.pha.pa.us (unknown [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id D5A41D1B479 + for ; + Wed, 3 Dec 2003 19:17:46 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hB3NHbY27219; + Wed, 3 Dec 2003 18:17:37 -0500 (EST) +From: Bruce Momjian +Message-Id: <200312032317.hB3NHbY27219@candle.pha.pa.us> +Subject: Re: A question on the query planner +In-Reply-To: <26699.1070423607@sss.pgh.pa.us> +To: Tom Lane +Date: Wed, 3 Dec 2003 18:17:37 -0500 (EST) +Cc: Greg Stark , Jared Carr , + pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/60 +X-Sequence-Number: 4920 + +Tom Lane wrote: +> Greg Stark writes: +> > Tom Lane writes: +> >> Define "no longer works well". +> +> > Well it seems to completely bar the use of a straight merge join between two +> > index scans: +> +> Hmmm ... [squints] ... it's not supposed to do that ... [digs] ... yeah, +> there's something busted here. Will get back to you ... + +LOL, but I am not sure why. :-) + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Wed Dec 3 19:22:54 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 37422D1B47E + for ; + Wed, 3 Dec 2003 23:22:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21780-07 + for ; + Wed, 3 Dec 2003 19:22:23 -0400 (AST) +Received: from live (64-35-136-226.gohighspeed.com [64.35.136.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B7DAD1B446 + for ; + Wed, 3 Dec 2003 19:22:20 -0400 (AST) +Received: from [192.168.254.101] (helo=89glass.com) + by live with esmtp (Exim 3.35 #1 (Debian)) + id 1ARgK1-0002hW-00; Wed, 03 Dec 2003 15:22:17 -0800 +Message-ID: <3FCE700E.5070206@89glass.com> +Date: Wed, 03 Dec 2003 15:21:50 -0800 +From: Jared Carr +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: A question on the query planner +References: <3FCBB639.10409@89glass.com> + <1070385381.24915.8650.camel@camel> <3FCCD225.8030609@89glass.com> + <87d6b79har.fsf@stark.dyndns.tv> <3FCCE48B.10406@89glass.com> + <871xrn9e09.fsf@stark.dyndns.tv> <3FCCF61E.90307@89glass.com> + <87ptf697h0.fsf@stark.dyndns.tv> <25476.1070409047@sss.pgh.pa.us> + <87znea7kis.fsf@stark.dyndns.tv> <26699.1070423607@sss.pgh.pa.us> + <2704.1070473746@sss.pgh.pa.us> <3FCE2B08.6090606@89glass.com> + <87k75d66jh.fsf@stark.dyndns.tv> +In-Reply-To: <87k75d66jh.fsf@stark.dyndns.tv> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/61 +X-Sequence-Number: 4921 + +Greg Stark wrote: + +>Jared Carr writes: +> +> +> +>>The patch definitely makes things more consistent...unfortunately it is more +>>consistent toward the slower execution times. Of course I am looking at this +>>simply from a straight performance standpoint and not a viewpoint of what +>>*should* be happening. At any rate here are the query plans with the various +>>settings. +>> +>> +> +>The optimizer seems to be at least considering reasonable plans now. It seems +>from the estimates that you need to rerun analyze. You might try "vacuum full +>analyze" to be sure. +> +>Also, you might try raising effective_cache_size and/or lowering +>random_page_size (it looks like something around 2 might help). +> +> +> +Yep, I had forgotten to run vacuum since I had patched it :P. The +overall performance is definitely better, +I will go ahead and tweak the server settings and see what I can get. +Thanks again for all the help. + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 19:57:49 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 23741D1B453 + for ; + Wed, 3 Dec 2003 23:57:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 29740-03 + for ; + Wed, 3 Dec 2003 19:57:17 -0400 (AST) +Received: from sardegna.mbigroup.it (unknown [151.8.40.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 7AD92D1B465 + for ; + Wed, 3 Dec 2003 19:57:13 -0400 (AST) +Received: from sicilia.pisa.mbigroup.it (localhost [127.0.0.1]) + by sardegna.mbigroup.it (8.11.6/8.8.7) with ESMTP id hB3Nobx25281; + Thu, 4 Dec 2003 00:50:37 +0100 +Received: from bigfoot.com (canarie.pisa.mbigroup.it [192.168.9.30]) + by sicilia.pisa.mbigroup.it (8.11.6/8.11.6) with ESMTP id hB3NoV302709; + Thu, 4 Dec 2003 00:50:31 +0100 +Message-ID: <3FCE76B3.5040502@bigfoot.com> +Date: Thu, 04 Dec 2003 00:50:11 +0100 +From: Gaetano Mendola +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031202 Thunderbird/0.4RC1 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Cc: Sean Shanny +Subject: Re: Has anyone run on the new G5 yet +References: <3FCE5855.5040403@earthlink.net> +In-Reply-To: <3FCE5855.5040403@earthlink.net> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/63 +X-Sequence-Number: 4923 + +Sean Shanny wrote: + +> We are currently running on a Dell 2650 with 2 Xeon 2.8 processors in +> hyper-threading mode, 4GB of ram, and 5 SCSI drives in a RAID 0, Adaptec +> PERC3/Di, configuration. I believe they are 10k drives. Files system +> is EXT3. We are running RH9 Linux kernel 2.4.20-20.9SMP with bigmem +> turned on. This box is used only for the warehouse. All the ETL work +> is done on this machine as well. DB version is postgreSQL 7.4. + +Are you experiencing improvment using the hyper-threading ? + + +Regards +Gaetano Mendola + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 19:56:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 71D31D1B455 + for ; + Wed, 3 Dec 2003 23:56:04 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28098-03 + for ; + Wed, 3 Dec 2003 19:55:36 -0400 (AST) +Received: from sardegna.mbigroup.it (unknown [151.8.40.3]) + by svr1.postgresql.org (Postfix) with ESMTP id EB67AD1B479 + for ; + Wed, 3 Dec 2003 19:55:32 -0400 (AST) +Received: from sicilia.pisa.mbigroup.it (localhost [127.0.0.1]) + by sardegna.mbigroup.it (8.11.6/8.8.7) with ESMTP id hB3NtPp25341; + Thu, 4 Dec 2003 00:55:25 +0100 +Received: from bigfoot.com (canarie.pisa.mbigroup.it [192.168.9.30]) + by sicilia.pisa.mbigroup.it (8.11.6/8.11.6) with ESMTP id hB3NtJ303048; + Thu, 4 Dec 2003 00:55:19 +0100 +Message-ID: <3FCE77D3.3010704@bigfoot.com> +Date: Thu, 04 Dec 2003 00:54:59 +0100 +From: Gaetano Mendola +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031202 Thunderbird/0.4RC1 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Cc: Tom Lane +Subject: Re: A question on the query planner +References: <3FCBB639.10409@89glass.com> <1070385381.24915.8650.camel@camel> + <3FCCD225.8030609@89glass.com> <87d6b79har.fsf@stark.dyndns.tv> + <3FCCE48B.10406@89glass.com> <871xrn9e09.fsf@stark.dyndns.tv> + <3FCCF61E.90307@89glass.com> <87ptf697h0.fsf@stark.dyndns.tv> + <25476.1070409047@sss.pgh.pa.us> <87znea7kis.fsf@stark.dyndns.tv> + <26699.1070423607@sss.pgh.pa.us> <2704.1070473746@sss.pgh.pa.us> +In-Reply-To: <2704.1070473746@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/62 +X-Sequence-Number: 4922 + +Tom Lane wrote: + +>>Hmmm ... [squints] ... it's not supposed to do that ... +> +> +> The attached patch seems to make it better. + +I guess is too late for 7.3.5. + +:-( + +Any chance for 7.4.1 ? + + + + +Regards +Gaetano Mendola + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 20:25:12 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A9D95D1B453 + for ; + Thu, 4 Dec 2003 00:25:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 32760-01 + for ; + Wed, 3 Dec 2003 20:24:40 -0400 (AST) +Received: from swan.mail.pas.earthlink.net (swan.mail.pas.earthlink.net + [207.217.120.123]) + by svr1.postgresql.org (Postfix) with ESMTP id BEF29D1B441 + for ; + Wed, 3 Dec 2003 20:24:37 -0400 (AST) +Received: from dpc6682164065.direcpc.com ([66.82.164.65] helo=earthlink.net) + by swan.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) + id 1ARhIG-0002BZ-00; Wed, 03 Dec 2003 16:24:35 -0800 +Message-ID: <3FCE7EB5.7030809@earthlink.net> +Date: Wed, 03 Dec 2003 19:24:21 -0500 +From: Sean Shanny +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Gaetano Mendola +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Has anyone run on the new G5 yet +References: <3FCE5855.5040403@earthlink.net> <3FCE76B3.5040502@bigfoot.com> +In-Reply-To: <3FCE76B3.5040502@bigfoot.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/64 +X-Sequence-Number: 4924 + +Gaetano, + +I don't believe we have ever run the system without it turned on. +Another switch to fiddle with. :-) + +--sean + +Gaetano Mendola wrote: + +> Sean Shanny wrote: +> +>> We are currently running on a Dell 2650 with 2 Xeon 2.8 processors in +>> hyper-threading mode, 4GB of ram, and 5 SCSI drives in a RAID 0, +>> Adaptec PERC3/Di, configuration. I believe they are 10k drives. +>> Files system is EXT3. We are running RH9 Linux kernel 2.4.20-20.9SMP +>> with bigmem turned on. This box is used only for the warehouse. All +>> the ETL work is done on this machine as well. DB version is +>> postgreSQL 7.4. +> +> +> Are you experiencing improvment using the hyper-threading ? +> +> +> Regards +> Gaetano Mendola +> +> + + +From pgsql-performance-owner@postgresql.org Wed Dec 3 23:10:51 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 048FCD1C979 + for ; + Thu, 4 Dec 2003 03:10:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 53790-04 + for ; + Wed, 3 Dec 2003 23:10:20 -0400 (AST) +Received: from necsin-fw.nec.com.sg (necsin-fw.nec.com.sg [203.127.255.1]) + by svr1.postgresql.org (Postfix) with ESMTP id B23BCD1B477 + for ; + Wed, 3 Dec 2003 23:10:09 -0400 (AST) +Received: from kato.nec.com.sg (kato.nec.com.sg [203.127.254.2]) + by necsin-fw.nec.com.sg with ESMTP id hB439srE006979; + Thu, 4 Dec 2003 11:09:54 +0800 (SGT) +Received: from necsind1.nec.com.sg ([203.127.252.220]) + by kato.nec.com.sg with ESMTP id hB439ru2025635; + Thu, 4 Dec 2003 11:09:54 +0800 (SGT) +Subject: Re: Minimum hardware requirements for Postgresql db +To: Christopher Browne , + pgsql-performance@postgresql.org +X-Mailer: Lotus Notes Release 5.0.5 September 22, 2000 +Message-ID: +From: CHEWTC@ap.nec.com.sg +Date: Thu, 4 Dec 2003 11:09:59 +0800 +X-MIMETrack: Serialize by Router on NECSIND1/WTC/NECSIN(Release 5.0.12 + |February 13, 2003) at 12/04/2003 11:10:00 AM +MIME-Version: 1.0 +Content-type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/65 +X-Sequence-Number: 4925 + + +Dear all + + +Sorry for my mistake on the 15000 recs per day. + +In fact, this server is planned as a OLTP database server for a retailer. +Our intention is either to setup 1 or 2 Postgresql db in the server. + +The proper sizing info for the 1st Postgresql db should be: + +No. of item master : 200,000 +(This item master grows at 0.5% daily). + +No. of transactions from Point-of-Sales machines: 25,000 + +Plus other tables, the total sizing that I estimated is 590,000 records +daily. + +The 2nd Postgresql db will be used by end users on client machines linked +via ODBC, doing manual data entry. +This will house the item master, loyalty card master and other Historical +data to be kept for at least 1.5 years. + +Therefore total sizing for this db is around 165,000,000 recs at any time. + +In summary, the single machine must be able to take up around 100 users +connections via both socket and ODBC. And house the above number of +records. + + +Thank you, +REgards. + + + + + + Christopher Browne + To: pgsql-performance@postgresql.org + Sent by: cc: + pgsql-performance-owner@pos Subject: Re: [PERFORM] Minimum hardware requirements for Postgresql db + tgresql.org + + + 03/12/2003 12:44 PM + + + + + + +After takin a swig o' Arrakan spice grog, CHEWTC@ap.nec.com.sg belched out: +> We would be recommending to our ct. on the use of Postgresql db as +> compared to MS SQL Server. We are targetting to use Redhat Linux ES +> v2.1, Postgresql v7.3.4 and Postgresql ODBC 07.03.0100. +> +> We would like to know the minimum specs required for our below +> target. The minimum specs is referring to no. of CPU, memory, +> harddisk capacity, RAID technology etc. And also the Postgresql +> parameters and configuration to run such a system. +> +> 1) We will be running 2 x Postgresql db in the machine. +> +> 2) Total number of connections to be around 100. The connections +> from the clients machines will be in ODBC and socket connections. +> +> 3) Estimated number of transactions to be written into the +> Postgresql db is around 15000 records per day. +> +> The growth rate in terms of number of connections is around 10% per +> year and the data retention is kept on average at least for 18 +> months for the 2 databases. +> +> Are there any reference books or sites that I can tap on for the +> above requirement? + +Perhaps the best reference on detailed performance information is the +"General Bits" documents. + + + + + +These don't point particularly at minimal hardware requirements, but +rather at how to configure the DBMS to best reflect what hardware you +have. But there's some degree to which you can work backwards... + +If you'll need to support 100 concurrent connections, then minimum +shared_buffers is 200, which implies 1600K of RAM required for shared +buffers. + +100 connections probably implies around 100MB of memory for the +backend processes to support the connections. + +That all points to the notion that you'd more than probably get +half-decent performance if you had a mere 256MB of RAM, which is about +$50 worth these days. + +None of it sounds terribly challenging; 15K records per day is 625 +records per hour which represents an INSERT every 6 seconds. Even if +that has to fit into an 8 hour day, that's still not a high number of +transactions per second. That _sounds like_ an application that could +work on old, obsolete hardware. I would imagine that my old Intel +Pentium Pro 200 might cope with the load, in much the way that that +server is more than capable of supporting a web server that would +serve a local workgroup. (I only have 64MB of RAM on that box, which +would be a mite low, but it's an _ancient_ server...) + +The only thing that makes me a little suspicious that there's +something funny about the prescription is your indication of having +100 concurrent users, which is really rather heavyweight in comparison +with the comparatively tiny number of transactions. Is this for some +sort of "departmental application"? Where there's a lot of manual +data entry, so that each user would generate a transaction every 3-4 +minutes? That actually sounds about right... + +Let me suggest that the "cost driver" in this will _not_ be the cost +of the hardware to support the database itself; it will instead be in +having redundant hardware and backup hardware to ensure reliability. + +It would seem likely that just about any sort of modern hardware would +be pretty adequate to the task. You can hardly _buy_ a system with +less than Gigahertz-speed CPUs, 40GB of disk, and 256MB of RAM. +Upgrade to have 2 SCSI disks, 512MB (or more, which is better) of RAM, +and the cost of a suitable system still won't be outrageous. + +Double it, buying a standby server, and the cost still oughtn't be +real scary. And if the application is important, you _should_ have a +standby server, irrespective of what software you might be running. +-- +(reverse (concatenate 'string "moc.enworbbc" "@" "enworbbc")) +http://www3.sympatico.ca/cbbrowne/x.html +Rules of the Evil Overlord #199. "I will not make alliances with those +more powerful than myself. Such a person would only double-cross me in +my moment of glory. I will make alliances with those less powerful +than myself. I will then double-cross them in their moment of glory." + + +---------------------------(end of broadcast)--------------------------- +TIP 9: the planner will ignore your desire to choose an index scan if your + joining column's datatypes do not match + + + + + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 01:41:40 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BF8FD1B4A7 + for ; + Thu, 4 Dec 2003 05:41:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73588-04 + for ; + Thu, 4 Dec 2003 01:41:04 -0400 (AST) +Received: from mta11.srv.hcvlny.cv.net (mta11.srv.hcvlny.cv.net + [167.206.5.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 03288D1B579 + for ; + Thu, 4 Dec 2003 01:41:03 -0400 (AST) +Received: from [192.168.1.10] (ool-4352919e.dyn.optonline.net [67.82.145.158]) + by mta11.srv.hcvlny.cv.net + (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) + with ESMTP id <0HPC00JY4VOM7B@mta11.srv.hcvlny.cv.net> for + pgsql-performance@postgresql.org; Thu, 04 Dec 2003 00:38:47 -0500 (EST) +Date: Thu, 04 Dec 2003 00:38:46 -0500 +From: "Matthew T. O'Connor" +Subject: Re: autovacuum daemon stops doing work after about an hour +In-reply-to: <16332.63508.196365.801418@yertle.int.kciLink.com> +To: Vivek Khera +Cc: pgsql-performance@postgresql.org +Message-id: <1070516326.1455.11.camel@zedora.zeut.net> +MIME-version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) +Content-type: text/plain +Content-transfer-encoding: 7BIT +References: <16332.63508.196365.801418@yertle.int.kciLink.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/66 +X-Sequence-Number: 4926 + +On Tue, 2003-12-02 at 15:37, Vivek Khera wrote: +> Now I'm trying to implement pg_autovacuum. It seems to work ok, but +> after about an hour or so, it does nothing. The process still is +> running, but nothing is sent to the log file. +> +> I'm running the daemon as distributed with PG 7.4 release as follows: +> +> pg_autovacuum -d4 -V 0.15 -A 1 -U postgres -L /var/tmp/autovacuum.log -D +> +> the last few lines of the log are: +> +> [2003-12-02 11:43:58 AM] VACUUM ANALYZE "public"."msg_recipients" +> [2003-12-02 12:24:33 PM] select relfilenode,reltuples,relpages from pg_class where relfilenode=18588239 +> [2003-12-02 12:24:33 PM] table name: vkmlm."public"."msg_recipients" +> [2003-12-02 12:24:33 PM] relfilenode: 18588239; relisshared: 0 +> [2003-12-02 12:24:33 PM] reltuples: 9; relpages: 529132 +> [2003-12-02 12:24:33 PM] curr_analyze_count: 1961488; cur_delete_count: 1005040 +> [2003-12-02 12:24:33 PM] ins_at_last_analyze: 1961488; del_at_last_vacuum: 1005040 +> [2003-12-02 12:24:33 PM] insert_threshold: 509; delete_threshold 1001 +> [2003-12-02 12:24:33 PM] Performing: VACUUM ANALYZE "public"."user_list" +> [2003-12-02 12:24:33 PM] VACUUM ANALYZE "public"."user_list" +> [2003-12-02 12:43:19 PM] select relfilenode,reltuples,relpages from pg_class where relfilenode=18588202 +> [2003-12-02 12:43:19 PM] table name: vkmlm."public"."user_list" +> [2003-12-02 12:43:19 PM] relfilenode: 18588202; relisshared: 0 +> [2003-12-02 12:43:19 PM] reltuples: 9; relpages: 391988 +> [2003-12-02 12:43:19 PM] curr_analyze_count: 1159843; cur_delete_count: 1118540 +> [2003-12-02 12:43:19 PM] ins_at_last_analyze: 1159843; del_at_last_vacuum: 1118540 +> [2003-12-02 12:43:19 PM] insert_threshold: 509; delete_threshold 1001 +> +> Then it just sits there. I started it at 11:35am, and it is now +> 3:30pm. + +Weird.... Alphabetically speaking, is vkmlm."public"."user_list" be the +last table in the last schema in the last database? You are running +with -d4, so you would get a message about going to sleep shortly after +dealing with the last table, but you didn't get the sleep message, so I +don't think the problem is that pg_autovacuum is sleeping for an +inordinate amount time. + +> I did the same last night at about 10:58pm, and it ran and did work until +> 11:57pm, then sat there until I killed/restarted pg_autovacuum this +> morning at 11:35. The process is not using any CPU time. +> +> I just killed/restarted it and it found work to do on my busy tables +> which I'd expect. + +when you kill it, do you get a core file? Could you do a backtrace and +see where pg_autovacuum is hung up? + +> I'm running Postgres 7.4 release on FreeBSD 4.9-RELEASE. + +I don't run FreeBSD, so I haven't tested with FreeBSD. Recently Craig +Boston reported and submitted a patch for a crash on FreeBSD, but that +doesn't sound like your problem. Could be some other type of platform +dependent problem. + + + +From pgsql-general-owner@postgresql.org Thu Dec 4 16:30:58 2003 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id B4599D1DE21; Thu, 4 Dec 2003 06:22:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 76284-10; Thu, 4 Dec 2003 02:22:13 -0400 (AST) +Received: from smtp.tor.pathcom.com (smtp.tor.pathcom.com [209.250.128.26]) + by svr1.postgresql.org (Postfix) with ESMTP + id 19CC1D1B49E; Thu, 4 Dec 2003 02:22:10 -0400 (AST) +Received: from sinope.axxent.ca (v47.wall.tor.axxent.ca [209.250.131.207]) + by smtp.tor.pathcom.com (8.12.9/8.12.6) with ESMTP id hB46MAKu018309; + Thu, 4 Dec 2003 01:22:10 -0500 (EST) +Received: by sinope.inside.pathcom.com with Internet Mail Service + (5.5.2653.19) + id ; Thu, 4 Dec 2003 01:22:10 -0500 +Message-ID: + +From: "Passynkov, Vadim" +To: "'pgsql-general@postgresql.org'" +Cc: "'pgsql-performance@postgresql.org'" +Subject: Async Query Processing on Solaris +Date: Thu, 4 Dec 2003 01:22:08 -0500 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain; + charset="iso-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/260 +X-Sequence-Number: 53654 + +I am using Asynchronous Query Processing interface from libpq library. +And I got some strange results on Solaris + +My test select query is 'SELECT * from pg_user;' +and I use select system synchronous I/O multiplexer in 'C' + +The first test sends 10000 select queries using 10 nonblocking connections +to database ( PQsendQuery ). +The second test sends the same 10000 select queries using 1 connection ( +PQexec ). + +On FreeBSD there is a huge difference between the async and the sync tests. +The async test is much faster than sync test. +On Solaris there is no speed difference between async and sync test, +actually async test is even slower than sync test. + +Q. Why ? + +On FreeBSD: + +/usr/bin/time ./PgAsyncManager async +async test start ... 10000 done +9.46 real 3.48 user 1.25 sys + +/usr/bin/time ./PgAsyncManager sync +sync test start ... 10000 done +22.64 real 3.35 user 1.24 sys + +On Solaris: + +/usr/bin/time ./PgAsyncManager async +async test start ... 10000 done + +real 20.6 +user 2.1 +sys 0.4 + +/usr/bin/time ./PgAsyncManager sync +sync test start ... 10000 done + +real 18.4 +user 1.1 +sys 0.5 + +From pgsql-performance-owner@postgresql.org Thu Dec 4 04:21:44 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DE28BD1B488 + for ; + Thu, 4 Dec 2003 08:21:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 87163-10 + for ; + Thu, 4 Dec 2003 04:21:12 -0400 (AST) +Received: from monsoon.he.net (monsoon.he.net [64.62.221.2]) + by svr1.postgresql.org (Postfix) with SMTP id 32634D1B483 + for ; + Thu, 4 Dec 2003 04:21:10 -0400 (AST) +Received: from [10.5.73.162] ([64.4.254.252]) by monsoon.he.net for + ; Thu, 4 Dec 2003 00:21:04 -0800 +Subject: Re: Has anyone run on the new G5 yet +From: Paul Tuckfield +To: pgsql-performance@postgresql.org +Cc: shannyconsulting@earthlink.net +Content-Type: text/plain +Organization: +Message-Id: <1070526289.4666.35.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) +Date: 04 Dec 2003 00:24:50 -0800 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/67 +X-Sequence-Number: 4927 + +(hope I'm posting this correctly) + +You wrote: + +>First question is do we gain anything by moving the RH Enterprise +>version of Linux in terms of performance, mainly in the IO realm as we +>are not CPU bound at all? Second and more radical, has anyone run +>postgreSQL on the new Apple G5 with an XRaid system? This seems like a +>great value combination. Fast CPU, wide bus, Fibre Channel IO, 2.5TB +>all for ~17k. + +Wow, funny coincidence: I've got a pair of dual xeons w. 8G + 14disk +fcal arrays, and an xserve with an XRaid that I've been screwing around +with. If you have specific tests you'd like to see, let me know. + +--- so, for the truly IO bound, here's my recent messin' around summary: + +In the not-so-structured tests I've done, I've been disappointed with +Redhat AS 2.1. IO thruput. I've had difficulty driving a lot of IO +thru my dual fcal channels: I can only get one going at 60M/sec, and +when I drive IO to the second, I still see only about 60M/sec combined. +and when I does get that high it uses about 30% CPU on a dual xeon +hyperthreaded box, all in sys (by vmstat). something very wrong there, +and the only thing I can conclude is that I'm serializing in the driver +somehow (qla2200 driver), thus parallel channels do the same as one, and +interrupt madness drives the cpu up just to do this contentious IO. + +This contrasts with the Redhat 9 I just installed on a similar box, that +got 170M/sec on 2 fcal channels, and the expected 5-6% cpu. + +The above testing was dd straight from /dev/rawX devices, so no buffer +cache confusion there. + +Also had problems getting the Redhat AS to bind to my newer qla2300 +adapters at all, whereas they bound fine under RH9. + +Redhat makes the claim of finer grained locks/semaphores in the qla and +AIC drivers in RH AS, but my tests seem to show that the 2 fcal ports +were serializing against eachother in the kernel under RH AS, and not so +under RH9. Maybe I'm useing the wrong driver under AS. eh. + +so sort story long, it seems like you're better of with RH9. But again, +before you lay out serious coin for xserve or others, if you have +specific tests you want to see, I'll take a little time to contrast w. +exserve. One of the xeons also has an aic7x scsi controler w 4 drives +so It might match your rig better. + +I also did some token testing on the xserve I have which I believe may +only have one processor (how do you tell on osX?) and the xraid has 5 +spindles in it. I did a cursory build of postgres on it and also a io +test (to the filesystem) and saw about 90M/sec. Dunno if it has dual +paths (if you guys know how to tell, let me know) + + +Biggest problem I've had in the past w. linux in general is that it +seems to make poor VM choices under heavy filesystem IO. I don't really +get exactly where it's going wrong , but I've had numerous experiences +on older systems where bursty IO would seem to cause paging on the box +(pageout of pieces of the oracle SGA shared memory) which is a +performance disaseter. It seems to happen even when the shared memory +was sized reasonably below the size of physical ram, presumably because +linux is too aggressive in allocating filesystem cache (?) anyway, it +seems to make decisions based on desire for zippy workstation +performance and gets burned on thruput on database servers. I'm +guessing this may be an issue for you , when doing heavy IO. Thing is, +it'll show like you're IO bound kindof because you're thrashing. + + +From pgsql-general-owner@postgresql.org Thu Dec 4 08:48:49 2003 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id D4739D1B534; Thu, 4 Dec 2003 12:48:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27040-06; Thu, 4 Dec 2003 08:48:13 -0400 (AST) +Received: from smtp.tor.pathcom.com (smtp.tor.pathcom.com [209.250.128.26]) + by svr1.postgresql.org (Postfix) with ESMTP + id AD63ED1B457; Thu, 4 Dec 2003 08:48:09 -0400 (AST) +Received: from sinope.axxent.ca (v47.wall.tor.axxent.ca [209.250.131.207]) + by smtp.tor.pathcom.com (8.12.9/8.12.6) with ESMTP id hB4CmD5g007083; + Thu, 4 Dec 2003 07:48:13 -0500 (EST) +Received: by sinope.inside.pathcom.com with Internet Mail Service + (5.5.2653.19) + id ; Thu, 4 Dec 2003 07:48:13 -0500 +Message-ID: + +From: "Passynkov, Vadim" +To: "'pgsql-general@postgresql.org'" +Cc: "'pgsql-performance@postgresql.org'" +Subject: Async Query Processing on Solaris +Date: Thu, 4 Dec 2003 07:48:12 -0500 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain; + charset="iso-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/234 +X-Sequence-Number: 53628 + +I am using Asynchronous Query Processing interface from libpq library. +And I got some strange results on Solaris + +My test select query is 'SELECT * from pg_user;' +and I use select system synchronous I/O multiplexer in 'C' + +The first test sends 10000 select queries using 10 nonblocking connections +to database ( PQsendQuery ). +The second test sends the same 10000 select queries using 1 connection ( +PQexec ). + +On FreeBSD there is a huge difference between the async and the sync tests. +The async test is much faster than sync test. +On Solaris there is no speed difference between async and sync test, +actually async test is even slower than sync test. + +Q. Why ? + +On FreeBSD: + +/usr/bin/time ./PgAsyncManager async +async test start ... 10000 done +9.46 real 3.48 user 1.25 sys + +/usr/bin/time ./PgAsyncManager sync +sync test start ... 10000 done +22.64 real 3.35 user 1.24 sys + +On Solaris: + +/usr/bin/time ./PgAsyncManager async +async test start ... 10000 done + +real 20.6 +user 2.1 +sys 0.4 + +/usr/bin/time ./PgAsyncManager sync +sync test start ... 10000 done + +real 18.4 +user 1.1 +sys 0.5 + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 09:28:48 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 18A67D1B499 + for ; + Thu, 4 Dec 2003 13:28:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 32634-05 + for ; + Thu, 4 Dec 2003 09:28:17 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B5D9D1B48D + for ; + Thu, 4 Dec 2003 09:28:14 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hB4DSDbI091964 + for ; Thu, 4 Dec 2003 13:28:13 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hB4DCKCM089904 + for pgsql-performance@postgresql.org; Thu, 4 Dec 2003 13:12:20 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Minimum hardware requirements for Postgresql db +Date: Thu, 04 Dec 2003 08:10:50 -0500 +Organization: cbbrowne Computing Inc +Lines: 88 +Message-ID: +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:YmtsyZ3pDDni9fqhiYAH2g4BzLU= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/69 +X-Sequence-Number: 4929 + +CHEWTC@ap.nec.com.sg wrote: +> Sorry for my mistake on the 15000 recs per day. + +It was useful for us to pick at that a bit; it was certainly looking a +mite suspicious. + +> In fact, this server is planned as a OLTP database server for a retailer. +> Our intention is either to setup 1 or 2 Postgresql db in the server. +> +> The proper sizing info for the 1st Postgresql db should be: +> +> No. of item master : 200,000 +> (This item master grows at 0.5% daily). +> +> No. of transactions from Point-of-Sales machines: 25,000 + +> Plus other tables, the total sizing that I estimated is 590,000 +> records daily. + +So that's more like 7 TPS, with, more than likely, a peak load several +times that. + +> The 2nd Postgresql db will be used by end users on client machines linked +> via ODBC, doing manual data entry. +> This will house the item master, loyalty card master and other Historical +> data to be kept for at least 1.5 years. +> +> Therefore total sizing for this db is around 165,000,000 recs at any time. + +FYI, it is useful to plan for purging the old data from the very +beginning; if you don't, things can get ugly :-(. + +> In summary, the single machine must be able to take up around 100 +> users connections via both socket and ODBC. And house the above +> number of records. + +Based on multiplying the load by 40, we certainly move from +"pedestrian hardware where anything will do" to something requiring +more exotic hardware. + +- You _definitely_ want a disk array, with a bunch of SCSI disks. + +- You _definitely_ will want some form of RAID controller with + battery-backed cache. + +- You probably want multiple CPUs. + +- You almost certainly will want a second (and maybe third) complete + redundant system that you replicate data to. + +- The thing that will have _wild_ effects on whether this is enough, + or whether you need to go for something even _more_ exotic + (e.g. - moving to big iron UNIX(tm), whether that be Solaris, + AIX, or HP/UX) is the issue of how heavily the main database gets + hit by queries. + + If "all" it is doing is consolidating transactions, and there is + little query load from the POS systems, that is a very different + level of load from what happens if it is also servicing pricing + queries. + + Performance will get _destroyed_, regardless of how heavy the iron + is, if you hit the OLTP system with a lot of transaction reports. + You'll want a secondary replicated system to draw that load off. + +Evaluating whether it needs to be "big" hardware or "really enormous" +hardware is not realistic based on what you have said. There are +_big_ variations possible based notably on: + + 1. What kind of query load does the OLTP server have to serve up? + + If the answer is "lots," then everything gets more expensive. + + 2. How was the database schema and the usage of the clients designed? + + How well it is done will have a _large_ impact on how many TPS the + system can cope with. + +You'll surely need to do some prototyping, and be open to +possibilities such as that you'll need to consider alternative OSes. +On Intel/AMD hardware, it may be worth considering FreeBSD; it may +also be needful to consider "official UNIX(tm)" hardware. It would be +unrealistic to pretend more certainty... +-- +(reverse (concatenate 'string "ac.notelrac.teneerf" "@" "454aa")) +http://www.ntlug.org/~cbbrowne/nonrdbms.html +"Being really good at C++ is like being really good at using rocks to +sharpen sticks." -- Thant Tessman + +From pgsql-admin-owner@postgresql.org Thu Dec 4 10:55:55 2003 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 64D61D1B468 + for ; + Thu, 4 Dec 2003 14:55:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 44395-09 + for ; + Thu, 4 Dec 2003 10:55:26 -0400 (AST) +Received: from ar-sd.net (unknown [81.196.32.112]) + by svr1.postgresql.org (Postfix) with ESMTP id 105B6D1B432 + for ; Thu, 4 Dec 2003 10:55:22 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by ar-sd.net (Postfix) with ESMTP id 7C9DD1D021 + for ; Thu, 4 Dec 2003 16:58:37 +0200 (EET) +Received: from andy (unknown [192.168.0.11]) + by ar-sd.net (Postfix) with SMTP id 562D61CCD8 + for ; Thu, 4 Dec 2003 16:58:37 +0200 (EET) +Message-ID: <014901c3ba76$ffd65650$0b00a8c0@andy> +From: "Andrei Bintintan" +To: +Subject: Index not used. WHY? +Date: Thu, 4 Dec 2003 16:57:51 +0200 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0146_01C3BA87.C0BC67F0" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 5.50.4927.1200 +X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 +X-Virus-Scanned: by AMaViS snapshot-20020531 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.6 tagged_above=0.0 required=5.0 tests=HTML_50_60, + HTML_FONT_COLOR_BLUE, HTML_FONT_COLOR_GREEN, HTML_FONT_COLOR_RED, + HTML_FONT_COLOR_UNSAFE +X-Spam-Level: +X-Archive-Number: 200312/35 +X-Sequence-Number: 11543 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0146_01C3BA87.C0BC67F0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi,=20 + +I have the following table: +CREATE TABLE public.rights ( +id int4 DEFAULT nextval('"rights_id_seq"'::text) NOT NULL,=20 +id_user int4 NOT NULL,=20 +id_modull int4 NOT NULL,=20 +CONSTRAINT rights_pkey PRIMARY KEY (id) +)=20 + +and I created the following indexes: + +CREATE INDEX right_id_modull_idx ON rights USING btree (id_modull); +CREATE INDEX right_id_user_idx ON rights USING btree (id_user); + +Now the problem: + +EXPLAIN SELECT * FROM rights r WHERE r.id_modull =3D15 +returnes: +Seq Scan on rights r (cost=3D0.00..12.30 rows=3D42 width=3D12) +Filter: (id_modull =3D 15) + +EXPLAIN SELECT * FROM rights r WHERE r.id_user =3D15 +returnes: +Index Scan using right_id_user_idx on rights r (cost=3D0.00..8.35 rows=3D11= + width=3D12) +Index Cond: (id_user =3D 15) + +Question: Why the right_id_modull_idx is NOT USED at the 1st query and the = +second query the right_id_user_idx index is used.=20 + +I don't understand this.=20 + +Thanx in advance. +Andy. + + + + +------=_NextPart_000_0146_01C3BA87.C0BC67F0 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi,
+
 
+
I have the following table:
+
+

CREATE TABLE public.rights (
id int4 DEFAULT=20 +nextval('"rights_id_seq"'::text) NOT NULL,
= +id_user int4 NOT NULL,
= +id_modull int4 NOT NULL,
= +CONSTRAINT rights_pkey PRIMARY KEY (id)
)=20 +

+

and I created the following indexes:<= +/P> +

CREATE INDEX right_id_modull_idx ON=20 +rights USING btree (id_modull);
CREATE
INDEX right_id_u= +ser_idx=20 +ON rights USING b= +tree=20 +(id_user);

+

Now the problem:

+

EXPLAIN SELECT * FROM rights r WHERE r.id_modull =3D15
returnes:
Seq Scan on= +=20 +rights r (cost=3D0.00..12.30 rows=3D42 width=3D12)
Filter: (id_modull = +=3D=20 +15)

+

EXPLAIN SELECT * FROM rights r WHERE r.id_user =3D15
returnes:
Index Scan using right_id_user_idx on=20 +rights r (cost=3D0.00..8.35 rows=3D11 width=3D12)
= +Index=20 +Cond: (id_user =3D 15)

+

Question: Why the right_id_modull_idx is NOT US= +ED at=20 +the 1st query and the second query the right_id_user_idx index is used.=20 +

+

I don't understand this.

+

Thanx in=20 +advance.
Andy.

+

 

+ +------=_NextPart_000_0146_01C3BA87.C0BC67F0-- + + +From pgsql-admin-owner@postgresql.org Thu Dec 4 11:21:53 2003 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id BB9F1D1B4B1; Thu, 4 Dec 2003 15:20:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 53565-08; Thu, 4 Dec 2003 11:19:49 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP + id EBAEBD1B468; Thu, 4 Dec 2003 11:19:44 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 3E7E535500; Thu, 4 Dec 2003 07:19:49 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 3CE3935437; Thu, 4 Dec 2003 07:19:49 -0800 (PST) +Date: Thu, 4 Dec 2003 07:19:49 -0800 (PST) +From: Stephan Szabo +To: Andrei Bintintan +Cc: pgsql-admin@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: Index not used. WHY? +In-Reply-To: <014901c3ba76$ffd65650$0b00a8c0@andy> +Message-ID: <20031204071432.R66123@megazone.bigpanda.com> +References: <014901c3ba76$ffd65650$0b00a8c0@andy> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/37 +X-Sequence-Number: 11545 + + +On Thu, 4 Dec 2003, Andrei Bintintan wrote: + +> Hi, +> +> I have the following table: +> CREATE TABLE public.rights ( +> id int4 DEFAULT nextval('"rights_id_seq"'::text) NOT NULL, +> id_user int4 NOT NULL, +> id_modull int4 NOT NULL, +> CONSTRAINT rights_pkey PRIMARY KEY (id) +> ) +> +> and I created the following indexes: +> +> CREATE INDEX right_id_modull_idx ON rights USING btree (id_modull); +> CREATE INDEX right_id_user_idx ON rights USING btree (id_user); +> +> Now the problem: +> +> EXPLAIN SELECT * FROM rights r WHERE r.id_modull =15 +> returnes: +> Seq Scan on rights r (cost=0.00..12.30 rows=42 width=12) +> Filter: (id_modull = 15) +> +> EXPLAIN SELECT * FROM rights r WHERE r.id_user =15 +> returnes: +> Index Scan using right_id_user_idx on rights r (cost=0.00..8.35 rows=11 width=12) +> Index Cond: (id_user = 15) +> +> Question: Why the right_id_modull_idx is NOT USED at the 1st query and +> the second query the right_id_user_idx index is used. + +As a note, pgsql-performance is a better list for these questions. + +So, standard questions: + +How many rows are in the table, what does EXPLAIN ANALYZE show for the +queries, if you force index usage (set enable_seqscan=off) on the first +what does EXPLAIN ANALYZE show then, have you used ANALYZE/VACUUM ANALYZE +recently? + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 12:07:16 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B74CFD1B4CC + for ; + Thu, 4 Dec 2003 16:06:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62031-10 + for ; + Thu, 4 Dec 2003 12:06:27 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by svr1.postgresql.org (Postfix) with ESMTP id 1629AD1B45A + for ; + Thu, 4 Dec 2003 12:06:27 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by luna.lyris.com (8.12.8/8.12.8) with ESMTP id hB4G6PIt022475 + for ; Thu, 4 Dec 2003 08:06:25 -0800 +Received: from luna.lyris.com ([216.91.57.116]) + by luna.lyris.com (MailMonitor for SMTP v1.2.2 ) ; + Thu, 4 Dec 2003 08:06:25 -0800 (PST) +Received: from cletus.lyris.com (cletus.lyris.com [216.91.56.155]) by + luna.lyris.net with SMTP (MailShield v2.04 - LINUX Jul 17 2001 + 16:58:31); Thu, 04 Dec 2003 08:06:25 -0800 +Subject: tuning questions +From: Jack Coates +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Organization: Lyris Technologies, Inc. +Message-Id: <1070553983.6498.52.camel@cletus.lyris.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.4-9mdk +Date: Thu, 04 Dec 2003 08:06:23 -0800 +Content-Transfer-Encoding: 7bit +X-SMTP-HELO: cletus.lyris.com +X-SMTP-MAIL-FROM: jack@lyris.com +X-SMTP-RCPT-TO: pgsql-performance@postgresql.org +X-SMTP-PEER-INFO: cletus.lyris.com [216.91.56.155] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/71 +X-Sequence-Number: 4931 + +Hi, + +sorry for duplication, I asked this on pgsql-admin first before +realizing it wasn't the appropriate list. + +I'm having trouble optimizing PostgreSQL for an admittedly heinous +worst-case scenario load. + +testbed: +dual P3 1.3 GHz box with 2GB RAM +two IDE 120G drives on separate channels (DMA on), OS on one, DB on the +other, some swap on each (totalling 2.8G). +RH Linux 8. + +I've installed PG 7.3.4 from source (./configure && make && make +install) and from PGDG RPMs and can switch back and forth. I also have +the 7.4 source but haven't done any testing with it yet aside from +starting it and importing some data. + +The application is on another server, and does this torture test: it +builds a large table (~6 million rows in one test, ~18 million in +another). Rows are then pulled in chunks of 4 to 6 thousand, acted on, +and inserted back into another table (which will of course eventually +grow to the full size of the first). + +The problem is that pulling the 4 to 6 thousand rows puts PostgreSQL +into a tail spin: postmaster hammers on CPU anywhere from 90 seconds to +five minutes before returning the data. During this time vmstat shows +that disk activity is up of course, but it doesn't appear to be with +page swapping (free and top and vmstat). + +Another problem is that performance of the 6 million row job is decent +if I stop the job and run a vacuumdb --analyze before letting it +continue; is this something that 7.4 will help with? vacuumb --analyze +doesn't seem to have much effect on the 18 million row job. + +I've tweaked shared buffers to 8192, pushed sort memory to 2048, vacuum +memory to 8192, and effective cache size to 10000. +/proc/sys/kernel/shmmax is set to 1600000000 and /proc/sys/fs/file-max +is set to 65536. Ulimit -n 3192. + +I've read several sites and postings on tuning PG and have tried a +number of different theories, but I'm still not getting the architecture +of how things work. + +thanks, +-- +Jack Coates, Lyris Technologies Applications Engineer +510-549-4350 x148, jack@lyris.com +"Interoperability is the keyword, uniformity is a dead end." + --Olivier Fourdan + + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 12:34:36 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A4873D1B49D + for ; + Thu, 4 Dec 2003 16:34:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70287-04 + for ; + Thu, 4 Dec 2003 12:34:01 -0400 (AST) +Received: from yertle.kcilink.com (yertle.kcilink.com [216.194.193.105]) + by svr1.postgresql.org (Postfix) with ESMTP id A30A4D1B4A1 + for ; + Thu, 4 Dec 2003 12:34:00 -0400 (AST) +Received: by yertle.kcilink.com (Postfix, from userid 100) + id 3B86E2178B; Thu, 4 Dec 2003 11:33:59 -0500 (EST) +From: Vivek Khera +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Message-ID: <16335.25079.106697.7521@yertle.int.kciLink.com> +Date: Thu, 4 Dec 2003 11:33:59 -0500 +To: pgsql-performance@postgresql.org +Subject: Re: autovacuum daemon stops doing work after about an hour +In-Reply-To: <1070516326.1455.11.camel@zedora.zeut.net> +References: <16332.63508.196365.801418@yertle.int.kciLink.com> + <1070516326.1455.11.camel@zedora.zeut.net> +X-Mailer: VM 7.17 under 21.4 (patch 14) "Reasonable Discussion" XEmacs Lucid +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/72 +X-Sequence-Number: 4932 + +>>>>> "MTO" == Matthew T O'Connor writes: + +>> Then it just sits there. I started it at 11:35am, and it is now +>> 3:30pm. + +MTO> Weird.... Alphabetically speaking, is vkmlm."public"."user_list" be the +MTO> last table in the last schema in the last database? You are running + +conveniently, yes it is... + +MTO> with -d4, so you would get a message about going to sleep shortly after +MTO> dealing with the last table, but you didn't get the sleep message, so I +MTO> don't think the problem is that pg_autovacuum is sleeping for an +MTO> inordinate amount time. + +The only sleep logged was + +[2003-12-03 04:47:13 PM] 1 All DBs checked in: 84996853 usec, will sleep for 469 secs. + + +Here's all it did on yesterday afternoon's "hour of work": + +[2003-12-03 04:45:48 PM] Performing: ANALYZE "public"."url_track" +[2003-12-03 04:46:27 PM] Performing: ANALYZE "public"."msg_recipients" +[2003-12-03 04:46:55 PM] Performing: ANALYZE "public"."deliveries" +[2003-12-03 04:46:55 PM] Performing: ANALYZE "public"."user_list" +[2003-12-03 04:47:12 PM] Performing: ANALYZE "public"."sessions" +[2003-12-03 04:55:02 PM] Performing: ANALYZE "public"."url_track" +[2003-12-03 04:55:22 PM] Performing: VACUUM ANALYZE "public"."msg_recipients" +[2003-12-03 05:40:11 PM] Performing: VACUUM ANALYZE "public"."user_list" + +then 18 minutes later, it reported: + +[2003-12-03 05:58:25 PM] select relfilenode,reltuples,relpages from pg_class where relfilenode=18588202 +[2003-12-03 05:58:25 PM] table name: vkmlm."public"."user_list" +[2003-12-03 05:58:25 PM] relfilenode: 18588202; relisshared: 0 +[2003-12-03 05:58:25 PM] reltuples: 9; relpages: 427920 +[2003-12-03 05:58:25 PM] curr_analyze_count: 2559236; cur_delete_count: 2475824 +[2003-12-03 05:58:25 PM] ins_at_last_analyze: 2559236; del_at_last_vacuum: 2475824 +[2003-12-03 05:58:25 PM] insert_threshold: 509; delete_threshold 1001 + +and stopped doing anything. + + +MTO> when you kill it, do you get a core file? Could you do a backtrace and +MTO> see where pg_autovacuum is hung up? + +nope. unfortunately my PG libs are without debugging, too. I'll +rebuild pg_autovacuum with debugging and run it under gdb so I can see +where it gets stuck. + +I'll report back when I find something. I just wanted to check first +if anyone else ran into this. + +From pgsql-performance-owner@postgresql.org Thu Dec 4 13:00:42 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C53B3D1B444 + for ; + Thu, 4 Dec 2003 17:00:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 74130-08 + for ; + Thu, 4 Dec 2003 12:59:43 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A207D1B446 + for ; + Thu, 4 Dec 2003 12:59:37 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4022070; Thu, 04 Dec 2003 09:00:25 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Jack Coates , pgsql-performance@postgresql.org +Subject: Re: tuning questions +Date: Thu, 4 Dec 2003 08:59:06 -0800 +User-Agent: KMail/1.4.3 +References: <1070553983.6498.52.camel@cletus.lyris.com> +In-Reply-To: <1070553983.6498.52.camel@cletus.lyris.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200312040859.06963.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/74 +X-Sequence-Number: 4933 + +Jack, + +> The application is on another server, and does this torture test: it +> builds a large table (~6 million rows in one test, ~18 million in +> another). Rows are then pulled in chunks of 4 to 6 thousand, acted on, +> and inserted back into another table (which will of course eventually +> grow to the full size of the first). + +>e tweaked shared buffers to 8192, pushed sort memory to 2048, vacuum +> memory to 8192, and effective cache size to 10000. +> /proc/sys/kernel/shmmax is set to 1600000000 and /proc/sys/fs/file-max +> is set to 65536. Ulimit -n 3192. + +Have you read this? +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +Actually, your situation is not "worst case". For one thing, your process is +effectively single-user; this allows you to throw all of your resources at +one user. The problem is that your settings have effectively throttled PG +at a level appropriate to a many-user and/or multi-purpose system. You need +to "open them up". + +For something involving massive updating/transformation like this, once you've +done the basics (see that URL above) the main settings which will affect you +are sort_mem and checkpoint_segments, both of which I'd advise jacking way up +(test by increments). Raising wal_buffers wouldn't hurt either. + +Also, give some thought to running VACUUM and/or ANALYZE between segments of +your procedure. Particularly if you do updates to many rows of a table and +then query based on the changed data, it is vital to run an ANALYZE first, +and usually a good idea to run a VACUUM if it was an UPDATE or DELETE and not +an INSERT. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Thu Dec 4 13:00:38 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F26C7D1B49B + for ; + Thu, 4 Dec 2003 17:00:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75349-03 + for ; + Thu, 4 Dec 2003 12:59:53 -0400 (AST) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id 3D5DDD1B464 + for ; + Thu, 4 Dec 2003 12:59:52 -0400 (AST) +Received: (qmail 25797 invoked from network); 4 Dec 2003 16:59:55 -0000 +Received: from localhost (HELO squeegit) (threshar@127.0.0.1) + by localhost with SMTP; 4 Dec 2003 16:59:55 -0000 +Date: Thu, 4 Dec 2003 11:59:32 -0500 +From: Jeff +To: Jack Coates +Cc: pgsql-performance@postgresql.org +Subject: Re: tuning questions +Message-Id: <20031204115932.154eebed.threshar@torgo.978.org> +In-Reply-To: <1070553983.6498.52.camel@cletus.lyris.com> +References: <1070553983.6498.52.camel@cletus.lyris.com> +X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i686-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/73 +X-Sequence-Number: 4934 + +On Thu, 04 Dec 2003 08:06:23 -0800 +Jack Coates wrote: + +> testbed: +> dual P3 1.3 GHz box with 2GB RAM +> two IDE 120G drives on separate channels (DMA on), OS on one, DB on +> the other, some swap on each (totalling 2.8G). +> RH Linux 8. + +Side Note: be sure to turn off write caching on those disks or you may +have data corruption in the event of a failure + +> The problem is that pulling the 4 to 6 thousand rows puts PostgreSQL +> into a tail spin: postmaster hammers on CPU anywhere from 90 seconds +> to five minutes before returning the data. During this time vmstat +> shows that disk activity is up of course, but it doesn't appear to be +> with page swapping (free and top and vmstat). +> +Have you tried modifying the app to retrieve the rows in smaller chunks? +(use a cursor). this way it only needs to alloate memory to hold say, +100 rows at a time instead of 6000. + +Also, have you explain analyze'd your queries to make sure PG is picking +a good plan to execute? + +> I've tweaked shared buffers to 8192, pushed sort memory to 2048, +> vacuum memory to 8192, and effective cache size to 10000. +> /proc/sys/kernel/shmmax is set to 1600000000 and /proc/sys/fs/file-max +> is set to 65536. Ulimit -n 3192. + +you should set effective cache size bigger, especially with 2GB of +memory. effective_cache_size tells PG 'about' how much data it cna +expect the OS to cache. + +and.. I'm not sure about your query, but perhaps the sort of those 6000 +rows is spilling to disk? If you look in explain analyze you'll see in +the "Sort" step(s) it will tell you how many rows and how "wide" they +are. If rows * width > sort_mem, it will have to spill the sort to +disk, which is slow. + +If you post query info and explain analyze's we can help optimize the +query itself. + + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + +From pgsql-performance-owner@postgresql.org Thu Dec 4 13:28:58 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BB0CD1B4C4 + for ; + Thu, 4 Dec 2003 17:28:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81423-01 + for ; + Thu, 4 Dec 2003 13:28:21 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id C3F73D1B4C2 + for ; + Thu, 4 Dec 2003 13:28:20 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hB4HSJbI029103 + for ; Thu, 4 Dec 2003 17:28:19 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hB4H6SMY025766 + for pgsql-performance@postgresql.org; Thu, 4 Dec 2003 17:06:28 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Has anyone run on the new G5 yet +Date: Thu, 04 Dec 2003 09:06:33 -0800 +Organization: Hub.Org Networking Services +Lines: 12 +Message-ID: +References: <3FCE5855.5040403@earthlink.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.5) Gecko/20031007 +X-Accept-Language: en-us, en +In-Reply-To: <3FCE5855.5040403@earthlink.net> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/76 +X-Sequence-Number: 4936 + +Sean Shanny wrote: +> +> First question is do we gain anything by moving the RH Enterprise +> version of Linux in terms of performance, mainly in the IO realm as we +> are not CPU bound at all? Second and more radical, has anyone run +> postgreSQL on the new Apple G5 with an XRaid system? This seems like a +> great value combination. Fast CPU, wide bus, Fibre Channel IO, 2.5TB +> all for ~17k. + +Seems like a great value but until Apple produces a G5 that supports +ECC, I'd pass on them. + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 13:10:29 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AD265D1B450 + for ; + Thu, 4 Dec 2003 17:10:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75122-07 + for ; + Thu, 4 Dec 2003 13:09:55 -0400 (AST) +Received: from mail.dsvr.co.uk (mail.dsvr.co.uk [212.69.192.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 850D8D1B49A + for ; + Thu, 4 Dec 2003 13:09:54 -0400 (AST) +Received: from dsvr.net (eth0.rt1.o1-1.tck.dsvr.net [::ffff:212.69.216.20]) + by mail.dsvr.co.uk with esmtp; Thu, 04 Dec 2003 17:09:53 +0000 +Message-ID: <3FCF6B2F.3070802@dsvr.net> +Date: Thu, 04 Dec 2003 17:13:19 +0000 +From: Rob Fielding +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20031119 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: tuning questions +References: <1070553983.6498.52.camel@cletus.lyris.com> +In-Reply-To: <1070553983.6498.52.camel@cletus.lyris.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/75 +X-Sequence-Number: 4935 + + +> +> I've tweaked shared buffers to 8192, pushed sort memory to 2048, vacuum +> memory to 8192, and effective cache size to 10000. +> /proc/sys/kernel/shmmax is set to 1600000000 and /proc/sys/fs/file-max +> is set to 65536. Ulimit -n 3192. + +Your sharedmemory is too high, and not even being used effectivey. Your +other settings are too low. + +Ball park guessing here, but I'd say first read (and understand) this: + +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +Then make shared memory about 10-20% available ram, and set: + +((shmmax/1024) - ( 14.2 * max_connections ) - 250 ) / 8.2 = shared_buffers + +decrease random_page_cost to 0.3 and wack up sort mem by 16 times, +effective cache size to about 50% RAM (depending on your other settings) +and try that for starters. + + +-- + +Rob Fielding +rob@dsvr.net + +www.dsvr.co.uk Development Designer Servers Ltd + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 13:46:41 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D91CD1B43F + for ; + Thu, 4 Dec 2003 17:46:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 83381-02 + for ; + Thu, 4 Dec 2003 13:46:08 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 8342DD1B441 + for ; + Thu, 4 Dec 2003 13:46:03 -0400 (AST) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id hB4HhWDW022521; + Thu, 4 Dec 2003 10:43:32 -0700 (MST) +Date: Thu, 4 Dec 2003 10:26:38 -0700 (MST) +From: "scott.marlowe" +To: Jack Coates +Cc: +Subject: Re: tuning questions +In-Reply-To: <1070553983.6498.52.camel@cletus.lyris.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/77 +X-Sequence-Number: 4937 + +On Thu, 4 Dec 2003, Jack Coates wrote: + +> Another problem is that performance of the 6 million row job is decent +> if I stop the job and run a vacuumdb --analyze before letting it +> continue; is this something that 7.4 will help with? vacuumb --analyze +> doesn't seem to have much effect on the 18 million row job. + +Just to add to what the others have said here, you probably want to run +the pg_autovacuum daemon in the background. It comes with 7.4 but will +work fine with 7.3. + + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 13:58:13 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 95C70D1B474 + for ; + Thu, 4 Dec 2003 17:58:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85015-03 + for ; + Thu, 4 Dec 2003 13:57:39 -0400 (AST) +Received: from rlx13.zapatec.com (66-117-144-213.zapatec.lmi.net + [66.117.144.213]) + by svr1.postgresql.org (Postfix) with ESMTP id 8AFFED1B45B + for ; + Thu, 4 Dec 2003 13:57:38 -0400 (AST) +Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) + by rlx13.zapatec.com (Postfix) with ESMTP id E7059A941 + for ; + Thu, 4 Dec 2003 09:57:38 -0800 (PST) +Received: (from dror@localhost) + by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id hB4Hvcjh058970 + for pgsql-performance@postgresql.org; + Thu, 4 Dec 2003 09:57:38 -0800 (PST) (envelope-from dror) +Date: Thu, 4 Dec 2003 09:57:38 -0800 +From: Dror Matalon +To: pgsql-performance@postgresql.org +Subject: Re: tuning questions +Message-ID: <20031204175738.GD34796@rlx11.zapatec.com> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <20031204115932.154eebed.threshar@torgo.978.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20031204115932.154eebed.threshar@torgo.978.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/78 +X-Sequence-Number: 4938 + +On Thu, Dec 04, 2003 at 11:59:32AM -0500, Jeff wrote: +> On Thu, 04 Dec 2003 08:06:23 -0800 +> Jack Coates wrote: +> +> > testbed: +> > dual P3 1.3 GHz box with 2GB RAM +> > two IDE 120G drives on separate channels (DMA on), OS on one, DB on +> > the other, some swap on each (totalling 2.8G). +> > RH Linux 8. +> +> Side Note: be sure to turn off write caching on those disks or you may +> have data corruption in the event of a failure + +I've seen this comment several times from different people. +Would someone care to explain how you would get data corruption? I +thought that the whole idea of the log is to provide a journal similar +to what you get in a journaling file system. + +In other words, the db writes a series of transactions to the log and marks +that "log entry" (don't know the right nomeclature) as valid. When the db +crashes, it reads the log, and discards the last "log entry" if it wasn't +marked as valid, and "replays" any transactions that haven't been +commited ot the db. The end result being that you might loose your last +transaction(s) if the db crashes, but nothing ever gets corrupted. + +So what am I missing in this picture? + +Regards, + +Dror + +-- +Dror Matalon +Zapatec Inc +1700 MLK Way +Berkeley, CA 94709 +http://www.fastbuzz.com +http://www.zapatec.com + +From pgsql-performance-owner@postgresql.org Thu Dec 4 14:17:45 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DA417D1B49B + for ; + Thu, 4 Dec 2003 18:17:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88924-03 + for ; + Thu, 4 Dec 2003 14:17:07 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id C8DC2D1B444 + for ; + Thu, 4 Dec 2003 14:17:05 -0400 (AST) +Received: from [66.219.92.2] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4022445; Thu, 04 Dec 2003 10:17:55 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "scott.marlowe" , + Jack Coates +Subject: Re: tuning questions +Date: Thu, 4 Dec 2003 10:03:52 -0800 +User-Agent: KMail/1.4.3 +Cc: +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200312041003.52985.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/81 +X-Sequence-Number: 4941 + +Scott, + +> Just to add to what the others have said here, you probably want to run= +=20 +> the pg_autovacuum daemon in the background. It comes with 7.4 but will= +=20 +> work fine with 7.3.=20=20 + +I don't recommend using pg_autovacuum with a data transformation task. pg= +_av=20 +is designed for "regular use" not huge batch tasks. + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 14:08:34 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 71886D1B444 + for ; + Thu, 4 Dec 2003 18:08:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85878-05 + for ; + Thu, 4 Dec 2003 14:07:59 -0400 (AST) +Received: from indygecko.com (h24-71-76-41.ok.shawcable.net [24.71.76.41]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B4D9D1B443 + for ; + Thu, 4 Dec 2003 14:07:58 -0400 (AST) +Received: from indy ([::ffff:192.168.10.10]) + by indygecko.com with esmtp; Thu, 04 Dec 2003 10:07:56 -0800 +Subject: Re: tuning questions +From: Jord Tanner +To: Dror Matalon +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20031204175738.GD34796@rlx11.zapatec.com> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <20031204115932.154eebed.threshar@torgo.978.org> + <20031204175738.GD34796@rlx11.zapatec.com> +Message-Id: <1070561276.5586.188.camel@gecko.indygecko.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.4.5 +Date: Thu, 04 Dec 2003 10:07:56 -0800 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/79 +X-Sequence-Number: 4939 + +If I understand the problem correctly, the issue is that IDE drives +signal that data has been written to disk when they actually are holding +the data in the write cache. In the case of a power down (and I remember +someone showing some test results confirming this, check the list +archive) the data in the drive write cache is lost, resulting in +corrupted logs. + +Anyone else have more details? + +Jord Tanner + +On Thu, 2003-12-04 at 09:57, Dror Matalon wrote: +> On Thu, Dec 04, 2003 at 11:59:32AM -0500, Jeff wrote: +> > On Thu, 04 Dec 2003 08:06:23 -0800 +> > Jack Coates wrote: +> > +> > > testbed: +> > > dual P3 1.3 GHz box with 2GB RAM +> > > two IDE 120G drives on separate channels (DMA on), OS on one, DB on +> > > the other, some swap on each (totalling 2.8G). +> > > RH Linux 8. +> > +> > Side Note: be sure to turn off write caching on those disks or you may +> > have data corruption in the event of a failure +> +> I've seen this comment several times from different people. +> Would someone care to explain how you would get data corruption? I +> thought that the whole idea of the log is to provide a journal similar +> to what you get in a journaling file system. +> +> In other words, the db writes a series of transactions to the log and marks +> that "log entry" (don't know the right nomeclature) as valid. When the db +> crashes, it reads the log, and discards the last "log entry" if it wasn't +> marked as valid, and "replays" any transactions that haven't been +> commited ot the db. The end result being that you might loose your last +> transaction(s) if the db crashes, but nothing ever gets corrupted. +> +> So what am I missing in this picture? +> +> Regards, +> +> Dror +-- +Jord Tanner + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 14:12:28 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A87DBD1B43F + for ; + Thu, 4 Dec 2003 18:12:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 87707-03 + for ; + Thu, 4 Dec 2003 14:11:53 -0400 (AST) +Received: from mail.libertyrms.com (unknown [209.167.124.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 4630CD1B468 + for ; + Thu, 4 Dec 2003 14:11:52 -0400 (AST) +Received: from [10.1.2.146] (helo=dba3.int.libertyrms.info) + by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) + id 1ARxxA-0003CA-00 + for ; Thu, 04 Dec 2003 13:11:52 -0500 +Received: by dba3.int.libertyrms.info (Postfix, from userid 1019) + id 6889A138F4; Thu, 4 Dec 2003 13:11:52 -0500 (EST) +Date: Thu, 4 Dec 2003 13:11:52 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: tuning questions +Message-ID: <20031204181152.GO6080@libertyrms.info> +Mail-Followup-To: Andrew Sullivan , + pgsql-performance@postgresql.org +References: <1070553983.6498.52.camel@cletus.lyris.com> + <20031204115932.154eebed.threshar@torgo.978.org> + <20031204175738.GD34796@rlx11.zapatec.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20031204175738.GD34796@rlx11.zapatec.com> +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/80 +X-Sequence-Number: 4940 + +On Thu, Dec 04, 2003 at 09:57:38AM -0800, Dror Matalon wrote: +> +> I've seen this comment several times from different people. +> Would someone care to explain how you would get data corruption? I +> thought that the whole idea of the log is to provide a journal similar +> to what you get in a journaling file system. + +> So what am I missing in this picture? + +That a journalling file system can _also_ have file corruption if you +have write caching enabled and no battery back up. If the drive +tells the OS, "Yep! It's all on the disk!" bit it is _not_ actually +scribed in the little bitty magnetic patterns -- and at that very +moment, the power goes away -- the data that was reported to have been +on the disk, but which was actually _not_ on the disk, is no longer +anywhere. (Well, except in the past. But time travel was disabled +some versions ago. ;-) + +A + +-- +---- +Andrew Sullivan 204-4141 Yonge Street +Afilias Canada Toronto, Ontario Canada + M2P 2A8 + +1 416 646 3304 x110 + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 14:31:13 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 07530D1B474 + for ; + Thu, 4 Dec 2003 18:30:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86836-10 + for ; + Thu, 4 Dec 2003 14:30:15 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id C7440D1B483 + for ; + Thu, 4 Dec 2003 14:30:13 -0400 (AST) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id hB4ITPDW025767; + Thu, 4 Dec 2003 11:29:25 -0700 (MST) +Date: Thu, 4 Dec 2003 11:12:30 -0700 (MST) +From: "scott.marlowe" +To: Josh Berkus +Cc: Jack Coates , +Subject: Re: tuning questions +In-Reply-To: <200312041003.52985.josh@agliodbs.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/82 +X-Sequence-Number: 4942 + +On Thu, 4 Dec 2003, Josh Berkus wrote: + +> Scott, +> +> > Just to add to what the others have said here, you probably want to run +> > the pg_autovacuum daemon in the background. It comes with 7.4 but will +> > work fine with 7.3. +> +> I don't recommend using pg_autovacuum with a data transformation task. pg_av +> is designed for "regular use" not huge batch tasks. + +What bad thing is likely to happen if it's used here? Fire too often or +use too much I/O bandwidth? Would that be fixed by the patch being tested +to introduce a delay every x pages of vacuuming? + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 14:36:52 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C724D1B49E + for ; + Thu, 4 Dec 2003 18:36:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88923-07 + for ; + Thu, 4 Dec 2003 14:36:05 -0400 (AST) +Received: from sardegna.mbigroup.it (unknown [151.8.40.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BFEFD1B444 + for ; + Thu, 4 Dec 2003 14:36:03 -0400 (AST) +Received: from sicilia.pisa.mbigroup.it (localhost [127.0.0.1]) + by sardegna.mbigroup.it (8.11.6/8.8.7) with ESMTP id hB4IZxe02358; + Thu, 4 Dec 2003 19:35:59 +0100 +Received: from bigfoot.com (canarie.pisa.mbigroup.it [192.168.9.30]) + by sicilia.pisa.mbigroup.it (8.11.6/8.11.6) with ESMTP id hB4IZs301619; + Thu, 4 Dec 2003 19:35:54 +0100 +Message-ID: <3FCF7E74.9060604@bigfoot.com> +Date: Thu, 04 Dec 2003 19:35:32 +0100 +From: Gaetano Mendola +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031202 Thunderbird/0.4RC1 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Cc: Vivek Khera +Subject: Re: autovacuum daemon stops doing work after about an hour +References: <16332.63508.196365.801418@yertle.int.kciLink.com> + <1070516326.1455.11.camel@zedora.zeut.net> + <16335.25079.106697.7521@yertle.int.kciLink.com> +In-Reply-To: <16335.25079.106697.7521@yertle.int.kciLink.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/83 +X-Sequence-Number: 4943 + +Vivek Khera wrote: + +>>>>>>"MTO" == Matthew T O'Connor writes: +> +> +>>>Then it just sits there. I started it at 11:35am, and it is now +>>>3:30pm. +> +> +> MTO> Weird.... Alphabetically speaking, is vkmlm."public"."user_list" be the +> MTO> last table in the last schema in the last database? You are running +> +> conveniently, yes it is... +> +> MTO> with -d4, so you would get a message about going to sleep shortly after +> MTO> dealing with the last table, but you didn't get the sleep message, so I +> MTO> don't think the problem is that pg_autovacuum is sleeping for an +> MTO> inordinate amount time. +> +> The only sleep logged was +> +> [2003-12-03 04:47:13 PM] 1 All DBs checked in: 84996853 usec, will sleep for 469 secs. + +What I seen is: + + +# tail -f auto.log +[2003-12-04 07:10:18 PM] reltuples: 72; relpages: 1 +[2003-12-04 07:10:18 PM] curr_analyze_count: 72; cur_delete_count: 0 +[2003-12-04 07:10:18 PM] ins_at_last_analyze: 72; del_at_last_vacuum: 0 +[2003-12-04 07:10:18 PM] insert_threshold: 572; delete_threshold 536 +[2003-12-04 07:10:18 PM] table name: empdb."public"."contracts" +[2003-12-04 07:10:18 PM] relfilenode: 17784; relisshared: 0 +[2003-12-04 07:10:18 PM] reltuples: 347; relpages: 5 +[2003-12-04 07:10:18 PM] curr_analyze_count: 347; cur_delete_count: 0 +[2003-12-04 07:10:18 PM] ins_at_last_analyze: 347; del_at_last_vacuum: 0 +[2003-12-04 07:10:18 PM] insert_threshold: 847; delete_threshold 673 + + +[ 5 minutes of delay ] <----- LOOK THIS + + +[2003-12-04 07:10:18 PM] 503 All DBs checked in: 179396 usec, will sleep +for 300 secs. +[2003-12-04 07:15:19 PM] 504 All DBs checked in: 98814 usec, will sleep +for 300 secs. + +I think is a good Idea put a fflush after: + +fprintf(LOGOUTPUT, "[%s] %s\n", timebuffer, logentry); + + +Regards +Gaetano Mendola + + + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 14:58:25 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E913D1B441 + for ; + Thu, 4 Dec 2003 18:58:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 93647-03 + for ; + Thu, 4 Dec 2003 14:57:52 -0400 (AST) +Received: from uhh.alcaron.ee (uhh.alcaron.ee [194.204.62.169]) + by svr1.postgresql.org (Postfix) with ESMTP id 43CD0D1B433 + for ; + Thu, 4 Dec 2003 14:57:51 -0400 (AST) +Received: from iff by uhh.alcaron.ee with local + id 1ARyff-00048V-00; Thu, 04 Dec 2003 20:57:51 +0200 +Date: Thu, 4 Dec 2003 20:57:51 +0200 +To: pgsql-performance@postgresql.org +Subject: Slow UPADTE, compared to INSERT +Message-ID: <20031204185751.GA15893@alcaron.ee> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.3.28i +From: Ivar Zarans +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/84 +X-Sequence-Number: 4944 + +Hello! + +I am relative newcomer to SQL and PostgreSQL world, so please forgive me +if this question is stupid. + +I am experiencing strange behaviour, where simple UPDATE of one field is +very slow, compared to INSERT into table with multiple indexes. I have +two tables - one with raw data records (about 24000), where one field +contains status information (varchar(10)). First table has no indexes, +only primary key (recid). Second table contains processed records - some +fields are same as first table, others are calculated during processing. +Records are processed by Python script, which uses PyPgSQL for PostgreSQL +access. + +Processing is done by selecting all records from table1 where status +matches certain criteria (import). Each record is processed and results +are inserted into table2, after inserting status field on same record in +table1 is updated with new value (done). Update statement itself is +extremely simple: "update table1 set status = 'done' where recid = ..." + +Most interesting is, that insert takes 0.004 seconds in average, but +update takes 0.255 seconds in average. Processing of 24000 records took +around 1 hour 20 minutes. + +Then i changed processing logic not to update every record in table1 +after processing. Instead i did insert recid value into temporary table +and updated records in table1 after all records were processed and +inserted into table2: +UPDATE table1 SET Status = 'done' WHERE recid IN (SELECT recid FROM temptable) + +This way i got processing time of 24000 records down to about 16 minutes. +About 13 minutes from this took last UPDATE statement. + +Why is UPDATE so slow compared to INSERT? I would expect more or less +similar performance, or slower on insert since table2 has four indexes +in addition to primary key, table1 has only primary key, which is used +on update. Am i doing something wrong or is this normal? + +I am using PostgreSQL 7.3.4, Debian/GNU Linux 3.0 (Woody), +kernel 2.4.21, Python 2.3.2, PyPgSQL 2.4 + +-- +Ivar Zarans + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 15:17:26 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BF9C0D1B446 + for ; + Thu, 4 Dec 2003 19:17:25 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 98924-02 + for ; + Thu, 4 Dec 2003 15:16:55 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by svr1.postgresql.org (Postfix) with ESMTP id 537A2D1B48E + for ; + Thu, 4 Dec 2003 15:16:53 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by luna.lyris.com (8.12.8/8.12.8) with ESMTP id hB4JGrIt025290 + for ; Thu, 4 Dec 2003 11:16:53 -0800 +Received: from luna.lyris.com ([216.91.57.116]) + by luna.lyris.com (MailMonitor for SMTP v1.2.2 ) ; + Thu, 4 Dec 2003 11:16:53 -0800 (PST) +Received: from cletus.lyris.com (cletus.lyris.com [216.91.56.155]) by + luna.lyris.net with SMTP (MailShield v2.04 - LINUX Jul 17 2001 + 16:58:31); Thu, 04 Dec 2003 11:16:53 -0800 +Subject: Re: tuning questions +From: Jack Coates +To: pgsql-performance +In-Reply-To: <3FCF6AEB.908@dsvr.net> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <3FCF6AEB.908@dsvr.net> +Content-Type: text/plain +Organization: Lyris Technologies, Inc. +Message-Id: <1070565411.13923.70.camel@cletus.lyris.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.4-9mdk +Date: Thu, 04 Dec 2003 11:16:51 -0800 +Content-Transfer-Encoding: 7bit +X-SMTP-HELO: cletus.lyris.com +X-SMTP-MAIL-FROM: jack@lyris.com +X-SMTP-RCPT-TO: pgsql-performance@postgresql.org +X-SMTP-PEER-INFO: cletus.lyris.com [216.91.56.155] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/85 +X-Sequence-Number: 4945 + +On Thu, 2003-12-04 at 09:12, Rob Fielding wrote: +> > +> > I've tweaked shared buffers to 8192, pushed sort memory to 2048, vacuum +> > memory to 8192, and effective cache size to 10000. +> > /proc/sys/kernel/shmmax is set to 1600000000 and /proc/sys/fs/file-max +> > is set to 65536. Ulimit -n 3192. +> +> Your sharedmemory is too high, and not even being used effectivey. Your +> other settings are too low. +> +> Ball park guessing here, but I'd say first read (and understand) this: +> +> http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +I've read it many times, understanding is slower :-) + +> +> Then make shared memory about 10-20% available ram, and set: +> +> ((shmmax/1024) - ( 14.2 * max_connections ) - 250 ) / 8.2 = shared_buffers +> +> decrease random_page_cost to 0.3 and wack up sort mem by 16 times, +> effective cache size to about 50% RAM (depending on your other settings) +> and try that for starters. + +Following this, I've done: +2gb ram += + 2,000,000,000 +bytes + +15 % of that += + 300,000,000 +bytes + +divided by +1024 += + 292,969 +kbytes + +max_conn * +14.2 += + 454 +kbytes + +subtract c4 += + 292,514 +kbytes + +subtract 250 += + 292,264 +kbytes + +divide by 8.2 += + 35,642 +shared_buffers + +performance is unchanged for the 18M job -- pg continues to use ~ +285-300M, system load and memory usage stay the same. I killed that, +deleted from the affected tables, inserted a 6M job, and started a +vacuumdb --anaylze. It's been running for 20 minutes now... + +getting the SQL query better optimized for PG is on my todo list, but +not something I can do right now -- this application is designed to be +cross-platform with MS-SQL, PG, and Oracle so tweaking SQL is a touchy +subject. + +The pgavd conversation is intriguing, but I don't really understand the +role of vacuuming. Would this be a correct statement: "PG needs to +regularly re-evaluate the database in order to adjust itself?" I'm +imagining that it continues to treat the table as a small one until +vacuum informs it that the table is now large? +-- +Jack Coates, Lyris Technologies Applications Engineer +510-549-4350 x148, jack@lyris.com +"Interoperability is the keyword, uniformity is a dead end." + --Olivier Fourdan + + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 15:17:50 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 05124D1B453 + for ; + Thu, 4 Dec 2003 19:17:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 93647-10 + for ; + Thu, 4 Dec 2003 15:17:19 -0400 (AST) +Received: from main.wiredfool.com (dsl231-055-035.sea1.dsl.speakeasy.net + [216.231.55.35]) + by svr1.postgresql.org (Postfix) with ESMTP id 9476DD1B498 + for ; + Thu, 4 Dec 2003 15:17:12 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by main.wiredfool.com (Postfix) with ESMTP id 2573C2728E + for ; + Thu, 4 Dec 2003 11:12:10 -0800 (PST) +Received: from main.wiredfool.com ([127.0.0.1]) + by localhost (cabbage [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 25416-02 for ; + Thu, 4 Dec 2003 11:12:07 -0800 (PST) +Received: from [IPv6:::1] (localhost [127.0.0.1]) + by main.wiredfool.com (Postfix) with ESMTP id 1D9312728D + for ; + Thu, 4 Dec 2003 11:12:07 -0800 (PST) +Mime-Version: 1.0 (Apple Message framework v606) +In-Reply-To: <20031204181152.GO6080@libertyrms.info> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <20031204115932.154eebed.threshar@torgo.978.org> + <20031204175738.GD34796@rlx11.zapatec.com> + <20031204181152.GO6080@libertyrms.info> +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <745F4B76-268E-11D8-848E-0003930F2A6C@soroos.net> +Content-Transfer-Encoding: 7bit +From: Eric Soroos +Subject: Re: tuning questions +Date: Thu, 4 Dec 2003 11:17:08 -0800 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.606) +X-Virus-Scanned: by amavisd-new-20030616-p3 (Debian) at main.wiredfool.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/86 +X-Sequence-Number: 4946 + + +On Dec 4, 2003, at 10:11 AM, Andrew Sullivan wrote: + +> On Thu, Dec 04, 2003 at 09:57:38AM -0800, Dror Matalon wrote: +>> +>> I've seen this comment several times from different people. +>> Would someone care to explain how you would get data corruption? I +>> thought that the whole idea of the log is to provide a journal similar +>> to what you get in a journaling file system. +> +>> So what am I missing in this picture? +> +> That a journalling file system can _also_ have file corruption if you +> have write caching enabled and no battery back up. If the drive +> tells the OS, "Yep! It's all on the disk!" bit it is _not_ actually +> scribed in the little bitty magnetic patterns -- and at that very +> moment, the power goes away -- the data that was reported to have been +> on the disk, but which was actually _not_ on the disk, is no longer +> anywhere. (Well, except in the past. But time travel was disabled +> some versions ago. ;-) + +It's not just a theoretical problem. It's happened to me on a laptop +drive in the last week or so. + +I was testing out dbmail by hammering on it on Panther laptop, hfs+ +journaling enabled, psql 7.4, latest and greatest. I managed to hang +the system hard, requiring a reboot. Psql wouldn't start after the +crash, complaining of a damaged relation and helpfully telling me that +'you may need to restore from backup'. + +No big deal on the data loss, since it was a test/hammering +installation. It would have been nice to be able to drop that relation +or prune the entire database, but I'm sure that would ultimately run +into referential integrity problems. + +eric + + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 15:34:26 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6DD2AD1B445 + for ; + Thu, 4 Dec 2003 19:34:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97909-10 + for ; + Thu, 4 Dec 2003 15:33:38 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 1DDBFD1B483 + for ; + Thu, 4 Dec 2003 15:33:35 -0400 (AST) +Received: from [66.219.92.2] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4022845; Thu, 04 Dec 2003 11:34:25 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Jack Coates , + pgsql-performance +Subject: Re: tuning questions +Date: Thu, 4 Dec 2003 11:20:21 -0800 +User-Agent: KMail/1.4.3 +References: <1070553983.6498.52.camel@cletus.lyris.com> + <3FCF6AEB.908@dsvr.net> + <1070565411.13923.70.camel@cletus.lyris.com> +In-Reply-To: <1070565411.13923.70.camel@cletus.lyris.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200312041120.21124.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/88 +X-Sequence-Number: 4948 + +Jack, + +> Following this, I've done: +> 2gb ram +> =3D +> 2,000,000,000 +> bytes + +This calculation is fun, but I really don't know where you got it from. I= +t=20 +seems quite baroque. What are you trying to set, exactly? + +> getting the SQL query better optimized for PG is on my todo list, but +> not something I can do right now -- this application is designed to be +> cross-platform with MS-SQL, PG, and Oracle so tweaking SQL is a touchy +> subject. + +Well, if you're queries are screwed up, no amount of .conf optimization is= +=20 +going to help you much. You could criticize that PG is less adept than= +=20 +some other systems at re-writing "bad queries", and you would be correct.= +=20=20 +However, there's not much to do about that on existing systems. + +How about posting some sample code? + +> The pgavd conversation is intriguing, but I don't really understand the +> role of vacuuming. Would this be a correct statement: "PG needs to +> regularly re-evaluate the database in order to adjust itself?" I'm +> imagining that it continues to treat the table as a small one until +> vacuum informs it that the table is now large? + +Not Vacuum, Analyze. Otherwise correct. Mind you, in "regular use" where= +=20 +only a small % of the table changes per hour, periodic ANALYZE is fine.=20= +=20 +However, in "batch data transform" analyze statements need to be keyed to t= +he=20 +updates and/or imports. + +BTW, I send a couple of e-mails to the Lyris documentation maintainer about= +=20 +updating out-of-date information about setting up PostgreSQL. I never got= + a=20 +response, and I don't think my changes were made. + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 15:24:11 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DAE58D1B482 + for ; + Thu, 4 Dec 2003 19:24:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 99873-02 + for ; + Thu, 4 Dec 2003 15:23:41 -0400 (AST) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id 7515AD1B45B + for ; + Thu, 4 Dec 2003 15:23:39 -0400 (AST) +Received: (qmail 26680 invoked from network); 4 Dec 2003 19:23:45 -0000 +Received: from localhost (HELO squeegit) (threshar@127.0.0.1) + by localhost with SMTP; 4 Dec 2003 19:23:45 -0000 +Date: Thu, 4 Dec 2003 14:23:20 -0500 +From: Jeff +To: Ivar Zarans +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +Message-Id: <20031204142320.3c021100.threshar@torgo.978.org> +In-Reply-To: <20031204185751.GA15893@alcaron.ee> +References: <20031204185751.GA15893@alcaron.ee> +X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i686-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/87 +X-Sequence-Number: 4947 + +On Thu, 4 Dec 2003 20:57:51 +0200 +Ivar Zarans wrote: +. + +> table1 is updated with new value (done). Update statement itself is +> extremely simple: "update table1 set status = 'done' where recid = +> ..." +> +> Most interesting is, that insert takes 0.004 seconds in average, but +> update takes 0.255 seconds in average. Processing of 24000 records +> took around 1 hour 20 minutes. + +Do you have an index on recid? + +and did you vacuum analyze after you loaded up the data? + +> +> Then i changed processing logic not to update every record in table1 +> after processing. Instead i did insert recid value into temporary +> table and updated records in table1 after all records were processed +> and inserted into table2: +> UPDATE table1 SET Status = 'done' WHERE recid IN (SELECT recid FROM +> temptable) +> + +"IN" queries are terribly slow on versions before 7.4 + +> Why is UPDATE so slow compared to INSERT? I would expect more or less +> similar performance, or slower on insert since table2 has four indexes +> in addition to primary key, table1 has only primary key, which is used +> on update. Am i doing something wrong or is this normal? +> + +Remember, UPDATE has to do all the work of select and more. + +And if you have 4 indexes those will also add to the time (Since it has +to update/add them to the tree) + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + +From pgsql-performance-owner@postgresql.org Thu Dec 4 15:37:10 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D875D1B484 + for ; + Thu, 4 Dec 2003 19:31:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 00227-04 + for ; + Thu, 4 Dec 2003 15:30:37 -0400 (AST) +Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 741C2D1B439 + for ; + Thu, 4 Dec 2003 15:29:59 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id B61F53E80 + for ; + Thu, 4 Dec 2003 14:29:59 -0500 (EST) +Received: from lorax.kcilink.com ([127.0.0.1]) + by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 36778-02-3 for ; + Thu, 4 Dec 2003 14:29:59 -0500 (EST) +Received: from lorax.kciLink.com (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id 120F73E7E + for ; + Thu, 4 Dec 2003 14:29:59 -0500 (EST) +Received: (from news@localhost) + by lorax.kciLink.com (8.12.9p2/8.12.9/Submit) id hB4JTwdo058269 + for pgsql-performance@postgresql.org; + Thu, 4 Dec 2003 14:29:58 -0500 (EST) (envelope-from news) +To: pgsql-performance@postgresql.org +Path: not-for-mail +From: Vivek Khera +Newsgroups: ml.postgres.performance +Subject: Re: autovacuum daemon stops doing work after about an hour +Date: Thu, 04 Dec 2003 14:29:58 -0500 +Organization: Khera Communications, Inc., Rockville, MD +Lines: 29 +Message-ID: +References: <16332.63508.196365.801418@yertle.int.kciLink.com> + <1070516326.1455.11.camel@zedora.zeut.net> +NNTP-Posting-Host: yertle.kcilink.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Trace: lorax.kcilink.com 1070566198 42459 216.194.193.105 (4 Dec 2003 + 19:29:58 GMT) +X-Complaints-To: daemon@kciLink.com +NNTP-Posting-Date: Thu, 4 Dec 2003 19:29:58 +0000 (UTC) +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + berkeley-unix) +Cancel-Lock: sha1:Gxyqdsi8L4gsC/yxpygcCYyn8qQ= +X-Virus-Scanned: by amavisd-new at kciLink.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/89 +X-Sequence-Number: 4949 + +>>>>> "MTO" == Matthew T O'Connor writes: + +>> I'm running Postgres 7.4 release on FreeBSD 4.9-RELEASE. + +MTO> I don't run FreeBSD, so I haven't tested with FreeBSD. Recently Craig +MTO> Boston reported and submitted a patch for a crash on FreeBSD, but that +MTO> doesn't sound like your problem. Could be some other type of platform +MTO> dependent problem. + +Oh lucky me. + +I think I found it. I compiled with -g -O and ran it under gdb, so +the output is line buffered. The last thing it prints out now is +this: + +[2003-12-04 02:11:17 PM] 3 All DBs checked in: -786419782 usec, will sleep for -1272 secs. + +since sleep() takes an unsigned int as its parameter, we are actually +sleeping for 4294966024 seconds == 136 years. + +I recall reading about the negative time to test the dbs +somewhere... I guess I'll get on debugging that. The time keeper in +this box is pretty darned accurate otherwise (using ntpd). + +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +Vivek Khera, Ph.D. Khera Communications, Inc. +Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 +AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ + +From pgsql-performance-owner@postgresql.org Thu Dec 4 15:46:01 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 72C16D1B48E + for ; + Thu, 4 Dec 2003 19:45:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03342-10 + for ; + Thu, 4 Dec 2003 15:45:29 -0400 (AST) +Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) + by svr1.postgresql.org (Postfix) with ESMTP id CD8AED1B521 + for ; + Thu, 4 Dec 2003 15:44:41 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id DF9C73E5B + for ; + Thu, 4 Dec 2003 14:44:42 -0500 (EST) +Received: from lorax.kcilink.com ([127.0.0.1]) + by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 10293-03-5 for ; + Thu, 4 Dec 2003 14:44:42 -0500 (EST) +Received: from lorax.kciLink.com (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id 33E593E16 + for ; + Thu, 4 Dec 2003 14:44:42 -0500 (EST) +Received: (from news@localhost) + by lorax.kciLink.com (8.12.9p2/8.12.9/Submit) id hB4JigwZ033557 + for pgsql-performance@postgresql.org; + Thu, 4 Dec 2003 14:44:42 -0500 (EST) (envelope-from news) +To: pgsql-performance@postgresql.org +Path: not-for-mail +From: Vivek Khera +Newsgroups: ml.postgres.performance +Subject: Re: autovacuum daemon stops doing work after about an hour +Date: Thu, 04 Dec 2003 14:44:41 -0500 +Organization: Khera Communications, Inc., Rockville, MD +Lines: 32 +Message-ID: +References: <16332.63508.196365.801418@yertle.int.kciLink.com> + <1070516326.1455.11.camel@zedora.zeut.net> +NNTP-Posting-Host: yertle.kcilink.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Trace: lorax.kcilink.com 1070567082 32569 216.194.193.105 (4 Dec 2003 + 19:44:42 GMT) +X-Complaints-To: daemon@kciLink.com +NNTP-Posting-Date: Thu, 4 Dec 2003 19:44:42 +0000 (UTC) +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + berkeley-unix) +Cancel-Lock: sha1:ywPj8067Vdc9BlPRneCXMWnBHFc= +X-Virus-Scanned: by amavisd-new at kciLink.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/90 +X-Sequence-Number: 4950 + +>>>>> "MTO" == Matthew T O'Connor writes: + +MTO> I don't run FreeBSD, so I haven't tested with FreeBSD. Recently Craig +MTO> Boston reported and submitted a patch for a crash on FreeBSD, but that + +some more debugging data: + +(gdb) print now +$2 = {tv_sec = 1070565077, tv_usec = 216477} +(gdb) print then +$3 = {tv_sec = 1070561568, tv_usec = 668963} +(gdb) print diff +$4 = -5459981371352 +(gdb) print sleep_secs +$5 = -1272 + +so for some reason, instead of calculating 3508547514 as the diff, it +got a hugely negative number. + +I'll bet it has something to do with the compiler... more debugging +to follow (without -O compilation...) + + + +MTO> ---------------------------(end of broadcast)--------------------------- +MTO> TIP 7: don't forget to increase your free space map settings + +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +Vivek Khera, Ph.D. Khera Communications, Inc. +Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 +AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ + +From pgsql-performance-owner@postgresql.org Thu Dec 4 15:55:33 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B298D1B535 + for ; + Thu, 4 Dec 2003 19:55:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06898-09 + for ; + Thu, 4 Dec 2003 15:55:02 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by svr1.postgresql.org (Postfix) with ESMTP id 9F474D1B445 + for ; + Thu, 4 Dec 2003 15:51:00 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by luna.lyris.com (8.12.8/8.12.8) with ESMTP id hB4JovIt031753; + Thu, 4 Dec 2003 11:50:58 -0800 +Received: from luna.lyris.com ([216.91.57.116]) + by luna.lyris.com (MailMonitor for SMTP v1.2.2 ) ; + Thu, 4 Dec 2003 11:50:57 -0800 (PST) +Received: from cletus.lyris.com (cletus.lyris.com [216.91.56.155]) by + luna.lyris.net with SMTP (MailShield v2.04 - LINUX Jul 17 2001 + 16:58:31); Thu, 04 Dec 2003 11:50:57 -0800 +Subject: Re: tuning questions +From: Jack Coates +To: josh@agliodbs.com +Cc: pgsql-performance +In-Reply-To: <200312041120.21124.josh@agliodbs.com> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <3FCF6AEB.908@dsvr.net> <1070565411.13923.70.camel@cletus.lyris.com> + <200312041120.21124.josh@agliodbs.com> +Content-Type: text/plain +Organization: Lyris Technologies, Inc. +Message-Id: <1070567455.13923.83.camel@cletus.lyris.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.4-9mdk +Date: Thu, 04 Dec 2003 11:50:55 -0800 +Content-Transfer-Encoding: 7bit +X-SMTP-HELO: cletus.lyris.com +X-SMTP-MAIL-FROM: jack@lyris.com +X-SMTP-RCPT-TO: josh@agliodbs.com,pgsql-performance@postgresql.org +X-SMTP-PEER-INFO: cletus.lyris.com [216.91.56.155] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/91 +X-Sequence-Number: 4951 + +On Thu, 2003-12-04 at 11:20, Josh Berkus wrote: +> Jack, +> +> > Following this, I've done: +> > 2gb ram +> > = +> > 2,000,000,000 +> > bytes +> +> This calculation is fun, but I really don't know where you got it from. It +> seems quite baroque. What are you trying to set, exactly? +Message-ID: <3FCF6AEB.908@dsvr.net> +Date: Thu, 04 Dec 2003 17:12:11 +0000 +From: Rob Fielding +> > getting the SQL query better optimized for PG is on my todo list, but +> > not something I can do right now -- this application is designed to be +> > cross-platform with MS-SQL, PG, and Oracle so tweaking SQL is a touchy +> > subject. +> +> Well, if you're queries are screwed up, no amount of .conf optimization is +> going to help you much. You could criticize that PG is less adept than +> some other systems at re-writing "bad queries", and you would be correct. +> However, there's not much to do about that on existing systems. +> +> How about posting some sample code? + +Tracking that down in CVS and translating from C++ is going to take a +while -- is there a way to get PG to log the queries it's receiving? + +> +> > The pgavd conversation is intriguing, but I don't really understand the +> > role of vacuuming. Would this be a correct statement: "PG needs to +> > regularly re-evaluate the database in order to adjust itself?" I'm +> > imagining that it continues to treat the table as a small one until +> > vacuum informs it that the table is now large? +> +> Not Vacuum, Analyze. Otherwise correct. Mind you, in "regular use" where +> only a small % of the table changes per hour, periodic ANALYZE is fine. +> However, in "batch data transform" analyze statements need to be keyed to the +> updates and/or imports. +> +> BTW, I send a couple of e-mails to the Lyris documentation maintainer about +> updating out-of-date information about setting up PostgreSQL. I never got a +> response, and I don't think my changes were made. + +She sits on the other side of the cube wall from me, and if I find a +decent config it's going into the manual -- consider this a golden +opportunity :-) + +-- +Jack Coates, Lyris Technologies Applications Engineer +510-549-4350 x148, jack@lyris.com +"Interoperability is the keyword, uniformity is a dead end." + --Olivier Fourdan + + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 15:55:50 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 70EC5D1B8F5 + for ; + Thu, 4 Dec 2003 19:55:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08063-03 + for ; + Thu, 4 Dec 2003 15:55:19 -0400 (AST) +Received: from uhh.alcaron.ee (uhh.alcaron.ee [194.204.62.169]) + by svr1.postgresql.org (Postfix) with ESMTP id 316C8D1B4A6 + for ; + Thu, 4 Dec 2003 15:51:21 -0400 (AST) +Received: from iff by uhh.alcaron.ee with local + id 1ARzVR-0004Ia-00; Thu, 04 Dec 2003 21:51:21 +0200 +Date: Thu, 4 Dec 2003 21:51:21 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +Message-ID: <20031204195121.GA16497@alcaron.ee> +References: <20031204185751.GA15893@alcaron.ee> + <20031204142320.3c021100.threshar@torgo.978.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20031204142320.3c021100.threshar@torgo.978.org> +User-Agent: Mutt/1.3.28i +From: Ivar Zarans +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/92 +X-Sequence-Number: 4952 + +On Thu, Dec 04, 2003 at 02:23:20PM -0500, Jeff wrote: + +> > Most interesting is, that insert takes 0.004 seconds in average, but +> > update takes 0.255 seconds in average. Processing of 24000 records +> > took around 1 hour 20 minutes. +> +> Do you have an index on recid? + +Yes, this is primary key of table1 + +> and did you vacuum analyze after you loaded up the data? + +No, this is running as nightly cronjob. All tests were done during one +day, so no vacuum was done. + +> "IN" queries are terribly slow on versions before 7.4 + +OK, this is useful to know :) + +> > Why is UPDATE so slow compared to INSERT? I would expect more or less +> > similar performance, or slower on insert since table2 has four indexes +> > in addition to primary key, table1 has only primary key, which is used +> > on update. Am i doing something wrong or is this normal? + +> Remember, UPDATE has to do all the work of select and more. +> +> And if you have 4 indexes those will also add to the time (Since it has +> to update/add them to the tree) + +My primary concern is performance difference between INSERT and UPDATE +in my first tests. There i did select from table1, fetched record, +processed it and inserted into table2. Then updated status of fetched +record in table1. Repeated in cycle as long as fetch returned record. +Average time for INSERT was 0.004 seconds, average time for UPDATE 0.255 +seconds. Update was done as "update table1 set status = 'done' where +recid = xxxx". As far as i understand, this type of simple update should +be faster, compared to INSERT into table with four indexes, but in my +case it is more than 60 times slower. Why?? + +My second tests were done with temporary table and update query as: +"UPDATE table1 SET Status = 'done' WHERE recid IN (SELECT recid FROM +temptable)". It is still slower than INSERT, but more or less +acceptable. Compared to my first tests overall processing time dropped +from 1 hour and 20 minutes to 16 minutes. + +So, my question remains - why is simple update more than 60 times +slower, compared to INSERT? Any ideas? + +-- +Ivar Zarans + +From pgsql-performance-owner@postgresql.org Thu Dec 4 16:50:54 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 34795D1B441 + for ; + Thu, 4 Dec 2003 20:28:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14901-06 + for ; + Thu, 4 Dec 2003 16:28:22 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 76791D1B453 + for ; + Thu, 4 Dec 2003 16:28:20 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hB4KSKbI057925 + for ; Thu, 4 Dec 2003 20:28:20 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hB4JwtAg052657 + for pgsql-performance@postgresql.org; Thu, 4 Dec 2003 19:58:55 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Slow UPADTE, compared to INSERT +Date: Thu, 04 Dec 2003 11:59:01 -0800 +Organization: Hub.Org Networking Services +Lines: 16 +Message-ID: +References: <20031204185751.GA15893@alcaron.ee> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +In-Reply-To: <20031204185751.GA15893@alcaron.ee> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/95 +X-Sequence-Number: 4955 + +Ivar Zarans wrote: +> +> I am experiencing strange behaviour, where simple UPDATE of one field is +> very slow, compared to INSERT into table with multiple indexes. I have +> two tables - one with raw data records (about 24000), where one field + +In Postgres and any other DB that uses MVCC (multi-version concurrency), +UPDATES will always be slower than INSERTS. With MVCC, what the DB does +is makes a copy of the record, updates that record and then invalidates +the previous record. This allows maintains a consistent view for anybody +who's reading the DB and also avoids the requirement of row locks. + +If you have to use UPDATE, make sure (1) your UPDATE WHERE clause is +properly indexed and (2) you are running ANALYZE/VACUUM periodically so +the query planner can optimize for your UPDATE statements. + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 16:55:45 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 280A2D1B44C + for ; + Thu, 4 Dec 2003 20:24:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14240-08 + for ; + Thu, 4 Dec 2003 16:23:42 -0400 (AST) +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 D73B4D1B445 + for ; + Thu, 4 Dec 2003 16:23:40 -0400 (AST) +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 1AS00j-0001qN-0V; Thu, 04 Dec 2003 20:23:41 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 3B0F517336; Thu, 4 Dec 2003 20:23:39 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id A787C16C60; Thu, 4 Dec 2003 20:23:37 +0000 (GMT) +From: Richard Huxton +To: Ivar Zarans , pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +Date: Thu, 4 Dec 2003 20:23:36 +0000 +User-Agent: KMail/1.5 +References: <20031204185751.GA15893@alcaron.ee> + <20031204142320.3c021100.threshar@torgo.978.org> + <20031204195121.GA16497@alcaron.ee> +In-Reply-To: <20031204195121.GA16497@alcaron.ee> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200312042023.37050.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/97 +X-Sequence-Number: 4957 + +On Thursday 04 December 2003 19:51, Ivar Zarans wrote: +> +> My second tests were done with temporary table and update query as: +> "UPDATE table1 SET Status = 'done' WHERE recid IN (SELECT recid FROM +> temptable)". It is still slower than INSERT, but more or less +> acceptable. Compared to my first tests overall processing time dropped +> from 1 hour and 20 minutes to 16 minutes. + +Ah - it's probably not the update but the IN. You can rewrite it using PG's +non-standard FROM: + +UPDATE t1 SET status='done' FROM t_tmp WHERE t1.rec_id = t_tmp.rec_id; + +Now that doesn't explain why the update is taking so long. One fifth of a +second is extremely slow. Are you certain that the index is being used? + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Thu Dec 4 16:53:29 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C370D1B443 + for ; + Thu, 4 Dec 2003 20:27:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14628-06 + for ; + Thu, 4 Dec 2003 16:27:26 -0400 (AST) +Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net + [194.217.242.88]) + by svr1.postgresql.org (Postfix) with ESMTP id 29C31D1B476 + for ; + Thu, 4 Dec 2003 16:27:25 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AS04L-0002XU-0U; Thu, 04 Dec 2003 20:27:25 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 924F117336; Thu, 4 Dec 2003 20:27:24 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id CEEFF17331; Thu, 4 Dec 2003 20:27:22 +0000 (GMT) +From: Richard Huxton +To: Jack Coates , josh@agliodbs.com +Subject: Re: tuning questions +Date: Thu, 4 Dec 2003 20:27:22 +0000 +User-Agent: KMail/1.5 +Cc: pgsql-performance +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312041120.21124.josh@agliodbs.com> + <1070567455.13923.83.camel@cletus.lyris.com> +In-Reply-To: <1070567455.13923.83.camel@cletus.lyris.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200312042027.22223.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/96 +X-Sequence-Number: 4956 + +On Thursday 04 December 2003 19:50, Jack Coates wrote: +> +> I'm trying to set Postgres's shared memory usage in a fashion that +> allows it to return requested results quickly. Unfortunately, none of +> these changes allow PG to use more than a little under 300M RAM. +> vacuumdb --analyze is now taking an inordinate amount of time as well +> (40 minutes and counting), so that change needs to be rolled back. + +You don't want PG to use all your RAM, it's designed to let the underlying OS +do a lot of caching for it. Probably worth having a look at vmstat/iostat and +see if it's saturating on I/O. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Thu Dec 4 16:44:09 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 29F7AD1B478 + for ; + Thu, 4 Dec 2003 20:38:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17654-01 + for ; + Thu, 4 Dec 2003 16:38:23 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by svr1.postgresql.org (Postfix) with ESMTP id B2D08D1B44C + for ; + Thu, 4 Dec 2003 16:38:20 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by luna.lyris.com (8.12.8/8.12.8) with ESMTP id hB4KblIt007660; + Thu, 4 Dec 2003 12:37:47 -0800 +Received: from luna.lyris.com ([216.91.57.116]) + by luna.lyris.com (MailMonitor for SMTP v1.2.2 ) ; + Thu, 4 Dec 2003 12:37:47 -0800 (PST) +Received: from cletus.lyris.com (cletus.lyris.com [216.91.56.155]) by + luna.lyris.net with SMTP (MailShield v2.04 - LINUX Jul 17 2001 + 16:58:31); Thu, 04 Dec 2003 12:37:47 -0800 +Subject: Re: tuning questions +From: Jack Coates +To: Richard Huxton +Cc: josh@agliodbs.com, + pgsql-performance +In-Reply-To: <200312042027.22223.dev@archonet.com> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312041120.21124.josh@agliodbs.com> + <1070567455.13923.83.camel@cletus.lyris.com> + <200312042027.22223.dev@archonet.com> +Content-Type: text/plain +Organization: Lyris Technologies, Inc. +Message-Id: <1070570264.13923.88.camel@cletus.lyris.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.4-9mdk +Date: Thu, 04 Dec 2003 12:37:45 -0800 +Content-Transfer-Encoding: 7bit +X-SMTP-HELO: cletus.lyris.com +X-SMTP-MAIL-FROM: jack@lyris.com +X-SMTP-RCPT-TO: dev@archonet.com, josh@agliodbs.com, + pgsql-performance@postgresql.org +X-SMTP-PEER-INFO: cletus.lyris.com [216.91.56.155] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/93 +X-Sequence-Number: 4953 + +On Thu, 2003-12-04 at 12:27, Richard Huxton wrote: +> On Thursday 04 December 2003 19:50, Jack Coates wrote: +> > +> > I'm trying to set Postgres's shared memory usage in a fashion that +> > allows it to return requested results quickly. Unfortunately, none of +> > these changes allow PG to use more than a little under 300M RAM. +> > vacuumdb --analyze is now taking an inordinate amount of time as well +> > (40 minutes and counting), so that change needs to be rolled back. +> +> You don't want PG to use all your RAM, it's designed to let the underlying OS +> do a lot of caching for it. Probably worth having a look at vmstat/iostat and +> see if it's saturating on I/O. + +latest changes: +shared_buffers = 35642 +max_fsm_relations = 1000 +max_fsm_pages = 10000 +wal_buffers = 64 +sort_mem = 32768 +vacuum_mem = 32768 +effective_cache_size = 10000 + +/proc/sys/kernel/shmmax = 500000000 + +IO is active, but hardly saturated. CPU load is hefty though, load +average is at 4 now. + + procs memory swap io +system cpu + r b w swpd free buff cache si so bi bo in cs us +sy id + 0 2 1 2808 11436 39616 1902988 0 0 240 896 765 469 +2 11 87 + 0 2 1 2808 11432 39616 1902988 0 0 244 848 768 540 +4 3 93 + 0 2 1 2808 11432 39616 1902984 0 0 204 876 788 507 +3 4 93 + 0 2 1 2808 11432 39616 1902984 0 0 360 416 715 495 +4 1 96 + 0 2 1 2808 11432 39616 1902984 0 0 376 328 689 441 +2 1 97 + 0 2 0 2808 11428 39616 1902976 0 0 464 360 705 479 +2 1 97 + 0 2 1 2808 11428 39616 1902976 0 0 432 380 718 547 +3 1 97 + 0 2 1 2808 11428 39616 1902972 0 0 440 372 742 512 +1 3 96 + 0 2 1 2808 11428 39616 1902972 0 0 416 364 711 504 +3 1 96 + 0 2 1 2808 11424 39616 1902972 0 0 456 492 743 592 +2 1 97 + 0 2 1 2808 11424 39616 1902972 0 0 440 352 707 494 +2 1 97 + 0 2 1 2808 11424 39616 1902972 0 0 456 360 709 494 +2 2 97 + 0 2 1 2808 11436 39616 1902968 0 0 536 516 807 708 +3 2 94 + +-- +Jack Coates, Lyris Technologies Applications Engineer +510-549-4350 x148, jack@lyris.com +"Interoperability is the keyword, uniformity is a dead end." + --Olivier Fourdan + + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 16:47:11 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6921BD1B49A + for ; + Thu, 4 Dec 2003 20:47:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 19863-01 + for ; + Thu, 4 Dec 2003 16:46:37 -0400 (AST) +Received: from uhh.alcaron.ee (uhh.alcaron.ee [194.204.62.169]) + by svr1.postgresql.org (Postfix) with ESMTP id 8211FD1C9ED + for ; + Thu, 4 Dec 2003 16:43:25 -0400 (AST) +Received: from iff by uhh.alcaron.ee with local + id 1AS0Jq-0004Y1-00; Thu, 04 Dec 2003 22:43:26 +0200 +Date: Thu, 4 Dec 2003 22:43:26 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +Message-ID: <20031204204326.GA17083@alcaron.ee> +References: <20031204185751.GA15893@alcaron.ee> + <20031204142320.3c021100.threshar@torgo.978.org> + <20031204195121.GA16497@alcaron.ee> + <200312042023.37050.dev@archonet.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200312042023.37050.dev@archonet.com> +User-Agent: Mutt/1.3.28i +From: Ivar Zarans +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/94 +X-Sequence-Number: 4954 + +On Thu, Dec 04, 2003 at 08:23:36PM +0000, Richard Huxton wrote: + +> Ah - it's probably not the update but the IN. You can rewrite it using PG's +> non-standard FROM: +> +> UPDATE t1 SET status='done' FROM t_tmp WHERE t1.rec_id = t_tmp.rec_id; + +Thanks for the hint. I'll try this. + +> Now that doesn't explain why the update is taking so long. One fifth of a +> second is extremely slow. Are you certain that the index is being used? + +Explain shows following output: + +explain update table1 set status = 'PROC' where recid = '199901'; + +Index Scan using table1_pkey on table1 (cost=0.00..6.01 rows=1 width=198) + Index Cond: (recid = 199901::bigint) + (2 rows) + + + +-- +Ivar Zarans + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 17:00:03 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A0396D1B443 + for ; + Thu, 4 Dec 2003 20:53:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 20708-05 + for ; + Thu, 4 Dec 2003 16:53:15 -0400 (AST) +Received: from dezeut.zeut.net (ool-4352919e.dyn.optonline.net + [67.82.145.158]) + by svr1.postgresql.org (Postfix) with ESMTP id BBAB6D1B47A + for ; + Thu, 4 Dec 2003 16:52:57 -0400 (AST) +Received: from dezeut.zeut.net (localhost.localdomain [127.0.0.1]) + by dezeut.zeut.net (8.12.8/8.12.8) with ESMTP id hB4Kqp7N021686; + Thu, 4 Dec 2003 15:52:51 -0500 +Received: (from apache@localhost) + by dezeut.zeut.net (8.12.8/8.12.8/Submit) id hB4KqpDP021684; + Thu, 4 Dec 2003 15:52:51 -0500 +X-Authentication-Warning: dezeut.zeut.net: apache set sender to + matthew@zeut.net using -f +Received: from 66.106.27.14 (SquirrelMail authenticated user dbmailtest) + by matth.zeut.net with HTTP; Thu, 4 Dec 2003 15:52:51 -0500 (EST) +Message-ID: <2348.66.106.27.14.1070571171.squirrel@matth.zeut.net> +Date: Thu, 4 Dec 2003 15:52:51 -0500 (EST) +Subject: Re: autovacuum daemon stops doing work after about an hour +From: "Matthew T. O'Connor" +To: +In-Reply-To: +References: <16332.63508.196365.801418@yertle.int.kciLink.com> + <1070516326.1455.11.camel@zedora.zeut.net> + +X-Priority: 3 +Importance: Normal +Cc: +X-Mailer: SquirrelMail (version 1.2.11) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/98 +X-Sequence-Number: 4958 + +>>>>>> "MTO" == Matthew T O'Connor writes: +> +> MTO> I don't run FreeBSD, so I haven't tested with FreeBSD. Recently +> Craig MTO> Boston reported and submitted a patch for a crash on FreeBSD, +> but that +> +> some more debugging data: +> +> (gdb) print now +> $2 = {tv_sec = 1070565077, tv_usec = 216477} +> (gdb) print then +> $3 = {tv_sec = 1070561568, tv_usec = 668963} +> (gdb) print diff +> $4 = -5459981371352 +> (gdb) print sleep_secs +> $5 = -1272 +> +> so for some reason, instead of calculating 3508547514 as the diff, it +> got a hugely negative number. +> +> I'll bet it has something to do with the compiler... more debugging to +> follow (without -O compilation...) + +Could this be the recently reported bug where time goes backwards on +FreeBSD? Can anyone who knows more about this problem chime in, I know it +was recently discussed on Hackers. + +The simple fix is to just make sure it's a positive number. If not, then +just sleep for some small positive amount. I can make a patch for this, +probably sometime this weekend. + +Thanks for tracking this down. + + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 17:29:14 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7DE7FD1B4C3 + for ; + Thu, 4 Dec 2003 21:29:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 26747-10 + for ; + Thu, 4 Dec 2003 17:28:43 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D82BD1B49D + for ; + Thu, 4 Dec 2003 17:28:40 -0400 (AST) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id hB4LRauH007806; + Thu, 4 Dec 2003 14:27:36 -0700 (MST) +Date: Thu, 4 Dec 2003 14:10:41 -0700 (MST) +From: "scott.marlowe" +To: Jack Coates +Cc: Richard Huxton , , + pgsql-performance +Subject: Re: tuning questions +In-Reply-To: <1070570264.13923.88.camel@cletus.lyris.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/103 +X-Sequence-Number: 4963 + +On Thu, 4 Dec 2003, Jack Coates wrote: + +> On Thu, 2003-12-04 at 12:27, Richard Huxton wrote: +> > On Thursday 04 December 2003 19:50, Jack Coates wrote: +> > > +> > > I'm trying to set Postgres's shared memory usage in a fashion that +> > > allows it to return requested results quickly. Unfortunately, none of +> > > these changes allow PG to use more than a little under 300M RAM. +> > > vacuumdb --analyze is now taking an inordinate amount of time as well +> > > (40 minutes and counting), so that change needs to be rolled back. +> > +> > You don't want PG to use all your RAM, it's designed to let the underlying OS +> > do a lot of caching for it. Probably worth having a look at vmstat/iostat and +> > see if it's saturating on I/O. +> +> latest changes: +> shared_buffers = 35642 +> max_fsm_relations = 1000 +> max_fsm_pages = 10000 +> wal_buffers = 64 +> sort_mem = 32768 +> vacuum_mem = 32768 +> effective_cache_size = 10000 +> +> /proc/sys/kernel/shmmax = 500000000 +> +> IO is active, but hardly saturated. CPU load is hefty though, load +> average is at 4 now. + +Postgresql is busily managing a far too large shared buffer. Let the +kernel do that. Postgresql's shared buffers should be bug enough to hold +as much of the current working set as it can, up to about 25% or so of the +servers memory, or 512Meg, whichever comes first. Unless a single query +will actually use all of the buffer at once, you're not likely to see an +improvement. + +Also, your effective cache size is really small. On a typical Postgresql +server with 2 gigs of ram, you'll have about 1 to 1.5 gigs as kernel cache +and buffer, and if it's dedicated to postgresql, then the effective cache +setting for 1 gig would be 131072 (assuming 8k pages). + +If you're updating a lot of tuples without vacuums, you'll likely want to +up your fsm settings. + +Note you can change things like sort_mem, effective_cache_size and +random_page_cost on the fly (but not buffers, they're allocated at +startup, nor fsm, they are as well.) + +so, if you're gonna have one huge honkin query that needs to sort a +hundred megs at a time, but you'd rather not up your sort memory that high +(sort mem is PER SORT, not per backend or per database, so it can get out +of hand quickly) then you can just + +set sort_mem=128000; + +before throwing out the big queries that need all the sort. + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 17:20:55 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3806AD1B491 + for ; + Thu, 4 Dec 2003 21:20:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 26242-05 + for ; + Thu, 4 Dec 2003 17:20:23 -0400 (AST) +Received: from yertle.kcilink.com (yertle.kcilink.com [216.194.193.105]) + by svr1.postgresql.org (Postfix) with ESMTP id D9481D1B47A + for ; + Thu, 4 Dec 2003 17:20:20 -0400 (AST) +Received: by yertle.kcilink.com (Postfix, from userid 100) + id 5AF5A2178A; Thu, 4 Dec 2003 16:20:22 -0500 (EST) +From: Vivek Khera +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Message-ID: <16335.42262.196435.193875@yertle.int.kciLink.com> +Date: Thu, 4 Dec 2003 16:20:22 -0500 +To: "Matthew T. O'Connor" +Cc: +Subject: Re: autovacuum daemon stops doing work after about an hour +In-Reply-To: <2348.66.106.27.14.1070571171.squirrel@matth.zeut.net> +References: <16332.63508.196365.801418@yertle.int.kciLink.com> + <1070516326.1455.11.camel@zedora.zeut.net> + + <2348.66.106.27.14.1070571171.squirrel@matth.zeut.net> +X-Mailer: VM 7.17 under 21.4 (patch 14) "Reasonable Discussion" XEmacs Lucid +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/99 +X-Sequence-Number: 4959 + +>>>>> "MTO" == Matthew T O'Connor writes: + +MTO> Could this be the recently reported bug where time goes backwards on +MTO> FreeBSD? Can anyone who knows more about this problem chime in, I know it +MTO> was recently discussed on Hackers. + + +Time does not go backwards -- the now and then variables are properly +incrementing in time as you see from the debugging output. + +The error appears to be with the computation of the "diff". It is +either a C programming error, or a compiler error. I'm not a C "cop" +so I can't tell you which it is. + +Witness this program, below, compiled as "cc -g -o t t.c" and the +output here: + +% ./t +seconds = 3509 +seconds1 = 3509000000 +useconds = -452486 +stepped diff = 3508547514 +seconds2 = -785967296 +seconds3 = 3509000000 +diff = -786419782 +long long diff = 3508547514 +% + +apperantly, if you compute (now.tv_sec - then.tv_sec) * 1000000 all at +once, it overflows since the RHS is all computed using longs rather +than long longs. Fix is to cast at least one of the values to long +long on the RHS, as in the computation of seconds3 below. compare +that to the computation of seconds2 and you'll see that this is the +cause. + +I'd be curious to see the output of this program on other platforms +and other compilers. I'm using gcc 2.95.4 as shipped with FreeBSD +4.8+. + +That all being said, you should never sleep less than the base time, +and never for more than a max amount, perhaps 1 hour? + + +--cut here-- +#include +#include + +int +main() +{ + struct timeval now, then; + long long diff = 0; + long long seconds, seconds1, seconds2, seconds3, useconds; + + now.tv_sec = 1070565077L; + now.tv_usec = 216477L; + + then.tv_sec = 1070561568L; + then.tv_usec = 668963L; + + seconds = now.tv_sec - then.tv_sec; + printf("seconds = %lld\n",seconds); + seconds1 = seconds * 1000000; + printf("seconds1 = %lld\n",seconds1); + useconds = now.tv_usec - then.tv_usec; + printf("useconds = %lld\n",useconds); + + diff = seconds1 + useconds; + printf("stepped diff = %lld\n",diff); + + /* this appears to be the culprit... it should be same as seconds1 */ + seconds2 = (now.tv_sec - then.tv_sec) * 1000000; + printf("seconds2 = %lld\n",seconds2); + + /* seems we need to cast long's to long long's for this computation */ + seconds3 = ((long long)now.tv_sec - (long long)then.tv_sec) * 1000000; + printf("seconds3 = %lld\n",seconds3); + + + diff = (now.tv_sec - then.tv_sec) * 1000000 + (now.tv_usec - then.tv_usec); + printf ("diff = %lld\n",diff); + + diff = ((long long)now.tv_sec - (long long)then.tv_sec) * 1000000 + (now.tv_usec - then.tv_usec); + printf ("long long diff = %lld\n",diff); + + exit(0); +} + + +--cut here-- + +From pgsql-performance-owner@postgresql.org Thu Dec 4 17:22:40 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A0AFD1B4AE + for ; + Thu, 4 Dec 2003 21:22:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 27632-01 + for ; + Thu, 4 Dec 2003 17:22:09 -0400 (AST) +Received: from yertle.kcilink.com (yertle.kcilink.com [216.194.193.105]) + by svr1.postgresql.org (Postfix) with ESMTP id 921C3D1B47A + for ; + Thu, 4 Dec 2003 17:22:07 -0400 (AST) +Received: by yertle.kcilink.com (Postfix, from userid 100) + id 60C142178A; Thu, 4 Dec 2003 16:22:09 -0500 (EST) +From: Vivek Khera +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Message-ID: <16335.42369.252957.290956@yertle.int.kciLink.com> +Date: Thu, 4 Dec 2003 16:22:09 -0500 +To: "Matthew T. O'Connor" +Cc: +Subject: Re: autovacuum daemon stops doing work after about an hour +In-Reply-To: <2348.66.106.27.14.1070571171.squirrel@matth.zeut.net> +References: <16332.63508.196365.801418@yertle.int.kciLink.com> + <1070516326.1455.11.camel@zedora.zeut.net> + + <2348.66.106.27.14.1070571171.squirrel@matth.zeut.net> +X-Mailer: VM 7.17 under 21.4 (patch 14) "Reasonable Discussion" XEmacs Lucid +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/100 +X-Sequence-Number: 4960 + +Actually, you can simplify the fix thusly: + + diff = (long long)(now.tv_sec - then.tv_sec) * 1000000 + (now.tv_usec - then.tv_usec); + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 17:25:21 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 15FA5D1B4C1 + for ; + Thu, 4 Dec 2003 21:25:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 26873-09 + for ; + Thu, 4 Dec 2003 17:24:44 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A3DDD1B4B9 + for ; + Thu, 4 Dec 2003 17:24:42 -0400 (AST) +Received: from [66.219.92.2] (HELO temoku) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4023430; Thu, 04 Dec 2003 13:25:33 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Jack Coates , Richard Huxton +Subject: Re: tuning questions +Date: Thu, 4 Dec 2003 13:24:37 -0800 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312042027.22223.dev@archonet.com> + <1070570264.13923.88.camel@cletus.lyris.com> +In-Reply-To: <1070570264.13923.88.camel@cletus.lyris.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: quoted-printable +Message-Id: <200312041324.37889.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/101 +X-Sequence-Number: 4961 + +Jack, + +> latest changes: +> shared_buffers =3D 35642 + +This is fine, it's about 14% of available RAM. Though the way you calculat= +ed=20 +it still confuses me. It's not complicated; it should be between 6% and 1= +5%=20 +of available RAM; since you're doing a data-transformation DB, yours should= +=20 +be toward the high end.=20 + +> max_fsm_relations =3D 1000 +> max_fsm_pages =3D 10000 + +You want to raise this a whole lot if your data transformations involve lar= +ge=20 +delete or update batches. I'd suggest running "vacuum analyze verbose"= +=20 +between steps to see how many dead pages you're accumulating. + +> wal_buffers =3D 64 +> sort_mem =3D 32768 +> vacuum_mem =3D 32768 +> effective_cache_size =3D 10000 + +This is way the heck too low. it's supposed to be the size of all availabl= +e=20 +RAM; I'd set it to 2GB*65% as a start. + +> IO is active, but hardly saturated. CPU load is hefty though, load +> average is at 4 now. + +Unless you're doing huge statistical aggregates (like radar charts), or hea= +vy=20 +numerical calculations-by-query, high CPU and idle I/O usually indicates a= +=20 +really bad query, like badly mismatched data types on a join or unconstrain= +ed=20 +joins or overblown formatting-by-query. + +--=20 +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 17:26:22 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EBD27D1B4A6 + for ; + Thu, 4 Dec 2003 21:26:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28396-03 + for ; + Thu, 4 Dec 2003 17:25:49 -0400 (AST) +Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 073D7D1B491 + for ; + Thu, 4 Dec 2003 17:25:43 -0400 (AST) +Received: from lerlaptop-red.iadfw.net ([207.136.3.72]) + by lerami.lerctr.org with asmtp (Exim 4.30) + id 1AS0yf-0004Vv-85; Thu, 04 Dec 2003 15:25:37 -0600 +Date: Thu, 04 Dec 2003 15:25:36 -0600 +From: Larry Rosenman +To: Vivek Khera , "Matthew T. O'Connor" +Cc: pgsql-performance@postgresql.org +Subject: Re: autovacuum daemon stops doing work after about an +Message-ID: <401840000.1070573136@lerlaptop-red.iadfw.net> +In-Reply-To: <16335.42262.196435.193875@yertle.int.kciLink.com> +References: <16332.63508.196365.801418@yertle.int.kciLink.com> + <1070516326.1455.11.camel@zedora.zeut.net> + + <2348.66.106.27.14.1070571171.squirrel@matth.zeut.net> + <16335.42262.196435.193875@yertle.int.kciLink.com> +X-Mailer: Mulberry/3.1.0 (Linux/x86) +X-PGP-Info: All other keys are old/dead. +X-PGP-Key: 0x3c49bdd6 +X-PGP-Fingerprint: D0D1 3C11 F42F 6B29 FA67 6BF3 AD13 4685 3C49 BDD6 +MIME-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="==========1B86D33B13306EE04F08==========" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/102 +X-Sequence-Number: 4962 + +--==========1B86D33B13306EE04F08========== +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + + + +--On Thursday, December 04, 2003 16:20:22 -0500 Vivek Khera=20 + wrote: + +>>>>>> "MTO" =3D=3D Matthew T O'Connor writes: +> +> MTO> Could this be the recently reported bug where time goes backwards on +> MTO> FreeBSD? Can anyone who knows more about this problem chime in, I +> know it MTO> was recently discussed on Hackers. +> +> +> Time does not go backwards -- the now and then variables are properly +> incrementing in time as you see from the debugging output. +> +> The error appears to be with the computation of the "diff". It is +> either a C programming error, or a compiler error. I'm not a C "cop" +> so I can't tell you which it is. +> +> Witness this program, below, compiled as "cc -g -o t t.c" and the +> output here: +> +> % ./t +> seconds =3D 3509 +> seconds1 =3D 3509000000 +> useconds =3D -452486 +> stepped diff =3D 3508547514 +> seconds2 =3D -785967296 +> seconds3 =3D 3509000000 +> diff =3D -786419782 +> long long diff =3D 3508547514 +> % +> +> apperantly, if you compute (now.tv_sec - then.tv_sec) * 1000000 all at +> once, it overflows since the RHS is all computed using longs rather +> than long longs. Fix is to cast at least one of the values to long +> long on the RHS, as in the computation of seconds3 below. compare +> that to the computation of seconds2 and you'll see that this is the +> cause. +> +> I'd be curious to see the output of this program on other platforms +> and other compilers. I'm using gcc 2.95.4 as shipped with FreeBSD +> 4.8+. +this is with the UnixWare compiler: +$ cc -O -o testvk testvk.c +$ ./testvk +seconds =3D 3509 +seconds1 =3D 3509000000 +useconds =3D -452486 +stepped diff =3D 3508547514 +seconds2 =3D -785967296 +seconds3 =3D 3509000000 +diff =3D -786419782 +long long diff =3D 3508547514 +$ + + +I think this is a C bug. + + + +> +> That all being said, you should never sleep less than the base time, +> and never for more than a max amount, perhaps 1 hour? +> +> +> --cut here-- +># include +># include +> +> int +> main() +> { +> struct timeval now, then; +> long long diff =3D 0; +> long long seconds, seconds1, seconds2, seconds3, useconds; +> +> now.tv_sec =3D 1070565077L; +> now.tv_usec =3D 216477L; +> +> then.tv_sec =3D 1070561568L; +> then.tv_usec =3D 668963L; +> +> seconds =3D now.tv_sec - then.tv_sec; +> printf("seconds =3D %lld\n",seconds); +> seconds1 =3D seconds * 1000000; +> printf("seconds1 =3D %lld\n",seconds1); +> useconds =3D now.tv_usec - then.tv_usec; +> printf("useconds =3D %lld\n",useconds); +> +> diff =3D seconds1 + useconds; +> printf("stepped diff =3D %lld\n",diff); +> +> /* this appears to be the culprit... it should be same as seconds1 */ +> seconds2 =3D (now.tv_sec - then.tv_sec) * 1000000; +> printf("seconds2 =3D %lld\n",seconds2); +> +> /* seems we need to cast long's to long long's for this computation */ +> seconds3 =3D ((long long)now.tv_sec - (long long)then.tv_sec) * 1000000; +> printf("seconds3 =3D %lld\n",seconds3); +> +> +> diff =3D (now.tv_sec - then.tv_sec) * 1000000 + (now.tv_usec - +> then.tv_usec); printf ("diff =3D %lld\n",diff); +> +> diff =3D ((long long)now.tv_sec - (long long)then.tv_sec) * 1000000 + +> (now.tv_usec - then.tv_usec); printf ("long long diff =3D %lld\n",diff); +> +> exit(0); +> } +> +> +> --cut here-- +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> + + + +--=20 +Larry Rosenman http://www.lerctr.org/~ler +Phone: +1 972-414-9812 E-Mail: ler@lerctr.org +US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749 + +--==========1B86D33B13306EE04F08========== +Content-Type: application/pgp-signature +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.3 (FreeBSD) + +iD8DBQE/z6ZQrRNGhTxJvdYRAizdAKCJrroU/PruGlADjJEybSh+IhRHwQCffnpM +rZH61B7ilXl1WNXE+fvLmCA= +=SdUH +-----END PGP SIGNATURE----- + +--==========1B86D33B13306EE04F08==========-- + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 17:37:45 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DC2BED1B4A6 + for ; + Thu, 4 Dec 2003 21:37:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28408-09 + for ; + Thu, 4 Dec 2003 17:37:13 -0400 (AST) +Received: from yertle.kcilink.com (yertle.kcilink.com [216.194.193.105]) + by svr1.postgresql.org (Postfix) with ESMTP id 0FDDCD1B484 + for ; + Thu, 4 Dec 2003 17:37:11 -0400 (AST) +Received: by yertle.kcilink.com (Postfix, from userid 100) + id 5D1622178A; Thu, 4 Dec 2003 16:37:12 -0500 (EST) +From: Vivek Khera +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Message-ID: <16335.43272.273411.653445@yertle.int.kciLink.com> +Date: Thu, 4 Dec 2003 16:37:12 -0500 +To: pgsql-performance@postgresql.org +Subject: Re: autovacuum daemon stops doing work after about an +In-Reply-To: <401840000.1070573136@lerlaptop-red.iadfw.net> +References: <16332.63508.196365.801418@yertle.int.kciLink.com> + <1070516326.1455.11.camel@zedora.zeut.net> + + <2348.66.106.27.14.1070571171.squirrel@matth.zeut.net> + <16335.42262.196435.193875@yertle.int.kciLink.com> + <401840000.1070573136@lerlaptop-red.iadfw.net> +X-Mailer: VM 7.17 under 21.4 (patch 14) "Reasonable Discussion" XEmacs Lucid +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/104 +X-Sequence-Number: 4964 + +>>>>> "LR" == Larry Rosenman writes: + +>> I'd be curious to see the output of this program on other platforms +>> and other compilers. I'm using gcc 2.95.4 as shipped with FreeBSD +>> 4.8+. +LR> this is with the UnixWare compiler: +LR> $ cc -O -o testvk testvk.c +LR> $ ./testvk +LR> seconds = 3509 +LR> seconds1 = 3509000000 +LR> useconds = -452486 +LR> stepped diff = 3508547514 +LR> seconds2 = -785967296 +LR> seconds3 = 3509000000 +LR> diff = -786419782 +LR> long long diff = 3508547514 +LR> $ + +LR> I think this is a C bug. + +Upon further reflection, I think so to. The entire RHS is long's so +the arithmetic is done in longs, then assigned to a long long when +done (after things have overflowed). Forcing any one of the RHS +values to be long long causes the arithmetic to all be done using long +longs, and then you get the numbers you expect. + +I think you only notice this in autovacuum when it takes a long time +to complete the work, like my example of about 3500 seconds. + +From pgsql-performance-owner@postgresql.org Thu Dec 4 18:13:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6EBA7D1B4A7 + for ; + Thu, 4 Dec 2003 22:13:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 35109-02 + for ; + Thu, 4 Dec 2003 18:13:13 -0400 (AST) +Received: from uhh.alcaron.ee (uhh.alcaron.ee [194.204.62.169]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D7CDD1B443 + for ; + Thu, 4 Dec 2003 18:13:10 -0400 (AST) +Received: from iff by uhh.alcaron.ee with local + id 1AS1ii-0004xy-00; Fri, 05 Dec 2003 00:13:12 +0200 +Date: Fri, 5 Dec 2003 00:13:12 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +Message-ID: <20031204221312.GA18874@alcaron.ee> +References: <20031204185751.GA15893@alcaron.ee> + <20031204142320.3c021100.threshar@torgo.978.org> + <20031204195121.GA16497@alcaron.ee> + <200312042023.37050.dev@archonet.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200312042023.37050.dev@archonet.com> +User-Agent: Mutt/1.3.28i +From: Ivar Zarans +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/105 +X-Sequence-Number: 4965 + +On Thu, Dec 04, 2003 at 08:23:36PM +0000, Richard Huxton wrote: + +> Ah - it's probably not the update but the IN. You can rewrite it using PG's +> non-standard FROM: +> +> UPDATE t1 SET status='done' FROM t_tmp WHERE t1.rec_id = t_tmp.rec_id; + +This was one *very useful* hint! Using this method i got my processing +time of 24000 records down to around 3 minutes 10 seconds. Comparing +with initial 1 hour 20 minutes and then 16 minutes, this is impressive +improvement! + +> Now that doesn't explain why the update is taking so long. One fifth of a +> second is extremely slow. Are you certain that the index is being used? + +I posted results of "EXPLAIN" in my previous message. Meanwhile i tried +to update just one record, using "psql". Also tried out "EXPLAIN +ANALYZE". This way i did not see any big delay - total runtime for one +update was around 1 msec. + +I am confused - has slowness of UPDATE something to do with Python and +PyPgSQL, since "psql" seems to have no delay whatsoever? Or is this +related to using two cursors, one for select results and other for +update? Even if this is related to Python or cursors, how am i getting +so big speed improvement only by using different query? + +-- +Ivar + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 18:38:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F285DD1B458 + for ; + Thu, 4 Dec 2003 22:38:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38598-02 + for ; + Thu, 4 Dec 2003 18:37:33 -0400 (AST) +Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net + [194.217.242.88]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E9EDD1B464 + for ; + Thu, 4 Dec 2003 18:37:31 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AS26G-0002VJ-0U; Thu, 04 Dec 2003 22:37:32 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 4EE0A16CB0; Thu, 4 Dec 2003 22:37:31 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 7483316732; Thu, 4 Dec 2003 22:37:29 +0000 (GMT) +From: Richard Huxton +To: William Yu , pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +Date: Thu, 4 Dec 2003 22:37:28 +0000 +User-Agent: KMail/1.5 +References: <20031204185751.GA15893@alcaron.ee> +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200312042237.28378.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/106 +X-Sequence-Number: 4966 + +On Thursday 04 December 2003 19:59, William Yu wrote: +> Ivar Zarans wrote: +> > I am experiencing strange behaviour, where simple UPDATE of one field is +> > very slow, compared to INSERT into table with multiple indexes. I have +> > two tables - one with raw data records (about 24000), where one field +> +> In Postgres and any other DB that uses MVCC (multi-version concurrency), +> UPDATES will always be slower than INSERTS. With MVCC, what the DB does +> is makes a copy of the record, updates that record and then invalidates +> the previous record. +[snip] + +Yes, but he's seeing 0.25secs to update one row - that's something odd. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Thu Dec 4 18:46:21 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 39AF7D1B482 + for ; + Thu, 4 Dec 2003 22:46:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 37999-07 + for ; + Thu, 4 Dec 2003 18:45:36 -0400 (AST) +Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net + [194.217.242.91]) + by svr1.postgresql.org (Postfix) with ESMTP id DD90FD1B46E + for ; + Thu, 4 Dec 2003 18:45:33 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AS2Dz-000FAX-0X; Thu, 04 Dec 2003 22:45:33 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 9775816CB0; Thu, 4 Dec 2003 22:45:25 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 0442B16C65; Thu, 4 Dec 2003 22:45:22 +0000 (GMT) +From: Richard Huxton +To: Ivar Zarans , pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +Date: Thu, 4 Dec 2003 22:45:21 +0000 +User-Agent: KMail/1.5 +References: <20031204185751.GA15893@alcaron.ee> + <200312042023.37050.dev@archonet.com> + <20031204221312.GA18874@alcaron.ee> +In-Reply-To: <20031204221312.GA18874@alcaron.ee> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200312042245.21899.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/107 +X-Sequence-Number: 4967 + +On Thursday 04 December 2003 22:13, Ivar Zarans wrote: +> On Thu, Dec 04, 2003 at 08:23:36PM +0000, Richard Huxton wrote: +> > Ah - it's probably not the update but the IN. You can rewrite it using +> > PG's non-standard FROM: +> > +> > UPDATE t1 SET status='done' FROM t_tmp WHERE t1.rec_id = t_tmp.rec_id; +> +> This was one *very useful* hint! Using this method i got my processing +> time of 24000 records down to around 3 minutes 10 seconds. Comparing +> with initial 1 hour 20 minutes and then 16 minutes, this is impressive +> improvement! + +Be aware, this is specific to PG - I'm not aware of this construction working +on any other DB. Three minutes still doesn't sound brilliant, but that could +be tuning issues. + +> > Now that doesn't explain why the update is taking so long. One fifth of a +> > second is extremely slow. Are you certain that the index is being used? +> +> I posted results of "EXPLAIN" in my previous message. Meanwhile i tried +> to update just one record, using "psql". Also tried out "EXPLAIN +> ANALYZE". This way i did not see any big delay - total runtime for one +> update was around 1 msec. + +Yep - the explain looked fine. If you run EXPLAIN ANALYSE it will give you +timings too (actual timings will be slightly less than reported ones since PG +won't be timing/reporting). + +> I am confused - has slowness of UPDATE something to do with Python and +> PyPgSQL, since "psql" seems to have no delay whatsoever? Or is this +> related to using two cursors, one for select results and other for +> update? Even if this is related to Python or cursors, how am i getting +> so big speed improvement only by using different query? + +Hmm - you didn't mention cursors. If this was a problem with PyPgSQL in +general I suspect we'd know about it by now. It could however be some +cursor-related issue. In general, you're probably better off trying to do +updates/inserts as a single statement and letting PG manage things rather +than processing one row at a time. + +If you've got the time, try putting together a small test-script with some +dummy data and see if it's reproducible. I'm sure the other Python users +would be interested in seeing where the problem is. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Thu Dec 4 19:00:21 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 65E47D1B464 + for ; + Thu, 4 Dec 2003 23:00:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43930-01 + for ; + Thu, 4 Dec 2003 18:59:49 -0400 (AST) +Received: from main.wiredfool.com (dsl231-055-035.sea1.dsl.speakeasy.net + [216.231.55.35]) + by svr1.postgresql.org (Postfix) with ESMTP id 40A99D1B43F + for ; + Thu, 4 Dec 2003 18:59:46 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by main.wiredfool.com (Postfix) with ESMTP + id D8F1F2728E; Thu, 4 Dec 2003 14:54:45 -0800 (PST) +Received: from main.wiredfool.com ([127.0.0.1]) + by localhost (cabbage [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 26637-09; Thu, 4 Dec 2003 14:54:43 -0800 (PST) +Received: from [IPv6:::1] (localhost [127.0.0.1]) + by main.wiredfool.com (Postfix) with ESMTP + id 724852728D; Thu, 4 Dec 2003 14:54:43 -0800 (PST) +In-Reply-To: <1070570264.13923.88.camel@cletus.lyris.com> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312041120.21124.josh@agliodbs.com> + <1070567455.13923.83.camel@cletus.lyris.com> + <200312042027.22223.dev@archonet.com> + <1070570264.13923.88.camel@cletus.lyris.com> +Mime-Version: 1.0 (Apple Message framework v606) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <8DABDA81-26AD-11D8-8622-0003930F2A6C@soroos.net> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance +From: Eric Soroos +Subject: Re: tuning questions +Date: Thu, 4 Dec 2003 14:59:45 -0800 +To: Jack Coates +X-Mailer: Apple Mail (2.606) +X-Virus-Scanned: by amavisd-new-20030616-p3 (Debian) at main.wiredfool.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/108 +X-Sequence-Number: 4968 + +> +> IO is active, but hardly saturated. CPU load is hefty though, load +> average is at 4 now. +> +> procs memory swap io +> system cpu +> r b w swpd free buff cache si so bi bo in cs +> us sy id + +> 0 2 1 2808 11432 39616 1902984 0 0 204 876 788 507 +> 3 4 93 + +You're getting a load average of 4 with 93% idle? + +That's a reasonable number of context switches, and if the blocks +you're reading/writing are discontinous, I could see io saturation +rearing it's head. + +This looks to me like you're starting and killing a lot of processes. + +Is this thrashing psql connections, or is it one big query? What are +your active processes? + +Your effective cache size looks to be about 1900 megs (+- binary), +assuming all of it is pg. + +eric + + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 19:17:24 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D265D1B4BE + for ; + Thu, 4 Dec 2003 23:17:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45489-04 + for ; + Thu, 4 Dec 2003 19:16:50 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by svr1.postgresql.org (Postfix) with ESMTP id 2652AD1B49B + for ; + Thu, 4 Dec 2003 19:16:47 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by luna.lyris.com (8.12.8/8.12.8) with ESMTP id hB4NGEIt006141; + Thu, 4 Dec 2003 15:16:14 -0800 +Received: from luna.lyris.com ([216.91.57.116]) + by luna.lyris.com (MailMonitor for SMTP v1.2.2 ) ; + Thu, 4 Dec 2003 15:16:13 -0800 (PST) +Received: from cletus.lyris.com (cletus.lyris.com [216.91.56.155]) by + luna.lyris.net with SMTP (MailShield v2.04 - LINUX Jul 17 2001 + 16:58:31); Thu, 04 Dec 2003 15:16:13 -0800 +Subject: Re: tuning questions +From: Jack Coates +To: josh@agliodbs.com +Cc: Richard Huxton , + pgsql-performance +In-Reply-To: <200312041324.37889.josh@agliodbs.com> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312042027.22223.dev@archonet.com> + <1070570264.13923.88.camel@cletus.lyris.com> + <200312041324.37889.josh@agliodbs.com> +Content-Type: text/plain +Organization: Lyris Technologies, Inc. +Message-Id: <1070579771.18838.187.camel@cletus.lyris.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.4-9mdk +Date: Thu, 04 Dec 2003 15:16:11 -0800 +Content-Transfer-Encoding: 7bit +X-SMTP-HELO: cletus.lyris.com +X-SMTP-MAIL-FROM: jack@lyris.com +X-SMTP-RCPT-TO: josh@agliodbs.com, dev@archonet.com, + pgsql-performance@postgresql.org +X-SMTP-PEER-INFO: cletus.lyris.com [216.91.56.155] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/109 +X-Sequence-Number: 4969 + +On Thu, 2003-12-04 at 13:24, Josh Berkus wrote: +> Jack, +> +> > latest changes: +> > shared_buffers = 35642 +> +> This is fine, it's about 14% of available RAM. Though the way you calculated +> it still confuses me. It's not complicated; it should be between 6% and 15% +> of available RAM; since you're doing a data-transformation DB, yours should +> be toward the high end. +> +> > max_fsm_relations = 1000 +> > max_fsm_pages = 10000 +> +> You want to raise this a whole lot if your data transformations involve large +> delete or update batches. I'd suggest running "vacuum analyze verbose" +> between steps to see how many dead pages you're accumulating. + +This looks really difficult to tune, and based on the load I'm giving +it, it looks really important. I've tried the verbose analyze and I've +looked at the rules of thumb, neither approach seems good for the +pattern of "hammer the system for a day or two, then leave it alone for +a week." I'm setting it to 500000 (half of the biggest table size +divided by a 6k page size), but I'll keep tweaking this. + +> +> > wal_buffers = 64 +> > sort_mem = 32768 +> > vacuum_mem = 32768 +> > effective_cache_size = 10000 +> +> This is way the heck too low. it's supposed to be the size of all available +> RAM; I'd set it to 2GB*65% as a start. + +This makes a little bit of difference. I set it to 65% (15869 pages). +Now we have some real disk IO: + procs memory swap io +system cpu + r b w swpd free buff cache si so bi bo in cs us +sy id + 0 3 1 2804 10740 40808 1899856 0 0 26624 0 941 4144 +13 24 63 + 1 2 1 2804 10808 40808 1899848 0 0 21748 60 1143 3655 +9 22 69 + +still high cpu (3-ish load) though, and there's no noticeable +improvement in query speed. + +> +> > IO is active, but hardly saturated. CPU load is hefty though, load +> > average is at 4 now. +> +> Unless you're doing huge statistical aggregates (like radar charts), or heavy +> numerical calculations-by-query, high CPU and idle I/O usually indicates a +> really bad query, like badly mismatched data types on a join or unconstrained +> joins or overblown formatting-by-query. + +Ran that by the programmer responsible for this area and watched the +statements go by with tcpdump -X. Looks like really simple stuff to me: +select a handful of values, then insert into one table and delete from +another. +-- +Jack Coates, Lyris Technologies Applications Engineer +510-549-4350 x148, jack@lyris.com +"Interoperability is the keyword, uniformity is a dead end." + --Olivier Fourdan + + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 19:20:48 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A4521D1B43F + for ; + Thu, 4 Dec 2003 23:20:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42304-09 + for ; + Thu, 4 Dec 2003 19:20:15 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by svr1.postgresql.org (Postfix) with ESMTP id 28974D1B4A6 + for ; + Thu, 4 Dec 2003 19:20:12 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by luna.lyris.com (8.12.8/8.12.8) with ESMTP id hB4NKBIt006934; + Thu, 4 Dec 2003 15:20:11 -0800 +Received: from luna.lyris.com ([216.91.57.116]) + by luna.lyris.com (MailMonitor for SMTP v1.2.2 ) ; + Thu, 4 Dec 2003 15:20:10 -0800 (PST) +Received: from cletus.lyris.com (cletus.lyris.com [216.91.56.155]) by + luna.lyris.net with SMTP (MailShield v2.04 - LINUX Jul 17 2001 + 16:58:31); Thu, 04 Dec 2003 15:20:10 -0800 +Subject: Re: tuning questions +From: Jack Coates +To: Eric Soroos +Cc: pgsql-performance +In-Reply-To: <8DABDA81-26AD-11D8-8622-0003930F2A6C@soroos.net> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312041120.21124.josh@agliodbs.com> + <1070567455.13923.83.camel@cletus.lyris.com> + <200312042027.22223.dev@archonet.com> + <1070570264.13923.88.camel@cletus.lyris.com> + <8DABDA81-26AD-11D8-8622-0003930F2A6C@soroos.net> +Content-Type: text/plain +Organization: Lyris Technologies, Inc. +Message-Id: <1070580008.13923.193.camel@cletus.lyris.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.4-9mdk +Date: Thu, 04 Dec 2003 15:20:08 -0800 +Content-Transfer-Encoding: 7bit +X-SMTP-HELO: cletus.lyris.com +X-SMTP-MAIL-FROM: jack@lyris.com +X-SMTP-RCPT-TO: eric-psql@soroos.net,pgsql-performance@postgresql.org +X-SMTP-PEER-INFO: cletus.lyris.com [216.91.56.155] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/110 +X-Sequence-Number: 4970 + +On Thu, 2003-12-04 at 14:59, Eric Soroos wrote: +> > +> > IO is active, but hardly saturated. CPU load is hefty though, load +> > average is at 4 now. +> > +> > procs memory swap io +> > system cpu +> > r b w swpd free buff cache si so bi bo in cs +> > us sy id +> +> > 0 2 1 2808 11432 39616 1902984 0 0 204 876 788 507 +> > 3 4 93 +> +> You're getting a load average of 4 with 93% idle? +down a bit since my last set of tweaks, but yeah: + 3:18pm up 2 days, 3:37, 3 users, load average: 3.42, 3.31, 2.81 +66 processes: 65 sleeping, 1 running, 0 zombie, 0 stopped +CPU0 states: 2.0% user, 3.4% system, 0.0% nice, 93.4% idle +CPU1 states: 1.3% user, 2.3% system, 0.0% nice, 95.2% idle +Mem: 2064656K av, 2053896K used, 10760K free, 0K shrd, 40388K +buff +Swap: 2899716K av, 2800K used, 2896916K free 1896232K +cached + + PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND +23103 root 15 0 1072 1072 840 R 1.3 0.0 0:01 top +23046 postgres 15 0 33364 32M 32220 S 0.5 1.6 0:12 postmaster +> +> That's a reasonable number of context switches, and if the blocks +> you're reading/writing are discontinous, I could see io saturation +> rearing it's head. +> +> This looks to me like you're starting and killing a lot of processes. + +isn't that by design though? I've been looking at other postgres servers +around the company and they seem to act pretty similar under load (none +is being pounded to this level, though). + +> +> Is this thrashing psql connections, or is it one big query? What are +> your active processes? + +[root@postgres root]# ps auxw | grep postgres +postgres 23042 0.0 0.4 308808 8628 pts/0 S 14:46 0:00 +/usr/bin/postmaster -p 5432 +postgres 23043 0.0 0.4 309788 8596 pts/0 S 14:46 0:00 postgres: +stats buffer process +postgres 23044 0.0 0.4 308828 8620 pts/0 S 14:46 0:00 postgres: +stats collector process +postgres 23046 0.6 1.4 309952 29872 pts/0 R 14:46 0:09 postgres: +lmuser lmdb 10.0.0.2 INSERT waiting +postgres 23047 1.4 14.7 310424 304240 pts/0 S 14:46 0:21 postgres: +lmuser lmdb 10.0.0.2 idle +postgres 23048 0.4 14.7 310044 304368 pts/0 S 14:46 0:07 postgres: +lmuser lmdb 10.0.0.2 idle +postgres 23049 0.0 0.5 309820 10352 pts/0 S 14:46 0:00 postgres: +lmuser lmdb 10.0.0.2 idle +postgres 23050 0.0 0.6 310424 13352 pts/0 S 14:46 0:00 postgres: +lmuser lmdb 10.0.0.2 idle +postgres 23051 0.0 0.6 309940 12992 pts/0 S 14:46 0:00 postgres: +lmuser lmdb 10.0.0.2 idle +postgres 23052 0.0 0.5 309880 11916 pts/0 S 14:46 0:00 postgres: +lmuser lmdb 10.0.0.2 idle +postgres 23053 0.0 0.6 309924 12872 pts/0 S 14:46 0:00 postgres: +lmuser lmdb 10.0.0.2 idle +postgres 23054 0.0 0.6 310012 13460 pts/0 S 14:46 0:00 postgres: +lmuser lmdb 10.0.0.2 idle +postgres 23055 0.0 0.5 309932 12284 pts/0 S 14:46 0:00 postgres: +lmuser lmdb 10.0.0.2 idle +postgres 23056 2.0 14.7 309964 304072 pts/0 S 14:46 0:30 postgres: +lmuser lmdb 10.0.0.2 idle +postgres 23057 2.4 14.7 309916 304104 pts/0 S 14:46 0:37 postgres: +lmuser lmdb 10.0.0.2 idle +postgres 23058 0.0 0.6 310392 13168 pts/0 S 14:46 0:00 postgres: +lmuser lmdb 10.0.0.2 idle +postgres 23059 0.5 14.7 310424 304072 pts/0 S 14:46 0:09 postgres: +lmuser lmdb 10.0.0.2 idle +postgres 23060 0.0 0.6 309896 13212 pts/0 S 14:46 0:00 postgres: +lmuser lmdb 10.0.0.2 idle +postgres 23061 0.5 1.4 309944 29832 pts/0 R 14:46 0:09 postgres: +lmuser lmdb 10.0.0.2 INSERT +postgres 23062 0.6 1.4 309936 29832 pts/0 S 14:46 0:09 postgres: +lmuser lmdb 10.0.0.2 INSERT waiting +postgres 23063 0.6 1.4 309944 30028 pts/0 S 14:46 0:09 postgres: +lmuser lmdb 10.0.0.2 INSERT waiting +postgres 23064 0.6 1.4 309944 29976 pts/0 S 14:46 0:09 postgres: +lmuser lmdb 10.0.0.2 INSERT waiting +postgres 23065 1.4 14.7 310412 304112 pts/0 S 14:46 0:21 postgres: +lmuser lmdb 216.91.56.200 idle +postgres 23066 0.5 1.4 309944 29496 pts/0 S 14:46 0:08 postgres: +lmuser lmdb 216.91.56.200 INSERT waiting +postgres 23067 0.5 1.4 310472 30040 pts/0 D 14:46 0:09 postgres: +lmuser lmdb 216.91.56.200 idle +postgres 23068 0.6 1.4 309936 30104 pts/0 R 14:46 0:09 postgres: +lmuser lmdb 216.91.56.200 INSERT waiting +postgres 23069 0.5 1.4 309936 29716 pts/0 S 14:46 0:09 postgres: +lmuser lmdb 216.91.56.200 INSERT waiting +postgres 23070 0.6 1.4 309944 29744 pts/0 S 14:46 0:09 postgres: +lmuser lmdb 10.0.0.2 INSERT waiting + +ten-ish stay idle all the time, the inserts go to update when the big +select is done and rows get moved from the active to the completed +table. + +> Your effective cache size looks to be about 1900 megs (+- binary), +> assuming all of it is pg. +> +> eric +> +-- +Jack Coates, Lyris Technologies Applications Engineer +510-549-4350 x148, jack@lyris.com +"Interoperability is the keyword, uniformity is a dead end." + --Olivier Fourdan + + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 19:48:31 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EC60AD1B49B + for ; + Thu, 4 Dec 2003 23:48:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48633-07 + for ; + Thu, 4 Dec 2003 19:47:59 -0400 (AST) +Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net + [194.217.242.90]) + by svr1.postgresql.org (Postfix) with ESMTP id C1012D1B458 + for ; + Thu, 4 Dec 2003 19:47:55 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AS3CP-000F3J-0W; Thu, 04 Dec 2003 23:47:57 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 9B17016C5B; Thu, 4 Dec 2003 23:47:56 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id ED8A515A6F; Thu, 4 Dec 2003 23:47:54 +0000 (GMT) +From: Richard Huxton +To: Jack Coates , josh@agliodbs.com +Subject: Re: tuning questions +Date: Thu, 4 Dec 2003 23:47:54 +0000 +User-Agent: KMail/1.5 +Cc: pgsql-performance +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312041324.37889.josh@agliodbs.com> + <1070579771.18838.187.camel@cletus.lyris.com> +In-Reply-To: <1070579771.18838.187.camel@cletus.lyris.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200312042347.54461.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/111 +X-Sequence-Number: 4971 + +On Thursday 04 December 2003 23:16, Jack Coates wrote: +> +> > > effective_cache_size = 10000 +> > +> > This is way the heck too low. it's supposed to be the size of all +> > available RAM; I'd set it to 2GB*65% as a start. +> +> This makes a little bit of difference. I set it to 65% (15869 pages). + +That's still only about 127MB (15869 * 8KB). + +> Now we have some real disk IO: +> procs memory swap io +> system cpu +> r b w swpd free buff cache si so bi bo in cs us +> sy id +> 0 3 1 2804 10740 40808 1899856 0 0 26624 0 941 4144 + +According to this your cache is currently 1,899,856 KB which in 8KB blocks is +237,482 - be frugal and say effective_cache_size = 200000 (or even 150000 if +the trace above isn't typical). + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Thu Dec 4 20:33:17 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 73A8CD1B4A6 + for ; + Fri, 5 Dec 2003 00:33:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 54066-09 + for ; + Thu, 4 Dec 2003 20:32:47 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A9D8D1B47A + for ; + Thu, 4 Dec 2003 20:32:43 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by luna.lyris.com (8.12.8/8.12.8) with ESMTP id hB50W8It019837; + Thu, 4 Dec 2003 16:32:08 -0800 +Received: from luna.lyris.com ([216.91.57.116]) + by luna.lyris.com (MailMonitor for SMTP v1.2.2 ) ; + Thu, 4 Dec 2003 16:32:08 -0800 (PST) +Received: from cletus.lyris.com (cletus.lyris.com [216.91.56.155]) by + luna.lyris.net with SMTP (MailShield v2.04 - LINUX Jul 17 2001 + 16:58:31); Thu, 04 Dec 2003 16:32:08 -0800 +Subject: Re: tuning questions +From: Jack Coates +To: Richard Huxton +Cc: josh@agliodbs.com, + pgsql-performance +In-Reply-To: <200312042347.54461.dev@archonet.com> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312041324.37889.josh@agliodbs.com> + <1070579771.18838.187.camel@cletus.lyris.com> + <200312042347.54461.dev@archonet.com> +Content-Type: text/plain +Organization: Lyris Technologies, Inc. +Message-Id: <1070584326.18838.235.camel@cletus.lyris.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.4-9mdk +Date: Thu, 04 Dec 2003 16:32:06 -0800 +Content-Transfer-Encoding: 7bit +X-SMTP-HELO: cletus.lyris.com +X-SMTP-MAIL-FROM: jack@lyris.com +X-SMTP-RCPT-TO: dev@archonet.com, josh@agliodbs.com, + pgsql-performance@postgresql.org +X-SMTP-PEER-INFO: cletus.lyris.com [216.91.56.155] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/112 +X-Sequence-Number: 4972 + +On Thu, 2003-12-04 at 15:47, Richard Huxton wrote: +> On Thursday 04 December 2003 23:16, Jack Coates wrote: +> > +> > > > effective_cache_size = 10000 +> > > +> > > This is way the heck too low. it's supposed to be the size of all +> > > available RAM; I'd set it to 2GB*65% as a start. +> > +> > This makes a little bit of difference. I set it to 65% (15869 pages). +> +> That's still only about 127MB (15869 * 8KB). + +yeah, missed the final digit when I copied it into the postgresql.conf +:-( Just reloaded with 158691 pages. +> +> > Now we have some real disk IO: +> > procs memory swap io +> > system cpu +> > r b w swpd free buff cache si so bi bo in cs us +> > sy id +> > 0 3 1 2804 10740 40808 1899856 0 0 26624 0 941 4144 +> +> According to this your cache is currently 1,899,856 KB which in 8KB blocks is +> 237,482 - be frugal and say effective_cache_size = 200000 (or even 150000 if +> the trace above isn't typical). + +d'oh, just realized what you're telling me here. /me smacks forehead. +Let's try effective_cache of 183105... (75%). Starting both servers, +waiting for big fetch to start, and... + + procs memory swap io +system cpu + r b w swpd free buff cache si so bi bo in cs us +sy id + 0 0 0 2800 11920 40532 1906516 0 0 0 0 521 8 +0 0 100 + 0 1 0 2800 11920 40532 1906440 0 0 356 52 611 113 +1 3 97 + 0 1 0 2800 11920 40532 1906424 0 0 20604 0 897 808 +1 18 81 + 0 1 0 2800 11920 40532 1906400 0 0 26112 0 927 820 +1 13 87 + 0 1 0 2800 11920 40532 1906384 0 0 26112 0 923 812 +1 12 87 + 0 1 0 2800 11920 40532 1906372 0 0 24592 0 921 805 +1 13 87 + 0 1 0 2800 11920 40532 1906368 0 0 3248 48 961 1209 +0 4 96 + 0 1 0 2800 11920 40532 1906368 0 0 2600 0 845 1631 +0 2 98 + 0 1 0 2800 11920 40532 1906364 0 0 2728 0 871 1714 +0 2 98 + +better in vmstat... but the query doesn't work any better unfortunately. + +The frustrating thing is, we also have a UP P3-500 with 512M RAM and two +IDE drives with the same PG install which is doing okay with this load +-- still half the speed of MS-SQL2K, but usable. I'm at a loss. +-- +Jack Coates, Lyris Technologies Applications Engineer +510-549-4350 x148, jack@lyris.com +"Interoperability is the keyword, uniformity is a dead end." + --Olivier Fourdan + + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 21:45:52 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 099C9D1B456 + for ; + Fri, 5 Dec 2003 01:45:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 63663-05 + for ; + Thu, 4 Dec 2003 21:45:16 -0400 (AST) +Received: from uhh.alcaron.ee (uhh.alcaron.ee [194.204.62.169]) + by svr1.postgresql.org (Postfix) with ESMTP id 2FF3FD1B446 + for ; + Thu, 4 Dec 2003 21:45:11 -0400 (AST) +Received: from iff by uhh.alcaron.ee with local + id 1AS51u-0005YQ-00; Fri, 05 Dec 2003 03:45:14 +0200 +Date: Fri, 5 Dec 2003 03:45:14 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +Message-ID: <20031205014514.GA21079@alcaron.ee> +References: <20031204185751.GA15893@alcaron.ee> + <200312042023.37050.dev@archonet.com> + <20031204221312.GA18874@alcaron.ee> + <200312042245.21899.dev@archonet.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200312042245.21899.dev@archonet.com> +User-Agent: Mutt/1.3.28i +From: Ivar Zarans +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/113 +X-Sequence-Number: 4973 + +On Thu, Dec 04, 2003 at 10:45:21PM +0000, Richard Huxton wrote: + +> If you've got the time, try putting together a small test-script with some +> dummy data and see if it's reproducible. I'm sure the other Python users +> would be interested in seeing where the problem is. + +Tried with test-script, but this functioned normally (Murphy's law!). +Then tweaked postrgesql.conf and switched on debugging options. Results +show (in my opinion) that Python has nothing to do with slow UPDATE. +Timing from postgresql itself shows duration of 0.29 sec. + +=== +postgres[21247]: [2707] DEBUG: StartTransactionCommand +postgres[21247]: [2708-1] LOG: query: +postgres[21247]: [2708-2] UPDATE +postgres[21247]: [2708-3] imp_cdr_200311 +postgres[21247]: [2708-4] SET +postgres[21247]: [2708-5] Status = 'SKIP' +postgres[21247]: [2708-6] WHERE +postgres[21247]: [2708-7] ImpRecID = '202425' +... +Skipped rewritten parse tree +... +postgres[21247]: [2710-1] LOG: plan: +postgres[21247]: [2710-2] { INDEXSCAN +postgres[21247]: [2710-3] :startup_cost 0.00 +postgres[21247]: [2710-4] :total_cost 6.01 +postgres[21247]: [2710-5] :rows 1 +postgres[21247]: [2710-6] :width 199 +postgres[21247]: [2710-7] :qptargetlist ( +... +Skipped target list +... +postgres[21247]: [2711] DEBUG: CommitTransactionCommand +postgres[21247]: [2712] LOG: duration: 0.292529 sec +=== + +Any suggestions for further investigation? + +-- +Ivar Zarans + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 22:08:15 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CF9D0D1B457 + for ; + Fri, 5 Dec 2003 02:07:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 66891-05 + for ; + Thu, 4 Dec 2003 22:07:28 -0400 (AST) +Received: from uhh.alcaron.ee (uhh.alcaron.ee [194.204.62.169]) + by svr1.postgresql.org (Postfix) with ESMTP id E91A3D1B43A + for ; + Thu, 4 Dec 2003 22:07:24 -0400 (AST) +Received: from iff by uhh.alcaron.ee with local + id 1AS5NQ-0005bY-00; Fri, 05 Dec 2003 04:07:28 +0200 +Date: Fri, 5 Dec 2003 04:07:28 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +Message-ID: <20031205020728.GA21440@alcaron.ee> +References: <20031204185751.GA15893@alcaron.ee> + <200312042023.37050.dev@archonet.com> + <20031204221312.GA18874@alcaron.ee> + <200312042245.21899.dev@archonet.com> + <20031205014514.GA21079@alcaron.ee> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20031205014514.GA21079@alcaron.ee> +User-Agent: Mutt/1.3.28i +From: Ivar Zarans +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/114 +X-Sequence-Number: 4974 + + +I have played around with explain and explain analyze and noticed one +interesting oddity: + +=== +explain UPDATE table1 SET status = 'SKIP' WHERE recid = 196641; + + Seq Scan on table1 (cost=0.00..16709.97 rows=1 width=199) + Filter: (recid = 196641) + +=== + +explain UPDATE table1 SET status = 'SKIP' WHERE recid = '196641'; + + Index Scan using table1_pkey on table1 (cost=0.00..6.01 rows=1 width=199) + Index Cond: (recid = 196641::bigint) + +=== + +explain UPDATE table1 SET status = 'SKIP' WHERE recid = 196641::bigint; + + Index Scan using table1_pkey on table1 (cost=0.00..6.01 rows=1 width=199) + Index Cond: (recid = 196641::bigint) + +=== + +Why first example, where recid is given as numeric constant, is using +sequential scan, but second example, where recid is given as string +constant works with index scan, as expected? Third example shows, that +numeric constant must be typecasted in order to function properly. + +Is this normal behaviour of fields with bigint type? + +-- +Ivar Zarans + + +From pgsql-performance-owner@postgresql.org Thu Dec 4 22:14:59 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 931C2D1B470 + for ; + Fri, 5 Dec 2003 02:14:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64493-09 + for ; + Thu, 4 Dec 2003 22:14:30 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 6EF60D1B472 + for ; + Thu, 4 Dec 2003 22:14:25 -0400 (AST) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + hB52E0oD057144; Fri, 5 Dec 2003 10:14:01 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <3FCFEA58.7090505@familyhealth.com.au> +Date: Fri, 05 Dec 2003 10:15:52 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ivar Zarans +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +References: <20031204185751.GA15893@alcaron.ee> + <200312042023.37050.dev@archonet.com> + <20031204221312.GA18874@alcaron.ee> + <200312042245.21899.dev@archonet.com> + <20031205014514.GA21079@alcaron.ee> + <20031205020728.GA21440@alcaron.ee> +In-Reply-To: <20031205020728.GA21440@alcaron.ee> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/115 +X-Sequence-Number: 4975 + +> Why first example, where recid is given as numeric constant, is using +> sequential scan, but second example, where recid is given as string +> constant works with index scan, as expected? Third example shows, that +> numeric constant must be typecasted in order to function properly. +> +> Is this normal behaviour of fields with bigint type? + +Yes, it's a known performance problem in PostgreSQL 7.4 and below. I +believe it's been fixed in 7.5 CVS already. + +Chris + + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 00:53:36 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6354ED1B449 + for ; + Fri, 5 Dec 2003 04:53:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 87664-03 + for ; + Fri, 5 Dec 2003 00:52:30 -0400 (AST) +Received: from main.wiredfool.com (dsl231-055-035.sea1.dsl.speakeasy.net + [216.231.55.35]) + by svr1.postgresql.org (Postfix) with ESMTP id 096C4D1B432 + for ; + Fri, 5 Dec 2003 00:52:29 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by main.wiredfool.com (Postfix) with ESMTP + id 03F9E2728E; Thu, 4 Dec 2003 20:47:25 -0800 (PST) +Received: from main.wiredfool.com ([127.0.0.1]) + by localhost (cabbage [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 27978-09; Thu, 4 Dec 2003 20:47:22 -0800 (PST) +Received: from [IPv6:::1] (localhost [127.0.0.1]) + by main.wiredfool.com (Postfix) with ESMTP + id 6F1312728D; Thu, 4 Dec 2003 20:47:22 -0800 (PST) +In-Reply-To: <1070584326.18838.235.camel@cletus.lyris.com> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312041324.37889.josh@agliodbs.com> + <1070579771.18838.187.camel@cletus.lyris.com> + <200312042347.54461.dev@archonet.com> + <1070584326.18838.235.camel@cletus.lyris.com> +Mime-Version: 1.0 (Apple Message framework v606) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance +From: Eric Soroos +Subject: Re: tuning questions +Date: Thu, 4 Dec 2003 20:52:22 -0800 +To: Jack Coates +X-Mailer: Apple Mail (2.606) +X-Virus-Scanned: by amavisd-new-20030616-p3 (Debian) at main.wiredfool.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/116 +X-Sequence-Number: 4976 + +> +> d'oh, just realized what you're telling me here. /me smacks forehead. +> Let's try effective_cache of 183105... (75%). Starting both servers, +> waiting for big fetch to start, and... +> +> procs memory swap io +> system cpu +> r b w swpd free buff cache si so bi bo in cs us +> sy id +> 0 0 0 2800 11920 40532 1906516 0 0 0 0 521 8 +> 0 0 100 +> 0 1 0 2800 11920 40532 1906440 0 0 356 52 611 113 +> 1 3 97 +> 0 1 0 2800 11920 40532 1906424 0 0 20604 0 897 808 +> 1 18 81 +> 0 1 0 2800 11920 40532 1906400 0 0 26112 0 927 820 +> 1 13 87 +> 0 1 0 2800 11920 40532 1906384 0 0 26112 0 923 812 +> 1 12 87 +> 0 1 0 2800 11920 40532 1906372 0 0 24592 0 921 805 +> 1 13 87 +> 0 1 0 2800 11920 40532 1906368 0 0 3248 48 961 1209 +> 0 4 96 +> 0 1 0 2800 11920 40532 1906368 0 0 2600 0 845 1631 +> 0 2 98 +> 0 1 0 2800 11920 40532 1906364 0 0 2728 0 871 1714 +> 0 2 98 +> +> better in vmstat... but the query doesn't work any better +> unfortunately. + +Your io now looks like you're getting a few seconds of continuous read, +and then you're getting into maxing out random reads. These look about +right for a single ide drive. + +> The frustrating thing is, we also have a UP P3-500 with 512M RAM and +> two +> IDE drives with the same PG install which is doing okay with this load +> -- still half the speed of MS-SQL2K, but usable. I'm at a loss. + +I wonder if you're doing table scans. From the earlier trace, it looked +like you have a few parallel select/process/insert processes going. + +If that's the case, you might be getting a big sequential scan at +first, then at some point you have enough selects going that it wtarts +looking more like random access. + +Can you run one of the selects from the psql console and see how fast +it runs? Do your inserts have any foreign key relations? + +One thing you might try is to shut down the postmaster and move the +pg_clog and pg_xlog directories to the other drive, and leave symlinks +pointing back. That should help your insert performance by putting the +wal on a seperate drive from the table data. It will really help if you +wind up having uncached read and write access at the same time. You +also might gain by using software raid 0 (with large stripe size, 512k +or so) across both drives, but if you don't have the appropriate +paritions in there now it's going to be a bunch of work. + +eric + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 04:09:16 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7561CD1B460 + for ; + Fri, 5 Dec 2003 08:09:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03299-10 + for ; + Fri, 5 Dec 2003 04:08:43 -0400 (AST) +Received: from ar-sd.net (unknown [81.196.32.112]) + by svr1.postgresql.org (Postfix) with ESMTP id 81837D1B474 + for ; + Fri, 5 Dec 2003 04:08:40 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by ar-sd.net (Postfix) with ESMTP + id 262561C8D4; Fri, 5 Dec 2003 10:11:48 +0200 (EET) +Received: from andy (unknown [192.168.0.11]) by ar-sd.net (Postfix) with SMTP + id 055C917723; Fri, 5 Dec 2003 10:11:48 +0200 (EET) +Message-ID: <00c901c3bb07$592bbe30$0b00a8c0@andy> +From: "Andrei Bintintan" +To: "Stephan Szabo" +Cc: +References: <014901c3ba76$ffd65650$0b00a8c0@andy> + <20031204071432.R66123@megazone.bigpanda.com> +Subject: Re: [ADMIN] Index not used. WHY? +Date: Fri, 5 Dec 2003 10:11:11 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 5.50.4927.1200 +X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 +X-Virus-Scanned: by AMaViS snapshot-20020531 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/117 +X-Sequence-Number: 4977 + +There are around 700 rows in this table. +If I set enable_seqscan=off then the index is used and I also used Vacuum +Analyze recently. + +I find it strange because the number of values of id_user and id_modull are +somehow in the same distribution and when I search the table the id_user +index is used but the id_modull index is not used. + +Does somehow postgre know that a seq scan runs faster in this case as a +index scan? Should I erase this index? +I have to say that the data's in this table are not changed offen, but there +are a LOT of joins made with this table. + +Best regards. +Andy. + + +----- Original Message ----- +From: "Stephan Szabo" +To: "Andrei Bintintan" +Cc: ; +Sent: Thursday, December 04, 2003 5:19 PM +Subject: Re: [ADMIN] Index not used. WHY? + + +> +> On Thu, 4 Dec 2003, Andrei Bintintan wrote: +> +> > Hi, +> > +> > I have the following table: +> > CREATE TABLE public.rights ( +> > id int4 DEFAULT nextval('"rights_id_seq"'::text) NOT NULL, +> > id_user int4 NOT NULL, +> > id_modull int4 NOT NULL, +> > CONSTRAINT rights_pkey PRIMARY KEY (id) +> > ) +> > +> > and I created the following indexes: +> > +> > CREATE INDEX right_id_modull_idx ON rights USING btree (id_modull); +> > CREATE INDEX right_id_user_idx ON rights USING btree (id_user); +> > +> > Now the problem: +> > +> > EXPLAIN SELECT * FROM rights r WHERE r.id_modull =15 +> > returnes: +> > Seq Scan on rights r (cost=0.00..12.30 rows=42 width=12) +> > Filter: (id_modull = 15) +> > +> > EXPLAIN SELECT * FROM rights r WHERE r.id_user =15 +> > returnes: +> > Index Scan using right_id_user_idx on rights r (cost=0.00..8.35 rows=11 +width=12) +> > Index Cond: (id_user = 15) +> > +> > Question: Why the right_id_modull_idx is NOT USED at the 1st query and +> > the second query the right_id_user_idx index is used. +> +> As a note, pgsql-performance is a better list for these questions. +> +> So, standard questions: +> +> How many rows are in the table, what does EXPLAIN ANALYZE show for the +> queries, if you force index usage (set enable_seqscan=off) on the first +> what does EXPLAIN ANALYZE show then, have you used ANALYZE/VACUUM ANALYZE +> recently? +> + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 04:40:38 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F5C4D1B47A + for ; + Fri, 5 Dec 2003 08:40:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14504-02 + for ; + Fri, 5 Dec 2003 04:40:07 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id D8495D1B475 + for ; + Fri, 5 Dec 2003 04:40:04 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.45 $ on + Novell NetWare via secured & encrypted transport (TLS); + Fri, 05 Dec 2003 01:40:07 -0700 +Message-ID: <3FD04457.6000504@myrealbox.com> +Date: Fri, 05 Dec 2003 14:09:51 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Andrei Bintintan +Cc: Stephan Szabo , + pgsql-performance@postgresql.org +Subject: Re: [ADMIN] Index not used. WHY? +References: <014901c3ba76$ffd65650$0b00a8c0@andy> + <20031204071432.R66123@megazone.bigpanda.com> + <00c901c3bb07$592bbe30$0b00a8c0@andy> +In-Reply-To: <00c901c3bb07$592bbe30$0b00a8c0@andy> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/118 +X-Sequence-Number: 4978 + +Andrei Bintintan wrote: + +> There are around 700 rows in this table. +> If I set enable_seqscan=off then the index is used and I also used Vacuum +> Analyze recently. + +For 700 rows I think seq. would work best. +> +> I find it strange because the number of values of id_user and id_modull are +> somehow in the same distribution and when I search the table the id_user +> index is used but the id_modull index is not used. +> +> Does somehow postgre know that a seq scan runs faster in this case as a +> index scan? Should I erase this index? +> I have to say that the data's in this table are not changed offen, but there +> are a LOT of joins made with this table. + +If table is cached then it does not matter. Unless it grows substantially, say +to around hundred thousand rows(Note your table is small), idex wouldn't be that +useful. + + Shridhar + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 05:13:33 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E32D0D1B475 + for ; + Fri, 5 Dec 2003 09:13:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10446-07 + for ; + Fri, 5 Dec 2003 05:13:01 -0400 (AST) +Received: from ecbull20.frec.bull.fr (ecbull20.frec.bull.fr [129.183.4.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 0EB03D1B47A + for ; + Fri, 5 Dec 2003 05:12:57 -0400 (AST) +Received: from ecn002.frec.bull.fr (ecn002.frec.bull.fr [129.183.4.6]) + by ecbull20.frec.bull.fr (8.9.2/8.9.1) with ESMTP id KAA16934; + Fri, 5 Dec 2003 10:13:05 +0100 +Received: from BULL.NET ([129.183.148.134]) + by ecn002.frec.bull.fr (Lotus Domino Release 5.0.12) + with ESMTP id 2003120510163396:112 ; Fri, 5 Dec 2003 10:16:33 +0100 +Message-ID: <3FD04C25.307690CC@BULL.NET> +Date: Fri, 05 Dec 2003 10:13:09 +0100 +From: Thierry Missimilly +Organization: BSIS/R&D +X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U) +X-Accept-Language: fr,en +MIME-Version: 1.0 +To: Jack Coates +Cc: pgsql-performance +Subject: Re: tuning questions +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312041120.21124.josh@agliodbs.com> + <1070567455.13923.83.camel@cletus.lyris.com> + <200312042027.22223.dev@archonet.com> + <1070570264.13923.88.camel@cletus.lyris.com> +X-MIMETrack: Itemize by SMTP Server on ECN002/FR/BULL(Release 5.0.12 |February + 13, 2003) at 05/12/2003 10:16:34, + Serialize by Router on ECN002/FR/BULL(Release 5.0.12 |February 13, + 2003) at 05/12/2003 10:16:40, + Serialize complete at 05/12/2003 10:16:40 +Content-Type: multipart/mixed; boundary="------------A086F02D18D306A929300A18" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/119 +X-Sequence-Number: 4979 + +This is a multi-part message in MIME format. +--------------A086F02D18D306A929300A18 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + +Jack Coates wrote: + +> +> latest changes: +> shared_buffers = 35642 +> max_fsm_relations = 1000 +> max_fsm_pages = 10000 +> wal_buffers = 64 +> sort_mem = 32768 +> vacuum_mem = 32768 +> effective_cache_size = 10000 +> +> /proc/sys/kernel/shmmax = 500000000 +> +> IO is active, but hardly saturated. CPU load is hefty though, load +> average is at 4 now. +> +> procs memory swap io +> system cpu +> r b w swpd free buff cache si so bi bo in cs us +> sy id +> 0 2 1 2808 11436 39616 1902988 0 0 240 896 765 469 +> 2 11 87 +> 0 2 1 2808 11432 39616 1902988 0 0 244 848 768 540 +> 4 3 93 +> 0 2 1 2808 11432 39616 1902984 0 0 204 876 788 507 +> 3 4 93 +> 0 2 1 2808 11432 39616 1902984 0 0 360 416 715 495 +> 4 1 96 +> 0 2 1 2808 11432 39616 1902984 0 0 376 328 689 441 +> 2 1 97 +> 0 2 0 2808 11428 39616 1902976 0 0 464 360 705 479 +> 2 1 97 +> 0 2 1 2808 11428 39616 1902976 0 0 432 380 718 547 +> 3 1 97 +> 0 2 1 2808 11428 39616 1902972 0 0 440 372 742 512 +> 1 3 96 +> 0 2 1 2808 11428 39616 1902972 0 0 416 364 711 504 +> 3 1 96 +> 0 2 1 2808 11424 39616 1902972 0 0 456 492 743 592 +> 2 1 97 +> 0 2 1 2808 11424 39616 1902972 0 0 440 352 707 494 +> 2 1 97 +> 0 2 1 2808 11424 39616 1902972 0 0 456 360 709 494 +> 2 2 97 +> 0 2 1 2808 11436 39616 1902968 0 0 536 516 807 708 +> 3 2 94 +> + +Hi Jack, + +As show by vmstat, your Operating System is spending 96% of its time in Idle. On +RedHat 8.0 IA32, Idle means idle and Wait I/O. +In your case, i think they are Wait I/O as you are working on 2.8 GB DB with only +2GB RAM, but it should be arround 30%. +Your performances whould increase only if User CPU increase otherwise, for exemple +if your system swap, only Sys CPU whould increase and your application will stay +slow. + +You can better check your I/O with : iostat 3 1000, and check that the max tps are +on the database filesystem. + +So, all the Postgres tuning you have tried do not change a lot as the bottleneck is +your I/O throuput. +But, one thing you can check is which parts of Postgres need a lot of I/O. +To do that, after shuting down PG, move your database on an other disk (OS disk ?) +for exemple /mypg/data and create a symblolic link for /mypg/data/ to +$PGDATA/base. + +Restart PG, and while you execute your application, check with iostat which disk as +the max of tps. I bet, it is the disk where the WAL buffer are logged. + +One more thing about I/O, for an IDE disk, the maximum number of Write Block + Read +Block per sec is about 10000 based on the I/O block size is 1 K. That means 10 +Mb/s. if you need more, you can try Stripped SCSI disks or RAID0 subsystem disks. + +Thierry Missimilly + +> +> -- +> Jack Coates, Lyris Technologies Applications Engineer +> 510-549-4350 x148, jack@lyris.com +> "Interoperability is the keyword, uniformity is a dead end." +> --Olivier Fourdan +> +> ---------------------------(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 + +--------------A086F02D18D306A929300A18 +Content-Type: text/x-vcard; charset=us-ascii; + name="THIERRY.MISSIMILLY.vcf" +Content-Description: Card for Thierry Missimilly +Content-Disposition: attachment; + filename="THIERRY.MISSIMILLY.vcf" +Content-Transfer-Encoding: 7bit + +begin:vcard +n:Missimilly;Thierry +tel;fax:+33 (0)4 76 29 78 78 +tel;work:+33 (0)4 76 29 74 54 +x-mozilla-html:FALSE +url:http:\\www.bull.com +org:BIS/R&D +adr:;;Bull SA, 1, rue de provence - BP 208;ECHIROLLES;;38432;FRANCE +version:2.1 +email;internet:Thierry.Missimilly@bull.net +x-mozilla-cpt:;-18184 +fn:Thierry Missimilly +end:vcard + +--------------A086F02D18D306A929300A18-- + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 06:08:59 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3299BD1B475 + for ; + Fri, 5 Dec 2003 10:08:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 23188-03 + for ; + Fri, 5 Dec 2003 06:08:29 -0400 (AST) +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 4699BD1B47A + for ; + Fri, 5 Dec 2003 06:08:22 -0400 (AST) +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 1ASCsp-00003O-0V; Fri, 05 Dec 2003 10:08:23 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 0AD5716A42; Fri, 5 Dec 2003 10:08:21 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 3462315948; Fri, 5 Dec 2003 10:08:20 +0000 (GMT) +From: Richard Huxton +To: Ivar Zarans , pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +Date: Fri, 5 Dec 2003 10:08:20 +0000 +User-Agent: KMail/1.5 +References: <20031204185751.GA15893@alcaron.ee> + <20031205014514.GA21079@alcaron.ee> + <20031205020728.GA21440@alcaron.ee> +In-Reply-To: <20031205020728.GA21440@alcaron.ee> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200312051008.20317.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/120 +X-Sequence-Number: 4980 + +On Friday 05 December 2003 02:07, Ivar Zarans wrote: +> I have played around with explain and explain analyze and noticed one +> interesting oddity: +[snip] +> Why first example, where recid is given as numeric constant, is using +> sequential scan, but second example, where recid is given as string +> constant works with index scan, as expected? Third example shows, that +> numeric constant must be typecasted in order to function properly. +> +> Is this normal behaviour of fields with bigint type? + +As Christopher says, normal (albeit irritating). Not sure it applies here - +all the examples you've shown me are using the index. + +Well - I must admit I'm stumped. Unless you have a *lot* of indexes and +foreign keys to check, I can't see why it would take so long to update a +single row. Can you post the schema for the table? +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Dec 5 08:39:20 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 94E06D1B48B + for ; + Fri, 5 Dec 2003 12:39:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42257-03 + for ; + Fri, 5 Dec 2003 08:38:45 -0400 (AST) +Received: from uhh.alcaron.ee (uhh.alcaron.ee [194.204.62.169]) + by svr1.postgresql.org (Postfix) with ESMTP id 99F67D1B460 + for ; + Fri, 5 Dec 2003 08:38:41 -0400 (AST) +Received: from iff by uhh.alcaron.ee with local + id 1ASFEJ-00079B-00; Fri, 05 Dec 2003 14:38:43 +0200 +Date: Fri, 5 Dec 2003 14:38:43 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +Message-ID: <20031205123843.GA27170@alcaron.ee> +References: <20031204185751.GA15893@alcaron.ee> + <20031205014514.GA21079@alcaron.ee> + <20031205020728.GA21440@alcaron.ee> + <200312051008.20317.dev@archonet.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200312051008.20317.dev@archonet.com> +User-Agent: Mutt/1.3.28i +From: Ivar Zarans +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/121 +X-Sequence-Number: 4981 + +On Fri, Dec 05, 2003 at 10:08:20AM +0000, Richard Huxton wrote: + +> > numeric constant must be typecasted in order to function properly. +> > +> > Is this normal behaviour of fields with bigint type? +> +> As Christopher says, normal (albeit irritating). Not sure it applies here - +> all the examples you've shown me are using the index. + +I guess i have solved this mystery. Problem appears to be exactly with +this - numeric constant representation in query. + +I am using PyPgSQL for PostgreSQL access and making update queries as this: + +qry = "UPDATE table1 SET status = %s WHERE recid = %s" +cursor.execute(qry, status, recid) + +Execute method of cursor object is supposed to merge "status" and +"recid" values into "qry", using proper quoting. When i started to play +around with debug information i noticed, that this query used sequential +scan for "recid". Then i also noticed, that query, sent to server looked +like this: +"UPDATE table1 SET status = 'SKIP' WHERE recid = 199901" + +Sure enough, when i used psql and EXPLAIN on this query, i got query +plan with sequential scan. And using recid value as string or typecasted +integer gave correct results with index scan. I wrote about this in my +previous message. + +It seems, that PyPgSQL query quoting is not aware of this performance +problem (to which Cristopher referred) and final query, sent to server +is correct SQL, but not correct, considering PostgreSQL bugs. + +One more explanation - previously i posted some logs, showing correct +query, using index scan, but still taking 0.29 seconds. Reason for this +delay is logging itself - it generates enough IO traffic to have impact +on query speed. With logging disabled, this query takes around 0.0022 +seconds, which is perfectly normal. + +Finally - what would be correct solution to this problem? Upgrading to +7.5 CVS is not an option :) One possibility is not to use PyPgSQL +variable substitution and create every query "by hand" - not very nice +solution, since variable substitution and quoting is quite convenient. + +Second (and better) possibility is to ask PyPgSQL develeopers to take care +of PostgreSQL oddities. + +Any other suggestions? + +-- +Ivar + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 08:50:29 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 247CBD1B48E + for ; + Fri, 5 Dec 2003 12:50:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 47259-02 + for ; + Fri, 5 Dec 2003 08:49:53 -0400 (AST) +Received: from smtp.pspl.co.in (unknown [202.54.11.65]) + by svr1.postgresql.org (Postfix) with ESMTP id 9A015D1B454 + for ; + Fri, 5 Dec 2003 08:49:48 -0400 (AST) +Received: (from root@localhost) + by smtp.pspl.co.in (8.12.9/8.12.9) id hB5CnwOX026523 + for ; Fri, 5 Dec 2003 18:19:58 +0530 +Received: from persistent.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) + (authenticated bits=0) + by persistent.co.in (8.12.9/8.12.9) with ESMTP id hB5Cnvhe026485; + Fri, 5 Dec 2003 18:19:57 +0530 +Message-ID: <3FD07EEA.8030007@persistent.co.in> +Date: Fri, 05 Dec 2003 18:19:46 +0530 +From: Shridhar Daithankar +Organization: Persistent Systems Pvt. Ltd. +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ivar Zarans +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +References: <20031204185751.GA15893@alcaron.ee> + <20031205014514.GA21079@alcaron.ee> + <20031205020728.GA21440@alcaron.ee> + <200312051008.20317.dev@archonet.com> + <20031205123843.GA27170@alcaron.ee> +In-Reply-To: <20031205123843.GA27170@alcaron.ee> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/122 +X-Sequence-Number: 4982 + +Ivar Zarans wrote: +> It seems, that PyPgSQL query quoting is not aware of this performance +> problem (to which Cristopher referred) and final query, sent to server +> is correct SQL, but not correct, considering PostgreSQL bugs. + +Personally I don't consider a bug but anyways.. You are the one facing problem +so I understand.. + +> Finally - what would be correct solution to this problem? Upgrading to +> 7.5 CVS is not an option :) One possibility is not to use PyPgSQL +> variable substitution and create every query "by hand" - not very nice +> solution, since variable substitution and quoting is quite convenient. +> +> Second (and better) possibility is to ask PyPgSQL develeopers to take care +> of PostgreSQL oddities. +> +> Any other suggestions? + +I know zero in python but just guessing.. + +Will following help? + +qry = "UPDATE table1 SET status = %s WHERE recid = '%s'" +cursor.execute(qry, status, recid) + + Just a thought.. + + Shridhar + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 09:13:56 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BC3B6D1B445 + for ; + Fri, 5 Dec 2003 13:13:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48494-07 + for ; + Fri, 5 Dec 2003 09:13:26 -0400 (AST) +Received: from uhh.alcaron.ee (uhh.alcaron.ee [194.204.62.169]) + by svr1.postgresql.org (Postfix) with ESMTP id BB5F9D1B465 + for ; + Fri, 5 Dec 2003 09:13:22 -0400 (AST) +Received: from iff by uhh.alcaron.ee with local + id 1ASFlt-0007Tk-00; Fri, 05 Dec 2003 15:13:25 +0200 +Date: Fri, 5 Dec 2003 15:13:25 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +Message-ID: <20031205131325.GB27524@alcaron.ee> +References: <20031204185751.GA15893@alcaron.ee> + <20031205014514.GA21079@alcaron.ee> + <20031205020728.GA21440@alcaron.ee> + <200312051008.20317.dev@archonet.com> + <20031205123843.GA27170@alcaron.ee> + <3FD07EEA.8030007@persistent.co.in> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3FD07EEA.8030007@persistent.co.in> +User-Agent: Mutt/1.3.28i +From: Ivar Zarans +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/123 +X-Sequence-Number: 4983 + +On Fri, Dec 05, 2003 at 06:19:46PM +0530, Shridhar Daithankar wrote: + +> >is correct SQL, but not correct, considering PostgreSQL bugs. +> +> Personally I don't consider a bug but anyways.. You are the one facing +> problem so I understand.. + +Well, if this is not bug, then what is consideration behind this +behaviour? BTW, according to Cristopher it is fixed in 7.5 CVS. +Why fix it if this is not a bug? :)) + +One more question - is this "feature" related only to "bigint" fields, +or are other datatypes affected as well? + +> Will following help? +> +> qry = "UPDATE table1 SET status = %s WHERE recid = '%s'" +> cursor.execute(qry, status, recid) + +Yes, this helps. But then it sort of obsoletes PyPgSQL-s own quoting +logic. I would prefer to take care of this all by myself or trust some +underlying code to do this for me. And PyPgSQL is quite nice - it +checks datatype and acts accordingly. + +-- +Ivar + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 09:24:23 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E65C0D1B459 + for ; + Fri, 5 Dec 2003 13:24:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 52549-02 + for ; + Fri, 5 Dec 2003 09:23:53 -0400 (AST) +Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net + [194.217.242.90]) + by svr1.postgresql.org (Postfix) with ESMTP id 74625D1B44A + for ; + Fri, 5 Dec 2003 09:23:49 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-32.mail.demon.net with esmtp (Exim 3.35 #1) + id 1ASFvv-000Bfj-0W; Fri, 05 Dec 2003 13:23:47 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 2B8CE1789C; Fri, 5 Dec 2003 13:23:46 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 41C731789A; Fri, 5 Dec 2003 13:23:44 +0000 (GMT) +From: Richard Huxton +To: Shridhar Daithankar , + Ivar Zarans +Subject: Re: Slow UPADTE, compared to INSERT +Date: Fri, 5 Dec 2003 13:23:43 +0000 +User-Agent: KMail/1.5 +Cc: pgsql-performance@postgresql.org +References: <20031204185751.GA15893@alcaron.ee> + <20031205123843.GA27170@alcaron.ee> + <3FD07EEA.8030007@persistent.co.in> +In-Reply-To: <3FD07EEA.8030007@persistent.co.in> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200312051323.43966.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/124 +X-Sequence-Number: 4984 + +On Friday 05 December 2003 12:49, Shridhar Daithankar wrote: +> Ivar Zarans wrote: +> > It seems, that PyPgSQL query quoting is not aware of this performance +> > problem (to which Cristopher referred) and final query, sent to server +> > is correct SQL, but not correct, considering PostgreSQL bugs. + +> +> Will following help? +> +> qry = "UPDATE table1 SET status = %s WHERE recid = '%s'" +> cursor.execute(qry, status, recid) + +Better IMHO would be: "UPDATE table1 SET status = %s WHERE recid = %s::int8" + +PG is very strict regarding types - normally a good thing, but it can hit you +unexpectedly in this scenario. The reason is that the literal number is +treated as int4, whereas quoted it is marked as type unknown. Unkown gets +cast to int8, whereas int4 gets left as-is. If you want to know why int4 +doesn't get promoted to int8 automatically, browse the hackers list for the +last couple of years. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Fri Dec 5 09:52:10 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D9E95D1B45B + for ; + Fri, 5 Dec 2003 13:52:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55940-03 + for ; + Fri, 5 Dec 2003 09:51:41 -0400 (AST) +Received: from smtp.pspl.co.in (unknown [202.54.11.65]) + by svr1.postgresql.org (Postfix) with ESMTP id F0DC9D1B457 + for ; + Fri, 5 Dec 2003 09:51:36 -0400 (AST) +Received: (from root@localhost) + by smtp.pspl.co.in (8.12.9/8.12.9) id hB5Dpp1x032718 + for ; Fri, 5 Dec 2003 19:21:51 +0530 +Received: from persistent.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) + (authenticated bits=0) + by persistent.co.in (8.12.9/8.12.9) with ESMTP id hB5Dpnhe032677; + Fri, 5 Dec 2003 19:21:50 +0530 +Message-ID: <3FD08D6A.4080207@persistent.co.in> +Date: Fri, 05 Dec 2003 19:21:38 +0530 +From: Shridhar Daithankar +Organization: Persistent Systems Pvt. Ltd. +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ivar Zarans +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +References: <20031204185751.GA15893@alcaron.ee> + <20031205014514.GA21079@alcaron.ee> + <20031205020728.GA21440@alcaron.ee> + <200312051008.20317.dev@archonet.com> + <20031205123843.GA27170@alcaron.ee> + <3FD07EEA.8030007@persistent.co.in> + <20031205131325.GB27524@alcaron.ee> +In-Reply-To: <20031205131325.GB27524@alcaron.ee> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/125 +X-Sequence-Number: 4985 + +Ivar Zarans wrote: +> On Fri, Dec 05, 2003 at 06:19:46PM +0530, Shridhar Daithankar wrote: +> +> +>>>is correct SQL, but not correct, considering PostgreSQL bugs. +>>Personally I don't consider a bug but anyways.. You are the one facing +>>problem so I understand.. +> Well, if this is not bug, then what is consideration behind this +> behaviour? BTW, according to Cristopher it is fixed in 7.5 CVS. +> Why fix it if this is not a bug? :)) + +This is not a bug. It is just that people find it confusing when postgresql +planner consider seemingly same type as different. e.g. treating int8 as +different than int4. Obvious thinking is they should be same. But given +postgresql's flexibility with create type, it is difficult to promote. + +AFAIK, the fix in CVS is to make indexes operatable with seemingly compatible +types. Which does not change the fact that postgresql can not upgrade data types +on it's own. + +Write good queries which adhere to strict data typing. It is better to +understand anyway. + +> One more question - is this "feature" related only to "bigint" fields, +> or are other datatypes affected as well? + +Every data type is affected. int2 will not use a int4 index and so on. + +>>Will following help? +>> +>>qry = "UPDATE table1 SET status = %s WHERE recid = '%s'" +>>cursor.execute(qry, status, recid) +> +> +> Yes, this helps. But then it sort of obsoletes PyPgSQL-s own quoting +> logic. I would prefer to take care of this all by myself or trust some +> underlying code to do this for me. And PyPgSQL is quite nice - it +> checks datatype and acts accordingly. + +Well, then pypgsql should be upgraded to query the pg catalogd to find exact +type of column. But that would be too cumbersome I guess. + + Shridhar + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 11:35:34 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D3C5AD1B459 + for ; + Fri, 5 Dec 2003 15:35:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73756-03 + for ; + Fri, 5 Dec 2003 11:35:00 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 20755D1B43A + for ; + Fri, 5 Dec 2003 11:34:56 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 867E3355D4; Fri, 5 Dec 2003 07:34:45 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 85311355A1; Fri, 5 Dec 2003 07:34:45 -0800 (PST) +Date: Fri, 5 Dec 2003 07:34:45 -0800 (PST) +From: Stephan Szabo +To: Andrei Bintintan +Cc: pgsql-performance@postgresql.org +Subject: Re: [ADMIN] Index not used. WHY? +In-Reply-To: <00c901c3bb07$592bbe30$0b00a8c0@andy> +Message-ID: <20031205072359.X5253@megazone.bigpanda.com> +References: <014901c3ba76$ffd65650$0b00a8c0@andy> + <20031204071432.R66123@megazone.bigpanda.com> + <00c901c3bb07$592bbe30$0b00a8c0@andy> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/126 +X-Sequence-Number: 4986 + +On Fri, 5 Dec 2003, Andrei Bintintan wrote: + +> There are around 700 rows in this table. +> If I set enable_seqscan=off then the index is used and I also used Vacuum +> Analyze recently. +> +> I find it strange because the number of values of id_user and id_modull are +> somehow in the same distribution and when I search the table the id_user +> index is used but the id_modull index is not used. + +It was guessing that one would return 11 rows and the other 42 which is +why one used the index and the other wouldn't. If those numbers aren't +realistic, you may want to raise the statistics target for the columns +(see ALTER TABLE) and re-run analyze. + +> Does somehow postgre know that a seq scan runs faster in this case as a +> index scan? Should I erase this index? + +It's making an educated guess. When you're doing an index scan, it needs +to read through the index and then get matching rows from the table. +However, because those reads from the table are in a potentially random +order, there's usually a higher cost associated with those reads than if +the table was read in order (barring cases where you know your database +should always stay cached in disk cache, etc...). If there's say 50 pages +in the entire table, a sequence scan does 50 sequential page reads and is +checking all those tuples. If you're getting say 42 rows through an +index, you're first reading through the index, and then getting pages +in a random order from the table where depends on the distribution of +values throughout the table. There's a variable in the configuration, +random_page_cost which controls the ratio of cost between a sequential +read and a random one (defaulting to 4). + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 12:48:22 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 260B0D1B43A + for ; + Fri, 5 Dec 2003 16:48:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85689-07 + for ; + Fri, 5 Dec 2003 12:47:47 -0400 (AST) +Received: from uhh.alcaron.ee (uhh.alcaron.ee [194.204.62.169]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B46FD1B46D + for ; + Fri, 5 Dec 2003 12:47:46 -0400 (AST) +Received: from iff by uhh.alcaron.ee with local + id 1ASJ7H-0007wW-00; Fri, 05 Dec 2003 18:47:43 +0200 +Date: Fri, 5 Dec 2003 18:47:43 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +Message-ID: <20031205164743.GA30510@alcaron.ee> +References: <20031204185751.GA15893@alcaron.ee> + <20031205123843.GA27170@alcaron.ee> + <3FD07EEA.8030007@persistent.co.in> + <200312051323.43966.dev@archonet.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200312051323.43966.dev@archonet.com> +User-Agent: Mutt/1.3.28i +From: Ivar Zarans +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/127 +X-Sequence-Number: 4987 + +On Fri, Dec 05, 2003 at 01:23:43PM +0000, Richard Huxton wrote: + +> Better IMHO would be: "UPDATE table1 SET status = %s WHERE recid = %s::int8" + +Thanks for the hint! + +> unexpectedly in this scenario. The reason is that the literal number is +> treated as int4, whereas quoted it is marked as type unknown. Unkown gets +> cast to int8, whereas int4 gets left as-is. + +This explains a lot. Thanks! +BTW, is this mentioned somewhere in PostgreSQL documentation? I can't +remember anything on this subject. Maybe i just somehow skipped it... + +-- +Ivar + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 12:53:32 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BBEEBD1B43F + for ; + Fri, 5 Dec 2003 16:53:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86410-01 + for ; + Fri, 5 Dec 2003 12:52:55 -0400 (AST) +Received: from uhh.alcaron.ee (uhh.alcaron.ee [194.204.62.169]) + by svr1.postgresql.org (Postfix) with ESMTP id 85074D1B445 + for ; + Fri, 5 Dec 2003 12:52:54 -0400 (AST) +Received: from iff by uhh.alcaron.ee with local + id 1ASJCH-0007xz-00; Fri, 05 Dec 2003 18:52:53 +0200 +Date: Fri, 5 Dec 2003 18:52:53 +0200 +To: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +Message-ID: <20031205165253.GB30510@alcaron.ee> +References: <20031204185751.GA15893@alcaron.ee> + <20031205014514.GA21079@alcaron.ee> + <20031205020728.GA21440@alcaron.ee> + <200312051008.20317.dev@archonet.com> + <20031205123843.GA27170@alcaron.ee> + <3FD07EEA.8030007@persistent.co.in> + <20031205131325.GB27524@alcaron.ee> + <3FD08D6A.4080207@persistent.co.in> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <3FD08D6A.4080207@persistent.co.in> +User-Agent: Mutt/1.3.28i +From: Ivar Zarans +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/128 +X-Sequence-Number: 4988 + +On Fri, Dec 05, 2003 at 07:21:38PM +0530, Shridhar Daithankar wrote: + +> planner consider seemingly same type as different. e.g. treating int8 as +> different than int4. Obvious thinking is they should be same. But given +> postgresql's flexibility with create type, it is difficult to promote. + +OK, this makes sense and explains a lot. Thanks! + +> Well, then pypgsql should be upgraded to query the pg catalogd to find +> exact type of column. But that would be too cumbersome I guess. + +Yes, so it seems. Time to rewrite my queries :) +Thanks again for help and explanations! + +-- +Ivar + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 13:06:28 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C1942D1B481 + for ; + Fri, 5 Dec 2003 17:06:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89713-03 + for ; + Fri, 5 Dec 2003 13:05:48 -0400 (AST) +Received: from fep02-mail.bloor.is.net.cable.rogers.com + (fep02-mail.bloor.is.net.cable.rogers.com [66.185.86.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C2F7D1B445 + for ; + Fri, 5 Dec 2003 13:05:47 -0400 (AST) +Received: from rogers.com ([65.50.20.132]) + by fep02-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20031205170439.CYCP481016.fep02-mail.bloor.is.net.cable.rogers.com@rogers.com>; + Fri, 5 Dec 2003 12:04:39 -0500 +Message-ID: <3FD0BAE9.7050801@rogers.com> +Date: Fri, 05 Dec 2003 12:05:45 -0500 +From: "Mike C. Fletcher" +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20030925 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ivar Zarans +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +References: <20031204185751.GA15893@alcaron.ee> + <20031205014514.GA21079@alcaron.ee> + <20031205020728.GA21440@alcaron.ee> + <200312051008.20317.dev@archonet.com> + <20031205123843.GA27170@alcaron.ee> +In-Reply-To: <20031205123843.GA27170@alcaron.ee> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Authentication-Info: Submitted using SMTP AUTH PLAIN at + fep02-mail.bloor.is.net.cable.rogers.com from [65.50.20.132] + using ID at Fri, 5 Dec 2003 12:04:39 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/129 +X-Sequence-Number: 4989 + +I just spent 2 days tracking this error down in my own code, actually. +What I wound up doing is having the two places where I generate the +queries (everything in my system goes through those two points, as I'm +using a middleware layer) check values used as identifying fields for +the presence of a bigint, and if one exists, replaces it with a wrapper +that does the coerced-string representation: + + class Wrap: + def __init__( self, value ): + self.value = value + def __str__( self ): + return "'%s'::bigint"%(self.value,) + __repr__ = __str__ + value = Wrap(value) + +Just doing that for the indexing/identifying values ATM. pyPgSQL will +back up to using simple repr for the object (rather than raising an +error as it would if you were using a formatted string), but will +otherwise treat it as a regular value for quoting and the like, so no +other modifications to the code required. + +By no means an elegant fix, but since your post (well, the resulting +thread) managed to solve my problem, figured I should at least tell +everyone thanks and how I worked around the problem. You wouldn't want +this kind of hack down in the pyPgSQL level I would think, as it's +DB-version specific. I suppose you could alter the __repr__ of the +PgInt8 class/type to always use the string or coerced form, but it seems +wrong to me. I'm actually hesitant to include it in our own middleware +layer, but oh well, it does seem to be necessary for even somewhat +reasonable performance. + +BTW, my case was a largish (88,000 record) table with a non-unique +bigint key, explain on update shows sequential search, while with +'int'::bigint goes to index search. Using pyPgSQL as the interface to +7.3.4 and 7.3.3. + +Enjoy, +Mike + +Ivar Zarans wrote: + +>On Fri, Dec 05, 2003 at 10:08:20AM +0000, Richard Huxton wrote: +> +> +... + +>I am using PyPgSQL for PostgreSQL access and making update queries as this: +> +> +... + +>It seems, that PyPgSQL query quoting is not aware of this performance +>problem (to which Cristopher referred) and final query, sent to server +>is correct SQL, but not correct, considering PostgreSQL bugs. +> +> +... + +>Finally - what would be correct solution to this problem? Upgrading to +>7.5 CVS is not an option :) One possibility is not to use PyPgSQL +>variable substitution and create every query "by hand" - not very nice +>solution, since variable substitution and quoting is quite convenient. +> +>Second (and better) possibility is to ask PyPgSQL develeopers to take care +>of PostgreSQL oddities. +> +>Any other suggestions? +> +> + +_______________________________________ + Mike C. Fletcher + Designer, VR Plumber, Coder + http://members.rogers.com/mcfletch/ + + + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 13:12:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 00838D1B445 + for ; + Fri, 5 Dec 2003 17:12:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89407-03 + for ; + Fri, 5 Dec 2003 13:12:09 -0400 (AST) +Received: from web01-imail.rogers.com + (web01-imail.bloor.is.net.cable.rogers.com [66.185.86.75]) + by svr1.postgresql.org (Postfix) with ESMTP id B8D6DD1B454 + for ; + Fri, 5 Dec 2003 13:12:08 -0400 (AST) +Received: from rogers.com ([65.50.20.132]) by web01-imail.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP + id <20031205171225.ZBLS73768.web01-imail.rogers.com@rogers.com> + for ; + Fri, 5 Dec 2003 12:12:25 -0500 +Message-ID: <3FD0BC67.5080300@rogers.com> +Date: Fri, 05 Dec 2003 12:12:07 -0500 +From: "Mike C. Fletcher" +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20030925 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +References: <20031204185751.GA15893@alcaron.ee> + <20031205123843.GA27170@alcaron.ee> + <3FD07EEA.8030007@persistent.co.in> + <200312051323.43966.dev@archonet.com> + <20031205164743.GA30510@alcaron.ee> +In-Reply-To: <20031205164743.GA30510@alcaron.ee> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Authentication-Info: Submitted using SMTP AUTH PLAIN at + web01-imail.rogers.com from [65.50.20.132] using ID + at Fri, 5 Dec 2003 12:12:25 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/130 +X-Sequence-Number: 4990 + +Ivar Zarans wrote: + +>On Fri, Dec 05, 2003 at 01:23:43PM +0000, Richard Huxton wrote: +> +> +>>Better IMHO would be: "UPDATE table1 SET status = %s WHERE recid = %s::int8" +>> +>> +> +>Thanks for the hint! +> +> +Which makes the wrapper class need: + def __str__( self ): + return "%s::int8"%(self.value,) + +Enjoy, +Mike + +_______________________________________ + Mike C. Fletcher + Designer, VR Plumber, Coder + http://members.rogers.com/mcfletch/ + + + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 13:27:20 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2236DD1B43A + for ; + Fri, 5 Dec 2003 17:27:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89434-05 + for ; + Fri, 5 Dec 2003 13:26:43 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id E993ED1B465 + for ; + Fri, 5 Dec 2003 13:26:41 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4027472; Fri, 05 Dec 2003 09:27:31 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Jack Coates , Richard Huxton +Subject: Re: tuning questions +Date: Fri, 5 Dec 2003 09:26:05 -0800 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312042347.54461.dev@archonet.com> + <1070584326.18838.235.camel@cletus.lyris.com> +In-Reply-To: <1070584326.18838.235.camel@cletus.lyris.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200312050926.05155.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/131 +X-Sequence-Number: 4991 + +Jack, + +> The frustrating thing is, we also have a UP P3-500 with 512M RAM and two +> IDE drives with the same PG install which is doing okay with this load +> -- still half the speed of MS-SQL2K, but usable. I'm at a loss. + +Overall, I'm really getting the feeling that this procedure was optimized for +Oracle and/or MSSQL and is hitting some things that aren't such a good idea +for PostgreSQL. I highly suggest that you try using log_duration and +log_statement (and in 7.4 log_min_duration_statement) to try to locate which +particular statements are taking the longest. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Dec 5 13:29:26 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C14D5D1B442 + for ; + Fri, 5 Dec 2003 17:29:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89372-08 + for ; + Fri, 5 Dec 2003 13:28:47 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 802FED1B43A + for ; + Fri, 5 Dec 2003 13:28:46 -0400 (AST) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id B086336FFD; Fri, 5 Dec 2003 12:28:30 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.dyndns.tv ident=foobar) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1ASJkk-0001zl-00; Fri, 05 Dec 2003 12:28:30 -0500 +To: Ivar Zarans +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +References: <20031204185751.GA15893@alcaron.ee> + <20031205014514.GA21079@alcaron.ee> + <20031205020728.GA21440@alcaron.ee> + <200312051008.20317.dev@archonet.com> + <20031205123843.GA27170@alcaron.ee> + <3FD07EEA.8030007@persistent.co.in> + <20031205131325.GB27524@alcaron.ee> +In-Reply-To: <20031205131325.GB27524@alcaron.ee> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 05 Dec 2003 12:28:30 -0500 +Message-ID: <87ad672myp.fsf@stark.dyndns.tv> +Lines: 20 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/132 +X-Sequence-Number: 4992 + +Ivar Zarans writes: + +> > qry = "UPDATE table1 SET status = %s WHERE recid = '%s'" +> > cursor.execute(qry, status, recid) +> +> Yes, this helps. But then it sort of obsoletes PyPgSQL-s own quoting +> logic. I would prefer to take care of this all by myself or trust some +> underlying code to do this for me. And PyPgSQL is quite nice - it +> checks datatype and acts accordingly. + +You should tell the PyPgSQL folk to use the new binary protocol for parameters +so that there are no quoting issues at all. + +But if it's going to interpolate strings into the query then pyPgSQL really +ought to be doing '%s' as above even for numbers. This lets postgres decide +what the optimal datatype is based on what you're comparing it to. Skipping +the quotes will only cause headaches. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 15:29:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A1EBDD1B459 + for ; + Fri, 5 Dec 2003 19:29:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15559-07 + for ; + Fri, 5 Dec 2003 15:28:35 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id D7CACD1B454 + for ; + Fri, 5 Dec 2003 15:28:33 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hB5JSRbI075028 + for ; Fri, 5 Dec 2003 19:28:27 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hB5J6CkP027493 + for pgsql-performance@postgresql.org; Fri, 5 Dec 2003 19:06:12 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Slightly OT -- Xeon versus Opteron Comparison +Date: Fri, 05 Dec 2003 11:06:25 -0800 +Organization: Hub.Org Networking Services +Lines: 11 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/133 +X-Sequence-Number: 4993 + +Ace's Hardware has put together a fairly comprehensive comparison +between Xeon & Opteron platforms running server apps. Unfortunately, +only MySQL "data mining" benchmarks as the review crew doesn't have that +much experience with OLTP-type systems but I'm gonna try to convince +them to add the ODSL DB benchmarks assuming they work fairly well with +Postgres. + +Read up the goodies here: + +http://www.aceshardware.com/read.jsp?id=60000275 + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 17:00:59 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D8D59D1B457 + for ; + Fri, 5 Dec 2003 21:00:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 29329-05 + for ; + Fri, 5 Dec 2003 17:00:28 -0400 (AST) +Received: from jhuml2.jhmi.edu (jhuml2.jhmi.edu [162.129.234.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 57BE2D1B482 + for ; + Fri, 5 Dec 2003 17:00:25 -0400 (AST) +Received: from jhuml2.jhmi.edu (jhuml2.jhmi.edu [162.129.234.21]) + by jhuml2.jhmi.edu (PMDF V6.2-X17 #30840) + with SMTP id <0HPF00EJAWJ081@jhuml2.jhmi.edu> for + pgsql-performance@postgresql.org; Fri, 05 Dec 2003 15:59:59 -0500 (EST) +Received: from jhuml2.jhmi.edu ([162.129.234.21]) + by jhuml2.jhmi.edu (SAVSMTP 3.1.0.29) with SMTP id M2003120515595921657 + for + ; Fri, 05 Dec 2003 15:59:59 -0500 +Received: from jhmimail.jhmi.edu (jhem2.jhmi.edu [162.129.8.23]) + by jhuml2.jhmi.edu (PMDF V6.2-X17 #30840) + with ESMTP id <0HPF00I0WWZZ3O@jhuml2.jhmi.edu> for + pgsql-performance@postgresql.org; Fri, 05 Dec 2003 15:59:59 -0500 (EST) +Received: from [162.129.178.57] by jhmimail.jhmi.edu (mshttpd); Fri, + 05 Dec 2003 13:03:42 -0800 +Date: Fri, 05 Dec 2003 13:03:42 -0800 +From: LIANHE SHAO +Subject: query using cpu nearly 100%, why? +To: pgsql-performance +Message-id: <19be88196606.19660619be88@jhmimail.jhmi.edu> +MIME-version: 1.0 +X-Mailer: iPlanet Messenger Express 5.2 HotFix 1.17 (built Jun 23 2003) +Content-type: text/plain; charset=us-ascii +Content-language: en +Content-transfer-encoding: 7bit +Content-disposition: inline +X-Accept-Language: en +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/134 +X-Sequence-Number: 4994 + +Hello, +I use php as front-end to query our database. When I use System Monitor to check the usage of cpu and memory, I noticed that the cpu very easily gets up to 100%. Is that normal? if not, could someone points out possible reason? + + +I am using linux7.3, pgsql 7.3.4, 1G Memory and 2GHz CPU. + +Regards, +William + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 17:52:25 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B8DFD1B433 + for ; + Fri, 5 Dec 2003 21:52:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 37296-04 + for ; + Fri, 5 Dec 2003 17:51:54 -0400 (AST) +Received: from noao.edu (noao.edu [140.252.1.54]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F52ED1B43A + for ; + Fri, 5 Dec 2003 17:51:52 -0400 (AST) +Received: from weaver.tuc.noao.edu ([140.252.38.8] verified) + by noao.edu (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 9794474; Fri, 05 Dec 2003 14:51:48 -0700 +Received: from weaver.tuc.noao.edu (localhost.localdomain [127.0.0.1]) + by weaver.tuc.noao.edu (8.12.8/8.12.5) with ESMTP id hB5Lpm7Q018261; + Fri, 5 Dec 2003 14:51:48 -0700 +Received: (from swampler@localhost) + by weaver.tuc.noao.edu (8.12.8/8.12.8/Submit) id hB5LpmxV018259; + Fri, 5 Dec 2003 14:51:48 -0700 +X-Authentication-Warning: weaver.tuc.noao.edu: swampler set sender to + swampler@noao.edu using -f +Subject: Help tracking down problem with inserts slowing down... +From: Steve Wampler +Reply-To: swampler@noao.edu +To: Postgres-performance +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: National Solar Observatory +Message-Id: <1070661108.20063.86.camel@weaver.tuc.noao.edu> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Fri, 05 Dec 2003 14:51:48 -0700 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/135 +X-Sequence-Number: 4995 + + +I need some help tracking down a sudden, massive slowdown +in inserts in one of our databases. + +PG: 7.2.3 (RedHat 8.0) + +Background. We currently run nearly identical systems +at two sites: Site A is a 'lab' site used for development, +Site B is a production site. + +The databases in question have identical structure: + + A simple table with 4 columns with a trigger function + on inserts (which checks to see if the entry already + exists, and if so, changes the insert into an update...) + A simple view with 4 columns into the above table. + +All access is through jdbc (JDK 1.3.1, jdbc 7.1-1.3), +postgresql.conf's are identical. + +The two sites were performing at comparable speeds until +a few days ago, when we deleted several million records +from each database and then did a vacuum full; analyze +on both. Now inserts at Site B are several orders of +magnitude slower than at Site A. The odd thing is that +Site B's DB now has only 60,000 records while Site A's is +up around 3 million. Inserts at A average 63ms, inserts +at B are now up at 4.5 seconds! + +EXPLAIN doesn't show any difference between the two. + +Can someone suggest ways to track this down? I don't know +much about postgresql internals/configuration. + +Thanks! +Steve +-- +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +From pgsql-performance-owner@postgresql.org Fri Dec 5 19:39:36 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 79B24D1B496 + for ; + Fri, 5 Dec 2003 23:39:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 46967-09 + for ; + Fri, 5 Dec 2003 19:39:06 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B260D1B480 + for ; + Fri, 5 Dec 2003 19:39:03 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 0BAAF1E36; Fri, 5 Dec 2003 18:38:49 -0500 (EST) +To: swampler@noao.edu +Cc: Postgres-performance +Subject: Re: Help tracking down problem with inserts slowing +From: Neil Conway +In-Reply-To: <1070661108.20063.86.camel@weaver.tuc.noao.edu> (Steve + Wampler's message of "Fri, 05 Dec 2003 14:51:48 -0700") +References: <1070661108.20063.86.camel@weaver.tuc.noao.edu> +Date: Fri, 05 Dec 2003 18:38:47 -0500 +Message-ID: <87fzfy96ns.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/136 +X-Sequence-Number: 4996 + +Steve Wampler writes: +> PG: 7.2.3 (RedHat 8.0) + +You're using PG 7.2.3 with the PG 7.1 JDBC driver; FWIW, upgrading to +newer software is highly recommended. + +> The two sites were performing at comparable speeds until a few days +> ago, when we deleted several million records from each database and +> then did a vacuum full; analyze on both. Now inserts at Site B are +> several orders of magnitude slower than at Site A. + +Two thoughts: + + (1) Can you confirm that the VACUUM FULL on site B actually + removed all the tuples you intended it to remove? Concurrent + transactions can limit the amount of data that VACUUM FULL is + able to reclaim. If you run contrib/pgstattuple (or compare + the database's disk consumption with the number of live rows + in it), you should be able to tell. + + (2) Look at the EXPLAIN for the SELECTs generated by the ON INSERT + trigger -- is there any difference between site A and B? + +-Neil + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 21:23:38 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0EA5ED1B488 + for ; + Sat, 6 Dec 2003 01:23:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 57911-07 + for ; + Fri, 5 Dec 2003 21:23:09 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by svr1.postgresql.org (Postfix) with ESMTP id 65888D1B46D + for ; + Fri, 5 Dec 2003 21:23:05 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by luna.lyris.com (8.12.8/8.12.8) with ESMTP id hB61MiIt030448 + for ; Fri, 5 Dec 2003 17:22:44 -0800 +Received: from luna.lyris.com ([216.91.57.116]) + by luna.lyris.com (MailMonitor for SMTP v1.2.2 ) ; + Fri, 5 Dec 2003 17:22:44 -0800 (PST) +Received: from cletus.lyris.com (cletus.lyris.com [216.91.56.155]) by + luna.lyris.net with SMTP (MailShield v2.04 - LINUX Jul 17 2001 + 16:58:31); Fri, 05 Dec 2003 17:22:44 -0800 +Subject: Re: tuning questions +From: Jack Coates +To: pgsql-performance +In-Reply-To: <200312050926.05155.josh@agliodbs.com> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312042347.54461.dev@archonet.com> + <1070584326.18838.235.camel@cletus.lyris.com> + <200312050926.05155.josh@agliodbs.com> +Content-Type: text/plain +Organization: Lyris Technologies, Inc. +Message-Id: <1070673761.13542.534.camel@cletus.lyris.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.4-9mdk +Date: Fri, 05 Dec 2003 17:22:42 -0800 +Content-Transfer-Encoding: 7bit +X-SMTP-HELO: cletus.lyris.com +X-SMTP-MAIL-FROM: jack@lyris.com +X-SMTP-RCPT-TO: pgsql-performance@postgresql.org +X-SMTP-PEER-INFO: cletus.lyris.com [216.91.56.155] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/137 +X-Sequence-Number: 4997 + +On Fri, 2003-12-05 at 09:26, Josh Berkus wrote: +> Jack, +> +> > The frustrating thing is, we also have a UP P3-500 with 512M RAM and two +> > IDE drives with the same PG install which is doing okay with this load +> > -- still half the speed of MS-SQL2K, but usable. I'm at a loss. +> +> Overall, I'm really getting the feeling that this procedure was optimized for +> Oracle and/or MSSQL and is hitting some things that aren't such a good idea +> for PostgreSQL. I highly suggest that you try using log_duration and +> log_statement (and in 7.4 log_min_duration_statement) to try to locate which +> particular statements are taking the longest. + +I'll definitely buy that as round two of optimization, but round one is +still "it's faster on the slower server." + +hdparm -I is identical between the boxes, filesystem structure layout is +identical, disk organization isn't identical, but far worse: the UP low +ram box has PG on /dev/hdb, ew. Predictably, vmstat shows low numbers... +but steady numbers. + +dev is the box which goes fast, and I was wrong, it's actually a 2GHz +P4. rufus is the box which goes slow. During the big fetch: +dev bi sits around 2000 blocks for twenty seconds while bo is around 50 +blocks, then bo jumps to 800 or so while the data is returned, then +we're done. + +rufus bi starts at 16000 blocks, then drops steadily while bo climbs. +After a minute or so, bi stabilizes at 4096 blocks, then bo bursts to +return the data. Then the next fetch starts, and it's bi of 500, bo of +300 for several minutes. + +These observations certainly all point to Eric and Thierry's +recommendations to better organize the filesystem and get faster disks.. +except that the dev box gets acceptable performance. + +So, I've dug into postgresql.conf on dev and rufus, and here's what I +found: + +RUFUS + + + + + + + + +how much +ram do +you +have? + + + + + + +75% +converted to 8K pages of that for effective_cache + + + +15% of +that or +512M, +whichever is larger, converted to 8K pages for shared_buffers +15% of +that +converted to 8K pages for vacuum_mem + + + +how many +messages +will you +send +between +vacuums? + + + +divide +that by +2 and +divide +by 6 for +max_fsm_pages + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +DEV + + + + + + + + +how much +ram do +you +have? + + + + + + +48% +converted to 8K pages of that for effective_cache + + + +6.5% of +that or +512M, +whichever is larger, converted to 8K pages for shared_buffers +52% of +that +converted to 8K pages for vacuum_mem + + + + +max_fsm_pages untouched on this box. + + + + + + + +I adjusted rufus's configuration to match those percentages, but left +max_fsm_pages dialed up to 500000. Now Rufus's vmstat shows much better +behavior: bi 12000 blocks gradually sloping down to 3000 during the big +select, bo steady until it's ready to return. As more jobs come in, we +see overlap areas where bi is 600-ish and bo is 200-ish, but they only +last a few tens of seconds. + +The big selects are still a lot slower than they are on the smaller +database and overall performance is still unacceptable. Next I dialed +max_fsm_pages back down to 10000 -- no change. Hm, maybe it's been too +long since the last vacuumdb --analyze, let's give it another. + +hdparm -Tt shows that disk performance is crappo on rufus, half what it +is on dev -- and freaking dev is using 16 bit IO! This is a motherboard +IDE controller issue. + +South Bridge: VIA vt8233 +Revision: ISA 0x0 IDE 0x6 + +That's it, I'm throwing out this whole test series and starting over +with different hardware. Database server is now a dual 2GHz Xeon with +2GB RAM & 2940UW SCSI, OS and PG's logs on 36G drive, PG data on 9GB +drive. Data is importing now and I'll restart the tests tonight. +-- +Jack Coates, Lyris Technologies Applications Engineer +510-549-4350 x148, jack@lyris.com +"Interoperability is the keyword, uniformity is a dead end." + --Olivier Fourdan + + + +From pgsql-performance-owner@postgresql.org Fri Dec 5 22:55:25 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EB48D1B445 + for ; + Sat, 6 Dec 2003 02:55:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65049-06 + for ; + Fri, 5 Dec 2003 22:54:54 -0400 (AST) +Received: from lakemtao04.cox.net (lakemtao04.cox.net [68.1.17.241]) + by svr1.postgresql.org (Postfix) with ESMTP id D3F88D1B43E + for ; + Fri, 5 Dec 2003 22:54:49 -0400 (AST) +Received: from [192.168.0.13] ([68.105.167.134]) by lakemtao04.cox.net + (InterMail vM.5.01.06.05 201-253-122-130-105-20030824) with ESMTP + id <20031206025451.PPKC19895.lakemtao04.cox.net@[192.168.0.13]>; + Fri, 5 Dec 2003 21:54:51 -0500 +From: Robert Treat +To: swampler@noao.edu, Postgres-performance +Subject: Re: Help tracking down problem with inserts slowing down... +Date: Fri, 5 Dec 2003 21:54:52 -0500 +User-Agent: KMail/1.5 +References: <1070661108.20063.86.camel@weaver.tuc.noao.edu> +In-Reply-To: <1070661108.20063.86.camel@weaver.tuc.noao.edu> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200312052154.52223.xzilla@users.sourceforge.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/138 +X-Sequence-Number: 4998 + +On Friday 05 December 2003 16:51, Steve Wampler wrote: +> I need some help tracking down a sudden, massive slowdown +> in inserts in one of our databases. +> +> PG: 7.2.3 (RedHat 8.0) +> +> Background. We currently run nearly identical systems +> at two sites: Site A is a 'lab' site used for development, +> Site B is a production site. +> +> The databases in question have identical structure: +> +> A simple table with 4 columns with a trigger function +> on inserts (which checks to see if the entry already +> exists, and if so, changes the insert into an update...) +> A simple view with 4 columns into the above table. +> +> All access is through jdbc (JDK 1.3.1, jdbc 7.1-1.3), +> postgresql.conf's are identical. +> +> The two sites were performing at comparable speeds until +> a few days ago, when we deleted several million records +> from each database and then did a vacuum full; analyze +> on both. Now inserts at Site B are several orders of +> magnitude slower than at Site A. The odd thing is that +> Site B's DB now has only 60,000 records while Site A's is +> up around 3 million. Inserts at A average 63ms, inserts +> at B are now up at 4.5 seconds! +> +> EXPLAIN doesn't show any difference between the two. +> +> Can someone suggest ways to track this down? I don't know +> much about postgresql internals/configuration. +> + +What does explain analyze show for the insert query? + +Are there FK and/or Indexes involved here? Did you you reindex? +A vacuum verbose could give you a good indication if you need to reindex, +compare the # of pages in the index with the # in the table. + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + +From pgsql-performance-owner@postgresql.org Sat Dec 6 09:19:55 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B79AD1B480 + for ; + Sat, 6 Dec 2003 13:19:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31461-07 + for ; + Sat, 6 Dec 2003 09:19:26 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id F403AD1B442 + for ; + Sat, 6 Dec 2003 09:19:21 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hB6DJL916645; + Sat, 6 Dec 2003 08:19:21 -0500 (EST) +From: Bruce Momjian +Message-Id: <200312061319.hB6DJL916645@candle.pha.pa.us> +Subject: Re: Has anyone run on the new G5 yet +In-Reply-To: <1070526289.4666.35.camel@localhost.localdomain> +To: Paul Tuckfield +Date: Sat, 6 Dec 2003 08:19:21 -0500 (EST) +Cc: pgsql-performance@postgresql.org, shannyconsulting@earthlink.net +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/139 +X-Sequence-Number: 4999 + +Paul Tuckfield wrote: +> Biggest problem I've had in the past w. linux in general is that it +> seems to make poor VM choices under heavy filesystem IO. I don't really +> get exactly where it's going wrong , but I've had numerous experiences +> on older systems where bursty IO would seem to cause paging on the box +> (pageout of pieces of the oracle SGA shared memory) which is a +> performance disaseter. It seems to happen even when the shared memory +> was sized reasonably below the size of physical ram, presumably because +> linux is too aggressive in allocating filesystem cache (?) anyway, it +> seems to make decisions based on desire for zippy workstation +> performance and gets burned on thruput on database servers. I'm +> guessing this may be an issue for you , when doing heavy IO. Thing is, +> it'll show like you're IO bound kindof because you're thrashing. + +This is not surprising. There has always been an issue with dynamic +buffer cache systems contending with memory used by processes. It takes +a long time to get the balance right, and still there might be cases +where it gets things wrong. Isn't there a Linux option to lock shared +memory in to RAM? If so, we should document this in our manuals, but +right now, there is no mention of 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 Sat Dec 6 13:09:36 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 153F8D1B436 + for ; + Sat, 6 Dec 2003 17:09:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49392-10 + for ; + Sat, 6 Dec 2003 13:09:03 -0400 (AST) +Received: from mail.facnd.com (unknown [66.173.100.50]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CA1FD1B45A + for ; + Sat, 6 Dec 2003 13:09:03 -0400 (AST) +Received: by mail.facnd.com (Postfix on SuSE Linux 7.3 (i386), + from userid 553) + id A581F1EF2; Sat, 6 Dec 2003 11:09:16 -0600 (CST) +Received: from rob (unknown [192.1.1.100]) + by mail.facnd.com (Postfix on SuSE Linux 7.3 (i386)) with ESMTP id + 738301EDE for ; + Sat, 6 Dec 2003 11:09:09 -0600 (CST) +Reply-To: +From: "Rob Sell" +To: +Subject: Pgbench results +Date: Sat, 6 Dec 2003 11:09:05 -0600 +Organization: Fargo Assembly Company +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.2800.1165 +Thread-Index: AcO8G6dYoeSXmZ47QHWWkdmaMLnjsQ== +Message-Id: <20031206170910.738301EDE@mail.facnd.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=2.2 tagged_above=0.0 required=5.0 + tests=FORGED_MUA_OUTLOOK, MISSING_OUTLOOK_NAME +X-Spam-Level: ** +X-Archive-Number: 200312/140 +X-Sequence-Number: 5000 + +Greetings all, + +I'm wondering is there a website where people can submit their pgbench +results along with their hardware and configuration's? If so where are they +at? I have yet to find any. I think this could be a very useful tool not +only for people looking at setting up a new server but for people trying to +tune their db... + +Thanks +Rob + + +From pgsql-performance-owner@postgresql.org Sat Dec 6 13:47:17 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EAE83D1B46C + for ; + Sat, 6 Dec 2003 17:47:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 52940-04 + for ; + Sat, 6 Dec 2003 13:46:44 -0400 (AST) +Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net + [194.217.242.85]) + by svr1.postgresql.org (Postfix) with ESMTP id 25689D1B445 + for ; + Sat, 6 Dec 2003 13:46:39 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) + id 1ASgVp-0009La-0Z; Sat, 06 Dec 2003 17:46:38 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id B44BC1740C; Sat, 6 Dec 2003 17:46:36 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 239D517333; Sat, 6 Dec 2003 17:46:34 +0000 (GMT) +From: Richard Huxton +To: LIANHE SHAO , + pgsql-performance +Subject: Re: query using cpu nearly 100%, why? +Date: Sat, 6 Dec 2003 17:46:32 +0000 +User-Agent: KMail/1.5 +References: <19be88196606.19660619be88@jhmimail.jhmi.edu> +In-Reply-To: <19be88196606.19660619be88@jhmimail.jhmi.edu> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200312061746.33037.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/141 +X-Sequence-Number: 5001 + +On Friday 05 December 2003 21:03, LIANHE SHAO wrote: +> Hello, +> I use php as front-end to query our database. When I use System Monitor to +> check the usage of cpu and memory, I noticed that the cpu very easily gets +> up to 100%. Is that normal? if not, could someone points out possible +> reason? + +The idea is that CPU should go to 100% when there's work to be done, and drop +off when the system is idle. There's nothing to be gained with having the CPU +at 50% and taking twice as long to perform a task. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Sat Dec 6 15:42:19 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 15685D1B441 + for ; + Sat, 6 Dec 2003 19:42:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 66287-03 + for ; + Sat, 6 Dec 2003 15:41:49 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 24950D1B481 + for ; + Sat, 6 Dec 2003 15:41:47 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 1133C1E12; Sat, 6 Dec 2003 14:41:41 -0500 (EST) +To: LIANHE SHAO +Cc: pgsql-performance +Subject: Re: query using cpu nearly 100%, why? +From: Neil Conway +In-Reply-To: <19be88196606.19660619be88@jhmimail.jhmi.edu> (LIANHE SHAO's + message of "Fri, 05 Dec 2003 13:03:42 -0800") +References: <19be88196606.19660619be88@jhmimail.jhmi.edu> +Date: Sat, 06 Dec 2003 14:41:36 -0500 +Message-ID: <8765gt91jj.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/142 +X-Sequence-Number: 5002 + +LIANHE SHAO writes: +> Hello, I use php as front-end to query our database. When I use +> System Monitor to check the usage of cpu and memory, I noticed that +> the cpu very easily gets up to 100%. Is that normal? if not, could +> someone points out possible reason? + +You haven't given us nearly enough information about the problem to +allow us to provide any meaningful advice. + +-Neil + + +From pgsql-performance-owner@postgresql.org Sat Dec 6 15:54:37 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5EC36D1B442 + for ; + Sat, 6 Dec 2003 19:54:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 68107-04 + for ; + Sat, 6 Dec 2003 15:54:06 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 86D96D1B468 + for ; + Sat, 6 Dec 2003 15:54:04 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 7C0281EBB; Sat, 6 Dec 2003 14:54:04 -0500 (EST) +To: Shridhar Daithankar +Cc: Ivar Zarans , pgsql-performance@postgresql.org +Subject: Re: Slow UPADTE, compared to INSERT +From: Neil Conway +In-Reply-To: <3FD08D6A.4080207@persistent.co.in> (Shridhar Daithankar's + message of "Fri, 05 Dec 2003 19:21:38 +0530") +References: <20031204185751.GA15893@alcaron.ee> + <20031205014514.GA21079@alcaron.ee> <20031205020728.GA21440@alcaron.ee> + <200312051008.20317.dev@archonet.com> + <20031205123843.GA27170@alcaron.ee> + <3FD07EEA.8030007@persistent.co.in> <20031205131325.GB27524@alcaron.ee> + <3FD08D6A.4080207@persistent.co.in> +Date: Sat, 06 Dec 2003 14:54:03 -0500 +Message-ID: <871xrh90ys.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/143 +X-Sequence-Number: 5003 + +Shridhar Daithankar writes: +> This is not a bug. It is just that people find it confusing when +> postgresql planner consider seemingly same type as different. + +It certainly is a bug, or at least a deficiency: PostgreSQL planner +*could* use the index to process the query, but the planner doesn't +consider doing so. The fact that it isn't able to do the necessary +type coercion is the *cause* of the bug, not a defence for this +behavior. + +> AFAIK, the fix in CVS is to make indexes operatable with seemingly +> compatible types. Which does not change the fact that postgresql can +> not upgrade data types on it's own. + +I'm not sure what you mean by that. In any case, I just checked, and +it does seem Tom has fixed this in CVS: + +template1=# create table abc (b int8); +CREATE TABLE +template1=# set enable_seqscan = false; +SET +template1=# create index abc_b_idx on abc (b); +CREATE INDEX +template1=# explain select * from abc where b = 4; + QUERY PLAN +---------------------------------------------------------------------- + Index Scan using abc_b_idx on abc (cost=0.00..17.07 rows=5 width=8) + Index Cond: (b = 4) +(2 rows) + +Cool! + +-Neil + + +From pgsql-performance-owner@postgresql.org Sun Dec 7 10:28:47 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 37CCED1B8C0 + for ; + Sun, 7 Dec 2003 14:28:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 59777-05 + for ; + Sun, 7 Dec 2003 10:28:17 -0400 (AST) +Received: from noao.edu (noao.edu [140.252.1.54]) + by svr1.postgresql.org (Postfix) with ESMTP id 05921D1B518 + for ; + Sun, 7 Dec 2003 10:28:13 -0400 (AST) +Received: from weaver.tuc.noao.edu ([140.252.38.8] verified) + by noao.edu (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 9807948; Sun, 07 Dec 2003 07:28:17 -0700 +Received: from weaver.tuc.noao.edu (localhost.localdomain [127.0.0.1]) + by weaver.tuc.noao.edu (8.12.8/8.12.5) with ESMTP id hB7ESG7Q008423; + Sun, 7 Dec 2003 07:28:16 -0700 +Received: (from swampler@localhost) + by weaver.tuc.noao.edu (8.12.8/8.12.8/Submit) id hB7ESGx1008421; + Sun, 7 Dec 2003 07:28:16 -0700 +Date: Sun, 7 Dec 2003 07:28:16 -0700 +From: Steve Wampler +To: Robert Treat +Cc: swampler@noao.edu, Postgres-performance +Subject: Re: Help tracking down problem with inserts slowing down... +Message-ID: <20031207142816.GA8321@weaver.tuc.noao.edu> +References: <1070661108.20063.86.camel@weaver.tuc.noao.edu> + <200312052154.52223.xzilla@users.sourceforge.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200312052154.52223.xzilla@users.sourceforge.net> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/144 +X-Sequence-Number: 5004 + +On Fri, Dec 05, 2003 at 09:54:52PM -0500, Robert Treat wrote: +> On Friday 05 December 2003 16:51, Steve Wampler wrote: +> > I need some help tracking down a sudden, massive slowdown +> > in inserts in one of our databases. +> > +> > PG: 7.2.3 (RedHat 8.0) +> > +> > Background. We currently run nearly identical systems +> > at two sites: Site A is a 'lab' site used for development, +> > Site B is a production site. +> > +> > The databases in question have identical structure: +> > +> > A simple table with 4 columns with a trigger function +> > on inserts (which checks to see if the entry already +> > exists, and if so, changes the insert into an update...) +> > A simple view with 4 columns into the above table. +> > +> > All access is through jdbc (JDK 1.3.1, jdbc 7.1-1.3), +> > postgresql.conf's are identical. +> > +> > The two sites were performing at comparable speeds until +> > a few days ago, when we deleted several million records +> > from each database and then did a vacuum full; analyze +> > on both. Now inserts at Site B are several orders of +> > magnitude slower than at Site A. The odd thing is that +> > Site B's DB now has only 60,000 records while Site A's is +> > up around 3 million. Inserts at A average 63ms, inserts +> > at B are now up at 4.5 seconds! +> > +> > EXPLAIN doesn't show any difference between the two. +> > +> > Can someone suggest ways to track this down? I don't know +> > much about postgresql internals/configuration. +> > +> +> What does explain analyze show for the insert query? +> +> Are there FK and/or Indexes involved here? Did you you reindex? +> A vacuum verbose could give you a good indication if you need to reindex, +> compare the # of pages in the index with the # in the table. + +Thanks Robert! + +It looks like reindex did the trick. + +Now I have a general question - what are the relationships between: +vacuum, analyze, reindex, and dropping/recreating the indices? +That is, which is the following is 'best' (or is there a different +ordering that is better)?: + +(1) vacuum + analyze + reindex + +(2) vacuum + reindex + analyze + +(3) drop indices + vacuum + create indices + analyze + +(4) drop indices + vacuum + analyze + create indices + +And, is reindex equivalent to dropping, then recreating the indices? + [it appears to be "no", from what I've just seen, but I don't know...] + +Thanks! +Steve +-- +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +From pgsql-performance-owner@postgresql.org Sun Dec 7 10:53:04 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6631DD1B518 + for ; + Sun, 7 Dec 2003 14:53:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 61222-06 + for ; + Sun, 7 Dec 2003 10:52:35 -0400 (AST) +Received: from noao.edu (noao.edu [140.252.1.54]) + by svr1.postgresql.org (Postfix) with ESMTP id 75BF6D1B48F + for ; + Sun, 7 Dec 2003 10:52:31 -0400 (AST) +Received: from weaver.tuc.noao.edu ([140.252.38.8] verified) + by noao.edu (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 9808033; Sun, 07 Dec 2003 07:52:36 -0700 +Received: from weaver.tuc.noao.edu (localhost.localdomain [127.0.0.1]) + by weaver.tuc.noao.edu (8.12.8/8.12.5) with ESMTP id hB7EqZ7Q008814; + Sun, 7 Dec 2003 07:52:35 -0700 +Received: (from swampler@localhost) + by weaver.tuc.noao.edu (8.12.8/8.12.8/Submit) id hB7EqZOc008812; + Sun, 7 Dec 2003 07:52:35 -0700 +Date: Sun, 7 Dec 2003 07:52:35 -0700 +From: Steve Wampler +To: Steve Wampler +Cc: Robert Treat , + Postgres-performance +Subject: Re: Help tracking down problem with inserts slowing down... +Message-ID: <20031207145235.GA8734@weaver.tuc.noao.edu> +References: <1070661108.20063.86.camel@weaver.tuc.noao.edu> + <200312052154.52223.xzilla@users.sourceforge.net> + <20031207142816.GA8321@weaver.tuc.noao.edu> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20031207142816.GA8321@weaver.tuc.noao.edu> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/145 +X-Sequence-Number: 5005 + +On Fri, Dec 05, 2003 at 09:54:52PM -0500, Robert Treat wrote: +>... +> A vacuum verbose could give you a good indication if you need to reindex, +> compare the # of pages in the index with the # in the table. + +Hmmm, I have a feeling that's not as obvious as I thought... I can't +identify the index (named 'id_index') in the output of vacuum verbose. +The closest I can find is: + +NOTICE: --Relation pg_index-- +NOTICE: Pages 2: Changed 0, Empty 0; Tup 56: Vac 0, Keep 0, UnUsed 42. + Total CPU 0.00s/0.00u sec elapsed 0.00 sec. + +Which probably isn't correct, right (the name doesn't seem to match)? + +The table's entry is: + +NOTICE: --Relation attributes_table-- +NOTICE: Pages 639: Changed 0, Empty 0; Tup 52846: Vac 0, Keep 0, UnUsed 48. + Total CPU 0.00s/0.01u sec elapsed 0.01 sec. + +Thanks! +Steve +-- +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +From pgsql-performance-owner@postgresql.org Sun Dec 7 12:54:22 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 398F3D1B49F + for ; + Sun, 7 Dec 2003 16:54:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 68515-07 + for ; + Sun, 7 Dec 2003 12:53:49 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 2BBD4D1B4D1 + for ; + Sun, 7 Dec 2003 12:53:48 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hB7Gqb19022389; + Sun, 7 Dec 2003 11:52:37 -0500 (EST) +To: Steve Wampler +Cc: Robert Treat , + Postgres-performance +Subject: Re: Help tracking down problem with inserts slowing down... +In-reply-to: <20031207145235.GA8734@weaver.tuc.noao.edu> +References: <1070661108.20063.86.camel@weaver.tuc.noao.edu> + <200312052154.52223.xzilla@users.sourceforge.net> + <20031207142816.GA8321@weaver.tuc.noao.edu> + <20031207145235.GA8734@weaver.tuc.noao.edu> +Comments: In-reply-to Steve Wampler + message dated "Sun, 07 Dec 2003 07:52:35 -0700" +Date: Sun, 07 Dec 2003 11:52:37 -0500 +Message-ID: <22388.1070815957@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/146 +X-Sequence-Number: 5006 + +Steve Wampler writes: +> Hmmm, I have a feeling that's not as obvious as I thought... I can't +> identify the index (named 'id_index') in the output of vacuum verbose. + +In 7.2, the index reports look like + Index %s: Pages %u; Tuples %.0f. +and should appear in the part of the printout that deals with their +owning table. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Dec 7 13:29:27 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B694D1B4B9 + for ; + Sun, 7 Dec 2003 17:29:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70674-08 + for ; + Sun, 7 Dec 2003 13:28:51 -0400 (AST) +Received: from noao.edu (noao.edu [140.252.1.54]) + by svr1.postgresql.org (Postfix) with ESMTP id D8D1CD1B8C3 + for ; + Sun, 7 Dec 2003 13:28:50 -0400 (AST) +Received: from weaver.tuc.noao.edu ([140.252.38.8] verified) + by noao.edu (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 9808796; Sun, 07 Dec 2003 10:28:50 -0700 +Received: from weaver.tuc.noao.edu (localhost.localdomain [127.0.0.1]) + by weaver.tuc.noao.edu (8.12.8/8.12.5) with ESMTP id hB7HSo7Q011516; + Sun, 7 Dec 2003 10:28:50 -0700 +Received: (from swampler@localhost) + by weaver.tuc.noao.edu (8.12.8/8.12.8/Submit) id hB7HSoow011514; + Sun, 7 Dec 2003 10:28:50 -0700 +X-Authentication-Warning: weaver.tuc.noao.edu: swampler set sender to + swampler@noao.edu using -f +Subject: Re: Help tracking down problem with inserts slowing +From: Steve Wampler +Reply-To: swampler@noao.edu +To: Neil Conway +Cc: Postgres-performance +In-Reply-To: <87fzfy96ns.fsf@mailbox.samurai.com> +References: <1070661108.20063.86.camel@weaver.tuc.noao.edu> + <87fzfy96ns.fsf@mailbox.samurai.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: National Solar Observatory +Message-Id: <1070818130.20063.145.camel@weaver.tuc.noao.edu> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Sun, 07 Dec 2003 10:28:50 -0700 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/147 +X-Sequence-Number: 5007 + +On Fri, 2003-12-05 at 16:38, Neil Conway wrote: + +> +> (1) Can you confirm that the VACUUM FULL on site B actually +> removed all the tuples you intended it to remove? Concurrent +> transactions can limit the amount of data that VACUUM FULL is +> able to reclaim. If you run contrib/pgstattuple (or compare +> the database's disk consumption with the number of live rows +> in it), you should be able to tell. + +Hmmm, I installed 7.2.3 from RPMs, but the contrib package seems +to be missing the pgstattuple library code. (According to the +readme, I should do: + + $ make + $ make install + $ psql -e -f /usr/local/pgsql/share/contrib/pgstattuple.sql test + +but the first two lines don't make sense with the binary rpm +distribution and trying the last line as (for my world): + + ->psql -e -f /usr/share/pgsql/contrib/pgstattuple.sql +farm.devel.configdb + +yields: + + DROP FUNCTION pgstattuple(NAME); + psql:/usr/share/pgsql/contrib/pgstattuple.sql:1: ERROR: +RemoveFunction: function 'pgstattuple(name)' does not exist + CREATE FUNCTION pgstattuple(NAME) RETURNS FLOAT8 + AS '$libdir/pgstattuple', 'pgstattuple' + LANGUAGE 'c' WITH (isstrict); + psql:/usr/share/pgsql/contrib/pgstattuple.sql:4: ERROR: stat failed +on file '$libdir/pgstattuple': No such file or directory + +I don't need this right now (a reindex seems to have fixed +our problem for now...), but it sounds like it would be useful +in the future. + +Thanks! +Steve +-- +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +From pgsql-performance-owner@postgresql.org Sun Dec 7 17:16:44 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 28EEAD1B464 + for ; + Sun, 7 Dec 2003 21:16:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 00464-03 + for ; + Sun, 7 Dec 2003 17:16:13 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 8395FD1B4A1 + for ; + Sun, 7 Dec 2003 17:16:10 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hB7LGBG27161; + Sun, 7 Dec 2003 16:16:11 -0500 (EST) +From: Bruce Momjian +Message-Id: <200312072116.hB7LGBG27161@candle.pha.pa.us> +Subject: Re: autovacuum daemon stops doing work after about an +In-Reply-To: <16335.43272.273411.653445@yertle.int.kciLink.com> +To: Vivek Khera +Date: Sun, 7 Dec 2003 16:16:11 -0500 (EST) +Cc: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/148 +X-Sequence-Number: 5008 + + +This has been fixed and will be in 7.4.1. + +--------------------------------------------------------------------------- + +Vivek Khera wrote: +> >>>>> "LR" == Larry Rosenman writes: +> +> >> I'd be curious to see the output of this program on other platforms +> >> and other compilers. I'm using gcc 2.95.4 as shipped with FreeBSD +> >> 4.8+. +> LR> this is with the UnixWare compiler: +> LR> $ cc -O -o testvk testvk.c +> LR> $ ./testvk +> LR> seconds = 3509 +> LR> seconds1 = 3509000000 +> LR> useconds = -452486 +> LR> stepped diff = 3508547514 +> LR> seconds2 = -785967296 +> LR> seconds3 = 3509000000 +> LR> diff = -786419782 +> LR> long long diff = 3508547514 +> LR> $ +> +> LR> I think this is a C bug. +> +> Upon further reflection, I think so to. The entire RHS is long's so +> the arithmetic is done in longs, then assigned to a long long when +> done (after things have overflowed). Forcing any one of the RHS +> values to be long long causes the arithmetic to all be done using long +> longs, and then you get the numbers you expect. +> +> I think you only notice this in autovacuum when it takes a long time +> to complete the work, like my example of about 3500 seconds. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Sun Dec 7 20:47:32 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 43765D1B436 + for ; + Mon, 8 Dec 2003 00:47:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17543-09 + for ; + Sun, 7 Dec 2003 20:47:00 -0400 (AST) +Received: from pns.mm.eutelsat.org (pns.mm.eutelsat.org [194.214.173.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 78E3DD1B46F + for ; + Sun, 7 Dec 2003 20:46:56 -0400 (AST) +Received: from nts-03.mm.eutelsat.org (localhost [127.0.0.1]) + by pns.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id hB80oCs01675 + for ; Mon, 8 Dec 2003 01:50:12 +0100 +Received: from bigfoot.com (accesspoint.mm.eutelsat.org [194.214.173.4]) + by nts-03.mm.eutelsat.org (8.11.6/linuxconf) with ESMTP id hB80ZRR16821 + for ; Mon, 8 Dec 2003 01:35:27 +0100 +Message-ID: <3FD3C9DA.5040805@bigfoot.com> +Date: Mon, 08 Dec 2003 01:46:18 +0100 +From: Gaetano Mendola +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031206 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Subject: Re: autovacuum daemon stops doing work after about an hour +References: <16332.63508.196365.801418@yertle.int.kciLink.com> + <1070516326.1455.11.camel@zedora.zeut.net> + <16335.25079.106697.7521@yertle.int.kciLink.com> + <3FCF7E74.9060604@bigfoot.com> +In-Reply-To: <3FCF7E74.9060604@bigfoot.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/149 +X-Sequence-Number: 5009 + +Gaetano Mendola wrote: +> Vivek Khera wrote: +> +>>>>>>> "MTO" == Matthew T O'Connor writes: +>> +>> +>> +>>>> Then it just sits there. I started it at 11:35am, and it is now +>>>> 3:30pm. +>> +>> +>> +>> MTO> Weird.... Alphabetically speaking, is vkmlm."public"."user_list" +>> be the +>> MTO> last table in the last schema in the last database? You are running +>> +>> conveniently, yes it is... +>> +>> MTO> with -d4, so you would get a message about going to sleep shortly +>> after +>> MTO> dealing with the last table, but you didn't get the sleep +>> message, so I +>> MTO> don't think the problem is that pg_autovacuum is sleeping for an +>> MTO> inordinate amount time. +>> +>> The only sleep logged was +>> +>> [2003-12-03 04:47:13 PM] 1 All DBs checked in: 84996853 usec, will +>> sleep for 469 secs. +> +> +> What I seen is: +> +> +> # tail -f auto.log +> [2003-12-04 07:10:18 PM] reltuples: 72; relpages: 1 +> [2003-12-04 07:10:18 PM] curr_analyze_count: 72; cur_delete_count: 0 +> [2003-12-04 07:10:18 PM] ins_at_last_analyze: 72; del_at_last_vacuum: 0 +> [2003-12-04 07:10:18 PM] insert_threshold: 572; delete_threshold 536 +> [2003-12-04 07:10:18 PM] table name: empdb."public"."contracts" +> [2003-12-04 07:10:18 PM] relfilenode: 17784; relisshared: 0 +> [2003-12-04 07:10:18 PM] reltuples: 347; relpages: 5 +> [2003-12-04 07:10:18 PM] curr_analyze_count: 347; cur_delete_count: 0 +> [2003-12-04 07:10:18 PM] ins_at_last_analyze: 347; del_at_last_vacuum: 0 +> [2003-12-04 07:10:18 PM] insert_threshold: 847; delete_threshold 673 +> +> +> [ 5 minutes of delay ] <----- LOOK THIS +> +> +> [2003-12-04 07:10:18 PM] 503 All DBs checked in: 179396 usec, will sleep +> for 300 secs. +> [2003-12-04 07:15:19 PM] 504 All DBs checked in: 98814 usec, will sleep +> for 300 secs. +> +> I think is a good Idea put a fflush after: +> +> fprintf(LOGOUTPUT, "[%s] %s\n", timebuffer, logentry); + +Was I wrong ? If you are watching in tail the log believeme is really +annoying. + +Regards +Gaetano Mendola + + + + + + + + + +From pgsql-performance-owner@postgresql.org Sun Dec 7 21:29:30 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 77DDCD1C951 + for ; + Mon, 8 Dec 2003 01:29:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 22383-10 + for ; + Sun, 7 Dec 2003 21:29:03 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id E7B63D1B48B + for ; + Sun, 7 Dec 2003 21:28:59 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hB81SxbI091483 + for ; Mon, 8 Dec 2003 01:28:59 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hB81JZKN090568 + for pgsql-performance@postgresql.org; Mon, 8 Dec 2003 01:19:35 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: autovacuum daemon stops doing work after about an hour +Date: Sun, 07 Dec 2003 20:17:33 -0500 +Organization: cbbrowne Computing Inc +Lines: 15 +Message-ID: +References: <16332.63508.196365.801418@yertle.int.kciLink.com> + <1070516326.1455.11.camel@zedora.zeut.net> + <16335.25079.106697.7521@yertle.int.kciLink.com> + <3FCF7E74.9060604@bigfoot.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:ooK8UmYiF4cDsjXv4BcRCfE2D7g= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/150 +X-Sequence-Number: 5010 + +The world rejoiced as mendola@bigfoot.com (Gaetano Mendola) wrote: +> I think is a good Idea put a fflush after: +> +> fprintf(LOGOUTPUT, "[%s] %s\n", timebuffer, logentry); + +I thought I had put fflush()es at all the interesting locations... + +Apparently it was an error to not go to the effort of making sure it +worked well on FreeBSD. (It was on my list, but I never got the Round +Tuits...) There's an AMD-64 box coming in soon, targeted at FreeBSD, +so that should change... +-- +let name="cbbrowne" and tld="acm.org" in name ^ "@" ^ tld;; +http://www3.sympatico.ca/cbbrowne/linux.html +What would a chair look like, if your knees bent the other way? + +From pgsql-performance-owner@postgresql.org Mon Dec 8 01:28:03 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 40957D1B469 + for ; + Mon, 8 Dec 2003 05:28:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51692-10 + for ; + Mon, 8 Dec 2003 01:27:31 -0400 (AST) +Received: from mta2.srv.hcvlny.cv.net (mta2.srv.hcvlny.cv.net [167.206.5.68]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F6D4D1B436 + for ; + Mon, 8 Dec 2003 01:27:30 -0400 (AST) +Received: from zeut.net (ool-4352919e.dyn.optonline.net [67.82.145.158]) + by mta2.srv.hcvlny.cv.net + (iPlanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) + with ESMTP id <0HPK00I889TOJ8@mta2.srv.hcvlny.cv.net> for + pgsql-performance@postgresql.org; Mon, 08 Dec 2003 00:27:25 -0500 (EST) +Date: Mon, 08 Dec 2003 00:27:29 -0500 +From: "Matthew T. O'Connor" +Subject: Re: autovacuum daemon stops doing work after about an hour +In-reply-to: +To: Christopher Browne +Cc: pgsql-performance@postgresql.org +Message-id: <3FD40BC1.7050906@zeut.net> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 + Thunderbird/0.4 +References: <16332.63508.196365.801418@yertle.int.kciLink.com> + <1070516326.1455.11.camel@zedora.zeut.net> + <16335.25079.106697.7521@yertle.int.kciLink.com> + <3FCF7E74.9060604@bigfoot.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/151 +X-Sequence-Number: 5011 + +Christopher Browne wrote: + +>The world rejoiced as mendola@bigfoot.com (Gaetano Mendola) wrote: +> +> +>>I think is a good Idea put a fflush after: +>> +>>fprintf(LOGOUTPUT, "[%s] %s\n", timebuffer, logentry); +>> +>> +> +>I thought I had put fflush()es at all the interesting locations... +> +> + +I just looked through the code, I think there are fflush()es at all but +one interesting locations. The last log_entry call before sleeping +doesn't have an fflush call after it. I'll submit a patch that adds it. + +>Apparently it was an error to not go to the effort of making sure it +>worked well on FreeBSD. (It was on my list, but I never got the Round +>Tuits...) There's an AMD-64 box coming in soon, targeted at FreeBSD, +>so that should change... +> +> +Yeah, FreeBSD testing would have been nice, but I don't have access to +any FreeBSD boxes so..... + + +From pgsql-performance-owner@postgresql.org Tue Dec 9 16:00:17 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 02C09D1B445 + for ; + Mon, 8 Dec 2003 14:04:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 26196-04 + for ; + Mon, 8 Dec 2003 10:04:19 -0400 (AST) +Received: from smtp02do.de.uu.net (smtp02do.de.uu.net [192.76.144.69]) + by svr1.postgresql.org (Postfix) with ESMTP id D29F0D1B4B1 + for ; + Mon, 8 Dec 2003 10:04:14 -0400 (AST) +Received: from bommel.kecam-han.de ([193.99.158.1]) + by smtp02do.de.uu.net (8.9.3p2/5.5.5) with ESMTP id PAA22793 + for ; + Mon, 8 Dec 2003 15:04:17 +0100 (MET) +Received: from mailrelay.kecam-han.de (ldap [10.9.1.54]) + by bommel.kecam-han.de (8.11.6+Sun/8.9.1) with ESMTP id hB8E4c609689 + for ; + Mon, 8 Dec 2003 15:04:38 +0100 (MET) +Received: from ke-elektronik.de (localhost [127.0.0.1]) + by mailrelay.kecam-han.de (8.12.2/8.12.2) with ESMTP id hB8E3ZUr019106 + for ; + Mon, 8 Dec 2003 15:03:55 +0100 (MET) +Message-ID: <3FD484B6.EF39A92F@ke-elektronik.de> +Date: Mon, 08 Dec 2003 15:03:34 +0100 +From: Hartmut Raschick +Organization: ke Kommunikations-Elektronik GmbH +X-Mailer: Mozilla 4.79 [en] (X11; U; SunOS 5.6 sun4u) +X-Accept-Language: de, ru, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: TRUNCATE veeeery slow compared to DELETE in 7.4 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/162 +X-Sequence-Number: 5022 + +has anyone else noticed a huge difference in "DELETE TABLE " +vs. "TRUNCATE " starting w/postgres 7.4? +putting aside details (num rows, indexes....): ca. 300 tables +(already empty if desired...) ALL to be emptied (via batch file). +here's a small "time pgsql -f kill_all" output: + +DELETE: +1) 0.03u 0.04s 0:02.46 2.8% (already empty) +2) 0.05u 0.06s 0:01.19 9.2% (already empty) + +TRUNCATE: +1) 0.10u 0.06s 6:58.66 0.0% (already empty, compile runnig simult.) +2) 0.10u 0.02s 2:51.71 0.0% (already empty) + +lovely, innit? + +settings in 7.4 (wal, shm...) are as for 7.3.x unless dead or (in their +7.4 default version) even higher. + +glimpsing at the quantify output (of the truncate version) it looks +as if this is "for (i = 0; i < all; i++)" whereas (from exec. time) +delete does "\rm -rf" + +is this a pay-off for autocommit gone away? +a conspiracy? +...what am i saying... + +we are using TRUNCATE btw, because someone once noted that this was +"good style", saying: "yes, i want to empty the whole thing", not: +"oops! forgot the where-clause, sorry for your table!" + +well, enlight me, please! + +P.S.: Grammarians dispute - and the case is still before the courts. + - Horace, Epistles (Ars Poetica) + +-- +Hartmut "Hardy" Raschick / Dept. t2 +ke Kommunikations-Elektronik GmbH +Wohlenberstr. 3, 30179 Hannover +Phone: ++49 (0)511 6747-564 +Fax: ++49 (0)511 6747-340 +e-Mail: hartmut.raschick@ke-elektronik.de +http://www.ke-elektronik.de + +From pgsql-performance-owner@postgresql.org Mon Dec 8 11:15:32 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E3166D1B4BA + for ; + Mon, 8 Dec 2003 15:15:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31612-10 + for ; + Mon, 8 Dec 2003 11:15:02 -0400 (AST) +Received: from noao.edu (noao.edu [140.252.1.54]) + by svr1.postgresql.org (Postfix) with ESMTP id A752AD1B449 + for ; + Mon, 8 Dec 2003 11:14:54 -0400 (AST) +Received: from weaver.tuc.noao.edu ([140.252.38.8] verified) + by noao.edu (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 9815943; Mon, 08 Dec 2003 08:14:53 -0700 +Received: from weaver.tuc.noao.edu (localhost.localdomain [127.0.0.1]) + by weaver.tuc.noao.edu (8.12.8/8.12.5) with ESMTP id hB8FEr7Q001182; + Mon, 8 Dec 2003 08:14:53 -0700 +Received: (from swampler@localhost) + by weaver.tuc.noao.edu (8.12.8/8.12.8/Submit) id hB8FErhP001180; + Mon, 8 Dec 2003 08:14:53 -0700 +X-Authentication-Warning: weaver.tuc.noao.edu: swampler set sender to + swampler@noao.edu using -f +Subject: Re: Help tracking down problem with inserts slowing +From: Steve Wampler +Reply-To: swampler@noao.edu +To: Tom Lane +Cc: Robert Treat , + Postgres-performance +In-Reply-To: <22388.1070815957@sss.pgh.pa.us> +References: <1070661108.20063.86.camel@weaver.tuc.noao.edu> + <200312052154.52223.xzilla@users.sourceforge.net> + <20031207142816.GA8321@weaver.tuc.noao.edu> + <20031207145235.GA8734@weaver.tuc.noao.edu> + <22388.1070815957@sss.pgh.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: National Solar Observatory +Message-Id: <1070896493.20063.159.camel@weaver.tuc.noao.edu> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Mon, 08 Dec 2003 08:14:53 -0700 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/152 +X-Sequence-Number: 5012 + +On Sun, 2003-12-07 at 09:52, Tom Lane wrote: +> Steve Wampler writes: +> > Hmmm, I have a feeling that's not as obvious as I thought... I can't +> > identify the index (named 'id_index') in the output of vacuum verbose. +> +> In 7.2, the index reports look like +> Index %s: Pages %u; Tuples %.0f. +> and should appear in the part of the printout that deals with their +> owning table. + +Thanks, Tom. Are there any reasons why it would not appear?: +------------------------------------------------------------- +farm.devel.configdb=# vacuum verbose attributes_table; +NOTICE: --Relation attributes_table-- +NOTICE: Pages 1389: Changed 0, Empty 0; Tup 111358: Vac 0, Keep 0, +UnUsed 51. + Total CPU 0.00s/0.02u sec elapsed 0.03 sec. +NOTICE: --Relation pg_toast_1743942-- +NOTICE: Pages 0: Changed 0, Empty 0; Tup 0: Vac 0, Keep 0, UnUsed 0. + Total CPU 0.00s/0.00u sec elapsed 0.00 sec. +VACUUM + +farm.devel.configdb=# \d attributes_table + Table "attributes_table" + Column | Type | Modifiers +--------+--------------------------+--------------- + id | character varying(64) | not null + name | character varying(64) | not null + units | character varying(32) | + value | text | + time | timestamp with time zone | default now() +Indexes: id_index +Primary key: attributes_table_pkey +Triggers: trigger_insert +--------------------------------------------------------------- + +The odd thing is that I could have sworn it appeared yesterday... + +-- +Steve Wampler -- swampler@noao.edu +The gods that smiled on your birth are now laughing out loud. + +From pgsql-performance-owner@postgresql.org Mon Dec 8 11:36:18 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 79985D1B4BA + for ; + Mon, 8 Dec 2003 15:36:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 35649-09 + for ; + Mon, 8 Dec 2003 11:35:50 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E177D1B481 + for ; + Mon, 8 Dec 2003 11:35:46 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hB8FZn19009619; + Mon, 8 Dec 2003 10:35:50 -0500 (EST) +To: swampler@noao.edu +Cc: Robert Treat , + Postgres-performance +Subject: Re: Help tracking down problem with inserts slowing +In-reply-to: <1070896493.20063.159.camel@weaver.tuc.noao.edu> +References: <1070661108.20063.86.camel@weaver.tuc.noao.edu> + <200312052154.52223.xzilla@users.sourceforge.net> + <20031207142816.GA8321@weaver.tuc.noao.edu> + <20031207145235.GA8734@weaver.tuc.noao.edu> + <22388.1070815957@sss.pgh.pa.us> + <1070896493.20063.159.camel@weaver.tuc.noao.edu> +Comments: In-reply-to Steve Wampler + message dated "Mon, 08 Dec 2003 08:14:53 -0700" +Date: Mon, 08 Dec 2003 10:35:49 -0500 +Message-ID: <9618.1070897749@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/153 +X-Sequence-Number: 5013 + +Steve Wampler writes: +> Thanks, Tom. Are there any reasons why it would not appear?: + +Oh, I shoulda read the code more carefully. I was looking at the bottom +of lazy_scan_index, where the printout is done, and failed to notice the +test at the top: + + /* + * If the index is not partial, skip the scan, and just assume it has + * the same number of tuples as the heap. + */ + +So for ordinary indexes, nothing will appear unless vacuum has actual +work to do (that is, it recycled at least one dead tuple in the table). + +Short answer: update or delete some row in the table, and then try +vacuum verbose. + +Alternatively, you can just look at the pg_class row for the index. +relpages and reltuples will contain the info you are after ... and +they are certainly up to date at this point ;-) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Dec 8 13:44:29 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D58F8D1B46F + for ; + Mon, 8 Dec 2003 17:44:27 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65976-05 + for ; + Mon, 8 Dec 2003 13:43:56 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D613D1B491 + for ; + Mon, 8 Dec 2003 13:43:54 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by luna.lyris.com (8.12.8/8.12.8) with ESMTP id hB8HhlIt007581 + for ; Mon, 8 Dec 2003 09:43:47 -0800 +Received: from luna.lyris.com ([216.91.57.116]) + by luna.lyris.com (MailMonitor for SMTP v1.2.2 ) ; + Mon, 8 Dec 2003 09:43:47 -0800 (PST) +Received: from cletus.lyris.com (cletus.lyris.com [216.91.56.155]) by + luna.lyris.net with SMTP (MailShield v2.04 - LINUX Jul 17 2001 + 16:58:31); Mon, 08 Dec 2003 09:43:47 -0800 +Subject: Re: tuning questions +From: Jack Coates +To: pgsql-performance +In-Reply-To: <1070673761.13542.534.camel@cletus.lyris.com> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312042347.54461.dev@archonet.com> + <1070584326.18838.235.camel@cletus.lyris.com> + <200312050926.05155.josh@agliodbs.com> + <1070673761.13542.534.camel@cletus.lyris.com> +Content-Type: text/plain +Organization: Lyris Technologies, Inc. +Message-Id: <1070905424.16088.63.camel@cletus.lyris.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.4-9mdk +Date: Mon, 08 Dec 2003 09:43:45 -0800 +Content-Transfer-Encoding: 7bit +X-SMTP-HELO: cletus.lyris.com +X-SMTP-MAIL-FROM: jack@lyris.com +X-SMTP-RCPT-TO: pgsql-performance@postgresql.org +X-SMTP-PEER-INFO: cletus.lyris.com [216.91.56.155] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/154 +X-Sequence-Number: 5014 + +On Fri, 2003-12-05 at 17:22, Jack Coates wrote: +... +> That's it, I'm throwing out this whole test series and starting over +> with different hardware. Database server is now a dual 2GHz Xeon with +> 2GB RAM & 2940UW SCSI, OS and PG's logs on 36G drive, PG data on 9GB +> drive. Data is importing now and I'll restart the tests tonight. + +Sorry to reply at myself, but thought I'd note that the performance is +practically unchanged by moving to better hardware and separating logs +and data onto different spindles. Although the disks are twice as fast +by hdparm -Tt, their behavior as shown by iostat and vmstat is little +different between dual and dev (single P4-2GHz/512MB/(2)IDE drives). +Dual is moderately faster than my first, IDE-based testbed (about 8%), +but still only 30% as fast as the low-powered dev. + +I've been running vacuumdb --analyze and/or vaccuumdb --full between +each config change, and I also let the job run all weekend. Saturday it +got --analyze every three hours or so, Sunday it got --analyze once in +the morning. None of these vacuumdb's are making any difference. + +Theories at this point, in no particular order: + +a) major differences between my 7.3.4 from source (compiled with no +options) and dev's 7.3.2-1PGDG RPMs. Looking at the spec file doesn't +reveal anything glaring to me, but is there something I'm missing? + +b) major differences between my kernel 2.4.18-14smp (RH8) and dev's +kernel 2.4.18-3 (RH7.3). + +c) phase of the moon. + +While SQL optimization is likely to improve performance across the +board, it doesn't explain the differences between these two systems and +I'd like to avoid it as a theory until the fast box can perform as well +as the slow box. + +Any ideas? Thanks in advance, +-- +Jack Coates, Lyris Technologies Applications Engineer +510-549-4350 x148, jack@lyris.com +"Interoperability is the keyword, uniformity is a dead end." + --Olivier Fourdan + + + +From pgsql-performance-owner@postgresql.org Mon Dec 8 14:41:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4EB45D1BA62 + for ; + Mon, 8 Dec 2003 18:41:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 74864-07 + for ; + Mon, 8 Dec 2003 14:41:15 -0400 (AST) +Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F7E4D1B4C1 + for ; + Mon, 8 Dec 2003 14:41:14 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id 6B2C53E55 + for ; + Mon, 8 Dec 2003 13:41:14 -0500 (EST) +Received: from lorax.kcilink.com ([127.0.0.1]) + by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 97237-03 for ; + Mon, 8 Dec 2003 13:41:13 -0500 (EST) +Received: from lorax.kciLink.com (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id A5E463E28 + for ; + Mon, 8 Dec 2003 13:41:13 -0500 (EST) +Received: (from news@localhost) + by lorax.kciLink.com (8.12.9p2/8.12.9/Submit) id hB8IfDT7082051 + for pgsql-performance@postgresql.org; + Mon, 8 Dec 2003 13:41:13 -0500 (EST) (envelope-from news) +To: pgsql-performance@postgresql.org +Path: not-for-mail +From: Vivek Khera +Newsgroups: ml.postgres.performance +Subject: Re: autovacuum daemon stops doing work after about an hour +Date: Mon, 08 Dec 2003 13:41:12 -0500 +Organization: Khera Communications, Inc., Rockville, MD +Lines: 20 +Message-ID: +References: <16332.63508.196365.801418@yertle.int.kciLink.com> + <1070516326.1455.11.camel@zedora.zeut.net> + <16335.25079.106697.7521@yertle.int.kciLink.com> + <3FCF7E74.9060604@bigfoot.com> + <3FD40BC1.7050906@zeut.net> +NNTP-Posting-Host: yertle.kcilink.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Trace: lorax.kcilink.com 1070908873 32027 216.194.193.105 (8 Dec 2003 + 18:41:13 GMT) +X-Complaints-To: daemon@kciLink.com +NNTP-Posting-Date: Mon, 8 Dec 2003 18:41:13 +0000 (UTC) +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + berkeley-unix) +Cancel-Lock: sha1:OM58FMOrWScQove6ySmsaM8yG9c= +X-Virus-Scanned: by amavisd-new at kciLink.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/155 +X-Sequence-Number: 5015 + +>>>>> "MTO" == Matthew T O'Connor writes: + +MTO> Yeah, FreeBSD testing would have been nice, but I don't have access to +MTO> any FreeBSD boxes so..... + +FWIW, with the fflush() added after that sleep, and the fix to the +long long computation of sleep time to keep it from overflowing, +pg_autovacuum has been working flawlessly on my FreeBSD 4.9 + PG 7.4.0 +production server. I'm just still playing with tuning pg_autovacuum +to keep it from vacuuming my busy tables *too* often. + +Just a question: will my test program show negative sleep 'diff' on +your linux box? I can't imagine that it would give different results +than on freebsd. + +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +Vivek Khera, Ph.D. Khera Communications, Inc. +Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 +AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/ + +From pgsql-performance-owner@postgresql.org Mon Dec 8 15:21:38 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 53D80D1B45A + for ; + Mon, 8 Dec 2003 19:21:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 77846-05 + for ; + Mon, 8 Dec 2003 15:21:10 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 5BCDDD1B448 + for ; + Mon, 8 Dec 2003 15:21:09 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hB8JJw19022186; + Mon, 8 Dec 2003 14:19:59 -0500 (EST) +To: Jack Coates +Cc: pgsql-performance +Subject: Re: tuning questions +In-reply-to: <1070905424.16088.63.camel@cletus.lyris.com> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312042347.54461.dev@archonet.com> + <1070584326.18838.235.camel@cletus.lyris.com> + <200312050926.05155.josh@agliodbs.com> + <1070673761.13542.534.camel@cletus.lyris.com> + <1070905424.16088.63.camel@cletus.lyris.com> +Comments: In-reply-to Jack Coates + message dated "Mon, 08 Dec 2003 09:43:45 -0800" +Date: Mon, 08 Dec 2003 14:19:58 -0500 +Message-ID: <22185.1070911198@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/156 +X-Sequence-Number: 5016 + +Jack Coates writes: +> Theories at this point, in no particular order: + +> a) major differences between my 7.3.4 from source (compiled with no +> options) and dev's 7.3.2-1PGDG RPMs. Looking at the spec file doesn't +> reveal anything glaring to me, but is there something I'm missing? + +There are quite a few performance-related patches between 7.3.2 and +7.3.4. Most of them should be in 7.3.4's favor but there are some +places where we had to take a performance hit in order to have a +suitably low-risk fix for a bug. You haven't told us enough about +the problem to know if any of those cases apply, though. AFAIR +you have not actually showed either the slow query or EXPLAIN ANALYZE +results for it on the two boxes ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Dec 9 04:32:58 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CA514D1B454 + for ; + Tue, 9 Dec 2003 08:32:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 83357-10 + for ; + Tue, 9 Dec 2003 04:32:26 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id BA86BD1B438 + for ; + Tue, 9 Dec 2003 04:32:24 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 10DDD1F93; Tue, 9 Dec 2003 03:32:25 -0500 (EST) +To: stephen farrell +Cc: pgsql-performance@postgresql.org +Subject: Re: Problem with insert into select... +From: Neil Conway +In-Reply-To: <3FBD72D5.1040202@almaden.ibm.com> (stephen farrell's message + of "Thu, 20 Nov 2003 18:05:09 -0800") +References: <3FBD2D8B.8020509@almaden.ibm.com> <7439.1069369120@sss.pgh.pa.us> + <3FBD72D5.1040202@almaden.ibm.com> +Date: Tue, 09 Dec 2003 03:32:24 -0500 +Message-ID: <87smjuqtlz.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/157 +X-Sequence-Number: 5017 + +stephen farrell writes: +> With the indexes created it worked. It took about 4 hours, but it +> inserted all of the records. + +Has this been satisfactorily resolved? + +If not, can you post an EXPLAIN ANALYZE for the failing query, as Tom +asked earlier? + +-Neil + + +From pgsql-performance-owner@postgresql.org Tue Dec 9 12:58:49 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 86080D1B46E + for ; + Tue, 9 Dec 2003 16:58:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70646-03 + for ; + Tue, 9 Dec 2003 12:58:13 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by svr1.postgresql.org (Postfix) with ESMTP id 1F065D1B4AE + for ; + Tue, 9 Dec 2003 12:58:12 -0400 (AST) +Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) + by luna.lyris.com (8.12.8/8.12.8) with ESMTP id hB9GvtIt032473; + Tue, 9 Dec 2003 08:57:55 -0800 +Received: from luna.lyris.com ([216.91.57.116]) + by luna.lyris.com (MailMonitor for SMTP v1.2.2 ) ; + Tue, 9 Dec 2003 08:57:55 -0800 (PST) +Received: from cletus.lyris.com (cletus.lyris.com [216.91.56.155]) by + luna.lyris.net with SMTP (MailShield v2.04 - LINUX Jul 17 2001 + 16:58:31); Tue, 09 Dec 2003 08:57:55 -0800 +Subject: Re: tuning questions +From: Jack Coates +To: Tom Lane +Cc: pgsql-performance +In-Reply-To: <22185.1070911198@sss.pgh.pa.us> +References: <1070553983.6498.52.camel@cletus.lyris.com> + <200312042347.54461.dev@archonet.com> + <1070584326.18838.235.camel@cletus.lyris.com> + <200312050926.05155.josh@agliodbs.com> + <1070673761.13542.534.camel@cletus.lyris.com> + <1070905424.16088.63.camel@cletus.lyris.com> + <22185.1070911198@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Lyris Technologies, Inc. +Message-Id: <1070989072.16079.19.camel@cletus.lyris.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.4-9mdk +Date: Tue, 09 Dec 2003 08:57:53 -0800 +Content-Transfer-Encoding: 7bit +X-SMTP-HELO: cletus.lyris.com +X-SMTP-MAIL-FROM: jack@lyris.com +X-SMTP-RCPT-TO: tgl@sss.pgh.pa.us,pgsql-performance@postgresql.org +X-SMTP-PEER-INFO: cletus.lyris.com [216.91.56.155] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/158 +X-Sequence-Number: 5018 + +On Mon, 2003-12-08 at 11:19, Tom Lane wrote: +> Jack Coates writes: +> > Theories at this point, in no particular order: +> +> > a) major differences between my 7.3.4 from source (compiled with no +> > options) and dev's 7.3.2-1PGDG RPMs. Looking at the spec file doesn't +> > reveal anything glaring to me, but is there something I'm missing? +> +> There are quite a few performance-related patches between 7.3.2 and +> 7.3.4. Most of them should be in 7.3.4's favor but there are some +> places where we had to take a performance hit in order to have a +> suitably low-risk fix for a bug. You haven't told us enough about +> the problem to know if any of those cases apply, though. AFAIR +> you have not actually showed either the slow query or EXPLAIN ANALYZE +> results for it on the two boxes ... +> +> regards, tom lane + +Right, because re-architecture of a cross-platform query makes sense if +performance is bad on all systems, but is questionable activity when +performance is fine on some systems and lousy on others. Hence my +statement that while SQL optimization is certainly something we want to +do for across-the-board performance increase, I wanted to focus on other +issues for troubleshooting this problem. I will be back to ask about +data access models later :-) + +I ended up going back to a default postgresql.conf and reapplying the +various tunings one-by-one. Turns out that while setting fsync = false +had little effect on the slow IDE box, it had a drastic effect on this +faster SCSI box and performance is quite acceptable now (aside from the +expected falloff of about 30% after the first twenty minutes, which I +believe comes from growing and shrinking tables without vacuumdb +--analyzing). + +-- +Jack Coates, Lyris Technologies Applications Engineer +510-549-4350 x148, jack@lyris.com +"Interoperability is the keyword, uniformity is a dead end." + --Olivier Fourdan + + + +From pgsql-performance-owner@postgresql.org Tue Dec 9 13:08:47 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C7D2D1B454 + for ; + Tue, 9 Dec 2003 17:08:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69676-06 + for ; + Tue, 9 Dec 2003 13:08:11 -0400 (AST) +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 7D0D3D1B47D + for ; + Tue, 9 Dec 2003 13:08:10 -0400 (AST) +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 006C896DE6; Tue, 9 Dec 2003 17:07:54 +0000 (GMT) +From: "Matt Clark" +To: "Jack Coates" , "Tom Lane" +Cc: "pgsql-performance" +Subject: Re: tuning questions +Date: Tue, 9 Dec 2003 17:07:53 -0000 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +In-Reply-To: <1070989072.16079.19.camel@cletus.lyris.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/159 +X-Sequence-Number: 5019 + +> I ended up going back to a default postgresql.conf and reapplying the +> various tunings one-by-one. Turns out that while setting fsync = false +> had little effect on the slow IDE box, it had a drastic effect on this +> faster SCSI box and performance is quite acceptable now (aside from the +> expected falloff of about 30% after the first twenty minutes, which I +> believe comes from growing and shrinking tables without vacuumdb +> --analyzing). + +Hmm. I wonder if that could be related to the issue where many IDE drives have write-caching enabled. With the write cache enabled +fsyncs are nearly immediate, so setting fsync=false makes little difference... + + + + + +From pgsql-performance-owner@postgresql.org Tue Dec 9 13:36:48 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 46DDDD1B48E + for ; + Tue, 9 Dec 2003 17:36:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75503-09 + for ; + Tue, 9 Dec 2003 13:36:13 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 46C4ED1B487 + for ; + Tue, 9 Dec 2003 13:36:12 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4049825; Tue, 09 Dec 2003 09:37:02 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Jack Coates , Tom Lane +Subject: Re: tuning questions +Date: Tue, 9 Dec 2003 09:35:04 -0800 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance +References: <1070553983.6498.52.camel@cletus.lyris.com> + <22185.1070911198@sss.pgh.pa.us> + <1070989072.16079.19.camel@cletus.lyris.com> +In-Reply-To: <1070989072.16079.19.camel@cletus.lyris.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200312090935.04658.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/160 +X-Sequence-Number: 5020 + +Jack, + +> Right, because re-architecture of a cross-platform query makes sense if +> performance is bad on all systems, but is questionable activity when +> performance is fine on some systems and lousy on others. Hence my +> statement that while SQL optimization is certainly something we want to +> do for across-the-board performance increase, I wanted to focus on other +> issues for troubleshooting this problem. I will be back to ask about +> data access models later :-) + +Yes, but an EXPLAIN ANALYZE will also help show issues like sorts running out +of memory, etc. Really, we don't currently have enough information to do +more than speculate; it's like trying to repair a car engine wearing a +blindfold. + +Particularly since it's possible that there are only 1 or 2 "bad queries" +which are messing everything else up. + +For that matter, it would really help to know: +-- How many simulatneous connections are running update queries during this +process? +-- How about some sample VACUUM VERBOSE results for the intra-process vacuums? + +> I ended up going back to a default postgresql.conf and reapplying the +> various tunings one-by-one. Turns out that while setting fsync = false +> had little effect on the slow IDE box, it had a drastic effect on this +> faster SCSI box and performance is quite acceptable now (aside from the +> expected falloff of about 30% after the first twenty minutes, which I +> believe comes from growing and shrinking tables without vacuumdb +> --analyzing). + +Well, that brings 2 things immediately to mind: +1) That may improve performance, but it does mean that if your machine loses +power you *will* be restoring from backup. It's risky to do. + +2) Your IDE system has write-caching enabled. Once again, this is a nice +performmance boost, if you don't mind database corruption in a power-out. + + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Dec 16 17:07:50 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E9048D1B48F + for ; + Tue, 9 Dec 2003 21:21:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 23084-03 + for ; + Tue, 9 Dec 2003 17:21:23 -0400 (AST) +Received: from www.smart-start-hosting.com (unknown [38.118.153.169]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CE43D1B461 + for ; + Tue, 9 Dec 2003 17:21:20 -0400 (AST) +Received: from shadovitz (localhost [127.0.0.1]) + by localhost (8.10.2/8.10.2) with ESMTP id hB9LEim13571; + Tue, 9 Dec 2003 13:14:44 -0800 +From: "David Shadovitz" +To: pgsql-performance@postgresql.org +Cc: david@shadovitz.com +Subject: Why is VACUUM ANALYZE so slow? +Date: Tue, 9 Dec 2003 14:14:44 -0700 +Message-Id: <20031209211444.M99946@www.shadovitz.com> +X-Mailer: Open WebMail 1.81 20021203 +X-OriginatingIP: 206.135.121.30 (david@shadovitz) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/232 +X-Sequence-Number: 5092 + +I'm running PG 7.2.2 on RH Linux 8.0. + +I'd like to know why "VACUUM ANALYZE
" is extemely slow (hours) for +certain tables. Here's what the log file shows when I run this command on +my "employees" table, which has just 5 columns and 55 records: + +VACUUM ANALYZE employees + +DEBUG: --Relation employees-- +DEBUG: index employees_pkey: Pages 2; Tuples 55: Deleted 0. + CPU 0.00s/0.00u sec elapsed 0.00 sec. +DEBUG: index emp_dept_id_idx: Pages 2; Tuples 55: Deleted 0. + CPU 0.00s/0.00u sec elapsed 0.00 sec. +DEBUG: index emp_emp_num_idx: Pages 2; Tuples 55: Deleted 0. + CPU 0.00s/0.00u sec elapsed 0.00 sec. +DEBUG: recycled transaction log file 00000000000000CC +DEBUG: geqo_main: using edge recombination crossover [ERX] + +(When I get a chance I will enable timestamping of log file entries.) + +Thanks for any insight. Please reply to me personally (david@shadovitz.com) +as well as to the list. + +-David + +From pgsql-performance-owner@postgresql.org Tue Dec 9 19:21:07 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C724CD1B481 + for ; + Tue, 9 Dec 2003 23:21:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38678-08 + for ; + Tue, 9 Dec 2003 19:20:37 -0400 (AST) +Received: from jhuml1.jhmi.edu (jhuml1.jhmi.edu [162.129.234.20]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A890D1B45A + for ; + Tue, 9 Dec 2003 19:20:34 -0400 (AST) +Received: from jhuml1.jhmi.edu (jhuml1.jhmi.edu [162.129.234.20]) + by jhuml1.jhmi.edu (PMDF V6.2-X17 #30839) + with SMTP id <0HPN00G0UHZ4HW@jhuml1.jhmi.edu> for + pgsql-performance@postgresql.org; Tue, 09 Dec 2003 18:20:20 -0500 (EST) +Received: from jhuml1.jhmi.edu ([162.129.234.20]) + by jhuml1.jhmi.edu (SAVSMTP 3.1.0.29) with SMTP id M2003120918202007799 + for + ; Tue, 09 Dec 2003 18:20:20 -0500 +Received: from jhmimail.jhmi.edu (jhem2.jhmi.edu [162.129.8.23]) + by jhuml1.jhmi.edu (PMDF V6.2-X17 #30839) + with ESMTP id <0HPN00HGBI5W7F@jhuml1.jhmi.edu> for + pgsql-performance@postgresql.org; Tue, 09 Dec 2003 18:20:20 -0500 (EST) +Received: from [162.129.178.60] by jhmimail.jhmi.edu (mshttpd); Tue, + 09 Dec 2003 23:24:19 +0000 (GMT) +Date: Tue, 09 Dec 2003 23:24:19 +0000 (GMT) +From: LIANHE SHAO +Subject: Index problem or function problem? +To: pgsql-performance +Message-id: <4595eb458230.4582304595eb@jhmimail.jhmi.edu> +MIME-version: 1.0 +X-Mailer: iPlanet Messenger Express 5.2 HotFix 1.17 (built Jun 23 2003) +Content-type: text/plain; charset=us-ascii +Content-language: en +Content-transfer-encoding: 7bit +Content-disposition: inline +X-Accept-Language: en +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/165 +X-Sequence-Number: 5025 + +Hello, +Today I met a very strange query problem, which I +spend several hours on it but have no clue. To make +thing clear, let me write somewhat in detail. + +I have two almost exactly same queries, except that +one is: lower(annotation) = lower (chip), another +is: annotation = chip. While the first one can get +result in less 10 seconds, the second one will hange +for more that 5 minutes. What a big differents !! + +I checked the indexes, there are both index for +lower() and without lower(). I even droped these +indexes and recreated them, then use vacuum analyze, +reindex, but thing does not change. the query plan +give quite different paths. + +Could somebody give any clues where difference comes +from? Thanks a lot. + +The first query, which get results in less than 10 +seconds + + PGA=> explain select ei.expid, er.geneid, +er.sampleid, ei.annotation, si.samplename, +ei.title as exp_name, aaa.chip, +aaa.sequence_derived_from as accession_number, +aaa.gene_symbol, aaa.title as gene_function, +er.exprs, er.mas5exprs from expressiondata er, +experimentinfo ei, sampleinfo si, +affy_array_annotation aaa where exists (select +distinct ei.expid from experimentinfo) and +lower(ei.annotation) = lower (aaa.chip) and (lower +(aaa.title) like '%mif%' or +lower(aaa.sequence_description) like '%mif%') and +exists (select distinct ei.annotation from +experimentinfo) and ei.expid = er.expid and er.expid += si.expid and er.sampleid = si.sampleid and +er.geneid = aaa.probeset_id order by si.sampleid +limit 20; + + QUERY PLAN + +------------------------------------------------------------------------------------------------------------------------------------- +------------------- + Limit (cost=24289.05..24289.10 rows=19 width=256) + -> Sort (cost=24289.05..24289.10 rows=19 width=256) + Sort Key: si.sampleid + -> Hash Join (cost=6.11..24288.64 rows=19 +width=256) + Hash Cond: ("outer".expid = +"inner".expid) + Join Filter: ("outer".sampleid = +"inner".sampleid) + -> Nested Loop (cost=0.00..24278.66 +rows=27 width=217) + Join Filter: ("outer".expid = +"inner".expid) + -> Nested Loop +(cost=0.00..18378.77 rows=45 width=180) + -> Seq Scan on +experimentinfo ei (cost=0.00..374.50 rows=5 width=99) + Filter: ((subplan) +AND (subplan)) + SubPlan + -> Unique +(cost=8.67..8.78 rows=2 width=0) + -> Sort +(cost=8.67..8.72 rows=21 width=0) + Sort +Key: $0 + -> +Seq Scan on experimentinfo (cost=0.00..8.21 rows=21 +width=0) + -> Unique +(cost=8.67..8.78 rows=2 width=0) + -> Sort +(cost=8.67..8.72 rows=21 width=0) + Sort +Key: $1 + -> +Seq Scan on experimentinfo (cost=0.00..8.21 rows=21 +width=0) + -> Index Scan using +affy_array_annotation_lower_chip_idx on +affy_array_annotation aaa (cost=0.00..3429.2 +4 rows=9 width=81) + Index Cond: +(lower(("outer".annotation)::text) = +lower((aaa.chip)::text)) + Filter: +((lower(title) ~~ '%mif%'::text) OR +(lower(sequence_description) ~~ '%mif%'::text)) + -> Index Scan using +expressiondata_geneid_idx on expressiondata er +(cost=0.00..130.96 rows=34 width=37) + Index Cond: (er.geneid = +"outer".probeset_id) + -> Hash (cost=4.55..4.55 rows=155 +width=39) + -> Seq Scan on sampleinfo si +(cost=0.00..4.55 rows=155 width=39) +(27 rows) + +===================== +The second query, which hangs. + + +PGA=> explain select ei.expid, er.geneid, +er.sampleid, ei.annotation, si.samplename, +ei.title as exp_name, aaa.chip, +aaa.sequence_derived_from as accession_number, +aaa.gene_symbol, aaa.title as gene_function, +er.exprs, er.mas5exprs from expressiondata er, +experimentinfo ei, sampleinfo si, +affy_array_annotation aaa where exists (select +distinct ei.expid from experimentinfo) and +ei.annotation = aaa.chip and (lower (aaa.title) +like '%mif%' or lower(aaa.sequence_description) like +'%mif%') and exists (select distinct ei.annotation +from experimentinfo) and ei.expid = er.expid and +er.expid = si.expid and er.sampleid = si.sampleid +and er.geneid = aaa.probeset_id order by si.sampleid +limit 20; + + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=157127.91..157128.38 rows=20 width=256) + -> Merge Join (cost=157127.91..157137.33 +rows=401 width=256) + Merge Cond: (("outer".sampleid = +"inner".sampleid) AND ("outer".expid = "inner".expid)) + -> Sort (cost=157117.73..157119.11 +rows=553 width=217) + Sort Key: er.sampleid, er.expid + -> Merge Join +(cost=154417.78..157092.52 rows=553 width=217) + Merge Cond: +(("outer".annotation = "inner".chip) AND +("outer".geneid = "inner".probeset_id)) + -> Sort +(cost=96501.38..97830.62 rows=531694 width=136) + Sort Key: ei.annotation, +er.geneid + -> Nested Loop +(cost=0.00..20188.81 rows=531694 width=136) + -> Seq Scan on +experimentinfo ei (cost=0.00..374.50 rows=5 width=99) + Filter: +((subplan) AND (subplan)) + SubPlan + -> Unique + (cost=8.67..8.78 rows=2 width=0) + -> +Sort (cost=8.67..8.72 rows=21 width=0) + + Sort Key: $0 + + -> Seq Scan on experimentinfo (cost=0.00..8.21 +rows=21 width=0) + -> Unique + (cost=8.67..8.78 rows=2 width=0) + -> +Sort (cost=8.67..8.72 rows=21 width=0) + + Sort Key: $1 + + -> Seq Scan on experimentinfo (cost=0.00..8.21 +rows=21 width=0) + -> Index Scan +using expressiondata_expid_idx on expressiondata er + (cost=0.00..2508.21 rows=101275 width=37) + Index Cond: +("outer".expid = er.expid) + -> Sort +(cost=57916.40..57920.67 rows=1710 width=81) + Sort Key: aaa.chip, +aaa.probeset_id + -> Seq Scan on +affy_array_annotation aaa (cost=0.00..57824.60 +rows=1710 width=81) + Filter: +((lower(title) ~~ '%mif%'::text) OR +(lower(sequence_description) ~~ '%mif%'::text)) + -> Sort (cost=10.19..10.58 rows=155 width=39) + Sort Key: si.sampleid, si.expid + -> Seq Scan on sampleinfo si +(cost=0.00..4.55 rows=155 width=39) +(30 rows) + +================= +The related tables: + + Table "public.experimentinfo" + Column | Type | Modifiers +---------------+------------------------+----------- + expid | integer | + name | character varying(128) | + lab | character varying(128) | + contact | character varying(128) | + title | character varying(128) | + abstract | text | + nsamples | integer | + disease_type | character varying(32) | + annotation | character varying(32) | +Indexes: experimetininfo_annotation_idx btree +(annotation), + experimetininfo_lower_annotation_idx btree +(lower(annotation)), + expinfo btree (expid) + + + Table "public.affy_array_annotation" + Column | Type + | Modifiers +-----------------------------------+------------------------+----------- + chip | character +varying(32) | not null + organism | character +varying(24) | + annotation_date | character +varying(24) | + sequence_type | character +varying(24) | + sequence_source | character +varying(32) | + sequence_derived_from | character +varying(32) | + sequence_description | text + | + sequence_id | text + | + transcript_id | character +varying(32) | + group_id | character +varying(64) | + title | text + | + gene_symbol | character +varying(64) | + +Indexes: affy_array_annotation_chip_idx btree (chip), + affy_array_annotation_idx_gene_symbol btree +(gene_symbol), + affy_array_annotation_idx_locuslink btree +(locuslink), + affy_array_annotation_idx_omim btree (omim), + affy_array_annotation_idx_pfam btree (pfam), + +affy_array_annotation_idx_sequence_derived_from +btree (sequence_derived_from), + +affy_array_annotation_idx_sequence_description btree +(sequence_description), + + affy_array_annotation_idx_title btree (title), + + affy_array_annotation_lower_chip_idx btree +(lower(chip)), + affy_array_annotation_lower_gene_symbol_idx +btree (lower(gene_symbol)), + + affy_array_annotation_lower_probeset_id_idx +btree (lower(probeset_id)), + +affy_array_annotation_lower_sequence_description_idx +btree (lower(sequence_description)), + affy_array_annotation_lower_title_idx btree +(lower(title)), + + affy_array_annotation_pkey btree +(probeset_id, chip), + affy_array_annotation_probeset_id_idx btree +(probeset_id), + + + + + + +Regards, +William + + +From pgsql-performance-owner@postgresql.org Wed Dec 10 01:56:48 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 471FED1B494 + for ; + Wed, 10 Dec 2003 05:56:47 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 87267-08 + for ; + Wed, 10 Dec 2003 01:56:16 -0400 (AST) +Received: from linda-1.paradise.net.nz (bm-1a.paradise.net.nz [202.0.58.20]) + by svr1.postgresql.org (Postfix) with ESMTP id C2A78D1B4AE + for ; + Wed, 10 Dec 2003 01:56:14 -0400 (AST) +Received: from smtp-3.paradise.net.nz (smtp-3a.paradise.net.nz [202.0.32.196]) + by linda-1.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0HPO00BD80HQSW@linda-1.paradise.net.nz> for + pgsql-performance@postgresql.org; Wed, 10 Dec 2003 18:56:14 +1300 (NZDT) +Received: from paradise.net.nz + (203-79-100-38.adsl.paradise.net.nz [203.79.100.38]) by + smtp-3.paradise.net.nz (Postfix) with ESMTP id 05519ADF50 for + ; + Wed, 10 Dec 2003 18:56:14 +1300 (NZDT) +Date: Wed, 10 Dec 2003 18:56:38 +1300 +From: Mark Kirkwood +Subject: Solaris Performance (Again) +To: pgsql-performance@postgresql.org +Message-id: <3FD6B596.8090803@paradise.net.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.4) Gecko/20031008 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/166 +X-Sequence-Number: 5026 + +This is a well-worn thread title - apologies, but these results seemed +interesting, and hopefully useful in the quest to get better performance +on Solaris: + +I was curious to see if the rather uninspiring pgbench performance +obtained from a Sun 280R (see General: ATA Disks and RAID controllers +for database servers) could be improved if more time was spent +tuning. + +With the help of a fellow workmate who is a bit of a Solaris guy, we +decided to have a go. + +The major performance killer appeared to be mounting the filesystem with +the logging option. The next most significant seemed to be the choice of +sync_method for Pg - the default (open_datasync), which we initially +thought should be the best - appears noticeably slower than fdatasync. + +We also tried changing some of the tuneable filesystem options using +tunefs - without any measurable effect. + +Are Pg/Solaris folks running with logging on and sync_method default out +there ? - or have most of you been through this already ? + + +Pgbench Results (no. clients and transactions/s ) : + +Setup 1: filesystem mounted with logging + +No. tps +----------- +1 17 +2 17 +4 22 +8 22 +16 28 +32 32 +64 37 + +Setup 2: filesystem mounted without logging + +No. tps +----------- +1 48 +2 55 +4 57 +8 62 +16 65 +32 82 +64 95 + +Setup 3 : filesystem mounted without logging, Pg sync_method = fdatasync + +No. tps +----------- +1 89 +2 94 +4 95 +8 93 +16 99 +32 115 +64 122 + +Note : The Pgbench runs were conducted using -s 10 and -t 1000 -c 1->64, +2 - 3 runs of each setup were performed (averaged figures shown). + +Mark + + +From pgsql-performance-owner@postgresql.org Wed Dec 10 09:54:24 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 17654D1B4C4 + for ; + Wed, 10 Dec 2003 13:54:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 50470-02 + for ; + Wed, 10 Dec 2003 09:53:53 -0400 (AST) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id 73D61D1B4CC + for ; + Wed, 10 Dec 2003 09:53:49 -0400 (AST) +Received: (qmail 42480 invoked from network); 10 Dec 2003 13:53:47 -0000 +Received: from localhost (HELO squeegit) (threshar@127.0.0.1) + by localhost with SMTP; 10 Dec 2003 13:53:47 -0000 +Date: Wed, 10 Dec 2003 08:53:23 -0500 +From: Jeff +To: Mark Kirkwood +Cc: pgsql-performance@postgresql.org +Subject: Re: Solaris Performance (Again) +Message-Id: <20031210085323.749a549f.threshar@torgo.978.org> +In-Reply-To: <3FD6B596.8090803@paradise.net.nz> +References: <3FD6B596.8090803@paradise.net.nz> +X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i686-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/167 +X-Sequence-Number: 5027 + +On Wed, 10 Dec 2003 18:56:38 +1300 +Mark Kirkwood wrote: + +> The major performance killer appeared to be mounting the filesystem +> with the logging option. The next most significant seemed to be the +> choice of sync_method for Pg - the default (open_datasync), which we +> initially thought should be the best - appears noticeably slower than +> fdatasync. +> + +Some interesting stuff, I'll have to play with it. Currently I'm pleased +with my solaris performance. + +What version of PG? + +If it is before 7.4 PG compiles with _NO_ optimization by default and +was a huge part of the slowness of PG on solaris. + + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + +From pgsql-performance-owner@postgresql.org Wed Dec 10 13:20:07 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D016D1B4AC + for ; + Wed, 10 Dec 2003 17:20:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84869-05 + for ; + Wed, 10 Dec 2003 13:19:34 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 22996D1B456 + for ; + Wed, 10 Dec 2003 13:19:33 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4054923; Wed, 10 Dec 2003 09:20:09 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Hartmut Raschick , + pgsql-performance@postgresql.org +Subject: Re: TRUNCATE veeeery slow compared to DELETE in 7.4 +Date: Wed, 10 Dec 2003 09:18:02 -0800 +User-Agent: KMail/1.4.3 +References: <3FD484B6.EF39A92F@ke-elektronik.de> +In-Reply-To: <3FD484B6.EF39A92F@ke-elektronik.de> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200312100918.02501.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/168 +X-Sequence-Number: 5028 + +Hartmut, + +> DELETE: +> 1) 0.03u 0.04s 0:02.46 2.8% (already empty) +> 2) 0.05u 0.06s 0:01.19 9.2% (already empty) +> +> TRUNCATE: +> 1) 0.10u 0.06s 6:58.66 0.0% (already empty, compile runnig simult.) +> 2) 0.10u 0.02s 2:51.71 0.0% (already empty) + +How about some times for a full table? + +Incidentally, I believe that TRUNCATE has always been slightly slower than +DROP TABLE. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Wed Dec 10 15:16:25 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C881DD1B469 + for ; + Wed, 10 Dec 2003 19:16:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 00769-09 + for ; + Wed, 10 Dec 2003 15:15:54 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id D5CBCD1B4AD + for ; + Wed, 10 Dec 2003 15:15:52 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 9D3471E15; Wed, 10 Dec 2003 14:15:36 -0500 (EST) +To: Mark Kirkwood +Cc: pgsql-performance@postgresql.org +Subject: Re: Solaris Performance (Again) +From: Neil Conway +In-Reply-To: <3FD6B596.8090803@paradise.net.nz> (Mark Kirkwood's message of + "Wed, 10 Dec 2003 18:56:38 +1300") +References: <3FD6B596.8090803@paradise.net.nz> +Date: Wed, 10 Dec 2003 14:15:35 -0500 +Message-ID: <87smjs4h7s.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/169 +X-Sequence-Number: 5029 + +Mark Kirkwood writes: +> Note : The Pgbench runs were conducted using -s 10 and -t 1000 -c +> 1->64, 2 - 3 runs of each setup were performed (averaged figures +> shown). + +FYI, the pgbench docs state: + + NOTE: scaling factor should be at least as large as the largest + number of clients you intend to test; else you'll mostly be + measuring update contention. + +-Neil + + +From pgsql-performance-owner@postgresql.org Wed Dec 10 15:30:43 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A7277D1B4AC + for ; + Wed, 10 Dec 2003 19:30:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08440-01 + for ; + Wed, 10 Dec 2003 15:30:12 -0400 (AST) +Received: from honorio.sinectis.com.ar (honorio.sinectis.com.ar + [216.244.192.201]) + by svr1.postgresql.org (Postfix) with ESMTP id 8780DD1B45E + for ; + Wed, 10 Dec 2003 15:30:09 -0400 (AST) +Received: by honorio.sinectis.com.ar (Postfix, from userid 99) + id BF23C6C8A6; Wed, 10 Dec 2003 16:29:58 -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.4.4 +From: nbarraza@uolsinectis.com.ar +To: pgsql-performance@postgresql.org +Cc: nbarraza@boldt.com.ar +Reply-To: nbarraza@uolsinectis.com.ar +Message-Id: <20031210192958.BF23C6C8A6@honorio.sinectis.com.ar> +Date: Wed, 10 Dec 2003 16:29:58 -0300 (GMT+3) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/170 +X-Sequence-Number: 5030 + +I have some problems on performance using postgresql v. 7.3.2 running on Linux RedHat 9. An update involving several rows (about 500000) on a table having 2800000 tuples takes in the order of 6 minutes. It is more than it takes on other plataforms (SqlServer, FOX). I think that there�s something wrong on my configuration. I�ve already adjusted some parameters as I could understand memory and disk usage. Next, I send a description of parameters changed in postgresql.conf, a scheme of the table, and an EXPLAIN ANALYZE of the command. The hardware configuration is a Pentium III 1 Ghz, 512 MB of memory, and an SCSI drive of 20 GB. Following goes the description: + +-- Values changed in postgresql.conf + +tcpip_socket = true +max_connections = 64 +shared_buffers = 4096 +wal_buffers = 100 +vacuum_mem = 16384 +vacuum_mem = 16384 +sort_mem = 32168 +checkpoint_segments = 8 +effective_cache_size = 10000 + + +-- +-- PostgreSQL database dump +-- + +\connect - nestor + +SET search_path = public, pg_catalog; + +-- +-- TOC entry 2 (OID 22661417) +-- Name: jugadas; Type: TABLE; Schema: public; Owner: nestor +-- + +CREATE TABLE jugadas ( + fecha_ju character(8), + hora_ju character(4), + juego character(2), + juego_vta character(2), + sorteo_p character(5), + sorteo_v character(5), + nro_servidor character(1), + ticket character(9), + terminal character(4), + sistema character(1), + agente character(5), + subagente character(3), + operador character(2), + importe character(7), + anulada character(1), + icode character(15), + codseg character(15), + tipo_moneda character(1), + apuesta character(100), + extraido character(1) +); + + +-- +-- TOC entry 4 (OID 25553754) +-- Name: key_jug_1; Type: INDEX; Schema: public; Owner: nestor +-- + +CREATE UNIQUE INDEX key_jug_1 ON jugadas USING btree (juego, juego_vta, sorteo_p, nro_servidor, ticket); + +boss=# explain analyze update jugadas set extraido = 'S' where juego = '03' and +juego_vta = '03' and sorteo_p = '89353' and extraido = 'N'; + QUERY PLAN + +--------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on jugadas (cost=0.00..174624.96 rows=70061 width=272) (actual time=21223.88..51858.07 rows=517829 loops=1) + Filter: ((juego = '03'::bpchar) AND (juego_vta = '03'::bpchar) AND (sorteo_p += '89353'::bpchar) AND (extraido = 'N'::bpchar)) + Total runtime: 291167.36 msec +(3 rows) + +boss=# show enable_seqscan; + enable_seqscan +---------------- + on +(1 row) + + +************* FORCING INDEX SCAN *********************************** + +boss=# set enable_seqscan = false; +SET + +boss=# explain analyze update jugadas set extraido = 'N' where juego = '03' and +juego_vta = '03' and sorteo_p = '89353' and extraido = 'S'; + QUERY PLAN + +------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using key_jug_1 on jugadas (cost=0.00..597959.76 rows=98085 width=272) (actual time=9.93..39947.93 rows=517829 loops=1) + Index Cond: ((juego = '03'::bpchar) AND (juego_vta = '03'::bpchar) AND (sorteo_p = '89353'::bpchar)) + Filter: (extraido = 'S'::bpchar) + Total runtime: 335280.56 msec +(4 rows) + +boss=# + +Thank you in advance for any help. + +Nestor + + +From pgsql-performance-owner@postgresql.org Wed Dec 10 15:55:02 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 104A5D1B449 + for ; + Wed, 10 Dec 2003 19:55:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11628-03 + for ; + Wed, 10 Dec 2003 15:54:30 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B03DD1B4D4 + for ; + Wed, 10 Dec 2003 15:54:29 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBAJsE19008001; + Wed, 10 Dec 2003 14:54:14 -0500 (EST) +To: Josh Berkus +Cc: Hartmut Raschick , + pgsql-performance@postgresql.org +Subject: Re: TRUNCATE veeeery slow compared to DELETE in 7.4 +In-reply-to: <200312100918.02501.josh@agliodbs.com> +References: <3FD484B6.EF39A92F@ke-elektronik.de> + <200312100918.02501.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Wed, 10 Dec 2003 09:18:02 -0800" +Date: Wed, 10 Dec 2003 14:54:14 -0500 +Message-ID: <8000.1071086054@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/171 +X-Sequence-Number: 5031 + +Josh Berkus writes: +> Incidentally, I believe that TRUNCATE has always been slightly slower than +> DROP TABLE. + +Well, it would be: it has to delete the original files and then create +new ones. I imagine the time to create new, empty indexes is the bulk +of the time Hartmut is measuring. (Remember that an "empty" index has +at least one page in it, the metadata page, for all of our index types, +so there is some actual I/O involved to do this.) + +It does not bother me that TRUNCATE takes nonzero time; it's intended +to be used in situations where DELETE would take huge amounts of time +(especially after you factor in the subsequent VACUUM activity). +The fact that DELETE takes near-zero time on a zero-length table is +not very relevant. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Dec 10 16:35:58 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 19D2BD1B498 + for ; + Wed, 10 Dec 2003 20:35:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16293-07 + for ; + Wed, 10 Dec 2003 16:35:25 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D136D1B468 + for ; + Wed, 10 Dec 2003 16:35:23 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 03E9835305; Wed, 10 Dec 2003 12:35:06 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id F3F07352A2; Wed, 10 Dec 2003 12:35:05 -0800 (PST) +Date: Wed, 10 Dec 2003 12:35:05 -0800 (PST) +From: Stephan Szabo +To: nbarraza@uolsinectis.com.ar +Cc: pgsql-performance@postgresql.org, nbarraza@boldt.com.ar +Subject: Re: +In-Reply-To: <20031210192958.BF23C6C8A6@honorio.sinectis.com.ar> +Message-ID: <20031210123323.S707@megazone.bigpanda.com> +References: <20031210192958.BF23C6C8A6@honorio.sinectis.com.ar> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=X-UNKNOWN +Content-Transfer-Encoding: QUOTED-PRINTABLE +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/172 +X-Sequence-Number: 5032 + + +On Wed, 10 Dec 2003 nbarraza@uolsinectis.com.ar wrote: + +> I have some problems on performance using postgresql v. 7.3.2 running on +> Linux RedHat 9. An update involving several rows (about 500000) on a +> table having 2800000 tuples takes in the order of 6 minutes. It is more +> than it takes on other plataforms (SqlServer, FOX). I think that there=B4s +> something wrong on my configuration. I=B4ve already adjusted some +> parameters as I could understand memory and disk usage. Next, I send a +> description of parameters changed in postgresql.conf, a scheme of the +> table, and an EXPLAIN ANALYZE of the command. The hardware configuration +> is a Pentium III 1 Ghz, 512 MB of memory, and an SCSI drive of 20 GB. +> Following goes the description: + +> -- Values changed in postgresql.conf + +> CREATE TABLE jugadas ( +> fecha_ju character(8), +> hora_ju character(4), +> juego character(2), +> juego_vta character(2), +> sorteo_p character(5), +> sorteo_v character(5), +> nro_servidor character(1), +> ticket character(9), +> terminal character(4), +> sistema character(1), +> agente character(5), +> subagente character(3), +> operador character(2), +> importe character(7), +> anulada character(1), +> icode character(15), +> codseg character(15), +> tipo_moneda character(1), +> apuesta character(100), +> extraido character(1) +> ); + +Are there any tables that reference this one or other triggers? If so, +what do the tables/contraints/triggers involve look like? + +I'm guessing there might be given the difference in the actual time +numbers to the total runtime on the explain analyze. + + +From pgsql-performance-owner@postgresql.org Thu Dec 11 00:22:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D7DBD1B430 + for ; + Thu, 11 Dec 2003 04:22:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72947-04 + for ; + Thu, 11 Dec 2003 00:22:13 -0400 (AST) +Received: from homer.lsd.di.uminho.pt (gsd.di.uminho.pt [193.136.20.132]) + by svr1.postgresql.org (Postfix) with SMTP id C2BE7D1B462 + for ; + Thu, 11 Dec 2003 00:22:06 -0400 (AST) +Received: (qmail 31367 invoked from network); 11 Dec 2003 04:18:20 -0000 +Received: from alfranio.lsd.di.uminho.pt (HELO lsd.di.uminho.pt) + (192.168.2.144) + by mailer.lsd.di.uminho.pt with SMTP; 11 Dec 2003 04:18:20 -0000 +Message-ID: <3FD7EEE8.4080904@lsd.di.uminho.pt> +Date: Thu, 11 Dec 2003 04:13:28 +0000 +From: Alfranio Correia Junior +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Performance problems with a higher number of clients +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/173 +X-Sequence-Number: 5033 + +Hello, + +I am facing a problem trying to put 500 concurrent users accessing +a postgresql instance. Basically, the machine begins to do a lot i/o... +swap area increases more and more... + +The vmstat began with 9200 (swpd) and after 20 minutes it was like that: + +VMSTAT: + + procs memory swap io system + cpu + r b w swpd free buff cache si so bi bo in cs us + sy id + 2 29 1 106716 9576 7000 409876 32 154 5888 1262 616 1575 8 + 12 80 + 0 29 1 107808 9520 6896 409904 60 220 5344 1642 662 1510 9 + 15 76 + 0 89 1 108192 9528 6832 410184 172 138 6810 1750 693 2466 11 + 16 73 + 0 27 1 108192 9900 6824 409852 14 112 4488 1294 495 862 2 + 9 88 + 8 55 1 108452 9552 6800 410284 26 12 6266 1082 651 2284 8 + 11 81 + 5 78 2 109220 8688 6760 410816 148 534 6318 1632 683 1230 6 + 13 81 + + +The application that I am trying to running mimmics the tpc-c benchmark... +Actually, I am simulating the tpc-c workload without considering +screens and other details. The only interesting is +on the database workload proposed by the benchmark and its distributions. + +The machine is a dual-processor pentium III, with 1GB, external storage +device. It runs Linux version 2.4.21-dt1 (root@dupond) (gcc version 2.96 +20000731 (Red Hat Linux 7.3 2.96-113)) #7 SMP Mon Apr 21 19:43:17 GMT +2003, Postgresql 7.5devel. + +Postgresql configuration: + +effective_cache_size = 35000 +shared_buffers = 5000 +random_page_cost = 2 +cpu_index_tuple_cost = 0.0005 +sort_mem = 10240 + +I would like to know if this behaivor is normal considering +the number of clients, the workload and the database size (7.8 GB) ? +Or if there is something that I can change to get better results. + +Best regards, + +Alfranio Junior. + + +From pgsql-performance-owner@postgresql.org Thu Dec 11 02:04:30 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8AEAAD1B4BD + for ; + Thu, 11 Dec 2003 06:04:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 76711-09 + for ; + Thu, 11 Dec 2003 02:04:02 -0400 (AST) +Received: from linda-2.paradise.net.nz (bm-2a.paradise.net.nz [202.0.58.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D4BFD1B481 + for ; + Thu, 11 Dec 2003 02:04:01 -0400 (AST) +Received: from smtp-3.paradise.net.nz (smtp-3a.paradise.net.nz [202.0.32.196]) + by linda-2.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0HPP005JQVID8M@linda-2.paradise.net.nz> for + pgsql-performance@postgresql.org; Thu, 11 Dec 2003 19:03:50 +1300 (NZDT) +Received: from paradise.net.nz (218-101-14-73.paradise.net.nz [218.101.14.73]) + by smtp-3.paradise.net.nz (Postfix) with ESMTP id B082FADF83; Thu, + 11 Dec 2003 19:03:49 +1300 (NZDT) +Date: Thu, 11 Dec 2003 19:04:15 +1300 +From: Mark Kirkwood +Subject: Re: Solaris Performance (Again) +In-reply-to: <20031210085323.749a549f.threshar@torgo.978.org> +To: Jeff +Cc: pgsql-performance@postgresql.org +Message-id: <3FD808DF.9080504@paradise.net.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.4) Gecko/20031008 +References: <3FD6B596.8090803@paradise.net.nz> + <20031210085323.749a549f.threshar@torgo.978.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/174 +X-Sequence-Number: 5034 + +Good point - + +It is Pg 7.4beta1 , compiled with + +CFLAGS += -O2 -funroll-loops -fexpensive-optimizations + +Jeff wrote: + +> +>What version of PG? +> +>If it is before 7.4 PG compiles with _NO_ optimization by default and +>was a huge part of the slowness of PG on solaris. +> +> +> +> + + +From pgsql-performance-owner@postgresql.org Thu Dec 11 02:09:53 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BC5E6D1B432 + for ; + Thu, 11 Dec 2003 06:09:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 83134-04 + for ; + Thu, 11 Dec 2003 02:09:24 -0400 (AST) +Received: from linda-1.paradise.net.nz (bm-1a.paradise.net.nz [202.0.58.20]) + by svr1.postgresql.org (Postfix) with ESMTP id C4B20D1B46C + for ; + Thu, 11 Dec 2003 02:09:22 -0400 (AST) +Received: from smtp-3.paradise.net.nz (smtp-3a.paradise.net.nz [202.0.32.196]) + by linda-1.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0HPP00KVTVRLD1@linda-1.paradise.net.nz> for + pgsql-performance@postgresql.org; Thu, 11 Dec 2003 19:09:22 +1300 (NZDT) +Received: from paradise.net.nz (218-101-14-73.paradise.net.nz [218.101.14.73]) + by smtp-3.paradise.net.nz (Postfix) with ESMTP id 959BDADFE0; Thu, + 11 Dec 2003 19:09:21 +1300 (NZDT) +Date: Thu, 11 Dec 2003 19:09:47 +1300 +From: Mark Kirkwood +Subject: Re: Solaris Performance (Again) +In-reply-to: <87smjs4h7s.fsf@mailbox.samurai.com> +To: Neil Conway +Cc: pgsql-performance@postgresql.org +Message-id: <3FD80A2B.2010601@paradise.net.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.4) Gecko/20031008 +References: <3FD6B596.8090803@paradise.net.nz> + <87smjs4h7s.fsf@mailbox.samurai.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/175 +X-Sequence-Number: 5035 + +yes - originally I was going to stop at 8 clients, but once the bit was +between the teeth....If I get another box to myself I will try -s 50 or +100 and see what that shows up. + +cheers + +Mark + +Neil Conway wrote: + +> FYI, the pgbench docs state: +> +> NOTE: scaling factor should be at least as large as the largest +> number of clients you intend to test; else you'll mostly be +> measuring update contention. +> +>-Neil +> +> +> + + +From pgsql-performance-owner@postgresql.org Thu Dec 11 02:37:13 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2F44AD1B481 + for ; + Thu, 11 Dec 2003 06:37:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85303-07 + for ; + Thu, 11 Dec 2003 02:36:42 -0400 (AST) +Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com + [192.108.102.143]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CE0CD1B47A + for ; + Thu, 11 Dec 2003 02:36:41 -0400 (AST) +Received: from myrealbox.com shridhar_daithankar@smtp-send.myrealbox.com + [202.54.11.72] + by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 3.46 $ on + Novell NetWare via secured & encrypted transport (TLS); + Wed, 10 Dec 2003 23:36:39 -0700 +Message-ID: <3FD81067.6010305@myrealbox.com> +Date: Thu, 11 Dec 2003 12:06:23 +0530 +From: Shridhar Daithankar +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Alfranio Correia Junior +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems with a higher number of clients +References: <3FD7EEE8.4080904@lsd.di.uminho.pt> +In-Reply-To: <3FD7EEE8.4080904@lsd.di.uminho.pt> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/176 +X-Sequence-Number: 5036 + +Alfranio Correia Junior wrote: +> Postgresql configuration: +> +> effective_cache_size = 35000 +> shared_buffers = 5000 +> random_page_cost = 2 +> cpu_index_tuple_cost = 0.0005 +> sort_mem = 10240 + +Lower sort mem to say 2000-3000, up shared buffers to 10K and up effective cache +size to around 65K. That should make it behave bit better. + +I guess tuning sort mem alone would give you performance you are expecting.. +Tune them one by one. + +HTH + + Shridhar + +From pgsql-performance-owner@postgresql.org Thu Dec 11 09:29:20 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 01509D1B462 + for ; + Thu, 11 Dec 2003 13:29:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 34383-04 + for ; + Thu, 11 Dec 2003 09:28:49 -0400 (AST) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id 601D4D1B49E + for ; + Thu, 11 Dec 2003 09:28:45 -0400 (AST) +Received: (qmail 2973 invoked from network); 11 Dec 2003 13:28:51 -0000 +Received: from localhost (HELO squeegit) (threshar@127.0.0.1) + by localhost with SMTP; 11 Dec 2003 13:28:51 -0000 +Date: Thu, 11 Dec 2003 08:28:26 -0500 +From: Jeff +To: Alfranio Correia Junior +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems with a higher number of clients +Message-Id: <20031211082826.7173d5e0.threshar@torgo.978.org> +In-Reply-To: <3FD7EEE8.4080904@lsd.di.uminho.pt> +References: <3FD7EEE8.4080904@lsd.di.uminho.pt> +X-Mailer: Sylpheed version 0.9.7 (GTK+ 1.2.10; i686-pc-linux-gnu) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/177 +X-Sequence-Number: 5037 + +On Thu, 11 Dec 2003 04:13:28 +0000 +Alfranio Correia Junior wrote: + +> r b w swpd free buff cache si so bi bo in cs +> us sy id +> 2 29 1 106716 9576 7000 409876 32 154 5888 1262 616 1575 +> 8 12 80 + +On linux I've found as soon as it has to swap its oh-so-wonderful VM +brings the machine to a screeching halt. + + +> sort_mem = 10240 +> +Here's a big problem + +This gives _EACH SORT_ 10MB (No more, no less) to play with. +10MB * 500 connections == 5000MB in one case.. Some queries may +have more sort steps. It is possible 1 connection could be using +30-40MB of sort_mem. You'll need to bring that value down to prevent +swapping. + +If you have a few "common" queries that are run a lot check out hte +explain analyze. You can see about how much sort_mem you'll need. Look +in the sort step. it should tell you the width and the # of rows. +Multiply those. That is sort of how much memory you'll need (I'd round +it up a bit) + +If under normal workload your DB is swapping you have problems. You'll +need to either tune your config or get bigger hardware. You may want to +also consider an OS that deals with that situation a bit better. + +good luck. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + +From pgsql-performance-owner@postgresql.org Thu Dec 11 10:59:08 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4316AD1BB91 + for ; + Thu, 11 Dec 2003 14:55:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51326-01 + for ; + Thu, 11 Dec 2003 10:55:03 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A8E8D1C4E2 + for ; + Thu, 11 Dec 2003 10:54:43 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBBEsH19013179; + Thu, 11 Dec 2003 09:54:18 -0500 (EST) +To: Alfranio Correia Junior +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems with a higher number of clients +In-reply-to: <3FD7EEE8.4080904@lsd.di.uminho.pt> +References: <3FD7EEE8.4080904@lsd.di.uminho.pt> +Comments: In-reply-to Alfranio Correia Junior + message dated "Thu, 11 Dec 2003 04:13:28 +0000" +Date: Thu, 11 Dec 2003 09:54:17 -0500 +Message-ID: <13178.1071154457@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/178 +X-Sequence-Number: 5038 + +Alfranio Correia Junior writes: +> I am facing a problem trying to put 500 concurrent users accessing +> a postgresql instance. + +I think you're going to need to buy more RAM. 1Gb of RAM means there +is a maximum of 2Mb available per Postgres process before you start +to go into swap hell --- in practice a lot less, since you have to allow +for other things like the kernel and other applications. + +AFAIR TPC-C doesn't involve any complex queries, so it's possible you +could run it with only 1Mb of workspace per process, but not when +you've configured + +> sort_mem = 10240 + +That's ten times more than your configuration can possibly support. +(I don't recall whether TPC-C uses any queries that would sort, so +it's possible this setting isn't affecting you; but if you are doing +any sorts then it's killing you.) + +Bottom line is you probably need more RAM. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Dec 11 12:01:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 12CEFD1DF71 + for ; + Thu, 11 Dec 2003 16:00:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 59848-08 + for ; + Thu, 11 Dec 2003 12:00:21 -0400 (AST) +Received: from hotmail.com (bay7-f88.bay7.hotmail.com [64.4.11.88]) + by svr1.postgresql.org (Postfix) with ESMTP id B625AD1DF95 + for ; + Thu, 11 Dec 2003 12:00:20 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Thu, 11 Dec 2003 08:00:19 -0800 +Received: from 200.24.104.55 by by7fd.bay7.hotmail.msn.com with HTTP; + Thu, 11 Dec 2003 16:00:19 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: hints in Postgres? +Date: Thu, 11 Dec 2003 11:00:19 -0500 +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1; format=flowed +Message-ID: +X-OriginalArrivalTime: 11 Dec 2003 16:00:19.0890 (UTC) + FILETIME=[E066B920:01C3BFFF] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/179 +X-Sequence-Number: 5039 + +Hi list, + +I need to know if there is anything like hints of Oracle in +Postgres..otherwise..I wish to find a way to force a query plan to use the +indexes or tell the optimizer things like "optimize based in statistics", "I +want to define the order of the a join" , "optimize based on a execution +plan that I consider the best" ... + +thanks. + +_________________________________________________________________ +Las mejores tiendas, los precios mas bajos, entregas en todo el mundo, +YupiMSN Compras: http://latam.msn.com/compras/ + + +From pgsql-performance-owner@postgresql.org Thu Dec 11 12:22:53 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 070CED1B4A1 + for ; + Thu, 11 Dec 2003 16:22:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 66373-09 + for ; + Thu, 11 Dec 2003 12:22:21 -0400 (AST) +Received: from kix.fsv.cvut.cz (Kix.FSV.CVUT.CZ [147.32.129.84]) + by svr1.postgresql.org (Postfix) with ESMTP id 656D1D1DF30 + for ; + Thu, 11 Dec 2003 12:22:20 -0400 (AST) +Received: from localhost (stehule@localhost) + by kix.fsv.cvut.cz (8.11.6/8.11.6) with ESMTP id hBBGMDY09791; + Thu, 11 Dec 2003 17:22:13 +0100 +Date: Thu, 11 Dec 2003 17:22:13 +0100 (CET) +From: Pavel Stehule +To: sandra ruiz +Cc: pgsql-performance@postgresql.org +Subject: Re: hints in Postgres? +In-Reply-To: +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/180 +X-Sequence-Number: 5040 + +hello + +maybe + +http://www.gtsm.com/oscon2003/toc.html +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + +bye +Pavel + + +On Thu, 11 Dec 2003, sandra ruiz wrote: + +> Hi list, +> +> I need to know if there is anything like hints of Oracle in +> Postgres..otherwise..I wish to find a way to force a query plan to use the +> indexes or tell the optimizer things like "optimize based in statistics", "I +> want to define the order of the a join" , "optimize based on a execution +> plan that I consider the best" ... +> +> thanks. +> +> _________________________________________________________________ +> Las mejores tiendas, los precios mas bajos, entregas en todo el mundo, +> YupiMSN Compras: http://latam.msn.com/compras/ +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> + + +From pgsql-performance-owner@postgresql.org Thu Dec 11 13:00:27 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C792DD1B438 + for ; + Thu, 11 Dec 2003 17:00:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72502-05 + for ; + Thu, 11 Dec 2003 12:59:52 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id D6147D1B46E + for ; + Thu, 11 Dec 2003 12:59:51 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hBBGxobK005184 + for ; Thu, 11 Dec 2003 16:59:51 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hBBGaZG5002490 + for pgsql-performance@postgresql.org; Thu, 11 Dec 2003 16:36:35 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: hints in Postgres? +Date: Thu, 11 Dec 2003 11:31:45 -0500 +Organization: cbbrowne Computing Inc +Lines: 24 +Message-ID: +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:y+0IPFvfAM3U+PlNhp3qRQc1Qx0= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/182 +X-Sequence-Number: 5042 + +Quoth mileruiz@hotmail.com ("sandra ruiz"): +> I need to know if there is anything like hints of Oracle in +> Postgres..otherwise..I wish to find a way to force a query plan to use +> the indexes or tell the optimizer things like "optimize based in +> statistics", "I want to define the order of the a join" , "optimize +> based on a execution plan that I consider the best" ... + +It is commonly considered a MISFEATURE of Oracle that it forces you to +tweak all of those sorts of 'knobs.' + +The approach taken with PostgreSQL is to use problems discovered to +try to improve the quality of the query optimizer. It is usually +clever enough to do a good job, and if it can be improved to +automatically notice that "better" plan, then that is a better thing +than imposing the burden of tuning each query on you. + +Tom Lane is "Doctor Optimization," and if you look at past discussion +threads of this sort, you'll see that he tends to rather strongly +oppose the introduction of "hints." +-- +select 'aa454' || '@' || 'freenet.carleton.ca'; +http://www3.sympatico.ca/cbbrowne/linux.html +As of next Monday, COMSAT will be flushed in favor of a string and two tin +cans. Please update your software. + +From pgsql-performance-owner@postgresql.org Tue Dec 16 17:08:02 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F3AF2D1B8B6 + for ; + Thu, 11 Dec 2003 16:51:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72502-03 + for ; + Thu, 11 Dec 2003 12:51:14 -0400 (AST) +Received: from dycon.com (titus.dycon.com [12.13.144.17]) + by svr1.postgresql.org (Postfix) with SMTP id 5DA30D1D1F2 + for ; + Thu, 11 Dec 2003 12:51:13 -0400 (AST) +Received: (qmail 25373 invoked by uid 1015); 11 Dec 2003 16:44:36 -0000 +Received: from unknown (HELO ulanji.com) (12.13.144.25) + by 0 with SMTP; 11 Dec 2003 16:44:36 -0000 +Message-ID: <3FD89D72.8080508@ulanji.com> +Date: Thu, 11 Dec 2003 11:38:10 -0500 +From: "Sean P. Thomas" +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Optimizing FK & PK performance... +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/234 +X-Sequence-Number: 5095 + +I am working on migrating to postgres and had some questions regarding +optimization that I could not find references in the documentation: + + +1. Is there any performance difference for declaring a primary or +foreign key a column or table contraint? From the documentation, which +way is faster and/or scales better: + + +CREATE TABLE distributors ( + did integer, + name varchar(40), + PRIMARY KEY(did) +); + +CREATE TABLE distributors ( + did integer PRIMARY KEY, + name varchar(40) +); + + +2. Is DEFERRABLE and INITIALLY IMMEDIATE or INITIALLY DEFERRABLE +perferred for performance? We generally have very small transactions +(web app) but we utilize a model of: + +view (limit scope for security) -> rules -> before triggers (validate +permissions and to set proper permissions) -> tables. + +I know there were some issues with deferring that was fixed but does it +benefit performance or cause any reliability issues? + + +Thank you for your assistance and let me know if I can offer additional +information. + + --spt + + + + +From pgsql-performance-owner@postgresql.org Thu Dec 11 12:46:02 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C7FA8D1B4B2 + for ; + Thu, 11 Dec 2003 16:46:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 68329-10 + for ; + Thu, 11 Dec 2003 12:45:30 -0400 (AST) +Received: from tino.sinectis.com.ar (tino.sinectis.com.ar [216.244.192.232]) + by svr1.postgresql.org (Postfix) with ESMTP id A6345D1B480 + for ; + Thu, 11 Dec 2003 12:45:29 -0400 (AST) +Received: by tino.sinectis.com.ar (Postfix, from userid 99) + id CFE346C3BE; Thu, 11 Dec 2003 13:45:17 -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.4.4 +From: nbarraza@uolsinectis.com.ar +To: pgsql-performance@postgresql.org +Subject: Command +Reply-To: nbarraza@uolsinectis.com.ar +Message-Id: <20031211164517.CFE346C3BE@tino.sinectis.com.ar> +Date: Thu, 11 Dec 2003 13:45:17 -0300 (GMT+3) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/181 +X-Sequence-Number: 5041 + +show + +From pgsql-performance-owner@postgresql.org Thu Dec 11 16:20:22 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A27DDD1B456 + for ; + Thu, 11 Dec 2003 20:20:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05943-02 + for ; + Thu, 11 Dec 2003 16:19:52 -0400 (AST) +Received: from visionlink.org (mail.visionlink.org [208.139.207.159]) + by svr1.postgresql.org (Postfix) with SMTP id EB0FBD1D0AE + for ; + Thu, 11 Dec 2003 16:19:49 -0400 (AST) +Received: from [65.100.170.142] (HELO [192.168.1.201]) by visionlink.org + (Stalker SMTP Server 1.8b8) with ESMTP id S.0002302965 for + ; Thu, 11 Dec 2003 13:20:53 -0700 +Mime-Version: 1.0 +X-Sender: bohmer@mail.visionlink.org +Message-Id: +Date: Thu, 11 Dec 2003 13:19:42 -0700 +To: pgsql-performance@postgresql.org +From: Jeff Bohmer +Subject: Hardware suggestions for Linux/PGSQL server +Content-Type: text/plain; charset="us-ascii" ; format="flowed" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/183 +X-Sequence-Number: 5043 + + +Hi everyone, + +I want to pick your brains for hardware suggestions about a +Linux-based PostgreSQL 7.4 server. It will be a dedicated DB server +backing our web sites and hit by application servers (which do +connection pooling). I've hopefully provided all relevant +information below. Any thoughts, comments or suggestions are welcome. + +Our current server and database: + Mac OS X Server 10.2.8 + single 1.25GHz G4 + 2 GB 333MHz RAM + 7200 rpm SCSI drive for OS, logs + 15k rpm SCSI drive for data + + PostgreSQL 7.3.4 + 1 database, 1.1 GB in size, growing by ~15 MB / week + 60 tables, 1 schema, largest is 1m rows, 1 at 600k, 3 at 100k + Peak traffic: + 500 UPDATEs, INSERTs and DELETEs / minute + 6000 SELECTs / minutes + 90 connections + +Performance is fine most of the time, but not during peak loads. +We're never swapping and disk IO during the SELECT peaks is hardly +anything (under 3MB/sec). I think UPDATE peaks might be saturating +disk IO. Normally, most queries finish in under .05 seconds. Some +take 2-3 seconds. During peaks, the fast queries are just OK and the +slower ones take too long (like over 8 seconds). + +We're moving to Linux from OS X for improved stability and more +hardware options. We need to do this soon. The current server is +max'd out at 2GB RAM and I'm afraid might start swapping in a month. + +Projected database/traffic in 12 months: + Database size will be at least 2.5 GB + Largest table still 1m rows, but 100k tables will grow to 250k + Will be replicated to a suitable standby slave machine + Peak traffic: + 2k UPDATEs, INSERTs, DELETEs / minute + 20k SELECTs / minute + 150 - 200 connections + +We're willing to shell out extra bucks to get something that will +undoubtedly handle the projected peak load in 12 months with +excellent performance. But we're not familiar with PG's performance +on Linux and don't like to waste money. + +I've been thinking of this (overkill? not enough?): + 2 Intel 32-bit CPUs + Lowest clock speed chip for the fastest available memory bus + 4 GB RAM (maybe we only need 3 GB to start with?) + SCSI RAID 1 for OS + For PostgreSQL data and logs ... + 15k rpm SCSI disks + RAID 5, 7 disks, 256MB battery-backed write cache + (Should we save $ and get a 4-disk RAID 10 array?) + +I wonder about the 32bit+bigmem vs. 64bit question. At what database +size will we need more than 4GB RAM? + +We'd like to always have enough RAM to cache the entire database. +While 64bit is in our long-term future, we're willing to stick with +32bit Linux until 64bit Linux on Itanium/Opteron and 64bit PostgreSQL +"settle in" to proven production-quality. + +TIA, +- Jeff + +-- + +Jeff Bohmer +VisionLink, Inc. +_________________________________ +303.402.0170 +www.visionlink.org +_________________________________ +People. Tools. Change. Community. + +From pgsql-performance-owner@postgresql.org Thu Dec 11 16:28:51 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0AABAD1B456 + for ; + Thu, 11 Dec 2003 20:28:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06229-05 + for ; + Thu, 11 Dec 2003 16:28:20 -0400 (AST) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id CA045D1D0AE + for ; + Thu, 11 Dec 2003 16:28:17 -0400 (AST) +Received: (qmail 10562 invoked by uid 500); 11 Dec 2003 20:27:55 -0000 +Date: Thu, 11 Dec 2003 14:27:55 -0600 +From: Bruno Wolff III +To: sandra ruiz +Cc: pgsql-performance@postgresql.org +Subject: Re: hints in Postgres? +Message-ID: <20031211202755.GB9844@wolff.to> +Mail-Followup-To: sandra ruiz , + pgsql-performance@postgresql.org +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/184 +X-Sequence-Number: 5044 + +On Thu, Dec 11, 2003 at 11:00:19 -0500, + sandra ruiz wrote: +> Hi list, +> +> I need to know if there is anything like hints of Oracle in +> Postgres..otherwise..I wish to find a way to force a query plan to use the +> indexes or tell the optimizer things like "optimize based in statistics", +> "I want to define the order of the a join" , "optimize based on a execution +> plan that I consider the best" ... + +There are a few things you can do. + +You can explicitly fix the join order using INNER JOIN (in 7.4 you have to set +a GUC variable for this to force join order). + +You can disable specific plan types (though sequential just becomes very +expensive as sometimes there is no other way to do things). + +You can set tuning values to properly express the relative cost of things +like CPU time, sequential disk reads and random disk reads. + +These are done by setting GUC variables either in the postgres config +file or using SET commands. They are per backend so some queries can +be done using one set of values while others going on at the same time +use different values. + +From pgsql-performance-owner@postgresql.org Thu Dec 11 17:00:25 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F5CCD1B45A + for ; + Thu, 11 Dec 2003 21:00:24 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11733-04 + for ; + Thu, 11 Dec 2003 16:59:54 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 2E7E5D1B456 + for ; + Thu, 11 Dec 2003 16:59:52 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hBBKxobI038025 + for ; Thu, 11 Dec 2003 20:59:51 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hBBKo3Me037153 + for pgsql-performance@postgresql.org; Thu, 11 Dec 2003 20:50:03 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Hardware suggestions for Linux/PGSQL server +Date: Thu, 11 Dec 2003 12:50:06 -0800 +Organization: Hub.Org Networking Services +Lines: 40 +Message-ID: +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +In-Reply-To: +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/185 +X-Sequence-Number: 5045 + +Jeff Bohmer wrote: +> We're willing to shell out extra bucks to get something that will +> undoubtedly handle the projected peak load in 12 months with excellent +> performance. But we're not familiar with PG's performance on Linux and +> don't like to waste money. + +Properly tuned, PG on Linux runs really nice. A few people have +mentioned the VM swapping algorithm on Linux is semi-dumb. I get around +that problem by having a ton of memory and almost no swap. + +> I've been thinking of this (overkill? not enough?): +> 2 Intel 32-bit CPUs +> Lowest clock speed chip for the fastest available memory bus +> 4 GB RAM (maybe we only need 3 GB to start with?) +> SCSI RAID 1 for OS +> For PostgreSQL data and logs ... +> 15k rpm SCSI disks +> RAID 5, 7 disks, 256MB battery-backed write cache +> (Should we save $ and get a 4-disk RAID 10 array?) +> +> I wonder about the 32bit+bigmem vs. 64bit question. At what database +> size will we need more than 4GB RAM? + +With 4GB of RAM, you're already running into bigmem. By default, Linux +gives 2GB of address space to programs and 2GB to kernel. I usually see +people quote 5%-15% penalty in general for using PAE versus a flat +address space. I've seen simple MySQL benchmarks where 64-bit versions +run 35%+ faster versus 32-bit+PAE but how that translates to PG, I dunno +yet. + +> We'd like to always have enough RAM to cache the entire database. While +> 64bit is in our long-term future, we're willing to stick with 32bit +> Linux until 64bit Linux on Itanium/Opteron and 64bit PostgreSQL "settle +> in" to proven production-quality. + +Well if this is the case, you probably should get an Opteron server +*now* and just run 32-bit Linux on it until you're sure about the +software. No point in buying a Xeon and then throwing the machine away +in a year when you decide you need 64-bit for more speed. + + +From pgsql-performance-owner@postgresql.org Thu Dec 11 18:02:59 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ADD90D1B4AD + for ; + Thu, 11 Dec 2003 22:02:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 20062-05 + for ; + Thu, 11 Dec 2003 18:02:27 -0400 (AST) +Received: from visionlink.org (mail.visionlink.org [208.139.207.159]) + by svr1.postgresql.org (Postfix) with SMTP id 3C9AFD1DE9B + for ; + Thu, 11 Dec 2003 18:02:24 -0400 (AST) +Received: from [65.100.170.142] (HELO [192.168.1.201]) by visionlink.org + (Stalker SMTP Server 1.8b8) with ESMTP id S.0002303498 for + ; Thu, 11 Dec 2003 15:03:25 -0700 +Mime-Version: 1.0 +X-Sender: bohmer@mail.visionlink.org +Message-Id: +In-Reply-To: +References: + +Date: Thu, 11 Dec 2003 15:02:11 -0700 +To: pgsql-performance@postgresql.org +From: Jeff Bohmer +Subject: Re: Hardware suggestions for Linux/PGSQL server +Content-Type: text/plain; charset="us-ascii" ; format="flowed" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/186 +X-Sequence-Number: 5046 + + +>Properly tuned, PG on Linux runs really nice. A few people have +>mentioned the VM swapping algorithm on Linux is semi-dumb. I get +>around that problem by having a ton of memory and almost no swap. + +I think we want your approach: enough RAM to avoid swapping altogether. + + + +>With 4GB of RAM, you're already running into bigmem. By default, +>Linux gives 2GB of address space to programs and 2GB to kernel. + +It seems I don't fully understand the bigmem situation. I've +searched the archives, googled, checked RedHat's docs, etc. But I'm +getting conflicting, incomplete and/or out of date information. Does +anyone have pointers to bigmem info or configuration for the 2.4 +kernel? + +If Linux is setup with 2GB for kernel and 2GB for user, would that be +OK with a DB size of 2-2.5 GB? I'm figuring the kernel will cache +most/all of the DB in it's 2GB and there's 2GB left for PG processes. +Where does PG's SHM buffers live, kernel or user? (I don't plan on +going crazy with buffers, but will guess we'd need about 128MB, 256MB +at most.) + + + +>I usually see people quote 5%-15% penalty in general for using PAE +>versus a flat address space. I've seen simple MySQL benchmarks where +>64-bit versions run 35%+ faster versus 32-bit+PAE but how that +>translates to PG, I dunno yet. +> +>>We'd like to always have enough RAM to cache the entire database. +>>While 64bit is in our long-term future, we're willing to stick with +>>32bit Linux until 64bit Linux on Itanium/Opteron and 64bit +>>PostgreSQL "settle in" to proven production-quality. +> +>Well if this is the case, you probably should get an Opteron server +>*now* and just run 32-bit Linux on it until you're sure about the +>software. No point in buying a Xeon and then throwing the machine +>away in a year when you decide you need 64-bit for more speed. + +That's a good point. I had forgotten about the option to run 32bit +on an Operton. If we had 3GB or 4GB initially on an Opteron, we'd +need bigmem for 32bit Linux, right? + +This might work nicely since we'd factor in the penalty from PAE for +now and have the performance boost from moving to 64bit available on +demand. Not having to build another DB server in a year would also +be nice. + +FYI, we need stability first and performance second. + +Thank you, +- Jeff + +-- + +Jeff Bohmer +VisionLink, Inc. +_________________________________ +303.402.0170 +www.visionlink.org +_________________________________ +People. Tools. Change. Community. + +From pgsql-performance-owner@postgresql.org Thu Dec 11 19:08:08 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1BD25D1B480 + for ; + Thu, 11 Dec 2003 23:08:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28357-10 + for ; + Thu, 11 Dec 2003 19:07:38 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id EB134D1D455 + for ; + Thu, 11 Dec 2003 19:07:30 -0400 (AST) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id hBBN6k8q016183; + Thu, 11 Dec 2003 16:06:46 -0700 (MST) +Date: Thu, 11 Dec 2003 15:48:58 -0700 (MST) +From: "scott.marlowe" +To: Jeff Bohmer +Cc: +Subject: Re: Hardware suggestions for Linux/PGSQL server +In-Reply-To: +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/187 +X-Sequence-Number: 5047 + + +Just one more piece of advice, you might want to look into a good battery +backed cache hardware RAID controller. They work quite well for heavily +updated databases. The more drives you throw at the RAID array the faster +it will be. + + +From pgsql-performance-owner@postgresql.org Thu Dec 11 20:00:27 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 88934D1DF1A + for ; + Fri, 12 Dec 2003 00:00:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 30808-09 + for ; + Thu, 11 Dec 2003 19:59:54 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id AA479D1D455 + for ; + Thu, 11 Dec 2003 19:59:51 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hBBNxpbI061868 + for ; Thu, 11 Dec 2003 23:59:51 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hBBNWfcJ058513 + for pgsql-performance@postgresql.org; Thu, 11 Dec 2003 23:32:41 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Hardware suggestions for Linux/PGSQL server +Date: Thu, 11 Dec 2003 15:32:47 -0800 +Organization: Hub.Org Networking Services +Lines: 44 +Message-ID: +References: + + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +In-Reply-To: +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/188 +X-Sequence-Number: 5048 + +Jeff Bohmer wrote: +> It seems I don't fully understand the bigmem situation. I've searched +> the archives, googled, checked RedHat's docs, etc. But I'm getting +> conflicting, incomplete and/or out of date information. Does anyone +> have pointers to bigmem info or configuration for the 2.4 kernel? + +Bigmem is the name for Linux's PAE support. + +> If Linux is setup with 2GB for kernel and 2GB for user, would that be OK +> with a DB size of 2-2.5 GB? I'm figuring the kernel will cache most/all +> of the DB in it's 2GB and there's 2GB left for PG processes. Where does +> PG's SHM buffers live, kernel or user? (I don't plan on going crazy +> with buffers, but will guess we'd need about 128MB, 256MB at most.) + +PG's SHM buffers live in user. Whether Linux's OS caches lives in user +or kernel, I think it's in kernel and I remember reading a max of ~950KB +w/o bigmem which means your 3.5GB of available OS memory will definitely +have to be swapped in and out of kernel space using PAE. + +>> Well if this is the case, you probably should get an Opteron server +>> *now* and just run 32-bit Linux on it until you're sure about the +>> software. No point in buying a Xeon and then throwing the machine away +>> in a year when you decide you need 64-bit for more speed. +> +> That's a good point. I had forgotten about the option to run 32bit on +> an Operton. If we had 3GB or 4GB initially on an Opteron, we'd need +> bigmem for 32bit Linux, right? +> +> This might work nicely since we'd factor in the penalty from PAE for now +> and have the performance boost from moving to 64bit available on +> demand. Not having to build another DB server in a year would also be +> nice. +> +> FYI, we need stability first and performance second. + +We ordered a 2x Opteron server the moment the CPU was released and it's +been perfect -- except for one incident where the PCI riser card had +drifted out of the PCI slot due to the heavy SCSI cables connected to +the card. + +I think most of the Opteron server MBs are pretty solid but you want +extra peace-of-mind, you could get a server from Newisys as they pack in +a cartload of extra monitoring features. + + +From pgsql-performance-owner@postgresql.org Thu Dec 11 21:17:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 75486D1B513 + for ; + Fri, 12 Dec 2003 01:17:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 40621-10 + for ; + Thu, 11 Dec 2003 21:17:16 -0400 (AST) +Received: from p15135922.pureserver.info (willfork.com [217.160.217.214]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C4DFD1B507 + for ; + Thu, 11 Dec 2003 21:17:12 -0400 (AST) +Received: from pD9EB7C08.dip.t-dialin.net (pD9EB7C08.dip.t-dialin.net + [217.235.124.8]) (authenticated bits=0) + by p15135922.pureserver.info (8.12.6/8.12.6) with ESMTP id + hBC1H6Am011618 + for ; Fri, 12 Dec 2003 02:17:09 +0100 +Subject: Measuring execution time for sql called from PL/pgSQL +From: Aram Kananov +To: "pgsql-performance@postgresql.org" +Content-Type: text/plain +Organization: +Message-Id: <1071191825.5163.164.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 12 Dec 2003 02:17:06 +0100 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/189 +X-Sequence-Number: 5049 + +Hi, + +I've got very slow insert performance on some +table which has trigger based on complex PL/pgSQL function. +Apparently insert is slow due some slow sql inside that function, +since CPU load is very high and disk usage is low during insert. +I run Red Hat 9 +Anthlon 2.6 +1GB ram +Fast IDE Disk + +Setting following in postgres.conf apparently doesn't help: +log_statement = true +log_duration = true +since it logs only sql issued by client. It logs only once +per session the sql text but during call to the PL/pgSQL function, +but of course no duration. + +Due the complexity of PL/pgSQL function trying to step by step +see the execution plans is very time consuming. + +Q1) Is there any way to see which statements are called for PL/pgSQL +and their duration? + +I've tried to measure the duration of sql with printing out +"localtimestamp" but for some reason during the same pg/plsql call it +returns the same +value: + +Example: +Following gets and prints out the localtimestamp value in the loop +create or replace function foobar() + returns integer as ' + declare + v timestamp; + begin + loop + select localtimestamp into v; + raise notice ''Timestamp: %'', v; + end loop; + return null; + end; ' language 'plpgsql' +; + +and as result of "select foobar();" + +i constantly get the same value: +NOTICE: Timestamp: 2003-12-12 01:51:35.768053 +NOTICE: Timestamp: 2003-12-12 01:51:35.768053 +NOTICE: Timestamp: 2003-12-12 01:51:35.768053 +NOTICE: Timestamp: 2003-12-12 01:51:35.768053 +NOTICE: Timestamp: 2003-12-12 01:51:35.768053 + +Q2) what i do wrong here and what is the "Proper Way" to measure +execution time of sql called inside PG/plSQL. + +Thanks in advance + +WBR +-- +Aram + + + + +From pgsql-performance-owner@postgresql.org Tue Dec 16 17:13:09 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 940DAD1B507 + for ; + Fri, 12 Dec 2003 01:57:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48748-06 + for ; + Thu, 11 Dec 2003 21:57:20 -0400 (AST) +Received: from www.smart-start-hosting.com (unknown [38.118.153.169]) + by svr1.postgresql.org (Postfix) with ESMTP id 74D23D1B454 + for ; + Thu, 11 Dec 2003 21:57:16 -0400 (AST) +Received: from shadovitz.com (localhost [127.0.0.1]) + by localhost (8.10.2/8.10.2) with ESMTP id hBC1oVm20348; + Thu, 11 Dec 2003 17:50:31 -0800 +From: "David Shadovitz" +To: Aram Kananov , + "pgsql-performance@postgresql.org" +Subject: Re: Measuring execution time for sql called from PL/pgSQL +Date: Thu, 11 Dec 2003 18:50:31 -0700 +Message-Id: <20031212015031.M16173@www.shadovitz.com> +In-Reply-To: <1071191825.5163.164.camel@localhost.localdomain> +References: <1071191825.5163.164.camel@localhost.localdomain> +X-Mailer: Open WebMail 1.81 20021203 +X-OriginatingIP: 216.180.56.31 (david@shadovitz.com) +MIME-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-1 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/236 +X-Sequence-Number: 5096 + +> I've tried to measure the duration of sql with printing out +> "localtimestamp" but for some reason during the same pg/plsql call +> it returns the same value: + +Aram, + +>From http://www.postgresql.org/docs/current/static/functions-datetime.html: + +There is also the function timeofday(), which for historical reasons returns +a text string rather than a timestamp value: + +SELECT timeofday(); + Result: Sat Feb 17 19:07:32.000126 2001 EST + +It is important to know that CURRENT_TIMESTAMP and related functions return +the start time of the current transaction; their values do not change during +the transaction. This is considered a feature: the intent is to allow a +single transaction to have a consistent notion of the "current" time, so that +multiple modifications within the same transaction bear the same time stamp. +timeofday() returns the wall-clock time and does advance during transactions. + +-David + +From pgsql-performance-owner@postgresql.org Thu Dec 11 22:35:52 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A717BD1B44D + for ; + Fri, 12 Dec 2003 02:35:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 50809-02 + for ; + Thu, 11 Dec 2003 22:35:23 -0400 (AST) +Received: from dhcp1.lsd.di.uminho.pt (gsd.di.uminho.pt [193.136.20.132]) + by svr1.postgresql.org (Postfix) with ESMTP id 89DB6D1B460 + for ; + Thu, 11 Dec 2003 22:35:17 -0400 (AST) +Received: from lsd.di.uminho.pt (localhost.localdomain [127.0.0.1]) + by dhcp1.lsd.di.uminho.pt (8.12.8/8.12.8) with ESMTP id hBC2ZGdS003891; + Fri, 12 Dec 2003 02:35:18 GMT +Message-ID: <3FD92964.8040709@lsd.di.uminho.pt> +Date: Fri, 12 Dec 2003 02:35:16 +0000 +From: Alfranio Tavares Correia Junior +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance problems with a higher number of clients +References: <3FD7EEE8.4080904@lsd.di.uminho.pt> + <13178.1071154457@sss.pgh.pa.us> +In-Reply-To: <13178.1071154457@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/190 +X-Sequence-Number: 5050 + +Thanks for the advices, +The performance is a bit better now. Unfortunately, the machine does not +allow +to put more than 200 - ~250 users without noticing swap hell. +I have to face the fact that I don't have enough memory.... + +I used the following configuration: + +effective_cache_size = 65000 +shared_buffers = 10000 +random_page_cost = 2 +cpu_index_tuple_cost = 0.0005 +sort_mem = 512 - I tested each query to see the amount of space +required to sort as Jeff suggested --> nothing above this value + +I tested the system with 100, 200, 300, 400, 500 and finally 250 users. +Until ~250 users the system presents good response time and the swap +almost does not exist. +During these expirements, I also started psql and tried to run some +queries. +Unfortunately, even with ~250 users there is one query that takes too +long to finish... +In fact, I canceled its execution after 5 minutes waiting to see anything. + +This is the query: + +select count(distinct(s_i_id)) + from stock, order_line + where ol_w_id = _xx_ and + ol_d_id = _xx_ and + ol_o_id between _xx_ and + _xx_ and + s_w_id = ol_w_id and + s_i_id = ol_i_id and + s_quantity < _xx_; + +When the system has no load, after a vacuum -f, I can execute the query +and the plan produced is presented as follows: + Aggregate (cost=49782.16..49782.16 rows=1 width=4) (actual +time=52361.573..52361.574 rows=1 loops=1) + -> Nested Loop (cost=0.00..49780.24 rows=768 width=4) (actual +time=101.554..52328.913 rows=952 loops=1) + -> Index Scan using pk_order_line on order_line o +(cost=0.00..15779.32 rows=8432 width=4) (actual time=84.352..151.345 +rows=8964 loops=1) + Index Cond: ((ol_w_id = 4) AND (ol_d_id = 4) AND (ol_o_id + >= 100) AND (ol_o_id <= 1000)) + -> Index Scan using pk_stock on stock (cost=0.00..4.02 rows=1 +width=4) (actual time=5.814..5.814 rows=0 loops=8964) + Index Cond: ((stock.s_w_id = 4) AND (stock.s_i_id = +"outer".ol_i_id)) + Filter: (s_quantity < 20) + Total runtime: 52403.673 ms +(8 rows) + +The talbes are designed as follows: + +--ROWS ~5000000 +CREATE TABLE stock ( + s_i_id int NOT NULL , + s_w_id int NOT NULL , + s_quantity int NULL , + s_dist_01 char (24) NULL , + s_dist_02 char (24) NULL , + s_dist_03 char (24) NULL , + s_dist_04 char (24) NULL , + s_dist_05 char (24) NULL , + s_dist_06 char (24) NULL , + s_dist_07 char (24) NULL , + s_dist_08 char (24) NULL , + s_dist_09 char (24) NULL , + s_dist_10 char (24) NULL , + s_ytd int NULL , + s_order_cnt int NULL , + s_remote_cnt int NULL , + s_data char (50) NULL +); + +--ROWS ~15196318 +CREATE TABLE order_line ( + ol_o_id int NOT NULL , + ol_d_id int NOT NULL , + ol_w_id int NOT NULL , + ol_number int NOT NULL , + ol_i_id int NULL , + ol_supply_w_id int NULL , + ol_delivery_d timestamp NULL , + ol_quantity int NULL , + ol_amount numeric(6, 2) NULL , + ol_dist_info char (24) NULL +); + +ALTER TABLE stock ADD +CONSTRAINT PK_stock PRIMARY KEY + ( + s_w_id, + s_i_id + ); +ALTER TABLE order_line ADD + CONSTRAINT PK_order_line PRIMARY KEY + ( + ol_w_id, + ol_d_id, + ol_o_id, + ol_number + ); +CREATE INDEX IX_order_line ON order_line(ol_i_id); + +Any suggestion ? + + +Tom Lane wrote: + +>Alfranio Correia Junior writes: +> +> +>>I am facing a problem trying to put 500 concurrent users accessing +>>a postgresql instance. +>> +>> +> +>I think you're going to need to buy more RAM. 1Gb of RAM means there +>is a maximum of 2Mb available per Postgres process before you start +>to go into swap hell --- in practice a lot less, since you have to allow +>for other things like the kernel and other applications. +> +>AFAIR TPC-C doesn't involve any complex queries, so it's possible you +>could run it with only 1Mb of workspace per process, but not when +>you've configured +> +> +> +>>sort_mem = 10240 +>> +>> +> +>That's ten times more than your configuration can possibly support. +>(I don't recall whether TPC-C uses any queries that would sort, so +>it's possible this setting isn't affecting you; but if you are doing +>any sorts then it's killing you.) +> +>Bottom line is you probably need more RAM. +> +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> +> + + + +From pgsql-performance-owner@postgresql.org Fri Dec 12 02:36:30 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 971B7D1CAFE + for ; + Fri, 12 Dec 2003 06:36:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78740-02 + for ; + Fri, 12 Dec 2003 02:35:58 -0400 (AST) +Received: from smtp.pspl.co.in (unknown [202.54.11.65]) + by svr1.postgresql.org (Postfix) with ESMTP id D7545D1CB36 + for ; + Fri, 12 Dec 2003 02:35:54 -0400 (AST) +Received: (from root@localhost) + by smtp.pspl.co.in (8.12.9/8.12.9) id hBC6ZxCW007264 + for ; Fri, 12 Dec 2003 12:05:59 +0530 +Received: from persistent.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) + (authenticated bits=0) + by persistent.co.in (8.12.9/8.12.9) with ESMTP id hBC6ZuAo007197; + Fri, 12 Dec 2003 12:05:56 +0530 +Message-ID: <3FD961C5.9070204@persistent.co.in> +Date: Fri, 12 Dec 2003 12:05:49 +0530 +From: Shridhar Daithankar +Organization: Persistent Systems Pvt. Ltd. +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeff Bohmer +Cc: pgsql-performance@postgresql.org +Subject: Re: Hardware suggestions for Linux/PGSQL server +References: + + +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/191 +X-Sequence-Number: 5051 + +Jeff Bohmer wrote: +>> Well if this is the case, you probably should get an Opteron server +>> *now* and just run 32-bit Linux on it until you're sure about the +>> software. No point in buying a Xeon and then throwing the machine away +>> in a year when you decide you need 64-bit for more speed. +> +> +> That's a good point. I had forgotten about the option to run 32bit on +> an Operton. If we had 3GB or 4GB initially on an Opteron, we'd need +> bigmem for 32bit Linux, right? +> +> This might work nicely since we'd factor in the penalty from PAE for now +> and have the performance boost from moving to 64bit available on +> demand. Not having to build another DB server in a year would also be +> nice. + +FWIW, there are only two pieces of software that need 64bit aware for a typical +server job. Kernel and glibc. Rest of the apps can do fine as 32 bits unless you +are oracle and insist on outsmarting OS. + +In fact running 32 bit apps on 64 bit OS has plenty of advantages like +effectively using the cache. Unless you need 64bit, going for 64bit software is +not advised. + + Shridhar + +-- +----------------------------- +Shridhar Daithankar +LIMS CPE Team Member, PSPL. +mailto:shridhar_daithankar@persistent.co.in +Phone:- +91-20-5676700 Extn.270 +Fax :- +91-20-5676701 +----------------------------- + + +From pgsql-performance-owner@postgresql.org Fri Dec 12 02:50:04 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 366E1D1B8BB; Fri, 12 Dec 2003 06:50:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 80913-04; Fri, 12 Dec 2003 02:49:30 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP + id C6E5ED1B441; Fri, 12 Dec 2003 02:49:27 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hBC6nQR15608; + Fri, 12 Dec 2003 01:49:26 -0500 (EST) +From: Bruce Momjian +Message-Id: <200312120649.hBC6nQR15608@candle.pha.pa.us> +Subject: fsync method checking +In-Reply-To: <3FD6B596.8090803@paradise.net.nz> +To: Mark Kirkwood +Date: Fri, 12 Dec 2003 01:49:26 -0500 (EST) +Cc: pgsql-performance@postgresql.org, + PostgreSQL-development +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary=ELM1071211762-12324-0_ +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/192 +X-Sequence-Number: 5052 + +--ELM1071211762-12324-0_ +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII + +Mark Kirkwood wrote: +> This is a well-worn thread title - apologies, but these results seemed +> interesting, and hopefully useful in the quest to get better performance +> on Solaris: +> +> I was curious to see if the rather uninspiring pgbench performance +> obtained from a Sun 280R (see General: ATA Disks and RAID controllers +> for database servers) could be improved if more time was spent +> tuning. +> +> With the help of a fellow workmate who is a bit of a Solaris guy, we +> decided to have a go. +> +> The major performance killer appeared to be mounting the filesystem with +> the logging option. The next most significant seemed to be the choice of +> sync_method for Pg - the default (open_datasync), which we initially +> thought should be the best - appears noticeably slower than fdatasync. + +I thought the default was fdatasync, but looking at the code it seems +the default is open_datasync if O_DSYNC is available. + +I assume the logic is that we usually do only one write() before +fsync(), so open_datasync should be faster. Why do we not use O_FSYNC +over fsync(). + +Looking at the code: + + #if defined(O_SYNC) + #define OPEN_SYNC_FLAG O_SYNC + #else + #if defined(O_FSYNC) + #define OPEN_SYNC_FLAG O_FSYNC + #endif + #endif + + #if defined(OPEN_SYNC_FLAG) + #if defined(O_DSYNC) && (O_DSYNC != OPEN_SYNC_FLAG) + #define OPEN_DATASYNC_FLAG O_DSYNC + #endif + #endif + + #if defined(OPEN_DATASYNC_FLAG) + #define DEFAULT_SYNC_METHOD_STR "open_datasync" + #define DEFAULT_SYNC_METHOD SYNC_METHOD_OPEN + #define DEFAULT_SYNC_FLAGBIT OPEN_DATASYNC_FLAG + #else + #if defined(HAVE_FDATASYNC) + #define DEFAULT_SYNC_METHOD_STR "fdatasync" + #define DEFAULT_SYNC_METHOD SYNC_METHOD_FDATASYNC + #define DEFAULT_SYNC_FLAGBIT 0 + #else + #define DEFAULT_SYNC_METHOD_STR "fsync" + #define DEFAULT_SYNC_METHOD SYNC_METHOD_FSYNC + #define DEFAULT_SYNC_FLAGBIT 0 + #endif + #endif + +I think the problem is that we prefer O_DSYNC over fdatasync, but do not +prefer O_FSYNC over fsync. + +Running the attached test program shows on BSD/OS 4.3: + + write 0.000360 + write & fsync 0.001391 + write, close & fsync 0.001308 + open o_fsync, write 0.000924 + +showing O_FSYNC faster than fsync(). + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +--ELM1071211762-12324-0_ +Content-Transfer-Encoding: 7bit +Content-Type: text/plain +Content-Disposition: inline; filename="/wrk/tmp/test_sync.c" + +/* + * test_fsync.c + * tests if fsync can be done from another process than the original write + */ + +#include +#include +#include +#include +#include +#include + +void die(char *str); +void print_elapse(struct timeval start_t, struct timeval elapse_t); + +int main(int argc, char *argv[]) +{ + struct timeval start_t; + struct timeval elapse_t; + int tmpfile; + char *strout = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + + /* write only */ + gettimeofday(&start_t, NULL); + if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT)) == -1) + die("can't open /var/tmp/test_fsync.out"); + write(tmpfile, &strout, 200); + close(tmpfile); + gettimeofday(&elapse_t, NULL); + unlink("/var/tmp/test_fsync.out"); + printf("write "); + print_elapse(start_t, elapse_t); + printf("\n"); + + /* write & fsync */ + gettimeofday(&start_t, NULL); + if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT)) == -1) + die("can't open /var/tmp/test_fsync.out"); + write(tmpfile, &strout, 200); + fsync(tmpfile); + close(tmpfile); + gettimeofday(&elapse_t, NULL); + unlink("/var/tmp/test_fsync.out"); + printf("write & fsync "); + print_elapse(start_t, elapse_t); + printf("\n"); + + /* write, close & fsync */ + gettimeofday(&start_t, NULL); + if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT)) == -1) + die("can't open /var/tmp/test_fsync.out"); + write(tmpfile, &strout, 200); + close(tmpfile); + /* reopen file */ + if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT)) == -1) + die("can't open /var/tmp/test_fsync.out"); + fsync(tmpfile); + close(tmpfile); + gettimeofday(&elapse_t, NULL); + unlink("/var/tmp/test_fsync.out"); + printf("write, close & fsync "); + print_elapse(start_t, elapse_t); + printf("\n"); + + /* open_fsync, write */ + gettimeofday(&start_t, NULL); + if ((tmpfile = open("/var/tmp/test_fsync.out", O_RDWR | O_CREAT | O_FSYNC)) == -1) + die("can't open /var/tmp/test_fsync.out"); + write(tmpfile, &strout, 200); + close(tmpfile); + gettimeofday(&elapse_t, NULL); + unlink("/var/tmp/test_fsync.out"); + printf("open o_fsync, write "); + print_elapse(start_t, elapse_t); + printf("\n"); + + return 0; +} + +void print_elapse(struct timeval start_t, struct timeval elapse_t) +{ + if (elapse_t.tv_usec < start_t.tv_usec) + { + elapse_t.tv_sec--; + elapse_t.tv_usec += 1000000; + } + + printf("%ld.%06ld", (long) (elapse_t.tv_sec - start_t.tv_sec), + (long) (elapse_t.tv_usec - start_t.tv_usec)); +} + +void die(char *str) +{ + fprintf(stderr, "%s", str); + exit(1); +} + +--ELM1071211762-12324-0_-- + +From pgsql-performance-owner@postgresql.org Fri Dec 12 03:47:23 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 52B20D1DE69 + for ; + Fri, 12 Dec 2003 07:47:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81363-10 + for ; + Fri, 12 Dec 2003 03:46:51 -0400 (AST) +Received: from serwer.skawsoft.com.pl (skawina.eu.org [80.48.213.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 8297CD1DE67 + for ; + Fri, 12 Dec 2003 03:46:48 -0400 (AST) +Received: from klaster.net (core-1.citynet.pl [80.48.135.69]) + by serwer.skawsoft.com.pl (Postfix) with ESMTP + id AF5A02B3CE; Fri, 12 Dec 2003 08:46:31 +0100 (CET) +Message-ID: <3FD9725D.9030304@klaster.net> +Date: Fri, 12 Dec 2003 08:46:37 +0100 +From: Tomasz Myrta +User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; + rv:1.5) Gecko/20031007 +X-Accept-Language: pl, en-us, en +MIME-Version: 1.0 +To: Aram Kananov +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Measuring execution time for sql called from PL/pgSQL +References: <1071191825.5163.164.camel@localhost.localdomain> +In-Reply-To: <1071191825.5163.164.camel@localhost.localdomain> +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/193 +X-Sequence-Number: 5053 + +Dnia 2003-12-12 02:17, U�ytkownik Aram Kananov napisa�: +> select localtimestamp into v; +> raise notice ''Timestamp: %'', v; + +Don't use localtimestamp, now() neither any transaction based time +function. They all return the same value among whole transaction. The +only time function, which can be used for performance tests is timeofday(). + +You can read more about time functions in manual. + +Regards, +Tomasz Myrta + + + + +From pgsql-performance-owner@postgresql.org Fri Dec 12 04:28:41 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B52BCD1DE81 + for ; + Fri, 12 Dec 2003 08:28:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 83925-10 + for ; + Fri, 12 Dec 2003 04:28:08 -0400 (AST) +Received: from conure.mail.pas.earthlink.net (conure.mail.pas.earthlink.net + [207.217.120.54]) + by svr1.postgresql.org (Postfix) with ESMTP id 93129D1DE69 + for ; + Fri, 12 Dec 2003 04:28:06 -0400 (AST) +Received: from hsa119.pool029.at101.earthlink.net ([216.249.98.119] + helo=shadovitzcmptr) + by conure.mail.pas.earthlink.net with smtp (Exim 3.33 #1) + id 1AUied-0004Zt-00 + for pgsql-performance@postgresql.org; Fri, 12 Dec 2003 00:28:07 -0800 +Received: by localhost with Microsoft MAPI; Fri, 12 Dec 2003 00:18:41 -0800 +Message-ID: <01C3C045.7EDD13C0.david@shadovitz.com> +From: David Shadovitz +Reply-To: "david@shadovitz.com" +To: "'pgsql-performance@postgresql.org'" +Subject: Query plan - now what? +Date: Fri, 12 Dec 2003 00:18:12 -0800 +X-Mailer: Microsoft Internet E-mail/MAPI - 8.0.0.4211 +MIME-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/194 +X-Sequence-Number: 5054 + +Well, now that I have the plan for my slow-running query, what do I do? Where +should I focus my attention? +Thanks. +-David + + +Hash Join (cost=16620.59..22331.88 rows=40133 width=266) (actual +time=118773.28..580889.01 rows=57076 loops=1) + -> Hash Join (cost=16619.49..21628.48 rows=40133 width=249) (actual +time=118771.29..535709.47 rows=57076 loops=1) + -> Hash Join (cost=16618.41..20724.39 rows=40133 width=240) (actual +time=118768.04..432327.82 rows=57076 loops=1) + -> Hash Join (cost=16617.34..19920.66 rows=40133 width=223) (actual +time=118764.67..340333.78 rows=57076 loops=l) + -> Hash Join (cost=16616.14..19217.14 rows=4Ol33 width=214) (actual +time=118761.38..258978.8l row=57076 loops=1) + -> Merge Join (cost=16615.07..18413.42 rows=40133 width=205) + (actual time=118758.74..187180.55 rows=57076 loops=i) + -> Index Scan using grf_grf_id_idx on giraffes (cost=O.O0..1115.61 +rows=53874 width=8) + (actual +time=2.37..6802.38 rows=57077 loops=l) + -> Sort (cost=l66l5.07..16615.07 rows=18554 width=197) (actual +time=118755.11..120261.06 rows=59416 loops=l) + -> Hash Join (cost=8126.08..14152.54 rows=18554 width=197) + (actual time=50615.72..l09853.7l rows=16310 loops=1) + -> Hash Join (cost=8124.39..12690.30 rows=24907 width=179) + (actual time=50607.36..86868.58 rows=iSBiS loops=1) + -> Hash Join (cost=249.26..2375.23 rows=24907 width=131) + (actual time=23476.42..35107.80 rows=16310 loops=l) + -> Nested Loop (cost=248.2l..1938.31 rows=24907 width=118) + (actual time=23474.70..28155.13 rows=16310 loops=1) + -> Seq Scan on zebras (cost=0.00..l.0l rows=l width=14) + (actual time=O.64..0.72 rows=1 ioops=1) + -> Materialize (cost=1688.23..l688.23 rows=24907 width=104) + (actual time=23473.77..23834.26 rows=16310 loops=l) + -> Hash Join (cost=248.21..1688.23 rows=24907 width=lO4) + (actual time=1199.26..23059.92 rows=16310 loops=l) + -> Seq Scan on frogs (cost=0.00..755.07 rows=24907 width=83) + (actual time=0.53..4629.58 rows=25702 +loops=l) + -> Hash (cost=225.57..225.57 rows=9057 width=21) + (actual time=1198.0l..1198.01 rows=0 loops=1) + -> Seq Scan on tigers (cost=0.00..225.57 rows=9057 width=21) + (actual time=0.39..892.67 rows=9927 +loops=1) + -> Hash (cost=l.O4..1.-4 rows=4 width=13) (actual time=l.07..1.07 +rows=0 loops=1) + -> Seq Scan on deers (cost=0.0O..1.04 rows=4 width=13) + (actual time=0.64..0.95 rows=4 loops=1) + -> Hash (cost=4955.28..4955.28 rows=91528 width=48) + (actual tlne=27O40.82..27040.82 rows=0 loops=1) + -> Seq Scan on warthogs (cost=0.00..4955.28 rows=91528 width=48) + (actual time=3.92..24031.27 rows=91528 +loops=1) + -> Hash (cost=1.55..1.55 rows=55 width=18) (actual time=7.l3..7.13 +rows=0 loops=1) + -> Seq Scan on monkeys (cost=0.00..l.55 rows=55 width=18) + (actual time=0.64..5.38 rows=55 loops=1) + -> Hash (cost=l.O5..1.05 rows=S width=9) (actual time=1.16..l.l6 rows=0 +loops=1) + -> Seq Scan on worms (cost=0.00..1.05 rows=S width=9) (actual +time=0.65..1.00 rows=5 loops=1) + -> Hash (cost=1.16..1.16 rows=16 width=9) (actual time=l.86..1.86 rows=0 +loops=1) + -> Seq Scan on lions (cost=0.00..l.16 rows=16 width=9) (actual +time=0.lO..1.36 rows=16 loops=1) + -> Hash (cost=1.06..1.06 rows=6 width=17) (actual time=1.35..1.35 rows=0 +loops=1) + -> Seq Scan on dogs (cost=0.00..1.06 rows=6 width=17) (actual +time=0.65..1.16 rows=6 loops=l) + -> Hash (cost=1.07..1.07 rows=3 width=9) (actual time=1.23..1.23 rows=0 +loops=1) + -> Seq Scan on parrots (cost=0.00..1.07 rows=3 width=9) (actual +time=0.69..1.13 rows=3 loops=1) + -> Hash (cost=l.08..1.08 rows=8 width=17) (actual time=0.98..0.98 rows=0 +loops=1) + -> Seq Scan on rhinos (cost=0.00..1.08 rows=8 width=17) (actual +time=0.10..0.73 rows=8 loops=1) + +Total runtime: 58l341.00 msec + + +From pgsql-performance-owner@postgresql.org Fri Dec 12 05:14:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A25E7D1DE82 + for ; + Fri, 12 Dec 2003 09:14:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 91701-08 + for ; + Fri, 12 Dec 2003 05:14:13 -0400 (AST) +Received: from smtp.pspl.co.in (unknown [202.54.11.65]) + by svr1.postgresql.org (Postfix) with ESMTP id 59238D1B554 + for ; + Fri, 12 Dec 2003 05:14:10 -0400 (AST) +Received: (from root@localhost) + by smtp.pspl.co.in (8.12.9/8.12.9) id hBC9EHe3010031 + for ; Fri, 12 Dec 2003 14:44:17 +0530 +Received: from persistent.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) + (authenticated bits=0) + by persistent.co.in (8.12.9/8.12.9) with ESMTP id hBC9EEAo009969; + Fri, 12 Dec 2003 14:44:15 +0530 +Message-ID: <3FD986DD.7000909@persistent.co.in> +Date: Fri, 12 Dec 2003 14:44:05 +0530 +From: Shridhar Daithankar +Organization: Persistent Systems Pvt. Ltd. +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "david@shadovitz.com" +Cc: "'pgsql-performance@postgresql.org'" +Subject: Re: Query plan - now what? +References: <01C3C045.7EDD13C0.david@shadovitz.com> +In-Reply-To: <01C3C045.7EDD13C0.david@shadovitz.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/195 +X-Sequence-Number: 5055 + +David Shadovitz wrote: + +> Well, now that I have the plan for my slow-running query, what do I do? Where +> should I focus my attention? + +Briefly looking over the plan and seeing the estimated v/s actual row mismatch,I +can suggest you following. + +1. Vacuum(full) the database. Probably you have already done it. +2. Raise statistics_target to 500 or more and reanalyze the table(s) in question. +3. Set enable_hash_join to false, before running the query and see if it helps. + + HTH + + Shridhar + +From pgsql-performance-owner@postgresql.org Fri Dec 12 06:49:12 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CC7D8D1B456 + for ; + Fri, 12 Dec 2003 10:49:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 02299-07 + for ; + Fri, 12 Dec 2003 06:48:41 -0400 (AST) +Received: from smtp02do.de.uu.net (smtp02do.de.uu.net [192.76.144.69]) + by svr1.postgresql.org (Postfix) with ESMTP id 27958D1B442 + for ; + Fri, 12 Dec 2003 06:48:37 -0400 (AST) +Received: from bommel.kecam-han.de ([193.99.158.1]) + by smtp02do.de.uu.net (8.9.3p2/5.5.5) with ESMTP id LAA07894 + for ; + Fri, 12 Dec 2003 11:48:38 +0100 (MET) +Received: from mailrelay.kecam-han.de (ldap [10.9.1.54]) + by bommel.kecam-han.de (8.11.6+Sun/8.9.1) with ESMTP id hBCAmx616545 + for ; + Fri, 12 Dec 2003 11:48:59 +0100 (MET) +Received: from ke-elektronik.de (localhost [127.0.0.1]) + by mailrelay.kecam-han.de (8.12.2/8.12.2) with ESMTP id hBCAltUr012470 + for ; + Fri, 12 Dec 2003 11:48:15 +0100 (MET) +Message-ID: <3FD99CDA.8161D80A@ke-elektronik.de> +Date: Fri, 12 Dec 2003 11:47:54 +0100 +From: Hartmut Raschick +Organization: ke Kommunikations-Elektronik GmbH +X-Mailer: Mozilla 4.79 [en] (X11; U; SunOS 5.6 sun4u) +X-Accept-Language: de, ru, en +MIME-Version: 1.0 +To: psqlperformace +Subject: Re: TRUNCATE veeeery slow compared to DELETE in 7.4 +References: <3FD484B6.EF39A92F@ke-elektronik.de> + <200312100918.02501.josh@agliodbs.com> + <8000.1071086054@sss.pgh.pa.us> +Content-Type: multipart/mixed; boundary="------------59882B14BEB9053A486EE494" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/196 +X-Sequence-Number: 5056 + +This is a multi-part message in MIME format. +--------------59882B14BEB9053A486EE494 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + +for the clearer understanding: this is NOT about TRUNCATE being +slow "as such" vs. DELETE, but about a change in the order of +a (...) magnitude from 7.3.4 to 7.4... + +here's some more info, plus test results w/a "full" db: + +300 tables, 20000 pieces of modelled hw, so there's one table +w/20000 entries, each model has a special table (per type), too; +so, entries over all of them sum up to 20000; not all types are +present. +plus: some types (w/not many instances) have "very special" tables, +too, these sometimes w/lots of columns 500-1600... + +alone on a sun fire-280 w/2 U-IIIi cpu's (well, only need one...): +all the time of the test, no vacuum anything was performed, +thus - by the book - making things worse... for the DELETE case. + +7.4: +---- +"full" database: +TRUNCATE: 0.03u 0.03s 1:21.40 0.0% +DELETE: 0.05u 0.01s 0:04.46 1.3% + +empty database: +TRUNCATE:0.02u 0.05s 1:21.00 0.0% +DELETE: 0.04u 0.04s 0:01.32 6.0% + +now for 7.3.4 database server (same machine, of cause): +-------------- +"full" database: +TRUNCATE: 0.04u 0.04s 0:03.79 2.1% +DELETE: 0.03u 0.03s 0:06.51 0.9% + +empty database: +TRUNCATE: 0.04u 0.05s 0:01.51 5.9% +DELETE: 0.01u 0.02s 0:01.00 3.0% + +what can i say... +...please find the attached configs. + +i reeeeally don't think this can be explained by table/index +complexity, it's the _same_ schema and contents for both cases, +they both were started w/createdb, they both were filled the same +way (by our server prog), there was no vacuum nowhere, test execution +order was the same in both cases. + +P.S.: Mon pessimisme va jusqu'=E0 suspecter la sinc=E9rit=E9 des pessimiste= +s. + - Jean Rostand (1894-1977), Journal d'un caract=E8re, 1931 + +--=20 +Hartmut "Hardy" Raschick / Dept. t2 +ke Kommunikations-Elektronik GmbH +Wohlenberstr. 3, 30179 Hannover +Phone: ++49 (0)511 6747-564 +Fax: ++49 (0)511 6747-340 +e-Mail: hartmut.raschick@ke-elektronik.de +http://www.ke-elektronik.de +--------------59882B14BEB9053A486EE494 +Content-Type: text/plain; charset=us-ascii; + name="postgresql.conf-7.3.4" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline; + filename="postgresql.conf-7.3.4" + +# +# 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". + + +#======================================================================== + + +# +# Connection Parameters +# +#tcpip_socket = false +tcpip_socket = true +#ssl = false + +#max_connections = 32 +max_connections = 128 +#superuser_reserved_connections = 2 + +#port = 5432 +port = 5433 +#hostname_lookup = false +#show_source_port = false + +#unix_socket_directory = '' +#unix_socket_group = '' +#unix_socket_permissions = 0777 # octal + +#virtual_host = '' + +#krb_server_keyfile = '' + + +# +# Shared Memory Size +# +#shared_buffers = 64 # min max_connections*2 or 16, 8KB each +shared_buffers = 256 # 2*max_connections, min 16, typically 8KB each +#max_fsm_relations = 1000 # min 10, fsm is free space map, ~40 bytes +#max_fsm_pages = 10000 # min 1000, fsm is free space map, ~6 bytes +max_fsm_pages = 50000 # min 1000, fsm is free space map, ~6 bytes +#max_locks_per_transaction = 64 # min 10 +#wal_buffers = 8 # min 4, typically 8KB each +wal_buffers = 40 # min 4, typically 8KB each + +# +# Non-shared Memory Sizes +# +#sort_mem = 1024 # min 64, size in KB +sort_mem = 16384 # min 64, size in KB +#vacuum_mem = 8192 # min 1024, size in KB +vacuum_mem = 16384 # min 1024, size in KB + + +# +# Write-ahead log (WAL) +# +#checkpoint_segments = 3 # in logfile segments, min 1, 16MB each +checkpoint_segments = 20 # in logfile segments, min 1, 16MB each +#checkpoint_timeout = 300 # range 30-3600, in seconds +checkpoint_timeout = 600 # range 30-3600, in seconds +# +#commit_delay = 0 # range 0-100000, in microseconds +commit_delay = 100000 # range 0-100000, in microseconds +#commit_siblings = 5 # range 1-1000 +commit_siblings = 100 # range 1-1000 +# +#fsync = true +fsync = false +#wal_sync_method = fsync # the default varies across platforms: +wal_sync_method = fdatasync # the default varies across platforms: +# # fsync, fdatasync, open_sync, or open_datasync +#wal_debug = 0 # range 0-16 + + +# +# Optimizer Parameters +# +#enable_seqscan = true +enable_seqscan = false +#enable_indexscan = true +#enable_tidscan = true +#enable_sort = true +#enable_nestloop = true +#enable_mergejoin = true +#enable_hashjoin = true + +#effective_cache_size = 1000 # typically 8KB each +#random_page_cost = 4 # units are one sequential page fetch cost +#cpu_tuple_cost = 0.01 # (same) +#cpu_index_tuple_cost = 0.001 # (same) +#cpu_operator_cost = 0.0025 # (same) + +#default_statistics_target = 10 # range 1-1000 + +# +# GEQO Optimizer Parameters +# +#geqo = true +#geqo_selection_bias = 2.0 # range 1.5-2.0 +#geqo_threshold = 11 +#geqo_pool_size = 0 # default based on tables in statement, + # range 128-1024 +#geqo_effort = 1 +#geqo_generations = 0 +#geqo_random_seed = -1 # auto-compute seed + + +# +# Message display +# +#server_min_messages = notice # Values, in order of decreasing detail: + # debug5, debug4, debug3, debug2, debug1, + # info, notice, warning, error, log, fatal, + # panic +#client_min_messages = notice # Values, in order of decreasing detail: + # debug5, debug4, debug3, debug2, debug1, + # log, info, notice, warning, error +#silent_mode = false + +#log_connections = false +log_connections = true +#log_pid = false +#log_statement = false +#log_duration = false +#log_timestamp = false + +#log_min_error_statement = error # Values in order of increasing severity: + # debug5, debug4, debug3, debug2, debug1, + # info, notice, warning, error, panic(off) + +#debug_print_parse = false +#debug_print_rewritten = false +#debug_print_plan = false +#debug_pretty_print = false + +#explain_pretty_print = true + +# requires USE_ASSERT_CHECKING +#debug_assertions = true + + +# +# Syslog +# +#syslog = 0 # range 0-2 +#syslog_facility = 'LOCAL0' +#syslog_ident = 'postgres' + + +# +# Statistics +# +#show_parser_stats = false +#show_planner_stats = false +#show_executor_stats = false +#show_statement_stats = false + +# requires BTREE_BUILD_STATS +#show_btree_build_stats = false + + +# +# Access statistics collection +# +#stats_start_collector = true +#stats_reset_on_server_start = true +#stats_command_string = false +#stats_row_level = false +#stats_block_level = false + + +# +# Lock Tracing +# +#trace_notify = false + +# requires LOCK_DEBUG +#trace_locks = false +#trace_userlocks = false +#trace_lwlocks = false +#debug_deadlocks = false +#trace_lock_oidmin = 16384 +#trace_lock_table = 0 + + +# +# Misc +# +#autocommit = true +#dynamic_library_path = '$libdir' +#search_path = '$user,public' +#datestyle = 'iso, us' +#timezone = unknown # actually, defaults to TZ environment setting +#australian_timezones = false +#client_encoding = sql_ascii # actually, defaults to database encoding +#authentication_timeout = 60 # 1-600, in seconds +#deadlock_timeout = 1000 # in milliseconds +#default_transaction_isolation = 'read committed' +#max_expr_depth = 10000 # min 10 +#max_files_per_process = 1000 # min 25 +#password_encryption = true +#sql_inheritance = true +#transform_null_equals = false +#statement_timeout = 0 # 0 is disabled, in milliseconds +#db_user_namespace = false + + + + + +# +# Locale settings +# +# (initialized by initdb -- may be changed) +LC_MESSAGES = 'C' +LC_MONETARY = 'en_US.ISO8859-15' +LC_NUMERIC = 'en_US.ISO8859-15' +LC_TIME = 'en_US.ISO8859-15' + +--------------59882B14BEB9053A486EE494 +Content-Type: text/plain; charset=us-ascii; + name="postgresql.conf-7.4" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline; + filename="postgresql.conf-7.4" + +# ----------------------------- +# PostgreSQL configuration file +# ----------------------------- +# +# This file consists of lines of the form: +# +# name = value +# +# (The '=' is optional.) White space may be used. Comments are introduced +# with '#' anywhere on a line. The complete list of option names and +# allowed values can be found in the PostgreSQL documentation. The +# commented-out settings shown in this file represent the default values. +# +# Any option can also be given as a command line switch to the +# postmaster, e.g. 'postmaster -c log_connections=on'. Some options +# can be changed at run-time with the 'SET' SQL command. +# +# This file is read on postmaster startup and when the postmaster +# receives a SIGHUP. If you edit the file on a running system, you have +# to SIGHUP the postmaster for the changes to take effect, or use +# "pg_ctl reload". + + +#--------------------------------------------------------------------------- +# CONNECTIONS AND AUTHENTICATION +#--------------------------------------------------------------------------- + +# - Connection Settings - + +#tcpip_socket = false +tcpip_socket = true +max_connections = 128 + # note: increasing max_connections costs about 500 bytes of shared + # memory per connection slot, in addition to costs from shared_buffers + # and max_locks_per_transaction. +#superuser_reserved_connections = 2 +#port = 5432 +port = 5474 +#unix_socket_directory = '' +#unix_socket_group = '' +#unix_socket_permissions = 0777 # octal +#virtual_host = '' # what interface to listen on; defaults to any +#rendezvous_name = '' # defaults to the computer name + +# - Security & Authentication - + +#authentication_timeout = 60 # 1-600, in seconds +#ssl = false +#password_encryption = true +#krb_server_keyfile = '' +#db_user_namespace = false + + +#--------------------------------------------------------------------------- +# RESOURCE USAGE (except WAL) +#--------------------------------------------------------------------------- + +# - Memory - + +shared_buffers = 1024 # min 16, at least max_connections*2, 8KB each +#sort_mem = 1024 # min 64, size in KB +sort_mem = 16384 # min 64, size in KB +#vacuum_mem = 8192 # min 1024, size in KB +vacuum_mem = 16384 # min 1024, size in KB + +# - Free Space Map - + +#max_fsm_pages = 20000 # min max_fsm_relations*16, 6 bytes each +max_fsm_pages = 50000 # min max_fsm_relations*16, 6 bytes each +#max_fsm_relations = 1000 # min 100, ~50 bytes each + +# - Kernel Resource Usage - + +#max_files_per_process = 1000 # min 25 +#preload_libraries = '' + + +#--------------------------------------------------------------------------- +# WRITE AHEAD LOG +#--------------------------------------------------------------------------- + +# - Settings - + +#fsync = true # turns forced synchronization on or off +fsync = false # turns forced synchronization on or off +#wal_sync_method = fsync # the default varies across platforms: +wal_sync_method = fdatasync # the default varies across platforms: + # fsync, fdatasync, open_sync, or open_datasync +#wal_buffers = 8 # min 4, 8KB each +wal_buffers = 40 # min 4, 8KB each + +# - Checkpoints - + +#checkpoint_segments = 3 # in logfile segments, min 1, 16MB each +checkpoint_segments = 20 # in logfile segments, min 1, 16MB each +#checkpoint_timeout = 300 # range 30-3600, in seconds +checkpoint_timeout = 600 # range 30-3600, in seconds +#checkpoint_warning = 30 # 0 is off, in seconds +#commit_delay = 0 # range 0-100000, in microseconds +commit_delay = 100000 # range 0-100000, in microseconds +#commit_siblings = 5 # range 1-1000 +commit_siblings = 100 # 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_seqscan = false +#enable_sort = true +#enable_tidscan = true + +# - Planner Cost Constants - + +#effective_cache_size = 1000 # typically 8KB each +#random_page_cost = 4 # units are one sequential page fetch cost +#cpu_tuple_cost = 0.01 # (same) +#cpu_index_tuple_cost = 0.001 # (same) +#cpu_operator_cost = 0.0025 # (same) + +# - Genetic Query Optimizer - + +#geqo = true +#geqo_threshold = 11 +#geqo_effort = 1 +#geqo_generations = 0 +#geqo_pool_size = 0 # default based on tables in statement, + # range 128-1024 +#geqo_selection_bias = 2.0 # range 1.5-2.0 + +# - Other Planner Options - + +#default_statistics_target = 10 # range 1-1000 +#from_collapse_limit = 8 +#join_collapse_limit = 8 # 1 disables collapsing of explicit JOINs + + +#--------------------------------------------------------------------------- +# ERROR REPORTING AND LOGGING +#--------------------------------------------------------------------------- + +# - Syslog - + +#syslog = 0 # range 0-2; 0=stdout; 1=both; 2=syslog +#syslog_facility = 'LOCAL0' +#syslog_ident = 'postgres' + +# - When to Log - + +#client_min_messages = notice # Values, in order of decreasing detail: + # debug5, debug4, debug3, debug2, debug1, + # log, info, notice, warning, error + +#log_min_messages = notice # Values, in order of decreasing detail: + # debug5, debug4, debug3, debug2, debug1, + # info, notice, warning, error, log, fatal, + # panic + +#log_error_verbosity = default # terse, default, or verbose messages + +#log_min_error_statement = panic # Values in order of increasing severity: + # debug5, debug4, debug3, debug2, debug1, + # info, notice, warning, error, panic(off) + +#log_min_duration_statement = -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_connections = true +#log_duration = false +#log_pid = false +#log_statement = false +#log_timestamp = false +#log_hostname = false +#log_source_port = false + + +#--------------------------------------------------------------------------- +# RUNTIME STATISTICS +#--------------------------------------------------------------------------- + +# - Statistics Monitoring - + +#log_parser_stats = false +#log_planner_stats = false +#log_executor_stats = false +#log_statement_stats = false + +# - Query/Index Statistics Collector - + +#stats_start_collector = true +#stats_command_string = false +#stats_block_level = false +#stats_row_level = false +#stats_reset_on_server_start = true + + +#--------------------------------------------------------------------------- +# CLIENT CONNECTION DEFAULTS +#--------------------------------------------------------------------------- + +# - Statement Behavior - + +#search_path = '$user,public' # schema names +#check_function_bodies = true +#default_transaction_isolation = 'read committed' +#default_transaction_read_only = false +#statement_timeout = 0 # 0 is disabled, in milliseconds + +# - Locale and Formatting - + +#datestyle = 'iso, mdy' +#timezone = unknown # actually, defaults to TZ environment setting +#australian_timezones = false +#extra_float_digits = 0 # min -15, max 2 +#client_encoding = sql_ascii # actually, defaults to database encoding + +# These settings are initialized by initdb -- they may be changed +lc_messages = 'C' # locale for system error message strings +lc_monetary = 'en_US.ISO8859-15' # locale for monetary formatting +lc_numeric = 'en_US.ISO8859-15' # locale for number formatting +lc_time = 'en_US.ISO8859-15' # locale for time formatting + +# - Other Defaults - + +#explain_pretty_print = true +#dynamic_library_path = '$libdir' +#max_expr_depth = 10000 # min 10 + +#--------------------------------------------------------------------------- +# LOCK MANAGEMENT +#--------------------------------------------------------------------------- + +#deadlock_timeout = 1000 # in milliseconds +#max_locks_per_transaction = 64 # min 10, ~260*max_connections bytes each + + +#--------------------------------------------------------------------------- +# VERSION/PLATFORM COMPATIBILITY +#--------------------------------------------------------------------------- + +# - Previous Postgres Versions - + +#add_missing_from = true +#regex_flavor = advanced # advanced, extended, or basic +#sql_inheritance = true + +# - Other Platforms & Clients - + +#transform_null_equals = false + +--------------59882B14BEB9053A486EE494-- + + +From pgsql-performance-owner@postgresql.org Tue Dec 16 17:15:35 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id D2FD8D1B45C; Fri, 12 Dec 2003 12:22:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08050-05; Fri, 12 Dec 2003 08:22:13 -0400 (AST) +Received: from smxsat1.smxs.net (smxsat1.smxs.net [213.150.10.1]) + by svr1.postgresql.org (Postfix) with ESMTP + id DD1F7D1B454; Fri, 12 Dec 2003 08:22:07 -0400 (AST) +Received: from m01x1.s-mxs.net [10.3.55.201] by smxsat1.smxs.net + over TLS secured channel with XWall v3.28f ; + Fri, 12 Dec 2003 13:22:03 +0100 +Received: from m0102.s-mxs.net [10.3.55.2] by m01x1.s-mxs.net + with XWall v3.28f ; Fri, 12 Dec 2003 13:22:01 +0100 +Received: from m0114.s-mxs.net ([10.3.55.14]) by m0102.s-mxs.net with + Microsoft SMTPSVC(5.0.2195.5329); Fri, 12 Dec 2003 13:22:01 +0100 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6503.0 +content-class: urn:content-classes:message +Subject: Re: [HACKERS] fsync method checking +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----_=_NextPart_001_01C3C0AA.8B1026A5" +Date: Fri, 12 Dec 2003 13:22:00 +0100 +Message-ID: <46C15C39FEB2C44BA555E356FBCD6FA40184CF68@m0114.s-mxs.net> +X-MS-Has-Attach: yes +X-MS-TNEF-Correlator: +Thread-Topic: [HACKERS] fsync method checking +Thread-Index: AcPAfH+RrTtfj1bcTvGhyP/wCNch4gAJ4azQ +From: "Zeugswetter Andreas SB SD" +To: "Bruce Momjian" , + "Mark Kirkwood" +Cc: , + "PostgreSQL-development" +X-OriginalArrivalTime: 12 Dec 2003 12:22:01.0144 (UTC) + FILETIME=[8B5A7380:01C3C0AA] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/238 +X-Sequence-Number: 5098 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C3C0AA.8B1026A5 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + +> Running the attached test program shows on BSD/OS 4.3: +>=20 +> write 0.000360 +> write & fsync 0.001391 + +I think the "write & fsync" pays for the previous "write" test (same filena= +me). + +> write, close & fsync 0.001308 +> open o_fsync, write 0.000924 + +I have tried to modify the program to more closely resemble WAL=20 +writes (all writes to WAL are 8k), the file is usually already open,=20 +and test larger (16k) transactions. + +zeu@a82101002:~> test_sync1 +write 0.000625 +write & fsync 0.016748 +write & fdatasync 0.006650 +write, close & fsync 0.017084 +write, close & fdatasync 0.006890 +open o_dsync, write 0.015997 +open o_dsync, one write 0.007128 + +For the last line xlog.c would need to be modified, but the measurements +seem to imply that it is only worth it on platforms that have O_DSYNC +but not fdatasync.=20=20 + +Andreas + +------_=_NextPart_001_01C3C0AA.8B1026A5 +Content-Type: application/octet-stream; + name="test_sync1.c" +Content-Transfer-Encoding: base64 +Content-Description: test_sync1.c +Content-Disposition: attachment; + filename="test_sync1.c" + +LyoNCiAqCXRlc3RfZnN5bmMuYw0KICoJCXRlc3RzIGlmIGZzeW5jIGNhbiBi +ZSBkb25lIGZyb20gYW5vdGhlciBwcm9jZXNzIHRoYW4gdGhlIG9yaWdpbmFs +IHdyaXRlDQogKi8NCg0KI2luY2x1ZGUgPHN5cy90eXBlcy5oPg0KI2luY2x1 +ZGUgPGZjbnRsLmg+DQojaW5jbHVkZSA8c3RkaW8uaD4NCiNpbmNsdWRlIDxz +dGRsaWIuaD4NCiNpbmNsdWRlIDx0aW1lLmg+DQojaW5jbHVkZSA8dW5pc3Rk +Lmg+DQoNCnZvaWQgZGllKGNoYXIgKnN0cik7DQp2b2lkIHByaW50X2VsYXBz +ZShzdHJ1Y3QgdGltZXZhbCBzdGFydF90LCBzdHJ1Y3QgdGltZXZhbCBlbGFw +c2VfdCk7DQoNCmludCBtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pDQp7 +DQoJc3RydWN0IHRpbWV2YWwgc3RhcnRfdDsNCglzdHJ1Y3QgdGltZXZhbCBl +bGFwc2VfdDsNCglpbnQgdG1wZmlsZSwgaTsNCgljaGFyICpzdHJvdXQgPSAo +Y2hhciAqKSBtYWxsb2MoNjU1MzYpOyAgDQoNCglmb3IgKGk9MDsgaTw2NTUz +NjsgaSsrKQ0KCQlzdHJvdXRbaV0gPSAnYSc7DQoNCglpZiAoKHRtcGZpbGUg +PSBvcGVuKCIvdmFyL3RtcC90ZXN0X2ZzeW5jLm91dCIsIE9fUkRXUiB8IE9f +Q1JFQVQsIFNfSVJVU1IgfCBTX0lXVVNSKSkgPT0gLTEpDQoJCWRpZSgiY2Fu +J3Qgb3BlbiAvdmFyL3RtcC90ZXN0X2ZzeW5jLm91dCIpOw0KCXdyaXRlKHRt +cGZpbGUsIHN0cm91dCwgNjU1MzYpOw0KCWZzeW5jKHRtcGZpbGUpOw0KCWNs +b3NlKHRtcGZpbGUpOwkJDQoNCgkvKiB3cml0ZSBvbmx5ICovCQ0KCWlmICgo +dG1wZmlsZSA9IG9wZW4oIi92YXIvdG1wL3Rlc3RfZnN5bmMub3V0IiwgT19S +RFdSKSkgPT0gLTEpDQoJCWRpZSgiY2FuJ3Qgb3BlbiAvdmFyL3RtcC90ZXN0 +X2ZzeW5jLm91dCIpOw0KCWdldHRpbWVvZmRheSgmc3RhcnRfdCwgTlVMTCk7 +DQoJd3JpdGUodG1wZmlsZSwgc3Ryb3V0LCA4MTkyKTsNCgl3cml0ZSh0bXBm +aWxlLCBzdHJvdXQsIDgxOTIpOw0KCWdldHRpbWVvZmRheSgmZWxhcHNlX3Qs +IE5VTEwpOw0KCWNsb3NlKHRtcGZpbGUpOwkJDQoJcHJpbnRmKCJ3cml0ZSAg +ICAgICAgICAgICAgICAgICAgICAiKTsNCglwcmludF9lbGFwc2Uoc3RhcnRf +dCwgZWxhcHNlX3QpOw0KCXByaW50ZigiXG4iKTsNCg0KCWlmICgodG1wZmls +ZSA9IG9wZW4oIi92YXIvdG1wL3Rlc3RfZnN5bmMub3V0IiwgT19SRFdSKSkg +PT0gLTEpDQoJCWRpZSgiY2FuJ3Qgb3BlbiAvdmFyL3RtcC90ZXN0X2ZzeW5j +Lm91dCIpOw0KCWZzeW5jKHRtcGZpbGUpOw0KCWNsb3NlKHRtcGZpbGUpOwkJ +DQoNCgkvKiB3cml0ZSAmIGZzeW5jICovDQoJaWYgKCh0bXBmaWxlID0gb3Bl +bigiL3Zhci90bXAvdGVzdF9mc3luYy5vdXQiLCBPX1JEV1IpKSA9PSAtMSkN +CgkJZGllKCJjYW4ndCBvcGVuIC92YXIvdG1wL3Rlc3RfZnN5bmMub3V0Iik7 +DQoJZ2V0dGltZW9mZGF5KCZzdGFydF90LCBOVUxMKTsNCgl3cml0ZSh0bXBm +aWxlLCBzdHJvdXQsIDgxOTIpOw0KCXdyaXRlKHRtcGZpbGUsIHN0cm91dCwg +ODE5Mik7DQoJZnN5bmModG1wZmlsZSk7DQoJZ2V0dGltZW9mZGF5KCZlbGFw +c2VfdCwgTlVMTCk7DQoJY2xvc2UodG1wZmlsZSk7CQkNCglwcmludGYoIndy +aXRlICYgZnN5bmMgICAgICAgICAgICAgICIpOw0KCXByaW50X2VsYXBzZShz +dGFydF90LCBlbGFwc2VfdCk7DQoJcHJpbnRmKCJcbiIpOw0KDQoJLyogd3Jp +dGUgJiBmZGF0YXN5bmMgKi8NCglpZiAoKHRtcGZpbGUgPSBvcGVuKCIvdmFy +L3RtcC90ZXN0X2ZzeW5jLm91dCIsIE9fUkRXUikpID09IC0xKQ0KCQlkaWUo +ImNhbid0IG9wZW4gL3Zhci90bXAvdGVzdF9mc3luYy5vdXQiKTsNCglnZXR0 +aW1lb2ZkYXkoJnN0YXJ0X3QsIE5VTEwpOw0KCXdyaXRlKHRtcGZpbGUsIHN0 +cm91dCwgODE5Mik7DQoJd3JpdGUodG1wZmlsZSwgc3Ryb3V0LCA4MTkyKTsN +CglmZGF0YXN5bmModG1wZmlsZSk7DQoJZ2V0dGltZW9mZGF5KCZlbGFwc2Vf +dCwgTlVMTCk7DQoJY2xvc2UodG1wZmlsZSk7CQkNCglwcmludGYoIndyaXRl +ICYgZmRhdGFzeW5jICAgICAgICAgICIpOw0KCXByaW50X2VsYXBzZShzdGFy +dF90LCBlbGFwc2VfdCk7DQoJcHJpbnRmKCJcbiIpOw0KDQoJaWYgKCh0bXBm +aWxlID0gb3BlbigiL3Zhci90bXAvdGVzdF9mc3luYy5vdXQiLCBPX1JEV1Ip +KSA9PSAtMSkNCgkJZGllKCJjYW4ndCBvcGVuIC92YXIvdG1wL3Rlc3RfZnN5 +bmMub3V0Iik7DQoJZnN5bmModG1wZmlsZSk7DQoJY2xvc2UodG1wZmlsZSk7 +CQkNCg0KCS8qIHdyaXRlLCBjbG9zZSAmIGZzeW5jICovDQoJaWYgKCh0bXBm +aWxlID0gb3BlbigiL3Zhci90bXAvdGVzdF9mc3luYy5vdXQiLCBPX1JEV1Ip +KSA9PSAtMSkNCgkJZGllKCJjYW4ndCBvcGVuIDEgL3Zhci90bXAvdGVzdF9m +c3luYy5vdXQiKTsNCglnZXR0aW1lb2ZkYXkoJnN0YXJ0X3QsIE5VTEwpOw0K +CXdyaXRlKHRtcGZpbGUsIHN0cm91dCwgODE5Mik7DQoJd3JpdGUodG1wZmls +ZSwgc3Ryb3V0LCA4MTkyKTsNCgljbG9zZSh0bXBmaWxlKTsNCgkvKiByZW9w +ZW4gZmlsZSAqLw0KCWlmICgodG1wZmlsZSA9IG9wZW4oIi92YXIvdG1wL3Rl +c3RfZnN5bmMub3V0IiwgT19SRFdSKSkgPT0gLTEpDQoJCWRpZSgiY2FuJ3Qg +b3BlbiAyIC92YXIvdG1wL3Rlc3RfZnN5bmMub3V0Iik7DQoJZnN5bmModG1w +ZmlsZSk7DQoJY2xvc2UodG1wZmlsZSk7CQkNCglnZXR0aW1lb2ZkYXkoJmVs +YXBzZV90LCBOVUxMKTsNCglwcmludGYoIndyaXRlLCBjbG9zZSAmIGZzeW5j +ICAgICAgICIpOw0KCXByaW50X2VsYXBzZShzdGFydF90LCBlbGFwc2VfdCk7 +DQoJcHJpbnRmKCJcbiIpOw0KDQoJLyogd3JpdGUsIGNsb3NlICYgZmRhdGFz +eW5jICovDQoJaWYgKCh0bXBmaWxlID0gb3BlbigiL3Zhci90bXAvdGVzdF9m +c3luYy5vdXQiLCBPX1JEV1IpKSA9PSAtMSkNCgkJZGllKCJjYW4ndCBvcGVu +IDEgL3Zhci90bXAvdGVzdF9mc3luYy5vdXQiKTsNCglnZXR0aW1lb2ZkYXko +JnN0YXJ0X3QsIE5VTEwpOw0KCXdyaXRlKHRtcGZpbGUsIHN0cm91dCwgODE5 +Mik7DQoJd3JpdGUodG1wZmlsZSwgc3Ryb3V0LCA4MTkyKTsNCgljbG9zZSh0 +bXBmaWxlKTsNCgkvKiByZW9wZW4gZmlsZSAqLw0KCWlmICgodG1wZmlsZSA9 +IG9wZW4oIi92YXIvdG1wL3Rlc3RfZnN5bmMub3V0IiwgT19SRFdSKSkgPT0g +LTEpDQoJCWRpZSgiY2FuJ3Qgb3BlbiAyIC92YXIvdG1wL3Rlc3RfZnN5bmMu +b3V0Iik7DQoJZmRhdGFzeW5jKHRtcGZpbGUpOw0KCWdldHRpbWVvZmRheSgm +ZWxhcHNlX3QsIE5VTEwpOw0KCWNsb3NlKHRtcGZpbGUpOwkJDQoJcHJpbnRm +KCJ3cml0ZSwgY2xvc2UgJiBmZGF0YXN5bmMgICAiKTsNCglwcmludF9lbGFw +c2Uoc3RhcnRfdCwgZWxhcHNlX3QpOw0KCXByaW50ZigiXG4iKTsNCg0KCWlm +ICgodG1wZmlsZSA9IG9wZW4oIi92YXIvdG1wL3Rlc3RfZnN5bmMub3V0Iiwg +T19SRFdSKSkgPT0gLTEpDQoJCWRpZSgiY2FuJ3Qgb3BlbiAvdmFyL3RtcC90 +ZXN0X2ZzeW5jLm91dCIpOw0KCWZzeW5jKHRtcGZpbGUpOw0KCWNsb3NlKHRt +cGZpbGUpOwkJDQoNCgkvKiBvcGVuX2RzeW5jLCB3cml0ZSAqLw0KCWlmICgo +dG1wZmlsZSA9IG9wZW4oIi92YXIvdG1wL3Rlc3RfZnN5bmMub3V0IiwgT19S +RFdSIHwgT19EU1lOQykpID09IC0xKQ0KCQlkaWUoImNhbid0IG9wZW4gL3Zh +ci90bXAvdGVzdF9mc3luYy5vdXQiKTsNCglnZXR0aW1lb2ZkYXkoJnN0YXJ0 +X3QsIE5VTEwpOw0KCXdyaXRlKHRtcGZpbGUsIHN0cm91dCwgODE5Mik7DQoJ +d3JpdGUodG1wZmlsZSwgc3Ryb3V0LCA4MTkyKTsNCglnZXR0aW1lb2ZkYXko +JmVsYXBzZV90LCBOVUxMKTsNCgljbG9zZSh0bXBmaWxlKTsNCglwcmludGYo +Im9wZW4gb19kc3luYywgd3JpdGUgICAgICAgICIpOw0KCXByaW50X2VsYXBz +ZShzdGFydF90LCBlbGFwc2VfdCk7DQoJcHJpbnRmKCJcbiIpOw0KDQoJaWYg +KCh0bXBmaWxlID0gb3BlbigiL3Zhci90bXAvdGVzdF9mc3luYy5vdXQiLCBP +X1JEV1IpKSA9PSAtMSkNCgkJZGllKCJjYW4ndCBvcGVuIC92YXIvdG1wL3Rl +c3RfZnN5bmMub3V0Iik7DQoJZnN5bmModG1wZmlsZSk7DQoJY2xvc2UodG1w +ZmlsZSk7CQkNCg0KCS8qIG9wZW5fZHN5bmMsIHdyaXRlICovDQoJaWYgKCh0 +bXBmaWxlID0gb3BlbigiL3Zhci90bXAvdGVzdF9mc3luYy5vdXQiLCBPX1JE +V1IgfCBPX0RTWU5DKSkgPT0gLTEpDQoJCWRpZSgiY2FuJ3Qgb3BlbiAvdmFy +L3RtcC90ZXN0X2ZzeW5jLm91dCIpOw0KCWdldHRpbWVvZmRheSgmc3RhcnRf +dCwgTlVMTCk7DQoJd3JpdGUodG1wZmlsZSwgc3Ryb3V0LCAxNjM4NCk7DQoJ +Z2V0dGltZW9mZGF5KCZlbGFwc2VfdCwgTlVMTCk7DQoJY2xvc2UodG1wZmls +ZSk7DQoJcHJpbnRmKCJvcGVuIG9fZHN5bmMsIG9uZSB3cml0ZSAgICAiKTsN +CglwcmludF9lbGFwc2Uoc3RhcnRfdCwgZWxhcHNlX3QpOw0KCXByaW50Zigi +XG4iKTsNCg0KCXVubGluaygiL3Zhci90bXAvdGVzdF9mc3luYy5vdXQiKTsN +Cg0KCXJldHVybiAwOw0KfQ0KDQp2b2lkIHByaW50X2VsYXBzZShzdHJ1Y3Qg +dGltZXZhbCBzdGFydF90LCBzdHJ1Y3QgdGltZXZhbCBlbGFwc2VfdCkNCnsN +CglpZiAoZWxhcHNlX3QudHZfdXNlYyA8IHN0YXJ0X3QudHZfdXNlYykNCgl7 +DQoJCWVsYXBzZV90LnR2X3NlYy0tOw0KCQllbGFwc2VfdC50dl91c2VjICs9 +IDEwMDAwMDA7DQoJfQ0KDQoJcHJpbnRmKCIlbGQuJTA2bGQiLCAobG9uZykg +KGVsYXBzZV90LnR2X3NlYyAtIHN0YXJ0X3QudHZfc2VjKSwNCgkJCQkJIChs +b25nKSAoZWxhcHNlX3QudHZfdXNlYyAtIHN0YXJ0X3QudHZfdXNlYykpOw0K +fQ0KDQp2b2lkIGRpZShjaGFyICpzdHIpDQp7DQoJZnByaW50ZihzdGRlcnIs +ICIlcyIsIHN0cik7DQoJZXhpdCgxKTsNCn0NCg== + +------_=_NextPart_001_01C3C0AA.8B1026A5-- + +From pgsql-admin-owner@postgresql.org Fri Dec 12 08:40:45 2003 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 12CB4D1B52A; Fri, 12 Dec 2003 12:40:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 19260-02; Fri, 12 Dec 2003 08:40:07 -0400 (AST) +Received: from host2.hostseguro.com (66-98-192-97.hostseguro.com + [66.98.192.97]) by svr1.postgresql.org (Postfix) with ESMTP + id 1A18FD1B459; Fri, 12 Dec 2003 08:40:04 -0400 (AST) +Received: from cpanel by host2.hostseguro.com with local (Exim 4.24) + id 1AUmaN-0002LT-9n; Fri, 12 Dec 2003 10:39:59 -0200 +Received: from 200-180-166-037.paemt7003.dsl.brasiltelecom.net.br + (200-180-166-037.paemt7003.dsl.brasiltelecom.net.br + [200.180.166.37]) by sistemica.info (IMP) with HTTP + for ; Fri, 12 Dec 2003 10:39:59 -0200 +Message-ID: <1071232799.3fd9b71f3d0bb@sistemica.info> +Date: Fri, 12 Dec 2003 10:39:59 -0200 +From: Rhaoni Chiu Pereira +To: PostgreSQL ADMIN , + PostgreSQL Performance +Subject: ODBC Driver generates a too big "windows swap file" and it's too slow +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.1 +X-Originating-IP: 200.180.166.37 +X-MailScanner-Information: Verificado pelo McAfee VirusScan / Scanned by + McAfee VirusScan +X-MailScanner: Nao infectado / Found to be clean +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - host2.hostseguro.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [32001 32001] / [47 12] +X-AntiAbuse: Sender Address Domain - sistemica.info +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.2 tagged_above=0.0 required=5.0 tests=BAYES_10, + RCVD_IN_DSBL, UPPERCASE_25_50, USER_AGENT_IMP +X-Spam-Level: +X-Archive-Number: 200312/166 +X-Sequence-Number: 11674 + +Hi List, + + First of all, I tried to subcribe the ODBC list but it seems that the +subscription's link is broken ! So here it goes: + + I have a delphi software use ttable components that converts dbf information +to PostgreSQL an Oracle Databases. My problem is that PostgreSQL is too slow, +the oracle db makes this convertion in 3.45 min and the Pg db makes int 29 min. + The software is the same ( only the database reference is diferent ) , this +sotware uses BDE to access the database with oracle native driver and using +postgreSQL odbc driver version 5. Both databases are in the same machine ( +Pentium 4 1.8Ghz, 384MB RAM DDR ) running RH 9 , Oracle 9i and PostgreSQL 7.3.2- +3. + When I ran this conversion I "snorted" the communication between the server +and the station to see how it does the sql requests , here it goes: + +ORACLE : + +- select owner, object_name, object_type, created from sys.all_objects where +object_type in ('TABLE', 'VIEW' ) and owner = 'VENDAS' and object_name += 'FTCOFI00' order by 1 ASC, 2 ASC + +- select owner, index_name, uniqueness from sys.all_indexes where table_owner += 'VENDAS' and table_name = 'FTCOFI00' order by owner ASC, index_name ASC + +- select column_name from sys.all_ind_columns where index_owner = 'VENDAS' and +index_name = 'FTCOFI01' order by column_position ASC + +- +SELECT "EMP" ,"FIL" ,"CODIGO_FISCAL" ,"CODIGO_FISCAL_ESTORNO" ,"DESCRICAO_FISCAL +" ,"CODIGO_OPERACIONAL" ,"DESCRICAO_USUARIO" ,"COD_NATIPI" ,"COD_NATIBGE" ,"EXTO +_NF1" ,"TEXTO_NF2" ,"NF_NORMALDIF" ,"NF_TRANSFILIAL" ,"COD_FILIAL" ,"COD_LANCTO_ +FILIAL" ,"NF_EXPORTACAO_DIRETA" ,"NF_EXPORTACAO_INDIRETA" ,"NF_SIMPREMESSA" ,"NF +_DEVOLUCAO" ,"NF_ENTRADA" ,"NF_REPOSICAO" ,"NF_OUTRASERIE" ,"NF_CONSIGNACAO" ,"N +F_PRODGRATIS" ,"NF_FATURANTECIP" ,"NF_DIFBASEICM" ,"NF_DIF_VALORICM" ,"NF_DIFBAS +EIPI" ,"NF_DIFVALORIPI" ,"NF_DIFPRECO" ,"BLOQ_CREDITO" ,"LIBERA_CREDITO" ,"VER_P +ARAM_VENDAS" ,"ENTRA_COBRANCA" ,"BASECALC_VLRBRUTO" ,"DESCNF_REFICM" ,"ALIQICM_I +GUALEST" ,"COD_TRIBICM" ,"COD_TRIBIPI" ,"ATUAL_ESTOQUE" ,"ATUAL_FABRICACAO" ,"AT +UAL_FATURA" ,"ATUAL_OUTENTR" ,"ATUAL_OUTSAIDA" ,"ATUAL_TRANFIL" ,"ATUAL_SEMIACAB +" ,"ATUAL_CARTPED" ,"ATUAL_ENTRSAID" ,"REV_CUSTMEDIO" ,"DIGITAR_FISICO" ,"DIGITA +R_FINANCEIRO" ,"USAR_CUSTO_CMU_INFORMAR" ,"GRUPO_FATURAMENTO" ,"TIPO_NF" ,"RESUM +O_FISCAL_CODIGO" , +"ATUAL_DISTRIB" ,"IMPR_OBS_NF_REG_ES" ,"DIFE_RECEITA" ,"COD_LANCTO" ,"SITUACAO" + FROM "FTCOFI00" ORDER BY "EMP" ASC , "FIL" ASC , "CODIGO_FISCAL" ASC + +- select owner, object_name, object_type, created from sys.all_objects where +object_type in ('TABLE', 'VIEW') and owner = 'VENDAS' and object_name += 'FTCLCR00' order by 1 ASC, 2 ASC + +- select owner, index_name, uniqueness from sys.all_indexes where table_owner += 'VENDAS' and table_name = 'FTCLCR00' order by owner ASC, index_name ASC + +- select column_name from sys.all_ind_columns where index_owner = 'VENDAS' and +index_name = 'FTCLCR01' order by column_position ASC + +- select column_name from sys.all_ind_columns where index_owner = 'VENDAS' and +index_name = 'FTCLCR02' order by column_position ASC + +- select column_name from sys.all_ind_columns where index_owner = 'VENDAS' and +index_name = 'FTCLCR03' order by column_position ASC + +- select column_name from sys.all_ind_columns where index_owner = 'VENDAS' and +index_name = 'FTCLCR04' order by column_position ASC + +- select column_name from sys.all_ind_columns where index_owner = 'VENDAS' and +index_name = 'FTCLCR05' order by column_position ASC + +- select column_name from sys.all_ind_columns where index_owner = 'VENDAS' and +index_name = 'FTCLCR06' order by column_position ASC + +- select column_name from sys.all_ind_columns where index_owner = 'VENDAS' and +index_name = 'FTCLCR07' order by column_position ASC + +- +SELECT "EMP" ,"FIL" ,"TIPO_CADASTRO" ,"CODIGO" ,"RAZAO_SOCIAL" ,"NOME_FANTASIA" +,"EMP_ENDERECO" ,"EMP_NRO" ,"EMP_COMPLEMENTO" ,"EMP_BAIRRO" ,"EMP_CIDADE" ,"EMP_ +ESTADO" ,"EMP_CEP" ,"EMP_PAIS" ,"EMP_EAN" ,"COB_ENDERECO" ,"COB_NRO" ,"COB_COMPL +EMENTO" ,"COB_BAIRRO" ,"COB_CIDADE" ,"COB_ESTADO" ,"COB_CEP" ,"COB_PAIS" ,"COB_E +AN" ,"ENT_ENDERECO" ,"ENT_NRO" ,"ENT_COMPLEMENTO" ,"ENT_BAIRRO" ,"ENT_CIDADE" ," +ENT_ESTADO", +"ENT_CEP" ,"ENT_PAIS" ,"ENT_EAN" ,"LOJA_EAN" ,"TELEFONE" ,"CELULAR" ,"FAX" ,"EMA +IL" ,"SITE" ,"CONTATO_NOME" ,"CONTATO_TELEFONE" ,"CONTATO_EMAIL" ,"CONTATO_DDMM_ +ANIV" ,"SITUACAO_CADASTRO" ,"OBSERVACOES" ,"DATA_CADASTRO" ,"DATA_ALTERACAO" ,"T +IPO_CONTRIBUINTE" ,"CODIGO_CONTRIBUINTE" ,"TIPO_INSCRICAO" ,"CODIGO_INSCRICAO"," +CODIGO_REDE" ,"CODIGO_TIPO_CLIENTE" ,"CODIGO_GRUPO_CLIENTE" ,"CODIGO_SUFRAMA" ," +DATA_VALIDADE_SUFRAMA" ,"LIMITE_CREDITO" , +"MARCA" ,"CLASSE" ,"BANDEIRA_CLIENTE" ,"CODIGO_TIPO_CREDOR" ,"NOME_REPRESENTANTE +" ,"TIPO_CONDICAO_PGTO" ,"PRAZO_PGTO_01" ,"PRAZO_PGTO_02" ,"PRAZO_PGTO_03" ,"COD +IGO_MOEDA_COMPRA" ,"FATOR_QUALIDADE" ,"DESPESA_FINANCEIRA" ,"CODIGO_DARF" ,"CODI +GO_NATUREZA_RENDIMENTO" ,"CONTA_CORRENTE_BANCO" ,"CONTA_CORRENTE_AGENCIA" ,"CONT +A_CORRENTE_NUMERO" ,"FORNECEDOR_SULPLASTIC" ,"SUFRAMA_TRIB_ICM" ,"SUFRAMA_TRIB_I +PI" ,"CONTA_CORRENTE_AGENC_DC" , +"CONTA_CORRENTE_NUM_DC" ,"CONTA_COR_FORMA_PAGTO" ,"FORMA_CREDITO" ,"SENHA" ,"LIM +ITE_CREDITO_PUIG" ,"COD_REPRES" ,"COD_CLIENTE_TEP" ,"EDI_MERCADOR" ,"TIPO_NF" ," +BONIFIC_BALCAO" FROM "FTCLCR00" ORDER BY "EMP" ASC , "FIL" +ASC , "TIPO_CADASTRO" ASC , "CODIGO" ASC + + +PostgreSQL: + +- select relname, nspname, relkind from pg_catalog.pg_class, +pg_catalog.pg_namespace where relkind in ('r', 'v') and nspname like 'vendas' +and relname like 'ftcofi00' and relname !~ '^pg_|^dd_' and pg_namespace.oid = +relnamespace order by nspname, relname + +- select u.nspname, c.relname, a.attname, a.atttypid, t.typname,a.attnum, +a.attlen, a.atttypmod, a.attnotnull, c.relhasrules, c.relkind from +pg_catalog.pg_namespace u, pg_catalog.pg_class c, pg_catalog.pg_attribute a, +pg_catalog.pg_type t where u.oid = c.relnamespace and (not a.attisdropped) and +c.oid= a.attrelid and a.atttypid = t.oid and (a.attnum > 0) and c.relname +like 'ftcofi00' and u.nspname like 'vendas' order by u.nspname, c.relname, +attnum + +- select u.nspname, c.relname, a.attname, a.atttypid, t.typname,a.attnum, +a.attlen, a.atttypmod, a.attnotnull, c.relhasrules, c.relkind from +pg_catalog.pg_namespace u, pg_catalog.pg_class c, pg_catalog.pg_attribute a, +pg_catalog.pg_type t where u.oid = c.relnamespace and (not a.attisdropped) and +c.oid= a.attrelid and a.atttypid = t.oid and (a.attnum > 0) and c.relname += 'ftcofi00'and u.nspname = 'vendas' order by u.nspname, c.relname, attnum + +- select c.relname, i.indkey, i.indisunique, i.indisclustered, a.amname, +c.relhasrules, n.nspname from pg_catalog.pg_index i, pg_catalog.pg_class c, +pg_catalog.pg_class d, pg_catalog.pg_am a, pg_catalog.pg_namespace n where +d.relname = 'ftcofi00' and n.nspname = 'vendas' and n.oid = d.relnamespace and +d.oid = i.indrelid and i.indexrelid = c.oid and c.relam = a.oid order by +i.indisprimary desc, i.indisunique, n.nspname, c.relname + +- +SELECT "emp" ,"fil" ,"codigo_fiscal" ,"codigo_fiscal_estorno" ,"descricao_fiscal +" ,"codigo_operacional" ,"descricao_usuario" ,"cod_natipi" ,"cod_natibge" ,"text +o_nf1" ,"texto_nf2" ,"nf_normaldif" ,"nf_transfilial" ,"cod_filial" ,"cod_lancto +_filial" ,"nf_exportacao_direta" ,"nf_exportacao_indireta" ,"nf_simpremessa" ,"n +f_devolucao" ,"nf_entrada" ,"nf_reposicao" ,"nf_outraserie" ,"nf_consignacao" ," +nf_prodgratis" ,"nf_faturantecip" ,"nf_difbaseicm" ,"nf_dif_valoricm" ,"nf_difba +seipi" ,"nf_difvaloripi" ,"nf_difpreco" ,"bloq_credito" ,"libera_credito" ,"ver_ +param_vendas" ,"entra_cobranca" ,"basecalc_vlrbruto" ,"descnf_reficm" ,"aliqicm_ +igualest" ,"cod_tribicm" ,"cod_tribipi" ,"atual_estoque" ,"atual_fabricacao" ,"a +tual_fatura" ,"atual_outentr" ,"atual_outsaida" ,"atual_tranfil" ,"atual_semiaca +b" ,"atual_cartped" ,"atual_entrsaid" ,"rev_custmedio" ,"digitar_fisico" ,"digit +ar_financeiro","usar_custo_cmu_informar" ,"grupo_faturamento" ,"tipo_nf" ,"resum +o_fiscal_codigo" ,"atual_distrib" , +"impr_obs_nf_reg_es" ,"difer_receita" ,"cod_lancto" ,"situacao" +FROM "vendas"."ftcofi00" ORDER BY "emp" ASC , "fil" ASC , "codigo_fiscal" ASC + +- select relname, nspname, relkind from pg_catalog.pg_class, +pg_catalog.pg_namespace where relkind in ('r', 'v') and nspname like 'vendas' +and relname like 'ftclcr00' and relname !~ '^pg_|^dd_' and pg_namespace.oid = +relnamespace order by nspname, relname + +- select u.nspname, c.relname, a.attname, a.atttypid, t.typname,a.attnum, +a.attlen, a.atttypmod, a.attnotnull, c.relhasrules, c.relkind from +pg_catalog.pg_namespace u, pg_catalog.pg_class c, pg_catalog.pg_attribute a, +pg_catalog.pg_type t where u.oid = c.relnamespace and (not a.attisdropped) and +c.oid= a.attrelid and a.atttypid = t.oid and (a.attnum > 0) and c.relname +like 'ftclcr00' and u.nspname like 'vendas' order by u.nspname, c.relname, +attnum + +- select u.nspname, c.relname, a.attname, a.atttypid, t.typname,a.attnum, +a.attlen, a.atttypmod, a.attnotnull, c.relhasrules, c.relkind from +pg_catalog.pg_namespace u, pg_catalog.pg_class c, pg_catalog.pg_attribute a, +pg_catalog.pg_type t where u.oid = c.relnamespace and (not a.attisdropped) and +c.oid= a.attrelid and a.atttypid = t.oid and (a.attnum > 0) and c.relname += 'ftclcr00'and u.nspname = 'vendas' order by u.nspname, c.relname, attnum + +- select c.relname, i.indkey, i.indisunique, i.indisclustered, a.amname, +c.relhasrules, n.nspname from pg_catalog.pg_index i, pg_catalog.pg_class c, +pg_catalog.pg_class d, pg_catalog.pg_am a, pg_catalog.pg_namespace n where +d.relname = 'ftclcr00' and n.nspname = 'vendas' and n.oid = d.relnamespace and +d.oid = i.indrelid and i.indexrelid = c.oid and c.relam = a.oid order by +i.indisprimary desc, i.indisunique, n.nspname, c.relname + +- +SELECT "emp" ,"fil" ,"tipo_cadastro" ,"codigo" ,"razao_social","nome_fantasia" , +"emp_endereco" ,"emp_nro" ,"emp_complemento" ,"emp_bairro" ,"emp_cidade" ,"emp_e +stado" ,"emp_cep" ,"emp_pais","emp_ean" ,"cob_endereco" ,"cob_nro" ,"cob_complem +ento" ,"cob_bairro" ,"cob_cidade" ,"cob_estado" ,"cob_cep" ,"cob_pais" ,"cob_ean +" ,"ent_endereco" ,"ent_nro" ,"ent_complemento" ,"ent_bairro" ,"ent_cidade" ,"en +t_estado" ,"ent_cep" ,"ent_pais" ,"ent_ean" ,"loja_ean" ,"telefone" ,"celular" , +"fax" ,"email" ,"site" ,"contato_nome" ,"contato_telefone" ,"contato_email" ,"co +ntato_ddmm_aniv" ,"situacao_cadastro" ,"observacoes" ,"data_cadastro" ,"data_alt +eracao" ,"tipo_contribuinte" ,"codigo_contribuinte" ,"tipo_inscricao" ,"codigo_i +nscricao" ,"codigo_rede" ,"codigo_tipo_cliente" ,"codigo_grupo_cliente" ,"codigo +_suframa" ,"data_validade_suframa" ,"limite_credito" ,"marca" ,"classe" ,"bandei +ra_cliente" ,"codigo_tipo_credor" ,"nome_representante" ,"tipo_condicao_pgto" ," +prazo_pgto_01" ,"prazo_pgto_02" ,"prazo_pgto_03" , +"codigo_moeda_compra" ,"fator_qualidade" ,"despesa_financeira" ,"codigo_darf" ," +codigo_natureza_rendimento" ,"conta_corrente_banco" ,"conta_corrente_agencia" ," +conta_corrente_numero" ,"fornecedor_sulplastic" ,"suframa_trib_icm" ,"suframa_tr +ib_ipi" ,"conta_corrente_agenc_dc" ,"conta_corrente_num_dc" ,"conta_cor_forma_pa +gto" ,"forma_credito" ,"senha" ,"limite_credito_puig" ,"cod_repres" ,"cod_client +e_tep" ,"edi_mercador" ,"tipo_nf" ,"bonific_balcao" FROM "vendas"."ftclcr00" +ORDER BY "emp" ASC , "fil" ASC , "tipo_cadastro" ASC , "codigo" ASC + + So , this snort generated a 3MB file for Oracle and it didn't request a +bigger windows swap file but PostgreSQL generated a 153 MB file and I needed a +700 MB windows swap file ( this is unacceptable !!!! ). + I tried changing the ttables components to a SQL Query but Pg did it in +49min an Oracle in 29min ( it looks like a index problem but there's no way to +force an index in Pqsql ). + I don't know whate else to do , and I really want to use PgSQL instead of +Oracle but to do this I must PgSQL working in a compatibile time ! + Any suggestions ? + +Atenciosamente, + +Rhaoni Chiu Pereira +Sist�mica Computadores + +Visite-nos na Web: http://sistemica.info +Fone/Fax : +55 51 3328 1122 + + + + + + +From pgsql-performance-owner@postgresql.org Fri Dec 12 11:34:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 606FFD1DFA3 + for ; + Fri, 12 Dec 2003 15:33:57 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 40164-08 + for ; + Fri, 12 Dec 2003 11:33:30 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 411DDD1E001 + for ; + Fri, 12 Dec 2003 11:33:26 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBCFXU19019870; + Fri, 12 Dec 2003 10:33:30 -0500 (EST) +To: "david@shadovitz.com" +Cc: "'pgsql-performance@postgresql.org'" +Subject: Re: Query plan - now what? +In-reply-to: <01C3C045.7EDD13C0.david@shadovitz.com> +References: <01C3C045.7EDD13C0.david@shadovitz.com> +Comments: In-reply-to David Shadovitz + message dated "Fri, 12 Dec 2003 00:18:12 -0800" +Date: Fri, 12 Dec 2003 10:33:30 -0500 +Message-ID: <19869.1071243210@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/198 +X-Sequence-Number: 5058 + +David Shadovitz writes: +> Well, now that I have the plan for my slow-running query, what do I +> do? + +This is not very informative when you didn't show us the query nor +the table schemas (column datatypes and the existence of indexes +are the important parts). I have a feeling that you might be well +advised to fold the multiple tables into one "animals" table, but +there's not enough info here to make that recommendation for sure. + +BTW, what did you do with this, print and OCR it? It's full of the +most bizarre typos ... mostly "l" for "1", but others too ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Dec 12 11:47:58 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C6A7ED1E139 + for ; + Fri, 12 Dec 2003 15:47:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42827-04 + for ; + Fri, 12 Dec 2003 11:47:26 -0400 (AST) +Received: from grouse.mail.pas.earthlink.net (grouse.mail.pas.earthlink.net + [207.217.120.116]) + by svr1.postgresql.org (Postfix) with ESMTP id DB06ED1B4AE + for ; + Fri, 12 Dec 2003 11:46:50 -0400 (AST) +Received: from user-11202lf.dsl.mindspring.com ([66.32.10.175] + helo=shadovitzcmptr) + by grouse.mail.pas.earthlink.net with smtp (Exim 3.33 #1) + id 1AUpVF-0001ZS-00; Fri, 12 Dec 2003 07:46:53 -0800 +Received: by localhost with Microsoft MAPI; Fri, 12 Dec 2003 07:46:42 -0800 +Message-ID: <01C3C084.156718C0.david@shadovitz.com> +From: David Shadovitz +Reply-To: "david@shadovitz.com" +To: "'pgsql-performance@postgresql.org'" +Cc: 'Tom Lane' +Subject: Re: Query plan - now what? +Date: Fri, 12 Dec 2003 07:46:36 -0800 +X-Mailer: Microsoft Internet E-mail/MAPI - 8.0.0.4211 +MIME-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/199 +X-Sequence-Number: 5059 + +> This is not very informative when you didn't show us the query nor +> the table schemas.. + +> BTW, what did you do with this, print and OCR it? + +Tom, + +I work in a classified environment, so I had to sanitize the query plan, print +it, and OCR it. I spent a lot of time fixing typos, but I guess at midnight my +eyes missed some. This hassle is why I posted neither the query nor the +schema. The database is normalized, though, but my use of animal names of +couse masks this. + +If you think that you or anyone else would invest the time, I could post more +info. + +I will also try Shridhar's suggestions on statistics_target and +enable_hash_join. + +Thanks. +-David + +From pgsql-admin-owner@postgresql.org Fri Dec 12 12:13:55 2003 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5B352D1E0C1; Fri, 12 Dec 2003 16:13:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49005-04; Fri, 12 Dec 2003 12:13:09 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP + id B895AD1DF54; Fri, 12 Dec 2003 12:06:57 -0400 (AST) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id hBCG688q023596; + Fri, 12 Dec 2003 09:06:08 -0700 (MST) +Date: Fri, 12 Dec 2003 08:48:14 -0700 (MST) +From: "scott.marlowe" +To: Rhaoni Chiu Pereira +Cc: PostgreSQL ADMIN , + PostgreSQL Performance +Subject: Re: ODBC Driver generates a too big "windows swap file" and +In-Reply-To: <1071232799.3fd9b71f3d0bb@sistemica.info> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/170 +X-Sequence-Number: 11678 + +On Fri, 12 Dec 2003, Rhaoni Chiu Pereira wrote: + + +Hi, is there a switch in your pgsql/odbc connector to enable cursors? If +so, try turning that on. + + +From pgsql-admin-owner@postgresql.org Fri Dec 12 12:16:12 2003 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 62C40D1DFAC; Fri, 12 Dec 2003 16:16:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49681-02; Fri, 12 Dec 2003 12:15:36 -0400 (AST) +Received: from ndl1mr1-a-fixed.sancharnet.in (ndl1mr1-a-fixed.sancharnet.in + [61.0.0.45]) by svr1.postgresql.org (Postfix) with ESMTP + id 5930ED1DFFD; Fri, 12 Dec 2003 12:11:26 -0400 (AST) +Received: from conversion-daemon.ndl1mr1-a-fixed.sancharnet.in by + ndl1mr1-a-fixed.sancharnet.in + (iPlanet Messaging Server 5.2 HotFix 1.17 (built Jun 23 2003)) + id <0HPS00701HUPJ5@ndl1mr1-a-fixed.sancharnet.in>; Fri, + 12 Dec 2003 21:38:50 +0530 (IST) +Received: from sancharnet.in ([61.0.95.114]) by ndl1mr1-a-fixed.sancharnet.in + (iPlanet Messaging Server 5.2 HotFix 1.17 (built Jun 23 2003)) + with ESMTPA id <0HPS00E3BI6JTR@ndl1mr1-a-fixed.sancharnet.in>; Fri, + 12 Dec 2003 21:38:50 +0530 (IST) +Date: Fri, 12 Dec 2003 21:43:10 +0530 +From: Sai Hertz And Control Systems +Subject: Tables Without OIDS and its effect +To: pgsql-admin@postgresql.org +Cc: pgsql-performance@postgresql.org +Reply-To: aspire420@hotpop.com +Message-id: <3FD9E916.8050005@sancharnet.in> +Organization: Sai Hertz And Control Systems +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 (Windows; U; Windows NT 5.1; en-US; rv:1.6b) + Gecko/20031205 Thunderbird/0.4 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=BAYES_20, + FROM_ENDS_IN_NUMS, RCVD_IN_OSIRUSOFT_COM, RCVD_IN_RFCI, + USER_AGENT_MOZILLA_UA +X-Spam-Level: +X-Archive-Number: 200312/171 +X-Sequence-Number: 11679 + +Dear all , + +I have created my tables without OIDS now my doubts are : +1. Will this speed up the data insertion process +2. Though I have not written any code in my any of the pgsql functions +which depend on OIDS + 1. Will without OIDS the functions behave internally differently + 2. Will my application break at any point +3. I decided to work with out OIDS because + 1. It has a limit of -2147483648 to +2147483647 + 2 Due to this limitation I would not like to drop recreate my +database because it is a bit difficult/dirty process + +All links and suggestion pertaining to OIDS are most welcome my mail box +is at your disposal and dont hassitate to +drop a two line comment. +----------------------- +My Sys Config: +RH 9.0 +PostgreSQL 7.3.4 +GCC 3.2.2 +PHP 4.3.4 +---------------------- +Regards, +V Kashyap + + + + +From pgsql-performance-owner@postgresql.org Fri Dec 12 12:59:45 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C55B4D1B4BB + for ; + Fri, 12 Dec 2003 16:59:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55639-04 + for ; + Fri, 12 Dec 2003 12:59:13 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 2CE21D1B4A8 + for ; + Fri, 12 Dec 2003 12:59:13 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hBCGxCU6032463 + for ; Fri, 12 Dec 2003 16:59:12 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hBCGZEVL029458 + for pgsql-performance@postgresql.org; Fri, 12 Dec 2003 16:35:14 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Hardware suggestions for Linux/PGSQL server +Date: Fri, 12 Dec 2003 08:35:17 -0800 +Organization: Hub.Org Networking Services +Lines: 17 +Message-ID: +References: + + + <3FD961C5.9070204@persistent.co.in> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +In-Reply-To: <3FD961C5.9070204@persistent.co.in> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/203 +X-Sequence-Number: 5063 + +Shridhar Daithankar wrote: +> +> FWIW, there are only two pieces of software that need 64bit aware for a +> typical server job. Kernel and glibc. Rest of the apps can do fine as 32 +> bits unless you are oracle and insist on outsmarting OS. +> +> In fact running 32 bit apps on 64 bit OS has plenty of advantages like +> effectively using the cache. Unless you need 64bit, going for 64bit +> software is not advised. + +This is a good point. While doing research on this matter a few months +back, I saw comments by people testing 64-bit MySQL that some operations +would run faster and some slower due to the use of 64-bit datatypes +versus 32-bit. The best solution in the end is probably to run 32-bit +Postgres under a 64-bit kernel -- unless your DB tends to have a lot of +64-bit datatypes. + + +From pgsql-performance-owner@postgresql.org Fri Dec 12 12:53:51 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 12791D1B481 + for ; + Fri, 12 Dec 2003 16:53:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 53512-08 + for ; + Fri, 12 Dec 2003 12:53:18 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 3EC1BD1B8BE + for ; + Fri, 12 Dec 2003 12:53:17 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBCGqu19020395; + Fri, 12 Dec 2003 11:53:16 -0500 (EST) +To: "david@shadovitz.com" +Cc: "'pgsql-performance@postgresql.org'" +Subject: Re: Query plan - now what? +In-reply-to: <01C3C084.156718C0.david@shadovitz.com> +References: <01C3C084.156718C0.david@shadovitz.com> +Comments: In-reply-to David Shadovitz + message dated "Fri, 12 Dec 2003 07:46:36 -0800" +Date: Fri, 12 Dec 2003 11:52:56 -0500 +Message-ID: <20394.1071247976@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/202 +X-Sequence-Number: 5062 + +David Shadovitz writes: +> If you think that you or anyone else would invest the time, I could post more +> info. + +I doubt you will get any useful help if you don't post more info. + +> I will also try Shridhar's suggestions on statistics_target and +> enable_hash_join. + +It seemed to me that the row estimates were not so far off that I would +call it a statistical failure; you can try increasing the stats target +but I'm not hopeful about that. My guess is that you will have to look +to revising either the query or the whole database structure (ie, +merging tables). We'll need the info I asked for before we can make +any recommendations, though. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Dec 12 14:05:44 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CCCFAD1E016 + for ; + Fri, 12 Dec 2003 18:05:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 67920-01 + for ; + Fri, 12 Dec 2003 14:05:05 -0400 (AST) +Received: from tino.sinectis.com.ar (tino.sinectis.com.ar [216.244.192.232]) + by svr1.postgresql.org (Postfix) with ESMTP id A88A8D1E012 + for ; + Fri, 12 Dec 2003 14:05:00 -0400 (AST) +Received: by tino.sinectis.com.ar (Postfix, from userid 99) + id 697FD6C58F; Fri, 12 Dec 2003 15:04: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.4.4 +From: nbarraza@uolsinectis.com.ar +To: pgsql-performance@postgresql.org +Subject: Performance related to size of tables +Reply-To: nbarraza@uolsinectis.com.ar +Message-Id: <20031212180449.697FD6C58F@tino.sinectis.com.ar> +Date: Fri, 12 Dec 2003 15:04:49 -0300 (GMT+3) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/204 +X-Sequence-Number: 5064 + +Hi everyone, +I found that performance get worse as the size of a given table +increases. I mean, for example I�ve just run some scripts shown in + +http://www.potentialtech.com/wmoran/postgresql.php + +I understand that those scripts are designed to see the behavior of postgresql under different filesystems. However, since them generate +a lot of I/O activity, I think they can be used to adjust some +configuration parameters. In that way, I increased the number of tuples inserted in the initial table to 2000000 and 3000000. What +I saw is that the running time goes from 3 min., to 11 min. My question is, is it possible to use that test to tune +some parameters?, if the answer is yes, what parameters should I change to get shorter running times? + +Thanks a lot + +Nestor + +From pgsql-performance-owner@postgresql.org Tue Dec 16 17:08:01 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 833B7D1B45A; Fri, 12 Dec 2003 20:55:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92295-10; Fri, 12 Dec 2003 16:55:25 -0400 (AST) +Received: from dbl.q-ag.de (dbl.q-ag.de [80.146.160.66]) + by svr1.postgresql.org (Postfix) with ESMTP + id 6555DD1D8B4; Fri, 12 Dec 2003 16:55:19 -0400 (AST) +Received: from colorfullife.com (dbl [127.0.0.1]) + by dbl.q-ag.de (8.12.3/8.12.3/Debian-6.6) with ESMTP id hBCKsYN9021076; + Fri, 12 Dec 2003 21:54:36 +0100 +Message-ID: <3FDA2B0A.1060709@colorfullife.com> +Date: Fri, 12 Dec 2003 21:54:34 +0100 +From: Manfred Spraul +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031030 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bruce Momjian +Cc: Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] fsync method checking +References: <200312120649.hBC6nQR15608@candle.pha.pa.us> +In-Reply-To: <200312120649.hBC6nQR15608@candle.pha.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/233 +X-Sequence-Number: 5093 + +Bruce Momjian wrote: + +> write 0.000360 +> write & fsync 0.001391 +> write, close & fsync 0.001308 +> open o_fsync, write 0.000924 +> +> +That's 1 milliseconds vs. 1.3 milliseconds. Neither value is realistic - +I guess the hw cache on and the os doesn't issue cache flush commands. +Realistic values are probably 5 ms vs 5.3 ms - 6%, not 30%. How large is +the syscall latency with BSD/OS 4.3? + +One advantage of a seperate write and fsync call is better performance +for the writes that are triggered within AdvanceXLInsertBuffer: I'm not +sure how often that's necessary, but it's a write while holding both the +WALWriteLock and WALInsertLock. If every write contains an implicit +sync, that call would be much more expensive than necessary. + +-- + Manfred + + +From pgsql-performance-owner@postgresql.org Fri Dec 12 17:11:45 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ADE28D1D38F + for ; + Fri, 12 Dec 2003 21:11:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 96734-03 + for ; + Fri, 12 Dec 2003 17:11:13 -0400 (AST) +Received: from linda-2.paradise.net.nz (bm-2a.paradise.net.nz [202.0.58.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 8BBAED1BCB8 + for ; + Fri, 12 Dec 2003 17:11:11 -0400 (AST) +Received: from smtp-1.paradise.net.nz (smtp-1a.paradise.net.nz [202.0.32.194]) + by linda-2.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0HPS00JS3W6N6P@linda-2.paradise.net.nz> for + pgsql-performance@postgresql.org; Sat, 13 Dec 2003 10:11:12 +1300 (NZDT) +Received: from paradise.net.nz + (218-101-14-127.paradise.net.nz [218.101.14.127]) by + smtp-1.paradise.net.nz (Postfix) with ESMTP id 188B982768; + Sat, 13 Dec 2003 10:11:11 +1300 (NZDT) +Date: Sat, 13 Dec 2003 10:11:29 +1300 +From: Mark Kirkwood +Subject: Re: Performance related to size of tables +In-reply-to: <20031212180449.697FD6C58F@tino.sinectis.com.ar> +To: nbarraza@uolsinectis.com.ar +Cc: pgsql-performance@postgresql.org +Message-id: <3FDA2F01.10205@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-transfer-encoding: 8BIT +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.5) Gecko/20031213 +References: <20031212180449.697FD6C58F@tino.sinectis.com.ar> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/205 +X-Sequence-Number: 5065 + +If you want to speed up the elapsed times, then the first thing would be +to attempt to reduce the IO using some indexes, e.g. on test1(anumber), +test2(anumber), test3((anumber%13)), test3((anumber%5)) and +test4((anumber%27)) + +However if you wish to keep hammering the IO then the you would not use +any indexes. However elapsed times for operations like: + +CREATE TABLE test4 AS SELECT ... FROM test1 JOIN test2 ON +test1.anumber=test2.anumber; + +are going to increase non linearly with the size of the source table +test1 (unless there are indexes on the anumber columns). + +I think this particular test is designed as a testbed for measuring IO +performance - as opposed to Postgresql performance. + + +regards + +Mark + +nbarraza@uolsinectis.com.ar wrote: + +>Hi everyone, +>I found that performance get worse as the size of a given table +>increases. I mean, for example I�ve just run some scripts shown in +> +>http://www.potentialtech.com/wmoran/postgresql.php +> +>I understand that those scripts are designed to see the behavior of postgresql under different filesystems. However, since them generate +>a lot of I/O activity, I think they can be used to adjust some +>configuration parameters. In that way, I increased the number of tuples inserted in the initial table to 2000000 and 3000000. What +>I saw is that the running time goes from 3 min., to 11 min. My question is, is it possible to use that test to tune +>some parameters?, if the answer is yes, what parameters should I change to get shorter running times? +> +> +> +> + + +From pgsql-performance-owner@postgresql.org Fri Dec 12 17:29:35 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id BBF6BD1B45A; Fri, 12 Dec 2003 21:29:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 98506-02; Fri, 12 Dec 2003 17:29:04 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id 8CDDBD1B460; Fri, 12 Dec 2003 17:29:02 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBCLSl19022122; + Fri, 12 Dec 2003 16:28:47 -0500 (EST) +To: Manfred Spraul +Cc: Bruce Momjian , + Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] fsync method checking +In-reply-to: <3FDA2B0A.1060709@colorfullife.com> +References: <200312120649.hBC6nQR15608@candle.pha.pa.us> + <3FDA2B0A.1060709@colorfullife.com> +Comments: In-reply-to Manfred Spraul + message dated "Fri, 12 Dec 2003 21:54:34 +0100" +Date: Fri, 12 Dec 2003 16:28:47 -0500 +Message-ID: <22121.1071264527@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/206 +X-Sequence-Number: 5066 + +Manfred Spraul writes: +> One advantage of a seperate write and fsync call is better performance +> for the writes that are triggered within AdvanceXLInsertBuffer: I'm not +> sure how often that's necessary, but it's a write while holding both the +> WALWriteLock and WALInsertLock. If every write contains an implicit +> sync, that call would be much more expensive than necessary. + +Ideally that path isn't taken very often. But I'm currently having a +discussion off-list with a CMU student who seems to be seeing a case +where it happens a lot. (She reports that both WALWriteLock and +WALInsertLock are causes of a lot of process blockages, which seems to +mean that a lot of the WAL I/O is being done with both held, which would +have to mean that AdvanceXLInsertBuffer is doing the I/O. More when we +figure out what's going on exactly...) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Dec 12 18:29:48 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 89384D1B430 + for ; + Fri, 12 Dec 2003 22:29:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 01515-09 + for ; + Fri, 12 Dec 2003 18:29:16 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id EE927D1BA62 + for ; + Fri, 12 Dec 2003 18:29:13 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hBCMTDU6081572 + for ; Fri, 12 Dec 2003 22:29:13 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hBCM1uoZ044278 + for pgsql-performance@postgresql.org; Fri, 12 Dec 2003 22:01:56 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Update on putting WAL on ramdisk/ +Date: Fri, 12 Dec 2003 14:02:03 -0800 +Organization: Hub.Org Networking Services +Lines: 17 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/207 +X-Sequence-Number: 5067 + +Some arbitrary data processing job + +WAL on single drive: 7.990 rec/s +WAL on 2nd IDE drive: 8.329 rec/s +WAL on tmpfs: 13.172 rec/s + +A huge jump in performance but a bit scary having a WAL that can +disappear at any time. I'm gonna workup a rsync script and do some +power-off experiments to see how badly it gets mangled. + +This could be good method though when you're dumping and restore an +entire DB. Make a tmpfs mount, restore, shutdown DB and then copy the +WAL back to the HD. + +I checked out the SanDisk IDE FlashDrives. They have a write cycle life +of 2 million. I'll explore more expensive solid state drives. + + +From pgsql-performance-owner@postgresql.org Fri Dec 12 18:37:21 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CEF13D1B8C0 + for ; + Fri, 12 Dec 2003 22:37:18 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06594-03 + for ; + Fri, 12 Dec 2003 18:36:50 -0400 (AST) +Received: from mta1.sucs.soton.ac.uk (mta1.sucs.soton.ac.uk [152.78.128.140]) + by svr1.postgresql.org (Postfix) with ESMTP id C2508D1B4C5 + for ; + Fri, 12 Dec 2003 18:36:46 -0400 (AST) +Received: from russell (cpc1-glfd2-4-0-cust205.glfd.cable.ntl.com + [81.99.187.205]) (authenticated bits=0) + by mta1.sucs.soton.ac.uk (8.12.10/8.12.10) with ESMTP id hBCMaP3A022304; + Fri, 12 Dec 2003 22:36:26 GMT +From: "Russell Garrett" +To: "William Yu" , + +Subject: Re: Update on putting WAL on ramdisk/ +Date: Fri, 12 Dec 2003 22:36:26 -0000 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) +In-reply-to: +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-ISS-MailScanner: Believed to be clean +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/208 +X-Sequence-Number: 5068 + +> WAL on single drive: 7.990 rec/s +> WAL on 2nd IDE drive: 8.329 rec/s +> WAL on tmpfs: 13.172 rec/s +> +> A huge jump in performance but a bit scary having a WAL that can +> disappear at any time. I'm gonna workup a rsync script and do some +> power-off experiments to see how badly it gets mangled. + +Surely this is just equivalent to disabling fsync? If you put a WAL on a +volatile file system, there's not a whole lot of point in having one at all. + +-------------------------------------------------------------------- +Russ Garrett russ@last.fm + http://last.fm + + +From pgsql-performance-owner@postgresql.org Tue Dec 16 17:08:03 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D6F2D1DFE7 + for ; + Fri, 12 Dec 2003 22:41:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06322-02 + for ; + Fri, 12 Dec 2003 18:40:44 -0400 (AST) +Received: from q.idc-mcs.com (unknown [64.156.199.9]) + by svr1.postgresql.org (Postfix) with ESMTP id ADFBED1C919 + for ; + Fri, 12 Dec 2003 18:40:41 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.5.6944.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C3C100.F1020EA8" +Subject: Excessive rows/tuples seriously degrading query performance +Date: Fri, 12 Dec 2003 14:40:28 -0800 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Excessive rows/tuples seriously degrading query performance +Thread-Index: AcPBAPD/EOCvMLcRQ9isBa7sLviPMg== +From: "Chadwick, Russell" +To: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/235 +X-Sequence-Number: 5094 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C3C100.F1020EA8 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +=20 +Hello everyone. +Can anyone explain why this table which has never had more than a couple ro= +ws in it shows > 500k in the query planner even after running vacuum full. = + Its terribly slow to return 2 rows of data. The 2 rows in it are being up= +dated a lot but I couldn't find any explanation for this behavior. Anythin= +g I could try besides droping db and recreating?=20=20 +Thanks - Russ +=20 +toolshed=3D# explain analyze select * from stock_log_positions ; + QUERY PLAN=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20 +---------------------------------------------------------------------------= +---------------------------------------------- + Seq Scan on stock_log_positions (cost=3D0.00..10907.77 rows=3D613577 widt= +h=3D22) (actual time=3D701.39..701.41 rows=3D2 loops=3D1) + Total runtime: 701.54 msec +(2 rows) +=20 +toolshed=3D# vacuum full analyze verbose stock_log_positions; +INFO: --Relation public.stock_log_positions-- +INFO: Pages 4773: Changed 1, reaped 767, Empty 0, New 0; Tup 613737: Vac 5= +7620, Keep/VTL 613735/613713, UnUsed 20652, MinLen 52, MaxLen 52; Re-using:= + Free/Avail. Space 4322596/4322596; EndEmpty/Avail. Pages 0/4773. + CPU 9.11s/13.68u sec elapsed 22.94 sec. +INFO: Index idx_stock_log_positions_when_log_filename: Pages 9465; Tuples = +613737: Deleted 57620. + CPU 1.55s/1.27u sec elapsed 6.69 sec. +INFO: Rel stock_log_positions: Pages: 4773 --> 4620; Tuple(s) moved: 59022. + CPU 1.00s/4.45u sec elapsed 8.83 sec. +INFO: Index idx_stock_log_positions_when_log_filename: Pages 9778; Tuples = +613737: Deleted 2897. + CPU 1.32s/0.44u sec elapsed 6.23 sec. +INFO: Analyzing public.stock_log_positions +VACUUM +=20 +toolshed=3D# explain analyze select * from stock_log_positions ; + QUERY PLAN=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= +=20=20=20 +---------------------------------------------------------------------------= +---------------------------------------------- + Seq Scan on stock_log_positions (cost=3D0.00..10757.37 rows=3D613737 widt= +h=3D22) (actual time=3D789.21..789.24 rows=3D2 loops=3D1) + Total runtime: 789.40 msec +(2 rows) +=20 +toolshed=3D# select * from stock_log_positions ; + when_log | filename | position=20 +------------+--------------+---------- + 2003-12-11 | ActiveTrader | 0 + 2003-12-11 | Headlines | 0 +(2 rows) + + +------_=_NextPart_001_01C3C100.F1020EA8 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +
 
+
Hello everyone.
+
Can anyone explain why this table which ha= +s never=20 +had more than a couple rows in it shows > 500k in the query planner even= +=20 +after running vacuum full.  Its terribly slow to return 2 rows of=20 +data.  The 2 rows in it are being updated a lot but I couldn't find an= +y=20 +explanation for this behavior.  Anything I could try besides droping d= +b and=20 +recreating? 
+
Thanks - Russ
+
 
+
toolshed=3D# explain analyze select * from stock_log_positions=20 +;
           &nbs= +p;            &= +nbsp;           &nbs= +p;            &= +nbsp;    =20 +QUERY=20 +PLAN            = +;            &n= +bsp;            = +;            &n= +bsp;     =20 +
-----------------------------------------------------------------------= +--------------------------------------------------
 Seq=20 +Scan on stock_log_positions  (cost=3D0.00..10907.77 rows=3D613577 widt= +h=3D22)=20 +(actual time=3D701.39..701.41 rows=3D2 loops=3D1)
 Total runtime: 7= +01.54=20 +msec
(2 rows)
+
 
+
toolshed=3D# vacuum full analyze verbose stock_log_positions;
INFO:= + =20 +--Relation public.stock_log_positions--
INFO:  Pages 4773: Changed = +1,=20 +reaped 767, Empty 0, New 0; Tup 613737: Vac 57620, Keep/VTL 613735/613713,= +=20 +UnUsed 20652, MinLen 52, MaxLen 52; Re-using: Free/Avail. Space 4322596/432= +2596;=20 +EndEmpty/Avail. Pages 0/4773.
       = + CPU=20 +9.11s/13.68u sec elapsed 22.94 sec.
INFO:  Index=20 +idx_stock_log_positions_when_log_filename: Pages 9465; Tuples 613737: Delet= +ed=20 +57620.
        CPU 1.55s/1.27u sec el= +apsed=20 +6.69 sec.
INFO:  Rel stock_log_positions: Pages: 4773 --> 4620;= +=20 +Tuple(s) moved: 59022.
        CPU=20 +1.00s/4.45u sec elapsed 8.83 sec.
INFO:  Index=20 +idx_stock_log_positions_when_log_filename: Pages 9778; Tuples 613737: Delet= +ed=20 +2897.
        CPU 1.32s/0.44u sec ela= +psed=20 +6.23 sec.
INFO:  Analyzing public.stock_log_positions
VACUUM +
 
+
toolshed=3D# explain analyze select * from stock_log_positions=20 +;
           &nbs= +p;            &= +nbsp;           &nbs= +p;            &= +nbsp;    =20 +QUERY=20 +PLAN            = +;            &n= +bsp;            = +;            &n= +bsp;     =20 +
-----------------------------------------------------------------------= +--------------------------------------------------
 Seq=20 +Scan on stock_log_positions  (cost=3D0.00..10757.37 rows=3D613737 widt= +h=3D22)=20 +(actual time=3D789.21..789.24 rows=3D2 loops=3D1)
 Total runtime: 7= +89.40=20 +msec
(2 rows)
+
 
+
toolshed=3D# select * from stock_log_positions ;
  when_log&nb= +sp;=20 +|   filename   | position=20 +
------------+--------------+----------
 2003-12-11 | ActiveTrad= +er=20 +|        0
 2003-12-11 |=20 +Headlines    |        0(2=20 +rows)
+------_=_NextPart_001_01C3C100.F1020EA8-- + +From pgsql-performance-owner@postgresql.org Fri Dec 12 18:59:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C72EFD1B488 + for ; + Fri, 12 Dec 2003 22:59:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08281-06 + for ; + Fri, 12 Dec 2003 18:59:16 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 2BB05D1B4AD + for ; + Fri, 12 Dec 2003 18:59:14 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hBCMxDU6012627 + for ; Fri, 12 Dec 2003 22:59:13 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hBCMjO55097997 + for pgsql-performance@postgresql.org; Fri, 12 Dec 2003 22:45:24 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Update on putting WAL on ramdisk/ +Date: Fri, 12 Dec 2003 14:45:31 -0800 +Organization: Hub.Org Networking Services +Lines: 18 +Message-ID: +References: + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +In-Reply-To: +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/209 +X-Sequence-Number: 5069 + +Russell Garrett wrote: +>>WAL on single drive: 7.990 rec/s +>>WAL on 2nd IDE drive: 8.329 rec/s +>>WAL on tmpfs: 13.172 rec/s +>> +>>A huge jump in performance but a bit scary having a WAL that can +>>disappear at any time. I'm gonna workup a rsync script and do some +>>power-off experiments to see how badly it gets mangled. +> +> +> Surely this is just equivalent to disabling fsync? If you put a WAL on a +> volatile file system, there's not a whole lot of point in having one at all. + +These tests were all with fsync off. + +And no, it's not equivalent to fsync off since the WAL is always written +immediately regardless of fsync setting. + + +From pgsql-admin-owner@postgresql.org Fri Dec 12 19:45:56 2003 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 1B70BD1B495; Fri, 12 Dec 2003 23:11:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08644-05; Fri, 12 Dec 2003 19:10:40 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP + id E4A7AD1CC78; Fri, 12 Dec 2003 19:10:36 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 6BC5D205E; Fri, 12 Dec 2003 18:10:22 -0500 (EST) +To: aspire420@hotpop.com +Cc: pgsql-admin@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Tables Without OIDS and its effect +From: Neil Conway +In-Reply-To: <3FD9E916.8050005@sancharnet.in> (Sai Hertz And Control + Systems's message of "Fri, 12 Dec 2003 21:43:10 +0530") +References: <3FD9E916.8050005@sancharnet.in> +Date: Fri, 12 Dec 2003 18:10:21 -0500 +Message-ID: <87he05pr8i.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/178 +X-Sequence-Number: 11685 + +Sai Hertz And Control Systems writes: +> I have created my tables without OIDS now my doubts are : +> 1. Will this speed up the data insertion process + +Slightly. It means that each inserted row will be 4 bytes smaller (on +disk), which in turn means you can fit more tuples on a page, and +therefore you'll need fewer pages and less disk space. However, I'd be +surprised if the performance improvement is very significant. + +> 2. Though I have not written any code in my any of the pgsql functions +> which depend on OIDS +> 1. Will without OIDS the functions behave internally differently +> 2. Will my application break at any point + +No. + +BTW, we intend to phase out the use of OIDs for user tables in the +long term. There have been a few threads on -hackers that discuss the +plans for doing this. + +-Neil + + +From pgsql-admin-owner@postgresql.org Sat Dec 13 06:34:37 2003 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 7FAAFD1B4B4; Sat, 13 Dec 2003 10:34:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84123-04; Sat, 13 Dec 2003 06:34:05 -0400 (AST) +Received: from ndl1mr1-a-fixed.sancharnet.in (ndl1mr1-a-fixed.sancharnet.in + [61.0.0.45]) by svr1.postgresql.org (Postfix) with ESMTP + id D388DD1B462; Sat, 13 Dec 2003 06:34:01 -0400 (AST) +Received: from conversion-daemon.ndl1mr1-a-fixed.sancharnet.in by + ndl1mr1-a-fixed.sancharnet.in + (iPlanet Messaging Server 5.2 HotFix 1.17 (built Jun 23 2003)) + id <0HPT00E01X538I@ndl1mr1-a-fixed.sancharnet.in>; Sat, + 13 Dec 2003 15:59:48 +0530 (IST) +Received: from sancharnet.in ([61.0.95.123]) by ndl1mr1-a-fixed.sancharnet.in + (iPlanet Messaging Server 5.2 HotFix 1.17 (built Jun 23 2003)) + with ESMTPA id <0HPT00899X4TZ0@ndl1mr1-a-fixed.sancharnet.in>; Sat, + 13 Dec 2003 15:59:48 +0530 (IST) +Date: Sat, 13 Dec 2003 16:03:37 +0530 +From: Sai Hertz And Control Systems +Subject: Re: [PERFORM] Tables Without OIDS and its effect +In-reply-to: <87he05pr8i.fsf@mailbox.samurai.com> +To: Neil Conway +Cc: aspire420@hotpop.com, Postgres Admin List , + pgsql-performance@postgresql.org +Reply-To: aspire420@hotpop.com +Message-id: <3FDAEB01.3040200@sancharnet.in> +Organization: Sai Hertz And Control Systems +MIME-version: 1.0 +Content-type: multipart/alternative; + boundary="Boundary_(ID_xtW9LKqOugmqp3bRWinEDw)" +X-Accept-Language: en-us, en +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6b) + Gecko/20031205 Thunderbird/0.4 +References: <3FD9E916.8050005@sancharnet.in> + <87he05pr8i.fsf@mailbox.samurai.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/179 +X-Sequence-Number: 11686 + +This is a multi-part message in MIME format. + +--Boundary_(ID_xtW9LKqOugmqp3bRWinEDw) +Content-type: text/plain; charset=us-ascii; format=flowed +Content-transfer-encoding: 7BIT + +Hello Neil Conway, + +We are doing some test on our applications and will let know the +community if without OIDS we could gain +more speed . + +>>2. Though I have not written any code in my any of the pgsql functions +>>which depend on OIDS +>> 1. Will without OIDS the functions behave internally differently +>> 2. Will my application break at any point +>> +>> +> +>No. +> +>BTW, we intend to phase out the use of OIDs for user tables in the +>long term. There have been a few threads on -hackers that discuss the +>plans for doing this. +> +> +This was a relief for us all , but an the same time we have found one +incompatibility + +This incompatibility is with +1. StarOffice 7.0 +2. OpenOffice 1.1 +and the incompatibility is when I retrieve data into Star SpreadSheet +or Open Office SpreadSheet +I am greeted with an error field *OID* not found. +Though these both are connecting to PostgreSQL 7.3.4 (Linux GCC 3.x) +via psqlODBC 07.02.0003 +On the Same time WinSQL connects as usual via psqlODBC 07.02.0003 and +is working fine. + +Though this does not effect us a lot since we are using PHP to show +and retrieve data +We are posting this such that any one relying totally on OpenOffice for +data retrieve and display +better know this , + +Our Test config was: +-------------------------- +Client :- +O.S Win XP (No service pack) +OpenOffice 1.1 Windows version +StarOffice 7.0 Eval Pack +psqlODBC 07.02.0003 +Server :- +OS RH 9.0 kernel-2.4.20-24.9 +PostgreSQL 7.3.4 + +Please if anyone has a different story while using WITHOUT OIDS +please let us and every one know . + + +Regards, +V Kashyap + + + + + +--Boundary_(ID_xtW9LKqOugmqp3bRWinEDw) +Content-type: text/html; charset=us-ascii +Content-transfer-encoding: 7BIT + + + + + + + + +Hello  Neil Conway,
+
+We are doing some test on our applications and will let know the +community  if without OIDS we could gain
+more speed .
+
+
+
2. Though I have not written any code in my any of the pgsql functions
+which depend on OIDS
+  1. Will without OIDS the functions behave internally differently
+  2. Will my application break at any point
+    
+
+

+No.
+
+BTW, we intend to phase out the use of OIDs for user tables in the
+long term. There have been a few threads on -hackers that discuss the
+plans for doing this.
+  
+
+This was a relief  for us all , but an the same time we have found one +incompatibility
+
+This incompatibility is with
+1.  StarOffice 7.0
+2. OpenOffice 1.1
+and the incompatibility is when I retrieve data into Star SpreadSheet +or  Open Office SpreadSheet
+I am greeted with an error field OID  not found.
+Though these both are connecting to PostgreSQL  7.3.4 (Linux GCC 3.x) +via psqlODBC  07.02.0003
+On the Same time WinSQL connects as usual via psqlODBC  07.02.0003  and +is working fine.
+
+Though  this does not  effect us a lot since we are using PHP to show +and retrieve data
+We are posting this such that any one relying totally on OpenOffice for +data  retrieve and display
+better know this ,
+
+Our Test config was:
+--------------------------
+Client :-
+O.S           Win XP (No service pack)
+OpenOffice    1.1  Windows version
+StarOffice      7.0   Eval Pack
+psqlODBC 07.02.0003
+Server  :-
+OS                      RH 9.0 kernel-2.4.20-24.9
+PostgreSQL       7.3.4
+
+Please if anyone has a different story  while using  WITHOUT  OIDS +please let us and every one know .
+
+
+Regards,
+V Kashyap
+
+
+
+
+ + + +--Boundary_(ID_xtW9LKqOugmqp3bRWinEDw)-- + +From pgsql-performance-owner@postgresql.org Sat Dec 13 14:39:18 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 33968D1DDE9 + for ; + Sat, 13 Dec 2003 18:39:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 23546-05 + for ; + Sat, 13 Dec 2003 14:38:54 -0400 (AST) +Received: from purple.bdb.fi (purple.bdb.fi [195.197.212.62]) + by svr1.postgresql.org (Postfix) with ESMTP id 8DE35D1DD50 + for ; + Sat, 13 Dec 2003 14:38:47 -0400 (AST) +Received: by purple.bdb.fi (Postfix, from userid 101) + id 4BF092FA8; Sat, 13 Dec 2003 20:38:53 +0200 (EET) +Received: from localhost (localhost [127.0.0.1]) + by purple.bdb.fi (Postfix) with ESMTP id 138722F9B + for ; + Sat, 13 Dec 2003 20:38:52 +0200 (EET) +Date: Sat, 13 Dec 2003 20:38:52 +0200 (EET) +From: Kari Lavikka +To: pgsql-performance@postgresql.org +Subject: a lot of problems with pg 7.4 +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/212 +X-Sequence-Number: 5072 + + +Hi! + +We have been running a rather busy website using pg 7.3 as the database. +Peak hitrate is something like 120 request / second without images and +other static stuff. The site is a sort of image gallery for IRC users. + +I evaluated pg 7.4 on our development server and it looked just fine +but performance with production loads seems to be quite poor. Most of +performance problems are caused by nonsensical query plans but there's +also some strange slowness that I can't locate. + + +I have included the essential tables, columns and indexes that +participate to queries in this mail. + +table rows +------- ---- +users 50k +image 400k +comment 17M + + Table "public.users" + Column | Type | +-------------+-----------------------------+ + uid | integer | + nick | character varying(40) | + status | character(1) | +Indexes: + "users_pkey" primary key, btree (uid) + "users_upper_nick" unique, btree (upper((nick)::text)) + "users_status" btree (status) + + Table "public.image" + Column | Type | +----------------------+-----------------------------+ + image_id | integer | + uid | integer | + status | character(1) | +Indexes: + "image_pkey" primary key, btree (image_id) + "image_uid_status" btree (uid, status) + + Table "public.comment" + Column | Type | +------------+-----------------------------+ + comment_id | integer | + image_id | integer | + uid_sender | integer | + comment | character varying(255) | +Indexes: + "comment_pkey" primary key, btree (comment_id) + "comment_image_id" btree (image_id) + "comment_uid_sender" btree (uid_sender) + + + +Planner estimates the cost of nested loop to be much higher than +hash join _although_ the other side of join consists of only one +row (which is found using a unique index). Well, bad estimation. +Difference in runtime is huge. + + +galleria=# explain analyze SELECT i.image_id, i.info, i.stamp, i.status, i.t_width, i.t_height, u.nick, u.uid FROM users u INNER JOIN image i ON i.uid = u.uid WHERE upper(u.nick) = upper('Intuitio') AND (i.status = 'd' OR i.status = 'v') AND u.status = 'a' ORDER BY status, stamp DESC; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=21690.23..21694.22 rows=1595 width=64) (actual time=2015.615..2015.637 rows=35 loops=1) + Sort Key: i.status, i.stamp + -> Hash Join (cost=907.20..21605.38 rows=1595 width=64) (actual time=891.400..2015.464 rows=35 loops=1) + Hash Cond: ("outer".uid = "inner".uid) + -> Seq Scan on image i (cost=0.00..18207.19 rows=330005 width=54) (actual time=0.012..1607.278 rows=341086 loops=1) + Filter: ((status = 'd'::bpchar) OR (status = 'v'::bpchar)) + -> Hash (cost=906.67..906.67 rows=213 width=14) (actual time=0.128..0.128 rows=0 loops=1) + -> Index Scan using users_upper_nick on users u (cost=0.00..906.67 rows=213 width=14) (actual time=0.120..0.122 rows=1 loops=1) + Index Cond: (upper((nick)::text) = 'INTUITIO'::text) + Filter: (status = 'a'::bpchar) + Total runtime: 2015.756 ms + +galleria=# set enable_hashjoin = false; +SET + +galleria=# explain analyze SELECT i.image_id, i.info, i.stamp, i.status, i.t_width, i.t_height, u.nick, u.uid FROM users u INNER JOIN image i ON i.uid = u.uid WHERE upper(u.nick) = upper('Intuitio') AND (i.status = 'd' OR i.status = 'v') AND u.status = 'a' ORDER BY status, stamp DESC; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=31090.72..31094.71 rows=1595 width=64) (actual time=5.240..5.267 rows=35 loops=1) + Sort Key: i.status, i.stamp + -> Nested Loop (cost=0.00..31005.87 rows=1595 width=64) (actual time=4.474..5.082 rows=35 loops=1) + -> Index Scan using users_upper_nick on users u (cost=0.00..906.67 rows=213 width=14) (actual time=3.902..3.906 rows=1 loops=1) + Index Cond: (upper((nick)::text) = 'INTUITIO'::text) + Filter: (status = 'a'::bpchar) + -> Index Scan using image_uid_status on image i (cost=0.00..141.03 rows=23 width=54) (actual time=0.537..0.961 rows=35 loops=1) + Index Cond: (i.uid = "outer".uid) + Filter: ((status = 'd'::bpchar) OR (status = 'v'::bpchar)) + Total runtime: 5.479 ms +(10 rows) + +Is there anything to do for this besides forcing hashjoin off? +I think there were similar problems with 7.3 + + + +Now something specific to 7.4. + +The following query selects all comments written to user's image. It worked +just fine with pg 7.3 but there seems to be a Materialize in a bit strange place. + +galleria=# explain SELECT s.nick, c.comment, c.private, c.admin, c.parsable, c.uid_sender, c.stamp, i.image_id, c.comment_id FROM users s, comment c, image i WHERE s.uid = c.uid_sender AND s.status = 'a' AND c.visible = 'y' AND c.image_id = i.image_id AND i.image_id = 184239 ORDER BY c.comment_id DESC; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------- + Sort (cost=1338.43..1339.41 rows=392 width=92) + Sort Key: c.comment_id + -> Nested Loop (cost=1308.41..1321.54 rows=392 width=92) + -> Index Scan using image_pkey on image i (cost=0.00..5.29 rows=2 width=4) + Index Cond: (image_id = 184239) + -> Materialize (cost=1308.41..1310.37 rows=196 width=92) + -> Nested Loop (cost=0.00..1308.41 rows=196 width=92) + -> Index Scan using comment_image_id on "comment" c (cost=0.00..60.68 rows=207 width=82) + Index Cond: (184239 = image_id) + Filter: (visible = 'y'::bpchar) + -> Index Scan using users_pkey on users s (cost=0.00..6.02 rows=1 width=14) + Index Cond: (s.uid = "outer".uid_sender) + Filter: (status = 'a'::bpchar) + + +However, when the joins are written in a different style the plan seems to be just right. + +galleria=# explain SELECT u.nick, c.comment, c.private, c.admin, c.parsable, c.uid_sender, c.stamp, i.image_id, c.comment_id FROM image i INNER JOIN comment c ON c.image_id = i.image_id INNER JOIN users u ON u.uid = c.uid_sender WHERE c.visible = 'y' AND c.image_id = i.image_id AND i.image_id = 184239 ORDER BY c.comment_id DESC; + QUERY PLAN +------------------------------------------------------------------------------------------------------- + Sort (cost=17.76..17.76 rows=1 width=92) + Sort Key: c.comment_id + -> Nested Loop (cost=0.00..17.75 rows=1 width=92) + -> Nested Loop (cost=0.00..11.72 rows=1 width=82) + -> Index Scan using image_pkey on image i (cost=0.00..5.29 rows=2 width=4) + Index Cond: (image_id = 184239) + -> Index Scan using comment_image_id on "comment" c (cost=0.00..3.20 rows=1 width=82) + Index Cond: ((c.image_id = "outer".image_id) AND (184239 = c.image_id)) + Filter: (visible = 'y'::bpchar) + -> Index Scan using users_pkey on users u (cost=0.00..6.01 rows=1 width=14) + Index Cond: (u.uid = "outer".uid_sender) +(11 rows) + + + +I happened to look into this query when one of them got stuck. Normally +postgres performs tens of these in a second, but after shutting down +the web server one them was still running. I gathered some statistics +and the runtime was something like half an hour! It was causing pretty +much disk io but quite little cpu load. Don't know what it was doing... + + +galleria=# select * from pg_stat_activity where current_query != ''; + datid | datname | procpid | usesysid | usename | current_query | query_start +-------+----------+---------+----------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------- + 17144 | galleria | 27849 | 100 | galleria | SELECT s.nick, c.comment, c.private, c.admin, c.parsable, c.uid_sender, c.stamp, i.image_id, c.comment_id FROM users s, comment c, image i WHERE s.uid = c.uid_sender AND s.status = 'a' AND c.visible = 'y' AND c.image_id = i.image_id AND i.image_id = 95406 | 2003-12-08 19:15:10.218859+02 +(1 row) + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ Command +29756 tuner 25 0 1212 1212 800 R 42.7 0.0 2:51.03 top +27849 postgres 15 0 783m 783m 780m D 6.2 20.0 0:55.86 postmaster + +procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- + r b swpd free buff cache si so bi bo in cs us sy id wa + 0 1 90912 551104 16180 3195612 0 0 2724 0 692 628 5 0 95 0 + 0 1 90912 548280 16192 3198464 0 0 2864 0 810 689 3 2 95 0 + 1 0 90912 545644 16192 3201068 0 0 2604 0 686 663 5 1 95 0 + 0 1 90912 542980 16192 3203712 0 0 2644 0 684 673 3 1 96 0 + 1 0 90912 540260 16220 3206480 0 0 2780 40 827 684 4 1 95 0 + 0 1 90912 537724 16224 3209032 0 0 2556 0 613 666 3 0 97 0 + 0 1 90912 534920 16224 3211840 0 0 2808 0 658 714 6 0 94 0 + 0 1 90912 532172 16224 3214596 0 0 2756 0 678 769 5 0 95 0 + + + +There's some other slowness with 7.4 as well. After running just fine for several +hours pg starts to eat a LOT of cpu. Query plans are just like normally and +pg_stat_activity shows nothing special. Disconnecting and reconnecting all clients +seems to help (restarting web server). + + +hw/sw configuration is something like this: +Dual Xeon 2.8GHz with 4GB of memory. RAID is fast enuff. +Linux 2.4 (Debian) + +Postgres is compiled using gcc 3.2, cflags: CFLAGS=-march=pentium4 -O3 -msse2 -mmmx + + + + + |\__/| + ( oo ) Kari Lavikka - tuner@bdb.fi - (050) 380 3808 +__ooO( )Ooo_______ _____ ___ _ _ _ _ _ _ _ + "" + +From pgsql-performance-owner@postgresql.org Sat Dec 13 18:57:51 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AA64CD1B467 + for ; + Sat, 13 Dec 2003 22:57:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48980-02 + for ; + Sat, 13 Dec 2003 18:57:26 -0400 (AST) +Received: from visionlink.org (mail.visionlink.org [208.139.207.159]) + by svr1.postgresql.org (Postfix) with SMTP id 4D613D1B465 + for ; + Sat, 13 Dec 2003 18:57:17 -0400 (AST) +Received: from [65.100.170.142] (HELO [192.168.1.201]) by visionlink.org + (Stalker SMTP Server 1.8b8) with ESMTP id S.0002315554 for + ; Sat, 13 Dec 2003 15:58:15 -0700 +Mime-Version: 1.0 +X-Sender: bohmer@mail.visionlink.org +Message-Id: +In-Reply-To: +References: +Date: Sat, 13 Dec 2003 15:57:04 -0700 +To: pgsql-performance@postgresql.org +From: Jeff Bohmer +Subject: Re: Hardware suggestions for Linux/PGSQL server +Content-Type: text/plain; charset="us-ascii" ; format="flowed" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/213 +X-Sequence-Number: 5073 + +>Just one more piece of advice, you might want to look into a good battery +>backed cache hardware RAID controller. They work quite well for heavily +>updated databases. The more drives you throw at the RAID array the faster +>it will be. + +I've seen this list often recommended such a setup. We'll probably +get battery-backed write cache and start out with a 4 disk RAID 10 +array. Then add more disks and change RAID 5 if more read +performance is needed. + +Thanks, +- Jeff +-- + +Jeff Bohmer +VisionLink, Inc. +_________________________________ +303.402.0170 +www.visionlink.org +_________________________________ +People. Tools. Change. Community. + +From pgsql-performance-owner@postgresql.org Sat Dec 13 19:01:05 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F2430D1B4D3 + for ; + Sat, 13 Dec 2003 23:01:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 49422-02 + for ; + Sat, 13 Dec 2003 19:00:40 -0400 (AST) +Received: from visionlink.org (mail.visionlink.org [208.139.207.159]) + by svr1.postgresql.org (Postfix) with SMTP id D4A84D1B467 + for ; + Sat, 13 Dec 2003 19:00:31 -0400 (AST) +Received: from [65.100.170.142] (HELO [192.168.1.201]) by visionlink.org + (Stalker SMTP Server 1.8b8) with ESMTP id S.0002315566 for + ; Sat, 13 Dec 2003 16:01:46 -0700 +Mime-Version: 1.0 +X-Sender: bohmer@mail.visionlink.org +Message-Id: +In-Reply-To: +References: + + <3FD961C5.9070204@persistent.co.in> +Date: Sat, 13 Dec 2003 16:00:32 -0700 +To: pgsql-performance@postgresql.org +From: Jeff Bohmer +Subject: Re: Hardware suggestions for Linux/PGSQL server +Content-Type: text/plain; charset="us-ascii" ; format="flowed" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/214 +X-Sequence-Number: 5074 + + +>Shridhar Daithankar wrote: +>> +>>FWIW, there are only two pieces of software that need 64bit aware +>>for a typical server job. Kernel and glibc. Rest of the apps can do +>>fine as 32 bits unless you are oracle and insist on outsmarting OS. +>> +>>In fact running 32 bit apps on 64 bit OS has plenty of advantages +>>like effectively using the cache. Unless you need 64bit, going for +>>64bit software is not advised. +> +>This is a good point. While doing research on this matter a few +>months back, I saw comments by people testing 64-bit MySQL that some +>operations would run faster and some slower due to the use of 64-bit +>datatypes versus 32-bit. The best solution in the end is probably to +>run 32-bit Postgres under a 64-bit kernel -- unless your DB tends to +>have a lot of 64-bit datatypes. + + +Thanks Shridhar and William, + +This advice has been very helpful. I would imagine a lot of folks +are, or will soon be looking at 32- vs. 64-bit just for memory +reasons and not 64-bit apps. + +- Jeff +-- + +Jeff Bohmer +VisionLink, Inc. +_________________________________ +303.402.0170 +www.visionlink.org +_________________________________ +People. Tools. Change. Community. + +From pgsql-performance-owner@postgresql.org Sun Dec 14 01:42:39 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F08F0D1B482 + for ; + Sun, 14 Dec 2003 05:42:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 79311-06 + for ; + Sun, 14 Dec 2003 01:42:22 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 63E3AD1B442 + for ; + Sun, 14 Dec 2003 01:42:09 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hBE5gLI21410; + Sun, 14 Dec 2003 00:42:21 -0500 (EST) +From: Bruce Momjian +Message-Id: <200312140542.hBE5gLI21410@candle.pha.pa.us> +Subject: Re: Tuning for mid-size server +In-Reply-To: <20031021213408.GA12200@libertyrms.info> +To: Andrew Sullivan +Date: Sun, 14 Dec 2003 00:42:21 -0500 (EST) +Cc: pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/215 +X-Sequence-Number: 5075 + +Andrew Sullivan wrote: +> On Tue, Oct 21, 2003 at 03:11:17PM -0600, scott.marlowe wrote: +> > I think where it makes sense is when you have something like a report +> > server where the result sets may be huge, but the parellel load is load, +> > i.e. 5 or 10 users tossing around 100 Meg or more at time. +> +> In our case, we were noticing that truss showed an unbelievable +> amount of time spent by the postmaster doing open() calls to the OS +> (this was on Solaris 7). So we thought, "Let's try a 2G buffer +> size." 2G was more than enough to hold the entire data set under +> question. Once the buffer started to fill, even plain SELECTs +> started taking a long time. The buffer algorithm is just not that +> clever, was my conclusion. +> +> (Standard disclaimer: not a long, controlled test. It's just a bit +> of gossip.) + +I know this is an old email, but have you tested larger shared buffers +in CVS HEAD with Jan's new cache replacement policy? + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Sun Dec 14 01:44:18 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3ADF5D1B442 + for ; + Sun, 14 Dec 2003 05:44:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 78697-07 + for ; + Sun, 14 Dec 2003 01:43:59 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id A6447D1B4D5 + for ; + Sun, 14 Dec 2003 01:43:46 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id hBE5i0v21938 + for pgsql-performance@postgresql.org; + Sun, 14 Dec 2003 00:44:00 -0500 (EST) +From: Bruce Momjian +Message-Id: <200312140544.hBE5i0v21938@candle.pha.pa.us> +Subject: Update performance doc +In-Reply-To: +To: pgsql-performance@postgresql.org +Date: Sun, 14 Dec 2003 00:44:00 -0500 (EST) +X-Mailer: ELM [version 2.4ME+ PL108 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/216 +X-Sequence-Number: 5076 + +I have updated my hardware performance documentation to reflect the +findings during the past few months on the performance list: + + http://candle.pha.pa.us/main/writings/pgsql/hw_performance/index.html + +Thanks. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Sun Dec 14 03:24:02 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DF6BD1D8EB + for ; + Sun, 14 Dec 2003 07:24:01 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 86498-06 + for ; + Sun, 14 Dec 2003 03:23:45 -0400 (AST) +Received: from flamingo.mail.pas.earthlink.net + (flamingo.mail.pas.earthlink.net [207.217.120.232]) + by svr1.postgresql.org (Postfix) with ESMTP id 553DDD1BB74 + for ; + Sun, 14 Dec 2003 03:23:32 -0400 (AST) +Received: from hsa070.pool014.at101.earthlink.net ([216.249.85.70] + helo=shadovitzcmptr) + by flamingo.mail.pas.earthlink.net with smtp (Exim 3.33 #1) + id 1AVQbM-0004Yv-00; Sat, 13 Dec 2003 23:23:40 -0800 +Received: by localhost with Microsoft MAPI; Sat, 13 Dec 2003 23:22:05 -0800 +Message-ID: <01C3C1CF.EC044640.david@shadovitz.com> +From: David Shadovitz +Reply-To: "david@shadovitz.com" +To: "'pgsql-performance@postgresql.org'" +Cc: 'Tom Lane' +Subject: Re: Query plan - now what? +Date: Sat, 13 Dec 2003 23:21:36 -0800 +X-Mailer: Microsoft Internet E-mail/MAPI - 8.0.0.4211 +MIME-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=1.0 tagged_above=0.0 required=5.0 tests=BAYES_30, + RCVD_IN_OSIRUSOFT_COM, UPPERCASE_25_50 +X-Spam-Level: * +X-Archive-Number: 200312/217 +X-Sequence-Number: 5077 + +Here are my query and schema. The ERD is at http://dshadovi.f2o.org/pg_erd.jpg +(sorry about its resolution). +-David + +SELECT + zbr.zebra_name + , dog.dog_name + , mnk.monkey_name + , wrm.abbreviation || ptr.abbreviation as abbrev2 + , whg.warthog_num + , whg.color + , rhn.rhino_name + , der.deer_name + , lin.designator + , frg.frog_id + , frg.sound_id + , tgr.tiger_name + , frg.leg_length + , frg.jump_distance +FROM + frogs frg + , deers der + , warthogs whg + , rhinos rhn + , zebras zbr + , dogs dog + , monkeys mnk + , worms wrm + , parrots prt + , giraffes grf + , lions lin + , tigers tgr +WHERE 1 = 1 +AND frg.deer_id = der.deer_id +AND whg.whg_id = frg.frg_id +AND frg.rhino_id = rhn.rhino_id +AND zbr.zebra_id = dog.zebra_id +AND dog.dog_id = mky.dog_id +AND mky.dog_id = whg.dog_id +AND mky.monkey_num = whg.monkey_num +AND whg.worm_id = wrm.worm_id +AND whg.parrot_id = prt.parrot_id +AND prt.beak = 'L' +AND frg.frog_id = grf.frog_id +AND grf.lion_id = lin.lion_id +AND frg.tiger_id = tgr.tiger_id +; + + +CREATE TABLE zebras ( + zebra_id INTEGER NOT NULL, + zebra_name VARCHAR(25), + PRIMARY KEY (zebra_id), + UNIQUE (zebra_name)); + +CREATE TABLE dogs ( + zebra_id INTEGER NOT NULL, + dog_id INTEGER NOT NULL, + dog_name VARCHAR(25), + FOREIGN KEY (zebra_id) REFERENCES zebras (zebra_id), + PRIMARY KEY (dog_id), + UNIQUE (dog_name, dog_num)); + +CREATE TABLE monkeys ( + dog_id INTEGER NOT NULL, + monkey_num INTEGER, + monkey_name VARCHAR(25), + PRIMARY KEY (dog_id, monkey_num), + FOREIGN_KEY (dog_id) REFERENCES dogs (dog_id)); + +CREATE INDEX mnk_dog_id_idx ON monkeys (dog_id); +CREAIE INDEX mnk_mnk_num_idx ON monkeys (monkey_num); + +CREATE TABLE warthogs ( + warthog_id INTEGER NOT NULL, + warthog_num INTEGER, + color VARCHAR(25) NOT NULL, + dog_id INTEGER NOT NULL, + monkey_num INTEGER NOT NULL, + parrot_id INTEGER, + beak CHAR(l), + worm_id INTEGER, + PRIMARY KEY (warthog_id), + FOREIGN KEY (parrot_id, beak) REFERENCES parrots (parrot_id, beak) + FOREIGN KEY (dog_id, monkey_num) REFERENCES monkeys (dog_id, monkey_nun) + FOREIGN KEY (worm_id) REFERENCES worms (worm_id)); + +CREATE UNIQUE INDEX whg_whg_id_idx ON warthogs (warthog_id) +CREATE INDEX whg_dog_id_idx ON warthogs (dog_id); +CREATE INDEX whg_mnk_num_idx ON warthogs (monkey_num) +CREATE INDEX whg_wrm_id_idx ON warthogs (worm_id); +CREATE INDEX IDX_warthogs_1 ON warthogs (monkey_num, dog_id) +CREATE INDEX lOX warthogs_2 ON warthogs (beak, parrot_id); + +CREATE TABLE worms ( + worm_id INTEGER NOT NULL, + abbreviation CHAR(l), + PRIMARY KEY worm_id)); + +CREATE TABLE parrots ( + parrot_id INTEGER NOT NULL, + beak CHAR(1) NOT NULL, + abbreviation CHAR(1), + PRIMARY KEY (parrot_id, beak)); + +CREATE INDEX prt_prt_id_idx ON parrots (parrot_id) +CREATE INDEX prt_beak_idx ON parrots (beak): + +CREATE TABLE deers ( + deer_id INTEGER NOT NULL, + deer_name VARCHAR(40), + PRIMARY KEY (deer_id)); + +CREATE UNIQUE INDEX der_der_id_unq_idx ON deers (deer_id); + +CREATE TABLE rhinos ( + rhino_id INTEGER NOT NULL, + rhino_name VARCHAR(255), + CONSTRAINT rhn_rhn_name_unique UNIQUE, + CONSTRAINT PK_rhn PRIMARY KEY (rhino_id)); + +CREATE UNIQUE INDEX rhn_rhn_id_unq_idx ON rhinos (rhino_id); + +CREATE TABLE tigers ( + tiger_id INTEGER NOT NULL, + tiger_name VARCHAR(255), + PRIMARY KEY (tiger_id)); + +CREATE UNIQUE INDEX tgr_tgr_id_unq_idx ON tigers (tiger_id); + +CREATE TABLE frogs ( + frog_id INTEGER NOT NULL, + warthog_id INTEGER NOT NULL, + rhino_id INTEGER NOT NULL, + deer_id INTEGER NOT NULL, + sound_id INTEGER, + tiger_id INTEGER, + leg_length VARCHAR(255), + jump_distance VARCHAR(lOO), + PRIMARY KEY (frog_id)); + +ALTER TABLE frogs ADD FOREIGN KEY (warthog_id) REFERENCES warthogs +(warthog_id), +ALTER TABLE frogs ADD FOREIGN KEY (rhino_id) REFERENCES rhinos (rhino_id); +ALTER TABLE frogs ADD FOREIGN KEY (deer id) REFERENCES deers (deer_id) +ALTER TABLE frogs ADD FOREIGN KEY (sound_id) REFERENCES sounds (sound id); +ALTER TABLE frogs ADD FOREIGN KEY (tiger_id) REFERENCES tigers (tiger_id); + +CREATE UNIQUE INDEX frg_frg_id_unq_idx ON frogs (frog_id); +CREATE UNIQUE INDEX frg_w_r_d_t_unq_idx ON frogs (warthog_id, rhino_id, +deer_id, tiger_id); +CREATE INDEX frg_whg_id_idx ON frogs (warthog_id); +CREATE INDEX frg rhn_id_idx ON frogs (rhino_id); +CREATE INDEX frg_der_id_idx ON frogs (deer_id); +CREATE INDEX frg_snd_id_idx ON frogs (sound_id); +CREATE INDEX frg_tgr_id_idx ON frogs (tiger_id); + +CREATE TABLE lions ( + lion_id INTEGER NOT NULL, + deer_id INTEGER, + PRIMARY KEY (lion_id)); + +CREATE UNIQUE INDEX lin_lin_id_unq_idx ON lions (lion_id); + +CREATE TABLE frogs_lions ( + frog_id INTEGER NOT NULL, + lion_id INTEGER NOT NULL, + PRIMARY KEY (frog_id, lion_id)); + +ALTER TABLE frogs_lions ADD FOREIGN KEY (lion_id) REFERENCES lions (lion_id); +ALTER TABLE frogs_lions ADD FOREIGN KEY (frog id) REFERENCES frogs (frog_id); + +CREATE UNIQUE INDEX frg_lin_frg_id_lin_id_unq_idx ON frogs_lions (frog_id, +lion_id); +CREATE INDEX frg_lin_lin_id_idx ON frogs_lions (lion_id); +CREATE INDEX frg_lin_frg_id_idx ON frogs_lions (frog_id); + + + +From pgsql-performance-owner@postgresql.org Sun Dec 14 05:55:14 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B5DE9D1DB0B + for ; + Sun, 14 Dec 2003 09:55:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97024-05 + for ; + Sun, 14 Dec 2003 05:54:55 -0400 (AST) +Received: from kiwi.iasi.rdsnet.ro (kiwi.iasi.rdsnet.ro [213.157.176.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E0AED1DAE9 + for ; + Sun, 14 Dec 2003 05:54:41 -0400 (AST) +Received: from blackblue.iasi.rdsnet.ro (blackblue.iasi.rdsnet.ro + [213.157.176.7]) + by kiwi.iasi.rdsnet.ro (8.12.9/8.12.9) with ESMTP id hBE9sfrv013841 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Sun, 14 Dec 2003 11:54:41 +0200 +Received: from blackblue.iasi.rdsnet.ro (localhost.localdomain [127.0.0.1]) + by blackblue.iasi.rdsnet.ro (8.12.9/8.12.9) with ESMTP id + hBE9sfxd015236 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Sun, 14 Dec 2003 11:54:41 +0200 +Received: from localhost (Mituc@localhost) + by blackblue.iasi.rdsnet.ro (8.12.9/8.12.9/Submit) with ESMTP id + hBE9sfZL015232; Sun, 14 Dec 2003 11:54:41 +0200 +X-Authentication-Warning: blackblue.iasi.rdsnet.ro: Mituc owned process doing + -bs +Date: Sun, 14 Dec 2003 11:54:41 +0200 (EET) +From: Tarhon-Onu Victor +To: Kari Lavikka +Cc: pgsql-performance@postgresql.org +Subject: Re: a lot of problems with pg 7.4 +In-Reply-To: +Message-ID: +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/218 +X-Sequence-Number: 5078 + +On Sat, 13 Dec 2003, Kari Lavikka wrote: + +> I evaluated pg 7.4 on our development server and it looked just fine +> but performance with production loads seems to be quite poor. Most of +> performance problems are caused by nonsensical query plans but there's +> also some strange slowness that I can't locate. + + I had the same problem. I use Fedora Core 1 and after I updated +from 7.4RC1/7.4RC2 (I build my own RPMs) to 7.4 using the binary RPMs +from a mirror site and sometimes I had to restart postmaster to make +something work. + I rebuilt the src.rpm from current rawhide (7.4-5) and now +everything is ok. The guys from redhat/fedora also add some patches +(rpm-pgsql-7.4.patch seems to be the most important, the rest seem to be +for a proper compile) but I didn't have the time to test if the loss of +performance is because in the original binary RPMs from postgresql.org +the patch(es) is(are) not present, because of the compiler and optflags +used to build the RPMs are not chosed well or something else. I used gcc +3.3.2 (from FC1 distro) and the following optflags: + +- On a P4 machine: optflags: i686 -O2 -g -march=pentium4 -msse2 -mfpmath=sse -fomit-frame-pointer -fforce-addr -fforce-mem -maccumulate-outgoing-args -finline-limit=2048 + +- On a Celeron Tualatin: optflags: i686 -O2 -g -march=pentium3 -msse -mfpmath=sse -fomit-frame-pointer -fforce-addr -fforce-mem -maccumulate-outgoing-args -finline-limit=2048 + + So, if you use the original binaries from postgresql.org try to +recompile from sources setting CFLAGS and CXXFLAGS to proper values +(maybe -msse2 -mfpmath=sse are not a good choice, you can try removing +them). + If not then review your postgresql configuration (buffers, +memory, page cost, etc), because 7.4 seems to be faster than 7.3 and +there is no reason for it to run slower on your system. + +-- +Any views or opinions presented within this e-mail are solely those of +the author and do not necessarily represent those of any company, unless +otherwise expressly stated. + +From pgsql-performance-owner@postgresql.org Sun Dec 14 13:14:35 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A0491D1DBBB + for ; + Sun, 14 Dec 2003 17:14:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28694-02 + for ; + Sun, 14 Dec 2003 13:14:04 -0400 (AST) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id B9B6AD1B47D + for ; + Sun, 14 Dec 2003 13:14:02 -0400 (AST) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id BE9BF8DD3; Sun, 14 Dec 2003 18:14:00 +0100 (CET) +Date: Sun, 14 Dec 2003 18:14:00 +0100 (CET) +From: Dennis Bjorklund +To: Kari Lavikka +Cc: pgsql-performance@postgresql.org +Subject: Re: a lot of problems with pg 7.4 +In-Reply-To: +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/219 +X-Sequence-Number: 5079 + +On Sat, 13 Dec 2003, Kari Lavikka wrote: + +> I evaluated pg 7.4 on our development server and it looked just fine +> but performance with production loads seems to be quite poor. Most of +> performance problems are caused by nonsensical query plans + +Some of the estimates that pg made in the plans you showed was way off. I +assume you have run VACUUM ANALYZE recently? If that does not help maybe +you need to increaste the statistics gathering on some columns so that pg +makes better estimates. With the wrong statistics it's not strange that pg +chooses bad plans. + +-- +/Dennis + + +From pgsql-performance-owner@postgresql.org Sun Dec 14 13:56:31 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 894E6D1DC04 + for ; + Sun, 14 Dec 2003 17:56:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28518-06 + for ; + Sun, 14 Dec 2003 13:56:00 -0400 (AST) +Received: from mail.libertyrms.com (unknown [209.167.124.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 01D27D1DB9D + for ; + Sun, 14 Dec 2003 13:56:00 -0400 (AST) +Received: from [10.1.2.146] (helo=dba3.int.libertyrms.info) + by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) + id 1AVaT6-0003PR-00; Sun, 14 Dec 2003 12:55:48 -0500 +Received: by dba3.int.libertyrms.info (Postfix, from userid 1019) + id 49F4C138CA; Sun, 14 Dec 2003 12:55:48 -0500 (EST) +Date: Sun, 14 Dec 2003 12:55:48 -0500 +From: Andrew Sullivan +To: Bruce Momjian +Cc: pgsql-performance@postgresql.org +Subject: Re: Tuning for mid-size server +Message-ID: <20031214175548.GA9375@libertyrms.info> +Mail-Followup-To: Andrew Sullivan , + Bruce Momjian , + pgsql-performance@postgresql.org +References: <20031021213408.GA12200@libertyrms.info> + <200312140542.hBE5gLI21410@candle.pha.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200312140542.hBE5gLI21410@candle.pha.pa.us> +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/220 +X-Sequence-Number: 5080 + +On Sun, Dec 14, 2003 at 12:42:21AM -0500, Bruce Momjian wrote: +> +> I know this is an old email, but have you tested larger shared buffers +> in CVS HEAD with Jan's new cache replacement policy? + +Not yet. It's on our TODO list, for sure, because the consequences +of relying too much on the filesystem buffers under certain perverse +loads is lousy database performance _precisely_ when we need it. I +expect some testing of this type some time in January. + +A + +-- +---- +Andrew Sullivan 204-4141 Yonge Street +Afilias Canada Toronto, Ontario Canada + M2P 2A8 + +1 416 646 3304 x110 + + +From pgsql-admin-owner@postgresql.org Sun Dec 14 18:53:04 2003 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6EF3CD1B524 + for ; + Sun, 14 Dec 2003 22:53:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 53359-03 + for ; + Sun, 14 Dec 2003 18:52:35 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id E7932D1B45B + for ; Sun, 14 Dec 2003 18:52:33 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBEMqZ19003271; + Sun, 14 Dec 2003 17:52:36 -0500 (EST) +To: Neil Conway +Cc: aspire420@hotpop.com, pgsql-admin@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Tables Without OIDS and its effect +In-reply-to: <87he05pr8i.fsf@mailbox.samurai.com> +References: <3FD9E916.8050005@sancharnet.in> + <87he05pr8i.fsf@mailbox.samurai.com> +Comments: In-reply-to Neil Conway + message dated "Fri, 12 Dec 2003 18:10:21 -0500" +Date: Sun, 14 Dec 2003 17:52:35 -0500 +Message-ID: <3270.1071442355@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/185 +X-Sequence-Number: 11692 + +Neil Conway writes: +> BTW, we intend to phase out the use of OIDs for user tables in the +> long term. + +I don't believe anyone has proposed removing the facility altogether. +There's a big difference between making the default behavior be not +to have OIDs and removing the ability to have OIDs. + + regards, tom lane + +From pgsql-admin-owner@postgresql.org Mon Dec 15 14:42:33 2003 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 0A2F1D1B48A; Mon, 15 Dec 2003 02:10:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69240-09; Sun, 14 Dec 2003 22:10:16 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP + id EEDABD1B4C6; Sun, 14 Dec 2003 22:10:13 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 5BEB2218C; Sun, 14 Dec 2003 21:10:16 -0500 (EST) +To: Tom Lane +Cc: aspire420@hotpop.com, pgsql-admin@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Tables Without OIDS and its effect +From: Neil Conway +In-Reply-To: <3270.1071442355@sss.pgh.pa.us> (Tom Lane's message of "Sun, 14 + Dec 2003 17:52:35 -0500") +References: <3FD9E916.8050005@sancharnet.in> + <87he05pr8i.fsf@mailbox.samurai.com> <3270.1071442355@sss.pgh.pa.us> +Date: Sun, 14 Dec 2003 21:10:15 -0500 +Message-ID: <87k74yg7aw.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/207 +X-Sequence-Number: 11713 + +Tom Lane writes: +> I don't believe anyone has proposed removing the facility +> altogether. There's a big difference between making the default +> behavior be not to have OIDs and removing the ability to have OIDs. + +Right, that's what I had meant to say. Sorry for the inaccuracy. + +-Neil + + +From pgsql-performance-owner@postgresql.org Mon Dec 15 00:17:55 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 23FFAD1B475 + for ; + Mon, 15 Dec 2003 04:17:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 82579-09 + for ; + Mon, 15 Dec 2003 00:17:15 -0400 (AST) +Received: from xyzzy.dhs.org (H98.C214.tor.velocet.net [216.138.214.98]) + by svr1.postgresql.org (Postfix) with ESMTP id 53D77D1B44A + for ; + Mon, 15 Dec 2003 00:17:15 -0400 (AST) +Received: from xyzzy.dhs.org (unknown [192.168.1.74]) + by xyzzy.dhs.org (Postfix) with ESMTP + id D27BD1B25E; Sun, 14 Dec 2003 23:17:13 -0500 (EST) +Message-ID: <3FDD35CF.6080103@xyzzy.dhs.org> +Date: Sun, 14 Dec 2003 23:17:19 -0500 +From: "Andrew G. Hammond" +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.5) Gecko/20031013 Thunderbird/0.3 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeff Bohmer +Cc: pgsql-performance@postgresql.org +Subject: Re: Hardware suggestions for Linux/PGSQL server +References: + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/223 +X-Sequence-Number: 5083 + +I don't know what your budget is, but there are now 10k RPM SATA 150 +drives on the market. Their price/performance is impressive. You may +want to consider going with a bunch of these instead of SCSI disks (more +spindles vs. faster spindles). 3ware makes a hardware raid card that can +drive up to 12 SATA disks. I have been told by a few people who have +used it that the linux driver is very solid. + +Drew + + +Jeff Bohmer wrote: + +>> Just one more piece of advice, you might want to look into a good +>> battery +>> backed cache hardware RAID controller. They work quite well for heavily +>> updated databases. The more drives you throw at the RAID array the +>> faster +>> it will be. +> +> +> I've seen this list often recommended such a setup. We'll probably +> get battery-backed write cache and start out with a 4 disk RAID 10 +> array. Then add more disks and change RAID 5 if more read performance +> is needed. +> +> Thanks, +> - Jeff + + + + +From pgsql-performance-owner@postgresql.org Mon Dec 15 01:30:17 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1992CD1B4C3 + for ; + Mon, 15 Dec 2003 05:30:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89743-09 + for ; + Mon, 15 Dec 2003 01:29:47 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 48F42D1B475 + for ; + Mon, 15 Dec 2003 01:29:46 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hBF5TjU6033273 + for ; Mon, 15 Dec 2003 05:29:45 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hBF5Kcla022421 + for pgsql-performance@postgresql.org; Mon, 15 Dec 2003 05:20:38 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Hardware suggestions for Linux/PGSQL server +Date: Mon, 15 Dec 2003 00:14:29 -0500 +Organization: cbbrowne Computing Inc +Lines: 23 +Message-ID: +References: + + <3FDD35CF.6080103@xyzzy.dhs.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:H/KAfwMrnYKY8ZSp0EHFd9u1trI= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/224 +X-Sequence-Number: 5084 + +In the last exciting episode, drew@xyzzy.dhs.org ("Andrew G. Hammond") wrote: +> I don't know what your budget is, but there are now 10k RPM SATA 150 +> drives on the market. Their price/performance is impressive. You may +> want to consider going with a bunch of these instead of SCSI disks +> (more spindles vs. faster spindles). 3ware makes a hardware raid +> card that can drive up to 12 SATA disks. I have been told by a few +> people who have used it that the linux driver is very solid. + +We got a couple of those in for testing purposes; when opportunity +presents itself, I'll have to check to see if they are any more honest +about commits than traditional IDE drives. + +If they still "lie" the same way IDE drives do, it is entirely +possible that they are NOT nearly as impressive as you presently +imagine. It's not much good if they're "way fast" if you can't trust +them to actually store data when they claim it is stored... +-- +(reverse (concatenate 'string "gro.gultn" "@" "enworbbc")) +http://www.ntlug.org/~cbbrowne/lisp.html +"Much of this software was user-friendly, meaning that it was intended +for users who did not know anything about computers, and furthermore +had absolutely no intention whatsoever of learning." +-- A. S. Tanenbaum, "Modern Operating Systems, ch 1.2.4" + +From pgsql-performance-owner@postgresql.org Mon Dec 15 12:38:23 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 28E1CD1DCF5 + for ; + Mon, 15 Dec 2003 16:38:21 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 71518-07 + for ; + Mon, 15 Dec 2003 12:37:58 -0400 (AST) +Received: from visionlink.org (mail.visionlink.org [208.139.207.159]) + by svr1.postgresql.org (Postfix) with SMTP id 7E35BD1B461 + for ; + Mon, 15 Dec 2003 12:37:51 -0400 (AST) +Received: from [65.100.170.142] (HELO [192.168.1.201]) by visionlink.org + (Stalker SMTP Server 1.8b8) with ESMTP id S.0002324650 for + ; Mon, 15 Dec 2003 09:39:01 -0700 +Mime-Version: 1.0 +X-Sender: bohmer@mail.visionlink.org +Message-Id: +In-Reply-To: +References: + + <3FDD35CF.6080103@xyzzy.dhs.org> + +Date: Mon, 15 Dec 2003 09:37:29 -0700 +To: pgsql-performance@postgresql.org +From: Jeff Bohmer +Subject: Re: Hardware suggestions for Linux/PGSQL server +Content-Type: text/plain; charset="us-ascii" ; format="flowed" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/225 +X-Sequence-Number: 5085 + +>In the last exciting episode, drew@xyzzy.dhs.org ("Andrew G. Hammond") wrote: +>> I don't know what your budget is, but there are now 10k RPM SATA 150 +>> drives on the market. Their price/performance is impressive. You may +>> want to consider going with a bunch of these instead of SCSI disks +>> (more spindles vs. faster spindles). 3ware makes a hardware raid +>> card that can drive up to 12 SATA disks. I have been told by a few +>> people who have used it that the linux driver is very solid. +> +>We got a couple of those in for testing purposes; when opportunity +>presents itself, I'll have to check to see if they are any more honest +>about commits than traditional IDE drives. +> +>If they still "lie" the same way IDE drives do, it is entirely +>possible that they are NOT nearly as impressive as you presently +>imagine. It's not much good if they're "way fast" if you can't trust +>them to actually store data when they claim it is stored... + +We lost data because of this very problem when a UPS didn't signal +the shut down before it ran out of juice. + +Here's an excellent explanation of the problem: +http://archives.postgresql.org/pgsql-general/2003-10/msg01343.php + +This post indicates that SATA drives still have problems, but a new +ATA standard might fix things in the future: +http://archives.postgresql.org/pgsql-general/2003-10/msg01395.php + +SATA RAID is a good option for a testing server, though. + + +- Jeff +-- + +Jeff Bohmer +VisionLink, Inc. +_________________________________ +303.402.0170 +www.visionlink.org +_________________________________ +People. Tools. Change. Community. + +From pgsql-admin-owner@postgresql.org Mon Dec 15 13:01:56 2003 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5A351D1DCFD; Mon, 15 Dec 2003 17:01:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73663-10; Mon, 15 Dec 2003 13:01:22 -0400 (AST) +Received: from host2.hostseguro.com (66-98-192-97.hostseguro.com + [66.98.192.97]) by svr1.postgresql.org (Postfix) with ESMTP + id 6BC63D1B430; Mon, 15 Dec 2003 13:01:16 -0400 (AST) +Received: from cpanel by host2.hostseguro.com with local (Exim 4.24) + id 1AVw5r-0006Xf-HB; Mon, 15 Dec 2003 15:01:15 -0200 +Received: from 200-180-185-142.paemt7003.dsl.brasiltelecom.net.br + (200-180-185-142.paemt7003.dsl.brasiltelecom.net.br + [200.180.185.142]) by sistemica.info (IMP) with HTTP + for ; Mon, 15 Dec 2003 15:01:15 -0200 +Message-ID: <1071507675.3fdde8db77a2e@sistemica.info> +Date: Mon, 15 Dec 2003 15:01:15 -0200 +From: Rhaoni Chiu Pereira +To: PostgreSQL ADMIN , + PostgreSQL Performance +Subject: Unsubscribe +MIME-Version: 1.0 +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +User-Agent: Internet Messaging Program (IMP) 3.2.1 +X-Originating-IP: 200.180.185.142 +X-MailScanner-Information: Verificado pelo McAfee VirusScan / Scanned by + McAfee VirusScan +X-MailScanner: Nao infectado / Found to be clean +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - host2.hostseguro.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [32001 32001] / [47 12] +X-AntiAbuse: Sender Address Domain - sistemica.info +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/197 +X-Sequence-Number: 11704 + + + + + + + +From pgsql-performance-owner@postgresql.org Mon Dec 15 14:06:20 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CFEADD1DCF5 + for ; + Mon, 15 Dec 2003 18:06:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89394-01 + for ; + Mon, 15 Dec 2003 14:05:56 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id A7BA0D1DDDB + for ; + Mon, 15 Dec 2003 14:05:49 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBFI5p19013829; + Mon, 15 Dec 2003 13:05:52 -0500 (EST) +To: LIANHE SHAO +Cc: pgsql-performance +Subject: Re: Index problem or function problem? +In-reply-to: <4595eb458230.4582304595eb@jhmimail.jhmi.edu> +References: <4595eb458230.4582304595eb@jhmimail.jhmi.edu> +Comments: In-reply-to LIANHE SHAO + message dated "Tue, 09 Dec 2003 23:24:19 +0000" +Date: Mon, 15 Dec 2003 13:05:51 -0500 +Message-ID: <13828.1071511551@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/227 +X-Sequence-Number: 5087 + +LIANHE SHAO writes: +> PGA=> explain select ei.expid, er.geneid, +> er.sampleid, ei.annotation, si.samplename, +> ei.title as exp_name, aaa.chip, +> aaa.sequence_derived_from as accession_number, +> aaa.gene_symbol, aaa.title as gene_function, +> er.exprs, er.mas5exprs from expressiondata er, +> experimentinfo ei, sampleinfo si, +> affy_array_annotation aaa where exists (select +> distinct ei.expid from experimentinfo) and +> ei.annotation = aaa.chip and (lower (aaa.title) +> like '%mif%' or lower(aaa.sequence_description) like +> '%mif%') and exists (select distinct ei.annotation +> from experimentinfo) and ei.expid = er.expid and +> er.expid = si.expid and er.sampleid = si.sampleid +> and er.geneid = aaa.probeset_id order by si.sampleid +> limit 20; + +What is the purpose of the EXISTS() clauses? They are almost surely not +doing what you intended, because AFAICS they are just an extremely +expensive means of producing a constant-TRUE result. In + exists (select distinct ei.expid from experimentinfo) +"ei.expid" is an outer reference, which will necessarily be the same +value over all rows of the sub-select. After computing this same value +for every row of experimentinfo, the system performs a DISTINCT +operation (sort + unique, not cheap) ... and then all it checks for is +whether at least one row was produced, which means the DISTINCT +operation was completely unnecessary. The only way the EXISTS could +return false is if experimentinfo were empty, but if it were so then the +outer FROM would've produced no rows and we'd not have got to WHERE +anyway. + +I'm not sure why you get a worse plan for the simpler variant of the +query; it would help to see EXPLAIN ANALYZE rather than EXPLAIN output. +But it's not worth trying to improve the performance until you are +calculating correct answers, and I suspect the above is not doing +what you are after at all. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Dec 15 14:22:20 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F3E5ED1B4CE + for ; + Mon, 15 Dec 2003 18:22:17 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 88066-06 + for ; + Mon, 15 Dec 2003 14:21:55 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id CD1D8D1DCDA + for ; + Mon, 15 Dec 2003 14:21:48 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBFILl19013899; + Mon, 15 Dec 2003 13:21:48 -0500 (EST) +To: Hartmut Raschick +Cc: pgsql-performance@postgresql.org, Rod Taylor +Subject: Re: TRUNCATE veeeery slow compared to DELETE in 7.4 +In-reply-to: <3FD99CDA.8161D80A@ke-elektronik.de> +References: <3FD484B6.EF39A92F@ke-elektronik.de> + <200312100918.02501.josh@agliodbs.com> + <8000.1071086054@sss.pgh.pa.us> + <3FD99CDA.8161D80A@ke-elektronik.de> +Comments: In-reply-to Hartmut Raschick + message dated "Fri, 12 Dec 2003 11:47:54 +0100" +Date: Mon, 15 Dec 2003 13:21:47 -0500 +Message-ID: <13898.1071512507@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/228 +X-Sequence-Number: 5088 + +Hartmut Raschick writes: +> [ TRUNCATE is much slower in 7.4 than in 7.3 ] + +After looking into this, I think this is because when Rod Taylor +reimplemented TRUNCATE to make it transaction-safe, he essentially +turned it into a variant of CLUSTER. It is slow because it is creating +and deleting dummy tables and indexes. I think this is not really +necessary and it could be done better while still being +transaction-safe. All we really need is to create a new empty table +file, update the table's pg_class row with the new relfilenode, mark +the old file for deletion, and then run REINDEX TABLE (which will +perform similar shenanigans with the indexes). + + regards, tom lane + +From pgsql-admin-owner@postgresql.org Mon Dec 15 18:55:15 2003 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E2A7D1CAFD + for ; + Mon, 15 Dec 2003 22:55:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 30267-07 + for ; + Mon, 15 Dec 2003 18:54:46 -0400 (AST) +Received: from smtp.covadmail.net (mx05.covadmail.net [63.65.120.65]) + by svr1.postgresql.org (Postfix) with SMTP id 44052D1C980 + for ; Mon, 15 Dec 2003 18:54:38 -0400 (AST) +Received: (covad.net 2977 invoked from network); 15 Dec 2003 22:54:41 -0000 +Received: from unknown (HELO meer.net) (jhefner@67.100.190.154) + by sun-qmail15 with SMTP; 15 Dec 2003 22:54:40 -0000 +Message-ID: <3FDE3BAB.35563F@meer.net> +Date: Mon, 15 Dec 2003 17:54:35 -0500 +From: Jeremy Hefner +X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U) +X-Accept-Language: en +MIME-Version: 1.0 +Cc: PostgreSQL ADMIN , + PostgreSQL Performance +Subject: unsubscribe +References: <1071507675.3fdde8db77a2e@sistemica.info> +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 + tests=EMAIL_ATTRIBUTION, QUOTED_EMAIL_TEXT, RCVD_IN_OSIRUSOFT_COM, + REFERENCES, REPLY_WITH_QUOTES +X-Spam-Level: +X-Archive-Number: 200312/211 +X-Sequence-Number: 11717 + +unsubscribe + +Rhaoni Chiu Pereira wrote: +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings + +From pgsql-performance-owner@postgresql.org Tue Dec 16 11:42:01 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 543B8D1DBF5 + for ; + Tue, 16 Dec 2003 15:41:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 55005-08 + for ; + Tue, 16 Dec 2003 11:41:32 -0400 (AST) +Received: from ml370.omarnet.it (host163-247.pool62110.interbusiness.it + [62.110.247.163]) + by svr1.postgresql.org (Postfix) with ESMTP id D6EC2D1DBC4 + for ; + Tue, 16 Dec 2003 11:41:25 -0400 (AST) +Received: by ml370.omarnet.it with Internet Mail Service (5.5.2657.72) + id ; Tue, 16 Dec 2003 16:40:04 +0100 +Message-ID: <7965BF282720D8118ED70050BA4E75760A9658@ml370.omarnet.it> +From: Claudia D'amato +To: pgsql-performance@postgresql.org +Subject: Postgres respond after toomany times to a query view +Date: Tue, 16 Dec 2003 16:40:03 +0100 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C3C3EA.DF546700" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.6 tagged_above=0.0 required=5.0 tests=BAYES_30, + HTML_20_30 +X-Spam-Level: +X-Archive-Number: 200312/229 +X-Sequence-Number: 5089 + +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_01C3C3EA.DF546700 +Content-Type: text/plain; + charset="iso-8859-1" + +Hi, I am developing a program using postgres and linux like operating +system. My problem is this: +I have a quite complicated view with roughly 10000 record. When I execute a +simple query like this + "select * from myview" +postgres respond after 50 - 55 minutes roughly. I hope that someone can help +me with some suggestion about reason of this behavior and some solution to +reduce time ti have results. Thank you for your attentions and I hope to +receive some feedback as soon as possible + +------_=_NextPart_001_01C3C3EA.DF546700 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +Postgres respond after toomany times to a query view + + + +

Hi, I am developing a program using postgr= +es and linux like operating system. My problem is this: +
I have a quite complicated view with roug= +hly 10000 record. When I execute a simple query like this +
        "select * from myview" +
postgres respond after 50 - 55 minutes ro= +ughly. I hope that someone can help me with some suggestion about reason of= + this behavior and some solution to reduce time ti have results. Thank you = +for your attentions and I hope to receive some feedback as soon as possible= +

+ + + +------_=_NextPart_001_01C3C3EA.DF546700-- + +From pgsql-performance-owner@postgresql.org Tue Dec 16 12:57:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F0E9FD1B449 + for ; + Tue, 16 Dec 2003 16:56:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69282-04 + for ; + Tue, 16 Dec 2003 12:56:28 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id D8431D1B46D + for ; + Tue, 16 Dec 2003 12:56:27 -0400 (AST) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id hBGGsL7N021407; + Tue, 16 Dec 2003 09:54:22 -0700 (MST) +Date: Tue, 16 Dec 2003 09:37:28 -0700 (MST) +From: "scott.marlowe" +To: Kari Lavikka +Cc: +Subject: Re: a lot of problems with pg 7.4 +In-Reply-To: +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/230 +X-Sequence-Number: 5090 + +On Sat, 13 Dec 2003, Kari Lavikka wrote: + +> +> Hi! +> +> We have been running a rather busy website using pg 7.3 as the database. +> Peak hitrate is something like 120 request / second without images and +> other static stuff. The site is a sort of image gallery for IRC users. +> +> I evaluated pg 7.4 on our development server and it looked just fine +> but performance with production loads seems to be quite poor. Most of +> performance problems are caused by nonsensical query plans but there's +> also some strange slowness that I can't locate. + +Have you analyzed your database since putting the new data into it? + +Also, you might need to increase your statistics target before analyzing +to get proper results as well. + + +From pgsql-performance-owner@postgresql.org Tue Dec 16 17:15:07 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 62F36D1B567 + for ; + Tue, 16 Dec 2003 17:06:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 71132-05 + for ; + Tue, 16 Dec 2003 13:06:26 -0400 (AST) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id A4260D1B579 + for ; + Tue, 16 Dec 2003 13:06:25 -0400 (AST) +Received: from nick (bilbo.ontko.com [199.164.165.101]) + by shire.ontko.com (8.12.3/8.12.3/Debian-6.6) with SMTP id + hBGH685f030864 + for ; Tue, 16 Dec 2003 12:06:10 -0500 +Reply-To: +From: "Nick Fankhauser - Doxpop" +To: "Pgsql-Performance@Postgresql. Org" +Subject: Nested loop question +Date: Tue, 16 Dec 2003 12:06:20 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/237 +X-Sequence-Number: 5097 + +Hi- + +I'm trying to optimize a query that I *think* should run very fast. +Essentially, I'm joining two tables that have very selective indexes and +constraining the query on an indexed field. (There's a third small lookup +table in the mix, but it doesn't really affect the bottom line.) + +actor is a table containing roughly 3 million rows with an index on +actor_full_name_uppercase and a unique index on actor_id. + +actor_summary also contains roughly 3 million rows. Its PK is a unique +combined index on (actor_id, county_id, case_disp_global_code). + +The vast majority of the rows in actor correspond to a single row in +actor_summary I'd estimate this at 95% or more. The remaining actors with +multiple records generally have two corresponding rows in actor summary. +Actor summary was created as a performance enhancer, where we can store some +pre-calculated values such as the number of court cases an actor is involved +in. + +The constraint is applied first, with reasonable speed. In the example +below, it takes about 15 seconds to gather the matches in actor. + +I'm unsure what is happening next. I notice that an index scan is occurring +on actor_summary_pk, with an "actual time" of 9.15, but then it looks like a +nested loop occurs at the next level to join these tables. Does this mean +that each probe of the actor_summary index will take 9.15 msec, but the +nested loop is going to do this once for each actor_id? + +The nested loop appears to be where most of my time is going, so I'm +focusing on this area, but don't know if there is a better approach to this +join. + +Is there a more efficient means than a nested loop to handle such a join? +Would a different method be chosen if there was exactly one row in +actor_summary for every row in actor? + +-Nick + +The query & explain analyze: + + +alpha=# +alpha=# +alpha=# explain analyze +alpha-# select +alpha-# min(actor.actor_id) as actor_id, +alpha-# min(actor.actor_entity_type) as actor_entity_type, +alpha-# min(actor.role_class_code) as role_class_code, +alpha-# min(actor.actor_full_name) as actor_full_name, +alpha-# min(actor.actor_person_date_of_birth) as +actor_person_date_of_birth, +alpha-# min(actor.actor_entity_acronym) as actor_entity_acronym, +alpha-# min(actor.actor_person_last_name) as actor_person_last_name, +alpha-# min(actor.actor_person_first_name) as actor_person_first_name, +alpha-# min(actor.actor_person_middle_name) as actor_person_middle_name, +alpha-# min(actor.actor_person_name_suffix) as actor_person_name_suffix, +alpha-# min(actor.actor_person_place_of_birth) as +actor_person_place_of_birth, +alpha-# min(actor.actor_person_height) as actor_person_height, +alpha-# min(actor.actor_person_height_unit) as actor_person_height_unit, +alpha-# min(actor.actor_person_weight) as actor_person_weight, +alpha-# min(actor.actor_person_weight_unit) as actor_person_weight_unit, +alpha-# min(actor.actor_person_ethnicity) as actor_person_ethnicity, +alpha-# min(actor.actor_person_citizenship_count) as +actor_person_citizenship_count, +alpha-# min(actor.actor_person_hair_color) as actor_person_hair_color, +alpha-# min(actor.actor_person_scars_marks_tatto) as +actor_person_scars_marks_tatto, +alpha-# min(actor.actor_person_marital_status) as +actor_person_marital_status, +alpha-# min(actor.actor_alias_for_actor_id) as actor_alias_for_actor_id, +alpha-# min(to_char(data_source.source_last_update, 'MM/DD/YYYY HH12:MI +AM TZ')) as last_update, +alpha-# min(actor_summary.single_case_public_id) as case_public_id, +alpha-# min(actor_summary.single_case_id) as case_id, +alpha-# sum(actor_summary.case_count)as case_count +alpha-# from +alpha-# actor, +alpha-# actor_summary, +alpha-# data_source +alpha-# where +alpha-# actor.actor_id = actor_summary.actor_id +alpha-# and data_source.source_id = actor.source_id +alpha-# and actor_full_name_uppercase like upper('sanders%') +alpha-# group by +alpha-# actor.actor_id +alpha-# order by +alpha-# min(actor.actor_full_name_uppercase), +alpha-# case_count desc, +alpha-# min(actor_summary.case_disp_global_code) +alpha-# limit +alpha-# 1000 +alpha-# ; + + + +QUERY PLAN +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +------------------------------- + Limit (cost=2555.58..2555.59 rows=1 width=547) (actual +time=48841.76..48842.90 rows=1000 loops=1) + -> Sort (cost=2555.58..2555.59 rows=1 width=547) (actual +time=48841.76..48842.18 rows=1001 loops=1) + Sort Key: min((actor.actor_full_name_uppercase)::text), +sum(actor_summary.case_count), +min((actor_summary.case_disp_global_code)::text) + -> Aggregate (cost=2555.50..2555.57 rows=1 width=547) (actual +time=48604.17..48755.28 rows=3590 loops=1) + -> Group (cost=2555.50..2555.50 rows=1 width=547) (actual +time=48604.04..48647.91 rows=3594 loops=1) + -> Sort (cost=2555.50..2555.50 rows=1 width=547) +(actual time=48604.01..48605.70 rows=3594 loops=1) + Sort Key: actor.actor_id + -> Nested Loop (cost=1.14..2555.49 rows=1 +width=547) (actual time=69.09..48585.83 rows=3594 loops=1) + -> Hash Join (cost=1.14..900.39 rows=204 +width=475) (actual time=46.92..15259.02 rows=3639 loops=1) + Hash Cond: ("outer".source_id = +"inner".source_id) + -> Index Scan using +actor_full_name_uppercase on actor (cost=0.00..895.04 rows=222 width=463) +(actual time=46.54..15220.77 rows=3639 loops=1) + Index Cond: +((actor_full_name_uppercase >= 'SANDERS'::character varying) AND +(actor_full_name_uppercase < 'SANDERT'::character varying)) + Filter: +(actor_full_name_uppercase ~~ 'SANDERS%'::text) + -> Hash (cost=1.11..1.11 rows=11 +width=12) (actual time=0.05..0.05 rows=0 loops=1) + -> Seq Scan on data_source +(cost=0.00..1.11 rows=11 width=12) (actual time=0.02..0.04 rows=11 loops=1) + -> Index Scan using actor_summary_pk on +actor_summary (cost=0.00..8.11 rows=1 width=72) (actual time=9.14..9.15 +rows=1 loops=3639) + Index Cond: ("outer".actor_id = +actor_summary.actor_id) + Total runtime: 48851.85 msec +(18 rows) + + +--------------------------------------------------------------------- +Nick Fankhauser + + nickf@doxpop.com Phone 1.765.965.7363 Fax 1.765.962.9788 +doxpop - Court records at your fingertips - http://www.doxpop.com/ + + + +From pgsql-performance-owner@postgresql.org Tue Dec 16 13:12:22 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 18554D1B535 + for ; + Tue, 16 Dec 2003 17:12:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 72240-07 + for ; + Tue, 16 Dec 2003 13:11:49 -0400 (AST) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id C17C8D1B475 + for ; + Tue, 16 Dec 2003 13:11:48 -0400 (AST) +Received: from nick (bilbo.ontko.com [199.164.165.101]) + by shire.ontko.com (8.12.3/8.12.3/Debian-6.6) with SMTP id + hBGHBk5f030965 + for ; Tue, 16 Dec 2003 12:11:48 -0500 +Reply-To: +From: "Nick Fankhauser" +To: "Pgsql-Performance@Postgresql. Org" +Subject: Nested loop performance +Date: Tue, 16 Dec 2003 12:11:59 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/231 +X-Sequence-Number: 5091 + +Hi- + +I'm trying to optimize a query that I *think* should run very fast. +Essentially, I'm joining two tables that have very selective indexes and +constraining the query on an indexed field. (There's a third small lookup +table in the mix, but it doesn't really affect the bottom line.) + +actor is a table containing roughly 3 million rows with an index on +actor_full_name_uppercase and a unique index on actor_id. + +actor_summary also contains roughly 3 million rows. Its PK is a unique +combined index on (actor_id, county_id, case_disp_global_code). + +The vast majority of the rows in actor correspond to a single row in +actor_summary I'd estimate this at 95% or more. The remaining actors with +multiple records generally have two corresponding rows in actor summary. +Actor summary was created as a performance enhancer, where we can store some +pre-calculated values such as the number of court cases an actor is involved +in. + +The constraint is applied first, with reasonable speed. In the example +below, it takes about 15 seconds to gather the matches in actor. + +I'm unsure what is happening next. I notice that an index scan is occurring +on actor_summary_pk, with an "actual time" of 9.15, but then it looks like a +nested loop occurs at the next level to join these tables. Does this mean +that each probe of the actor_summary index will take 9.15 msec, but the +nested loop is going to do this once for each actor_id? + +The nested loop appears to be where most of my time is going, so I'm +focusing on this area, but don't know if there is a better approach to this +join. + +Is there a more efficient means than a nested loop to handle such a join? +Would a different method be chosen if there was exactly one row in +actor_summary for every row in actor? + +-Nick + +The query & explain analyze: + + +alpha=# +alpha=# +alpha=# explain analyze +alpha-# select +alpha-# min(actor.actor_id) as actor_id, +alpha-# min(actor.actor_entity_type) as actor_entity_type, +alpha-# min(actor.role_class_code) as role_class_code, +alpha-# min(actor.actor_full_name) as actor_full_name, +alpha-# min(actor.actor_person_date_of_birth) as +actor_person_date_of_birth, +alpha-# min(actor.actor_entity_acronym) as actor_entity_acronym, +alpha-# min(actor.actor_person_last_name) as actor_person_last_name, +alpha-# min(actor.actor_person_first_name) as actor_person_first_name, +alpha-# min(actor.actor_person_middle_name) as actor_person_middle_name, +alpha-# min(actor.actor_person_name_suffix) as actor_person_name_suffix, +alpha-# min(actor.actor_person_place_of_birth) as +actor_person_place_of_birth, +alpha-# min(actor.actor_person_height) as actor_person_height, +alpha-# min(actor.actor_person_height_unit) as actor_person_height_unit, +alpha-# min(actor.actor_person_weight) as actor_person_weight, +alpha-# min(actor.actor_person_weight_unit) as actor_person_weight_unit, +alpha-# min(actor.actor_person_ethnicity) as actor_person_ethnicity, +alpha-# min(actor.actor_person_citizenship_count) as +actor_person_citizenship_count, +alpha-# min(actor.actor_person_hair_color) as actor_person_hair_color, +alpha-# min(actor.actor_person_scars_marks_tatto) as +actor_person_scars_marks_tatto, +alpha-# min(actor.actor_person_marital_status) as +actor_person_marital_status, +alpha-# min(actor.actor_alias_for_actor_id) as actor_alias_for_actor_id, +alpha-# min(to_char(data_source.source_last_update, 'MM/DD/YYYY HH12:MI +AM TZ')) as last_update, +alpha-# min(actor_summary.single_case_public_id) as case_public_id, +alpha-# min(actor_summary.single_case_id) as case_id, +alpha-# sum(actor_summary.case_count)as case_count +alpha-# from +alpha-# actor, +alpha-# actor_summary, +alpha-# data_source +alpha-# where +alpha-# actor.actor_id = actor_summary.actor_id +alpha-# and data_source.source_id = actor.source_id +alpha-# and actor_full_name_uppercase like upper('sanders%') +alpha-# group by +alpha-# actor.actor_id +alpha-# order by +alpha-# min(actor.actor_full_name_uppercase), +alpha-# case_count desc, +alpha-# min(actor_summary.case_disp_global_code) +alpha-# limit +alpha-# 1000 +alpha-# ; + + + +QUERY PLAN +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +------------------------------- + Limit (cost=2555.58..2555.59 rows=1 width=547) (actual +time=48841.76..48842.90 rows=1000 loops=1) + -> Sort (cost=2555.58..2555.59 rows=1 width=547) (actual +time=48841.76..48842.18 rows=1001 loops=1) + Sort Key: min((actor.actor_full_name_uppercase)::text), +sum(actor_summary.case_count), +min((actor_summary.case_disp_global_code)::text) + -> Aggregate (cost=2555.50..2555.57 rows=1 width=547) (actual +time=48604.17..48755.28 rows=3590 loops=1) + -> Group (cost=2555.50..2555.50 rows=1 width=547) (actual +time=48604.04..48647.91 rows=3594 loops=1) + -> Sort (cost=2555.50..2555.50 rows=1 width=547) +(actual time=48604.01..48605.70 rows=3594 loops=1) + Sort Key: actor.actor_id + -> Nested Loop (cost=1.14..2555.49 rows=1 +width=547) (actual time=69.09..48585.83 rows=3594 loops=1) + -> Hash Join (cost=1.14..900.39 rows=204 +width=475) (actual time=46.92..15259.02 rows=3639 loops=1) + Hash Cond: ("outer".source_id = +"inner".source_id) + -> Index Scan using +actor_full_name_uppercase on actor (cost=0.00..895.04 rows=222 width=463) +(actual time=46.54..15220.77 rows=3639 loops=1) + Index Cond: +((actor_full_name_uppercase >= 'SANDERS'::character varying) AND +(actor_full_name_uppercase < 'SANDERT'::character varying)) + Filter: +(actor_full_name_uppercase ~~ 'SANDERS%'::text) + -> Hash (cost=1.11..1.11 rows=11 +width=12) (actual time=0.05..0.05 rows=0 loops=1) + -> Seq Scan on data_source +(cost=0.00..1.11 rows=11 width=12) (actual time=0.02..0.04 rows=11 loops=1) + -> Index Scan using actor_summary_pk on +actor_summary (cost=0.00..8.11 rows=1 width=72) (actual time=9.14..9.15 +rows=1 loops=3639) + Index Cond: ("outer".actor_id = +actor_summary.actor_id) + Total runtime: 48851.85 msec +(18 rows) + + +--------------------------------------------------------------------- +Nick Fankhauser + + nickf@doxpop.com Phone 1.765.965.7363 Fax 1.765.962.9788 +doxpop - Court records at your fingertips - http://www.doxpop.com/ + + + +From pgsql-performance-owner@postgresql.org Tue Dec 16 17:29:09 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E968D1D903 + for ; + Tue, 16 Dec 2003 21:29:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 13888-05 + for ; + Tue, 16 Dec 2003 17:28:36 -0400 (AST) +Received: from fuji.krosing.net (217-159-136-226-dsl.kt.estpak.ee + [217.159.136.226]) + by svr1.postgresql.org (Postfix) with ESMTP id 05EB5D1D387 + for ; + Tue, 16 Dec 2003 17:24:53 -0400 (AST) +Received: from fuji.krosing.net (localhost.localdomain [127.0.0.1]) + by fuji.krosing.net (8.12.8/8.12.8) with ESMTP id hBGLOkLx005536; + Tue, 16 Dec 2003 23:24:47 +0200 +Received: (from hannu@localhost) + by fuji.krosing.net (8.12.8/8.12.8/Submit) id hBGLOjMY005534; + Tue, 16 Dec 2003 23:24:45 +0200 +X-Authentication-Warning: fuji.krosing.net: hannu set sender to hannu@tm.ee + using -f +Subject: Re: Excessive rows/tuples seriously degrading query +From: Hannu Krosing +To: "Chadwick, Russell" +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1071609885.5397.8.camel@fuji.krosing.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Tue, 16 Dec 2003 23:24:45 +0200 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/239 +X-Sequence-Number: 5099 + +Chadwick, Russell kirjutas L, 13.12.2003 kell 00:40: +> +> Hello everyone. +> Can anyone explain why this table which has never had more than a +> couple rows in it shows > 500k in the query planner even after running +> vacuum full. Its terribly slow to return 2 rows of data. The 2 rows +> in it are being updated a lot but I couldn't find any explanation for +> this behavior. + +It can be that there is an idle transaction somewhere that has locked a +lot of rows (i.e. all your updates have been running inside the same +transaction for hour or days) + +try: +$ ps ax| grep post + +on my linux box this gives + + 1683 ? S 0:00 /usr/bin/postmaster -p 5432 + 1704 ? S 0:00 postgres: stats buffer process + 1705 ? S 0:00 postgres: stats collector process + 5520 ? S 0:00 postgres: hu hannu [local] idle in transaction + 5524 pts/2 S 0:00 grep post + +where backend 5520 seems to be the culprit. + +> Anything I could try besides droping db and recreating? + +make sure that no other backend is connected to db and do your +> vacuum full; analyze; + + +or if there seems to be something unidentifieable making your table +unusable, then just recreate that table: + +begin; +create table stock_log_positions_tmp + as select * from stock_log_positions; +drop table stock_log_positions; +alter table stock_log_positions_tmp + rename to stock_log_positions; +-- if you have any constraints, indexes or foreign keys +-- then recreate them here as well +commit; + +> Thanks - Russ +> +--------------- +hannu + + +From pgsql-performance-owner@postgresql.org Tue Dec 16 18:48:38 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 25150D1B473 + for ; + Tue, 16 Dec 2003 22:48:37 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21457-08 + for ; + Tue, 16 Dec 2003 18:48:08 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D321D1CA77 + for ; + Tue, 16 Dec 2003 18:48:06 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 68DA522C4; Tue, 16 Dec 2003 17:48:07 -0500 (EST) +To: "Sean P. Thomas" +Cc: pgsql-performance@postgresql.org +Subject: Re: Optimizing FK & PK performance... +From: Neil Conway +In-Reply-To: <3FD89D72.8080508@ulanji.com> (Sean P. Thomas's message of + "Thu, 11 Dec 2003 11:38:10 -0500") +References: <3FD89D72.8080508@ulanji.com> +Date: Tue, 16 Dec 2003 17:47:59 -0500 +Message-ID: <87fzfkl6qo.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/240 +X-Sequence-Number: 5100 + +"Sean P. Thomas" writes: +> 1. Is there any performance difference for declaring a primary or +> foreign key a column or table contraint? From the documentation, +> which way is faster and/or scales better: +> +> CREATE TABLE distributors ( +> did integer, +> name varchar(40), +> PRIMARY KEY(did) +> ); +> +> CREATE TABLE distributors ( +> did integer PRIMARY KEY, +> name varchar(40) +> ); + +These are equivalent -- the performance should be the same. + +-Neil + + +From pgsql-performance-owner@postgresql.org Tue Dec 16 18:51:50 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7FFABD1B4BD + for ; + Tue, 16 Dec 2003 22:51:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 24367-07 + for ; + Tue, 16 Dec 2003 18:51:20 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id B9369D1B4A8 + for ; + Tue, 16 Dec 2003 18:51:17 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id 177A72357; Tue, 16 Dec 2003 17:51:19 -0500 (EST) +To: "David Shadovitz" +Cc: pgsql-performance@postgresql.org, david@shadovitz.com +Subject: Re: Why is VACUUM ANALYZE
so slow? +From: Neil Conway +In-Reply-To: <20031209211444.M99946@www.shadovitz.com> (David Shadovitz's + message of "Tue, 9 Dec 2003 14:14:44 -0700") +References: <20031209211444.M99946@www.shadovitz.com> +Date: Tue, 16 Dec 2003 17:51:18 -0500 +Message-ID: <87brq8l6l5.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/241 +X-Sequence-Number: 5101 + +"David Shadovitz" writes: +> I'm running PG 7.2.2 on RH Linux 8.0. + +Note that this version of PostgreSQL is quite old. + +> I'd like to know why "VACUUM ANALYZE
" is extemely slow (hours) for +> certain tables. + +Is there another concurrent transaction that has modified the table +but has not committed? VACUUM ANALYZE will need to block waiting for +it. You might be able to get some insight into this by examining the +pg_locks system view: + +http://www.postgresql.org/docs/current/static/monitoring-locks.html + +As well as the pg_stat_activity view. + +-Neil + + +From pgsql-general-owner@postgresql.org Tue Dec 16 19:50:16 2003 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 1CAC9D1B531; Tue, 16 Dec 2003 23:50:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31799-08; Tue, 16 Dec 2003 19:49:45 -0400 (AST) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP + id A8A03D1BC5C; Tue, 16 Dec 2003 19:49:37 -0400 (AST) +Received: from ibm-a.pdx.osdl.net (ibm-a.pdx.osdl.net [172.20.1.50]) + by mail.osdl.org (8.11.6/8.11.6) with ESMTP id hBGNneZ21642; + Tue, 16 Dec 2003 15:49:40 -0800 +Subject: update slows down in pl/pgsql function +From: Jenny Zhang +To: perf-pgsql , + pgsql-general@postgresql.org +Content-Type: text/plain +Organization: osdl +Message-Id: <1071618760.10925.17.camel@ibm-a.pdx.osdl.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Tue, 16 Dec 2003 15:52:41 -0800 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/917 +X-Sequence-Number: 54310 + +I have stored procedure written in pl/pgsql which takes about 13 seconds +to finish. I was able to identify that the slowness is caused by one +update SQL: + +UPDATE shopping_cart SET sc_sub_total=sc_subtotal, sc_date=now() +WHERE sc_id=sc_id; + +If I comment this sql out, the stored procedure returns within 1 second. + +What puzzles me is that if I execute the same update SQL in psql +interface, it returns very fast. The following is the explain analyze +output for that SQL. + +#>explain analyze UPDATE shopping_cart SET sc_sub_total=1, sc_date=now() +where sc_id=260706; + QUERY +PLAN +---------------------------------------------------------------------------------------------------------------------------------- + Index Scan using shopping_cart_pkey on shopping_cart (cost=0.00..5.01 +rows=1 width=144) (actual time=0.22..0.37 rows=1 loops=1) + Index Cond: (sc_id = 260706::numeric) + Total runtime: 1.87 msec +(3 rows) + +Is it true that using pl/pgsql increases the overhead that much? + +TIA, +Jenny +-- +Jenny Zhang +Open Source Development Lab +12725 SW Millikan Way, Suite 400 +Beaverton, OR 97005 +(503)626-2455 ext 31 + + + +From pgsql-general-owner@postgresql.org Tue Dec 16 19:55:05 2003 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id C0F17D1B494; Tue, 16 Dec 2003 23:55:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 32497-06; Tue, 16 Dec 2003 19:54:34 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP + id 14236D1B447; Tue, 16 Dec 2003 19:54:32 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 3BD0C3548A; Tue, 16 Dec 2003 15:54:34 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 3A54235405; Tue, 16 Dec 2003 15:54:34 -0800 (PST) +Date: Tue, 16 Dec 2003 15:54:34 -0800 (PST) +From: Stephan Szabo +To: Jenny Zhang +Cc: perf-pgsql , + pgsql-general@postgresql.org +Subject: Re: update slows down in pl/pgsql function +In-Reply-To: <1071618760.10925.17.camel@ibm-a.pdx.osdl.net> +Message-ID: <20031216155342.J28271@megazone.bigpanda.com> +References: <1071618760.10925.17.camel@ibm-a.pdx.osdl.net> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/918 +X-Sequence-Number: 54311 + +On Tue, 16 Dec 2003, Jenny Zhang wrote: + +> I have stored procedure written in pl/pgsql which takes about 13 seconds +> to finish. I was able to identify that the slowness is caused by one +> update SQL: +> +> UPDATE shopping_cart SET sc_sub_total=sc_subtotal, sc_date=now() +> WHERE sc_id=sc_id; + +Umm, is that exactly the condition you're using? Isn't that going to +update the entire table? + +From pgsql-performance-owner@postgresql.org Tue Dec 16 19:56:32 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CE763D1BA6E + for ; + Tue, 16 Dec 2003 23:56:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 34056-01 + for ; + Tue, 16 Dec 2003 19:56:00 -0400 (AST) +Received: from jalapeno.crazydogs.org (jalapeno.jellybean.co.uk + [212.78.70.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A8BED1B447 + for ; + Tue, 16 Dec 2003 19:55:57 -0400 (AST) +Received: from rp by jalapeno.crazydogs.org with local (Exim 3.35 #1 (Debian)) + id 1AWP2T-0001Mi-00 + for ; Tue, 16 Dec 2003 23:55:41 +0000 +Date: Tue, 16 Dec 2003 23:55:41 +0000 +From: Richard Poole +To: "Pgsql-Performance@Postgresql. Org" +Subject: Re: Nested loop performance +Message-ID: <20031216235541.GB8054@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.3.28i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/244 +X-Sequence-Number: 5104 + +On Tue, Dec 16, 2003 at 12:11:59PM -0500, Nick Fankhauser wrote: +> +> I'm trying to optimize a query that I *think* should run very fast. +> Essentially, I'm joining two tables that have very selective indexes and +> constraining the query on an indexed field. (There's a third small lookup +> table in the mix, but it doesn't really affect the bottom line.) +> +> actor is a table containing roughly 3 million rows with an index on +> actor_full_name_uppercase and a unique index on actor_id. +> +> actor_summary also contains roughly 3 million rows. Its PK is a unique +> combined index on (actor_id, county_id, case_disp_global_code). + +... + +> I'm unsure what is happening next. I notice that an index scan is occurring +> on actor_summary_pk, with an "actual time" of 9.15, but then it looks like a +> nested loop occurs at the next level to join these tables. Does this mean +> that each probe of the actor_summary index will take 9.15 msec, but the +> nested loop is going to do this once for each actor_id? + +... + +> Is there a more efficient means than a nested loop to handle such a join? +> Would a different method be chosen if there was exactly one row in +> actor_summary for every row in actor? + +It seems that your basic problem is that you're fetching lots of rows +from two big ol' tables. The innermost estimation mistake being made +by the planner is that the restriction on actor_full_name_uppercase +will be much more selective than it is; it thinks there will be 222 +matching actors and in fact there are 3639. But being right about this +wouldn't make things a lot quicker, if it would make them quicker at +all; the index scan for them is taking about 15 seconds and presumably +a sequential scan of that table would be at least in the same ballpark. + +Once it's got those rows it needs to look up matches for them in +actor_summary. Again, that's 3639 index scans of an index into a +wide-ish table; your interpretation of the 9.15 is correct. (9 ms * +3639 rows =~ 30 seconds). + +It doesn't seem to me that there would be a substantially better plan +for this query with your tables as they stand. If your data were more +normalised, then your big scans might be quicker (because their rows +would be smaller so they would hit fewer disk pages), and the extra +lookups in your detail tables would only be done for the rows which +actually ended up getting returned - but that would hardly be likely +to make an order-of-magnitude difference to your overall speed. + +If it were my query and I really really needed it to be considerably +faster, I'd think about hyper-normalising in the hope that my main +tables would shrink so far I could keep them in RAM effectively all +the time. The answers to your direct questions are (1) yes, (2) no, +not really, and (3) no. + +Richard + +From pgsql-general-owner@postgresql.org Tue Dec 16 20:05:03 2003 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id C95D7D1B442; Wed, 17 Dec 2003 00:04:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33703-06; Tue, 16 Dec 2003 20:04:31 -0400 (AST) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP + id E3405D1BB71; Tue, 16 Dec 2003 20:04:26 -0400 (AST) +Received: from ibm-a.pdx.osdl.net (ibm-a.pdx.osdl.net [172.20.1.50]) + by mail.osdl.org (8.11.6/8.11.6) with ESMTP id hBH04QZ25571; + Tue, 16 Dec 2003 16:04:26 -0800 +Subject: Re: update slows down in pl/pgsql function +From: Jenny Zhang +To: Stephan Szabo +Cc: perf-pgsql , + general-pgsql +In-Reply-To: <20031216155342.J28271@megazone.bigpanda.com> +References: <1071618760.10925.17.camel@ibm-a.pdx.osdl.net> + <20031216155342.J28271@megazone.bigpanda.com> +Content-Type: text/plain +Organization: osdl +Message-Id: <1071619646.10925.19.camel@ibm-a.pdx.osdl.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Tue, 16 Dec 2003 16:07:26 -0800 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/919 +X-Sequence-Number: 54312 + +Oops, I named the var name the same as the column name. Changing it to +something else solved the problem. + +Thanks, +Jenny +On Tue, 2003-12-16 at 15:54, Stephan Szabo wrote: +> On Tue, 16 Dec 2003, Jenny Zhang wrote: +> +> > I have stored procedure written in pl/pgsql which takes about 13 seconds +> > to finish. I was able to identify that the slowness is caused by one +> > update SQL: +> > +> > UPDATE shopping_cart SET sc_sub_total=sc_subtotal, sc_date=now() +> > WHERE sc_id=sc_id; +> +> Umm, is that exactly the condition you're using? Isn't that going to +> update the entire table? +> +> ---------------------------(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 Tue Dec 16 21:17:56 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 67D79D1CB3F + for ; + Wed, 17 Dec 2003 01:17:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 40437-05 + for ; + Tue, 16 Dec 2003 21:17:26 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id B8648D1CB21 + for ; + Tue, 16 Dec 2003 21:17:22 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 6C5DF3524B; Tue, 16 Dec 2003 17:17:26 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 6AEF734DBC; Tue, 16 Dec 2003 17:17:26 -0800 (PST) +Date: Tue, 16 Dec 2003 17:17:26 -0800 (PST) +From: Stephan Szabo +To: Nick Fankhauser +Cc: "Pgsql-Performance@Postgresql. Org" +Subject: Re: Nested loop performance +In-Reply-To: +Message-ID: <20031216171625.A31260@megazone.bigpanda.com> +References: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/247 +X-Sequence-Number: 5107 + + +On Tue, 16 Dec 2003, Nick Fankhauser wrote: + +> Is there a more efficient means than a nested loop to handle such a join? +> Would a different method be chosen if there was exactly one row in +> actor_summary for every row in actor? + +As a question, what does explain analyze give you if you +set enable_nestloop=false; before trying the query? + +From pgsql-performance-owner@postgresql.org Tue Dec 16 21:14:43 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 33F1ED1B47D + for ; + Wed, 17 Dec 2003 01:14:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 40647-05 + for ; + Tue, 16 Dec 2003 21:14:14 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id DC553D1B4B1 + for ; + Tue, 16 Dec 2003 21:14:09 -0400 (AST) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + hBH1DtoD085143; Wed, 17 Dec 2003 09:13:56 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <3FDFAEA8.1090607@familyhealth.com.au> +Date: Wed, 17 Dec 2003 09:17:28 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Sean P. Thomas" +Cc: pgsql-performance@postgresql.org +Subject: Re: Optimizing FK & PK performance... +References: <3FD89D72.8080508@ulanji.com> +In-Reply-To: <3FD89D72.8080508@ulanji.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/246 +X-Sequence-Number: 5106 + +> 1. Is there any performance difference for declaring a primary or +> foreign key a column or table contraint? From the documentation, which +> way is faster and/or scales better: +> +> +> CREATE TABLE distributors ( +> did integer, +> name varchar(40), +> PRIMARY KEY(did) +> ); +> +> CREATE TABLE distributors ( +> did integer PRIMARY KEY, +> name varchar(40) +> ); + +No difference - they're parsed to exactly the same thing (the first +version). + +> 2. Is DEFERRABLE and INITIALLY IMMEDIATE or INITIALLY DEFERRABLE +> perferred for performance? We generally have very small transactions +> (web app) but we utilize a model of: + +No idea on this one :/ + +Chris + + +From pgsql-performance-owner@postgresql.org Wed Dec 17 01:31:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 685F5D1B439 + for ; + Wed, 17 Dec 2003 05:30:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 68158-08 + for ; + Wed, 17 Dec 2003 01:30:28 -0400 (AST) +Received: from mallard.mail.pas.earthlink.net (mallard.mail.pas.earthlink.net + [207.217.120.48]) + by svr1.postgresql.org (Postfix) with ESMTP id A2B6DD1B43A + for ; + Wed, 17 Dec 2003 01:30:27 -0400 (AST) +Received: from hsa158.pool003.at101.earthlink.net ([216.249.70.158] + helo=shadovitzcmptr) + by mallard.mail.pas.earthlink.net with smtp (Exim 3.33 #1) + id 1AWUGM-0004PZ-00; Tue, 16 Dec 2003 21:30:22 -0800 +Received: by localhost with Microsoft MAPI; Tue, 16 Dec 2003 20:45:44 -0800 +Message-ID: <01C3C415.9359D080.david@shadovitz.com> +From: David Shadovitz +Reply-To: "david@shadovitz.com" +To: 'Neil Conway' +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Why is VACUUM ANALYZE
so slow? +Date: Tue, 16 Dec 2003 20:37:02 -0800 +X-Mailer: Microsoft Internet E-mail/MAPI - 8.0.0.4211 +MIME-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/249 +X-Sequence-Number: 5109 + +Neil, + +Thanks for the good advice. I noticed that I had some sessions for which I +could not account, and I think even a 2nd postmaster running. It looks like +I've cleaned everything up, and now I can VACUUM and I can DROP an index which +wouldn't drop. + +And I'm looking into upgrading PostgreSQL. + +-David + +On Tuesday, December 16, 2003 2:51 PM, Neil Conway [SMTP:neilc@samurai.com] +wrote: +> "David Shadovitz" writes: +> > I'm running PG 7.2.2 on RH Linux 8.0. +> +> Note that this version of PostgreSQL is quite old. +> +> > I'd like to know why "VACUUM ANALYZE
" is extemely slow (hours) for +> > certain tables. +> +> Is there another concurrent transaction that has modified the table +> but has not committed? VACUUM ANALYZE will need to block waiting for +> it. You might be able to get some insight into this by examining the +> pg_locks system view: +> +> http://www.postgresql.org/docs/current/static/monitoring-locks.html +> +> As well as the pg_stat_activity view. +> +> -Neil + +From pgsql-performance-owner@postgresql.org Wed Dec 17 01:30:55 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B1998D1B42F + for ; + Wed, 17 Dec 2003 05:30:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70425-03 + for ; + Wed, 17 Dec 2003 01:30:24 -0400 (AST) +Received: from mallard.mail.pas.earthlink.net (mallard.mail.pas.earthlink.net + [207.217.120.48]) + by svr1.postgresql.org (Postfix) with ESMTP id 8AF41D1B437 + for ; + Wed, 17 Dec 2003 01:30:23 -0400 (AST) +Received: from hsa158.pool003.at101.earthlink.net ([216.249.70.158] + helo=shadovitzcmptr) + by mallard.mail.pas.earthlink.net with smtp (Exim 3.33 #1) + id 1AWUGN-0004Pg-00 + for pgsql-performance@postgresql.org; Tue, 16 Dec 2003 21:30:23 -0800 +Received: by localhost with Microsoft MAPI; Tue, 16 Dec 2003 20:45:44 -0800 +Message-ID: <01C3C415.93ADBCE0.david@shadovitz.com> +From: David Shadovitz +Reply-To: "david@shadovitz.com" +To: "pgsql-performance@postgresql.org" +Subject: Why is restored database faster? +Date: Tue, 16 Dec 2003 20:42:58 -0800 +X-Mailer: Microsoft Internet E-mail/MAPI - 8.0.0.4211 +MIME-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/248 +X-Sequence-Number: 5108 + +I backed up my database using pg_dump, and then restored it onto a different +server using psql. I see that the query "SELECT COUNT(*) FROM myTable" +executes immediately on the new server but takes several seconds on the old +one. (The servers are identical.) + +What could account for this difference? Clustering? How can I get the +original server to perform as well as the new one? + +Thanks. +-David + +From pgsql-performance-owner@postgresql.org Wed Dec 17 02:00:50 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C115DD1B437 + for ; + Wed, 17 Dec 2003 06:00:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73570-03 + for ; + Wed, 17 Dec 2003 02:00:17 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 35D35D1B43F + for ; + Wed, 17 Dec 2003 02:00:16 -0400 (AST) +Received: from tokyo.samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + by bob.samurai.com (Postfix) with ESMTP + id E179223BC; Wed, 17 Dec 2003 01:00:14 -0500 (EST) +To: "david@shadovitz.com" +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Why is restored database faster? +From: Neil Conway +In-Reply-To: <01C3C415.93ADBCE0.david@shadovitz.com> (David Shadovitz's + message of "Tue, 16 Dec 2003 20:42:58 -0800") +References: <01C3C415.93ADBCE0.david@shadovitz.com> +Date: Wed, 17 Dec 2003 01:00:13 -0500 +Message-ID: <87iskgugpe.fsf@mailbox.samurai.com> +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/250 +X-Sequence-Number: 5110 + +David Shadovitz writes: +> What could account for this difference? + +Lots of things -- disk fragmentation, expired tuples that aren't being +cleaned up by VACUUM due to a long-lived transaction, the state of the +kernel buffer cache, the configuration of the kernel, etc. + +> How can I get the original server to perform as well as the new one? + +Well, you can start by giving us some more information. For example, +what is the output of VACUUM VERBOSE on the slow server? How much disk +space does the database directory take up on both machines? + +(BTW, "SELECT count(*) FROM table" isn't a particularly good DBMS +performance indication...) + +-Neil + + +From pgsql-performance-owner@postgresql.org Wed Dec 17 02:31:49 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CDA2D1C4ED + for ; + Wed, 17 Dec 2003 06:31:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 71054-09 + for ; + Wed, 17 Dec 2003 02:31:17 -0400 (AST) +Received: from smtp.pspl.co.in (unknown [202.54.11.65]) + by svr1.postgresql.org (Postfix) with ESMTP id DE46ED1C4D0 + for ; + Wed, 17 Dec 2003 02:31:13 -0400 (AST) +Received: (from root@localhost) + by smtp.pspl.co.in (8.12.9/8.12.9) id hBH6VIbo014665 + for ; Wed, 17 Dec 2003 12:01:18 +0530 +Received: from persistent.co.in (daithan.intranet.pspl.co.in [192.168.7.161]) + (authenticated bits=0) + by persistent.co.in (8.12.9/8.12.9) with ESMTP id hBH6VDQK014554; + Wed, 17 Dec 2003 12:01:13 +0530 +Message-ID: <3FDFF82A.2070201@persistent.co.in> +Date: Wed, 17 Dec 2003 12:01:06 +0530 +From: Shridhar Daithankar +Organization: Persistent Systems Pvt. Ltd. +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Neil Conway +Cc: "david@shadovitz.com" , + "pgsql-performance@postgresql.org" +Subject: Re: Why is restored database faster? +References: <01C3C415.93ADBCE0.david@shadovitz.com> + <87iskgugpe.fsf@mailbox.samurai.com> +In-Reply-To: <87iskgugpe.fsf@mailbox.samurai.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/251 +X-Sequence-Number: 5111 + +Neil Conway wrote: + +>>How can I get the original server to perform as well as the new one? + +Well, you have the answer. Dump the database, stop postmaster and restore it. +That should be faster than original one. + +> +> (BTW, "SELECT count(*) FROM table" isn't a particularly good DBMS +> performance indication...) + +Particularly in case of postgresql..:-) + + Shridhar + +From pgsql-performance-owner@postgresql.org Wed Dec 17 02:43:21 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B9694D1B4C8 + for ; + Wed, 17 Dec 2003 06:43:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 77260-06 + for ; + Wed, 17 Dec 2003 02:42:49 -0400 (AST) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 59368D1C4E2 + for ; + Wed, 17 Dec 2003 02:42:47 -0400 (AST) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id D54BB8DD3; Wed, 17 Dec 2003 07:42:46 +0100 (CET) +Date: Wed, 17 Dec 2003 07:42:46 +0100 (CET) +From: Dennis Bjorklund +To: David Shadovitz +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Why is restored database faster? +In-Reply-To: <01C3C415.93ADBCE0.david@shadovitz.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/252 +X-Sequence-Number: 5112 + +On Tue, 16 Dec 2003, David Shadovitz wrote: + +> I backed up my database using pg_dump, and then restored it onto a different +> server using psql. I see that the query "SELECT COUNT(*) FROM myTable" +> executes immediately on the new server but takes several seconds on the old +> one. (The servers are identical.) +> +> What could account for this difference? Clustering? How can I get the +> original server to perform as well as the new one? + +You probably need to run VACUUM FULL. It locks the tables during its +execution so only do it when the database is not in full use. + +If this helps you probably need to do normal vacuums more often and maybe +tune the max_fsm_pages to be bigger. + +-- +/Dennis + + +From pgsql-performance-owner@postgresql.org Wed Dec 17 05:52:52 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 32F42D1B565 + for ; + Wed, 17 Dec 2003 09:52:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 98641-06 + for ; + Wed, 17 Dec 2003 05:52:22 -0400 (AST) +Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net + [194.217.242.92]) + by svr1.postgresql.org (Postfix) with ESMTP id 00DC5D1C990 + for ; + Wed, 17 Dec 2003 05:52:20 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AWYLs-000Fn1-0Y; Wed, 17 Dec 2003 09:52:20 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 3BCCA167DB; Wed, 17 Dec 2003 09:52:19 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id E5F0615987; Wed, 17 Dec 2003 09:52:16 +0000 (GMT) +From: Richard Huxton +To: , + "Pgsql-Performance@Postgresql. Org" +Subject: Re: Nested loop question +Date: Wed, 17 Dec 2003 09:52:15 +0000 +User-Agent: KMail/1.5 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200312170952.15759.dev@archonet.com> +X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/253 +X-Sequence-Number: 5113 + +On Tuesday 16 December 2003 17:06, Nick Fankhauser - Doxpop wrote: +> Hi- +> +> I'm trying to optimize a query that I *think* should run very fast. +> Essentially, I'm joining two tables that have very selective indexes and +> constraining the query on an indexed field. (There's a third small lookup +> table in the mix, but it doesn't really affect the bottom line.) + +> I'm unsure what is happening next. I notice that an index scan is occurring +> on actor_summary_pk, with an "actual time" of 9.15, but then it looks like +> a nested loop occurs at the next level to join these tables. Does this mean +> that each probe of the actor_summary index will take 9.15 msec, but the +> nested loop is going to do this once for each actor_id? + +That's right - you need to multiply the actual time by the number of loops. In +your case this would seem to be about 33 seconds. + +> -> Index Scan using actor_summary_pk on +> actor_summary (cost=0.00..8.11 rows=1 width=72) (actual time=9.14..9.15 +> rows=1 loops=3639) +> Index Cond: ("outer".actor_id = +> actor_summary.actor_id) + +> The nested loop appears to be where most of my time is going, so I'm +> focusing on this area, but don't know if there is a better approach to this +> join. +> +> Is there a more efficient means than a nested loop to handle such a join? +> Would a different method be chosen if there was exactly one row in +> actor_summary for every row in actor? + +Hmm - tricky to say in your case. PG has decided to filter on actor then look +up the corresponding values in actor_summary. Given that you have 3 million +rows in both tables that seems a reasonable approach. You could always try +forcing different plans by switching the various ENABLE_HASHJOIN etc options +(see the runtime configuration section of the manuals). I'm not sure that +will help you here though. + +The fact that it's taking you 9ms to do each index lookup suggests to me that +it's going to disk each time. Does that sound plausible, or do you think you +have enough RAM to cache your large indexes? + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Dec 17 11:26:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AACABD1B486 + for ; + Wed, 17 Dec 2003 15:26:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45255-01 + for ; + Wed, 17 Dec 2003 11:26:16 -0400 (AST) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D279D1B488 + for ; + Wed, 17 Dec 2003 11:26:12 -0400 (AST) +Received: from nick (bilbo.ontko.com [199.164.165.101]) + by shire.ontko.com (8.12.3/8.12.3/Debian-6.6) with SMTP id + hBHFQ65j020851; Wed, 17 Dec 2003 10:26:13 -0500 +Reply-To: +From: "Nick Fankhauser" +To: "Richard Huxton" , + "Pgsql-Performance@Postgresql. Org" +Subject: Re: Nested loop question +Date: Wed, 17 Dec 2003 10:26:19 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +In-Reply-To: <200312170952.15759.dev@archonet.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/255 +X-Sequence-Number: 5115 + + +> The fact that it's taking you 9ms to do each index lookup +> suggests to me that +> it's going to disk each time. Does that sound plausible, or do +> you think you +> have enough RAM to cache your large indexes? + +I'm sure we don't have enough RAM to cache all of our large indexes, so your +supposition makes sense. We have 1GB on this machine. In responding to the +performance problems we're having, one of the questions has been adding +memory vs crafting "helper" tables to speed things up. The issue is that +this database needs to be able to scale easily to about 10 times the size, +so although we could easily triple the memory at reasonable expense, we'd +eventually hit a wall. + +Is there any solid method to insure that a particular index always resides +in memory? A hybrid approach that might scale reliably would be to bump up +our memory and then make sure key indexes are cached. however, I'm concerned +that if we didn't have a way to ensure that the indexes that we choose +remain cached, we would have very inconsistent responses. + +Thanks for your ideas! + +-Nick + + + + +From pgsql-performance-owner@postgresql.org Wed Dec 17 11:26:44 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F0CBD1B47D + for ; + Wed, 17 Dec 2003 15:26:42 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 45227-01 + for ; + Wed, 17 Dec 2003 11:26:15 -0400 (AST) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 31BECD1B47E + for ; + Wed, 17 Dec 2003 11:26:11 -0400 (AST) +Received: from nick (bilbo.ontko.com [199.164.165.101]) + by shire.ontko.com (8.12.3/8.12.3/Debian-6.6) with SMTP id + hBHFQ65k020851; Wed, 17 Dec 2003 10:26:14 -0500 +Reply-To: +From: "Nick Fankhauser" +To: "Stephan Szabo" , + "Nick Fankhauser" +Cc: "Pgsql-Performance@Postgresql. Org" +Subject: Re: Nested loop performance +Date: Wed, 17 Dec 2003 10:26:20 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +In-Reply-To: <20031216171625.A31260@megazone.bigpanda.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/254 +X-Sequence-Number: 5114 + + +> As a question, what does explain analyze give you if you +> set enable_nestloop=false; before trying the query? + +Here are the results- It looks quite a bit more painful than the other plan, +although the wall time is in the same ballpark. + +alpha=# explain analyze +alpha-# select +alpha-# min(actor.actor_id) as actor_id, +alpha-# min(actor.actor_entity_type) as actor_entity_type, +alpha-# min(actor.role_class_code) as role_class_code, +alpha-# min(actor.actor_full_name) as actor_full_name, +alpha-# min(actor.actor_person_date_of_birth) as +actor_person_date_of_birth, +alpha-# min(actor.actor_entity_acronym) as actor_entity_acronym, +alpha-# min(actor.actor_person_last_name) as actor_person_last_name, +alpha-# min(actor.actor_person_first_name) as actor_person_first_name, +alpha-# min(actor.actor_person_middle_name) as actor_person_middle_name, +alpha-# min(actor.actor_person_name_suffix) as actor_person_name_suffix, +alpha-# min(actor.actor_person_place_of_birth) as +actor_person_place_of_birth, +alpha-# min(actor.actor_person_height) as actor_person_height, +alpha-# min(actor.actor_person_height_unit) as actor_person_height_unit, +alpha-# min(actor.actor_person_weight) as actor_person_weight, +alpha-# min(actor.actor_person_weight_unit) as actor_person_weight_unit, +alpha-# min(actor.actor_person_ethnicity) as actor_person_ethnicity, +alpha-# min(actor.actor_person_citizenship_count) as +actor_person_citizenship_count, +alpha-# min(actor.actor_person_hair_color) as actor_person_hair_color, +alpha-# min(actor.actor_person_scars_marks_tatto) as +actor_person_scars_marks_tatto, +alpha-# min(actor.actor_person_marital_status) as +actor_person_marital_status, +alpha-# min(actor.actor_alias_for_actor_id) as actor_alias_for_actor_id, +alpha-# min(to_char(data_source.source_last_update, 'MM/DD/YYYY HH12:MI +AM TZ')) as last_update, +alpha-# min(actor_summary.single_case_public_id) as case_public_id, +alpha-# min(actor_summary.single_case_id) as case_id, +alpha-# sum(actor_summary.case_count)as case_count +alpha-# from +alpha-# actor, +alpha-# actor_summary, +alpha-# data_source +alpha-# where +alpha-# actor.actor_id = actor_summary.actor_id +alpha-# and data_source.source_id = actor.source_id +alpha-# and actor.actor_full_name_uppercase like upper('sanders%') +alpha-# group by +alpha-# actor.actor_id +alpha-# order by +alpha-# min(actor.actor_full_name_uppercase), +alpha-# case_count desc, +alpha-# min(actor_summary.case_disp_global_code) +alpha-# limit +alpha-# 1000; + +QUERY PLAN + +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +---------------- +---------------------- + Limit (cost=168919.98..168920.03 rows=20 width=548) (actual +time=91247.95..91249.05 rows=1000 loops=1) + -> Sort (cost=168919.98..168920.03 rows=20 width=548) (actual +time=91247.95..91248.35 rows=1001 loops=1) + Sort Key: min((actor.actor_full_name_uppercase)::text), +sum(actor_summary.case_count), +min((actor_summary.case_disp_global_code)::text) + -> Aggregate (cost=168904.95..168919.54 rows=20 width=548) +(actual time=91015.00..91164.68 rows=3590 loops=1) + -> Group (cost=168904.95..168905.95 rows=201 width=548) +(actual time=90999.87..91043.25 rows=3594 loops=1) + -> Sort (cost=168904.95..168905.45 rows=201 +width=548) (actual time=90999.83..91001.57 rows=3594 loops=1) + Sort Key: actor.actor_id + -> Hash Join (cost=903.08..168897.24 rows=201 +width=548) (actual time=25470.63..90983.45 rows=3594 loops=1) + Hash Cond: ("outer".actor_id = +"inner".actor_id) + -> Seq Scan on actor_summary +(cost=0.00..150715.43 rows=3455243 width=73) (actual time=8.03..52902.24 +rows=3455243 loops=1) + -> Hash (cost=902.57..902.57 rows=204 +width=475) (actual time=25459.92..25459.92 rows=0 loops=1) + -> Hash Join (cost=1.14..902.57 +rows=204 width=475) (actual time=155.92..25451.25 rows=3639 loops=1) + Hash Cond: ("outer".source_id = +"inner".source_id) + -> Index Scan using +actor_full_name_uppercase on actor (cost=0.00..897.20 rows=223 width=463) +(actual time=144.93..25404. +10 rows=3639 loops=1) + Index Cond: +((actor_full_name_uppercase >= 'SANDERS'::character varying) AND +(actor_full_name_uppercase < 'SANDERT':: +character varying)) + Filter: +(actor_full_name_uppercase ~~ 'SANDERS%'::text) + -> Hash (cost=1.11..1.11 +rows=11 width=12) (actual time=10.66..10.66 rows=0 loops=1) + -> Seq Scan on +data_source (cost=0.00..1.11 rows=11 width=12) (actual time=10.63..10.64 +rows=11 loops=1) + Total runtime: 91275.18 msec +(19 rows) + +alpha=# + + + +From pgsql-performance-owner@postgresql.org Wed Dec 17 11:27:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 06A58D1BB71 + for ; + Wed, 17 Dec 2003 15:26:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 39356-07 + for ; + Wed, 17 Dec 2003 11:26:30 -0400 (AST) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id E7190D1B4BB + for ; + Wed, 17 Dec 2003 11:26:25 -0400 (AST) +Received: from nick (bilbo.ontko.com [199.164.165.101]) + by shire.ontko.com (8.12.3/8.12.3/Debian-6.6) with SMTP id + hBHFQ65l020851; Wed, 17 Dec 2003 10:26:15 -0500 +Reply-To: +From: "Nick Fankhauser" +To: "Richard Poole" , + "Pgsql-Performance@Postgresql. Org" +Subject: Re: Nested loop performance +Date: Wed, 17 Dec 2003 10:26:25 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +In-Reply-To: <20031216235541.GB8054@guests.deus.net> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/256 +X-Sequence-Number: 5116 + +> It seems that your basic problem is that you're fetching lots of rows +> from two big ol' tables. + +> It doesn't seem to me that there would be a substantially better plan +> for this query with your tables as they stand. + +That's more or less the conclusion I had come to. I was just hoping someone +else could point out an approach I've been missing. (sigh!) + + + +> If your data were more +> normalised, then your big scans might be quicker (because their rows +> would be smaller so they would hit fewer disk pages), + +This started off as a 5-table join on well-normalized data. Unfortunately, +the actor table doesn't get any smaller, and the work involved in +calculating the "case_count" information on the fly was clearly becoming a +problem- particularly with actors that had a heavy caseload. (Busy attorneys +and judges.) The actor_summary approach makes these previous problem cases +go away, but the payback is that (as you correctly pointed out) queries on +average citizens who only have one case suffer from the de-normalized +approach. + +We're currently considering the approach of just returning all of the rows +to our application, and doing the aggregation and limit work in the app. The +inconsistency of the data makes it very tough for the query planner to come +up with an strategy that is always a winner. + +Thanks for your thoughts! + +-Nick + + + +From pgsql-performance-owner@postgresql.org Mon Dec 22 16:38:13 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5A462D1B437; Wed, 17 Dec 2003 16:58:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 58048-03; Wed, 17 Dec 2003 12:58:15 -0400 (AST) +Received: from smxsat1.smxs.net (smxsat1.smxs.net [213.150.10.1]) + by svr1.postgresql.org (Postfix) with ESMTP + id B8164D1B441; Wed, 17 Dec 2003 12:58:12 -0400 (AST) +Received: from m01x1.s-mxs.net [10.3.55.201] by smxsat1.smxs.net + over TLS secured channel with XWall v3.28g ; + Wed, 17 Dec 2003 17:57:54 +0100 +Received: from m0102.s-mxs.net [10.3.55.2] by m01x1.s-mxs.net + with XWall v3.28f ; Wed, 17 Dec 2003 17:57:53 +0100 +Received: from m0114.s-mxs.net ([10.3.55.14]) by m0102.s-mxs.net with + Microsoft SMTPSVC(5.0.2195.5329); Wed, 17 Dec 2003 17:57:53 +0100 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6503.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: [HACKERS] fsync method checking +Date: Wed, 17 Dec 2003 17:57:52 +0100 +Message-ID: <46C15C39FEB2C44BA555E356FBCD6FA496208C@m0114.s-mxs.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [HACKERS] fsync method checking +Thread-Index: AcPA90yf7GDEkd2TQ9idLmOL/AmsmQDxrHRQ +From: "Zeugswetter Andreas SB SD" +To: "Tom Lane" , + "Manfred Spraul" +Cc: "Bruce Momjian" , + "Mark Kirkwood" , + , + "PostgreSQL-development" +X-OriginalArrivalTime: 17 Dec 2003 16:57:53.0114 (UTC) + FILETIME=[E92963A0:01C3C4BE] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/284 +X-Sequence-Number: 5144 + + +> Ideally that path isn't taken very often. But I'm currently having a +> discussion off-list with a CMU student who seems to be seeing a case +> where it happens a lot. (She reports that both WALWriteLock and +> WALInsertLock are causes of a lot of process blockages, which seems to +> mean that a lot of the WAL I/O is being done with both held, which would +> have to mean that AdvanceXLInsertBuffer is doing the I/O.=20=20 +> More when we figure out what's going on exactly...) + +I would figure, that this is in a situation where a large transaction +fills one XLInsertBuffer, and a lot of WAL buffers are not yet written. + +Andreas + +From pgsql-performance-owner@postgresql.org Wed Dec 17 14:35:02 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 850BAD1B8BC + for ; + Wed, 17 Dec 2003 18:35:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69990-10 + for ; + Wed, 17 Dec 2003 14:34:30 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 61257D1B534 + for ; + Wed, 17 Dec 2003 14:34:29 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBHIYO19008942; + Wed, 17 Dec 2003 13:34:27 -0500 (EST) +To: Hannu Krosing +Cc: "Chadwick, Russell" , + pgsql-performance@postgresql.org +Subject: Re: Excessive rows/tuples seriously degrading query +In-reply-to: <1071609885.5397.8.camel@fuji.krosing.net> +References: + <1071609885.5397.8.camel@fuji.krosing.net> +Comments: In-reply-to Hannu Krosing + message dated "Tue, 16 Dec 2003 23:24:45 +0200" +Date: Wed, 17 Dec 2003 13:34:24 -0500 +Message-ID: <8941.1071686064@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/257 +X-Sequence-Number: 5117 + +Hannu Krosing writes: +> Chadwick, Russell kirjutas L, 13.12.2003 kell 00:40: +>> Can anyone explain why this table which has never had more than a +>> couple rows in it shows > 500k in the query planner even after running +>> vacuum full. + +> It can be that there is an idle transaction somewhere that has locked a +> lot of rows (i.e. all your updates have been running inside the same +> transaction for hour or days) + +In fact an old open transaction is surely the issue, given that the +VACUUM report shows a huge number of "kept" tuples: + +>> INFO: Pages 4773: Changed 1, reaped 767, Empty 0, New 0; Tup 613737: Vac 57620, Keep/VTL 613735/613713, UnUsed 20652, MinLen 52, MaxLen 52; Re-using: Free/Avail. Space 4322596/4322596; EndEmpty/Avail. Pages 0/4773. +>> CPU 9.11s/13.68u sec elapsed 22.94 sec. + +"Keep" is the number of tuples that are committed dead but can't be +removed yet because there is some other open transaction that is old +enough that it should be able to see them if it looks. + +Apparently the access pattern on this table is constant updates of the +two logical rows, leaving lots and lots of dead versions. You need to +vacuum it more often to keep down the amount of deadwood, and you need +to avoid having very-long-running transactions open when you vacuum. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Dec 17 15:57:21 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F21A8D1B452 + for ; + Wed, 17 Dec 2003 19:57:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 81206-10 + for ; + Wed, 17 Dec 2003 15:56:51 -0400 (AST) +Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) + by svr1.postgresql.org (Postfix) with ESMTP id DD9A2D1B459 + for ; + Wed, 17 Dec 2003 15:56:49 -0400 (AST) +Received: from nick (bilbo.ontko.com [199.164.165.101]) + by shire.ontko.com (8.12.3/8.12.3/Debian-6.6) with SMTP id + hBHJun5f027972 + for ; Wed, 17 Dec 2003 14:56:50 -0500 +Reply-To: +From: "Nick Fankhauser" +To: "Pgsql-Performance@Postgresql. Org" +Subject: Adding RAM: seeking advice & warnings of hidden "gotchas" +Date: Wed, 17 Dec 2003 14:57:02 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/258 +X-Sequence-Number: 5118 + +Hi- + +After having done my best to squeeze better performance out of our +application by tuning within our existing resources, I'm falling back on +adding memory as a short-term solution while we get creative for a long-term +fix. I'm curious about what experiences others have had with the process of +adding big chunks of RAM. In particular, if I'm trying to encourage the OS +to cache more of my index information in RAM, what sort of configuration +should I do at both the PostgreSQL and OS level? + +In a slightly off-topic vein, I'd also like to hear about it if anyone knows +about any gotchas at the OS level that might become a problem. + +The server is a dual processor Athlon 1.2GHz box with hardware SCSI RAID. It +currently has 1 GB RAM, and we're planning to add one GB more for a total of +2GB. The OS is Debian Linux Kernel 2.4.x, and we're on PostgreSQL v7.3.2 + +My current memory related settings are: + +SHMMAX and SHMALL set to 128MB (OS setting) +shared buffers 8192 (64MB) +sort_mem 16384 (16MB) +effective_cache_size 65536 (512MB) + + +We support up to 70 active users, sharing a connection pool of 16 +connections. Most of the queries center around 3 tables that are about 1.5 +GB each. + + +Thanks. + -Nick + +--------------------------------------------------------------------- +Nick Fankhauser + + nickf@doxpop.com Phone 1.765.965.7363 Fax 1.765.962.9788 +doxpop - Court records at your fingertips - http://www.doxpop.com/ + + + +From pgsql-performance-owner@postgresql.org Wed Dec 17 17:39:45 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 67B67D1BA62 + for ; + Wed, 17 Dec 2003 21:39:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06735-10 + for ; + Wed, 17 Dec 2003 17:39:12 -0400 (AST) +Received: from main.wiredfool.com (dsl231-055-035.sea1.dsl.speakeasy.net + [216.231.55.35]) + by svr1.postgresql.org (Postfix) with ESMTP id DFC97D1B477 + for ; + Wed, 17 Dec 2003 17:38:47 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by main.wiredfool.com (Postfix) with ESMTP + id 403A22728F; Wed, 17 Dec 2003 13:33:38 -0800 (PST) +Received: from main.wiredfool.com ([127.0.0.1]) + by localhost (cabbage [127.0.0.1]) (amavisd-new, port 10024) with ESMTP + id 20898-05; Wed, 17 Dec 2003 13:33:34 -0800 (PST) +Received: from [IPv6:::1] (localhost [127.0.0.1]) + by main.wiredfool.com (Postfix) with ESMTP + id 9726A2728D; Wed, 17 Dec 2003 13:33:34 -0800 (PST) +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v606) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <63587126-30D9-11D8-A85B-0003930F2A6C@soroos.net> +Content-Transfer-Encoding: 7bit +Cc: "Pgsql-Performance@Postgresql. Org" +From: Eric Soroos +Subject: Re: Adding RAM: seeking advice & warnings of hidden "gotchas" +Date: Wed, 17 Dec 2003 13:38:44 -0800 +To: +X-Mailer: Apple Mail (2.606) +X-Virus-Scanned: by amavisd-new-20030616-p3 (Debian) at main.wiredfool.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/259 +X-Sequence-Number: 5119 + + +On Dec 17, 2003, at 11:57 AM, Nick Fankhauser wrote: + +> Hi- +> +> After having done my best to squeeze better performance out of our +> application by tuning within our existing resources, I'm falling back +> on +> adding memory as a short-term solution while we get creative for a +> long-term +> fix. I'm curious about what experiences others have had with the +> process of +> adding big chunks of RAM. In particular, if I'm trying to encourage +> the OS +> to cache more of my index information in RAM, what sort of +> configuration +> should I do at both the PostgreSQL and OS level? + +You need bigmem compiled in the kernel, which you should already have +at the 1 gig level iirc. +You should bump up your effective cache size, probably to around 1.75 +gig. + +I wouldn't bump up the shared buffers beyond where you have them now. +If you're swapping out sorts to disk, you may gain boosting sortmem +some since you have the additional memory to use. + +> The server is a dual processor Athlon 1.2GHz box with hardware SCSI +> RAID. It +> currently has 1 GB RAM, and we're planning to add one GB more for a +> total of +> 2GB. The OS is Debian Linux Kernel 2.4.x, and we're on PostgreSQL +> v7.3.2 + +I've got a machine running Debian Stable w/2.4.x, 1.3 ghz p3, 1.5 gig +ram, pg 7.2.4 and it's rock solid. + + +eric + + +From pgsql-performance-owner@postgresql.org Wed Dec 17 18:19:35 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 022EDD1B495 + for ; + Wed, 17 Dec 2003 22:19:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15132-03 + for ; + Wed, 17 Dec 2003 18:19:04 -0400 (AST) +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 08CC0D1B45D + for ; + Wed, 17 Dec 2003 18:19:00 -0400 (AST) +Received: from finisterre (82-68-132-233.dsl.in-addr.zen.co.uk + [82.68.132.233]) + by bayswater1.ymogen.net (Postfix) with SMTP + id A7A4B9AE38; Wed, 17 Dec 2003 22:18:45 +0000 (GMT) +From: "Matt Clark" +To: , + "Pgsql-Performance@Postgresql. Org" +Subject: Re: Adding RAM: seeking advice & warnings of hidden "gotchas" +Date: Wed, 17 Dec 2003 22:18:45 -0000 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +In-Reply-To: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/260 +X-Sequence-Number: 5120 + +If you have 3 1.5GB tables then you might as well go for 4GB while you're at +it. Make sure you've got a bigmem kernel either running or available, and +boost effective_cache_size by whatever amount you increase the RAM by. We +run a Quad Xeon/4GB server on Redhat 7.3 and it's solid as a rock. + +There is no way I know of to get indexes preferentially cached over data +though. + +Matt + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Nick +> Fankhauser +> Sent: 17 December 2003 19:57 +> To: Pgsql-Performance@Postgresql. Org +> Subject: [PERFORM] Adding RAM: seeking advice & warnings of hidden +> "gotchas" +> +> +> Hi- +> +> After having done my best to squeeze better performance out of our +> application by tuning within our existing resources, I'm falling back on +> adding memory as a short-term solution while we get creative for +> a long-term +> fix. I'm curious about what experiences others have had with the +> process of +> adding big chunks of RAM. In particular, if I'm trying to encourage the OS +> to cache more of my index information in RAM, what sort of configuration +> should I do at both the PostgreSQL and OS level? +> +> In a slightly off-topic vein, I'd also like to hear about it if +> anyone knows +> about any gotchas at the OS level that might become a problem. +> +> The server is a dual processor Athlon 1.2GHz box with hardware +> SCSI RAID. It +> currently has 1 GB RAM, and we're planning to add one GB more for +> a total of +> 2GB. The OS is Debian Linux Kernel 2.4.x, and we're on PostgreSQL v7.3.2 +> +> My current memory related settings are: +> +> SHMMAX and SHMALL set to 128MB (OS setting) +> shared buffers 8192 (64MB) +> sort_mem 16384 (16MB) +> effective_cache_size 65536 (512MB) +> +> +> We support up to 70 active users, sharing a connection pool of 16 +> connections. Most of the queries center around 3 tables that are about 1.5 +> GB each. +> +> +> Thanks. +> -Nick +> +> --------------------------------------------------------------------- +> Nick Fankhauser +> +> nickf@doxpop.com Phone 1.765.965.7363 Fax 1.765.962.9788 +> doxpop - Court records at your fingertips - http://www.doxpop.com/ +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings +> + + +From pgsql-performance-owner@postgresql.org Thu Dec 18 00:00:12 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C20E4D1B449 + for ; + Thu, 18 Dec 2003 03:59:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 50374-09 + for ; + Wed, 17 Dec 2003 23:59:25 -0400 (AST) +Received: from snipe.mail.pas.earthlink.net (snipe.mail.pas.earthlink.net + [207.217.120.62]) + by svr1.postgresql.org (Postfix) with ESMTP id 75BCDD1B44D + for ; + Wed, 17 Dec 2003 23:59:24 -0400 (AST) +Received: from hsa218.pool032.at101.earthlink.net ([216.249.101.218] + helo=shadovitzcmptr) + by snipe.mail.pas.earthlink.net with smtp (Exim 3.33 #1) + id 1AWpJW-00001w-00; Wed, 17 Dec 2003 19:59:02 -0800 +Received: by localhost with Microsoft MAPI; Wed, 17 Dec 2003 19:55:01 -0800 +Message-ID: <01C3C4D7.A7F88280.david@shadovitz.com> +From: David Shadovitz +Reply-To: "david@shadovitz.com" +To: 'Dennis Bjorklund' , + "'shridhar_daithankar@persistent.co.in'" + , + "'neilc@samurai.com'" +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Why is restored database faster? +Date: Wed, 17 Dec 2003 19:54:45 -0800 +X-Mailer: Microsoft Internet E-mail/MAPI - 8.0.0.4211 +MIME-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/261 +X-Sequence-Number: 5121 + +Dennis, Shridhar, and Neil, + +Thanks for your input. Here are my responses: + +I ran VACUUM FULL on the table in question. Although that did reduce "Pages" +and "UnUsed", the "SELECT *" query is still much slower on this installation +than in the new, restored one. + + Old server: + # VACUUM FULL abc; + VACUUM + # VACUUM VERBOSE abc; + NOTICE: --Relation abc-- + NOTICE: Pages 1526: Changed 0, Empty 0; Tup 91528; Vac 0, Keep 0, UnUsed 32. + Total CPU 0.07s/0.52u sec elapsed 0.60 sec. + VACUUM + + New server: + # VACUUM VERBOSE abc; + NOTICE: --Relation abc-- + NOTICE: Pages 1526: Changed 0, Empty 0; Tup 91528; Vac 0, Keep 0, UnUsed 0. + Total CPU 0.02s/0.00u sec elapsed 0.02 sec. + VACUUM + +max_fsm_pages is at its default value, 10000. + +People don't have the practice of dumping and restoring just for the purpose of +improving performance, do they? + +Neil asked how much disk space the database directory takes on each machine. + What directory is of interest? The whole thing takes up about 875 MB on each +machine. + +-David + +From pgsql-performance-owner@postgresql.org Thu Dec 18 02:48:21 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 74623D1B46D + for ; + Thu, 18 Dec 2003 06:48:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69309-03 + for ; + Thu, 18 Dec 2003 02:47:50 -0400 (AST) +Received: from smtp.pspl.co.in (unknown [202.54.11.65]) + by svr1.postgresql.org (Postfix) with ESMTP id 556EED1B46E + for ; + Thu, 18 Dec 2003 02:47:47 -0400 (AST) +Received: (from root@localhost) + by smtp.pspl.co.in (8.12.9/8.12.9) id hBI6lqG1018277 + for ; Thu, 18 Dec 2003 12:17:52 +0530 +Received: from daithan.intranet.pspl.co.in (daithan.intranet.pspl.co.in + [192.168.7.161]) (authenticated bits=0) + by persistent.co.in (8.12.9/8.12.9) with ESMTP id hBI6lpQK018257 + for ; Thu, 18 Dec 2003 12:17:51 +0530 +From: Shridhar Daithankar +To: "pgsql-performance@postgresql.org" +Subject: Re: Why is restored database faster? +Date: Thu, 18 Dec 2003 12:17:12 +0530 +User-Agent: KMail/1.5.4 +References: <01C3C4D7.A7F88280.david@shadovitz.com> +In-Reply-To: <01C3C4D7.A7F88280.david@shadovitz.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200312181217.12520.shridhar_daithankar@persistent.co.in> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/262 +X-Sequence-Number: 5122 + +On Thursday 18 December 2003 09:24, David Shadovitz wrote: +> Old server: +> # VACUUM FULL abc; +> VACUUM +> # VACUUM VERBOSE abc; +> NOTICE: --Relation abc-- +> NOTICE: Pages 1526: Changed 0, Empty 0; Tup 91528; Vac 0, Keep 0, UnUsed +> 32. Total CPU 0.07s/0.52u sec elapsed 0.60 sec. +> VACUUM +> +> New server: +> # VACUUM VERBOSE abc; +> NOTICE: --Relation abc-- +> NOTICE: Pages 1526: Changed 0, Empty 0; Tup 91528; Vac 0, Keep 0, UnUsed +> 0. Total CPU 0.02s/0.00u sec elapsed 0.02 sec. +> VACUUM +> +> max_fsm_pages is at its default value, 10000. + +Well, then the only issue left is file sytem defragmentation. Which file +system is this anyway + +> People don't have the practice of dumping and restoring just for the +> purpose of improving performance, do they? + +Well, at times it is required. Especially if it is update intensive +environment. An no database is immune to that + +> Neil asked how much disk space the database directory takes on each +> machine. What directory is of interest? The whole thing takes up about 875 +> MB on each machine. + +That is fairly small.. Should not take much time..in my guess, the time it +takes to vacuum is more than time to dump and reload. + +Another quick way to defragment a file system is to copy entire data directory +to another partition(Shutdown postmaster first), delete it from original +partition and move back. Contegous wriing to a partition results in +defragmentation effectively. + +Try it and see if it helps. It could be much less trouble than dump/restore.. + +HTH + + Shridhar + + +From pgsql-performance-owner@postgresql.org Thu Dec 18 11:13:07 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 68832D1B491 + for ; + Thu, 18 Dec 2003 15:13:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 30772-08 + for ; + Thu, 18 Dec 2003 11:12:18 -0400 (AST) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 05E88D1B4CF + for ; + Thu, 18 Dec 2003 11:12:14 -0400 (AST) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 9A14E8DD4; Thu, 18 Dec 2003 16:12:16 +0100 (CET) +Date: Thu, 18 Dec 2003 16:12:16 +0100 (CET) +From: Dennis Bjorklund +To: Shridhar Daithankar +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Why is restored database faster? +In-Reply-To: <200312181217.12520.shridhar_daithankar@persistent.co.in> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/263 +X-Sequence-Number: 5123 + +On Thu, 18 Dec 2003, Shridhar Daithankar wrote: + +> Well, then the only issue left is file sytem defragmentation. + +And the internal fragmentation that can be "fixed" with the CLUSTER +command. + +-- +/Dennis + + +From pgsql-performance-owner@postgresql.org Mon Dec 22 16:38:16 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2959DD1B45D + for ; + Thu, 18 Dec 2003 17:05:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 52007-04 + for ; + Thu, 18 Dec 2003 13:05:01 -0400 (AST) +Received: from smtp-slave1.fsdata.se (smtp-gw.fsdata.se [195.35.82.150]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CF6FD1B45E + for ; + Thu, 18 Dec 2003 13:05:00 -0400 (AST) +Received: from www3.aname.net (www3.aname.net [62.119.28.103]) + by smtp-slave1.fsdata.se (8.12.10/8.12.0) with ESMTP id hBIH4qIY023254 + for ; Thu, 18 Dec 2003 18:04:52 +0100 +Received: from www3.aname.net (localhost [127.0.0.1]) + by www3.aname.net (8.12.10/8.12.10) with ESMTP id hBIH4qgX010135 + for ; Thu, 18 Dec 2003 18:04:52 +0100 +Received: (from servi008@localhost) + by www3.aname.net (8.12.10/8.12.0/Submit) id hBIH4qJj010134; + Thu, 18 Dec 2003 18:04:52 +0100 +Date: Thu, 18 Dec 2003 18:04:52 +0100 +From: Conny Thimren +Reply-To: conny.thimren@servit.se +Subject: general peformance question +To: pgsql-performance@postgresql.org +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/plain; CHARSET=iso-8859-1 +Content-Transfer-Encoding: QUOTED-PRINTABLE +Importance: Normal +X-Mailer: FS Webmail v2.0 +X-FSDATA-AntiSpamScore: 1.8 +X-FSDATA-AntiSpamRules: MIME_QP_DEFICIENT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/285 +X-Sequence-Number: 5145 + +Hi, +This a kind of newbie-question. I've been using Postgres for a long time in= + a low transction environment - and it is great. + +Now I've got an inquiry for using Postgresql in a heavy-load on-line system= +. This system must handle something like 20 questions per sec with a respon= +se time at 1/10 sec. Each question will result in approx 5-6 reads and a co= +uple of updates. +Anybody have a feeling if this is realistic on a Intelbased Linux server wi= +th Postgresql. Ofcourse I know that this is too little info for an exact an= +swer but - as I said - maybe someone can give a hint if it's possible. Mayb= +e someone with heavy-load can give an example of what is possible... + +Regards +Conny Thimr=E9n + + +From pgsql-performance-owner@postgresql.org Thu Dec 18 14:44:31 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 555DDD1B906 + for ; + Thu, 18 Dec 2003 18:44:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 64935-03 + for ; + Thu, 18 Dec 2003 14:43:41 -0400 (AST) +Received: from morework.geizhals.at (home.geizhals.at [213.229.14.34]) + by svr1.postgresql.org (Postfix) with ESMTP id DC588D1B8C0 + for ; + Thu, 18 Dec 2003 14:43:38 -0400 (AST) +Received: from localhost (morework [127.0.0.1]) + by morework.geizhals.at (Postfix) with ESMTP id 84B21524176 + for ; + Thu, 18 Dec 2003 19:43:25 +0100 (CET) +Received: from geizhals.at (chello080110242194.117.11.tuwien.teleweb.at + [80.110.242.194]) + by morework.geizhals.at (Postfix) with ESMTP id 4623D52410E + for ; + Thu, 18 Dec 2003 19:43:25 +0100 (CET) +Message-ID: <3FE1F5A1.6080908@geizhals.at> +Date: Thu, 18 Dec 2003 19:44:49 +0100 +From: "Marinos J. Yannikos" +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: why do optimizer parameters have to be set manually? +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by AMaViS snapshot-20020222 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/264 +X-Sequence-Number: 5124 + +Hi, + +it seems to me that the optimizer parameters (like random_page_cost +etc.) could easily be calculated and adjusted dynamically be the DB +backend based on the planner's cost estimates and actual run times for +different queries. Perhaps the developers could comment on that? + +I'm not sure how the parameters are used internally (apart from whatever +"EXPLAIN" shows), but if cpu_operator_cost is the same for all +operators, this should probably also be adjusted for individual +operators (I suppose that ">" is not as costly as "~*"). + +As far as the static configuration is concerned, I'd be interested in +other users' parameters and hardware configurations. Here's ours (for a +write-intensive db that also performs many queries with regular +expression matching): + +effective_cache_size = 1000000 # typically 8KB each +#random_page_cost = 0.2 # units are one sequential page fetch cost +random_page_cost = 3 # units are one sequential page fetch cost +#cpu_tuple_cost = 0.01 # (same) +cpu_index_tuple_cost = 0.01 # (same) 0.1 +#cpu_operator_cost = 0.0025 # (same) +cpu_operator_cost = 0.025 # (same) + +other options: + +shared_buffers = 240000 # 2*max_connections, min 16, typically 8KB each +max_fsm_relations = 10000 # min 10, fsm is free space map, ~40 bytes +max_fsm_pages = 10000000 # min 1000, fsm is free space map, ~6 bytes +#max_locks_per_transaction = 20 # min 10 +wal_buffers = 128 # min 4, typically 8KB each +sort_mem = 800000 # min 64, size in KB +vacuum_mem = 100000 # min 1024, size in KB +checkpoint_segments = 80 # in logfile segments, min 1, 16MB each +checkpoint_timeout = 300 # range 30-3600, in seconds +commit_delay = 100000 # range 0-100000, in microseconds +commit_siblings = 5 # range 1-1000 + +12GB RAM, dual 2,80GHz Xeon, 6x 10K rpm disks in a RAID-5, Linux 2.4.23 +with HT enabled. + +Regards, + Marinos + + +From pgsql-performance-owner@postgresql.org Thu Dec 18 16:31:22 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C89D7D1B4C8 + for ; + Thu, 18 Dec 2003 20:31:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 77069-06 + for ; + Thu, 18 Dec 2003 16:30:33 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id EEDF2D1B53E + for ; + Thu, 18 Dec 2003 16:30:31 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hBIKUVU6044642 + for ; Thu, 18 Dec 2003 20:30:31 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hBIKA0IS019960 + for pgsql-performance@postgresql.org; Thu, 18 Dec 2003 20:10:00 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: why do optimizer parameters have to be set manually? +Date: Thu, 18 Dec 2003 14:17:43 -0500 +Organization: Hub.Org Networking Services +Lines: 23 +Message-ID: <60n09q9bqg.fsf@dev6.int.libertyrms.info> +References: <3FE1F5A1.6080908@geizhals.at> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +User-Agent: Gnus/5.1003 (Gnus v5.10.3) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:986zF5HVCKX8G4/7FrcwSG24Oek= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/266 +X-Sequence-Number: 5126 + +mjy@geizhals.at ("Marinos J. Yannikos") writes: +> it seems to me that the optimizer parameters (like random_page_cost +> etc.) could easily be calculated and adjusted dynamically be the DB +> backend based on the planner's cost estimates and actual run times for +> different queries. Perhaps the developers could comment on that? + +Yes, it seems like a Small Matter Of Programming. + +http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?SMOP + +In seriousness, yes, it would seem a reasonable idea to calculate some +of these values a bit more dynamically. + +I would be inclined to start with something that ran a workload, and +provided static values based on how that workload went. That would +require NO intervention inside the DB server; it could be accomplished +simply by writing a database script. Feel free to contribute either a +script or a backend "hack"... +-- +let name="cbbrowne" and tld="libertyrms.info" in String.concat "@" [name;tld];; + +Christopher Browne +(416) 646 3304 x124 (land) + +From pgsql-performance-owner@postgresql.org Mon Dec 22 16:39:10 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 697E0D1B442 + for ; + Thu, 18 Dec 2003 19:42:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 68591-08 + for ; + Thu, 18 Dec 2003 15:41:20 -0400 (AST) +Received: from smtp4.hy.skanova.net (smtp4.hy.skanova.net [195.67.199.133]) + by svr1.postgresql.org (Postfix) with ESMTP id 62E3FD1B444 + for ; + Thu, 18 Dec 2003 15:41:02 -0400 (AST) +Received: from Foo (h224n2fls35o962.telia.com [217.211.189.224]) + by smtp4.hy.skanova.net (8.12.10/8.12.10) with SMTP id hBIJegr5012844 + for ; + Thu, 18 Dec 2003 20:40:42 +0100 (CET) +Message-ID: <004901c3c59f$365de160$6400a8c0@telia.com> +From: "Conny Thimren" +To: +Subject: general performance question +Date: Thu, 18 Dec 2003 20:43:29 +0100 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0046_01C3C5A7.97E6C700" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 5.50.4920.2300 +X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4920.2300 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=1.2 tagged_above=0.0 required=5.0 tests=HTML_10_20 +X-Spam-Level: * +X-Archive-Number: 200312/287 +X-Sequence-Number: 5147 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0046_01C3C5A7.97E6C700 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi,=20 +This a kind of newbie-question. I've been using Postgres for a long time in= + a low transction environment - and it is great.=20 + +Now I've got an inquiry for using Postgresql in a heavy-load on-line system= +. This system must handle something like 20 questions per sec with a respon= +se time at 1/10 sec. Each question will result in approx 5-6 reads and a co= +uple of updates.=20 +Anybody have a feeling if this is realistic on a Intelbased Linux server wi= +th Postgresql. Ofcourse I know that this is too little info for an exact an= +swer but - as I said - maybe someone can give a hint if it's possible. Mayb= +e someone with heavy-load can give an example of what is possible...=20 + +Regards=20 +Conny Thimr=E9n=20 + + +------=_NextPart_000_0046_01C3C5A7.97E6C700 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
Hi= +,
This a=20 +kind of newbie-question. I've been using Postgres for a long time in a low= +=20 +transction environment - and it is great.

Now I've got an inquiry f= +or=20 +using Postgresql in a heavy-load on-line system. This system must handle=20 +something like 20 questions per sec with a response time at 1/10 sec. Each= +=20 +question will result in approx 5-6 reads and a couple of updates.
Anybo= +dy=20 +have a feeling if this is realistic on a Intelbased Linux server with=20 +Postgresql. Ofcourse I know that this is too little info for an exact answe= +r but=20 +- as I said - maybe someone can give a hint if it's possible. Maybe someone= + with=20 +heavy-load can give an example of what is possible...

Regards
C= +onny=20 +Thimr=E9n


+ +------=_NextPart_000_0046_01C3C5A7.97E6C700-- + + +From pgsql-performance-owner@postgresql.org Thu Dec 18 15:57:44 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 28CFDD1B437 + for ; + Thu, 18 Dec 2003 19:57:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73381-03 + for ; + Thu, 18 Dec 2003 15:56:55 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 111F3D1B48D + for ; + Thu, 18 Dec 2003 15:56:37 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBIJuL19022687; + Thu, 18 Dec 2003 14:56:21 -0500 (EST) +To: "Marinos J. Yannikos" +Cc: pgsql-performance@postgresql.org +Subject: Re: why do optimizer parameters have to be set manually? +In-reply-to: <3FE1F5A1.6080908@geizhals.at> +References: <3FE1F5A1.6080908@geizhals.at> +Comments: In-reply-to "Marinos J. Yannikos" + message dated "Thu, 18 Dec 2003 19:44:49 +0100" +Date: Thu, 18 Dec 2003 14:56:20 -0500 +Message-ID: <22686.1071777380@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/265 +X-Sequence-Number: 5125 + +"Marinos J. Yannikos" writes: +> it seems to me that the optimizer parameters (like random_page_cost +> etc.) could easily be calculated and adjusted dynamically be the DB +> backend based on the planner's cost estimates and actual run times for +> different queries. Perhaps the developers could comment on that? + +No, they are not that easy to determine. In particular I think the idea +of automatically feeding back error measurements is hopeless, because +you cannot tell which parameters are wrong. + +> I'm not sure how the parameters are used internally (apart from whatever +> "EXPLAIN" shows), but if cpu_operator_cost is the same for all +> operators, this should probably also be adjusted for individual +> operators (I suppose that ">" is not as costly as "~*"). + +In theory perhaps, but in practice this is far down in the noise in most +situations. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Dec 18 19:19:58 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A20DAD1B43E + for ; + Thu, 18 Dec 2003 23:19:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 01372-09 + for ; + Thu, 18 Dec 2003 19:19:10 -0400 (AST) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id F3D73D1B459 + for ; + Thu, 18 Dec 2003 19:19:06 -0400 (AST) +Received: (qmail 13026 invoked from network); 18 Dec 2003 23:18:49 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 18 Dec 2003 23:18:49 -0000 +Subject: is it possible to get the optimizer to use indexes with a like clause +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: pgsql-performance@postgresql.org +In-Reply-To: <60n09q9bqg.fsf@dev6.int.libertyrms.info> +References: <3FE1F5A1.6080908@geizhals.at> + <60n09q9bqg.fsf@dev6.int.libertyrms.info> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1071789528.1629.10.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 18 Dec 2003 18:18:48 -0500 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/267 +X-Sequence-Number: 5127 + +It appears that the optimizer only uses indexes for = clause? + +Dave + + +From pgsql-performance-owner@postgresql.org Mon Dec 22 16:39:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 626E7D1B8B6 + for ; + Fri, 19 Dec 2003 01:41:20 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14803-03 + for ; + Thu, 18 Dec 2003 21:40:33 -0400 (AST) +Received: from main.gmane.org (main.gmane.org [80.91.224.249]) + by svr1.postgresql.org (Postfix) with ESMTP id 24876D1B439 + for ; + Thu, 18 Dec 2003 21:40:29 -0400 (AST) +Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1AX9cl-0005Rv-00 + for ; Fri, 19 Dec 2003 02:40:15 +0100 +X-Injected-Via-Gmane: http://gmane.org/ +To: pgsql-performance@postgresql.org +Received: from sea.gmane.org ([80.91.224.252]) + by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) + id 1AX9an-0005QT-00 + for ; + Fri, 19 Dec 2003 02:38:13 +0100 +Received: from news by sea.gmane.org with local (Exim 3.35 #1 (Debian)) + id 1AX9an-0001T2-00 + for ; + Fri, 19 Dec 2003 02:38:13 +0100 +From: Doug McNaught +Subject: Re: is it possible to get the optimizer to use indexes +Date: Thu, 18 Dec 2003 20:38:13 -0500 +Lines: 12 +Message-ID: <87d6alsi2i.fsf@asmodeus.mcnaught.org> +References: <3FE1F5A1.6080908@geizhals.at> + <60n09q9bqg.fsf@dev6.int.libertyrms.info> + <1071789528.1629.10.camel@localhost.localdomain> + <3FE256AA.8000707@familyhealth.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@sea.gmane.org +User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (gnu/linux) +Cancel-Lock: sha1:3UKEZsz1UOTkQlhldXduaTM4I+o= +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/286 +X-Sequence-Number: 5146 + +Christopher Kings-Lynne writes: + +>> It appears that the optimizer only uses indexes for = clause? +> +> The optimizer will used indexes for LIKE clauses, so long as the +> clause is a prefix search, eg: +> +> SELECT * FROM test WHERE a LIKE 'prf%'; + +Doesn't this still depend on your locale? + +-Doug + + +From pgsql-performance-owner@postgresql.org Thu Dec 18 21:34:56 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C474D1B439 + for ; + Fri, 19 Dec 2003 01:34:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15855-03 + for ; + Thu, 18 Dec 2003 21:34:08 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id B3995D1B48E + for ; + Thu, 18 Dec 2003 21:34:03 -0400 (AST) +Received: from familyhealth.com.au (work-40.internal [192.168.0.40]) + by houston.familyhealth.com.au (8.12.9p1/8.12.9) with ESMTP id + hBJ1XkoD062763; Fri, 19 Dec 2003 09:33:46 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <3FE256AA.8000707@familyhealth.com.au> +Date: Fri, 19 Dec 2003 09:38:50 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pg@fastcrypt.com +Cc: pgsql-performance@postgresql.org +Subject: Re: is it possible to get the optimizer to use indexes +References: <3FE1F5A1.6080908@geizhals.at> + <60n09q9bqg.fsf@dev6.int.libertyrms.info> + <1071789528.1629.10.camel@localhost.localdomain> +In-Reply-To: <1071789528.1629.10.camel@localhost.localdomain> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/268 +X-Sequence-Number: 5128 + +> It appears that the optimizer only uses indexes for = clause? + +The optimizer will used indexes for LIKE clauses, so long as the clause +is a prefix search, eg: + +SELECT * FROM test WHERE a LIKE 'prf%'; + +Chris + + +From pgsql-performance-owner@postgresql.org Thu Dec 18 23:09:31 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DA271D1B478 + for ; + Fri, 19 Dec 2003 03:09:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21276-05 + for ; + Thu, 18 Dec 2003 23:08:43 -0400 (AST) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 2785DD1B47D + for ; + Thu, 18 Dec 2003 23:08:39 -0400 (AST) +Received: (qmail 32257 invoked from network); 19 Dec 2003 03:08:37 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 19 Dec 2003 03:08:37 -0000 +Subject: Re: is it possible to get the optimizer to use indexes +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Christopher Kings-Lynne +Cc: pgsql-performance@postgresql.org +In-Reply-To: <3FE256AA.8000707@familyhealth.com.au> +References: <3FE1F5A1.6080908@geizhals.at> + <60n09q9bqg.fsf@dev6.int.libertyrms.info> + <1071789528.1629.10.camel@localhost.localdomain> + <3FE256AA.8000707@familyhealth.com.au> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1071803317.1629.16.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 18 Dec 2003 22:08:37 -0500 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/269 +X-Sequence-Number: 5129 + +after vacuum verbose analyze, I still get + +explain select * from isppm where item_upc_cd like '06038301234'; + QUERY PLAN +----------------------------------------------------------------------- + Seq Scan on isppm (cost=100000000.00..100009684.89 rows=2 width=791) + Filter: (item_upc_cd ~~ '06038301234'::text) +(2 rows) + +isp=# explain select * from isppm where item_upc_cd = '06038301234'; + QUERY PLAN +------------------------------------------------------------------------ + Index Scan using isppm_x0 on isppm (cost=0.00..5.86 rows=2 width=791) + Index Cond: (item_upc_cd = '06038301234'::bpchar) +(2 rows) + + +Dave +On Thu, 2003-12-18 at 20:38, Christopher Kings-Lynne wrote: +> > It appears that the optimizer only uses indexes for = clause? +> +> The optimizer will used indexes for LIKE clauses, so long as the clause +> is a prefix search, eg: +> +> SELECT * FROM test WHERE a LIKE 'prf%'; +> +> Chris +> +> + + +From pgsql-performance-owner@postgresql.org Thu Dec 18 23:31:25 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 88CD3D1B4B7 + for ; + Fri, 19 Dec 2003 03:31:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 20768-06 + for ; + Thu, 18 Dec 2003 23:30:36 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B31AD1B45A + for ; + Thu, 18 Dec 2003 23:30:32 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hBJ3UVU6081650 + for ; Fri, 19 Dec 2003 03:30:32 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hBJ3SVB1078996 + for pgsql-performance@postgresql.org; Fri, 19 Dec 2003 03:28:31 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: is it possible to get the optimizer to use indexes with a like + clause +Date: Thu, 18 Dec 2003 22:22:38 -0500 +Organization: cbbrowne Computing Inc +Lines: 21 +Message-ID: +References: <3FE1F5A1.6080908@geizhals.at> + <60n09q9bqg.fsf@dev6.int.libertyrms.info> + <1071789528.1629.10.camel@localhost.localdomain> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + linux) +Cancel-Lock: sha1:Q3cISRgx/BUPdg4/ElO3oOiwRiA= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/270 +X-Sequence-Number: 5130 + +pg@fastcrypt.com (Dave Cramer) wrote: +> It appears that the optimizer only uses indexes for = clause? + +It can use indices only if there is a given prefix. + +Thus: + where text_field like 'A%' + +can use the index, essentially transforming this into the clauses + + where text_field >= 'A' and + text_field < 'B'. + +You can't get much out of an index for + where text_field like '%SOMETHING' +-- +(reverse (concatenate 'string "moc.enworbbc" "@" "enworbbc")) +http://www3.sympatico.ca/cbbrowne/wp.html +"When the grammar checker identifies an error, it suggests a +correction and can even makes some changes for you." +-- Microsoft Word for Windows 2.0 User's Guide, p.35: + +From pgsql-performance-owner@postgresql.org Thu Dec 18 23:37:04 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B053D1B45C + for ; + Fri, 19 Dec 2003 03:37:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 19710-08 + for ; + Thu, 18 Dec 2003 23:36:17 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 328A7D1B441 + for ; + Thu, 18 Dec 2003 23:36:13 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 5D686355CF; Thu, 18 Dec 2003 19:36:02 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 5BEFB3556C; Thu, 18 Dec 2003 19:36:02 -0800 (PST) +Date: Thu, 18 Dec 2003 19:36:02 -0800 (PST) +From: Stephan Szabo +To: Dave Cramer +Cc: Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: is it possible to get the optimizer to use indexes +In-Reply-To: <1071803317.1629.16.camel@localhost.localdomain> +Message-ID: <20031218193514.Q20465@megazone.bigpanda.com> +References: <3FE1F5A1.6080908@geizhals.at> + <60n09q9bqg.fsf@dev6.int.libertyrms.info> + <1071789528.1629.10.camel@localhost.localdomain> + <3FE256AA.8000707@familyhealth.com.au> + <1071803317.1629.16.camel@localhost.localdomain> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/271 +X-Sequence-Number: 5131 + + +On Thu, 18 Dec 2003, Dave Cramer wrote: + +> after vacuum verbose analyze, I still get +> +> explain select * from isppm where item_upc_cd like '06038301234'; +> QUERY PLAN +> ----------------------------------------------------------------------- +> Seq Scan on isppm (cost=100000000.00..100009684.89 rows=2 width=791) +> Filter: (item_upc_cd ~~ '06038301234'::text) +> (2 rows) + +IIRC, the other limitation is that it only does so in "C" locale due to +wierdnesses in other locales. + +From pgsql-performance-owner@postgresql.org Thu Dec 18 23:44:54 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 48C79D1B46E + for ; + Fri, 19 Dec 2003 03:44:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 29658-03 + for ; + Thu, 18 Dec 2003 23:44:05 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id E2BEFD1B45A + for ; + Thu, 18 Dec 2003 23:44:00 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBJ3i019006122; + Thu, 18 Dec 2003 22:44:00 -0500 (EST) +To: pg@fastcrypt.com +Cc: Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: is it possible to get the optimizer to use indexes +In-reply-to: <1071803317.1629.16.camel@localhost.localdomain> +References: <3FE1F5A1.6080908@geizhals.at> + <60n09q9bqg.fsf@dev6.int.libertyrms.info> + <1071789528.1629.10.camel@localhost.localdomain> + <3FE256AA.8000707@familyhealth.com.au> + <1071803317.1629.16.camel@localhost.localdomain> +Comments: In-reply-to Dave Cramer + message dated "18 Dec 2003 22:08:37 -0500" +Date: Thu, 18 Dec 2003 22:44:00 -0500 +Message-ID: <6121.1071805440@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/272 +X-Sequence-Number: 5132 + +Dave Cramer writes: +> after vacuum verbose analyze, I still get [a seqscan] + +The other gating factor is that you have to have initdb'd in C locale. +Non-C locales tend to use wild and wooly sort orders that are not +compatible with what LIKE needs. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Dec 19 05:51:10 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A491AD1B486 + for ; + Fri, 19 Dec 2003 09:51:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 71215-09 + for ; + Fri, 19 Dec 2003 05:50:20 -0400 (AST) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id A76B5D1B48F + for ; + Fri, 19 Dec 2003 05:50:17 -0400 (AST) +Received: (qmail 7249 invoked from network); 19 Dec 2003 09:50: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 Dec 2003 09:50:13 -0000 +Subject: Re: is it possible to get the optimizer to use indexes +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Tom Lane +Cc: Christopher Kings-Lynne , + pgsql-performance@postgresql.org +In-Reply-To: <6121.1071805440@sss.pgh.pa.us> +References: <3FE1F5A1.6080908@geizhals.at> + <60n09q9bqg.fsf@dev6.int.libertyrms.info> + <1071789528.1629.10.camel@localhost.localdomain> + <3FE256AA.8000707@familyhealth.com.au> + <1071803317.1629.16.camel@localhost.localdomain> + <6121.1071805440@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1071827412.1627.25.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 19 Dec 2003 04:50:12 -0500 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/273 +X-Sequence-Number: 5133 + +So even in a north-american locale, such as en_CA this will be a +problem? + +Dave +On Thu, 2003-12-18 at 22:44, Tom Lane wrote: +> Dave Cramer writes: +> > after vacuum verbose analyze, I still get [a seqscan] +> +> The other gating factor is that you have to have initdb'd in C locale. +> Non-C locales tend to use wild and wooly sort orders that are not +> compatible with what LIKE needs. +> +> regards, tom lane +> +> + + +From pgsql-performance-owner@postgresql.org Fri Dec 19 09:52:59 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 28034D1B449 + for ; + Fri, 19 Dec 2003 13:52:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 03274-04 + for ; + Fri, 19 Dec 2003 09:52:12 -0400 (AST) +Received: from morework.geizhals.at (home.geizhals.at [213.229.14.34]) + by svr1.postgresql.org (Postfix) with ESMTP id 88178D1B43A + for ; + Fri, 19 Dec 2003 09:52:08 -0400 (AST) +Received: from localhost (morework [127.0.0.1]) + by morework.geizhals.at (Postfix) with ESMTP + id 4A808524177; Fri, 19 Dec 2003 14:51:58 +0100 (CET) +Received: from geizhals.at (chello080110242194.117.11.tuwien.teleweb.at + [80.110.242.194]) by morework.geizhals.at (Postfix) with ESMTP + id 0046C52416C; Fri, 19 Dec 2003 14:51:57 +0100 (CET) +Message-ID: <3FE302D2.7080901@geizhals.at> +Date: Fri, 19 Dec 2003 14:53:22 +0100 +From: "Marinos J. Yannikos" +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: why do optimizer parameters have to be set manually? +References: <3FE1F5A1.6080908@geizhals.at> <22686.1071777380@sss.pgh.pa.us> +In-Reply-To: <22686.1071777380@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by AMaViS snapshot-20020222 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/274 +X-Sequence-Number: 5134 + +Tom Lane wrote: +> No, they are not that easy to determine. In particular I think the idea +> of automatically feeding back error measurements is hopeless, because +> you cannot tell which parameters are wrong. + +Isn't it just a matter of solving an equation system with n variables (n +being the number of parameters), where each equation stands for the +calculation of the run time of a particular query? I.e. something like +this for a sequential scan over 1000 rows with e.g. 2 operators used per +iteration that took 2 seconds (simplified so that the costs are actual +timings and not relative costs to a base value): + +1000 * sequential_scan_cost + 1000 * 2 * cpu_operator_cost = 2.0 seconds + +With a sufficient number of equations (not just n, since not all query +plans use all the parameters) this system can be solved for the +particular query mix that was used. E.g. with a second sequential scan +over 2000 rows with 1 operator per iteration that took 3 seconds you can +derive: + +sequential_scan_cost = 1ms +cpu_operator_cost = 0.5ms + +This could probably be implemented with very little overhead compared to +the actual run times of the queries. + +Regard, + Marinos + + + + +From pgsql-performance-owner@postgresql.org Fri Dec 19 10:39:30 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A463BD1B44B + for ; + Fri, 19 Dec 2003 14:39:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 15134-01 + for ; + Fri, 19 Dec 2003 10:38:38 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E037D1B43A + for ; + Fri, 19 Dec 2003 10:38:29 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBJEcE19009225; + Fri, 19 Dec 2003 09:38:15 -0500 (EST) +To: pg@fastcrypt.com +Cc: Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: is it possible to get the optimizer to use indexes +In-reply-to: <1071827412.1627.25.camel@localhost.localdomain> +References: <3FE1F5A1.6080908@geizhals.at> + <60n09q9bqg.fsf@dev6.int.libertyrms.info> + <1071789528.1629.10.camel@localhost.localdomain> + <3FE256AA.8000707@familyhealth.com.au> + <1071803317.1629.16.camel@localhost.localdomain> + <6121.1071805440@sss.pgh.pa.us> + <1071827412.1627.25.camel@localhost.localdomain> +Comments: In-reply-to Dave Cramer + message dated "19 Dec 2003 04:50:12 -0500" +Date: Fri, 19 Dec 2003 09:38:14 -0500 +Message-ID: <9224.1071844694@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/275 +X-Sequence-Number: 5135 + +Dave Cramer writes: +> So even in a north-american locale, such as en_CA this will be a +> problem? + +If it's not "C" we won't try to optimize LIKE. I know en_US does not +work (case-insensitive, funny rules about spaces, etc) and I would +expect en_CA has the same issues. + +If you're using 7.4 you have the option to create a special index +instead of re-initdb'ing your whole database. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Dec 19 11:08:06 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 313E7D1B43A + for ; + Fri, 19 Dec 2003 15:08:05 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 16914-07 + for ; + Fri, 19 Dec 2003 11:07:19 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 76D21D1B42F + for ; + Fri, 19 Dec 2003 11:07:13 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBJF7F19009383; + Fri, 19 Dec 2003 10:07:15 -0500 (EST) +To: "Marinos J. Yannikos" +Cc: pgsql-performance@postgresql.org +Subject: Re: why do optimizer parameters have to be set manually? +In-reply-to: <3FE302D2.7080901@geizhals.at> +References: <3FE1F5A1.6080908@geizhals.at> <22686.1071777380@sss.pgh.pa.us> + <3FE302D2.7080901@geizhals.at> +Comments: In-reply-to "Marinos J. Yannikos" + message dated "Fri, 19 Dec 2003 14:53:22 +0100" +Date: Fri, 19 Dec 2003 10:07:15 -0500 +Message-ID: <9382.1071846435@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/276 +X-Sequence-Number: 5136 + +"Marinos J. Yannikos" writes: +> Tom Lane wrote: +>> No, they are not that easy to determine. In particular I think the idea +>> of automatically feeding back error measurements is hopeless, because +>> you cannot tell which parameters are wrong. + +> Isn't it just a matter of solving an equation system with n variables (n +> being the number of parameters), where each equation stands for the +> calculation of the run time of a particular query? + +If we knew all the variables involved, it might be (though since the +equations would be nonlinear, the solution would be more difficult than +you suppose). The real problems are: + +1. There is lots of noise in any real-world measurement, mostly due to +competition from other processes. + +2. There are effects we don't even try to model, such as the current +contents of kernel cache. Everybody who's done any work with Postgres +knows that for small-to-middling tables, running the same query twice in +a row will yield considerably different runtimes, because the second +time through all the data will be in kernel cache. But we don't have +any useful way to model that in the optimizer, since we can't see what +the kernel has in its buffers. + +3. Even for the effects we do try to model, some of the equations are +pretty ad-hoc and might not fit real data very well. (I have little +confidence in the current correction for index order correlation, for +example.) + +In short, if you just try to fit the present cost equations to real +data, what you'll get will inevitably be "garbage in, garbage out". +You could easily end up with parameter values that are much less +realistic than the defaults. + +Over time we'll doubtless improve the optimizer's cost models, and +someday we might get to a point where this wouldn't be a fool's errand, +but I don't see it happening in the foreseeable future. + +I think a more profitable approach is to set up special test code to try +to approximate the value of individual parameters measured in isolation. +For instance, the current default of 4.0 for random_page_cost was +developed through rather extensive testing a few years ago, and I think +it's still a decent average value (for the case where you are actually +doing I/O, mind you). But if your disks have particularly fast or slow +seek times, maybe it's not good for you. It might be useful to package +up a test program that repeats those measurements on particular systems +--- though the problem of noisy measurements still applies. It is not +easy or cheap to get a measurement that isn't skewed by kernel caching +behavior. (You need a test file significantly larger than RAM, and +even then you'd better repeat the measurement quite a few times to see +how much noise there is in it.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Dec 19 12:01:35 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 515FED1B48D + for ; + Fri, 19 Dec 2003 16:01:33 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 25138-10 + for ; + Fri, 19 Dec 2003 12:00:44 -0400 (AST) +Received: from webware.ee (webware.ee [212.7.7.3]) + by svr1.postgresql.org (Postfix) with ESMTP id 3AC97D1B471 + for ; + Fri, 19 Dec 2003 12:00:30 -0400 (AST) +Received: from webware.ee (pc234.host4.starman.ee [62.65.196.234]) + by webware.ee (Postfix) with ESMTP + id D7DF1378100; Fri, 19 Dec 2003 18:01:34 +0200 (EET) +Message-ID: <3FE32099.40901@webware.ee> +Date: Fri, 19 Dec 2003 18:00:25 +0200 +From: =?ISO-8859-1?Q?Erki_Kaldj=E4rv?= +Organization: Webware =?ISO-8859-1?Q?O=DC?= +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; + rv:1.0.1) Gecko/20020823 Netscape/7.0 +X-Accept-Language: et,en +MIME-Version: 1.0 +To: Tom Lane +Cc: pg@fastcrypt.com, Christopher Kings-Lynne , + pgsql-performance@postgresql.org +Subject: Re: is it possible to get the optimizer to use indexes +References: <3FE1F5A1.6080908@geizhals.at> + <60n09q9bqg.fsf@dev6.int.libertyrms.info> + <1071789528.1629.10.camel@localhost.localdomain> + <3FE256AA.8000707@familyhealth.com.au> + <1071803317.1629.16.camel@localhost.localdomain> + <6121.1071805440@sss.pgh.pa.us> + <1071827412.1627.25.camel@localhost.localdomain> + <9224.1071844694@sss.pgh.pa.us> +Content-Type: multipart/alternative; + boundary="------------040301000406030407010001" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/277 +X-Sequence-Number: 5137 + +--------------040301000406030407010001 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit + +Hello, + +i got indexes to work with "text_pattern_ops" for locale et_EE. + +So instead of: +create index some_index_name on some_table(some_text_field); + +nor + +create index some_index_name on some_table(some_text_field text_ops); + +try to create index as follows: +create index some_index_name on some_table(some_text_field +text_pattern_ops); + +Note that text_pattern_ops is available pg >= 7.4. + +Regards, + +Erki Kaldj�rv +Webware O� +www.webware.ee + +Tom Lane wrote: + +>Dave Cramer writes: +> +> +>>So even in a north-american locale, such as en_CA this will be a +>>problem? +>> +>> +> +>If it's not "C" we won't try to optimize LIKE. I know en_US does not +>work (case-insensitive, funny rules about spaces, etc) and I would +>expect en_CA has the same issues. +> +>If you're using 7.4 you have the option to create a special index +>instead of re-initdb'ing your whole database. +> +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 4: Don't 'kill -9' the postmaster +> +> + + +--------------040301000406030407010001 +Content-Type: text/html; charset=us-ascii +Content-Transfer-Encoding: 7bit + + + + + + + + +Hello,
+
+i got indexes to work with "text_pattern_ops" for locale et_EE.
+
+So instead of:
+create index some_index_name on some_table(some_text_field);
+
+nor
+
+create index some_index_name on some_table(some_text_field text_ops);
+
+try to create index as follows:
+create index some_index_name on some_table(some_text_field text_pattern_ops);
+
+Note that text_pattern_ops is available pg >= 7.4.
+
+Regards,
+
+Erki Kaldjärv
+Webware OÜ
+www.webware.ee
+
+Tom Lane wrote:
+
+
Dave Cramer <pg@fastcrypt.com> writes:
+  
+
+
So even in a north-american locale, such as en_CA this will be a
+problem?
+    
+
+

+If it's not "C" we won't try to optimize LIKE.  I know en_US does not
+work (case-insensitive, funny rules about spaces, etc) and I would
+expect en_CA has the same issues.
+
+If you're using 7.4 you have the option to create a special index
+instead of re-initdb'ing your whole database.
+
+			regards, tom lane
+
+---------------------------(end of broadcast)---------------------------
+TIP 4: Don't 'kill -9' the postmaster
+  
+
+
+ + + +--------------040301000406030407010001-- + + + +From pgsql-performance-owner@postgresql.org Fri Dec 19 14:06:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 32D1AD1BA6E + for ; + Fri, 19 Dec 2003 18:05:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 46488-05 + for ; + Fri, 19 Dec 2003 14:04:57 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 3F6D8D1B8EA + for ; + Fri, 19 Dec 2003 14:00:45 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id hBJI0cU6001986 + for ; Fri, 19 Dec 2003 18:00:38 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id hBJHiDIq063765 + for pgsql-performance@postgresql.org; Fri, 19 Dec 2003 17:44:13 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: why do optimizer parameters have to be set manually? +Date: Fri, 19 Dec 2003 09:44:17 -0800 +Organization: Hub.Org Networking Services +Lines: 10 +Message-ID: +References: <3FE1F5A1.6080908@geizhals.at> <22686.1071777380@sss.pgh.pa.us> + <3FE302D2.7080901@geizhals.at> <9382.1071846435@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +In-Reply-To: <9382.1071846435@sss.pgh.pa.us> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/278 +X-Sequence-Number: 5138 + +Tom Lane wrote: +> easy or cheap to get a measurement that isn't skewed by kernel caching +> behavior. (You need a test file significantly larger than RAM, and +> even then you'd better repeat the measurement quite a few times to see +> how much noise there is in it.) + +I found a really fast way in Linux to flush the kernel cache and that is +to unmount the drive and then remount. Beats having to read though a +file > RAM everytime. + + +From pgsql-performance-owner@postgresql.org Mon Dec 22 06:52:49 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 585D9D1B4AE + for ; + Mon, 22 Dec 2003 10:52:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97397-01 + for ; + Mon, 22 Dec 2003 06:52:00 -0400 (AST) +Received: from nitrogen.id.pl (nitrogen.id.pl [193.178.214.5]) + by svr1.postgresql.org (Postfix) with SMTP id D039AD1B518 + for ; + Mon, 22 Dec 2003 06:51:26 -0400 (AST) +Received: (qmail 5148 invoked by uid 0); 22 Dec 2003 10:51:13 -0000 +Received: from unknown (HELO siaco.id.pl) (213.25.114.8) + by smtp.id.pl with SMTP; 22 Dec 2003 10:51:12 -0000 +Received: (qmail 24417 invoked by uid 1000); 22 Dec 2003 10:51:08 -0000 +Resent-From: Ryszard Lach +Resent-Date: Mon, 22 Dec 2003 11:51:08 +0100 +Resent-Message-ID: <20031222105108.GB23673@siaco.id.pl> +Resent-To: pgsql-performance@postgresql.org +Date: Mon, 22 Dec 2003 11:39:18 +0100 +From: Ryszard Lach +To: pgsql-performance@postgresql.org +Subject: "select max/count(id)" not using index +Message-ID: <20031222103918.GA23673@siaco.id.pl> +Reply-To: Ryszard Lach +Mime-Version: 1.0 +Content-Type: text/plain; charset=iso-8859-2 +Content-Disposition: inline +X-My-GPG-Key: echo | mail -s "send key pub" ryszard@lach.name +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/279 +X-Sequence-Number: 5139 + +Hi. + +I have a table with 24k records and btree index on column 'id'. Is this +normal, that 'select max(id)' or 'select count(id)' causes a sequential +scan? It takes over 24 seconds (on a pretty fast machine): + +=> explain ANALYZE select max(id) from ogloszenia; + QUERY PLAN +---------------------------------------------------------------------- + Aggregate (cost=3511.05..3511.05 rows=1 width=4) (actual +time=24834.629..24834.629 rows=1 loops=1) + -> Seq Scan on ogloszenia (cost=0.00..3473.04 rows=15204 width=4) +(actual time=0.013..24808.377 rows=16873 loops=1) + Total runtime: 24897.897 ms + +Maybe it's caused by a number of varchar fields in this table? However, +'id' column is 'integer' and is primary key. + +Clustering table on index created on 'id' makes such a queries +many faster, but they still use a sequential scan. + +Richard. + +-- +"First they ignore you. Then they laugh at you. Then they +fight you. Then you win." - Mohandas Gandhi. + +From pgsql-performance-owner@postgresql.org Mon Dec 22 06:57:46 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ECA32D1B456 + for ; + Mon, 22 Dec 2003 10:57:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 92280-08 + for ; + Mon, 22 Dec 2003 06:56:58 -0400 (AST) +Received: from relay01.kbs.net.au (relay01.kbs.net.au [203.220.32.149]) + by svr1.postgresql.org (Postfix) with ESMTP id 43F2AD1B496 + for ; + Mon, 22 Dec 2003 06:56:55 -0400 (AST) +Received: from [203.221.246.88] (helo=familyhealth.com.au) + by relay01.kbs.net.au with esmtp (Exim 3.36 #2) + id 1AYNk6-0005RM-00; Mon, 22 Dec 2003 21:56:55 +1100 +Message-ID: <3FE6CDF2.10608@familyhealth.com.au> +Date: Mon, 22 Dec 2003 18:56:50 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.6b) Gecko/20031205 Thunderbird/0.4 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Ryszard Lach +Cc: pgsql-performance@postgresql.org +Subject: Re: "select max/count(id)" not using index +References: <20031222103918.GA23673@siaco.id.pl> +In-Reply-To: <20031222103918.GA23673@siaco.id.pl> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/280 +X-Sequence-Number: 5140 + + +> I have a table with 24k records and btree index on column 'id'. Is this +> normal, that 'select max(id)' or 'select count(id)' causes a sequential +> scan? It takes over 24 seconds (on a pretty fast machine): +> +> => explain ANALYZE select max(id) from ogloszenia; + +Yes, it is. It is a known issue with Postgres's extensible operator +architecture. + +The work around is to have an index on the id column and do this instead: + +SELECT id FROM ogloszenia ORDER BY id DESC LIMIT 1; + +Which will be really fast. + +Chris + + +From pgsql-performance-owner@postgresql.org Mon Dec 22 11:29:48 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CF1A7D1B42F + for ; + Mon, 22 Dec 2003 15:29:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28934-10 + for ; + Mon, 22 Dec 2003 11:29:00 -0400 (AST) +Received: from mailout04.sul.t-online.com (mailout04.sul.t-online.com + [194.25.134.18]) + by svr1.postgresql.org (Postfix) with ESMTP id E61CED1B44D + for ; + Mon, 22 Dec 2003 11:28:31 -0400 (AST) +Received: from fwd04.aul.t-online.de by mailout04.sul.t-online.com with smtp + id 1AYNn6-0004cf-03; Mon, 22 Dec 2003 12:00:00 +0100 +Received: from router.azrael.de + (XHtrgcZ1Qe5BoippkwgC4OGlA9YmT16ZUYhl4QH2-TxgYlIvjV4u4O@[80.141.232.167]) + by fmrl04.sul.t-online.com + with esmtp id 1AYNmu-1y12US0; Mon, 22 Dec 2003 11:59:48 +0100 +Received: from azrael.azrael.de (azrael.azrael.de [192.168.202.18]) + by router.azrael.de (8.11.4/8.11.4) with ESMTP id hBMAxkt15644; + Mon, 22 Dec 2003 11:59:47 +0100 +Date: Mon, 22 Dec 2003 11:59:58 +0100 +From: Evil Azrael +X-Priority: 3 (Normal) +Message-ID: <110164283326.20031222115958@evilazrael.de> +To: Ryszard Lach +Cc: pgsql-performance@postgresql.org +Subject: Re: "select max/count(id)" not using index +In-Reply-To: <20031222103918.GA23673@siaco.id.pl> +References: <20031222103918.GA23673@siaco.id.pl> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-2 +Content-Transfer-Encoding: 8bit +X-Seen: false +X-ID: XHtrgcZ1Qe5BoippkwgC4OGlA9YmT16ZUYhl4QH2-TxgYlIvjV4u4O@t-dialin.net +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/283 +X-Sequence-Number: 5143 + +Guten Tag Ryszard Lach, + +Am Montag, 22. Dezember 2003 um 11:39 schrieben Sie: + +RL> Hi. + +RL> I have a table with 24k records and btree index on column 'id'. Is this +RL> normal, that 'select max(id)' or 'select count(id)' causes a sequential +RL> scan? It takes over 24 seconds (on a pretty fast machine): + +Yes, that was occasionally discussed on the mailinglists. For the +max(id) you can use instead "SELECT id FROM table ORDER BY id DESC +LIMIT 1" + + +Christoph Nelles + + +=>> explain ANALYZE select max(id) from ogloszenia; +RL> QUERY PLAN +RL> ---------------------------------------------------------------------- +RL> Aggregate (cost=3511.05..3511.05 rows=1 width=4) (actual +RL> time=24834.629..24834.629 rows=1 loops=1) +RL> -> Seq Scan on ogloszenia (cost=0.00..3473.04 rows=15204 width=4) +RL> (actual time=0.013..24808.377 rows=16873 loops=1) +RL> Total runtime: 24897.897 ms + +RL> Maybe it's caused by a number of varchar fields in this table? However, +RL> 'id' column is 'integer' and is primary key. + +RL> Clustering table on index created on 'id' makes such a queries +RL> many faster, but they still use a sequential scan. + +RL> Richard. + + + + +-- +Mit freundlichen Gr�ssen +Evil Azrael mailto:evilazrael@evilazrael.de + + +From pgsql-performance-owner@postgresql.org Mon Dec 22 07:03:58 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 31E56D1B4B7 + for ; + Mon, 22 Dec 2003 11:03:56 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97406-07 + for ; + Mon, 22 Dec 2003 07:03:08 -0400 (AST) +Received: from kix.fsv.cvut.cz (Kix.FSV.CVUT.CZ [147.32.129.84]) + by svr1.postgresql.org (Postfix) with ESMTP id B2A51D1B487 + for ; + Mon, 22 Dec 2003 07:03:04 -0400 (AST) +Received: from localhost (stehule@localhost) + by kix.fsv.cvut.cz (8.11.6/8.11.6) with ESMTP id hBMB35b27958; + Mon, 22 Dec 2003 12:03:05 +0100 +Date: Mon, 22 Dec 2003 12:03:05 +0100 (CET) +From: Pavel Stehule +To: Ryszard Lach +Cc: pgsql-performance@postgresql.org, Ryszard Lach +Subject: Re: "select max/count(id)" not using index +In-Reply-To: <20031222103918.GA23673@siaco.id.pl> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/281 +X-Sequence-Number: 5141 + +Hello + +It is normal behavior PostgreSQL. Use + +SELECT id FROM tabulka ORDER BY id DESC LIMIT 1; + +regards +Pavel + +On Mon, 22 Dec 2003, Ryszard Lach wrote: + +> Hi. +> +> I have a table with 24k records and btree index on column 'id'. Is this +> normal, that 'select max(id)' or 'select count(id)' causes a sequential +> scan? It takes over 24 seconds (on a pretty fast machine): +> +> => explain ANALYZE select max(id) from ogloszenia; +> QUERY PLAN +> ---------------------------------------------------------------------- +> Aggregate (cost=3511.05..3511.05 rows=1 width=4) (actual +> time=24834.629..24834.629 rows=1 loops=1) +> -> Seq Scan on ogloszenia (cost=0.00..3473.04 rows=15204 width=4) +> (actual time=0.013..24808.377 rows=16873 loops=1) +> Total runtime: 24897.897 ms +> +> Maybe it's caused by a number of varchar fields in this table? However, +> 'id' column is 'integer' and is primary key. +> +> Clustering table on index created on 'id' makes such a queries +> many faster, but they still use a sequential scan. +> +> Richard. +> +> + + +From pgsql-performance-owner@postgresql.org Mon Dec 22 07:04:57 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 21365D1B487 + for ; + Mon, 22 Dec 2003 11:04:55 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94268-09 + for ; + Mon, 22 Dec 2003 07:04:07 -0400 (AST) +Received: from serwer.skawsoft.com.pl (skawina.eu.org [80.48.213.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 236E4D1B4CF + for ; + Mon, 22 Dec 2003 07:04:04 -0400 (AST) +Received: from klaster.net (core-1.citynet.pl [80.48.135.69]) + by serwer.skawsoft.com.pl (Postfix) with ESMTP + id A53DF2B3CB; Mon, 22 Dec 2003 12:03:32 +0100 (CET) +Message-ID: <3FE6CF91.6070300@klaster.net> +Date: Mon, 22 Dec 2003 12:03:45 +0100 +From: Tomasz Myrta +User-Agent: Mozilla/5.0 (Windows; U; Win 9x 4.90; pl-PL; + rv:1.5) Gecko/20031007 +X-Accept-Language: pl, en-us, en +MIME-Version: 1.0 +To: Ryszard Lach +Cc: pgsql-performance@postgresql.org +Subject: Re: "select max/count(id)" not using index +References: <20031222103918.GA23673@siaco.id.pl> +In-Reply-To: <20031222103918.GA23673@siaco.id.pl> +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/282 +X-Sequence-Number: 5142 + +Dnia 2003-12-22 11:39, U�ytkownik Ryszard Lach napisa�: + +> Hi. +> +> I have a table with 24k records and btree index on column 'id'. Is this +> normal, that 'select max(id)' or 'select count(id)' causes a sequential +> scan? It takes over 24 seconds (on a pretty fast machine): +'select count(id)' +Yes, this is normal. Because of MVCC all rows must be checked and +Postgres doesn't cache count(*) like Mysql. + +'select max(id)' +This is also normal, but try to change this query into: +select id from some_table order by id desc limit 1; + +What is your Postgresql version? + +Regards, +Tomasz Myrta + + +From pgsql-performance-owner@postgresql.org Mon Dec 22 16:39:11 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4C441D1B44D + for ; + Mon, 22 Dec 2003 19:13:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69235-03 + for ; + Mon, 22 Dec 2003 15:12:13 -0400 (AST) +Received: from wren.rentec.com (unknown [65.213.84.9]) + by svr1.postgresql.org (Postfix) with ESMTP id 08706D1B4B1 + for ; + Mon, 22 Dec 2003 15:12:10 -0400 (AST) +Received: from rentec.com (IDENT:618@murre.rentec.com [172.26.132.91]) + by wren.rentec.com (8.12.1/8.12.1) with ESMTP id hBMJBt12012828 + for ; + Mon, 22 Dec 2003 14:11:55 -0500 (EST) +Message-ID: <3FE741FA.4000002@rentec.com> +Date: Mon, 22 Dec 2003 14:11:54 -0500 +From: Michael Guerin +User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.4) Gecko/20030703 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: postgresql performance on linux port +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/288 +X-Sequence-Number: 5148 + + I just restored a database running on a solaris box to a linux box +and queries take forever to execute. The linux box is faster and has +twice the memory allocated to postgresql, is there anything obvious that +I should look at? It is using a journal file system. + + + + +From pgsql-performance-owner@postgresql.org Mon Dec 22 16:47:24 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 05A7BD1B440 + for ; + Mon, 22 Dec 2003 20:47:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 83012-05 + for ; + Mon, 22 Dec 2003 16:46:33 -0400 (AST) +Received: from mail.hive.nj2.inquent.com (mc.carriermail.com [205.178.180.9]) + by svr1.postgresql.org (Postfix) with SMTP id AF045D1B518 + for ; + Mon, 22 Dec 2003 16:45:40 -0400 (AST) +Received: (qmail 9261 invoked from network); 22 Dec 2003 20:45:26 -0000 +Received: from unknown (HELO ?10.0.2.2?) (216.208.117.7) + by 205.178.180.9 with SMTP; 22 Dec 2003 20:45:26 -0000 +Subject: Re: general peformance question +From: Rod Taylor +To: conny.thimren@servit.se +Cc: Postgresql Performance +In-Reply-To: +References: +Content-Type: text/plain +Message-Id: <1072125923.17267.55.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Mon, 22 Dec 2003 15:45:24 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/289 +X-Sequence-Number: 5149 + +On Thu, 2003-12-18 at 12:04, Conny Thimren wrote: +> Hi, +> This a kind of newbie-question. I've been using Postgres for a long time in a low transction environment - and it is great. +> +> Now I've got an inquiry for using Postgresql in a heavy-load on-line system. This system must handle something like 20 questions per sec with a response time at 1/10 sec. Each question will result in approx 5-6 reads and a couple of updates. +> Anybody have a feeling if this is realistic on a Intelbased Linux server with Postgresql. Ofcourse I know that this is too little info for an exact answer but - as I said - maybe someone can give a hint if it's possible. Maybe someone with heavy-load can give an example of what is possible... + +Ok, is that 20 questions per second (20 in parallel taking 1 second +each) or serialized taking 50ms each. + +Are they simple selects / updates (less than 10 rows in result set, very +simple joins) or are they monster 30 table join queries? + + +From pgsql-performance-owner@postgresql.org Wed Dec 24 20:53:14 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A1333D1B44B + for ; + Mon, 22 Dec 2003 21:15:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 84583-06 + for ; + Mon, 22 Dec 2003 17:14:47 -0400 (AST) +Received: from ganymede.hub.org (u46n208.hfx.eastlink.ca [24.222.46.208]) + by svr1.postgresql.org (Postfix) with ESMTP id A26E0D1B4E0 + for ; + Mon, 22 Dec 2003 17:14:45 -0400 (AST) +Received: by ganymede.hub.org (Postfix, from userid 1000) + id 21E7638B92; Mon, 22 Dec 2003 17:11:25 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by ganymede.hub.org (Postfix) with ESMTP id 1835A386C7 + for ; + Mon, 22 Dec 2003 17:11:25 -0400 (AST) +Date: Mon, 22 Dec 2003 17:11:25 -0400 (AST) +From: "Marc G. Fournier" +To: pgsql-performance@postgresql.org +Subject: mnogosearch under 7.4 ... +Message-ID: <20031222165147.S916@ganymede.hub.org> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/293 +X-Sequence-Number: 5153 + + +G'day all ... + +Dave asked me today about 'slow downs' on the search engines, so am +looking at the various queries generated by enabling +log_statement/log_duration, to get a feel for is something is "off" ... +and the following seems a bit weird ... + +QueryA and QueryB are the same query, but against two different tables in +the databases ... QueryA takes ~4x longer to run then QueryB, but both +EXPLAINs look similar ... in fact, looking at the EXPLAIN ANALYZE output, +I would expect that QueryB would be the slower of the two ... but, the +actual vs estimated times for ndict5/ndict4 seem off (ndict4 is estimated +high, ndict5 is estimated low) ... + +QueryA: + +186_archives=# explain analyze SELECT ndict5.url_id,ndict5.intag + FROM ndict5, url + WHERE ndict5.word_id=1343124681 + AND url.rec_id=ndict5.url_id + AND ((url.url || '') LIKE 'http://archives.postgresql.org/%%'); + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=0.00..69799.69 rows=44 width=8) (actual time=113.067..26477.672 rows=14112 loops=1) + -> Index Scan using n5_word on ndict5 (cost=0.00..34321.89 rows=8708 width=8) (actual time=27.349..25031.666 rows=15501 loops=1) + Index Cond: (word_id = 1343124681) + -> Index Scan using url_rec_id on url (cost=0.00..4.06 rows=1 width=4) (actual time=0.061..0.068 rows=1 loops=15501) + Index Cond: (url.rec_id = "outer".url_id) + Filter: ((url || ''::text) ~~ 'http://archives.postgresql.org/%%'::text) + Total runtime: 26550.566 ms +(7 rows) + +QueryB: + +186_archives=# explain analyze SELECT ndict4.url_id,ndict4.intag + FROM ndict4, url + WHERE ndict4.word_id=-2038735111 + AND url.rec_id=ndict4.url_id + AND ((url.url || '') LIKE 'http://archives.postgresql.org/%%'); + + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------ + Nested Loop (cost=0.00..99120.97 rows=62 width=8) (actual time=26.330..6630.581 rows=2694 loops=1) + -> Index Scan using n4_word on ndict4 (cost=0.00..48829.52 rows=12344 width=8) (actual time=7.954..6373.098 rows=2900 loops=1) + Index Cond: (word_id = -2038735111) + -> Index Scan using url_rec_id on url (cost=0.00..4.06 rows=1 width=4) (actual time=0.059..0.066 rows=1 loops=2900) + Index Cond: (url.rec_id = "outer".url_id) + Filter: ((url || ''::text) ~~ 'http://archives.postgresql.org/%%'::text) + Total runtime: 6643.462 ms +(7 rows) + + + + +---- +Marc G. Fournier Hub.Org Networking Services (http://www.hub.org) +Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664 + +From pgsql-performance-owner@postgresql.org Mon Dec 22 18:50:41 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B23BDD1B448 + for ; + Mon, 22 Dec 2003 22:50:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 97133-07 + for ; + Mon, 22 Dec 2003 18:49:53 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 7065BD1B450 + for ; + Mon, 22 Dec 2003 18:49:50 -0400 (AST) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id hBMMmZeD000851; + Mon, 22 Dec 2003 15:48:35 -0700 (MST) +Date: Mon, 22 Dec 2003 15:30:56 -0700 (MST) +From: "scott.marlowe" +To: Conny Thimren +Cc: +Subject: Re: general peformance question +In-Reply-To: +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/291 +X-Sequence-Number: 5151 + +On Thu, 18 Dec 2003, Conny Thimren wrote: + +> Hi, +> This a kind of newbie-question. I've been using Postgres for a long time in a low transction environment - and it is great. +> +> Now I've got an inquiry for using Postgresql in a heavy-load on-line system. This system must handle something like 20 questions per sec with a response time at 1/10 sec. Each question will result in approx 5-6 reads and a couple of updates. +> Anybody have a feeling if this is realistic on a Intelbased Linux server with Postgresql. Ofcourse I know that this is too little info for an exact answer but - as I said - maybe someone can give a hint if it's possible. Maybe someone with heavy-load can give an example of what is possible... + +That really depends on how heavy each query is, so it's hard to say from +what little you've given us. + +If you are doing simple banking style transactions, then you can easily +handle this load, if you are talking a simple shopping cart, ditto, if, +however, you are talking about queries that run 4 or 5 tables with +millions of rows againts each other, you're gonna have to test it +yourself. + +With the autovacuum daemon running, I ran a test overnight of pgbench +(more for general purpose burn in than anything else) + +pgbench -i -s 100 +pgbench -c 50 -t 250000 + +that's 10 million transactions, and it took just over twelve hours to +complete at 220+ transactions per second. + +so, for financials, you're likely to find it easy to meet your target. +But as the tables get bigger / more complex / more interconnected you'll +see a drop in performance. + + +From pgsql-performance-owner@postgresql.org Mon Dec 22 18:33:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2B723D1B446 + for ; + Mon, 22 Dec 2003 22:33:00 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 96705-06 + for ; + Mon, 22 Dec 2003 18:32:12 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DBDCD1B450 + for ; + Mon, 22 Dec 2003 18:32:09 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBMMWB19018709; + Mon, 22 Dec 2003 17:32:11 -0500 (EST) +To: Michael Guerin +Cc: pgsql-performance@postgresql.org +Subject: Re: postgresql performance on linux port +In-reply-to: <3FE741FA.4000002@rentec.com> +References: <3FE741FA.4000002@rentec.com> +Comments: In-reply-to Michael Guerin + message dated "Mon, 22 Dec 2003 14:11:54 -0500" +Date: Mon, 22 Dec 2003 17:32:11 -0500 +Message-ID: <18708.1072132331@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/290 +X-Sequence-Number: 5150 + +Michael Guerin writes: +> I just restored a database running on a solaris box to a linux box +> and queries take forever to execute. + +Did you remember to run ANALYZE? Have you applied the same +configuration settings that you were using before? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Dec 24 21:06:38 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 89BC2D1B480 + for ; + Tue, 23 Dec 2003 00:34:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 08231-07 + for ; + Mon, 22 Dec 2003 20:33:44 -0400 (AST) +Received: from wren.rentec.com (unknown [65.213.84.9]) + by svr1.postgresql.org (Postfix) with ESMTP id F35FDD1B4A3 + for ; + Mon, 22 Dec 2003 20:33:40 -0400 (AST) +Received: from rentec.com (guerinpc.rentec.com [172.16.161.26]) + by wren.rentec.com (8.12.1/8.12.1) with ESMTP id hBN0XZ12013021; + Mon, 22 Dec 2003 19:33:35 -0500 (EST) +Message-ID: <3FE78D61.2F0AECAD@rentec.com> +Date: Mon, 22 Dec 2003 19:33:37 -0500 +From: Michael Guerin +X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) +X-Accept-Language: en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: postgresql performance on linux port +References: <3FE741FA.4000002@rentec.com> <18708.1072132331@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/294 +X-Sequence-Number: 5154 + +Hi Tom, + + I don't believe I did run Analyze, I was under the assumption that the +statistics would have been up to date when the indexes were created. +Thanks for the quick response. + +-mike + + +Tom Lane wrote: + +> Michael Guerin writes: +> > I just restored a database running on a solaris box to a linux box +> > and queries take forever to execute. +> +> Did you remember to run ANALYZE? Have you applied the same +> configuration settings that you were using before? +> +> regards, tom lane + + +From pgsql-performance-owner@postgresql.org Wed Dec 24 09:59:36 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D2246D1B466 + for ; + Wed, 24 Dec 2003 13:59:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51717-02 + for ; + Wed, 24 Dec 2003 09:58:45 -0400 (AST) +Received: from net2.micro-automation.com (net2.micro-automation.com + [64.7.141.29]) + by svr1.postgresql.org (Postfix) with SMTP id 4D199D1B446 + for ; + Wed, 24 Dec 2003 09:58:41 -0400 (AST) +Received: (qmail 19690 invoked from network); 24 Dec 2003 13:58:34 -0000 +Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) + by net2.micro-automation.com with SMTP; 24 Dec 2003 13:58:34 -0000 +Subject: Re: is it possible to get the optimizer to use indexes +From: Dave Cramer +Reply-To: pg@fastcrypt.com +To: Doug McNaught +Cc: pgsql-performance@postgresql.org +In-Reply-To: <87d6alsi2i.fsf@asmodeus.mcnaught.org> +References: <3FE1F5A1.6080908@geizhals.at> + <60n09q9bqg.fsf@dev6.int.libertyrms.info> + <1071789528.1629.10.camel@localhost.localdomain> + <3FE256AA.8000707@familyhealth.com.au> + <87d6alsi2i.fsf@asmodeus.mcnaught.org> +Content-Type: text/plain +Organization: Cramer Consulting +Message-Id: <1072274314.1687.12.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) +Date: 24 Dec 2003 08:58:34 -0500 +Content-Transfer-Encoding: 7bit +X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/292 +X-Sequence-Number: 5152 + +Doug, + +Yes, it does depend on the locale, you can get around this in 7.4 by +building the index with smart operators + +Dave +On Thu, 2003-12-18 at 20:38, Doug McNaught wrote: +> Christopher Kings-Lynne writes: +> +> >> It appears that the optimizer only uses indexes for = clause? +> > +> > The optimizer will used indexes for LIKE clauses, so long as the +> > clause is a prefix search, eg: +> > +> > SELECT * FROM test WHERE a LIKE 'prf%'; +> +> Doesn't this still depend on your locale? +> +> -Doug +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> +> + + +From pgsql-performance-owner@postgresql.org Wed Dec 24 21:06:56 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 375B3D1B94F + for ; + Wed, 24 Dec 2003 16:27:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 66842-02 + for ; + Wed, 24 Dec 2003 12:27:03 -0400 (AST) +Received: from HQEX1.sapiens.int (unknown [209.88.187.126]) + by svr1.postgresql.org (Postfix) with ESMTP id 61FE0D1B481 + for ; + Wed, 24 Dec 2003 12:26:58 -0400 (AST) +Received: from corigin.co.il ([192.168.168.3]) by HQEX1.sapiens.int with + Microsoft SMTPSVC(5.0.2195.5329); Wed, 24 Dec 2003 18:26:51 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 +Content-Class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C3CA3A.93F9A512" +Subject: +Date: Wed, 24 Dec 2003 18:25:43 +0200 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +thread-index: AcPKOpP/Yr548916RgyY/vZTtpBlJA== +From: "Michael Rothschild" +To: +X-OriginalArrivalTime: 24 Dec 2003 16:26:51.0370 (UTC) + FILETIME=[BC5E0CA0:01C3CA3A] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/295 +X-Sequence-Number: 5155 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C3CA3A.93F9A512 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +I consider using PostgreSQL for a project we have in our company and, to +get a better picture of the product, I started scanning its source code +and internal documentation. +Based on what I saw (and maybe I didn't see enough) it seems that the +optimizer will always decide to repeatedly scan the whole row set +returned by sub selects in the context of an IN clause sequentially, as +opposed to what I would expect it to do (which is to create some index +or hash structure to improve performance). +For example, if I have the following query: +Select * from a where x in (select y from b where z=3D7)=20 +Then I would expect an index or hash structure to be created for b.y +when it is first scanned and brought into the cache but I couldn't see +it happening in the source. +As I said, I only inferred it from reading the source - not from actual +experiments - so I may be wrong. +1. Am I wrong? +2. If I'm right, is there any plan to change it (after all, in the +context of an IN clause, an index on the returned row set is all that is +needed - the row set itself does not seem to matter). +=20 +Thank you, +=20 +Michael Rothschild + +------_=_NextPart_001_01C3CA3A.93F9A512 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + +Message + + + +
+
I consider using PostgreSQL for a project we hav= +e in=20 +our company and, to get a better picture of the product, I s= +tarted=20 +scanning its source code and internal documentation.
+
Based on what I saw (and maybe I didn't see enou= +gh)=20 +it seems that the optimizer will always decide to repeatedly scan th= +e=20 +whole row set returned by sub selects in the context of an IN=20 +clause sequentially, as opposed to what I would expect it to do (which= + is=20 +to create some index or hash structure to improve=20 +performance).
+
For example, if I have the follow= +ing=20 +query:
Select * from a where x in (selec= +t y from=20 +b where z=3D7)
+
Then I would expect an index or hash structure to be = +created=20 +for b.y when it is first scanned and brought into the cache but I couldn't = +see=20 +it happening in the source.
+
As I said, I only inferred it from readin= +g the=20 +source - not from actual experiments - so I may be=20 +wrong.
+
1. Am I= +=20 +wrong?
+
2. If I'm= + right, is=20 +there any plan to change it (after all, in the context of an IN clause, an = +index=20 +on the returned row set is all that is needed - the row set itself does not= + seem=20 +to matter).
+
 
+
Thank=20 +you,
+
 
+
Michael=20 +Rothschild
+=00 +------_=_NextPart_001_01C3CA3A.93F9A512-- + +From pgsql-performance-owner@postgresql.org Wed Dec 24 22:48:33 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 30934D1B455 + for ; + Thu, 25 Dec 2003 02:48:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31885-01 + for ; + Wed, 24 Dec 2003 22:47:45 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F4CBD1B471 + for ; + Wed, 24 Dec 2003 22:47:40 -0400 (AST) +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 + hBP2lToD058752; Thu, 25 Dec 2003 10:47:29 +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 + hBP2lTrK058749; Thu, 25 Dec 2003 10:47:29 +0800 (WST) +X-Authentication-Warning: houston.familyhealth.com.au: chriskl owned process + doing -bs +Date: Thu, 25 Dec 2003 10:47:28 +0800 (WST) +From: Christopher Kings-Lynne +To: Michael Rothschild +Cc: pgsql-performance@postgresql.org +Subject: Re: +In-Reply-To: +Message-ID: <20031225104501.V58695-100000@houston.familyhealth.com.au> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/296 +X-Sequence-Number: 5156 + +> For example, if I have the following query: +> Select * from a where x in (select y from b where z=7) +> Then I would expect an index or hash structure to be created for b.y +> when it is first scanned and brought into the cache but I couldn't see +> it happening in the source. +> As I said, I only inferred it from reading the source - not from actual +> experiments - so I may be wrong. +> 1. Am I wrong? + +You are wrong - this is old behaviour and one of the major speed +improvements of PostgreSQL 7.4 is that IN subqueries now use a hash index +and hence they are much faster. + +Chris + + + +From pgsql-performance-owner@postgresql.org Thu Dec 25 12:29:53 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 88F91D1B450 + for ; + Thu, 25 Dec 2003 16:29:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 96122-06 + for ; + Thu, 25 Dec 2003 12:29:01 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A210D1B455 + for ; + Thu, 25 Dec 2003 12:29:00 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBPGSs19020566; + Thu, 25 Dec 2003 11:28:54 -0500 (EST) +To: "Michael Rothschild" +Cc: pgsql-performance@postgresql.org +Subject: Re: +In-reply-to: +References: +Comments: In-reply-to "Michael Rothschild" + message dated "Wed, 24 Dec 2003 18:25:43 +0200" +Date: Thu, 25 Dec 2003 11:28:54 -0500 +Message-ID: <20565.1072369734@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/297 +X-Sequence-Number: 5157 + +"Michael Rothschild" writes: +> Based on what I saw (and maybe I didn't see enough) it seems that the +> optimizer will always decide to repeatedly scan the whole row set +> returned by sub selects in the context of an IN clause sequentially, + +What version were you looking at? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Dec 26 20:12:09 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E9133D1B479 + for ; + Sat, 27 Dec 2003 00:12:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 59501-07 + for ; + Fri, 26 Dec 2003 20:11:20 -0400 (AST) +Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 856E1D1B43C + for ; + Fri, 26 Dec 2003 20:11:17 -0400 (AST) +Received: from juxtapose (c-24-1-81-113.client.comcast.net[24.1.81.113]) + by comcast.net (sccrmhc13) with SMTP + id <2003122700111901600ro8oie>; Sat, 27 Dec 2003 00:11:19 +0000 +From: "Keith Bottner" +To: +Subject: What's faster? +Date: Fri, 26 Dec 2003 18:11:19 -0600 +Message-ID: <008301c3cc0d$f3f337b0$7d00a8c0@juxtapose> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0084_01C3CBDB.A958C7B0" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.6 tagged_above=0.0 required=5.0 tests=HTML_30_40 +X-Spam-Level: +X-Archive-Number: 200312/298 +X-Sequence-Number: 5158 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0084_01C3CBDB.A958C7B0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +I have a database where the vast majority of information that is related to +a customer never changes. However, there is a single field (i.e. balance) +that changes potentially tens to hundreds of times per day per customer +(customers ranging in the 1000s to 10000s). This information is not indexed. +Because Postgres requires VACUUM ANALYZE more frequently on updated tables, +should I break this single field out into its own table, and if so what kind +of a speed up can I expect to achieve. I would be appreciative of any +guidance offered. +=20 +BTW, currently using Postgres 7.3.4 +=20 +=20 +Keith +=20 +=20 + +------=_NextPart_000_0084_01C3CBDB.A958C7B0 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + +Message + + + +
I have a = +database=20 +where the vast majority of information that is related to a customer never= +=20 +changes. However, there is a single field (i.e. balance) that changes= +=20 +potentially tens to hundreds of times per day per customer (customers rangi= +ng in=20 +the 1000s to 10000s). This information is not indexed. Because Postgres req= +uires=20 +VACUUM ANALYZE more frequently on updated tables, should I break this singl= +e=20 +field out into its own table, and if so what kind of a speed up can I expec= +t to=20 +achieve. I would be appreciative of any guidance offered. +
 
+
BTW, curr= +ently using=20 +Postgres 7.3.4
+
 
+
 
+ +
Keith
+
 
+
 
+ +------=_NextPart_000_0084_01C3CBDB.A958C7B0-- + + +From pgsql-performance-owner@postgresql.org Fri Dec 26 20:49:55 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 58E82D1B432 + for ; + Sat, 27 Dec 2003 00:49:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 60019-09 + for ; + Fri, 26 Dec 2003 20:49:08 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id E5A76D1B449 + for ; + Fri, 26 Dec 2003 20:49:04 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBR0n719008603; + Fri, 26 Dec 2003 19:49:07 -0500 (EST) +To: "Keith Bottner" +Cc: pgsql-performance@postgresql.org +Subject: Re: What's faster? +In-reply-to: <008301c3cc0d$f3f337b0$7d00a8c0@juxtapose> +References: <008301c3cc0d$f3f337b0$7d00a8c0@juxtapose> +Comments: In-reply-to "Keith Bottner" + message dated "Fri, 26 Dec 2003 18:11:19 -0600" +Date: Fri, 26 Dec 2003 19:49:07 -0500 +Message-ID: <8602.1072486147@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/299 +X-Sequence-Number: 5159 + +"Keith Bottner" writes: +> I have a database where the vast majority of information that is related to +> a customer never changes. However, there is a single field (i.e. balance) +> that changes potentially tens to hundreds of times per day per customer +> (customers ranging in the 1000s to 10000s). This information is not indexed. +> Because Postgres requires VACUUM ANALYZE more frequently on updated tables, +> should I break this single field out into its own table, + +Very likely a good idea, if the primary key that you'd need to add to +identify the balance is narrow. Hard to say exactly how large the +benefit would be, but I'd think the update costs would be reduced +considerably. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Dec 26 21:07:13 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3C8ECD1B450 + for ; + Sat, 27 Dec 2003 01:07:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 65119-08 + for ; + Fri, 26 Dec 2003 21:06:25 -0400 (AST) +Received: from gw.tssi.com (gw.tssi.com [198.147.197.1]) + by svr1.postgresql.org (Postfix) with ESMTP id B77C3D1B432 + for ; + Fri, 26 Dec 2003 21:06:21 -0400 (AST) +Received: from gw.tssi.com (nolan@gw.tssi.com [127.0.0.1] (may be forged)) + by gw.tssi.com (8.12.6/8.12.6) with ESMTP id hBR16MjC002312; + Fri, 26 Dec 2003 19:06:23 -0600 +Received: (from nolan@localhost) + by gw.tssi.com (8.12.6/8.12.6/Submit) id hBR16MLg002310; + Fri, 26 Dec 2003 19:06:22 -0600 +From: Mike Nolan +Message-Id: <200312270106.hBR16MLg002310@gw.tssi.com> +Subject: Re: What's faster? +To: kbottner@comcast.net (Keith Bottner) +Date: Fri, 26 Dec 2003 19:06:21 -0600 (CST) +Cc: pgsql-performance@postgresql.org +In-Reply-To: <008301c3cc0d$f3f337b0$7d00a8c0@juxtapose> from "Keith Bottner" + at Dec 26, 2003 06:11:19 PM +X-Mailer: ELM [version 2.5 PL3] +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/300 +X-Sequence-Number: 5160 + +> Because Postgres requires VACUUM ANALYZE more frequently on updated tables, +> should I break this single field out into its own table, and if so what kind +> of a speed up can I expect to achieve. I would be appreciative of any +> guidance offered. + +Unless that field is part of the key, I wouldn't think that a vacuum +analyze would be needed, as the key distribution isn't changing. + +I don't know if that is still true if that field is indexed. Tom? + +Even then, as I understand things vacuum analyze doesn't rebuild indexes, +so I could see a need to drop and rebuild indexes on a regular basis, +even if you move that field into a separate table. +-- +Mike Nolan + +From pgsql-performance-owner@postgresql.org Sat Dec 27 00:01:00 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D7AEDD1B436 + for ; + Sat, 27 Dec 2003 04:00:58 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 80619-03 + for ; + Sat, 27 Dec 2003 00:00:08 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 67D6CD1B44B + for ; + Sat, 27 Dec 2003 00:00:08 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBR40419009345; + Fri, 26 Dec 2003 23:00:04 -0500 (EST) +To: Mike Nolan +Cc: kbottner@comcast.net (Keith Bottner), + pgsql-performance@postgresql.org +Subject: Re: What's faster? +In-reply-to: <200312270106.hBR16MLg002310@gw.tssi.com> +References: <200312270106.hBR16MLg002310@gw.tssi.com> +Comments: In-reply-to Mike Nolan + message dated "Fri, 26 Dec 2003 19:06:21 -0600" +Date: Fri, 26 Dec 2003 23:00:03 -0500 +Message-ID: <9344.1072497603@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/301 +X-Sequence-Number: 5161 + +Mike Nolan writes: +>> Because Postgres requires VACUUM ANALYZE more frequently on updated tables, +>> should I break this single field out into its own table, and if so what kind +>> of a speed up can I expect to achieve. I would be appreciative of any +>> guidance offered. + +> Unless that field is part of the key, I wouldn't think that a vacuum +> analyze would be needed, as the key distribution isn't changing. + +The "analyze" wouldn't matter ... but the "vacuum" would. He needs to +get rid of the dead rows in a timely fashion. The wider the rows, the +more disk space is at stake. + +Also, if he has more than just a primary index on the main table, +the cost of updating the secondary indexes must be considered. +A balance-only table would presumably have just one index to update. + +Against all this you have to weigh the cost of doing a join to get the +balance, so it's certainly not a no-brainer choice. But I think it's +surely worth considering such a design. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Dec 27 06:52:56 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A41FD1B4AC + for ; + Sat, 27 Dec 2003 10:52:54 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 31612-02 + for ; + Sat, 27 Dec 2003 06:52:07 -0400 (AST) +Received: from druid.net (druid.net [216.126.72.98]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A77ED1B47A + for ; + Sat, 27 Dec 2003 06:52:04 -0400 (AST) +Received: by druid.net (Postfix, from userid 1000) + id 8784F1B52; Sat, 27 Dec 2003 05:52:08 -0500 (EST) +From: "D'Arcy J.M. Cain" +To: "Keith Bottner" , +Subject: Re: What's faster? +Date: Sat, 27 Dec 2003 05:52:07 -0500 +User-Agent: KMail/1.5.2 +References: <008301c3cc0d$f3f337b0$7d00a8c0@juxtapose> +In-Reply-To: <008301c3cc0d$f3f337b0$7d00a8c0@juxtapose> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200312270552.07823.darcy@druid.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/302 +X-Sequence-Number: 5162 + +On December 26, 2003 07:11 pm, Keith Bottner wrote: +> I have a database where the vast majority of information that is related to +> a customer never changes. However, there is a single field (i.e. balance) +> that changes potentially tens to hundreds of times per day per customer +> (customers ranging in the 1000s to 10000s). This information is not +> indexed. Because Postgres requires VACUUM ANALYZE more frequently on +> updated tables, should I break this single field out into its own table, +> and if so what kind of a speed up can I expect to achieve. I would be +> appreciative of any guidance offered. + +We went through this recently. One thing we found that may apply to you is +how many fields in the client record have a foreign key constraint. We find +that tables with lots of FKeys are a lot more intensive on updates. In our +case it was another table, think of it as an order or header table with a +balance, that has over 10 million records. Sometimes we have 200,000 +transactions a day where we have to check the balance. We eventually moved +every field that could possibly be updated on a regular basis out to separate +tables. The improvement was dramatic. + +-- +D'Arcy J.M. Cain | Democracy is three wolves +http://www.druid.net/darcy/ | and a sheep voting on ++1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. + +From pgsql-performance-owner@postgresql.org Sat Dec 27 14:31:33 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E3E4ED1B4B7 + for ; + Sat, 27 Dec 2003 18:31:31 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 71990-02 + for ; + Sat, 27 Dec 2003 14:30:42 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 3AF4BD1B4E1 + for ; + Sat, 27 Dec 2003 14:30:41 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBRIUd19012772; + Sat, 27 Dec 2003 13:30:39 -0500 (EST) +To: "D'Arcy J.M. Cain" +Cc: "Keith Bottner" , + pgsql-performance@postgresql.org +Subject: Re: What's faster? +In-reply-to: <200312270552.07823.darcy@druid.net> +References: <008301c3cc0d$f3f337b0$7d00a8c0@juxtapose> + <200312270552.07823.darcy@druid.net> +Comments: In-reply-to "D'Arcy J.M. Cain" + message dated "Sat, 27 Dec 2003 05:52:07 -0500" +Date: Sat, 27 Dec 2003 13:30:38 -0500 +Message-ID: <12771.1072549838@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/303 +X-Sequence-Number: 5163 + +"D'Arcy J.M. Cain" writes: +> We went through this recently. One thing we found that may apply to you is +> how many fields in the client record have a foreign key constraint. We find +> that tables with lots of FKeys are a lot more intensive on updates. + +BTW, this should have gotten better in 7.3.4 and later --- there is +logic to skip checking an FKey reference if the referencing columns +didn't change during the update. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Dec 29 12:36:47 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 148C7D1B472 + for ; + Mon, 29 Dec 2003 16:36:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38588-05 + for ; + Mon, 29 Dec 2003 12:35:57 -0400 (AST) +Received: from bittern.mail.pas.earthlink.net (bittern.mail.pas.earthlink.net + [207.217.120.119]) + by svr1.postgresql.org (Postfix) with ESMTP id C82C6D1B443 + for ; + Mon, 29 Dec 2003 12:35:56 -0400 (AST) +Received: from dpc6682160001.direcpc.com ([66.82.160.1] helo=earthlink.net) + by bittern.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) + id 1Ab0NA-0006qe-00 + for pgsql-performance@postgresql.org; Mon, 29 Dec 2003 08:36:07 -0800 +Message-ID: <3FF057DF.7000605@earthlink.net> +Date: Mon, 29 Dec 2003 11:35:43 -0500 +From: Sean Shanny +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Question about difference in performance of 2 queries on large table +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/304 +X-Sequence-Number: 5164 + +To all, + +The facts: + +PostgreSQL 7.4.0 running on BSD 5.1 on Dell 2650 with 4GB RAM, 5 SCSI +drives in hardware RAID 0 configuration. Database size with indexes is +currently 122GB. Schema for the table in question is at the end of this +email. The DB has been vacuumed full and analyzed. Between 2 and 3 +million records are added to the table in question each night. An +analyze is run on the entire DB after the data has been loaded each +night. There are no updates or deletes of records during the nightly +load, only insertions. + +I am trying to understand why the performance between the two queries +below is so different. I am trying to find the count of all pages that +have a 'valid' content_key. -1 is our 'we don't have any content' key. +The first plan below has horrendous performance. we only get about 2% +CPU usage and iostat shows 3-5 MB/sec IO. The second plan runs at 30% +cpu and 15-30MB.sec IO. + +Could someone shed some light on why the huge difference in +performance? Both are doing index scans plus a filter. We have no +content_keys below -1 at this time so the queries return the same results. + +Thanks. + + +--sean + + +explain select count (distinct (persistent_cookie_key) ) from +f_pageviews where date_key between 305 and 334 and content_key > -1; + QUERY PLAN +------------------------------------------------------------------------------------------------------------ + Aggregate (cost=688770.29..688770.29 rows=1 width=4) + -> Index Scan using idx_pageviews_content on f_pageviews +(cost=0.00..645971.34 rows=17119580 width=4) + Index Cond: (content_key > -1) + Filter: ((date_key >= 305) AND (date_key <= 334)) +(4 rows) + + +explain select count (distinct (persistent_cookie_key) ) from +f_pageviews where date_key between 305 and 334 and content_key <> -1; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------ + Aggregate (cost=1365419.12..1365419.12 rows=1 width=4) + -> Index Scan using idx_pageviews_date_nov_2003 on f_pageviews +(cost=0.00..1322615.91 rows=17121284 width=4) + Index Cond: ((date_key >= 305) AND (date_key <= 334)) + Filter: (content_key <> -1) +(4 rows) + + + \d f_pageviews + Table "public.f_pageviews" + Column | Type | Modifiers +------------------------+---------+------------------------------------------------------------- + id | integer | not null default +nextval('public.f_pageviews_id_seq'::text) + date_key | integer | not null + time_key | integer | not null + content_key | integer | not null + location_key | integer | not null + session_key | integer | not null + subscriber_key | text | not null + persistent_cookie_key | integer | not null + ip_key | integer | not null + referral_key | integer | not null + servlet_key | integer | not null + tracking_key | integer | not null + provider_key | text | not null + marketing_campaign_key | integer | not null + orig_airport | text | not null + dest_airport | text | not null + commerce_page | boolean | not null default false + job_control_number | integer | not null + sequenceid | integer | not null default 0 + url_key | integer | not null + useragent_key | integer | not null + web_server_name | text | not null default 'Not Available'::text + cpc | integer | not null default 0 + referring_servlet_key | integer | default 1 + first_page_key | integer | default 1 + newsletterid_key | text | not null default 'Not Available'::text +Indexes: + "f_pageviews_pkey" primary key, btree (id) + "idx_pageviews_content" btree (content_key) + "idx_pageviews_date_dec_2003" btree (date_key) WHERE ((date_key >= +335) AND (date_key <= 365)) + "idx_pageviews_date_nov_2003" btree (date_key) WHERE ((date_key >= +304) AND (date_key <= 334)) + "idx_pageviews_referring_servlet" btree (referring_servlet_key) + "idx_pageviews_servlet" btree (servlet_key) + "idx_pageviews_session" btree (session_key) + + + + +From pgsql-performance-owner@postgresql.org Mon Dec 29 12:49:47 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1536CD1B443 + for ; + Mon, 29 Dec 2003 16:49:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 41877-02 + for ; + Mon, 29 Dec 2003 12:48:57 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 59E79D1B4A0 + for ; + Mon, 29 Dec 2003 12:48:10 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBTGm819015477; + Mon, 29 Dec 2003 11:48:08 -0500 (EST) +To: Sean Shanny +Cc: pgsql-performance@postgresql.org +Subject: Re: Question about difference in performance of 2 queries on large + table +In-reply-to: <3FF057DF.7000605@earthlink.net> +References: <3FF057DF.7000605@earthlink.net> +Comments: In-reply-to Sean Shanny + message dated "Mon, 29 Dec 2003 11:35:43 -0500" +Date: Mon, 29 Dec 2003 11:48:07 -0500 +Message-ID: <15476.1072716487@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/305 +X-Sequence-Number: 5165 + +Please show EXPLAIN ANALYZE output for your queries, not just EXPLAIN. +Also it would be useful to see the pg_stats rows for the date_key and +content_key columns. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Dec 29 12:50:10 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CBBBDD1B513 + for ; + Mon, 29 Dec 2003 16:50:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 38936-08 + for ; + Mon, 29 Dec 2003 12:49:20 -0400 (AST) +Received: from zigo.dhs.org (as2-4-3.an.g.bonet.se [194.236.34.191]) + by svr1.postgresql.org (Postfix) with ESMTP id 7EBF4D1B436 + for ; + Mon, 29 Dec 2003 12:48:51 -0400 (AST) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 4126B8DD6; Mon, 29 Dec 2003 17:48:49 +0100 (CET) +Date: Mon, 29 Dec 2003 17:48:49 +0100 (CET) +From: Dennis Bjorklund +To: Sean Shanny +Cc: pgsql-performance@postgresql.org +Subject: Re: Question about difference in performance of 2 queries +In-Reply-To: <3FF057DF.7000605@earthlink.net> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/306 +X-Sequence-Number: 5166 + +On Mon, 29 Dec 2003, Sean Shanny wrote: + +> The first plan below has horrendous performance. we only get about 2% +> CPU usage and iostat shows 3-5 MB/sec IO. The second plan runs at 30% +> cpu and 15-30MB.sec IO. +> +> Could someone shed some light on why the huge difference in +> performance? Both are doing index scans plus a filter. We have no +> content_keys below -1 at this time so the queries return the same results. + +EXPLAIN ANALYZE gives more information then EXPLAIN, and is prefered. + +It uses different indexes in the two queries, and one seems to be +faster then the other. Why, I can't tell yet. + +I would assume that you would get the fastet result if you had an index + + (content_key, date_key) + +I don't know if pg will even use an index to speed up a <> operation. When +you had > then it could use the idx_pageviews_content index. Why it choose +that when the other would be faster I don't know. Maybe explain analyze +will give some hint. + +-- +/Dennis + + +From pgsql-performance-owner@postgresql.org Mon Dec 29 13:45:15 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C32DD1B440 + for ; + Mon, 29 Dec 2003 17:45:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 47911-09 + for ; + Mon, 29 Dec 2003 13:44:23 -0400 (AST) +Received: from bittern.mail.pas.earthlink.net (bittern.mail.pas.earthlink.net + [207.217.120.119]) + by svr1.postgresql.org (Postfix) with ESMTP id 0AB97D1B4A0 + for ; + Mon, 29 Dec 2003 13:44:23 -0400 (AST) +Received: from dpc6682160001.direcpc.com ([66.82.160.1] helo=earthlink.net) + by bittern.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) + id 1Ab1RQ-0007EE-00; Mon, 29 Dec 2003 09:44:34 -0800 +Message-ID: <3FF067EB.4050405@earthlink.net> +Date: Mon, 29 Dec 2003 12:44:11 -0500 +From: Sean Shanny +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Cc: Tom Lane +Subject: Re: Question about difference in performance of 2 queries +References: <3FF057DF.7000605@earthlink.net> <15476.1072716487@sss.pgh.pa.us> +In-Reply-To: <15476.1072716487@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/307 +X-Sequence-Number: 5167 + +I am running explain analyze now and will post results as they finish. + +Thanks. + +--sean + +Tom Lane wrote: + +>Please show EXPLAIN ANALYZE output for your queries, not just EXPLAIN. +>Also it would be useful to see the pg_stats rows for the date_key and +>content_key columns. +> +> regards, tom lane +> +> +> + + +From pgsql-performance-owner@postgresql.org Mon Dec 29 14:47:13 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B2DAFD1B436 + for ; + Mon, 29 Dec 2003 18:47:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 56288-05 + for ; + Mon, 29 Dec 2003 14:46:22 -0400 (AST) +Received: from bittern.mail.pas.earthlink.net (bittern.mail.pas.earthlink.net + [207.217.120.119]) + by svr1.postgresql.org (Postfix) with ESMTP id 5CE99D1B437 + for ; + Mon, 29 Dec 2003 14:46:21 -0400 (AST) +Received: from dpc6682160001.direcpc.com ([66.82.160.1] helo=earthlink.net) + by bittern.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) + id 1Ab2PP-0007Sj-00; Mon, 29 Dec 2003 10:46:33 -0800 +Message-ID: <3FF07671.7050706@earthlink.net> +Date: Mon, 29 Dec 2003 13:46:09 -0500 +From: Sean Shanny +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Cc: Tom Lane +Subject: Re: Question about difference in performance of 2 queries +References: <3FF057DF.7000605@earthlink.net> <15476.1072716487@sss.pgh.pa.us> +In-Reply-To: <15476.1072716487@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/308 +X-Sequence-Number: 5168 + +Here is the pg_stats data. The explain analyze queries are still running. + +select * from pg_stats where tablename = 'f_pageviews' and attname = +'date_key'; + schemaname | tablename | attname | null_frac | avg_width | +n_distinct | most_common_vals +| +most_common_freqs +| histogram_bounds | correlation +------------+-------------+----------+-----------+-----------+------------+-------------------------------------------+---------------------------------------------------------------------------------------------------+-----------------------------------------------+------------- + public | f_pageviews | date_key | 0 | 4 | +60 | {335,307,309,336,308,321,314,342,322,316} | +{0.0283333,0.0243333,0.0243333,0.0243333,0.024,0.0233333,0.0226667,0.0226667,0.0223333,0.0216667} +| {304,311,318,325,329,334,341,346,351,356,363} | 0.345026 +(1 row) + +select * from pg_stats where tablename = 'f_pageviews' and attname = +'content_key'; + schemaname | tablename | attname | null_frac | avg_width | +n_distinct | most_common_vals | most_common_freqs +| +histogram_bounds | correlation +------------+-------------+-------------+-----------+-----------+------------+------------------+-----------------------+-------------------------------------------------------------------------------------+------------- + public | f_pageviews | content_key | 0 | 4 | +983 | {-1,1528483} | {0.749333,0.00166667} | +{38966,323835,590676,717061,919148,1091875,1208244,1299702,1375366,1434079,1528910} +| 0.103399 +(1 row) + +Thanks. + +--sean + + +Tom Lane wrote: + +>Please show EXPLAIN ANALYZE output for your queries, not just EXPLAIN. +>Also it would be useful to see the pg_stats rows for the date_key and +>content_key columns. +> +> regards, tom lane +> +> +> + + +From pgsql-performance-owner@postgresql.org Mon Dec 29 15:26:42 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 28712D1B498 + for ; + Mon, 29 Dec 2003 19:26:39 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62922-09 + for ; + Mon, 29 Dec 2003 15:25:51 -0400 (AST) +Received: from bittern.mail.pas.earthlink.net (bittern.mail.pas.earthlink.net + [207.217.120.119]) + by svr1.postgresql.org (Postfix) with ESMTP id CD654D1B450 + for ; + Mon, 29 Dec 2003 15:25:49 -0400 (AST) +Received: from dpc6682160001.direcpc.com ([66.82.160.1] helo=earthlink.net) + by bittern.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) + id 1Ab31b-0000in-00 + for pgsql-performance@postgresql.org; Mon, 29 Dec 2003 11:26:02 -0800 +Message-ID: <3FF07FB2.5060608@earthlink.net> +Date: Mon, 29 Dec 2003 14:25:38 -0500 +From: Sean Shanny +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Question about difference in performance of 2 queries +References: <3FF057DF.7000605@earthlink.net> <15476.1072716487@sss.pgh.pa.us> +In-Reply-To: <15476.1072716487@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/309 +X-Sequence-Number: 5169 + +Here is one of the explain analyzes. This is the from the faster +query. Ignore the total runtime as we are currently doing other queries +on this machine so it is slightly loaded. + +Thanks. + +--sean + + +explain analyze select count (distinct (persistent_cookie_key) ) from +f_pageviews where date_key between 305 and 334 and content_key <> -1; + +QUERY PLAN + +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Aggregate (cost=1384925.95..1384925.95 rows=1 width=4) (actual +time=4541462.030..4541462.034 rows=1 loops=1) + -> Index Scan using idx_pageviews_date_nov_2003 on f_pageviews +(cost=0.00..1343566.52 rows=16543772 width=4) (actual +time=83.267..4286664.678 rows=15710722 loops=1) + Index Cond: ((date_key >= 305) AND (date_key <= 334)) + Filter: (content_key <> -1) + Total runtime: 4541550.832 ms +(5 rows) + +Tom Lane wrote: + +>Please show EXPLAIN ANALYZE output for your queries, not just EXPLAIN. +>Also it would be useful to see the pg_stats rows for the date_key and +>content_key columns. +> +> regards, tom lane +> +> +> + + +From pgsql-performance-owner@postgresql.org Mon Dec 29 15:40:08 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D5CEAD1B4AC + for ; + Mon, 29 Dec 2003 19:40:07 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 68108-02 + for ; + Mon, 29 Dec 2003 15:39:20 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id A10E0D1B49C + for ; + Mon, 29 Dec 2003 15:39:14 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id hBTJdC19016346; + Mon, 29 Dec 2003 14:39:12 -0500 (EST) +To: Sean Shanny +Cc: pgsql-performance@postgresql.org +Subject: Re: Question about difference in performance of 2 queries +In-reply-to: <3FF07671.7050706@earthlink.net> +References: <3FF057DF.7000605@earthlink.net> <15476.1072716487@sss.pgh.pa.us> + <3FF07671.7050706@earthlink.net> +Comments: In-reply-to Sean Shanny + message dated "Mon, 29 Dec 2003 13:46:09 -0500" +Date: Mon, 29 Dec 2003 14:39:11 -0500 +Message-ID: <16345.1072726751@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/310 +X-Sequence-Number: 5170 + +Sean Shanny writes: +> Here is the pg_stats data. The explain analyze queries are still running. + +> select * from pg_stats where tablename = 'f_pageviews' and attname = +> 'content_key'; +> schemaname | tablename | attname | null_frac | avg_width | +> n_distinct | most_common_vals | most_common_freqs +> | +> histogram_bounds | correlation +> ------------+-------------+-------------+-----------+-----------+------------+------------------+-----------------------+-------------------------------------------------------------------------------------+------------- +> public | f_pageviews | content_key | 0 | 4 | +> 983 | {-1,1528483} | {0.749333,0.00166667} | + +Oh-ho, I see the problem: about 75% of your table has content_key = -1. + +Why is that a problem, you ask? Well, the planner realizes that +"content_key > -1" is a pretty good restriction condition (better than +the date condition, apparently) and so it tries to use that as the index +scan condition. The problem is that in 7.4 and before, the btree index +code implements a "> -1" scan starting boundary by finding the first -1 +and then advancing to the first key that's not -1. So you end up +scanning through 75% of the index before anything useful happens :-( + +I just fixed this poor behavior in CVS tip a couple weeks ago: +http://archives.postgresql.org/pgsql-committers/2003-12/msg00220.php +but the patch seems too large and unproven to risk back-patching into +7.4.*. + +If you expect that a pretty large fraction of your data will always have +dummy content_key, it'd probably be worth changing the index to not +index -1's at all --- that is, make it a partial index with the +condition "WHERE content_key > -1". Another workaround is to leave the +index as-is but phrase the query WHERE condition as "content_key >= 0" +instead of "> -1". + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Dec 29 15:53:41 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6308ED1B48E + for ; + Mon, 29 Dec 2003 19:53:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 70004-01 + for ; + Mon, 29 Dec 2003 15:52:51 -0400 (AST) +Received: from bittern.mail.pas.earthlink.net (bittern.mail.pas.earthlink.net + [207.217.120.119]) + by svr1.postgresql.org (Postfix) with ESMTP id 29209D1B436 + for ; + Mon, 29 Dec 2003 15:52:50 -0400 (AST) +Received: from dpc6682160001.direcpc.com ([66.82.160.1] helo=earthlink.net) + by bittern.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) + id 1Ab3Ri-0006nC-00 + for pgsql-performance@postgresql.org; Mon, 29 Dec 2003 11:53:01 -0800 +Message-ID: <3FF08606.2080204@earthlink.net> +Date: Mon, 29 Dec 2003 14:52:38 -0500 +From: Sean Shanny +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Question about difference in performance of 2 queries +References: <3FF057DF.7000605@earthlink.net> <15476.1072716487@sss.pgh.pa.us> + <3FF07671.7050706@earthlink.net> <16345.1072726751@sss.pgh.pa.us> +In-Reply-To: <16345.1072726751@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/311 +X-Sequence-Number: 5171 + +Tom, + +Thanks. I will make the changes you suggest concerning the indexes. I +am finding partial indexes to be very handy. :-) + +I canceled the explain analyze on the other query as we have found the +problem and who knows how long it would take to complete. + +Thanks again. + +--sean + +Tom Lane wrote: + +>Sean Shanny writes: +> +> +>>Here is the pg_stats data. The explain analyze queries are still running. +>> +>> +> +> +> +>>select * from pg_stats where tablename = 'f_pageviews' and attname = +>>'content_key'; +>> schemaname | tablename | attname | null_frac | avg_width | +>>n_distinct | most_common_vals | most_common_freqs +>>| +>>histogram_bounds | correlation +>>------------+-------------+-------------+-----------+-----------+------------+------------------+-----------------------+-------------------------------------------------------------------------------------+------------- +>> public | f_pageviews | content_key | 0 | 4 | +>>983 | {-1,1528483} | {0.749333,0.00166667} | +>> +>> +> +>Oh-ho, I see the problem: about 75% of your table has content_key = -1. +> +>Why is that a problem, you ask? Well, the planner realizes that +>"content_key > -1" is a pretty good restriction condition (better than +>the date condition, apparently) and so it tries to use that as the index +>scan condition. The problem is that in 7.4 and before, the btree index +>code implements a "> -1" scan starting boundary by finding the first -1 +>and then advancing to the first key that's not -1. So you end up +>scanning through 75% of the index before anything useful happens :-( +> +>I just fixed this poor behavior in CVS tip a couple weeks ago: +>http://archives.postgresql.org/pgsql-committers/2003-12/msg00220.php +>but the patch seems too large and unproven to risk back-patching into +>7.4.*. +> +>If you expect that a pretty large fraction of your data will always have +>dummy content_key, it'd probably be worth changing the index to not +>index -1's at all --- that is, make it a partial index with the +>condition "WHERE content_key > -1". Another workaround is to leave the +>index as-is but phrase the query WHERE condition as "content_key >= 0" +>instead of "> -1". +> +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> +> +> + + +From pgsql-performance-owner@postgresql.org Mon Dec 29 16:34:47 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B67F8D1B436 + for ; + Mon, 29 Dec 2003 20:34:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 75028-10 + for ; + Mon, 29 Dec 2003 16:33:59 -0400 (AST) +Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) + by svr1.postgresql.org (Postfix) with ESMTP id B42E4D1B43C + for ; + Mon, 29 Dec 2003 16:33:57 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id 39A9F3E42 + for ; + Mon, 29 Dec 2003 15:33:58 -0500 (EST) +Received: from lorax.kcilink.com ([127.0.0.1]) + by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 02693-01-2 for ; + Mon, 29 Dec 2003 15:33:57 -0500 (EST) +Received: from lorax.kcilink.com (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id 9606F3E33 + for ; + Mon, 29 Dec 2003 15:33:57 -0500 (EST) +Received: (from news@localhost) + by lorax.kcilink.com (8.12.9p2/8.12.9/Submit) id hBTKXvGA024420 + for pgsql-performance@postgresql.org; + Mon, 29 Dec 2003 15:33:57 -0500 (EST) (envelope-from news) +To: pgsql-performance@postgresql.org +Path: not-for-mail +From: Vivek Khera +Newsgroups: ml.postgres.performance +Subject: deferred foreign keys +Date: Mon, 29 Dec 2003 15:33:57 -0500 +Organization: Khera Communications, Inc., Rockville, MD +Lines: 27 +Message-ID: +NNTP-Posting-Host: yertle.kcilink.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Trace: lorax.kcilink.com 1072730037 59545 65.205.34.180 (29 Dec 2003 + 20:33:57 GMT) +X-Complaints-To: daemon@kciLink.com +NNTP-Posting-Date: Mon, 29 Dec 2003 20:33:57 +0000 (UTC) +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + berkeley-unix) +Cancel-Lock: sha1:9TYKO5cEojn18uHttgg36sHTv1E= +X-Virus-Scanned: by amavisd-new at kciLink.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/312 +X-Sequence-Number: 5172 + +I'm observing that when I have many processes doing some work on my +system that the transactions run along almost in lockstep. It appears +from messages posted here that the foreign keys are acquiring and +holding locks during the transactions, which seems like it would cause +this behavior. + +I'd like to experiment with deferred foreign key checks so that the +lock is only held during the commit when the checks are done. + +My questions are: + +1) can I, and if so, how do I convert my existing FK's to deferrable + without drop/create of the keys. Some of the keys take a long time + to create and I'd like to avoid the hit. + +2) do I increase the liklihood of deadlocks when the FK locks are + being acquired or is it just as likeley as with the current + non-deferred checking? + +I'm running 7.4 (soon to be 7.4.1) + + +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +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 Tue Dec 30 11:03:15 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 76658D1B4A2 + for ; + Tue, 30 Dec 2003 15:03:13 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 09343-06 + for ; + Tue, 30 Dec 2003 11:02:28 -0400 (AST) +Received: from mx.tripadvisor.com (unknown [151.203.96.35]) + by svr1.postgresql.org (Postfix) with ESMTP id 34B2CD1B554 + for ; + Tue, 30 Dec 2003 11:02:17 -0400 (AST) +Received: from [192.168.35.16] (shanny.tripadvisor.com [192.168.35.16]) + by mx.tripadvisor.com (8.12.10/8.12.10) with ESMTP id hBUF2I9p088142; + Tue, 30 Dec 2003 10:02:18 -0500 (EST) + (envelope-from nshanny@tripadvisor.com) +In-Reply-To: <16345.1072726751@sss.pgh.pa.us> +References: <3FF057DF.7000605@earthlink.net> <15476.1072716487@sss.pgh.pa.us> + <3FF07671.7050706@earthlink.net> <16345.1072726751@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v609) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: Sean Shanny , + pgsql-performance@postgresql.org +From: Nicholas Shanny +Subject: Re: Question about difference in performance of 2 queries +Date: Tue, 30 Dec 2003 10:00:30 -0500 +To: Tom Lane +X-Mailer: Apple Mail (2.609) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/313 +X-Sequence-Number: 5173 + +Tom, + +I understand the problem and your solution makes sense although I am +still puzzled by the machine under-utilization. If you run the original +query and monitor the IO/CPU usage you find that it is minimal. + +here is the output from iostat 1 for a brief portion of the query. I am +very curious to understand why when scanning the index the IO/CPU +utilization is seemingly low. + +Cheers +Nick Shanny +TripAdvisor, Inc. + + 0 77 32.00 106 3.31 0.00 0 0.00 0.00 0 0.00 0 0 2 0 +98 + 0 76 32.00 125 3.90 0.00 0 0.00 0.00 0 0.00 0 0 2 +0 97 + 0 76 32.00 125 3.90 0.00 0 0.00 0.00 0 0.00 0 0 1 +1 98 + 0 76 32.75 127 4.05 0.00 0 0.00 0.00 0 0.00 0 0 1 +0 99 + tty aacd0 acd0 fd0 +cpu + tin tout KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s us ni sy +in id + 0 76 32.00 127 3.96 0.00 0 0.00 0.00 0 0.00 0 0 3 +0 97 + 0 229 32.24 135 4.24 0.00 0 0.00 0.00 0 0.00 0 0 4 +0 95 + 0 76 32.00 129 4.02 0.00 0 0.00 0.00 0 0.00 0 0 2 +0 97 + 0 76 32.00 123 3.84 0.00 0 0.00 0.00 0 0.00 0 0 2 +0 98 + 0 76 31.72 115 3.56 0.00 0 0.00 0.00 0 0.00 0 0 2 +0 98 + 0 76 32.50 126 3.99 0.00 0 0.00 0.00 0 0.00 0 0 3 +1 96 + 0 76 32.00 123 3.84 0.00 0 0.00 0.00 0 0.00 0 0 3 +0 97 + 0 76 32.00 122 3.81 0.00 0 0.00 0.00 0 0.00 1 0 2 +0 97 + 0 76 32.00 135 4.21 0.00 0 0.00 0.00 0 0.00 0 0 2 +1 97 + 0 76 32.00 97 3.03 0.00 0 0.00 0.00 0 0.00 0 0 3 +0 97 + +On Dec 29, 2003, at 2:39 PM, Tom Lane wrote: + +> Sean Shanny writes: +>> Here is the pg_stats data. The explain analyze queries are still +>> running. +> +>> select * from pg_stats where tablename = 'f_pageviews' and attname = +>> 'content_key'; +>> schemaname | tablename | attname | null_frac | avg_width | +>> n_distinct | most_common_vals | most_common_freqs +>> | +>> histogram_bounds | correlation +>> ------------+-------------+-------------+-----------+----------- +>> +------------+------------------+----------------------- +>> +--------------------------------------------------------------------- +>> ----------------+------------- +>> public | f_pageviews | content_key | 0 | 4 | +>> 983 | {-1,1528483} | {0.749333,0.00166667} | +> +> Oh-ho, I see the problem: about 75% of your table has content_key = -1. +> +> Why is that a problem, you ask? Well, the planner realizes that +> "content_key > -1" is a pretty good restriction condition (better than +> the date condition, apparently) and so it tries to use that as the +> index +> scan condition. The problem is that in 7.4 and before, the btree index +> code implements a "> -1" scan starting boundary by finding the first -1 +> and then advancing to the first key that's not -1. So you end up +> scanning through 75% of the index before anything useful happens :-( +> +> I just fixed this poor behavior in CVS tip a couple weeks ago: +> http://archives.postgresql.org/pgsql-committers/2003-12/msg00220.php +> but the patch seems too large and unproven to risk back-patching into +> 7.4.*. +> +> If you expect that a pretty large fraction of your data will always +> have +> dummy content_key, it'd probably be worth changing the index to not +> index -1's at all --- that is, make it a partial index with the +> condition "WHERE content_key > -1". Another workaround is to leave the +> index as-is but phrase the query WHERE condition as "content_key >= 0" +> instead of "> -1". +> +> regards, tom lane +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> + + +From pgsql-performance-owner@postgresql.org Tue Dec 30 12:33:40 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E617D1B8C8 + for ; + Tue, 30 Dec 2003 16:33:38 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21075-05 + for ; + Tue, 30 Dec 2003 12:32:48 -0400 (AST) +Received: from mail4.speakeasy.net (mail4.speakeasy.net [216.254.0.204]) + by svr1.postgresql.org (Postfix) with ESMTP id 7AA26D1B468 + for ; + Tue, 30 Dec 2003 12:32:47 -0400 (AST) +Received: (qmail 25116 invoked from network); 30 Dec 2003 16:32:46 -0000 +Received: from atlas.jonathangardner.net (HELO jonathangardner.net) + (jgardn@[66.92.192.166]) + (envelope-sender ) + by mail4.speakeasy.net (qmail-ldap-1.03) with RC4-MD5 encrypted SMTP + for ; 30 Dec 2003 16:32:46 -0000 +From: Jonathan Gardner +To: pgsql-performance@postgresql.org +Subject: DELETE ... WHERE ctid IN (...) vs. Iteration +Date: Tue, 30 Dec 2003 08:32:38 -0800 +User-Agent: KMail/1.5.94 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: Text/Plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Message-Id: <200312300832.44945.jgardner@jonathangardner.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/314 +X-Sequence-Number: 5174 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +I guess this may have come up before, but now that 7.4 has the IN with=20 +improved performance, it may be time to revisit this topic. + +Compare these two algorithms (in plpgsql): + +(a) +DELETE FROM foo WHERE ctid IN ( + SELECT foo.ctid + FROM ... WHERE ... +); + +(b) +FOR result IN SELECT foo.ctid FROM ... WHERE ... LOOP + DELETE FROM foo WHERE ctid =3D result; +END LOOP; + +My poor understanding of how the IN operator works leaves me to believe=20 +that for a large set of data in the IN group, a hash is used and a=20 +tablescan done on foo. However, for a small set of data in the IN group,= +=20 +no tablescan is performed. + +I assume that (a) works at O(ln(N)) for large N, and O(N) for small N,=20 +while (b) works at O(N) universally. Therefore, (a) is the superior=20 +algorithm. I welcome criticism and correction. + +- --=20 +Jonathan Gardner +jgardner@jonathangardner.net +Live Free, Use Linux! +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.2 (GNU/Linux) + +iD8DBQE/8aipWgwF3QvpWNwRAk8GAJoDWISjxG7LMB1FdCFmwlOafsmZTwCePx18 +lyHLNBJ8nP0RHzv6WfRzQ+M=3D +=3DFPdW +-----END PGP SIGNATURE----- + +From pgsql-performance-owner@postgresql.org Wed Dec 31 13:18:45 2003 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (neptune.hub.org [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 73686D1B440 + for ; + Wed, 31 Dec 2003 17:18:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11455-03 + for ; + Wed, 31 Dec 2003 13:17:54 -0400 (AST) +Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 5EF6CD1C981 + for ; + Wed, 31 Dec 2003 13:17:53 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id 9F0FB3E65 + for ; + Wed, 31 Dec 2003 12:17:51 -0500 (EST) +Received: from lorax.kcilink.com ([127.0.0.1]) + by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 84374-05-4 for ; + Wed, 31 Dec 2003 12:17:51 -0500 (EST) +Received: from lorax.kcilink.com (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id E37CA3E4D + for ; + Wed, 31 Dec 2003 12:17:50 -0500 (EST) +Received: (from news@localhost) + by lorax.kcilink.com (8.12.9p2/8.12.9/Submit) id hBVHHogZ033782 + for pgsql-performance@postgresql.org; + Wed, 31 Dec 2003 12:17:50 -0500 (EST) (envelope-from news) +To: pgsql-performance@postgresql.org +Path: not-for-mail +From: Vivek Khera +Newsgroups: ml.postgres.performance +Subject: Re: deferred foreign keys +Date: Wed, 31 Dec 2003 12:17:50 -0500 +Organization: Khera Communications, Inc., Rockville, MD +Lines: 16 +Message-ID: +References: +NNTP-Posting-Host: yertle.kcilink.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Trace: lorax.kcilink.com 1072891070 90029 65.205.34.180 (31 Dec 2003 + 17:17:50 GMT) +X-Complaints-To: daemon@kciLink.com +NNTP-Posting-Date: Wed, 31 Dec 2003 17:17:50 +0000 (UTC) +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + berkeley-unix) +Cancel-Lock: sha1:0SjR8PMhIyH041mh3DSKaJ7YFMA= +X-Virus-Scanned: by amavisd-new at kciLink.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200312/315 +X-Sequence-Number: 5175 + +One more question: does the FK checker know to skip checking a +constraint if the column in question did not change during an update? + +That is, if I have a user table that references an owner_id in an +owners table as a foreign key, but I update fields other than owner_id +in the user table, will it still try to verify that owner_id is a +valid value even though it did not change? + +I'm using PG 7.4. + +Thanks. +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +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/ +