diff --git "a/pgsql-performance.200403" "b/pgsql-performance.200403" new file mode 100644--- /dev/null +++ "b/pgsql-performance.200403" @@ -0,0 +1,35240 @@ +From pgsql-performance-owner@postgresql.org Mon Mar 1 03:30:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2CC9BD1E950 + for ; + Mon, 1 Mar 2004 07:30: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 14734-03 + for ; + Mon, 1 Mar 2004 03:29:45 -0400 (AST) +Received: from linda-3.paradise.net.nz (bm-3a.paradise.net.nz [202.0.58.22]) + by svr1.postgresql.org (Postfix) with ESMTP id C8297D1E954 + for ; + Mon, 1 Mar 2004 03:29:43 -0400 (AST) +Received: from smtp-3.paradise.net.nz (smtp-3b.paradise.net.nz [202.0.32.212]) + by linda-3.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0HTV0047NZHIQ0@linda-3.paradise.net.nz> for + pgsql-performance@postgresql.org; Mon, 01 Mar 2004 20:29:43 +1300 (NZDT) +Received: from paradise.net.nz + (203-79-100-108.adsl.paradise.net.nz [203.79.100.108]) + by smtp-3.paradise.net.nz (Postfix) with ESMTP id 67827ADF23; Mon, + 01 Mar 2004 20:29:42 +1300 (NZDT) +Date: Mon, 01 Mar 2004 20:30:58 +1300 +From: Mark Kirkwood +Subject: Re: FreeBSD config +In-reply-to: <403EEEB8.3080807@frodo.hserus.net> +To: Shridhar Daithankar +Cc: Dror Matalon , pgsql-performance@postgresql.org +Message-id: <4042E6B2.1060906@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.5) Gecko/20031213 +References: <20040226180345.GU26787@rlx11.zapatec.com> + + <20040226191616.GA26787@rlx11.zapatec.com> + <20040226230606.GG49146@smtp.k12us.com> + <20040226234246.GN26787@rlx11.zapatec.com> + <403EEEB8.3080807@frodo.hserus.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/1 +X-Sequence-Number: 5857 + + + +Shridhar Daithankar wrote: + +> Dror Matalon wrote: +> +>> I've read Matt Dillon's discussion about the freebsd VM at +>> http://www.daemonnews.org/200001/freebsd_vm.html and I didn't see him +>> saying that Freebsd uses all the free RAM for disk cache. Would you care +>> to provide a URL pointing to that? +> +> +> +Quoting from http://www.daemonnews.org/200001/freebsd_vm.html : + +* +When To Free a Page* + +Since the VM system uses all available memory for disk caching, there +are usually very few truly-free pages... + + +Got to say - a very interesting discussion you have all being having, I +am now quite confused about what those vfs.*buf* variables actually do... + +Please feed back any clarfications from the FreeBSD experts to this list! + +regards + +Mark + + +From pgsql-performance-owner@postgresql.org Mon Mar 1 03:40:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 79DCBD1DF91 + for ; + Mon, 1 Mar 2004 07:40: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 14881-06 + for ; + Mon, 1 Mar 2004 03:39:50 -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 2F410D1E950 + for ; + Mon, 1 Mar 2004 03:39:49 -0400 (AST) +Received: from rlx11.zapatec.com (rlx11.pr.zapatec.com [192.168.1.132]) + by rlx13.zapatec.com (Postfix) with ESMTP id C88E8A941 + for ; + Sun, 29 Feb 2004 23:39:49 -0800 (PST) +Received: (from dror@localhost) + by rlx11.zapatec.com (8.12.3/8.12.3/Submit) id i217dnpb017591 + for pgsql-performance@postgresql.org; + Sun, 29 Feb 2004 23:39:49 -0800 (PST) (envelope-from dror) +Date: Sun, 29 Feb 2004 23:39:48 -0800 +From: Dror Matalon +To: pgsql-performance@postgresql.org +Subject: Re: FreeBSD config +Message-ID: <20040301073948.GC87033@rlx11.zapatec.com> +References: <20040226180345.GU26787@rlx11.zapatec.com> + + <20040226191616.GA26787@rlx11.zapatec.com> + <20040226230606.GG49146@smtp.k12us.com> + <20040226234246.GN26787@rlx11.zapatec.com> + <403EEEB8.3080807@frodo.hserus.net> + <4042E6B2.1060906@paradise.net.nz> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4042E6B2.1060906@paradise.net.nz> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/2 +X-Sequence-Number: 5858 + +On Mon, Mar 01, 2004 at 08:30:58PM +1300, Mark Kirkwood wrote: +> +> +> Shridhar Daithankar wrote: +> +> >Dror Matalon wrote: +> > +> >>I've read Matt Dillon's discussion about the freebsd VM at +> >>http://www.daemonnews.org/200001/freebsd_vm.html and I didn't see him +> >>saying that Freebsd uses all the free RAM for disk cache. Would you care +> >>to provide a URL pointing to that? +> > +> > +> > + +I noticed this passage too, but ... +> Quoting from http://www.daemonnews.org/200001/freebsd_vm.html : +> +> * +> When To Free a Page* +> +> Since the VM system uses all available memory for disk caching, there + ^^^^^^^^^^^^^ + +The VM system, as you can see from the article, is focused on paging and +caching the programs and program data. Is the cache for disk reads and +writes thrown into the mix as well? + +> are usually very few truly-free pages... +> + +> +> Got to say - a very interesting discussion you have all being having, I +> am now quite confused about what those vfs.*buf* variables actually do... + +Same here. + +> +> Please feed back any clarfications from the FreeBSD experts to this list! +> +> regards +> +> Mark +> + +-- +Dror Matalon +Zapatec Inc +1700 MLK Way +Berkeley, CA 94709 +http://www.fastbuzz.com +http://www.zapatec.com + +From pgsql-performance-owner@postgresql.org Mon Mar 1 04:18:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C025D1E96D + for ; + Mon, 1 Mar 2004 08:18: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 20556-09 + for ; + Mon, 1 Mar 2004 04:18:16 -0400 (AST) +Received: from linda-3.paradise.net.nz (bm-3a.paradise.net.nz [202.0.58.22]) + by svr1.postgresql.org (Postfix) with ESMTP id ADEDFD1E952 + for ; + Mon, 1 Mar 2004 04:18:14 -0400 (AST) +Received: from smtp-2.paradise.net.nz (smtp-2a.paradise.net.nz [202.0.32.195]) + by linda-3.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0HTW005YE1QF2Z@linda-3.paradise.net.nz> for + pgsql-performance@postgresql.org; Mon, 01 Mar 2004 21:18:15 +1300 (NZDT) +Received: from paradise.net.nz + (203-79-100-108.adsl.paradise.net.nz [203.79.100.108]) + by smtp-2.paradise.net.nz (Postfix) with ESMTP id F312F9E2BF; Mon, + 01 Mar 2004 21:18:14 +1300 (NZDT) +Date: Mon, 01 Mar 2004 21:19:31 +1300 +From: Mark Kirkwood +Subject: Re: FreeBSD config +In-reply-to: <20040301073948.GC87033@rlx11.zapatec.com> +To: Dror Matalon +Cc: pgsql-performance@postgresql.org +Message-id: <4042F213.7040106@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.5) Gecko/20031213 +References: <20040226180345.GU26787@rlx11.zapatec.com> + + <20040226191616.GA26787@rlx11.zapatec.com> + <20040226230606.GG49146@smtp.k12us.com> + <20040226234246.GN26787@rlx11.zapatec.com> + <403EEEB8.3080807@frodo.hserus.net> + <4042E6B2.1060906@paradise.net.nz> + <20040301073948.GC87033@rlx11.zapatec.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/3 +X-Sequence-Number: 5859 + + + +>I noticed this passage too, but ... +> +> +>>Quoting from http://www.daemonnews.org/200001/freebsd_vm.html : +>> +>>* +>>When To Free a Page* +>> +>>Since the VM system uses all available memory for disk caching, there +>> +>> +> ^^^^^^^^^^^^^ +> +>The VM system, as you can see from the article, is focused on paging and +>caching the programs and program data. Is the cache for disk reads and +>writes thrown into the mix as well? +> +> +> +Yes - that is the real question. The following link : + +http://www.freebsd.org/doc/en_US.ISO8859-1/books/arch-handbook/vm-cache.html + +and the few "next" pages afterward talk about a unified buffer cache i.e +file buffer cache is part of the KVM system which is part of the VM +system - but this does not seem to preclude those vfs.*buf* variables +limiting the size of the file buffer cache... hmm ... so no real +decrease of confusion at this end.. :-) + +Mark + + + +From pgsql-performance-owner@postgresql.org Mon Mar 1 10:35:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 804ABD1E8CF + for ; + Mon, 1 Mar 2004 14:35: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 44491-02 + for ; + Mon, 1 Mar 2004 10:35:01 -0400 (AST) +Received: from fep01-mail.bloor.is.net.cable.rogers.com + (fep01-mail.bloor.is.net.cable.rogers.com [66.185.86.71]) + by svr1.postgresql.org (Postfix) with ESMTP id 151D9D1E8FB + for ; + Mon, 1 Mar 2004 10:34:57 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep01-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040301143447.BQJ230350.fep01-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Mon, 1 Mar 2004 09:34:47 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id A62BD40D3; Mon, 1 Mar 2004 09:34:57 -0500 (EST) +Date: Mon, 1 Mar 2004 09:34:57 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: compiling 7.4.1 on Solaris 9 +Message-ID: <20040301143457.GC8345@phlogiston.dyndns.org> +Mail-Followup-To: 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-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep01-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Mon, + 1 Mar 2004 09:34:47 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/4 +X-Sequence-Number: 5860 + +On Thu, Feb 26, 2004 at 12:46:23PM +0000, teknokrat wrote: +> I've read about the place. Would using -O3 be an improvement? + +In my experience, it's not only not an improvement, it sometimes +breaks the code. That's on 8, though, not 9. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +The plural of anecdote is not data. + --Roger Brinner + +From pgsql-performance-owner@postgresql.org Mon Mar 1 12:31:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B2218D1DD65 + for ; + Mon, 1 Mar 2004 16:31: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 89147-08 + for ; + Mon, 1 Mar 2004 12:30:53 -0400 (AST) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id EE69DD1DD41 + for ; + Mon, 1 Mar 2004 12:30:48 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C3FFA2.D3DD1332" +Subject: Scaling further up +Date: Mon, 1 Mar 2004 10:35:30 -0500 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509802F@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Scaling further up +Thread-Index: AcP/otPU/DsPePFgS+ekCHEdz1VRMA== +From: "Anjan Dave" +To: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/5 +X-Sequence-Number: 5861 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C3FFA2.D3DD1332 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + +All: +=20 +We have a Quad-Intel XEON 2.0GHz (1MB cache), 12GB memory, running RH9, +PG 7.4.0. There's an internal U320, 10K RPM RAID-10 setup on 4 drives. +=20 +We are expecting a pretty high load, a few thousands of 'concurrent' +users executing either select, insert, update, statments. +=20 +What is the next step up in terms of handling very heavy loads? +Clustering?=20 +=20 +Are there any standard, recommended clustering options? +=20 +How about this? http://c-jdbc.objectweb.org +=20 +=20 +Also, in terms of hardware, overall, what benefits more, a SunFire 880 +(6 or 8 CPUs, lots of RAM, internal FC Drives) type of machine, or an +IA-64 architecture? +=20 +Appreciate any inputs, +=20 +Thanks, +Anjan +************************************************************************ +**=20 + +This e-mail and any files transmitted with it are intended for the use +of the addressee(s) only and may be confidential and covered by the +attorney/client and other privileges. If you received this e-mail in +error, please notify the sender; do not disclose, copy, distribute, or +take any action in reliance on the contents of this information; and +delete it from your system. Any other use of this e-mail is prohibited. + +=20 + +------_=_NextPart_001_01C3FFA2.D3DD1332 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + +Message + + + +
All:
+
 
+
We have&n= +bsp;a=20 +Quad-Intel XEON 2.0GHz (1MB cache), 12GB memory, running RH9, PG 7.4.0. The= +re's=20 +an internal U320, 10K RPM RAID-10 setup on 4 drives.
+
 
+
We are ex= +pecting=20 +a pretty high load, a few thousands of 'concurrent' users executi= +ng=20 +either select, insert, update, statments.
+
 
+
What is t= +he next=20 +step up in terms of  handling very heavy loads? Clustering?=20 +
+
 
+
Are there= + any=20 +standard, recommended clustering options?
+
 
+
How about= + this? http://c-jdbc.objectweb.org
+
 
+
Also, in = +terms of=20 +hardware, overall, what benefits more, a SunFire 880 (6 or 8 CPUs, lots of = +RAM,=20 +internal FC Drives) type of machine, or an IA-64=20 +architecture?
+
 
+
Appreciat= +e any=20 +inputs,
+
 
+
Thanks,
Anjan
+
+

************************************************************************= +**=20 +

+

This e-mail and any files transmitted with it are intended for the use o= +f the=20 +addressee(s) only and may be confidential and covered by the attorney/clien= +t and=20 +other privileges. If you received this e-mail in error, please notify the= +=20 +sender; do not disclose, copy, distribute, or take any action in reliance o= +n the=20 +contents of this information; and delete it from your system. Any other use= + of=20 +this e-mail is prohibited.

+
 
+=00 +------_=_NextPart_001_01C3FFA2.D3DD1332-- + +From pgsql-performance-owner@postgresql.org Mon Mar 1 12:41:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BE856D1DD11 + for ; + Mon, 1 Mar 2004 16:41: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 98120-05 + for ; + Mon, 1 Mar 2004 12:41:36 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 57373D1DD0C + for ; + Mon, 1 Mar 2004 12:41:35 -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 i21Gcrsw025556; + Mon, 1 Mar 2004 09:38:53 -0700 (MST) +Date: Mon, 1 Mar 2004 09:26:50 -0700 (MST) +From: "scott.marlowe" +To: Ivan Voras +Cc: +Subject: Re: Slow query +In-Reply-To: <403B4EDE.7020907@fer.hr> +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: 200403/6 +X-Sequence-Number: 5862 + +On Tue, 24 Feb 2004, Ivan Voras wrote: + +> -> Nested Loop (cost=1.04..788.76 rows=3 width=500) (actual +> time=4078.85..20185.89 rows=38999 loops=1) +> -> Nested Loop (cost=1.04..771.27 rows=3 width=485) +> (actual time=4078.71..14673.27 rows=38999 loops=1) +> -> Nested Loop (cost=0.00..752.16 rows=195 +> width=288) (actual time=4078.20..6702.17 rows=38999 loops=1) +> -> Nested Loop +> (cost=0.00..748.72 rows=195 width=184) (actual time=0.21..3197.16 +> rows=38999 loops=1) + +Note those nested loops up there. They think that you are going to be +operating on 3,3,195, and 195 rows respectively, when they actually are +operating on 38999, 38999, 38999, and 38999 in reality. + +set enable_nestloop = off + +and see if that helps. If so, see if altering the responsible columns +default stats to something higher (100 is a good start) and reanalyze to +see if you get a better plan. As long as those estimates are that far +off, you're gonna get a poorly performing query when the planner is +allowed to use nested loops. + + +From pgsql-performance-owner@postgresql.org Mon Mar 1 13:30:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DC65FD1BB15 + for ; + Mon, 1 Mar 2004 17:30:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 11879-07 + for ; + Mon, 1 Mar 2004 13:30:44 -0400 (AST) +Received: from mail.dsvr.co.uk (mail.dsvr.co.uk [212.69.192.8]) + by svr1.postgresql.org (Postfix) with ESMTP id 25524D1BA9F + for ; + Mon, 1 Mar 2004 13:30:43 -0400 (AST) +Received: from [212.69.216.20] (helo=dsvr.net) + by mail.dsvr.co.uk with esmtp (Exim 4.30) id 1AxrFa-0002WD-8b + for pgsql-performance@postgresql.org; Mon, 01 Mar 2004 17:30:42 +0000 +Message-ID: <40437341.8060105@dsvr.net> +Date: Mon, 01 Mar 2004 17:30:41 +0000 +From: Rob Fielding +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: WAL Optimisation - configuration and usage +References: <4040E08C.1040408@dsvr.net> <1078015971.24316.9.camel@jester> + <4041E430.7010109@dsvr.net> +In-Reply-To: <4041E430.7010109@dsvr.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: 200403/7 +X-Sequence-Number: 5863 + + +Further update to my WAL experimentation. pg_xlog files have increased +to 81, and checking today up to 84. Currently nothing much going on with +the server save a background process running a select every 30 seconds +with almost no impact (according to IO from vmstats). + +This in itself is a good sign - an improvement on running last week, but +I'd still like to get clarification on WAL file usage if possible. + +Log file tailing has nothing more interesting than a whole set of +"recycled transaction log file" entries : + +2004-03-01 16:01:55 DEBUG: recycled transaction log file 0000007100000017 +2004-03-01 16:07:01 DEBUG: recycled transaction log file 0000007100000018 +2004-03-01 16:17:14 DEBUG: recycled transaction log file 0000007100000019 +2004-03-01 16:22:20 DEBUG: recycled transaction log file 000000710000001A +2004-03-01 16:32:31 DEBUG: recycled transaction log file 000000710000001B +2004-03-01 16:37:36 DEBUG: recycled transaction log file 000000710000001C +2004-03-01 16:47:48 DEBUG: recycled transaction log file 000000710000001D +2004-03-01 16:52:54 DEBUG: recycled transaction log file 000000710000001E +2004-03-01 17:03:05 DEBUG: recycled transaction log file 000000710000001F + +Looks kinda automated, but the times aren't quite even at around 6-10 +minutes apart. + +cheers, +-- + +Rob Fielding +rob@dsvr.net + +www.dsvr.co.uk Development Designer Servers Ltd + +From pgsql-performance-owner@postgresql.org Mon Mar 1 16:54:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B6713D1E9B9 + for ; + Mon, 1 Mar 2004 20:54: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 97144-01 + for ; + Mon, 1 Mar 2004 16:54:21 -0400 (AST) +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by svr1.postgresql.org (Postfix) with ESMTP id 970B2D1E9AC + for ; + Mon, 1 Mar 2004 16:54:19 -0400 (AST) +Received: from ALGOL.sollentuna.se (janus-en.sollentuna.se [195.84.163.194]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id ACD448F2A3; Mon, 1 Mar 2004 21:54:20 +0100 (CET) +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +Subject: Re: Scaling further up +Date: Mon, 1 Mar 2004 21:54:20 +0100 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCE34B351@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Scaling further up +Thread-Index: AcP/otPU/DsPePFgS+ekCHEdz1VRMAALBG+A +From: "Magnus Hagander" +To: "Anjan Dave" , + +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/8 +X-Sequence-Number: 5864 + +> All: +>=20 +> We have a Quad-Intel XEON 2.0GHz (1MB cache), 12GB memory, running +RH9, PG 7.4.0. There's=20 +> an internal U320, 10K RPM RAID-10 setup on 4 drives. +>=20 +> We are expecting a pretty high load, a few thousands of 'concurrent' +users executing either=20 +> select, insert, update, statments. + +> What is the next step up in terms of handling very heavy loads? +Clustering?=20 + +I'd look at adding more disks first. Depending on what type of query +load you get, that box sounds like it will be very much I/O bound. More +spindles =3D more parallell operations =3D faster under load. Consider +adding 15KRPM disks as well, they're not all that much more expensive, +and should give you better performance than 10KRPM. + +Also, make sure you put your WAL disks on a separate RAIDset if possible +(not just a separate partition on existing RAIDset). + +Finally, if you don't already have it, look for a battery-backed RAID +controller that can do writeback-cacheing, and enable that. (Don't even +think about enabling it unless it's battery backed!) And add as much RAM +as you can to that controller. + + +//Magnus + +From pgsql-performance-owner@postgresql.org Mon Mar 1 17:57:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E8ADD1E926 + for ; + Mon, 1 Mar 2004 21:57: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 17152-07 + for ; + Mon, 1 Mar 2004 17:57:41 -0400 (AST) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B9DBD1D2BA + for ; + Mon, 1 Mar 2004 17:57:38 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Scaling further up +Date: Mon, 1 Mar 2004 16:02:27 -0500 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C8DC@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Scaling further up +Thread-Index: AcP/otPU/DsPePFgS+ekCHEdz1VRMAALBG+AAABAkoA= +From: "Anjan Dave" +To: "Magnus Hagander" , +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/9 +X-Sequence-Number: 5865 + +For the disks part - I am looking at a SAN implementation, and I will be +planning a separate RAID group for the WALs. + +The controller is a PERC, with 128MB cache, and I think it is writeback. + +Other than the disks, I am curious what other people are using in terms +of the horsepower needed. The Quad server has been keeping up, but we +are expecting quite high loads in the near future, and I am not sure if +just by having the disks on a high-end storage will do it. + +Thanks, +Anjan + + +-----Original Message----- +From: Magnus Hagander [mailto:mha@sollentuna.net]=20 +Sent: Monday, March 01, 2004 3:54 PM +To: Anjan Dave; pgsql-performance@postgresql.org +Subject: RE: [PERFORM] Scaling further up + + +> All: +>=20 +> We have a Quad-Intel XEON 2.0GHz (1MB cache), 12GB memory, running +RH9, PG 7.4.0. There's=20 +> an internal U320, 10K RPM RAID-10 setup on 4 drives. +>=20 +> We are expecting a pretty high load, a few thousands of 'concurrent' +users executing either=20 +> select, insert, update, statments. + +> What is the next step up in terms of handling very heavy loads? +Clustering?=20 + +I'd look at adding more disks first. Depending on what type of query +load you get, that box sounds like it will be very much I/O bound. More +spindles =3D more parallell operations =3D faster under load. Consider +adding 15KRPM disks as well, they're not all that much more expensive, +and should give you better performance than 10KRPM. + +Also, make sure you put your WAL disks on a separate RAIDset if possible +(not just a separate partition on existing RAIDset). + +Finally, if you don't already have it, look for a battery-backed RAID +controller that can do writeback-cacheing, and enable that. (Don't even +think about enabling it unless it's battery backed!) And add as much RAM +as you can to that controller. + + +//Magnus + +From pgsql-performance-owner@postgresql.org Mon Mar 1 20:28:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 50022D1E962 + for ; + Tue, 2 Mar 2004 00:28: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 57557-09 + for ; + Mon, 1 Mar 2004 20:28:12 -0400 (AST) +Received: from cmailm4.svr.pol.co.uk (cmailm4.svr.pol.co.uk [195.92.193.211]) + by svr1.postgresql.org (Postfix) with ESMTP id 52760D1E959 + for ; + Mon, 1 Mar 2004 20:28:08 -0400 (AST) +Received: from modem-2651.lion.dialup.pol.co.uk ([217.135.170.91] + helo=LaptopDellXP) by cmailm4.svr.pol.co.uk with esmtp (Exim 4.14) + id 1AxxlZ-0003bQ-Ex; Tue, 02 Mar 2004 00:28:09 +0000 +Reply-To: +From: "Simon Riggs" +To: "'Rob Fielding'" , + +Subject: Re: WAL Optimisation - configuration and usage +Date: Tue, 2 Mar 2004 00:27:51 -0000 +Organization: 2nd Quadrant +Message-ID: <003501c3ffed$33422210$5baa87d9@LaptopDellXP> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +Importance: Normal +In-Reply-To: <4040E08C.1040408@dsvr.net> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/10 +X-Sequence-Number: 5866 + +>Rob Fielding wrote: +> My focus today has been on WAL - I've not looked at WAL before. By +> increasing the settings thus : +> +> wal_buffers = 64 # need to determin WAL usage +> wal_files = 64 # range 0-64 +> wal_sync_method = fsync # the default varies across platforms: +> wal_debug = 0 # range 0-16 +> +> # hopefully this should see less LogFlushes per LogInsert - use more +WAL +> though. +> commit_delay = 10000 # range 0-100000 +> commit_siblings = 2 # range 1-1000 +> checkpoint_segments = 16 # in logfile segments (16MB each), min 1 +> checkpoint_timeout = 300 # in seconds, range 30-3600 +> fsync = true + +> But I think we can get more out of this as the above setting were +picked +> from thin air and my concern here is being able to determin WAL file +> usage and if the system is caught out on the other extreme that we're +> not commiting fast enough. Currently I've read that WAL files +shouldn't +> be more than 2*checkpoint_segments+1 however my pg_xlog directory +> contains 74 files. This suggests I'm using more logfiles than I +should. +> Also I'm not sure what wal_buffers really should be set to. + +As Richard Huxton says, we're all learning...I'm looking at WAL logic +for other reasons right now... + +This is based upon my reading of the code; I think the manual contains +at least one confusion that has not assisted your understanding (or +mine): + +The WAL files limit of 2*checkpoint_segments+1 refers to the number of +files allocated-in-advance of the current log, not the total number of +files in use. pg uses a cycle of logs, reusing older ones when all the +transactions in those log files have been checkpointed. The limit is set +to allow checkpoint to release segments and have them all be reused at +once. Pg stores them up for use again later when workload hots up again. + +If it cannot recycle a file because there is a still-current txn on the +end of the cycle, then it will allocate a new file and use this instead, +but still keeping everything in a cycle. Thus if transactions are +particularly long running, then the number of files in the cycle will +grow. So overall, normal behaviour so far. I don't think there's +anything to worry about in having that many files in your xlog cycle. + +That behaviour is usually seen with occasional long running txns. When a +long running transaction is over, pg will try to reduce the number of +files in the cycle until its back to target. + +You seem to be reusing one file in the cycle every 10 mins - this is +happening as the result of a checkpoint timeout - "kinda automated" as +you say. [A checkpoint is the only time you can get the messages you're +getting] At one file per checkpoint, it will take 16*2+1=33 +checkpoints*10 mins = 5 hours before it hits the advance allocation file +limit and then starts to reduce number of files. That's why they appear +to stay constant... + +If you want to check whether this is correct, manually issue a number of +CHECKPOINT statements. The messages should change from "recycled" to +"removing" transaction log file once you've got to 33 checkpoints - the +number of WAL log files should start to go down also? If so, then +there's nothing too strange going on, just pg being a little slow in +reducing the number of wal log files. + +So, it seems that you are running occasional very long transactions. +During that period you run up to 60-80 wal files. That's just on the +edge of your wal_buffers limit, which means you start to write wal +quicker than you'd like past that point. Your checkpoint_timeout is 300 +seconds, but a checkpoint will also be called every checkpoint_segments, +or currently every 16 wal files. Since you go as high as 60-80 then you +are checkpointing 4-5 times during the heavy transaction period - +assuming it's all one block of work. In the end, each checkpoint is +causing a huge I/O storm, during which not much work happens. + +I would suggest that you reduce the effect of checkpointing by either: +- re-write app to do scan deletes in smaller chunks in quieter periods +or +- increase checkpoint_segments to 128, though this may effect your +recoverability + +You can of course only do so much with the memory available to you. If +you increase one allocation of memory, you may have to reduce another +parameter and that may be counter productive. + +[An alternative view is that you should go for more frequent, not less +frequent checkpoints in this situation, smoothing out the effect of the +checkpoints, rather than trying to avoid them at all. On the other hand, +that approach also increases total WAL log volume, which means you'll +make poor use of I/O and memory buffering. I'd stay high.] + +However, I'm not sure +- why checkpoint interval of 300 secs causes them to happen every 10 +mins in quieter periods; is that an occaisional update occurring? +- why checkpoint only releases single Wal file each time - but that +maybe me just reading the code incorrectly. + +Please set WAL_DEBUG to 1 so we can see a bit more info: thanks. + +> Can I get any feedback on this ? How to look into pg's WAL usage would +> be what I'm looking for. BTW this is an old install I'm afraid 7.2.2 - +> it's been impossible to upgrade up until now because it's been too +slow. +> I have moved the pg_xlog onto the root SCSI disk - it doesn't appear +to +> have made a huge difference but it could be on the same cable. + +My advice is don't touch WAL_SYNC_METHOD... + +I **think** the WAL behaviour is still the same in 7.4.1, so no rush to +upgrade on that account - unless you're using temporary tables.... + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Mon Mar 1 21:06:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AD1EED1D182 + for ; + Tue, 2 Mar 2004 01:06: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 69744-06 + for ; + Mon, 1 Mar 2004 21:06:03 -0400 (AST) +Received: from kserver17.erfurt12.de (unknown [80.190.233.41]) + by svr1.postgresql.org (Postfix) with ESMTP id 537ECD1DD39 + for ; + Mon, 1 Mar 2004 21:05:59 -0400 (AST) +Received: by kserver17.erfurt12.de (Postfix, from userid 642) + id DA8D55A816E; Tue, 2 Mar 2004 01:49:03 +0100 (CET) +To: pgsql-performance@postgresql.org +From: postgres@countup.de +Subject: Re: Select-Insert-Query +Content-Type: text/html; charset=iso-8859-1; +Message-Id: <20040302004903.DA8D55A816E@kserver17.erfurt12.de> +Date: Tue, 2 Mar 2004 01:49:03 +0100 (CET) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/12 +X-Sequence-Number: 5868 + +Hi, +
+
nobody has an idea? :-( +
+
-----Urspr�ngliche Nachricht----- +
Von: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] Im Auftrag von postgres@countup.de +
Gesendet: Freitag, 27. Februar 2004 17:53 +
An: pgsql-performance@postgresql.org +
Betreff: [PERFORM] Select-Insert-Query +
+
Hi, +
+
what is the most performant way to select for example the first 99 rows of a table and insert them into another table... +
+
at the moment i do this: +
+
for userrecord in select * from table where account_id = a_account_id and counter_id = userrecord.counter_id and visitortable_id between a_minid and a_maxid limit 99 loop +
insert into lastusers (account_id, counter_id, date, ip, hostname) values(a_account_id,userrecord.counter_id,userrecord.date + ,userrecord.ip,userrecord.hostname); +
end loop; +
+
i think "limit" is a performance killer, is that right? but what to do instead +
+
thanks +
bye +
+ +From pgsql-performance-owner@postgresql.org Mon Mar 1 21:01:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 33222D1DD0C + for ; + Tue, 2 Mar 2004 01:01: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 69998-02 + for ; + Mon, 1 Mar 2004 21:01:34 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 82A2FD1BB95 + for ; + Mon, 1 Mar 2004 21:01:30 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2211Ug3024769; + Mon, 1 Mar 2004 20:01:30 -0500 (EST) +To: simon@2ndquadrant.com +Cc: "'Rob Fielding'" , pgsql-performance@postgresql.org +Subject: Re: WAL Optimisation - configuration and usage +In-reply-to: <003501c3ffed$33422210$5baa87d9@LaptopDellXP> +References: <003501c3ffed$33422210$5baa87d9@LaptopDellXP> +Comments: In-reply-to "Simon Riggs" + message dated "Tue, 02 Mar 2004 00:27:51 +0000" +Date: Mon, 01 Mar 2004 20:01:29 -0500 +Message-ID: <24768.1078189289@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/11 +X-Sequence-Number: 5867 + +"Simon Riggs" writes: +> - why checkpoint interval of 300 secs causes them to happen every 10 +> mins in quieter periods; is that an occaisional update occurring? + +There is code in there to suppress a checkpoint if no WAL-loggable +activity has happened since the last checkpoint. Not sure if that's +relevant to the issue or not though. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 1 21:10:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7407CD1DD41 + for ; + Tue, 2 Mar 2004 01:10: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 72863-04 + for ; + Mon, 1 Mar 2004 21:10:55 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id E1877D1DD0C + for ; + Mon, 1 Mar 2004 21:10:51 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4523548; Mon, 01 Mar 2004 17:12:03 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: , "'Rob Fielding'" , + +Subject: Re: WAL Optimisation - configuration and usage +Date: Mon, 1 Mar 2004 17:10:07 -0800 +User-Agent: KMail/1.5.4 +References: <003501c3ffed$33422210$5baa87d9@LaptopDellXP> +In-Reply-To: <003501c3ffed$33422210$5baa87d9@LaptopDellXP> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403011710.07289.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/13 +X-Sequence-Number: 5869 + +Simon, + +> Please set WAL_DEBUG to 1 so we can see a bit more info: thanks. + +I'm pretty sure that WAL_DEBUG requires a compile-time option. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Mon Mar 1 21:13:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5333ED1D182 + for ; + Tue, 2 Mar 2004 01:13: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 71120-07 + for ; + Mon, 1 Mar 2004 21:13:14 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 68614D1BB95 + for ; + Mon, 1 Mar 2004 21:13:10 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4523559; Mon, 01 Mar 2004 17:14:23 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Anjan Dave" , "Magnus Hagander" , + +Subject: Re: Scaling further up +Date: Mon, 1 Mar 2004 17:12:21 -0800 +User-Agent: KMail/1.5.4 +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C8DC@vt-pe2550-001.vantage.vantage.com> +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C8DC@vt-pe2550-001.vantage.vantage.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403011712.21802.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/14 +X-Sequence-Number: 5870 + +Anjan, + +> Other than the disks, I am curious what other people are using in terms +> of the horsepower needed. The Quad server has been keeping up, but we +> are expecting quite high loads in the near future, and I am not sure if +> just by having the disks on a high-end storage will do it. + +Do a performance analysis of RH9. My experience with RH on Xeon has been +quite discouraging lately, and I've been recommending swapping stock kernels +for the RH kernel. + +Of course, if this is RHES, rather than the standard, then test & talk to RH +instead. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Mon Mar 1 23:21:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D7738D1B4C3 + for ; + Tue, 2 Mar 2004 03:21: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 93826-08 + for ; + Mon, 1 Mar 2004 23:20:52 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D5A2D1B4E4 + for ; + Mon, 1 Mar 2004 23:20:34 -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 i223KR1Y089626 + for ; Tue, 2 Mar 2004 03:20:30 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i222oTDq080022 + for pgsql-performance@postgresql.org; Tue, 2 Mar 2004 02:50:29 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Scaling further up +Date: Mon, 01 Mar 2004 21:43:18 -0500 +Organization: cbbrowne Computing Inc +Lines: 26 +Message-ID: +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C8DC@vt-pe2550-001.vantage.vantage.com> + <200403011712.21802.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through + Obscurity, + linux) +Cancel-Lock: sha1:RkjEDS6ayqOlxzKGaUAD8JmLxVg= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/15 +X-Sequence-Number: 5871 + +After a long battle with technology, josh@agliodbs.com (Josh Berkus), an earthling, wrote: +>> Other than the disks, I am curious what other people are using in +>> terms of the horsepower needed. The Quad server has been keeping +>> up, but we are expecting quite high loads in the near future, and I +>> am not sure if just by having the disks on a high-end storage will +>> do it. +> +> Do a performance analysis of RH9. My experience with RH on Xeon has +> been quite discouraging lately, and I've been recommending swapping +> stock kernels for the RH kernel. + +By that, you mean that you recommend that RHAT kernels be replaced by +"stock" ones? + +> Of course, if this is RHES, rather than the standard, then test & +> talk to RH instead. + +If you're spending the money, better demand value from the vendor... + +(And if RHAT is going to charge the big bucks, they'll have to provide +service...) +-- +(reverse (concatenate 'string "gro.gultn" "@" "enworbbc")) +http://www.ntlug.org/~cbbrowne/rdbms.html +"I take it all back. Microsoft Exchange is RFC compliant. +RFC 1925, point three." -- Author unknown + +From pgsql-performance-owner@postgresql.org Tue Mar 9 19:35:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FCC4D1BB43 + for ; + Tue, 2 Mar 2004 11:20: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 25278-03 + for ; + Tue, 2 Mar 2004 07:20:39 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 08069D1BA93 + for ; + Tue, 2 Mar 2004 07:20: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 i22BKY1Y065182 + for ; Tue, 2 Mar 2004 11:20:34 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i22AsLpR059319 + for pgsql-performance@postgresql.org; Tue, 2 Mar 2004 10:54:21 GMT +From: teknokrat +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: compiling 7.4.1 on Solaris 9 +Date: Tue, 02 Mar 2004 10:54:23 +0000 +Organization: Hub.Org Networking Services +Lines: 17 +Message-ID: +References: + <20040301143457.GC8345@phlogiston.dyndns.org> +Reply-To: teknokrat@yahoo.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0+) Gecko/20020518 +X-Accept-Language: en, en-us, ko +In-Reply-To: <20040301143457.GC8345@phlogiston.dyndns.org> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/116 +X-Sequence-Number: 5972 + +Andrew Sullivan wrote: +> On Thu, Feb 26, 2004 at 12:46:23PM +0000, teknokrat wrote: +> +>>I've read about the place. Would using -O3 be an improvement? +> +> +> In my experience, it's not only not an improvement, it sometimes +> breaks the code. That's on 8, though, not 9. +> +> A +> + +thanks, i remember a thread about problems with flags passed to gcc on +solaris. I was wondering if there had been any resolution and if the +defaults for 7.4 are considered Ok. + +thanks + +From pgsql-performance-owner@postgresql.org Tue Mar 2 14:57:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 22126D1B470 + for ; + Tue, 2 Mar 2004 18: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 94772-03 + for ; + Tue, 2 Mar 2004 14:57:35 -0400 (AST) +Received: from redhotpenguin.com (c-24-7-88-83.client.comcast.net + [24.7.88.83]) + by svr1.postgresql.org (Postfix) with ESMTP id A2EC7D1BB43 + for ; + Tue, 2 Mar 2004 14:57:31 -0400 (AST) +Received: (qmail 7013 invoked by uid 506); 2 Mar 2004 18:57:30 -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.2/5.0):. + Processed in 1.877205 secs); 02 Mar 2004 18:57:30 -0000 +Received: from unknown (HELO harpua.redhotpenguin.com) + (fred@redhotpenguin.com@192.168.0.3) + by 192.168.0.2 with RC4-MD5 encrypted SMTP; 2 Mar 2004 18:57:28 -0000 +Subject: Re: Scaling further up +From: Fred Moyer +Reply-To: fred@redhotpenguin.com +To: William Yu , Anjan Dave +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509802F@vt-pe2550-001.vantage.vantage.com> + +Content-Type: text/plain +Organization: Red Hot Penguin Consulting LLC +Message-Id: <1078225047.2707.67.camel@harpua.redhotpenguin.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Tue, 02 Mar 2004 10:57:27 +0000 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/18 +X-Sequence-Number: 5874 + +On Tue, 2004-03-02 at 17:42, William Yu wrote: +> Anjan Dave wrote: +> > We have a Quad-Intel XEON 2.0GHz (1MB cache), 12GB memory, running RH9, +> > PG 7.4.0. There's an internal U320, 10K RPM RAID-10 setup on 4 drives. +> > +> > We are expecting a pretty high load, a few thousands of 'concurrent' +> > users executing either select, insert, update, statments. +> +> The quick and dirty method would be to upgrade to the recently announced +> 3GHz Xeon MPs with 4MB of L3. My semi-educated guess is that you'd get +> another +60% there due to the huge L3 hiding the Xeon's shared bus penalty. + +If you are going to have thousands of 'concurrent' users you should +seriously consider the 2.6 kernel if you are running Linux or as an +alternative going with FreeBSD. You will need to load test your system +and become an expert on tuning Postgres to get the absolute maximum +performance from each and every query you have. + +And you will need lots of hard drives. By lots I mean dozen(s) in a +raid 10 array with a good controller. Thousands of concurrent users +means hundreds or thousands of transactions per second. I've personally +seen it scale that far but in my opinion you will need a lot more hard +drives and ram than cpu. + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 07:48:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B17D2D1B8B6 + for ; + Tue, 2 Mar 2004 11:48: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 34741-04 + for ; + Tue, 2 Mar 2004 07:48:15 -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 11FABD1B476 + for ; + Tue, 2 Mar 2004 07:48:06 -0400 (AST) +Received: from lfix.demon.co.uk ([80.177.205.209] helo=cerberus.lfix.co.uk) + by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) + id 1Ay8Nh-000GMg-0Y; Tue, 02 Mar 2004 11:48:13 +0000 +Received: from localhost ([127.0.0.1]) + by cerberus.lfix.co.uk with esmtp (Exim 4.30) + id 1Ay8Na-0003tb-8I; Tue, 02 Mar 2004 11:48:06 +0000 +Subject: Re: Select-Insert-Query +From: Oliver Elphick +Reply-To: olly@lfix.co.uk +To: postgres@countup.de +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20040302004903.DA8D55A816E@kserver17.erfurt12.de> +References: <20040302004903.DA8D55A816E@kserver17.erfurt12.de> +Content-Type: text/plain +Organization: LFIX Ltd +Message-Id: <1078228086.13842.60.camel@cerberus.lfix.co.uk> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Tue, 02 Mar 2004 11:48:06 +0000 +Content-Transfer-Encoding: 7bit +X-LFIX-MailScanner: Found to be clean +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/16 +X-Sequence-Number: 5872 + +On Tue, 2004-03-02 at 00:49, postgres@countup.de wrote: + +> what is the most performant way to select for example the first 99 +> rows of a table and insert them into another table... +> +> at the moment i do this: +> +> for userrecord in select * from table where account_id = a_account_id +> and counter_id = userrecord.counter_id and visitortable_id between +> a_minid and a_maxid limit 99 loop + +Using LIMIT without ORDER BY will give a selection that is dependent on +the physical location of rows in the table; this will change whenever +one of them is UPDATEd. + +> insert into lastusers (account_id, counter_id, date, ip, hostname) +> values(a_account_id,userrecord.counter_id,userrecord.date +> ,userrecord.ip,userrecord.hostname); +> end loop; +> +> i think "limit" is a performance killer, is that right? but what to do +> instead + +I'm sure it is the loop that is the killer. Use a query in the INSERT +statement: + +INSERT INTO lastusers (account_id, counter_id, date, ip, hostname) + SELECT * FROM table + WHERE account_id = a_account_id AND + counter_id = userrecord.counter_id AND + visitortable_id between a_minid and a_maxid + ORDER BY date DESC + LIMIT 99; + +-- +Oliver Elphick +LFIX Ltd + + +From pgsql-www-owner@postgresql.org Tue Mar 2 12:41:03 2004 +X-Original-To: pgsql-www-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 557E1D1B9BB + for ; + Tue, 2 Mar 2004 16:41: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 39280-08 + for ; + Tue, 2 Mar 2004 12:40:57 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 5F27BD1B470 + for ; Tue, 2 Mar 2004 12:40:53 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i22Gek325112; + Tue, 2 Mar 2004 11:40:46 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403021640.i22Gek325112@candle.pha.pa.us> +Subject: Re: [PERFORM] Materialized View Summary +In-Reply-To: <200402240811.13013.jgardner@jonathangardner.net> +To: "Jonathan M. Gardner" +Date: Tue, 2 Mar 2004 11:40:46 -0500 (EST) +Cc: PostgreSQL www +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: 200403/15 +X-Sequence-Number: 3831 + + +Can we get this URL added to the techdocs site please? Thanks. + +--------------------------------------------------------------------------- + +Jonathan M. Gardner wrote: +[ PGP not available, raw data follows ] +> -----BEGIN PGP SIGNED MESSAGE----- +> Hash: SHA1 +> +> I've written a summary of my findings on implementing and using +> materialized views in PostgreSQL. I've already deployed eagerly updating +> materialized views on several views in a production environment for a +> company called RedWeek: http://redweek.com/. As a result, some queries +> that were taking longer than 30 seconds to run now run in a fraction of a +> millisecond. +> +> You can view my summary at +> http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html +> +> Comments and suggestions are definitely welcome. +> +> - -- +> Jonathan Gardner +> jgardner@jonathangardner.net +> -----BEGIN PGP SIGNATURE----- +> Version: GnuPG v1.2.3 (GNU/Linux) +> +> iD8DBQFAO3eZqp6r/MVGlwwRAnpEAKC8+/lFyPBbXetPEfFLwgUvJZLCmgCfYlmR +> 0vZmCcbGSNT/m/W8QOIhufk= +> =snCu +> -----END PGP SIGNATURE----- +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> +[ End of raw data] + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-www-owner@postgresql.org Tue Mar 2 12:54:44 2004 +X-Original-To: pgsql-www-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9063BD1B470 + for ; + Tue, 2 Mar 2004 16:54: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 50692-05 + for ; + Tue, 2 Mar 2004 12:54:39 -0400 (AST) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 2D53CD1B906 + for ; Tue, 2 Mar 2004 12:54:38 -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 i22GPRcM032388; + Tue, 2 Mar 2004 11:25:27 -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 i22GsDl02530; + Tue, 2 Mar 2004 11:54:13 -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 FVMAV3RM; Tue, 2 Mar 2004 11:54:11 -0500 +Subject: Re: [PERFORM] Materialized View Summary +From: Robert Treat +To: Bruce Momjian +Cc: "Jonathan M. Gardner" , + PostgreSQL www +In-Reply-To: <200403021640.i22Gek325112@candle.pha.pa.us> +References: <200403021640.i22Gek325112@candle.pha.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 02 Mar 2004 11:54:12 -0500 +Message-Id: <1078246452.3204.123.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/16 +X-Sequence-Number: 3832 + +Already there, under "Technical Guides and Documents", I gave it a new +section "Materialized Views" + +Robert Treat + +On Tue, 2004-03-02 at 11:40, Bruce Momjian wrote: +> +> Can we get this URL added to the techdocs site please? Thanks. +> +> --------------------------------------------------------------------------- +> +> Jonathan M. Gardner wrote: +> [ PGP not available, raw data follows ] +> > -----BEGIN PGP SIGNED MESSAGE----- +> > Hash: SHA1 +> > +> > I've written a summary of my findings on implementing and using +> > materialized views in PostgreSQL. I've already deployed eagerly updating +> > materialized views on several views in a production environment for a +> > company called RedWeek: http://redweek.com/. As a result, some queries +> > that were taking longer than 30 seconds to run now run in a fraction of a +> > millisecond. +> > +> > You can view my summary at +> > http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html +> > +> > Comments and suggestions are definitely welcome. +> > +> > - -- +> > Jonathan Gardner +> > jgardner@jonathangardner.net +> > -----BEGIN PGP SIGNATURE----- +> > Version: GnuPG v1.2.3 (GNU/Linux) +> > +> > iD8DBQFAO3eZqp6r/MVGlwwRAnpEAKC8+/lFyPBbXetPEfFLwgUvJZLCmgCfYlmR +> > 0vZmCcbGSNT/m/W8QOIhufk= +> > =snCu +> > -----END PGP SIGNATURE----- +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 2: you can get off all lists at once with the unregister command +> > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> > +> [ End of raw data] +> +> -- +> Bruce Momjian | http://candle.pha.pa.us +> pgman@candle.pha.pa.us | (610) 359-1001 +> + If your life is a hard drive, | 13 Roberts Road +> + Christ can be your backup. | Newtown Square, Pennsylvania 19073 +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings + +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 13:50:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B0A98D1B8B7 + for ; + Tue, 2 Mar 2004 17:50: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 74101-01 + for ; + Tue, 2 Mar 2004 13:50:37 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id D1194D1B470 + for ; + Tue, 2 Mar 2004 13:50:36 -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 i22Hoa1Y047536 + for ; Tue, 2 Mar 2004 17:50:36 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i22Hg23I045002 + for pgsql-performance@postgresql.org; Tue, 2 Mar 2004 17:42:02 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Scaling further up +Date: Tue, 02 Mar 2004 09:42:03 -0800 +Organization: Hub.Org Networking Services +Lines: 10 +Message-ID: +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509802F@vt-pe2550-001.vantage.vantage.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509802F@vt-pe2550-001.vantage.vantage.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/17 +X-Sequence-Number: 5873 + +Anjan Dave wrote: +> We have a Quad-Intel XEON 2.0GHz (1MB cache), 12GB memory, running RH9, +> PG 7.4.0. There's an internal U320, 10K RPM RAID-10 setup on 4 drives. +> +> We are expecting a pretty high load, a few thousands of 'concurrent' +> users executing either select, insert, update, statments. + +The quick and dirty method would be to upgrade to the recently announced +3GHz Xeon MPs with 4MB of L3. My semi-educated guess is that you'd get +another +60% there due to the huge L3 hiding the Xeon's shared bus penalty. + +From pgsql-performance-owner@postgresql.org Tue Mar 2 16:26:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 56746D1BB6B + for ; + Tue, 2 Mar 2004 20:26: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 25930-02 + for ; + Tue, 2 Mar 2004 16:26:04 -0400 (AST) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id C6314D1BB74 + for ; + Tue, 2 Mar 2004 16:26:00 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Scaling further up +Date: Tue, 2 Mar 2004 14:41:12 -0500 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098039@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Scaling further up +Thread-Index: AcQAiDd+hZ5UlC0nSnOoxL1hVvgSIAABPdNQ +From: "Anjan Dave" +To: , "William Yu" +Cc: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/19 +X-Sequence-Number: 5875 + +"By lots I mean dozen(s) in a raid 10 array with a good controller."=20 + +I believe, for RAID-10, I will need even number of drives. Currently, +the size of the database is about 13GB, and is not expected to grow +exponentially with thousands of concurrent users, so total space is not +of paramount importance compared to performance. + +Does this sound reasonable setup? +10x36GB FC drives on RAID-10 +4x36GB FC drives for the logs on RAID-10 (not sure if this is the +correct ratio)? +1 hotspare +Total=3D15 Drives per enclosure. + +Tentatively, I am looking at an entry-level EMC CX300 product with 2GB +RAID cache, etc. + +Question - Are 73GB drives supposed to give better performance because +of higher number of platters? + +Thanks, +Anjan + + +-----Original Message----- +From: Fred Moyer [mailto:fred@redhotpenguin.com]=20 +Sent: Tuesday, March 02, 2004 5:57 AM +To: William Yu; Anjan Dave +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Scaling further up + + +On Tue, 2004-03-02 at 17:42, William Yu wrote: +> Anjan Dave wrote: +> > We have a Quad-Intel XEON 2.0GHz (1MB cache), 12GB memory, running=20 +> > RH9, +> > PG 7.4.0. There's an internal U320, 10K RPM RAID-10 setup on 4 +drives. +> >=20=20 +> > We are expecting a pretty high load, a few thousands of 'concurrent' +> > users executing either select, insert, update, statments. +>=20 +> The quick and dirty method would be to upgrade to the recently=20 +> announced +> 3GHz Xeon MPs with 4MB of L3. My semi-educated guess is that you'd get + +> another +60% there due to the huge L3 hiding the Xeon's shared bus +penalty. + +If you are going to have thousands of 'concurrent' users you should +seriously consider the 2.6 kernel if you are running Linux or as an +alternative going with FreeBSD. You will need to load test your system +and become an expert on tuning Postgres to get the absolute maximum +performance from each and every query you have. + +And you will need lots of hard drives. By lots I mean dozen(s) in a +raid 10 array with a good controller. Thousands of concurrent users +means hundreds or thousands of transactions per second. I've personally +seen it scale that far but in my opinion you will need a lot more hard +drives and ram than cpu. + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 16:45:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E80D7D1B8B6 + for ; + Tue, 2 Mar 2004 20:45:36 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 25388-06 + for ; + Tue, 2 Mar 2004 16:45:34 -0400 (AST) +Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) + by svr1.postgresql.org (Postfix) with ESMTP id C4FC4D1B567 + for ; + Tue, 2 Mar 2004 16:45:32 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id 6F4083EFE + for ; + Tue, 2 Mar 2004 15:45:32 -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 40327-04-2 for ; + Tue, 2 Mar 2004 15:45:32 -0500 (EST) +Received: from lorax.kcilink.com (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id D729F3EA8 + for ; + Tue, 2 Mar 2004 15:45:31 -0500 (EST) +Received: (from news@localhost) + by lorax.kcilink.com (8.12.9p2/8.12.9/Submit) id i22KjVn7098106 + for pgsql-performance@postgresql.org; + Tue, 2 Mar 2004 15:45:31 -0500 (EST) (envelope-from news) +To: pgsql-performance@postgresql.org +Path: not-for-mail +From: Vivek Khera +Newsgroups: ml.postgres.performance +Subject: Re: FreeBSD config +Date: Tue, 02 Mar 2004 15:45:31 -0500 +Organization: Khera Communications, Inc., Rockville, MD +Lines: 16 +Message-ID: +References: <20040226180345.GU26787@rlx11.zapatec.com> + <20040227054639.H34315-100000@houston.familyhealth.com.au> + <20040226215838.GK26787@rlx11.zapatec.com> + <20040226231013.GH49146@smtp.k12us.com> +NNTP-Posting-Host: yertle.kcilink.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Trace: lorax.kcilink.com 1078260331 79461 65.205.34.180 (2 Mar 2004 20:45:31 + GMT) +X-Complaints-To: daemon@kciLink.com +NNTP-Posting-Date: Tue, 2 Mar 2004 20:45:31 +0000 (UTC) +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + berkeley-unix) +Cancel-Lock: sha1:TnGUP+FfxHi2e+JIru1qQ4p97tE= +X-Virus-Scanned: by amavisd-new at kcilink.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/20 +X-Sequence-Number: 5876 + +>>>>> "CW" == Christopher Weimann writes: + +>> which brings me back to my question why not make Freebsd use more of its +>> memory for disk caching and then tell postgres about it. +>> + +CW> Because you can't. It already uses ALL RAM that isn't in use for +CW> something else. + +No, it does not. + +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +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 Mar 2 16:51:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BB1BAD1B8B7 + for ; + Tue, 2 Mar 2004 20:51: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 30226-05 + for ; + Tue, 2 Mar 2004 16:51:27 -0400 (AST) +Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) + by svr1.postgresql.org (Postfix) with ESMTP id D64BED1B8B6 + for ; + Tue, 2 Mar 2004 16:51:25 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id 523863F2A + for ; + Tue, 2 Mar 2004 15:51:27 -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 03076-06 for ; + Tue, 2 Mar 2004 15:51:26 -0500 (EST) +Received: from lorax.kcilink.com (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id B26463F29 + for ; + Tue, 2 Mar 2004 15:51:26 -0500 (EST) +Received: (from news@localhost) + by lorax.kcilink.com (8.12.9p2/8.12.9/Submit) id i22KpQxM076937 + for pgsql-performance@postgresql.org; + Tue, 2 Mar 2004 15:51:26 -0500 (EST) (envelope-from news) +To: pgsql-performance@postgresql.org +Path: not-for-mail +From: Vivek Khera +Newsgroups: ml.postgres.performance +Subject: Re: Database Server Tuning +Date: Tue, 02 Mar 2004 15:51:26 -0500 +Organization: Khera Communications, Inc., Rockville, MD +Lines: 20 +Message-ID: +References: <200402262128.i1QLS4VD023380@mxsf20.cluster1.charter.net> +NNTP-Posting-Host: yertle.kcilink.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Trace: lorax.kcilink.com 1078260686 79461 65.205.34.180 (2 Mar 2004 20:51:26 + GMT) +X-Complaints-To: daemon@kciLink.com +NNTP-Posting-Date: Tue, 2 Mar 2004 20:51:26 +0000 (UTC) +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + berkeley-unix) +Cancel-Lock: sha1:ix7dXNgyUHZnc1j3O6jp4dyFU+w= +X-Virus-Scanned: by amavisd-new at kcilink.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/21 +X-Sequence-Number: 5877 + +>>>>> "JA" == John Allgood writes: + +JA> I am planning on separating the OS, Data, WAL on to separate drives +JA> which will be mirrored. I am looking for input on setting kernel parameters, +JA> and Postgres server runtime parameters and other settings relating to + +I did a bunch of testing with different RAID levels on a 14 disk +array. I finally settled on this: RAID5 across 14 disks for the +data, the OS (including syslog directory) and WAL on a RAID1 pair on +the other channel of the same controller (I didn't want to spring for +dual RAID controllers). The biggest bumps in performance came from +increasing the checkpoint_buffers since my DB is heavily written to, +and increasing sort_mem. + + +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +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 Mar 2 17:30:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 12CEDD1B4B4 + for ; + Tue, 2 Mar 2004 21:30: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 51185-02 + for ; + Tue, 2 Mar 2004 17:30:49 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 8143ED1B4C3 + for ; + Tue, 2 Mar 2004 17:30:46 -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 i22LSZCL003349; + Tue, 2 Mar 2004 14:28:35 -0700 (MST) +Date: Tue, 2 Mar 2004 14:16:24 -0700 (MST) +From: "scott.marlowe" +To: Anjan Dave +Cc: , William Yu , + +Subject: Re: Scaling further up +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098039@vt-pe2550-001.vantage.vantage.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-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/25 +X-Sequence-Number: 5881 + +On Tue, 2 Mar 2004, Anjan Dave wrote: + +> "By lots I mean dozen(s) in a raid 10 array with a good controller." +> +> I believe, for RAID-10, I will need even number of drives. + +Correct. + +> Currently, +> the size of the database is about 13GB, and is not expected to grow +> exponentially with thousands of concurrent users, so total space is not +> of paramount importance compared to performance. +> +> Does this sound reasonable setup? +> 10x36GB FC drives on RAID-10 +> 4x36GB FC drives for the logs on RAID-10 (not sure if this is the +> correct ratio)? +> 1 hotspare +> Total=15 Drives per enclosure. + +Putting the Logs on RAID-10 is likely to be slower than, or no faster than +putting them on RAID-1, since the RAID-10 will have to write to 4 drives, +while the RAID-1 will only have to write to two drives. now, if you were +reading in the logs a lot, it might help to have the RAID-10. + +> Tentatively, I am looking at an entry-level EMC CX300 product with 2GB +> RAID cache, etc. + +Pick up a spare, I'll get you my home address, etc... :-) + +Seriously, that's huge. At that point you may well find that putting +EVERYTHING on a big old RAID-5 performs best, since you've got lots of +caching / write buffering going on. + +> Question - Are 73GB drives supposed to give better performance because +> of higher number of platters? + +Generally, larger hard drives perform better than smaller hard drives +because they a: have more heads and / or b: have a higher areal density. + +It's a common misconception that faster RPM drives are a lot faster, when, +in fact, their only speed advantage is slight faster seeks. The areal +density of faster spinning hard drives tends to be somewhat less than the +slower spinning drives, since the maximum frequency the heads can work in +on both drives, assuming the same technology, is the same. I.e. the speed +at which you can read data off of the platter doesn't usually go up with a +higher RPM drive, only the speed with which you can get to the first +sector. + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 17:17:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3D785D1B4C3 + for ; + Tue, 2 Mar 2004 21:17: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 45863-02 + for ; + Tue, 2 Mar 2004 17:17:01 -0400 (AST) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id D4338D1B470 + for ; + Tue, 2 Mar 2004 17:16:58 -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 i22KmDcM002516; + Tue, 2 Mar 2004 15:48:13 -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 i22LGwl09269; + Tue, 2 Mar 2004 16:16:58 -0500 +Received: from intergylinux (intergylinux.mmrd.com [172.25.4.92]) by + gnvex001.mmrd.com with SMTP (Microsoft Exchange Internet Mail + Service Version 5.5.2657.72) + id FVMAVQJA; Tue, 2 Mar 2004 16:16:56 -0500 +From: Chris Ruprecht +Organization: CDRBill +To: "Anjan Dave" , , + "William Yu" +Subject: Re: Scaling further up +Date: Tue, 2 Mar 2004 16:16:55 -0500 +User-Agent: KMail/1.5.1 +Cc: +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098039@vt-pe2550-001.vantage.vantage.com> +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098039@vt-pe2550-001.vantage.vantage.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403021616.55833.chris@ruprecht.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/22 +X-Sequence-Number: 5878 + +Hi all, + +If you have a DB of 'only' 13 GB and you do not expect it to grow much, it +might be advisable to have enough memory (RAM) to hold the entire DB in +shared memory (everything is cached). If you have a server with say 24 GB or +memory and can allocate 20 GB for cache, you don't care about the speed of +disks any more - all you worry about is the speed of your memory and your +network connection. +I believe, this not possible using 32-bit technology, you would have to go to +some 64-bit platform, but if it's speed you want ... +You can also try solid state hard disk drives. These are actually just meory, +there are no moving parts, but the look and behave like very very fast disk +drives. I have seen them at capacities of 73 GB - but they didn't mention the +price (I'd probably have a heart attack when I look at the price tag). + +Best regards, +Chris + + +On Tuesday 02 March 2004 14:41, Anjan Dave wrote: +> "By lots I mean dozen(s) in a raid 10 array with a good controller." +> +> I believe, for RAID-10, I will need even number of drives. Currently, +> the size of the database is about 13GB, and is not expected to grow +> exponentially with thousands of concurrent users, so total space is not +> of paramount importance compared to performance. +> +> Does this sound reasonable setup? +> 10x36GB FC drives on RAID-10 +> 4x36GB FC drives for the logs on RAID-10 (not sure if this is the +> correct ratio)? +> 1 hotspare +> Total=15 Drives per enclosure. +> +> Tentatively, I am looking at an entry-level EMC CX300 product with 2GB +> RAID cache, etc. +> +> Question - Are 73GB drives supposed to give better performance because +> of higher number of platters? +> +> Thanks, +> Anjan +> +> +> -----Original Message----- +> From: Fred Moyer [mailto:fred@redhotpenguin.com] +> Sent: Tuesday, March 02, 2004 5:57 AM +> To: William Yu; Anjan Dave +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] Scaling further up +> +> On Tue, 2004-03-02 at 17:42, William Yu wrote: +> > Anjan Dave wrote: +> > > We have a Quad-Intel XEON 2.0GHz (1MB cache), 12GB memory, running +> > > RH9, +> > > PG 7.4.0. There's an internal U320, 10K RPM RAID-10 setup on 4 +> +> drives. +> +> > > We are expecting a pretty high load, a few thousands of 'concurrent' +> > > users executing either select, insert, update, statments. +> > +> > The quick and dirty method would be to upgrade to the recently +> > announced +> > 3GHz Xeon MPs with 4MB of L3. My semi-educated guess is that you'd get +> > +> > another +60% there due to the huge L3 hiding the Xeon's shared bus +> +> penalty. +> +> If you are going to have thousands of 'concurrent' users you should +> seriously consider the 2.6 kernel if you are running Linux or as an +> alternative going with FreeBSD. You will need to load test your system +> and become an expert on tuning Postgres to get the absolute maximum +> performance from each and every query you have. +> +> And you will need lots of hard drives. By lots I mean dozen(s) in a +> raid 10 array with a good controller. Thousands of concurrent users +> means hundreds or thousands of transactions per second. I've personally +> seen it scale that far but in my opinion you will need a lot more hard +> drives and ram than cpu. +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 17:27:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 09C09D1B4C3 + for ; + Tue, 2 Mar 2004 21:27: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 48920-03 + for ; + Tue, 2 Mar 2004 17:27:10 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 73F6CD1B4BA + for ; + Tue, 2 Mar 2004 17:27:08 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4528678; Tue, 02 Mar 2004 13:28:16 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Anjan Dave" , , + "William Yu" +Subject: Re: Scaling further up +Date: Tue, 2 Mar 2004 13:26:19 -0800 +User-Agent: KMail/1.5.4 +Cc: +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098039@vt-pe2550-001.vantage.vantage.com> +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098039@vt-pe2550-001.vantage.vantage.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403021326.19998.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/23 +X-Sequence-Number: 5879 + +Anjan, + +> Question - Are 73GB drives supposed to give better performance because +> of higher number of platters? + +Not for your situation, no. Your issue is random seek times for multiple +simultaneous seek requests and batched checkpoint updates. Things that help +with this are: +More spindles +Better controllers, both RAID and individual disks +Faster drives + +Particularly, I'd check out stuff like reports from Tom's Hardware for +evaluating the real speed of drives and seek times. Often a really good +10000 RPM SCSI will beat a 15000RPM SCSI if the latter has poor onboard +programming. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 17:28:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 67ADCD1B507 + for ; + Tue, 2 Mar 2004 21:28: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 47637-06 + for ; + Tue, 2 Mar 2004 17:28:25 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BDD1D1B4BB + for ; + Tue, 2 Mar 2004 17:28:23 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4528688; Tue, 02 Mar 2004 13:29:32 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Vivek Khera , pgsql-performance@postgresql.org +Subject: Re: Database Server Tuning +Date: Tue, 2 Mar 2004 13:27:37 -0800 +User-Agent: KMail/1.5.4 +References: <200402262128.i1QLS4VD023380@mxsf20.cluster1.charter.net> + +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403021327.37097.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/24 +X-Sequence-Number: 5880 + +Vivek, + +> I did a bunch of testing with different RAID levels on a 14 disk +> array. I finally settled on this: RAID5 across 14 disks for the +> data, the OS (including syslog directory) and WAL on a RAID1 pair on +> the other channel of the same controller (I didn't want to spring for +> dual RAID controllers). The biggest bumps in performance came from +> increasing the checkpoint_buffers since my DB is heavily written to, +> and increasing sort_mem. + +With large RAID, have you found that having WAL on a seperate array actually +boosts performance? The empirical tests we've seen so far don't seem to +support this. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 17:32:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 56036D1B566 + for ; + Tue, 2 Mar 2004 21:32: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 50699-04 + for ; + Tue, 2 Mar 2004 17:32:04 -0400 (AST) +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by svr1.postgresql.org (Postfix) with ESMTP id 734CFD1B8B6 + for ; + Tue, 2 Mar 2004 17:32:02 -0400 (AST) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 43397217B5 + for ; + Tue, 2 Mar 2004 16:32:03 -0500 (EST) +Mime-Version: 1.0 (Apple Message framework v612) +In-Reply-To: <200403021327.37097.josh@agliodbs.com> +References: <200402262128.i1QLS4VD023380@mxsf20.cluster1.charter.net> + + <200403021327.37097.josh@agliodbs.com> +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <0BD83171-6C91-11D8-95B1-000A9578CFCC@kcilink.com> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: Database Server Tuning +Date: Tue, 2 Mar 2004 16:32:03 -0500 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.612) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/26 +X-Sequence-Number: 5882 + + +On Mar 2, 2004, at 4:27 PM, Josh Berkus wrote: + +> Vivek, +> +>> I did a bunch of testing with different RAID levels on a 14 disk +>> array. I finally settled on this: RAID5 across 14 disks for the +>> data, the OS (including syslog directory) and WAL on a RAID1 pair on +>> the other channel of the same controller (I didn't want to spring for +> + + +> With large RAID, have you found that having WAL on a seperate array +> actually +> boosts performance? The empirical tests we've seen so far don't seem +> to +> support this. + +Yes, it was a noticeable improvement. + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 18:35:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C297D1BB91 + for ; + Tue, 2 Mar 2004 22:35:43 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 68504-05 + for ; + Tue, 2 Mar 2004 18:35:40 -0400 (AST) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 1979BD1BB43 + for ; + Tue, 2 Mar 2004 18:35:37 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Scaling further up +Date: Tue, 2 Mar 2004 16:50:04 -0500 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509803B@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Scaling further up +Thread-Index: AcQAm7rWA5NZuIGBQ4y/okkXHcE+LAAAJN8Q +From: "Anjan Dave" +To: "Chris Ruprecht" , , + "William Yu" +Cc: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/29 +X-Sequence-Number: 5885 + +That was part of my original question - whether it makes sense to go for +a mid-range SunFire machine (64bit HW, 64bit OS), which is scalable to +high amounts of memory, and shouldn't have any issues addressing it all. +I've had that kind of setup once temporarily on a V480 (quad UltraSparc, +16GB RAM) machine, and it did well in production use. Without having the +time/resources to do extensive testing, I am not sure if +Postgres/Solaris9 is really suggested by the community for +high-performance, as opposed to a XEON/Linux setup. Storage being a +separate discussion. + +Thanks, +Anjan + +-----Original Message----- +From: Chris Ruprecht [mailto:chris@ruprecht.org]=20 +Sent: Tuesday, March 02, 2004 4:17 PM +To: Anjan Dave; fred@redhotpenguin.com; William Yu +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Scaling further up + + +Hi all, + +If you have a DB of 'only' 13 GB and you do not expect it to grow much, +it=20 +might be advisable to have enough memory (RAM) to hold the entire DB in=20 +shared memory (everything is cached). If you have a server with say 24 +GB or=20 +memory and can allocate 20 GB for cache, you don't care about the speed +of=20 +disks any more - all you worry about is the speed of your memory and +your=20 +network connection. +I believe, this not possible using 32-bit technology, you would have to +go to=20 +some 64-bit platform, but if it's speed you want ... +You can also try solid state hard disk drives. These are actually just +meory,=20 +there are no moving parts, but the look and behave like very very fast +disk=20 +drives. I have seen them at capacities of 73 GB - but they didn't +mention the=20 +price (I'd probably have a heart attack when I look at the price tag). + +Best regards, +Chris + + +On Tuesday 02 March 2004 14:41, Anjan Dave wrote: +> "By lots I mean dozen(s) in a raid 10 array with a good controller." +> +> I believe, for RAID-10, I will need even number of drives. Currently,=20 +> the size of the database is about 13GB, and is not expected to grow=20 +> exponentially with thousands of concurrent users, so total space is=20 +> not of paramount importance compared to performance. +> +> Does this sound reasonable setup? +> 10x36GB FC drives on RAID-10 +> 4x36GB FC drives for the logs on RAID-10 (not sure if this is the=20 +> correct ratio)? 1 hotspare +> Total=3D15 Drives per enclosure. +> +> Tentatively, I am looking at an entry-level EMC CX300 product with 2GB + +> RAID cache, etc. +> +> Question - Are 73GB drives supposed to give better performance because + +> of higher number of platters? +> +> Thanks, +> Anjan +> +> +> -----Original Message----- +> From: Fred Moyer [mailto:fred@redhotpenguin.com] +> Sent: Tuesday, March 02, 2004 5:57 AM +> To: William Yu; Anjan Dave +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] Scaling further up +> +> On Tue, 2004-03-02 at 17:42, William Yu wrote: +> > Anjan Dave wrote: +> > > We have a Quad-Intel XEON 2.0GHz (1MB cache), 12GB memory, running + +> > > RH9, PG 7.4.0. There's an internal U320, 10K RPM RAID-10 setup on=20 +> > > 4 +> +> drives. +> +> > > We are expecting a pretty high load, a few thousands of=20 +> > > 'concurrent' users executing either select, insert, update,=20 +> > > statments. +> > +> > The quick and dirty method would be to upgrade to the recently=20 +> > announced 3GHz Xeon MPs with 4MB of L3. My semi-educated guess is=20 +> > that you'd get +> > +> > another +60% there due to the huge L3 hiding the Xeon's shared bus +> +> penalty. +> +> If you are going to have thousands of 'concurrent' users you should=20 +> seriously consider the 2.6 kernel if you are running Linux or as an=20 +> alternative going with FreeBSD. You will need to load test your=20 +> system and become an expert on tuning Postgres to get the absolute=20 +> maximum performance from each and every query you have. +> +> And you will need lots of hard drives. By lots I mean dozen(s) in a=20 +> raid 10 array with a good controller. Thousands of concurrent users=20 +> means hundreds or thousands of transactions per second. I've=20 +> personally seen it scale that far but in my opinion you will need a=20 +> lot more hard drives and ram than cpu. +> +> +> ---------------------------(end of=20 +> broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 18:35:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 28E31D1BC5C + for ; + Tue, 2 Mar 2004 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 66047-09 + for ; + Tue, 2 Mar 2004 18:35:43 -0400 (AST) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CC4CD1BB15 + for ; + Tue, 2 Mar 2004 18:35:38 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Scaling further up +Date: Tue, 2 Mar 2004 17:03:32 -0500 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509803C@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Scaling further up +Thread-Index: AcQAnacyqWuW/BxtRU+S6HA1tLOXMgAAa9Rw +From: "Anjan Dave" +To: "scott.marlowe" +Cc: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/30 +X-Sequence-Number: 5886 + +Here's what I recorded today from iostat (linux, iostat -x -k, sda3 is +the pg slice, logs included) during peak time on the RAID-10 array - +What i see is mostly writes, and sometimes, quite a bit of writing, +during which the average wait times shoot up. + +Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s rkB/s wkB/s +avgrq-sz avgqu-sz await svctm %util +/dev/sda3 18.81 113.21 3.90 36.33 181.54 1207.75 90.77 603.88 +34.54 0.49 0.73 0.22 0.87 +/dev/sda3 0.00 208.00 0.00 150.00 0.00 2884.00 0.00 1442.00 +19.23 0.75 0.50 0.33 5.00 +/dev/sda3 0.00 239.00 0.00 169.00 0.00 3264.00 0.00 1632.00 +19.31 2.15 1.27 0.33 5.50 +/dev/sda3 0.00 224.50 0.00 158.00 0.00 3060.00 0.00 1530.00 +19.37 1.90 1.20 0.28 4.50 +/dev/sda3 0.00 157.00 0.00 117.00 0.00 2192.00 0.00 1096.00 +18.74 0.40 0.34 0.30 3.50 +/dev/sda3 0.00 249.50 0.00 179.00 0.00 3596.00 0.00 1798.00 +20.09 21.40 10.78 0.39 7.00 +/dev/sda3 0.00 637.50 0.00 620.50 0.00 9936.00 0.00 4968.00 +16.01 1137.15 183.55 1.85 115.00 +/dev/sda3 0.00 690.00 0.00 548.50 0.00 9924.00 0.00 4962.00 +18.09 43.10 7.82 0.46 25.50 +/dev/sda3 0.00 485.00 0.00 392.00 0.00 7028.00 0.00 3514.00 +17.93 86.90 22.21 1.14 44.50 +/dev/sda3 0.00 312.50 0.00 206.50 0.00 4156.00 0.00 2078.00 +20.13 3.50 1.69 0.53 11.00 +/dev/sda3 0.00 386.50 0.00 275.50 0.00 5336.00 0.00 2668.00 +19.37 16.80 6.10 0.60 16.50 +/dev/sda3 0.00 259.00 0.00 176.50 0.00 3492.00 0.00 1746.00 +19.78 3.25 1.84 0.40 7.00 +/dev/sda3 0.00 196.00 0.00 99.00 0.00 2360.00 0.00 1180.00 +23.84 0.10 0.10 0.10 1.00 +/dev/sda3 0.00 147.00 0.00 100.00 0.00 1976.00 0.00 988.00 +19.76 0.50 0.50 0.45 4.50 +/dev/sda3 0.00 126.50 0.00 94.50 0.00 1768.00 0.00 884.00 +18.71 0.20 0.21 0.21 2.00 +/dev/sda3 0.00 133.50 0.00 106.50 0.00 1920.00 0.00 960.00 +18.03 0.50 0.47 0.47 5.00 +/dev/sda3 0.00 146.50 0.00 118.00 0.00 2116.00 0.00 1058.00 +17.93 0.20 0.21 0.17 2.00 +/dev/sda3 0.00 156.00 0.00 128.50 0.00 2276.00 0.00 1138.00 +17.71 0.35 0.27 0.27 3.50 +/dev/sda3 0.00 145.00 0.00 105.00 0.00 2000.00 0.00 1000.00 +19.05 0.25 0.24 0.24 2.50 +/dev/sda3 0.00 72.96 0.00 54.51 0.00 1019.74 0.00 509.87 +18.71 0.17 0.31 0.31 1.72 +/dev/sda3 0.00 168.50 0.00 139.50 0.00 2464.00 0.00 1232.00 +17.66 0.65 0.47 0.39 5.50 +/dev/sda3 0.00 130.50 0.00 100.00 0.00 1844.00 0.00 922.00 +18.44 0.00 0.00 0.00 0.00 +/dev/sda3 0.00 122.00 0.00 101.00 0.00 1784.00 0.00 892.00 +17.66 0.25 0.25 0.25 2.50 +/dev/sda3 0.00 143.00 0.00 121.50 0.00 2116.00 0.00 1058.00 +17.42 0.25 0.21 0.21 2.50 +/dev/sda3 0.00 134.50 0.00 96.50 0.00 1848.00 0.00 924.00 +19.15 0.35 0.36 0.36 3.50 +/dev/sda3 0.00 153.50 0.00 115.00 0.00 2148.00 0.00 1074.00 +18.68 0.35 0.30 0.30 3.50 +/dev/sda3 0.00 101.50 0.00 80.00 0.00 1452.00 0.00 726.00 +18.15 0.20 0.25 0.25 2.00 +/dev/sda3 0.00 108.50 0.00 92.50 0.00 1608.00 0.00 804.00 +17.38 0.25 0.27 0.27 2.50 +/dev/sda3 0.00 179.00 0.00 132.50 0.00 2492.00 0.00 1246.00 +18.81 0.55 0.42 0.42 5.50 +/dev/sda3 1.00 113.00 1.00 83.00 16.00 1568.00 8.00 784.00 +18.86 0.15 0.18 0.12 1.00 +/dev/sda3 0.00 117.00 0.00 97.50 0.00 1716.00 0.00 858.00 +17.60 0.20 0.21 0.21 2.00 +/dev/sda3 0.00 541.00 0.00 415.50 0.00 7696.00 0.00 3848.00 +18.52 146.50 35.09 1.37 57.00 +/dev/sda3 0.00 535.00 0.00 392.50 0.00 7404.00 0.00 3702.00 +18.86 123.70 31.67 1.31 51.50 +/dev/sda3 0.00 993.50 0.00 697.50 0.00 13544.00 0.00 6772.00 +19.42 174.25 24.98 1.25 87.00 +/dev/sda3 0.00 245.00 0.00 108.50 0.00 2832.00 0.00 1416.00 +26.10 0.55 0.51 0.51 5.50 + +-----Original Message----- +From: scott.marlowe [mailto:scott.marlowe@ihs.com]=20 +Sent: Tuesday, March 02, 2004 4:16 PM +To: Anjan Dave +Cc: fred@redhotpenguin.com; William Yu; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Scaling further up + + +On Tue, 2 Mar 2004, Anjan Dave wrote: + +> "By lots I mean dozen(s) in a raid 10 array with a good controller." +>=20 +> I believe, for RAID-10, I will need even number of drives. + +Correct. + +> Currently, +> the size of the database is about 13GB, and is not expected to grow=20 +> exponentially with thousands of concurrent users, so total space is=20 +> not of paramount importance compared to performance. +>=20 +> Does this sound reasonable setup? +> 10x36GB FC drives on RAID-10 +> 4x36GB FC drives for the logs on RAID-10 (not sure if this is the=20 +> correct ratio)? 1 hotspare +> Total=3D15 Drives per enclosure. + +Putting the Logs on RAID-10 is likely to be slower than, or no faster +than=20 +putting them on RAID-1, since the RAID-10 will have to write to 4 +drives,=20 +while the RAID-1 will only have to write to two drives. now, if you +were=20 +reading in the logs a lot, it might help to have the RAID-10. + +> Tentatively, I am looking at an entry-level EMC CX300 product with 2GB + +> RAID cache, etc. + +Pick up a spare, I'll get you my home address, etc... :-) + +Seriously, that's huge. At that point you may well find that putting=20 +EVERYTHING on a big old RAID-5 performs best, since you've got lots of=20 +caching / write buffering going on. + +> Question - Are 73GB drives supposed to give better performance because + +> of higher number of platters? + +Generally, larger hard drives perform better than smaller hard drives=20 +because they a: have more heads and / or b: have a higher areal density. + +It's a common misconception that faster RPM drives are a lot faster, +when,=20 +in fact, their only speed advantage is slight faster seeks. The areal=20 +density of faster spinning hard drives tends to be somewhat less than +the=20 +slower spinning drives, since the maximum frequency the heads can work +in=20 +on both drives, assuming the same technology, is the same. I.e. the +speed=20 +at which you can read data off of the platter doesn't usually go up with +a=20 +higher RPM drive, only the speed with which you can get to the first=20 +sector. + + +From pgsql-hackers-pitr-owner@postgresql.org Fri Mar 5 22:23:21 2004 +X-Original-To: pgsql-hackers-pitr-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id AB541D1B470; Tue, 2 Mar 2004 22:16: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 60509-08; Tue, 2 Mar 2004 18:16:23 -0400 (AST) +Received: from cmailm5.svr.pol.co.uk (cmailm5.svr.pol.co.uk [195.92.193.21]) + by svr1.postgresql.org (Postfix) with ESMTP + id 31848D1C96F; Tue, 2 Mar 2004 18:16:16 -0400 (AST) +Received: from modem-2578.lemur.dialup.pol.co.uk ([217.135.138.18] + helo=LaptopDellXP) by cmailm5.svr.pol.co.uk with esmtp (Exim 4.14) + id 1AyIBT-0003od-4X; Tue, 02 Mar 2004 22:16:15 +0000 +Reply-To: +From: "Simon Riggs" +To: "'Tom Lane'" +Cc: "'Rob Fielding'" , , + +Subject: Re: [PERFORM] WAL Optimisation - configuration and usage +Date: Tue, 2 Mar 2004 22:16:12 -0000 +Organization: 2nd Quadrant +Message-ID: <004801c400a3$f9696640$5baa87d9@LaptopDellXP> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +Importance: Normal +In-Reply-To: <24768.1078189289@sss.pgh.pa.us> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/4 +X-Sequence-Number: 28 + +>Tom Lane +> "Simon Riggs" writes: +> > - why checkpoint interval of 300 secs causes them to happen every 10 +> > mins in quieter periods; is that an occaisional update occurring? +> +> There is code in there to suppress a checkpoint if no WAL-loggable +> activity has happened since the last checkpoint. Not sure if that's +> relevant to the issue or not though. + +Thanks Tom, at least that clears up why the checkpoints are off. + +I must admit, I'm taken aback though: + +I'd prefer it if it DIDN'T do that. If the system is quiet, the odd +checkpoint doesn't matter that much - however, taking a long time to +return the xlog files to the *desired* state of having many +pre-allocated log files is not a great thing. + +What do you think about continuing to checkpoint normally until the +number of xlog files has returned to 2*checkpoint_segments+1, then +allowing a slow down of checkpoints when quiet? It would be easy enough +to set a variable true while rearranging files to the limit, then set it +false when the limit has been hit and then using that to activate the +slow-down code (not that I know where that is mind...). However, that +would require some backend to postmaster ipc, which may be a problem. + +Or perhaps the real problem is only recycling one file at a time - if +we're running this as the checkpoint process it wouldn't be a problem to +recycle more than one at the same time would it? + +The reason for my interest is: when archiving logs for PITR, there may +be occasional long pauses while waiting for tape mounts (typically 30 +minutes from notification to change). These pauses could (and therefore +will eventually for some people) cause severe log file build up, and I'm +interested in making sure this build up doesn't take too long to clear. +Forgetting the archival API stuff for a second, this is roughly the same +situation as Rob is experiencing (or at least causing him to pause and +think). + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 18:16:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 62C90D1C9EC + for ; + Tue, 2 Mar 2004 22:16: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 66246-01 + for ; + Tue, 2 Mar 2004 18:16:21 -0400 (AST) +Received: from cmailm5.svr.pol.co.uk (cmailm5.svr.pol.co.uk [195.92.193.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 7B170D1C9C2 + for ; + Tue, 2 Mar 2004 18:16:17 -0400 (AST) +Received: from modem-2578.lemur.dialup.pol.co.uk ([217.135.138.18] + helo=LaptopDellXP) by cmailm5.svr.pol.co.uk with esmtp (Exim 4.14) + id 1AyIBW-0003od-AQ; Tue, 02 Mar 2004 22:16:18 +0000 +Reply-To: +From: "Simon Riggs" +To: , "'Rob Fielding'" , + +Subject: Re: WAL Optimisation - configuration and usage +Date: Tue, 2 Mar 2004 22:16:12 -0000 +Organization: 2nd Quadrant +Message-ID: <004901c400a3$fb570570$5baa87d9@LaptopDellXP> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +Importance: Normal +In-Reply-To: <200403011710.07289.josh@agliodbs.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/27 +X-Sequence-Number: 5883 + +>Josh Berkus wrote +> >Simon Riggs wrote +> > Please set WAL_DEBUG to 1 so we can see a bit more info: thanks. +>=20 +> I'm pretty sure that WAL_DEBUG requires a compile-time option. + +In my naivet=E9, I just set and use it. I discovered it in the code, then +set it to take advantage. + +I'm surprised, but you are right, the manual does SAY this requires a +compile time option; it is unfortunately not correct. Maybe this was +once as you say? If Rob is using 7.2.2 maybe this still applies to him? +I don=92t know. + +Setting wal_debug > 0 in postgresql.conf sets a variable XLOGDEBUG, +which although it is all capitals is not in fact a compiler directive, +as it looks. This variable is used within xlog.c to output **too much** +information to the log. However, it is the only option at present. + +This prompts me however to consider the idea of having various levels of +WAL debug output, or using some kind of log_checkpoint mechanism to +better understand what is going on. + +Best Regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 18:49:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 954BED1BA6E + for ; + Tue, 2 Mar 2004 22:49: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 69547-08 + for ; + Tue, 2 Mar 2004 18:49:32 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id B0AB3D1B979 + for ; + Tue, 2 Mar 2004 18:49:28 -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 i22Mn4CL012335; + Tue, 2 Mar 2004 15:49:04 -0700 (MST) +Date: Tue, 2 Mar 2004 15:36:52 -0700 (MST) +From: "scott.marlowe" +To: Anjan Dave +Cc: Chris Ruprecht , , + William Yu , +Subject: Re: Scaling further up +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509803B@vt-pe2550-001.vantage.vantage.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-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/31 +X-Sequence-Number: 5887 + +On Tue, 2 Mar 2004, Anjan Dave wrote: + +> That was part of my original question - whether it makes sense to go for +> a mid-range SunFire machine (64bit HW, 64bit OS), which is scalable to +> high amounts of memory, and shouldn't have any issues addressing it all. +> I've had that kind of setup once temporarily on a V480 (quad UltraSparc, +> 16GB RAM) machine, and it did well in production use. Without having the +> time/resources to do extensive testing, I am not sure if +> Postgres/Solaris9 is really suggested by the community for +> high-performance, as opposed to a XEON/Linux setup. Storage being a +> separate discussion. + +Some folks on the list have experience with Postgresql on Solaris, and +they generally say they use Solaris not for performance reasons, but for +reliability reasons. I.e. the bigger Sun hardware is fault tolerant. + +For speed, the X86 32 and 64 bit architectures seem to be noticeable +faster than Sparc. However, running Linux or BSD on Sparc make them +pretty fast too, but you lose the fault tolerant support for things like +hot swappable CPUs or memory. + + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 18:56:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6941BD1BB64 + for ; + Tue, 2 Mar 2004 22:56: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 80957-01 + for ; + Tue, 2 Mar 2004 18:56:21 -0400 (AST) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CB836D1BA6E + for ; + Tue, 2 Mar 2004 18:56:18 -0400 (AST) +Received: from [134.22.70.251] (dyn-70-251.tor.dsl.tht.net [134.22.70.251]) + by tht.net (Postfix) with ESMTP + id 21E4176AB0; Tue, 2 Mar 2004 17:56:21 -0500 (EST) +Subject: Re: Scaling further up +From: Rod Taylor +To: Scott Marlowe +Cc: Anjan Dave , + Chris Ruprecht , fred@redhotpenguin.com, + William Yu , + Postgresql Performance +In-Reply-To: +References: +Content-Type: text/plain +Message-Id: <1078268191.39213.159.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Tue, 02 Mar 2004 17:56:32 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/32 +X-Sequence-Number: 5888 + +> For speed, the X86 32 and 64 bit architectures seem to be noticeable +> faster than Sparc. However, running Linux or BSD on Sparc make them +> pretty fast too, but you lose the fault tolerant support for things like +> hot swappable CPUs or memory. + +Agreed.. You can get a Quad Opteron with 16GB memory for around 20K. + +Grab 3, a cheap SAN and setup a little master/slave replication with +failover (how is Slony coming?), and you're all set. + + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 20:11:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 61BD6D1B4B4 + for ; + Wed, 3 Mar 2004 00:11: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 97119-08 + for ; + Tue, 2 Mar 2004 20:11:29 -0400 (AST) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EBBBD1B476 + for ; + Tue, 2 Mar 2004 20:11:25 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Scaling further up +Date: Tue, 2 Mar 2004 18:24:40 -0500 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C8F1@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Scaling further up +Thread-Index: AcQAqZSxIa0OnNC1T8+6FbxnHqxiwQAA9hgg +From: "Anjan Dave" +To: "Rod Taylor" , "Scott Marlowe" +Cc: "Chris Ruprecht" , , + "William Yu" , + "Postgresql Performance" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/35 +X-Sequence-Number: 5891 + +Can you describe the vendors/components of a "cheap SAN setup?" + +Thanks, +Anjan + +-----Original Message----- +From: Rod Taylor [mailto:pg@rbt.ca]=20 +Sent: Tuesday, March 02, 2004 5:57 PM +To: Scott Marlowe +Cc: Anjan Dave; Chris Ruprecht; fred@redhotpenguin.com; William Yu; +Postgresql Performance +Subject: Re: [PERFORM] Scaling further up + + +> For speed, the X86 32 and 64 bit architectures seem to be noticeable +> faster than Sparc. However, running Linux or BSD on Sparc make them=20 +> pretty fast too, but you lose the fault tolerant support for things +like=20 +> hot swappable CPUs or memory. + +Agreed.. You can get a Quad Opteron with 16GB memory for around 20K. + +Grab 3, a cheap SAN and setup a little master/slave replication with +failover (how is Slony coming?), and you're all set. + + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 19:05:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 27062D1BC4D + for ; + Tue, 2 Mar 2004 23:05: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 80714-03 + for ; + Tue, 2 Mar 2004 19:05:11 -0400 (AST) +Received: from phaedrusdeinus.org (dsl092-130-239.chi1.dsl.speakeasy.net + [66.92.130.239]) + by svr1.postgresql.org (Postfix) with SMTP id BD93ED1BC5C + for ; + Tue, 2 Mar 2004 19:05:07 -0400 (AST) +Received: (qmail 94085 invoked by uid 1001); 2 Mar 2004 23:25:41 -0000 +Date: Tue, 2 Mar 2004 17:25:41 -0600 +From: johnnnnnn +To: "scott.marlowe" +Cc: pgsql-performance@postgresql.org +Subject: Re: Scaling further up +Message-ID: <20040302232540.GA4102@performics.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098039@vt-pe2550-001.vantage.vantage.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/33 +X-Sequence-Number: 5889 + +On Tue, Mar 02, 2004 at 02:16:24PM -0700, scott.marlowe wrote: +> It's a common misconception that faster RPM drives are a lot faster, +> when, in fact, their only speed advantage is slight faster seeks. +> The areal density of faster spinning hard drives tends to be +> somewhat less than the slower spinning drives, since the maximum +> frequency the heads can work in on both drives, assuming the same +> technology, is the same. I.e. the speed at which you can read data +> off of the platter doesn't usually go up with a higher RPM drive, +> only the speed with which you can get to the first sector. + +This would imply that an upgrade in drive RPM should be accompanied by +a decrease in random_page_cost, correct? + +random_page_cost should be set with the following things taken into +account: + - seek speed + - likelihood of page to be cached in memory by the kernel + - anything else? + + +Sorry, i realize this pulls the thread a bit off-topic, but i've heard +that about RPM speeds before, and i just want some confirmation that +my deductions are reasonable. + +-johnnnnnnnnnnn + +From pgsql-performance-owner@postgresql.org Tue Mar 2 20:01:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D97F5D1B83D + for ; + Wed, 3 Mar 2004 00: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 97269-04 + for ; + Tue, 2 Mar 2004 20:01:12 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 67142D1B567 + for ; + Tue, 2 Mar 2004 20:01:09 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by bob.samurai.com (Postfix) with ESMTP + id 0354B1F01; Tue, 2 Mar 2004 19:01:12 -0500 (EST) +Received: from bob.samurai.com ([127.0.0.1]) + by localhost (bob.samurai.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 87750-01-10; Tue, 2 Mar 2004 19:01:11 -0500 (EST) +Received: from samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by bob.samurai.com (Postfix) with ESMTP + id DDB421F11; Tue, 2 Mar 2004 19:01:10 -0500 (EST) +Message-ID: <40452047.6030501@samurai.com> +Date: Tue, 02 Mar 2004 19:01:11 -0500 +From: Neil Conway +User-Agent: Mozilla Thunderbird 0.5 (X11/20040221) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: simon@2ndquadrant.com +Cc: josh@agliodbs.com, 'Rob Fielding' , + pgsql-performance@postgresql.org +Subject: Re: WAL Optimisation - configuration and usage +References: <004901c400a3$fb570570$5baa87d9@LaptopDellXP> +In-Reply-To: <004901c400a3$fb570570$5baa87d9@LaptopDellXP> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at mailbox.samurai.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/34 +X-Sequence-Number: 5890 + +Simon Riggs wrote: +>>Josh Berkus wrote +>> +>>>Simon Riggs wrote +>>>Please set WAL_DEBUG to 1 so we can see a bit more info: thanks. +>> +>>I'm pretty sure that WAL_DEBUG requires a compile-time option. +> +> I'm surprised, but you are right, the manual does SAY this requires a +> compile time option; it is unfortunately not correct. + +Actually, the manual is correct: in 7.4 and earlier releases, enabling +wal_debug can be done without also setting a compile-time #ifdef. As +of current CVS HEAD, the WAL_DEBUG #ifdef must be defined before this +variable is available. + +-Neil + +From pgsql-performance-owner@postgresql.org Tue Mar 2 22:06:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C99FBD1B8CB + for ; + Wed, 3 Mar 2004 02:06: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 28250-10 + for ; + Tue, 2 Mar 2004 22:06:29 -0400 (AST) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id CBF42D1C9C3 + for ; + Tue, 2 Mar 2004 22:06:24 -0400 (AST) +Received: (qmail 56958 invoked from network); 3 Mar 2004 02:06:35 -0000 +Received: from unknown (HELO ?192.168.0.8?) (10.10.10.177) + by 10.10.10.10 with SMTP; 3 Mar 2004 02:06:35 -0000 +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v609) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <7AACCD10-6CB7-11D8-AD74-000393D1F76E@torgo.978.org> +Content-Transfer-Encoding: 7bit +Cc: , + Anjan Dave , , + William Yu , Chris Ruprecht +From: Jeff +Subject: Re: Scaling further up +Date: Tue, 2 Mar 2004 21:07:10 -0500 +To: "scott.marlowe" +X-Mailer: Apple Mail (2.609) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/36 +X-Sequence-Number: 5892 + + +On Mar 2, 2004, at 5:36 PM, scott.marlowe wrote: + +> Some folks on the list have experience with Postgresql on Solaris, and +> they generally say they use Solaris not for performance reasons, but +> for +> reliability reasons. I.e. the bigger Sun hardware is fault tolerant. +> +Solaris isn't nearly as bad for PG as it used to be. + +But as you say - the #1 reason to use sun is reliability. (In my case, +it was because we had a giant sun laying around :) + +I'm trying to remember exactly what happens.. but I know on sun if it +had a severe memory error it kills off processes with data on that dimm +(Since it has no idea if it is bad or not. Thanks to ECC this is very +rare, but it can happen.). I want to say if a CPU dies any processes +running on it at that moment are also killed. but the more I think +about that th emore I don't think that is the case. + +As for x86.. if ram or a cpu goes bad you're SOL. + +Although opterons are sexy you need to remember they really are brand +new cpus - I'm sure AMD has done tons of testing but sun ultrasparc's +have been in every situation conceivable in production. If you are +going to really have thousands of users you probably want to bet the +farm on something proven. + +lots and lots of spindles +lots and lots of ram + +You may also want to look into a replication solution as a hot backup. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Tue Mar 2 22:27:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 29AFDD1B4B4 + for ; + Wed, 3 Mar 2004 02:27: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 36681-03 + for ; + Tue, 2 Mar 2004 22:27:49 -0400 (AST) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1466AD1B470 + for ; + Tue, 2 Mar 2004 22:27:45 -0400 (AST) +Received: from [134.22.70.251] (dyn-70-251.tor.dsl.tht.net [134.22.70.251]) + by tht.net (Postfix) with ESMTP + id CA49E76A8F; Tue, 2 Mar 2004 21:27:53 -0500 (EST) +Subject: Re: Scaling further up +From: Rod Taylor +To: Anjan Dave +Cc: Scott Marlowe , + Chris Ruprecht , fred@redhotpenguin.com, + William Yu , + Postgresql Performance +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C8F1@vt-pe2550-001.vantage.vantage.com> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C8F1@vt-pe2550-001.vantage.vantage.com> +Content-Type: text/plain +Message-Id: <1078280880.39213.166.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Tue, 02 Mar 2004 21:28:00 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/37 +X-Sequence-Number: 5893 + +On Tue, 2004-03-02 at 18:24, Anjan Dave wrote: +> Can you describe the vendors/components of a "cheap SAN setup?" + +heh.. Excellent point. + +My point was that you could get away with a smaller setup (number of +disks) if it doesn't have to deal with reads and writes are not time +dependent than you will if you attempt to pull 500MB/sec off the disks. + +If it is foreseeable that the database can be held in Ram, that it is +much easier and cheaper way to get high IO than with physical disks. + + + +From pgsql-performance-owner@postgresql.org Wed Mar 3 04:57:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 44B69D1B4B0 + for ; + Wed, 3 Mar 2004 08:57: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 24794-09 + for ; + Wed, 3 Mar 2004 04:57:21 -0400 (AST) +Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net + [194.217.242.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 20850D1B4BB + for ; + Wed, 3 Mar 2004 04:57:19 -0400 (AST) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) + id 1AySBs-000CC7-0b + for pgsql-performance@postgresql.org; Wed, 03 Mar 2004 08:57:20 +0000 +Date: Wed, 3 Mar 2004 08:57:18 +0000 +From: Paul Thomas +To: "pgsql-performance @ postgresql . org" +Subject: Re: Scaling further up +Message-ID: <20040303085718.A24535@bacon> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098039@vt-pe2550-001.vantage.vantage.com> + + <20040302232540.GA4102@performics.com> +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: <20040302232540.GA4102@performics.com>; + from john@phaedrusdeinus.org on Tue, Mar 02, 2004 at 23:25:41 + +0000 +X-Mailer: Balsa 1.2.3 +Lines: 25 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/38 +X-Sequence-Number: 5894 + + +On 02/03/2004 23:25 johnnnnnn wrote: +> [snip] +> random_page_cost should be set with the following things taken into +> account: +> - seek speed + +Which is not exactly the same thing as spindle speed as it's a combination +of spindle speed and track-to-track speed. I think you'll find that a 15K +rpm disk, whilst it will probably have a lower seek time than a 10K rpm +disk, won't have a proportionately (i.e., 2/3rds) lower seek time. + +> - likelihood of page to be cached in memory by the kernel + +That's effective cache size. + + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for the Smaller +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Wed Mar 3 05:25:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 31C5ED1BCB9 + for ; + Wed, 3 Mar 2004 09:25: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 41916-03 + for ; + Wed, 3 Mar 2004 05:25:38 -0400 (AST) +Received: from mail.enyo.de (mail.enyo.de [212.9.189.167]) + by svr1.postgresql.org (Postfix) with ESMTP id 71BFCD1B8B7 + for ; + Wed, 3 Mar 2004 05:25:33 -0400 (AST) +Received: (debugging) helo=deneb.enyo.de ip=212.9.189.171 name=deneb.enyo.de +Received: from deneb.enyo.de ([212.9.189.171]) + by mail.enyo.de with esmtp id 1AySd6-0000CX-TU + for pgsql-performance@postgresql.org; Wed, 03 Mar 2004 10:25:28 +0100 +Received: from fw by deneb.enyo.de with local (Exim 4.30) id 1AySd6-0001mF-Lb + for pgsql-performance@postgresql.org; Wed, 03 Mar 2004 10:25:28 +0100 +Date: Wed, 3 Mar 2004 10:25:28 +0100 +To: pgsql-performance@postgresql.org +Subject: Bulk INSERT performance in 7.4.1 +Message-ID: <20040303092528.GA6647@deneb.enyo.de> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.5.5.1+cvs20040105i +From: Florian Weimer +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/39 +X-Sequence-Number: 5895 + +After an upgrade to 7.4.1 (from 7.3) we see a severe performance +regression in bulk INSERTs. + +This is apparently caused by constant checkpointing (every 10 to 20 +seconds). I've already increased the number of checkpoint segments to +32, but currently, there are just 10 or 11 files in the pg_xlog +directory. With 7.3, we had configured checkpoint_segements at 16, and +there were 33 pg_xlog files. Checkpoints happened every couple of +minutes. + +How can I reduce the checkpoint frequency? + +(I'd like to try that first because it's the most obvious anomaly. +Maybe we can look at the involved table later.) + +-- +Current mail filters: many dial-up/DSL/cable modem hosts, and the +following domains: atlas.cz, bigpond.com, freenet.de, hotmail.com, +libero.it, netscape.net, postino.it, tiscali.co.uk, tiscali.cz, +tiscali.it, voila.fr, wanadoo.fr, yahoo.com. + +From pgsql-performance-owner@postgresql.org Wed Mar 3 07:32:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 297D9D1C96F + for ; + Wed, 3 Mar 2004 11:32: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 77434-08 + for ; + Wed, 3 Mar 2004 07:32:24 -0400 (AST) +Received: from fep01-mail.bloor.is.net.cable.rogers.com + (fep01-mail.bloor.is.net.cable.rogers.com [66.185.86.71]) + by svr1.postgresql.org (Postfix) with ESMTP id 68ECED1C96D + for ; + Wed, 3 Mar 2004 07:32:21 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep01-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040303113208.ZYL230350.fep01-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Wed, 3 Mar 2004 06:32:08 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id A97A43F3A; Wed, 3 Mar 2004 06:32:22 -0500 (EST) +Date: Wed, 3 Mar 2004 06:32:22 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: Scaling further up +Message-ID: <20040303113222.GA12150@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509803B@vt-pe2550-001.vantage.vantage.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78509803B@vt-pe2550-001.vantage.vantage.com> +User-Agent: Mutt/1.5.4i +X-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep01-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Wed, + 3 Mar 2004 06:32:08 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/40 +X-Sequence-Number: 5896 + +On Tue, Mar 02, 2004 at 04:50:04PM -0500, Anjan Dave wrote: +> time/resources to do extensive testing, I am not sure if +> Postgres/Solaris9 is really suggested by the community for +> high-performance, as opposed to a XEON/Linux setup. Storage being a +> separate discussion. + +I can tell you from experience that performance on Solaris is nowhere +close to what you'd expect, given the coin you're forking over for +it. I think the reason to use Solaris is its support for all the +nifty hot-swappable hardware, and not for its speed or any putative +benefit you might get from having 64 bits at your disposal. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +The fact that technology doesn't work is no bar to success in the marketplace. + --Philip Greenspun + +From pgsql-performance-owner@postgresql.org Wed Mar 3 10:10:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4245AD1BB6B + for ; + Wed, 3 Mar 2004 14:10: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 40145-04 + for ; + Wed, 3 Mar 2004 10:10:33 -0400 (AST) +Received: from mail.enyo.de (mail.enyo.de [212.9.189.167]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D7DDD1BA4C + for ; + Wed, 3 Mar 2004 10:10:29 -0400 (AST) +Received: (debugging) helo=deneb.enyo.de ip=212.9.189.171 name=deneb.enyo.de +Received: from deneb.enyo.de ([212.9.189.171]) + by mail.enyo.de with esmtp id 1AyX4y-0001L1-Vc + for pgsql-performance@postgresql.org; Wed, 03 Mar 2004 15:10:32 +0100 +Received: from fw by deneb.enyo.de with local (Exim 4.30) id 1AyX4y-0003Cm-4i + for pgsql-performance@postgresql.org; Wed, 03 Mar 2004 15:10:32 +0100 +Date: Wed, 3 Mar 2004 15:10:32 +0100 +To: pgsql-performance@postgresql.org +Subject: Re: Bulk INSERT performance in 7.4.1 +Message-ID: <20040303141032.GA12276@deneb.enyo.de> +References: <20040303092528.GA6647@deneb.enyo.de> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20040303092528.GA6647@deneb.enyo.de> +User-Agent: Mutt/1.5.5.1+cvs20040105i +From: Florian Weimer +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/41 +X-Sequence-Number: 5897 + +Florian Weimer wrote: + +> After an upgrade to 7.4.1 (from 7.3) we see a severe performance +> regression in bulk INSERTs. + +In turns out that we were running the default configuration, and not the +tuned one in /etc/postgresql. *blush* + +After increasing the number of checkpoint segments and the shared-memory +buffers, performance is back to the expected levels. It might even be a +bit faster. + +-- +Current mail filters: many dial-up/DSL/cable modem hosts, and the +following domains: atlas.cz, bigpond.com, freenet.de, hotmail.com, +libero.it, netscape.net, postino.it, tiscali.co.uk, tiscali.cz, +tiscali.it, voila.fr, wanadoo.fr, yahoo.com. + +From pgsql-performance-owner@postgresql.org Wed Mar 3 18:11:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B79BD1C4ED + for ; + Wed, 3 Mar 2004 22:11: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 04993-06 + for ; + Wed, 3 Mar 2004 18:11:14 -0400 (AST) +Received: from mail1.ihs.com (unknown [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 991C8D1CA78 + for ; + Wed, 3 Mar 2004 18:09:17 -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 i23IZTJg026073; + Wed, 3 Mar 2004 11:35:30 -0700 (MST) +Date: Wed, 3 Mar 2004 11:23:11 -0700 (MST) +From: "scott.marlowe" +To: Paul Thomas +Cc: "pgsql-performance @ postgresql . org" +Subject: Re: Scaling further up +In-Reply-To: <20040303085718.A24535@bacon> +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-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/50 +X-Sequence-Number: 5906 + +On Wed, 3 Mar 2004, Paul Thomas wrote: + +> +> On 02/03/2004 23:25 johnnnnnn wrote: +> > [snip] +> > random_page_cost should be set with the following things taken into +> > account: +> > - seek speed +> +> Which is not exactly the same thing as spindle speed as it's a combination +> of spindle speed and track-to-track speed. I think you'll find that a 15K +> rpm disk, whilst it will probably have a lower seek time than a 10K rpm +> disk, won't have a proportionately (i.e., 2/3rds) lower seek time. + +There are three factors that affect how fast you can get to the next +sector: + +seek time +settle time +rotational latency + +Most drives only list the first, and don't bother to mention the other +two. + +On many modern drives, the seek times are around 5 to 10 milliseconds. +The settle time varies as well. the longer the seek, the longer the +settle, generally. This is the time it takes for the head to stop shaking +and rest quietly over a particular track. +Rotational Latency is the amount of time you have to wait, on average, for +the sector you want to come under the heads. + +Assuming an 8 ms seek, and 2 ms settle (typical numbers), and that the +rotational latency on average is 1/2 of a rotation: At 10k rpm, a +rotation takes 1/166.667 of a second, or 6 mS. So, a half a rotation is +approximately 3 mS. By going to a 15k rpm drive, the latency drops to 2 +mS. So, if we add them up, on the same basic drive, one being 10k and one +being 15k, we get: + +10krpm: 8+2+3 = 13 mS +15krpm: 8+2+2 = 12 mS + +So, based on the decrease in rotational latency being the only advantage +the 15krpm drive has over the 10krpm drive, we get an decrease in access +time of only 1 mS, or only about an 8% decrease in actual seek time. + +So, if you're random page cost on 10krpm drives was 1.7, you'd need to +drop it to 1.57 or so to reflect the speed increase from 15krpm drives. + +I.e. it's much more likely that going from 1 gig to 2 gigs of ram will +make a noticeable difference than going from 10k to 15k drives. + + +From pgsql-performance-owner@postgresql.org Wed Mar 3 16:46:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 453DBD1DF8B + for ; + Wed, 3 Mar 2004 20:46: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 85280-09 + for ; + Wed, 3 Mar 2004 16:46:54 -0400 (AST) +Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) + by svr1.postgresql.org (Postfix) with ESMTP id 238DDD1DF7C + for ; + Wed, 3 Mar 2004 16:46:47 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by www.postgresql.com (Postfix) with ESMTP id 52BCBCF4D2D + for ; + Wed, 3 Mar 2004 16:46:46 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4534057; Wed, 03 Mar 2004 11:00:19 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Neil Conway +Subject: Re: WAL Optimisation - configuration and usage +Date: Wed, 3 Mar 2004 10:58:20 -0800 +User-Agent: KMail/1.5.4 +References: <004901c400a3$fb570570$5baa87d9@LaptopDellXP> + <40452047.6030501@samurai.com> +In-Reply-To: <40452047.6030501@samurai.com> +Cc: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403031058.20934.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/43 +X-Sequence-Number: 5899 + +Neil, + +> Actually, the manual is correct: in 7.4 and earlier releases, enabling +> wal_debug can be done without also setting a compile-time #ifdef. As +> of current CVS HEAD, the WAL_DEBUG #ifdef must be defined before this +> variable is available. + +Hmmm. I was told that it was this way for 7.4 as well; that's why it's in +the docs that way. + + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Wed Mar 3 16:46:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C6DED1DF89 + for ; + Wed, 3 Mar 2004 20:46: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 85592-05 + for ; + Wed, 3 Mar 2004 16:46:55 -0400 (AST) +Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E477D1D695 + for ; + Wed, 3 Mar 2004 16:46:48 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by www.postgresql.com (Postfix) with ESMTP id 7D8C3CF4D07 + for ; + Wed, 3 Mar 2004 16:46:47 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4534059; Wed, 03 Mar 2004 11:01:16 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Vivek Khera , pgsql-performance@postgresql.org +Subject: Re: Database Server Tuning +Date: Wed, 3 Mar 2004 10:59:19 -0800 +User-Agent: KMail/1.5.4 +References: <200402262128.i1QLS4VD023380@mxsf20.cluster1.charter.net> + <200403021327.37097.josh@agliodbs.com> + <0BD83171-6C91-11D8-95B1-000A9578CFCC@kcilink.com> +In-Reply-To: <0BD83171-6C91-11D8-95B1-000A9578CFCC@kcilink.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403031059.19759.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/42 +X-Sequence-Number: 5898 + +Vivek, + +> > With large RAID, have you found that having WAL on a seperate array +> > actually +> > boosts performance? The empirical tests we've seen so far don't seem +> > to +> > support this. +> +> Yes, it was a noticeable improvement. + +Do you have any stats? This would be useful for your talk, as well. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Wed Mar 3 16:47:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BD658D1DC52 + for ; + Wed, 3 Mar 2004 20:46: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 85586-03 + for ; + Wed, 3 Mar 2004 16:46:59 -0400 (AST) +Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) + by svr1.postgresql.org (Postfix) with ESMTP id CDE1BD1DF80 + for ; + Wed, 3 Mar 2004 16:46:51 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by www.postgresql.com (Postfix) with ESMTP id ADBFCCF4D2F + for ; + Wed, 3 Mar 2004 16:46:48 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4534138; Wed, 03 Mar 2004 11:11:25 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: johnnnnnn , + "scott.marlowe" +Subject: Re: Scaling further up +Date: Wed, 3 Mar 2004 11:09:23 -0800 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098039@vt-pe2550-001.vantage.vantage.com> + + <20040302232540.GA4102@performics.com> +In-Reply-To: <20040302232540.GA4102@performics.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403031109.23201.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/44 +X-Sequence-Number: 5900 + +John, + +> This would imply that an upgrade in drive RPM should be accompanied by +> a decrease in random_page_cost, correct? + +Maybe. Maybe not. Tom's Hardware did some Bonnie++ testing with a variety +of new drives last year. They were moderately surprised to find that there +were "faster" drives (i.e. higher RPM) which had lower real throughput due to +poor onboard software and hardware, such as a small and slow onboard cache. + +So, it would be reasonable to assume that a 10,000 RPM Barracuda could support +marginally lower random_page_cost than a 7,200 RPM Barracuda ... but that +tells you nothing about a 10,000 RPM Maxtor Diamond (as an example). + +Also, many other factors influence real random_page_cost; the size and access +pattern of your database is probably much more important than your RPM. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Wed Mar 3 17:54:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 72BFED1EC67 + for ; + Wed, 3 Mar 2004 21:41: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 93398-08 + for ; + Wed, 3 Mar 2004 17:41:08 -0400 (AST) +Received: from cayenne.palmdigitalmedia.com (cayenne.palmdigitalmedia.com + [63.110.43.230]) + by svr1.postgresql.org (Postfix) with SMTP id 8A377D1EC69 + for ; + Wed, 3 Mar 2004 17:40:54 -0400 (AST) +Received: (qmail 14398 invoked from network); 3 Mar 2004 19:54:15 -0000 +Received: from unknown (HELO ?192.168.124.23?) (63.110.43.226) + by 0 with SMTP; 3 Mar 2004 19:54:15 -0000 +User-Agent: Microsoft-Entourage/10.1.1.2418 +Date: Wed, 03 Mar 2004 14:56:06 -0500 +Subject: Feature request: smarter use of conditional indexes +From: John Siracusa +To: Postgres Performance +Message-ID: +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: 200403/47 +X-Sequence-Number: 5903 + +Given an index like this: + + CREATE UNIQUE INDEX i1 ON t1 (c1) WHERE c1 IS NOT NULL; + +and a query like this: + + SELECT * FROM t1 WHERE c1 = 123; + +I'd like the planner to be smart enough to use an index scan using i1. Yes, +I can change the query to this: + + SELECT * FROM t1 WHERE c1 = 123 AND c1 IS NOT NULL; + +In which case the index will be used, but I shouldn't have to. More +practically, since a lot of my SQL is auto-generated, it's difficult to make +this query change just in the cases where I need it. And I'm loathe to +change every "column = value" pair in my auto-generated SQL into a double +pair of "(column = value and column is not null)" It's redundant and looks +pretty silly, IMO. + +Thanks for you consideration :) + +-John + + +From pgsql-performance-owner@postgresql.org Wed Mar 3 16:51:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D7036D1EA31 + for ; + Wed, 3 Mar 2004 20:51: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 85406-06 + for ; + Wed, 3 Mar 2004 16:51:09 -0400 (AST) +Received: from lorax.kcilink.com (lorax.kcilink.com [206.112.95.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 31522D1E9FB + for ; + Wed, 3 Mar 2004 16:51:02 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id CFA613E3D + for ; + Wed, 3 Mar 2004 15:28:56 -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 29249-02 for ; + Wed, 3 Mar 2004 15:28:56 -0500 (EST) +Received: from lorax.kcilink.com (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id 3A8D33E37 + for ; + Wed, 3 Mar 2004 15:28:56 -0500 (EST) +Received: (from news@localhost) + by lorax.kcilink.com (8.12.9p2/8.12.9/Submit) id i23KSriE007332 + for pgsql-performance@postgresql.org; + Wed, 3 Mar 2004 15:28:53 -0500 (EST) (envelope-from news) +To: pgsql-performance@postgresql.org +Path: not-for-mail +From: Vivek Khera +Newsgroups: ml.postgres.performance +Subject: Re: Bulk INSERT performance in 7.4.1 +Date: Wed, 03 Mar 2004 15:28:53 -0500 +Organization: Khera Communications, Inc., Rockville, MD +Lines: 15 +Message-ID: +References: <20040303092528.GA6647@deneb.enyo.de> + <20040303141032.GA12276@deneb.enyo.de> +NNTP-Posting-Host: yertle.kcilink.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Trace: lorax.kcilink.com 1078345733 31516 65.205.34.180 (3 Mar 2004 20:28:53 + GMT) +X-Complaints-To: daemon@kciLink.com +NNTP-Posting-Date: Wed, 3 Mar 2004 20:28:53 +0000 (UTC) +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + berkeley-unix) +Cancel-Lock: sha1:1MwEZB8dZ6/idnkMwGiZSPuhMx4= +X-Virus-Scanned: by amavisd-new at kcilink.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/45 +X-Sequence-Number: 5901 + +>>>>> "FW" == Florian Weimer writes: + +FW> After increasing the number of checkpoint segments and the shared-memory +FW> buffers, performance is back to the expected levels. It might even be a +FW> bit faster. + +If you've got the time, could you try also doing the full bulk insert +test with the checkpoint log files on another physical disk? See if +that's any faster. + +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +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 Wed Mar 3 17:58:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 20139D1EC68 + for ; + Wed, 3 Mar 2004 21:38: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 95438-03 + for ; + Wed, 3 Mar 2004 17:38:04 -0400 (AST) +Received: from COLSWEEPER.cranel.com (newmail.cranel.com [66.192.200.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 49E7BD1EC6D + for ; + Wed, 3 Mar 2004 17:37:52 -0400 (AST) +Received: from colmail01.cranel.com (colmail01.cranel.com) by + COLSWEEPER.cranel.com + (Content Technologies SMTPRS 4.3.12) with ESMTP id + ; + Wed, 3 Mar 2004 16:37:08 -0500 +Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by + colmail01.cranel.com with SMTP (Microsoft Exchange Internet + Mail Service Version 5.5.2657.72) + id GCWBC0VF; Wed, 3 Mar 2004 16:41:54 -0500 +Message-ID: <4046502C.7090307@cranel.com> +Date: Wed, 03 Mar 2004 16:37:48 -0500 +From: Greg Spiegelberg +Organization: Cranel, Inc. +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Vivek Khera +Cc: pgsql-performance@postgresql.org +Subject: Re: Bulk INSERT performance in 7.4.1 +References: <20040303092528.GA6647@deneb.enyo.de> + <20040303141032.GA12276@deneb.enyo.de> + +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: 200403/48 +X-Sequence-Number: 5904 + +Would turning autocommit off help? + + +Vivek Khera wrote: +>>>>>>"FW" == Florian Weimer writes: +> +> +> FW> After increasing the number of checkpoint segments and the shared-memory +> FW> buffers, performance is back to the expected levels. It might even be a +> FW> bit faster. +> +> If you've got the time, could you try also doing the full bulk insert +> test with the checkpoint log files on another physical disk? See if +> that's any faster. +> + + +-- +Greg Spiegelberg + Sr. Product Development Engineer + Cranel, Incorporated. + Phone: 614.318.4314 + Fax: 614.431.8388 + Email: gspiegelberg@Cranel.com +Cranel. Technology. Integrity. Focus. + + + +From pgsql-performance-owner@postgresql.org Wed Mar 3 17:40:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 92449D1EAC9 + for ; + Wed, 3 Mar 2004 21:39: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 91779-09 + for ; + Wed, 3 Mar 2004 17:39:48 -0400 (AST) +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E693D1EC64 + for ; + Wed, 3 Mar 2004 17:39:35 -0400 (AST) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 472F1217B5; + Wed, 3 Mar 2004 16:39:37 -0500 (EST) +In-Reply-To: <4046502C.7090307@cranel.com> +References: <20040303092528.GA6647@deneb.enyo.de> + <20040303141032.GA12276@deneb.enyo.de> + + <4046502C.7090307@cranel.com> +Mime-Version: 1.0 (Apple Message framework v612) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <44D5E259-6D5B-11D8-AE36-000A9578CFCC@kcilink.com> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Vivek Khera +Subject: Re: Bulk INSERT performance in 7.4.1 +Date: Wed, 3 Mar 2004 16:39:37 -0500 +To: Greg Spiegelberg +X-Mailer: Apple Mail (2.612) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/46 +X-Sequence-Number: 5902 + + +On Mar 3, 2004, at 4:37 PM, Greg Spiegelberg wrote: + +> Would turning autocommit off help? +> + +doubtful, since the bulk insert is all one transaction. + + +From pgsql-hackers-pitr-owner@postgresql.org Fri Mar 5 22:23:21 2004 +X-Original-To: pgsql-hackers-pitr-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 25E91D1EC65; Wed, 3 Mar 2004 21:40: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 93409-08; Wed, 3 Mar 2004 17:40:30 -0400 (AST) +Received: from cmailm6.svr.pol.co.uk (cmailm6.svr.pol.co.uk [195.92.193.22]) + by svr1.postgresql.org (Postfix) with ESMTP + id 280CED1EC60; Wed, 3 Mar 2004 17:40:18 -0400 (AST) +Received: from modem-1415.panther.dialup.pol.co.uk ([217.135.245.135] + helo=LaptopDellXP) by cmailm6.svr.pol.co.uk with esmtp (Exim 4.14) + id 1Aye6G-0006yd-Rt; Wed, 03 Mar 2004 21:40:21 +0000 +Reply-To: +From: "Simon Riggs" +To: "'Neil Conway'" , +Cc: "'Rob Fielding'" , , + , +Subject: Re: [PERFORM] WAL Optimisation - configuration and usage +Date: Wed, 3 Mar 2004 21:40:09 -0000 +Organization: 2nd Quadrant +Message-ID: <006801c40168$1db208d0$5baa87d9@LaptopDellXP> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +Importance: Normal +In-Reply-To: <40452047.6030501@samurai.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/5 +X-Sequence-Number: 29 + +>Neil Conway +> Simon Riggs wrote: +> >>Josh Berkus wrote +> >> +> >>>Simon Riggs wrote +> >>>Please set WAL_DEBUG to 1 so we can see a bit more info: thanks. +> >> +> >>I'm pretty sure that WAL_DEBUG requires a compile-time option. +> > +> > I'm surprised, but you are right, the manual does SAY this requires +a +> > compile time option; it is unfortunately not correct. +> +> Actually, the manual is correct: in 7.4 and earlier releases, enabling +> wal_debug can be done without also setting a compile-time #ifdef. As +> of current CVS HEAD, the WAL_DEBUG #ifdef must be defined before this +> variable is available. + +Touche! I stand corrected, thank you both. My suggestion does work for +Rob, then. + +[This also implies I have a screwed version on my machine, so thank you +also for flushing that lurking issue out for me. I'd had a suspicion for +a few weeks. Lucky I'm still just prototyping.] + +On the other hand, I was just about to change the wal_debug behaviour to +allow better debugging of PITR features as they're added. I think it is +very important to be able to put the system fairly easily into debug +mode; a recompile is easy enough, but it would be even better to avoid +this completely. This would mean reversing the change you describe: +here's the design: + +The behaviour I wish to add is: +Keep wal_debug as a value between 0 and 16. +If =0 then no debug output (default). +Use following bitmasks against the value +Mask 1 = XLOG Checkpoints get logged +Mask 2 = Archive API calls get logged +Mask 4 = Transaction - commits get logged +Mask 8 = Flush & INSERTs get logged + +That way it should be fairly straightforward to control the amount and +type of information available to administrators. The existing design +produces too much info to be easily usable, mostly requiring a perl +program to filter out the info overload and do record counts. This +suggested design allows you to control the volume of messages, since the +bitmasks are arranged in volume/frequency order and brings the wal_debug +option back into something useful for problem diagnosis on live systems, +not just hacking the code. + +Anybody object to these mods, or have better/different ideas? Getting +the diagnostics right is fairly important, IMHO, to making PITR become +real. + +Best regards, Simon Riggs + + +From pgsql-performance-owner@postgresql.org Tue Mar 9 19:47:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 76F5ED1CA78 + for ; + Wed, 3 Mar 2004 21:50: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 99657-04 + for ; + Wed, 3 Mar 2004 17:50:05 -0400 (AST) +Received: from mail.vistashare.com (www.vistashare.net [65.207.67.162]) + by svr1.postgresql.org (Postfix) with ESMTP id E73F7D1CC7F + for ; + Wed, 3 Mar 2004 17:49:51 -0400 (AST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.vistashare.com (Postfix) with ESMTP id 5175FAEED + for ; + Wed, 3 Mar 2004 16:49:45 -0500 (EST) +From: Chris Kratz +Organization: VistaShare +To: pgsql-performance@postgresql.org +Subject: Delete performance on delete from table with inherited tables +Date: Wed, 3 Mar 2004 16:49:44 -0500 +User-Agent: KMail/1.6.1 +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Message-Id: <200403031649.44937.chris.kratz@vistashare.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/117 +X-Sequence-Number: 5973 + +Hello all, + +I have a performance issue that I cannot seem to solve and am hoping that +someone might be able to make some suggestions. + +First some background information. We are using PostgreSQL 7.3.4 on Linux +with kernel 2.4.19. The box is a single P4 2.4Ghz proc with 1G ram and uw +scsi drives in a hardware raid setup. + +We have a transactioninfo table with about 163k records. psql describes the +table as: + +\d transactioninfo + Table "public.transactioninfo" + Column | Type | Modifiers +---------------+--------------------------+-------------------------------------------------------- + transactionid | integer | not null default +nextval('transaction_sequence'::text) + userid | integer | + programid | integer | + time | timestamp with time zone | + comment | text | + undoable | boolean | + del | boolean | +Indexes: transactioninfo_pkey primary key btree (transactionid), + delidx btree (del), + transactioninfo_date btree ("time", programid, userid) +Triggers: RI_ConstraintTrigger_6672989, + RI_ConstraintTrigger_6672990, + RI_ConstraintTrigger_6672992, +--snip-- +--snip-- + RI_ConstraintTrigger_6673121, + RI_ConstraintTrigger_6673122 + +There are about 67 inherited tables that inherit the fields from this table, +hence the 134 constraint triggers. + +There is a related table transactionlog which has a fk(foreign key) to +transactioninfo. It contains about 600k records. + +There are 67 hist_tablename tables, each with a different structure. Then an +additional 67 tables called hist_tablename_log which inherit from the +transactionlog table and appropriate hist_tablename table. By the automagic +of inheritance, since the transactionlog has a fk to transactioninfo, each of +the hist_tablename_log tables does as well (if I am reading the pg_trigger +table correctly). + +Once a day we run a sql select statement to clear out all records in +transactioninfo that don't have a matching record in transactionlog. We +accumulate between 5k-10k records a day that need clearing from +transactioninfo. That clear ran this morning for 5 hours and 45 minutes. + +Today I am working on streamlining the sql to try and get the delete down to a +manageable time frame. The original delete statement was quite inefficent. +So, far, I've found that it appears to be much faster to break the task into +two pieces. The first is to update a flag on transactioninfo to mark empty +transactions and then a followup delete which clears based on that flag. The +update takes about a minute or so. + +update only transactioninfo set del=TRUE where + not exists (select transactionid from transactionlog l where +l.transactionid=transactioninfo.transactionid); +UPDATE 6911 +Time: 59763.26 ms + + Now if I delete a single transactioninfo record found by selecting del=true +limit 1 I get + +explain analyze delete from only transactioninfo where transactionid=734607; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------ + Index Scan using transactioninfo_pkey on transactioninfo (cost=0.00..6.01 +rows=1 width=6) (actual time=0.18..0.18 rows=1 loops=1) + Index Cond: (transactionid = 734607) + Total runtime: 0.41 msec +(3 rows) + +Time: 855.08 ms + +With the 7000 records to delete and a delete time of 0.855s, we are looking at +1.5hrs to do the clear which is a great improvement from the 6 hours we have +been seeing. But it still seems like it should run faster. + +The actual clear statement used in the clear is as follows: +explain delete from transactioninfo where del=true; + QUERY PLAN +---------------------------------------------------------------------- + Seq Scan on transactioninfo (cost=0.00..6177.21 rows=78528 width=6) + Filter: (del = true) +(2 rows) + +Another interesting observation is that the raid subsystem shows very low +activity during the clear. The backend process is almost entirely cpu bound. + +Some of the documentation implies that inherited tables cause deletes to be +very slow on the parent table, so I did the following experiment. + +vistashare=# create table transactioninfo_copy as select * from +transactioninfo; +SELECT +Time: 6876.88 ms +vistashare=# create index transinfo_copy_del_idx on transactioninfo_copy(del); +CREATE INDEX +Time: 446.20 ms +vistashare=# delete from transactioninfo_copy where del=true; +DELETE 6904 +Time: 202.33 ms + +Which certainly points to the triggers being the culprit. In reading the +documentation, it seems like the "delete from only..." statement should +ignore the constraint triggers. But it seems quite obvious from the +experiments that it is not. Also, the fact that the query plan doesn't show +the actual time used when analyze is used seems to again point to the after +delete triggers as being the culprit. + +Is there any other way to make this faster then to drop and rebuild all the +attached constraints? Is there a way to "disable" the constraints for a +single statement. Because of the unique nature of the data, we know that the +inherited tables don't need to be inspected. The table structure has worked +quite well up till now and we are hoping to not have to drop our foreign keys +and inheritance if possible. Any ideas? + +Thanks for your time, + +-Chris +-- +Chris Kratz +Systems Analyst/Programmer +VistaShare LLC + +From pgsql-performance-owner@postgresql.org Tue Mar 9 19:25:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0DA3BD1CA50 + for ; + Wed, 3 Mar 2004 23:50: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 37943-06 + for ; + Wed, 3 Mar 2004 19:50:58 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id C95BDD1C517 + for ; + Wed, 3 Mar 2004 19:50:48 -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 i23Noi1Y049764 + for ; Wed, 3 Mar 2004 23:50:44 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i23NZk9Y047698 + for pgsql-performance@postgresql.org; Wed, 3 Mar 2004 23:35:46 GMT +From: CoL +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Feature request: smarter use of conditional indexes +Date: Thu, 04 Mar 2004 00:37:46 +0100 +Organization: Hub.Org Networking Services +Lines: 29 +Message-ID: +References: +Reply-To: col@mportal.hu +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.7a) Gecko/20040219 +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: 200403/115 +X-Sequence-Number: 5971 + +hi, + +John Siracusa wrote, On 3/3/2004 20:56: + +> Given an index like this: +> +> CREATE UNIQUE INDEX i1 ON t1 (c1) WHERE c1 IS NOT NULL; +> +> and a query like this: +> +> SELECT * FROM t1 WHERE c1 = 123; +> +> I'd like the planner to be smart enough to use an index scan using i1. Yes, +> I can change the query to this: +> +> SELECT * FROM t1 WHERE c1 = 123 AND c1 IS NOT NULL; +> +> In which case the index will be used, but I shouldn't have to. More +> practically, since a lot of my SQL is auto-generated, it's difficult to make +> this query change just in the cases where I need it. And I'm loathe to +> change every "column = value" pair in my auto-generated SQL into a double +> pair of "(column = value and column is not null)" It's redundant and looks +> pretty silly, IMO. + +how about: CREATE UNIQUE INDEX i1 ON t1 (c1); +WHERE c1 IS NOT NULL in this case what is the point of doing this? +You do not need this condition. + +C. + +From pgsql-performance-owner@postgresql.org Wed Mar 3 19:44:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B7278D1B4B0 + for ; + Wed, 3 Mar 2004 23:44: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 39008-02 + for ; + Wed, 3 Mar 2004 19:44:39 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 905C4D1C517 + for ; + Wed, 3 Mar 2004 19:44:30 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by bob.samurai.com (Postfix) with ESMTP + id D2E1A1D8F; Wed, 3 Mar 2004 18:44:38 -0500 (EST) +Received: from bob.samurai.com ([127.0.0.1]) + by localhost (bob.samurai.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 44024-01-2; Wed, 3 Mar 2004 18:44:38 -0500 (EST) +Received: from samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by bob.samurai.com (Postfix) with ESMTP + id 021B41DB6; Wed, 3 Mar 2004 18:44:38 -0500 (EST) +Message-ID: <40466DE8.1030309@samurai.com> +Date: Wed, 03 Mar 2004 18:44:40 -0500 +From: Neil Conway +User-Agent: Mozilla Thunderbird 0.5 (X11/20040221) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: josh@agliodbs.com +Cc: pgsql-performance@postgresql.org +Subject: Re: WAL Optimisation - configuration and usage +References: <004901c400a3$fb570570$5baa87d9@LaptopDellXP> + <40452047.6030501@samurai.com> + <200403031058.20934.josh@agliodbs.com> +In-Reply-To: <200403031058.20934.josh@agliodbs.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at mailbox.samurai.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/51 +X-Sequence-Number: 5907 + +Josh Berkus wrote: +> Hmmm. I was told that it was this way for 7.4 as well; that's why it's in +> the docs that way. + +No such statement is made in the docs AFAIK: they merely say "If +nonzero, turn on WAL-related debugging output." + +I invented a new #ifdef symbol when making this change in CVS HEAD, so +I think you are misremembering. + +-Neil + +From pgsql-hackers-pitr-owner@postgresql.org Wed Mar 3 19:47:45 2004 +X-Original-To: pgsql-hackers-pitr-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 268D9D1B8E4; Wed, 3 Mar 2004 23:47: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 40058-01; Wed, 3 Mar 2004 19:47:48 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id BA95DD1C9EF; Wed, 3 Mar 2004 19:47:39 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i23NkN1f019295; + Wed, 3 Mar 2004 18:46:23 -0500 (EST) +To: simon@2ndquadrant.com +Cc: "'Neil Conway'" , josh@agliodbs.com, + "'Rob Fielding'" , pgsql-performance@postgresql.org, + pgsql-hackers-pitr@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] [PERFORM] WAL Optimisation - configuration and usage +In-reply-to: <006801c40168$1db208d0$5baa87d9@LaptopDellXP> +References: <006801c40168$1db208d0$5baa87d9@LaptopDellXP> +Comments: In-reply-to "Simon Riggs" + message dated "Wed, 03 Mar 2004 21:40:09 +0000" +Date: Wed, 03 Mar 2004 18:46:23 -0500 +Message-ID: <19294.1078357583@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/2 +X-Sequence-Number: 26 + +"Simon Riggs" writes: +> The behaviour I wish to add is: +> Keep wal_debug as a value between 0 and 16. +> If =0 then no debug output (default). +> Use following bitmasks against the value +> Mask 1 = XLOG Checkpoints get logged +> Mask 2 = Archive API calls get logged +> Mask 4 = Transaction - commits get logged +> Mask 8 = Flush & INSERTs get logged + +I see no value in reverting Neil's change. The above looks way too much +like old-line assembler-programmer thinking to me, anyway. Why not +invent a separate, appropriately named boolean variable for each thing +you want to control? Even C programmers manage to avoid doing the sort +of mental arithmetic that the above would force onto DBAs. + +As for whether it should be #ifdef'd or not, I'd have no objection to +turning WAL_DEBUG on by default in pg_config_manual.h for the duration +of PITR development. One should not however confuse short-term +debugging needs with features that the average user is going to need +indefinitely. (It was not too long ago that there was still debugging +code for btree index building in there, for crissakes.) + + regards, tom lane + +From pgsql-hackers-pitr-owner@postgresql.org Wed Mar 3 19:50:00 2004 +X-Original-To: pgsql-hackers-pitr-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id E6E9ED1CB0F; Wed, 3 Mar 2004 23:49: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 36839-04; Wed, 3 Mar 2004 19:50:04 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP + id BCCC5D1CA52; Wed, 3 Mar 2004 19:49:55 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by bob.samurai.com (Postfix) with ESMTP + id C636E1D8F; Wed, 3 Mar 2004 18:50:03 -0500 (EST) +Received: from bob.samurai.com ([127.0.0.1]) + by localhost (bob.samurai.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 44206-01-3; Wed, 3 Mar 2004 18:50:03 -0500 (EST) +Received: from samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by bob.samurai.com (Postfix) with ESMTP + id 903ED1D66; Wed, 3 Mar 2004 18:50:02 -0500 (EST) +Message-ID: <40466F2C.3050108@samurai.com> +Date: Wed, 03 Mar 2004 18:50:04 -0500 +From: Neil Conway +User-Agent: Mozilla Thunderbird 0.5 (X11/20040221) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: simon@2ndquadrant.com +Cc: josh@agliodbs.com, 'Rob Fielding' , + pgsql-performance@postgresql.org, pgsql-hackers-pitr@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] WAL Optimisation - configuration and usage +References: <006801c40168$1db208d0$5baa87d9@LaptopDellXP> +In-Reply-To: <006801c40168$1db208d0$5baa87d9@LaptopDellXP> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at mailbox.samurai.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/3 +X-Sequence-Number: 27 + +Simon Riggs wrote: +> On the other hand, I was just about to change the wal_debug behaviour to +> allow better debugging of PITR features as they're added. + +That's a development activity. Enabling the WAL_DEBUG #ifdef by +default during the 7.5 development cycle would be uncontroversial, I +think. + +> I think it is very important to be able to put the system fairly +> easily into debug mode + +It is? Why would this be useful for non-development activities? + +(It may well be the case that we ought to report more or better +information about the status of the WAL subsystem; but WAL_DEBUG is +surely not the right mechanism for emitting information intended for +an administrator.) + +-Neil + +From pgsql-performance-owner@postgresql.org Wed Mar 3 19:53:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5AE78D1B4B0 + for ; + Wed, 3 Mar 2004 23: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 33280-10 + for ; + Wed, 3 Mar 2004 19:53:58 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 0FF59D1CAFD + for ; + Wed, 3 Mar 2004 19:53:50 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i23Nru4H019342; + Wed, 3 Mar 2004 18:53:56 -0500 (EST) +To: John Siracusa +Cc: Postgres Performance +Subject: Re: Feature request: smarter use of conditional indexes +In-reply-to: +References: +Comments: In-reply-to John Siracusa + message dated "Wed, 03 Mar 2004 14:56:06 -0500" +Date: Wed, 03 Mar 2004 18:53:56 -0500 +Message-ID: <19341.1078358036@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/54 +X-Sequence-Number: 5910 + +John Siracusa writes: +> Given an index like this: +> CREATE UNIQUE INDEX i1 ON t1 (c1) WHERE c1 IS NOT NULL; +> and a query like this: +> SELECT * FROM t1 WHERE c1 = 123; +> I'd like the planner to be smart enough to use an index scan using i1. + +Send a patch ;-) + +The routine you want to teach about this is pred_test_simple_clause() in +src/backend/optimizer/path/indxpath.c. ISTM that it's legitimate to +conclude that "foo IS NOT NULL" is implied by "foo op anything" or +"anything op foo" if the operator is marked strict. + +Note: please patch against CVS head, as that code got rewritten since +7.4. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 3 20:52:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 04F80D1B4B0 + for ; + Thu, 4 Mar 2004 00:52: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 55183-04 + for ; + Wed, 3 Mar 2004 20:52:16 -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 1E484D1CA78 + for ; + Wed, 3 Mar 2004 20:52:07 -0400 (AST) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) + id 1Ayh5w-0004Yl-0U; Thu, 04 Mar 2004 00:52:12 +0000 +Date: Thu, 4 Mar 2004 00:52:08 +0000 +From: Paul Thomas +To: "scott . marlowe" +Cc: "pgsql-performance @ postgresql . org" +Subject: Re: Scaling further up +Message-ID: <20040304005208.A25816@bacon> +References: <20040303085718.A24535@bacon> + +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: ; + from scott.marlowe@ihs.com on Wed, Mar 03, 2004 at 18:23:11 +0000 +X-Mailer: Balsa 1.2.3 +Lines: 35 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/55 +X-Sequence-Number: 5911 + +On 03/03/2004 18:23 scott.marlowe wrote: +> [snip] +> There are three factors that affect how fast you can get to the next +> sector: +> +> seek time +> settle time +> rotational latency +> +> Most drives only list the first, and don't bother to mention the other +> two. + +Ah yes, one of my (very) few still functioning brain cells was nagging +about another bit of time in the equation :) + +> On many modern drives, the seek times are around 5 to 10 milliseconds. +> [snip] + +Going back to the OPs posting about random_page_cost, imagine I have 2 +servers identical in every way except the disk drive. Server A has a 10K +rpm drive and server B has a 15K rpm drive. Seek/settle times aren't +spectacularly different between the 2 drives. I'm wondering if drive B +might actually merit a _higher_ random_page_cost than drive A as, once it +gets settled on a disk track, it can suck the data off a lot faster. +opinions/experiences anyone? + + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for the Smaller +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Wed Mar 3 21:26:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8954ED1BC4D + for ; + Thu, 4 Mar 2004 01:26: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 59123-06 + for ; + Wed, 3 Mar 2004 21:26:36 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id E27F7D1B9A6 + for ; + Wed, 3 Mar 2004 21:26: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 + i241QDGi070613; Thu, 4 Mar 2004 09:26:13 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <40468704.9030601@familyhealth.com.au> +Date: Thu, 04 Mar 2004 09:31:48 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: John Siracusa , + Postgres Performance +Subject: Re: Feature request: smarter use of conditional indexes +References: + <19341.1078358036@sss.pgh.pa.us> +In-Reply-To: <19341.1078358036@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: 200403/56 +X-Sequence-Number: 5912 + + +>>Given an index like this: +>> CREATE UNIQUE INDEX i1 ON t1 (c1) WHERE c1 IS NOT NULL; +>>and a query like this: +>> SELECT * FROM t1 WHERE c1 = 123; +>>I'd like the planner to be smart enough to use an index scan using i1. +> +> +> Send a patch ;-) +> +> The routine you want to teach about this is pred_test_simple_clause() in +> src/backend/optimizer/path/indxpath.c. ISTM that it's legitimate to +> conclude that "foo IS NOT NULL" is implied by "foo op anything" or +> "anything op foo" if the operator is marked strict. + +I've actually mentioned this one before in that of all the partial +indexes I have, almost all of then are a WHERE x IS NOT NULL format. I +don't know if that's a common use, but if it is, then maybe it's worth +just adding the knowledge for IS NOT NULL... + +The other thing is that at the moment, cascading foreign keys will not +use partial indexes even if they match the predicate. Maybe an IS NOT +NULL hack will help there... + +Chris + + +From pgsql-performance-owner@postgresql.org Thu Mar 4 06:06:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 28DB6D1B8DF + for ; + Thu, 4 Mar 2004 10:06: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 92720-08 + for ; + Thu, 4 Mar 2004 06:06:13 -0400 (AST) +Received: from mail.enyo.de (mail.enyo.de [212.9.189.167]) + by svr1.postgresql.org (Postfix) with ESMTP id B8B95D1C9D0 + for ; + Thu, 4 Mar 2004 06:06:10 -0400 (AST) +Received: (debugging) helo=deneb.enyo.de ip=212.9.189.171 name=deneb.enyo.de +Received: from deneb.enyo.de ([212.9.189.171]) + by mail.enyo.de with esmtp id 1Aypk0-0004xh-I7; + Thu, 04 Mar 2004 11:06:08 +0100 +Received: from fw by deneb.enyo.de with local (Exim 4.30) + id 1Aypk0-0001Wu-7i; Thu, 04 Mar 2004 11:06:08 +0100 +Date: Thu, 4 Mar 2004 11:06:08 +0100 +To: Vivek Khera +Cc: pgsql-performance@postgresql.org +Subject: Re: Bulk INSERT performance in 7.4.1 +Message-ID: <20040304100608.GA5521@deneb.enyo.de> +References: <20040303092528.GA6647@deneb.enyo.de> + <20040303141032.GA12276@deneb.enyo.de> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.5.1+cvs20040105i +From: Florian Weimer +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/57 +X-Sequence-Number: 5913 + +Vivek Khera wrote: + +> If you've got the time, could you try also doing the full bulk insert +> test with the checkpoint log files on another physical disk? See if +> that's any faster. + +We have been doing that for a few weeks, but the performance +improvements are less than what we expected. There is hardly any disk +activity on the log RAID, even during checkpointing. + +After I activated the tuned configuration, we are again mostly CPU-bound +(it seems that updating all four indices is quite expensive). The +bulk INSERT process runs single-threaded right now, and if we switched +to multiple processes for that, we could reach some 1,500 INSERTs per +second, I believe. This is more than sufficient for us; our real-time +data collector is tuned to emit about 150 records per second, on the +average. (There is an on-disk queue to compensate temporary problems, +such as spikes in the data rate and database updates gone awry.) + +-- +Current mail filters: many dial-up/DSL/cable modem hosts, and the +following domains: atlas.cz, bigpond.com, freenet.de, hotmail.com, +libero.it, netscape.net, postino.it, tiscali.co.uk, tiscali.cz, +tiscali.it, voila.fr, wanadoo.fr, yahoo.com. + +From pgsql-performance-owner@postgresql.org Tue Mar 9 19:20:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3AD8CD1C9D0 + for ; + Thu, 4 Mar 2004 13: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 82163-02 + for ; + Thu, 4 Mar 2004 09:57:38 -0400 (AST) +Received: from web21202.mail.yahoo.com (web21202.mail.yahoo.com + [216.136.130.18]) + by svr1.postgresql.org (Postfix) with SMTP id F25A0D1B4C3 + for ; + Thu, 4 Mar 2004 09:57:35 -0400 (AST) +Message-ID: <20040304135739.26926.qmail@web21202.mail.yahoo.com> +Received: from [67.81.102.201] by web21202.mail.yahoo.com via HTTP; + Thu, 04 Mar 2004 05:57:39 PST +Date: Thu, 4 Mar 2004 05:57:39 -0800 (PST) +From: Aaron W +Subject: Re: Scaling further up +To: pgsql-performance@postgresql.org, adave@vantage.com +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/114 +X-Sequence-Number: 5970 + +.... +I'd look at adding more disks first. Depending on what +type of query +load you get, that box sounds like it will be very +much I/O bound.... + +Given a a 13G database on a 12G system, with a low +growth rate, it is likely that there is almost no I/O +for most activities. The exception is checkpointing. +The first thing I'd do is try to build a spreadsheet +model of: +- select frequency, and # logical and physical reads +involved +- insert/delete/update frequency, and # logical and +physical read and writes involved +- commit frequency, etc. +(start out with simplistic assumptions, and do it for +peak load) +- system events (checkpoints, vacuum) + +I assume that the only high I/O you will see will be +for logging. The RAID issue there is basically +obviated by the sequential write nature of WAL. If +that is the case, EMC is not the most cost effective +or obvious solution - since the value they provide is +mostly manageability for disaster recovery. The goal +in this case is to write at the application max speed, +and with mimimal latency. Any responsible battery +backed up write through (mirrored) cached controller +can do that for you. + +On the other hand, if your requests are not *all* +trivial, you are going to test the hardware and +scheduling algorithms of OS and pg. Even if 0.1% of +3,000 tps take a second - that ends up generating 3 +seconds of load.... Any, even slightly, slow +transactions will generate enormous queues which slow +down everything. + +In most systems of this volume I've seen, the mix of +activities is constantly invalidating cache, making L2 +caching less important. Memory to CPU bus speed is a +limiting factor, as well as raw CPU speed in +processing the requests. Xeon is not a great +architecture for this because of FSB contention; I +suspect a 4-way will be completely FSB bottlenecked so +a more than 4 way would likely not change performance. + + +I would try to get a simple model/benchmark going and +test against it. You should be talking to the big iron +vendors for their take on your issues and get their +capacity benchmarks. + +__________________________________ +Do you Yahoo!? +Yahoo! Search - Find what you�re looking for faster +http://search.yahoo.com + +From pgsql-performance-owner@postgresql.org Thu Mar 4 12:40:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 787D1D1CB3F + for ; + Thu, 4 Mar 2004 16:40: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 48348-01 + for ; + Thu, 4 Mar 2004 12:40:22 -0400 (AST) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id DACA6D1B911 + for ; + Thu, 4 Mar 2004 12:40:19 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Scaling further up +Date: Thu, 4 Mar 2004 10:57:03 -0500 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098045@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Scaling further up +Thread-Index: AcQB8KjUU2PLdk+XR16e76AUfxo/EAABiHIg +From: "Anjan Dave" +To: "Aaron W" , + +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/58 +X-Sequence-Number: 5914 + +Great response, Thanks. + +Regarding 12GB memory and 13G db, and almost no I/O, one thing I don't +understand is that even though the OS caches most of the memory and PG +can use it if it needs it, why would the system swap (not much, only +during peak times)? The SHMMAX is set to 512MB, shared_buffers is 150MB, +effective cache size is 2GB, sort mem is 2MB, rest is default values. It +also happens that a large query (reporting type) can hold up the other +queries, and the load averages shoot up during peak times. + +Regarding a baseline -=20 + +-We have docs and monitor for frequency of sql statements, most +expensive ones, etc. (IronEye) +-I am monitoring disk reads/writes using iostat +-How do I measure commit frequency, and system events like checkpoint? +(vacuum is done nightly during less or no load) + +Thanks, +Anjan + + +-----Original Message----- +From: Aaron W [mailto:aaronwerman@yahoo.com]=20 +Sent: Thursday, March 04, 2004 8:58 AM +To: pgsql-performance@postgresql.org; Anjan Dave +Subject: Re: Scaling further up + + +.... +I'd look at adding more disks first. Depending on what +type of query +load you get, that box sounds like it will be very +much I/O bound.... + +Given a a 13G database on a 12G system, with a low +growth rate, it is likely that there is almost no I/O +for most activities. The exception is checkpointing. +The first thing I'd do is try to build a spreadsheet +model of: +- select frequency, and # logical and physical reads +involved +- insert/delete/update frequency, and # logical and +physical read and writes involved +- commit frequency, etc. +(start out with simplistic assumptions, and do it for +peak load) +- system events (checkpoints, vacuum) + +I assume that the only high I/O you will see will be +for logging. The RAID issue there is basically +obviated by the sequential write nature of WAL. If +that is the case, EMC is not the most cost effective +or obvious solution - since the value they provide is +mostly manageability for disaster recovery. The goal +in this case is to write at the application max speed, +and with mimimal latency. Any responsible battery +backed up write through (mirrored) cached controller +can do that for you. + +On the other hand, if your requests are not *all* +trivial, you are going to test the hardware and +scheduling algorithms of OS and pg. Even if 0.1% of +3,000 tps take a second - that ends up generating 3 +seconds of load.... Any, even slightly, slow +transactions will generate enormous queues which slow +down everything.=20 + +In most systems of this volume I've seen, the mix of +activities is constantly invalidating cache, making L2 +caching less important. Memory to CPU bus speed is a +limiting factor, as well as raw CPU speed in +processing the requests. Xeon is not a great +architecture for this because of FSB contention; I +suspect a 4-way will be completely FSB bottlenecked so +a more than 4 way would likely not change performance. + + +I would try to get a simple model/benchmark going and +test against it. You should be talking to the big iron +vendors for their take on your issues and get their +capacity benchmarks. + +__________________________________ +Do you Yahoo!? +Yahoo! Search - Find what you're looking for faster +http://search.yahoo.com + +From pgsql-performance-owner@postgresql.org Thu Mar 4 13:25:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B9EFBD1BCC2 + for ; + Thu, 4 Mar 2004 17:25: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 70138-01 + for ; + Thu, 4 Mar 2004 13:25:51 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id A7D86D1B511 + for ; + Thu, 4 Mar 2004 13:25:47 -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 i24HOhJg027516; + Thu, 4 Mar 2004 10:24:43 -0700 (MST) +Date: Thu, 4 Mar 2004 10:12:18 -0700 (MST) +From: "scott.marlowe" +To: Paul Thomas +Cc: "pgsql-performance @ postgresql . org" +Subject: Re: Scaling further up +In-Reply-To: <20040304005208.A25816@bacon> +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-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/59 +X-Sequence-Number: 5915 + +On Thu, 4 Mar 2004, Paul Thomas wrote: + +> On 03/03/2004 18:23 scott.marlowe wrote: +> > [snip] +> > There are three factors that affect how fast you can get to the next +> > sector: +> > +> > seek time +> > settle time +> > rotational latency +> > +> > Most drives only list the first, and don't bother to mention the other +> > two. +> +> Ah yes, one of my (very) few still functioning brain cells was nagging +> about another bit of time in the equation :) +> +> > On many modern drives, the seek times are around 5 to 10 milliseconds. +> > [snip] +> +> Going back to the OPs posting about random_page_cost, imagine I have 2 +> servers identical in every way except the disk drive. Server A has a 10K +> rpm drive and server B has a 15K rpm drive. Seek/settle times aren't +> spectacularly different between the 2 drives. I'm wondering if drive B +> might actually merit a _higher_ random_page_cost than drive A as, once it +> gets settled on a disk track, it can suck the data off a lot faster. +> opinions/experiences anyone? + +It might well be that you have higher settle times that offset the small +gain in rotational latency. I haven't looked into it, so I don't know one +way or the other, but it seems a reasonable assumption. + +However, a common misconception is that the higher angular velocity of +the 15krpm drives would allow you to read data faster. In fact, the limit +of how fast you can read is set by the head. There's a maximum frequency +that it can read, and the areal density / rpm have to be such that you +don't exceed that frequency. OFten, the speed at which you read off the +platters is exactly the same between a 10k and 15k of the same family. + +The required lower areal density is the reason 15krpm drives show up in +the lower capacities first. + + +From pgsql-performance-owner@postgresql.org Fri Mar 5 09:35:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BEC8CD1D17E + for ; + Fri, 5 Mar 2004 13:35: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 18393-05 + for ; + Fri, 5 Mar 2004 09:35:05 -0400 (AST) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id CB62BD1D151 + for ; + Fri, 5 Mar 2004 09:35:00 -0400 (AST) +Received: (qmail 12478 invoked from network); 5 Mar 2004 13:35:06 -0000 +Received: from localhost (HELO ?10.124.7.34?) (threshar@127.0.0.1) + by localhost with SMTP; 5 Mar 2004 13:35:06 -0000 +Mime-Version: 1.0 (Apple Message framework v612) +Content-Transfer-Encoding: 7bit +Message-Id: +Content-Type: text/plain; charset=US-ASCII; format=flowed +To: pgsql-performance@postgresql.org +From: Jeff +Subject: Fixed width rows faster? +Date: Fri, 5 Mar 2004 08:35:05 -0500 +X-Mailer: Apple Mail (2.612) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/60 +X-Sequence-Number: 5916 + +I'm guessing the answer to this is "no" + +Is there any performance advantage to using a fixed width row (with PG)? + +I've heard this theory a few times and I think it is based on older, +different databases and we have also some custom software here that +uses fixed width rows to be able to hit row N in O(1), but that isn't +what I'd call a real database. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Fri Mar 5 10:07:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A88AAD1D0B6 + for ; + Fri, 5 Mar 2004 14:07: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 30111-02 + for ; + Fri, 5 Mar 2004 10:07:38 -0400 (AST) +Received: from internet.potentialtech.com (h-66-167-251-6.PHLAPAFG.covad.net + [66.167.251.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 5737FD1CAD1 + for ; + Fri, 5 Mar 2004 10:07:34 -0400 (AST) +Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net + [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP + id 9927669A39; Fri, 5 Mar 2004 09:07:37 -0500 (EST) +Message-ID: <404889A6.7@potentialtech.com> +Date: Fri, 05 Mar 2004 09:07:34 -0500 +From: Bill Moran +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Jeff +Cc: pgsql-performance@postgresql.org +Subject: Re: Fixed width rows faster? +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: 200403/61 +X-Sequence-Number: 5917 + +Jeff wrote: +> I'm guessing the answer to this is "no" +> +> Is there any performance advantage to using a fixed width row (with PG)? + +No. The user docs state that the performance is equal for char, varchar +and text. + +> I've heard this theory a few times and I think it is based on older, +> different databases + +MySQL used to have this issue (I don't know if it still does or not) to +the point that the docs once claimed that an index on a varchar was barely +as fast as a char with no index at all. + +> and we have also some custom software here that uses +> fixed width rows to be able to hit row N in O(1), but that isn't what +> I'd call a real database. + +Isn't needed in modern versions of Postgres, but I don't know (historically) +if it ever was or not. + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + + +From pgsql-performance-owner@postgresql.org Fri Mar 5 10:31:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 77BB1D1D400 + for ; + Fri, 5 Mar 2004 14:31: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 38228-01 + for ; + Fri, 5 Mar 2004 10:31:50 -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 074BDD1D2FE + for ; + Fri, 5 Mar 2004 10:31:42 -0400 (AST) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 4500980DC; Fri, 5 Mar 2004 15:31:44 +0100 (CET) +Date: Fri, 5 Mar 2004 15:31:44 +0100 (CET) +From: Dennis Bjorklund +To: Jeff +Cc: pgsql-performance@postgresql.org +Subject: Re: Fixed width rows faster? +In-Reply-To: +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/62 +X-Sequence-Number: 5918 + +On Fri, 5 Mar 2004, Jeff wrote: + +> Is there any performance advantage to using a fixed width row (with PG)? + +As far as I know there is only a small win when you want to extract some +field from a tuple and with variable width fields you have to walk to the +correct field. But this is a small performance problem unless you have +very many variable size columns in the table. + +> different databases and we have also some custom software here that +> uses fixed width rows to be able to hit row N in O(1) + +This can not happen in pg since there is no row N. Every transaction can +have a different view of the table, some rows are visible and some others +are not. To find row N you have to walk from the start and inspect every +tuple to see if it's visible to this transaction or not. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Fri Mar 5 19:29:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 037A1D1CB21 + for ; + Fri, 5 Mar 2004 23:29: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 05129-07 + for ; + Fri, 5 Mar 2004 19:29:48 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 344EBD1CAD0 + for ; + Fri, 5 Mar 2004 19:29:45 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4549276; Fri, 05 Mar 2004 15:30:54 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Bill Moran , + Jeff +Subject: Re: Fixed width rows faster? +Date: Fri, 5 Mar 2004 15:28:55 -0800 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: + <404889A6.7@potentialtech.com> +In-Reply-To: <404889A6.7@potentialtech.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403051528.55578.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/63 +X-Sequence-Number: 5919 + +Jeff, Bill: + +> No. The user docs state that the performance is equal for char, varchar +> and text. + +Actually, CHAR is slightly *slower* than VARCHAR or TEXT for SELECTs in many +applications. This is becuase of the field padding, and the frequent +necessity of casting CHAR::TEXT and back. + +For INSERT and UPDATE, TEXT is the fastest becuase it's not checking a length +constraint (takes time) or padding the field out to the required CHAR length +(even more time). + +Frankly, the only reason to use anything other than TEXT is compatibility with +other databases and applications. + + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Mar 5 19:37:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AD815D1D2CE + for ; + Fri, 5 Mar 2004 23:37: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 05858-08 + for ; + Fri, 5 Mar 2004 19:37:49 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id A0D52D1D108 + for ; + Fri, 5 Mar 2004 19:37:46 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) + with ESMTP id 4549311; Fri, 05 Mar 2004 15:39:00 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Dennis Bjorklund , Jeff +Subject: Re: Fixed width rows faster? +Date: Fri, 5 Mar 2004 15:37:02 -0800 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403051537.02535.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/64 +X-Sequence-Number: 5920 + +Jeff: + +> As far as I know there is only a small win when you want to extract some +> field from a tuple and with variable width fields you have to walk to the +> correct field. But this is a small performance problem unless you have +> very many variable size columns in the table. + +BTW, Dennis here is not talking about CHAR; CHAR is handled as a +variable-length field in Postgres. INTEGER is a fixed-width field. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Mar 5 19:43:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 80F0FD1D1F2 + for ; + Fri, 5 Mar 2004 23:43: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 11150-04 + for ; + Fri, 5 Mar 2004 19:43:39 -0400 (AST) +Received: from gw.tssi.com (gw.tssi.com [198.147.197.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A189D1D2AC + for ; + Fri, 5 Mar 2004 19:43:36 -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 i25NhY8S021798; + Fri, 5 Mar 2004 17:43:35 -0600 +Received: (from nolan@localhost) + by gw.tssi.com (8.12.6/8.12.6/Submit) id i25NhYsv021796; + Fri, 5 Mar 2004 17:43:34 -0600 +From: Mike Nolan +Message-Id: <200403052343.i25NhYsv021796@gw.tssi.com> +Subject: Re: Fixed width rows faster? +To: josh@agliodbs.com +Date: Fri, 5 Mar 2004 17:43:33 -0600 (CST) +Cc: wmoran@potentialtech.com (Bill Moran), + threshar@torgo.978.org (Jeff), pgsql-performance@postgresql.org +In-Reply-To: <200403051528.55578.josh@agliodbs.com> from "Josh Berkus" at Mar + 05, 2004 03:28:55 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: 200403/65 +X-Sequence-Number: 5921 + +> Frankly, the only reason to use anything other than TEXT is compatibility with +> other databases and applications. + +You don't consider a requirement that a field be no longer than a +certain length a reason not to use TEXT? +-- +Mike Nolan + +From pgsql-performance-owner@postgresql.org Fri Mar 5 19:54:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 90F4DD1D5A6 + for ; + Fri, 5 Mar 2004 23:54: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 06871-09 + for ; + Fri, 5 Mar 2004 19:54:34 -0400 (AST) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5B300D1D2C6 + for ; + Fri, 5 Mar 2004 19:54:29 -0400 (AST) +Received: from [134.22.70.251] (dyn-70-251.tor.dsl.tht.net [134.22.70.251]) + by tht.net (Postfix) with ESMTP + id 07D8776A81; Fri, 5 Mar 2004 18:54:35 -0500 (EST) +Subject: Re: Fixed width rows faster? +From: Rod Taylor +To: Mike Nolan +Cc: Josh Berkus , + Bill Moran , Jeff , + Postgresql Performance +In-Reply-To: <200403052343.i25NhYsv021796@gw.tssi.com> +References: <200403052343.i25NhYsv021796@gw.tssi.com> +Content-Type: text/plain +Message-Id: <1078530843.57624.24.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Fri, 05 Mar 2004 18:54:04 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/66 +X-Sequence-Number: 5922 + +On Fri, 2004-03-05 at 18:43, Mike Nolan wrote: +> > Frankly, the only reason to use anything other than TEXT is compatibility with +> > other databases and applications. +> +> You don't consider a requirement that a field be no longer than a +> certain length a reason not to use TEXT? + +Actually, I don't. Good reason to have a check constraint on it though +(hint, check constraints can be changed while column types cannot be, at +this moment). + + +From pgsql-performance-owner@postgresql.org Sat Mar 6 00:21:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 01BF9D1D2AC + for ; + Sat, 6 Mar 2004 04:21: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 58358-03 + for ; + Sat, 6 Mar 2004 00:21:10 -0400 (AST) +Received: from relay01.kbs.net.au (relay01.kbs.net.au [203.220.32.149]) + by svr1.postgresql.org (Postfix) with ESMTP id 66D40D1D25D + for ; + Sat, 6 Mar 2004 00:21:05 -0400 (AST) +Received: from [203.221.247.164] (helo=familyhealth.com.au) + by relay01.kbs.net.au with esmtp (Exim 3.36 #2) + id 1AzTId-0007P9-00; Sat, 06 Mar 2004 15:20:32 +1100 +Message-ID: <4049518D.70705@familyhealth.com.au> +Date: Sat, 06 Mar 2004 12:20:29 +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: Rod Taylor +Cc: Mike Nolan , Josh Berkus , + Bill Moran , Jeff , + Postgresql Performance +Subject: Re: Fixed width rows faster? +References: <200403052343.i25NhYsv021796@gw.tssi.com> + <1078530843.57624.24.camel@jester> +In-Reply-To: <1078530843.57624.24.camel@jester> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/67 +X-Sequence-Number: 5923 + +>>You don't consider a requirement that a field be no longer than a +>>certain length a reason not to use TEXT? + +Can't you just create a TEXT(255) field same as you can just create +VARCHAR (with no length) field? I think they're basically synonyms for +each other these days. + +Chris + +From pgsql-performance-owner@postgresql.org Sat Mar 6 00:32:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 59662D1D2FE + for ; + Sat, 6 Mar 2004 04:32: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 63545-04 + for ; + Sat, 6 Mar 2004 00:32:23 -0400 (AST) +Received: from gw.tssi.com (gw.tssi.com [198.147.197.1]) + by svr1.postgresql.org (Postfix) with ESMTP id AD129D1B4ED + for ; + Sat, 6 Mar 2004 00:32:17 -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 i264WF8S025071; + Fri, 5 Mar 2004 22:32:16 -0600 +Received: (from nolan@localhost) + by gw.tssi.com (8.12.6/8.12.6/Submit) id i264WFCk025069; + Fri, 5 Mar 2004 22:32:15 -0600 +From: Mike Nolan +Message-Id: <200403060432.i264WFCk025069@gw.tssi.com> +Subject: Re: Fixed width rows faster? +To: chriskl@familyhealth.com.au (Christopher Kings-Lynne) +Date: Fri, 5 Mar 2004 22:32:14 -0600 (CST) +Cc: pg@rbt.ca (Rod Taylor), josh@agliodbs.com (Josh Berkus), + wmoran@potentialtech.com (Bill Moran), threshar@torgo.978.org (Jeff), + pgsql-performance@postgresql.org (Postgresql Performance) +In-Reply-To: <4049518D.70705@familyhealth.com.au> from "Christopher + Kings-Lynne" at Mar 06, 2004 12:20:29 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: 200403/68 +X-Sequence-Number: 5924 + +> >>You don't consider a requirement that a field be no longer than a +> >>certain length a reason not to use TEXT? +> +> Can't you just create a TEXT(255) field same as you can just create +> VARCHAR (with no length) field? I think they're basically synonyms for +> each other these days. + +I'll defer to the SQL standard gurus on this, as well as to the internals +guys, but I suspect there is a difference between the standard itself +and implementor details, such as how char, varchar, varchar2 and text +are implemented. As long as things work as specified, I don't think +the standard cares much about what's happening behind the curtain. +-- +Mike Nolan + +From pgsql-performance-owner@postgresql.org Sat Mar 6 01:42:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B0C82D1D1F2 + for ; + Sat, 6 Mar 2004 05:42: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 89523-01 + for ; + Sat, 6 Mar 2004 01:42:27 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 57502D1D10B + for ; + Sat, 6 Mar 2004 01:42:22 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i265gJ72014232; + Sat, 6 Mar 2004 00:42:19 -0500 (EST) +To: Mike Nolan +Cc: josh@agliodbs.com, wmoran@potentialtech.com (Bill Moran), + threshar@torgo.978.org (Jeff), pgsql-performance@postgresql.org +Subject: Re: Fixed width rows faster? +In-reply-to: <200403052343.i25NhYsv021796@gw.tssi.com> +References: <200403052343.i25NhYsv021796@gw.tssi.com> +Comments: In-reply-to Mike Nolan + message dated "Fri, 05 Mar 2004 17:43:33 -0600" +Date: Sat, 06 Mar 2004 00:42:19 -0500 +Message-ID: <14231.1078551739@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/69 +X-Sequence-Number: 5925 + +Mike Nolan writes: +>> Frankly, the only reason to use anything other than TEXT is +>> compatibility with other databases and applications. + +> You don't consider a requirement that a field be no longer than a +> certain length a reason not to use TEXT? + +If you have an actual business-logic requirement to restrict a field to +no more than N characters, then by all means use varchar(N); that's +what it's for. But I agree with what I think Josh meant: there is very +seldom any non-broken reason to have a hard upper limit on string +lengths. If you think you need varchar(N) you should stop and ask +why exactly. If you cannot give a specific, coherent reason why the +particular value of N that you're using is the One True Length for the +field, then you really need to think twice. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Mar 6 01:53:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C15CAD1D64C + for ; + Sat, 6 Mar 2004 05:53: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 89756-03 + for ; + Sat, 6 Mar 2004 01:53:57 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id B957BD1D606 + for ; + Sat, 6 Mar 2004 01:53:52 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i265rnws014336; + Sat, 6 Mar 2004 00:53:49 -0500 (EST) +To: Mike Nolan +Cc: chriskl@familyhealth.com.au (Christopher Kings-Lynne), + pg@rbt.ca (Rod Taylor), josh@agliodbs.com (Josh Berkus), + wmoran@potentialtech.com (Bill Moran), threshar@torgo.978.org (Jeff), + pgsql-performance@postgresql.org (Postgresql Performance) +Subject: Re: Fixed width rows faster? +In-reply-to: <200403060432.i264WFCk025069@gw.tssi.com> +References: <200403060432.i264WFCk025069@gw.tssi.com> +Comments: In-reply-to Mike Nolan + message dated "Fri, 05 Mar 2004 22:32:14 -0600" +Date: Sat, 06 Mar 2004 00:53:49 -0500 +Message-ID: <14335.1078552429@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/70 +X-Sequence-Number: 5926 + +Mike Nolan writes: +>> Can't you just create a TEXT(255) field same as you can just create +>> VARCHAR (with no length) field? I think they're basically synonyms for +>> each other these days. + +> I'll defer to the SQL standard gurus on this, as well as to the internals +> guys, but I suspect there is a difference between the standard itself +> and implementor details, such as how char, varchar, varchar2 and text +> are implemented. As long as things work as specified, I don't think +> the standard cares much about what's happening behind the curtain. + +TEXT is not a standard datatype at all; that is, you will not find it +in the standard, even though quite a few DBMSes have a datatype that +they call by that name. + +Postgres' interpretation of TEXT is that there is no length-limitation +option. I don't know what other DBMSes do with their versions of TEXT. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Mar 6 06:02:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 305FBD1D501 + for ; + Sat, 6 Mar 2004 10:02: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 22264-08 + for ; + Sat, 6 Mar 2004 06:02:25 -0400 (AST) +Received: from relay01.kbs.net.au (relay01.kbs.net.au [203.220.32.149]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CB46D1D25D + for ; + Sat, 6 Mar 2004 06:02:19 -0400 (AST) +Received: from [203.221.247.164] (helo=familyhealth.com.au) + by relay01.kbs.net.au with esmtp (Exim 3.36 #2) + id 1AzYcV-0003xV-00; Sat, 06 Mar 2004 21:01:24 +1100 +Message-ID: <4049A16E.1040606@familyhealth.com.au> +Date: Sat, 06 Mar 2004 18:01:18 +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: Tom Lane +Cc: Mike Nolan , josh@agliodbs.com, + Bill Moran , Jeff , + pgsql-performance@postgresql.org +Subject: Re: Fixed width rows faster? +References: <200403052343.i25NhYsv021796@gw.tssi.com> + <14231.1078551739@sss.pgh.pa.us> +In-Reply-To: <14231.1078551739@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: 200403/71 +X-Sequence-Number: 5927 + +> If you have an actual business-logic requirement to restrict a field to +> no more than N characters, then by all means use varchar(N); that's +> what it's for. But I agree with what I think Josh meant: there is very +> seldom any non-broken reason to have a hard upper limit on string +> lengths. If you think you need varchar(N) you should stop and ask +> why exactly. If you cannot give a specific, coherent reason why the +> particular value of N that you're using is the One True Length for the +> field, then you really need to think twice. + +One nice reason to have like VARCHAR(4096) or whatever is that if there +is a bug in your website and you forget to length check some user input, +it stops them from screwing you by uploading megs and megs of data into +a 'firstname' field, say. + +Chris + + +From pgsql-performance-owner@postgresql.org Sat Mar 6 09:17:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 69423D1D17E + for ; + Sat, 6 Mar 2004 13: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 53281-02 + for ; + Sat, 6 Mar 2004 09:17:24 -0400 (AST) +Received: from expasy-ng.isb-sib.ch (expasy-f.unige.ch [192.33.215.142]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A932D1CCC5 + for ; + Sat, 6 Mar 2004 09:17:13 -0400 (AST) +Received: from caliente (router.isb-sib.ch [192.33.215.254]) + (authenticated bits=0) + by expasy-ng.isb-sib.ch (8.12.10/8.12.8) with ESMTP id i26DHIki029052 + for ; Sat, 6 Mar 2004 14:17:18 +0100 +Message-ID: <004501c4037d$63e27f80$c300000a@caliente> +From: "Eric Jain" +To: "pgsql-performance" +References: + <404889A6.7@potentialtech.com> + <200403051528.55578.josh@agliodbs.com> +Subject: Re: Fixed width rows faster? +Date: Sat, 6 Mar 2004 14:17:35 +0100 +Organization: Swiss Institute of Bioinformatics +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-sib-MailScanner-Information: Please contact the ISP for more information +X-sib-MailScanner: Found to be clean +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/72 +X-Sequence-Number: 5928 + +> Frankly, the only reason to use anything other than TEXT is +> compatibility with other databases and applications. + +The main reason why I am still using VARCHAR rather than TEXT in many +places is to ensure that the column can be indexed. Postgres, it seems, +refuses to insert a string that is longer than some value into an +indexed column, and I'll rather have such errors flagged while inserting +a row rather than while rebuilding an index after having inserted lots +of rows. + + +From pgsql-performance-owner@postgresql.org Sat Mar 6 12:27:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 54B5BD1D400 + for ; + Sat, 6 Mar 2004 16:27:19 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 76455-10 + for ; + Sat, 6 Mar 2004 12:27:13 -0400 (AST) +Received: from fep03-mail.bloor.is.net.cable.rogers.com + (fep03-mail.bloor.is.net.cable.rogers.com [66.185.86.73]) + by svr1.postgresql.org (Postfix) with ESMTP id 11847D1D306 + for ; + Sat, 6 Mar 2004 12:27:12 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep03-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040306162654.TRTI411419.fep03-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Sat, 6 Mar 2004 11:26:54 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 20C6E3F40; Sat, 6 Mar 2004 11:26:58 -0500 (EST) +Date: Sat, 6 Mar 2004 11:26:58 -0500 +From: Andrew Sullivan +To: pgsql-performance +Subject: Re: Fixed width rows faster? +Message-ID: <20040306162658.GB20089@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance +References: + <404889A6.7@potentialtech.com> + <200403051528.55578.josh@agliodbs.com> + <004501c4037d$63e27f80$c300000a@caliente> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <004501c4037d$63e27f80$c300000a@caliente> +User-Agent: Mutt/1.5.4i +X-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep03-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Sat, + 6 Mar 2004 11:26:54 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/73 +X-Sequence-Number: 5929 + +On Sat, Mar 06, 2004 at 02:17:35PM +0100, Eric Jain wrote: +> places is to ensure that the column can be indexed. Postgres, it seems, +> refuses to insert a string that is longer than some value into an +> indexed column, and I'll rather have such errors flagged while inserting + +Care to provide some details of this? It sure sounds like a bug to +me, if it's true. I've never run into anything like this, though. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +In the future this spectacle of the middle classes shocking the avant- +garde will probably become the textbook definition of Postmodernism. + --Brad Holland + +From pgsql-performance-owner@postgresql.org Sat Mar 6 16:51:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 79A1DD1D6CC + for ; + Sat, 6 Mar 2004 20:51: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 23891-01 + for ; + Sat, 6 Mar 2004 16:51:49 -0400 (AST) +Received: from sccrmhc12.comcast.net (sccrmhc12.comcast.net [204.127.202.56]) + by svr1.postgresql.org (Postfix) with ESMTP id D0BB1D1D550 + for ; + Sat, 6 Mar 2004 16:51:46 -0400 (AST) +Received: from [10.0.1.2] (h000393e3ce55.ne.client2.attbi.com[24.91.235.158]) + by comcast.net (sccrmhc12) with SMTP + id <2004030620514801200fcqlpe>; Sat, 6 Mar 2004 20:51:48 +0000 +User-Agent: Microsoft-Entourage/10.1.4.030702.0 +Date: Sat, 06 Mar 2004 15:51:47 -0500 +Subject: Re: Feature request: smarter use of conditional indexes +From: John Siracusa +To: Postgres Performance +Message-ID: +In-Reply-To: <19341.1078358036@sss.pgh.pa.us> +Mime-version: 1.0 +Reply-To: siracusa@mindspring.com +Content-type: text/plain; charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/74 +X-Sequence-Number: 5930 + +On 3/3/04 6:53 PM, Tom Lane wrote: +> John Siracusa writes: +>> Given an index like this: +>> CREATE UNIQUE INDEX i1 ON t1 (c1) WHERE c1 IS NOT NULL; +>> and a query like this: +>> SELECT * FROM t1 WHERE c1 = 123; +>> I'd like the planner to be smart enough to use an index scan using i1. +> +> Send a patch ;-) +> +> The routine you want to teach about this is pred_test_simple_clause() in +> src/backend/optimizer/path/indxpath.c. ISTM that it's legitimate to +> conclude that "foo IS NOT NULL" is implied by "foo op anything" or +> "anything op foo" if the operator is marked strict. + +Gack, C is not my forte... + +So...I'm noodling around in pred_test_simple_clause() and my test query of: + + SELECT * FROM t1 WHERE c1 = 123; + +lands me in pred_test_simple_clause() with a "predicate" with a NodeTag of +NullTest, and a "clause" with a NodeTag of OpExpr. The clause "rightop" +IsA() Const. So far, it seems to make sense. It's comparing the clause "c1 += 123" with the predicate on the "i1" index ("IS NOT NULL") to see if one +implies the other. + +But now I'm stuck, because IsA(predicate, NullTest) is *also* true if the +index i1 is dropped and index i2 is created like this: + + CREATE UNIQUE INDEX i2 ON t1 (c1) WHERE c1 IS NOT NULL; + +IOW, both "IS NOT NULL" and "IS NULL" lead to IsA(predicate, NullTest) being +true. I found this, which looked promising: + +typedef enum BoolTestType +{ + IS_TRUE, IS_NOT_TRUE, IS_FALSE, IS_NOT_FALSE, IS_UNKNOWN, IS_NOT_UNKNOWN +} BoolTestType; + +typedef struct BooleanTest +{ + Expr xpr; + Expr *arg; /* input expression */ + BoolTestType booltesttype; /* test type */ +} BooleanTest; + +But then I realized that "predicate" is "Expr *" inside the +pred_test_simple_clause() function, and Expr seems only to have a single +field, which is tested by IsA() + +typedef struct Expr +{ + NodeTag type; +} Expr; + +So apparently all I can do is find out if it's a null test, but not if it is +specifically "IS NOT NULL" + +Now I'm stuck, and thinking that I'd have to modify more than +pred_test_simple_clause() to make this work. Any additional pointers? :) + +-John + + +From pgsql-performance-owner@postgresql.org Sat Mar 6 16:52:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7333ED1D43B + for ; + Sat, 6 Mar 2004 20:52:30 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 14042-10 + for ; + Sat, 6 Mar 2004 16:52:30 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 6AC39D1D306 + for ; + Sat, 6 Mar 2004 16:52:28 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i26KqQZs018297; + Sat, 6 Mar 2004 15:52:27 -0500 (EST) +To: "Eric Jain" +Cc: "pgsql-performance" +Subject: Re: Fixed width rows faster? +In-reply-to: <004501c4037d$63e27f80$c300000a@caliente> +References: + <404889A6.7@potentialtech.com> + <200403051528.55578.josh@agliodbs.com> + <004501c4037d$63e27f80$c300000a@caliente> +Comments: In-reply-to "Eric Jain" + message dated "Sat, 06 Mar 2004 14:17:35 +0100" +Date: Sat, 06 Mar 2004 15:52:26 -0500 +Message-ID: <18296.1078606346@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/75 +X-Sequence-Number: 5931 + +"Eric Jain" writes: +> The main reason why I am still using VARCHAR rather than TEXT in many +> places is to ensure that the column can be indexed. Postgres, it seems, +> refuses to insert a string that is longer than some value into an +> indexed column, and I'll rather have such errors flagged while inserting +> a row rather than while rebuilding an index after having inserted lots +> of rows. + +This is bogus reasoning. The limit on index entry length will not +change when you rebuild the index. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Mar 6 17:06:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A6067D1D43B + for ; + Sat, 6 Mar 2004 21:06: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 23530-04 + for ; + Sat, 6 Mar 2004 17:06:12 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id B8942D1D400 + for ; + Sat, 6 Mar 2004 17:06:09 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i26L692o018410; + Sat, 6 Mar 2004 16:06:09 -0500 (EST) +To: siracusa@mindspring.com +Cc: Postgres Performance +Subject: Re: Feature request: smarter use of conditional indexes +In-reply-to: +References: +Comments: In-reply-to John Siracusa + message dated "Sat, 06 Mar 2004 15:51:47 -0500" +Date: Sat, 06 Mar 2004 16:06:09 -0500 +Message-ID: <18409.1078607169@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/76 +X-Sequence-Number: 5932 + +John Siracusa writes: +> So apparently all I can do is find out if it's a null test, but not if it is +> specifically "IS NOT NULL" + +No, because once you have determined that the node really IsA NullTest, +you can cast the pointer to (NullTest *) and look at the +NullTest-specific fields. Think of this as poor man's object-oriented +programming: Node is the supertype of Expr which is the supertype of +NullTest (and a lot of other kinds of nodes, too). + +It'd look something like + + if (IsA(predicate, NullTest) && + ((NullTest *) predicate)->nulltesttype == IS_NOT_NULL) + { + /* check to see if arg field matches either side of opclause, + * and if so check whether operator is strict ... + */ + } + +You can find plenty of examples of this programming pattern throughout +the backend. In fact pred_test_simple_clause is doing exactly this +to check that what it's given is an OpExpr and not some other node type. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Mar 6 17:55:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 77F24D1CAC7 + for ; + Sat, 6 Mar 2004 21:55:34 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 28771-04 + for ; + Sat, 6 Mar 2004 17:55:35 -0400 (AST) +Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FB92D1CA67 + for ; + Sat, 6 Mar 2004 17:55:32 -0400 (AST) +Received: from [10.0.1.2] (h000393e3ce55.ne.client2.attbi.com[24.91.235.158]) + by comcast.net (sccrmhc13) with SMTP + id <2004030621553301600ggquke>; Sat, 6 Mar 2004 21:55:33 +0000 +User-Agent: Microsoft-Entourage/10.1.4.030702.0 +Date: Sat, 06 Mar 2004 16:55:33 -0500 +Subject: Re: Feature request: smarter use of conditional indexes +From: John Siracusa +To: Postgres Performance +Message-ID: +In-Reply-To: <18409.1078607169@sss.pgh.pa.us> +Mime-version: 1.0 +Reply-To: siracusa@mindspring.com +Content-type: text/plain; charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/77 +X-Sequence-Number: 5933 + +On 3/6/04 4:06 PM, Tom Lane wrote: +> John Siracusa writes: +>> So apparently all I can do is find out if it's a null test, but not if it is +>> specifically "IS NOT NULL" +> +> No, because once you have determined that the node really IsA NullTest, +> you can cast the pointer to (NullTest *) and look at the +> NullTest-specific fields. + +I tried casting, but stupidly tried to access the type name (BoolTestType) +instead of the field name (nulltesttype). Duh! :) + +> Think of this as poor man's object-oriented programming: Node is the supertype +> of Expr which is the supertype of NullTest (and a lot of other kinds of nodes, +> too). + +Yeah, I read that in the comments but was defeated by my devious brain ;) +Thanks, I'll see how much farther I can go before getting stuck again :) + +-John + + +From pgsql-performance-owner@postgresql.org Sat Mar 6 21:16:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 89C48D1D803 + for ; + Sun, 7 Mar 2004 01:16: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 63530-04 + for ; + Sat, 6 Mar 2004 21:16:36 -0400 (AST) +Received: from gw.tssi.com (gw.tssi.com [198.147.197.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 72A4BD1D779 + for ; + Sat, 6 Mar 2004 21:16:32 -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 i271GX8S005871; + Sat, 6 Mar 2004 19:16:33 -0600 +Received: (from nolan@localhost) + by gw.tssi.com (8.12.6/8.12.6/Submit) id i271GWPS005869; + Sat, 6 Mar 2004 19:16:32 -0600 +From: Mike Nolan +Message-Id: <200403070116.i271GWPS005869@gw.tssi.com> +Subject: Re: Fixed width rows faster? +To: pg@rbt.ca (Rod Taylor) +Date: Sat, 6 Mar 2004 19:16:31 -0600 (CST) +Cc: josh@agliodbs.com (Josh Berkus), + wmoran@potentialtech.com (Bill Moran), threshar@torgo.978.org (Jeff), + pgsql-performance@postgresql.org (Postgresql Performance) +In-Reply-To: <1078530843.57624.24.camel@jester> from "Rod Taylor" at Mar 05, + 2004 06:54:04 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: 200403/78 +X-Sequence-Number: 5934 + +> Actually, I don't. Good reason to have a check constraint on it though +> (hint, check constraints can be changed while column types cannot be, at +> this moment). + +Is there a way to copy a table INCLUDING the check constraints? If not, +then that information is lost, unlike varchar(n). +-- +Mike Nolan + + +From pgsql-performance-owner@postgresql.org Sat Mar 6 21:21:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 11F82D1D108 + for ; + Sun, 7 Mar 2004 01:21: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 61118-02 + for ; + Sat, 6 Mar 2004 21:21:45 -0400 (AST) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 09CCCD1D105 + for ; + Sat, 6 Mar 2004 21:21:42 -0400 (AST) +Received: from [134.22.71.174] (dyn-71-174.tor.dsl.tht.net [134.22.71.174]) + by tht.net (Postfix) with ESMTP + id D3B0B76A37; Sat, 6 Mar 2004 20:21:49 -0500 (EST) +Subject: Re: Fixed width rows faster? +From: Rod Taylor +To: Mike Nolan +Cc: Josh Berkus , + Bill Moran , Jeff , + Postgresql Performance +In-Reply-To: <200403070116.i271GWPS005869@gw.tssi.com> +References: <200403070116.i271GWPS005869@gw.tssi.com> +Content-Type: text/plain +Message-Id: <1078622544.57624.26.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Sat, 06 Mar 2004 20:22:25 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/79 +X-Sequence-Number: 5935 + +On Sat, 2004-03-06 at 20:16, Mike Nolan wrote: +> > Actually, I don't. Good reason to have a check constraint on it though +> > (hint, check constraints can be changed while column types cannot be, at +> > this moment). +> +> Is there a way to copy a table INCLUDING the check constraints? If not, +> then that information is lost, unlike varchar(n). + +No, not constraints. + + +From pgsql-performance-owner@postgresql.org Sat Mar 6 21:32:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CF00AD1D108 + for ; + Sun, 7 Mar 2004 01:32: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 58537-08 + for ; + Sat, 6 Mar 2004 21:32:10 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 7346ED1D779 + for ; + Sat, 6 Mar 2004 21:32:06 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by bob.samurai.com (Postfix) with ESMTP + id 81FE21D99; Sat, 6 Mar 2004 20:32:09 -0500 (EST) +Received: from bob.samurai.com ([127.0.0.1]) + by localhost (bob.samurai.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 17502-01-7; Sat, 6 Mar 2004 20:32:09 -0500 (EST) +Received: from samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by bob.samurai.com (Postfix) with ESMTP + id 7C8A61D8A; Sat, 6 Mar 2004 20:32:08 -0500 (EST) +Message-ID: <404A7B98.7090401@samurai.com> +Date: Sat, 06 Mar 2004 20:32:08 -0500 +From: Neil Conway +User-Agent: Mozilla Thunderbird 0.5 (X11/20040304) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Mike Nolan +Cc: Rod Taylor , Josh Berkus , + Bill Moran , Jeff , + Postgresql Performance +Subject: Re: Fixed width rows faster? +References: <200403070116.i271GWPS005869@gw.tssi.com> +In-Reply-To: <200403070116.i271GWPS005869@gw.tssi.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at mailbox.samurai.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/80 +X-Sequence-Number: 5936 + +Mike Nolan wrote: +> Is there a way to copy a table INCLUDING the check constraints? If not, +> then that information is lost, unlike varchar(n). + +"pg_dump -t" should work fine, unless I'm misunderstanding you. + +-Neil + +From pgsql-performance-owner@postgresql.org Sat Mar 6 22:26:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 46225D1B51F + for ; + Sun, 7 Mar 2004 02:26: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 74665-01 + for ; + Sat, 6 Mar 2004 22:26:35 -0400 (AST) +Received: from gw.tssi.com (gw.tssi.com [198.147.197.1]) + by svr1.postgresql.org (Postfix) with ESMTP id D8B3ED1B4ED + for ; + Sat, 6 Mar 2004 22:26:30 -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 i272QV8S006571; + Sat, 6 Mar 2004 20:26:32 -0600 +Received: (from nolan@localhost) + by gw.tssi.com (8.12.6/8.12.6/Submit) id i272QUE8006569; + Sat, 6 Mar 2004 20:26:30 -0600 +From: Mike Nolan +Message-Id: <200403070226.i272QUE8006569@gw.tssi.com> +Subject: Re: Fixed width rows faster? +To: neilc@samurai.com (Neil Conway) +Date: Sat, 6 Mar 2004 20:26:30 -0600 (CST) +Cc: pg@rbt.ca (Rod Taylor), josh@agliodbs.com (Josh Berkus), + wmoran@potentialtech.com (Bill Moran), threshar@torgo.978.org (Jeff), + pgsql-performance@postgresql.org (Postgresql Performance) +In-Reply-To: <404A7B98.7090401@samurai.com> from "Neil Conway" at Mar 06, + 2004 08:32:08 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: 200403/81 +X-Sequence-Number: 5937 + +> Mike Nolan wrote: +> > Is there a way to copy a table INCLUDING the check constraints? If not, +> > then that information is lost, unlike varchar(n). +> +> "pg_dump -t" should work fine, unless I'm misunderstanding you. + +I was specifically referring to doing it in SQL. + +The COPY command goes from table to file or file to table, the +CREATE TABLE ... SELECT loses the check constraints. + +Is there no SQL command that allows me to clone a table, including check +constraints? + +Something like COPY TABLE xxx TO TABLE yyy WITH CHECK CONSTRAINTS. +-- +Mike Nolan + +From pgsql-performance-owner@postgresql.org Sat Mar 6 22:29:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 408CDD1B511 + for ; + Sun, 7 Mar 2004 02: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 67081-10 + for ; + Sat, 6 Mar 2004 22:29:30 -0400 (AST) +Received: from rwcrmhc11.comcast.net (rwcrmhc11.comcast.net [204.127.198.35]) + by svr1.postgresql.org (Postfix) with ESMTP id 090E6D1B4ED + for ; + Sat, 6 Mar 2004 22:29:26 -0400 (AST) +Received: from [10.0.1.2] (h000393e3ce55.ne.client2.attbi.com[24.91.235.158]) + by comcast.net (rwcrmhc11) with SMTP + id <20040307022928013002eirpe>; Sun, 7 Mar 2004 02:29:28 +0000 +Mime-Version: 1.0 (Apple Message framework v612) +Content-Transfer-Encoding: 7bit +Message-Id: <41C473B6-6FDF-11D8-9156-000A95BA4506@mindspring.com> +Content-Type: text/plain; charset=US-ASCII; format=flowed +To: Postgres Performance +From: John Siracusa +Subject: Re: Feature request: smarter use of conditional indexes +Date: Sat, 6 Mar 2004 21:29:27 -0500 +X-Mailer: Apple Mail (2.612) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/82 +X-Sequence-Number: 5938 + +On 3/3/04 6:53 PM, Tom Lane wrote: +> John Siracusa writes: +>> Given an index like this: +>> CREATE UNIQUE INDEX i1 ON t1 (c1) WHERE c1 IS NOT NULL; +>> and a query like this: +>> SELECT * FROM t1 WHERE c1 = 123; +>> I'd like the planner to be smart enough to use an index scan using +>> i1. +> +> Send a patch ;-) + +How does this look? It seems to do what I want without horribly +breaking anything as far as I can tell. I ran "make check" and got the +same result as I did before my changes (5 failures in OS X 10.3.2). +But then, I also got the same result when I wasn't even checking to +make sure that both clauses were looking at the same variable :) I'm +not sure how to add a test for this particular change either. + +% cvs diff src/backend/optimizer/path/indxpath.c +Index: src/backend/optimizer/path/indxpath.c +=================================================================== +RCS file: +/projects/cvsroot/pgsql-server/src/backend/optimizer/path/indxpath.c,v +retrieving revision 1.156 +diff -r1.156 indxpath.c +1032a1033,1055 + > { + > /* One last chance: "var = const" or "const = var" implies "var is +not null" */ + > if (IsA(predicate, NullTest) && + > ((NullTest *) predicate)->nulltesttype == IS_NOT_NULL && + > is_opclause(clause) && op_strict(((OpExpr *) clause)->opno) && + > length(((OpExpr *) clause)->args) == 2) + > { + > leftop = get_leftop((Expr *) clause); + > rightop = get_rightop((Expr *) clause); + > + > /* One of the two arguments must be a constant */ + > if (IsA(rightop, Const)) + > clause_var = leftop; + > else if (IsA(leftop, Const)) + > clause_var = rightop; + > else + > return false; + > + > /* Finally, make sure "var" is the same var in both clauses */ + > if (equal(((NullTest *) predicate)->arg, clause_var)) + > return true; + > } + > +1033a1057 + > } + + +From pgsql-performance-owner@postgresql.org Sat Mar 6 22:39:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 58D9ED1B51F + for ; + Sun, 7 Mar 2004 02:39: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 76076-02 + for ; + Sat, 6 Mar 2004 22:39:44 -0400 (AST) +Received: from lerami.lerctr.org (lerami.lerctr.org [207.158.72.11]) + by svr1.postgresql.org (Postfix) with ESMTP id 11F0BD1B511 + for ; + Sat, 6 Mar 2004 22:39:40 -0400 (AST) +Received: from lerlaptop.lerctr.org ([207.158.72.14]) + by lerami.lerctr.org with asmtp (Exim 4.30) + id 1AzoCc-0001w0-Ey; Sat, 06 Mar 2004 20:39:42 -0600 +Date: Sat, 06 Mar 2004 20:39:38 -0600 +From: Larry Rosenman +To: John Siracusa , + Postgres Performance +Subject: Re: Feature request: smarter use of conditional indexes +Message-ID: <32080000.1078627178@lerlaptop.lerctr.org> +In-Reply-To: <41C473B6-6FDF-11D8-9156-000A95BA4506@mindspring.com> +References: <41C473B6-6FDF-11D8-9156-000A95BA4506@mindspring.com> +X-Mailer: Mulberry/3.1.2 (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="==========5B2F37D9C3BDA9B57E07==========" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/83 +X-Sequence-Number: 5939 + +--==========5B2F37D9C3BDA9B57E07========== +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + + + +--On Saturday, March 06, 2004 21:29:27 -0500 John Siracusa=20 + wrote: + +> On 3/3/04 6:53 PM, Tom Lane wrote: +>> John Siracusa writes: +>>> Given an index like this: +>>> CREATE UNIQUE INDEX i1 ON t1 (c1) WHERE c1 IS NOT NULL; +>>> and a query like this: +>>> SELECT * FROM t1 WHERE c1 =3D 123; +>>> I'd like the planner to be smart enough to use an index scan using +>>> i1. +>> +>> Send a patch ;-) +Just a suggestion, please use diff -c format, as it makes it easier for +the folks who apply the patches to do so. +[snip] + + +--=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 + +--==========5B2F37D9C3BDA9B57E07========== +Content-Type: application/pgp-signature +Content-Transfer-Encoding: 7bit + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.4 (FreeBSD) + +iD4DBQFASotsrRNGhTxJvdYRAoUNAJjlYvpK2RsxyyZfl4TLMDS0hRFfAJ9lzd7z +K7ohm0b+2Ans6UvrttZFFw== +=ceT7 +-----END PGP SIGNATURE----- + +--==========5B2F37D9C3BDA9B57E07==========-- + + +From pgsql-performance-owner@postgresql.org Sat Mar 6 23:00:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D9788D1D165 + for ; + Sun, 7 Mar 2004 03:00: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 76259-04 + for ; + Sat, 6 Mar 2004 23:00:44 -0400 (AST) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5806DD1C96F + for ; + Sat, 6 Mar 2004 23:00:40 -0400 (AST) +Received: from [134.22.71.174] (dyn-71-174.tor.dsl.tht.net [134.22.71.174]) + by tht.net (Postfix) with ESMTP + id 757CF76A1A; Sat, 6 Mar 2004 22:00:48 -0500 (EST) +Subject: Re: Fixed width rows faster? +From: Rod Taylor +To: Mike Nolan +Cc: Neil Conway , Josh Berkus , + Bill Moran , Jeff , + Postgresql Performance +In-Reply-To: <200403070226.i272QUE8006569@gw.tssi.com> +References: <200403070226.i272QUE8006569@gw.tssi.com> +Content-Type: text/plain +Message-Id: <1078628481.57624.29.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Sat, 06 Mar 2004 22:01:22 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/84 +X-Sequence-Number: 5940 + +On Sat, 2004-03-06 at 21:26, Mike Nolan wrote: +> > Mike Nolan wrote: +> > > Is there a way to copy a table INCLUDING the check constraints? If not, +> > > then that information is lost, unlike varchar(n). +> > +> > "pg_dump -t" should work fine, unless I'm misunderstanding you. +> +> I was specifically referring to doing it in SQL. +> +> The COPY command goes from table to file or file to table, the +> CREATE TABLE ... SELECT loses the check constraints. +> +> Is there no SQL command that allows me to clone a table, including check +> constraints? + +There is not in the spec or in PostgreSQL. Although, this may be a +relevant extension to the LIKE structure inheritance in 200N spec +(partly implemented 7.4). + + +From pgsql-performance-owner@postgresql.org Sat Mar 6 23:47:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A9E72D1D43B + for ; + Sun, 7 Mar 2004 03:47: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 84614-05 + for ; + Sat, 6 Mar 2004 23:47:04 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id B5CF3D1D400 + for ; + Sat, 6 Mar 2004 23:46:59 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i273kv9X020142; + Sat, 6 Mar 2004 22:46:57 -0500 (EST) +To: Larry Rosenman +Cc: John Siracusa , + Postgres Performance +Subject: Re: Feature request: smarter use of conditional indexes +In-reply-to: <32080000.1078627178@lerlaptop.lerctr.org> +References: <41C473B6-6FDF-11D8-9156-000A95BA4506@mindspring.com> + <32080000.1078627178@lerlaptop.lerctr.org> +Comments: In-reply-to Larry Rosenman + message dated "Sat, 06 Mar 2004 20:39:38 -0600" +Date: Sat, 06 Mar 2004 22:46:57 -0500 +Message-ID: <20141.1078631217@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/85 +X-Sequence-Number: 5941 + +Larry Rosenman writes: +> Just a suggestion, please use diff -c format, as it makes it easier for +> the folks who apply the patches to do so. + +That's not just a suggestion ... patches that aren't in diff -c (or at +least diff -u) format will be rejected out of hand. Without the context +lines provided by these formats, applying a patch is an exercise in +risk-taking, because you can't be certain that you are applying the same +patch the submitter intended. + +Personally I consider -c format the only one of the three that is +readable for reviewing purposes, so even if I weren't intending +immediate application, I'd ask for -c before looking at the patch. +There are some folks who consider -u format readable, but I'm not +one of them ... + +BTW, patches really ought to go to pgsql-patches ... they're a bit +off-topic here. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 7 07:42:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BB9FD1DADC + for ; + Sun, 7 Mar 2004 11:42:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 39805-05 + for ; + Sun, 7 Mar 2004 07:42:29 -0400 (AST) +Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0090BD1D8A5 + for ; + Sun, 7 Mar 2004 07:42:26 -0400 (AST) +Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) + id 1Azwft-0004aK-Gm + for pgsql-performance@postgresql.org; Sun, 07 Mar 2004 12:42:29 +0100 +Received: from [195.135.143.206] (helo=[10.0.1.2]) + by emma.rox.net with asmtp (Exim 4.22) id 1Azwfs-0004ZZ-0K + for pgsql-performance@postgresql.org; Sun, 07 Mar 2004 12:42:28 +0100 +Mime-Version: 1.0 (Apple Message framework v612) +Content-Transfer-Encoding: 7bit +Message-Id: <7F2B9EA0-702C-11D8-9DA8-000A95C496AC@cluster9.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: PgSQL Performance ML +From: David Teran +Subject: speeding up a select with C function? +Date: Sun, 7 Mar 2004 12:42:22 +0100 +X-Mailer: Apple Mail (2.612) +X-Scanned-By: rockenstein AG +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/86 +X-Sequence-Number: 5942 + +Hi, + + we need to optimize / speed up a simple select: + +explain analyze select +((t0.int_value-t1.int_value)*(t0.int_value-t1.int_value)) +from job_property t0, job_property t1 +where t0.id_job_profile = 5 +and t1.id_job_profile = 6 +and t1.id_job_attribute = t0.id_job_attribute +and t1.int_value < t0.int_value; + +the result from explain analyze is: + +first run: +------------------------------------------------------------------------ +------------------------------------------------------------------------ +------------------------------ + Merge Join (cost=8314.36..8336.21 rows=258 width=8) (actual +time=226.544..226.890 rows=43 loops=1) + Merge Cond: ("outer".id_job_attribute = "inner".id_job_attribute) + Join Filter: ("inner".int_value < "outer".int_value) + -> Sort (cost=4157.18..4159.75 rows=1026 width=8) (actual +time=113.781..113.826 rows=232 loops=1) + Sort Key: t0.id_job_attribute + -> Index Scan using job_property__id_job_profile__fk_index on +job_property t0 (cost=0.00..4105.87 rows=1026 width=8) (actual +time=0.045..113.244 rows=232 loops=1) + Index Cond: (id_job_profile = 5) + -> Sort (cost=4157.18..4159.75 rows=1026 width=8) (actual +time=112.504..112.544 rows=254 loops=1) + Sort Key: t1.id_job_attribute + -> Index Scan using job_property__id_job_profile__fk_index on +job_property t1 (cost=0.00..4105.87 rows=1026 width=8) (actual +time=0.067..112.090 rows=254 loops=1) + Index Cond: (id_job_profile = 6) + Total runtime: 227.120 ms +(12 rows) + +second run: +------------------------------------------------------------------------ +------------------------------------------------------------------------ +---------------------------- + Merge Join (cost=8314.36..8336.21 rows=258 width=8) (actual +time=4.323..4.686 rows=43 loops=1) + Merge Cond: ("outer".id_job_attribute = "inner".id_job_attribute) + Join Filter: ("inner".int_value < "outer".int_value) + -> Sort (cost=4157.18..4159.75 rows=1026 width=8) (actual +time=2.666..2.700 rows=232 loops=1) + Sort Key: t0.id_job_attribute + -> Index Scan using job_property__id_job_profile__fk_index on +job_property t0 (cost=0.00..4105.87 rows=1026 width=8) (actual +time=0.279..2.354 rows=232 loops=1) + Index Cond: (id_job_profile = 5) + -> Sort (cost=4157.18..4159.75 rows=1026 width=8) (actual +time=1.440..1.477 rows=254 loops=1) + Sort Key: t1.id_job_attribute + -> Index Scan using job_property__id_job_profile__fk_index on +job_property t1 (cost=0.00..4105.87 rows=1026 width=8) (actual +time=0.040..1.133 rows=254 loops=1) + Index Cond: (id_job_profile = 6) + Total runtime: 4.892 ms +(12 rows) + + +I have run vacuum analyze before executing the statements. I wonder now +if there is any chance to speed this up. Could we use a C function to +access the indexes faster or is there any other chance to speed this +up? + +The Server is a dual G5/2GHZ with 8 GB of RAM and a 3.5 TB fiberchannel +RAID. The job_property table is about 1 GB large (checked with dbsize) +and has about 6.800.000 rows. + + +regards David + + +From pgsql-performance-owner@postgresql.org Sun Mar 7 09:42:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 24F22D1D38E + for ; + Sun, 7 Mar 2004 13:42: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 53211-03 + for ; + Sun, 7 Mar 2004 09:42:43 -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 8C0CFD1D38B + for ; + Sun, 7 Mar 2004 09:42:39 -0400 (AST) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id CAD9480DC; Sun, 7 Mar 2004 14:42:41 +0100 (CET) +Date: Sun, 7 Mar 2004 14:42:41 +0100 (CET) +From: Dennis Bjorklund +To: Andrew Sullivan +Cc: pgsql-performance +Subject: Re: Fixed width rows faster? +In-Reply-To: <20040306162658.GB20089@phlogiston.dyndns.org> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/87 +X-Sequence-Number: 5943 + +On Sat, 6 Mar 2004, Andrew Sullivan wrote: + +> > places is to ensure that the column can be indexed. Postgres, it seems, +> > refuses to insert a string that is longer than some value into an +> > indexed column, and I'll rather have such errors flagged while inserting +> +> Care to provide some details of this? It sure sounds like a bug to +> me, if it's true. I've never run into anything like this, though. + +There is a limit of the size of values that can be indexed. I think it's +8k or something (a block I assume). Something for someone with an itch to +fix in the future. + +The error however comes when you try to insert the value. Doing a reindex +will not change the length of the value and will always work. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Sun Mar 7 10:49:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 63A1FD1DC2E + for ; + Sun, 7 Mar 2004 14: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 55371-10 + for ; + Sun, 7 Mar 2004 10:49:12 -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 2DB71D1DC2D + for ; + Sun, 7 Mar 2004 10:49:08 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep02-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040307144829.TGWB434741.fep02-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Sun, 7 Mar 2004 09:48:29 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 1D1413F4B; Sun, 7 Mar 2004 09:49:07 -0500 (EST) +Date: Sun, 7 Mar 2004 09:49:07 -0500 +From: Andrew Sullivan +To: pgsql-performance +Subject: Re: Fixed width rows faster? +Message-ID: <20040307144907.GA23162@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance +References: <20040306162658.GB20089@phlogiston.dyndns.org> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.4i +X-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep02-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Sun, + 7 Mar 2004 09:48:27 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/88 +X-Sequence-Number: 5944 + +On Sun, Mar 07, 2004 at 02:42:41PM +0100, Dennis Bjorklund wrote: + +> The error however comes when you try to insert the value. Doing a reindex +> will not change the length of the value and will always work. + +I didn't do a good job in my quoting, but this is what I meant. It'd +surely be a bug if you could get a value into an indexed field, but +couldn't later rebuild that index. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +The fact that technology doesn't work is no bar to success in the marketplace. + --Philip Greenspun + +From pgsql-performance-owner@postgresql.org Sun Mar 7 11:02:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D263D1DB0B + for ; + Sun, 7 Mar 2004 15:02: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 65058-02 + for ; + Sun, 7 Mar 2004 11:02:15 -0400 (AST) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2EF15D1DB23 + for ; + Sun, 7 Mar 2004 11:02:11 -0400 (AST) +Received: from [134.22.68.25] (dyn-68-25.tor.dsl.tht.net [134.22.68.25]) + by tht.net (Postfix) with ESMTP + id 8D20276A36; Sun, 7 Mar 2004 10:02:16 -0500 (EST) +Subject: Re: speeding up a select with C function? +From: Rod Taylor +To: David Teran +Cc: PgSQL Performance ML +In-Reply-To: <7F2B9EA0-702C-11D8-9DA8-000A95C496AC@cluster9.com> +References: <7F2B9EA0-702C-11D8-9DA8-000A95C496AC@cluster9.com> +Content-Type: text/plain +Message-Id: <1078671774.57624.52.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Sun, 07 Mar 2004 10:02:55 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/89 +X-Sequence-Number: 5945 + +> I have run vacuum analyze before executing the statements. I wonder now +> if there is any chance to speed this up. + +Is this an active table for writes? You may want to take a look at +CLUSTER. In some circumstances, it can take an order of magnitude off +the query time by allowing less pages to be retrieved from disk. + +Other than that, if you're willing to drop performance of all queries +not hitting the table to speed up this one, you can pin the index and +table into memory (cron job running a select periodically to ensure it +sticks). + +Shrink the actual data size (Drop the OID column, use a smallint instead +of an integer, etc.) + + +One final option is to alter PostgreSQL into possibly doing a +sudo-sequential scan on the table when reading indexes, rather than +pulling data from the table in a random order as it is found in the +index. This is a rather complex project, but doable. +http://momjian.postgresql.org/cgi-bin/pgtodo?performance + + +From pgsql-performance-owner@postgresql.org Sun Mar 7 20:27:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BA798D1C96F + for ; + Mon, 8 Mar 2004 00:27: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 45796-05 + for ; + Sun, 7 Mar 2004 20:27:16 -0400 (AST) +Received: from gizmo08bw.bigpond.com (gizmo08bw.bigpond.com [144.140.70.18]) + by svr1.postgresql.org (Postfix) with SMTP id B6A50D1B967 + for ; + Sun, 7 Mar 2004 20:27:11 -0400 (AST) +Received: (qmail 31112 invoked from network); 8 Mar 2004 00:19:38 -0000 +Received: from unknown (HELO bwmam07.bigpond.com) (144.135.24.87) + by gizmo08bw.bigpond.com with SMTP; 8 Mar 2004 00:19:38 -0000 +Received: from cpe-203-45-192-2.qld.bigpond.net.au ([203.45.192.2]) by + bwmam07.bigpond.com(MAM REL_3_4_2 62/1036324) with SMTP id + 1036324; Mon, 08 Mar 2004 10:27:12 +1000 +Message-ID: <001101c404a3$fb34d320$fd08a8c0@steve> +From: "Steven Butler" +To: +Subject: Using bigint needs explicit cast to use the index +Date: Mon, 8 Mar 2004 10:26:21 +1000 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/90 +X-Sequence-Number: 5946 + +Hi, + +I've recently converted a database to use bigint for the indices. Suddenly +simple queries like + +select * from new_test_result where parent_id = 2 + +are doing full table scans instead of using the index. The table has over 4 +million rows, of which only 30 or so would be selected by the query. + +The database table in question was fully vacuumed and clustered on the +index. + +I tried disabling seqscan, but it still did full table scan. After browsing +around a bit, I had a hunch it might be failing to use the index because it +is perhaps converting the parent_id to an integer, and I don't have a +functional index on that (wouldn't seem correct either). + +I tested my hunch by casting the constant to bigint (as can be seen below) +and suddenly the query is using the index again. + +We are currently using pg 7.3.4. Is this intended behaviour? Should the +constant be cast to the type of the table column where possible, or should +it be the other way around? If this is considered a bug, is it already +fixed, in 7.3.6 or 7.4.x? + +Kind Regards, +Steve Butler + + + +steve=# \d new_test_result; + Table "public.new_test_result" + Column | Type | Modifiers +-----------+---------+------------------------------------------------------ +----------- + id | bigint | not null default +nextval('public.new_test_result_id_seq'::text) + parent_id | bigint | + testcode | text | + testtype | text | + testdesc | text | + pass | integer | + latency | integer | + bytessent | integer | + bytesrecv | integer | + defect | text | +Indexes: test_result_parent_id_fk btree (parent_id) +Foreign Key constraints: $1 FOREIGN KEY (parent_id) REFERENCES +new_test_run(id) ON UPDATE NO ACTION ON DELETE CASCADE + +steve=# explain select * from new_test_result where parent_id = 2; + QUERY PLAN +----------------------------------------------------------------------- + Seq Scan on new_test_result (cost=0.00..123370.57 rows=23 width=125) + Filter: (parent_id = 2) +(2 rows) + +steve=# explain select * from new_test_result where parent_id = 2::bigint; + QUERY PLAN +---------------------------------------------------------------------------- +----------------------- + Index Scan using test_result_parent_id_fk on new_test_result +(cost=0.00..3.32 rows=23 width=125) + Index Cond: (parent_id = 2::bigint) +(2 rows) + + +From pgsql-performance-owner@postgresql.org Sun Mar 7 20:44:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5696DD1B967 + for ; + Mon, 8 Mar 2004 00:44: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 45935-05 + for ; + Sun, 7 Mar 2004 20:44:02 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id 89092D1B8BC + for ; + Sun, 7 Mar 2004 20:43:58 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by bob.samurai.com (Postfix) with ESMTP + id 452B51E03; Sun, 7 Mar 2004 19:44:01 -0500 (EST) +Received: from bob.samurai.com ([127.0.0.1]) + by localhost (bob.samurai.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 56631-01; Sun, 7 Mar 2004 19:43:59 -0500 (EST) +Received: from samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by bob.samurai.com (Postfix) with ESMTP + id 5E1A01DD8; Sun, 7 Mar 2004 19:43:59 -0500 (EST) +Message-ID: <404BC1CE.3040009@samurai.com> +Date: Sun, 07 Mar 2004 19:43:58 -0500 +From: Neil Conway +User-Agent: Mozilla Thunderbird 0.5 (X11/20040304) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Steven Butler +Cc: pgsql-performance@postgresql.org +Subject: Re: Using bigint needs explicit cast to use the index +References: <001101c404a3$fb34d320$fd08a8c0@steve> +In-Reply-To: <001101c404a3$fb34d320$fd08a8c0@steve> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at mailbox.samurai.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/91 +X-Sequence-Number: 5947 + +Steven Butler wrote: +> I've recently converted a database to use bigint for the indices. Suddenly +> simple queries like +> +> select * from new_test_result where parent_id = 2 +> +> are doing full table scans instead of using the index. + +This is fixed in CVS HEAD. In the mean time, you can enclose the +integer literal in single quotes, or explicitely cast it to the type +of the column. + +FWIW, this is an FAQ. + +-Neil + +From pgsql-performance-owner@postgresql.org Sun Mar 7 21:25:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 748ACD1B51F + for ; + Mon, 8 Mar 2004 01:25: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 45991-09 + for ; + Sun, 7 Mar 2004 21:25:25 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 4FFBBD1B4B0 + for ; + Sun, 7 Mar 2004 21:25:20 -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 + i281PESw006077; Mon, 8 Mar 2004 09:25:16 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <404BCC6F.5060903@familyhealth.com.au> +Date: Mon, 08 Mar 2004 09:29:19 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: David Teran +Cc: PgSQL Performance ML +Subject: Re: speeding up a select with C function? +References: <7F2B9EA0-702C-11D8-9DA8-000A95C496AC@cluster9.com> +In-Reply-To: <7F2B9EA0-702C-11D8-9DA8-000A95C496AC@cluster9.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: 200403/92 +X-Sequence-Number: 5948 + +> explain analyze select +> ((t0.int_value-t1.int_value)*(t0.int_value-t1.int_value)) +> from job_property t0, job_property t1 +> where t0.id_job_profile = 5 +> and t1.id_job_profile = 6 +> and t1.id_job_attribute = t0.id_job_attribute +> and t1.int_value < t0.int_value; + +Don't bother with C function, use SQL function instead. You could get a +50% speedup. + +Chris + +From pgsql-performance-owner@postgresql.org Mon Mar 8 02:22:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E0D69D1BAF8 + for ; + Mon, 8 Mar 2004 06:22: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 92517-09 + for ; + Mon, 8 Mar 2004 02:22:07 -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 7AA8CD1B54E + for ; + Mon, 8 Mar 2004 02:22:05 -0400 (AST) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id 273B980DC; Mon, 8 Mar 2004 07:22:05 +0100 (CET) +Date: Mon, 8 Mar 2004 07:22:05 +0100 (CET) +From: Dennis Bjorklund +To: David Teran +Cc: PgSQL Performance ML +Subject: Re: speeding up a select with C function? +In-Reply-To: <7F2B9EA0-702C-11D8-9DA8-000A95C496AC@cluster9.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/93 +X-Sequence-Number: 5949 + +On Sun, 7 Mar 2004, David Teran wrote: + +> we need to optimize / speed up a simple select: +> +> explain analyze select +> ((t0.int_value-t1.int_value)*(t0.int_value-t1.int_value)) +> from job_property t0, job_property t1 +> where t0.id_job_profile = 5 +> and t1.id_job_profile = 6 +> and t1.id_job_attribute = t0.id_job_attribute +> and t1.int_value < t0.int_value; + +Try to add an index on (id_job_profile, id_job_attribute) or maybe even +(id_job_profile, id_job_attribute, int_value) + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Mon Mar 8 02:57:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E19ED1B54E + for ; + Mon, 8 Mar 2004 06:57:16 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 05857-09 + for ; + Mon, 8 Mar 2004 02:57:15 -0400 (AST) +Received: from dnscache2.syd.nexon.com.au (dnscache2.syd.nexon.com.au + [210.215.48.100]) + by svr1.postgresql.org (Postfix) with ESMTP id D3490D1B562 + for ; + Mon, 8 Mar 2004 02:57:12 -0400 (AST) +Received: from chris ([210.215.130.98]) + by dnscache2.syd.nexon.com.au (8.12.8p1/8.12.8) with ESMTP id + i283tt9g020952; Mon, 8 Mar 2004 14:55:55 +1100 (EST) + (envelope-from chris@interspire.com) +From: "Chris Smith" +To: +Subject: simple query join +Date: Mon, 8 Mar 2004 17:57:09 +1100 +Message-ID: <002201c404da$93d50790$0d00a8c0@chris> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0023_01C40536.C7457F90" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2616 +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/94 +X-Sequence-Number: 5950 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0023_01C40536.C7457F90 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit + +Hi all, + +I've got what should be a relatively simple join between two tables that +is taking forever and I can't work out why. + +Version 7.3.4RH. + +It can't be upgraded because the system is kept in sync with RedHat +Enterprise (using up2date). Not my system otherwise I'd do that :( + +Database has been 'vacuum analyze'd. + +blah=> \d sq_asset; + Table "public.sq_asset" + Column | Type | Modifiers + +----------------+-----------------------------+------------------------- +- + type_code | character varying(100) | not null + version | character varying(20) | not null default '0.0.0' + name | character varying(255) | not null default '' + short_name | character varying(255) | not null default '' + status | integer | not null default 1 + languages | character varying(50) | not null default '' + charset | character varying(50) | not null default '' + force_secure | character(1) | not null default '0' + created | timestamp without time zone | not null + updated | timestamp without time zone | not null + created_userid | character varying(255) | not null default '0' + updated_userid | character varying(255) | not null default '0' + assetid | integer | not null default 0 +Indexes: sq_asset_pkey primary key btree (assetid) + +blah=> select count(*) from sq_asset; + count +------- + 16467 +(1 row) + + +blah=> \d sq_asset_permission; + Table "public.sq_asset_permission" + Column | Type | Modifiers +------------+------------------------+---------------------- + permission | integer | not null default 0 + access | character(1) | not null default '0' + assetid | character varying(255) | not null default '0' + userid | character varying(255) | not null default '0' +Indexes: sq_asset_permission_pkey primary key btree (assetid, userid, +permission) + "sq_asset_permission_access" btree ("access") + "sq_asset_permission_assetid" btree (assetid) + "sq_asset_permission_permission" btree (permission) + "sq_asset_permission_userid" btree (userid) + +blah=> select count(*) from sq_asset_permission; + count +------- + 73715 +(1 row) + + +EXPLAIN ANALYZE SELECT p.* +FROM sq_asset a, sq_asset_permission p +WHERE a.assetid = p.assetid +AND p.permission = '1' +AND p.access = '1' +AND p.userid = '0'; + QUERY PLAN +------------------------------------------------------------------------ +-------------------------------------------------------- + Nested Loop (cost=0.00..4743553.10 rows=2582 width=27) (actual +time=237.91..759310.60 rows=11393 loops=1) + Join Filter: (("inner".assetid)::text = ("outer".assetid)::text) + -> Seq Scan on sq_asset_permission p (cost=0.00..1852.01 rows=2288 +width=23) (actual time=0.06..196.90 rows=12873 loops=1) + Filter: ((permission = 1) AND ("access" = '1'::bpchar) AND +(userid = '0'::character varying)) + -> Seq Scan on sq_asset a (cost=0.00..1825.67 rows=16467 width=4) +(actual time=1.40..29.09 rows=16467 loops=12873) + Total runtime: 759331.85 msec +(6 rows) + + +It's a straight join so I can't see why it would be this slow.. The +tables are pretty small too. + +Thanks for any suggestions :) + +Chris. + + +------=_NextPart_000_0023_01C40536.C7457F90 +Content-Type: text/html; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + + + + +Message + + + +
Hi=20 +all,
+
 
+
I've go= +t what=20 +should be a relatively simple join between two tables that is taking foreve= +r and=20 +I can't work out why.
+
 
+
Version= +=20 +7.3.4RH.
+
 
+
It can'= +t be=20 +upgraded because the system is kept in sync with RedHat Enterprise (using= +=20 +up2date). Not my system otherwise I'd do that :(
+
 
+
Databas= +e has been=20 +'vacuum analyze'd.
+
 
+
blah=3D= +> \d=20 +sq_asset;
          &n= +bsp;            = +; =20 +Table "public.sq_asset"
    =20 +Column    =20 +|           =20 +Type            = +;=20 +|       =20 +Modifiers        =20 +
----------------+-----------------------------+------------------------= +--
 type_code     =20 +| character varying(100)      | not=20 +null
 version        | character= +=20 +varying(20)       | not null default=20 +'0.0.0'
 name         = + =20 +| character varying(255)      | not null default= +=20 +''
 short_name     | character=20 +varying(255)      | not null default=20 +''
 status         |=20 +integer           &n= +bsp;        =20 +| not null default 1
 languages      |=20 +character varying(50)       | not null defaul= +t=20 +''
 charset        | character= +=20 +varying(50)       | not null default=20 +''
 force_secure   |=20 +character(1)          &nb= +sp;    =20 +| not null default=20 +'0'
 created        | timestamp= +=20 +without time zone | not=20 +null
 updated        | timestamp= +=20 +without time zone | not null
 created_userid | character=20 +varying(255)      | not null default=20 +'0'
 updated_userid | character=20 +varying(255)      | not null default=20 +'0'
 assetid        |=20 +integer           &n= +bsp;        =20 +| not null default 0
Indexes: sq_asset_pkey primary key btree=20 +(assetid)
+
+
blah=3D= +> select=20 +count(*) from sq_asset;
 count
-------
 16467
(1=20 +row)
+
 
+
 
+
blah=3D= +> \d=20 +sq_asset_permission;
        &nb= +sp;   =20 +Table "public.sq_asset_permission"
   Column  =20 +|         =20 +Type         =20 +|      Modifiers     &nbs= +p;=20 +
------------+------------------------+----------------------
 p= +ermission=20 +|=20 +integer           &n= +bsp;   =20 +| not null default 0
 access     |=20 +character(1)           | = +not=20 +null default '0'
 assetid    | character varying(255= +) |=20 +not null default '0'
 userid     | character=20 +varying(255) | not null default '0'
Indexes: sq_asset_permission_pkey pr= +imary=20 +key btree (assetid, userid, permission)
   =20 +"sq_asset_permission_access" btree ("access")
   =20 +"sq_asset_permission_assetid" btree (assetid)
   =20 +"sq_asset_permission_permission" btree (permission)
   = +=20 +"sq_asset_permission_userid" btree (userid)
+
blah=3D= +> select=20 +count(*) from sq_asset_permission;
 count=20 +
-------
 73715
(1 row)
+
 
+
EXPLAIN= + ANALYZE=20 +SELECT p.*
FROM sq_asset a, sq_asset_permission p
WHERE a.assetid =3D= +=20 +p.assetid
AND p.permission =3D '1'
AND p.access =3D '1'
AND p.user= +id =3D=20 +'0';
           &= +nbsp;           &nbs= +p;            &= +nbsp;           &nbs= +p;         =20 +QUERY=20 +PLAN
-------------------------------------------------------------------= +-------------------------------------------------------------
 Nest= +ed=20 +Loop  (cost=3D0.00..4743553.10 rows=3D2582 width=3D27) (actual=20 +time=3D237.91..759310.60 rows=3D11393 loops=3D1)
   Join Filte= +r:=20 +(("inner".assetid)::text =3D ("outer".assetid)::text)
   ->= + =20 +Seq Scan on sq_asset_permission p  (cost=3D0.00..1852.01 rows=3D2288 w= +idth=3D23)=20 +(actual time=3D0.06..196.90 rows=3D12873=20 +loops=3D1)
         Filter:=20 +((permission =3D 1) AND ("access" =3D '1'::bpchar) AND (userid =3D '0'::cha= +racter=20 +varying))
   ->  Seq Scan on sq_asset a =20 +(cost=3D0.00..1825.67 rows=3D16467 width=3D4) (actual time=3D1.40..29.09 ro= +ws=3D16467=20 +loops=3D12873)
 Total runtime: 759331.85 msec
(6=20 +rows)
+
 
+
It's a = +straight=20 +join so I can't see why it would be this slow.. The tables are pretty small= +=20 +too.
+
 
+
Thanks = +for any=20 +suggestions :)
+
 
+
Chris.
+
 
+ +------=_NextPart_000_0023_01C40536.C7457F90-- + + +From pgsql-performance-owner@postgresql.org Mon Mar 8 03:12:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C2FE8D1D18D + for ; + Mon, 8 Mar 2004 07:12:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 06333-08 + for ; + Mon, 8 Mar 2004 03:12:53 -0400 (AST) +Received: from gizmo04bw.bigpond.com (gizmo04bw.bigpond.com [144.140.70.14]) + by svr1.postgresql.org (Postfix) with SMTP id 9F80BD1B530 + for ; + Mon, 8 Mar 2004 03:12:49 -0400 (AST) +Received: (qmail 12553 invoked from network); 8 Mar 2004 07:08:04 -0000 +Received: from unknown (HELO bwmam07.bigpond.com) (144.135.24.87) + by gizmo04bw.bigpond.com with SMTP; 8 Mar 2004 07:08:04 -0000 +Received: from cpe-203-45-192-2.qld.bigpond.net.au ([203.45.192.2]) by + bwmam07.bigpond.com(MAM REL_3_4_2 62/1158095) with SMTP id + 1158095; Mon, 08 Mar 2004 17:12:47 +1000 +Message-ID: <006901c404dc$a43af520$fd08a8c0@steve> +From: "Steven Butler" +To: "Chris Smith" , + +References: <002201c404da$93d50790$0d00a8c0@chris> +Subject: Re: simple query join +Date: Mon, 8 Mar 2004 17:11:56 +1000 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0066_01C40530.75C6FA00" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/95 +X-Sequence-Number: 5951 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0066_01C40530.75C6FA00 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +MessageLooks to me like it's because your assetid is varchar in one table a= +nd an integer in the other table. AFAIK, PG is unable to use an index join= + when the join types are different. The query plan shows it is doing full = +table scans of both tables. + +Change both to varchar or both to integer and see what happens. + +Also make sure to vacuum analyze the tables regularly to keep the query pla= +nner statistics up-to-date. + +Cheers, +Steve Butler + assetid | integer | not null default 0 + Indexes: sq_asset_pkey primary key btree (assetid) + + assetid | character varying(255) | not null default '0' + EXPLAIN ANALYZE SELECT p.* + FROM sq_asset a, sq_asset_permission p + WHERE a.assetid =3D p.assetid + AND p.permission =3D '1' + AND p.access =3D '1' + AND p.userid =3D '0'; + QUERY PLAN + -------------------------------------------------------------------------= +------------------------------------------------------- + Nested Loop (cost=3D0.00..4743553.10 rows=3D2582 width=3D27) (actual ti= +me=3D237.91..759310.60 rows=3D11393 loops=3D1) + Join Filter: (("inner".assetid)::text =3D ("outer".assetid)::text) + -> Seq Scan on sq_asset_permission p (cost=3D0.00..1852.01 rows=3D22= +88 width=3D23) (actual time=3D0.06..196.90 rows=3D12873 loops=3D1) + Filter: ((permission =3D 1) AND ("access" =3D '1'::bpchar) AND (= +userid =3D '0'::character varying)) + -> Seq Scan on sq_asset a (cost=3D0.00..1825.67 rows=3D16467 width= +=3D4) (actual time=3D1.40..29.09 rows=3D16467 loops=3D12873) + Total runtime: 759331.85 msec + (6 rows) + +------=_NextPart_000_0066_01C40530.75C6FA00 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + +Message + + + + + +
Looks to me like it's because your assetid= + is=20 +varchar in one table and an integer in the other table.  AFAIK, PG is= +=20 +unable to use an index join when the join types are different.  The qu= +ery=20 +plan shows it is doing full table scans of both tables.
+
 
+
Change both to varchar or both to integer = +and see=20 +what happens.
+
 
+
Also make sure to vacuum analyze the table= +s=20 +regularly to keep the query planner statistics up-to-date.
+
 
+
Cheers,
+
Steve Butler
+
+
 assetid      = +  |=20 + integer           = +         =20 + | not null default 0
Indexes: sq_asset_pkey primary key btree=20 + (assetid)
+
+
 assetid    | character varying(255) | not n= +ull=20 + default '0'
EXPLAIN ANALYZE SELECT p.*
FROM sq_asset a, sq_asset_permissi= +on=20 + p
WHERE a.assetid =3D p.assetid
AND p.permission =3D '1'
AND p.a= +ccess =3D=20 + '1'
AND p.userid =3D=20 + '0';
           = +;            &n= +bsp;            = +;            &n= +bsp;         =20 + QUERY=20 + PLAN
-----------------------------------------------------------------= +---------------------------------------------------------------
 Ne= +sted=20 + Loop  (cost=3D0.00..4743553.10 rows=3D2582 width=3D27) (actual=20 + time=3D237.91..759310.60 rows=3D11393 loops=3D1)
   Join Fil= +ter:=20 + (("inner".assetid)::text =3D ("outer".assetid)::text)
  =20 + ->  Seq Scan on sq_asset_permission p  (cost=3D0.00..1852.01= +=20 + rows=3D2288 width=3D23) (actual time=3D0.06..196.90 rows=3D12873=20 + loops=3D1)
         Filter:=20 + ((permission =3D 1) AND ("access" =3D '1'::bpchar) AND (userid =3D '0'::c= +haracter=20 + varying))
   ->  Seq Scan on sq_asset a =20 + (cost=3D0.00..1825.67 rows=3D16467 width=3D4) (actual time=3D1.40..29.09 = +rows=3D16467=20 + loops=3D12873)
 Total runtime: 759331.85 msec
(6=20 + rows)
+ +------=_NextPart_000_0066_01C40530.75C6FA00-- + + +From pgsql-performance-owner@postgresql.org Mon Mar 8 03:47:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C6012D1D4C3 + for ; + Mon, 8 Mar 2004 07:47: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 15807-05 + for ; + Mon, 8 Mar 2004 03:47:52 -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 E540AD1B530 + for ; + Mon, 8 Mar 2004 03:47:50 -0400 (AST) +Received: from zigo.zigo.dhs.org (zigo.zigo.dhs.org [192.168.0.1]) + by zigo.dhs.org (Postfix) with ESMTP + id A79D180DC; Mon, 8 Mar 2004 08:47:51 +0100 (CET) +Date: Mon, 8 Mar 2004 08:47:51 +0100 (CET) +From: Dennis Bjorklund +To: Chris Smith +Cc: pgsql-performance@postgresql.org +Subject: Re: simple query join +In-Reply-To: <002201c404da$93d50790$0d00a8c0@chris> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=ISO-8859-1 +Content-Transfer-Encoding: 8BIT +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/96 +X-Sequence-Number: 5952 + +On Mon, 8 Mar 2004, Chris Smith wrote: + +> assetid | integer | not null default 0 + +> assetid | character varying(255) | not null default '0' + +The types above does not match, and these are the attributes you use to +join. + +-- +/Dennis Bj�rklund + + +From pgsql-performance-owner@postgresql.org Mon Mar 8 05:39:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D563BD1B530 + for ; + Mon, 8 Mar 2004 09:39: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 31658-10 + for ; + Mon, 8 Mar 2004 05:39:43 -0400 (AST) +Received: from expasy-ng.isb-sib.ch (expasy-f.unige.ch [192.33.215.142]) + by svr1.postgresql.org (Postfix) with ESMTP id 286FDD1DB5B + for ; + Mon, 8 Mar 2004 05:39:39 -0400 (AST) +Received: from caliente (router.isb-sib.ch [192.33.215.254]) + (authenticated bits=0) + by expasy-ng.isb-sib.ch (8.12.10/8.12.8) with ESMTP id i289daki026702; + Mon, 8 Mar 2004 10:39:36 +0100 +Message-ID: <004101c404f1$537989c0$c300000a@caliente> +From: "Eric Jain" +To: "Tom Lane" +Cc: "pgsql-performance" +References: + <404889A6.7@potentialtech.com> + <200403051528.55578.josh@agliodbs.com> + <004501c4037d$63e27f80$c300000a@caliente> + <18296.1078606346@sss.pgh.pa.us> +Subject: Re: Fixed width rows faster? +Date: Mon, 8 Mar 2004 10:39:59 +0100 +Organization: Swiss Institute of Bioinformatics +MIME-Version: 1.0 +Content-Type: text/plain; + charset="Windows-1252" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-sib-MailScanner-Information: Please contact the ISP for more information +X-sib-MailScanner: Found to be clean +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/97 +X-Sequence-Number: 5953 + +> This is bogus reasoning. The limit on index entry length will not +> change when you rebuild the index. + +What I meant by 'rebuilding' was not issuing a REINDEX command, but +creating a new index after having dropped the index and inserted +whatever records. Building indexes can be slow, and I'd rather not have +the operation fail after several hours because record #98556761 is +deemed to be too long for indexing... + +While we are busy complaining, it's a pity Postgres doesn't allow us to +disable and later recreate all indexes on a table using a single command +;-) + + +From pgsql-performance-owner@postgresql.org Mon Mar 8 12:05:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0CBE0D1D5D9 + for ; + Mon, 8 Mar 2004 16:05: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 38002-04 + for ; + Mon, 8 Mar 2004 12:05:28 -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 049B5D1D550 + for ; + Mon, 8 Mar 2004 12:05:27 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep02-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040308160445.ECBO434741.fep02-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Mon, 8 Mar 2004 11:04:45 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 309833F40; Mon, 8 Mar 2004 11:05:25 -0500 (EST) +Date: Mon, 8 Mar 2004 11:05:25 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: Using bigint needs explicit cast to use the index +Message-ID: <20040308160525.GA25077@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <001101c404a3$fb34d320$fd08a8c0@steve> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <001101c404a3$fb34d320$fd08a8c0@steve> +User-Agent: Mutt/1.5.4i +X-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep02-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Mon, + 8 Mar 2004 11:04:44 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/98 +X-Sequence-Number: 5954 + +On Mon, Mar 08, 2004 at 10:26:21AM +1000, Steven Butler wrote: +> I tested my hunch by casting the constant to bigint (as can be seen below) +> and suddenly the query is using the index again. + +Yes. You can make this work all the time by quoting the constant. +That is, instead of + + WHERE indexcolumn = 123 + +do + + WHERE indexcolumn = '123' + + +> We are currently using pg 7.3.4. Is this intended behaviour? Should the +> constant be cast to the type of the table column where possible, or should + +"Intended", no. "Expected", yes. This topic has had the best +Postgres minds work on it, and so far nobody's come up with a +solution. There was a proposal to put in a special-case automatic +fix for int4/int8 in 7.4, but I don't know whether it made it in. + +A +-- +Andrew Sullivan | ajs@crankycanuck.ca +I remember when computers were frustrating because they *did* exactly what +you told them to. That actually seems sort of quaint now. + --J.D. Baldwin + +From pgsql-performance-owner@postgresql.org Mon Mar 8 12:23:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F0592D1B53C + for ; + Mon, 8 Mar 2004 16:23: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 42879-04 + for ; + Mon, 8 Mar 2004 12:23:04 -0400 (AST) +Received: from bob.samurai.com (bob.samurai.com [205.207.28.75]) + by svr1.postgresql.org (Postfix) with ESMTP id B243CD1D9E6 + for ; + Mon, 8 Mar 2004 12:23:03 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by bob.samurai.com (Postfix) with ESMTP + id 929891E36; Mon, 8 Mar 2004 11:22:57 -0500 (EST) +Received: from bob.samurai.com ([127.0.0.1]) + by localhost (bob.samurai.com [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 84105-01-5; Mon, 8 Mar 2004 11:22:57 -0500 (EST) +Received: from samurai.com (d226-89-59.home.cgocable.net [24.226.89.59]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by bob.samurai.com (Postfix) with ESMTP + id B23FD1D9D; Mon, 8 Mar 2004 11:22:56 -0500 (EST) +Message-ID: <404C9DE0.7000200@samurai.com> +Date: Mon, 08 Mar 2004 11:22:56 -0500 +From: Neil Conway +User-Agent: Mozilla Thunderbird 0.5 (X11/20040304) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Andrew Sullivan +Cc: pgsql-performance@postgresql.org +Subject: Re: Using bigint needs explicit cast to use the index +References: <001101c404a3$fb34d320$fd08a8c0@steve> + <20040308160525.GA25077@phlogiston.dyndns.org> +In-Reply-To: <20040308160525.GA25077@phlogiston.dyndns.org> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at mailbox.samurai.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/99 +X-Sequence-Number: 5955 + +Andrew Sullivan wrote: +> "Intended", no. "Expected", yes. This topic has had the best +> Postgres minds work on it, and so far nobody's come up with a +> solution. + +Actually, this has already been fixed in CVS HEAD (as I mentioned in +this thread yesterday). To wit: + +nconway=# create table t1 (a int8); +CREATE TABLE +nconway=# create index t1_a_idx on t1 (a); +CREATE INDEX +nconway=# explain select * from t1 where a = 5; + QUERY PLAN +-------------------------------------------------------------------- + Index Scan using t1_a_idx on t1 (cost=0.00..17.07 rows=5 width=8) + Index Cond: (a = 5) +(2 rows) +nconway=# select version(); + version +------------------------------------------------------------------------------------ + PostgreSQL 7.5devel on i686-pc-linux-gnu, compiled by GCC gcc (GCC) +3.3.3 (Debian) +(1 row) + +-Neil + +From pgsql-performance-owner@postgresql.org Mon Mar 8 12:30:49 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CC203D1CCB9 + for ; + Mon, 8 Mar 2004 16:30:48 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 42676-06 + for ; + Mon, 8 Mar 2004 12:30:38 -0400 (AST) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 592B0D1C9C4 + for ; + Mon, 8 Mar 2004 12:30:37 -0400 (AST) +Received: (qmail 24073 invoked by uid 500); 8 Mar 2004 16:33:20 -0000 +Date: Mon, 8 Mar 2004 10:33:20 -0600 +From: Bruno Wolff III +To: pgsql-performance@postgresql.org +Subject: Re: Using bigint needs explicit cast to use the index +Message-ID: <20040308163320.GA32497@wolff.to> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <001101c404a3$fb34d320$fd08a8c0@steve> + <20040308160525.GA25077@phlogiston.dyndns.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20040308160525.GA25077@phlogiston.dyndns.org> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/100 +X-Sequence-Number: 5956 + +On Mon, Mar 08, 2004 at 11:05:25 -0500, + Andrew Sullivan wrote: +> +> "Intended", no. "Expected", yes. This topic has had the best +> Postgres minds work on it, and so far nobody's come up with a +> solution. There was a proposal to put in a special-case automatic +> fix for int4/int8 in 7.4, but I don't know whether it made it in. + +This is handled better in 7.5. Instead of doing things deciding what +types of type conversion to do, a check is make for cross type conversion +functions that could be used for an index scan. This is a general solution +that doesn't result in unexpected type conversions. + +From pgsql-performance-owner@postgresql.org Mon Mar 8 12:52:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 49113D1CA83 + for ; + Mon, 8 Mar 2004 16:52: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 45655-07 + for ; + Mon, 8 Mar 2004 12:51:56 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 52869D1B906 + for ; + Mon, 8 Mar 2004 12:51:56 -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 i28Gpr1Y099639 + for ; Mon, 8 Mar 2004 16:51:53 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i28GfbMK097146 + for pgsql-performance@postgresql.org; Mon, 8 Mar 2004 16:41:37 GMT +From: William Yu +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Scaling further up +Date: Mon, 08 Mar 2004 08:40:28 -0800 +Organization: Hub.Org Networking Services +Lines: 20 +Message-ID: +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098045@vt-pe2550-001.vantage.vantage.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.5) Gecko/20031007 +X-Accept-Language: en-us, en +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098045@vt-pe2550-001.vantage.vantage.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/102 +X-Sequence-Number: 5958 + +Anjan Dave wrote: +> Great response, Thanks. +> +> Regarding 12GB memory and 13G db, and almost no I/O, one thing I don't +> understand is that even though the OS caches most of the memory and PG +> can use it if it needs it, why would the system swap (not much, only +> during peak times)? The SHMMAX is set to 512MB, shared_buffers is 150MB, +> effective cache size is 2GB, sort mem is 2MB, rest is default values. It +> also happens that a large query (reporting type) can hold up the other +> queries, and the load averages shoot up during peak times. + +In regards to your system going to swap, the only item I see is sort_mem +at 2MB. How many simultaneous transactions do you get? If you get +hundreds or thousands like your first message stated, every select sort +would take up 2MB of memory regardless of whether it needed it or not. +That could cause your swap activity during peak traffic. + +The only other item to bump up is the effective cache size -- I'd set it +to 12GB. + + +From pgsql-performance-owner@postgresql.org Mon Mar 8 12:46:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 08D18D1CCBF + for ; + Mon, 8 Mar 2004 16:46: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 45823-10 + for ; + Mon, 8 Mar 2004 12:46:38 -0400 (AST) +Received: from fep01-mail.bloor.is.net.cable.rogers.com + (fep01-mail.bloor.is.net.cable.rogers.com [66.185.86.71]) + by svr1.postgresql.org (Postfix) with ESMTP id 81956D1B53C + for ; + Mon, 8 Mar 2004 12:46:36 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep01-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040308164622.HBRF230350.fep01-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Mon, 8 Mar 2004 11:46:22 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 5917E3F40; Mon, 8 Mar 2004 11:46:34 -0500 (EST) +Date: Mon, 8 Mar 2004 11:46:34 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: Using bigint needs explicit cast to use the index +Message-ID: <20040308164634.GB25077@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <001101c404a3$fb34d320$fd08a8c0@steve> + <20040308160525.GA25077@phlogiston.dyndns.org> + <404C9DE0.7000200@samurai.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <404C9DE0.7000200@samurai.com> +User-Agent: Mutt/1.5.4i +X-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep01-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Mon, + 8 Mar 2004 11:46:22 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/101 +X-Sequence-Number: 5957 + +On Mon, Mar 08, 2004 at 11:22:56AM -0500, Neil Conway wrote: +> Actually, this has already been fixed in CVS HEAD (as I mentioned in +> this thread yesterday). To wit: + +Yes, I saw that after I sent my mail. What can I say except, "Yay! +Good work!" + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +This work was visionary and imaginative, and goes to show that visionary +and imaginative work need not end up well. + --Dennis Ritchie + +From pgsql-performance-owner@postgresql.org Mon Mar 8 13:55:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DCD97D1DC19 + for ; + Mon, 8 Mar 2004 17:55: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 66665-05 + for ; + Mon, 8 Mar 2004 13:55:47 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 0356CD1DB96 + for ; + Mon, 8 Mar 2004 13:55:45 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i28Htau25541; + Mon, 8 Mar 2004 12:55:36 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403081755.i28Htau25541@candle.pha.pa.us> +Subject: Re: Feature request: smarter use of conditional indexes +In-Reply-To: <20141.1078631217@sss.pgh.pa.us> +To: Tom Lane +Date: Mon, 8 Mar 2004 12:55:36 -0500 (EST) +Cc: Larry Rosenman , John Siracusa , + Postgres 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: 200403/103 +X-Sequence-Number: 5959 + +Tom Lane wrote: +> Larry Rosenman writes: +> > Just a suggestion, please use diff -c format, as it makes it easier for +> > the folks who apply the patches to do so. +> +> That's not just a suggestion ... patches that aren't in diff -c (or at +> least diff -u) format will be rejected out of hand. Without the context +> lines provided by these formats, applying a patch is an exercise in +> risk-taking, because you can't be certain that you are applying the same +> patch the submitter intended. + +Also, when you get 'fuzz' output when applying the patch, you should +review the patch to make sure it appeared in the right place. That has +gotten me a few times. + +-- + 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 Mar 8 17:43:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E86FD1C4EB + for ; + Mon, 8 Mar 2004 21:43: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 28958-01 + for ; + Mon, 8 Mar 2004 17:43:49 -0400 (AST) +Received: from dnscache2.syd.nexon.com.au (dnscache2.syd.nexon.com.au + [210.215.48.100]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DFE5D1BB93 + for ; + Mon, 8 Mar 2004 17:43:45 -0400 (AST) +Received: from chris ([210.215.130.98]) + by dnscache2.syd.nexon.com.au (8.12.8p1/8.12.8) with ESMTP id + i28IgT9g056479 for ; + Tue, 9 Mar 2004 05:42:30 +1100 (EST) + (envelope-from chris@interspire.com) +From: "Chris Smith" +To: +Subject: Re: simple query join +Date: Tue, 9 Mar 2004 08:43:40 +1100 +Message-ID: <000501c40556$6c25cf00$0d00a8c0@chris> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_0006_01C405B2.9F964700" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2616 +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +In-Reply-To: <006901c404dc$a43af520$fd08a8c0@steve> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/104 +X-Sequence-Number: 5960 + +This is a multi-part message in MIME format. + +------=_NextPart_000_0006_01C405B2.9F964700 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit + +Eek. Casting both to varchar makes it super quick so I'll fix up the +tables. + +Added to the list of things to check for next time... + +On a side note - I tried it with 7.4.1 on another box and it handled it +ok. + +Thanks again :) + +Chris. + + +-----Original Message----- +From: Steven Butler [mailto:stevenb@kjross.com.au] +Sent: Monday, March 08, 2004 6:12 PM +To: Chris Smith; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] simple query join + + +Looks to me like it's because your assetid is varchar in one table and +an integer in the other table. AFAIK, PG is unable to use an index join +when the join types are different. The query plan shows it is doing +full table scans of both tables. + +Change both to varchar or both to integer and see what happens. + +Also make sure to vacuum analyze the tables regularly to keep the query +planner statistics up-to-date. + +Cheers, +Steve Butler + + assetid | integer | not null default 0 +Indexes: sq_asset_pkey primary key btree (assetid) + + + assetid | character varying(255) | not null default '0' +EXPLAIN ANALYZE SELECT p.* +FROM sq_asset a, sq_asset_permission p +WHERE a.assetid = p.assetid +AND p.permission = '1' +AND p.access = '1' +AND p.userid = '0'; + QUERY PLAN +------------------------------------------------------------------------ +-------------------------------------------------------- + Nested Loop (cost=0.00..4743553.10 rows=2582 width=27) (actual +time=237.91..759310.60 rows=11393 loops=1) + Join Filter: (("inner".assetid)::text = ("outer".assetid)::text) + -> Seq Scan on sq_asset_permission p (cost=0.00..1852.01 rows=2288 +width=23) (actual time=0.06..196.90 rows=12873 loops=1) + Filter: ((permission = 1) AND ("access" = '1'::bpchar) AND +(userid = '0'::character varying)) + -> Seq Scan on sq_asset a (cost=0.00..1825.67 rows=16467 width=4) +(actual time=1.40..29.09 rows=16467 loops=12873) + Total runtime: 759331.85 msec +(6 rows) + + + +------=_NextPart_000_0006_01C405B2.9F964700 +Content-Type: text/html; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable + + + + +Message + + + + + +
Eek.=20 +Casting both to varchar makes it super quick so = +I'll=20 +fix up the tables.
+
 
+
Added to the list of things to check for next=20 +time...
+
 
+
On a=20 +side note - I tried it with 7.4.1 on another box and it handled it=20 +ok.
+
 
+
Thanks again :)
+
 
+
Chris.
+
 
+
+
+
-----Original Message-----
From: Steven = +Butler=20 + [mailto:stevenb@kjross.com.au]
Sent: Monday, March 08, 2004 6:= +12=20 + PM
To: Chris Smith;=20 + pgsql-performance@postgresql.org
Subject: Re: [PERFORM] simple = +query=20 + join

+
Looks to me like it's because your asset= +id is=20 + varchar in one table and an integer in the other table.  AFAIK, PG i= +s=20 + unable to use an index join when the join types are different.  The = +query=20 + plan shows it is doing full table scans of both tables.
+
 
+
Change both to varchar or both to intege= +r and see=20 + what happens.
+
 
+
Also make sure to vacuum analyze the tab= +les=20 + regularly to keep the query planner statistics up-to-date. +
 
+
Cheers,
+
Steve Butler
+
+
 assetid     &nbs= +p; =20 + |=20 + integer          &nbs= +p;         =20 + | not null default 0
Indexes: sq_asset_pkey primary key btree=20 + (assetid)
+
+
 assetid    | character varying(255) | not= + null=20 + default '0'
EXPLAIN ANALYZE SELECT p.*
FROM sq_asset a,= +=20 + sq_asset_permission p
WHERE a.assetid =3D p.assetid
AND p.permiss= +ion =3D=20 + '1'
AND p.access =3D '1'
AND p.userid =3D=20 + '0';
          &nb= +sp;            = +            &nb= +sp;            = +          =20 + QUERY=20 + PLAN
---------------------------------------------------------------= +-----------------------------------------------------------------
 = +Nested=20 + Loop  (cost=3D0.00..4743553.10 rows=3D2582 width=3D27) (actual=20 + time=3D237.91..759310.60 rows=3D11393 loops=3D1)
   Join F= +ilter:=20 + (("inner".assetid)::text =3D ("outer".assetid)::text)
  = +=20 + ->  Seq Scan on sq_asset_permission p  (cost=3D0.00..1852.= +01=20 + rows=3D2288 width=3D23) (actual time=3D0.06..196.90 rows=3D12873=20 + loops=3D1)
         Filter:= +=20 + ((permission =3D 1) AND ("access" =3D '1'::bpchar) AND (userid =3D '0':= +:character=20 + varying))
   ->  Seq Scan on sq_asset a =20 + (cost=3D0.00..1825.67 rows=3D16467 width=3D4) (actual time=3D1.40..29.0= +9 rows=3D16467=20 + loops=3D12873)
 Total runtime: 759331.85 msec
(6=20 + rows)
+ +------=_NextPart_000_0006_01C405B2.9F964700-- + + +From pgsql-hackers-owner@postgresql.org Mon Mar 8 19:28:41 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D1757D1C95E + for ; + Mon, 8 Mar 2004 23: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 52170-06 + for ; + Mon, 8 Mar 2004 19:28:35 -0400 (AST) +Received: from cmailg1.svr.pol.co.uk (cmailg1.svr.pol.co.uk [195.92.195.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D4A1D1D38E + for ; + Mon, 8 Mar 2004 19:28:32 -0400 (AST) +Received: from modem-3571.llama.dialup.pol.co.uk ([217.135.189.243] + helo=LaptopDellXP) by cmailg1.svr.pol.co.uk with esmtp (Exim 4.14) + id 1B0UAf-0008Jp-F9; Mon, 08 Mar 2004 23:28:29 +0000 +Reply-To: +From: "Simon Riggs" +To: "'Tom Lane'" +Cc: "'Neil Conway'" , , + +Subject: Re: [PERFORM] WAL Optimisation - configuration and usage +Date: Mon, 8 Mar 2004 23:28:25 -0000 +Organization: 2nd Quadrant +Message-ID: <004601c40565$0e848c60$f3bd87d9@LaptopDellXP> +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: <19294.1078357583@sss.pgh.pa.us> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/296 +X-Sequence-Number: 50888 + +>Tom Lane +> "Simon Riggs" writes: +> > The behaviour I wish to add is: +> > Keep wal_debug as a value between 0 and 16. +> > If =0 then no debug output (default). +> > Use following bitmasks against the value +> > Mask 1 = XLOG Checkpoints get logged +> > Mask 2 = Archive API calls get logged +> > Mask 4 = Transaction - commits get logged +> > Mask 8 = Flush & INSERTs get logged +> +> I see no value in reverting Neil's change. The above looks way too +much +> like old-line assembler-programmer thinking to me, anyway. Why not +> invent a separate, appropriately named boolean variable for each thing +> you want to control? Even C programmers manage to avoid doing the +sort +> of mental arithmetic that the above would force onto DBAs. +> +> As for whether it should be #ifdef'd or not, I'd have no objection to +> turning WAL_DEBUG on by default in pg_config_manual.h for the duration +> of PITR development. One should not however confuse short-term +> debugging needs with features that the average user is going to need +> indefinitely. (It was not too long ago that there was still debugging +> code for btree index building in there, for crissakes.) + +...erm, I guess you didn't like that one then? ;} + +> As for whether it should be #ifdef'd or not, I'd have no objection to +> turning WAL_DEBUG on by default in pg_config_manual.h for the duration +> of PITR development. + +Yes OK, thank you. + +> Why not +> invent a separate, appropriately named boolean variable for each thing +> you want to control? + +Yes, OK, will do. + +Best Regards, Simon Riggs + + +From pgsql-hackers-owner@postgresql.org Tue Mar 9 03:02:54 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7500FD1B906 + for ; + Tue, 9 Mar 2004 07:02: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 29627-10 + for ; + Tue, 9 Mar 2004 03:02:51 -0400 (AST) +Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) + by svr1.postgresql.org (Postfix) with ESMTP id 608C8D1C4EB + for ; + Tue, 9 Mar 2004 03:02:49 -0400 (AST) +Received: from concord.pspl.co.in ([202.54.11.72]:62319 + helo=ps0499.intranet.pspl.co.in) by frodo.hserus.net with asmtp + (Cipher TLSv1:RC4-MD5:128) (Exim 4.30 #1) + id 1B0bGL-0007mS-35 by authid with plain + for ; Tue, 09 Mar 2004 12:32:49 +0530 +From: Shridhar Daithankar +Reply-To: shridhar@frodo.hserus.net +To: pgsql-hackers@postgresql.org +Subject: [OT] Respository [was Re: [PERFORM] Feature request: smarter use of + conditional indexes] +Date: Tue, 9 Mar 2004 12:32:43 +0530 +User-Agent: KMail/1.6 +References: <41C473B6-6FDF-11D8-9156-000A95BA4506@mindspring.com> + <32080000.1078627178@lerlaptop.lerctr.org> + <20141.1078631217@sss.pgh.pa.us> +In-Reply-To: <20141.1078631217@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200403091232.43621.shridhar@frodo.hserus.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/314 +X-Sequence-Number: 50906 + +On Sunday 07 March 2004 09:16, Tom Lane wrote: +> Personally I consider -c format the only one of the three that is +> readable for reviewing purposes, so even if I weren't intending +> immediate application, I'd ask for -c before looking at the patch. +> There are some folks who consider -u format readable, but I'm not +> one of them ... + +I was wondering what people use to keep track of their personal development +especially when they do not have a cvs commit access. + +I am toying with idea of using GNU arch for personal use. It encourages +branching, merging and having as many repository trees as possible. I haven't +tried it in field as yet but if it delivers what it promises, it could be a +great assistance. + +I know that there are not many postgresql branches like say linux kernel needs +but having a good tool does not hurt, isn't it..:-) + + Just a thought.. + + Shridhar + +From pgsql-performance-owner@postgresql.org Tue Mar 9 05:54:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D9C88D1B9AF + for ; + Tue, 9 Mar 2004 09:54: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 68909-07 + for ; + Tue, 9 Mar 2004 05:54:18 -0400 (AST) +Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ADC26D1B54E + for ; + Tue, 9 Mar 2004 05:54:15 -0400 (AST) +Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) + id 1B0dwI-0003yM-Ke; Tue, 09 Mar 2004 10:54:18 +0100 +Received: from [195.135.143.206] (helo=[10.0.1.2]) + by emma.rox.net with asmtp (Exim 4.22) + id 1B0dwG-0003ub-Sn; Tue, 09 Mar 2004 10:54:16 +0100 +In-Reply-To: <404BCC6F.5060903@familyhealth.com.au> +References: <7F2B9EA0-702C-11D8-9DA8-000A95C496AC@cluster9.com> + <404BCC6F.5060903@familyhealth.com.au> +Mime-Version: 1.0 (Apple Message framework v612) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: PgSQL Performance ML +From: David Teran +Subject: Re: speeding up a select with C function? +Date: Tue, 9 Mar 2004 10:54:10 +0100 +To: Christopher Kings-Lynne +X-Mailer: Apple Mail (2.612) +X-Scanned-By: rockenstein AG +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/105 +X-Sequence-Number: 5961 + +Hi, + + +On 08.03.2004, at 02:29, Christopher Kings-Lynne wrote: + +>> explain analyze select +>> ((t0.int_value-t1.int_value)*(t0.int_value-t1.int_value)) +>> from job_property t0, job_property t1 +>> where t0.id_job_profile = 5 +>> and t1.id_job_profile = 6 +>> and t1.id_job_attribute = t0.id_job_attribute +>> and t1.int_value < t0.int_value; +> +> Don't bother with C function, use SQL function instead. You could get +> a 50% speedup. +> +Is this always the case when using SQL instead of the C API to get +values or only the function 'call' itself? We are thinking to use C +functions which are optimized for the G5 altivec unit. + +regards David + + +From pgsql-performance-owner@postgresql.org Tue Mar 9 08:02:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 60391D1BA6C + for ; + Tue, 9 Mar 2004 12:02: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 01249-04 + for ; + Tue, 9 Mar 2004 08:02:48 -0400 (AST) +Received: from ns2.rox.net (ns2.rox.net [212.63.65.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BB804D1D8B5 + for ; + Tue, 9 Mar 2004 08:02:44 -0400 (AST) +Received: from localhost ([127.0.0.1]) by emma.rox.net with esmtp (Exim 4.22) + id 1B0fwe-0008Np-Rg; Tue, 09 Mar 2004 13:02:48 +0100 +Received: from [195.135.143.206] (helo=[10.0.1.2]) + by emma.rox.net with asmtp (Exim 4.22) + id 1B0fwc-0008KG-52; Tue, 09 Mar 2004 13:02:46 +0100 +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v612) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: PgSQL Performance ML +From: David Teran +Subject: Re: speeding up a select with C function? +Date: Tue, 9 Mar 2004 13:02:41 +0100 +To: Dennis Bjorklund +X-Mailer: Apple Mail (2.612) +X-Scanned-By: rockenstein AG +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/106 +X-Sequence-Number: 5962 + +Hi Dennis, + +>> we need to optimize / speed up a simple select: +>> +>> explain analyze select +>> ((t0.int_value-t1.int_value)*(t0.int_value-t1.int_value)) +>> from job_property t0, job_property t1 +>> where t0.id_job_profile = 5 +>> and t1.id_job_profile = 6 +>> and t1.id_job_attribute = t0.id_job_attribute +>> and t1.int_value < t0.int_value; +> +> Try to add an index on (id_job_profile, id_job_attribute) or maybe even +> (id_job_profile, id_job_attribute, int_value) +> + +Tried this but the index is not used. I know the same problem was true +with a FrontBase database so i wonder how i can force that the index is +used. As i was not sure in which order the query is executed i decided +to create indexes for all variations: + +id_job_profile, id_job_attribute, int_value +id_job_profile, int_value, id_job_attribute +int_value, id_job_attribute, id_job_profile, +int_value, id_job_profile, id_job_attribute +.... + + +here is the output: + +------------------------------------------------------------------------ +------------------------------------------------------------------------ +--------------------------------------- + Merge Join (cost=5369.08..5383.14 rows=150 width=4) (actual +time=2.527..2.874 rows=43 loops=1) + Merge Cond: ("outer".id_job_attribute = "inner".id_job_attribute) + Join Filter: ("inner".int_value < "outer".int_value) + -> Sort (cost=2684.54..2686.37 rows=734 width=6) (actual +time=1.140..1.177 rows=232 loops=1) + Sort Key: t0.id_job_attribute + -> Index Scan using +job_property_short__id_job_profile__fk_index on job_property_short t0 +(cost=0.00..2649.60 rows=734 width=6) (actual time=0.039..0.820 +rows=232 loops=1) + Index Cond: (id_job_profile = 5) + -> Sort (cost=2684.54..2686.37 rows=734 width=6) (actual +time=1.175..1.223 rows=254 loops=1) + Sort Key: t1.id_job_attribute + -> Index Scan using +job_property_short__id_job_profile__fk_index on job_property_short t1 +(cost=0.00..2649.60 rows=734 width=6) (actual time=0.023..0.878 +rows=254 loops=1) + Index Cond: (id_job_profile = 6) + Total runtime: 3.065 ms +(12 rows) + + + + +So the question is how to tell Postgres to use the index. + +regards David + + +From pgsql-performance-owner@postgresql.org Tue Mar 9 10:46:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AC733D1C511 + for ; + Tue, 9 Mar 2004 14:46: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 45981-05 + for ; + Tue, 9 Mar 2004 10:46:29 -0400 (AST) +Received: from relay01.kbs.net.au (relay01.kbs.net.au [203.220.32.149]) + by svr1.postgresql.org (Postfix) with ESMTP id 024BBD1BA93 + for ; + Tue, 9 Mar 2004 10:46:25 -0400 (AST) +Received: from [203.221.246.98] (helo=familyhealth.com.au) + by relay01.kbs.net.au with esmtp (Exim 3.36 #2) + id 1B0iV8-0003f0-00; Wed, 10 Mar 2004 01:46:34 +1100 +Message-ID: <404DD8BE.5080504@familyhealth.com.au> +Date: Tue, 09 Mar 2004 22:46:22 +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: David Teran +Cc: PgSQL Performance ML +Subject: Re: speeding up a select with C function? +References: <7F2B9EA0-702C-11D8-9DA8-000A95C496AC@cluster9.com> + <404BCC6F.5060903@familyhealth.com.au> + +In-Reply-To: +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/107 +X-Sequence-Number: 5963 + +>> Don't bother with C function, use SQL function instead. You could get +>> a 50% speedup. +>> +> Is this always the case when using SQL instead of the C API to get +> values or only the function 'call' itself? We are thinking to use C +> functions which are optimized for the G5 altivec unit. + +SQL functions are stored prepared, so there is less per-call query +planning overhead. I'm not sure there'd be much advantage to doing them +in C... + +Chris + + +From pgsql-performance-owner@postgresql.org Tue Mar 9 11:37:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B916D1B906 + for ; + Tue, 9 Mar 2004 15: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 60122-09 + for ; + Tue, 9 Mar 2004 11:37:33 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id DC512D1BA44 + for ; + Tue, 9 Mar 2004 11:37:28 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i29FbUhu025392; + Tue, 9 Mar 2004 10:37:30 -0500 (EST) +To: David Teran +Cc: Dennis Bjorklund , + PgSQL Performance ML +Subject: Re: speeding up a select with C function? +In-reply-to: +References: + +Comments: In-reply-to David Teran + message dated "Tue, 09 Mar 2004 13:02:41 +0100" +Date: Tue, 09 Mar 2004 10:37:30 -0500 +Message-ID: <25391.1078846650@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/108 +X-Sequence-Number: 5964 + +David Teran writes: +> Merge Join (cost=5369.08..5383.14 rows=150 width=4) (actual +> time=2.527..2.874 rows=43 loops=1) +> Merge Cond: ("outer".id_job_attribute = "inner".id_job_attribute) +> Join Filter: ("inner".int_value < "outer".int_value) +> -> Sort (cost=2684.54..2686.37 rows=734 width=6) (actual +> time=1.140..1.177 rows=232 loops=1) +> Sort Key: t0.id_job_attribute +> -> Index Scan using +> job_property_short__id_job_profile__fk_index on job_property_short t0 +> (cost=0.00..2649.60 rows=734 width=6) (actual time=0.039..0.820 +> rows=232 loops=1) +> Index Cond: (id_job_profile = 5) +> -> Sort (cost=2684.54..2686.37 rows=734 width=6) (actual +> time=1.175..1.223 rows=254 loops=1) +> Sort Key: t1.id_job_attribute +> -> Index Scan using +> job_property_short__id_job_profile__fk_index on job_property_short t1 +> (cost=0.00..2649.60 rows=734 width=6) (actual time=0.023..0.878 +> rows=254 loops=1) +> Index Cond: (id_job_profile = 6) +> Total runtime: 3.065 ms +> (12 rows) + +> So the question is how to tell Postgres to use the index. + +Er, which part of that do you think is not using an index? + +More generally, it is not necessarily the case that a join *should* use +an index. I'm a bit surprised that the above bothers to sort; I'd +expect a hash join to be more appropriate. Have you tried experimenting +with enable_mergejoin and the other planner-testing settings? + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Tue Mar 9 13:46:20 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 35EB4D1DB6C + for ; + Tue, 9 Mar 2004 17:46: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 08408-02 + for ; + Tue, 9 Mar 2004 13:46:06 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id EA359D1D391 + for ; + Tue, 9 Mar 2004 13:46:03 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i29Hk1B23539; + Tue, 9 Mar 2004 12:46:01 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403091746.i29Hk1B23539@candle.pha.pa.us> +Subject: Re: [OT] Respository [was Re: [PERFORM] Feature request: smarter +In-Reply-To: <200403091232.43621.shridhar@frodo.hserus.net> +To: shridhar@frodo.hserus.net +Date: Tue, 9 Mar 2004 12:46:01 -0500 (EST) +Cc: pgsql-hackers@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: 200403/328 +X-Sequence-Number: 50920 + +Shridhar Daithankar wrote: +> On Sunday 07 March 2004 09:16, Tom Lane wrote: +> > Personally I consider -c format the only one of the three that is +> > readable for reviewing purposes, so even if I weren't intending +> > immediate application, I'd ask for -c before looking at the patch. +> > There are some folks who consider -u format readable, but I'm not +> > one of them ... +> +> I was wondering what people use to keep track of their personal development +> especially when they do not have a cvs commit access. + +See the developer's FAQ. They usually use cporig to make copies of +files they are going to modify, then difforig to send the diffs to us, +or they copy the entire source tree, modify it, and do a recursive diff +themselves. + +-- + 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-hackers-owner@postgresql.org Tue Mar 9 14:51:36 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4793FD1DB6C + for ; + Tue, 9 Mar 2004 18:51: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 26272-06 + for ; + Tue, 9 Mar 2004 14:51:33 -0400 (AST) +Received: from joeconway.com (66-146-172-82.skyriver.net [66.146.172.82]) + by svr1.postgresql.org (Postfix) with ESMTP id 949DED1DB17 + for ; + Tue, 9 Mar 2004 14:51:31 -0400 (AST) +Received: from [206.19.64.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1058832; Tue, 09 Mar 2004 10:47:06 -0800 +Message-ID: <404E1181.8090504@joeconway.com> +Date: Tue, 09 Mar 2004 10:48:33 -0800 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bruce Momjian +Cc: shridhar@frodo.hserus.net, pgsql-hackers@postgresql.org +Subject: Re: [OT] Respository [was Re: [PERFORM] Feature request: +References: <200403091746.i29Hk1B23539@candle.pha.pa.us> +In-Reply-To: <200403091746.i29Hk1B23539@candle.pha.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/332 +X-Sequence-Number: 50924 + +Bruce Momjian wrote: +> Shridhar Daithankar wrote: +>>I was wondering what people use to keep track of their personal development +>>especially when they do not have a cvs commit access. +> +> See the developer's FAQ. They usually use cporig to make copies of +> files they are going to modify, then difforig to send the diffs to us, +> or they copy the entire source tree, modify it, and do a recursive diff +> themselves. + +I used to use cvsup to get a full copy of the repository, and then work +locally out of that (check out and diff only). + +Joe + + +From pgsql-performance-owner@postgresql.org Tue Mar 9 16:18:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A009D1DB5B + for ; + Tue, 9 Mar 2004 20:18:09 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48444-05 + for ; + Tue, 9 Mar 2004 16:18:07 -0400 (AST) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 41053D1DB34 + for ; + Tue, 9 Mar 2004 16:18:02 -0400 (AST) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id <17JJG1N8>; Tue, 9 Mar 2004 15:17:56 -0500 +Message-ID: +From: "Shea,Dan [CIS]" +To: pgsql-performance@postgresql.org +Subject: Cluster and vacuum performance +Date: Tue, 9 Mar 2004 15:17:59 -0500 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/109 +X-Sequence-Number: 5965 + +I have a few questions about cluster and vacuum. +We have a table that is 56 GB in size and after a purge based on dates 16GB +was made available as reported below. +PWFPM_DEV=# vacuum full verbose analyze forecastelement; +INFO: vacuuming "public.forecastelement" +INFO: "forecastelement": found 93351479 removable, 219177133 nonremovable +row versions in 6621806 pages +DETAIL: 0 dead row versions cannot be removed yet. +Nonremovable row versions range from 156 to 192 bytes long. +There were 611201 unused item pointers. +Total free space (including removable row versions) is 16296891960 bytes. +1974172 pages are or will become empty, including 26 at the end of the +table. +1990268 pages containing 15794855436 free bytes are potential move +destinations. +CPU 467.29s/48.52u sec elapsed 4121.69 sec. + +How can you improve the performance of cluster? +1. BY increasing sort_mem? +2. Does increasing vacuum_mem help? +3. Does checkpoint_segments improve it? + +Dan + +From pgsql-performance-owner@postgresql.org Tue Mar 9 16:27:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 0FD8ED1DB34; Tue, 9 Mar 2004 20:27: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 50390-07; Tue, 9 Mar 2004 16:27:11 -0400 (AST) +Received: from cmailg6.svr.pol.co.uk (cmailg6.svr.pol.co.uk [195.92.195.176]) + by svr1.postgresql.org (Postfix) with ESMTP + id 04B9DD1DAFB; Tue, 9 Mar 2004 16:27:10 -0400 (AST) +Received: from modem-3858.rhino.dialup.pol.co.uk ([62.137.111.18] + helo=LaptopDellXP) by cmailg6.svr.pol.co.uk with esmtp (Exim 4.14) + id 1B0noe-0008Sw-Nz; Tue, 09 Mar 2004 20:27:05 +0000 +Reply-To: +From: "Simon Riggs" +To: "'Neil Conway'" +Cc: , , + +Subject: Re: [HACKERS] WAL Optimisation - configuration and usage +Date: Tue, 9 Mar 2004 20:26:55 -0000 +Organization: 2nd Quadrant +Message-ID: <006601c40614$df319e20$f3bd87d9@LaptopDellXP> +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: <40466F2C.3050108@samurai.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/110 +X-Sequence-Number: 5966 + +>Neil Conway +> Simon Riggs wrote: +> > On the other hand, I was just about to change the wal_debug +behaviour to +> > allow better debugging of PITR features as they're added. +> +> That's a development activity. Enabling the WAL_DEBUG #ifdef by +> default during the 7.5 development cycle would be uncontroversial, I +> think. + +Yes that's the best proposal. Can I leave that with you? + +> > I think it is very important to be able to put the system fairly +> > easily into debug mode +> +> It is? Why would this be useful for non-development activities? +> +> (It may well be the case that we ought to report more or better +> information about the status of the WAL subsystem; but WAL_DEBUG is +> surely not the right mechanism for emitting information intended for +> an administrator.) + +Right again. I guess my proposal amounted to quick-and-dirty logging. + +I'll think some more. + +Best Regards, Simon Riggs + + +From pgsql-admin-owner@postgresql.org Tue Mar 9 16:29:53 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id AF8CCD1BA6C; Tue, 9 Mar 2004 20:29:51 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 48418-10; Tue, 9 Mar 2004 16:29:47 -0400 (AST) +Received: from COLSWEEPER.cranel.com (newmail.cranel.com [66.192.200.227]) + by svr1.postgresql.org (Postfix) with ESMTP + id A7A47D1BAC8; Tue, 9 Mar 2004 16:29:44 -0400 (AST) +Received: from colmail01.cranel.com (colmail01.cranel.com) by + COLSWEEPER.cranel.com + (Content Technologies SMTPRS 4.3.12) with ESMTP id + ; + Tue, 9 Mar 2004 15:29:01 -0500 +Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by + colmail01.cranel.com with SMTP (Microsoft Exchange Internet + Mail Service Version 5.5.2657.72) + id GRDD7MRX; Tue, 9 Mar 2004 15:33:51 -0500 +Message-ID: <404E2937.4060604@cranel.com> +Date: Tue, 09 Mar 2004 15:29:43 -0500 +From: Greg Spiegelberg +Organization: Cranel, Inc. +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PgSQL Performance ML , + Postgres Admin List +Subject: syslog slowing the database? +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: 200403/149 +X-Sequence-Number: 12718 + +I've been waiting all day for a pg_restore to finish on a test system +identically configured as our production in hardware and software +with the exception prod is 7.3.5 and test is 7.4.1. + +The file it's restoring from is about 8GB uncompressed from a +"pg_dump -b -F t" and after 2 hours the directory the database is in +contains only 1GB. iostat reported ~2000 blocks written every 2 +seconds to the DB file system. + +I turned syslog off to see if it was blocking anything and in the +past couple minutes 1GB has been restored and iostat reports ~35,000 +blocks written every 2 seconds to the DB file system. + +The system is completely idle except for this restore process. Could +syslog the culprit? + +I turned syslog back on and the restore slowed down again. Turned +it off and it sped right back up. + +Can anyone confirm this for me? + +Greg + +-- +Greg Spiegelberg + Sr. Product Development Engineer + Cranel, Incorporated. + Phone: 614.318.4314 + Fax: 614.431.8388 + Email: gspiegelberg@Cranel.com +Cranel. Technology. Integrity. Focus. + + + +From pgsql-admin-owner@postgresql.org Tue Mar 9 22:52:10 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id D4927D1CCB9; Tue, 9 Mar 2004 21:34: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 66719-07; Tue, 9 Mar 2004 17:34:48 -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 C9BACD1C96F; Tue, 9 Mar 2004 17:34:45 -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 1B0os9-0006D9-0X; Tue, 09 Mar 2004 21:34:46 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 9E99E17884; Tue, 9 Mar 2004 21:34:39 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 578AA16E18; Tue, 9 Mar 2004 21:34:37 +0000 (GMT) +From: Richard Huxton +To: Greg Spiegelberg , + PgSQL Performance ML , + Postgres Admin List +Subject: Re: [PERFORM] syslog slowing the database? +Date: Tue, 9 Mar 2004 21:34:35 +0000 +User-Agent: KMail/1.5 +References: <404E2937.4060604@cranel.com> +In-Reply-To: <404E2937.4060604@cranel.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403092134.35905.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: 200403/173 +X-Sequence-Number: 12742 + +On Tuesday 09 March 2004 20:29, Greg Spiegelberg wrote: + +> iostat reported ~2000 blocks written every 2 +> seconds to the DB file system. +> +> I turned syslog off to see if it was blocking anything and in the +> past couple minutes 1GB has been restored and iostat reports ~35,000 +> blocks written every 2 seconds to the DB file system. + +> Can anyone confirm this for me? + +If syslog is set to sync after every line and you're logging too much then it +could slow things down as the disk heads shift back and fore between two +areas of disk. How many disks do you have and in what configuration? + +Also - was PG logging a lot of info, or is some other application the culprit? + +Tip: put a minus "-" in front of the file-path in your syslog.conf and it +won't sync to disk after every entry. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Mar 9 18:28:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 64BC8D1BAC8 + for ; + Tue, 9 Mar 2004 22:21: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 83266-04 + for ; + Tue, 9 Mar 2004 18:21:43 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id F0005D1B54E + for ; + Tue, 9 Mar 2004 18:21:40 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4592521; Tue, 09 Mar 2004 14:22:55 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Shea,Dan [CIS]" , + pgsql-performance@postgresql.org +Subject: Re: Cluster and vacuum performance +Date: Tue, 9 Mar 2004 14:20:53 -0800 +User-Agent: KMail/1.5.4 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403091420.53924.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/113 +X-Sequence-Number: 5969 + +Dan, + +> INFO: vacuuming "public.forecastelement" +> INFO: "forecastelement": found 93351479 removable, 219177133 nonremovable + +The high number of nonremovable above probably indicates that you have a +transaction being held open which prevents VACUUM from being effective. +Look for long-hung processes and/or transaction management errors in your +client code. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Mar 9 21:46:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2811DD1BA8F + for ; + Tue, 9 Mar 2004 22:57: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 91453-02 + for ; + Tue, 9 Mar 2004 18:57:39 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 14DB3D1BB5F + for ; + Tue, 9 Mar 2004 18:57:36 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i29Mvae4029478; + Tue, 9 Mar 2004 17:57:36 -0500 (EST) +To: "Shea,Dan [CIS]" +Cc: pgsql-performance@postgresql.org +Subject: Re: Cluster and vacuum performance +In-reply-to: +References: +Comments: In-reply-to "Shea,Dan [CIS]" + message dated "Tue, 09 Mar 2004 15:17:59 -0500" +Date: Tue, 09 Mar 2004 17:57:36 -0500 +Message-ID: <29477.1078873056@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/123 +X-Sequence-Number: 5979 + +"Shea,Dan [CIS]" writes: +> How can you improve the performance of cluster? +> 1. BY increasing sort_mem? + +Yes. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 9 21:31:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 17CE1D1D1B2 + for ; + Tue, 9 Mar 2004 23:30: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 03268-01 + for ; + Tue, 9 Mar 2004 19:30:56 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FBD5D1D17E + for ; + Tue, 9 Mar 2004 19:30:53 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i29NUqH0029781; + Tue, 9 Mar 2004 18:30:52 -0500 (EST) +To: josh@agliodbs.com +Cc: "Shea,Dan [CIS]" , + pgsql-performance@postgresql.org +Subject: Re: Cluster and vacuum performance +In-reply-to: <200403091420.53924.josh@agliodbs.com> +References: + <200403091420.53924.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Tue, 09 Mar 2004 14:20:53 -0800" +Date: Tue, 09 Mar 2004 18:30:52 -0500 +Message-ID: <29780.1078875052@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/122 +X-Sequence-Number: 5978 + +Josh Berkus writes: +>> INFO: vacuuming "public.forecastelement" +>> INFO: "forecastelement": found 93351479 removable, 219177133 nonremovable + +> The high number of nonremovable above probably indicates that you have a +> transaction being held open which prevents VACUUM from being effective. + +You misread it --- "nonremovable" doesn't mean "dead but not removable", +it just means "not removable". Actually the next line of his log showed +there were zero nonremovable dead tuples, so he's not got any +open-transaction problem. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 9 21:09:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E99ED1CA6C + for ; + Wed, 10 Mar 2004 00:07: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 04893-08 + for ; + Tue, 9 Mar 2004 20:07:17 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 8CDBFD1C9C4 + for ; + Tue, 9 Mar 2004 20:07:14 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2A07Hhc000248; + Tue, 9 Mar 2004 19:07:17 -0500 (EST) +To: Chris Kratz +Cc: pgsql-performance@postgresql.org +Subject: Re: Delete performance on delete from table with inherited tables +In-reply-to: <200403031649.44937.chris.kratz@vistashare.com> +References: <200403031649.44937.chris.kratz@vistashare.com> +Comments: In-reply-to Chris Kratz + message dated "Wed, 03 Mar 2004 16:49:44 -0500" +Date: Tue, 09 Mar 2004 19:07:17 -0500 +Message-ID: <247.1078877237@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/120 +X-Sequence-Number: 5976 + +Chris Kratz writes: +> There are about 67 inherited tables that inherit the fields from this table, +> hence the 134 constraint triggers. + +Why "hence"? Inheritance doesn't create any FK relationships. You must +have done so. What are those FK constraints exactly? + +> Some of the documentation implies that inherited tables cause deletes to be +> very slow on the parent table, so I did the following experiment. + +No, but foreign keys linked from tables that don't have indexes can be +pretty slow. + +> it seems like the "delete from only..." statement should +> ignore the constraint triggers. + +Why would you expect that? + +It appears to me that this table is the referenced table for a large +number of foreign-key relationships, and thus when you delete a row from +it, many other tables have to be checked to verify that they do not +contain entries matching that row. That's going to be relatively slow, +even with indexes on the other tables. It's not very clear from your +description what the FK relationships actually do in your database +schema, but I would suggest looking at redesigning the schema so that +you do not need them. + + regards, tom lane + +From pgsql-admin-owner@postgresql.org Tue Mar 9 20:52:45 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id E8CD0D1C4EB; Wed, 10 Mar 2004 00:16: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 13399-02; Tue, 9 Mar 2004 20:16:51 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id 4CE2ED1BA93; Tue, 9 Mar 2004 20:16:48 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2A0GjpK000371; + Tue, 9 Mar 2004 19:16:46 -0500 (EST) +To: Greg Spiegelberg +Cc: PgSQL Performance ML , + Postgres Admin List +Subject: Re: syslog slowing the database? +In-reply-to: <404E2937.4060604@cranel.com> +References: <404E2937.4060604@cranel.com> +Comments: In-reply-to Greg Spiegelberg + message dated "Tue, 09 Mar 2004 15:29:43 -0500" +Date: Tue, 09 Mar 2004 19:16:45 -0500 +Message-ID: <370.1078877805@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/168 +X-Sequence-Number: 12737 + +Greg Spiegelberg writes: +> I turned syslog back on and the restore slowed down again. Turned +> it off and it sped right back up. + +We have heard reports before of syslog being quite slow. What platform +are you on exactly? Does Richard's suggestion of turning off syslog's +fsync help? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 9 20:46:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 66039D1B530 + for ; + Wed, 10 Mar 2004 00:18:23 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 13341-03 + for ; + Tue, 9 Mar 2004 20:18:24 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 1412FD1BA2E + for ; + Tue, 9 Mar 2004 20:18:21 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id E33DD354FB; Tue, 9 Mar 2004 16:18:22 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id E1BE9354AC; Tue, 9 Mar 2004 16:18:22 -0800 (PST) +Date: Tue, 9 Mar 2004 16:18:22 -0800 (PST) +From: Stephan Szabo +To: Chris Kratz +Cc: pgsql-performance@postgresql.org +Subject: Re: Delete performance on delete from table with inherited +In-Reply-To: <200403031649.44937.chris.kratz@vistashare.com> +Message-ID: <20040309155908.Y9964@megazone.bigpanda.com> +References: <200403031649.44937.chris.kratz@vistashare.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/118 +X-Sequence-Number: 5974 + + +On Wed, 3 Mar 2004, Chris Kratz wrote: + +> Which certainly points to the triggers being the culprit. In reading the +> documentation, it seems like the "delete from only..." statement should +> ignore the constraint triggers. But it seems quite obvious from the + +Delete from only merely means that children of the table being deleted +will not have their rows checked against any where conditions and removed +for that reason. It does not affect constraint triggers at all. + +Given I'm guessing it's going to be running about 7000 * 67 queries to +check the validity of the delete for 7000 rows each having 67 foreign +keys, I'm not sure there's much to do other than hack around the issue +right now. + +If you're a superuser, you could temporarily hack reltriggers on the +table's pg_class row to 0, run the delete and then set it back to the +correct number. I'm guessing from your message that there's never any +chance of a concurrent transaction putting in a matching row in a way that +something is marked as deletable when it isn't? + + + + +From pgsql-admin-owner@postgresql.org Tue Mar 9 22:56:27 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DA650D1BA2E + for ; + Wed, 10 Mar 2004 01:06: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 26034-03 + for ; + Tue, 9 Mar 2004 21:06:44 -0400 (AST) +Received: from mail2.fbab.net (spectre.fbab.net [212.214.165.139]) + by svr1.postgresql.org (Postfix) with SMTP id 7301CD1BA8F + for ; Tue, 9 Mar 2004 21:06:39 -0400 (AST) +Received: (qmail 26262 invoked by uid 136); 10 Mar 2004 01:06:42 -0000 +Received: from mag@fbab.net by mail2.fbab.net by uid 133 with + qmail-scanner-1.20rc1 (avp: 4.0.3.0. Clear:RC:0:. + Processed in 0.053613 secs); 10 Mar 2004 01:06:42 -0000 +Received: from unknown (HELO fbab.net) (magpool1@212.214.165.129) + by mail2.fbab.net with SMTP; 10 Mar 2004 01:06:41 -0000 +Message-ID: <404E6A1E.8040804@fbab.net> +Date: Wed, 10 Mar 2004 02:06:38 +0100 +From: "Magnus Naeslund(t)" +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Greg Spiegelberg , + PgSQL Performance ML , + Postgres Admin List +Subject: Re: [PERFORM] syslog slowing the database? +References: <404E2937.4060604@cranel.com> <370.1078877805@sss.pgh.pa.us> +In-Reply-To: <370.1078877805@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: 200403/175 +X-Sequence-Number: 12744 + +Tom Lane wrote: +> Greg Spiegelberg writes: +> +>>I turned syslog back on and the restore slowed down again. Turned +>>it off and it sped right back up. +> +> +> We have heard reports before of syslog being quite slow. What platform +> are you on exactly? Does Richard's suggestion of turning off syslog's +> fsync help? +> + +Another tip is to use a better (well atleast more optimized) syslog +implementation, like metalog. It optimizes log writes to a blocksize +that is better for disk throughput. +You can also use "per line" mode with those if you want, i think. + +I use another logger that is called multilog (see at http://cr.yp.to), +that's a pipe logger thing, like one per postmaster. +It also gives very exact timestamps to every line, has built in log +rotation and works nice with all programs i use it for. + +One thing is for sure, if you log much, standard syslog (atleast on +linux) sucks big time. +I gained back approx 30% CPU on a mailserver over here by changing to +another logger. + +Cheers +Magnus + + + + +From pgsql-admin-owner@postgresql.org Tue Mar 9 22:52:12 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id CD4F8D1BB5F; Wed, 10 Mar 2004 01:09: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 26384-04; Tue, 9 Mar 2004 21:09:16 -0400 (AST) +Received: from bucky.ehpg.net (mail.ehpg.net [64.71.189.194]) + by svr1.postgresql.org (Postfix) with ESMTP + id 21956D1BA93; Tue, 9 Mar 2004 21:09:13 -0400 (AST) +Received: from (ehpg.net) [208.29.195.71]by bucky.ehpg.netwith asmtp(Exim 4.21 + #1 (Gentoo Linux 1.4))id 1B0sDj-0003x7-WE; + Tue, 09 Mar 2004 17:09:16 -0800 +Message-ID: <404E6AB9.4030404@ehpg.net> +Date: Tue, 09 Mar 2004 17:09:13 -0800 +From: "Gavin M. Roy" +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +Cc: PgSQL Performance ML , + Postgres Admin List +Subject: Re: [PERFORM] syslog slowing the database? +References: <404E2937.4060604@cranel.com> <370.1078877805@sss.pgh.pa.us> +In-Reply-To: <370.1078877805@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Antivirus-Scanned: Clean +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/174 +X-Sequence-Number: 12743 + +Might want to look at metalog, it does delayed writes, though ultimately +your issue is io bound and there's not much you can do to reduce io if +you want to keep syslog logging your pgsql queries and such. + +Tom Lane wrote: + +>Greg Spiegelberg writes: +> +> +>>I turned syslog back on and the restore slowed down again. Turned +>>it off and it sped right back up. +>> +>> +> +>We have heard reports before of syslog being quite slow. What platform +>are you on exactly? Does Richard's suggestion of turning off syslog's +>fsync help? +> +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> +> + + +From pgsql-admin-owner@postgresql.org Tue Mar 9 22:56:52 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id ABF3BD1D1B2; Wed, 10 Mar 2004 01:33:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 33250-10; Tue, 9 Mar 2004 21:33:00 -0400 (AST) +Received: from rockhopper (CPE-144-132-200-73.nsw.bigpond.net.au + [144.132.200.73]) by svr1.postgresql.org (Postfix) with ESMTP + id 3D1F6D1CCB9; Tue, 9 Mar 2004 21:32:54 -0400 (AST) +Received: from [192.168.5.2] (chinstrap [192.168.5.2]) + by rockhopper (8.11.6/8.11.2) with ESMTP id i2A1WCH12856; + Wed, 10 Mar 2004 12:32:12 +1100 +Subject: Re: [PERFORM] syslog slowing the database? +From: Stephen Robert Norris +To: "Gavin M. Roy" +Cc: PgSQL Performance ML , + Postgres Admin List +In-Reply-To: <404E6AB9.4030404@ehpg.net> +References: <404E2937.4060604@cranel.com> <370.1078877805@sss.pgh.pa.us> + <404E6AB9.4030404@ehpg.net> +Content-Type: text/plain +Organization: CommSecure Australia Pty Ltd +Message-Id: <1078882327.9858.24.camel@chinstrap> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) +Date: Wed, 10 Mar 2004 12:32:07 +1100 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/176 +X-Sequence-Number: 12745 + +On Wed, 2004-03-10 at 12:09, Gavin M. Roy wrote: +> Might want to look at metalog, it does delayed writes, though ultimately +> your issue is io bound and there's not much you can do to reduce io if +> you want to keep syslog logging your pgsql queries and such. + +Yeah, but syslog with fsync() after each line is much, much worse than +syslog without it, assuming anything else is on the same disk (array). +It just guarantees to screw up your drive head movements... + +-- +Stephen Norris srn@fn.com.au +Farrow Norris Pty Ltd +61 417 243 239 + + +From pgsql-performance-owner@postgresql.org Tue Mar 9 23:35:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 01E3ED1BA35 + for ; + Wed, 10 Mar 2004 03:35: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 41546-07 + for ; + Tue, 9 Mar 2004 23:35:28 -0400 (AST) +Received: from ideafix.webnow.com.br (ideafix.webnow.com.br [200.155.4.67]) + by svr1.postgresql.org (Postfix) with ESMTP id 29E6ED1B54E + for ; + Tue, 9 Mar 2004 23:35:20 -0400 (AST) +Received: by ideafix.webnow.com.br (Postfix, from userid 48) + id DB956198F2B; Wed, 10 Mar 2004 00:35:15 -0300 (BRT) +Received: from 148100.cps.virtua.com.br ([200.174.148.100]) + (SquirrelMail authenticated user marcus.magalhaes@vlinfo.com.br) + by webmail.webnow.com.br with HTTP; + Wed, 10 Mar 2004 00:35:15 -0300 (BRT) +Message-ID: <62371.200.174.148.100.1078889715.squirrel@webmail.webnow.com.br> +Date: Wed, 10 Mar 2004 00:35:15 -0300 (BRT) +Subject: optimizing large query with IN (...) +From: "Marcus Andree S. Magalhaes" +To: +X-Priority: 3 +Importance: Normal +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: 200403/125 +X-Sequence-Number: 5981 + + +Guys, + +I got a Java program to tune. It connects to a 7.4.1 postgresql server +running Linux using JDBC. + +The program needs to update a counter on a somewhat large number of +rows, about 1200 on a ~130k rows table. The query is something like +the following: + +UPDATE table SET table.par = table.par + 1 +WHERE table.key IN ('value1', 'value2', ... , 'value1200' ) + +This query runs on a transaction (by issuing a call to +setAutoCommit(false)) and a commit() right after the query +is sent to the backend. + +The process of committing and updating the values is painfully slow +(no surprises here). Any ideas? + +Thanks. + + + +From pgsql-performance-owner@postgresql.org Sat Mar 13 16:01:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 74B74D1BA13 + for ; + Wed, 10 Mar 2004 03:52: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 47236-01 + for ; + Tue, 9 Mar 2004 23:52:12 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id A4322D1B906 + for ; + Tue, 9 Mar 2004 23:52:08 -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 i2A3q21Y075361 + for ; Wed, 10 Mar 2004 03:52:02 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i2A3hRsl074151 + for pgsql-performance@postgresql.org; Wed, 10 Mar 2004 03:43:27 GMT +From: Mike Bridge +X-Newsgroups: comp.databases.postgresql.performance +Subject: High CPU with 7.4.1 after running for about 2 weeks +Message-ID: +X-Newsreader: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Lines: 17 +Date: Wed, 10 Mar 2004 03:43:37 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/180 +X-Sequence-Number: 6036 + +I've been running Postgresql 7.4.1 for a couple weeks after upgrading +from 7.2. I noticed today that the postmaster had been using 99% of +the dual CPUs (on a PowerEdge 2650) non-stop for the last couple days. +I stopped all the clients, and it didn't abate---even with no +connections---so I restarted the postmaster. Now everything is +running smoothly again. + +Is there anything that might accumulate after two weeks that might +cause postgresql to thrash? I'm running pg_autovacuum, so the +database itself should be nice and clean. It isn't connections, +because I restarted the clients a few times without success. I've +been running a long time on 7.2 with essentially the same +configuration (minus pg_autovacuum) without any problems.... + +Thanks for any help, + +-Mike + +From pgsql-performance-owner@postgresql.org Sat Mar 13 15:59:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 828A2D1D29F + for ; + Wed, 10 Mar 2004 07:36: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 82946-07 + for ; + Wed, 10 Mar 2004 03:36:41 -0400 (AST) +Received: from email.philnet (unknown [61.1.74.109]) + by svr1.postgresql.org (Postfix) with ESMTP id 6335AD1B979 + for ; + Wed, 10 Mar 2004 03:36:32 -0400 (AST) +Received: from phil.com.sg + (IDENT:1qSnEZZXYhQQf67EVn/nl/6FhtUsPH8M@xserver.philnet [172.16.1.6]) + by email.philnet (8.11.6/8.11.2) with ESMTP id i2A7JrB11893 + for ; Wed, 10 Mar 2004 12:49:53 +0530 +Message-ID: <404EBDA5.ED3248AE@phil.com.sg> +Date: Wed, 10 Mar 2004 12:33:01 +0530 +From: Maneesha Nunes +X-Mailer: Mozilla 4.78 [en] (X11; U; Linux 2.4.20-8 i686) +X-Accept-Language: en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Drop Tables Very Slow in Postgresql 7.2.1 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-MailScanner: Found to be clean +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=1.4 tagged_above=0.0 required=5.0 tests=BAYES_20, + RCVD_IN_DYNABLOCK, RCVD_IN_RFCI, RCVD_IN_SORBS +X-Spam-Level: * +X-Archive-Number: 200403/179 +X-Sequence-Number: 6035 + +Hello there !!! + +I am using postgresql7.2.1 as the backend for an E.R.P system running +on Linux Redhat 7.2(Enigma) +The database size is around 20-25GB +Dropping of an individual table whose size is around 200Mb takes more +than 7 mins, and also increases the load on our System +The database is vacuumed/ reindexed on a daily basis. + +We have recreated the same database on a Linux Redhat release 9 OS, and +used PostgreSQL 7.3.2, the drop here is really fast. + +Any suggestions as to how I could improve the performance of drop on +postgresql7.2.1. + + +Thanks +maneesha. + + + +From pgsql-performance-owner@postgresql.org Wed Mar 10 04:13:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B646DD1BA2E + for ; + Wed, 10 Mar 2004 08:13: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 96951-02 + for ; + Wed, 10 Mar 2004 04:13:39 -0400 (AST) +Received: from expasy-ng.isb-sib.ch (expasy-f.unige.ch [192.33.215.142]) + by svr1.postgresql.org (Postfix) with ESMTP id 90E8FD1B979 + for ; + Wed, 10 Mar 2004 04:13:36 -0400 (AST) +Received: from caliente (router.isb-sib.ch [192.33.215.254]) + (authenticated bits=0) + by expasy-ng.isb-sib.ch (8.12.10/8.12.8) with ESMTP id i2A8DXki019795 + for ; Wed, 10 Mar 2004 09:13:33 +0100 +Message-ID: <001401c40677$9723fed0$c300000a@caliente> +From: "Eric Jain" +To: "pgsql-performance" +References: <62371.200.174.148.100.1078889715.squirrel@webmail.webnow.com.br> +Subject: Re: optimizing large query with IN (...) +Date: Wed, 10 Mar 2004 09:13:37 +0100 +Organization: Swiss Institute of Bioinformatics +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-sib-MailScanner-Information: Please contact the ISP for more information +X-sib-MailScanner: Found to be clean +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/126 +X-Sequence-Number: 5982 + +> UPDATE table SET table.par = table.par + 1 +> WHERE table.key IN ('value1', 'value2', ... , 'value1200' ) + +How fast is the query alone, i.e. + + SELECT * FROM table + WHERE table.key IN ('value1', 'value2', ... , 'value1200' ) + + +From pgsql-performance-owner@postgresql.org Wed Mar 10 04:32:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C5A16D1B530 + for ; + Wed, 10 Mar 2004 08:32: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 99239-03 + for ; + Wed, 10 Mar 2004 04:32:50 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 82305D1B4DB + for ; + Wed, 10 Mar 2004 04:32:47 -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 + i2A8WbWL095245; Wed, 10 Mar 2004 16:32:37 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <404ED40F.2040800@familyhealth.com.au> +Date: Wed, 10 Mar 2004 16:38:39 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Eric Jain +Cc: pgsql-performance +Subject: Re: optimizing large query with IN (...) +References: <62371.200.174.148.100.1078889715.squirrel@webmail.webnow.com.br> + <001401c40677$9723fed0$c300000a@caliente> +In-Reply-To: <001401c40677$9723fed0$c300000a@caliente> +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: 200403/127 +X-Sequence-Number: 5983 + +>>UPDATE table SET table.par = table.par + 1 +>>WHERE table.key IN ('value1', 'value2', ... , 'value1200' ) +> +> +> How fast is the query alone, i.e. +> +> SELECT * FROM table +> WHERE table.key IN ('value1', 'value2', ... , 'value1200' ) + +Also, post the output of '\d table' and EXPLAIN ANALYZE UPDATE... + +Chris + + +From pgsql-performance-owner@postgresql.org Wed Mar 10 09:56:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C4C88D1C511 + for ; + Wed, 10 Mar 2004 13: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 84975-09 + for ; + Wed, 10 Mar 2004 09:56:59 -0400 (AST) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 241EAD1B4DB + for ; + Wed, 10 Mar 2004 09:56:51 -0400 (AST) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id <17JJHYMT>; Wed, 10 Mar 2004 08:56:52 -0500 +Message-ID: +From: "Shea,Dan [CIS]" +To: pgsql-performance@postgresql.org +Subject: Cluster failure due to space +Date: Wed, 10 Mar 2004 08:56:57 -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: 200403/128 +X-Sequence-Number: 5984 + +I have had a cluster failure on a table. It most likely was due to space. +I do not not have the error message anymore, but it was indicating that it +was most likely a space problem. The partition was filled to 99%. The +table is about 56 GB and what I believe to be the new table that it was +writing to looks to be 40 files of 1GB. + +The problem is that it did not clean itself up properly. + +The oids that I believe it was writing to are still there. +There are 56 files of 102724113.* and 40 files of 361716097.*. +A vacuum had indicated that there was around 16 GB of free space. +I can not find any reference to 361716097 in the pg_class table. +Am I going to have to manually delete the 361716097.* files myself? + +Dan. + +From pgsql-performance-owner@postgresql.org Wed Mar 10 10:50:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 75735D1B837 + for ; + Wed, 10 Mar 2004 14:50: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 01758-01 + for ; + Wed, 10 Mar 2004 10:50:07 -0400 (AST) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D9E2D1B80C + for ; + Wed, 10 Mar 2004 10:50:06 -0400 (AST) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id AF1F59029F3; Wed, 10 Mar 2004 06:42:54 -0800 (PST) +Date: Wed, 10 Mar 2004 06:42:54 -0800 +From: Steve Atkins +To: pgsql-performance@postgresql.org +Subject: Re: optimizing large query with IN (...) +Message-ID: <20040310144253.GA31063@gp.word-to-the-wise.com> +References: <62371.200.174.148.100.1078889715.squirrel@webmail.webnow.com.br> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <62371.200.174.148.100.1078889715.squirrel@webmail.webnow.com.br> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/129 +X-Sequence-Number: 5985 + +On Wed, Mar 10, 2004 at 12:35:15AM -0300, Marcus Andree S. Magalhaes wrote: +> Guys, +> +> I got a Java program to tune. It connects to a 7.4.1 postgresql server +> running Linux using JDBC. +> +> The program needs to update a counter on a somewhat large number of +> rows, about 1200 on a ~130k rows table. The query is something like +> the following: +> +> UPDATE table SET table.par = table.par + 1 +> WHERE table.key IN ('value1', 'value2', ... , 'value1200' ) +> +> This query runs on a transaction (by issuing a call to +> setAutoCommit(false)) and a commit() right after the query +> is sent to the backend. +> +> The process of committing and updating the values is painfully slow +> (no surprises here). Any ideas? + +I posted an analysis of use of IN () like this a few weeks ago on +pgsql-general. + +The approach you're using is optimal for < 3 values. + +For any more than that, insert value1 ... value1200 into a temporary +table, then do + + UPDATE table SET table.par = table.par + 1 + WHERE table.key IN (SELECT value from temp_table); + +Indexing the temporary table marginally increases the speed, but not +significantly. + +Cheers, + Steve + + + +From pgsql-performance-owner@postgresql.org Wed Mar 10 11:28:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ACBA4D1B8EA + for ; + Wed, 10 Mar 2004 15: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 08801-08 + for ; + Wed, 10 Mar 2004 11:24:06 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 776CED1B897 + for ; + Wed, 10 Mar 2004 11:24:04 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2AFO0fA006732; + Wed, 10 Mar 2004 10:24:00 -0500 (EST) +To: "Shea,Dan [CIS]" +Cc: pgsql-performance@postgresql.org +Subject: Re: Cluster failure due to space +In-reply-to: +References: +Comments: In-reply-to "Shea,Dan [CIS]" + message dated "Wed, 10 Mar 2004 08:56:57 -0500" +Date: Wed, 10 Mar 2004 10:24:00 -0500 +Message-ID: <6731.1078932240@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/130 +X-Sequence-Number: 5986 + +"Shea,Dan [CIS]" writes: +> The problem is that it did not clean itself up properly. + +Hm. It should have done so. What were the exact filenames and sizes of +the not-deleted files? + +> I can not find any reference to 361716097 in the pg_class table. + +You are looking at pg_class.relfilenode, I hope, not pg_class.oid. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 10 11:41:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4043BD1C7F0 + for ; + Wed, 10 Mar 2004 15:39: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 15568-07 + for ; + Wed, 10 Mar 2004 11:39:02 -0400 (AST) +Received: from ECCMCBH.cmc.int.ec.gc.ca (ecdor130.cmc.ec.gc.ca + [199.212.17.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A6F2D1B4CB + for ; + Wed, 10 Mar 2004 11:39:01 -0400 (AST) +Received: by eccmcbh.cmc.ec.gc.ca with Internet Mail Service (5.5.2653.19) + id <17JJ2BSH>; Wed, 10 Mar 2004 10:38:39 -0500 +Message-ID: +From: "Shea,Dan [CIS]" +To: 'Tom Lane' +Cc: pgsql-performance@postgresql.org +Subject: Re: Cluster failure due to space +Date: Wed, 10 Mar 2004 10:38:43 -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: 200403/131 +X-Sequence-Number: 5987 + + + + +"Shea,Dan [CIS]" writes: +>> The problem is that it did not clean itself up properly. + +>Hm. It should have done so. What were the exact filenames and sizes of +>the not-deleted files? +361716097 to 361716097.39 are 1073741824 bytes. +361716097.40 is 186105856 bytes. + +> I can not find any reference to 361716097 in the pg_class table. + +>>You are looking at pg_class.relfilenode, I hope, not pg_class.oid. +Yes I am looking through pg_class.relfilenode. + +Dan. + +From pgsql-admin-owner@postgresql.org Wed Mar 10 12:33:44 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 70A44D1CACF; Wed, 10 Mar 2004 15:52: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 26819-03; Wed, 10 Mar 2004 11:51:58 -0400 (AST) +Received: from COLSWEEPER.cranel.com (newmail.cranel.com [66.192.200.227]) + by svr1.postgresql.org (Postfix) with ESMTP + id ECB1ED1BB36; Wed, 10 Mar 2004 11:51:55 -0400 (AST) +Received: from colmail01.cranel.com (colmail01.cranel.com) by + COLSWEEPER.cranel.com + (Content Technologies SMTPRS 4.3.12) with ESMTP id + ; + Wed, 10 Mar 2004 10:51:09 -0500 +Received: from cranel.com (gspiegelberg.cranel.com [192.168.11.134]) by + colmail01.cranel.com with SMTP (Microsoft Exchange Internet + Mail Service Version 5.5.2657.72) + id GRDD737G; Wed, 10 Mar 2004 10:55:59 -0500 +Message-ID: <404F3996.2070105@cranel.com> +Date: Wed, 10 Mar 2004 10:51:50 -0500 +From: Greg Spiegelberg +Organization: Cranel, Inc. +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: PgSQL Performance ML , + Postgres Admin List +Subject: Re: syslog slowing the database? +References: <404E2937.4060604@cranel.com> <370.1078877805@sss.pgh.pa.us> +In-Reply-To: <370.1078877805@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: 200403/186 +X-Sequence-Number: 12755 + +Tom Lane wrote: +> Greg Spiegelberg writes: +> +>>I turned syslog back on and the restore slowed down again. Turned +>>it off and it sped right back up. +> +> We have heard reports before of syslog being quite slow. What platform +> are you on exactly? Does Richard's suggestion of turning off syslog's +> fsync help? + +RedHat 7.3 w/ 2.4.24 kernel on a dual Intel PIII 1.3Ghz, 2GB memory, +U160 internal on integrated controller, 1Gbps SAN for database. +Database file being restored and the actual database are on different +disk and controllers than syslog files. + +With the ``-'' in front of the syslog file postgres logs too gives +me roughly 75% of the I/O the performance as reported by iostat. So, +it helps though turning syslog off gives the optimum performance. + +If the log and database were on the same disk I'd be okay with the +current workaround. If the ``-'' gave me near the same performance as +turning syslog off I'd be okay with that too. However, neither of these +are the case so there has to be something else blocking between the two +processes. + +<2 hours and multiple test later> + +I've found that hardware interrupts are the culprit. Given my system +config both SCSI and fibre controllers were throttling the system with +the interrupts required to write the data (syslog & database) and read +the data from the restore. I'm okay with that. + +In the order of worst to best. + +* There were, on average about 450 interrupts/sec with the default + config of syslog on one disk, database on the SAN and syslog using + fsync. + +* Turning fsync off in syslog puts interrupts around 105/sec and. + +* Having syslog fsync turned off in syslog AND moving the syslog file + to a filesystem serviced by the same fibre controller put interrupts + at around 92/sec. I decided to do this after watching the I/O on + the SAN with syslog turned off and found that it had bandwidth to + spare. FYI, the system when idle generated about 50 interrupts/sec. + + +I'm going with the later for now on the test system and after running +it through it's paces with all our processes I'll make the change in +production. I'll post if I run into anything else. + +Greg + + +BTW, I like what metalog has to offer but I prefer using as many of the +default tools as possible and replacing them only when absolutely +necessary. What I've learned with syslog here is that it is still +viable but likely requires a minor tweak. If this tweak fails in +testing I'll look at metalog then. + + +-- +Greg Spiegelberg + Sr. Product Development Engineer + Cranel, Incorporated. + Phone: 614.318.4314 + Fax: 614.431.8388 + Email: gspiegelberg@Cranel.com +Cranel. Technology. Integrity. Focus. + + + +From pgsql-performance-owner@postgresql.org Wed Mar 10 12:10:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 58C50D1BB52 + for ; + Wed, 10 Mar 2004 16:07: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 36215-02 + for ; + Wed, 10 Mar 2004 12:07:39 -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 DAAABD1B80C + for ; + Wed, 10 Mar 2004 12:07:36 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep02-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040310160646.HFDN434741.fep02-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Wed, 10 Mar 2004 11:06:46 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id D62003F40; Wed, 10 Mar 2004 11:07:28 -0500 (EST) +Date: Wed, 10 Mar 2004 11:07:28 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: compiling 7.4.1 on Solaris 9 +Message-ID: <20040310160728.GA29779@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <20040301143457.GC8345@phlogiston.dyndns.org> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.4i +X-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep02-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Wed, + 10 Mar 2004 11:06:45 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/132 +X-Sequence-Number: 5988 + +On Tue, Mar 02, 2004 at 10:54:23AM +0000, teknokrat wrote: +> thanks, i remember a thread about problems with flags passed to gcc on +> solaris. I was wondering if there had been any resolution and if the +> defaults for 7.4 are considered Ok. + +As near as I can tell, -O2 is used by default on Solaris now. Again, +this is on 8, not 9. + +At work, we have been doing a number of tests on 7.4. The +performance is such an improvement over 7.2 that the QA folks thought +there must be something wrong. So I suppose the defaults are ok. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca + +From pgsql-performance-owner@postgresql.org Wed Mar 10 14:17:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 95B4FD1B9AF + for ; + Wed, 10 Mar 2004 16:49: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 46674-07 + for ; + Wed, 10 Mar 2004 12:49:18 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E4C4D1CACF + for ; + Wed, 10 Mar 2004 12:49:17 -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 i2AGmmSn015388; + Wed, 10 Mar 2004 09:48:52 -0700 (MST) +Date: Wed, 10 Mar 2004 09:47:09 -0700 (MST) +From: "scott.marlowe" +To: "Marcus Andree S. Magalhaes" +Cc: +Subject: Re: optimizing large query with IN (...) +In-Reply-To: <62371.200.174.148.100.1078889715.squirrel@webmail.webnow.com.br> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/139 +X-Sequence-Number: 5995 + +On Wed, 10 Mar 2004, Marcus Andree S. Magalhaes wrote: + +> +> Guys, +> +> I got a Java program to tune. It connects to a 7.4.1 postgresql server +> running Linux using JDBC. +> +> The program needs to update a counter on a somewhat large number of +> rows, about 1200 on a ~130k rows table. The query is something like +> the following: +> +> UPDATE table SET table.par = table.par + 1 +> WHERE table.key IN ('value1', 'value2', ... , 'value1200' ) +> +> This query runs on a transaction (by issuing a call to +> setAutoCommit(false)) and a commit() right after the query +> is sent to the backend. +> +> The process of committing and updating the values is painfully slow +> (no surprises here). Any ideas? + +The problem, as I understand it, is that 7.4 introduced massive +improvements in handling moderately large in() clauses, as long as they +can fit in sort_mem, and are provided by a subselect. + +So, creating a temp table with all the values in it and using in() on the +temp table may be a win: + +begin; +create temp table t_ids(id int); +insert into t_ids(id) values (123); <- repeat a few hundred times +select * from maintable where id in (select id from t_ids); +... + + + +From pgsql-admin-owner@postgresql.org Wed Mar 10 14:04:10 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 326FFD1CA0D; Wed, 10 Mar 2004 16:54: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 45231-10; Wed, 10 Mar 2004 12:53:58 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id 320CAD1C98E; Wed, 10 Mar 2004 12:53:57 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2AGrprE007689; + Wed, 10 Mar 2004 11:53:51 -0500 (EST) +To: Greg Spiegelberg +Cc: PgSQL Performance ML , + Postgres Admin List +Subject: Re: syslog slowing the database? +In-reply-to: <404F3996.2070105@cranel.com> +References: <404E2937.4060604@cranel.com> <370.1078877805@sss.pgh.pa.us> + <404F3996.2070105@cranel.com> +Comments: In-reply-to Greg Spiegelberg + message dated "Wed, 10 Mar 2004 10:51:50 -0500" +Date: Wed, 10 Mar 2004 11:53:51 -0500 +Message-ID: <7688.1078937631@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/188 +X-Sequence-Number: 12757 + +Greg Spiegelberg writes: +> If the log and database were on the same disk I'd be okay with the +> current workaround. If the ``-'' gave me near the same performance as +> turning syslog off I'd be okay with that too. However, neither of these +> are the case so there has to be something else blocking between the two +> processes. + +You could also consider not using syslog at all: let the postmaster +output to its stderr, and pipe that into a log-rotation program. +I believe some people use Apache's log rotator for this with good +results. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 10 13:09:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 927E9D1CCC5 + for ; + Wed, 10 Mar 2004 17:02: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 55299-02 + for ; + Wed, 10 Mar 2004 13:02:32 -0400 (AST) +Received: from ideafix.webnow.com.br (ideafix.webnow.com.br [200.155.4.67]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CD20D1CADC + for ; + Wed, 10 Mar 2004 13:02:29 -0400 (AST) +Received: by ideafix.webnow.com.br (Postfix, from userid 48) + id BE859197644; Wed, 10 Mar 2004 14:02:23 -0300 (BRT) +Received: from 148100.cps.virtua.com.br ([200.174.148.100]) + (SquirrelMail authenticated user marcus.magalhaes@vlinfo.com.br) + by webmail.webnow.com.br with HTTP; + Wed, 10 Mar 2004 14:02:23 -0300 (BRT) +Message-ID: <63139.200.174.148.100.1078938143.squirrel@webmail.webnow.com.br> +Date: Wed, 10 Mar 2004 14:02:23 -0300 (BRT) +Subject: Re: optimizing large query with IN (...) +From: "Marcus Andree S. Magalhaes" +To: +In-Reply-To: +References: <62371.200.174.148.100.1078889715.squirrel@webmail.webnow.com.br> + +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: 200403/134 +X-Sequence-Number: 5990 + + +Hmm... from the 'performance' point of view, since the data comes from +a quite complex select statement, Isn't it better/quicker to have this +select replaced by a select into and creating a temporary database? + + + +> The problem, as I understand it, is that 7.4 introduced massive +> improvements in handling moderately large in() clauses, as long as they +> can fit in sort_mem, and are provided by a subselect. +> +> So, creating a temp table with all the values in it and using in() on +> the temp table may be a win: +> +> begin; +> create temp table t_ids(id int); +> insert into t_ids(id) values (123); <- repeat a few hundred times +> select * from maintable where id in (select id from t_ids); +> ... + + + + +From pgsql-performance-owner@postgresql.org Wed Mar 10 14:06:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 705B9D1BCB2 + for ; + Wed, 10 Mar 2004 17:18: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 69518-03 + for ; + Wed, 10 Mar 2004 13:18:14 -0400 (AST) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP id DC115D1B80C + for ; + Wed, 10 Mar 2004 13:18:13 -0400 (AST) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id 6D892900015; Wed, 10 Mar 2004 09:11:04 -0800 (PST) +Date: Wed, 10 Mar 2004 09:11:04 -0800 +From: Steve Atkins +To: pgsql-performance@postgresql.org +Subject: Re: optimizing large query with IN (...) +Message-ID: <20040310171104.GA1666@gp.word-to-the-wise.com> +References: <62371.200.174.148.100.1078889715.squirrel@webmail.webnow.com.br> + + <63139.200.174.148.100.1078938143.squirrel@webmail.webnow.com.br> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <63139.200.174.148.100.1078938143.squirrel@webmail.webnow.com.br> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/138 +X-Sequence-Number: 5994 + +On Wed, Mar 10, 2004 at 02:02:23PM -0300, Marcus Andree S. Magalhaes wrote: + +> Hmm... from the 'performance' point of view, since the data comes from +> a quite complex select statement, Isn't it better/quicker to have this +> select replaced by a select into and creating a temporary database? + +Definitely - why loop the data into the application and back out again +if you don't need to? + +> > The problem, as I understand it, is that 7.4 introduced massive +> > improvements in handling moderately large in() clauses, as long as they +> > can fit in sort_mem, and are provided by a subselect. +> > +> > So, creating a temp table with all the values in it and using in() on +> > the temp table may be a win: +> > +> > begin; +> > create temp table t_ids(id int); +> > insert into t_ids(id) values (123); <- repeat a few hundred times +> > select * from maintable where id in (select id from t_ids); +> > ... + +Cheers, + Steve + +From pgsql-performance-owner@postgresql.org Wed Mar 10 14:03:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 99BD9D1BAC8 + for ; + Wed, 10 Mar 2004 17:36: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 02398-10 + for ; + Wed, 10 Mar 2004 13:36:32 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id C9845D1B80C + for ; + Wed, 10 Mar 2004 13:36:31 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4596984; Wed, 10 Mar 2004 09:37:43 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Tom Lane +Subject: Re: Cluster and vacuum performance +Date: Wed, 10 Mar 2004 09:35:47 -0800 +User-Agent: KMail/1.5.4 +Cc: "Shea,Dan [CIS]" , + pgsql-performance@postgresql.org +References: + <200403091420.53924.josh@agliodbs.com> + <29780.1078875052@sss.pgh.pa.us> +In-Reply-To: <29780.1078875052@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403100935.47299.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/137 +X-Sequence-Number: 5993 + +Tom, + +> You misread it --- "nonremovable" doesn't mean "dead but not removable", +> it just means "not removable". Actually the next line of his log showed +> there were zero nonremovable dead tuples, so he's not got any +> open-transaction problem. + +Ooops. Sorry, Dan. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Wed Mar 10 13:55:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 473CDD1CAD9 + for ; + Wed, 10 Mar 2004 17:54: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 88254-05 + for ; + Wed, 10 Mar 2004 13:53:59 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 676D4D1BB52 + for ; + Wed, 10 Mar 2004 13:53:58 -0400 (AST) +Received: from css120.ihs.com (css120.ihs.com [170.207.105.120]) + by mail1.ihs.com (8.12.10/8.12.10) with ESMTP id i2AHqvSn022696; + Wed, 10 Mar 2004 10:52:57 -0700 (MST) +Date: Wed, 10 Mar 2004 10:51:18 -0700 (MST) +From: "scott.marlowe" +To: "Marcus Andree S. Magalhaes" +Cc: +Subject: Re: optimizing large query with IN (...) +In-Reply-To: <63139.200.174.148.100.1078938143.squirrel@webmail.webnow.com.br> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/135 +X-Sequence-Number: 5991 + +I'm not sure exactly what you're saying here. If the data in the in() +clause comes from a complex select, then just use the select in there, and +bypass the temporary table idea. + +I'm not sure what a temporary database is, did you mean temporary table? +if so, then my above comment addresses that point. + +On Wed, 10 Mar 2004, Marcus Andree S. Magalhaes wrote: + +> +> Hmm... from the 'performance' point of view, since the data comes from +> a quite complex select statement, Isn't it better/quicker to have this +> select replaced by a select into and creating a temporary database? +> +> +> +> > The problem, as I understand it, is that 7.4 introduced massive +> > improvements in handling moderately large in() clauses, as long as they +> > can fit in sort_mem, and are provided by a subselect. +> > +> > So, creating a temp table with all the values in it and using in() on +> > the temp table may be a win: +> > +> > begin; +> > create temp table t_ids(id int); +> > insert into t_ids(id) values (123); <- repeat a few hundred times +> > select * from maintable where id in (select id from t_ids); +> > ... +> +> +> +> + + +From pgsql-admin-owner@postgresql.org Wed Mar 10 15:12:06 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 768E4D1DC14; Wed, 10 Mar 2004 19:10: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 18186-04; Wed, 10 Mar 2004 15:10:10 -0400 (AST) +Received: from busybox.pixar.com (busybox.pixar.com [138.72.18.213]) + by svr1.postgresql.org (Postfix) with ESMTP + id A8E33D1DF86; Wed, 10 Mar 2004 15:08:57 -0400 (AST) +Received: from pixar.com (dreadnok.pixar.com [138.72.16.110]) + by busybox.pixar.com (8.12.8/8.12.8) with ESMTP id i2AJ8oHw030829; + Wed, 10 Mar 2004 11:08:50 -0800 +Message-ID: <404F67C2.70003@pixar.com> +Date: Wed, 10 Mar 2004 11:08:50 -0800 +From: Mark Harrison +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Greg Spiegelberg , + PgSQL Performance ML , + Postgres Admin List +Subject: Re: syslog slowing the database? +References: <404E2937.4060604@cranel.com> <370.1078877805@sss.pgh.pa.us> + <404F3996.2070105@cranel.com> <7688.1078937631@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: 200403/190 +X-Sequence-Number: 12759 + +Tom Lane wrote: +> Greg Spiegelberg writes: +> +>>If the log and database were on the same disk I'd be okay with the +>>current workaround. If the ``-'' gave me near the same performance as +>>turning syslog off I'd be okay with that too. However, neither of these +>>are the case so there has to be something else blocking between the two +>>processes. +> +> +> You could also consider not using syslog at all: let the postmaster +> output to its stderr, and pipe that into a log-rotation program. +> I believe some people use Apache's log rotator for this with good +> results. + +I do this... here's the relevant lines from my startup script: + +ROTATE="/inst/apache/bin/rotatelogs $PGLOGS/postgresql 86400" +$PGBIN/pg_ctl start -s -D $PGDATA | $ROTATE & + +Following is a patch to rotatelogs that does two things: + +- makes a symbolic link 'foo.current' that points to the + current output file. + +- gzips the rotated logfile + +If you have gnu tools installed, you can + tail --retry --follow=name foo.current +and it will automatically track the most recent +log file. + +HTH, +Mark + +-- +Mark Harrison +Pixar Animation Studios + + +*** rotatelogs.c-orig 2004-03-10 10:24:02.000000000 -0800 +--- rotatelogs.c 2004-03-10 11:01:55.000000000 -0800 +*************** +*** 25,30 **** +--- 25,32 ---- + int main (int argc, char **argv) + { + char buf[BUFSIZE], buf2[MAX_PATH], errbuf[ERRMSGSZ]; ++ char linkbuf[MAX_PATH]; ++ char oldbuf2[MAX_PATH]; + time_t tLogEnd = 0, tRotation; + int nLogFD = -1, nLogFDprev = -1, nMessCount = 0, nRead, nWrite; + int utc_offset = 0; +*************** +*** 75,80 **** +--- 77,84 ---- + setmode(0, O_BINARY); + #endif + ++ sprintf(linkbuf, "%s.current", szLogRoot); ++ sprintf(oldbuf2, ""); + use_strftime = (strstr(szLogRoot, "%") != NULL); + for (;;) { + nRead = read(0, buf, sizeof buf); +*************** +*** 99,104 **** +--- 103,111 ---- + sprintf(buf2, "%s.%010d", szLogRoot, (int) tLogStart); + } + tLogEnd = tLogStart + tRotation; ++ printf("oldbuf2=%s\n",oldbuf2); ++ printf("buf2=%s\n",buf2); ++ printf("linkbuf=%s\n",linkbuf); + nLogFD = open(buf2, O_WRONLY | O_CREAT | O_APPEND, 0666); + if (nLogFD < 0) { + /* Uh-oh. Failed to open the new log file. Try to clear +*************** +*** 125,130 **** +--- 132,146 ---- + } + else { + close(nLogFDprev); ++ /* use: tail --follow=name foo.current */ ++ unlink(linkbuf); ++ symlink(buf2,linkbuf); ++ if (strlen(oldbuf2) > 0) { ++ char cmd[MAX_PATH+100]; ++ sprintf(cmd, "gzip %s &", oldbuf2); ++ system(cmd); ++ } ++ strcpy(oldbuf2, buf2); + } + nMessCount = 0; + } + + +From pgsql-performance-owner@postgresql.org Wed Mar 10 17:09:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 99D4AD1B4A7 + for ; + Wed, 10 Mar 2004 21:00:40 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 62971-03 + for ; + Wed, 10 Mar 2004 17:00:38 -0400 (AST) +Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) + by svr1.postgresql.org (Postfix) with ESMTP id 85A73D1B467 + for ; + Wed, 10 Mar 2004 17:00:36 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id 39A0F3F38 + for ; + Wed, 10 Mar 2004 16:00:37 -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 08515-01-2 for ; + Wed, 10 Mar 2004 16:00:36 -0500 (EST) +Received: by lorax.kcilink.com (Postfix, from userid 8) + id AF0653F36; Wed, 10 Mar 2004 16:00:36 -0500 (EST) +To: pgsql-performance@postgresql.org +Path: not-for-mail +From: Vivek Khera +Newsgroups: ml.postgres.performance +Subject: Re: syslog slowing the database? +Date: Wed, 10 Mar 2004 16:00:36 -0500 +Organization: Khera Communications, Inc., Rockville, MD +Lines: 20 +Message-ID: +References: <404E2937.4060604@cranel.com> +NNTP-Posting-Host: yertle.kcilink.com +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Trace: lorax.kcilink.com 1078952436 27132 65.205.34.180 (10 Mar 2004 + 21:00:36 GMT) +X-Complaints-To: daemon@kciLink.com +NNTP-Posting-Date: Wed, 10 Mar 2004 21:00:36 +0000 (UTC) +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + berkeley-unix) +Cancel-Lock: sha1:2Prg0lzJXy1ZUTYDMvG1nQ2KH3Y= +X-Virus-Scanned: by amavisd-new at kcilink.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/141 +X-Sequence-Number: 5997 + +>>>>> "GS" == Greg Spiegelberg writes: + +GS> I've been waiting all day for a pg_restore to finish on a test system +GS> identically configured as our production in hardware and software +GS> with the exception prod is 7.3.5 and test is 7.4.1. + +GS> The file it's restoring from is about 8GB uncompressed from a +GS> "pg_dump -b -F t" and after 2 hours the directory the database is in +GS> contains only 1GB. iostat reported ~2000 blocks written every 2 +GS> seconds to the DB file system. + +Have you considered increasing the value of checkpoint_segments to +something like 50 or 100 during your restore? It made a *dramatic* +improvement on my system when I did the same migration. + +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +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 Wed Mar 10 19:21:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D1337D1B459 + for ; + Wed, 10 Mar 2004 23:21: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 27070-03 + for ; + Wed, 10 Mar 2004 19:21:43 -0400 (AST) +Received: from jefftrout.com (h00a0cc4084e5.ne.client2.attbi.com + [24.128.241.68]) + by svr1.postgresql.org (Postfix) with SMTP id D38D1D1D263 + for ; + Wed, 10 Mar 2004 19:21:39 -0400 (AST) +Received: (qmail 20919 invoked from network); 10 Mar 2004 23:21:48 -0000 +Received: from unknown (HELO ?192.168.0.6?) (10.10.10.177) + by 10.10.10.10 with SMTP; 10 Mar 2004 23:21:48 -0000 +In-Reply-To: +References: + <20040301143457.GC8345@phlogiston.dyndns.org> + +Mime-Version: 1.0 (Apple Message framework v612) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Jeff +Subject: Re: compiling 7.4.1 on Solaris 9 +Date: Wed, 10 Mar 2004 18:21:43 -0500 +To: teknokrat@yahoo.com +X-Mailer: Apple Mail (2.612) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/142 +X-Sequence-Number: 5998 + + +On Mar 2, 2004, at 5:54 AM, teknokrat wrote: + +> Andrew Sullivan wrote: +>> On Thu, Feb 26, 2004 at 12:46:23PM +0000, teknokrat wrote: +>>> I've read about the place. Would using -O3 be an improvement? +>> In my experience, it's not only not an improvement, it sometimes +>> breaks the code. That's on 8, though, not 9. +>> A +> +> thanks, i remember a thread about problems with flags passed to gcc on +> solaris. I was wondering if there had been any resolution and if the +> defaults for 7.4 are considered Ok. +> +Yes. The compile flags on solaris were fixed on 7.4. Previously it +wasn't using any optimization flags. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + +From pgsql-performance-owner@postgresql.org Sat Mar 13 15:59:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 85C9DD1CAD9 + for ; + Wed, 10 Mar 2004 23:29: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 26515-06 + for ; + Wed, 10 Mar 2004 19:29:54 -0400 (AST) +Received: from outputservices.com (outputt1130.customer.frii.net + [216.17.159.130]) + by svr1.postgresql.org (Postfix) with ESMTP id C3D5FD1C9E1 + for ; + Wed, 10 Mar 2004 19:29:50 -0400 (AST) +Received: from outputservices.com (outputservices.com [137.106.76.15]) + by outputservices.com (8.11.3/8.11.3) with ESMTP id i2ANTti09169 + for ; + Wed, 10 Mar 2004 16:29:55 -0700 (MST) +Message-ID: <404FA4F3.6080903@outputservices.com> +Date: Wed, 10 Mar 2004 16:29:55 -0700 +From: Marty Scholes +User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; + rv:1.0.1) Gecko/20020920 Netscape/7.0 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Scaling further up +References: <404F9D0F.5040309@outputservices.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: 200403/178 +X-Sequence-Number: 6034 + +I have some suggestions based on my anecdotal experience. + +1. This is a relatively small DB -- the working set will likely be in +RAM at any moment in time, making read I/O time mostly irrelevant. + +2. The killer will be write times -- specifically log writes. Small and +heavily synchronized writes, log and data writes, will drag down an +impressive hardware RAID setup. We run mirrored hardware RAID 5 arrays +with write back cache and are constantly seeking ways to improve write +performance. We do a lot of batch processing, though, so we do a lot of +write I/Os. + +3. Be very careful with "battery backed write cache." It usually works +as advertised. More than once in the past decade I have seen +spontaneous cache corruption after power losss. The corruption usually +happens when some admin, including me, has assumed that the cache will +ALWAYS survive a power failure unblemished and has no "plan B." Make +sure you have a contingency plan for corruption, or don't enable the cache. + +4. RAID 10 will likely have bigger stripe sizes on the RAID 0 portion of +the setup, and might hinder, not help small write I/O performance. + +5. Most (almost all) of the I/O time will be due to the access time +(head seek + head settle + rotational latency) and very little of the +I/O time will due to data transfer time. In other words, getting drives +that provide faster transfer rates will barely improve performance. The +secret is lowering the access time. + +6. A relatively cheap way to drastically drop the access time is to get +large drive(s) and only use a portion of them for storage. The less +space used on the drive, the less area the heads need to cover for +seeks. At one extreme, you could make the partition the size of a +single cylinder. This would make access time (ignoring OS and +controller overhead) identical to rotational latency, which is as low as +4.2 ms for a cheap 7200 RPM drive. + +7. A drive with a 5 ms average service time, servicing 8 KB blocks, will +yield as much as 1.6 MB/s sustained write throughput. Not bad for a +cheap uncached solution. Any OS aggregation of writes during the +fsync() call will further improve this number -- it is basically a lower +bound for throughput. + +8. Many people, especially managers, cannot stomach buying disk space +and only using a portion of it. In many cases, it seems more palatable +to purchase a much more expensive solution to get to the same speeds. + +Good luck. + +scott.marlowe wrote: +> On Wed, 3 Mar 2004, Paul Thomas wrote: +> +> > +> > On 02/03/2004 23:25 johnnnnnn wrote: +> > > [snip] +> > > random_page_cost should be set with the following things taken into +> > > account: +> > > - seek speed +> > +> > Which is not exactly the same thing as spindle speed as it's a +> combination +> > of spindle speed and track-to-track speed. I think you'll find that a +> 15K +> > rpm disk, whilst it will probably have a lower seek time than a 10K rpm +> > disk, won't have a proportionately (i.e., 2/3rds) lower seek time. +> +> There are three factors that affect how fast you can get to the next +> sector: +> +> seek time +> settle time +> rotational latency +> +> Most drives only list the first, and don't bother to mention the other +> two. +> +> On many modern drives, the seek times are around 5 to 10 milliseconds. +> The settle time varies as well. the longer the seek, the longer the +> settle, generally. This is the time it takes for the head to stop shaking +> and rest quietly over a particular track. +> Rotational Latency is the amount of time you have to wait, on average, for +> the sector you want to come under the heads. +> +> Assuming an 8 ms seek, and 2 ms settle (typical numbers), and that the +> rotational latency on average is 1/2 of a rotation: At 10k rpm, a +> rotation takes 1/166.667 of a second, or 6 mS. So, a half a rotation is +> approximately 3 mS. By going to a 15k rpm drive, the latency drops to 2 +> mS. So, if we add them up, on the same basic drive, one being 10k and one +> being 15k, we get: +> +> 10krpm: 8+2+3 = 13 mS +> 15krpm: 8+2+2 = 12 mS +> +> So, based on the decrease in rotational latency being the only advantage +> the 15krpm drive has over the 10krpm drive, we get an decrease in access +> time of only 1 mS, or only about an 8% decrease in actual seek time. +> +> So, if you're random page cost on 10krpm drives was 1.7, you'd need to +> drop it to 1.57 or so to reflect the speed increase from 15krpm drives. +> +> I.e. it's much more likely that going from 1 gig to 2 gigs of ram will +> make a noticeable difference than going from 10k to 15k drives. +> +> +> + + + +From pgsql-performance-owner@postgresql.org Sat Mar 13 15:53:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AB354D1D3BC + for ; + Thu, 11 Mar 2004 00: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 48884-01 + for ; + Wed, 10 Mar 2004 20:52:25 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id C55A6D1D2E2 + for ; + Wed, 10 Mar 2004 20:52:21 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i2B0qK1c018800 + for ; Thu, 11 Mar 2004 00:52:21 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i2B0fg4f017800 + for pgsql-performance@postgresql.org; Thu, 11 Mar 2004 00:41:42 GMT +From: Joseph Shraibman +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: optimizing large query with IN (...) +Date: Wed, 10 Mar 2004 19:41:45 -0500 +Organization: Hub.Org Networking Services +Lines: 17 +Message-ID: <404FB5C9.3060803@selectacast.net> +References: <62371.200.174.148.100.1078889715.squirrel@webmail.webnow.com.br> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +To: "Marcus Andree S. Magalhaes" +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +In-Reply-To: <62371.200.174.148.100.1078889715.squirrel@webmail.webnow.com.br> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/176 +X-Sequence-Number: 6032 + +Marcus Andree S. Magalhaes wrote: +> Guys, +> +> I got a Java program to tune. It connects to a 7.4.1 postgresql server +> running Linux using JDBC. +> +> The program needs to update a counter on a somewhat large number of +> rows, about 1200 on a ~130k rows table. The query is something like +> the following: +> +> UPDATE table SET table.par = table.par + 1 +> WHERE table.key IN ('value1', 'value2', ... , 'value1200' ) +> + +How often do you update this counter? Each update requires adding a new +row to the table and invalidating the old one. Then the old ones stick +around until the next vacuum. + +From pgsql-performance-owner@postgresql.org Sat Mar 13 15:56:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 82B5AD1D342 + for ; + Thu, 11 Mar 2004 00: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 44531-05 + for ; + Wed, 10 Mar 2004 20:52:24 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 74D18D1D2DC + for ; + Wed, 10 Mar 2004 20:52:21 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i2B0qK1a018800 + for ; Thu, 11 Mar 2004 00:52:21 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i2B0hs90017885 + for pgsql-performance@postgresql.org; Thu, 11 Mar 2004 00:43:54 GMT +From: Joseph Shraibman +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Postgresql on SAN +Date: Wed, 10 Mar 2004 19:43:57 -0500 +Organization: Hub.Org Networking Services +Lines: 8 +Message-ID: +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF78508C847@vt-pe2550-001.vantage.vantage.com> + <200402190936.47208.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +In-Reply-To: <200402190936.47208.josh@agliodbs.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/177 +X-Sequence-Number: 6033 + +Josh Berkus wrote: +> +> +> See above. Also keep in mind that PostgreSQL's use of I/O should improve +> 100% in version 7.5. +> + +Really? What happened? + +From pgsql-admin-owner@postgresql.org Sat Mar 13 15:41:35 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 76FC5D1B80B; Thu, 11 Mar 2004 01:28: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 56023-02; Wed, 10 Mar 2004 21:28:18 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP + id 9A200D1B4F4; Wed, 10 Mar 2004 21:28:14 -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 + i2B1SBWL069890; Thu, 11 Mar 2004 09:28:11 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <404FC23E.9000207@familyhealth.com.au> +Date: Thu, 11 Mar 2004 09:34:54 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Greg Spiegelberg , + PgSQL Performance ML , + Postgres Admin List +Subject: Re: [PERFORM] syslog slowing the database? +References: <404E2937.4060604@cranel.com> <370.1078877805@sss.pgh.pa.us> + <404F3996.2070105@cranel.com> <7688.1078937631@sss.pgh.pa.us> +In-Reply-To: <7688.1078937631@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: 200403/207 +X-Sequence-Number: 12776 + +> You could also consider not using syslog at all: let the postmaster +> output to its stderr, and pipe that into a log-rotation program. +> I believe some people use Apache's log rotator for this with good +> results. + +Not an option I'm afraid. PostgreSQL just jams and stops logging after +the first rotation... + +I've read in the docs that syslog logging is the only "production" +solution... + +Chris + + +From pgsql-admin-owner@postgresql.org Sat Mar 13 16:22:07 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 976EFD1CCAD; Thu, 11 Mar 2004 01:37: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 55026-06; Wed, 10 Mar 2004 21:37:58 -0400 (AST) +Received: from dnscache2.syd.nexon.com.au (dnscache2.syd.nexon.com.au + [210.215.48.100]) by svr1.postgresql.org (Postfix) with ESMTP + id 36A90D1CAD9; Wed, 10 Mar 2004 21:37:53 -0400 (AST) +Received: from chris ([210.215.130.98]) + by dnscache2.syd.nexon.com.au (8.12.8p1/8.12.8) with ESMTP id + i2AMaf9g039982; Thu, 11 Mar 2004 09:36:42 +1100 (EST) + (envelope-from chris@interspire.com) +From: "Chris Smith" +To: "'Christopher Kings-Lynne'" +Cc: "'PgSQL Performance ML'" , + "'Postgres Admin List'" +Subject: Re: [PERFORM] syslog slowing the database? +Date: Thu, 11 Mar 2004 12:37:38 +1100 +Message-ID: <000201c40709$70e5e070$0d00a8c0@chris> +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 +Importance: Normal +In-Reply-To: <404FC23E.9000207@familyhealth.com.au> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/214 +X-Sequence-Number: 12783 + +It might depend on how you're rotating it. + +Try the copy/truncate method instead of moving the log file. If you move +the log file to another filename you usually have to restart the app +doing the logging before it starts logging again. + +Chris. + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Christopher +Kings-Lynne +Sent: Thursday, March 11, 2004 12:35 PM +To: Tom Lane +Cc: Greg Spiegelberg; PgSQL Performance ML; Postgres Admin List +Subject: Re: [PERFORM] [ADMIN] syslog slowing the database? + + +> You could also consider not using syslog at all: let the postmaster +> output to its stderr, and pipe that into a log-rotation program. I +> believe some people use Apache's log rotator for this with good +> results. + +Not an option I'm afraid. PostgreSQL just jams and stops logging after +the first rotation... + +I've read in the docs that syslog logging is the only "production" +solution... + +Chris + + +---------------------------(end of broadcast)--------------------------- +TIP 2: you can get off all lists at once with the unregister command + (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + + + +From pgsql-admin-owner@postgresql.org Wed Mar 10 22:01:17 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 33158D1D2E2 + for ; + Thu, 11 Mar 2004 02:01: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 57309-08 + for ; + Wed, 10 Mar 2004 22:01:16 -0400 (AST) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id AE6FED1D263 + for ; Wed, 10 Mar 2004 22:01:11 -0400 (AST) +Received: (qmail 13421 invoked by uid 500); 11 Mar 2004 02:03:46 -0000 +Date: Wed, 10 Mar 2004 20:03:46 -0600 +From: Bruno Wolff III +To: Christopher Kings-Lynne +Cc: Tom Lane , Greg Spiegelberg , + PgSQL Performance ML , + Postgres Admin List +Subject: Re: [PERFORM] syslog slowing the database? +Message-ID: <20040311020346.GA13391@wolff.to> +Mail-Followup-To: Christopher Kings-Lynne , + Tom Lane , + Greg Spiegelberg , + PgSQL Performance ML , + Postgres Admin List +References: <404E2937.4060604@cranel.com> <370.1078877805@sss.pgh.pa.us> + <404F3996.2070105@cranel.com> <7688.1078937631@sss.pgh.pa.us> + <404FC23E.9000207@familyhealth.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <404FC23E.9000207@familyhealth.com.au> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/194 +X-Sequence-Number: 12763 + +On Thu, Mar 11, 2004 at 09:34:54 +0800, + Christopher Kings-Lynne wrote: +> >You could also consider not using syslog at all: let the postmaster +> >output to its stderr, and pipe that into a log-rotation program. +> >I believe some people use Apache's log rotator for this with good +> >results. +> +> Not an option I'm afraid. PostgreSQL just jams and stops logging after +> the first rotation... +> +> I've read in the docs that syslog logging is the only "production" +> solution... + +I use multilog to log postgres' output and it works fine. + +From pgsql-admin-owner@postgresql.org Thu Mar 11 00:10:17 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 62EE4D1B4B9; Thu, 11 Mar 2004 04:09: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 05619-03; Thu, 11 Mar 2004 00:09:53 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id BF1F9D1D269; Thu, 11 Mar 2004 00:09:52 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2B49fJU015550; + Wed, 10 Mar 2004 23:09:41 -0500 (EST) +To: Christopher Kings-Lynne +Cc: Greg Spiegelberg , + PgSQL Performance ML , + Postgres Admin List +Subject: Re: [PERFORM] syslog slowing the database? +In-reply-to: <404FC23E.9000207@familyhealth.com.au> +References: <404E2937.4060604@cranel.com> <370.1078877805@sss.pgh.pa.us> + <404F3996.2070105@cranel.com> <7688.1078937631@sss.pgh.pa.us> + <404FC23E.9000207@familyhealth.com.au> +Comments: In-reply-to Christopher Kings-Lynne + message dated "Thu, 11 Mar 2004 09:34:54 +0800" +Date: Wed, 10 Mar 2004 23:09:41 -0500 +Message-ID: <15549.1078978181@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/196 +X-Sequence-Number: 12765 + +Christopher Kings-Lynne writes: +>> You could also consider not using syslog at all: let the postmaster +>> output to its stderr, and pipe that into a log-rotation program. +>> I believe some people use Apache's log rotator for this with good +>> results. + +> Not an option I'm afraid. PostgreSQL just jams and stops logging after +> the first rotation... + +I know some people use this in production. Dunno what went wrong in +your test, but it can be made to work. + + regards, tom lane + +From pgsql-admin-owner@postgresql.org Thu Mar 11 09:59:33 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5FF9AD1D8DA; Thu, 11 Mar 2004 13:59: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 61252-07; Thu, 11 Mar 2004 09:58:42 -0400 (AST) +Received: from mail.abitab.com.uy (r200-40-59-195.adinet.com.uy + [200.40.59.195]) by svr1.postgresql.org (Postfix) with ESMTP + id 66FACD1D29F; Thu, 11 Mar 2004 09:58:32 -0400 (AST) +Received: from badesa05.desarrollo.bancaqm.com.uy + (badesa05.desarrollo.bancaqm.com.uy [10.100.4.5]) + by mail.abitab.com.uy (Abitab MailServer by RootWay) with SMTP + id E1ECF3FDDC; Thu, 11 Mar 2004 10:56:37 -0300 (UYT) +Subject: started Data Warehousing +From: Pablo Marrero +To: "pgsql-admin@postgresql.org" , + PgSQL Performance ML +Content-Type: text/plain +Organization: +Message-Id: <1079013242.1676.22.camel@badesa05.desarrollo.bancaqm.com.uy> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.2.2 +Date: 11 Mar 2004 10:54:03 -0300 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/198 +X-Sequence-Number: 12767 + +Hello people! +I have a question, I am going to begin a project for the University in +the area of Data Warehousing and I want to use postgres. +Do you have some recommendation to me? + +Thanks!! + +Greetings, Pablo + + + +From pgsql-admin-owner@postgresql.org Sat Mar 13 15:41:50 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 4582FD1DB17; Thu, 11 Mar 2004 14:53: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 84250-03; Thu, 11 Mar 2004 10:53:12 -0400 (AST) +Received: from hosting.commandprompt.com (138.commandprompt.com + [207.173.200.138]) by svr1.postgresql.org (Postfix) with ESMTP + id EE78AD1DA9B; Thu, 11 Mar 2004 10:53:06 -0400 (AST) +Received: from commandprompt.com (clbb-248.saw.net [64.146.135.248]) + (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i2BEr2p09069; + Thu, 11 Mar 2004 06:53:02 -0800 +Message-ID: <40507DCA.8030609@commandprompt.com> +Date: Thu, 11 Mar 2004 06:55:06 -0800 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: Christopher Kings-Lynne , + Greg Spiegelberg , + PgSQL Performance ML , + Postgres Admin List +Subject: Re: [PERFORM] syslog slowing the database? +References: <404E2937.4060604@cranel.com> <370.1078877805@sss.pgh.pa.us> + <404F3996.2070105@cranel.com> <7688.1078937631@sss.pgh.pa.us> + <404FC23E.9000207@familyhealth.com.au> + <15549.1078978181@sss.pgh.pa.us> +In-Reply-To: <15549.1078978181@sss.pgh.pa.us> +Content-Type: multipart/mixed; boundary="------------070505090500040600080701" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/209 +X-Sequence-Number: 12778 + +This is a multi-part message in MIME format. +--------------070505090500040600080701 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + + +>>Not an option I'm afraid. PostgreSQL just jams and stops logging after +>>the first rotation... + +Are you using a copy truncate method to rotate the logs? In RedHat add +the keyword COPYTRUCATE to your /etc/logrotate.d/syslog file. + +Sincerely, + +Joshua D. Drake + + + +> +> +> I know some people use this in production. Dunno what went wrong in +> your test, but it can be made to work. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + + +--------------070505090500040600080701 +Content-Type: text/x-vcard; charset=utf8; + name="jd.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="jd.vcf" + +begin:vcard +fn:Joshua D. Drake +n:Drake;Joshua D. +org:Command Prompt, Inc. +adr:;;PO Box 215;Cascade Locks;Oregon;97014;USA +email;internet:jd@commandprompt.com +title:Consultant +tel;work:503-667-4564 +tel;fax:503-210-0034 +note:Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. +x-mozilla-html:FALSE +url:http://www.commandprompt.com/ +version:2.1 +end:vcard + + +--------------070505090500040600080701-- + +From pgsql-admin-owner@postgresql.org Sat Mar 13 15:41:45 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 9855CD1DC9D; Thu, 11 Mar 2004 14:53: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 83775-04; Thu, 11 Mar 2004 10:53:50 -0400 (AST) +Received: from hosting.commandprompt.com (138.commandprompt.com + [207.173.200.138]) by svr1.postgresql.org (Postfix) with ESMTP + id 9165DD1DC06; Thu, 11 Mar 2004 10:53:43 -0400 (AST) +Received: from commandprompt.com (clbb-248.saw.net [64.146.135.248]) + (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i2BErhp09167; + Thu, 11 Mar 2004 06:53:43 -0800 +Message-ID: <40507DF4.2020701@commandprompt.com> +Date: Thu, 11 Mar 2004 06:55:48 -0800 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Pablo Marrero +Cc: "pgsql-admin@postgresql.org" , + PgSQL Performance ML +Subject: Re: [PERFORM] started Data Warehousing +References: <1079013242.1676.22.camel@badesa05.desarrollo.bancaqm.com.uy> +In-Reply-To: <1079013242.1676.22.camel@badesa05.desarrollo.bancaqm.com.uy> +Content-Type: multipart/mixed; boundary="------------090306030703030508030807" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/208 +X-Sequence-Number: 12777 + +This is a multi-part message in MIME format. +--------------090306030703030508030807 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Pablo Marrero wrote: +> Hello people! +> I have a question, I am going to begin a project for the University in +> the area of Data Warehousing and I want to use postgres. +> Do you have some recommendation to me? +> + +Regarding what? Do you have an specific questions? + +Sincerely, + +Joshua D. Drake + + +> Thanks!! +> +> Greetings, Pablo +> +> +> +> ---------------------------(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 + + +--------------090306030703030508030807 +Content-Type: text/x-vcard; charset=utf8; + name="jd.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="jd.vcf" + +begin:vcard +fn:Joshua D. Drake +n:Drake;Joshua D. +org:Command Prompt, Inc. +adr:;;PO Box 215;Cascade Locks;Oregon;97014;USA +email;internet:jd@commandprompt.com +title:Consultant +tel;work:503-667-4564 +tel;fax:503-210-0034 +note:Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. +x-mozilla-html:FALSE +url:http://www.commandprompt.com/ +version:2.1 +end:vcard + + +--------------090306030703030508030807-- + +From pgsql-admin-owner@postgresql.org Sat Mar 13 15:58:40 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 19A95D1DCEB; Thu, 11 Mar 2004 15:09: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 90123-06; Thu, 11 Mar 2004 11:09:05 -0400 (AST) +Received: from themode.com (themode.com [161.58.169.198]) + by svr1.postgresql.org (Postfix) with ESMTP + id D3779D1DB8E; Thu, 11 Mar 2004 11:09:00 -0400 (AST) +Received: from localhost (bde@localhost) + by themode.com (8.12.11/8.12.10) with ESMTP id i2BF8r31082853; + Thu, 11 Mar 2004 10:08:54 -0500 (EST) +Date: Thu, 11 Mar 2004 10:08:52 -0500 (EST) +From: brew@theMode.com +X-X-Sender: mode@themode.com +To: Pablo Marrero +Cc: "pgsql-admin@postgresql.org" , + PgSQL Performance ML +Subject: Re: [PERFORM] started Data Warehousing +In-Reply-To: <1079013242.1676.22.camel@badesa05.desarrollo.bancaqm.com.uy> +Message-ID: +References: <1079013242.1676.22.camel@badesa05.desarrollo.bancaqm.com.uy> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/212 +X-Sequence-Number: 12781 + + +Pablo..... + +> I have a question, I am going to begin a project for the University in +> the area of Data Warehousing and I want to use postgres. Do you have +> some recommendation to me? + +Yes. Set up a linux machine if you don't have access to one so you can +load postgresql and start learning how postgresql works by playing with +it. Even after you get the production database running you can use it for +testing (or even the main machine, depending, but it's nice to have a test +platform entirely removed from the hot database). + +And start reading, read the pgsql newsgroups (and not just performance, +there are other more basic ones), read the online docs and books, and +there are printed books, too. A wealth of information. + +I'm sure others have more ideas to recommend, too...... + +brew + + ========================================================================== + Strange Brew (brew@theMode.com) + Check out my Musician's Online Database Exchange (The MODE Pages) + http://www.TheMode.com + ========================================================================== + + +From pgsql-performance-owner@postgresql.org Thu Mar 11 14:26:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0305FD1D8AE + for ; + Thu, 11 Mar 2004 18:26: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 61387-06 + for ; + Thu, 11 Mar 2004 14:26:12 -0400 (AST) +Received: from smtpout.mac.com (smtpout.mac.com [17.250.248.88]) + by svr1.postgresql.org (Postfix) with ESMTP id 46763D1D332 + for ; + Thu, 11 Mar 2004 14:26:05 -0400 (AST) +Received: from mac.com (smtpin07-en2 [10.13.10.152]) + by smtpout.mac.com (Xserve/MantshX 2.0) with ESMTP id i2BIQA8p016802 + for ; + Thu, 11 Mar 2004 10:26:10 -0800 (PST) +Received: from mac.com ([212.20.254.120]) (authenticated bits=0) + by mac.com (Xserve/smtpin07/MantshX 3.0) with ESMTP id i2BIQ5AD012333 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) + for ; + Thu, 11 Mar 2004 10:26:10 -0800 (PST) +Message-ID: <4050AF10.9060006@mac.com> +Date: Thu, 11 Mar 2004 18:25:20 +0000 +From: Mike Moran +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.3b) Gecko/20030210 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PgSQL Performance ML +Subject: Impact of varchar/text in use of indexes +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: 200403/151 +X-Sequence-Number: 6007 + +Hi. I have two existing tables, A and B. A has a 'varchar(1000)' field +and B has a 'text' field, each with btree indexes defined. When I do a +join between these, on this field, it seems to a hash join, as opposed +to using the indexes, as I might expect (I'm no postgres expert, btw). + +My question is: if I changed both fields to be text or varchar(1000) +then would the index be used? + +Ta, + +-- +Mike + + + +From pgsql-performance-owner@postgresql.org Thu Mar 11 14:29:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D543D1D342 + for ; + Thu, 11 Mar 2004 18:29: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 30039-08 + for ; + Thu, 11 Mar 2004 14:29:16 -0400 (AST) +Received: from fep01-mail.bloor.is.net.cable.rogers.com + (fep01-mail.bloor.is.net.cable.rogers.com [66.185.86.71]) + by svr1.postgresql.org (Postfix) with ESMTP id 39E57D1B9A4 + for ; + Thu, 11 Mar 2004 14:29:10 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep01-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040311182851.ZJDP230350.fep01-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Thu, 11 Mar 2004 13:28:51 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 1A1E43F3F; Thu, 11 Mar 2004 13:29:08 -0500 (EST) +Date: Thu, 11 Mar 2004 13:29:08 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: compiling 7.4.1 on Solaris 9 +Message-ID: <20040311182908.GA32153@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <20040301143457.GC8345@phlogiston.dyndns.org> + + <20040310160728.GA29779@phlogiston.dyndns.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20040310160728.GA29779@phlogiston.dyndns.org> +User-Agent: Mutt/1.5.4i +X-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep01-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Thu, + 11 Mar 2004 13:28:50 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/152 +X-Sequence-Number: 6008 + +On Wed, Mar 10, 2004 at 11:07:28AM -0500, Andrew Sullivan wrote: + +> At work, we have been doing a number of tests on 7.4. The +> performance is such an improvement over 7.2 that the QA folks thought +> there must be something wrong. So I suppose the defaults are ok. + +I know, I know, replying to myself. I just wanted to note that we +_were_ using optimisation with 7.2. 7.4 is still a lot faster. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca + +From pgsql-performance-owner@postgresql.org Thu Mar 11 15:02:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5E684D1B9A4 + for ; + Thu, 11 Mar 2004 19:02: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 38436-10 + for ; + Thu, 11 Mar 2004 15:02:19 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 4AEEAD1CCB1 + for ; + Thu, 11 Mar 2004 15:02:13 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2BJ2BdV021846; + Thu, 11 Mar 2004 14:02:12 -0500 (EST) +To: Mike Moran +Cc: PgSQL Performance ML +Subject: Re: Impact of varchar/text in use of indexes +In-reply-to: <4050AF10.9060006@mac.com> +References: <4050AF10.9060006@mac.com> +Comments: In-reply-to Mike Moran + message dated "Thu, 11 Mar 2004 18:25:20 +0000" +Date: Thu, 11 Mar 2004 14:02:11 -0500 +Message-ID: <21844.1079031731@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/153 +X-Sequence-Number: 6009 + +Mike Moran writes: +> Hi. I have two existing tables, A and B. A has a 'varchar(1000)' field +> and B has a 'text' field, each with btree indexes defined. When I do a +> join between these, on this field, it seems to a hash join, as opposed +> to using the indexes, as I might expect (I'm no postgres expert, btw). + +> My question is: if I changed both fields to be text or varchar(1000) +> then would the index be used? + +Probably not, and in any case your assumption is mistaken. Indexes are +not always the right way to join. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 11 21:47:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AFA87D1DBD8 + for ; + Fri, 12 Mar 2004 01: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 42122-01 + for ; + Thu, 11 Mar 2004 21:47:26 -0400 (AST) +Received: from hotmail.com (bay13-f54.bay13.hotmail.com [64.4.31.54]) + by svr1.postgresql.org (Postfix) with ESMTP id 2BD5DD1DB34 + for ; + Thu, 11 Mar 2004 21:47:18 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Thu, 11 Mar 2004 17:47:23 -0800 +Received: from 68.38.165.44 by by13fd.bay13.hotmail.msn.com with HTTP; + Fri, 12 Mar 2004 01:47:23 GMT +X-Originating-IP: [68.38.165.44] +X-Originating-Email: [bigwhitecow@hotmail.com] +X-Sender: bigwhitecow@hotmail.com +From: "Eric Brown" +To: pgsql-performance@postgresql.org +Subject: severe performance issue with planner +Date: Thu, 11 Mar 2004 20:47:23 -0500 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +Message-ID: +X-OriginalArrivalTime: 12 Mar 2004 01:47:23.0697 (UTC) + FILETIME=[F7046210:01C407D3] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/154 +X-Sequence-Number: 6010 + +First let me explain the situation: + +I came into the #postgresql irc channel talking about this problem, and +someone advised me to use this mailing list (so i'm not just wasting your +time i hope). I'm not sure how to describe the problem fully, so I'll start +by explaining what my database does, a little about the table structure, +then an example of a problematic query, and some other information that +might be relevant. + +My database is a Chinese-English/English-Chinese dictionary. It lets users +search Chinese words by any character in the word, or any sequence of +characters (starting anywhere the user wants). Characters are often +searched by their pinyin values (a romanization of the sounds). The +dictionary has an average word length of 2 (but it sucks), but there are +also many words of length 4 and 6 characters. So it wouldn't be uncommon to +search for something like "a1 la1 bo yu" (arabic). There are also some very +long words with 12 or more characters (where my problem becomes more +pronounced). + +That being said, the most important table here is the words table: + Table "public.words" + Column | Type | Modifiers +--------------+----------------------+----------- +wid | integer | not null +sequence | smallint | not null +variant | smallint | not null +char_count | smallint | not null +unicode | character varying(5) | not null +pinyin | character varying(8) | not null +simpvar | character varying(5) | +zvar | character varying(5) | +compatvar | character varying(5) | +def_exists | boolean | not null +num_variants | smallint | +page_order | integer | +pinyins | character varying | +unicodes | character varying | +Indexes: + "words2_pkey" primary key, btree (wid, variant, "sequence") + "page_index" btree (page_order) + "pinyin_index" btree (pinyin) + "unicode_index" btree (unicode) + + +The best example of the problem I have when using this table is this query: + +SELECT + w8.wid, + w8.variant, + w8.num_variants, + sum_text(w8.unicode) as unicodes, + sum_text(w8.pinyin) as pinyins +FROM + words as w0, words as w1, + words as w2, words as w3, + words as w4, words as w5, + words as w6, words as w7, + words as w8 +WHERE + w0.wid > 0 AND + w0.pinyin = 'zheng4' AND + w0.def_exists = 't' AND + w0.sequence = 0 AND + w1.wid = w0.wid AND + w1.pinyin LIKE 'fu_' AND + w1.variant = w0.variant AND + w1.sequence = (w0.sequence + 1) AND + w2.wid = w1.wid AND + w2.pinyin LIKE 'ji_' AND + w2.variant = w1.variant AND + w2.sequence = (w1.sequence + 1) AND + w3.wid = w2.wid AND + w3.pinyin LIKE 'guan_' AND + w3.variant = w2.variant AND + w3.sequence = (w2.sequence + 1) AND + w4.wid = w3.wid AND + w4.pinyin LIKE 'kai_' AND + w4.variant = w3.variant AND + w4.sequence = (w3.sequence + 1) AND + w5.wid = w4.wid AND + w5.pinyin LIKE 'fang_' AND + w5.variant = w4.variant AND + w5.sequence = (w4.sequence + 1) AND + w6.wid = w5.wid AND + w6.pinyin LIKE 'xi_' AND + w6.variant = w5.variant AND + w6.sequence = (w5.sequence + 1) AND + w7.wid = w6.wid AND + w7.pinyin LIKE 'tong_' AND + w7.variant = w6.variant AND + w7.sequence = (w6.sequence + 1) AND + w8.wid = w7.wid AND + w8.variant = w7.variant +GROUP BY + w8.wid, + w8.variant, + w8.num_variants, + w8.page_order , + w0.sequence , + w1.sequence , + w2.sequence , + w3.sequence , + w4.sequence , + w5.sequence , + w6.sequence , + w7.sequence +ORDER BY + w8.page_order; + +(phew!) + +with the default geqo_threshold of 11, this query takes 3155ms on my machine +(a 1ghz athlon with 384 megs of pc133 ram). This is very very long. + +if i first do prepare blah as SELECT ....., then run execute blah, the time +goes down to about 275ms (i had been running this query a lot, and did a +vacuum update before all this). + +the ouput from EXPLAIN ANALYZE : + + + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +Sort (cost=54.13..54.14 rows=1 width=43) (actual time=315.357..315.357 +rows=1 loops=1) + Sort Key: w8.page_order + -> HashAggregate (cost=54.12..54.12 rows=1 width=43) (actual +time=315.328..315.330 rows=1 loops=1) + -> Nested Loop (cost=0.00..54.08 rows=1 width=43) (actual +time=6.229..314.566 rows=12 loops=1) + Join Filter: (("outer".wid = "inner".wid) AND +("outer".variant = "inner".variant) AND ("outer"."sequence" = +("inner"."sequence" + 1)) AND ("inner"."sequence" = ("outer"."sequence" + +1))) + -> Nested Loop (cost=0.00..48.07 rows=1 width=83) (actual +time=6.088..279.745 rows=12 loops=1) + Join Filter: (("inner"."sequence" = ("outer"."sequence" ++ 1)) AND ("outer"."sequence" = ("inner"."sequence" + 1))) + -> Nested Loop (cost=0.00..42.05 rows=1 width=75) +(actual time=5.980..278.602 rows=12 loops=1) + -> Nested Loop (cost=0.00..36.04 rows=1 +width=48) (actual time=5.910..278.280 rows=1 loops=1) + Join Filter: (("inner".variant = +"outer".variant) AND ("inner".wid = "outer".wid)) + -> Nested Loop (cost=0.00..30.04 rows=1 +width=40) (actual time=3.465..275.137 rows=1 loops=1) + Join Filter: ("inner"."sequence" = +("outer"."sequence" + 1)) + -> Nested Loop (cost=0.00..24.03 +rows=1 width=32) (actual time=3.408..275.045 rows=1 loops=1) + Join Filter: +("outer"."sequence" = ("inner"."sequence" + 1)) + -> Nested Loop +(cost=0.00..18.00 rows=1 width=24) (actual time=3.350..274.948 rows=1 +loops=1) + -> Nested Loop +(cost=0.00..11.99 rows=1 width=16) (actual time=3.295..274.678 rows=6 +loops=1) + Join Filter: +(("inner".wid = "outer".wid) AND ("inner".variant = "outer".variant) AND +("inner"."sequence" = ("outer"."sequence" + 1))) + -> Index Scan +using pinyin_index on words w4 (cost=0.00..5.98 rows=1 width=8) (actual +time=0.090..1.222 rows=165 loops=1) + Index Cond: +(((pinyin)::text >= 'kai'::character varying) AND ((pinyin)::text < +'kaj'::character varying)) + Filter: +((pinyin)::text ~~ 'kai_'::text) + -> Index Scan +using pinyin_index on words w5 (cost=0.00..5.98 rows=1 width=8) (actual +time=0.017..1.380 rows=259 loops=165) + Index Cond: +(((pinyin)::text >= 'fang'::character varying) AND ((pinyin)::text < +'fanh'::character varying)) + Filter: +((pinyin)::text ~~ 'fang_'::text) + -> Index Scan using +words2_pkey on words w1 (cost=0.00..6.00 rows=1 width=8) (actual +time=0.032..0.037 rows=0 loops=6) + Index Cond: +(("outer".wid = w1.wid) AND ("outer".variant = w1.variant)) + Filter: +((pinyin)::text ~~ 'fu_'::text) + -> Index Scan using +words2_pkey on words w0 (cost=0.00..6.01 rows=1 width=8) (actual +time=0.033..0.068 rows=1 loops=1) + Index Cond: (("outer".wid += w0.wid) AND (w0.wid > 0) AND ("outer".variant = w0.variant)) + Filter: (((pinyin)::text += 'zheng4'::text) AND (def_exists = true) AND ("sequence" = 0)) + -> Index Scan using words2_pkey on +words w2 (cost=0.00..6.00 rows=1 width=8) (actual time=0.029..0.060 rows=1 +loops=1) + Index Cond: ((w2.wid = +"outer".wid) AND (w2.variant = "outer".variant)) + Filter: ((pinyin)::text ~~ +'ji_'::text) + -> Index Scan using pinyin_index on words +w7 (cost=0.00..5.98 rows=1 width=8) (actual time=0.030..2.573 rows=338 +loops=1) + Index Cond: (((pinyin)::text >= +'tong'::character varying) AND ((pinyin)::text < 'tonh'::character varying)) + Filter: ((pinyin)::text ~~ +'tong_'::text) + -> Index Scan using words2_pkey on words w8 +(cost=0.00..5.99 rows=1 width=27) (actual time=0.029..0.130 rows=12 loops=1) + Index Cond: ((w8.wid = "outer".wid) AND +(w8.variant = "outer".variant)) + -> Index Scan using words2_pkey on words w6 +(cost=0.00..6.00 rows=1 width=8) (actual time=0.040..0.060 rows=1 loops=12) + Index Cond: ((w6.wid = "outer".wid) AND +(w6.variant = "outer".variant)) + Filter: ((pinyin)::text ~~ 'xi_'::text) + -> Index Scan using pinyin_index on words w3 +(cost=0.00..5.98 rows=1 width=8) (actual time=0.023..2.312 rows=304 +loops=12) + Index Cond: (((pinyin)::text >= 'guan'::character +varying) AND ((pinyin)::text < 'guao'::character varying)) + Filter: ((pinyin)::text ~~ 'guan_'::text) +Total runtime: 316.493 ms +(44 rows) + +Time: 3167.853 ms + + + +As you can see, the two run times there are quite different... The person I +spoke to in the irc channel said this all indicated a poor planning time, +and I think I agree. Yesterday I tried setting geqo_threshold to 7 instead +of the default of 11, and it seemed to help a little, but the running times +were still extremely high. + +I guess I do have a question in addition to just wanting to notify the right +people of this problem: Since a lot of my queries are similar to this one +(but not similar enough to allow me to use one or two of them over and over +with different parameters), is there any way for me to reorganize or rewrite +the queries so that the planner doesn't take so long? (I would hate to have +to take all of this out of the db's hands and iterate in code myself...) + +If you guys are optimistic about someone being able to fix this problem in +pgsql, I will just wait for the bug fix. + + +Thanks for listening :) let me know if you need any more information (oh +yea, this is on Linux, version 7.4.1) + +_________________________________________________________________ +Create a Job Alert on MSN Careers and enter for a chance to win $1000! +http://msn.careerbuilder.com/promo/kaday.htm?siteid=CBMSN_1K&sc_extcmp=JS_JASweep_MSNHotm2 + + +From pgsql-performance-owner@postgresql.org Thu Mar 11 22:37:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 155B3D1BA13 + for ; + Fri, 12 Mar 2004 02:37: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 51012-03 + for ; + Thu, 11 Mar 2004 22:37:40 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 547E3D1B906 + for ; + Thu, 11 Mar 2004 22:37:31 -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 + i2C2bVWL018535; Fri, 12 Mar 2004 10:37:31 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <40512394.2050506@familyhealth.com.au> +Date: Fri, 12 Mar 2004 10:42:28 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Eric Brown +Cc: pgsql-performance@postgresql.org +Subject: Re: severe performance issue with planner +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: 200403/155 +X-Sequence-Number: 6011 + +> if i first do prepare blah as SELECT ....., then run execute blah, the +> time goes down to about 275ms (i had been running this query a lot, and +> did a vacuum update before all this). + +If you make it an SQL stored procedure, you get the speed up of the +PREPARE command, without having to prepare manually all the time. + +Chris + + +From pgsql-performance-owner@postgresql.org Fri Mar 12 00:08:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id F2C33D1D3DC + for ; + Fri, 12 Mar 2004 04:07: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 73474-02 + for ; + Fri, 12 Mar 2004 00:07:21 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 291D8D1D342 + for ; + Fri, 12 Mar 2004 00:07:20 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2C47DVu004727; + Thu, 11 Mar 2004 23:07:13 -0500 (EST) +To: "Eric Brown" +Cc: pgsql-performance@postgresql.org +Subject: Re: severe performance issue with planner +In-reply-to: +References: +Comments: In-reply-to "Eric Brown" + message dated "Thu, 11 Mar 2004 20:47:23 -0500" +Date: Thu, 11 Mar 2004 23:07:13 -0500 +Message-ID: <4726.1079064433@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/156 +X-Sequence-Number: 6012 + +"Eric Brown" writes: +> [ planning a 9-table query takes too long ] + +See http://www.postgresql.org/docs/7.4/static/explicit-joins.html +for some useful tips. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 12 01:41:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BC2BD1C9CF + for ; + Fri, 12 Mar 2004 05:41: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 91219-04 + for ; + Fri, 12 Mar 2004 01:41:41 -0400 (AST) +Received: from alvarezp.ods.org (unknown [200.77.201.28]) + by svr1.postgresql.org (Postfix) with ESMTP id 78977D1BA3B + for ; + Fri, 12 Mar 2004 01:41:36 -0400 (AST) +Received: (from apache@localhost) + by alvarezp.ods.org (8.11.6/8.11.6) id i2C5fQV22042; + Thu, 11 Mar 2004 21:41:26 -0800 +X-Authentication-Warning: alvarezp.ods.org: apache set sender to + alvarezp@alvarezp.ods.org using -f +Received: from 192.168.0.64 (SquirrelMail authenticated user alvarezp) + by alvarezp.ods.org with HTTP; Thu, 11 Mar 2004 21:41:26 -0800 (PST) +Message-ID: <2400.192.168.0.64.1079070086.squirrel@alvarezp.ods.org> +Date: Thu, 11 Mar 2004 21:41:26 -0800 (PST) +Subject: Sorting when LEFT JOINING to 2 same tables, even aliased. +From: "Octavio Alvarez" +To: pgsql-performance@postgresql.org +Reply-To: alvarezp@alvarezp.ods.org +User-Agent: SquirrelMail/1.4.0-1.7.x +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/157 +X-Sequence-Number: 6013 + + +Hello to everybody. + +I ask your help for a severe problem when doing a query that LEFT JOINs +one table to another ON a field, and then LEFT JOINs again to another +"instance" of a table ON another field which stores the same entity, but +with different meaning. + +I include 3 EXPLAIN ANALYZEs: +* The first one, the target (and problematic) query, which runs in 5 to 6 +minutes. +* The second one, a variation with the second LEFT JOIN commented out, +which runs in 175 to 450 ms. +* The third one, a variation of the first one with ORDER BY removed, which +gives me about 19 seconds. + +Therefore, I feel like there are two problems here the one that raises the +clock to 6 minutes and one that raises it to 20 seconds. I expected a much +lower time. I checked indexes and data types already, they are all fine. +All relevant fields have BTREEs, all PKs have UNIQUE BTREE, and all id and +ext_* fields have 'integer' as data type. Each ext_* has its corresponding +REFERENCES contraint. + +I translated all the table and field names to make it easier to read. I +made my best not to let any typo go through. + +I'd appreciate any help. + +Octavio. + +=== First EXPLAIN ANALYZE === + +EXPLAIN ANALYZE +SELECT + t_materias_en_tira.id AS Id, + t_clientes.paterno || ' ' || t_clientes.materno || ' ' || +t_clientes.nombre AS Alumno, + t_materias.nombre AS Materia, + t_materias__equivalentes.nombre AS MateriaEquivalente, + t_grupos.nombre AS Grupo, + calificacion_final AS Calificacion, + tipo AS Tipo, + eer AS EER, + total_asistencias AS TotalAsistencias, + total_clases As TotalClases +FROM + t_materias_en_tira + LEFT JOIN t_alumnos_en_semestre ON ext_alumno_en_semestre = +t_alumnos_en_semestre.id + LEFT JOIN t_alumnos ON ext_alumno = t_alumnos.id + LEFT JOIN t_clientes ON ext_cliente = t_clientes.id + LEFT JOIN t_materias ON ext_materia = t_materias.id + LEFT JOIN t_materias AS t_materias__equivalentes ON +ext_materia__equivalencia = t_materias.id + LEFT JOIN t_grupos ON ext_grupo = t_grupos.id +WHERE + t_alumnos_en_semestre.ext_ciclo = 2222 +ORDER BY + Alumno, Materia; + +This one gave: + QUERY +PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=11549.08..11552.11 rows=1210 width=112) (actual +time=311246.000..355615.000 rows=1309321 loops=1) + Sort Key: (((((t_clientes.paterno)::text || ' '::text) || +(t_clientes.materno)::text) || ' '::text) || +(t_clientes.nombre)::text), t_materias.nombre + InitPlan + -> Result (cost=0.00..0.01 rows=1 width=0) (actual +time=2.000..2.000 rows=1 loops=1) + -> Hash Left Join (cost=1089.25..11487.11 rows=1210 width=112) +(actual time=83.000..19303.000 rows=1309321 loops=1) + Hash Cond: ("outer".ext_grupo = "inner".id) + -> Nested Loop Left Join (cost=1086.92..11454.53 rows=1210 +width=107) (actual time=82.000..9077.000 rows=1309321 loops=1) + Join Filter: ("outer".ext_materia__equivalencia = +"outer".id) -> Hash Left Join (cost=1078.15..1181.93 +rows=1210 +width=93) (actual time=82.000..275.000 rows=3473 loops=1) + Hash Cond: ("outer".ext_materia = "inner".id) -> +Merge Right Join (cost=1068.43..1154.07 +rows=1210 width=71) (actual time=81.000..213.000 +rows=3473 loops=1) + Merge Cond: ("outer".id = "inner".ext_cliente) +-> Index Scan using t_clientes_pkey on +t_clientes (cost=0.00..62.87 rows=1847 +width=38) (actual time=10.000..34.000 rows=1847 +loops=1) + -> Sort (cost=1068.43..1071.46 rows=1210 +width=41) (actual time=71.000..76.000 rows=3473 +loops=1) + Sort Key: t_alumnos.ext_cliente + -> Hash Left Join (cost=41.12..1006.48 +rows=1210 width=41) (actual +time=9.000..61.000 rows=3473 loops=1) + Hash Cond: ("outer".ext_alumno = +"inner".id) + -> Nested Loop (cost=0.00..944.18 +rows=1210 width=41) (actual +time=3.000..36.000 rows=3473 +loops=1) + -> Index Scan using +i_t_alumnos_en_semestre__ext_ciclo +on t_alumnos_en_semestre +(cost=0.00..8.63 rows=269 +width=8) (actual +time=2.000..3.000 rows=457 +loops=1) + Index Cond: (ext_ciclo += $0) + -> Index Scan using +i_t_materias_en_tira__ext_alumno_en_semestre +on t_materias_en_tira +(cost=0.00..3.32 rows=12 +width=41) (actual +time=0.009..0.035 rows=8 +loops=457) + Index Cond: +(t_materias_en_tira.ext_alumno_en_semestre += "outer".id) + -> Hash (cost=36.50..36.50 +rows=1850 width=8) (actual +time=6.000..6.000 rows=0loops=1) + -> Seq Scan on t_alumnos +(cost=0.00..36.50 rows=1850 +width=8) (actual +time=1.000..3.000 rows=1850 +loops=1) + -> Hash (cost=8.77..8.77 rows=377 width=26) (actual +time=1.000..1.000 rows=0 loops=1) + -> Seq Scan on t_materias (cost=0.00..8.77 +rows=377 width=26) (actual time=0.000..1.000 +rows=377 loops=1) + -> Materialize (cost=8.77..12.54 rows=377 width=22) +(actual time=0.000..0.175 rows=377 loops=3473) + -> Seq Scan on t_materias t_materias__equivalentes +(cost=0.00..8.77 rows=377 width=22) (actual +time=0.000..1.000 rows=377 loops=1) + -> Hash (cost=2.07..2.07 rows=107 width=13) (actual +time=1.000..1.000 rows=0 loops=1) + -> Seq Scan on t_grupos (cost=0.00..2.07 rows=107 +width=13) (actual time=0.000..1.000 rows=107 loops=1) + + Total runtime: 356144.000 ms + +=== Second EXPLAIN ANALYZE === + +EXPLAIN ANALYZE +SELECT + t_materias_en_tira.id AS Id, + t_clientes.paterno || ' ' || t_clientes.materno || ' ' || +t_clientes.nombre AS Alumno, + t_materias.nombre AS Materia, +-- t_materias__equivalentes.nombre AS MateriaEquivalente, + t_grupos.nombre AS Grupo, + calificacion_final AS Calificacion, + tipo AS Tipo, + eer AS EER, + total_asistencias AS TotalAsistencias, + total_clases As TotalClases +FROM + t_materias_en_tira + LEFT JOIN t_alumnos_en_semestre ON ext_alumno_en_semestre = +t_alumnos_en_semestre.id + LEFT JOIN t_alumnos ON ext_alumno = t_alumnos.id + LEFT JOIN t_clientes ON ext_cliente = t_clientes.id + LEFT JOIN t_materias ON ext_materia = t_materias.id +-- LEFT JOIN t_materias AS t_materias__equivalentes ON +ext_materia__equivalencia = t_materias.id + LEFT JOIN t_grupos ON ext_grupo = t_grupos.id +WHERE + t_alumnos_en_semestre.ext_ciclo = 2222 +ORDER BY + Alumno, Materia; + +EXPLAIN ANALYZE +SELECT + t_materias_en_tira.id AS Id, + t_clientes.paterno || ' ' || t_clientes.materno || ' ' || +t_clientes.nombre AS Alumno, + t_materias.nombre AS Materia, + t_materias__equivalentes.nombre AS MateriaEquivalente, + t_grupos.nombre AS Grupo, + calificacion_final AS Calificacion, + tipo AS Tipo, + eer AS EER, + total_asistencias AS TotalAsistencias, + total_clases As TotalClases +FROM + t_materias_en_tira + LEFT JOIN t_alumnos_en_semestre ON ext_alumno_en_semestre = +t_alumnos_en_semestre.id + LEFT JOIN t_alumnos ON ext_alumno = t_alumnos.id + LEFT JOIN t_clientes ON ext_cliente = t_clientes.id + LEFT JOIN t_materias ON ext_materia = t_materias.id + LEFT JOIN t_materias AS t_materias__equivalentes ON +ext_materia__equivalencia = t_materias.id + LEFT JOIN t_grupos ON ext_grupo = t_grupos.id +WHERE + t_alumnos_en_semestre.ext_ciclo = 2222; + +It gave: + + QUERY +PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=1276.49..1279.51 rows=1210 width=90) (actual +time=341.000..341.000 rows=3473 loops=1) + Sort Key: (((((t_clientes.paterno)::text || ' '::text) || +(t_clientes.materno)::text) || ' '::text) || +(t_clientes.nombre)::text), t_materias.nombre + InitPlan + -> Result (cost=0.00..0.01 rows=1 width=0) (actual +time=146.000..146.000 rows=1 loops=1) + -> Hash Left Join (cost=1080.48..1214.52 rows=1210 width=90) (actual +time=209.000..284.000 rows=3473 loops=1) + Hash Cond: ("outer".ext_grupo = "inner".id) + -> Hash Left Join (cost=1078.15..1181.93 rows=1210 width=85) +(actual time=208.000..250.000 rows=3473 loops=1) + Hash Cond: ("outer".ext_materia = "inner".id) + -> Merge Right Join (cost=1068.43..1154.07 rows=1210 +width=67) (actual time=207.000..227.000 rows=3473loops=1) + Merge Cond: ("outer".id = "inner".ext_cliente) -> +Index Scan using t_clientes_pkey on t_clientes +(cost=0.00..62.87 rows=1847 width=38) (actual +time=0.000..5.000 rows=1847 loops=1) + -> Sort (cost=1068.43..1071.46 rows=1210 width=37) +(actual time=207.000..209.000 rows=3473 loops=1) + Sort Key: t_alumnos.ext_cliente + -> Hash Left Join (cost=41.12..1006.48 +rows=1210 width=37) (actual +time=152.000..196.000 rows=3473 loops=1) + Hash Cond: ("outer".ext_alumno = +"inner".id) -> Nested Loop +(cost=0.00..944.18 +rows=1210 width=37) (actual +time=146.000..177.000 rows=3473 loops=1) + -> Index Scan using +i_t_alumnos_en_semestre__ext_ciclo +on t_alumnos_en_semestre +(cost=0.00..8.63 rows=269 width=8) +(actual time=146.000..148.000 +rows=457 loops=1) + Index Cond: (ext_ciclo = $0) + -> Index Scan using +i_t_materias_en_tira__ext_alumno_en_semestre +on t_materias_en_tira +(cost=0.00..3.32 rows=12 width=37) +(actual time=0.009..0.022 rows=8 +loops=457) + Index Cond: +(t_materias_en_tira.ext_alumno_en_semestre += "outer".id) + -> Hash (cost=36.50..36.50 rows=1850 +width=8) (actual time=6.000..6.000 rows=0 +loops=1) + -> Seq Scan on t_alumnos +(cost=0.00..36.50 rows=1850 +width=8) (actual time=0.000..3.000 +rows=1850 loops=1) + -> Hash (cost=8.77..8.77 rows=377 width=26) (actual +time=1.000..1.000 rows=0 loops=1) + -> Seq Scan on t_materias (cost=0.00..8.77 rows=377 +width=26) (actual time=0.000..0.000 rows=377loops=1) + -> Hash (cost=2.07..2.07 rows=107 width=13) (actual +time=1.000..1.000 rows=0 loops=1) + -> Seq Scan on t_grupos (cost=0.00..2.07 rows=107 +width=13) (actual time=0.000..0.000 rows=107 loops=1) + + Total runtime: 346.000 ms + +=== Third EXPLAIN ANALYZE === + +EXPLAIN ANALYZE +SELECT + t_materias_en_tira.id AS Id, + t_clientes.paterno || ' ' || t_clientes.materno || ' ' || +t_clientes.nombre AS Alumno, + t_materias.nombre AS Materia, + t_materias__equivalentes.nombre AS MateriaEquivalente, + t_grupos.nombre AS Grupo, + calificacion_final AS Calificacion, + tipo AS Tipo, + eer AS EER, + total_asistencias AS TotalAsistencias, + total_clases As TotalClases +FROM + t_materias_en_tira + LEFT JOIN t_alumnos_en_semestre ON ext_alumno_en_semestre = +t_alumnos_en_semestre.id + LEFT JOIN t_alumnos ON ext_alumno = t_alumnos.id + LEFT JOIN t_clientes ON ext_cliente = t_clientes.id + LEFT JOIN t_materias ON ext_materia = t_materias.id + LEFT JOIN t_materias AS t_materias__equivalentes ON +ext_materia__equivalencia = t_materias.id + LEFT JOIN t_grupos ON ext_grupo = t_grupos.id +WHERE + t_alumnos_en_semestre.ext_ciclo = 2222; + +Result: + + QUERY +PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Left Join (cost=484.34..4470.54 rows=459 width=112) (actual +time=70.000..18241.000 rows=1309321 loops=1) + Hash Cond: ("outer".ext_grupo = "inner".id) + -> Nested Loop Left Join (cost=482.01..4456.73 rows=459 width=107) +(actual time=70.000..7912.000 rows=1309321 loops=1) + Join Filter: ("outer".ext_materia__equivalencia = "outer".id) -> +Hash Left Join (cost=473.24..554.49 rows=459 width=93) +(actual time=70.000..142.000 rows=3473 loops=1) + Hash Cond: ("outer".ext_materia = "inner".id) + -> Merge Right Join (cost=463.52..537.90 rows=459 +width=71) (actual time=67.000..109.000 rows=3473 loops=1) + Merge Cond: ("outer".id = "inner".ext_cliente) -> +Index Scan using t_clientes_pkey on t_clientes +(cost=0.00..62.87 rows=1847 width=38) (actual +time=0.000..14.000 rows=1847 loops=1) + -> Sort (cost=463.52..464.67 rows=459 width=41) +(actual time=67.000..69.000 rows=3473 loops=1) + Sort Key: t_alumnos.ext_cliente + -> Merge Right Join (cost=379.40..443.23 +rows=459 width=41) (actual time=34.000..57.000 +rows=3473 loops=1) + Merge Cond: ("outer".id = +"inner".ext_alumno) + -> Index Scan using t_alumnos_pkey on +t_alumnos (cost=0.00..52.35 rows=1850 +width=8) (actual time=0.000..4.000 +rows=1850 loops=1) + -> Sort (cost=379.40..380.55 rows=459 +width=41) (actual time=34.000..36.000 +rows=3473 loops=1) + Sort Key: +t_alumnos_en_semestre.ext_alumno + -> Nested Loop (cost=0.00..359.11 +rows=459 width=41) (actual +time=0.000..21.000 rows=3473 +loops=1) + -> Index Scan using +i_t_alumnos_en_semestre__ext_ciclo +on t_alumnos_en_semestre +(cost=0.00..4.36 rows=102 +width=8) (actual +time=0.000..1.000 rows=457 +loops=1) + Index Cond: (ext_ciclo += 2222) + -> Index Scan using +i_t_materias_en_tira__ext_alumno_en_semestre +on t_materias_en_tira +(cost=0.00..3.32 rows=12 +width=41) (actual +time=0.004..0.026 rows=8 +loops=457) + Index Cond: +(t_materias_en_tira.ext_alumno_en_semestre += "outer".id) + -> Hash (cost=8.77..8.77 rows=377 width=26) (actual +time=2.000..2.000 rows=0 loops=1) + -> Seq Scan on t_materias (cost=0.00..8.77 rows=377 +width=26) (actual time=0.000..2.000 rows=377 loops=1) + -> Materialize (cost=8.77..12.54 rows=377 width=22) (actual +time=0.000..0.163 rows=377 loops=3473) + -> Seq Scan on t_materias t_materias__equivalentes +(cost=0.00..8.77 rows=377 width=22) (actual +time=0.000..1.000 rows=377 loops=1) + -> Hash (cost=2.07..2.07 rows=107 width=13) (actual time=0.000..0.000 +rows=0 loops=1) + -> Seq Scan on t_grupos (cost=0.00..2.07 rows=107 width=13) +(actual time=0.000..0.000 rows=107 loops=1) + + Total runtime: 18787.000 ms + +SELECT count(*) FROM t_materias_en_tira; + count +------- + 41059 +(1 row) + +SELECT count(*) FROM t_materias; + count +------- + 377 +(1 row) + +SELECT version();; + version +--------------------------------------------------------------------------------------- + PostgreSQL 7.4.1 on i686-pc-cygwin, compiled by GCC gcc (GCC) 3.3.1 +(cygming special) +(1 row) + + +-- +Octavio Alvarez. +E-mail: alvarezp@alvarezp.ods.org. + +Agradezco que sus correos sean enviados siempre a esta direcci�n. + + + +-- +Octavio Alvarez. +E-mail: alvarezp@alvarezp.ods.org. + +Agradezco que sus correos sean enviados siempre a esta direcci�n. + +From pgsql-performance-owner@postgresql.org Fri Mar 12 02:09:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E41CD1BA46 + for ; + Fri, 12 Mar 2004 06: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 96799-04 + for ; + Fri, 12 Mar 2004 02:09:20 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 475EAD1B91C + for ; + Fri, 12 Mar 2004 02:09:19 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id A93B3356D9; Thu, 11 Mar 2004 22:09:16 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id A7742356C4; Thu, 11 Mar 2004 22:09:16 -0800 (PST) +Date: Thu, 11 Mar 2004 22:09:16 -0800 (PST) +From: Stephan Szabo +To: Octavio Alvarez +Cc: pgsql-performance@postgresql.org +Subject: Re: Sorting when LEFT JOINING to 2 same tables, even +In-Reply-To: <2400.192.168.0.64.1079070086.squirrel@alvarezp.ods.org> +Message-ID: <20040311215456.D77015@megazone.bigpanda.com> +References: <2400.192.168.0.64.1079070086.squirrel@alvarezp.ods.org> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/158 +X-Sequence-Number: 6014 + + +On Thu, 11 Mar 2004, Octavio Alvarez wrote: + +> +> Hello to everybody. +> +> I ask your help for a severe problem when doing a query that LEFT JOINs +> one table to another ON a field, and then LEFT JOINs again to another +> "instance" of a table ON another field which stores the same entity, but +> with different meaning. +> +> I include 3 EXPLAIN ANALYZEs: +> * The first one, the target (and problematic) query, which runs in 5 to 6 +> minutes. +> * The second one, a variation with the second LEFT JOIN commented out, +> which runs in 175 to 450 ms. +> * The third one, a variation of the first one with ORDER BY removed, which +> gives me about 19 seconds. +> +> Therefore, I feel like there are two problems here the one that raises the +> clock to 6 minutes and one that raises it to 20 seconds. I expected a much +> lower time. I checked indexes and data types already, they are all fine. +> All relevant fields have BTREEs, all PKs have UNIQUE BTREE, and all id and +> ext_* fields have 'integer' as data type. Each ext_* has its corresponding +> REFERENCES contraint. +> +> I translated all the table and field names to make it easier to read. I +> made my best not to let any typo go through. +> +> I'd appreciate any help. + +This join filter +> Join Filter: ("outer".ext_materia__equivalencia = +> "outer".id) + +which I believe belongs to + +> LEFT JOIN t_materias AS t_materias__equivalentes ON +> ext_materia__equivalencia = t_materias.id + +seems wrong. Did you maybe mean = t_materias__equivalentes.id +there? + + +From pgsql-performance-owner@postgresql.org Fri Mar 12 13:40:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 53C37D1B9A4 + for ; + Fri, 12 Mar 2004 17:39: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 87711-08 + for ; + Fri, 12 Mar 2004 13:39:40 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id BD35ED1B989 + for ; + Fri, 12 Mar 2004 13:39:37 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4609517; Fri, 12 Mar 2004 09:40:47 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "scott.marlowe" , + "Marcus Andree S. Magalhaes" +Subject: Re: optimizing large query with IN (...) +Date: Fri, 12 Mar 2004 09:39:18 -0800 +User-Agent: KMail/1.4.3 +Cc: +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200403120939.18797.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/159 +X-Sequence-Number: 6015 + +Marcus, + +> The problem, as I understand it, is that 7.4 introduced massive +> improvements in handling moderately large in() clauses, as long as they +> can fit in sort_mem, and are provided by a subselect. + +Also, this problem may be fixed in 7.5, when it comes out. It's a known +issue. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Fri Mar 12 14:00:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 51A26D1C4E0 + for ; + Fri, 12 Mar 2004 18:00: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 03277-03 + for ; + Fri, 12 Mar 2004 14:00:40 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 85585D1B979 + for ; + Fri, 12 Mar 2004 14:00:34 -0400 (AST) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id B4DA517C312; Fri, 12 Mar 2004 13:00:33 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1B1qxV-0003Xd-00; Fri, 12 Mar 2004 13:00:33 -0500 +To: "Eric Brown" +Cc: pgsql-performance@postgresql.org +Subject: Re: severe performance issue with planner +References: +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 12 Mar 2004 13:00:33 -0500 +Message-ID: <873c8e54ji.fsf@stark.xeocode.com> +Lines: 58 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/160 +X-Sequence-Number: 6016 + + +The other posts about using explicit joins and using stored procedures are +both good points. But I have a few other comments to make: + +"Eric Brown" writes: + +> WHERE +> w0.wid > 0 AND +> w0.pinyin = 'zheng4' AND +> w0.def_exists = 't' AND +> w0.sequence = 0 AND +> w1.wid = w0.wid AND +> w1.pinyin LIKE 'fu_' AND +> w1.variant = w0.variant AND +> w1.sequence = (w0.sequence + 1) AND + +I'm not sure it'll help the planner, but w0.sequence+1 is always just going to +be 1, and so on with the others. I think the planner might be able to figure +that out but the plan doesn't seem to show it doing so. I'm not sure it would +help the plan though. + +Similarly you have w1.wid=w0.wid and w2.wid=w1.wid and w3.wid=w2.wid etc. And +also with the "variant" column. You might be able to get this planned better +by writing it as a join from w0 to all the others rather than a chain of +w0->w1->w2->... Again I'm not sure; you would have to experiment. + + +But I wonder if there isn't a way to do this in a single pass using an +aggregate. I'm not sure I understand the schema exactly, but perhaps something +like this? + +select w8.wid, + w8.variant, + w8.num_variants, + sum_text(w8.unicode) as unicodes, + sum_text(w8.pinyin) as pinyins + from ( + select wid,variant, + from words + where (sequence = 0 and pinyin = 'zheng4') + OR (sequence = 1 and pinyin like 'ji_') + OR (sequence = 2 and pinyin like 'guan_') + OR (sequence = 3 and pinyin like 'kai_') + OR (sequence = 4 and pinyin like 'fang_') + OR (sequence = 5 and pinyin like 'xi_') + OR (sequence = 6 and pinyin like 'tong_') + OR (sequence = 7 and pinyin like 'fu_') + group by wid,variant + having count(*) = 8 + ) as w + join words as w8 using (wid,variant) + +This might be helped by having an index on but it might not +even need it. + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Fri Mar 12 14:15:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1BE5FD1B989 + for ; + Fri, 12 Mar 2004 18:14: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 98491-10 + for ; + Fri, 12 Mar 2004 14:14:48 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id A0019D1B903 + for ; + Fri, 12 Mar 2004 14:14:46 -0400 (AST) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 9713717C416; Fri, 12 Mar 2004 13:14:46 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1B1rBG-0003dg-00; Fri, 12 Mar 2004 13:14:46 -0500 +To: Greg Stark +Cc: "Eric Brown" , + pgsql-performance@postgresql.org +Subject: Re: severe performance issue with planner +References: + <873c8e54ji.fsf@stark.xeocode.com> +In-Reply-To: <873c8e54ji.fsf@stark.xeocode.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 12 Mar 2004 13:14:46 -0500 +Message-ID: <87wu5q3pbd.fsf@stark.xeocode.com> +Lines: 46 +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: 200403/161 +X-Sequence-Number: 6017 + + +Sorry, I forgot a key clause there: + +Greg Stark writes: + +> select w8.wid, +> w8.variant, +> w8.num_variants, +> sum_text(w8.unicode) as unicodes, +> sum_text(w8.pinyin) as pinyins +> from ( +> select wid,variant, +> from words +> where (sequence = 0 and pinyin = 'zheng4') +> OR (sequence = 1 and pinyin like 'ji_') +> OR (sequence = 2 and pinyin like 'guan_') +> OR (sequence = 3 and pinyin like 'kai_') +> OR (sequence = 4 and pinyin like 'fang_') +> OR (sequence = 5 and pinyin like 'xi_') +> OR (sequence = 6 and pinyin like 'tong_') +> OR (sequence = 7 and pinyin like 'fu_') +> group by wid,variant +> having count(*) = 8 +> ) as w +> join words as w8 using (wid,variant) + + where w8.sequence = 8 + +Or perhaps that ought to be + + join words as w8 on ( w8.wid=w.wid + and w8.variant=w.variant + and w8.sequence = 8) + +or even + + join (select * from words where sequence = 8) as w8 using (wid,variant) + + +I think they should all be equivalent though. + + + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Fri Mar 12 15:18:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C0BB9D1BA6E + for ; + Fri, 12 Mar 2004 19:18: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 24503-07 + for ; + Fri, 12 Mar 2004 15:18:28 -0400 (AST) +Received: from trade-india.com (unknown [61.16.154.82]) + by svr1.postgresql.org (Postfix) with SMTP id 69E51D1BA46 + for ; + Fri, 12 Mar 2004 15:18:23 -0400 (AST) +Received: (qmail 25209 invoked from network); 12 Mar 2004 19:12:59 -0000 +Received: from system66.trade-india-local.com (HELO office1.trade-india.com) + (192.168.0.66) + by system66.trade-india-local.com with SMTP; 12 Mar 2004 19:12:59 -0000 +Received: from 192.168.0.100 (SquirrelMail authenticated user mallah) + by system67.trade-india-local.com with HTTP; + Sat, 13 Mar 2004 00:42:59 +0530 (IST) +Message-ID: + <1419.192.168.0.100.1079118779.squirrel@system67.trade-india-local.com> +Date: Sat, 13 Mar 2004 00:42:59 +0530 (IST) +Subject: pg_xlog on same drive as OS +From: mallah@trade-india.com +To: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.2 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/162 +X-Sequence-Number: 6018 + +greetings! +on a dedicated pgsql server is putting pg_xlog +in drive as OS almost equivalent to putting on a seperate +drive? + + +in both case the actual data files are in a seperate +drive. + +regds +mallah + +From pgsql-performance-owner@postgresql.org Fri Mar 12 16:03:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 767B6D1BB52 + for ; + Fri, 12 Mar 2004 20:03: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 35487-06 + for ; + Fri, 12 Mar 2004 16:03:48 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 82214D1B80C + for ; + Fri, 12 Mar 2004 16:03:46 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4610493; Fri, 12 Mar 2004 12:04:59 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: mallah@trade-india.com, pgsql-performance@postgresql.org +Subject: Re: pg_xlog on same drive as OS +Date: Fri, 12 Mar 2004 12:03:02 -0800 +User-Agent: KMail/1.5.4 +References: + <1419.192.168.0.100.1079118779.squirrel@system67.trade-india-local.com> +In-Reply-To: + <1419.192.168.0.100.1079118779.squirrel@system67.trade-india-local.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403121203.02384.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/163 +X-Sequence-Number: 6019 + +Mallah, + +> on a dedicated pgsql server is putting pg_xlog +> in drive as OS almost equivalent to putting on a seperate +> drive? + +Yes. If I have limited drives, this is what I do. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Mar 12 17:52:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9259ED1CAF3 + for ; + Fri, 12 Mar 2004 21:52: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 78877-04 + for ; + Fri, 12 Mar 2004 17:52:48 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 8ED91D1C4EB + for ; + Fri, 12 Mar 2004 17:52: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 i2CLqj1Y027965 + for ; Fri, 12 Mar 2004 21:52:46 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i2CLoR5P027625 + for pgsql-performance@postgresql.org; Fri, 12 Mar 2004 21:50:27 GMT +From: Christopher Browne +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: pg_xlog on same drive as OS +Date: Fri, 12 Mar 2004 15:52:49 -0500 +Organization: cbbrowne Computing Inc +Lines: 17 +Message-ID: +References: + <1419.192.168.0.100.1079118779.squirrel@system67.trade-india-local.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Complaints-To: usenet@news.hub.org +X-message-flag: Outlook is rather hackable, isn't it? +X-Home-Page: http://www.cbbrowne.com/info/ +X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne +User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through + Obscurity, + linux) +Cancel-Lock: sha1:vM9SnvjORxnU1ghFC3kdlEHohGo= +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/164 +X-Sequence-Number: 6020 + +In the last exciting episode, mallah@trade-india.com wrote: +> greetings! +> on a dedicated pgsql server is putting pg_xlog +> in drive as OS almost equivalent to putting on a seperate +> drive? +> +> in both case the actual data files are in a seperate +> drive. + +Well, if the OS drive is relatively inactive, then it may be "separate +enough" that you won't find performance hurt too much by this. +-- +If this was helpful, rate me +http://cbbrowne.com/info/postgresql.html +MICROS~1 is not the answer. +MICROS~1 is the question. +NO (or Linux) is the answer. + +From pgsql-performance-owner@postgresql.org Fri Mar 12 19:02:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1C7D5D1D69B + for ; + Fri, 12 Mar 2004 23:02: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 98728-04 + for ; + Fri, 12 Mar 2004 19:02:06 -0400 (AST) +Received: from bramble.mmrd.com (unknown [65.217.53.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 197CED1C9DB + for ; + Fri, 12 Mar 2004 19:02:02 -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 i2CMZbcM026483; + Fri, 12 Mar 2004 17:35:39 -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 i2CN1vl04639; + Fri, 12 Mar 2004 18:01:57 -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 FVMAXMKM; Fri, 12 Mar 2004 18:01:54 -0500 +Subject: Re: Scaling further up +From: Robert Treat +To: William Yu +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098045@vt-pe2550-001.vantage.vantage.com> + +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +X-Mailer: Ximian Evolution 1.0.8 +Date: 12 Mar 2004 18:01:57 -0500 +Message-Id: <1079132517.27322.22.camel@camel> +Mime-Version: 1.0 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/165 +X-Sequence-Number: 6021 + +On Mon, 2004-03-08 at 11:40, William Yu wrote: +> Anjan Dave wrote: +> > Great response, Thanks. +> > +> > Regarding 12GB memory and 13G db, and almost no I/O, one thing I don't +> > understand is that even though the OS caches most of the memory and PG +> > can use it if it needs it, why would the system swap (not much, only +> > during peak times)? The SHMMAX is set to 512MB, shared_buffers is 150MB, +> > effective cache size is 2GB, sort mem is 2MB, rest is default values. It +> > also happens that a large query (reporting type) can hold up the other +> > queries, and the load averages shoot up during peak times. +> +> In regards to your system going to swap, the only item I see is sort_mem +> at 2MB. How many simultaneous transactions do you get? If you get +> hundreds or thousands like your first message stated, every select sort +> would take up 2MB of memory regardless of whether it needed it or not. +> That could cause your swap activity during peak traffic. +> +> The only other item to bump up is the effective cache size -- I'd set it +> to 12GB. +> + +Was surprised that no one corrected this bit of erroneous info (or at +least I didn't see it) so thought I would for completeness. a basic +explanation is that sort_mem controls how much memory a given query is +allowed to use before spilling to disk, but it will not grab that much +memory if it doesn't need it. + +See the docs for a more detailed explanation: +http://www.postgresql.org/docs/7.4/interactive/runtime-config.html#RUNTIME-CONFIG-RESOURCE + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +From pgsql-performance-owner@postgresql.org Fri Mar 12 19:25:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E711ED1D168 + for ; + Fri, 12 Mar 2004 23:25:49 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 02653-09 + for ; + Fri, 12 Mar 2004 19:25:50 -0400 (AST) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 1480BD1CCD2 + for ; + Fri, 12 Mar 2004 19:25:47 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +Content-Class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Scaling further up +Date: Fri, 12 Mar 2004 18:25:48 -0500 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098062@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Scaling further up +Thread-Index: AcQIhkCGleWIBVNKSNSTLmMWT+B2fwAAXOHg +From: "Anjan Dave" +To: "Robert Treat" , + "William Yu" +Cc: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/166 +X-Sequence-Number: 6022 + +We upgraded from 8GB to 12GB RAM a month or so ago, but even in the +past, I've never seen the system exhaust on it's system cache (~6GB, in +'top'), while it's swapping. + +Some one had mentioned why not have the entire DB in memory? How do I +configure that, for knowledge? + +Max connections is set to 500, and we haven't bumped it yet. (I've seen +over 200 active queries, but the traffic is seasonal, so the high +connection value) + +Thanks, +Anjan + +-----Original Message----- +From: Robert Treat [mailto:xzilla@users.sourceforge.net]=20 +Sent: Friday, March 12, 2004 6:02 PM +To: William Yu +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Scaling further up + + +On Mon, 2004-03-08 at 11:40, William Yu wrote: +> Anjan Dave wrote: +> > Great response, Thanks. +> >=20 +> > Regarding 12GB memory and 13G db, and almost no I/O, one thing I=20 +> > don't understand is that even though the OS caches most of the=20 +> > memory and PG can use it if it needs it, why would the system swap=20 +> > (not much, only during peak times)? The SHMMAX is set to 512MB,=20 +> > shared_buffers is 150MB, effective cache size is 2GB, sort mem is=20 +> > 2MB, rest is default values. It also happens that a large query=20 +> > (reporting type) can hold up the other queries, and the load=20 +> > averages shoot up during peak times. +>=20 +> In regards to your system going to swap, the only item I see is=20 +> sort_mem +> at 2MB. How many simultaneous transactions do you get? If you get=20 +> hundreds or thousands like your first message stated, every select +sort=20 +> would take up 2MB of memory regardless of whether it needed it or not. + +> That could cause your swap activity during peak traffic. +>=20 +> The only other item to bump up is the effective cache size -- I'd set=20 +> it +> to 12GB. +>=20 + +Was surprised that no one corrected this bit of erroneous info (or at +least I didn't see it) so thought I would for completeness. a basic +explanation is that sort_mem controls how much memory a given query is +allowed to use before spilling to disk, but it will not grab that much +memory if it doesn't need it.=20 + +See the docs for a more detailed explanation: +http://www.postgresql.org/docs/7.4/interactive/runtime-config.html#RUNTI +ME-CONFIG-RESOURCE + +Robert Treat +--=20 +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + + +---------------------------(end of broadcast)--------------------------- +TIP 7: don't forget to increase your free space map settings + +From pgsql-performance-owner@postgresql.org Fri Mar 12 21:42:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3DBA2D1D2E2 + for ; + Sat, 13 Mar 2004 01:42: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 29233-08 + for ; + Fri, 12 Mar 2004 21:42:25 -0400 (AST) +Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 3731AD1D2DC + for ; + Fri, 12 Mar 2004 21:42:21 -0400 (AST) +Received: from [206.19.64.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1077315 for pgsql-performance@postgresql.org; + Fri, 12 Mar 2004 17:37:55 -0800 +Message-ID: <4052661D.5060505@joeconway.com> +Date: Fri, 12 Mar 2004 17:38:37 -0800 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance +Subject: rapid degradation after postmaster restart +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: 200403/167 +X-Sequence-Number: 6023 + +I'm trying to troubleshoot a performance issue on an application ported +from Oracle to postgres. Now, I know the best way to get help is to post +the schema, explain analyze output, etc, etc -- unfortunately I can't do +that at the moment. However, maybe someone can point me in the right +direction to figure this out on my own. That said, here are a few details... + +PostgreSQL 7.4.1 +bash-2.03$ uname -a +SunOS col65 5.8 Generic_108528-27 sun4u sparc SUNW,Sun-Fire-280R + +The problem is this: the application runs an insert, that fires off a +trigger, that cascades into a fairly complex series of functions, that +do a bunch of calculations, inserts, updates, and deletes. Immediately +after a postmaster restart, the first insert or two take about 1.5 +minutes (undoubtedly this could be improved, but it isn't the main +issue). However by the second or third insert, the time increases to 7 - +9 minutes. Restarting the postmaster causes the cycle to repeat, i.e. +the first one or two inserts are back to the 1.5 minute range. + +Any ideas spring to mind? I don't have much experience with Postgres on +Solaris -- could it be related to that somehow? + +Thanks for any insights. + +Joe + +From pgsql-performance-owner@postgresql.org Fri Mar 12 22:51:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 71A21D1DC15 + for ; + Sat, 13 Mar 2004 02:51: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 46834-08 + for ; + Fri, 12 Mar 2004 22:51:05 -0400 (AST) +Received: from outputservices.com (outputt1130.customer.frii.net + [216.17.159.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 9DB0BD1D342 + for ; + Fri, 12 Mar 2004 22:51:00 -0400 (AST) +Received: from outputservices.com (outputservices.com [137.106.76.15]) + by outputservices.com (8.11.3/8.11.3) with ESMTP id i2D2p6i15908; + Fri, 12 Mar 2004 19:51:07 -0700 (MST) +Message-ID: <4052771A.1080506@outputservices.com> +Date: Fri, 12 Mar 2004 19:51:06 -0700 +From: Marty Scholes +User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; + rv:1.0.1) Gecko/20020920 Netscape/7.0 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Joe Conway +Cc: pgsql-performance +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/168 +X-Sequence-Number: 6024 + +Six days ago I installed Pg 7.4.1 on Sparc Solaris 8 also. I am hopeful +that we as well can migrate a bunch of our apps from Oracle. + +After doing some informal benchmarks and performance testing for the +past week I am becoming more and more impressed with what I see. + +I have seen similar results to what you are describing. + +I found that running a full vacuum: + +vacuumdb -fza + +followed by a checkpoint makes it run fast again. + +Try timing the update with and without a full vacuum. + +I can't help but wonder if a clean shutdown includes some vacuuming. + +Obviously, in a production database this would be an issue. + +Please post back what you learn. + +Sincerely, +Marty + +I have been doing a bunch of informat + +Joe Conway wrote: +> I'm trying to troubleshoot a performance issue on an application ported +> from Oracle to postgres. Now, I know the best way to get help is to post +> the schema, explain analyze output, etc, etc -- unfortunately I can't do +> that at the moment. However, maybe someone can point me in the right +> direction to figure this out on my own. That said, here are a few +> details... +> +> PostgreSQL 7.4.1 +> bash-2.03$ uname -a +> SunOS col65 5.8 Generic_108528-27 sun4u sparc SUNW,Sun-Fire-280R +> +> The problem is this: the application runs an insert, that fires off a +> trigger, that cascades into a fairly complex series of functions, that +> do a bunch of calculations, inserts, updates, and deletes. Immediately +> after a postmaster restart, the first insert or two take about 1.5 +> minutes (undoubtedly this could be improved, but it isn't the main +> issue). However by the second or third insert, the time increases to 7 - +> 9 minutes. Restarting the postmaster causes the cycle to repeat, i.e. +> the first one or two inserts are back to the 1.5 minute range. +> +> Any ideas spring to mind? I don't have much experience with Postgres on +> Solaris -- could it be related to that somehow? +> +> Thanks for any insights. +> +> Joe +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: Have you searched our list archives? +> +> http://archives.postgresql.org + + + +From pgsql-performance-owner@postgresql.org Sat Mar 13 00:03:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2028FD1B989 + for ; + Sat, 13 Mar 2004 04:02: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 66449-01 + for ; + Sat, 13 Mar 2004 00:02:40 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id CFA6CD1CAF3 + for ; + Sat, 13 Mar 2004 00:02:38 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2D42aEN014885; + Fri, 12 Mar 2004 23:02:36 -0500 (EST) +To: Joe Conway +Cc: pgsql-performance +Subject: Re: rapid degradation after postmaster restart +In-reply-to: <4052661D.5060505@joeconway.com> +References: <4052661D.5060505@joeconway.com> +Comments: In-reply-to Joe Conway + message dated "Fri, 12 Mar 2004 17:38:37 -0800" +Date: Fri, 12 Mar 2004 23:02:35 -0500 +Message-ID: <14884.1079150555@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/169 +X-Sequence-Number: 6025 + +Joe Conway writes: +> The problem is this: the application runs an insert, that fires off a +> trigger, that cascades into a fairly complex series of functions, that +> do a bunch of calculations, inserts, updates, and deletes. Immediately +> after a postmaster restart, the first insert or two take about 1.5 +> minutes (undoubtedly this could be improved, but it isn't the main +> issue). However by the second or third insert, the time increases to 7 - +> 9 minutes. Restarting the postmaster causes the cycle to repeat, i.e. +> the first one or two inserts are back to the 1.5 minute range. + +I realize this question might take some patience to answer, but what +does the performance curve look like beyond three trials? Does it level +off or continue to get worse? If it doesn't level off, does the +degradation seem linear in the number of trials, or worse than linear? + +I have no ideas in mind, just trying to gather data ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Mar 13 11:39:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F6CAD1D168 + for ; + Sat, 13 Mar 2004 15:39: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 85017-09 + for ; + Sat, 13 Mar 2004 11:39:41 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 53FAFD1CCAD + for ; + Sat, 13 Mar 2004 11:39:37 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2DFddgZ018482; + Sat, 13 Mar 2004 10:39:39 -0500 (EST) +To: Joe Conway +Cc: pgsql-performance +Subject: Re: rapid degradation after postmaster restart +In-reply-to: <4052661D.5060505@joeconway.com> +References: <4052661D.5060505@joeconway.com> +Comments: In-reply-to Joe Conway + message dated "Fri, 12 Mar 2004 17:38:37 -0800" +Date: Sat, 13 Mar 2004 10:39:39 -0500 +Message-ID: <18481.1079192379@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/170 +X-Sequence-Number: 6026 + +Joe Conway writes: +> ... Immediately +> after a postmaster restart, the first insert or two take about 1.5 +> minutes (undoubtedly this could be improved, but it isn't the main +> issue). However by the second or third insert, the time increases to 7 - +> 9 minutes. Restarting the postmaster causes the cycle to repeat, i.e. +> the first one or two inserts are back to the 1.5 minute range. + +Just to be clear on this: you have to restart the postmaster to bring +the time back down? Simply starting a fresh backend session doesn't do +it? + +Are you using particularly large values for shared_buffers or any of the +other resource parameters? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Mar 13 11:55:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6B59ED1E104 + for ; + Sat, 13 Mar 2004 15:55: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 92405-08 + for ; + Sat, 13 Mar 2004 11:55:42 -0400 (AST) +Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) + by svr1.postgresql.org (Postfix) with ESMTP id A4133D1E149 + for ; + Sat, 13 Mar 2004 11:55:37 -0400 (AST) +Received: from [192.168.5.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1078102; Sat, 13 Mar 2004 07:51:12 -0800 +Message-ID: <40532E14.3010805@joeconway.com> +Date: Sat, 13 Mar 2004 07:51:48 -0800 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> +In-Reply-To: <14884.1079150555@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: 200403/171 +X-Sequence-Number: 6027 + +Tom Lane wrote: +> I realize this question might take some patience to answer, but what +> does the performance curve look like beyond three trials? Does it level +> off or continue to get worse? If it doesn't level off, does the +> degradation seem linear in the number of trials, or worse than linear? + +I try to gather some data during the weekend and report back. + +Thanks, + +Joe + +From pgsql-performance-owner@postgresql.org Sat Mar 13 12:07:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 25CE7D1B534 + for ; + Sat, 13 Mar 2004 16:07: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 98368-05 + for ; + Sat, 13 Mar 2004 12:07:22 -0400 (AST) +Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 4A883D1CCAD + for ; + Sat, 13 Mar 2004 12:07:21 -0400 (AST) +Received: from [192.168.5.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1078159; Sat, 13 Mar 2004 08:02:49 -0800 +Message-ID: <405330CD.4050304@joeconway.com> +Date: Sat, 13 Mar 2004 08:03:25 -0800 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> <18481.1079192379@sss.pgh.pa.us> +In-Reply-To: <18481.1079192379@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: 200403/172 +X-Sequence-Number: 6028 + +Tom Lane wrote: +> Just to be clear on this: you have to restart the postmaster to bring +> the time back down? Simply starting a fresh backend session doesn't do +> it? + +Yes, a full postmaster restart is needed. It is a command line script +that does the insert, so each one is a new backend. + +> Are you using particularly large values for shared_buffers or any of the +> other resource parameters? + +I'll have to look at this again (I have to vpn in to the company lan +which kills all my current connections) -- the server and application +belong to another department at my employer. + +IIRC, shared buffers was reasonable, maybe 128MB. One thing that is +worthy of note is that they are using pg_autovacuum and a very low +vacuum_mem setting (1024). But I also believe that max_fsm_relations and +max_fsm_pages have been bumped up from default (something like 10000 & +200000). + +I'll post the non-default postgresql.conf settings shortly. The extended +tests discussed in the nearby post will take a bit more time to get. + +Thanks, + +Joe + + +From pgsql-performance-owner@postgresql.org Sat Mar 13 12:11:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 374FFD1CCA5 + for ; + Sat, 13 Mar 2004 16: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 02148-03 + for ; + Sat, 13 Mar 2004 12:11:07 -0400 (AST) +Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 47312D1B55C + for ; + Sat, 13 Mar 2004 12:11:07 -0400 (AST) +Received: from [192.168.5.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1078182; Sat, 13 Mar 2004 08:06:36 -0800 +Message-ID: <405331B0.6080102@joeconway.com> +Date: Sat, 13 Mar 2004 08:07:12 -0800 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Marty Scholes +Cc: pgsql-performance +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> + <4052771A.1080506@outputservices.com> +In-Reply-To: <4052771A.1080506@outputservices.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: 200403/173 +X-Sequence-Number: 6029 + +Marty Scholes wrote: +> I have seen similar results to what you are describing. +> +> I found that running a full vacuum: +> +> vacuumdb -fza +> +> followed by a checkpoint makes it run fast again. +> +> Try timing the update with and without a full vacuum. + +Will do. I'll let you know how it goes. + +Thanks for the reply. + +Joe + + +From pgsql-performance-owner@postgresql.org Sat Mar 13 12:52:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6562FD1C9BB + for ; + Sat, 13 Mar 2004 16:52: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 10711-03 + for ; + Sat, 13 Mar 2004 12:52:12 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 0E2EAD1C9B5 + for ; + Sat, 13 Mar 2004 12:52:12 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4616793; Sat, 13 Mar 2004 08:53:24 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Joe Conway , Tom Lane +Subject: Re: rapid degradation after postmaster restart +Date: Sat, 13 Mar 2004 08:51:22 -0800 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance +References: <4052661D.5060505@joeconway.com> <18481.1079192379@sss.pgh.pa.us> + <405330CD.4050304@joeconway.com> +In-Reply-To: <405330CD.4050304@joeconway.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403130851.22684.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/174 +X-Sequence-Number: 6030 + +Joe, + +> IIRC, shared buffers was reasonable, maybe 128MB. One thing that is +> worthy of note is that they are using pg_autovacuum and a very low +> vacuum_mem setting (1024). But I also believe that max_fsm_relations and +> max_fsm_pages have been bumped up from default (something like 10000 & +> 200000). + +pg_autovacuum may be your problem. Imagine this: + +1) The chain of updates and inserts called by the procedures makes enough +changes, on its own, to trigger pg_autovacuum. +2) Because they have a big database, and a low vacuum_mem, a vacuum of the +largest table takes noticable time, like several minutes. +3) This means that the vacuum is still running during the second and +succeeding events .... + +Something to check by watching the process list. + +FWIW, I don't use pg_autovacuum for databases which have frequent large batch +updates; I find it results in uneven performance. + +Feel free to phone me if you're still stuck! + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Sat Mar 13 13:31:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 239C9D1B903 + for ; + Sat, 13 Mar 2004 17: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 10711-10 + for ; + Sat, 13 Mar 2004 13:31:19 -0400 (AST) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A71DD1C4EC + for ; + Sat, 13 Mar 2004 13:31:19 -0400 (AST) +Received: from ool-4352919e.dyn.optonline.net ([67.82.145.158] helo=zeut.net) + by outbound.mailhop.org with asmtp (TLSv1:AES256-SHA:256) (Exim 4.20) + id 1B2Cyh-000NTT-Eu; Sat, 13 Mar 2004 12:31:15 -0500 +Message-ID: <405345F7.7080803@zeut.net> +Date: Sat, 13 Mar 2004 12:33:43 -0500 +From: "Matthew T. O'Connor" +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Joe Conway +Cc: Tom Lane , + pgsql-performance +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> <18481.1079192379@sss.pgh.pa.us> + <405330CD.4050304@joeconway.com> +In-Reply-To: <405330CD.4050304@joeconway.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Report-Abuse-To: abuse@dyndns.org +X-MHO-User: Zeut +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/175 +X-Sequence-Number: 6031 + +Joe Conway wrote: + +> Tom Lane wrote: +> +>> Just to be clear on this: you have to restart the postmaster to bring +>> the time back down? Simply starting a fresh backend session doesn't do +>> it? +> +> +> IIRC, shared buffers was reasonable, maybe 128MB. One thing that is +> worthy of note is that they are using pg_autovacuum and a very low +> vacuum_mem setting (1024). But I also believe that max_fsm_relations +> and max_fsm_pages have been bumped up from default (something like +> 10000 & 200000). +> + +pg_autovacuum could be a problem if it's vacuuming too often. Have you +looked to see if a vacuum or analyze is running while the server is +slow? If so, have you played with the pg_autovacuum default vacuum and +analyze thresholds? If it appears that it is related to pg_autovacuum +please send me the command options used to run it and a logfile of it's +output running at at a debug level of -d2 + + +Matthew + + +From pgsql-performance-owner@postgresql.org Sat Mar 13 19:17:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 46120D1E123 + for ; + Sat, 13 Mar 2004 23:17:10 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85175-07 + for ; + Sat, 13 Mar 2004 19:17:11 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 721ABD1DB8D + for ; + Sat, 13 Mar 2004 19:17:08 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2DNH8cT007305; + Sat, 13 Mar 2004 18:17:08 -0500 (EST) +To: Mike Bridge +Cc: pgsql-performance@postgresql.org +Subject: Re: High CPU with 7.4.1 after running for about 2 weeks +In-reply-to: +References: +Comments: In-reply-to Mike Bridge + message dated "Wed, 10 Mar 2004 03:43:37 +0000" +Date: Sat, 13 Mar 2004 18:17:08 -0500 +Message-ID: <7304.1079219828@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/182 +X-Sequence-Number: 6038 + +Mike Bridge writes: +> I've been running Postgresql 7.4.1 for a couple weeks after upgrading +> from 7.2. I noticed today that the postmaster had been using 99% of +> the dual CPUs (on a PowerEdge 2650) non-stop for the last couple days. +> I stopped all the clients, and it didn't abate---even with no +> connections---so I restarted the postmaster. Now everything is +> running smoothly again. + +Since the postmaster is a single unthreaded process, it's quite +impossible for it to take up 100% of two CPUs. Could you be more +precise about which processes were eating CPU, and what they were +doing according to the available state data? (ps auxww and +pg_stat_activity can be helpful tools.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 15 16:40:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A8A60D1DB53 + for ; + Sun, 14 Mar 2004 03:23: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 36360-06 + for ; + Sat, 13 Mar 2004 23:23:04 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 466F3D1DA9B + for ; + Sat, 13 Mar 2004 23:23:00 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by news.hub.org (8.12.9/8.12.9) with ESMTP id i2E3Mx1Y003808 + for ; Sun, 14 Mar 2004 03:22:59 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i2E3AELc094044 + for pgsql-performance@postgresql.org; Sun, 14 Mar 2004 03:10:14 GMT +From: Mike Bridge +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: High CPU with 7.4.1 after running for about 2 weeks +Message-ID: +References: + <7304.1079219828@sss.pgh.pa.us> +X-Newsreader: Forte Agent 1.93/32.576 English (American) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Lines: 28 +Date: Sun, 14 Mar 2004 03:10:18 GMT +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/200 +X-Sequence-Number: 6056 + +>Since the postmaster is a single unthreaded process, it's quite +>impossible for it to take up 100% of two CPUs. Could you be more +>precise about which processes were eating CPU, and what they were +>doing according to the available state data? (ps auxww and +>pg_stat_activity can be helpful tools.) +> +> regards, tom lane + +I shut down all our clients (all java except one in perl), and +pg_stat_activity showed that there was still one query active. That's +a good table to know about! Anyway, it didn't end until I sent it a +TERM signal. I assume this means there's a runaway query somewhere, +which I'll have to hunt down. + +But if the client dies, doesn't postgresql normally terminate the +query that that client initiated? Or do I need to set +statement_timeout? + +(As for the 100% CPU, I was confused by the fact that I was getting +two lines in "top" (on Linux) with 99% utilization---I assume with two +runaway queries.) + +Thanks for your help! + +-Mike + + + + +From pgsql-performance-owner@postgresql.org Sat Mar 13 23:47:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 80129D1C9B5 + for ; + Sun, 14 Mar 2004 03:47: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 44825-02 + for ; + Sat, 13 Mar 2004 23:47:45 -0400 (AST) +Received: from mail63.csoft.net (unknown [63.111.22.74]) + by svr1.postgresql.org (Postfix) with SMTP id 91B68D1B8EA + for ; + Sat, 13 Mar 2004 23:47:40 -0400 (AST) +Received: (qmail 8371 invoked by uid 1112); 14 Mar 2004 03:48:01 -0000 +Date: Sat, 13 Mar 2004 22:48:01 -0500 (EST) +From: Kris Jurka +X-X-Sender: books@leary.csoft.net +To: Tom Lane +Cc: Eric Brown , + pgsql-performance@postgresql.org +Subject: Re: severe performance issue with planner +In-Reply-To: <4726.1079064433@sss.pgh.pa.us> +Message-ID: +References: + <4726.1079064433@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/183 +X-Sequence-Number: 6039 + + + +On Thu, 11 Mar 2004, Tom Lane wrote: + +> "Eric Brown" writes: +> > [ planning a 9-table query takes too long ] +> +> See http://www.postgresql.org/docs/7.4/static/explicit-joins.html +> for some useful tips. +> + +Is this the best answer we've got? For me with an empty table this query +takes 4 seconds to plan, is that the expected planning time? I know I've +got nine table queries that don't take that long. + +Setting geqo_threshold less than 9, it takes 1 second to plan. Does this +indicate that geqo_threshold is set too high, or is it a tradeoff between +planning time and plan quality? If the planning time is so high because +the are a large number of possible join orders, should geqo_threhold be +based on the number of possible plans somehow instead of the number of +tables involved? + +Kris Jurka + + +From pgsql-performance-owner@postgresql.org Sun Mar 14 11:52:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 91BC4D1C952 + for ; + Sun, 14 Mar 2004 15:52: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 97501-05 + for ; + Sun, 14 Mar 2004 11:52:29 -0400 (AST) +Received: from fep04-mail.bloor.is.net.cable.rogers.com + (fep04-mail.bloor.is.net.cable.rogers.com [66.185.86.74]) + by svr1.postgresql.org (Postfix) with ESMTP id 14AD7D1BACC + for ; + Sun, 14 Mar 2004 11:52:24 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep04-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040314155154.ICB3598.fep04-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Sun, 14 Mar 2004 10:51:54 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 7C2B23E38; Sun, 14 Mar 2004 10:52:27 -0500 (EST) +Date: Sun, 14 Mar 2004 10:52:27 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: Drop Tables Very Slow in Postgresql 7.2.1 +Message-ID: <20040314155227.GA1400@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <404EBDA5.ED3248AE@phil.com.sg> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <404EBDA5.ED3248AE@phil.com.sg> +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep04-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Sun, + 14 Mar 2004 10:51:54 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/184 +X-Sequence-Number: 6040 + +On Wed, Mar 10, 2004 at 12:33:01PM +0530, Maneesha Nunes wrote: +> Hello there !!! +> +> I am using postgresql7.2.1 as the backend for an E.R.P system running +> on Linux Redhat 7.2(Enigma) + +You should upgrade, to at the _very least_ the last release of 7.2. +There were bugs in earlier releases fixed in later releases; that's +why there's a 7.2.4. (I'll also point out that the 7.2 series is +missing plenty of performance enhancements which came later. I'd get +to work on upgrading, because 7.2 is now basically unmaintained.) + +But in any case, you likely have issues on your system tables. I'd +do a VACUUM FULL and a complete REINDEX of the system tables next. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +I remember when computers were frustrating because they *did* exactly what +you told them to. That actually seems sort of quaint now. + --J.D. Baldwin + +From pgsql-performance-owner@postgresql.org Sun Mar 14 12:00:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 06703D1B4C3 + for ; + Sun, 14 Mar 2004 16: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 01734-04 + for ; + Sun, 14 Mar 2004 12:00:21 -0400 (AST) +Received: from fep03-mail.bloor.is.net.cable.rogers.com + (fep03-mail.bloor.is.net.cable.rogers.com [66.185.86.73]) + by svr1.postgresql.org (Postfix) with ESMTP id BD51CD1B467 + for ; + Sun, 14 Mar 2004 12:00:14 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep03-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040314160018.MDTG411419.fep03-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Sun, 14 Mar 2004 11:00:18 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id CB7083E38; Sun, 14 Mar 2004 11:00:18 -0500 (EST) +Date: Sun, 14 Mar 2004 11:00:18 -0500 +From: Andrew Sullivan +To: PgSQL Performance ML +Subject: Re: [ADMIN] syslog slowing the database? +Message-ID: <20040314160018.GB1400@phlogiston.dyndns.org> +Mail-Followup-To: PgSQL Performance ML +References: <404E2937.4060604@cranel.com> <370.1078877805@sss.pgh.pa.us> + <404F3996.2070105@cranel.com> <7688.1078937631@sss.pgh.pa.us> + <404FC23E.9000207@familyhealth.com.au> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <404FC23E.9000207@familyhealth.com.au> +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep03-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Sun, + 14 Mar 2004 11:00:18 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/185 +X-Sequence-Number: 6041 + +On Thu, Mar 11, 2004 at 09:34:54AM +0800, Christopher Kings-Lynne wrote: +> >You could also consider not using syslog at all: let the postmaster +> >output to its stderr, and pipe that into a log-rotation program. +> +> Not an option I'm afraid. PostgreSQL just jams and stops logging after +> the first rotation... + +Actually, this is what we do. Last year we offered an (admittedly +expensive) bespoke log rotator written in Perl for just this purpose. +It was rejected on the grounds that it didn't do anything Apache's +rotator didn't do, so I didn't pursue it. I'm willing to put it up +on gborg, though, if anyone thinks it'll be worth having around. +FWIW, we use ours in production. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +The plural of anecdote is not data. + --Roger Brinner + +From pgsql-performance-owner@postgresql.org Sun Mar 14 15:33:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4E56CD1DD14 + for ; + Sun, 14 Mar 2004 19:33: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 47901-01 + for ; + Sun, 14 Mar 2004 15:33:36 -0400 (AST) +Received: from mailhost3.tudelft.nl (mailhost3.tudelft.nl [130.161.180.14]) + by svr1.postgresql.org (Postfix) with ESMTP id D835DD1DAA7 + for ; + Sun, 14 Mar 2004 15:33:28 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by rav.antivirus (Postfix) with ESMTP id 94BAF2EE21 + for ; + Sun, 14 Mar 2004 20:33:34 +0100 (MET) +Received: from listserv.tudelft.nl (listserv.tudelft.nl [130.161.180.33]) + by mailhost3.tudelft.nl (Postfix) with ESMTP id 14BB02EE12 + for ; + Sun, 14 Mar 2004 20:33:34 +0100 (MET) +Received: from vulcanus.its.tudelft.nl (x193056-2.shuis-s.tudelft.nl + [145.94.193.58]) + by listserv.tudelft.nl (8.12.10/8.12.8) with ESMTP id i2EJXWDR014993 + for ; + Sun, 14 Mar 2004 20:33:33 +0100 (MET) +Message-ID: <4054B36C.8030306@vulcanus.its.tudelft.nl> +Date: Sun, 14 Mar 2004 20:33:00 +0100 +From: Arjen van der Meijden +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Large CASE-statement is pretty slow? +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at tudelft.nl +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/186 +X-Sequence-Number: 6042 + +Hi list, + +I was more or less toying with an idea for a project I have, which +includes renumbering a primary key (don't ask, it's necessary :/ ) + +Anyway, I was looking into the usefullness of a INSERT INTO newtable +SELECT field, field, CASE pkey WHEN x1 THEN y1 WHEN x2 THEN y2 etc END +FROM oldtable + +The resulting select was about 1.7MB of query-text, mostly composed of +the CASE-statement. So I discarded that idea, I still wanted to know how +much time it would take on my database (MySQL) and found it to take +about 1100 seconds, in contrast to simply selecting the data, which'd +take about 0.7 seconds orso... The table I tested this on is about 30MB. + +Of course I wanted to know how long it'd take on postgresql, selecting +the pkey-field only (without the case) took also some 0.7 seconds (the +entire table may have been more). +But the CASE-version took 9026139.201 ms, i.e. over 9000 seconds about 8 +times slower than MySQL. + +What I'm wondering about: +Although I was not expecting Postgresql to heavily beat MySQL, I was +surprised to see it so much slower. Is the CASE-statement in Postgresql +that inefficient? Or is it simply not very scalable (i.e. don't try to +have 100000 cases like I did)? + +The database is a lightly optimised gentoo-compile of 7.4.2, the +mysql-version was 4.0.18 in case anyone wanted to know that. + + +Best regards, + +Arjen van der Meijden + + +PS, don't try to "help improve the query" I discarded the idea as too +inefficient and went along with a simple left join to get the "new pkey" +out of a temporary table ;) + + + +From pgsql-performance-owner@postgresql.org Sun Mar 14 17:09:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 75918D1D1D5 + for ; + Sun, 14 Mar 2004 21: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 59443-10 + for ; + Sun, 14 Mar 2004 17:09:41 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 9C8C0D1CCCF + for ; + Sun, 14 Mar 2004 17:09:33 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2EL9ejT025014; + Sun, 14 Mar 2004 16:09:40 -0500 (EST) +To: Arjen van der Meijden +Cc: pgsql-performance@postgresql.org +Subject: Re: Large CASE-statement is pretty slow? +In-reply-to: <4054B36C.8030306@vulcanus.its.tudelft.nl> +References: <4054B36C.8030306@vulcanus.its.tudelft.nl> +Comments: In-reply-to Arjen van der Meijden + + message dated "Sun, 14 Mar 2004 20:33:00 +0100" +Date: Sun, 14 Mar 2004 16:09:40 -0500 +Message-ID: <25013.1079298580@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/187 +X-Sequence-Number: 6043 + +Arjen van der Meijden writes: +> Anyway, I was looking into the usefullness of a INSERT INTO newtable +> SELECT field, field, CASE pkey WHEN x1 THEN y1 WHEN x2 THEN y2 etc END +> FROM oldtable + +> The resulting select was about 1.7MB of query-text, mostly composed of +> the CASE-statement. + +Hm, you mean one single SELECT, one single CASE? How many WHEN clauses +exactly? Exactly what did a typical clause of the CASE look like? + +I wouldn't be too surprised to find some bit of code that's O(N^2) in +the number of arms of the CASE, or something like that; it's not an area +that we've ever felt the need to optimize. But I'd like a fairly +specific test case before trying to look into it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 14 19:10:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B7608D1E0FD + for ; + Sun, 14 Mar 2004 23:10: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 84181-09 + for ; + Sun, 14 Mar 2004 19:10:11 -0400 (AST) +Received: from kserver17.erfurt12.de (unknown [80.190.233.41]) + by svr1.postgresql.org (Postfix) with ESMTP id 8368FD1DCF1 + for ; + Sun, 14 Mar 2004 19:10:02 -0400 (AST) +Received: by kserver17.erfurt12.de (Postfix, from userid 642) + id BA6D35A816F; Sun, 14 Mar 2004 22:43:41 +0100 (CET) +To: pgsql-performance@postgresql.org +From: postgres@countup.de +Subject: Deadlocks... +Content-Type: text/html; charset=iso-8859-1; +Message-Id: <20040314214341.BA6D35A816F@kserver17.erfurt12.de> +Date: Sun, 14 Mar 2004 22:43:41 +0100 (CET) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=1.3 tagged_above=0.0 required=5.0 tests=BAYES_01, + HTML_MESSAGE, MIME_HEADER_CTYPE_ONLY, MIME_HTML_ONLY, NO_REAL_NAME +X-Spam-Level: * +X-Archive-Number: 200403/189 +X-Sequence-Number: 6045 + +Hi, +
+
i have 2 Functions, one ist called by page visitors (something about 2,000 times / 1 hour) +
and the other just by the admin (let say 1 time per hour or per login) +
i often get a deadlock error after calling the admin function +
yes they try to access the same table somewhere in the function code. +
The Admin function can take up to 20-30 seconds and visitor function just 20 to 30 ms +
What can i do there? Have i to study a lot about locking tables or something else? +
+
Thanks for your Help +
regards, +
Boris + +From pgsql-performance-owner@postgresql.org Sun Mar 14 18:10:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 870CCD1BA35 + for ; + Sun, 14 Mar 2004 22:10: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 77684-04 + for ; + Sun, 14 Mar 2004 18:10:58 -0400 (AST) +Received: from hotmail.com (law10-oe17.law10.hotmail.com [64.4.14.121]) + by svr1.postgresql.org (Postfix) with ESMTP id 9296CD1B4C3 + for ; + Sun, 14 Mar 2004 18:10:50 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Sun, 14 Mar 2004 14:10:57 -0800 +Received: from 67.81.102.201 by law10-oe17.law10.hotmail.com with DAV; + Sun, 14 Mar 2004 22:10:57 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: "Marty Scholes" , + +References: <404F9D0F.5040309@outputservices.com> + <404FA4F3.6080903@outputservices.com> +Subject: Re: Scaling further up +Date: Sun, 14 Mar 2004 17:11:22 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Message-ID: +X-OriginalArrivalTime: 14 Mar 2004 22:10:57.0989 (UTC) + FILETIME=[3A2BD750:01C40A11] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/188 +X-Sequence-Number: 6044 + +Sorry about not chiming in before - I've been too swamped to think. I agree +with most of the points, but a lot of these posts are interesting and seem +to describe systems from an SA perspective to my DBA-centric view. + +----- Original Message ----- +From: "Marty Scholes" +To: +Sent: Wednesday, March 10, 2004 6:29 PM +Subject: Re: [PERFORM] Scaling further up + + +> I have some suggestions based on my anecdotal experience. +> +> 1. This is a relatively small DB -- the working set will likely be in +> RAM at any moment in time, making read I/O time mostly irrelevant. +> +> 2. The killer will be write times -- specifically log writes. Small and +> heavily synchronized writes, log and data writes, will drag down an +> impressive hardware RAID setup. We run mirrored hardware RAID 5 arrays +> with write back cache and are constantly seeking ways to improve write +> performance. We do a lot of batch processing, though, so we do a lot of +> write I/Os. + +My experience with RAID5 for streaming sequential writes is bad. This is +sometimes helped by the hardware caching to cover the cost of the additional +I/Os for striping (write through RAID5 + big cache acts like RAID 1+0 until +you run out of cache). Batch processing is different from high concurrency +transactions because it needs faster volume streaming, while TP is dependant +on the speed of ack'ing (few big writes with less synchronous waits vs. lots +of small writes which serialize everyone). (RAID 3 worked for me in the past +for logging, but I haven't used it in years.) + +> +> 3. Be very careful with "battery backed write cache." It usually works +> as advertised. More than once in the past decade I have seen +> spontaneous cache corruption after power losss. The corruption usually +> happens when some admin, including me, has assumed that the cache will +> ALWAYS survive a power failure unblemished and has no "plan B." Make +> sure you have a contingency plan for corruption, or don't enable the +cache. + +I agree strongly. There is also the same problem with disk write back cache +and even with SCSI controllers with write through enabled. PITR would help +here. A lot of these problems are due to procedural error post crash. + +> +> 4. RAID 10 will likely have bigger stripe sizes on the RAID 0 portion of +> the setup, and might hinder, not help small write I/O performance. + +In a high volume system without write caching you are almost always going to +see queuing, which can make the larger buffer mostly irrelevant, if it's not +huge. Write caching thrives on big block sizes (which is a key reason why +Symmetrix doesn't do worse than it does) by reducing I/O counts. Most shops +I've set up or seen use mirroring or RAID 10 for logs. Note also that many +RAID 10 controllers in a non-write cached setup allows having a race between +the two writers, acknowledging when the first of the two completes - +increasing throughput by about 1/4. + +> +> 5. Most (almost all) of the I/O time will be due to the access time +> (head seek + head settle + rotational latency) and very little of the +> I/O time will due to data transfer time. In other words, getting drives +> that provide faster transfer rates will barely improve performance. The +> secret is lowering the access time. + +True. This is very much a latency story. Even in volume batch, you can see +access time that clearly shows some other system configuration bottleneck +that happens elsewhere before hitting I/O capacity. + +> +> 6. A relatively cheap way to drastically drop the access time is to get +> large drive(s) and only use a portion of them for storage. The less +> space used on the drive, the less area the heads need to cover for +> seeks. At one extreme, you could make the partition the size of a +> single cylinder. This would make access time (ignoring OS and +> controller overhead) identical to rotational latency, which is as low as +> 4.2 ms for a cheap 7200 RPM drive. + +This is a good strategy for VLDB, and may not be relevant in this case. + +Also - big sequential writes and 15K rpm drives, in the case of +writethrough, is a beautiful thing - they look like a manufacturers' demo. A +primary performance role of a RDBMS is to convert random I/O to sequential +(by buffering reads and using a streaming log to defer random writes to +checkpoints). RDBMS's are the prime beneficiaries of the drive speed +improvements - since logging, backups, and copies are about the only things +(ignoring bad perl scripts and find commands) that generate loads of 50+ +mB/sec. + +/Aaron + +From pgsql-performance-owner@postgresql.org Sun Mar 14 19:21:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D660D1E155 + for ; + Sun, 14 Mar 2004 23:21: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 87461-09 + for ; + Sun, 14 Mar 2004 19:21:58 -0400 (AST) +Received: from mailhost3.tudelft.nl (mailhost3.tudelft.nl [130.161.180.14]) + by svr1.postgresql.org (Postfix) with ESMTP id 54D37D1E154 + for ; + Sun, 14 Mar 2004 19:21:50 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by rav.antivirus (Postfix) with ESMTP + id 27C3E2EE9F; Mon, 15 Mar 2004 00:21:58 +0100 (MET) +Received: from listserv.tudelft.nl (listserv.tudelft.nl [130.161.180.33]) + by mailhost3.tudelft.nl (Postfix) with ESMTP + id EA9E82EE8E; Mon, 15 Mar 2004 00:21:57 +0100 (MET) +Received: from vulcanus.its.tudelft.nl (x193056-2.shuis-s.tudelft.nl + [145.94.193.58]) + by listserv.tudelft.nl (8.12.10/8.12.8) with ESMTP id i2ENLuDR022367; + Mon, 15 Mar 2004 00:21:57 +0100 (MET) +Message-ID: <4054E8ED.3090200@vulcanus.its.tudelft.nl> +Date: Mon, 15 Mar 2004 00:21:17 +0100 +From: Arjen van der Meijden +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: Large CASE-statement is pretty slow? +References: <4054B36C.8030306@vulcanus.its.tudelft.nl> + <25013.1079298580@sss.pgh.pa.us> +In-Reply-To: <25013.1079298580@sss.pgh.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at tudelft.nl +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/190 +X-Sequence-Number: 6046 + +Tom Lane wrote: + +> Arjen van der Meijden writes: +> +>>Anyway, I was looking into the usefullness of a INSERT INTO newtable +>>SELECT field, field, CASE pkey WHEN x1 THEN y1 WHEN x2 THEN y2 etc END +>>FROM oldtable +> +> +>>The resulting select was about 1.7MB of query-text, mostly composed of +>>the CASE-statement. +> +> +> Hm, you mean one single SELECT, one single CASE? How many WHEN clauses +> exactly? Exactly what did a typical clause of the CASE look like? +Yes, one SELECT-query with one single CASE-statement. +The CASE-statement had the simple-case-structure like: +SELECT CASE UserID WHEN 1 THEN 1 WHEN 34 THEN 2 ... etc + +I noticed, by the way, that the ordering is on the THEN y parameter, the +x parameter (WHEN x THEN y) is "more or less increasing". + +But some numbers: +The table I did my tests on has 88291 rows, I did the select on the +integer primary key, so the CASE was the only column in the select. +I'm running the query again on a table that has only the primary key of +my original table and it seems to be as slow. +I'm not really sure how many WHEN's there are in that CASE, but it is +supposed to be a relocation of all primary key-values to some other +value, so it will contain some number close to that 88291. + +> I wouldn't be too surprised to find some bit of code that's O(N^2) in +> the number of arms of the CASE, or something like that; it's not an area +> that we've ever felt the need to optimize. But I'd like a fairly +> specific test case before trying to look into it. + +Well, I have discarded this type of query as "too inefficient" and found +a better way, so don't feel the need to optimize it just because I +noticed it is slow with very large CASEs. Although CASEs with a few +hundred WHENs wont be that uncommon and might improve a bit as well? + +I can send you the "primary key only"-table and the query off list if +you want to. That won't make me violate any privacy rule and is probably +a good test case? + +Best regards, + +Arjen van der Meijden + + + +From pgsql-admin-owner@postgresql.org Mon Mar 15 11:21:13 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id DE9E3D1C511; Mon, 15 Mar 2004 15:21: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 54273-06; Mon, 15 Mar 2004 11:21:13 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP + id CE139D1C4EB; Mon, 15 Mar 2004 11:21:08 -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 i2FFK6AZ029110; + Mon, 15 Mar 2004 08:20:06 -0700 (MST) +Date: Mon, 15 Mar 2004 08:17:49 -0700 (MST) +From: "scott.marlowe" +To: Christopher Kings-Lynne +Cc: Tom Lane , Greg Spiegelberg , + PgSQL Performance ML , + Postgres Admin List +Subject: Re: [PERFORM] syslog slowing the database? +In-Reply-To: <404FC23E.9000207@familyhealth.com.au> +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-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/222 +X-Sequence-Number: 12791 + +On Thu, 11 Mar 2004, Christopher Kings-Lynne wrote: + +> > You could also consider not using syslog at all: let the postmaster +> > output to its stderr, and pipe that into a log-rotation program. +> > I believe some people use Apache's log rotator for this with good +> > results. +> +> Not an option I'm afraid. PostgreSQL just jams and stops logging after +> the first rotation... +> +> I've read in the docs that syslog logging is the only "production" +> solution... + +Can you use the apache log rotator? It's known to work in my environment +(redhat 7.2, postgresql 7.2 and 7.4) with this command to start it in my +rc.local file: + +su - postgres -c 'pg_ctl start | rotatelogs $PGDATA/pglog 86400 2>1&' + + +From pgsql-admin-owner@postgresql.org Mon Mar 15 11:38:17 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id B820CD1E317; Mon, 15 Mar 2004 15:38: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 58215-07; Mon, 15 Mar 2004 11:38:18 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP + id 18B63D1E154; Mon, 15 Mar 2004 11:38:13 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i2FFc2009800; + Mon, 15 Mar 2004 10:38:02 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403151538.i2FFc2009800@candle.pha.pa.us> +Subject: Re: [PERFORM] syslog slowing the database? +In-Reply-To: +To: "scott.marlowe" +Date: Mon, 15 Mar 2004 10:38:02 -0500 (EST) +Cc: Christopher Kings-Lynne , + Tom Lane , Greg Spiegelberg , + PgSQL Performance ML , + Postgres Admin List +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: 200403/223 +X-Sequence-Number: 12792 + +scott.marlowe wrote: +> On Thu, 11 Mar 2004, Christopher Kings-Lynne wrote: +> +> > > You could also consider not using syslog at all: let the postmaster +> > > output to its stderr, and pipe that into a log-rotation program. +> > > I believe some people use Apache's log rotator for this with good +> > > results. +> > +> > Not an option I'm afraid. PostgreSQL just jams and stops logging after +> > the first rotation... +> > +> > I've read in the docs that syslog logging is the only "production" +> > solution... +> +> Can you use the apache log rotator? It's known to work in my environment +> (redhat 7.2, postgresql 7.2 and 7.4) with this command to start it in my +> rc.local file: +> +> su - postgres -c 'pg_ctl start | rotatelogs $PGDATA/pglog 86400 2>1&' + +Sure, our documentation specifically mentions using rotatelogs. + +-- + 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-admin-owner@postgresql.org Mon Mar 15 12:01:06 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id AFE42D1E31E; Mon, 15 Mar 2004 16: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 71218-03; Mon, 15 Mar 2004 12:01:01 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP + id 6809DD1E154; Mon, 15 Mar 2004 12:01:00 -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 i2FFxgAZ003621; + Mon, 15 Mar 2004 08:59:42 -0700 (MST) +Date: Mon, 15 Mar 2004 08:57:25 -0700 (MST) +From: "scott.marlowe" +To: Bruce Momjian +Cc: Christopher Kings-Lynne , + Tom Lane , Greg Spiegelberg , + PgSQL Performance ML , + Postgres Admin List +Subject: Re: [PERFORM] syslog slowing the database? +In-Reply-To: <200403151538.i2FFc2009800@candle.pha.pa.us> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-IHS-MailScanner: Found to be clean +X-IHS-MailScanner-SpamCheck: +X-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/224 +X-Sequence-Number: 12793 + +On Mon, 15 Mar 2004, Bruce Momjian wrote: + +> scott.marlowe wrote: +> > On Thu, 11 Mar 2004, Christopher Kings-Lynne wrote: +> > +> > > > You could also consider not using syslog at all: let the postmaster +> > > > output to its stderr, and pipe that into a log-rotation program. +> > > > I believe some people use Apache's log rotator for this with good +> > > > results. +> > > +> > > Not an option I'm afraid. PostgreSQL just jams and stops logging after +> > > the first rotation... +> > > +> > > I've read in the docs that syslog logging is the only "production" +> > > solution... +> > +> > Can you use the apache log rotator? It's known to work in my environment +> > (redhat 7.2, postgresql 7.2 and 7.4) with this command to start it in my +> > rc.local file: +> > +> > su - postgres -c 'pg_ctl start | rotatelogs $PGDATA/pglog 86400 2>1&' +> +> Sure, our documentation specifically mentions using rotatelogs. + + +hehe. What I meant was can Christopher use it, or does he have a +limitation in his environment where he can't get ahold of the apache log +rotater... :-) + + +From pgsql-performance-owner@postgresql.org Mon Mar 15 13:15:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EF6C3D1DAA7 + for ; + Mon, 15 Mar 2004 17:15: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 00670-03 + for ; + Mon, 15 Mar 2004 13:15:52 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id C23DFD1DA9B + for ; + Mon, 15 Mar 2004 13:15:49 -0400 (AST) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id ED7FB17C30A; Mon, 15 Mar 2004 12:15:45 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1B2vgn-0006Vd-00; Mon, 15 Mar 2004 12:15:45 -0500 +To: Arjen van der Meijden +Cc: pgsql-performance@postgresql.org +Subject: Re: Large CASE-statement is pretty slow? +References: <4054B36C.8030306@vulcanus.its.tudelft.nl> +In-Reply-To: <4054B36C.8030306@vulcanus.its.tudelft.nl> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 15 Mar 2004 12:15:45 -0500 +Message-ID: <87y8q22fr2.fsf@stark.xeocode.com> +Lines: 18 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/194 +X-Sequence-Number: 6050 + +Arjen van der Meijden writes: + +> +> Of course I wanted to know how long it'd take on postgresql, selecting the +> pkey-field only (without the case) took also some 0.7 seconds (the entire table +> may have been more). +> But the CASE-version took 9026139.201 ms, i.e. over 9000 seconds about 8 times +> slower than MySQL. + +Was this the select with the CASE, or the update? + +If you did the update and have lots of foreign key references to the table +then every record that's updated forces a check to make sure there are no +references to that record (or an update if it's ON UPDATE CASCADE). If there +are no indexes on the referencing table columns that will be very slow. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Mar 15 13:20:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B3760D1E128 + for ; + Mon, 15 Mar 2004 17:20: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 05539-03 + for ; + Mon, 15 Mar 2004 13:20:51 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 60ADAD1E155 + for ; + Mon, 15 Mar 2004 13:20:50 -0400 (AST) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id EF02917C316; Mon, 15 Mar 2004 12:20:49 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1B2vlh-0006WA-00; Mon, 15 Mar 2004 12:20:49 -0500 +To: Arjen van der Meijden +Cc: pgsql-performance@postgresql.org +Subject: Re: Large CASE-statement is pretty slow? +References: <4054B36C.8030306@vulcanus.its.tudelft.nl> + <25013.1079298580@sss.pgh.pa.us> + <4054E8ED.3090200@vulcanus.its.tudelft.nl> +In-Reply-To: <4054E8ED.3090200@vulcanus.its.tudelft.nl> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 15 Mar 2004 12:20:49 -0500 +Message-ID: <87smga2fim.fsf@stark.xeocode.com> +Lines: 13 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/195 +X-Sequence-Number: 6051 + + +Arjen van der Meijden writes: + +> Well, I have discarded this type of query as "too inefficient" and found a +> better way + +Loading the mapping into a table with an index and doing an update using +"from" to do a join seems likely to end up being the most efficient method. +Postgres would probably not even bother with the index and do a hash join. + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon Mar 15 14:55:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A753ED1CCD2 + for ; + Mon, 15 Mar 2004 18:55: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 32556-05 + for ; + Mon, 15 Mar 2004 14:54:54 -0400 (AST) +Received: from mailhost3.tudelft.nl (mailhost3.tudelft.nl [130.161.180.14]) + by svr1.postgresql.org (Postfix) with ESMTP id 19063D1B909 + for ; + Mon, 15 Mar 2004 14:54:53 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by rav.antivirus (Postfix) with ESMTP + id 08A9B2F0F3; Mon, 15 Mar 2004 19:54:53 +0100 (MET) +Received: from listserv.tudelft.nl (listserv.tudelft.nl [130.161.180.33]) + by mailhost3.tudelft.nl (Postfix) with ESMTP + id C2F622F0EF; Mon, 15 Mar 2004 19:54:52 +0100 (MET) +Received: from vulcanus.its.tudelft.nl (x193056-2.shuis-s.tudelft.nl + [145.94.193.58]) + by listserv.tudelft.nl (8.12.10/8.12.8) with ESMTP id i2FIspDR012101; + Mon, 15 Mar 2004 19:54:52 +0100 (MET) +Message-ID: <4055FBDD.1020207@vulcanus.its.tudelft.nl> +Date: Mon, 15 Mar 2004 19:54:21 +0100 +From: Arjen van der Meijden +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Greg Stark +Cc: pgsql-performance@postgresql.org +Subject: Re: Large CASE-statement is pretty slow? +References: <4054B36C.8030306@vulcanus.its.tudelft.nl> + <87y8q22fr2.fsf@stark.xeocode.com> +In-Reply-To: <87y8q22fr2.fsf@stark.xeocode.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at tudelft.nl +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/196 +X-Sequence-Number: 6052 + +Greg Stark wrote: + +> Arjen van der Meijden writes: +> +> +> Was this the select with the CASE, or the update? + +It was just the select to see how long it'd take. I already anticipated +it to be possibly a "slow query", so I only did the select first. + +Best regards, + +Arjen van der Meijden + + + +From pgsql-performance-owner@postgresql.org Mon Mar 15 16:09:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 548B3D1C9E1 + for ; + Mon, 15 Mar 2004 20:09: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 67784-05 + for ; + Mon, 15 Mar 2004 16:09:34 -0400 (AST) +Received: from fep01-mail.bloor.is.net.cable.rogers.com + (fep01-mail.bloor.is.net.cable.rogers.com [66.185.86.71]) + by svr1.postgresql.org (Postfix) with ESMTP id 12898D1C969 + for ; + Mon, 15 Mar 2004 16:09:31 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep01-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040315200907.QCWR230350.fep01-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Mon, 15 Mar 2004 15:09:07 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 08E4D3DC8; Mon, 15 Mar 2004 15:09:31 -0500 (EST) +Date: Mon, 15 Mar 2004 15:09:31 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: Scaling further up +Message-ID: <20040315200930.GA2921@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098062@vt-pe2550-001.vantage.vantage.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098062@vt-pe2550-001.vantage.vantage.com> +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep01-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Mon, + 15 Mar 2004 15:09:07 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/197 +X-Sequence-Number: 6053 + +On Fri, Mar 12, 2004 at 06:25:48PM -0500, Anjan Dave wrote: +> We upgraded from 8GB to 12GB RAM a month or so ago, but even in the +> past, I've never seen the system exhaust on it's system cache (~6GB, in +> 'top'), while it's swapping. +> +> Some one had mentioned why not have the entire DB in memory? How do I +> configure that, for knowledge? + +You don't. It'll automatically be in memory if (a) you have enough +memory, (b) you don't have anything else on the machine using the +memory, and (c) it's been read at least one time. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca + +From pgsql-performance-owner@postgresql.org Mon Mar 15 16:30:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B233ED1E208 + for ; + Mon, 15 Mar 2004 20:28:44 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73300-10 + for ; + Mon, 15 Mar 2004 16:28:44 -0400 (AST) +Received: from mail.mattdavies.net (mail.mattdavies.net [64.122.21.130]) + by svr1.postgresql.org (Postfix) with ESMTP id F3FB7D1E146 + for ; + Mon, 15 Mar 2004 16:28:37 -0400 (AST) +Received: (qmail 88493 invoked by uid 5009); 15 Mar 2004 20:28:37 -0000 +Received: from matt@mattdavies.net by mail.mattdavies.net by uid 89 with + qmail-scanner-1.20 (clamscan: 0.67. Clear:RC:1(127.0.0.1):. + Processed in 0.056267 secs); 15 Mar 2004 20:28:37 -0000 +Received: from unknown (HELO matt.mattdavies.net) (127.0.0.1) + by localhost with SMTP; 15 Mar 2004 20:28:36 -0000 +Received: (from nobody@localhost) + by matt.mattdavies.net (8.12.8p1/8.12.8/Submit) id i2FKSZPK088482 + for pgsql-performance@postgresql.org; + Mon, 15 Mar 2004 13:28:35 -0700 (MST) +X-Authentication-Warning: matt.mattdavies.net: nobody set sender to + matt@mattdavies.net using -f +Received: from hif-koby7.hill.af.mil (hif-koby7.hill.af.mil [137.241.250.102]) + by www.mattdavies.net (IMP) with HTTP + for ; + Mon, 15 Mar 2004 13:28:35 -0700 +Message-ID: <1079382515.405611f35f1c5@www.mattdavies.net> +Date: Mon, 15 Mar 2004 13:28:35 -0700 +From: Matt Davies +To: pgsql-performance@postgresql.org +Subject: Re: Scaling further up +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098062@vt-pe2550-001.vantage.vantage.com> + <20040315200930.GA2921@phlogiston.dyndns.org> +In-Reply-To: <20040315200930.GA2921@phlogiston.dyndns.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +User-Agent: Internet Messaging Program (IMP) 3.2.2 +X-Originating-IP: 137.241.250.102 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/199 +X-Sequence-Number: 6055 + +Quoting Andrew Sullivan : + +> On Fri, Mar 12, 2004 at 06:25:48PM -0500, Anjan Dave wrote: +> > We upgraded from 8GB to 12GB RAM a month or so ago, but even in the +> > past, I've never seen the system exhaust on it's system cache (~6GB, in +> > 'top'), while it's swapping. +> > +> > Some one had mentioned why not have the entire DB in memory? How do I +> > configure that, for knowledge? +> +> You don't. It'll automatically be in memory if (a) you have enough +> memory, (b) you don't have anything else on the machine using the +> memory, and (c) it's been read at least one time. + +This is the preferred method, but you could create a memory disk if running +linux. This has several caveats, though. + +1. You may have to recompile the kernel for support. +2. You must store the database on a hard drive partition during reboots. +3. Because of #2 this option is generally useful if you have static content that +is loaded to the MD upon startup of the system. + +You could have some fancy methodology of shutting down the system and then +copying the data to a disk-based filesystem, but this is inherently bad since +at any moment a power outage would erase any updates changes. + +The option is there to start with all data in memory, but in general, this is +probablt not what you want. Just an FYI. + +From pgsql-performance-owner@postgresql.org Mon Mar 15 16:29:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 57E9CD1E30D + for ; + Mon, 15 Mar 2004 20: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 74312-10 + for ; + Mon, 15 Mar 2004 16:28:55 -0400 (AST) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id A6F58D1E213 + for ; + Mon, 15 Mar 2004 16:28:50 -0400 (AST) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i2FKSkCj016672 + for ; Mon, 15 Mar 2004 14:28:47 -0600 +From: "Rosser Schwarz" +To: +Subject: atrocious update performance +Date: Mon, 15 Mar 2004 14:28:46 -0600 +Message-ID: <001401c40acc$1e4e7180$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-MailScanner-From: rschwarz@totalcardinc.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/198 +X-Sequence-Number: 6054 + +We're in the throes of an MS SQL to PostgreSQL migration; our databases +include a number of ~5M row tables. We decided to take this opportunity +to clean up and slightly re-normalize our schemas, given what we've +learned about the data over its lifetime and such, else we wouldn't be +experiencing any of the following (we could instead just dump and `copy +from`). + +We have a temporary table, public.tempprod, containing 4.7M rows, one +for each row in account.cust. account.cust has, among others, two +columns, prod and subprod, which we're trying to update from tempprod +joined against prod. The update tends to take unnecessarily long-- +rather, we've had to finally kill it after its taking obscenely too +long. + +The table: + +# \d account.cust + Table "account.cust" + Column | Type | Modifiers=20=20=20= +=20=20=20=20 +-----------+-----------------------------+---------------------------------- +---- + custid | bigint | not null default + | | +nextval('account.custid_seq'::text) + ownerid | integer | not null + origid | text | not null + pname | text | + fname | text | + mname | text | + lname | text | + suffix | text | + addr1 | text | + addr2 | text | + addr3 | text | + city | text | + state | text | + zip | text | + zipplus | text | + homeph | text | + workph | text | + otherph | text | + ssn | text | + isactive | boolean | default true + createddt | timestamp without time zone | default now() + prodid | bigint | + subprodid | bigint | +Indexes: + "cust_pkey" primary key, btree (custid) + "ix_addr1" btree (addr1) WHERE (addr1 IS NOT NULL) + "ix_addr2" btree (addr2) WHERE (addr2 IS NOT NULL) + "ix_city" btree (city) WHERE (city IS NOT NULL) + "ix_fname" btree (fname) WHERE (fname IS NOT NULL) + "ix_homeph" btree (homeph) WHERE (homeph IS NOT NULL) + "ix_lname" btree (lname) WHERE (lname IS NOT NULL) + "ix_mname" btree (mname) WHERE (mname IS NOT NULL) + "ix_origid" btree (origid) + "ix_ssn" btree (ssn) WHERE (ssn IS NOT NULL) + "ix_state" btree (state) WHERE (state IS NOT NULL) + "ix_workph" btree (workph) WHERE (workph IS NOT NULL) + "ix_zip" btree (zip) WHERE (zip IS NOT NULL) + +We're currently running on a dual Xeon 700 (I know, I know; it's what +we've got) with 2.5GB RAM and 4x36GB SCSI in hardware RAID 5 (Dell +Perc3 something-or-other controller). If we can demonstrate that=20 +PostgreSQL will meet our needs, we'll be going production on a dual +Opteron, maxed memory, with a 12-disk Fibre Channel array. + +The query is: + +update account.cust set prodid =3D=20 +(select p.prodid from account.prod p + join public.tempprod t on t.pool =3D p.origid + where custid =3D t.did) + +And then, upon its completion, s/prod/subprod/. + +That shouldn't run overnight, should it, let alone for -days-? + +In experimenting with ways of making the updates take less time, we tried +adding product and subproduct columns to tempprod, and updating those. +That seemed to work marginally better: + +explain analyze update public.tempprod set prodid =3D=20 +(select account.prod.prodid::bigint=20 + from account.prod=20 + where public.tempprod.pool::text =3D account.prod.origid::text) + +Seq Scan on tempprod (cost=3D0.00..9637101.35 rows 4731410 width=3D56) (act= +ual +time=3D24273.467..16090470.438 rows=3D4731410 loops=3D1) + SubPlan + -> Limit (cost=3D0.00..2.02 rows=3D2 width=3D8) (actual time=3D0.134..= +0.315 + rows=3D1 loops=3D4731410) + -> Seq Scan on prod (cost=3D0.00..2.02 rows=3D2 width=3D8) (actu= +al + time=3D0.126..0.305 rows=3D1 loops=3D4731410) + Filter: (($0)::text =3D (origid)::text) +Total runtime: 2284551.962 ms + +But then going from public.tempprod to account.cust again takes days. I +just cancelled an update that's been running since last Thursday. +Alas, given how long the queries take to run, I can't supply an `explain +analyze`. The `explain` seems reasonable enough: + +# explain update account.cust set prodid =3D tempprod.prodid + where tempprod.did =3D origid; + + Merge Join (cost=3D0.00..232764.69 rows=3D4731410 width=3D252) + Merge Cond: (("outer".origid)::text =3D ("inner".did)::text) + -> Index Scan using ix_origid on cust (cost=3D0.00..94876.83 + rows=3D4731410 width=3D244) + -> Index Scan using ix_did on tempprod (cost=3D0.00..66916.71 + rows=3D4731410 width=3D18) + +The relevant bits from my postgreql.conf (note, we built with a BLCKSZ +of 16K): + +shared_buffers =3D 4096 +sort_mem =3D 32768 +vacuum_mem =3D 32768 +wal_buffers =3D 16384 +checkpoint_segments =3D 64 +checkpoint_timeout =3D 1800 +checkpoint_warning =3D 30 +commit_delay =3D 50000 +effective_cache_size =3D 131072 + +Any advice, suggestions or comments of the "You bleeding idiot, why do +you have frob set to x?!" sort welcome. Unfortunately, if we can't +improve this, significantly, the powers what be will probably pass +on PostgreSQL, even though everything we've done so far--with this +marked exception--performs pretty spectacularly, all told. + +/rls + +-- +Rosser Schwarz +Total Card, Inc. + + +From pgsql-performance-owner@postgresql.org Mon Mar 15 16:40:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 980A3D1DA9B + for ; + Mon, 15 Mar 2004 20:34: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 80164-03 + for ; + Mon, 15 Mar 2004 16:34:35 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 0140ED1C9E1 + for ; + Mon, 15 Mar 2004 16:34:33 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2FKYViB003224; + Mon, 15 Mar 2004 15:34:31 -0500 (EST) +To: Arjen van der Meijden +Cc: pgsql-performance@postgresql.org +Subject: Re: Large CASE-statement is pretty slow? +In-reply-to: <4054E8ED.3090200@vulcanus.its.tudelft.nl> +References: <4054B36C.8030306@vulcanus.its.tudelft.nl> + <25013.1079298580@sss.pgh.pa.us> + <4054E8ED.3090200@vulcanus.its.tudelft.nl> +Comments: In-reply-to Arjen van der Meijden + + message dated "Mon, 15 Mar 2004 00:21:17 +0100" +Date: Mon, 15 Mar 2004 15:34:31 -0500 +Message-ID: <3223.1079382871@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/201 +X-Sequence-Number: 6057 + +Arjen van der Meijden writes: +> [ huge CASE is pretty slow ] + +I did some profiling of the test case that Arjen was kind enough to send +me. It seems there are two distinct problems. One is that the parser +uses repeated lappend()'s to construct the list of CASE arms; this +makes building the structure O(N^2) in the number of arms. (If you +simply try to EXPLAIN the query, you find out that the parse time is +about a third of the run time :-( ... and 90% of that is spent inside +nconc() which is the guts of lappend.) This problem is slated to be +fixed by Neil Conway's upcoming rewrite of the list support, which will +convert lappend into a constant-time operation. + +The other difficulty is that the evaluation machinery for arithmetic +expressions has a lot of overhead. The profile run shows: + + % cumulative self self total + time seconds seconds calls s/call s/call name + 38.15 41.92 41.92 229646 0.00 0.00 nconc + 21.76 65.84 23.92 199054454 0.00 0.00 ExecEvalExpr + 11.38 78.34 12.50 10000 0.00 0.00 ExecEvalCase + 8.43 87.61 9.27 66348151 0.00 0.00 ExecEvalFuncArgs + 8.12 96.54 8.93 66348151 0.00 0.00 ExecMakeFunctionResult + 2.96 99.78 3.25 66348151 0.00 0.00 ExecEvalVar + 1.23 101.14 1.36 10058 0.00 0.00 AllocSetCheck + 1.23 102.49 1.35 66348151 0.00 0.00 ExecEvalOper + 1.12 103.72 1.24 76537 0.00 0.00 OpernameGetCandidates + 0.85 104.66 0.94 66424693 0.00 0.00 int4eq + +(Note: I added LIMIT 10000 to the query so that the CASE is only carried +out 10000 times, rather than nearly 90000 times as in Arjen's original +test case. Without this, the call-counter overflows for ExecEvalExpr, +and the time percentages seem to get confused. One must recognize +though that this overstates the parser overhead compared to the original +test case.) + +Clearly the useful work (int4eq) is getting a bit swamped by the ExecEval +mechanism. I have some ideas about reducing the overhead, which I'll +post to the pghackers list in a bit. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 15 16:59:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B69CD1CAD0 + for ; + Mon, 15 Mar 2004 20:40: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 83197-02 + for ; + Mon, 15 Mar 2004 16:40:48 -0400 (AST) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 46609D1B4C3 + for ; + Mon, 15 Mar 2004 16:40:46 -0400 (AST) +Received: from ool-4353b51a.dyn.optonline.net ([67.83.181.26] helo=zeut.net) + by outbound.mailhop.org with asmtp (TLSv1:AES256-SHA:256) (Exim 4.20) + id 1B2yt3-00048O-M8; Mon, 15 Mar 2004 15:40:37 -0500 +Message-ID: <405614CA.5030101@zeut.net> +Date: Mon, 15 Mar 2004 15:40:42 -0500 +From: "Matthew T. O'Connor" +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Joe Conway +Cc: Tom Lane , + pgsql-performance , + Josh Berkus +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> + <4055F343.6070600@joeconway.com> +In-Reply-To: <4055F343.6070600@joeconway.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Report-Abuse-To: abuse@dyndns.org +X-MHO-User: zeut +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/202 +X-Sequence-Number: 6058 + +Joe Conway wrote: + +> A few pg_autovacuum questions came out of this: +> +> First, the default vacuum scaling factor is 2, which I think implies +> the big table should only get vacuumed every 56 million or so changes. +> I didn't come anywhere near that volume in my tests, yet the table did +> get vacuumed more than once (I was watching the pg_autovacuum log +> output). Do I misunderstand this setting? + + +I think you understand correctly. A table with 1,000,000 rows should +get vacuumed approx every 2,000,000 changes (assuming default values for +-V ). FYI and insert and a delete count as one change, but and update +counts as two. + +Unfortunately, the running with -d2 would show the numbers that +pg_autovacuum is using to decide if it when it should vacuum or +analyze. Also, are you sure that it vacuumed more than once and +wasn't doing analyzes most of the time? + +Also, I'm not sure if 2 is a good default value for the scaling factor +but I erred on the side of not vacuuming too often. + +> Second, Matthew requested pg_autovacuum run with -d2; I found that +> with -d2 set, pg_autovacuum would immediately exit on start. -d0 and +> -d1 work fine however. + + +That's unfortunate as that is the detail we need to see what +pg_autovacuum thinks is really going on. We had a similar sounding +crash on FreeBSD due to some unitialized variables that were being +printed out by the debug code, however that was fixed a long time ago. +Any chance you can look into this? + +> That's all I can think of at the moment. I'd like to try the 7.4 patch +> that makes vacuum sleep every few pages -- can anyone point me to the +> latest and greatest that will apply to 7.4? + + +Yes I would be very curious to see the results with the vacuum delay +patch installed (is that patch applied to HEAD?) + + + +From pgsql-performance-owner@postgresql.org Mon Mar 15 17:06:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E3D4DD1BA35 + for ; + Mon, 15 Mar 2004 21:06: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 95014-02 + for ; + Mon, 15 Mar 2004 17:05:57 -0400 (AST) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BD013D1E29B + for ; + Mon, 15 Mar 2004 17:05:54 -0400 (AST) +Received: from [134.22.71.76] (dyn-71-76.tor.dsl.tht.net [134.22.71.76]) + by tht.net (Postfix) with ESMTP + id A086276A5B; Mon, 15 Mar 2004 16:05:54 -0500 (EST) +Subject: Re: atrocious update performance +From: Rod Taylor +To: Rosser Schwarz +Cc: Postgresql Performance +In-Reply-To: <001401c40acc$1e4e7180$2500fa0a@CardServices.TCI.com> +References: <001401c40acc$1e4e7180$2500fa0a@CardServices.TCI.com> +Content-Type: text/plain +Message-Id: <1079384792.33643.4.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Mon, 15 Mar 2004 16:06:33 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/203 +X-Sequence-Number: 6059 + +> # explain update account.cust set prodid = tempprod.prodid +> where tempprod.did = origid; +> +> Merge Join (cost=0.00..232764.69 rows=4731410 width=252) +> Merge Cond: (("outer".origid)::text = ("inner".did)::text) +> -> Index Scan using ix_origid on cust (cost=0.00..94876.83 +> rows=4731410 width=244) +> -> Index Scan using ix_did on tempprod (cost=0.00..66916.71 +> rows=4731410 width=18) + +I'm going to hazard a guess and say you have a number of foreign keys +that refer to account.cust.prodid? This is probably the time consuming +part -- perhaps even a missing index on one of those keys that refers to +this field. + +Going the other way should be just as good for your purposes, and much +faster since you're not updating several foreign key'd fields bound to +account.cust.prodid. + +UPDATE tempprod.prodid = prodid + FROM account.cust + WHERE temprod.did = cust.origid; + + + +From pgsql-performance-owner@postgresql.org Mon Mar 15 17:16:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 493DED1C952 + for ; + Mon, 15 Mar 2004 21:16:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 95022-04 + for ; + Mon, 15 Mar 2004 17:15:58 -0400 (AST) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id D86B0D1D45A + for ; + Mon, 15 Mar 2004 17:15:55 -0400 (AST) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i2FLFtCj018906 + for ; Mon, 15 Mar 2004 15:15:55 -0600 +From: "Rosser Schwarz" +To: "'Postgresql Performance'" +Subject: Re: atrocious update performance +Date: Mon, 15 Mar 2004 15:15:55 -0600 +Message-ID: <001501c40ad2$b3f7ade0$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: <1079384792.33643.4.camel@jester> +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-MailScanner-From: rschwarz@totalcardinc.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/204 +X-Sequence-Number: 6060 + +> > # explain update account.cust set prodid = tempprod.prodid +> > where tempprod.did = origid; + +> > Merge Join (cost=0.00..232764.69 rows=4731410 width=252) +> > Merge Cond: (("outer".origid)::text = ("inner".did)::text) +> > -> Index Scan using ix_origid on cust (cost=0.00..94876.83 +> > rows=4731410 width=244) +> > -> Index Scan using ix_did on tempprod (cost=0.00..66916.71 +> > rows=4731410 width=18) + +> I'm going to hazard a guess and say you have a number of foreign keys +> that refer to account.cust.prodid? This is probably the time consuming +> part -- perhaps even a missing index on one of those keys +> that refers to +> this field. + +Actually, there are no foreign keys to those columns. Once they're +populated, I'll apply a foreign key constraint and they'll refer to the +appropriate row in the prod and subprod tables, but nothing will +reference account.cust.[sub]prodid. There are, of course, several foreign +keys referencing account.cust.custid. + +> Going the other way should be just as good for your purposes, and much +> faster since you're not updating several foreign key'd fields bound to +> account.cust.prodid. + +> UPDATE tempprod.prodid = prodid +> FROM account.cust +> WHERE temprod.did = cust.origid; + +Not quite. Without this update, acount.cust.[sub]prodid are null. The +data was strewn across multiple tables in MS SQL; we're normalizing it +into one, hence the need to populate the two columns independently. + +/rls + +-- +Rosser Schwarz +Total Card, Inc. + + +From pgsql-performance-owner@postgresql.org Mon Mar 15 17:29:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1405AD1D370 + for ; + Mon, 15 Mar 2004 21:29: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 01313-03 + for ; + Mon, 15 Mar 2004 17:29:55 -0400 (AST) +Received: from hotmail.com (law10-oe48.law10.hotmail.com [64.4.14.20]) + by svr1.postgresql.org (Postfix) with ESMTP id 49E67D1CCCF + for ; + Mon, 15 Mar 2004 17:29:49 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Mon, 15 Mar 2004 13:29:50 -0800 +Received: from 67.81.102.201 by law10-oe48.law10.hotmail.com with DAV; + Mon, 15 Mar 2004 21:29:50 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: "Rosser Schwarz" , + +References: <001401c40acc$1e4e7180$2500fa0a@CardServices.TCI.com> +Subject: Re: atrocious update performance +Date: Mon, 15 Mar 2004 16:29:51 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Message-ID: +X-OriginalArrivalTime: 15 Mar 2004 21:29:50.0600 (UTC) + FILETIME=[A5E7E880:01C40AD4] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/205 +X-Sequence-Number: 6061 + +Bulk updates are generally dogs (not just in pg), so I avoid doing them by +doing faster selects and inserts. You can create a new table using 'create +table as' to produce your target results. This is real fast - avoiding the +row iteration in insert, allowing the select optimizer to run and no index +overhead. Then alter/rename, add indexes and whatever else hangs off the +table (or if you're lazy do an insert/select into the original target +table). I often see 2 orders of magnitude improvement doing this, and no +need to vacuum. + +/Aaron + +----- Original Message ----- +From: "Rosser Schwarz" +To: +Sent: Monday, March 15, 2004 3:28 PM +Subject: [PERFORM] atrocious update performance + + +We're in the throes of an MS SQL to PostgreSQL migration; our databases +include a number of ~5M row tables. We decided to take this opportunity +to clean up and slightly re-normalize our schemas, given what we've +learned about the data over its lifetime and such, else we wouldn't be +experiencing any of the following (we could instead just dump and `copy +from`). + +We have a temporary table, public.tempprod, containing 4.7M rows, one +for each row in account.cust. account.cust has, among others, two +columns, prod and subprod, which we're trying to update from tempprod +joined against prod. The update tends to take unnecessarily long-- +rather, we've had to finally kill it after its taking obscenely too +long. + +The table: + +# \d account.cust + Table "account.cust" + Column | Type | Modifiers +-----------+-----------------------------+---------------------------------- +---- + custid | bigint | not null default + | | +nextval('account.custid_seq'::text) + ownerid | integer | not null + origid | text | not null + pname | text | + fname | text | + mname | text | + lname | text | + suffix | text | + addr1 | text | + addr2 | text | + addr3 | text | + city | text | + state | text | + zip | text | + zipplus | text | + homeph | text | + workph | text | + otherph | text | + ssn | text | + isactive | boolean | default true + createddt | timestamp without time zone | default now() + prodid | bigint | + subprodid | bigint | +Indexes: + "cust_pkey" primary key, btree (custid) + "ix_addr1" btree (addr1) WHERE (addr1 IS NOT NULL) + "ix_addr2" btree (addr2) WHERE (addr2 IS NOT NULL) + "ix_city" btree (city) WHERE (city IS NOT NULL) + "ix_fname" btree (fname) WHERE (fname IS NOT NULL) + "ix_homeph" btree (homeph) WHERE (homeph IS NOT NULL) + "ix_lname" btree (lname) WHERE (lname IS NOT NULL) + "ix_mname" btree (mname) WHERE (mname IS NOT NULL) + "ix_origid" btree (origid) + "ix_ssn" btree (ssn) WHERE (ssn IS NOT NULL) + "ix_state" btree (state) WHERE (state IS NOT NULL) + "ix_workph" btree (workph) WHERE (workph IS NOT NULL) + "ix_zip" btree (zip) WHERE (zip IS NOT NULL) + +We're currently running on a dual Xeon 700 (I know, I know; it's what +we've got) with 2.5GB RAM and 4x36GB SCSI in hardware RAID 5 (Dell +Perc3 something-or-other controller). If we can demonstrate that +PostgreSQL will meet our needs, we'll be going production on a dual +Opteron, maxed memory, with a 12-disk Fibre Channel array. + +The query is: + +update account.cust set prodid = +(select p.prodid from account.prod p +join public.tempprod t on t.pool = p.origid +where custid = t.did) + +And then, upon its completion, s/prod/subprod/. + +That shouldn't run overnight, should it, let alone for -days-? + +In experimenting with ways of making the updates take less time, we tried +adding product and subproduct columns to tempprod, and updating those. +That seemed to work marginally better: + +explain analyze update public.tempprod set prodid = +(select account.prod.prodid::bigint +from account.prod +where public.tempprod.pool::text = account.prod.origid::text) + +Seq Scan on tempprod (cost=0.00..9637101.35 rows 4731410 width=56) (actual +time=24273.467..16090470.438 rows=4731410 loops=1) + SubPlan + -> Limit (cost=0.00..2.02 rows=2 width=8) (actual time=0.134..0.315 + rows=1 loops=4731410) + -> Seq Scan on prod (cost=0.00..2.02 rows=2 width=8) (actual + time=0.126..0.305 rows=1 loops=4731410) + Filter: (($0)::text = (origid)::text) +Total runtime: 2284551.962 ms + +But then going from public.tempprod to account.cust again takes days. I +just cancelled an update that's been running since last Thursday. +Alas, given how long the queries take to run, I can't supply an `explain +analyze`. The `explain` seems reasonable enough: + +# explain update account.cust set prodid = tempprod.prodid +where tempprod.did = origid; + + Merge Join (cost=0.00..232764.69 rows=4731410 width=252) + Merge Cond: (("outer".origid)::text = ("inner".did)::text) + -> Index Scan using ix_origid on cust (cost=0.00..94876.83 + rows=4731410 width=244) + -> Index Scan using ix_did on tempprod (cost=0.00..66916.71 + rows=4731410 width=18) + +The relevant bits from my postgreql.conf (note, we built with a BLCKSZ +of 16K): + +shared_buffers = 4096 +sort_mem = 32768 +vacuum_mem = 32768 +wal_buffers = 16384 +checkpoint_segments = 64 +checkpoint_timeout = 1800 +checkpoint_warning = 30 +commit_delay = 50000 +effective_cache_size = 131072 + +Any advice, suggestions or comments of the "You bleeding idiot, why do +you have frob set to x?!" sort welcome. Unfortunately, if we can't +improve this, significantly, the powers what be will probably pass +on PostgreSQL, even though everything we've done so far--with this +marked exception--performs pretty spectacularly, all told. + +/rls + +-- +Rosser Schwarz +Total Card, Inc. + + +---------------------------(end of broadcast)--------------------------- +TIP 2: you can get off all lists at once with the unregister command + (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + +From pgsql-performance-owner@postgresql.org Mon Mar 15 17:47:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 90517D1CCD2 + for ; + Mon, 15 Mar 2004 21:47: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 01275-08 + for ; + Mon, 15 Mar 2004 17:46:58 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 751BDD1CCCF + for ; + Mon, 15 Mar 2004 17:46:55 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2FLksJD007888; + Mon, 15 Mar 2004 16:46:55 -0500 (EST) +To: Mike Bridge +Cc: pgsql-performance@postgresql.org +Subject: Re: High CPU with 7.4.1 after running for about 2 weeks +In-reply-to: +References: + <7304.1079219828@sss.pgh.pa.us> + +Comments: In-reply-to Mike Bridge + message dated "Sun, 14 Mar 2004 03:10:18 +0000" +Date: Mon, 15 Mar 2004 16:46:54 -0500 +Message-ID: <7887.1079387214@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/206 +X-Sequence-Number: 6062 + +Mike Bridge writes: +> But if the client dies, doesn't postgresql normally terminate the +> query that that client initiated? Or do I need to set +> statement_timeout? + +The backend generally won't notice that the connection is dead until +it next tries to fetch a command from the client. So if the client +launches a long-running query and then goes away, the query will +normally complete. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 15 17:53:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 563C0D1B4DB + for ; + Mon, 15 Mar 2004 21:53: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 06331-07 + for ; + Mon, 15 Mar 2004 17:53:57 -0400 (AST) +Received: from tht.net (vista.tht.net [216.126.88.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D32A3D1D549 + for ; + Mon, 15 Mar 2004 17:53:54 -0400 (AST) +Received: from [134.22.71.76] (dyn-71-76.tor.dsl.tht.net [134.22.71.76]) + by tht.net (Postfix) with ESMTP + id 4BAE176A43; Mon, 15 Mar 2004 16:53:57 -0500 (EST) +Subject: Re: atrocious update performance +From: Rod Taylor +To: Rosser Schwarz +Cc: 'Postgresql Performance' +In-Reply-To: <001501c40ad2$b3f7ade0$2500fa0a@CardServices.TCI.com> +References: <001501c40ad2$b3f7ade0$2500fa0a@CardServices.TCI.com> +Content-Type: text/plain +Message-Id: <1079387674.33643.12.camel@jester> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Mon, 15 Mar 2004 16:54:35 -0500 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/207 +X-Sequence-Number: 6063 + +On Mon, 2004-03-15 at 16:15, Rosser Schwarz wrote: +> > > # explain update account.cust set prodid = tempprod.prodid +> > > where tempprod.did = origid; +> +> > > Merge Join (cost=0.00..232764.69 rows=4731410 width=252) +> > > Merge Cond: (("outer".origid)::text = ("inner".did)::text) +> > > -> Index Scan using ix_origid on cust (cost=0.00..94876.83 +> > > rows=4731410 width=244) +> > > -> Index Scan using ix_did on tempprod (cost=0.00..66916.71 +> > > rows=4731410 width=18) +> +> > I'm going to hazard a guess and say you have a number of foreign keys +> > that refer to account.cust.prodid? This is probably the time consuming +> > part -- perhaps even a missing index on one of those keys +> > that refers to +> > this field. +> +> Actually, there are no foreign keys to those columns. Once they're +> populated, I'll apply a foreign key constraint and they'll refer to the +> appropriate row in the prod and subprod tables, but nothing will +> reference account.cust.[sub]prodid. There are, of course, several foreign +> keys referencing account.cust.custid. + +If there are no feign keys to it, I wouldn't expect it to take more than +10 minutes on slow hardware. + +Fresh out of ideas here. + + + +From pgsql-performance-owner@postgresql.org Mon Mar 15 18:51:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 075C5D1DC7C + for ; + Mon, 15 Mar 2004 22:51: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 23350-06 + for ; + Mon, 15 Mar 2004 18:51:34 -0400 (AST) +Received: from commsecure.com.au (CommSecureAustPtyLtd.sb1.optus.net.au + [203.202.148.106]) + by svr1.postgresql.org (Postfix) with ESMTP id E2043D1DCF1 + for ; + Mon, 15 Mar 2004 18:50:38 -0400 (AST) +Received: from [172.16.15.13] (ws12.commsecure.com.au [172.16.15.13]) + by commsecure.com.au (8.11.6/8.11.6) with ESMTP id i2FMloV27922; + Tue, 16 Mar 2004 09:47:50 +1100 +Subject: Re: Scaling further up +From: Stephen Robert Norris +To: Matt Davies +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1079382515.405611f35f1c5@www.mattdavies.net> +References: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF785098062@vt-pe2550-001.vantage.vantage.com> + <20040315200930.GA2921@phlogiston.dyndns.org> + <1079382515.405611f35f1c5@www.mattdavies.net> +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-4aDSe6bRa4NC7STN9+JI" +Organization: CommSecure Australia Pty Ltd +Message-Id: <1079390869.1256.1.camel@ws12.commsecure.com.au> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) +Date: Tue, 16 Mar 2004 09:47:50 +1100 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/208 +X-Sequence-Number: 6064 + +--=-4aDSe6bRa4NC7STN9+JI +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Tue, 2004-03-16 at 07:28, Matt Davies wrote: +> This is the preferred method, but you could create a memory disk if runni= +ng +> linux. This has several caveats, though. +>=20 +> 1. You may have to recompile the kernel for support. +> 2. You must store the database on a hard drive partition during reboots. +> 3. Because of #2 this option is generally useful if you have static conte= +nt that +> is loaded to the MD upon startup of the system.=20 + +And 4. You use twice as much memory - one lot for the FS, the second for +buffer cache. + +It's generally going to be slower than simply doing some typical queries +to preload the data into buffer cache, I think. + + Stephen + +--=-4aDSe6bRa4NC7STN9+JI +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.3 (GNU/Linux) + +iD8DBQBAVjKU4hFS2REFUecRAm1lAJ44t0kEDBmrllTwztxR/UUbt508EQCfd1e3 +mHvjrlE4yzXvrkAu9D4ETLE= +=wMCo +-----END PGP SIGNATURE----- + +--=-4aDSe6bRa4NC7STN9+JI-- + + +From pgsql-performance-owner@postgresql.org Mon Mar 15 19:20:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EC720D1E295 + for ; + Mon, 15 Mar 2004 23:20: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 32244-10 + for ; + Mon, 15 Mar 2004 19:20:34 -0400 (AST) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 876F2D1E17C + for ; + Mon, 15 Mar 2004 19:20:31 -0400 (AST) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i2FNKWCj024548 + for ; Mon, 15 Mar 2004 17:20:32 -0600 +From: "Rosser Schwarz" +To: +Subject: Re: atrocious update performance +Date: Mon, 15 Mar 2004 17:20:32 -0600 +Message-ID: <001a01c40ae4$1cdd4160$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-MailScanner-From: rschwarz@totalcardinc.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=BAYES_44, + RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200403/209 +X-Sequence-Number: 6065 + +> You can create a new table using 'create table as' to produce your +> target results. This is real fast ... +> I often see 2 orders of magnitude improvement doing this, and no +> need to vacuum. + +Indeed: + +"Query returned successfully with no result in 582761 ms." + +Though I must say, ten minutes is nominally more than two orders of +mangitude performance improvement, versus several days. + +Many thanks, Aaron. + +/rls + +-- +Rosser Schwarz +Total Card, Inc. + + +From pgsql-performance-owner@postgresql.org Mon Mar 15 20:08:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4B9F1D1BACC + for ; + Tue, 16 Mar 2004 00:08:26 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 47697-04 + for ; + Mon, 15 Mar 2004 20:08:21 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 0181AD1E2AA + for ; + Mon, 15 Mar 2004 20:08:17 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2G08Ko0008913; + Mon, 15 Mar 2004 19:08:20 -0500 (EST) +To: "Rosser Schwarz" +Cc: pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +In-reply-to: <001a01c40ae4$1cdd4160$2500fa0a@CardServices.TCI.com> +References: <001a01c40ae4$1cdd4160$2500fa0a@CardServices.TCI.com> +Comments: In-reply-to "Rosser Schwarz" + message dated "Mon, 15 Mar 2004 17:20:32 -0600" +Date: Mon, 15 Mar 2004 19:08:19 -0500 +Message-ID: <8912.1079395699@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/210 +X-Sequence-Number: 6066 + +"Rosser Schwarz" writes: +>> You can create a new table using 'create table as' to produce your +>> target results. This is real fast ... +>> I often see 2 orders of magnitude improvement doing this, and no +>> need to vacuum. + +> Indeed: +> "Query returned successfully with no result in 582761 ms." +> Though I must say, ten minutes is nominally more than two orders of +> mangitude performance improvement, versus several days. + +Hm. There is no way that inserting a row is two orders of magnitude +faster than updating a row --- they both require storing a new row and +making whatever index entries are needed. The only additional cost of +the update is finding the old row (not a very big deal AFAICS in the +examples you gave) and marking it deleted (definitely cheap). So +there's something awfully fishy going on here. + +I'm inclined to suspect an issue with foreign-key checking. You didn't +give us any details about foreign key relationships your "cust" table is +involved in --- could we see those? And the schemas of the other tables +involved? + +Also, exactly which PG version is this? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 15 22:42:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 098A1D1E128 + for ; + Tue, 16 Mar 2004 02:42: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 82012-06 + for ; + Mon, 15 Mar 2004 22:42:11 -0400 (AST) +Received: from hotmail.com (law10-oe54.law10.hotmail.com [64.4.14.47]) + by svr1.postgresql.org (Postfix) with ESMTP id 4AB48D1D2F7 + for ; + Mon, 15 Mar 2004 22:42:07 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Mon, 15 Mar 2004 18:42:07 -0800 +Received: from 67.81.102.201 by law10-oe54.law10.hotmail.com with DAV; + Tue, 16 Mar 2004 02:42:07 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: "Rosser Schwarz" , + "Tom Lane" +Cc: +References: <001a01c40ae4$1cdd4160$2500fa0a@CardServices.TCI.com> + <8912.1079395699@sss.pgh.pa.us> +Subject: Re: atrocious update performance +Date: Mon, 15 Mar 2004 21:42:09 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Message-ID: +X-OriginalArrivalTime: 16 Mar 2004 02:42:07.0805 (UTC) + FILETIME=[46267ED0:01C40B00] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/211 +X-Sequence-Number: 6067 + +The original point was about a very slow update of an entire table with a +plan that looped, and over a dozen conditional indices - vs. a 'create as' +in a CPU starved environment. I stand by my statement about observing the +orders of magnitude difference. In theory I agree that the update should be +in the same order of magnitude as the create as, but in practice I disagree. +I also think something is wrong on the logical side (besides FKs, are there +any triggers?) but was responding to the Gordian knot issue of bailing out +of pg. + +Can you post a sample extract, Rosser? Otherwise, I'll try to put together a +sample of a slow mass join update. + +/Aaron + +----- Original Message ----- +From: "Tom Lane" +To: "Rosser Schwarz" +Cc: +Sent: Monday, March 15, 2004 7:08 PM +Subject: Re: [PERFORM] atrocious update performance + + +> "Rosser Schwarz" writes: +> >> You can create a new table using 'create table as' to produce your +> >> target results. This is real fast ... +> >> I often see 2 orders of magnitude improvement doing this, and no +> >> need to vacuum. +> +> > Indeed: +> > "Query returned successfully with no result in 582761 ms." +> > Though I must say, ten minutes is nominally more than two orders of +> > mangitude performance improvement, versus several days. +> +> Hm. There is no way that inserting a row is two orders of magnitude +> faster than updating a row --- they both require storing a new row and +> making whatever index entries are needed. The only additional cost of +> the update is finding the old row (not a very big deal AFAICS in the +> examples you gave) and marking it deleted (definitely cheap). So +> there's something awfully fishy going on here. +> +> I'm inclined to suspect an issue with foreign-key checking. You didn't +> give us any details about foreign key relationships your "cust" table is +> involved in --- could we see those? And the schemas of the other tables +> involved? +> +> Also, exactly which PG version is this? +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + +From pgsql-performance-owner@postgresql.org Tue Mar 16 01:00:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0F85DD1E317 + for ; + Tue, 16 Mar 2004 05: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 17411-06 + for ; + Tue, 16 Mar 2004 01:00:16 -0400 (AST) +Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 1AD6FD1D63E + for ; + Tue, 16 Mar 2004 01:00:15 -0400 (AST) +Received: from [192.168.5.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1086897; Mon, 15 Mar 2004 20:55:39 -0800 +Message-ID: <405689A4.4080406@joeconway.com> +Date: Mon, 15 Mar 2004 20:59:16 -0800 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Matthew T. O'Connor" +Cc: Tom Lane , + pgsql-performance , + Josh Berkus +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> + <4055F343.6070600@joeconway.com> <405614CA.5030101@zeut.net> +In-Reply-To: <405614CA.5030101@zeut.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: 200403/212 +X-Sequence-Number: 6068 + +Matthew T. O'Connor wrote: +> I think you understand correctly. A table with 1,000,000 rows should +> get vacuumed approx every 2,000,000 changes (assuming default values for +> -V ). FYI and insert and a delete count as one change, but and update +> counts as two. +> +> Unfortunately, the running with -d2 would show the numbers that +> pg_autovacuum is using to decide if it when it should vacuum or +> analyze. Also, are you sure that it vacuumed more than once and +> wasn't doing analyzes most of the time? + +Yeah, I'm sure. Snippets from the log: + +[...lots-o-tables...] +[2004-03-14 12:44:48 PM] added table: specdb."public"."parametric_states" +[2004-03-14 12:49:48 PM] Performing: VACUUM ANALYZE +"public"."transaction_data" +[2004-03-14 01:29:59 PM] Performing: VACUUM ANALYZE +"public"."transaction_data" +[2004-03-14 02:08:26 PM] Performing: ANALYZE "public"."out_of_spec" +[2004-03-14 02:08:26 PM] Performing: VACUUM ANALYZE +"public"."transaction_data" +[2004-03-14 02:22:44 PM] Performing: VACUUM ANALYZE "public"."spc_graphs" +[2004-03-14 03:06:45 PM] Performing: VACUUM ANALYZE "public"."out_of_spec" +[2004-03-14 03:06:45 PM] Performing: VACUUM ANALYZE +"public"."transaction_data" +[2004-03-14 03:19:51 PM] Performing: VACUUM ANALYZE "public"."spc_graphs" +[2004-03-14 03:21:09 PM] Performing: ANALYZE "public"."parametric_states" +[2004-03-14 03:54:57 PM] Performing: ANALYZE "public"."out_of_spec" +[2004-03-14 03:54:57 PM] Performing: VACUUM ANALYZE +"public"."transaction_data" +[2004-03-14 04:07:52 PM] Performing: VACUUM ANALYZE "public"."spc_graphs" +[2004-03-14 04:09:33 PM] Performing: ANALYZE "public"."equip_status_history" +[2004-03-14 04:09:33 PM] Performing: VACUUM ANALYZE +"public"."parametric_states" +[2004-03-14 04:43:46 PM] Performing: VACUUM ANALYZE "public"."out_of_spec" +[2004-03-14 04:43:46 PM] Performing: VACUUM ANALYZE +"public"."transaction_data" +[2004-03-14 04:56:35 PM] Performing: VACUUM ANALYZE "public"."spc_graphs" +[2004-03-14 04:58:32 PM] Performing: ANALYZE "public"."parametric_states" +[2004-03-14 05:28:58 PM] added database: specdb + +This is the entire period of the first test, with default autovac +settings. The table "public"."transaction_data" is the one with 28 +million active rows. The entire test run inserts about 600 x 600 = +360,000 rows, out of which roughly two-thirds are later deleted. + +> That's unfortunate as that is the detail we need to see what +> pg_autovacuum thinks is really going on. We had a similar sounding +> crash on FreeBSD due to some unitialized variables that were being +> printed out by the debug code, however that was fixed a long time ago. +> Any chance you can look into this? + +I can try. The server belongs to another department, and they are under +the gun to get back on track with their testing. Also, they compiled +without debug symbols, so I need to get permission to recompile. + +> Yes I would be very curious to see the results with the vacuum delay +> patch installed (is that patch applied to HEAD?) + +Any idea where I can get my hands on the latest version. I found the +original post from Tom, but I thought there was a later version with +both number of pages and time to sleep as knobs. + +Thanks, + +Joe + +From pgsql-performance-owner@postgresql.org Tue Mar 16 01:25:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ABAB7D1D370 + for ; + Tue, 16 Mar 2004 05:25:29 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17642-10 + for ; + Tue, 16 Mar 2004 01:25:28 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id AA083D1B9BC + for ; + Tue, 16 Mar 2004 01:25:27 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2G5PNE4016736; + Tue, 16 Mar 2004 00:25:23 -0500 (EST) +To: Joe Conway +Cc: "Matthew T. O'Connor" , + pgsql-performance , + Josh Berkus +Subject: Re: rapid degradation after postmaster restart +In-reply-to: <405689A4.4080406@joeconway.com> +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> + <4055F343.6070600@joeconway.com> <405614CA.5030101@zeut.net> + <405689A4.4080406@joeconway.com> +Comments: In-reply-to Joe Conway + message dated "Mon, 15 Mar 2004 20:59:16 -0800" +Date: Tue, 16 Mar 2004 00:25:23 -0500 +Message-ID: <16735.1079414723@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/213 +X-Sequence-Number: 6069 + +Joe Conway writes: +> Any idea where I can get my hands on the latest version. I found the +> original post from Tom, but I thought there was a later version with +> both number of pages and time to sleep as knobs. + +That was as far as I got. I think Jan posted a more complex version +that would still be reasonable to apply to 7.4. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 16 01:32:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0702FD1C969 + for ; + Tue, 16 Mar 2004 05: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 22059-08 + for ; + Tue, 16 Mar 2004 01:32:35 -0400 (AST) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 29D0DD1B9BC + for ; + Tue, 16 Mar 2004 01:32:34 -0400 (AST) +Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] helo=zeut.net) + by outbound.mailhop.org with asmtp (TLSv1:AES256-SHA:256) (Exim 4.20) + id 1B37Bo-0005kv-VO; Tue, 16 Mar 2004 00:32:33 -0500 +Message-ID: <4056916B.5090204@zeut.net> +Date: Tue, 16 Mar 2004 00:32:27 -0500 +From: "Matthew T. O'Connor" +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Joe Conway +Cc: Tom Lane , + pgsql-performance , + Josh Berkus +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> + <4055F343.6070600@joeconway.com> <405614CA.5030101@zeut.net> + <405689A4.4080406@joeconway.com> +In-Reply-To: <405689A4.4080406@joeconway.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Report-Abuse-To: abuse@dyndns.org +X-MHO-User: zeut +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/214 +X-Sequence-Number: 6070 + +Joe Conway wrote: + +> Yeah, I'm sure. Snippets from the log: +> +> [...lots-o-tables...] +> [2004-03-14 12:44:48 PM] added table: specdb."public"."parametric_states" +> [2004-03-14 12:49:48 PM] Performing: VACUUM ANALYZE +> "public"."transaction_data" +> [2004-03-14 01:29:59 PM] Performing: VACUUM ANALYZE +> "public"."transaction_data" +> [2004-03-14 02:08:26 PM] Performing: ANALYZE "public"."out_of_spec" +> [2004-03-14 02:08:26 PM] Performing: VACUUM ANALYZE +> "public"."transaction_data" +> [2004-03-14 02:22:44 PM] Performing: VACUUM ANALYZE "public"."spc_graphs" +> [2004-03-14 03:06:45 PM] Performing: VACUUM ANALYZE +> "public"."out_of_spec" +> [2004-03-14 03:06:45 PM] Performing: VACUUM ANALYZE +> "public"."transaction_data" +> [2004-03-14 03:19:51 PM] Performing: VACUUM ANALYZE "public"."spc_graphs" +> [2004-03-14 03:21:09 PM] Performing: ANALYZE "public"."parametric_states" +> [2004-03-14 03:54:57 PM] Performing: ANALYZE "public"."out_of_spec" +> [2004-03-14 03:54:57 PM] Performing: VACUUM ANALYZE +> "public"."transaction_data" +> [2004-03-14 04:07:52 PM] Performing: VACUUM ANALYZE "public"."spc_graphs" +> [2004-03-14 04:09:33 PM] Performing: ANALYZE +> "public"."equip_status_history" +> [2004-03-14 04:09:33 PM] Performing: VACUUM ANALYZE +> "public"."parametric_states" +> [2004-03-14 04:43:46 PM] Performing: VACUUM ANALYZE +> "public"."out_of_spec" +> [2004-03-14 04:43:46 PM] Performing: VACUUM ANALYZE +> "public"."transaction_data" +> [2004-03-14 04:56:35 PM] Performing: VACUUM ANALYZE "public"."spc_graphs" +> [2004-03-14 04:58:32 PM] Performing: ANALYZE "public"."parametric_states" +> [2004-03-14 05:28:58 PM] added database: specdb + + +Yeah, you're right..... + +> This is the entire period of the first test, with default autovac +> settings. The table "public"."transaction_data" is the one with 28 +> million active rows. The entire test run inserts about 600 x 600 = +> 360,000 rows, out of which roughly two-thirds are later deleted. + + +Strange... I wonder if this is some integer overflow problem. There was +one reported recently and fixed as of CVS head yesterday, you might try +that, however without the -d2 output I'm only guessing at why +pg_autovacuum is vacuuming so much / so often. + +> I can try. The server belongs to another department, and they are +> under the gun to get back on track with their testing. Also, they +> compiled without debug symbols, so I need to get permission to recompile. + + +Good luck, I hope you can get permission. Would e nice to fix this +little crash. + +>> Yes I would be very curious to see the results with the vacuum delay +>> patch installed (is that patch applied to HEAD?) +> +> +> Any idea where I can get my hands on the latest version. I found the +> original post from Tom, but I thought there was a later version with +> both number of pages and time to sleep as knobs. + + +I think Jan posted one a while back.... [searches archives...] But I +must say I'm at a loss to find it in the archives. Anyone know where a +good delay patch is for 7.4? If we can't find one, any chance you can +do some testing with CVS HEAD just to see if that works any better. I +know there has been a fair amount of work done to improve this situation +(not just vacuum delay, but ARC etc...) +. + +From pgsql-performance-owner@postgresql.org Tue Mar 16 01:39:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EAFBD1C969 + for ; + Tue, 16 Mar 2004 05:39: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 23064-06 + for ; + Tue, 16 Mar 2004 01:39:03 -0400 (AST) +Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 65AD5D1B9BC + for ; + Tue, 16 Mar 2004 01:39:02 -0400 (AST) +Received: from [192.168.5.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1086929; Mon, 15 Mar 2004 21:34:27 -0800 +Message-ID: <405692BB.1020905@joeconway.com> +Date: Mon, 15 Mar 2004 21:38:03 -0800 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: "Matthew T. O'Connor" , + pgsql-performance , + Josh Berkus +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> + <4055F343.6070600@joeconway.com> <405614CA.5030101@zeut.net> + <405689A4.4080406@joeconway.com> <16735.1079414723@sss.pgh.pa.us> +In-Reply-To: <16735.1079414723@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: 200403/215 +X-Sequence-Number: 6071 + +Tom Lane wrote: +> Joe Conway writes: +>>Any idea where I can get my hands on the latest version. I found the +>>original post from Tom, but I thought there was a later version with +>>both number of pages and time to sleep as knobs. +> +> That was as far as I got. I think Jan posted a more complex version +> that would still be reasonable to apply to 7.4. + +I thought that too, but was having trouble finding it. I'll look again. + +Thanks, + +Joe + + +From pgsql-performance-owner@postgresql.org Tue Mar 16 01:49:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B87B6D1DD14 + for ; + Tue, 16 Mar 2004 05:49: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 23822-07 + for ; + Tue, 16 Mar 2004 01:49:05 -0400 (AST) +Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) + by svr1.postgresql.org (Postfix) with ESMTP id BD914D1D2DC + for ; + Tue, 16 Mar 2004 01:49:03 -0400 (AST) +Received: from [192.168.5.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1086938; Mon, 15 Mar 2004 21:44:28 -0800 +Message-ID: <40569515.70902@joeconway.com> +Date: Mon, 15 Mar 2004 21:48:05 -0800 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Matthew T. O'Connor" +Cc: Tom Lane , + pgsql-performance , + Josh Berkus +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> + <4055F343.6070600@joeconway.com> <405614CA.5030101@zeut.net> + <405689A4.4080406@joeconway.com> <4056916B.5090204@zeut.net> +In-Reply-To: <4056916B.5090204@zeut.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: 200403/216 +X-Sequence-Number: 6072 + +Matthew T. O'Connor wrote: +> Strange... I wonder if this is some integer overflow problem. There was +> one reported recently and fixed as of CVS head yesterday, you might try +> that, however without the -d2 output I'm only guessing at why +> pg_autovacuum is vacuuming so much / so often. + +I'll see what I can do tomorrow to track it down. + +I have already recommended to the program manager that they switch to +7.4.2 plus the autovacuum patch. Not sure they will be willing to make +any changes at this stage in their release process though. + +> If we can't find one, any chance you can +> do some testing with CVS HEAD just to see if that works any better. I +> know there has been a fair amount of work done to improve this situation +> (not just vacuum delay, but ARC etc...) + +I might do that, but not likely on Solaris. I can probably get a copy of +the current database and testing scripts, and give it a try on one of my +own machines (all Linux, either RHAS3, RH9, or Fedora). + +Joe + + +From pgsql-hackers-owner@postgresql.org Tue Mar 16 03:12:44 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3E03FD1E2E2 + for ; + Tue, 16 Mar 2004 07:12: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 45614-04 + for ; + Tue, 16 Mar 2004 03:12:37 -0400 (AST) +Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) + by svr1.postgresql.org (Postfix) with ESMTP id A47DFD1E2AA + for ; + Tue, 16 Mar 2004 03:12:35 -0400 (AST) +Received: from [206.19.64.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1087007; Mon, 15 Mar 2004 23:08:01 -0800 +Message-ID: <4056A8A7.4060208@joeconway.com> +Date: Mon, 15 Mar 2004 23:11:35 -0800 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Matthew T. O'Connor" +Cc: Tom Lane , + pgsql-hackers , + Josh Berkus +Subject: Re: [PERFORM] rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> + <4055F343.6070600@joeconway.com> <405614CA.5030101@zeut.net> + <405689A4.4080406@joeconway.com> <4056916B.5090204@zeut.net> +In-Reply-To: <4056916B.5090204@zeut.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: 200403/709 +X-Sequence-Number: 51301 + +[moving to hackers] + +Matthew T. O'Connor wrote: +> Good luck, I hope you can get permission. Would e nice to fix this +> little crash. + +I went ahead and recompiled with --enable-debug, and get this trace: + +#0 0xfefb3218 in strlen () from /usr/lib/libc.so.1 +#1 0xff006520 in _doprnt () from /usr/lib/libc.so.1 +#2 0xff0082e8 in sprintf () from /usr/lib/libc.so.1 +#3 0x1213c in print_db_info (dbi=0x28980, print_tbl_list=0) + at pg_autovacuum.c:681 +#4 0x120fc in print_db_list (db_list=0x25f80, print_table_lists=0) + at pg_autovacuum.c:673 +#5 0x11b44 in init_db_list () at pg_autovacuum.c:416 +#6 0x12c58 in main (argc=154384, argv=0xff043a54) at pg_autovacuum.c:1007 + +Line 681 is this: + sprintf(logbuffer, "dbname: %s Username %s Passwd %s", + dbi->dbname, dbi->username, dbi->password); + +It appears that dbi->password is a null pointer: +(gdb) print dbi->dbname +$1 = 0x25f68 "template1" +(gdb) print dbi->username +$2 = 0x25b20 "dba" +(gdb) print dbi->password +$3 = 0x0 + +Problem is, since this is a development machine, they have everything +set to "trust" in pg_hba.conf. I added a "-P foo" to the command line, +and it starts up fine now. + +HTH, + +Joe + +From pgsql-performance-owner@postgresql.org Tue Mar 16 03:31:10 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C4B07D1E128 + for ; + Tue, 16 Mar 2004 07: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 42912-10 + for ; + Tue, 16 Mar 2004 03:31:07 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id E8EB5D1D2DC + for ; + Tue, 16 Mar 2004 03:31:05 -0400 (AST) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id D036617C129; Tue, 16 Mar 2004 02:31:06 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1B392Y-0001vJ-00; Tue, 16 Mar 2004 02:31:06 -0500 +To: "Rosser Schwarz" +Cc: "'Postgresql Performance'" +Subject: Re: atrocious update performance +References: <001501c40ad2$b3f7ade0$2500fa0a@CardServices.TCI.com> +In-Reply-To: <001501c40ad2$b3f7ade0$2500fa0a@CardServices.TCI.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 16 Mar 2004 02:31:06 -0500 +Message-ID: <871xnt1c5h.fsf@stark.xeocode.com> +Lines: 22 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/217 +X-Sequence-Number: 6073 + + +"Rosser Schwarz" writes: + +> Actually, there are no foreign keys to those columns. Once they're +> populated, I'll apply a foreign key constraint and they'll refer to the +> appropriate row in the prod and subprod tables, but nothing will +> reference account.cust.[sub]prodid. There are, of course, several foreign +> keys referencing account.cust.custid. + +Just to be clear, the foreign key constraints they're worrying about are not +constraints on the table you're updating. They're constraints on other tables +referring to the table you're updating. + +Since you're updating the column here postgres has to be sure nothing is +referring to the old value you're obliterating, and to do that it has to +select for possible records in the referencing tables referring to the value. +If there are any references in other tables referring to this column then you +need an index on the column in the referencing table to be able to update the +column in referenced table efficiently. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Tue Mar 16 03:39:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DCA06D1D851 + for ; + Tue, 16 Mar 2004 07:38: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 49688-06 + for ; + Tue, 16 Mar 2004 03:38:56 -0400 (AST) +Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) + by svr1.postgresql.org (Postfix) with ESMTP id EAD0FD1D370 + for ; + Tue, 16 Mar 2004 03:38:54 -0400 (AST) +Received: from concord.pspl.co.in ([202.54.11.72]:62790 helo=frodo.hserus.net) + by frodo.hserus.net with asmtp + (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.30 #2) + id 1B39A5-000Bqp-Ph by authid with plain; + Tue, 16 Mar 2004 13:08:54 +0530 +Message-ID: <4056AF09.9030003@frodo.hserus.net> +Date: Tue, 16 Mar 2004 13:08:49 +0530 +From: Shridhar Daithankar +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: Rosser Schwarz +Cc: pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +References: <001401c40acc$1e4e7180$2500fa0a@CardServices.TCI.com> +In-Reply-To: <001401c40acc$1e4e7180$2500fa0a@CardServices.TCI.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: 200403/218 +X-Sequence-Number: 6074 + +Rosser Schwarz wrote: + + > shared_buffers = 4096 +> sort_mem = 32768 +> vacuum_mem = 32768 +> wal_buffers = 16384 +> checkpoint_segments = 64 +> checkpoint_timeout = 1800 +> checkpoint_warning = 30 +> commit_delay = 50000 +> effective_cache_size = 131072 + +You didn't mention the OS so I would take it as either linux/freeBSD. + +First of all, your shared buffers are low. 4096 is 64MB with 16K block size. I +would say at least push them to 150-200MB. + +Secondly your sort mem is too high. Note that it is per sort per query. You +could build a massive swap storm with such a setting. + +Similarly pull down vacuum and WAL buffers to around 512-1024 each. + +I know that your problem is solved by using insert rather than updates. But I +just want to point out that you still need to analyze the table to update the +statistics or the further queres will not be exactly good. + +And lastly, you can bundle entire thing including creating duplicate table, +populating it, renaming original table etc in a single transaction and nobody +will notice it. I am almost sure MS-SQL can not do that. Not many databases have +trasact-safe DDLs out there.. + + HTH + + Shridhar + +From pgsql-performance-owner@postgresql.org Tue Mar 16 11:25:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 28437D1B9BC + for ; + Tue, 16 Mar 2004 15:25: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 12386-01 + for ; + Tue, 16 Mar 2004 11:25:39 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 18C7CD1B8EA + for ; + Tue, 16 Mar 2004 11:25:35 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2GFPZVJ024847; + Tue, 16 Mar 2004 10:25:36 -0500 (EST) +To: Shridhar Daithankar +Cc: Rosser Schwarz , + pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +In-reply-to: <4056AF09.9030003@frodo.hserus.net> +References: <001401c40acc$1e4e7180$2500fa0a@CardServices.TCI.com> + <4056AF09.9030003@frodo.hserus.net> +Comments: In-reply-to Shridhar Daithankar + message dated "Tue, 16 Mar 2004 13:08:49 +0530" +Date: Tue, 16 Mar 2004 10:25:35 -0500 +Message-ID: <24846.1079450735@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/219 +X-Sequence-Number: 6075 + +Shridhar Daithankar writes: +> Rosser Schwarz wrote: +>> shared_buffers = 4096 +>> sort_mem = 32768 +>> vacuum_mem = 32768 +>> wal_buffers = 16384 +>> checkpoint_segments = 64 +>> checkpoint_timeout = 1800 +>> checkpoint_warning = 30 +>> commit_delay = 50000 +>> effective_cache_size = 131072 + +> First of all, your shared buffers are low. 4096 is 64MB with 16K block +> size. I would say at least push them to 150-200MB. + +Check. Much more than that isn't necessarily better though. +shared_buffers = 10000 is frequently mentioned as a "sweet spot". + +> Secondly your sort mem is too high. Note that it is per sort per query. You +> could build a massive swap storm with such a setting. + +Agreed, but I doubt that has anything to do with the immediate +problem, since he's not testing parallel queries. + +> Similarly pull down vacuum and WAL buffers to around 512-1024 each. + +The vacuum_mem setting here is 32Mb, which seems okay to me, if not on +the low side. Again though it's not his immediate problem. + +I agree that the wal_buffers setting is outlandishly large; I can't see +any plausible reason for it to be more than a few dozen. I don't know +whether oversized wal_buffers can directly cause any performance issues, +but it's certainly not a well-tested scenario. + +The other setting I was going to comment on is checkpoint_warning; +it seems mighty low in comparison to checkpoint_timeout. If you are +targeting a checkpoint every half hour, I'd think you'd want the system +to complain about checkpoints spaced more closely than several minutes. + +But with the possible exception of wal_buffers, I can't see anything in +these settings that explains the originally complained-of performance +problem. I'm still wondering about foreign key checks. + + regards, tom lane + +From pgsql-hackers-owner@postgresql.org Tue Mar 16 11:50:36 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C275D1B91B + for ; + Tue, 16 Mar 2004 15:50: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 12289-05 + for ; + Tue, 16 Mar 2004 11:50:25 -0400 (AST) +Received: from dezeut.zeut.net (ool-4352919e.dyn.optonline.net + [67.82.145.158]) + by svr1.postgresql.org (Postfix) with ESMTP id B5605D1E2CA + for ; + Tue, 16 Mar 2004 11:50:20 -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 i2GFo7TH026955; + Tue, 16 Mar 2004 10:50:07 -0500 +Received: (from apache@localhost) + by dezeut.zeut.net (8.12.8/8.12.8/Submit) id i2GFo69o026953; + Tue, 16 Mar 2004 10:50:06 -0500 +X-Authentication-Warning: dezeut.zeut.net: apache set sender to + matthew@zeut.net using -f +Received: from 192.154.91.225 (SquirrelMail authenticated user dbmailtest) + by matth.zeut.net with HTTP; Tue, 16 Mar 2004 10:50:06 -0500 (EST) +Message-ID: <12158.192.154.91.225.1079452206.squirrel@matth.zeut.net> +Date: Tue, 16 Mar 2004 10:50:06 -0500 (EST) +Subject: Re: [PERFORM] rapid degradation after postmaster restart +From: "Matthew T. O'Connor" +To: +In-Reply-To: <4056A8A7.4060208@joeconway.com> +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> + <4055F343.6070600@joeconway.com> <405614CA.5030101@zeut.net> + <405689A4.4080406@joeconway.com> <4056916B.5090204@zeut.net> + <4056A8A7.4060208@joeconway.com> +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-Spam-Status: No, hits=1.4 tagged_above=0.0 required=5.0 tests=BAYES_00, + RCVD_IN_DYNABLOCK, RCVD_IN_NJABL, RCVD_IN_NJABL_DIALUP, RCVD_IN_SORBS +X-Spam-Level: * +X-Archive-Number: 200403/725 +X-Sequence-Number: 51317 + +> [moving to hackers] +> +> Line 681 is this: +> sprintf(logbuffer, "dbname: %s Username %s Passwd %s", +> dbi->dbname, dbi->username, dbi->password); +> +> It appears that dbi->password is a null pointer: +> (gdb) print dbi->dbname +> $1 = 0x25f68 "template1" +> (gdb) print dbi->username +> $2 = 0x25b20 "dba" +> (gdb) print dbi->password +> $3 = 0x0 +> +> Problem is, since this is a development machine, they have everything +> set to "trust" in pg_hba.conf. I added a "-P foo" to the command line, +> and it starts up fine now. + +Ok, that is about what I figured the problem would be. I will try to take +a look at this soon and submit a patch. However since you can work around +it now, can you do another test run with -d2? + +Thanks for tracking this down. + +Matthew + + + + +From pgsql-performance-owner@postgresql.org Tue Mar 16 13:33:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D3E45D1E93E + for ; + Tue, 16 Mar 2004 17:33: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 57300-06 + for ; + Tue, 16 Mar 2004 13:33:03 -0400 (AST) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 453F3D1E936 + for ; + Tue, 16 Mar 2004 13:33:02 -0400 (AST) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i2GHWuDx012962 + for ; Tue, 16 Mar 2004 11:32:56 -0600 +From: "Rosser Schwarz" +To: +Subject: Re: atrocious update performance +Date: Tue, 16 Mar 2004 11:32:56 -0600 +Message-ID: <001d01c40b7c$b80c98a0$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: <24846.1079450735@sss.pgh.pa.us> +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-MailScanner-From: rschwarz@totalcardinc.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/220 +X-Sequence-Number: 6076 + +while you weren't looking, Tom Lane wrote: + +> But with the possible exception of wal_buffers, I can't see=20 +> anything in +> these settings that explains the originally complained-of performance +> problem. I'm still wondering about foreign key checks. + +Many of the configs I posted were fairly wild values, set to gather +data points for further tweaking. Unfortunately, with this query +there hasn't been time for many passes, and I've too much else on my +plate to try concocting demonstration cases. The postmaster's been +hupped with more sane values, but I experienced this same issue with +the defaults. + +As for foreign keys, three tables refer to account.cust; all of them +refer to account.cust.custid, the pk. One of those tables has several +hundred thousand rows, many more to come; the others are empty. Unless +I've woefully misunderstood, the presence or absence of a foreign key +referring to one column should be moot for updates writing another +column, shouldn't it? + +To answer your (and others') question, Tom, 7.4.1 on 2.4.20-18.9smp. +Red Hat, I believe. I was handed the machine, which is also in use +for lightweight production stuff: intranet webserver, rinky-dink +MySQL doo-dads, &c. I'm sure that has an impact, usurping the disk +heads and such--maybe even more than I'd expect--but I can't imagine +that'd cause an update to one 4.7M row table, from another 4.7M row +table, both clustered on a join column that maps one-to-one between +them, to take days. I'm baffled; everything else is perfectly snappy, +given the hardware. Anything requiring a sequential scan over one of +the big tables is a slog, but that's to be expected and hence all the +indices. + +Watching iostat, I've observed a moderately cyclic read-big, write- +big pattern, wavelengths generally out of phase, interspersed with +smaller, almost epicycles--from the machine's other tasks, I'm sure. +top has postmaster's cpu usage rarely breaking 25% over the course +of the query's execution, and spending most of its time much lower; +memory usage hovers somewhere north of 500MB. + +In what little time I had to stare at a disturbingly matrix-esque +array of terminals scrolling sundry metrics, I didn't notice a +correlation between cpu usage spikes and peaks in the IO cycle's +waveforms. For whatever that's worth. + +The other tables involved are: + +# \d account.acct + Table "account.acct" + Column | Type | Modifiers=20=20=20=20=20= +=20 +------------+-----------------------------+--------------------------------- +---- + acctid | bigint | not null default + | +nextval('account.acctid_seq'::text) + custid | bigint | + acctstatid | integer | not null + acctno | character varying(50) | + bal | money | + begdt | timestamp without time zone | not null + enddt | timestamp without time zone | + debtid | character varying(50) | +Indexes: + "acct_pkey" primary key, btree (acctid) + "ix_acctno" btree (acctno) WHERE (acctno IS NOT NULL) +Foreign-key constraints: + "$1" FOREIGN KEY (custid) REFERENCES account.cust(custid) + ON UPDATE CASCADE ON DELETE RESTRICT + "$2" FOREIGN KEY (acctstatid) REFERENCES account.acctstat(acctstatid) + ON UPDATE CASCADE ON DELETE RESTRICT + +# \d account.note + Table "account.note" + Column | Type | Modifiers=20=20=20=20= +=20=20=20 +-----------+-----------------------------+---------------------------------- +--- + noteid | bigint | not null default + | +nextval('account.noteid_seq'::text) + custid | bigint | not null + note | text | not null + createddt | timestamp without time zone | not null default now() +Indexes: + "note_pkey" primary key, btree (noteid) +Foreign-key constraints: + "$1" FOREIGN KEY (custid) REFERENCES account.cust(custid) + ON UPDATE CASCADE ON DELETE RESTRICT + +# \d account.origacct + Table "account.origacct" + Column | Type | Modifiers +-------------+-----------------------------+----------- + custid | bigint | + lender | character varying(50) | + chgoffdt | timestamp without time zone | + opendt | timestamp without time zone | + offbureaudt | timestamp without time zone | + princbal | money | + intbal | money | + totbal | money | + lastpayamt | money | + lastpaydt | timestamp without time zone | + debttype | integer | + debtid | character varying(10) | + acctno | character varying(50) | +Foreign-key constraints: + "$1" FOREIGN KEY (custid) REFERENCES account.cust(custid) + ON UPDATE CASCADE ON DELETE RESTRICT + +And the table we were joining to get the new values for prodid and +subprodid: + +# \d tempprod + Table "public.tempprod" + Column | Type | Modifiers +-----------+-----------------------+----------- + debtid | character varying(10) | not null + pool | character varying(10) | not null + port | character varying(10) | not null + subprodid | bigint | + prodid | bigint | +Indexes: + "ix_debtid" btree (debtid) + +/rls + +-- +Rosser Schwarz +Total Card, Inc. + + +From pgsql-performance-owner@postgresql.org Tue Mar 16 14:04:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 526A8D1B909 + for ; + Tue, 16 Mar 2004 18:04: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 71998-05 + for ; + Tue, 16 Mar 2004 14:04:48 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id B0ED5D1B55C + for ; + Tue, 16 Mar 2004 14:04:46 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2GI4kJv026149; + Tue, 16 Mar 2004 13:04:46 -0500 (EST) +To: "Rosser Schwarz" +Cc: pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +In-reply-to: <001d01c40b7c$b80c98a0$2500fa0a@CardServices.TCI.com> +References: <001d01c40b7c$b80c98a0$2500fa0a@CardServices.TCI.com> +Comments: In-reply-to "Rosser Schwarz" + message dated "Tue, 16 Mar 2004 11:32:56 -0600" +Date: Tue, 16 Mar 2004 13:04:46 -0500 +Message-ID: <26148.1079460286@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/221 +X-Sequence-Number: 6077 + +"Rosser Schwarz" writes: +> As for foreign keys, three tables refer to account.cust; all of them +> refer to account.cust.custid, the pk. One of those tables has several +> hundred thousand rows, many more to come; the others are empty. Unless +> I've woefully misunderstood, the presence or absence of a foreign key +> referring to one column should be moot for updates writing another +> column, shouldn't it? + +Well, that is the crux of the issue, and also why I was asking about +versions. It's only been since 7.3.4 or so that we skip checking FKs on +update. + +Looking at the code, though, the update check is only skipped if the +previous version of the row predates the current transaction. +(Otherwise we can't be sure that the value was ever checked.) This +means that slow FK checks could be your problem if the application is +set up to issue multiple UPDATEs affecting the same row(s) during a +single transaction. I'm not clear on whether that applies to you or not. + +And anyway the bottom line is: have you got indexes on the columns +*referencing* account.cust.custid? If not you probably ought to add +them, since without them there will definitely be some slow cases. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 16 14:54:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 213F6D1E8FB + for ; + Tue, 16 Mar 2004 18:54: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 82303-10 + for ; + Tue, 16 Mar 2004 14:54:40 -0400 (AST) +Received: from mail2.dbitech.ca (radius.wavefire.com [64.141.13.252]) + by svr1.postgresql.org (Postfix) with SMTP id 1A4B8D1E2D7 + for ; + Tue, 16 Mar 2004 14:54:37 -0400 (AST) +Received: (qmail 20568 invoked from network); 16 Mar 2004 18:59:49 -0000 +Received: from dbitech.wavefire.com (HELO 64.141.15.253) (darcy@64.141.15.253) + by radius.wavefire.com with SMTP; 16 Mar 2004 18:59:49 -0000 +From: Darcy Buskermolen +Organization: Wavefire Technologies Corp. +Subject: Fwd: Configuring disk cache size on postgress +Date: Tue, 16 Mar 2004 10:54:35 -0800 +User-Agent: KMail/1.5.4 +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403161054.35616.darcy@wavefire.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/222 +X-Sequence-Number: 6078 + +This apeared on the Freebsd-perfomace list and though people here could help +as well. + + + +---------- Forwarded Message ---------- + +Subject: Configuring disk cache size on postgress +Date: March 16, 2004 10:44 am +From: Dror Matalon +To: freebsd-performance@freebsd.org + +Hi Folks, + +When configuring postgres, one of the variables to configure is +effective_cache_size: + Sets the optimizer's assumption about the effective size of the disk + cache (that is, the portion of the kernel's disk cache that will be + used for PostgreSQL data files). This is measured in disk pages, which + are normally 8 kB each. + (http://www.varlena.com/varlena/GeneralBits/Tidbits/annotated_conf_e.html) + +The conventional wisdom on the postgres list has been that for freebsd +you calculate this by doing `sysctl -n vfs.hibufspace` / 8192). + +Now I'm running 4.9 with 2 Gig of ram and sysctl -n vfs.hibufspace +indicates usage of 200MB. + +Questions: +1. How much RAM is freebsd using for *disk* caching? Is it part of the +general VM or is it limited to the above 200MB? I read Matt Dillon's +http://www.daemonnews.org/200001/freebsd_vm.html, but most of the +discussion there seems to be focused on caching programs and program +data. + +2. Can I tell, and if so how, how much memory the OS is using for disk +caching? + +3. What are the bufspace variables for? + +This subject has been touched on before in +http://unix.derkeiler.com/Mailing-Lists/FreeBSD/performance/2003-09/0045.html +which point to a patch to increase the bufspace. + +Regards, + +Dror + + +-- +Dror Matalon +Zapatec Inc +1700 MLK Way +Berkeley, CA 94709 +http://www.fastbuzz.com +http://www.zapatec.com +_______________________________________________ +freebsd-performance@freebsd.org mailing list +http://lists.freebsd.org/mailman/listinfo/freebsd-performance +To unsubscribe, send any mail to + "freebsd-performance-unsubscribe@freebsd.org" + +------------------------------------------------------- + +-- +Darcy Buskermolen +Wavefire Technologies Corp. +ph: 250.717.0200 +fx: 250.763.1759 +http://www.wavefire.com + + +From pgsql-performance-owner@postgresql.org Tue Mar 16 15:58:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B5C6D1E926 + for ; + Tue, 16 Mar 2004 19:58: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 12567-05 + for ; + Tue, 16 Mar 2004 15:58:49 -0400 (AST) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 32033D1E8B1 + for ; + Tue, 16 Mar 2004 15:58:47 -0400 (AST) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i2GJwlDx019171; + Tue, 16 Mar 2004 13:58:47 -0600 +From: "Rosser Schwarz" +To: "'Tom Lane'" +Cc: +Subject: Re: atrocious update performance +Date: Tue, 16 Mar 2004 13:58:47 -0600 +Message-ID: <001e01c40b91$181d66c0$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: <26148.1079460286@sss.pgh.pa.us> +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-MailScanner-From: rschwarz@totalcardinc.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/223 +X-Sequence-Number: 6079 + +while you weren't looking, Tom Lane wrote: + +> ...slow FK checks could be your problem if the application is set +> up to issue multiple UPDATEs affecting the same row(s) during a +> single transaction. I'm not clear on whether that applies to you +> or not. + +It shouldn't. It's just one large batch update that should be hitting +every row serially. + +> And anyway the bottom line is: have you got indexes on the columns +> *referencing* account.cust.custid? + +No. I'd've sworn I had one on account.acct.custid, since that table +is popupated (currently ~500K rows), but it's not. + +$ time psql tci -c "explain analyze select * from account.acct where +custid = 257458" + QUERY PLAN +----------------------------------------------------------------------- + Seq Scan on acct (cost=0.00..7166.68 rows=2 width=71) (actual + time=1047.122..1047.122 rows=0 loops=1) + Filter: (custid = 257458) + Total runtime: 1047.362 ms +(3 rows) + + +real 0m1.083s +user 0m0.010s +sys 0m0.000s + +If it is looking up the custid in account.acct for each row, that's, +say, 1 seconds per lookup, for 4.7 million lookups, for, if my math +is right (4,731,410 / 3600 / 24) 54 days. I suppose that tracks, but +that doesn't make sense, given what you said about the fk checks, +above. + +Of course, if I index the column and amend the query to say "where +custid = 194752::bigint" I get back much saner numbers: + + QUERY PLAN +---------------------------------------------------------------------- + Index Scan using ix_fk_acct_custid on acct (cost=0.00..3.34 rows=2 + width=71) (actual time=0.126..0.141 rows=2 loops=1) + Index Cond: (custid = 194752::bigint) + Total runtime: 0.314 ms +(3 rows) + + +real 0m0.036s +user 0m0.010s +sys 0m0.000s + +Which would still take just under two days. + +$ time psql tci -c "explain analyze update account.cust set prodid = +tempprod.prodid, subprodid = tempprod.subprodid where origid = +tempprod.debtid" + +But if I'm not touching the column referenced from account.acct, why +would it be looking there at all? I've got an explain analyze of the +update running now, but until it finishes, I can't say for certain +what it's doing. explain, alone, says: + +$ time psql tci -c "explain update account.cust set prodid = +tempprod.prodid, subprodid = tempprod.subprodid where origid = +tempprod.debtid;" + QUERY PLAN +--------------------------------------------------------------------- + Merge Join (cost=0.00..232764.69 rows=4731410 width=252) + Merge Cond: (("outer".origid)::text = ("inner".debtid)::text) + -> Index Scan using ix_origid on cust (cost=0.00..94876.83 + rows=4731410 width=236) + -> Index Scan using ix_debtid on tempprod (cost=0.00..66916.71 + rows=4731410 width=26) +(4 rows) + + +real 0m26.965s +user 0m0.010s +sys 0m0.000s + +which shows it not hitting account.acct at all. (And why did it take +the planner 20-some seconds to come up with that query plan?) + +tempprod doesn't have an index either, but then it doesn't reference +account.cust; instead, the update would be done by joining the two on +debtid/origid, which map one-to-one, are both indexed, and with both +tables clustered on those indices--exactly as was the CREATE TABLE AS +Aaron suggested elsethread. + +Unfortunately, this isn't the only large update we'll have to do. We +receive a daily, ~100K rows file that may have new values for any field +of any row in account.cust, .acct or sundry other tables. The process +of updating from that file is time-critical; it must run in minutes, at +the outside. + +/rls + +-- +Rosser Schwarz +Total Card, Inc. + + +From pgsql-performance-owner@postgresql.org Tue Mar 16 16:14:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7647ED1E86C + for ; + Tue, 16 Mar 2004 20:14: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 22463-01 + for ; + Tue, 16 Mar 2004 16:14:50 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B2BCD1E17F + for ; + Tue, 16 Mar 2004 16:14:48 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2GKEkC8027130; + Tue, 16 Mar 2004 15:14:46 -0500 (EST) +To: "Rosser Schwarz" +Cc: pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +In-reply-to: <001e01c40b91$181d66c0$2500fa0a@CardServices.TCI.com> +References: <001e01c40b91$181d66c0$2500fa0a@CardServices.TCI.com> +Comments: In-reply-to "Rosser Schwarz" + message dated "Tue, 16 Mar 2004 13:58:47 -0600" +Date: Tue, 16 Mar 2004 15:14:46 -0500 +Message-ID: <27129.1079468086@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/224 +X-Sequence-Number: 6080 + +"Rosser Schwarz" writes: +> But if I'm not touching the column referenced from account.acct, why +> would it be looking there at all? I've got an explain analyze of the +> update running now, but until it finishes, I can't say for certain +> what it's doing. explain, alone, says: + +EXPLAIN won't tell you anything about triggers that might get fired +during the UPDATE, so it's not much help for investigating possible +FK performance problems. EXPLAIN ANALYZE will give you some indirect +evidence: the difference between the total query time and the total time +reported for the topmost plan node represents the time spent running +triggers and physically updating the tuples. I suspect we are going +to see a big difference. + +> which shows it not hitting account.acct at all. (And why did it take +> the planner 20-some seconds to come up with that query plan?) + +It took 20 seconds to EXPLAIN? That's pretty darn odd in itself. I'm +starting to think there must be something quite whacked-out about your +installation, but I haven't got any real good ideas about what. + +(I'm assuming of course that there weren't a ton of other jobs eating +CPU while you tried to do the EXPLAIN.) + +[ thinks for awhile... ] The only theory that comes to mind for making +the planner so slow is oodles of dead tuples in pg_statistic. Could I +trouble you to run + vacuum full verbose pg_statistic; +and send along the output? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 16 18:18:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C14BD1B55C + for ; + Tue, 16 Mar 2004 22:18: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 62894-01 + for ; + Tue, 16 Mar 2004 18:18:46 -0400 (AST) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 54C05D1CCD2 + for ; + Tue, 16 Mar 2004 18:18:43 -0400 (AST) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i2GMIfDx025531; + Tue, 16 Mar 2004 16:18:41 -0600 +From: "Rosser Schwarz" +To: "'Tom Lane'" +Cc: +Subject: Re: atrocious update performance +Date: Tue, 16 Mar 2004 16:18:41 -0600 +Message-ID: <001f01c40ba4$a3810420$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: <27129.1079468086@sss.pgh.pa.us> +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-MailScanner-From: rschwarz@totalcardinc.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/225 +X-Sequence-Number: 6081 + +while you weren't looking, Tom Lane wrote: + +> EXPLAIN won't tell you anything about triggers that might get fired +> during the UPDATE, so it's not much help for investigating possible +> FK performance problems. EXPLAIN ANALYZE will give you some indirect +> evidence: the difference between the total query time and the total time +> reported for the topmost plan node represents the time spent running +> triggers and physically updating the tuples. I suspect we are going +> to see a big difference. + +It's still running. + +> It took 20 seconds to EXPLAIN? That's pretty darn odd in itself. + +It struck me, too. + +> I'm starting to think there must be something quite whacked-out about +> your installation, but I haven't got any real good ideas about what. + +Built from source. configure arguments: + +./configure --prefix=/var/postgresql --bindir=/usr/bin +--enable-thread-safety --with-perl --with-python --with-openssl +--with-krb5=/usr/kerberos + +I can answer more specific questions; otherwise, I'm not sure what to +look for, either. If we could take the machine out of production (oh, +hell; I think I just volunteered myself for weekend work) long enough +to reinstall everything to get a fair comparison... + +So far as I know, though, it's a more or less stock Red Hat. 2.4.20- +something. + +> (I'm assuming of course that there weren't a ton of other jobs eating +> CPU while you tried to do the EXPLAIN.) + +CPU's spiked sopradically, which throttled everything else, but it never +stays high. top shows the current explain analyze running between 50- +ish% and negligible. iostat -k 3 shows an average of 3K/sec written, for +a hundred-odd tps. + +I can't get any finer-grained than that, unfortunately; the machine was +handed to me with a single, contiguous filesystem, in production use. + +> [ thinks for awhile... ] The only theory that comes to mind +> for making +> the planner so slow is oodles of dead tuples in pg_statistic. Could I +> trouble you to run +> vacuum full verbose pg_statistic; +> and send along the output? + +INFO: vacuuming "pg_catalog.pg_statistic" +INFO: "pg_statistic": found 215 removable, 349 nonremovable row versions +in 7 pages +DETAIL: 0 dead row versions cannot be removed yet. +Nonremovable row versions range from 72 to 8132 bytes long. +There were 3 unused item pointers. +Total free space (including removable row versions) is 91572 bytes. +0 pages are or will become empty, including 0 at the end of the table. +7 pages containing 91572 free bytes are potential move destinations. +CPU 0.00s/0.00u sec elapsed 0.71 sec. +INFO: index "pg_statistic_relid_att_index" now contains 349 row versions +in 2 pages +DETAIL: 215 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.00s/0.00u sec elapsed 0.00 sec. +INFO: "pg_statistic": moved 120 row versions, truncated 7 to 5 pages +DETAIL: CPU 0.03s/0.01u sec elapsed 0.17 sec. +INFO: index "pg_statistic_relid_att_index" now contains 349 row versions +in 2 pages +DETAIL: 120 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.00s/0.00u sec elapsed 0.00 sec. +INFO: vacuuming "pg_toast.pg_toast_16408" +INFO: "pg_toast_16408": found 12 removable, 12 nonremovable row versions +in 5 pages +DETAIL: 0 dead row versions cannot be removed yet. +Nonremovable row versions range from 660 to 8178 bytes long. +There were 0 unused item pointers. +Total free space (including removable row versions) is 91576 bytes. +2 pages are or will become empty, including 0 at the end of the table. +5 pages containing 91576 free bytes are potential move destinations. +CPU 0.00s/0.00u sec elapsed 0.27 sec. +INFO: index "pg_toast_16408_index" now contains 12 row versions in 2 pages +DETAIL: 12 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.00s/0.00u sec elapsed 0.05 sec. +INFO: "pg_toast_16408": moved 10 row versions, truncated 5 to 3 pages +DETAIL: CPU 0.00s/0.00u sec elapsed 0.01 sec. +INFO: index "pg_toast_16408_index" now contains 12 row versions in 2 pages +DETAIL: 10 index row versions were removed. +0 index pages have been deleted, 0 are currently reusable. +CPU 0.00s/0.00u sec elapsed 0.00 sec. + +Having never more than glanced at the output of "vacuum verbose", I +can't say whether that makes the cut for oodles. My suspicion is no. + +/rls + +-- +Rosser Schwarz +Total Card, Inc. + + +From pgsql-performance-owner@postgresql.org Tue Mar 16 18:29:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B7D99D1C9B7 + for ; + Tue, 16 Mar 2004 22:29: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 65482-04 + for ; + Tue, 16 Mar 2004 18:29:54 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id D7F85D1C969 + for ; + Tue, 16 Mar 2004 18:29:51 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2GMTrrf000295; + Tue, 16 Mar 2004 17:29:54 -0500 (EST) +To: "Rosser Schwarz" +Cc: pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +In-reply-to: <001f01c40ba4$a3810420$2500fa0a@CardServices.TCI.com> +References: <001f01c40ba4$a3810420$2500fa0a@CardServices.TCI.com> +Comments: In-reply-to "Rosser Schwarz" + message dated "Tue, 16 Mar 2004 16:18:41 -0600" +Date: Tue, 16 Mar 2004 17:29:53 -0500 +Message-ID: <294.1079476193@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/226 +X-Sequence-Number: 6082 + +"Rosser Schwarz" writes: +> Having never more than glanced at the output of "vacuum verbose", I +> can't say whether that makes the cut for oodles. My suspicion is no. + +Nope, it sure doesn't. We occasionally see people who don't know they +need to vacuum regularly and have accumulated hundreds or thousands of +dead tuples for every live one :-(. That's clearly not the issue here. + +I'm fresh out of ideas, and the fact that this is a live server kinda +limits what we can do experimentally ... but clearly, *something* is +very wrong. + +Well, when you don't know what to look for, you still have to look. +One possibly useful idea is to trace the kernel calls of the backend +process while it does that ridiculously long EXPLAIN --- think you could +try that? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 16 20:20:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C393D1E2A6 + for ; + Wed, 17 Mar 2004 00:20: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 89825-08 + for ; + Tue, 16 Mar 2004 20:20:46 -0400 (AST) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C52CD1E180 + for ; + Tue, 16 Mar 2004 20:20:40 -0400 (AST) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i2H0KdDx029283; + Tue, 16 Mar 2004 18:20:39 -0600 +From: "Rosser Schwarz" +To: "'Tom Lane'" +Cc: +Subject: Re: atrocious update performance +Date: Tue, 16 Mar 2004 18:20:39 -0600 +Message-ID: <002301c40bb5$ad50db40$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: <294.1079476193@sss.pgh.pa.us> +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-MailScanner-From: rschwarz@totalcardinc.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS +X-Spam-Level: +X-Archive-Number: 200403/227 +X-Sequence-Number: 6083 + +while you weren't looking, Tom Lane wrote: + +[trace] + +`strace -p 21882` run behind the below query and plan ... below that. + +# explain update account.cust set prodid =3D tempprod.prodid, subprodid =3D +tempprod.subprodid where origid =3D tempprod.debtid; + QUERY PLAN +------------------------------------------------------------------------- + Merge Join (cost=3D0.00..232764.69 rows=3D4731410 width=3D252) + Merge Cond: (("outer".origid)::text =3D ("inner".debtid)::text) + -> Index Scan using ix_origid on cust (cost=3D0.00..94876.83 + rows=3D4731410 width=3D236) + -> Index Scan using ix_debtid on tempprod (cost=3D0.00..66916.71 + rows=3D4731410 width=3D26) +(4 rows) + +---------- + +recv(9, "Q\0\0\0}explain update account.cust"..., 8192, 0) =3D 126 +gettimeofday({1079482151, 106228}, NULL) =3D 0 +brk(0) =3D 0x82d9000 +brk(0x82db000) =3D 0x82db000 +open("/var/lib/pgsql/data/base/495616/6834170", O_RDWR|O_LARGEFILE) =3D 8 +_llseek(8, 212402176, [212402176], SEEK_SET) =3D 0 +write(8, "\342\1\0\0\0\314\374\6\24\0\0\0\214\7pG\360\177\1\200\320"..., +32768) =3D 32768 +close(8) =3D 0 +open("/var/lib/pgsql/data/base/495616/16635", O_RDWR|O_LARGEFILE) =3D 8 +read(8, "\0\0\0\0\20\0\0\0\1\0\0\0\24\0\360\177\360\177\1\200b1"..., 32768) +=3D +32768 +open("/var/lib/pgsql/data/base/495616/6834168", O_RDWR|O_LARGEFILE) =3D 10 +_llseek(10, 60817408, [60817408], SEEK_SET) =3D 0 +write(10, "\342\1\0\0`\334\5\7\24\0\0\0t\0010x\360\177\1\200\330\377"..., +32768) =3D 32768 +close(10) =3D 0 +read(8, "\334\1\0\0h\217\270n\24\0\0\0H\0H|\360\177\1\200@\376\220"..., +32768) +=3D 32768 +open("/var/lib/pgsql/data/base/495616/6834165", O_RDWR|O_LARGEFILE) =3D 10 +_llseek(10, 130777088, [130777088], SEEK_SET) =3D 0 +write(10, "\342\1\0\0<\341\7\7\24\0\0\0004\t0I\360\177\1\200\330\377"..., +32768) =3D 32768 +close(10) =3D 0 +open("/var/lib/pgsql/data/base/495616/16595", O_RDWR|O_LARGEFILE) =3D 10 +read(10, "\334\1\0\0\360\216\270n\24\0\0\0X\0@y\0\200\1\200\320\371"..., +32768) =3D 32768 +open("/var/lib/pgsql/data/base/495616/6834168", O_RDWR|O_LARGEFILE) =3D 11 +_llseek(11, 145915904, [145915904], SEEK_SET) =3D 0 +write(11, "\342\1\0\0\300\350\n\7\24\0\0\0\224\6\310Z\360\177\1\200"..., +32768) =3D 32768 +close(11) =3D 0 +open("/var/lib/pgsql/data/base/495616/16614", O_RDWR|O_LARGEFILE) =3D 11 +read(11, "\0\0\0\0\24\231P\306\16\0\0\0\24\0\360\177\360\177\1\200"..., +32768) +=3D 32768 +open("/var/lib/pgsql/data/base/495616/6834166", O_RDWR|O_LARGEFILE) =3D 12 +_llseek(12, 148570112, [148570112], SEEK_SET) =3D 0 +write(12, "\342\1\0\0\274\365\22\7\24\0\0\0X\3\234o\360\177\1\200"..., +32768) +=3D 32768 +close(12) =3D 0 +_llseek(11, 98304, [98304], SEEK_SET) =3D 0 +read(11, "\0\0\0\0\24\231P\306\16\0\0\0\34\0\234\177\360\177\1\200"..., +32768) +=3D 32768 +open("/var/lib/pgsql/data/base/495616/6834163", O_RDWR|O_LARGEFILE) =3D 12 +_llseek(12, 251789312, [251789312], SEEK_SET) =3D 0 +write(12, "\342\1\0\0l\366\23\7\24\0\0\0\364\10\260J\360\177\1\200"..., +32768) +=3D 32768 +close(12) =3D 0 +_llseek(11, 32768, [32768], SEEK_SET) =3D 0 +read(11, "\340\1\0\0\324\231\273\241\24\0\0\0\234\5\330\26\360\177"..., +32768) +=3D 32768 +open("/var/lib/pgsql/data/base/495616/6834165", O_RDWR|O_LARGEFILE) =3D 12 +_llseek(12, 117309440, [117309440], SEEK_SET) =3D 0 +write(12, "\342\1\0\0d\36)\7\24\0\0\0000\tHI\360\177\1\200\330\377"..., +32768) +=3D 32768 +close(12) =3D 0 +open("/var/lib/pgsql/data/base/495616/1259", O_RDWR|O_LARGEFILE) =3D 12 +_llseek(12, 32768, [32768], SEEK_SET) =3D 0 +read(12, "\334\1\0\0\324v-p\24\0\0\0000\3\304\3\0\200\1\200<\377"..., 32768) +=3D +32768 +open("/var/lib/pgsql/data/base/495616/6834173", O_RDWR|O_LARGEFILE) =3D 13 +_llseek(13, 247824384, [247824384], SEEK_SET) =3D 0 +write(13, "\342\1\0\0h *\7\24\0\0\0\204\4dm\360\177\1\200\340\377"..., +32768) +=3D 32768 +close(13) =3D 0 +open("/var/lib/pgsql/data/base/495616/16613", O_RDWR|O_LARGEFILE) =3D 13 +read(13, "\0\0\0\0\20\0\0\0\1\0\0\0\24\0\360\177\360\177\1\200b1"..., 32768) +=3D +32768 +open("/var/lib/pgsql/data/base/495616/6834168", O_RDWR|O_LARGEFILE) =3D 14 +_llseek(14, 204472320, [204472320], SEEK_SET) =3D 0 +write(14, "\342\1\0\0\314\272:\7\24\0\0\0\324\t\354K\360\177\1\200"..., +32768) +=3D 32768 +close(14) =3D 0 +read(13, "\340\1\0\0X\231\273\241\24\0\0\0\370\6Dk\360\177\1\200"..., 32768) +=3D +32768 +open("/var/lib/pgsql/data/base/495616/6834166", O_RDWR|O_LARGEFILE) =3D 14 +_llseek(14, 152010752, [152010752], SEEK_SET) =3D 0 +write(14, "\342\1\0\0p\277<\7\24\0\0\0\364\n\220I\360\177\1\200\334"..., +32768) =3D 32768 +close(14) =3D 0 +open("/var/lib/pgsql/data/base/495616/16610", O_RDWR|O_LARGEFILE) =3D 14 +read(14, "\0\0\0\0\10\317\27\t\16\0\0\0\24\0\360\177\360\177\1\200"..., +32768) +=3D 32768 +open("/var/lib/pgsql/data/base/495616/6834170", O_RDWR|O_LARGEFILE) =3D 15 +_llseek(15, 86441984, [86441984], SEEK_SET) =3D 0 +write(15, "\342\1\0\0\330B?\7\24\0\0\0\370\6 N\360\177\1\200\310\377"..., +32768) =3D 32768 +close(15) =3D 0 +_llseek(14, 98304, [98304], SEEK_SET) =3D 0 +read(14, "\340\1\0\0,l\257\241\24\0\0\0(\0\250\177\360\177\1\200"..., 32768) +=3D +32768 +open("/var/lib/pgsql/data/base/495616/6834166", O_RDWR|O_LARGEFILE) =3D 15 +_llseek(15, 121896960, [121896960], SEEK_SET) =3D 0 +write(15, "\342\1\0\0\264\303?\7\24\0\0\0\234\tHP\360\177\1\200\334"..., +32768) =3D 32768 +close(15) =3D 0 +_llseek(14, 65536, [65536], SEEK_SET) =3D 0 +read(14, "\334\1\0\0\310u\252n\23\0\0\0\234\20\320=3D\360\177\1\200"..., +32768) +=3D 32768 +open("/var/lib/pgsql/data/base/495616/6834173", O_RDWR|O_LARGEFILE) =3D 15 +_llseek(15, 41549824, [41549824], SEEK_SET) =3D 0 +write(15, "\342\1\0\0\0\312B\7\24\0\0\0\234\7\350T\360\177\1\200\330"..., +32768) =3D 32768 +close(15) =3D 0 +open("/var/lib/pgsql/data/base/495616/1249", O_RDWR|O_LARGEFILE) =3D 15 +_llseek(15, 229376, [229376], SEEK_SET) =3D 0 +read(15, "O\1\0\0\214\241\200\0\23\0\0\0\364\3\0\4\0\200\1\200\200"..., +32768) +=3D 32768 +open("/var/lib/pgsql/data/base/495616/6834163", O_RDWR|O_LARGEFILE) =3D 16 +_llseek(16, 57147392, [57147392], SEEK_SET) =3D 0 +write(16, "\342\1\0\0004\320G\7\24\0\0\0\374\7\200P\360\177\1\200"..., +32768) +=3D 32768 +close(16) =3D 0 +_llseek(15, 163840, [163840], SEEK_SET) =3D 0 +read(15, "\21\1\0\0\214\3\224R\23\0\0\0\364\3\0\4\0\200\1\200\200"..., +32768) +=3D 32768 +open("/var/lib/pgsql/data/base/495616/6834163", O_RDWR|O_LARGEFILE) =3D 16 +_llseek(16, 241893376, [241893376], SEEK_SET) =3D 0 +write(16, "\342\1\0\0\220TK\7\24\0\0\0,\t`I\360\177\1\200\330\377"..., +32768) +=3D 32768 +close(16) =3D 0 +_llseek(12, 0, [0], SEEK_SET) =3D 0 +read(12, "O\1\0\0\350\340\316,\23\0\0\0X\3\230\3\0\200\1\200d\304"..., +32768) +=3D 32768 +open("/var/lib/pgsql/data/base/495616/6834171", O_RDWR|O_LARGEFILE) =3D 16 +_llseek(16, 88702976, [88702976], SEEK_SET) =3D 0 +write(16, "\342\1\0\0\324\326K\7\24\0\0\0`\v\370E\360\177\1\200\334"..., +32768) =3D 32768 +close(16) =3D 0 +_llseek(14, 32768, [32768], SEEK_SET) =3D 0 +read(14, "\0\0\0\0\10\317\27\t\16\0\0\0\234\20\320=3D\360\177\1\200"..., +32768) +=3D 32768 +open("/var/lib/pgsql/data/base/495616/6834173", O_RDWR|O_LARGEFILE) =3D 16 +_llseek(16, 152043520, [152043520], SEEK_SET) =3D 0 +write(16, "\342\1\0\0\220fU\7\24\0\0\0l\n\320K\360\177\1\200\334\377"..., +32768) =3D 32768 +close(16) =3D 0 +_llseek(15, 0, [0], SEEK_SET) =3D 0 +read(15, "\0\0\0\0\20\0\0\0\1\0\0\0\364\3\0\4\0\200\1\200\200\377"..., +32768) +=3D 32768 +open("/var/lib/pgsql/data/base/495616/6834163", O_RDWR|O_LARGEFILE) =3D 16 +_llseek(16, 70025216, [70025216], SEEK_SET) =3D 0 +write(16, "\342\1\0\0\370\rk\7\24\0\0\0 \10\250O\360\177\1\200\330"..., +32768) +=3D 32768 +close(16) =3D 0 +read(15, "\0\0\0\0\20\0\0\0\1\0\0\0\364\3\0\4\0\200\1\200\200\377"..., +32768) +=3D 32768 +open("/var/lib/pgsql/data/base/495616/6834163", O_RDWR|O_LARGEFILE) =3D 16 +_llseek(16, 152764416, [152764416], SEEK_SET) =3D 0 +write(16, "\342\1\0\0008\222m\7\24\0\0\0\370\10\230J\360\177\1\200"..., +32768) +=3D 32768 +close(16) =3D 0 +open("/var/lib/pgsql/data/base/495616/16630", O_RDWR|O_LARGEFILE) =3D 16 +read(16, "\0\0\0\0\20\0\0\0\1\0\0\0\24\0\360\177\360\177\1\200b1"..., 32768) +=3D +32768 +open("/var/lib/pgsql/data/base/495616/6834163", O_RDWR|O_LARGEFILE) =3D 17 +_llseek(17, 143753216, [143753216], SEEK_SET) =3D 0 +write(17, "\342\1\0\0\314!w\7\24\0\0\0\20\t\10J\360\177\1\200\330"..., +32768) +=3D 32768 +close(17) =3D 0 +read(16, "\340\1\0\0\340\204\264\241\24\0\0\0H\2Ty\360\177\1\200"..., 32768) +=3D +32768 +open("/var/lib/pgsql/data/base/495616/6834170", O_RDWR|O_LARGEFILE) =3D 17 +_llseek(17, 192512000, [192512000], SEEK_SET) =3D 0 +write(17, "\342\1\0\0`\253y\7\24\0\0\0\250\7\330G\360\177\1\200\324"..., +32768) =3D 32768 +close(17) =3D 0 +open("/var/lib/pgsql/data/base/495616/16390", O_RDWR|O_LARGEFILE) =3D 17 +read(17, "\334\1\0\0t\242\23p\24\0\0\0\0\2\210\2\0\200\1\200\24\377"..., +32768) =3D 32768 +open("/var/lib/pgsql/data/base/495616/16396", O_RDWR|O_LARGEFILE) =3D 18 +_llseek(18, 0, [32768], SEEK_END) =3D 0 +open("/var/lib/pgsql/data/base/495616/6834168", O_RDWR|O_LARGEFILE) =3D 19 +_llseek(19, 63471616, [63471616], SEEK_SET) =3D 0 +write(19, "\342\1\0\0\2444\200\7\24\0\0\0$\10\240O\360\177\1\200\330"..., +32768) =3D 32768 +close(19) =3D 0 +_llseek(18, 0, [0], SEEK_SET) =3D 0 +read(18, "\0\0\0\0\20\0\0\0\1\0\0\0$\0\240}\0\200\1\200h\3770\1\320"..., +32768) =3D 32768 +brk(0) =3D 0x82db000 +brk(0x82dd000) =3D 0x82dd000 +open("/var/lib/pgsql/data/base/495616/6834166", O_RDWR|O_LARGEFILE) =3D 19 +_llseek(19, 64290816, [64290816], SEEK_SET) =3D 0 +write(19, "\342\1\0\0<\265\200\7\24\0\0\0d\t`Q\360\177\1\200\334\377"..., +32768) =3D 32768 +close(19) =3D 0 +open("/var/lib/pgsql/data/base/495616/16605", O_RDWR|O_LARGEFILE) =3D 19 +read(19, "\0\0\0\0\20\0\0\0\1\0\0\0\24\0\360\177\360\177\1\200b1"..., 32768) +=3D +32768 +open("/var/lib/pgsql/data/base/495616/6834163", O_RDWR|O_LARGEFILE) =3D 20 +_llseek(20, 152731648, [152731648], SEEK_SET) =3D 0 +write(20, "\342\1\0\0\264=3D\206\7\24\0\0\0\370\10\230J\360\177\1\200"..., +32768) =3D 32768 +close(20) =3D 0 +read(19, "\0\0\0\0\20\0\0\0\1\0\0\0\264\3pq\360\177\1\200\300\363"..., +32768) +=3D 32768 +open("/var/lib/pgsql/data/base/495616/6834170", O_RDWR|O_LARGEFILE) =3D 20 +_llseek(20, 150274048, [150274048], SEEK_SET) =3D 0 +write(20, "\342\1\0\0\230\310\212\7\24\0\0\0\210\7lO\360\177\1\200"..., +32768) +=3D 32768 +close(20) =3D 0 +open("/var/lib/pgsql/data/base/495616/16398", O_RDWR|O_LARGEFILE) =3D 20 +read(20, "\0\0\0\0\20\0\0\0\1\0\0\0\264\3`_\0\200\1\200\334\377H"..., 32768) +=3D +32768 +open("/var/lib/pgsql/data/base/495616/6834166", O_RDWR|O_LARGEFILE) =3D 21 +_llseek(21, 260046848, [260046848], SEEK_SET) =3D 0 +write(21, "\342\1\0\0\4\322\220\7\24\0\0\0\264\2\320r\360\177\1\200"..., +32768) =3D 32768 +close(21) =3D 0 +open("/var/lib/pgsql/data/base/495616/16639", O_RDWR|O_LARGEFILE) =3D 21 +read(21, "\0\0\0\0\20\0\0\0\1\0\0\0\24\0\360\177\360\177\1\200b1"..., 32768) +=3D +32768 +open("/var/lib/pgsql/data/base/495616/6834170", O_RDWR|O_LARGEFILE) =3D 22 +_llseek(22, 174424064, [174424064], SEEK_SET) =3D 0 +write(22, "\342\1\0\0\200\\\225\7\24\0\0\0D\t$H\360\177\1\200\330"..., +32768) +=3D 32768 +close(22) =3D 0 +read(21, "\0\0\0\0\20\0\0\0\1\0\0\0\200\t\254c\360\177\1\200\344"..., 32768) +=3D +32768 +open("/var/lib/pgsql/data/base/495616/6834163", O_RDWR|O_LARGEFILE) =3D 22 +_llseek(22, 109084672, [109084672], SEEK_SET) =3D 0 +write(22, "\342\1\0\0\310\335\226\7\24\0\0\0 \10\250O\360\177\1\200"..., +32768) =3D 32768 +close(22) =3D 0 +open("/var/lib/pgsql/data/base/495616/16392", O_RDWR|O_LARGEFILE) =3D 22 +read(22, "\0\0\0\0\20\0\0\0\1\0\0\0X\3\350\3\0\200\1\200h\3770\1"..., 32768) +=3D +32768 +open("/var/lib/pgsql/data/base/495616/6834170", O_RDWR|O_LARGEFILE) =3D 23 +_llseek(23, 200900608, [200900608], SEEK_SET) =3D 0 +write(23, "\342\1\0\0\314\344\232\7\24\0\0\0\344\7\304G\360\177\1"..., +32768) +=3D 32768 +close(23) =3D 0 +open("/var/lib/pgsql/data/base/495616/16606", O_RDWR|O_LARGEFILE) =3D 23 +read(23, "\0\0\0\0\20\0\0\0\1\0\0\0\24\0\360\177\360\177\1\200b1"..., 32768) +=3D +32768 +open("/var/lib/pgsql/data/base/495616/6834168", O_RDWR|O_LARGEFILE) =3D 24 +_llseek(24, 85426176, [85426176], SEEK_SET) =3D 0 +write(24, "\342\1\0\0\30\345\232\7\24\0\0\0\264\7\360V\360\177\1\200"..., +32768) =3D 32768 +close(24) =3D 0 +read(23, "\0\0\0\0\20\0\0\0\1\0\0\0H\1 {\360\177\1\200P\377 \0@\377"..., +32768) =3D 32768 +open("/var/lib/pgsql/data/base/495616/6834166", O_RDWR|O_LARGEFILE) =3D 24 +_llseek(24, 156729344, [156729344], SEEK_SET) =3D 0 +write(24, "\342\1\0\0\260e\233\7\24\0\0\0\30\n\334M\360\177\1\200"..., +32768) +=3D 32768 +close(24) =3D 0 +open("/var/lib/pgsql/data/base/495616/16400", O_RDWR|O_LARGEFILE) =3D 24 +read(24, "\0\0\0\0\20\0\0\0\1\0\0\0H\1,u\0\200\1\200\334\377H\0\270"..., +32768) =3D 32768 +open("/var/lib/pgsql/data/base/495616/6834168", O_RDWR|O_LARGEFILE) =3D 25 +_llseek(25, 92995584, [92995584], SEEK_SET) =3D 0 +write(25, "\342\1\0\0\244i\235\7\24\0\0\0\360\ttO\360\177\1\200\324"..., +32768) =3D 32768 +close(25) =3D 0 +open("/var/lib/pgsql/data/base/495616/16607", O_RDWR|O_LARGEFILE) =3D 25 +read(25, "\0\0\0\0\264\341\v\t\16\0\0\0\24\0\360\177\360\177\1\200"..., +32768) +=3D 32768 +open("/var/lib/pgsql/data/base/495616/6834170", O_RDWR|O_LARGEFILE) =3D 26 +_llseek(26, 209387520, [209387520], SEEK_SET) =3D 0 +write(26, "\342\1\0\0; + Wed, 17 Mar 2004 01:22: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 03706-10 + for ; + Tue, 16 Mar 2004 21:22:05 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 122EFD1E90D + for ; + Tue, 16 Mar 2004 21:22:02 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2H1M4Fx005350; + Tue, 16 Mar 2004 20:22:04 -0500 (EST) +To: "Rosser Schwarz" +Cc: pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +In-reply-to: <002301c40bb5$ad50db40$2500fa0a@CardServices.TCI.com> +References: <002301c40bb5$ad50db40$2500fa0a@CardServices.TCI.com> +Comments: In-reply-to "Rosser Schwarz" + message dated "Tue, 16 Mar 2004 18:20:39 -0600" +Date: Tue, 16 Mar 2004 20:22:04 -0500 +Message-ID: <5349.1079486524@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/228 +X-Sequence-Number: 6084 + +"Rosser Schwarz" writes: +> `strace -p 21882` run behind the below query and plan ... below that. + +Hmm ... that took 20 seconds eh? + +It is a fairly interesting trace. It shows that the backend needed to +read 63 system catalog pages (that weren't already in shared memory), +which is not too unreasonable I think ... though I wonder if more of +them shouldn't have been in memory already. The odd thing is that for +*every single read* it was necessary to first dump out a dirty page +in order to make a buffer free. That says you are running with the +entire contents of shared buffer space dirty at all times. That's +probably not the regime you want to be operating in. I think we already +suggested increasing shared_buffers. You might also want to think about +not using such a large checkpoint interval. (The background-writing +logic already committed for 7.5 should help this problem, but it's not +there in 7.4.) + +Another interesting fact is that the bulk of the writes were "blind +writes", involving an open()/write()/close() sequence instead of keeping +the open file descriptor around for re-use. This is not too surprising +in a freshly started backend, I guess; it's unlikely to have had reason +to create a relation descriptor for the relations it may have to dump +pages for. In some Unixen, particularly Solaris, open() is fairly +expensive and so blind writes are bad news. I didn't think it was a big +problem in Linux though. (This is another area we've improved for 7.5: +there are no more blind writes. But that won't help you today.) + +What's not immediately evident is whether the excess I/O accounted for +all of the slowdown. Could you retry the strace with -r and -T options +so we can see how much time is being spent inside and outside the +syscalls? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 16 23:25:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 10FD8D1D28E + for ; + Wed, 17 Mar 2004 03:25:15 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 44453-05 + for ; + Tue, 16 Mar 2004 23:25:17 -0400 (AST) +Received: from hotmail.com (law10-oe28.law10.hotmail.com [64.4.14.85]) + by svr1.postgresql.org (Postfix) with ESMTP id AFB51D1D2A0 + for ; + Tue, 16 Mar 2004 23:25:12 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Tue, 16 Mar 2004 19:25:13 -0800 +Received: from 67.81.102.201 by law10-oe28.law10.hotmail.com with DAV; + Wed, 17 Mar 2004 03:25:12 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: "Rosser Schwarz" +Cc: +References: <002301c40bb5$ad50db40$2500fa0a@CardServices.TCI.com> +Subject: Re: atrocious update performance +Date: Tue, 16 Mar 2004 22:25:16 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Message-ID: +X-OriginalArrivalTime: 17 Mar 2004 03:25:13.0099 (UTC) + FILETIME=[7584CDB0:01C40BCF] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/229 +X-Sequence-Number: 6085 + +Quick observations: + +1. We have an explanation for what's going on, based on the message being +exactly 666 lines long :-) +2. I'm clueless on the output, but perhaps Tom can see something. A quick +glance shows that the strace seemed to run 27 seconds, during which it did: + count| call + -------|--------- + 84 | _llseek + 40 | brk + 54 | close + 88 | open + 63 | read +in other words, nothing much (though it did *a lot* of opens and closes of +db files to do nothing ). + +Can you do another strace for a few minutes against the actual update query +adding the -c/-t options and control-c out? + +----- Original Message ----- +From: "Rosser Schwarz" +To: "'Tom Lane'" +Cc: +Sent: Tuesday, March 16, 2004 7:20 PM +Subject: Re: [PERFORM] atrocious update performance + + +while you weren't looking, Tom Lane wrote: + +[trace] + +`strace -p 21882` run behind the below query and plan ... below that. + +# explain update account.cust set prodid = tempprod.prodid, subprodid = +tempprod.subprodid where origid = tempprod.debtid; + +From pgsql-performance-owner@postgresql.org Wed Mar 17 00:50:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D46A2D1C515 + for ; + Wed, 17 Mar 2004 04:50: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 52661-09 + for ; + Wed, 17 Mar 2004 00:50:29 -0400 (AST) +Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 4474FD1E17D + for ; + Wed, 17 Mar 2004 00:50:28 -0400 (AST) +Received: from [192.168.5.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1090339; Tue, 16 Mar 2004 20:45:51 -0800 +Message-ID: <4057D8BD.4080902@joeconway.com> +Date: Tue, 16 Mar 2004 20:49:01 -0800 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: "Matthew T. O'Connor" , + pgsql-performance , + Josh Berkus +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> + <4055F343.6070600@joeconway.com> <405614CA.5030101@zeut.net> + <405689A4.4080406@joeconway.com> <16735.1079414723@sss.pgh.pa.us> +In-Reply-To: <16735.1079414723@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: 200403/230 +X-Sequence-Number: 6086 + +Tom Lane wrote: +> Joe Conway writes: +> +>>Any idea where I can get my hands on the latest version. I found the +>>original post from Tom, but I thought there was a later version with +>>both number of pages and time to sleep as knobs. +> +> That was as far as I got. I think Jan posted a more complex version +> that would still be reasonable to apply to 7.4. + +I have tested Tom's original patch now. The good news -- it works great +in terms of reducing the load imposed by vacuum -- almost to the level +of being unnoticeable. The bad news -- in a simulation test which loads +an hour's worth of data, even with delay set to 1 ms, vacuum of the +large table exceeds two hours (vs 12-14 minutes with delay = 0). Since +that hourly load is expected 7 x 24, this obviously isn't going to work. + +The problem with Jan's more complex version of the patch (at least the +one I found - perhaps not the right one) is it includes a bunch of other +experimental stuff that I'd not want to mess with at the moment. Would +changing the input units (for the original patch) from milli-secs to +micro-secs be a bad idea? If so, I guess I'll get to extracting what I +need from Jan's patch. + +Thanks, + +Joe + + +From pgsql-performance-owner@postgresql.org Wed Mar 17 01:14:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A2032D1E441 + for ; + Wed, 17 Mar 2004 05:14: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 60910-08 + for ; + Wed, 17 Mar 2004 01:14:26 -0400 (AST) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 9EE13D1E90B + for ; + Wed, 17 Mar 2004 01:14:25 -0400 (AST) +Received: from ool-4352919e.dyn.optonline.net ([67.82.145.158] helo=zeut.net) + by outbound.mailhop.org with asmtp (TLSv1:AES256-SHA:256) (Exim 4.20) + id 1B3TNm-000PrR-Be; Wed, 17 Mar 2004 00:14:22 -0500 +Message-ID: <4057DE34.1080001@zeut.net> +Date: Wed, 17 Mar 2004 00:12:20 -0500 +From: "Matthew T. O'Connor" +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Joe Conway +Cc: Tom Lane , "Matthew T. O'Connor" , + pgsql-performance , + Josh Berkus +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> + <4055F343.6070600@joeconway.com> <405614CA.5030101@zeut.net> + <405689A4.4080406@joeconway.com> <16735.1079414723@sss.pgh.pa.us> + <4057D8BD.4080902@joeconway.com> +In-Reply-To: <4057D8BD.4080902@joeconway.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Report-Abuse-To: abuse@dyndns.org +X-MHO-User: Zeut +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/231 +X-Sequence-Number: 6087 + +On Tue, 2004-03-16 at 23:49, Joe Conway wrote: +> I have tested Tom's original patch now. The good news -- it works great +> in terms of reducing the load imposed by vacuum -- almost to the level +> of being unnoticeable. The bad news -- in a simulation test which loads +> an hour's worth of data, even with delay set to 1 ms, vacuum of the +> large table exceeds two hours (vs 12-14 minutes with delay = 0). Since +> that hourly load is expected 7 x 24, this obviously isn't going to work. + +If memory serves, the problem is that you actually sleep 10ms even when +you set it to 1. One of the thing changed in Jan's later patch was the +ability to specify how many pages to work on before sleeping, rather +than how long to sleep inbetween every 1 page. You might be able to do +a quick hack and have it do 10 pages or so before sleeping. + +Matthew + + +From pgsql-performance-owner@postgresql.org Wed Mar 17 01:17:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EF4D6D1E154 + for ; + Wed, 17 Mar 2004 05:17: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 67678-04 + for ; + Wed, 17 Mar 2004 01:17:46 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E8FDD1DF84 + for ; + Wed, 17 Mar 2004 01:17:45 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2H5HeYr021012; + Wed, 17 Mar 2004 00:17:41 -0500 (EST) +To: Joe Conway +Cc: "Matthew T. O'Connor" , + pgsql-performance , + Josh Berkus +Subject: Re: rapid degradation after postmaster restart +In-reply-to: <4057D8BD.4080902@joeconway.com> +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> + <4055F343.6070600@joeconway.com> <405614CA.5030101@zeut.net> + <405689A4.4080406@joeconway.com> <16735.1079414723@sss.pgh.pa.us> + <4057D8BD.4080902@joeconway.com> +Comments: In-reply-to Joe Conway + message dated "Tue, 16 Mar 2004 20:49:01 -0800" +Date: Wed, 17 Mar 2004 00:17:40 -0500 +Message-ID: <21011.1079500660@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/232 +X-Sequence-Number: 6088 + +Joe Conway writes: +> I have tested Tom's original patch now. The good news -- it works great +> in terms of reducing the load imposed by vacuum -- almost to the level +> of being unnoticeable. The bad news -- in a simulation test which loads +> an hour's worth of data, even with delay set to 1 ms, vacuum of the +> large table exceeds two hours (vs 12-14 minutes with delay = 0). Since +> that hourly load is expected 7 x 24, this obviously isn't going to work. + +Turns the dial down a bit too far then ... + +> The problem with Jan's more complex version of the patch (at least the +> one I found - perhaps not the right one) is it includes a bunch of other +> experimental stuff that I'd not want to mess with at the moment. Would +> changing the input units (for the original patch) from milli-secs to +> micro-secs be a bad idea? + +Unlikely to be helpful; on most kernels the minimum sleep delay is 1 or +10 msec, so asking for a few microsec is the same as asking for some +millisec. I think what you need is a knob of the form "sleep N msec +after each M pages of I/O". I'm almost certain that Jan posted such a +patch somewhere between my original and the version you refer to above. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 17 01:20:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 60C9ED1E93F + for ; + Wed, 17 Mar 2004 05:20: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 65179-06 + for ; + Wed, 17 Mar 2004 01:19:58 -0400 (AST) +Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 509F3D1E28B + for ; + Wed, 17 Mar 2004 01:19:57 -0400 (AST) +Received: from [206.19.64.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1090376; Tue, 16 Mar 2004 21:15:19 -0800 +Message-ID: <4057DFA3.90407@joeconway.com> +Date: Tue, 16 Mar 2004 21:18:27 -0800 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Matthew T. O'Connor" +Cc: Tom Lane , + pgsql-performance , + Josh Berkus +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> + <4055F343.6070600@joeconway.com> <405614CA.5030101@zeut.net> + <405689A4.4080406@joeconway.com> <16735.1079414723@sss.pgh.pa.us> + <4057D8BD.4080902@joeconway.com> <4057DE34.1080001@zeut.net> +In-Reply-To: <4057DE34.1080001@zeut.net> +Content-Type: multipart/mixed; boundary="------------070505040900090607040909" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/233 +X-Sequence-Number: 6089 + +This is a multi-part message in MIME format. +--------------070505040900090607040909 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +Matthew T. O'Connor wrote: +> If memory serves, the problem is that you actually sleep 10ms even when +> you set it to 1. One of the thing changed in Jan's later patch was the +> ability to specify how many pages to work on before sleeping, rather +> than how long to sleep inbetween every 1 page. You might be able to do +> a quick hack and have it do 10 pages or so before sleeping. + +I thought I remembered something about that. + +It turned out to be less difficult than I first thought to extract the +vacuum delay stuff from Jan's performance patch. I haven't yet tried it +out, but it's attached in case you are interested. I'll report back once +I have some results. + +Joe + +--------------070505040900090607040909 +Content-Type: text/plain; + name="performance_mod.74.diff" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline; + filename="performance_mod.74.diff" + +Index: src/backend/access/nbtree/nbtree.c +=================================================================== +RCS file: /home/pgsql/CvsRoot/pgsql-server/src/backend/access/nbtree/nbtree.c,v +retrieving revision 1.106 +diff -c -b -r1.106 nbtree.c +*** src/backend/access/nbtree/nbtree.c 2003/09/29 23:40:26 1.106 +--- src/backend/access/nbtree/nbtree.c 2003/11/03 17:56:54 +*************** +*** 18,23 **** +--- 18,25 ---- + */ + #include "postgres.h" + ++ #include ++ + #include "access/genam.h" + #include "access/heapam.h" + #include "access/nbtree.h" +*************** +*** 27,32 **** +--- 29,39 ---- + #include "storage/smgr.h" + + ++ extern int vacuum_page_delay; ++ extern int vacuum_page_groupsize; ++ extern int vacuum_page_groupcount; ++ ++ + /* Working state for btbuild and its callback */ + typedef struct + { +*************** +*** 610,615 **** +--- 617,631 ---- + + CHECK_FOR_INTERRUPTS(); + ++ if (vacuum_page_delay > 0) ++ { ++ if (++vacuum_page_groupcount >= vacuum_page_groupsize) ++ { ++ vacuum_page_groupcount = 0; ++ usleep(vacuum_page_delay * 1000); ++ } ++ } ++ + ndeletable = 0; + page = BufferGetPage(buf); + opaque = (BTPageOpaque) PageGetSpecialPointer(page); +*************** +*** 736,741 **** +--- 752,768 ---- + Buffer buf; + Page page; + BTPageOpaque opaque; ++ ++ CHECK_FOR_INTERRUPTS(); ++ ++ if (vacuum_page_delay > 0) ++ { ++ if (++vacuum_page_groupcount >= vacuum_page_groupsize) ++ { ++ vacuum_page_groupcount = 0; ++ usleep(vacuum_page_delay * 1000); ++ } ++ } + + buf = _bt_getbuf(rel, blkno, BT_READ); + page = BufferGetPage(buf); +Index: src/backend/commands/vacuumlazy.c +=================================================================== +RCS file: /home/pgsql/CvsRoot/pgsql-server/src/backend/commands/vacuumlazy.c,v +retrieving revision 1.32 +diff -c -b -r1.32 vacuumlazy.c +*** src/backend/commands/vacuumlazy.c 2003/09/25 06:57:59 1.32 +--- src/backend/commands/vacuumlazy.c 2003/11/03 17:57:27 +*************** +*** 37,42 **** +--- 37,44 ---- + */ + #include "postgres.h" + ++ #include ++ + #include "access/genam.h" + #include "access/heapam.h" + #include "access/xlog.h" +*************** +*** 88,93 **** +--- 90,99 ---- + static TransactionId OldestXmin; + static TransactionId FreezeLimit; + ++ int vacuum_page_delay = 0; /* milliseconds per page group */ ++ int vacuum_page_groupsize = 10; /* group size */ ++ int vacuum_page_groupcount = 0; /* current group size count */ ++ + + /* non-export function prototypes */ + static void lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, +*************** +*** 228,233 **** +--- 234,248 ---- + + CHECK_FOR_INTERRUPTS(); + ++ if (vacuum_page_delay > 0) ++ { ++ if (++vacuum_page_groupcount >= vacuum_page_groupsize) ++ { ++ vacuum_page_groupcount = 0; ++ usleep(vacuum_page_delay * 1000); ++ } ++ } ++ + /* + * If we are close to overrunning the available space for + * dead-tuple TIDs, pause and do a cycle of vacuuming before we +*************** +*** 469,474 **** +--- 484,498 ---- + + CHECK_FOR_INTERRUPTS(); + ++ if (vacuum_page_delay > 0) ++ { ++ if (++vacuum_page_groupcount >= vacuum_page_groupsize) ++ { ++ vacuum_page_groupcount = 0; ++ usleep(vacuum_page_delay * 1000); ++ } ++ } ++ + tblk = ItemPointerGetBlockNumber(&vacrelstats->dead_tuples[tupindex]); + buf = ReadBuffer(onerel, tblk); + LockBufferForCleanup(buf); +*************** +*** 799,804 **** +--- 823,837 ---- + hastup; + + CHECK_FOR_INTERRUPTS(); ++ ++ if (vacuum_page_delay > 0) ++ { ++ if (++vacuum_page_groupcount >= vacuum_page_groupsize) ++ { ++ vacuum_page_groupcount = 0; ++ usleep(vacuum_page_delay * 1000); ++ } ++ } + + blkno--; + +Index: src/backend/utils/misc/guc.c +=================================================================== +RCS file: /home/pgsql/CvsRoot/pgsql-server/src/backend/utils/misc/guc.c,v +retrieving revision 1.164 +diff -c -b -r1.164 guc.c +*** src/backend/utils/misc/guc.c 2003/10/18 22:59:09 1.164 +--- src/backend/utils/misc/guc.c 2003/11/03 21:10:52 +*************** +*** 70,78 **** +--- 70,80 ---- + extern int PreAuthDelay; + extern int AuthenticationTimeout; + extern int CheckPointTimeout; + extern int CommitDelay; + extern int CommitSiblings; + extern char *preload_libraries_string; ++ extern int vacuum_page_delay; ++ extern int vacuum_page_groupsize; + + #ifdef HAVE_SYSLOG + extern char *Syslog_facility; +*************** +*** 1188,1193 **** +--- 1199,1222 ---- + }, + &log_min_duration_statement, + -1, -1, INT_MAX / 1000, NULL, NULL ++ }, ++ ++ { ++ {"vacuum_page_delay", PGC_USERSET, CLIENT_CONN_STATEMENT, ++ gettext_noop("Sets VACUUM's delay in milliseconds between processing successive pages."), ++ NULL ++ }, ++ &vacuum_page_delay, ++ 0, 0, 100, NULL, NULL ++ }, ++ ++ { ++ {"vacuum_page_groupsize", PGC_USERSET, CLIENT_CONN_STATEMENT, ++ gettext_noop("Sets VACUUM's delay group size."), ++ NULL ++ }, ++ &vacuum_page_groupsize, ++ 10, 1, 1000, NULL, NULL + }, + + /* End-of-list marker */ + +--------------070505040900090607040909-- + +From pgsql-performance-owner@postgresql.org Wed Mar 17 03:33:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 48199D1DB53 + for ; + Wed, 17 Mar 2004 07:33:22 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 96750-03 + for ; + Wed, 17 Mar 2004 03:33:21 -0400 (AST) +Received: from mail63.csoft.net (unknown [63.111.22.74]) + by svr1.postgresql.org (Postfix) with SMTP id 7B1DAD1D85F + for ; + Wed, 17 Mar 2004 03:33:17 -0400 (AST) +Received: (qmail 6747 invoked by uid 1112); 17 Mar 2004 07:33:44 -0000 +Date: Wed, 17 Mar 2004 02:33:44 -0500 (EST) +From: Kris Jurka +X-X-Sender: books@leary.csoft.net +To: pgsql-performance@postgresql.org +Subject: Re: severe performance issue with planner (fwd) +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: 200403/234 +X-Sequence-Number: 6090 + + +I sent this message to the list and although it shows up in the archives, +I did not receive a copy of it through the list, so I'm resending as I +suspect others did not see it either. + +---------- Forwarded message ---------- +Date: Sat, 13 Mar 2004 22:48:01 -0500 (EST) +From: Kris Jurka +To: Tom Lane +Cc: Eric Brown , pgsql-performance@postgresql.org +Subject: Re: [PERFORM] severe performance issue with planner + +On Thu, 11 Mar 2004, Tom Lane wrote: + +> "Eric Brown" writes: +> > [ planning a 9-table query takes too long ] +> +> See http://www.postgresql.org/docs/7.4/static/explicit-joins.html +> for some useful tips. +> + +Is this the best answer we've got? For me with an empty table this query +takes 4 seconds to plan, is that the expected planning time? I know I've +got nine table queries that don't take that long. + +Setting geqo_threshold less than 9, it takes 1 second to plan. Does this +indicate that geqo_threshold is set too high, or is it a tradeoff between +planning time and plan quality? If the planning time is so high because +the are a large number of possible join orders, should geqo_threhold be +based on the number of possible plans somehow instead of the number of +tables involved? + +Kris Jurka + + +From pgsql-performance-owner@postgresql.org Wed Mar 17 03:46:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AE6E0D1DF84 + for ; + Wed, 17 Mar 2004 07:46: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 01685-02 + for ; + Wed, 17 Mar 2004 03:46:45 -0400 (AST) +Received: from frodo.hserus.net (frodo.hserus.net [204.74.68.40]) + by svr1.postgresql.org (Postfix) with ESMTP id 97EBFD1DD14 + for ; + Wed, 17 Mar 2004 03:46:43 -0400 (AST) +Received: from concord.pspl.co.in ([202.54.11.72]:61875 helo=frodo.hserus.net) + by frodo.hserus.net with asmtp + (Cipher TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.30 #2) + id 1B3VlE-0006tU-4J by authid with plain + for ; Wed, 17 Mar 2004 13:16:44 +0530 +Message-ID: <4058025D.5050805@frodo.hserus.net> +Date: Wed, 17 Mar 2004 13:16:37 +0530 +From: Shridhar Daithankar +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: Performance +Subject: A good article about application tuning +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: 200403/235 +X-Sequence-Number: 6091 + +http://www.databasejournal.com/features/postgresql/article.php/3323561 + + Shridhar + +From pgsql-performance-owner@postgresql.org Wed Mar 17 05:11:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4843BD1B560 + for ; + Wed, 17 Mar 2004 09:11:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 21312-02 + for ; + Wed, 17 Mar 2004 05:11:44 -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 BA9AFD1B55E + for ; + Wed, 17 Mar 2004 05:11:41 -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 1B3X5S-000HN3-0X; Wed, 17 Mar 2004 09:11:42 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id EC32E179D5; Wed, 17 Mar 2004 09:11:40 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 1C37C165CD; Wed, 17 Mar 2004 09:11:38 +0000 (GMT) +From: Richard Huxton +To: Tom Lane , "Rosser Schwarz" +Subject: Re: atrocious update performance +Date: Wed, 17 Mar 2004 09:11:37 +0000 +User-Agent: KMail/1.5 +Cc: pgsql-performance@postgresql.org +References: <001a01c40ae4$1cdd4160$2500fa0a@CardServices.TCI.com> + <8912.1079395699@sss.pgh.pa.us> +In-Reply-To: <8912.1079395699@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403170911.37462.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: 200403/236 +X-Sequence-Number: 6092 + +On Tuesday 16 March 2004 00:08, Tom Lane wrote: +> +> I'm inclined to suspect an issue with foreign-key checking. You didn't +> give us any details about foreign key relationships your "cust" table is +> involved in --- could we see those? And the schemas of the other tables +> involved? + +Two questions Tom: +1. Do the stats tables record FK checks, or just explicit table accesses? +2. If not, should they? + +If the only real activity is this update then simple before/after views of the +stats might be revealing. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Mar 17 11:16:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 07A1ED1CCD2 + for ; + Wed, 17 Mar 2004 15:16:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 43941-08 + for ; + Wed, 17 Mar 2004 11:16:43 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 668EBD1C4EB + for ; + Wed, 17 Mar 2004 11:16:39 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2HFGdkO025017; + Wed, 17 Mar 2004 10:16:40 -0500 (EST) +To: Richard Huxton +Cc: "Rosser Schwarz" , + pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +In-reply-to: <200403170911.37462.dev@archonet.com> +References: <001a01c40ae4$1cdd4160$2500fa0a@CardServices.TCI.com> + <8912.1079395699@sss.pgh.pa.us> + <200403170911.37462.dev@archonet.com> +Comments: In-reply-to Richard Huxton + message dated "Wed, 17 Mar 2004 09:11:37 +0000" +Date: Wed, 17 Mar 2004 10:16:39 -0500 +Message-ID: <25016.1079536599@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/237 +X-Sequence-Number: 6093 + +Richard Huxton writes: +> Two questions Tom: +> 1. Do the stats tables record FK checks, or just explicit table accesses? + +The stats record everything, IIRC. + +> If the only real activity is this update then simple before/after +> views of the stats might be revealing. + +That's quite a good thought, though since Rosser's system is live it +might be hard to get a view of just one query's activity. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 17 11:40:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 348FAD1E2E2 + for ; + Wed, 17 Mar 2004 15:40:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 51334-08 + for ; + Wed, 17 Mar 2004 11:40:41 -0400 (AST) +Received: from award.gotdns.org (pcp01097251pcs.tsclos01.al.comcast.net + [68.62.129.152]) + by svr1.postgresql.org (Postfix) with ESMTP id 401FCD1CCD2 + for ; + Wed, 17 Mar 2004 11:40:35 -0400 (AST) +Received: (qmail 8115 invoked by uid 81); 17 Mar 2004 09:40:35 -0600 +Received: from 68.62.129.152 (SquirrelMail authenticated user award) + by award.gotdns.org with HTTP; Wed, 17 Mar 2004 09:40:35 -0600 (CST) +Message-ID: <11658.68.62.129.152.1079538035.squirrel@award.gotdns.org> +In-Reply-To: <4057D8BD.4080902@joeconway.com> +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> + <4055F343.6070600@joeconway.com> <405614CA.5030101@zeut.net> + <405689A4.4080406@joeconway.com> <16735.1079414723@sss.pgh.pa.us> + <4057D8BD.4080902@joeconway.com> +Date: Wed, 17 Mar 2004 09:40:35 -0600 (CST) +Subject: Re: rapid degradation after postmaster restart +From: "Arthur Ward" +To: "Joe Conway" +Cc: "pgsql-performance" +User-Agent: SquirrelMail/1.4.2 +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/238 +X-Sequence-Number: 6094 + +> The problem with Jan's more complex version of the patch (at least the +> one I found - perhaps not the right one) is it includes a bunch of other +> experimental stuff that I'd not want to mess with at the moment. Would +> changing the input units (for the original patch) from milli-secs to +> micro-secs be a bad idea? If so, I guess I'll get to extracting what I +> need from Jan's patch. + +Jan's vacuum-delay-only patch that nobody can find is here: + +http://archives.postgresql.org/pgsql-hackers/2003-11/msg00518.php + +I've been using it in testing & production without any problems. + +From pgsql-performance-owner@postgresql.org Wed Mar 17 13:35:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CCDDD1CCD1 + for ; + Wed, 17 Mar 2004 17:33: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 00474-02 + for ; + Wed, 17 Mar 2004 13:33:39 -0400 (AST) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 8544CD1C9E1 + for ; + Wed, 17 Mar 2004 13:33:37 -0400 (AST) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i2HHXVAl021309; + Wed, 17 Mar 2004 11:33:31 -0600 +From: "Rosser Schwarz" +To: "'Tom Lane'" +Cc: +Subject: Re: atrocious update performance +Date: Wed, 17 Mar 2004 11:33:31 -0600 +Message-ID: <002a01c40c45$f736d8a0$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: <5349.1079486524@sss.pgh.pa.us> +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-MailScanner-From: rschwarz@totalcardinc.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/239 +X-Sequence-Number: 6095 + +while you weren't looking, Tom Lane wrote: + +> What's not immediately evident is whether the excess I/O accounted for +> all of the slowdown. Could you retry the strace with -r and -T options +> so we can see how much time is being spent inside and outside the +> syscalls? + +Unlike the previous run (this is a trace of the explain), this one went +immediately. No delay. + +I also have, per Aaron's request, a trace -ct against the backend running +the explain analyze. I killed it well before "a few minutes"; it's just +shy of 900K. I don't think I'll be forwarding that on to the list, though +I can put it up on a web server somewhere easily enough. + +Try . + +# `strace -rT -p 25075` + 0.000000 read(0, "\r", 1) =3D 1 <5.514983> + 5.516215 write(1, "\n", 1) =3D 1 <0.000034> + 0.000545 rt_sigprocmask(SIG_BLOCK, [INT], [33], 8) =3D 0 <0.000013> + 0.000200 ioctl(0, SNDCTL_TMR_STOP, {B38400 opost isig icanon echo ...}) +=3D 0 + <0.000032> + 0.000162 rt_sigprocmask(SIG_SETMASK, [33], NULL, 8) =3D 0 <0.000013> + 0.000120 rt_sigaction(SIGINT, {0x804d404, [], SA_RESTORER|SA_RESTART, +0x420 +276f8}, {0x401ec910, [], SA_RESTORER, 0x420276f8}, 8) =3D 0 <0.000015> + 0.000154 rt_sigaction(SIGTERM, {SIG_DFL}, {0x401ec910, [], SA_RESTORER, +0x4 +20276f8}, 8) =3D 0 <0.000014> + 0.000136 rt_sigaction(SIGQUIT, {SIG_DFL}, {0x401ec910, [], SA_RESTORER, +0x4 +20276f8}, 8) =3D 0 <0.000013> + 0.000134 rt_sigaction(SIGALRM, {SIG_DFL}, {0x401ec910, [], SA_RESTORER, +0x4 +20276f8}, 8) =3D 0 <0.000012> + 0.000164 rt_sigaction(SIGTSTP, {SIG_DFL}, {0x401ec910, [], SA_RESTORER, +0x4 +20276f8}, 8) =3D 0 <0.000013> + 0.000140 rt_sigaction(SIGTTOU, {SIG_DFL}, {0x401ec910, [], SA_RESTORER, +0x4 +20276f8}, 8) =3D 0 <0.000013> + 0.000135 rt_sigaction(SIGTTIN, {SIG_DFL}, {0x401ec910, [], SA_RESTORER, +0x4 +20276f8}, 8) =3D 0 <0.000013> + 0.000135 rt_sigaction(SIGWINCH, {SIG_DFL}, {0x401ec9d0, [], +SA_RESTORER, 0x +420276f8}, 8) =3D 0 <0.000014> + 0.000250 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) =3D 0 <0.00001= +3> + 0.000138 send(3, "Q\0\0\0}explain update account.cust"..., 126, 0) =3D +126 <0 +.000032> + 0.000164 rt_sigaction(SIGPIPE, {SIG_DFL}, {SIG_IGN}, 8) =3D 0 <0.00001= +3> + 0.000132 poll([{fd=3D3, events=3DPOLLIN|POLLERR, revents=3DPOLLIN}], 1= +, -1) =3D +1 < +0.222093> + 0.222388 recv(3, "T\0\0\0#\0\1QUERY +PLAN\0\0\0\0\0\0\0\0\0\0\31\377\377\377 +"..., 16384, 0) =3D 394 <0.000031> + 0.000360 ioctl(0, SNDCTL_TMR_TIMEBASE, {B38400 opost isig icanon echo +...}) + =3D 0 <0.000019> + 0.000137 ioctl(1, SNDCTL_TMR_TIMEBASE, {B38400 opost isig icanon echo +...}) + =3D 0 <0.000013> + 0.000135 ioctl(1, TIOCGWINSZ, {ws_row=3D64, ws_col=3D80, ws_xpixel=3D0, +ws_ypixel +=3D0}) =3D 0 <0.000015> + 0.000175 write(1, " "..., 92) =3D 92 +<0.000038 +> + 0.000184 write(1, "--------------------------------"..., 92) =3D 92 +<0.000025 +> + 0.000154 write(1, " Merge Join (cost=3D0.00..232764."..., 59) =3D 59 +<0.000023 +> + 0.000136 write(1, " Merge Cond: ((\"outer\".origid)"..., 65) =3D 65 +<0.0000 +23> + 0.000134 write(1, " -> Index Scan using ix_origi"..., 88) =3D 88 +<0.000025 +> + 0.000129 write(1, " -> Index Scan using ix_debti"..., 91) =3D 91 +<0.000025 +> + 0.000136 write(1, "(4 rows)\n", 9) =3D 9 <0.000022> + 0.000116 write(1, "\n", 1) =3D 1 <0.000021> + 0.000144 rt_sigprocmask(SIG_BLOCK, NULL, [33], 8) =3D 0 <0.000013> + 0.000121 rt_sigaction(SIGINT, {0x804d404, [], SA_RESTORER|SA_RESTART, +0x420 +276f8}, {0x804d404, [], SA_RESTORER|SA_RESTART, 0x420276f8}, 8) =3D 0 +<0.000015> + 0.000208 rt_sigprocmask(SIG_BLOCK, [INT], [33], 8) =3D 0 <0.000013> + 0.000129 ioctl(0, TIOCGWINSZ, {ws_row=3D64, ws_col=3D80, ws_xpixel=3D0, +ws_ypixel +=3D0}) =3D 0 <0.000013> + 0.000102 ioctl(0, TIOCSWINSZ, {ws_row=3D64, ws_col=3D80, ws_xpixel=3D0, +ws_ypixel +=3D0}) =3D 0 <0.000014> + 0.000105 ioctl(0, SNDCTL_TMR_TIMEBASE, {B38400 opost isig icanon echo +...}) + =3D 0 <0.000013> + 0.000127 ioctl(0, SNDCTL_TMR_STOP, {B38400 opost isig -icanon -echo +...}) =3D + 0 <0.000028> + 0.000147 rt_sigprocmask(SIG_SETMASK, [33], NULL, 8) =3D 0 <0.000012> + 0.000114 rt_sigaction(SIGINT, {0x401ec910, [], SA_RESTORER, +0x420276f8}, {0 +x804d404, [], SA_RESTORER|SA_RESTART, 0x420276f8}, 8) =3D 0 <0.000012> + 0.000149 rt_sigaction(SIGTERM, {0x401ec910, [], SA_RESTORER, +0x420276f8}, { +SIG_DFL}, 8) =3D 0 <0.000013> + 0.000136 rt_sigaction(SIGQUIT, {0x401ec910, [], SA_RESTORER, +0x420276f8}, { +SIG_DFL}, 8) =3D 0 <0.000012> + 0.000136 rt_sigaction(SIGALRM, {0x401ec910, [], SA_RESTORER, +0x420276f8}, { +SIG_DFL}, 8) =3D 0 <0.000012> + 0.000136 rt_sigaction(SIGTSTP, {0x401ec910, [], SA_RESTORER, +0x420276f8}, { +SIG_DFL}, 8) =3D 0 <0.000013> + 0.000136 rt_sigaction(SIGTTOU, {0x401ec910, [], SA_RESTORER, +0x420276f8}, { +SIG_DFL}, 8) =3D 0 <0.000012> + 0.000136 rt_sigaction(SIGTTIN, {0x401ec910, [], SA_RESTORER, +0x420276f8}, { +SIG_DFL}, 8) =3D 0 <0.000013> + 0.000212 rt_sigaction(SIGWINCH, {0x401ec9d0, [], SA_RESTORER, +0x420276f8}, +{SIG_DFL}, 8) =3D 0 <0.000012> + 0.000188 write(1, "\r\rtci=3D# \rtci=3D# ", 15) =3D 15 <0.000019> + 0.000112 rt_sigprocmask(SIG_BLOCK, NULL, [33], 8) =3D 0 <0.000012> + 0.000110 read(0, "\\", 1) =3D 1 <18.366895> + 18.368284 write(1, "\rtci=3D# \\\rtci=3D# \\", 16) =3D 16 <0.000029> + 0.000134 rt_sigprocmask(SIG_BLOCK, NULL, [33], 8) =3D 0 <0.000013> + 0.000125 read(0, "q", 1) =3D 1 <0.117572> + 0.117719 write(1, "\rtci=3D# \\q\rtci=3D# \\q", 18) =3D 18 <0.000020> + 0.000118 rt_sigprocmask(SIG_BLOCK, NULL, [33], 8) =3D 0 <0.000012> + 0.000107 read(0, "\r", 1) =3D 1 <1.767409> + 1.767604 write(1, "\n", 1) =3D 1 <0.000032> + 0.000140 rt_sigprocmask(SIG_BLOCK, [INT], [33], 8) =3D 0 <0.000013> + 0.000138 ioctl(0, SNDCTL_TMR_STOP, {B38400 opost isig icanon echo ...}) +=3D 0 + <0.000030> + 0.000143 rt_sigprocmask(SIG_SETMASK, [33], NULL, 8) =3D 0 <0.000013> + 0.000111 rt_sigaction(SIGINT, {0x804d404, [], SA_RESTORER|SA_RESTART, +0x420 +276f8}, {0x401ec910, [], SA_RESTORER, 0x420276f8}, 8) =3D 0 <0.000014> + 0.000153 rt_sigaction(SIGTERM, {SIG_DFL}, {0x401ec910, [], SA_RESTORER, +0x4 +20276f8}, 8) =3D 0 <0.000013> + 0.000134 rt_sigaction(SIGQUIT, {SIG_DFL}, {0x401ec910, [], SA_RESTORER, +0x4 +20276f8}, 8) =3D 0 <0.000013> + 0.000134 rt_sigaction(SIGALRM, {SIG_DFL}, {0x401ec910, [], SA_RESTORER, +0x4 +20276f8}, 8) =3D 0 <0.000013> + 0.000133 rt_sigaction(SIGTSTP, {SIG_DFL}, {0x401ec910, [], SA_RESTORER, +0x4 +20276f8}, 8) =3D 0 <0.000013> + 0.000134 rt_sigaction(SIGTTOU, {SIG_DFL}, {0x401ec910, [], SA_RESTORER, +0x4 +20276f8}, 8) =3D 0 <0.000013> + 0.000134 rt_sigaction(SIGTTIN, {SIG_DFL}, {0x401ec910, [], SA_RESTORER, +0x4 +20276f8}, 8) =3D 0 <0.000012> + 0.000134 rt_sigaction(SIGWINCH, {SIG_DFL}, {0x401ec9d0, [], +SA_RESTORER, 0x +420276f8}, 8) =3D 0 <0.000014> + 0.001271 rt_sigaction(SIGINT, {SIG_DFL}, {0x804d404, [], +SA_RESTORER|SA_RES +TART, 0x420276f8}, 8) =3D 0 <0.000013> + 0.000532 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) =3D 0 <0.00001= +4> + 0.000145 send(3, "X\0\0\0\4", 5, 0) =3D 5 <0.000028> + 0.000126 rt_sigaction(SIGPIPE, {SIG_DFL}, {SIG_IGN}, 8) =3D 0 <0.00001= +3> + 0.000140 close(3) =3D 0 <0.000033> + 0.000147 rt_sigaction(SIGPIPE, {SIG_DFL}, {SIG_DFL}, 8) =3D 0 <0.00001= +3> + 0.000197 open("/var/lib/pgsql/.psql_history", O_WRONLY|O_CREAT|O_TRUNC, +060 +0) =3D 3 <0.000168> + 0.000694 write(3, "\\d payment.batch\nalter sequence "..., 16712) =3D +16712 < +0.000209> + 0.000311 close(3) =3D 0 <0.000057> + 0.055587 munmap(0x40030000, 4096) =3D 0 <0.000032> + 0.000130 exit_group(0) =3D ? + +/rls + +-- +Rosser Schwarz +Total Card, Inc.=20 + + +From pgsql-performance-owner@postgresql.org Wed Mar 17 13:59:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E7A6D1B55E + for ; + Wed, 17 Mar 2004 17:58:14 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 07620-06 + for ; + Wed, 17 Mar 2004 13:58:12 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id C82B7D1B4D3 + for ; + Wed, 17 Mar 2004 13:58:09 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2HHw9aq026452; + Wed, 17 Mar 2004 12:58:09 -0500 (EST) +To: "Rosser Schwarz" +Cc: pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +In-reply-to: <002a01c40c45$f736d8a0$2500fa0a@CardServices.TCI.com> +References: <002a01c40c45$f736d8a0$2500fa0a@CardServices.TCI.com> +Comments: In-reply-to "Rosser Schwarz" + message dated "Wed, 17 Mar 2004 11:33:31 -0600" +Date: Wed, 17 Mar 2004 12:58:09 -0500 +Message-ID: <26451.1079546289@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/240 +X-Sequence-Number: 6096 + +"Rosser Schwarz" writes: +>> Could you retry the strace with -r and -T options + +> Unlike the previous run (this is a trace of the explain), this one went +> immediately. No delay. + +Hm. It looks like you mistakenly traced psql rather than the backend, +but since the delay went away we wouldn't have learned anything anyhow. +Have you got any idea what conditions may have changed between seeing +delay and not seeing delay? + +> I also have, per Aaron's request, a trace -ct against the backend running +> the explain analyze. I killed it well before "a few minutes"; it's just +> shy of 900K. I don't think I'll be forwarding that on to the list, though +> I can put it up on a web server somewhere easily enough. +> Try . + +This is pretty odd too. It looks like it's doing checkpoints every so +often (look for the writes to pg_control), which a backend engaged in +a long-running query surely ought not be doing. Need to think about +why that might be... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 17 14:18:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D085AD1B580 + for ; + Wed, 17 Mar 2004 18:11: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 10328-09 + for ; + Wed, 17 Mar 2004 14:11:24 -0400 (AST) +Received: from fep04-mail.bloor.is.net.cable.rogers.com + (fep04-mail.bloor.is.net.cable.rogers.com [66.185.86.74]) + by svr1.postgresql.org (Postfix) with ESMTP id C6514D1B4D3 + for ; + Wed, 17 Mar 2004 14:11:16 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep04-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040317181039.NESF3598.fep04-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Wed, 17 Mar 2004 13:10:39 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id BA8A23DC8; Wed, 17 Mar 2004 13:11:15 -0500 (EST) +Date: Wed, 17 Mar 2004 13:11:15 -0500 +From: Andrew Sullivan +To: pgsql-performance +Subject: Re: rapid degradation after postmaster restart +Message-ID: <20040317181115.GA7805@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance +References: <4052661D.5060505@joeconway.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4052661D.5060505@joeconway.com> +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep04-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Wed, + 17 Mar 2004 13:10:39 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/241 +X-Sequence-Number: 6097 + +Sorry I haven't had a chance to reply to this sooner. + +On Fri, Mar 12, 2004 at 05:38:37PM -0800, Joe Conway wrote: +> The problem is this: the application runs an insert, that fires off a +> trigger, that cascades into a fairly complex series of functions, that +> do a bunch of calculations, inserts, updates, and deletes. Immediately +> after a postmaster restart, the first insert or two take about 1.5 +> minutes (undoubtedly this could be improved, but it isn't the main +> issue). However by the second or third insert, the time increases to 7 - +> 9 minutes. Restarting the postmaster causes the cycle to repeat, i.e. +> the first one or two inserts are back to the 1.5 minute range. + +The vacuum delay stuff that you're working on may help, but I can't +really believe it's your salvation if this is happening after only a +few minutes. No matter how much you're doing inside those functions, +you surely can't be causing so many dead tuples that a vacuum is +necessary that soon. Did you try not vacuuming for a little while to +see if it helps? + +I didn't see it anywhere in this thread, but are you quite sure that +you're not swapping? Note that vmstat on multiprocessor Solaris +machines is not notoriously useful. You may want to have a look at +what the example stuff in the SE Toolkit tells you, or what you get +from sar. I believe you have to use a special kernel setting on +Solaris to mark shared memory as being ineligible for swap. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +This work was visionary and imaginative, and goes to show that visionary +and imaginative work need not end up well. + --Dennis Ritchie + +From pgsql-performance-owner@postgresql.org Wed Mar 17 14:42:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B7D35D1B580 + for ; + Wed, 17 Mar 2004 18:42: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 23245-03 + for ; + Wed, 17 Mar 2004 14:42:26 -0400 (AST) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 8E541D1E85C + for ; + Wed, 17 Mar 2004 14:42:23 -0400 (AST) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i2HIgMAl024345; + Wed, 17 Mar 2004 12:42:22 -0600 +From: "Rosser Schwarz" +To: "'Tom Lane'" +Cc: +Subject: Re: atrocious update performance +Date: Wed, 17 Mar 2004 12:42:22 -0600 +Message-ID: <002b01c40c4f$95d8a750$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: <26451.1079546289@sss.pgh.pa.us> +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-MailScanner-From: rschwarz@totalcardinc.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/242 +X-Sequence-Number: 6098 + +while you weren't looking, Tom Lane wrote: + +> Hm. It looks like you mistakenly traced psql rather than the backend, +> but since the delay went away we wouldn't have learned +> anything anyhow. +> Have you got any idea what conditions may have changed between seeing +> delay and not seeing delay? + +None, offhand. I have noticed that when a large query is running, +the machine can sporadically just freeze--or at least take inordinately +long for some other process, be it top or ls, another query, or whatever +to start. Nothing looks saturated when it happens, and, while you can +count on it to happen, it's not consistent enough to reproduce. + +> This is pretty odd too. It looks like it's doing checkpoints every so +> often (look for the writes to pg_control), which a backend engaged in +> a long-running query surely ought not be doing. Need to think about +> why that might be... + +Does the fact that all the reads and writes are 32K mean anything out +of the ordinary? $PGSRC/src/include/pg_config_manual.h has BLCKSZ +#defined to 16384. I was running previously with a 32K BLCKSZ, but +that turned out to be rather sub-optimal for as heavily indexed as our +tables are. I've dumped and rebuilt several times since then. + +/rls + +-- +Rosser Schwarz +Total Card, Inc. + + +From pgsql-performance-owner@postgresql.org Wed Mar 17 15:21:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 073F9D1B4D3 + for ; + Wed, 17 Mar 2004 19:21: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 35586-09 + for ; + Wed, 17 Mar 2004 15:21:11 -0400 (AST) +Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 47CBED1DB53 + for ; + Wed, 17 Mar 2004 15:21:09 -0400 (AST) +Received: from [206.19.64.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1092020; Wed, 17 Mar 2004 11:16:31 -0800 +Message-ID: <4058A4C8.7090108@joeconway.com> +Date: Wed, 17 Mar 2004 11:19:36 -0800 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Andrew Sullivan +Cc: pgsql-performance +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> + <20040317181115.GA7805@phlogiston.dyndns.org> +In-Reply-To: <20040317181115.GA7805@phlogiston.dyndns.org> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/243 +X-Sequence-Number: 6099 + +Andrew Sullivan wrote: +> Sorry I haven't had a chance to reply to this sooner. + +> The vacuum delay stuff that you're working on may help, but I can't +> really believe it's your salvation if this is happening after only a +> few minutes. No matter how much you're doing inside those functions, +> you surely can't be causing so many dead tuples that a vacuum is +> necessary that soon. Did you try not vacuuming for a little while to +> see if it helps? + +I discussed it later in the thread, but we're adding about 400K rows per +hour and deleting most of them after processing (note this is a +commercial app, written and maintained by another department -- I can +recommend changes, but this late into their release cycle they are very +reluctant to change the app). This is 7 x 24 data collection from +equipment, so there is no "slow" time to use as a maintenance window. + +But since the server in question is a test machine, I was able to shut +everything off long enough to do a full vacuum -- it took about 12 hours. + +> I didn't see it anywhere in this thread, but are you quite sure that +> you're not swapping? Note that vmstat on multiprocessor Solaris +> machines is not notoriously useful. You may want to have a look at +> what the example stuff in the SE Toolkit tells you, or what you get +> from sar. I believe you have to use a special kernel setting on +> Solaris to mark shared memory as being ineligible for swap. + +I'm (reasonably) sure there is no swapping. Minimum free memory (from +top) is about 800 MB, and "vmstat -S" shows no swap-in or swap-out. + +I've been playing with a version of Jan's performance patch in the past +few hours. Based on my simulations, it appears that a 1 ms delay every +10 pages is just about right. The performance hit is negligible (based +on overall test time, and cpu % used by the vacuum process). I still +have a bit more analysis to do, but this is looking pretty good. More +later... + +Joe + +From pgsql-performance-owner@postgresql.org Wed Mar 17 15:40:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 19705D1C9E6 + for ; + Wed, 17 Mar 2004 19:40: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 42795-06 + for ; + Wed, 17 Mar 2004 15:40:28 -0400 (AST) +Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) + by svr1.postgresql.org (Postfix) with ESMTP id 0712DD1B80B + for ; + Wed, 17 Mar 2004 15:40:27 -0400 (AST) +Received: from [206.19.64.3] (account jconway HELO joeconway.com) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 1092044; Wed, 17 Mar 2004 11:35:49 -0800 +Message-ID: <4058A94E.10808@joeconway.com> +Date: Wed, 17 Mar 2004 11:38:54 -0800 +From: Joe Conway +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; + rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Arthur Ward +Cc: pgsql-performance +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> <14884.1079150555@sss.pgh.pa.us> + <4055F343.6070600@joeconway.com> <405614CA.5030101@zeut.net> + <405689A4.4080406@joeconway.com> <16735.1079414723@sss.pgh.pa.us> + <4057D8BD.4080902@joeconway.com> + <11658.68.62.129.152.1079538035.squirrel@award.gotdns.org> +In-Reply-To: <11658.68.62.129.152.1079538035.squirrel@award.gotdns.org> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/244 +X-Sequence-Number: 6100 + +Arthur Ward wrote: +> Jan's vacuum-delay-only patch that nobody can find is here: +> +> http://archives.postgresql.org/pgsql-hackers/2003-11/msg00518.php +> +> I've been using it in testing & production without any problems. + +Great to know -- many thanks. + +I've hacked my own vacuum-delay-only patch form Jan's all_performance +patch. It looks like the only difference is that it uses usleep() +instead of select(). So far the tests look promising. + +Thanks, + +Joe + + +From pgsql-performance-owner@postgresql.org Wed Mar 17 15:48:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CA705D1C9E6 + for ; + Wed, 17 Mar 2004 19:48: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 43660-07 + for ; + Wed, 17 Mar 2004 15:48:36 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id A8838D1D2DB + for ; + Wed, 17 Mar 2004 15:48:34 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2HJmVcd027248; + Wed, 17 Mar 2004 14:48:31 -0500 (EST) +To: "Rosser Schwarz" +Cc: pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +In-reply-to: <002b01c40c4f$95d8a750$2500fa0a@CardServices.TCI.com> +References: <002b01c40c4f$95d8a750$2500fa0a@CardServices.TCI.com> +Comments: In-reply-to "Rosser Schwarz" + message dated "Wed, 17 Mar 2004 12:42:22 -0600" +Date: Wed, 17 Mar 2004 14:48:31 -0500 +Message-ID: <27247.1079552911@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/245 +X-Sequence-Number: 6101 + +"Rosser Schwarz" writes: +> while you weren't looking, Tom Lane wrote: +>> Have you got any idea what conditions may have changed between seeing +>> delay and not seeing delay? + +> None, offhand. I have noticed that when a large query is running, +> the machine can sporadically just freeze--or at least take inordinately +> long for some other process, be it top or ls, another query, or whatever +> to start. Nothing looks saturated when it happens, and, while you can +> count on it to happen, it's not consistent enough to reproduce. + +Interesting. You should leave "vmstat 1" running in the background and +see if you can correlate these freezes with bursts of disk I/O or swap. +I saw a couple of delays in your big strace that seemed odd --- a couple +of one-second-plus intervals, and a four-second-plus interval, with no +obvious reason for them. Perhaps the same issue? + +> Does the fact that all the reads and writes are 32K mean anything out +> of the ordinary? $PGSRC/src/include/pg_config_manual.h has BLCKSZ +> #defined to 16384. I was running previously with a 32K BLCKSZ, but +> that turned out to be rather sub-optimal for as heavily indexed as our +> tables are. I've dumped and rebuilt several times since then. + +I hate to break it to you, but that most definitely means you are +running with BLCKSZ = 32K. Whatever you thought you were rebuilding +didn't take effect. + +I agree that the larger blocksize is of dubious value. People used to +do that back when the blocksize limited your row width, but these days +I think you're probably best off with the standard 8K. + +Another thing that's fairly striking is the huge bursts of WAL activity +--- your trace shows that the thing is writing entire WAL segments (16 +MB) at one go, rather than dribbling it out a page or two at a time as +the code is intended to do. I think what is happening is that you have +wal_buffers = 1024 (correct?) yielding 32MB of WAL buffers, and since +there are no other transactions happening, nothing gets written until +you hit the "write when the buffers are half full" heuristic. I would +suggest knocking wal_buffers down to something closer to the default +(maybe 4 or 8 buffers) to reduce these I/O storms. (Memo to hackers: +we need to see to it that the new background writer process takes some +responsibility for pushing out filled WAL buffers, not only data +buffers.) + +If the big EXPLAIN ANALYZE is still running, would you get a dump of its +open files (see "lsof -p") and correlate those with the tables being +used in the query? I'm trying to figure out what the different writes +and reads represent. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 17 16:34:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F5FAD1E936 + for ; + Wed, 17 Mar 2004 20:34: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 67352-04 + for ; + Wed, 17 Mar 2004 16:34:12 -0400 (AST) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 0A34AD1E92B + for ; + Wed, 17 Mar 2004 16:34:10 -0400 (AST) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i2HKY7Al028802; + Wed, 17 Mar 2004 14:34:07 -0600 +From: "Rosser Schwarz" +To: "'Tom Lane'" +Cc: +Subject: Re: atrocious update performance +Date: Wed, 17 Mar 2004 14:34:07 -0600 +Message-ID: <002d01c40c5f$324b0420$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: <27247.1079552911@sss.pgh.pa.us> +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-MailScanner-From: rschwarz@totalcardinc.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/246 +X-Sequence-Number: 6102 + +while you weren't looking, Tom Lane wrote: + +> I hate to break it to you, but that most definitely means you are +> running with BLCKSZ = 32K. Whatever you thought you were rebuilding +> didn't take effect. + +I saw that and thought so. The other day, I was rooting around in +$PGDATA, and saw a lot of 32K files and wondered for a moment, too. +If that's the case, though, that's ... weird. + +> I agree that the larger blocksize is of dubious value. People used to +> do that back when the blocksize limited your row width, but these days +> I think you're probably best off with the standard 8K. + +I'd been experimenting with larger blocksizes after we started seeing +a lot of seqscans in query plans. 32K proved quickly that it hurts +index scan performance, so I was--I thought--trying 16. + +> If the big EXPLAIN ANALYZE is still running, would you get a dump of its +> open files (see "lsof -p") and correlate those with the tables being +> used in the query? I'm trying to figure out what the different writes +> and reads represent. + +It looks rather like it's hitting the foreign keys; one of the files +that shows is the account.note table, which has an fk to the pk of the +table being updated. The file's zero size, but it's open. The only +reason it should be open is if foreign keys are being checked, yes? + +You'd said that the foreign keys were only checked if last-change is +after current-query, as of 7.3.4, yes? `rpm -qa postgresql` comes up +with 7.3.2-3, which makes no sense, 'cos I know I removed it before +installing current; I remember making sure no-one was using pg on this +machine, and remember saying rpm -e. + +Regardless, something thinks it's still there. Is there any way that +it is, and that I've somehow been running 7.3.2 all along? `which +psql`, &c show the bindir from my configure, but I'm not sure that's +sufficient. + +How would I tell? I don't remember any of the binaries having a +--version argument. + +/rls + +-- +Rosser Schwarz +Total Card, Inc. + + +From pgsql-performance-owner@postgresql.org Wed Mar 17 16:43:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D63A8D1E943 + for ; + Wed, 17 Mar 2004 20:43: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 67561-07 + for ; + Wed, 17 Mar 2004 16:43:44 -0400 (AST) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 28B7FD1E90D + for ; + Wed, 17 Mar 2004 16:43:41 -0400 (AST) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i2HKheAl029243; + Wed, 17 Mar 2004 14:43:40 -0600 +From: "Rosser Schwarz" +To: "'Tom Lane'" +Cc: +Subject: Re: atrocious update performance +Date: Wed, 17 Mar 2004 14:43:36 -0600 +Message-ID: <002e01c40c60$87631d70$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: <002d01c40c5f$324b0420$2500fa0a@CardServices.TCI.com> +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-MailScanner-From: rschwarz@totalcardinc.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/247 +X-Sequence-Number: 6103 + +I wrote: + +> Regardless, something thinks it's still there. Is there any way that +> it is, and that I've somehow been running 7.3.2 all along? `which +> psql`, &c show the bindir from my configure, but I'm not sure that's +> sufficient. + +The weird thing is that I know I never built 7.3.anything with 32K +BLCKSZ, never built 7.3.anything at all. If 7.3 were installed, would +it have any problem reading a 7.4 cluster? + +/rls + +-- +Rosser Schwarz +Total Card, Inc. + + +From pgsql-performance-owner@postgresql.org Wed Mar 17 16:52:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A77D1D1E2AA + for ; + Wed, 17 Mar 2004 20: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 67561-10 + for ; + Wed, 17 Mar 2004 16:52:04 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 2019ED1D2DB + for ; + Wed, 17 Mar 2004 16:52:02 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2HKq2Wr027876; + Wed, 17 Mar 2004 15:52:03 -0500 (EST) +To: "Rosser Schwarz" +Cc: pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +In-reply-to: <002e01c40c60$87631d70$2500fa0a@CardServices.TCI.com> +References: <002e01c40c60$87631d70$2500fa0a@CardServices.TCI.com> +Comments: In-reply-to "Rosser Schwarz" + message dated "Wed, 17 Mar 2004 14:43:36 -0600" +Date: Wed, 17 Mar 2004 15:52:02 -0500 +Message-ID: <27875.1079556722@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/248 +X-Sequence-Number: 6104 + +"Rosser Schwarz" writes: +>> Regardless, something thinks it's still there. Is there any way that +>> it is, and that I've somehow been running 7.3.2 all along? `which +>> psql`, &c show the bindir from my configure, but I'm not sure that's +>> sufficient. + +"select version()" is the definitive test for backend version. + +> The weird thing is that I know I never built 7.3.anything with 32K +> BLCKSZ, never built 7.3.anything at all. If 7.3 were installed, would +> it have any problem reading a 7.4 cluster? + +7.3 would refuse to start on a 7.4 cluster, and vice versa. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 17 16:57:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1E04AD1D2DB + for ; + Wed, 17 Mar 2004 20:57: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 76161-02 + for ; + Wed, 17 Mar 2004 16:57:16 -0400 (AST) +Received: from outbound.mailhop.org (outbound.mailhop.org [63.208.196.171]) + by svr1.postgresql.org (Postfix) with ESMTP id 64990D1C4EB + for ; + Wed, 17 Mar 2004 16:57:14 -0400 (AST) +Received: from ool-4350c7ad.dyn.optonline.net ([67.80.199.173] helo=zeut.net) + by outbound.mailhop.org with asmtp (TLSv1:AES256-SHA:256) (Exim 4.20) + id 1B3i6C-0000bl-17; Wed, 17 Mar 2004 15:57:12 -0500 +Message-ID: <4058BBA5.4080002@zeut.net> +Date: Wed, 17 Mar 2004 15:57:09 -0500 +From: "Matthew T. O'Connor" +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Andrew Sullivan +Cc: pgsql-performance +Subject: Re: rapid degradation after postmaster restart +References: <4052661D.5060505@joeconway.com> + <20040317181115.GA7805@phlogiston.dyndns.org> +In-Reply-To: <20040317181115.GA7805@phlogiston.dyndns.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Mail-Handler: MailHop Outbound by DynDNS.org +X-Report-Abuse-To: abuse@dyndns.org +X-MHO-User: zeut +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/249 +X-Sequence-Number: 6105 + +Andrew Sullivan wrote: + +>The vacuum delay stuff that you're working on may help, but I can't +>really believe it's your salvation if this is happening after only a +>few minutes. No matter how much you're doing inside those functions, +>you surely can't be causing so many dead tuples that a vacuum is +>necessary that soon. Did you try not vacuuming for a little while to +>see if it helps? +> +> + +Some of this thread was taken off line so I'm not sure it was mentioned +on the list, but a big part of the problem was that Joe was running into +the same bug that Cott Lang ran into a while ago which caused the vacuum +threshold to get set far too low resulting in vacuums far too often.. +This has been fixed and the patch has been committed unfortunately it +didn't make it into 7.4.2, but it will be in 7.4.3 / 7.5. + +>I didn't see it anywhere in this thread, but are you quite sure that +>you're not swapping? Note that vmstat on multiprocessor Solaris +>machines is not notoriously useful. You may want to have a look at +>what the example stuff in the SE Toolkit tells you, or what you get +>from sar. I believe you have to use a special kernel setting on +>Solaris to mark shared memory as being ineligible for swap. +> +> + +I haven't heard from Joe how things are going with the fixed +pg_autovacuum but that in combination with the vacuum delay stuff should +work well. + +Matthew + + + + +From pgsql-performance-owner@postgresql.org Wed Mar 17 19:49:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 31BB0D1C9E6 + for ; + Wed, 17 Mar 2004 23:49: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 30160-01 + for ; + Wed, 17 Mar 2004 19:49:34 -0400 (AST) +Received: from auemail1.firewall.lucent.com (auemail1.lucent.com + [192.11.223.161]) + by svr1.postgresql.org (Postfix) with ESMTP id 3B582D1B560 + for ; + Wed, 17 Mar 2004 19:49:31 -0400 (AST) +Received: from ihmail.ih.lucent.com (h135-1-218-70.lucent.com [135.1.218.70]) + by auemail1.firewall.lucent.com (Switch-2.2.8/Switch-2.2.8) with + ESMTP id i2HNnTi01087 for ; + Wed, 17 Mar 2004 17:49:30 -0600 (CST) +Received: from [135.185.171.143] (USS-Excelsior.ih.lucent.com + [135.185.171.143]) by ihmail.ih.lucent.com (8.11.7+Sun/EMS-1.5 sol2) + id i2HNnSE20191; Wed, 17 Mar 2004 17:49:28 -0600 (CST) +Mime-Version: 1.0 +X-Sender: slgan@135.1.218.70 +Message-Id: +Date: Wed, 17 Mar 2004 17:52:13 -0600 +To: pgsql-performance@postgresql.org +From: Seum-Lim Gan +Subject: PostgreSQL Disk Usage and Page Size +Cc: ahsaleh@lucent.com +Content-Type: text/plain; charset="us-ascii" ; format="flowed" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/250 +X-Sequence-Number: 6106 + +Hi all, + +we have a question about the pagesize in PostgreSQL: + +Using different pagesizes: 4K, 8K, 16K, 32K, when we store different +record sizes +such as in the following example: + +CREATE TABLE TEST_1 ( +F1 VARCHAR(10), +F2 VARCHAR(5) ); + +CREATE TABLE TEST_2 ( +F1 VARCHAR(10), +F2 VARCHAR(10) ); + +we're consistently having the following storage behavior: + +60 records / 4k_page +120 records / 8k_page +240 records / 16k_page +480 records / 32k_page. + +So it seems that it doesn't matter whether the record size is +15 bytes or 20 bytes, there's maximum number of records per page +as shown above. + +Any clues if there's any parameter or bug causing that? + +Gan (for Amgad) +-- ++--------------------------------------------------------+ +| Seum-Lim GAN email : slgan@lucent.com | +| Lucent Technologies | +| 2000 N. Naperville Road, 6B-403F tel : (630)-713-6665 | +| Naperville, IL 60566, USA. fax : (630)-713-7272 | +| web : http://inuweb.ih.lucent.com/~slgan | ++--------------------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Wed Mar 17 20:08:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7CC66D1DF4D + for ; + Thu, 18 Mar 2004 00:08: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 31783-04 + for ; + Wed, 17 Mar 2004 20:08:02 -0400 (AST) +Received: from commsecure.com.au (CommSecureAustPtyLtd.sb1.optus.net.au + [203.202.148.106]) + by svr1.postgresql.org (Postfix) with ESMTP id A9703D1C9E6 + for ; + Wed, 17 Mar 2004 20:07:57 -0400 (AST) +Received: from [172.16.15.13] (ws12.commsecure.com.au [172.16.15.13]) + by commsecure.com.au (8.11.6/8.11.6) with ESMTP id i2I07ZV31135; + Thu, 18 Mar 2004 11:07:35 +1100 +Subject: Re: PostgreSQL Disk Usage and Page Size +From: Stephen Robert Norris +To: Seum-Lim Gan +Cc: pgsql-performance@postgresql.org, ahsaleh@lucent.com +In-Reply-To: +References: +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; + boundary="=-StJCWEB3WcFRnftYXnNK" +Organization: CommSecure Australia Pty Ltd +Message-Id: <1079568455.12785.3.camel@ws12.commsecure.com.au> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 (1.4.5-7) +Date: Thu, 18 Mar 2004 11:07:35 +1100 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/251 +X-Sequence-Number: 6107 + +--=-StJCWEB3WcFRnftYXnNK +Content-Type: text/plain +Content-Transfer-Encoding: quoted-printable + +On Thu, 2004-03-18 at 10:52, Seum-Lim Gan wrote: +> Hi all, +>=20 +> we have a question about the pagesize in PostgreSQL: +>=20 +> Using different pagesizes: 4K, 8K, 16K, 32K, when we store different=20 +> record sizes +> such as in the following example: +>=20 +> CREATE TABLE TEST_1 ( +> F1 VARCHAR(10), +> F2 VARCHAR(5) ); +>=20 +> CREATE TABLE TEST_2 ( +> F1 VARCHAR(10), +> F2 VARCHAR(10) ); +>=20 +> we're consistently having the following storage behavior: +>=20 +> 60 records / 4k_page +> 120 records / 8k_page +> 240 records / 16k_page +> 480 records / 32k_page. +>=20 +> So it seems that it doesn't matter whether the record size is +> 15 bytes or 20 bytes, there's maximum number of records per page +> as shown above. +>=20 +> Any clues if there's any parameter or bug causing that? +>=20 +> Gan (for Amgad) + +Well, you're size counts are completely wrong, for starters. + +Each varchar uses 4 bytes + length of the string, so that's 8 more bytes +per row. Then you may have an OID as well for another 4 bytes. I'd also +not be surprised if the length of the string is rounded up to the +nearest word (although I don't know if it is), and I'd be amazed if the +length of the record isn't rounded to some boundary too. + +There's a handy page in the documentation that talks about how to know +how big rows are, I suggest you start there... + + Stephen + +--=-StJCWEB3WcFRnftYXnNK +Content-Type: application/pgp-signature; name=signature.asc +Content-Description: This is a digitally signed message part + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.2.3 (GNU/Linux) + +iD8DBQBAWOhG4hFS2REFUecRAr5pAJwND6QRtsl6XafSFxuUArFyN7N0TQCcCA6R +2fEwsUrzWoWUiarfFdU2SPI= +=J1py +-----END PGP SIGNATURE----- + +--=-StJCWEB3WcFRnftYXnNK-- + + +From pgsql-performance-owner@postgresql.org Wed Mar 17 20:18:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 620D3D1B560 + for ; + Thu, 18 Mar 2004 00: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 36481-02 + for ; + Wed, 17 Mar 2004 20:18:04 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 3702ED1E90F + for ; + Wed, 17 Mar 2004 20:18:01 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 169993543E; Wed, 17 Mar 2004 16:18:02 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 14F883543D; Wed, 17 Mar 2004 16:18:02 -0800 (PST) +Date: Wed, 17 Mar 2004 16:18:02 -0800 (PST) +From: Stephan Szabo +To: Seum-Lim Gan +Cc: pgsql-performance@postgresql.org, ahsaleh@lucent.com +Subject: Re: PostgreSQL Disk Usage and Page Size +In-Reply-To: +Message-ID: <20040317160012.G32224@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: 200403/252 +X-Sequence-Number: 6108 + +On Wed, 17 Mar 2004, Seum-Lim Gan wrote: + +> we have a question about the pagesize in PostgreSQL: +> +> Using different pagesizes: 4K, 8K, 16K, 32K, when we store different +> record sizes +> such as in the following example: +> +> CREATE TABLE TEST_1 ( +> F1 VARCHAR(10), +> F2 VARCHAR(5) ); +> +> CREATE TABLE TEST_2 ( +> F1 VARCHAR(10), +> F2 VARCHAR(10) ); +> +> we're consistently having the following storage behavior: +> +> 60 records / 4k_page +> 120 records / 8k_page +> 240 records / 16k_page +> 480 records / 32k_page. +> +> So it seems that it doesn't matter whether the record size is +> 15 bytes or 20 bytes, there's maximum number of records per page +> as shown above. + +The rows aren't 15 or 20 bytes, they're something closer to: + +row header (24 bytes?) + f1 length (4 bytes) + actual bytes for f1 + +f2 length (4 bytes) + actual bytes for f2 +(I'm not sure about additional padding, but there's probably some to word +boundaries) + +And since you're using varchar, you won't see an actual row size +difference unless you're using different data between the two tables. + +If you're in a one byte encoding and putting in maximum length strings, +I'd expect something like 52 and 56 bytes for the above two tables. + +From pgsql-performance-owner@postgresql.org Thu Mar 18 01:03:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 71D4DD1DB53 + for ; + Thu, 18 Mar 2004 05:03: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 01001-08 + for ; + Thu, 18 Mar 2004 01:03:50 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id B0B7BD1E883 + for ; + Thu, 18 Mar 2004 01:03:48 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2I53lV9004895; + Thu, 18 Mar 2004 00:03:47 -0500 (EST) +To: Kris Jurka +Cc: pgsql-performance@postgresql.org +Subject: Re: severe performance issue with planner (fwd) +In-reply-to: +References: +Comments: In-reply-to Kris Jurka + message dated "Wed, 17 Mar 2004 02:33:44 -0500" +Date: Thu, 18 Mar 2004 00:03:47 -0500 +Message-ID: <4894.1079586227@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/253 +X-Sequence-Number: 6109 + +Kris Jurka writes: +> On Thu, 11 Mar 2004, Tom Lane wrote: +>> "Eric Brown" writes: +>>> [ planning a 9-table query takes too long ] +>> +>> See http://www.postgresql.org/docs/7.4/static/explicit-joins.html +>> for some useful tips. + +> Is this the best answer we've got? For me with an empty table this query +> takes 4 seconds to plan, is that the expected planning time? I know I've +> got nine table queries that don't take that long. + +The problem with this example is that it's a nine-way self-join. +Ordinarily the planner can eliminate many possible join paths at low +levels, because they are more expensive than other available options. +But in this situation all the available options have *exactly the same +cost estimate* because they are all founded on exactly the same statistics. +The planner fails to prune any of them and ends up making a random +choice after examining way too many alternatives. + +Maybe we should think about instituting a hard upper limit on the number +of alternatives considered. But I'm not sure what the consequences of +that would be. In the meantime, the answer for the OP is to arbitrarily +limit the number of join orders considered, as described in the +above-mentioned web page. With the given query constraints there's +really only one join order worth thinking about ... + +> Setting geqo_threshold less than 9, it takes 1 second to plan. Does this +> indicate that geqo_threshold is set too high, or is it a tradeoff between +> planning time and plan quality? + +Selecting the GEQO planner doesn't really matter here, because it has +no better clue about how to choose among a lot of alternatives with +identical cost estimates. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 18 12:56:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B402DD1B8F5 + for ; + Thu, 18 Mar 2004 16:56: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 35061-04 + for ; + Thu, 18 Mar 2004 12:56:05 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id DBA6BD1EB9B + for ; + Thu, 18 Mar 2004 12:56:00 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 5218C35762; Thu, 18 Mar 2004 08:56:03 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 508AE35441; Thu, 18 Mar 2004 08:56:03 -0800 (PST) +Date: Thu, 18 Mar 2004 08:56:03 -0800 (PST) +From: Stephan Szabo +To: "Saleh, Amgad H (Amgad)" +Cc: Seum-Lim Gan , + "'srn@commsecure.com.au'" , + pgsql-performance@postgresql.org +Subject: Re: PostgreSQL Disk Usage and Page Size +In-Reply-To: + +Message-ID: <20040318085310.S50452@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: 200403/254 +X-Sequence-Number: 6110 + +On Thu, 18 Mar 2004, Saleh, Amgad H (Amgad) wrote: + +> Stephan / Stephen +> +> We know about the overhead and do understand the math you've provided. +> This is not the question we're asking. We've just provided the table definitions as +> examples. +> +> The real question was, even with the 52 & 56 (assuming right),' I wouldn't get +> the same number of records per page for all 4k, 8k, 16k, and 32k pages. + +On my system, I don't using your tests, IIRC I got 134 with TEST_1 and +like 128 or so on TEST_2 when I used strings of maximum length for the +columns. + +> +> To make it more clear to you here's an example: +> +> For an 8k-page: we've got 120 records/page for both tables and other tables such as +> +> CREATE TABLE TEST_3 ( +> F1 VARCHAR(10), +> F2 VARCHAR(12) ); + +Are you storing the same data in all three tables or different data in all +three tables? That's important because there's no difference in length +between varchar(5) and varchar(12) when storing the same 5 character +string. + + +From pgsql-performance-owner@postgresql.org Thu Mar 18 13:34:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 3907DD1B80B; Thu, 18 Mar 2004 17:34: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 46844-03; Thu, 18 Mar 2004 13:34:50 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP + id 7754CD1BAC8; Thu, 18 Mar 2004 13:34:44 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i2IHYaR29308; + Thu, 18 Mar 2004 12:34:36 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403181734.i2IHYaR29308@candle.pha.pa.us> +Subject: Re: [HACKERS] fsync method checking +In-Reply-To: <46C15C39FEB2C44BA555E356FBCD6FA40184CF68@m0114.s-mxs.net> +To: Zeugswetter Andreas SB SD +Date: Thu, 18 Mar 2004 12:34:36 -0500 (EST) +Cc: Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +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: 200403/255 +X-Sequence-Number: 6111 + + +I have updated my program with your suggested changes and put in +src/tools/fsync. Please see how you like it. + +--------------------------------------------------------------------------- + +Zeugswetter Andreas SB SD wrote: +> +> > Running the attached test program shows on BSD/OS 4.3: +> > +> > write 0.000360 +> > write & fsync 0.001391 +> +> I think the "write & fsync" pays for the previous "write" test (same filename). +> +> > write, close & fsync 0.001308 +> > open o_fsync, write 0.000924 +> +> I have tried to modify the program to more closely resemble WAL +> writes (all writes to WAL are 8k), the file is usually already open, +> 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. +> +> Andreas + +Content-Description: test_sync1.c + +[ Attachment, skipping... ] + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Mar 18 13:46:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 3B40AD1C9E9; Thu, 18 Mar 2004 17:46: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 44918-10; Thu, 18 Mar 2004 13:46:24 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP + id 649BBD1E929; Thu, 18 Mar 2004 13:46:16 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i2IHkDA00975; + Thu, 18 Mar 2004 12:46:13 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403181746.i2IHkDA00975@candle.pha.pa.us> +Subject: Re: [HACKERS] fsync method checking +In-Reply-To: <200312120649.hBC6nQR15608@candle.pha.pa.us> +To: Bruce Momjian +Date: Thu, 18 Mar 2004 12:46:13 -0500 (EST) +Cc: Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +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: 200403/256 +X-Sequence-Number: 6112 + + +I have been poking around with our fsync default options to see if I can +improve them. One issue is that we never default to O_SYNC, but default +to O_DSYNC if it exists, which seems strange. + +What I did was to beef up my test program and get it into CVS for folks +to run. What I found was that different operating systems have +different optimal defaults. On BSD/OS and FreeBSD, fdatasync/fsync was +better, but on Linux, O_DSYNC/O_SYNC was faster. + +BSD/OS 4.3: + Simple write timing: + write 0.000055 + + Compare fsync before and after write's close: + write, fsync, close 0.000707 + write, close, fsync 0.000808 + + Compare one o_sync write to two: + one 16k o_sync write 0.009762 + two 8k o_sync writes 0.008799 + + Compare file sync methods with one 8k write: + (o_dsync unavailable) + open o_sync, write 0.000658 + (fdatasync unavailable) + write, fsync, 0.000702 + + Compare file sync methods with 2 8k writes: + (The fastest should be used for wal_sync_method) + (o_dsync unavailable) + open o_sync, write 0.010402 + (fdatasync unavailable) + write, fsync, 0.001025 + +This shows terrible O_SYNC performance for 2 8k writes, but is faster +for a single 8k write. Strange. + +FreeBSD 4.9: + Simple write timing: + write 0.000083 + + Compare fsync before and after write's close: + write, fsync, close 0.000412 + write, close, fsync 0.000453 + + Compare one o_sync write to two: + one 16k o_sync write 0.000409 + two 8k o_sync writes 0.000993 + + Compare file sync methods with one 8k write: + (o_dsync unavailable) + open o_sync, write 0.000683 + (fdatasync unavailable) + write, fsync, 0.000405 + + Compare file sync methods with 2 8k writes: + (o_dsync unavailable) + open o_sync, write 0.000789 + (fdatasync unavailable) + write, fsync, 0.000414 + +This shows fsync to be fastest in both cases. + +Linux 2.4.9: + Simple write timing: + write 0.000061 + + Compare fsync before and after write's close: + write, fsync, close 0.000398 + write, close, fsync 0.000407 + + Compare one o_sync write to two: + one 16k o_sync write 0.000570 + two 8k o_sync writes 0.000340 + + Compare file sync methods with one 8k write: + (o_dsync unavailable) + open o_sync, write 0.000166 + write, fdatasync 0.000462 + write, fsync, 0.000447 + + Compare file sync methods with 2 8k writes: + (o_dsync unavailable) + open o_sync, write 0.000334 + write, fdatasync 0.000445 + write, fsync, 0.000447 + +This shows O_SYNC to be fastest, even for 2 8k writes. + +This unapplied patch: + + ftp://candle.pha.pa.us/pub/postgresql/mypatches/fsync + +adds DEFAULT_OPEN_SYNC to the bsdi/freebsd/linux template files, which +controls the default for those platforms. Platforms with no template +default to fdatasync/fsync. + +Would other users run src/tools/fsync and report their findings so I can +update the template files for their OS's? This is a process similar to +our thread testing. + +Thanks. + +--------------------------------------------------------------------------- + +Bruce Momjian wrote: +> 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 + +> /* +> * 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); +> } + +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Mar 18 13:58:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 32E93D1C9EA + for ; + Thu, 18 Mar 2004 17:58: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 57371-03 + for ; + Thu, 18 Mar 2004 13:57:50 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 5D322D1C4EB + for ; + Thu, 18 Mar 2004 13:57:45 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 1F4DD357C4; Thu, 18 Mar 2004 09:57:50 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 1DC7235762; Thu, 18 Mar 2004 09:57:50 -0800 (PST) +Date: Thu, 18 Mar 2004 09:57:50 -0800 (PST) +From: Stephan Szabo +To: "Saleh, Amgad H (Amgad)" +Cc: Seum-Lim Gan , + "'srn@commsecure.com.au'" , + pgsql-performance@postgresql.org +Subject: Re: PostgreSQL Disk Usage and Page Size +In-Reply-To: + +Message-ID: <20040318095213.C51797@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: 200403/257 +X-Sequence-Number: 6113 + +On Thu, 18 Mar 2004, Saleh, Amgad H (Amgad) wrote: + +> +> Stephan: +> +> In each table we're storing the max. string length. +> +> For example: +> +> for TEST_1, we're storing 'abcdefghjk' and 'lmnop' +> for TEST_2, we're storing 'abcdefghjk' and 'lmnopqrstu' +> for TEST_3, we're storing 'abcdefghjk' and 'lmnopqrstuvw' + +Hmm, on my machine it seemed like I was getting slightly different row +count per page results for the first two cases. The last two aren't going +to be different due to padding if the machine pads to 4 byte boundaries. + + +From pgsql-hackers-owner@postgresql.org Thu Mar 18 14:23:27 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7BAAED1BA48 + for ; + Thu, 18 Mar 2004 18:23: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 65391-03 + for ; + Thu, 18 Mar 2004 14:23:21 -0400 (AST) +Received: from trolak.mydnsbox2.com (ns1.mydnsbox2.com [207.44.142.118]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E119D1B4D3 + for ; + Thu, 18 Mar 2004 14:23:14 -0400 (AST) +Received: from dunslane.net (cpe-024-211-141-025.nc.rr.com [24.211.141.25]) + (authenticated (0 bits)) + by trolak.mydnsbox2.com (8.11.6/8.11.6) with ESMTP id i2IJNNn04841 + for ; Thu, 18 Mar 2004 13:23:23 -0600 +Message-ID: <4059E912.2050509@dunslane.net> +Date: Thu, 18 Mar 2004 13:23:14 -0500 +From: Andrew Dunstan +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031114 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PostgreSQL-development +Subject: Re: fsync method checking +References: <200403181746.i2IHkDA00975@candle.pha.pa.us> +In-Reply-To: <200403181746.i2IHkDA00975@candle.pha.pa.us> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/815 +X-Sequence-Number: 51407 + + + +Bruce Momjian wrote: + +>I have been poking around with our fsync default options to see if I can +>improve them. One issue is that we never default to O_SYNC, but default +>to O_DSYNC if it exists, which seems strange. +> +>What I did was to beef up my test program and get it into CVS for folks +>to run. What I found was that different operating systems have +>different optimal defaults. On BSD/OS and FreeBSD, fdatasync/fsync was +>better, but on Linux, O_DSYNC/O_SYNC was faster. +> +>[snip] +> +>Linux 2.4.9: +> +> + +This is a pretty old kernel (I am writing from a machine running 2.4.22) + +Maybe before we do this for Linux testing on a more modern kernel might +be wise. + +cheers + +andrew + + +From pgsql-hackers-owner@postgresql.org Thu Mar 18 14:40:53 2004 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DCC7D1E2AA + for ; + Thu, 18 Mar 2004 18:40:50 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 69856-03 + for ; + Thu, 18 Mar 2004 14:40:45 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP id 7A298D1B4BA + for ; + Thu, 18 Mar 2004 14:40:38 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i2IIeh309334; + Thu, 18 Mar 2004 13:40:43 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403181840.i2IIeh309334@candle.pha.pa.us> +Subject: Re: fsync method checking +In-Reply-To: <4059E912.2050509@dunslane.net> +To: Andrew Dunstan +Date: Thu, 18 Mar 2004 13:40:43 -0500 (EST) +Cc: PostgreSQL-development +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: 200403/818 +X-Sequence-Number: 51410 + +Andrew Dunstan wrote: +> +> +> Bruce Momjian wrote: +> +> >I have been poking around with our fsync default options to see if I can +> >improve them. One issue is that we never default to O_SYNC, but default +> >to O_DSYNC if it exists, which seems strange. +> > +> >What I did was to beef up my test program and get it into CVS for folks +> >to run. What I found was that different operating systems have +> >different optimal defaults. On BSD/OS and FreeBSD, fdatasync/fsync was +> >better, but on Linux, O_DSYNC/O_SYNC was faster. +> > +> >[snip] +> > +> >Linux 2.4.9: +> > +> > +> +> This is a pretty old kernel (I am writing from a machine running 2.4.22) +> +> Maybe before we do this for Linux testing on a more modern kernel might +> be wise. + +Sure, I am sure someone will post results. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Mar 18 14:44:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 7AD7AD1E929; Thu, 18 Mar 2004 18:44: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 71161-03; Thu, 18 Mar 2004 14:44:09 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id 79F19D1E2AA; Thu, 18 Mar 2004 14:44:03 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2IIi2qf011044; + Thu, 18 Mar 2004 13:44:02 -0500 (EST) +To: Bruce Momjian +Cc: Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] fsync method checking +In-reply-to: <200403181746.i2IHkDA00975@candle.pha.pa.us> +References: <200403181746.i2IHkDA00975@candle.pha.pa.us> +Comments: In-reply-to Bruce Momjian + message dated "Thu, 18 Mar 2004 12:46:13 -0500" +Date: Thu, 18 Mar 2004 13:44:02 -0500 +Message-ID: <11043.1079635442@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/258 +X-Sequence-Number: 6114 + +Bruce Momjian writes: +> I have been poking around with our fsync default options to see if I can +> improve them. One issue is that we never default to O_SYNC, but default +> to O_DSYNC if it exists, which seems strange. + +As I recall, that was based on testing on some different platforms. +It's not particularly "strange": O_SYNC implies writing at least two +places on the disk (file and inode). O_DSYNC or fdatasync should +theoretically be the fastest alternatives, O_SYNC and fsync the worst. + +> Compare fsync before and after write's close: +> write, fsync, close 0.000707 +> write, close, fsync 0.000808 + +What does that mean? You can't fsync a closed file. + +> This shows terrible O_SYNC performance for 2 8k writes, but is faster +> for a single 8k write. Strange. + +I'm not sure I believe these numbers at all... my experience is that +getting trustworthy disk I/O numbers is *not* easy. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 18 15:07:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 316CDD1BA48; Thu, 18 Mar 2004 18:50: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 67802-10; Thu, 18 Mar 2004 14:50:41 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP + id 4FC4DD1EBBB; Thu, 18 Mar 2004 14:50:32 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i2IIoWo11126; + Thu, 18 Mar 2004 13:50:32 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403181850.i2IIoWo11126@candle.pha.pa.us> +Subject: Re: [HACKERS] fsync method checking +In-Reply-To: <11043.1079635442@sss.pgh.pa.us> +To: Tom Lane +Date: Thu, 18 Mar 2004 13:50:32 -0500 (EST) +Cc: Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +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: 200403/260 +X-Sequence-Number: 6116 + +Tom Lane wrote: +> Bruce Momjian writes: +> > I have been poking around with our fsync default options to see if I can +> > improve them. One issue is that we never default to O_SYNC, but default +> > to O_DSYNC if it exists, which seems strange. +> +> As I recall, that was based on testing on some different platforms. +> It's not particularly "strange": O_SYNC implies writing at least two +> places on the disk (file and inode). O_DSYNC or fdatasync should +> theoretically be the fastest alternatives, O_SYNC and fsync the worst. + +But why perfer O_DSYNC over fdatasync if you don't prefer O_SYNC over +fsync? + +> +> > Compare fsync before and after write's close: +> > write, fsync, close 0.000707 +> > write, close, fsync 0.000808 +> +> What does that mean? You can't fsync a closed file. + +You reopen and fsync. + +> > This shows terrible O_SYNC performance for 2 8k writes, but is faster +> > for a single 8k write. Strange. +> +> I'm not sure I believe these numbers at all... my experience is that +> getting trustworthy disk I/O numbers is *not* easy. + +These numbers were reproducable on all the platforms I tested. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Mar 18 15:00:56 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FAC4D1BA48 + for ; + Thu, 18 Mar 2004 18:52: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 75637-01 + for ; + Thu, 18 Mar 2004 14:52:46 -0400 (AST) +Received: from mail3.panix.com (mail3.panix.com [166.84.1.74]) + by svr1.postgresql.org (Postfix) with ESMTP id 249F8D1DD0F + for ; + Thu, 18 Mar 2004 14:52:40 -0400 (AST) +Received: from panix3.panix.com (panix3.panix.com [166.84.1.3]) + by mail3.panix.com (Postfix) with ESMTP id C37F29873F + for ; + Thu, 18 Mar 2004 13:52:37 -0500 (EST) +Received: (from adler@localhost) + by panix3.panix.com (8.11.6p2-a/8.8.8/PanixN1.1) id i2IIqbQ05537 + for pgsql-performance@postgresql.org; + Thu, 18 Mar 2004 13:52:37 -0500 (EST) +Date: Thu, 18 Mar 2004 13:52:37 -0500 +From: Michael Adler +To: pgsql-performance@postgresql.org +Subject: string casting for index usage +Message-ID: <20040318185237.GA3568@pobox.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/259 +X-Sequence-Number: 6115 + + +In porting an application from v7.2 and v7.3, I noticed that a join on a varchar column and a text column was ignoring indices that were helpful in v7.2. When I explicitly cast the text to a varchar (or set ENABLE_SEQSCAN TO false) the index is scanned and it works as efficiently as in v7.2. + +Obviously there were many casting improvements made in 7.3, but our application doesn't exactly see it that way. Is explicit casting the only solution (other than schema modification)? I haven't found anything in the documentation on this subject. + +Thanks, +Mike + +From pgsql-performance-owner@postgresql.org Mon Mar 22 11:14:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 499E3D1D613; Thu, 18 Mar 2004 19:18: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 85510-01; Thu, 18 Mar 2004 15:18:46 -0400 (AST) +Received: from poros.telenet-ops.be (poros.telenet-ops.be [195.130.132.44]) + by svr1.postgresql.org (Postfix) with ESMTP + id 23924D1BA68; Thu, 18 Mar 2004 15:18:40 -0400 (AST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by poros.telenet-ops.be (Postfix) with SMTP + id 57353380006; Thu, 18 Mar 2004 20:18:45 +0100 (MET) +Received: from kabel.telenet.be (D5767DEE.kabel.telenet.be [213.118.125.238]) + by poros.telenet-ops.be (Postfix) with ESMTP + id 8CA1C380263; Thu, 18 Mar 2004 20:18:44 +0100 (MET) +Received: by kabel.telenet.be (Postfix, from userid 501) + id 08EC6158AD5; Thu, 18 Mar 2004 20:18:40 +0100 (CET) +Date: Thu, 18 Mar 2004 20:18:40 +0100 +From: Kurt Roeckx +To: Bruce Momjian +Cc: Tom Lane , Mark Kirkwood , + pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] fsync method checking +Message-ID: <20040318191840.GA7088@ping.be> +References: <11043.1079635442@sss.pgh.pa.us> + <200403181850.i2IIoWo11126@candle.pha.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200403181850.i2IIoWo11126@candle.pha.pa.us> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/284 +X-Sequence-Number: 6140 + +On Thu, Mar 18, 2004 at 01:50:32PM -0500, Bruce Momjian wrote: +> > I'm not sure I believe these numbers at all... my experience is that +> > getting trustworthy disk I/O numbers is *not* easy. +> +> These numbers were reproducable on all the platforms I tested. + +It's not because they are reproducable that they mean anything in +the real world. + + +Kurt + + +From pgsql-performance-owner@postgresql.org Thu Mar 18 15:22:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 6DAE3D1B91B; Thu, 18 Mar 2004 19:22: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 85510-03; Thu, 18 Mar 2004 15:22:17 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP + id 987DBD1B4BA; Thu, 18 Mar 2004 15:22:10 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i2IJMAd16258; + Thu, 18 Mar 2004 14:22:10 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403181922.i2IJMAd16258@candle.pha.pa.us> +Subject: Re: [HACKERS] fsync method checking +In-Reply-To: <20040318191840.GA7088@ping.be> +To: Kurt Roeckx +Date: Thu, 18 Mar 2004 14:22:10 -0500 (EST) +Cc: Tom Lane , Mark Kirkwood , + pgsql-performance@postgresql.org, + PostgreSQL-development +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: 200403/261 +X-Sequence-Number: 6117 + +Kurt Roeckx wrote: +> On Thu, Mar 18, 2004 at 01:50:32PM -0500, Bruce Momjian wrote: +> > > I'm not sure I believe these numbers at all... my experience is that +> > > getting trustworthy disk I/O numbers is *not* easy. +> > +> > These numbers were reproducable on all the platforms I tested. +> +> It's not because they are reproducable that they mean anything in +> the real world. + +OK, what better test do you suggest? Right now, there has been no +testing of these. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Mar 18 15:28:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 50DB0D1B9BC; Thu, 18 Mar 2004 19:28: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 84155-07; Thu, 18 Mar 2004 15:28:14 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id 05266D1B4BA; Thu, 18 Mar 2004 15:28:07 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2IJS7N6011460; + Thu, 18 Mar 2004 14:28:07 -0500 (EST) +To: Bruce Momjian +Cc: Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] fsync method checking +In-reply-to: <200403181850.i2IIoWo11126@candle.pha.pa.us> +References: <200403181850.i2IIoWo11126@candle.pha.pa.us> +Comments: In-reply-to Bruce Momjian + message dated "Thu, 18 Mar 2004 13:50:32 -0500" +Date: Thu, 18 Mar 2004 14:28:07 -0500 +Message-ID: <11459.1079638087@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/262 +X-Sequence-Number: 6118 + +Bruce Momjian writes: +> Tom Lane wrote: +>> As I recall, that was based on testing on some different platforms. + +> But why perfer O_DSYNC over fdatasync if you don't prefer O_SYNC over +> fsync? + +It's what tested out as the best bet. I think we were using pgbench +as the test platform, which as you know I have doubts about, but at +least it is testing one actual write/sync pattern Postgres can generate. +The choice between the open flags and fdatasync/fsync depends a whole +lot on your writing patterns (how much data you tend to write between +fsync points), so I don't have a lot of faith in randomly-chosen test +programs as a guide to what to use for Postgres. + +>> What does that mean? You can't fsync a closed file. + +> You reopen and fsync. + +Um. I just looked at that test program, and I think it needs a whole +lot of work yet. + +* Some of the test cases count open()/close() overhead, some don't. + This is bad, especially on platforms like Solaris where open() is + notoriously expensive. + +* You really cannot put any faith in measuring a single write, + especially on a machine that's not *completely* idle otherwise. + I'd feel somewhat comfortable if you wrote, say, 1000 8K blocks and + measured the time for that. (And you have to think about how far + apart the fsyncs are in that sequence; you probably want to repeat the + measurement with several different fsync spacings.) It would also be + a good idea to compare writing 1000 successive blocks with rewriting + the same block 1000 times --- if the latter does not happen roughly + at the disk RPM rate, then we know the drive is lying and all the + numbers should be discarded as meaningless. + +* The program is claimed to test whether you can write from one process + and fsync from another, but it does no such thing AFAICS. + +BTW, rather than hard-wiring the test file name, why don't you let it be +specified on the command line? That would make it lots easier for +people to compare the performance of several disk drives, if they have +'em. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 18 15:55:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id B7482D1B580; Thu, 18 Mar 2004 19:55: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 94674-04; Thu, 18 Mar 2004 15:55:37 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP + id CC87ED1B4BA; Thu, 18 Mar 2004 15:55:29 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i2IJtT721737; + Thu, 18 Mar 2004 14:55:29 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403181955.i2IJtT721737@candle.pha.pa.us> +Subject: Re: [HACKERS] fsync method checking +In-Reply-To: <11459.1079638087@sss.pgh.pa.us> +To: Tom Lane +Date: Thu, 18 Mar 2004 14:55:29 -0500 (EST) +Cc: Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +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: 200403/263 +X-Sequence-Number: 6119 + +Tom Lane wrote: +> Bruce Momjian writes: +> > Tom Lane wrote: +> >> As I recall, that was based on testing on some different platforms. +> +> > But why perfer O_DSYNC over fdatasync if you don't prefer O_SYNC over +> > fsync? +> +> It's what tested out as the best bet. I think we were using pgbench +> as the test platform, which as you know I have doubts about, but at +> least it is testing one actual write/sync pattern Postgres can generate. +> The choice between the open flags and fdatasync/fsync depends a whole +> lot on your writing patterns (how much data you tend to write between +> fsync points), so I don't have a lot of faith in randomly-chosen test +> programs as a guide to what to use for Postgres. + +I assume pgbench has so much variance that trying to see fsync changes +in there would be hopeless. + +> >> What does that mean? You can't fsync a closed file. +> +> > You reopen and fsync. +> +> Um. I just looked at that test program, and I think it needs a whole +> lot of work yet. +> +> * Some of the test cases count open()/close() overhead, some don't. +> This is bad, especially on platforms like Solaris where open() is +> notoriously expensive. + +The only one I saw that had an extra open() was the fsync after close +test. I add a do-nothing open/close to the previous test so they are +the same. + +> * You really cannot put any faith in measuring a single write, +> especially on a machine that's not *completely* idle otherwise. +> I'd feel somewhat comfortable if you wrote, say, 1000 8K blocks and +> measured the time for that. (And you have to think about how far + +OK, it now measures a loop of 1000. + +> apart the fsyncs are in that sequence; you probably want to repeat the +> measurement with several different fsync spacings.) It would also be +> a good idea to compare writing 1000 successive blocks with rewriting +> the same block 1000 times --- if the latter does not happen roughly +> at the disk RPM rate, then we know the drive is lying and all the +> numbers should be discarded as meaningless. + + +> +> * The program is claimed to test whether you can write from one process +> and fsync from another, but it does no such thing AFAICS. + +It really just shows whether the fsync fater the close has similar +timing to the one before the close. That was the best way I could think +to test it. + +> BTW, rather than hard-wiring the test file name, why don't you let it be +> specified on the command line? That would make it lots easier for +> people to compare the performance of several disk drives, if they have +> 'em. + +I have updated the test program in CVS. + +New BSD/OS results: + +Simple write timing: + write 0.034801 + +Compare fsync times on write() and non-write() descriptor: +(If the times are similar, fsync() can sync data written + on a different descriptor.) + write, fsync, close 0.868831 + write, close, fsync 0.717281 + +Compare one o_sync write to two: + one 16k o_sync write 10.121422 + two 8k o_sync writes 4.405151 + +Compare file sync methods with one 8k write: + (o_dsync unavailable) + open o_sync, write 1.542213 + (fdatasync unavailable) + write, fsync, 1.703689 + +Compare file sync methods with 2 8k writes: +(The fastest should be used for wal_sync_method) + (o_dsync unavailable) + open o_sync, write 4.498607 + (fdatasync unavailable) + write, fsync, 2.473842 + +-- + 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 Mar 22 11:20:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id BEFA9D1BAC8; Thu, 18 Mar 2004 20:04: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 87755-10; Thu, 18 Mar 2004 16:04:06 -0400 (AST) +Received: from adicia.telenet-ops.be (adicia.telenet-ops.be [195.130.132.56]) + by svr1.postgresql.org (Postfix) with ESMTP + id D8FDAD1C9EA; Thu, 18 Mar 2004 16:03:55 -0400 (AST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by adicia.telenet-ops.be (Postfix) with SMTP + id 4B9121F7282; Thu, 18 Mar 2004 21:04:01 +0100 (MET) +Received: from kabel.telenet.be (D5767DEE.kabel.telenet.be [213.118.125.238]) + by adicia.telenet-ops.be (Postfix) with ESMTP + id 83E1B1F71EE; Thu, 18 Mar 2004 21:04:00 +0100 (MET) +Received: by kabel.telenet.be (Postfix, from userid 501) + id A9AFA158AD5; Thu, 18 Mar 2004 21:03:59 +0100 (CET) +Date: Thu, 18 Mar 2004 21:03:59 +0100 +From: Kurt Roeckx +To: Bruce Momjian +Cc: Tom Lane , Mark Kirkwood , + pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] fsync method checking +Message-ID: <20040318200359.GA8330@ping.be> +References: <20040318191840.GA7088@ping.be> + <200403181922.i2IJMAd16258@candle.pha.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200403181922.i2IJMAd16258@candle.pha.pa.us> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/287 +X-Sequence-Number: 6143 + +On Thu, Mar 18, 2004 at 02:22:10PM -0500, Bruce Momjian wrote: +> +> OK, what better test do you suggest? Right now, there has been no +> testing of these. + +I suggest you start by doing atleast preallocating a 16 MB file +and do the tests on that, to atleast be somewhat simular to what +WAL does. + +I have no idea what the access pattern is for normal WAL +operations or how many times it gets synched. Does it only do +f(data)sync() at commit time, or for every block it writes? + +I think if you write more data you'll see more differences +between O_(D)SYNC and f(data)sync(). + +I guess it can depend on if you have lots of small transactions, +or more big ones. + +Atleast try to make something that covers different access +patterns. + + +Kurt + + +From pgsql-performance-owner@postgresql.org Thu Mar 18 16:09:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id CB33AD1BA68; Thu, 18 Mar 2004 20:09: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 93313-08; Thu, 18 Mar 2004 16:09:03 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id 797C8D1D2BC; Thu, 18 Mar 2004 16:08:55 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2IK8nS1011719; + Thu, 18 Mar 2004 15:08:49 -0500 (EST) +To: Bruce Momjian +Cc: Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] fsync method checking +In-reply-to: <200403181955.i2IJtT721737@candle.pha.pa.us> +References: <200403181955.i2IJtT721737@candle.pha.pa.us> +Comments: In-reply-to Bruce Momjian + message dated "Thu, 18 Mar 2004 14:55:29 -0500" +Date: Thu, 18 Mar 2004 15:08:48 -0500 +Message-ID: <11718.1079640528@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/264 +X-Sequence-Number: 6120 + +Bruce Momjian writes: +> Tom Lane wrote: +>> It's what tested out as the best bet. I think we were using pgbench +>> as the test platform, which as you know I have doubts about, but at +>> least it is testing one actual write/sync pattern Postgres can generate. + +> I assume pgbench has so much variance that trying to see fsync changes +> in there would be hopeless. + +The results were fairly reproducible, as I recall; else we'd have looked +for another test method. You may want to go back and consult the +pghackers archives. + +>> * Some of the test cases count open()/close() overhead, some don't. + +> The only one I saw that had an extra open() was the fsync after close +> test. I add a do-nothing open/close to the previous test so they are +> the same. + +Why is it sensible to include open/close overhead in the "simple write" +case and not in the "o_sync write" cases, for instance? Doesn't seem +like a fair comparison to me. Adding the open overhead to all cases +might make it "fair", but it would also make it not what we want to +measure. + +>> * The program is claimed to test whether you can write from one process +>> and fsync from another, but it does no such thing AFAICS. + +> It really just shows whether the fsync fater the close has similar +> timing to the one before the close. That was the best way I could think +> to test it. + +Sure, but where's the "separate process" part? What this seems to test +is whether a single process can sync its own writes through a different +file descriptor; which is interesting but by no means the only thing we +need to be sure of if we want to make the bgwriter handle syncing. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 18 16:09:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 227F1D1BA48; Thu, 18 Mar 2004 20:09: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 91181-09; Thu, 18 Mar 2004 16:09:37 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP + id 42F16D1C9D7; Thu, 18 Mar 2004 16:09:27 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i2IK9PJ24080; + Thu, 18 Mar 2004 15:09:25 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403182009.i2IK9PJ24080@candle.pha.pa.us> +Subject: Re: [HACKERS] fsync method checking +In-Reply-To: <20040318200359.GA8330@ping.be> +To: Kurt Roeckx +Date: Thu, 18 Mar 2004 15:09:25 -0500 (EST) +Cc: Tom Lane , Mark Kirkwood , + pgsql-performance@postgresql.org, + PostgreSQL-development +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: 200403/265 +X-Sequence-Number: 6121 + +Kurt Roeckx wrote: +> On Thu, Mar 18, 2004 at 02:22:10PM -0500, Bruce Momjian wrote: +> > +> > OK, what better test do you suggest? Right now, there has been no +> > testing of these. +> +> I suggest you start by doing atleast preallocating a 16 MB file +> and do the tests on that, to atleast be somewhat simular to what +> WAL does. +> +> I have no idea what the access pattern is for normal WAL +> operations or how many times it gets synched. Does it only do +> f(data)sync() at commit time, or for every block it writes? +> +> I think if you write more data you'll see more differences +> between O_(D)SYNC and f(data)sync(). +> +> I guess it can depend on if you have lots of small transactions, +> or more big ones. +> +> Atleast try to make something that covers different access +> patterns. + +OK, I preallocated 16mb. New results: + +Simple write timing: + write 0.037900 + +Compare fsync times on write() and non-write() descriptor: +(If the times are similar, fsync() can sync data written + on a different descriptor.) + write, fsync, close 0.692942 + write, close, fsync 0.762524 + +Compare one o_sync write to two: + one 16k o_sync write 8.494621 + two 8k o_sync writes 4.177680 + +Compare file sync methods with one 8k write: + (o_dsync unavailable) + open o_sync, write 1.836835 + (fdatasync unavailable) + write, fsync, 1.780872 + +Compare file sync methods with 2 8k writes: +(The fastest should be used for wal_sync_method) + (o_dsync unavailable) + open o_sync, write 4.255614 + (fdatasync unavailable) + write, fsync, 2.120843 + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Mar 18 16:20:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 271D8D1E93F; Thu, 18 Mar 2004 20:20: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 06823-02; Thu, 18 Mar 2004 16:20:41 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id D65BDD1E2AA; Thu, 18 Mar 2004 16:20:31 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2IKKORt011817; + Thu, 18 Mar 2004 15:20:24 -0500 (EST) +To: Kurt Roeckx +Cc: Bruce Momjian , + Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] fsync method checking +In-reply-to: <20040318200359.GA8330@ping.be> +References: <20040318191840.GA7088@ping.be> + <200403181922.i2IJMAd16258@candle.pha.pa.us> + <20040318200359.GA8330@ping.be> +Comments: In-reply-to Kurt Roeckx + message dated "Thu, 18 Mar 2004 21:03:59 +0100" +Date: Thu, 18 Mar 2004 15:20:23 -0500 +Message-ID: <11816.1079641223@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/266 +X-Sequence-Number: 6122 + +Kurt Roeckx writes: +> I have no idea what the access pattern is for normal WAL +> operations or how many times it gets synched. Does it only do +> f(data)sync() at commit time, or for every block it writes? + +If we are using fsync/fdatasync, we issue those at commit time or when +completing a WAL segment. If we are using the open flags, then of +course there's no separate sync call. + +My previous point about checking different fsync spacings corresponds to +different assumptions about average transaction size. I think a useful +tool for determining wal_sync_method has got to be able to reflect that +range of possibilities. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 22 11:12:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 76473D1CA04; Thu, 18 Mar 2004 20:26: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 09466-02; Thu, 18 Mar 2004 16:26:28 -0400 (AST) +Received: from adicia.telenet-ops.be (adicia.telenet-ops.be [195.130.132.56]) + by svr1.postgresql.org (Postfix) with ESMTP + id 07EC3D1D120; Thu, 18 Mar 2004 16:26:21 -0400 (AST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by adicia.telenet-ops.be (Postfix) with SMTP + id 4C7051F738E; Thu, 18 Mar 2004 21:26:23 +0100 (MET) +Received: from kabel.telenet.be (D5767DEE.kabel.telenet.be [213.118.125.238]) + by adicia.telenet-ops.be (Postfix) with ESMTP + id 0D9641F7261; Thu, 18 Mar 2004 21:26:22 +0100 (MET) +Received: by kabel.telenet.be (Postfix, from userid 501) + id 8C538158AD5; Thu, 18 Mar 2004 21:26:21 +0100 (CET) +Date: Thu, 18 Mar 2004 21:26:21 +0100 +From: Kurt Roeckx +To: Bruce Momjian +Cc: Tom Lane , Mark Kirkwood , + pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] fsync method checking +Message-ID: <20040318202621.GB8330@ping.be> +References: <20040318200359.GA8330@ping.be> + <200403182009.i2IK9PJ24080@candle.pha.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200403182009.i2IK9PJ24080@candle.pha.pa.us> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/283 +X-Sequence-Number: 6139 + +Here are my results on Linux 2.6.1 using cvs version 1.7. + +Those times with > 20 seconds, you really hear the disk go crazy. + +And I have the feeling something must be wrong. Those results +are reproducible. + + +Kurt + + +Simple write timing: + write 0.139558 + +Compare fsync times on write() and non-write() descriptor: +(If the times are similar, fsync() can sync data written + on a different descriptor.) + write, fsync, close 8.249364 + write, close, fsync 8.356813 + +Compare one o_sync write to two: + one 16k o_sync write 28.487650 + two 8k o_sync writes 2.310304 + +Compare file sync methods with one 8k write: + (o_dsync unavailable) + open o_sync, write 1.010688 + write, fdatasync 25.109604 + write, fsync, 26.051218 + +Compare file sync methods with 2 8k writes: +(The fastest should be used for wal_sync_method) + (o_dsync unavailable) + open o_sync, write 2.212223 + write, fdatasync 27.439907 + write, fsync, 27.772294 + + +From pgsql-performance-owner@postgresql.org Thu Mar 18 16:34:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id EEF84D1E966; Thu, 18 Mar 2004 20:34: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 06132-07; Thu, 18 Mar 2004 16:34:44 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP + id 891FCD1E2AA; Thu, 18 Mar 2004 16:34:34 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i2IKYLp27844; + Thu, 18 Mar 2004 15:34:21 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403182034.i2IKYLp27844@candle.pha.pa.us> +Subject: Re: [HACKERS] fsync method checking +In-Reply-To: <20040318202621.GB8330@ping.be> +To: Kurt Roeckx +Date: Thu, 18 Mar 2004 15:34:21 -0500 (EST) +Cc: Tom Lane , Mark Kirkwood , + pgsql-performance@postgresql.org, + PostgreSQL-development +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: 200403/267 +X-Sequence-Number: 6123 + +Kurt Roeckx wrote: +> Here are my results on Linux 2.6.1 using cvs version 1.7. +> +> Those times with > 20 seconds, you really hear the disk go crazy. +> +> And I have the feeling something must be wrong. Those results +> are reproducible. +> + +Wow, your O_SYNC times are great. Where can I buy some? :-) + +Anyway, we do need to find a way to test this because obviously there is +huge platform variability. + +--------------------------------------------------------------------------- + + +> +> Kurt +> +> +> Simple write timing: +> write 0.139558 +> +> Compare fsync times on write() and non-write() descriptor: +> (If the times are similar, fsync() can sync data written +> on a different descriptor.) +> write, fsync, close 8.249364 +> write, close, fsync 8.356813 +> +> Compare one o_sync write to two: +> one 16k o_sync write 28.487650 +> two 8k o_sync writes 2.310304 +> +> Compare file sync methods with one 8k write: +> (o_dsync unavailable) +> open o_sync, write 1.010688 +> write, fdatasync 25.109604 +> write, fsync, 26.051218 +> +> Compare file sync methods with 2 8k writes: +> (The fastest should be used for wal_sync_method) +> (o_dsync unavailable) +> open o_sync, write 2.212223 +> write, fdatasync 27.439907 +> write, fsync, 27.772294 +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Mar 18 16:39:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 38F0ED1D2A0 + for ; + Thu, 18 Mar 2004 20:39:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 10148-04 + for ; + Thu, 18 Mar 2004 16:39:13 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 83CA4D1CCD6 + for ; + Thu, 18 Mar 2004 16:39:07 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2IKdC2e012026; + Thu, 18 Mar 2004 15:39:12 -0500 (EST) +To: Michael Adler +Cc: pgsql-performance@postgresql.org +Subject: Re: string casting for index usage +In-reply-to: <20040318185237.GA3568@pobox.com> +References: <20040318185237.GA3568@pobox.com> +Comments: In-reply-to Michael Adler + message dated "Thu, 18 Mar 2004 13:52:37 -0500" +Date: Thu, 18 Mar 2004 15:39:12 -0500 +Message-ID: <12025.1079642352@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/268 +X-Sequence-Number: 6124 + +Michael Adler writes: +> In porting an application from v7.2 and v7.3, I noticed that a join on a varchar column and a text column was ignoring indices that were helpful in v7.2. When I explicitly cast the text to a varchar (or set ENABLE_SEQSCAN TO false) the index is scanned and it works as efficiently as in v7.2. + +Maybe you should be moving to 7.4, instead. + +A desultory test didn't show any difference between 7.2.4 and 7.3.6 +in this respect, however. Perhaps you forgot to ANALYZE yet in the +new database? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 18 16:40:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 3EB78D1DB53; Thu, 18 Mar 2004 20:40: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 13118-02; Thu, 18 Mar 2004 16:40:47 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id 8A41ED1D549; Thu, 18 Mar 2004 16:40:40 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4648284; Thu, 18 Mar 2004 12:41:57 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Tom Lane , Kurt Roeckx +Subject: Re: [HACKERS] fsync method checking +Date: Thu, 18 Mar 2004 12:39:58 -0800 +User-Agent: KMail/1.5.4 +Cc: Bruce Momjian , + Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +References: <20040318191840.GA7088@ping.be> <20040318200359.GA8330@ping.be> + <11816.1079641223@sss.pgh.pa.us> +In-Reply-To: <11816.1079641223@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403181239.58226.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/269 +X-Sequence-Number: 6125 + +Tom, Bruce, + +> My previous point about checking different fsync spacings corresponds to +> different assumptions about average transaction size. I think a useful +> tool for determining wal_sync_method has got to be able to reflect that +> range of possibilities. + +Questions: +1) This is an OSS project. Why not just recruit a bunch of people on +PERFORMANCE and GENERAL to test the 4 different synch methods using real +databases? No test like reality, I say .... + +2) Won't Jan's work on 7.5 memory and I/O management mean that we have to +re-evaluate synching anyway? + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Thu Mar 18 16:56:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id C24D6D1E213; Thu, 18 Mar 2004 20:49: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 16957-02; Thu, 18 Mar 2004 16:49:33 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP + id 33425D1DC5D; Thu, 18 Mar 2004 16:49:26 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i2IKnKK00246; + Thu, 18 Mar 2004 15:49:20 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403182049.i2IKnKK00246@candle.pha.pa.us> +Subject: Re: [HACKERS] fsync method checking +In-Reply-To: <200403181239.58226.josh@agliodbs.com> +To: josh@agliodbs.com +Date: Thu, 18 Mar 2004 15:49:20 -0500 (EST) +Cc: Tom Lane , Kurt Roeckx , + Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +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: 200403/270 +X-Sequence-Number: 6126 + +Josh Berkus wrote: +> Tom, Bruce, +> +> > My previous point about checking different fsync spacings corresponds to +> > different assumptions about average transaction size. I think a useful +> > tool for determining wal_sync_method has got to be able to reflect that +> > range of possibilities. +> +> Questions: +> 1) This is an OSS project. Why not just recruit a bunch of people on +> PERFORMANCE and GENERAL to test the 4 different synch methods using real +> databases? No test like reality, I say .... + +Well, I wrote the program to allow testing. I don't see a complex test +as being that much better than simple one. We don't need accurate +numbers. We just need to know if fsync or O_SYNC is faster. + +> +> 2) Won't Jan's work on 7.5 memory and I/O management mean that we have to +> re-evaluate synching anyway? + +No, it should not change sync issues. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Mar 18 17:01:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id CA908D1EB9D; Thu, 18 Mar 2004 21:01: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 18050-06; Thu, 18 Mar 2004 17:01:09 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id 0676ED1E150; Thu, 18 Mar 2004 17:00:58 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2IL0s0b012262; + Thu, 18 Mar 2004 16:00:54 -0500 (EST) +To: josh@agliodbs.com +Cc: Kurt Roeckx , Bruce Momjian , + Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] fsync method checking +In-reply-to: <200403181239.58226.josh@agliodbs.com> +References: <20040318191840.GA7088@ping.be> <20040318200359.GA8330@ping.be> + <11816.1079641223@sss.pgh.pa.us> + <200403181239.58226.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Thu, 18 Mar 2004 12:39:58 -0800" +Date: Thu, 18 Mar 2004 16:00:54 -0500 +Message-ID: <12261.1079643654@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/271 +X-Sequence-Number: 6127 + +Josh Berkus writes: +> 1) This is an OSS project. Why not just recruit a bunch of people on +> PERFORMANCE and GENERAL to test the 4 different synch methods using real +> databases? No test like reality, I say .... + +I agree --- that is likely to yield *far* more useful results than +any standalone test program, for the purpose of finding out what +wal_sync_method to use in real databases. However, there's a second +issue here: we would like to move sync/checkpoint responsibility into +the bgwriter, and that requires knowing whether it's valid to let one +process fsync on behalf of writes that were done by other processes. +That's got nothing to do with WAL sync performance. I think that it +would be sensible to make a test program that focuses on this one +specific question. (There has been some handwaving to the effect that +everybody knows this is safe on Unixen, but I question whether the +handwavers have seen the internals of HPUX or AIX for instance; and +besides we need to worry about Windows now.) + +A third reason for having a simple test program is to confirm whether +your drives are syncing at all (cf. hdparm discussion). + +> 2) Won't Jan's work on 7.5 memory and I/O management mean that we have to +> re-evaluate synching anyway? + +So far nothing's been done that touches WAL writing. However, I am +thinking about making the bgwriter process take some of the load of +writing WAL buffers (right now it only writes data-file buffers). +And you're right, after that happens we will need to re-measure. +The open flags will probably become considerably more attractive than +they are now, if the bgwriter handles most non-commit writes of WAL. +(We might also think of letting the bgwriter use a different sync method +than the backends do.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 18 17:05:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 90F7ED1E15F; Thu, 18 Mar 2004 21:04: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 19940-06; Thu, 18 Mar 2004 17:04:58 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id EAD69D1E131; Thu, 18 Mar 2004 17:04:51 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2IL4jXD012316; + Thu, 18 Mar 2004 16:04:45 -0500 (EST) +To: Bruce Momjian +Cc: josh@agliodbs.com, Kurt Roeckx , + Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] fsync method checking +In-reply-to: <200403182049.i2IKnKK00246@candle.pha.pa.us> +References: <200403182049.i2IKnKK00246@candle.pha.pa.us> +Comments: In-reply-to Bruce Momjian + message dated "Thu, 18 Mar 2004 15:49:20 -0500" +Date: Thu, 18 Mar 2004 16:04:45 -0500 +Message-ID: <12315.1079643885@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/272 +X-Sequence-Number: 6128 + +Bruce Momjian writes: +> Well, I wrote the program to allow testing. I don't see a complex test +> as being that much better than simple one. We don't need accurate +> numbers. We just need to know if fsync or O_SYNC is faster. + +Faster than what? The thing everyone is trying to point out here is +that it depends on context, and we have little faith that this test +program creates a context similar to a live Postgres database. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 22 11:19:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id BFCEED1B904; Thu, 18 Mar 2004 21: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 18499-09; Thu, 18 Mar 2004 17:09:53 -0400 (AST) +Received: from apate.telenet-ops.be (apate.telenet-ops.be [195.130.132.57]) + by svr1.postgresql.org (Postfix) with ESMTP + id 84812D1B566; Thu, 18 Mar 2004 17:09:47 -0400 (AST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by apate.telenet-ops.be (Postfix) with SMTP + id 15C1D37FAF; Thu, 18 Mar 2004 22:09:54 +0100 (MET) +Received: from kabel.telenet.be (D5767DEE.kabel.telenet.be [213.118.125.238]) + by apate.telenet-ops.be (Postfix) with ESMTP + id 76305380C5; Thu, 18 Mar 2004 22:09:53 +0100 (MET) +Received: by kabel.telenet.be (Postfix, from userid 501) + id 16415158AD5; Thu, 18 Mar 2004 22:09:51 +0100 (CET) +Date: Thu, 18 Mar 2004 22:09:51 +0100 +From: Kurt Roeckx +To: Bruce Momjian +Cc: Tom Lane , Mark Kirkwood , + pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] fsync method checking +Message-ID: <20040318210951.GA8784@ping.be> +References: <20040318202621.GB8330@ping.be> + <200403182034.i2IKYLp27844@candle.pha.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200403182034.i2IKYLp27844@candle.pha.pa.us> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/286 +X-Sequence-Number: 6142 + +On Thu, Mar 18, 2004 at 03:34:21PM -0500, Bruce Momjian wrote: +> Kurt Roeckx wrote: +> > Here are my results on Linux 2.6.1 using cvs version 1.7. +> > +> > Those times with > 20 seconds, you really hear the disk go crazy. +> > +> > And I have the feeling something must be wrong. Those results +> > are reproducible. +> > +> +> Wow, your O_SYNC times are great. Where can I buy some? :-) +> +> Anyway, we do need to find a way to test this because obviously there is +> huge platform variability. + +New results with version 1.8: + +Simple write timing: + write 0.150613 + +Compare fsync times on write() and non-write() descriptor: +(If the times are similar, fsync() can sync data written + on a different descriptor.) + write, fsync, close 9.170472 + write, close, fsync 8.851715 + +Compare one o_sync write to two: + one 16k o_sync write 2.617860 + two 8k o_sync writes 2.563437 + +Compare file sync methods with one 8k write: + (o_dsync unavailable) + open o_sync, write 1.031721 + write, fdatasync 25.599010 + write, fsync, 26.192824 + +Compare file sync methods with 2 8k writes: +(The fastest should be used for wal_sync_method) + (o_dsync unavailable) + open o_sync, write 2.268718 + write, fdatasync 27.029396 + write, fsync, 27.399243 + + +From pgsql-performance-owner@postgresql.org Mon Mar 22 11:17:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id EF549D1E15F + for ; + Thu, 18 Mar 2004 21:24:06 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 24022-07 + for ; + Thu, 18 Mar 2004 17:24:07 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 4CC9DD1C4EB + for ; + Thu, 18 Mar 2004 17:24:01 -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 i2ILNw1Y016031 + for ; Thu, 18 Mar 2004 21:23:58 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i2ILLQua015797 + for pgsql-performance@postgresql.org; Thu, 18 Mar 2004 21:21:26 GMT +From: Joseph Shraibman +X-Newsgroups: comp.databases.postgresql.performance +Subject: two seperate queries run faster than queries ORed together +Date: Thu, 18 Mar 2004 16:21:32 -0500 +Organization: Hub.Org Networking Services +Lines: 50 +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 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/285 +X-Sequence-Number: 6141 + +explain +SELECT COUNT(u.ukey) FROM u, d WHERE d.ukey = u.ukey AND u.pkey = 260 +AND (u.status = 3 ) AND NOT u.boolfield ; + QUERY PLAN +---------------------------------------------------------------------------------------------- + Aggregate (cost=45707.84..45707.84 rows=1 width=4) + -> Nested Loop (cost=0.00..45707.16 rows=273 width=4) + -> Seq Scan on usertable u (cost=0.00..44774.97 rows=272 +width=4) + Filter: ((pkey = 260) AND (status = 3) AND (NOT boolfield)) + -> Index Scan using d_pkey on d (cost=0.00..3.41 rows=1 width=4) + Index Cond: (d.ukey = "outer".ukey) + + +explain +SELECT COUNT(u.ukey) FROM u, d WHERE d.ukey = u.ukey AND u.pkey = 260 +AND (d.status = 3 ) AND NOT u.boolfield ; + + QUERY PLAN +---------------------------------------------------------------------------------------------- + Aggregate (cost=28271.38..28271.38 rows=1 width=4) + -> Nested Loop (cost=0.00..28271.38 rows=1 width=4) + -> Seq Scan on d (cost=0.00..28265.47 rows=1 width=4) + Filter: (status = 3) + -> Index Scan using u_pkey on u (cost=0.00..5.89 rows=1 width=4) + Index Cond: (("outer".ukey = u.ukey) AND (u.pkey = 260)) + Filter: (NOT boolfield) + + +explain +SELECT COUNT(u.ukey) FROM u, d WHERE d.ukey = u.ukey AND u.pkey = 260 +AND (u.status = 3 OR d.status = 3 ) AND NOT u.boolfield ; + + + QUERY PLAN +--------------------------------------------------------------------------------------- + Aggregate (cost=128867.45..128867.45 rows=1 width=4) + -> Hash Join (cost=32301.47..128866.77 rows=272 width=4) + Hash Cond: ("outer".ukey = "inner".ukey) + Join Filter: (("inner".status = 3) OR ("outer".status = 3)) + -> Seq Scan on u (cost=0.00..41215.97 rows=407824 width=6) + Filter: ((pkey = 260) AND (NOT boolfield)) + -> Hash (cost=25682.98..25682.98 rows=1032998 width=6) + -> Seq Scan on d (cost=0.00..25682.98 rows=1032998 +width=6) + + +... so what do I do? It would be a real pain to rewrite this query to +run twice and add the results up, especially since I don't always know +beforehand when it will be faster based on different values to the query. + +From pgsql-performance-owner@postgresql.org Thu Mar 18 20:41:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 4B315D1E943; Fri, 19 Mar 2004 00:41:08 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 85690-03; Thu, 18 Mar 2004 20:41:13 -0400 (AST) +Received: from filer (c-24-6-183-218.client.comcast.net [24.6.183.218]) + by svr1.postgresql.org (Postfix) with ESMTP + id DB256D1E93F; Thu, 18 Mar 2004 20:41:05 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) (uid 1000) + by filer with local; Thu, 18 Mar 2004 16:41:12 -0800 +Date: Thu, 18 Mar 2004 16:41:12 -0800 +From: Kevin Brown +To: pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] fsync method checking +Message-ID: <20040319004112.GA19547@filer> +Mail-Followup-To: Kevin Brown , + pgsql-performance@postgresql.org, + PostgreSQL-development +References: <200403182049.i2IKnKK00246@candle.pha.pa.us> + <12315.1079643885@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +In-Reply-To: <12315.1079643885@sss.pgh.pa.us> +Organization: Frobozzco International +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/273 +X-Sequence-Number: 6129 + +Tom Lane wrote: +> Bruce Momjian writes: +> > Well, I wrote the program to allow testing. I don't see a complex test +> > as being that much better than simple one. We don't need accurate +> > numbers. We just need to know if fsync or O_SYNC is faster. +> +> Faster than what? The thing everyone is trying to point out here is +> that it depends on context, and we have little faith that this test +> program creates a context similar to a live Postgres database. + +Note, too, that the preferred method isn't likely to depend just on the +operating system, it's likely to depend also on the filesystem type +being used. + +Linux provides quite a few of them: ext2, ext3, jfs, xfs, and reiserfs, +and that's just off the top of my head. I imagine the performance of +the various syncing methods will vary significantly between them. + + +It seems reasonable to me that decisions such as which sync method to +use should initially be made at installation time: have the test program +run on the target filesystem as part of the installation process, and +build the initial postgresql.conf based on the results. You might even +be able to do some additional testing such as measuring the difference +between random block access and sequential access, and again feed the +results into the postgresql.conf file. This is no substitute for +experience with the platform, but I expect it's likely to get you closer +to something optimal than doing nothing. The only question, of course, +is whether or not it's worth going to the effort when it may or may not +gain you a whole lot. Answering that is going to require some +experimentation with such an automatic configuration system. + + + +-- +Kevin Brown kevin@sysexperts.com + +From pgsql-performance-owner@postgresql.org Thu Mar 18 21:34:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 33C3DD1DD0F + for ; + Fri, 19 Mar 2004 01:34: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 97106-06 + for ; + Thu, 18 Mar 2004 21:34:32 -0400 (AST) +Received: from hotmail.com (bay13-f69.bay13.hotmail.com [64.4.31.69]) + by svr1.postgresql.org (Postfix) with ESMTP id 1D1E1D1DC9E + for ; + Thu, 18 Mar 2004 21:34:24 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Thu, 18 Mar 2004 17:23:52 -0800 +Received: from 68.38.165.44 by by13fd.bay13.hotmail.msn.com with HTTP; + Fri, 19 Mar 2004 01:23:52 GMT +X-Originating-IP: [68.38.165.44] +X-Originating-Email: [bigwhitecow@hotmail.com] +X-Sender: bigwhitecow@hotmail.com +From: "Eric Brown" +To: pgsql-performance@postgresql.org +Subject: Re: severe performance issue with planner (fwd) +Date: Thu, 18 Mar 2004 20:23:52 -0500 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +Message-ID: +X-OriginalArrivalTime: 19 Mar 2004 01:23:52.0835 (UTC) + FILETIME=[D6F82D30:01C40D50] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/274 +X-Sequence-Number: 6130 + +I think i just sent an email out to the qrong person.. so if this ends up in +the list 2x i'm very sorry: + +i changed the query to:SELECT +w8.wid, +w8.variant, +w8.num_variants, +sum_text(w8.unicode) as unicodes, +sum_text(w8.pinyin) as pinyins +FROM +words as w0 JOIN words as w1 ON(w1.wid = w0.wid AND w1.variant = w0.variant +AND w1.sequence = w0.sequence + 1 AND w1.pinyin LIKE 'fu_') +JOIN words as w2 ON(w2.wid = w1.wid AND w2.variant = w1.variant AND +w2.sequence = w1.sequence + 1 AND w2.pinyin LIKE 'ji_') +JOIN words as w3 ON(w3.wid = w2.wid AND w3.variant = w2.variant AND +w3.sequence = w2.sequence + 1 AND w3.pinyin LIKE 'guan_') +JOIN words as w4 ON(w4.wid = w3.wid AND w4.variant = w3.variant AND +w4.sequence = w3.sequence + 1 AND w4.pinyin LIKE 'kai_') +JOIN words as w5 ON(w5.wid = w4.wid AND w5.variant = w4.variant AND +w5.sequence = w4.sequence + 1 AND w5.pinyin LIKE 'fang_') +JOIN words as w6 ON(w6.wid = w5.wid AND w6.variant = w5.variant AND +w6.sequence = w5.sequence + 1 AND w6.pinyin LIKE 'xi_') +JOIN words as w7 ON(w7.wid = w6.wid AND w7.variant = w6.variant AND +w7.sequence = w6.sequence + 1 AND w7.pinyin LIKE 'tong_') +JOIN words as w8 ON(w8.wid = w7.wid AND w8.variant = w7.variant) +WHERE +w0.wid > 0 AND +w0.pinyin = 'zheng4' AND +w0.def_exists = 't' AND +w0.sequence = 0 +GROUP BY +w8.wid, +w8.variant, +w8.num_variants, +w8.page_order, +w0.sequence , +w1.sequence , +w2.sequence , +w3.sequence , +w4.sequence , +w5.sequence , +w6.sequence , +w7.sequence +ORDER BY +w8.page_order; + + +and this cuts the time from 2900ms to about 1200ms. Is there any way to get +better time since the prepared statements for this explicit join query is +about 320ms... + +thx so far guys + + + +> +>Kris Jurka writes: +> > On Thu, 11 Mar 2004, Tom Lane wrote: +> >> "Eric Brown" writes: +> >>> [ planning a 9-table query takes too long ] +> >> +> >> See http://www.postgresql.org/docs/7.4/static/explicit-joins.html +> >> for some useful tips. +> +> > Is this the best answer we've got? For me with an empty table this +>query +> > takes 4 seconds to plan, is that the expected planning time? I know +>I've +> > got nine table queries that don't take that long. +> +>The problem with this example is that it's a nine-way self-join. +>Ordinarily the planner can eliminate many possible join paths at low +>levels, because they are more expensive than other available options. +>But in this situation all the available options have *exactly the same +>cost estimate* because they are all founded on exactly the same statistics. +>The planner fails to prune any of them and ends up making a random +>choice after examining way too many alternatives. +> +>Maybe we should think about instituting a hard upper limit on the number +>of alternatives considered. But I'm not sure what the consequences of +>that would be. In the meantime, the answer for the OP is to arbitrarily +>limit the number of join orders considered, as described in the +>above-mentioned web page. With the given query constraints there's +>really only one join order worth thinking about ... +> +> > Setting geqo_threshold less than 9, it takes 1 second to plan. Does +>this +> > indicate that geqo_threshold is set too high, or is it a tradeoff +>between +> > planning time and plan quality? +> +>Selecting the GEQO planner doesn't really matter here, because it has +>no better clue about how to choose among a lot of alternatives with +>identical cost estimates. +> +> regards, tom lane +> +>---------------------------(end of broadcast)--------------------------- +>TIP 8: explain analyze is your friend + +_________________________________________________________________ +FREE pop-up blocking with the new MSN Toolbar � get it now! +http://clk.atdmt.com/AVE/go/onm00200415ave/direct/01/ + + +From pgsql-performance-owner@postgresql.org Thu Mar 18 21:59:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3BCDCD1B904 + for ; + Fri, 19 Mar 2004 01:59: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 06230-05 + for ; + Thu, 18 Mar 2004 21:59:39 -0400 (AST) +Received: from hotmail.com (bay13-f111.bay13.hotmail.com [64.4.31.111]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C61AD1B566 + for ; + Thu, 18 Mar 2004 21:59:31 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Thu, 18 Mar 2004 17:59:40 -0800 +Received: from 68.38.165.44 by by13fd.bay13.hotmail.msn.com with HTTP; + Fri, 19 Mar 2004 01:59:39 GMT +X-Originating-IP: [68.38.165.44] +X-Originating-Email: [bigwhitecow@hotmail.com] +X-Sender: bigwhitecow@hotmail.com +From: "Eric Brown" +To: pgsql-performance@postgresql.org +Subject: Re: severe performance issue with planner (fwd) +Date: Thu, 18 Mar 2004 20:59:39 -0500 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +Message-ID: +X-OriginalArrivalTime: 19 Mar 2004 01:59:40.0253 (UTC) + FILETIME=[D6EE28D0:01C40D55] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/275 +X-Sequence-Number: 6131 + +I also tried this (printf1 in irc suggested "folding" the joins) : + +SELECT +w8.wid, +w8.variant, +w8.num_variants, +sum_text(w8.unicode) as unicodes, +sum_text(w8.pinyin) as pinyins +FROM +(words as w8 JOIN +(words as w7 JOIN +(words as w6 JOIN +(words as w5 JOIN +(words as w4 JOIN +(words as w3 JOIN +(words as w2 JOIN +(words as w0 JOIN words as w1 + +ON(w1.wid = w0.wid AND w1.variant = w0.variant AND w1.sequence = w0.sequence ++ 1 AND w1.pinyin LIKE 'fu_')) +ON(w2.wid = w1.wid AND w2.variant = w1.variant AND w2.sequence = w1.sequence ++ 1 AND w2.pinyin LIKE 'ji_')) +ON(w3.wid = w2.wid AND w3.variant = w2.variant AND w3.sequence = w2.sequence ++ 1 AND w3.pinyin LIKE 'guan_')) +ON(w4.wid = w3.wid AND w4.variant = w3.variant AND w4.sequence = w3.sequence ++ 1 AND w4.pinyin LIKE 'kai_')) +ON(w5.wid = w4.wid AND w5.variant = w4.variant AND w5.sequence = w4.sequence ++ 1 AND w5.pinyin LIKE 'fang_')) +ON(w6.wid = w5.wid AND w6.variant = w5.variant AND w6.sequence = w5.sequence ++ 1 AND w6.pinyin LIKE 'xi_')) +ON(w7.wid = w6.wid AND w7.variant = w6.variant AND w7.sequence = w6.sequence ++ 1 AND w7.pinyin LIKE 'tong_')) +ON(w8.wid = w7.wid AND w8.variant = w7.variant)) + + +WHERE +w0.wid > 0 AND +w0.pinyin = 'zheng4' AND +w0.def_exists = 't' AND +w0.sequence = 0 +GROUP BY +w8.wid, +w8.variant, +w8.num_variants, +w8.page_order, +w0.sequence , +w1.sequence , +w2.sequence , +w3.sequence , +w4.sequence , +w5.sequence , +w6.sequence , +w7.sequence +ORDER BY +w8.page_order; + + +this gets teh time down to 800ms (not too shabby..).. and as a prepared +statement, it only takes 15ms!!! i am hopeful there is a way to totally +bypass most of this overhead.. but i need more help :\ + +_________________________________________________________________ +MSN Toolbar provides one-click access to Hotmail from any Web page � FREE +download! http://clk.atdmt.com/AVE/go/onm00200413ave/direct/01/ + + +From pgsql-performance-owner@postgresql.org Fri Mar 19 00:08:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id B7AA0D1E213; Fri, 19 Mar 2004 04:08: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 37752-07; Fri, 19 Mar 2004 00:08:41 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP + id E349AD1DF8E; Fri, 19 Mar 2004 00:08:39 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i2J48VO12436; + Thu, 18 Mar 2004 23:08:31 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403190408.i2J48VO12436@candle.pha.pa.us> +Subject: Re: [HACKERS] fsync method checking +In-Reply-To: <11718.1079640528@sss.pgh.pa.us> +To: Tom Lane +Date: Thu, 18 Mar 2004 23:08:31 -0500 (EST) +Cc: Mark Kirkwood , pgsql-performance@postgresql.org, + PostgreSQL-development +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: 200403/276 +X-Sequence-Number: 6132 + +Tom Lane wrote: +> > It really just shows whether the fsync fater the close has similar +> > timing to the one before the close. That was the best way I could think +> > to test it. +> +> Sure, but where's the "separate process" part? What this seems to test +> is whether a single process can sync its own writes through a different +> file descriptor; which is interesting but by no means the only thing we +> need to be sure of if we want to make the bgwriter handle syncing. + +I am not sure how to easily test if a separate process can do the same. +I am sure it can be done, but for me it was enough to see that it works +in a single process. Unix isn't very process-centered for I/O, so I +don't think it would make much of a difference. Now, Win32, that might +be an issue. + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Fri Mar 19 00:23:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ED1AFD1E14C + for ; + Fri, 19 Mar 2004 04:23: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 45088-04 + for ; + Fri, 19 Mar 2004 00:23:39 -0400 (AST) +Received: from ram.rentec.com (ram.rentec.com [192.5.35.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 330E5D1DC9E + for ; + Fri, 19 Mar 2004 00:23:38 -0400 (AST) +Received: from rentec.com (stangesun.rentec.com [172.16.160.106]) + by ram.rentec.com (8.12.1/8.12.1) with ESMTP id i2J4NYNb025091 + for ; + Thu, 18 Mar 2004 23:23:35 -0500 (EST) +Message-ID: <405A7576.9000208@rentec.com> +Date: Thu, 18 Mar 2004 23:22:14 -0500 +From: Alan Stange +User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.7a) Gecko/20040219 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: vacuum performance +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: 200403/277 +X-Sequence-Number: 6133 + +Hello all, + +I have a question/observation about vacuum performance. I'm running +Solaris 9, pg 7.4.1. +The process in questions is doing a vacuum: + +bash-2.05$ /usr/ucb/ps auxww | grep 4885 +fiasco 4885 19.1 3.7605896592920 ? O 19:29:44 91:38 postgres: +fiasco fiasco [local] VACUUM + +I do a truss on the process and see the output below looping over and +over. Note the constant opening and closing of the file 42064889.3. + +Why the open/close cycle as opposed to caching the file descriptor +somewhere? + +If PG really does need to loop like this, it should be much faster to +set the cwd and then open without the path in the file name. You're +forcing the kernel to do a lot of work walking the path, checking for +nfs mounts, symlinks, etc. + +Thanks! + +-- Alan + +open64("/export/nst1/fi/pg/data1/base/91488/42064889.3", O_RDWR) = 47 +llseek(47, 0x18F6E000, SEEK_SET) = 0x18F6E000 +write(47, "\0\0\0 zA9A3D9E8\0\0\0 "".., 8192) = 8192 +close(47) = 0 +read(29, "\0\0\0 }ED WF1B0\0\0\0 $".., 8192) = 8192 +open64("/export/nst1/fi/pg/data1/base/91488/42064889.3", O_RDWR) = 47 +llseek(47, 0x18F78000, SEEK_SET) = 0x18F78000 +write(47, "\0\0\0 zA9AC 090\0\0\0 "".., 8192) = 8192 +close(47) = 0 +llseek(43, 0x26202000, SEEK_SET) = 0x26202000 +read(43, "\0\0\084 EC9FC P\0\0\0 )".., 8192) = 8192 +semop(52, 0xFFBFC5E0, 1) = 0 +semop(52, 0xFFBFC640, 1) = 0 +open64("/export/nst1/fi/pg/data1/base/91488/42064889.3", O_RDWR) = 47 +llseek(47, 0x18F62000, SEEK_SET) = 0x18F62000 +write(47, "\0\0\0 zA9C2\bB8\0\0\0 "".., 8192) = 8192 +close(47) = 0 +read(29, "\0\0\0 }ED X1210\0\0\0 $".., 8192) = 8192 +semop(52, 0xFFBFC5E0, 1) = 0 +semop(52, 0xFFBFC640, 1) = 0 +open64("/export/nst1/fi/pg/data1/base/91488/42064889.3", O_RDWR) = 47 +llseek(47, 0x18018000, SEEK_SET) = 0x18018000 +write(47, "\0\0\0 zA997ADB0\0\0\0 "".., 8192) = 8192 +close(47) = 0 +llseek(43, 0x26200000, SEEK_SET) = 0x26200000 +read(43, "\0\0\084 EC4F5E8\0\0\0 )".., 8192) = 8192 +semop(52, 0xFFBFC5E0, 1) = 0 +semop(52, 0xFFBFC640, 1) = 0 +llseek(13, 13918208, SEEK_SET) = 13918208 +write(13, "D0 Z\001\0\0\0 )\0\0\087".., 8192) = 8192 +write(13, "D0 Z\001\0\0\0 )\0\0\087".., 8192) = 8192 +write(13, "D0 Z\001\0\0\0 )\0\0\087".., 8192) = 8192 +write(13, "D0 Z\001\0\0\0 )\0\0\087".., 8192) = 8192 +write(13, "D0 Z\001\0\0\0 )\0\0\087".., 8192) = 8192 +open64("/export/nst1/fi/pg/data1/base/91488/42064889.3", O_RDWR) = 47 +llseek(47, 0x18F52000, SEEK_SET) = 0x18F52000 +write(47, "\0\0\0 zABE7 V10\0\0\0 "".., 8192) = 8192 +close(47) = 0 +semop(46, 0xFFBFC5D0, 1) = 0 +read(29, "\0\0\0 }ED X 2 p\0\0\0 $".., 8192) = 8192 +semop(52, 0xFFBFC5E0, 1) = 0 +semop(52, 0xFFBFC640, 1) = 0 +llseek(43, 0x270DA000, SEEK_SET) = 0x270DA000 +write(43, "\0\0\087A2E8 #B8\0\0\0 )".., 8192) = 8192 +llseek(43, 0x261FE000, SEEK_SET) = 0x261FE000 +read(43, "\0\0\084 EC498\0\0\0\0 )".., 8192) = 8192 +poll(0xFFBFC100, 0, 10) = 0 +open64("/export/nst1/fi/pg/data1/base/91488/42064889.3", O_RDWR) = 47 +llseek(47, 0x1804A000, SEEK_SET) = 0x1804A000 +write(47, "\0\0\0 zAA0F8DE0\0\0\0 "".., 8192) = 8192 +close(47) = 0 +read(29, "\0\0\0 }ED X RD0\0\0\0 $".., 8192) = 8192 +semop(52, 0xFFBFC5E0, 1) = 0 +semop(52, 0xFFBFC640, 1) = 0 +write(13, "D0 Z\001\0\0\0 )\0\0\087".., 8192) = 8192 +write(13, "D0 Z\001\0\0\0 )\0\0\087".., 8192) = 8192 +write(13, "D0 Z\001\0\0\0 )\0\0\087".., 8192) = 8192 +write(13, "D0 Z\001\0\0\0 )\0\0\087".., 8192) = 8192 +open64("/export/nst1/fi/pg/data1/base/91488/42064889.3", O_RDWR) = 47 + + +From pgsql-performance-owner@postgresql.org Fri Mar 19 02:18:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B62DAD1E8AB + for ; + Fri, 19 Mar 2004 06:18:28 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 63121-10 + for ; + Fri, 19 Mar 2004 02:18:21 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 399D5D1E928 + for ; + Fri, 19 Mar 2004 02:18:20 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2J6IKNS020589; + Fri, 19 Mar 2004 01:18:20 -0500 (EST) +To: Alan Stange +Cc: pgsql-performance@postgresql.org +Subject: Re: vacuum performance +In-reply-to: <405A7576.9000208@rentec.com> +References: <405A7576.9000208@rentec.com> +Comments: In-reply-to Alan Stange + message dated "Thu, 18 Mar 2004 23:22:14 -0500" +Date: Fri, 19 Mar 2004 01:18:20 -0500 +Message-ID: <20588.1079677100@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/278 +X-Sequence-Number: 6134 + +Alan Stange writes: +> I do a truss on the process and see the output below looping over and +> over. Note the constant opening and closing of the file 42064889.3. +> Why the open/close cycle as opposed to caching the file descriptor +> somewhere? + +This is probably a "blind write". We've gotten rid of those for 7.5. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 19 20:17:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8F5C9D1E9B5 + for ; + Sat, 20 Mar 2004 00:17: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 66537-04 + for ; + Fri, 19 Mar 2004 20:17:27 -0400 (AST) +Received: from l2mail1.panix.com (l2mail1.panix.com [166.84.1.75]) + by svr1.postgresql.org (Postfix) with ESMTP id EC38CD1E934 + for ; + Fri, 19 Mar 2004 20:17:23 -0400 (AST) +Received: from mail3.panix.com (mail3.panix.com [166.84.1.74]) + by l2mail1.panix.com (Postfix) with ESMTP id 5DA9912C86 + for ; + Fri, 19 Mar 2004 17:24:28 -0500 (EST) +Received: from panix3.panix.com (panix3.panix.com [166.84.1.3]) + by mail3.panix.com (Postfix) with ESMTP + id C88E19877F; Fri, 19 Mar 2004 17:22:17 -0500 (EST) +Received: (from adler@localhost) + by panix3.panix.com (8.11.6p2-a/8.8.8/PanixN1.1) id i2JMMHZ23901; + Fri, 19 Mar 2004 17:22:17 -0500 (EST) +Date: Fri, 19 Mar 2004 17:22:17 -0500 +From: Michael Adler +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: string casting for index usage +Message-ID: <20040319222217.GA14902@pobox.com> +References: <20040318185237.GA3568@pobox.com> <12025.1079642352@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <12025.1079642352@sss.pgh.pa.us> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/280 +X-Sequence-Number: 6136 + +On Thu, Mar 18, 2004 at 03:39:12PM -0500, Tom Lane wrote: +> Michael Adler writes: +> > In porting an application from v7.2 and v7.3, I noticed that a join on a varchar column and a text column was ignoring indices that were helpful in v7.2. When I explicitly cast the text to a varchar (or set ENABLE_SEQSCAN TO false) the index is scanned and it works as efficiently as in v7.2. +> +> Maybe you should be moving to 7.4, instead. + +That's a fair suggestion, but it's not practical for our 75 sites, most without decent network access. If this is in fact addressed in newer releases, then my point is mostly inconsequential. + +We use Debian stable (7.2.1-2woody4) and Debian testing (7.3.4-9). + +> A desultory test didn't show any difference between 7.2.4 and 7.3.6 +> in this respect, however. Perhaps you forgot to ANALYZE yet in the +> new database? + +I have a test with sample data and queries to demonstrate what I'm seeing. I hope it is useful. + +Having to do manual casts is not cruel and unusual, but it's not encouraging to see performance go down after an upgrade. If anyone has any clever solutions, let me know. + +tables, data, and queries: +http://www.panix.com/~adler/manual-cast-for-index-scan.sql + +my test output: +http://www.panix.com/~adler/manual-cast-for-index-scan_7.3.4-9.out +http://www.panix.com/~adler/manual-cast-for-index-scan_7.2.1-2woody4.out + +(the times are not horrific in these specific examples, but the sequential scan makes them unscalable). + + +manual-cast-for-index-scan_7.3.4-9.out: + +DROP TABLE t1; +DROP TABLE +DROP TABLE t2; +DROP TABLE +CREATE TABLE t1 ( + key_col text, + grp text +); +CREATE TABLE +COPY t1 FROM stdin; +CREATE UNIQUE INDEX tempindex1 ON t1 USING btree (key_col); +CREATE INDEX +CREATE TABLE t2 ( + item_num character varying(5), + key_col character varying(14) +); +CREATE TABLE +COPY t2 FROM stdin; +CREATE INDEX tempindex2 ON t2 USING btree (key_col); +CREATE INDEX +VACUUM ANALYZE; +VACUUM +SELECT version(); + PostgreSQL 7.3.4 on i386-pc-linux-gnu, compiled by GCC i386-linux-gcc (GCC) 3.3.2 (Debian) + +EXPLAIN ANALYZE SELECT item_num, t1.key_col FROM t1 LEFT JOIN t2 ON (t2.key_col = t1.key_col) WHERE grp = '24'; + Nested Loop (cost=0.00..23803.27 rows=194 width=31) (actual time=20.95..1401.46 rows=69 loops=1) + Join Filter: (("inner".key_col)::text = "outer".key_col) + -> Seq Scan on t1 (cost=0.00..492.94 rows=194 width=18) (actual time=0.32..30.27 rows=69 loops=1) + Filter: (grp = '24'::text) + -> Seq Scan on t2 (cost=0.00..66.87 rows=4287 width=13) (actual time=0.01..12.06 rows=4287 loops=69) + Total runtime: 1401.73 msec + +EXPLAIN ANALYZE SELECT item_num, t1.key_col FROM t1 LEFT JOIN t2 ON (t2.key_col::text = t1.key_col) WHERE grp = '24'; + Nested Loop (cost=0.00..23803.27 rows=194 width=31) (actual time=20.27..1398.82 rows=69 loops=1) + Join Filter: (("inner".key_col)::text = "outer".key_col) + -> Seq Scan on t1 (cost=0.00..492.94 rows=194 width=18) (actual time=0.26..25.91 rows=69 loops=1) + Filter: (grp = '24'::text) + -> Seq Scan on t2 (cost=0.00..66.87 rows=4287 width=13) (actual time=0.01..12.02 rows=4287 loops=69) + Total runtime: 1399.08 msec + +EXPLAIN ANALYZE SELECT item_num, t1.key_col FROM t1 LEFT JOIN t2 ON (t2.key_col = t1.key_col::varchar(24)) WHERE grp = '24'; + Nested Loop (cost=0.00..4819.13 rows=194 width=31) (actual time=0.52..27.46 rows=69 loops=1) + -> Seq Scan on t1 (cost=0.00..492.94 rows=194 width=18) (actual time=0.27..25.94 rows=69 loops=1) + Filter: (grp = '24'::text) + -> Index Scan using tempindex2 on t2 (cost=0.00..22.17 rows=12 width=13) (actual time=0.01..0.01 rows=0 loops=69) + Index Cond: (t2.key_col = ("outer".key_col)::character varying(24)) + Total runtime: 27.70 msec + + + +manual-cast-for-index-scan_7.2.1-2woody4.out: + +DROP TABLE t1; +DROP +DROP TABLE t2; +DROP +CREATE TABLE t1 ( + key_col text, + grp text +); +CREATE +COPY t1 FROM stdin; +CREATE UNIQUE INDEX tempindex1 ON t1 USING btree (key_col); +CREATE +CREATE TABLE t2 ( + item_num character varying(5), + key_col character varying(14) +); +CREATE +COPY t2 FROM stdin; +CREATE INDEX tempindex2 ON t2 USING btree (key_col); +CREATE +VACUUM ANALYZE; +VACUUM +SELECT version(); + PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.4 + +EXPLAIN ANALYZE SELECT item_num, t1.key_col FROM t1 LEFT JOIN t2 ON (t2.key_col = t1.key_col) WHERE grp = '24'; +psql:castedneed.sql:29127: NOTICE: QUERY PLAN: + +Nested Loop (cost=0.00..1405.88 rows=204 width=32) (actual time=0.46..40.60 rows=69 loops=1) + -> Seq Scan on t1 (cost=0.00..505.94 rows=204 width=18) (actual time=0.35..39.09 rows=69 loops=1) + -> Index Scan using tempindex2 on t2 (cost=0.00..4.27 rows=11 width=14) (actual time=0.01..0.01 rows=0 loops=69) +Total runtime: 40.81 msec + +EXPLAIN +EXPLAIN ANALYZE SELECT item_num, t1.key_col FROM t1 LEFT JOIN t2 ON (t2.key_col::text = t1.key_col) WHERE grp = '24'; +psql:castedneed.sql:29128: NOTICE: QUERY PLAN: + +Nested Loop (cost=0.00..1405.88 rows=204 width=32) (actual time=0.40..39.88 rows=69 loops=1) + -> Seq Scan on t1 (cost=0.00..505.94 rows=204 width=18) (actual time=0.35..38.44 rows=69 loops=1) + -> Index Scan using tempindex2 on t2 (cost=0.00..4.27 rows=11 width=14) (actual time=0.01..0.01 rows=0 loops=69) +Total runtime: 40.07 msec + +EXPLAIN +EXPLAIN ANALYZE SELECT item_num, t1.key_col FROM t1 LEFT JOIN t2 ON (t2.key_col = t1.key_col::varchar(24)) WHERE grp = '24'; +psql:castedneed.sql:29129: NOTICE: QUERY PLAN: + +Nested Loop (cost=0.00..1416.66 rows=4383 width=32) (actual time=0.40..41.59 rows=69 loops=1) + -> Seq Scan on t1 (cost=0.00..505.94 rows=204 width=18) (actual time=0.36..40.05 rows=69 loops=1) + -> Index Scan using tempindex2 on t2 (cost=0.00..4.30 rows=11 width=14) (actual time=0.01..0.01 rows=0 loops=69) +Total runtime: 41.78 msec + +EXPLAIN + + +From pgsql-performance-owner@postgresql.org Fri Mar 19 19:29:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DC99BD1EF27 + for ; + Fri, 19 Mar 2004 23:29: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 47633-05 + for ; + Fri, 19 Mar 2004 19:29:09 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 90204D1EF21 + for ; + Fri, 19 Mar 2004 19:29:06 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2JNSpsZ002126; + Fri, 19 Mar 2004 18:28:51 -0500 (EST) +To: Michael Adler +Cc: pgsql-performance@postgresql.org +Subject: Re: string casting for index usage +In-reply-to: <20040319222217.GA14902@pobox.com> +References: <20040318185237.GA3568@pobox.com> <12025.1079642352@sss.pgh.pa.us> + <20040319222217.GA14902@pobox.com> +Comments: In-reply-to Michael Adler + message dated "Fri, 19 Mar 2004 17:22:17 -0500" +Date: Fri, 19 Mar 2004 18:28:50 -0500 +Message-ID: <2125.1079738930@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/279 +X-Sequence-Number: 6135 + +Michael Adler writes: +> On Thu, Mar 18, 2004 at 03:39:12PM -0500, Tom Lane wrote: +>> A desultory test didn't show any difference between 7.2.4 and 7.3.6 +>> in this respect, however. Perhaps you forgot to ANALYZE yet in the +>> new database? + +> I have a test with sample data and queries to demonstrate what I'm seeing. + +Ah. I had been testing the equivalent of this query with an INNER join +instead of a LEFT join. Both 7.2 and 7.3 pick a plan with an inner +indexscan on t1 in that case. The LEFT join prevents use of such a +plan, and the only way to do it quickly in those releases is to use an +inner indexscan on t2. + +7.2 is really cheating here, because what is happening under the hood is +that the parser resolves the query as "textcol texteq varcharcol::text", +there not being any direct text=varchar operator. (text is chosen as +the preferred type over varchar when it would otherwise be a coin flip.) +But then the planner would simply assume that it's okay to substitute +varchareq for texteq, apparently on the grounds that if the input types +are binary compatible then the operators must be interchangeable. That +made it possible to match the join clause to the varchar-opclass index +on t2. But of course this theory is ridiculous on its face ... it +happens to be okay for varchar and text but in general you'd not have +the same comparison semantics for two different operators. (As an +example, int4 and OID are binary compatible but their index operators +are definitely not interchangeable, because one is signed comparison and +the other unsigned.) + +7.3 is an intermediate state in which we'd ripped out the bogus planner +assumption but not developed fully adequate substitutes. + +7.4 is substantially smarter than either, and can generate merge and +hash joins as well as ye plain olde indexed nestloop for this query. +In a quick test, it seemed that all three plan types yielded about the +same runtimes for this query with this much data. I didn't have time +to try scaling up the amount of data to see where things went, but I'd +expect the nestloop to be a loser at large scales even with an inner +indexscan. + +Anyway, bottom line is that 7.4 and CVS tip are competitive with 7.2 +again, only they do it right this time ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 19 23:48:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 474D8D1E934; Sat, 20 Mar 2004 03:48: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 16938-04; Fri, 19 Mar 2004 23:48:17 -0400 (AST) +Received: from filer (c-24-6-183-218.client.comcast.net [24.6.183.218]) + by svr1.postgresql.org (Postfix) with ESMTP + id 3B53CD1E8AB; Fri, 19 Mar 2004 23:48:13 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) (uid 1000) + by filer with local; Fri, 19 Mar 2004 19:48:17 -0800 +Date: Fri, 19 Mar 2004 19:48:17 -0800 +From: Kevin Brown +To: pgsql-performance@postgresql.org, + PostgreSQL-development +Subject: Re: [HACKERS] fsync method checking +Message-ID: <20040320034817.GA9566@filer> +Mail-Followup-To: Kevin Brown , + pgsql-performance@postgresql.org, + PostgreSQL-development +References: <200403182049.i2IKnKK00246@candle.pha.pa.us> + <12315.1079643885@sss.pgh.pa.us> <20040319004112.GA19547@filer> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +In-Reply-To: <20040319004112.GA19547@filer> +Organization: Frobozzco International +User-Agent: Mutt/1.5.4i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/281 +X-Sequence-Number: 6137 + +I wrote: +> Note, too, that the preferred method isn't likely to depend just on the +> operating system, it's likely to depend also on the filesystem type +> being used. +> +> Linux provides quite a few of them: ext2, ext3, jfs, xfs, and reiserfs, +> and that's just off the top of my head. I imagine the performance of +> the various syncing methods will vary significantly between them. + +For what it's worth, my database throughput for transactions involving +a lot of inserts, updates, and deletes is about 12% faster using +fdatasync() than O_SYNC under Linux using JFS. + +I'll run the test program and report my results with it as well, so +we'll be able to see if there's any consistency between it and the live +database. + + + + +-- +Kevin Brown kevin@sysexperts.com + +From pgsql-performance-owner@postgresql.org Mon Mar 22 10:08:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 718E3D1D38B + for ; + Mon, 22 Mar 2004 14:08: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 11991-03 + for ; + Mon, 22 Mar 2004 10:08:37 -0400 (AST) +Received: from COLSWEEPER.cranel.local (newmail.cranel.com [66.192.200.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 0DAE3D1B98D + for ; + Mon, 22 Mar 2004 10:08:28 -0400 (AST) +Received: from colmail01.cranel.local (colmail01.cranel.com) by + COLSWEEPER.cranel.local + (Content Technologies SMTPRS 4.3.12) with ESMTP id + ; + Mon, 22 Mar 2004 09:07:57 -0500 +Received: from cranel.com (192.168.11.134 [192.168.11.134]) by + colmail01.cranel.local with SMTP (Microsoft Exchange Internet + Mail Service Version 5.5.2657.72) + id HN8F5Z4R; Mon, 22 Mar 2004 09:12:48 -0500 +Message-ID: <405EF35C.2080705@cranel.com> +Date: Mon, 22 Mar 2004 09:08:28 -0500 +From: Greg Spiegelberg +Organization: Cranel, Inc. +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Rosser Schwarz +Cc: 'Tom Lane' , pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +References: <002a01c40c45$f736d8a0$2500fa0a@CardServices.TCI.com> +In-Reply-To: <002a01c40c45$f736d8a0$2500fa0a@CardServices.TCI.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: 200403/282 +X-Sequence-Number: 6138 + +I've been following this thread closely as I have the same problem +with an UPDATE. Everything is identical here right down to the +strace output. + +Has anyone found a workaround or resolved the problem? If not, +I have test systems here which I can use to help up test and explore. + +Greg + +-- +Greg Spiegelberg + Sr. Product Development Engineer + Cranel, Incorporated. + Phone: 614.318.4314 + Fax: 614.431.8388 + Email: gspiegelberg@Cranel.com +Cranel. Technology. Integrity. Focus. + + + +From pgsql-performance-owner@postgresql.org Mon Mar 22 12:55:28 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B54A1D1DB16 + for ; + Mon, 22 Mar 2004 16:55: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 91887-03 + for ; + Mon, 22 Mar 2004 12:55:33 -0400 (AST) +Received: from anchor-post-37.mail.demon.net (anchor-post-36.mail.demon.net + [194.217.242.86]) + by svr1.postgresql.org (Postfix) with ESMTP id CCF68D1D64C + for ; + Mon, 22 Mar 2004 12:55:22 -0400 (AST) +Received: from mwynhau.demon.co.uk ([193.237.186.96] + helo=mainbox.archonet.com) + by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) + id 1B5Si5-0001Gz-0b; Mon, 22 Mar 2004 16:55:33 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id EC32417A3E; Mon, 22 Mar 2004 16:55:31 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 3A3D816E5D; Mon, 22 Mar 2004 16:55:29 +0000 (GMT) +From: Richard Huxton +To: Joseph Shraibman , + pgsql-performance@postgresql.org +Subject: Re: two seperate queries run faster than queries ORed together +Date: Mon, 22 Mar 2004 16:55:28 +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: <200403221655.28667.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: 200403/288 +X-Sequence-Number: 6144 + +On Thursday 18 March 2004 21:21, Joseph Shraibman wrote: +> explain +> SELECT COUNT(u.ukey) FROM u, d WHERE d.ukey = u.ukey AND u.pkey = 260 +> AND (u.status = 3 OR d.status = 3 ) AND NOT u.boolfield ; +> +> +> QUERY PLAN +> --------------------------------------------------------------------------- +>------------ Aggregate (cost=128867.45..128867.45 rows=1 width=4) +> -> Hash Join (cost=32301.47..128866.77 rows=272 width=4) +> Hash Cond: ("outer".ukey = "inner".ukey) +> Join Filter: (("inner".status = 3) OR ("outer".status = 3)) +> -> Seq Scan on u (cost=0.00..41215.97 rows=407824 width=6) +> Filter: ((pkey = 260) AND (NOT boolfield)) + +There's your problem. For some reason it thinks it's getting 407,824 rows back +from that filtered seq-scan. I take it that pkey is a primary-key and is +defined as being UNIQUE? If you actually did have several hundred thousand +matches then a seq-scan might be sensible. + +I'd start by analyze-ing the table in question, and if that doesn't have any +effect look at the column stats and see what spread of values it thinks you +have. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Mon Mar 22 13:34:53 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 09FA8D1C4EB; Mon, 22 Mar 2004 17:34: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 07349-04; Mon, 22 Mar 2004 13:34:58 -0400 (AST) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP + id 4342BD1B51F; Mon, 22 Mar 2004 13:34:47 -0400 (AST) +Received: from osdl.org (markw@ibm-b.pdx.osdl.net [172.20.1.51]) + by mail.osdl.org (8.11.6/8.11.6) with ESMTP id i2MHYGE01546; + Mon, 22 Mar 2004 09:34:17 -0800 +Message-Id: <200403221734.i2MHYGE01546@mail.osdl.org> +Date: Mon, 22 Mar 2004 09:33:59 -0800 (PST) +From: markw@osdl.org +Subject: Re: [HACKERS] fsync method checking +To: tgl@sss.pgh.pa.us +Cc: josh@agliodbs.com, Q@ping.be, pgman@candle.pha.pa.us, + markir@paradise.net.nz, pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +In-Reply-To: <12261.1079643654@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: TEXT/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/289 +X-Sequence-Number: 6145 + +On 18 Mar, Tom Lane wrote: +> Josh Berkus writes: +>> 1) This is an OSS project. Why not just recruit a bunch of people on +>> PERFORMANCE and GENERAL to test the 4 different synch methods using real +>> databases? No test like reality, I say .... +> +> I agree --- that is likely to yield *far* more useful results than +> any standalone test program, for the purpose of finding out what +> wal_sync_method to use in real databases. However, there's a second +> issue here: we would like to move sync/checkpoint responsibility into +> the bgwriter, and that requires knowing whether it's valid to let one +> process fsync on behalf of writes that were done by other processes. +> That's got nothing to do with WAL sync performance. I think that it +> would be sensible to make a test program that focuses on this one +> specific question. (There has been some handwaving to the effect that +> everybody knows this is safe on Unixen, but I question whether the +> handwavers have seen the internals of HPUX or AIX for instance; and +> besides we need to worry about Windows now.) + +I could certainly do some testing if you want to see how DBT-2 does. +Just tell me what to do. ;) + +Mark + +From pgsql-performance-owner@postgresql.org Mon Mar 22 13:41:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 14E74D1BC62 + for ; + Mon, 22 Mar 2004 17: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 11306-02 + for ; + Mon, 22 Mar 2004 13:41:28 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id D2758D1B44E + for ; + Mon, 22 Mar 2004 13:41:17 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2MHfE3G006392; + Mon, 22 Mar 2004 12:41:14 -0500 (EST) +To: markw@osdl.org +Cc: josh@agliodbs.com, Q@ping.be, pgman@candle.pha.pa.us, + markir@paradise.net.nz, pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] fsync method checking +In-reply-to: <200403221734.i2MHYGE01546@mail.osdl.org> +References: <200403221734.i2MHYGE01546@mail.osdl.org> +Comments: In-reply-to markw@osdl.org + message dated "Mon, 22 Mar 2004 09:33:59 -0800" +Date: Mon, 22 Mar 2004 12:41:14 -0500 +Message-ID: <6391.1079977274@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/290 +X-Sequence-Number: 6146 + +markw@osdl.org writes: +> I could certainly do some testing if you want to see how DBT-2 does. +> Just tell me what to do. ;) + +Just do some runs that are identical except for the wal_sync_method +setting. Note that this should not have any impact on SELECT +performance, only insert/update/delete performance. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 22 13:42:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id D251ED1B44E; Mon, 22 Mar 2004 17:42: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 08859-04; Mon, 22 Mar 2004 13:43:02 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP + id 9393DD1CB21; Mon, 22 Mar 2004 13:42:49 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i2MHghv15851; + Mon, 22 Mar 2004 12:42:43 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403221742.i2MHghv15851@candle.pha.pa.us> +Subject: Re: [HACKERS] fsync method checking +In-Reply-To: <200403221734.i2MHYGE01546@mail.osdl.org> +To: markw@osdl.org +Date: Mon, 22 Mar 2004 12:42:43 -0500 (EST) +Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com, Q@ping.be, + markir@paradise.net.nz, pgsql-performance@postgresql.org, + pgsql-hackers@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: 200403/291 +X-Sequence-Number: 6147 + +markw@osdl.org wrote: +> On 18 Mar, Tom Lane wrote: +> > Josh Berkus writes: +> >> 1) This is an OSS project. Why not just recruit a bunch of people on +> >> PERFORMANCE and GENERAL to test the 4 different synch methods using real +> >> databases? No test like reality, I say .... +> > +> > I agree --- that is likely to yield *far* more useful results than +> > any standalone test program, for the purpose of finding out what +> > wal_sync_method to use in real databases. However, there's a second +> > issue here: we would like to move sync/checkpoint responsibility into +> > the bgwriter, and that requires knowing whether it's valid to let one +> > process fsync on behalf of writes that were done by other processes. +> > That's got nothing to do with WAL sync performance. I think that it +> > would be sensible to make a test program that focuses on this one +> > specific question. (There has been some handwaving to the effect that +> > everybody knows this is safe on Unixen, but I question whether the +> > handwavers have seen the internals of HPUX or AIX for instance; and +> > besides we need to worry about Windows now.) +> +> I could certainly do some testing if you want to see how DBT-2 does. +> Just tell me what to do. ;) + +To test, you would run from CVS version src/tools/fsync, find the +fastest fsync method from the last group of outputs, then try the +wal_fsync_method setting to see if the one that tools/fsync says is +fastest is actually fastest. However, it might be better to run your +tests and get some indication of how frequently writes and fsync's are +going to WAL and modify tools/fsync to match what your DBT-2 test does. + +-- + 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 Mar 22 13:55:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 41E14D1CB21 + for ; + Mon, 22 Mar 2004 17: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 12618-09 + for ; + Mon, 22 Mar 2004 13:55:39 -0400 (AST) +Received: from tupari.net (node-40242ac2.lga.onnet.us.uu.net [64.36.42.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 82D06D1C4EB + for ; + Mon, 22 Mar 2004 13:55:28 -0400 (AST) +Received: from selectacast.net ([192.168.0.2]) + by tupari.net (8.12.8/8.12.8) with ESMTP id i2MHtVCE025419; + Mon, 22 Mar 2004 12:55:34 -0500 +Message-ID: <405F2893.5090805@selectacast.net> +Date: Mon, 22 Mar 2004 12:55:31 -0500 +From: Joseph Shraibman +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Richard Huxton +Cc: pgsql-performance@postgresql.org +Subject: Re: two seperate queries run faster than queries ORed together +References: <200403221655.28667.dev@archonet.com> +In-Reply-To: <200403221655.28667.dev@archonet.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: 200403/292 +X-Sequence-Number: 6148 + +Richard Huxton wrote: +> On Thursday 18 March 2004 21:21, Joseph Shraibman wrote: +> +>>explain +>>SELECT COUNT(u.ukey) FROM u, d WHERE d.ukey = u.ukey AND u.pkey = 260 +>>AND (u.status = 3 OR d.status = 3 ) AND NOT u.boolfield ; +>> +>> +>> QUERY PLAN +>>--------------------------------------------------------------------------- +>>------------ Aggregate (cost=128867.45..128867.45 rows=1 width=4) +>> -> Hash Join (cost=32301.47..128866.77 rows=272 width=4) +>> Hash Cond: ("outer".ukey = "inner".ukey) +>> Join Filter: (("inner".status = 3) OR ("outer".status = 3)) +>> -> Seq Scan on u (cost=0.00..41215.97 rows=407824 width=6) +>> Filter: ((pkey = 260) AND (NOT boolfield)) +> +> +> There's your problem. For some reason it thinks it's getting 407,824 rows back +> from that filtered seq-scan. I take it that pkey is a primary-key and is +> defined as being UNIQUE? If you actually did have several hundred thousand +> matches then a seq-scan might be sensible. +> +No, pkey is not the primary key in this case. The number of entries in u +that have pkey 260 and not boolfield is 344706. The number of those that +have status == 3 is 7. To total number of entries in d that have status + == 3 is 4. + +> I'd start by analyze-ing the table in question, +Is done every night. + +The problem is that it seems the planner doesn't think to do the +different parts of the OR seperately and then combine the answers. + +From pgsql-performance-owner@postgresql.org Mon Mar 22 14:24:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C7B8D1B98D + for ; + Mon, 22 Mar 2004 18:24: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 28397-04 + for ; + Mon, 22 Mar 2004 14:24:22 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id B4CB0D1B49B + for ; + Mon, 22 Mar 2004 14:24:11 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2MIOJ4X006876; + Mon, 22 Mar 2004 13:24:19 -0500 (EST) +To: Joseph Shraibman +Cc: Richard Huxton , + pgsql-performance@postgresql.org +Subject: Re: two seperate queries run faster than queries ORed together +In-reply-to: <405F2893.5090805@selectacast.net> +References: <200403221655.28667.dev@archonet.com> + <405F2893.5090805@selectacast.net> +Comments: In-reply-to Joseph Shraibman + message dated "Mon, 22 Mar 2004 12:55:31 -0500" +Date: Mon, 22 Mar 2004 13:24:19 -0500 +Message-ID: <6875.1079979859@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/293 +X-Sequence-Number: 6149 + +Joseph Shraibman writes: +> No, pkey is not the primary key in this case. The number of entries in u +> that have pkey 260 and not boolfield is 344706. + +... and every one of those rows *must* be included in the join input, +regardless of its status value, because it might join to some d row that +has status=3. Conversely, every single row of d must be considered in +the join because it might join to some u row with status=3. So any way +you slice it, this query requires a large and expensive join operation, +no matter that there are only a few rows with the right status values in +the other table. + +I'd rewrite the query if I were you. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 22 15:00:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8EB72D1D2EA + for ; + Mon, 22 Mar 2004 19: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 43028-02 + for ; + Mon, 22 Mar 2004 15:00:30 -0400 (AST) +Received: from tupari.net (node-40242ac2.lga.onnet.us.uu.net [64.36.42.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 326E1D1DACE + for ; + Mon, 22 Mar 2004 15:00:19 -0400 (AST) +Received: from selectacast.net ([192.168.0.2]) + by tupari.net (8.12.8/8.12.8) with ESMTP id i2MJ0UCE025470; + Mon, 22 Mar 2004 14:00:31 -0500 +Message-ID: <405F37CE.9070302@selectacast.net> +Date: Mon, 22 Mar 2004 14:00:30 -0500 +From: Joseph Shraibman +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: two seperate queries run faster than queries ORed together +References: <200403221655.28667.dev@archonet.com> + <405F2893.5090805@selectacast.net> <6875.1079979859@sss.pgh.pa.us> +In-Reply-To: <6875.1079979859@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: 200403/294 +X-Sequence-Number: 6150 + +Tom Lane wrote: +> Joseph Shraibman writes: +> +>>No, pkey is not the primary key in this case. The number of entries in u +>>that have pkey 260 and not boolfield is 344706. +> +> +> ... and every one of those rows *must* be included in the join input, + +*If* you use one big join in the first place. If postgres ran the query +to first get the values with status == 3 from u, then ran the query to +get the entries from d, then combined them, the result would be the same +but the output faster. Instead it is doing seq scans on both tables and +doing an expensive join that returns only a few rows. + + +From pgsql-performance-owner@postgresql.org Mon Mar 22 15:32:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6A39FD1BCC2 + for ; + Mon, 22 Mar 2004 19:32: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 49019-07 + for ; + Mon, 22 Mar 2004 15:32:30 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 11E84D1B97B + for ; + Mon, 22 Mar 2004 15:32:19 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 66AAE3596E; Mon, 22 Mar 2004 11:32:30 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 652E135969; Mon, 22 Mar 2004 11:32:30 -0800 (PST) +Date: Mon, 22 Mar 2004 11:32:30 -0800 (PST) +From: Stephan Szabo +To: Joseph Shraibman +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: two seperate queries run faster than queries ORed +In-Reply-To: <405F37CE.9070302@selectacast.net> +Message-ID: <20040322113002.D62908@megazone.bigpanda.com> +References: <200403221655.28667.dev@archonet.com> + <405F2893.5090805@selectacast.net> <6875.1079979859@sss.pgh.pa.us> + <405F37CE.9070302@selectacast.net> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/295 +X-Sequence-Number: 6151 + + +On Mon, 22 Mar 2004, Joseph Shraibman wrote: + +> Tom Lane wrote: +> > Joseph Shraibman writes: +> > +> >>No, pkey is not the primary key in this case. The number of entries in u +> >>that have pkey 260 and not boolfield is 344706. +> > +> > +> > ... and every one of those rows *must* be included in the join input, +> +> *If* you use one big join in the first place. If postgres ran the query +> to first get the values with status == 3 from u, then ran the query to +> get the entries from d, then combined them, the result would be the same +> but the output faster. Instead it is doing seq scans on both tables and + +Well, you have to be careful on the combination to not give the wrong +answers if there's a row with u.status=3 that matches a row d.status=3. + +From pgsql-performance-owner@postgresql.org Mon Mar 22 15:40:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 62249D1D767 + for ; + Mon, 22 Mar 2004 19:39: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 51280-10 + for ; + Mon, 22 Mar 2004 15:40:06 -0400 (AST) +Received: from tupari.net (node-40242ac2.lga.onnet.us.uu.net [64.36.42.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 54ED7D1D8A5 + for ; + Mon, 22 Mar 2004 15:39:53 -0400 (AST) +Received: from selectacast.net ([192.168.0.2]) + by tupari.net (8.12.8/8.12.8) with ESMTP id i2MJe4CE025499; + Mon, 22 Mar 2004 14:40:04 -0500 +Message-ID: <405F4114.5070602@selectacast.net> +Date: Mon, 22 Mar 2004 14:40:04 -0500 +From: Joseph Shraibman +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Stephan Szabo , + pgsql-performance@postgresql.org +Subject: Re: two seperate queries run faster than queries ORed together +References: <200403221655.28667.dev@archonet.com> + <405F2893.5090805@selectacast.net> <6875.1079979859@sss.pgh.pa.us> + <405F37CE.9070302@selectacast.net> + <20040322113002.D62908@megazone.bigpanda.com> +In-Reply-To: <20040322113002.D62908@megazone.bigpanda.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/296 +X-Sequence-Number: 6152 + +Stephan Szabo wrote: +> On Mon, 22 Mar 2004, Joseph Shraibman wrote: +> +> +>>Tom Lane wrote: +>> +>>>Joseph Shraibman writes: +>>> +>>> +>>>>No, pkey is not the primary key in this case. The number of entries in u +>>>>that have pkey 260 and not boolfield is 344706. +>>> +>>> +>>>... and every one of those rows *must* be included in the join input, +>> +>>*If* you use one big join in the first place. If postgres ran the query +>>to first get the values with status == 3 from u, then ran the query to +>>get the entries from d, then combined them, the result would be the same +>>but the output faster. Instead it is doing seq scans on both tables and +> +> +> Well, you have to be careful on the combination to not give the wrong +> answers if there's a row with u.status=3 that matches a row d.status=3. + +Right you would have to avoid duplicates. The existing DISTINCT code +should be able to handle that. + +From pgsql-performance-owner@postgresql.org Mon Mar 22 16:44:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2EADCD1C4EC + for ; + Mon, 22 Mar 2004 20:44: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 30372-04 + for ; + Mon, 22 Mar 2004 16:44:10 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id F4095D1B8C0 + for ; + Mon, 22 Mar 2004 16:43:58 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2MKi9oR007926; + Mon, 22 Mar 2004 15:44:10 -0500 (EST) +To: Stephan Szabo +Cc: Joseph Shraibman , + pgsql-performance@postgresql.org +Subject: Re: two seperate queries run faster than queries ORed +In-reply-to: <20040322113002.D62908@megazone.bigpanda.com> +References: <200403221655.28667.dev@archonet.com> + <405F2893.5090805@selectacast.net> <6875.1079979859@sss.pgh.pa.us> + <405F37CE.9070302@selectacast.net> + <20040322113002.D62908@megazone.bigpanda.com> +Comments: In-reply-to Stephan Szabo + message dated "Mon, 22 Mar 2004 11:32:30 -0800" +Date: Mon, 22 Mar 2004 15:44:09 -0500 +Message-ID: <7925.1079988249@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/297 +X-Sequence-Number: 6153 + +Stephan Szabo writes: +> Well, you have to be careful on the combination to not give the wrong +> answers if there's a row with u.status=3 that matches a row d.status=3. + +We could in theory handle that using something similar to the method +currently used for "OR" indexscans (that is, rather than doing either +UNION- or UNION-ALL-like processing, we drop tuples from later scans +that meet the qual tests of the earlier scans). However I don't see any +clean way in the current planner to cost out both approaches and pick +the cheaper one. It looks to me like we'd have to do over the *entire* +join planning process each way, which is ugly as well as unreasonably +expensive. The problem is that the OR approach only wins when the +component clauses of the OR can drop down to lower levels of the plan +tree if they are considered separately. But a plan tree with a +restriction at a low level and one without it are two different things, +and the dynamic-programming approach we use to build up join plans +doesn't yield the same solutions. (As indeed it shouldn't, since the +whole point of Joseph's example is to get fundamentally different plans +for the two parts of the OR.) + +We could possibly approach it heuristically, that is examine the clauses +and try to guess whether it's better to split them apart or not. But +even assuming that we punt on that part of the problem, it seems like a +mess. For instance suppose that there are additional relations in the +query that aren't mentioned in the OR clause. The planner may want to +join some of those relations in advance of forming the join that the OR +itself describes. Pushing down different parts of the OR might cause +the best join path to change. How could you merge multiple scans if +some include extra relations and some don't? + +In short, I see how such a plan could be executed, but I don't see any +effective approach for generating the plan ... + + regards, tom lane + +From pgsql-admin-owner@postgresql.org Thu Mar 25 18:10:24 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 6805DD1DB2B; Mon, 22 Mar 2004 21:00: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 70211-02; Mon, 22 Mar 2004 17:00:22 -0400 (AST) +Received: from mxca1.netopia.com (host222.netopia.com [65.206.239.222]) + by svr1.postgresql.org (Postfix) with ESMTP + id 890DFD1DACB; Mon, 22 Mar 2004 17:00:10 -0400 (AST) +Received: by mxca1.netopia.com with Internet Mail Service (5.5.2657.72) + id ; Mon, 22 Mar 2004 13:00:22 -0800 +Message-ID: +From: "Subbiah, Stalin" +To: "'pgsql-performance@postgresql.org'" +Cc: "'pgsql-admin@postgresql.org'" +Subject: Databases Vs. Schemas +Date: Mon, 22 Mar 2004 13:00:21 -0800 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: text/plain; + charset="ISO-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/337 +X-Sequence-Number: 12906 + +Hi All, + +We are evaluating the options for having multiple databases vs. schemas on a +single database cluster for a custom grown app that we developed. Each app +installs same set of tables for each service. And the service could easily +be in thousands. so Is it better to have 1000 databases vs 1000 schemas in a +database cluster. What are the performance overhead of having multiple +databases vs. schemas (if any). I'm leaning towards having schemas rather +than databases but i would like to get others opinion on this. Appreciate +your reply. + +Thanks, +Stalin + + + + +From pgsql-admin-owner@postgresql.org Mon Mar 22 17:30:16 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 811B6D1BCC2; Mon, 22 Mar 2004 21: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 73696-09; Mon, 22 Mar 2004 17:30:25 -0400 (AST) +Received: from mxca1.netopia.com (host222.netopia.com [65.206.239.222]) + by svr1.postgresql.org (Postfix) with ESMTP + id 11DF7D1B8C0; Mon, 22 Mar 2004 17:30:13 -0400 (AST) +Received: by mxca1.netopia.com with Internet Mail Service (5.5.2657.72) + id ; Mon, 22 Mar 2004 13:30:26 -0800 +Message-ID: +From: "Subbiah, Stalin" +To: "'pgsql-admin@postgresql.org'" +Cc: "'pgsql-performance@postgresql.org'" +Subject: Databases Vs. Schemas +Date: Mon, 22 Mar 2004 13:30:24 -0800 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: text/plain; + charset="ISO-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/290 +X-Sequence-Number: 12859 + +--sorry to repost, just subscribed to the list. hopefully it gets to the +list this time -- + +Hi All, + +We are evaluating the options for having multiple databases vs. schemas on a +single database cluster for a custom grown app that we developed. Each app +installs same set of tables for each service. And the service could easily +be in thousands. so Is it better to have 1000 databases vs 1000 schemas in a +database cluster. What are the performance overhead of having multiple +databases vs. schemas (if any). I'm leaning towards having schemas rather +than databases but i would like to get others opinion on this. Appreciate +your reply. + +Thanks, +Stalin + +From pgsql-admin-owner@postgresql.org Mon Mar 22 18:08:29 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id A2B20D1B49B; Mon, 22 Mar 2004 22:04: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 94251-03; Mon, 22 Mar 2004 18:04:50 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP + id 7DADDD1B44E; Mon, 22 Mar 2004 18:04:38 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2MM4o9R008797; + Mon, 22 Mar 2004 17:04:50 -0500 (EST) +To: "Subbiah, Stalin" +Cc: "'pgsql-admin@postgresql.org'" , + "'pgsql-performance@postgresql.org'" +Subject: Re: Databases Vs. Schemas +In-reply-to: +References: +Comments: In-reply-to "Subbiah, Stalin" + message dated "Mon, 22 Mar 2004 13:30:24 -0800" +Date: Mon, 22 Mar 2004 17:04:50 -0500 +Message-ID: <8796.1079993090@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/292 +X-Sequence-Number: 12861 + +"Subbiah, Stalin" writes: +> Is it better to have 1000 databases vs 1000 schemas in a +> database cluster. + +You almost certainly want to go for schemas, at least from a performance +point of view. The overhead of a schema is small (basically one more +row in pg_namespace) whereas the overhead of a database is not trivial. + +The main reason you might not want to use schemas is if you want fairly +airtight separation between different services. Separate databases +would prevent services from looking at each others' catalog entries. + + regards, tom lane + +From pgsql-admin-owner@postgresql.org Mon Mar 22 20:05:36 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 0E4BDD1CCA7; Tue, 23 Mar 2004 00: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 28829-05; Mon, 22 Mar 2004 20:05:46 -0400 (AST) +Received: from mxca1.netopia.com (host222.netopia.com [65.206.239.222]) + by svr1.postgresql.org (Postfix) with ESMTP + id DF649D1C4EC; Mon, 22 Mar 2004 20:05:32 -0400 (AST) +Received: by mxca1.netopia.com with Internet Mail Service (5.5.2657.72) + id ; Mon, 22 Mar 2004 16:05:46 -0800 +Message-ID: +From: "Subbiah, Stalin" +To: "'pgsql-performance@postgresql.org'" +Cc: "'pgsql-admin@postgresql.org'" +Subject: Benchmarking postgres on Solaris/Linux +Date: Mon, 22 Mar 2004 16:05:45 -0800 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: text/plain; + charset="ISO-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/293 +X-Sequence-Number: 12862 + +As anyone done benchmarking tests with postgres running on solaris and linux +(redhat) assuming both environment has similar hardware, memory, processing +speed etc. By reading few posts here, i can see linux would outperform +solaris cause linux being very good at kernel caching than solaris which is +being the key performance booster for postgres. what is the preferred OS +for postgres deployment if given an option between linux and solaris. As +well as filesystem to be used (xfs, ufs, ext3...). Any pointer to source of +information is appreciated. + +Thanks, +Stalin + +From pgsql-performance-owner@postgresql.org Mon Mar 22 21:30:21 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7BA65D1CC7F + for ; + Tue, 23 Mar 2004 01:30: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 53443-02 + for ; + Mon, 22 Mar 2004 21:30:29 -0400 (AST) +Received: from hotmail.com (bay13-f14.bay13.hotmail.com [64.4.31.14]) + by svr1.postgresql.org (Postfix) with ESMTP id 67FD1D1D478 + for ; + Mon, 22 Mar 2004 21:30:15 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Mon, 22 Mar 2004 17:30:29 -0800 +Received: from 68.38.165.44 by by13fd.bay13.hotmail.msn.com with HTTP; + Tue, 23 Mar 2004 01:30:29 GMT +X-Originating-IP: [68.38.165.44] +X-Originating-Email: [bigwhitecow@hotmail.com] +X-Sender: bigwhitecow@hotmail.com +From: "Eric Brown" +To: pgsql-performance@postgresql.org +Subject: Re: severe performance issue with planner +Date: Mon, 22 Mar 2004 20:30:29 -0500 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +Message-ID: +X-OriginalArrivalTime: 23 Mar 2004 01:30:29.0811 (UTC) + FILETIME=[6D3CE830:01C41076] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/301 +X-Sequence-Number: 6157 + +ok, at the advice of jurka, I will post new results: + +Here's the query as I have changed it now: +SELECT +w8.wid, +w8.variant, +w8.num_variants, +sum_text(w8.unicode) as unicodes, +sum_text(w8.pinyin) as pinyins +FROM +(words as w8 JOIN +(words as w7 JOIN +(words as w6 JOIN +(words as w5 JOIN +(words as w4 JOIN +(words as w3 JOIN +(words as w2 JOIN +(words as w0 JOIN words as w1 + +ON(w1.wid = w0.wid AND w1.variant = w0.variant AND w1.sequence = w0.sequence ++ 1 AND w1.pinyin LIKE 'fu_')) +ON(w2.wid = w1.wid AND w2.variant = w1.variant AND w2.sequence = w1.sequence ++ 1 AND w2.pinyin LIKE 'ji_')) +ON(w3.wid = w2.wid AND w3.variant = w2.variant AND w3.sequence = w2.sequence ++ 1 AND w3.pinyin LIKE 'guan_')) +ON(w4.wid = w3.wid AND w4.variant = w3.variant AND w4.sequence = w3.sequence ++ 1 AND w4.pinyin LIKE 'kai_')) +ON(w5.wid = w4.wid AND w5.variant = w4.variant AND w5.sequence = w4.sequence ++ 1 AND w5.pinyin LIKE 'fang_')) +ON(w6.wid = w5.wid AND w6.variant = w5.variant AND w6.sequence = w5.sequence ++ 1 AND w6.pinyin LIKE 'xi_')) +ON(w7.wid = w6.wid AND w7.variant = w6.variant AND w7.sequence = w6.sequence ++ 1 AND w7.pinyin LIKE 'tong_')) +ON(w8.wid = w7.wid AND w8.variant = w7.variant)) + + +WHERE +w0.wid > 0 AND +w0.pinyin = 'zheng4' AND +w0.def_exists = 't' AND +w0.sequence = 0 +GROUP BY +w8.wid, +w8.variant, +w8.num_variants, +w8.page_order, +w0.sequence , +w1.sequence , +w2.sequence , +w3.sequence , +w4.sequence , +w5.sequence , +w6.sequence , +w7.sequence +ORDER BY +w8.page_order; + + +And here's the output of explain analyze: + + + + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +Sort (cost=54.26..54.26 rows=1 width=43) (actual time=14.916..14.917 rows=1 +loops=1) + Sort Key: w8.page_order + -> HashAggregate (cost=54.24..54.25 rows=1 width=43) (actual +time=14.891..14.892 rows=1 loops=1) + -> Nested Loop (cost=0.00..54.10 rows=4 width=43) (actual +time=3.676..14.446 rows=12 loops=1) + -> Nested Loop (cost=0.00..48.09 rows=1 width=64) (actual +time=3.638..14.269 rows=1 loops=1) + Join Filter: ("outer"."sequence" = ("inner"."sequence" ++ 1)) + -> Nested Loop (cost=0.00..42.06 rows=1 width=56) +(actual time=3.581..14.181 rows=1 loops=1) + Join Filter: (("inner".wid = "outer".wid) AND +("inner".variant = "outer".variant) AND ("inner"."sequence" = +("outer"."sequence" + 1)) AND ("outer"."sequence" = ("inner"."sequence" + +1))) + -> Nested Loop (cost=0.00..36.05 rows=1 +width=48) (actual time=2.152..12.443 rows=1 loops=1) + Join Filter: (("outer"."sequence" = +("inner"."sequence" + 1)) AND ("inner"."sequence" = ("outer"."sequence" + +1))) + -> Nested Loop (cost=0.00..30.03 rows=1 +width=40) (actual time=2.104..12.368 rows=1 loops=1) + Join Filter: (("outer".variant = +"inner".variant) AND ("outer".wid = "inner".wid) AND ("inner"."sequence" = +("outer"."sequence" + 1))) + -> Nested Loop (cost=0.00..24.02 +rows=1 width=32) (actual time=2.040..11.226 rows=1 loops=1) + Join Filter: +("outer"."sequence" = ("inner"."sequence" + 1)) + -> Nested Loop +(cost=0.00..18.00 rows=1 width=24) (actual time=1.979..11.147 rows=1 +loops=1) + Join Filter: +(("inner".variant = "outer".variant) AND ("inner".wid = "outer".wid)) + -> Nested Loop +(cost=0.00..12.00 rows=1 width=16) (actual time=0.258..8.765 rows=1 loops=1) + -> Index Scan +using pinyin_index on words w3 (cost=0.00..5.99 rows=1 width=8) (actual +time=0.084..2.399 rows=304 loops=1) + Index Cond: +(((pinyin)::text >= 'guan'::character varying) AND ((pinyin)::text < +'guao'::character varying)) + Filter: +((pinyin)::text ~~ 'guan_'::text) + -> Index Scan +using words2_pkey on words w1 (cost=0.00..6.00 rows=1 width=8) (actual +time=0.018..0.018 rows=0 loops=304) + Index Cond: +(("outer".wid = w1.wid) AND ("outer".variant = w1.variant)) + Filter: +((pinyin)::text ~~ 'fu_'::text) + -> Index Scan using +pinyin_index on words w7 (cost=0.00..5.99 rows=1 width=8) (actual +time=0.025..1.863 rows=338 loops=1) + Index Cond: +(((pinyin)::text >= 'tong'::character varying) AND ((pinyin)::text < +'tonh'::character varying)) + Filter: +((pinyin)::text ~~ 'tong_'::text) + -> Index Scan using +words2_pkey on words w6 (cost=0.00..6.00 rows=1 width=8) (actual +time=0.037..0.052 rows=1 loops=1) + Index Cond: ((w6.wid = +"outer".wid) AND (w6.variant = "outer".variant)) + Filter: ((pinyin)::text +~~ 'xi_'::text) + -> Index Scan using pinyin_index on +words w4 (cost=0.00..5.99 rows=1 width=8) (actual time=0.028..0.874 +rows=165 loops=1) + Index Cond: (((pinyin)::text >= +'kai'::character varying) AND ((pinyin)::text < 'kaj'::character varying)) + Filter: ((pinyin)::text ~~ +'kai_'::text) + -> Index Scan using words2_pkey on words +w2 (cost=0.00..6.00 rows=1 width=8) (actual time=0.023..0.047 rows=1 +loops=1) + Index Cond: (("outer".wid = w2.wid) +AND ("outer".variant = w2.variant)) + Filter: ((pinyin)::text ~~ +'ji_'::text) + -> Index Scan using pinyin_index on words w5 +(cost=0.00..5.99 rows=1 width=8) (actual time=0.025..1.436 rows=259 loops=1) + Index Cond: (((pinyin)::text >= +'fang'::character varying) AND ((pinyin)::text < 'fanh'::character varying)) + Filter: ((pinyin)::text ~~ 'fang_'::text) + -> Index Scan using words2_pkey on words w0 +(cost=0.00..6.01 rows=1 width=8) (actual time=0.030..0.058 rows=1 loops=1) + Index Cond: (("outer".wid = w0.wid) AND (w0.wid > +0) AND ("outer".variant = w0.variant)) + Filter: (((pinyin)::text = 'zheng4'::text) AND +(def_exists = true) AND ("sequence" = 0)) + -> Index Scan using words2_pkey on words w8 +(cost=0.00..6.00 rows=1 width=27) (actual time=0.019..0.103 rows=12 loops=1) + Index Cond: ((w8.wid = "outer".wid) AND (w8.variant = +"outer".variant)) +Total runtime: 15.987 ms +(44 rows) + +Time: 838.446 ms + + +As you can see, there still appears to be some issue with planning taking +~820ms, while the actual query should only take 16ms (and as you can see i +used the "folding" technique which takes some load off of the planner. + + +Here is the old query/analysis as run right now: +SELECT + w8.wid, + w8.variant, + w8.num_variants, + sum_text(w8.unicode) as unicodes, + sum_text(w8.pinyin) as pinyins +FROM + words as w0, words as w1, + words as w2, words as w3, + words as w4, words as w5, + words as w6, words as w7, + words as w8 +WHERE + w0.wid > 0 AND + w0.pinyin = 'zheng4' AND + w0.def_exists = 't' AND + w0.sequence = 0 AND + w1.wid = w0.wid AND + w1.pinyin LIKE 'fu_' AND + w1.variant = w0.variant AND + w1.sequence = (w0.sequence + 1) AND + w2.wid = w1.wid AND + w2.pinyin LIKE 'ji_' AND + w2.variant = w1.variant AND + w2.sequence = (w1.sequence + 1) AND + w3.wid = w2.wid AND + w3.pinyin LIKE 'guan_' AND + w3.variant = w2.variant AND + w3.sequence = (w2.sequence + 1) AND + w4.wid = w3.wid AND + w4.pinyin LIKE 'kai_' AND + w4.variant = w3.variant AND + w4.sequence = (w3.sequence + 1) AND + w5.wid = w4.wid AND + w5.pinyin LIKE 'fang_' AND + w5.variant = w4.variant AND + w5.sequence = (w4.sequence + 1) AND + w6.wid = w5.wid AND + w6.pinyin LIKE 'xi_' AND + w6.variant = w5.variant AND + w6.sequence = (w5.sequence + 1) AND + w7.wid = w6.wid AND + w7.pinyin LIKE 'tong_' AND + w7.variant = w6.variant AND + w7.sequence = (w6.sequence + 1) AND + w8.wid = w7.wid AND + w8.variant = w7.variant +GROUP BY + w8.wid, + w8.variant, + w8.num_variants, + w8.page_order , + w0.sequence , + w1.sequence , + w2.sequence , + w3.sequence , + w4.sequence , + w5.sequence , + w6.sequence , + w7.sequence +ORDER BY + w8.page_order; + +wepy=> EXPLAIN ANALYZE wepy=> explain ANALYZE + QUERY +PLAN +wepy-> wepy-> +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +wepy-> wepy-> Sort (cost=54.15..54.16 rows=1 width=43) (actual +time=1043.148..1043.149 rows=1 loops=1) +wepy-> wepy-> Sort Key: w8.page_order +wepy-> wepy-> -> HashAggregate (cost=54.14..54.14 rows=1 width=43) +(actual time=1043.121..1043.122 rows=1 loops=1) +wepy-> wepy-> -> Nested Loop (cost=0.00..54.10 rows=1 width=43) +(actual time=9.627..1042.565 rows=12 loops=1) +wepy-> wepy-> Join Filter: (("inner"."sequence" = +("outer"."sequence" + 1)) AND ("outer"."sequence" = ("inner"."sequence" + +1))) +wepy-> wepy-> -> Nested Loop (cost=0.00..48.08 rows=1 +width=83) (actual time=9.557..1041.784 rows=12 loops=1) +wepy-> wepy-> Join Filter: (("outer".wid = "inner".wid) +AND ("outer".variant = "inner".variant) AND ("outer"."sequence" = +("inner"."sequence" + 1)) AND ("inner"."sequence" = ("outer"."sequence" + +1))) +wepy-> wepy-> -> Nested Loop (cost=0.00..11.99 rows=1 +width=16) (actual time=3.152..290.176 rows=6 loops=1) +wepy-> wepy-> Join Filter: (("inner".wid = +"outer".wid) AND ("inner".variant = "outer".variant) AND ("inner"."sequence" += ("outer"."sequence" + 1))) +wepy-> wepy-> -> Index Scan using pinyin_index +on words w4 (cost=0.00..5.99 rows=1 width=8) (actual time=0.084..1.233 +rows=165 loops=1) +wepy-> wepy-> Index Cond: (((pinyin)::text + >= 'kai'::character varying) AND ((pinyin)::text < 'kaj'::character +varying)) +wepy-> wepy-> Filter: ((pinyin)::text ~~ +'kai_'::text) +wepy-> wepy-> -> Index Scan using pinyin_index +on words w5 (cost=0.00..5.99 rows=1 width=8) (actual time=0.018..1.411 +rows=259 loops=165) +wepy-> wepy-> Index Cond: (((pinyin)::text + >= 'fang'::character varying) AND ((pinyin)::text < 'fanh'::character +varying)) +wepy-> wepy-> Filter: ((pinyin)::text ~~ +'fang_'::text) +wepy-> wepy-> -> Nested Loop (cost=0.00..36.06 rows=1 +width=67) (actual time=4.500..125.184 rows=12 loops=6) +wepy-> wepy-> -> Nested Loop (cost=0.00..30.05 +rows=1 width=40) (actual time=4.446..125.003 rows=1 loops=6) +wepy-> wepy-> Join Filter: +("inner"."sequence" = ("outer"."sequence" + 1)) +wepy-> wepy-> -> Nested Loop +(cost=0.00..24.03 rows=1 width=32) (actual time=4.391..124.920 rows=1 +loops=6) +wepy-> wepy-> -> Nested Loop +(cost=0.00..18.01 rows=1 width=24) (actual time=4.339..124.781 rows=3 +loops=6) +wepy-> wepy-> Join Filter: +(("inner".variant = "outer".variant) AND ("inner".wid = "outer".wid) AND +("inner"."sequence" = ("outer"."sequence" + 1))) +wepy-> wepy-> -> Nested Loop +(cost=0.00..12.00 rows=1 width=16) (actual time=0.154..10.898 rows=18 +loops=6) +wepy-> wepy-> -> Index +Scan using pinyin_index on words w3 (cost=0.00..5.99 rows=1 width=8) +(actual time=0.027..2.358 rows=304 loops=6) +wepy-> wepy-> Index +Cond: (((pinyin)::text >= 'guan'::character varying) AND ((pinyin)::text < +'guao'::character varying)) +wepy-> wepy-> +Filter: ((pinyin)::text ~~ 'guan_'::text) +wepy-> wepy-> -> Index +Scan using words2_pkey on words w6 (cost=0.00..6.00 rows=1 width=8) (actual +time=0.025..0.025 rows=0 loops=1824) +wepy-> wepy-> Index +Cond: ((w6.wid = "outer".wid) AND (w6.variant = "outer".variant)) +wepy-> wepy-> +Filter: ((pinyin)::text ~~ 'xi_'::text) +wepy-> wepy-> -> Index Scan +using pinyin_index on words w7 (cost=0.00..5.99 rows=1 width=8) (actual +time=0.017..5.788 rows=338 loops=108) +wepy-> wepy-> Index Cond: +(((pinyin)::text >= 'tong'::character varying) AND ((pinyin)::text < +'tonh'::character varying)) +wepy-> wepy-> Filter: +((pinyin)::text ~~ 'tong_'::text) +wepy-> wepy-> -> Index Scan using +words2_pkey on words w0 (cost=0.00..6.01 rows=1 width=8) (actual +time=0.026..0.035 rows=0 loops=18) +wepy-> wepy-> Index Cond: +(("outer".wid = w0.wid) AND (w0.wid > 0) AND ("outer".variant = w0.variant)) +wepy-> wepy-> Filter: +(((pinyin)::text = 'zheng4'::text) AND (def_exists = true) AND ("sequence" = +0)) +wepy-> wepy-> -> Index Scan using +words2_pkey on words w1 (cost=0.00..6.00 rows=1 width=8) (actual +time=0.021..0.047 rows=1 loops=6) +wepy-> wepy-> Index Cond: +(("outer".wid = w1.wid) AND ("outer".variant = w1.variant)) +wepy-> wepy-> Filter: ((pinyin)::text +~~ 'fu_'::text) +wepy-> wepy-> -> Index Scan using words2_pkey on +words w8 (cost=0.00..6.00 rows=1 width=27) (actual time=0.021..0.085 +rows=12 loops=6) +wepy-> wepy-> Index Cond: ((w8.wid = +"outer".wid) AND (w8.variant = "outer".variant)) +wepy-> wepy-> -> Index Scan using words2_pkey on words w2 +(cost=0.00..6.00 rows=1 width=8) (actual time=0.021..0.046 rows=1 loops=12) +wepy-> wepy-> Index Cond: ((w2.wid = "outer".wid) AND +(w2.variant = "outer".variant)) +wepy-> wepy-> Filter: ((pinyin)::text ~~ 'ji_'::text) +wepy-> wepy-> Total runtime: 1044.239 ms +wepy-> wepy-> (43 rows) +wepy-> wepy-> +wepy-> wepy-> Time: 3939.938 ms + + + +Even the total runtime has improved dramatically with the use of explicit +joins and folding. However, I still need to cut the query time down much +more... My last resort is to dig through the source code and see if I can +understand how the planner works, but I suspect it's thousands of lines of +code :\ + +BTW, I have since upgraded to 7.4.2 (from 7.4.1), and you can verify these +planner times even with an empty table. The table spec is below: + + Table "public.words" + Column | Type | Modifiers +--------------+----------------------+----------- +wid | integer | not null +sequence | smallint | not null +variant | smallint | not null +char_count | smallint | not null +unicode | character varying(5) | not null +pinyin | character varying(8) | not null +simpvar | character varying(5) | +zvar | character varying(5) | +compatvar | character varying(5) | +def_exists | boolean | not null +num_variants | smallint | +page_order | integer | +pinyins | character varying | +unicodes | character varying | +Indexes: + "words2_pkey" primary key, btree (wid, variant, "sequence") + "page_index" btree (page_order) + "pinyin_index" btree (pinyin) + "unicode_index" btree (unicode) + +_________________________________________________________________ +Get rid of annoying pop-up ads with the new MSN Toolbar � FREE! +http://clk.atdmt.com/AVE/go/onm00200414ave/direct/01/ + + +From pgsql-admin-owner@postgresql.org Thu Mar 25 17:01:11 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 98E19D1E9BA; Tue, 23 Mar 2004 05:20: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 61011-06; Tue, 23 Mar 2004 01:20:29 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id 05DA6D1E104; Tue, 23 Mar 2004 01:20:28 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4674847; Mon, 22 Mar 2004 21:21:44 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Subbiah, Stalin" , + "'pgsql-admin@postgresql.org'" +Subject: Re: [PERFORM] Databases Vs. Schemas +Date: Mon, 22 Mar 2004 21:19:50 -0800 +User-Agent: KMail/1.5.4 +Cc: "'pgsql-performance@postgresql.org'" +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403222119.50331.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/327 +X-Sequence-Number: 12896 + +Stalin, + +> We are evaluating the options for having multiple databases vs. schemas on a +> single database cluster for a custom grown app that we developed. Each app +> installs same set of tables for each service. And the service could easily +> be in thousands. so Is it better to have 1000 databases vs 1000 schemas in a +> database cluster. What are the performance overhead of having multiple +> databases vs. schemas (if any). I'm leaning towards having schemas rather +> than databases but i would like to get others opinion on this. Appreciate +> your reply. + +No performance difference AFAIK. The real question is whether you have to +have queries joining several "databases". If yes, use Schema; if no, use +databases. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-admin-owner@postgresql.org Thu Mar 25 18:15:18 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 7AC90D1C915; Tue, 23 Mar 2004 05:20: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 59850-09; Tue, 23 Mar 2004 01:20:57 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id 81892D1B4B2; Tue, 23 Mar 2004 01:20:56 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4674851; Mon, 22 Mar 2004 21:22:13 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Subbiah, Stalin" , + "'pgsql-performance@postgresql.org'" +Subject: Re: [PERFORM] Benchmarking postgres on Solaris/Linux +Date: Mon, 22 Mar 2004 21:20:21 -0800 +User-Agent: KMail/1.5.4 +Cc: "'pgsql-admin@postgresql.org'" +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403222120.21194.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/340 +X-Sequence-Number: 12909 + +Stalin, + +> As anyone done benchmarking tests with postgres running on solaris and linux +> (redhat) assuming both environment has similar hardware, memory, processing +> speed etc. By reading few posts here, i can see linux would outperform +> solaris cause linux being very good at kernel caching than solaris which is +> being the key performance booster for postgres. what is the preferred OS +> for postgres deployment if given an option between linux and solaris. As +> well as filesystem to be used (xfs, ufs, ext3...). Any pointer to source of +> information is appreciated. + +Most of that is a matter of opinion. Read the cumulative archives of this +list. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-admin-owner@postgresql.org Thu Mar 25 18:13:15 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id D5B4ED1D2A4; Tue, 23 Mar 2004 05:38: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 64682-06; Tue, 23 Mar 2004 01:38:12 -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 73D1FD1CC7F; Tue, 23 Mar 2004 01:38:11 -0400 (AST) +Received: from smtp-2.paradise.net.nz (smtp-2b.paradise.net.nz [202.0.32.211]) + by linda-2.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0HV000J58KZLGU@linda-2.paradise.net.nz>; Tue, + 23 Mar 2004 17:38:10 +1200 (NZST) +Received: from paradise.net.nz + (203-96-145-196.adsl.paradise.net.nz [203.96.145.196]) + by smtp-2.paradise.net.nz (Postfix) with ESMTP id 17D299E657; Tue, + 23 Mar 2004 17:38:09 +1200 (NZST) +Date: Tue, 23 Mar 2004 17:39:38 +1200 +From: Mark Kirkwood +Subject: Re: [PERFORM] Benchmarking postgres on Solaris/Linux +In-reply-to: +To: "Subbiah, Stalin" +Cc: "'pgsql-performance@postgresql.org'" , + "'pgsql-admin@postgresql.org'" +Message-id: <405FCD9A.2010207@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.5) Gecko/20031213 +References: +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/339 +X-Sequence-Number: 12908 + +The hardware platform to deploy onto may well influence your choice : + +Intel is usually the most cost effective , which means using Linux makes +sense in that case (anybody measured Pg performance on Solaris/Intel....?). + +If however, you are going to run a very "big in some sense" database, +then 64 bit hardware is desirable and you can look at the Sun offerings. +In this case you can run either Linux or Solaris (some informal +benchmarks suggest that for small numbers of cpus, Linux is probably +faster). + +It might be worth considering Apple if you want a 64-bit chip that has a +clock speed comparable to Intel's - the Xserv is similarly priced to Sun +V210 (both dual cpu 1U's). + +Are you free to choose any hardware? + +best wishes + +Mark + +Subbiah, Stalin wrote: + +>(snipped) what is the preferred OS +>for postgres deployment if given an option between linux and solaris. +> +> +> + + +From pgsql-performance-owner@postgresql.org Fri Mar 26 17:59:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DB65D1EBC5 + for ; + Tue, 23 Mar 2004 11:25: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 04415-02 + for ; + Tue, 23 Mar 2004 07:25:06 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 8DC26D1EBB6 + for ; + Tue, 23 Mar 2004 07:25:03 -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 i2NBP21Y071852 + for ; Tue, 23 Mar 2004 11:25:02 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i2NB6esw068879 + for pgsql-performance@postgresql.org; Tue, 23 Mar 2004 11:06:40 GMT +From: CoL +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Databases Vs. Schemas +Date: Tue, 23 Mar 2004 12:06:42 +0100 +Organization: Hub.Org Networking Services +Lines: 27 +Message-ID: +References: + <200403222119.50331.josh@agliodbs.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Mozilla Thunderbird 0.5+ (Windows/20040223) +X-Accept-Language: en-us, en +In-Reply-To: <200403222119.50331.josh@agliodbs.com> +To: pgsql-performance@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/387 +X-Sequence-Number: 6243 + +hi + +Josh Berkus wrote: + +> Stalin, +> +> +>>We are evaluating the options for having multiple databases vs. schemas on a +>>single database cluster for a custom grown app that we developed. Each app +>>installs same set of tables for each service. And the service could easily +>>be in thousands. so Is it better to have 1000 databases vs 1000 schemas in a +>>database cluster. What are the performance overhead of having multiple +>>databases vs. schemas (if any). I'm leaning towards having schemas rather +>>than databases but i would like to get others opinion on this. Appreciate +>>your reply. +> +> +> No performance difference AFAIK. The real question is whether you have to +> have queries joining several "databases". If yes, use Schema; if no, use +> databases. + +don't forget the pg_hba.conf :) You need 1000 declaration. Was a thread +before, title: performance problem - 10.000 databases +Check this: +http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=1068039213.28814.116.camel%40franki-laptop.tpi.pl&rnum=10&prev=/groups%3Fq%3D1000%2Bdatabase%2Bgroup:comp.databases.postgresql.*%26hl%3Den%26lr%3D%26ie%3DUTF-8%26group%3Dcomp.databases.postgresql.*%26selm%3D1068039213.28814.116.camel%2540franki-laptop.tpi.pl%26rnum%3D10 + +C. + +From pgsql-admin-owner@postgresql.org Tue Mar 23 09:54:03 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5C11BD1DAE9; Tue, 23 Mar 2004 13:54: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 60467-06; Tue, 23 Mar 2004 09:54:04 -0400 (AST) +Received: from localhost.localdomain (unknown [166.70.154.50]) + by svr1.postgresql.org (Postfix) with ESMTP + id EF031D1D342; Tue, 23 Mar 2004 09:53:59 -0400 (AST) +Received: from [127.0.0.1] (strongbad [127.0.0.1]) + by localhost.localdomain (8.12.8/8.12.8) with ESMTP id i2NDs1Bo004582; + Tue, 23 Mar 2004 06:54:01 -0700 +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <8B012B25-7CD1-11D8-85EE-000A959D1424@intercation.com> +Content-Transfer-Encoding: 7bit +Cc: "'pgsql-admin@postgresql.org'" , + "'pgsql-performance@postgresql.org'" +From: Adam Ruth +Subject: Re: Databases Vs. Schemas +Date: Tue, 23 Mar 2004 06:54:02 -0700 +To: "Subbiah, Stalin" +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/297 +X-Sequence-Number: 12866 + +We have a similarly sized database and we went with schemas. We did +something different, though, we created one schema that contained all +of the tables (we used the public schema) and then created the hundreds +of schemas with views that access only the related rows for a +particular schema. Something like this: + +create table public.file (siteid int, id int, [fields]); +create schema sc1; +create view sc1.file as select * from public.file where siteid = 1; +create schema sc2; +create view sc2.file as select * from public file where siteid = 2; + +And we also created rules to allow update, delete, and insert on those +views so that they looked like tables. The reason we did this is +because we ran into issues with too many open files during pg_dump when +we had thousands of tables instead of about 1 hundred tables and +thousands of views. + +We, however, did have a need to periodically select data from 2 schemas +at a time, and it was simpler logic than if we needed 2 database +connections. + +Adam Ruth + +On Mar 22, 2004, at 2:30 PM, Subbiah, Stalin wrote: + +> --sorry to repost, just subscribed to the list. hopefully it gets to +> the +> list this time -- +> +> Hi All, +> +> We are evaluating the options for having multiple databases vs. +> schemas on a +> single database cluster for a custom grown app that we developed. Each +> app +> installs same set of tables for each service. And the service could +> easily +> be in thousands. so Is it better to have 1000 databases vs 1000 +> schemas in a +> database cluster. What are the performance overhead of having multiple +> databases vs. schemas (if any). I'm leaning towards having schemas +> rather +> than databases but i would like to get others opinion on this. +> Appreciate +> your reply. +> +> Thanks, +> Stalin +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 10:12:04 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5C0A1D1BC62 + for ; + Tue, 23 Mar 2004 14:12: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 67598-06 + for ; + Tue, 23 Mar 2004 10:12:05 -0400 (AST) +Received: from mail231.csoft.net (resin.csoft.net [63.111.22.86]) + by svr1.postgresql.org (Postfix) with SMTP id 34D86D1EC02 + for ; + Tue, 23 Mar 2004 10:12:00 -0400 (AST) +Received: (qmail 17753 invoked from network); 23 Mar 2004 14:12:01 -0000 +Received: from unknown (HELO chezphil.org) (63.111.27.87) + by mail231.csoft.net with SMTP; 23 Mar 2004 14:12:01 -0000 +Content-Disposition: inline +Content-Transfer-Encoding: binary +Content-Type: text/plain +MIME-Version: 1.0 +X-Mailer: MIME::Lite 3.01 (F2.71; A1.17; B2.12; Q2.03) +From: "Phil Endecott" +To: pgsql-performance@postgresql.org +Subject: Optimisation of INTERSECT expressions +Date: Tue, 23 Mar 2004 09:12:01 -0500 +X-Mailer: Phil's WebMail +Message-Id: <20040323141200.34D86D1EC02@svr1.postgresql.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/305 +X-Sequence-Number: 6161 + +Dear PostgresQL Experts, + +I am trying to get to the bottom of some efficiency problems and hope that +you can help. The difficulty seems to be with INTERSECT expressions. + +I have a query of the form + select A from T where C1 intersect select A from T where C2; +It runs in about 100 ms. + +But it is equivalent to this query + select A from T where C1 and C2; +which runs in less than 10 ms. + +Looking at the output of "explain analyse" on the first query, it seems +that PostgresQL always computes the two sub-expressions and then computes +an explicit intersection on the results. I had hoped that it would notice +that both subexpressions are scanning the same input table T and convert +the expression to the second form. + +Is there a reason why it can't do this transformation? + +(Of course, I could just re-write my code to use the second form, but my +application is generating these bits of SQL programmatically, and it is not +trivial as in some cases the two tables are not the same so an intersection +really is needed; if PostgresQL can do it for me, that would be much +better. I don't want to write an SQL parser!) + + +While studying the same code I found another case where my INTERSECT +expressions don't seem to be optimised as much as I'd like. In this case, +one of the subexpressions being intersected is empty much of the time. But +even when it is empty, PostgresQL computes the other (expensive) +subexpression and does an intersect. Could PostgresQL do something like this: + +- guess which subexpression is likely to produce fewest rows +- compute this subexpression +- if empty, return now with an empty result +- compute other subexpression +- compute intersection +- return intersection + +Alternatively, it could be defined that the left subexpression is always +computed first and the second not computed if it is empty, like the +behaviour of logical AND and OR operators in C. + +Thanks in advance for any suggestions. + +--Phil. + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 10:50:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9208CD1EBEC + for ; + Tue, 23 Mar 2004 14:50:52 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 87553-09 + for ; + Tue, 23 Mar 2004 10:50:53 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 96D29D1EBC0 + for ; + Tue, 23 Mar 2004 10:50:49 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 20C973585D; Tue, 23 Mar 2004 06:50:53 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 19C12356CB; Tue, 23 Mar 2004 06:50:53 -0800 (PST) +Date: Tue, 23 Mar 2004 06:50:53 -0800 (PST) +From: Stephan Szabo +To: Phil Endecott +Cc: pgsql-performance@postgresql.org +Subject: Re: Optimisation of INTERSECT expressions +In-Reply-To: <20040323141200.34D86D1EC02@svr1.postgresql.org> +Message-ID: <20040323063650.X85869@megazone.bigpanda.com> +References: <20040323141200.34D86D1EC02@svr1.postgresql.org> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/306 +X-Sequence-Number: 6162 + +On Tue, 23 Mar 2004, Phil Endecott wrote: + +> Dear PostgresQL Experts, +> +> I am trying to get to the bottom of some efficiency problems and hope that +> you can help. The difficulty seems to be with INTERSECT expressions. +> +> I have a query of the form +> select A from T where C1 intersect select A from T where C2; +> It runs in about 100 ms. +> +> But it is equivalent to this query +> select A from T where C1 and C2; +> which runs in less than 10 ms. +> +> Looking at the output of "explain analyse" on the first query, it seems +> that PostgresQL always computes the two sub-expressions and then computes +> an explicit intersection on the results. I had hoped that it would notice +> that both subexpressions are scanning the same input table T and convert +> the expression to the second form. +> +> Is there a reason why it can't do this transformation? + +Probably because noone's bothered to try to prove under what conditions +it's the same. + +For example, given a non-unique A, the two queries can give different +answers (if say the same two A values match both C1 and C2 in different +rows how many output rows does each give? *), also given a non-stable A +(for example random) the two queries are not necessarily equivalent. + +From pgsql-performance-owner@postgresql.org Tue Mar 23 11:14:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D1C9D1E934 + for ; + Tue, 23 Mar 2004 15:14: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 05983-03 + for ; + Tue, 23 Mar 2004 11:14:46 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C4B2D1E29F + for ; + Tue, 23 Mar 2004 11:14:42 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 46D05357BA; Tue, 23 Mar 2004 07:14:46 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 455D4357B9; Tue, 23 Mar 2004 07:14:46 -0800 (PST) +Date: Tue, 23 Mar 2004 07:14:46 -0800 (PST) +From: Stephan Szabo +To: Phil Endecott +Cc: pgsql-performance@postgresql.org +Subject: Re: Optimisation of INTERSECT expressions +In-Reply-To: <20040323063650.X85869@megazone.bigpanda.com> +Message-ID: <20040323071350.Y86816@megazone.bigpanda.com> +References: <20040323141200.34D86D1EC02@svr1.postgresql.org> + <20040323063650.X85869@megazone.bigpanda.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/307 +X-Sequence-Number: 6163 + + +On Tue, 23 Mar 2004, Stephan Szabo wrote: + +> On Tue, 23 Mar 2004, Phil Endecott wrote: +> +> > Dear PostgresQL Experts, +> > +> > I am trying to get to the bottom of some efficiency problems and hope that +> > you can help. The difficulty seems to be with INTERSECT expressions. +> > +> > I have a query of the form +> > select A from T where C1 intersect select A from T where C2; +> > It runs in about 100 ms. +> > +> > But it is equivalent to this query +> > select A from T where C1 and C2; +> > which runs in less than 10 ms. +> > +> > Looking at the output of "explain analyse" on the first query, it seems +> > that PostgresQL always computes the two sub-expressions and then computes +> > an explicit intersection on the results. I had hoped that it would notice +> > that both subexpressions are scanning the same input table T and convert +> > the expression to the second form. +> > +> > Is there a reason why it can't do this transformation? +> +> Probably because noone's bothered to try to prove under what conditions +> it's the same. +> +> For example, given a non-unique A, the two queries can give different +> answers (if say the same two A values match both C1 and C2 in different +> rows how many output rows does each give? *), also given a non-stable A +> (for example random) the two queries are not necessarily equivalent. + +Ugh, the example got trimmed out for the * + +Given a non-unique A, C1 as B>5, c2 as C>5 and the data: +A | B | C +1 | 6 | 1 +1 | 1 | 6 + +The intersect gives 1 row, the and query gives 0 AFAICS. + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 11:48:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A9CD4D1B97B + for ; + Tue, 23 Mar 2004 15:48:12 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 17496-10 + for ; + Tue, 23 Mar 2004 11:48:14 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id B9260D1B49B + for ; + Tue, 23 Mar 2004 11:48:09 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2NFlgJu020716; + Tue, 23 Mar 2004 10:47:42 -0500 (EST) +To: Stephan Szabo +Cc: Phil Endecott , + pgsql-performance@postgresql.org +Subject: Re: Optimisation of INTERSECT expressions +In-reply-to: <20040323071350.Y86816@megazone.bigpanda.com> +References: <20040323141200.34D86D1EC02@svr1.postgresql.org> + <20040323063650.X85869@megazone.bigpanda.com> + <20040323071350.Y86816@megazone.bigpanda.com> +Comments: In-reply-to Stephan Szabo + message dated "Tue, 23 Mar 2004 07:14:46 -0800" +Date: Tue, 23 Mar 2004 10:47:42 -0500 +Message-ID: <20715.1080056862@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/308 +X-Sequence-Number: 6164 + +Stephan Szabo writes: +> Given a non-unique A, C1 as B>5, c2 as C>5 and the data: +> A | B | C +> 1 | 6 | 1 +> 1 | 1 | 6 +> The intersect gives 1 row, the and query gives 0 AFAICS. + +Another way that the queries are not equivalent is that INTERSECT is +defined to remove duplicate output rows (much like DISTINCT) whereas +the AND form of course won't do that. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 23 12:10:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 60855D1B51F + for ; + Tue, 23 Mar 2004 16: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 33524-05 + for ; + Tue, 23 Mar 2004 12:08:02 -0400 (AST) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id A4ED6D1EBFE + for ; + Tue, 23 Mar 2004 12:08:01 -0400 (AST) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i2NG7vRG007011 + for ; Tue, 23 Mar 2004 10:07:57 -0600 +From: "Rosser Schwarz" +To: +Subject: Re: atrocious update performance +Date: Tue, 23 Mar 2004 10:07:57 -0600 +Message-ID: <003c01c410f1$0192d7e0$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: <405EF35C.2080705@cranel.com> +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-MailScanner-From: rschwarz@totalcardinc.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/309 +X-Sequence-Number: 6165 + +Greg Spiegelberg wrote: + +> I've been following this thread closely as I have the same problem +> with an UPDATE. Everything is identical here right down to the +> strace output. + +> Has anyone found a workaround or resolved the problem? If not, +> I have test systems here which I can use to help up test and explore. + +I'm still gathering data. The explain analyze I'd expected to finish +Thursday afternoon hasn't yet. I'm going to kill it and try a few +smaller runs, increasing in size, until the behavior manifests. + +Will advise. + +/rls + + +From pgsql-admin-owner@postgresql.org Thu Mar 25 17:36:32 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 450B2D1DC5D; Tue, 23 Mar 2004 16: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 36073-08; Tue, 23 Mar 2004 12:17:22 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id EEA58D1BC62; Tue, 23 Mar 2004 12:17:20 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4677471; Tue, 23 Mar 2004 08:18:37 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Mark Kirkwood , + "Subbiah, Stalin" +Subject: Re: [PERFORM] Benchmarking postgres on Solaris/Linux +Date: Tue, 23 Mar 2004 08:15:39 -0800 +User-Agent: KMail/1.4.3 +Cc: "'pgsql-performance@postgresql.org'" , + "'pgsql-admin@postgresql.org'" +References: + <405FCD9A.2010207@paradise.net.nz> +In-Reply-To: <405FCD9A.2010207@paradise.net.nz> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200403230815.39993.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/331 +X-Sequence-Number: 12900 + +Mark, + +> It might be worth considering Apple if you want a 64-bit chip that has a +> clock speed comparable to Intel's - the Xserv is similarly priced to Sun +> V210 (both dual cpu 1U's). + +Personally I'd stay *far* away from the XServs until Apple learns to build +some real server harware. The current XServs have internal parts more +appropriate to a Dell desktop (promise controller, low-speed commodity IDE +drives), than a server. + +If Apple has prices these IU desktop machines similar to Sun, then I sense +doom ahead for the Apple Server Division. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Mar 23 12:41:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B819D1EC4C + for ; + Tue, 23 Mar 2004 16:28: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 44256-08 + for ; + Tue, 23 Mar 2004 12:28:29 -0400 (AST) +Received: from mail231.csoft.net (resin.csoft.net [63.111.22.86]) + by svr1.postgresql.org (Postfix) with SMTP id B4131D1EC40 + for ; + Tue, 23 Mar 2004 12:28:23 -0400 (AST) +Received: (qmail 13130 invoked from network); 23 Mar 2004 16:21:39 -0000 +Received: from unknown (HELO chezphil.org) (63.111.27.87) + by mail231.csoft.net with SMTP; 23 Mar 2004 16:21:39 -0000 +Content-Disposition: inline +Content-Transfer-Encoding: binary +Content-Type: text/plain +MIME-Version: 1.0 +X-Mailer: MIME::Lite 3.01 (F2.71; A1.17; B2.12; Q2.03) +From: "Phil Endecott" +To: pgsql-performance@postgresql.org +Subject: Re: Optimisation of INTERSECT expressions +Date: Tue, 23 Mar 2004 11:21:39 -0500 +X-Mailer: Phil's WebMail +Message-Id: <20040323162823.B4131D1EC40@svr1.postgresql.org> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/310 +X-Sequence-Number: 6166 + +I asked: +> select A from T where C1 intersect select A from T where C2; +> select A from T where C1 and C2; +> [why isn't the first optimised into the second?] + +Stephan Szabo answered: +> Given a non-unique A, C1 as B>5, c2 as C>5 and the data: +> A | B | C +> 1 | 6 | 1 +> 1 | 1 | 6 +> The intersect gives 1 row, the and query gives 0 AFAICS. + +Tom Lane answered: +> Another way that the queries are not equivalent is that INTERSECT is +> defined to remove duplicate output rows (much like DISTINCT) whereas +> the AND form of course won't do that. + +Thanks! In my case the attribute A is unique - it is the primary key - and +I hadn't considered the more general case properly. + +So I suppose I'll have to find a more sophisticated way to generate my +queries. Imagine a user interface for a search facility with various +buttons and text entry fields. At the moment, for each part of the search +that the user has enabled I create a string of SQL. I then compose them +into a single statement using INTERSECT. Each sub-query always returns the +same attribute, but to make things complicated they may come from different +tables. It now seems that I'll have to merge the queries more thoroughly. + Does anyone have any suggestions about how to do this? I'd like a nice +general technique that works for all possible subqueries, as my current +composition with INTERSECT does. + + +Any thoughts on my other question about empty intersections? + +Thanks again for the feedback. + +--Phil. + +From pgsql-performance-owner@postgresql.org Tue Mar 23 13:04:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DB578D1EC64 + for ; + Tue, 23 Mar 2004 17:02: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 66971-02 + for ; + Tue, 23 Mar 2004 13:02:06 -0400 (AST) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id D9FE2D1EC60 + for ; + Tue, 23 Mar 2004 13:02:00 -0400 (AST) +Received: (qmail 25212 invoked by uid 500); 23 Mar 2004 17:05:00 -0000 +Date: Tue, 23 Mar 2004 11:05:00 -0600 +From: Bruno Wolff III +To: Phil Endecott +Cc: pgsql-performance@postgresql.org +Subject: Re: Optimisation of INTERSECT expressions +Message-ID: <20040323170500.GA25181@wolff.to> +Mail-Followup-To: Phil Endecott , + pgsql-performance@postgresql.org +References: <20040323162823.B4131D1EC40@svr1.postgresql.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20040323162823.B4131D1EC40@svr1.postgresql.org> +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/312 +X-Sequence-Number: 6168 + +On Tue, Mar 23, 2004 at 11:21:39 -0500, + Phil Endecott wrote: +> Does anyone have any suggestions about how to do this? I'd like a nice +> general technique that works for all possible subqueries, as my current +> composition with INTERSECT does. + +One adjustment you might make is using INTERSECT ALL if you know there +can't be duplicates. Then time won't be wasted trying to remove duplicates. + +From pgsql-performance-owner@postgresql.org Tue Mar 23 13:18:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DB679D1EBBE + for ; + Tue, 23 Mar 2004 17:18: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 77854-08 + for ; + Tue, 23 Mar 2004 13:18:17 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E399D1DBAF + for ; + Tue, 23 Mar 2004 13:18:16 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4677831; Tue, 23 Mar 2004 09:19:33 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Phil Endecott" , + pgsql-performance@postgresql.org +Subject: Re: Optimisation of INTERSECT expressions +Date: Tue, 23 Mar 2004 09:17:40 -0800 +User-Agent: KMail/1.5.4 +References: <20040323162823.B4131D1EC40@svr1.postgresql.org> +In-Reply-To: <20040323162823.B4131D1EC40@svr1.postgresql.org> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403230917.40133.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/313 +X-Sequence-Number: 6169 + +Phil, + +> So I suppose I'll have to find a more sophisticated way to generate my +> queries. Imagine a user interface for a search facility with various +> buttons and text entry fields. At the moment, for each part of the search +> that the user has enabled I create a string of SQL. I then compose them +> into a single statement using INTERSECT. Each sub-query always returns the +> same attribute, but to make things complicated they may come from different +> tables. It now seems that I'll have to merge the queries more thoroughly. +> Does anyone have any suggestions about how to do this? I'd like a nice +> general technique that works for all possible subqueries, as my current +> composition with INTERSECT does. + +I've done this but it involves a choice between a lot of infrastrucure for +fully configurable queries, or limiting user choice. The former option +requires that you construct reference tables holding what search fields are +available, what kind of values they hold, and what operators to use while +querying, as well as a table storing the joins used for the various tables +that can be queried. + +Based on that, you can construct dynamically a query on any field or combo of +fields listed in your reference tables. + +If search options are more constrained, you can simply take the easier path of +hard-coding the query building blocks into a set-returning function. I do +this all the time for Web search interfaces, where the user only has about 9 +things to search on. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 13:21:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6EF86D1B51F + for ; + Tue, 23 Mar 2004 17:21: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 80376-08 + for ; + Tue, 23 Mar 2004 13:21:35 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 67381D1EC4A + for ; + Tue, 23 Mar 2004 13:21:32 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2NHLVPT021624; + Tue, 23 Mar 2004 12:21:31 -0500 (EST) +To: Bruno Wolff III +Cc: Phil Endecott , + pgsql-performance@postgresql.org +Subject: Re: Optimisation of INTERSECT expressions +In-reply-to: <20040323170500.GA25181@wolff.to> +References: <20040323162823.B4131D1EC40@svr1.postgresql.org> + <20040323170500.GA25181@wolff.to> +Comments: In-reply-to Bruno Wolff III + message dated "Tue, 23 Mar 2004 11:05:00 -0600" +Date: Tue, 23 Mar 2004 12:21:31 -0500 +Message-ID: <21623.1080062491@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/314 +X-Sequence-Number: 6170 + +Bruno Wolff III writes: +> On Tue, Mar 23, 2004 at 11:21:39 -0500, +> Phil Endecott wrote: +>> Does anyone have any suggestions about how to do this? I'd like a nice +>> general technique that works for all possible subqueries, as my current +>> composition with INTERSECT does. + +> One adjustment you might make is using INTERSECT ALL if you know there +> can't be duplicates. Then time won't be wasted trying to remove duplicates. + +Actually, I don't think that will help. UNION ALL is much faster than +UNION, because it doesn't have to match up duplicates, but INTERSECT +and EXCEPT still have to match rows from the inputs in order to find +out if they should emit a row at all. IIRC there will not be any +noticeable speed difference with or without ALL. + +AFAICS, what Phil will want to do is + + SELECT a FROM table1 WHERE cond11 AND cond12 AND ... + INTERSECT + SELECT a FROM table2 WHERE cond21 AND cond22 AND ... + INTERSECT + ... + +which is more painful to assemble than his current approach, but it +shouldn't be *that* bad --- you just need to tag each condition with the +table it applies to, and bring together matching tags when you build the +SQL string. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 23 13:36:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A23D7D1E2AA + for ; + Tue, 23 Mar 2004 17:36: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 89403-04 + for ; + Tue, 23 Mar 2004 13:36:35 -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 E97A5D1DC5D + for ; + Tue, 23 Mar 2004 13:36:33 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep02-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040323173533.BQHR289632.fep02-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Tue, 23 Mar 2004 12:35:33 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 664C23BE3; Tue, 23 Mar 2004 12:36:32 -0500 (EST) +Date: Tue, 23 Mar 2004 12:36:32 -0500 +From: Andrew Sullivan +To: "'pgsql-performance@postgresql.org'" +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +Message-ID: <20040323173632.GC14274@phlogiston.dyndns.org> +Mail-Followup-To: "'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.5.1+cvs20040105i +X-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep02-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Tue, + 23 Mar 2004 12:35:33 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/315 +X-Sequence-Number: 6171 + +On Mon, Mar 22, 2004 at 04:05:45PM -0800, Subbiah, Stalin wrote: +> being the key performance booster for postgres. what is the preferred OS +> for postgres deployment if given an option between linux and solaris. As + +One thing this very much depends on is what you're trying to do. +Suns have a reputation for greater reliability. While my own +experience with Sun hardware has been rather shy of sterling, I _can_ +say that it stands head and shoulders above a lot of the x86 gear you +can get. + +If you're planning to use Solaris on x86, don't bother. Solaris is a +slow, bloated pig compared to Linux, at least when it comes to +managing the largish number of processes that Postgres requires. + +If pure speed is what you're after, I have found that 2-way, 32 bit +Linux on P-IIIs compares very favourably to 4 way 64 bit Ultra SPARC +IIs. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +The fact that technology doesn't work is no bar to success in the marketplace. + --Philip Greenspun + +From pgsql-admin-owner@postgresql.org Tue Mar 23 14:17:09 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 24D84D1EC57; Tue, 23 Mar 2004 18:17: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 01690-08; Tue, 23 Mar 2004 14:17:02 -0400 (AST) +Received: from mxca1.netopia.com (host222.netopia.com [65.206.239.222]) + by svr1.postgresql.org (Postfix) with ESMTP + id 4918ED1CC93; Tue, 23 Mar 2004 14:17:00 -0400 (AST) +Received: by mxca1.netopia.com with Internet Mail Service (5.5.2657.72) + id ; Tue, 23 Mar 2004 10:16:59 -0800 +Message-ID: +From: "Subbiah, Stalin" +To: 'Adam Ruth' , + "Subbiah, Stalin" +Cc: "'pgsql-admin@postgresql.org'" , + "'pgsql-performance@postgresql.org'" +Subject: Re: Databases Vs. Schemas +Date: Tue, 23 Mar 2004 10:16:52 -0800 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: text/plain; + charset="ISO-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/303 +X-Sequence-Number: 12872 + +>And we also created rules to allow update, delete, and insert on those +>views so that they looked like tables. The reason we did this is +>because we ran into issues with too many open files during pg_dump when +>we had thousands of tables instead of about 1 hundred tables and +>thousands of views. + +Is it because you had smaller value set for max. allowable number of open +files descriptor. what was ulimit -a set to ? + +>We, however, did have a need to periodically select data from 2 schemas +>at a time, and it was simpler logic than if we needed 2 database +>connections. + +Adam Ruth + +On Mar 22, 2004, at 2:30 PM, Subbiah, Stalin wrote: + +> --sorry to repost, just subscribed to the list. hopefully it gets to +> the +> list this time -- +> +> Hi All, +> +> We are evaluating the options for having multiple databases vs. +> schemas on a +> single database cluster for a custom grown app that we developed. Each +> app +> installs same set of tables for each service. And the service could +> easily +> be in thousands. so Is it better to have 1000 databases vs 1000 +> schemas in a +> database cluster. What are the performance overhead of having multiple +> databases vs. schemas (if any). I'm leaning towards having schemas +> rather +> than databases but i would like to get others opinion on this. +> Appreciate +> your reply. +> +> Thanks, +> Stalin +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 3: if posting/reading through Usenet, please send an appropriate +> subscribe-nomail command to majordomo@postgresql.org so that your +> message can get through to the mailing list cleanly +> + +From pgsql-performance-owner@postgresql.org Tue Mar 23 14:40:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CA8D7D1EC4A + for ; + Tue, 23 Mar 2004 18:40: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 16896-10 + for ; + Tue, 23 Mar 2004 14:40:44 -0400 (AST) +Received: from mxca1.netopia.com (host222.netopia.com [65.206.239.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 29AADD1EC43 + for ; + Tue, 23 Mar 2004 14:40:40 -0400 (AST) +Received: by mxca1.netopia.com with Internet Mail Service (5.5.2657.72) + id ; Tue, 23 Mar 2004 10:40:40 -0800 +Message-ID: +From: "Subbiah, Stalin" +To: 'Andrew Sullivan' , + "'pgsql-performance@postgresql.org'" +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +Date: Tue, 23 Mar 2004 10:40:32 -0800 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: text/plain; + charset="ISO-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/317 +X-Sequence-Number: 6173 + +We are looking into Sun V210 (2 x 1 GHz cpu, 2 gig ram, 5.8Os) vs. Dell 1750 +(2 x 2.4 GHz xeon, 2 gig ram, RH3.0). database will mostly be +write intensive and disks will be on raid 10. Wondering if 64bit 1 GHz to +32bit 2.4 GHz make a big difference here. + +Thanks! + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Andrew +Sullivan +Sent: Tuesday, March 23, 2004 9:37 AM +To: 'pgsql-performance@postgresql.org' +Subject: Re: [PERFORM] [ADMIN] Benchmarking postgres on Solaris/Linux + + +On Mon, Mar 22, 2004 at 04:05:45PM -0800, Subbiah, Stalin wrote: +> being the key performance booster for postgres. what is the preferred OS +> for postgres deployment if given an option between linux and solaris. As + +One thing this very much depends on is what you're trying to do. +Suns have a reputation for greater reliability. While my own +experience with Sun hardware has been rather shy of sterling, I _can_ +say that it stands head and shoulders above a lot of the x86 gear you +can get. + +If you're planning to use Solaris on x86, don't bother. Solaris is a +slow, bloated pig compared to Linux, at least when it comes to +managing the largish number of processes that Postgres requires. + +If pure speed is what you're after, I have found that 2-way, 32 bit +Linux on P-IIIs compares very favourably to 4 way 64 bit Ultra SPARC +IIs. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +The fact that technology doesn't work is no bar to success in the +marketplace. + --Philip Greenspun + +---------------------------(end of broadcast)--------------------------- +TIP 2: you can get off all lists at once with the unregister command + (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + +From pgsql-performance-owner@postgresql.org Tue Mar 23 14:49:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0CBB7D1B55C + for ; + Tue, 23 Mar 2004 18:49: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 23141-07 + for ; + Tue, 23 Mar 2004 14:49:20 -0400 (AST) +Received: from sphere.istructure.com (unknown [24.199.154.122]) + by svr1.postgresql.org (Postfix) with ESMTP id AD3ABD1EC3E + for ; + Tue, 23 Mar 2004 14:49:18 -0400 (AST) +Received: by sphere.istructure.com with Internet Mail Service (5.5.2657.72) + id ; Tue, 23 Mar 2004 13:49:13 -0500 +Message-ID: +From: Woody Woodring +To: pgsql-performance@postgresql.org +Subject: Help with query plan inconsistencies +Date: Tue, 23 Mar 2004 13:49:07 -0500 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/318 +X-Sequence-Number: 6174 + +Hello, + +I am using postgres 7.4.2 as a backend for geocode data for a mapping +application. My question is why can't I get a consistent use of my indexes +during a query, I tend to get a lot of seq scan results. + +I use a standard query: + +SELECT lat, long, mac, status FROM ( + SELECT text(mac) as mac, lat long, CASE status WHEN 0 THEN 0 WHEN 1 THEN +1 ELSE -1 END + as status FROM cable_billing LEFT OUTER JOIN davic USING(mac) WHERE +boxtype='d' +)AS FOO WHERE (long>=X1) AND (long<=X2) AND (lat>=Y1) AND (lat<=Y2) + +Where X1,X2,Y1,Y2 are the coordinates for the rectangle of the map viewing +area. + +QUERY PLAN #1 & #2 are from when I get a view from 10 miles out, sometimes +it uses the index(#1) and most of the time not(#2). I do run into plans +that seq scan both sides of the join. + +QUERY PLAN #3 is when I view from 5 miles out, and I have much greater +chance of getting index scans ( about 90% of the time). + +I have listed information about the database below. + +Cable_billing ~500,000 rows updated once per day +Davic ~500,000 rows, about 100 rows update per minute + +Any info or suggestions would be appreciated. + +Woody + + +twc-ral-overview=# \d cable_billing; + Table "public.cable_billing" + Column | Type | Modifiers +-----------------+------------------------+----------- + cable_billingid | integer | not null + mac | macaddr | not null + account | integer | + number | character varying(10) | + address | character varying(200) | + region | character varying(30) | + division | integer | + franchise | integer | + node | character varying(10) | + lat | numeric | + long | numeric | + trunk | character varying(5) | + ps | character varying(5) | + fd | character varying(5) | + le | character varying(5) | + update | integer | + boxtype | character(1) | +Indexes: cable_billing_pkey primary key btree (mac), + cable_billing_account_index btree (account), + cable_billing_lat_long_idx btree (lat, long), + cable_billing_node_index btree (node), + cable_billing_region_index btree (region) + +twc-ral-overview=# \d davic + Table "public.davic" + Column | Type | Modifiers +---------+-----------------------+----------- + davicid | integer | not null + mac | macaddr | not null + source | character varying(20) | + status | smallint | + updtime | integer | + type | character varying(10) | + avail1 | integer | +Indexes: davic_pkey primary key btree (mac) + + + +twc-ral-overview=# vacuum analyze; +VACUUM +twc-ral-overview=# explain analyze SELECT lat, long, mac, status FROM +(SELECT text(mac) as mac, lat, long, CASE status WHEN 0 THEN 0 WHEN 1 THEN 1 +ELSE -1 END as status FROM cable_billing LEFT OUTER JOIN davic USING(mac) +WHERE boxtype='d') AS foo WHERE (long>=-78.70723462816063) AND +(long<=-78.53096764204116) AND (lat>=35.57411187866667) AND +(lat<=35.66366331376857); +QUERY PLAN #1 + +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +----- + Nested Loop Left Join (cost=0.00..23433.18 rows=1871 width=34) (actual +time=0.555..5095.434 rows=3224 loops=1) + -> Index Scan using cable_billing_lat_long_idx on cable_billing +(cost=0.00..12145.85 rows=1871 width=32) (actual time=0.431..249.931 +rows=3224 loops=1) + Index Cond: ((lat >= 35.57411187866667) AND (lat <= +35.66366331376857) AND (long >= -78.70723462816063) AND (long <= +-78.53096764204116)) + Filter: (boxtype = 'd'::bpchar) + -> Index Scan using davic_pkey on davic (cost=0.00..6.01 rows=1 +width=8) (actual time=1.476..1.480 rows=1 loops=3224) + Index Cond: ("outer".mac = davic.mac) + Total runtime: 5100.028 ms +(7 rows) + + + +twc-ral-overview=# vacuum analyze; +VACUUM +twc-ral-overview=# explain analyze SELECT lat, long, mac, status FROM +(SELECT text(mac) as mac, lat, long, CASE status WHEN 0 THEN 0 WHEN 1 THEN 1 +ELSE -1 END as status FROM cable_billing LEFT OUTER JOIN davic USING(mac) +WHERE boxtype='d') AS foo WHERE (long>=-78.87878592206046) AND +(long<=-78.70220280717479) AND (lat>=35.71703190638861) AND +(lat<=35.80658335998006); +QUERY PLAN #2 + +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +------------------- + Nested Loop Left Join (cost=0.00..76468.90 rows=9223 width=34) (actual +time=0.559..17387.427 rows=19997 loops=1) + -> Seq Scan on cable_billing (cost=0.00..20837.76 rows=9223 width=32) +(actual time=0.290..7117.799 rows=19997 loops=1) + Filter: ((boxtype = 'd'::bpchar) AND (long >= -78.87878592206046) +AND (long <= -78.70220280717479) AND (lat >= 35.71703190638861) AND (lat <= +35.80658335998006)) + -> Index Scan using davic_pkey on davic (cost=0.00..6.01 rows=1 +width=8) (actual time=0.455..0.461 rows=1 loops=19997) + Index Cond: ("outer".mac = davic.mac) + Total runtime: 17416.501 ms +(6 rows) + + + +twc-ral-overview=# explain analyze SELECT lat, long, mac, status FROM +(SELECT text(mac) as mac, lat, long, CASE status WHEN 0 THEN 0 WHEN 1 THEN 1 +ELSE -1 END as status FROM cable_billing LEFT OUTER JOIN davic USING(mac) +WHERE boxtype='d') AS foo WHERE (long>=-78.83419423836857) AND +(long<=-78.7467945148866) AND (lat>=35.73964586635293) AND +(lat<=35.783969313080604); +QUERY PLAN #3 + +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +----- + Nested Loop Left Join (cost=0.00..29160.02 rows=2327 width=34) (actual +time=0.279..510.773 rows=5935 loops=1) + -> Index Scan using cable_billing_lat_long_idx on cable_billing +(cost=0.00..15130.08 rows=2326 width=32) (actual time=0.197..274.115 +rows=5935 loops=1) + Index Cond: ((lat >= 35.73964586635293) AND (lat <= +35.783969313080604) AND (long >= -78.83419423836857) AND (long <= +-78.7467945148866)) + Filter: (boxtype = 'd'::bpchar) + -> Index Scan using davic_pkey on davic (cost=0.00..6.01 rows=1 +width=8) (actual time=0.021..0.024 rows=1 loops=5935) + Index Cond: ("outer".mac = davic.mac) + Total runtime: 516.782 ms +(7 rows) + +---------------------------------------------------------------------------- +----------------------------------- + +iglass Networks +211-A S. Salem St. +(919) 387-3550 x813 +P.O. Box 651 +(919) 387-3570 fax +Apex, NC 27502 +http://www.iglass.net + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 14:51:59 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 06FC8D1EC6E + for ; + Tue, 23 Mar 2004 18:51: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 23603-08 + for ; + Tue, 23 Mar 2004 14:51:51 -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 29835D1EC69 + for ; + Tue, 23 Mar 2004 14:51:49 -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 D1B509AC9D; Tue, 23 Mar 2004 18:51:46 +0000 (GMT) +From: "Matt Clark" +To: "Subbiah, Stalin" , + "'Andrew Sullivan'" , + +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +Date: Tue, 23 Mar 2004 18:51:43 -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.6604 (9.0.2911.0) +In-Reply-To: +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/319 +X-Sequence-Number: 6175 + +If it's going to be write intensive then the RAID controller will be the most important thing. A dual p3/500 with a write-back +cache will smoke either of the boxes you mention using software RAID on write performance. + +As for the compute intensive side (complex joins & sorts etc), the Dell will most likely beat the Sun by some distance, although +what the Sun lacks in CPU power it may make up a bit in memory bandwidth/latency. + +Matt + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Subbiah, +> Stalin +> Sent: 23 March 2004 18:41 +> To: 'Andrew Sullivan'; 'pgsql-performance@postgresql.org' +> Subject: Re: [PERFORM] [ADMIN] Benchmarking postgres on Solaris/Linux +> +> +> We are looking into Sun V210 (2 x 1 GHz cpu, 2 gig ram, 5.8Os) vs. Dell 1750 +> (2 x 2.4 GHz xeon, 2 gig ram, RH3.0). database will mostly be +> write intensive and disks will be on raid 10. Wondering if 64bit 1 GHz to +> 32bit 2.4 GHz make a big difference here. +> +> Thanks! +> +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Andrew +> Sullivan +> Sent: Tuesday, March 23, 2004 9:37 AM +> To: 'pgsql-performance@postgresql.org' +> Subject: Re: [PERFORM] [ADMIN] Benchmarking postgres on Solaris/Linux +> +> +> On Mon, Mar 22, 2004 at 04:05:45PM -0800, Subbiah, Stalin wrote: +> > being the key performance booster for postgres. what is the preferred OS +> > for postgres deployment if given an option between linux and solaris. As +> +> One thing this very much depends on is what you're trying to do. +> Suns have a reputation for greater reliability. While my own +> experience with Sun hardware has been rather shy of sterling, I _can_ +> say that it stands head and shoulders above a lot of the x86 gear you +> can get. +> +> If you're planning to use Solaris on x86, don't bother. Solaris is a +> slow, bloated pig compared to Linux, at least when it comes to +> managing the largish number of processes that Postgres requires. +> +> If pure speed is what you're after, I have found that 2-way, 32 bit +> Linux on P-IIIs compares very favourably to 4 way 64 bit Ultra SPARC +> IIs. +> +> A +> +> -- +> Andrew Sullivan | ajs@crankycanuck.ca +> The fact that technology doesn't work is no bar to success in the +> marketplace. +> --Philip Greenspun +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 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 Mar 23 14:57:58 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D080D1EC4D + for ; + Tue, 23 Mar 2004 18: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 25908-06 + for ; + Tue, 23 Mar 2004 14:53:50 -0400 (AST) +Received: from vt-pe2550-001.VANTAGE.vantage.com (unknown [64.80.203.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 9E0D9D1EAFD + for ; + Tue, 23 Mar 2004 14:53:48 -0400 (AST) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 +Content-Class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: base64 +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +Date: Tue, 23 Mar 2004 13:53:48 -0500 +Message-ID: + <4BAFBB6B9CC46F41B2AD7D9F4BBAF7850980A8@vt-pe2550-001.vantage.vantage.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] [ADMIN] Benchmarking postgres on Solaris/Linux +Thread-Index: AcQRB2xqyRRO4OxMTyewihyOw1NcwwAAHjGD +From: "Anjan Dave" +To: "Subbiah, Stalin" , + "Andrew Sullivan" , +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/320 +X-Sequence-Number: 6176 + +V2hhdCBidXMgc3BlZWRzPw0KIA0KNTMzTUh6IG9uIHRoZSAzMi1iaXQgSW50 +ZWwgd2lsbCBnaXZlIHlvdSBhYm91dCA0LjJHYnBzIG9mIElPIHRocm91Z2hw +dXQuLi4NCiANCkkgdGhpbmsgdGhlIFN1biB3aWxsIGJlIDE1ME1IeiwgNjRi +aXQgaXMgMi40R2JwcyBvZiBJTy4gQ29ycmVjdCBtZSBpZiBpIGFtIHdyb25n +Lg0KIA0KVGhhbmtzLA0KQW5qYW4NCg0KCS0tLS0tT3JpZ2luYWwgTWVzc2Fn +ZS0tLS0tIA0KCUZyb206IFN1YmJpYWgsIFN0YWxpbiBbbWFpbHRvOlNTdWJi +aWFoQG5ldG9waWEuY29tXSANCglTZW50OiBUdWUgMy8yMy8yMDA0IDE6NDAg +UE0gDQoJVG86ICdBbmRyZXcgU3VsbGl2YW4nOyAncGdzcWwtcGVyZm9ybWFu +Y2VAcG9zdGdyZXNxbC5vcmcnIA0KCUNjOiANCglTdWJqZWN0OiBSZTogW1BF +UkZPUk1dIFtBRE1JTl0gQmVuY2htYXJraW5nIHBvc3RncmVzIG9uIFNvbGFy +aXMvTGludXgNCgkNCgkNCg0KCVdlIGFyZSBsb29raW5nIGludG8gU3VuIFYy +MTAgKDIgeCAxIEdIeiBjcHUsIDIgZ2lnIHJhbSwgNS44T3MpIHZzLiBEZWxs +IDE3NTANCgkoMiB4IDIuNCBHSHogeGVvbiwgMiBnaWcgcmFtLCBSSDMuMCku +IGRhdGFiYXNlIHdpbGwgbW9zdGx5IGJlDQoJd3JpdGUgaW50ZW5zaXZlIGFu +ZCBkaXNrcyB3aWxsIGJlIG9uIHJhaWQgMTAuIFdvbmRlcmluZyBpZiA2NGJp +dCAxIEdIeiB0bw0KCTMyYml0IDIuNCBHSHogbWFrZSBhIGJpZyBkaWZmZXJl +bmNlIGhlcmUuDQoJDQoJVGhhbmtzIQ0KCQ0KCS0tLS0tT3JpZ2luYWwgTWVz +c2FnZS0tLS0tDQoJRnJvbTogcGdzcWwtcGVyZm9ybWFuY2Utb3duZXJAcG9z +dGdyZXNxbC5vcmcNCglbbWFpbHRvOnBnc3FsLXBlcmZvcm1hbmNlLW93bmVy +QHBvc3RncmVzcWwub3JnXU9uIEJlaGFsZiBPZiBBbmRyZXcNCglTdWxsaXZh +bg0KCVNlbnQ6IFR1ZXNkYXksIE1hcmNoIDIzLCAyMDA0IDk6MzcgQU0NCglU +bzogJ3Bnc3FsLXBlcmZvcm1hbmNlQHBvc3RncmVzcWwub3JnJw0KCVN1Ympl +Y3Q6IFJlOiBbUEVSRk9STV0gW0FETUlOXSBCZW5jaG1hcmtpbmcgcG9zdGdy +ZXMgb24gU29sYXJpcy9MaW51eA0KCQ0KCQ0KCU9uIE1vbiwgTWFyIDIyLCAy +MDA0IGF0IDA0OjA1OjQ1UE0gLTA4MDAsIFN1YmJpYWgsIFN0YWxpbiB3cm90 +ZToNCgk+IGJlaW5nIHRoZSBrZXkgcGVyZm9ybWFuY2UgYm9vc3RlciBmb3Ig +cG9zdGdyZXMuICB3aGF0IGlzIHRoZSBwcmVmZXJyZWQgT1MNCgk+IGZvciBw +b3N0Z3JlcyBkZXBsb3ltZW50IGlmIGdpdmVuIGFuIG9wdGlvbiBiZXR3ZWVu +IGxpbnV4IGFuZCBzb2xhcmlzLiBBcw0KCQ0KCU9uZSB0aGluZyB0aGlzIHZl +cnkgbXVjaCBkZXBlbmRzIG9uIGlzIHdoYXQgeW91J3JlIHRyeWluZyB0byBk +by4NCglTdW5zIGhhdmUgYSByZXB1dGF0aW9uIGZvciBncmVhdGVyIHJlbGlh +YmlsaXR5LiAgV2hpbGUgbXkgb3duDQoJZXhwZXJpZW5jZSB3aXRoIFN1biBo +YXJkd2FyZSBoYXMgYmVlbiByYXRoZXIgc2h5IG9mIHN0ZXJsaW5nLCBJIF9j +YW5fDQoJc2F5IHRoYXQgaXQgc3RhbmRzIGhlYWQgYW5kIHNob3VsZGVycyBh +Ym92ZSBhIGxvdCBvZiB0aGUgeDg2IGdlYXIgeW91DQoJY2FuIGdldC4NCgkN +CglJZiB5b3UncmUgcGxhbm5pbmcgdG8gdXNlIFNvbGFyaXMgb24geDg2LCBk +b24ndCBib3RoZXIuICBTb2xhcmlzIGlzIGENCglzbG93LCBibG9hdGVkIHBp +ZyBjb21wYXJlZCB0byBMaW51eCwgYXQgbGVhc3Qgd2hlbiBpdCBjb21lcyB0 +bw0KCW1hbmFnaW5nIHRoZSBsYXJnaXNoIG51bWJlciBvZiBwcm9jZXNzZXMg +dGhhdCBQb3N0Z3JlcyByZXF1aXJlcy4NCgkNCglJZiBwdXJlIHNwZWVkIGlz +IHdoYXQgeW91J3JlIGFmdGVyLCBJIGhhdmUgZm91bmQgdGhhdCAyLXdheSwg +MzIgYml0DQoJTGludXggb24gUC1JSUlzIGNvbXBhcmVzIHZlcnkgZmF2b3Vy +YWJseSB0byA0IHdheSA2NCBiaXQgVWx0cmEgU1BBUkMNCglJSXMuDQoJDQoJ +QQ0KCQ0KCS0tDQoJQW5kcmV3IFN1bGxpdmFuICB8IGFqc0BjcmFua3ljYW51 +Y2suY2ENCglUaGUgZmFjdCB0aGF0IHRlY2hub2xvZ3kgZG9lc24ndCB3b3Jr +IGlzIG5vIGJhciB0byBzdWNjZXNzIGluIHRoZQ0KCW1hcmtldHBsYWNlLg0K +CSAgICAgICAgICAgICAgICAtLVBoaWxpcCBHcmVlbnNwdW4NCgkNCgktLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0oZW5kIG9mIGJyb2FkY2FzdCktLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0NCglUSVAgMjogeW91IGNhbiBnZXQg +b2ZmIGFsbCBsaXN0cyBhdCBvbmNlIHdpdGggdGhlIHVucmVnaXN0ZXIgY29t +bWFuZA0KCSAgICAoc2VuZCAidW5yZWdpc3RlciBZb3VyRW1haWxBZGRyZXNz +SGVyZSIgdG8gbWFqb3Jkb21vQHBvc3RncmVzcWwub3JnKQ0KCQ0KCS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLShlbmQgb2YgYnJvYWRjYXN0KS0tLS0t +LS0tLS0tLS0tLS0tLS0tLS0tLS0tLQ0KCVRJUCA5OiB0aGUgcGxhbm5lciB3 +aWxsIGlnbm9yZSB5b3VyIGRlc2lyZSB0byBjaG9vc2UgYW4gaW5kZXggc2Nh +biBpZiB5b3VyDQoJICAgICAgam9pbmluZyBjb2x1bW4ncyBkYXRhdHlwZXMg +ZG8gbm90IG1hdGNoDQoJDQoNCg== + +From pgsql-performance-owner@postgresql.org Tue Mar 23 15:47:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E7B52D1E104 + for ; + Tue, 23 Mar 2004 19:25: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 40660-03 + for ; + Tue, 23 Mar 2004 15:25:10 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP id 6F724D1D58C + for ; + Tue, 23 Mar 2004 15:25:09 -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 i2NJP81a077375 + for ; Tue, 23 Mar 2004 19:25:09 GMT + (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i2NJH9Lo075646 + for pgsql-performance@postgresql.org; Tue, 23 Mar 2004 19:17:09 GMT +From: Joseph Shraibman +X-Newsgroups: comp.databases.postgresql.performance +Subject: Re: Help with query plan inconsistencies +Date: Tue, 23 Mar 2004 14:17:09 -0500 +Organization: Hub.Org Networking Services +Lines: 183 +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 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 +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: 200403/321 +X-Sequence-Number: 6177 + +I'm going to ask because someone else surely will: + +Do you regularily vacuum/analyze the database? + +Woody Woodring wrote: +> Hello, +> +> I am using postgres 7.4.2 as a backend for geocode data for a mapping +> application. My question is why can't I get a consistent use of my indexes +> during a query, I tend to get a lot of seq scan results. +> +> I use a standard query: +> +> SELECT lat, long, mac, status FROM ( +> SELECT text(mac) as mac, lat long, CASE status WHEN 0 THEN 0 WHEN 1 THEN +> 1 ELSE -1 END +> as status FROM cable_billing LEFT OUTER JOIN davic USING(mac) WHERE +> boxtype='d' +> )AS FOO WHERE (long>=X1) AND (long<=X2) AND (lat>=Y1) AND (lat<=Y2) +> +> Where X1,X2,Y1,Y2 are the coordinates for the rectangle of the map viewing +> area. +> +> QUERY PLAN #1 & #2 are from when I get a view from 10 miles out, sometimes +> it uses the index(#1) and most of the time not(#2). I do run into plans +> that seq scan both sides of the join. +> +> QUERY PLAN #3 is when I view from 5 miles out, and I have much greater +> chance of getting index scans ( about 90% of the time). +> +> I have listed information about the database below. +> +> Cable_billing ~500,000 rows updated once per day +> Davic ~500,000 rows, about 100 rows update per minute +> +> Any info or suggestions would be appreciated. +> +> Woody +> +> +> twc-ral-overview=# \d cable_billing; +> Table "public.cable_billing" +> Column | Type | Modifiers +> -----------------+------------------------+----------- +> cable_billingid | integer | not null +> mac | macaddr | not null +> account | integer | +> number | character varying(10) | +> address | character varying(200) | +> region | character varying(30) | +> division | integer | +> franchise | integer | +> node | character varying(10) | +> lat | numeric | +> long | numeric | +> trunk | character varying(5) | +> ps | character varying(5) | +> fd | character varying(5) | +> le | character varying(5) | +> update | integer | +> boxtype | character(1) | +> Indexes: cable_billing_pkey primary key btree (mac), +> cable_billing_account_index btree (account), +> cable_billing_lat_long_idx btree (lat, long), +> cable_billing_node_index btree (node), +> cable_billing_region_index btree (region) +> +> twc-ral-overview=# \d davic +> Table "public.davic" +> Column | Type | Modifiers +> ---------+-----------------------+----------- +> davicid | integer | not null +> mac | macaddr | not null +> source | character varying(20) | +> status | smallint | +> updtime | integer | +> type | character varying(10) | +> avail1 | integer | +> Indexes: davic_pkey primary key btree (mac) +> +> +> +> twc-ral-overview=# vacuum analyze; +> VACUUM +> twc-ral-overview=# explain analyze SELECT lat, long, mac, status FROM +> (SELECT text(mac) as mac, lat, long, CASE status WHEN 0 THEN 0 WHEN 1 THEN 1 +> ELSE -1 END as status FROM cable_billing LEFT OUTER JOIN davic USING(mac) +> WHERE boxtype='d') AS foo WHERE (long>=-78.70723462816063) AND +> (long<=-78.53096764204116) AND (lat>=35.57411187866667) AND +> (lat<=35.66366331376857); +> QUERY PLAN #1 +> +> ---------------------------------------------------------------------------- +> ---------------------------------------------------------------------------- +> ----- +> Nested Loop Left Join (cost=0.00..23433.18 rows=1871 width=34) (actual +> time=0.555..5095.434 rows=3224 loops=1) +> -> Index Scan using cable_billing_lat_long_idx on cable_billing +> (cost=0.00..12145.85 rows=1871 width=32) (actual time=0.431..249.931 +> rows=3224 loops=1) +> Index Cond: ((lat >= 35.57411187866667) AND (lat <= +> 35.66366331376857) AND (long >= -78.70723462816063) AND (long <= +> -78.53096764204116)) +> Filter: (boxtype = 'd'::bpchar) +> -> Index Scan using davic_pkey on davic (cost=0.00..6.01 rows=1 +> width=8) (actual time=1.476..1.480 rows=1 loops=3224) +> Index Cond: ("outer".mac = davic.mac) +> Total runtime: 5100.028 ms +> (7 rows) +> +> +> +> twc-ral-overview=# vacuum analyze; +> VACUUM +> twc-ral-overview=# explain analyze SELECT lat, long, mac, status FROM +> (SELECT text(mac) as mac, lat, long, CASE status WHEN 0 THEN 0 WHEN 1 THEN 1 +> ELSE -1 END as status FROM cable_billing LEFT OUTER JOIN davic USING(mac) +> WHERE boxtype='d') AS foo WHERE (long>=-78.87878592206046) AND +> (long<=-78.70220280717479) AND (lat>=35.71703190638861) AND +> (lat<=35.80658335998006); +> QUERY PLAN #2 +> +> ---------------------------------------------------------------------------- +> ---------------------------------------------------------------------------- +> ------------------- +> Nested Loop Left Join (cost=0.00..76468.90 rows=9223 width=34) (actual +> time=0.559..17387.427 rows=19997 loops=1) +> -> Seq Scan on cable_billing (cost=0.00..20837.76 rows=9223 width=32) +> (actual time=0.290..7117.799 rows=19997 loops=1) +> Filter: ((boxtype = 'd'::bpchar) AND (long >= -78.87878592206046) +> AND (long <= -78.70220280717479) AND (lat >= 35.71703190638861) AND (lat <= +> 35.80658335998006)) +> -> Index Scan using davic_pkey on davic (cost=0.00..6.01 rows=1 +> width=8) (actual time=0.455..0.461 rows=1 loops=19997) +> Index Cond: ("outer".mac = davic.mac) +> Total runtime: 17416.501 ms +> (6 rows) +> +> +> +> twc-ral-overview=# explain analyze SELECT lat, long, mac, status FROM +> (SELECT text(mac) as mac, lat, long, CASE status WHEN 0 THEN 0 WHEN 1 THEN 1 +> ELSE -1 END as status FROM cable_billing LEFT OUTER JOIN davic USING(mac) +> WHERE boxtype='d') AS foo WHERE (long>=-78.83419423836857) AND +> (long<=-78.7467945148866) AND (lat>=35.73964586635293) AND +> (lat<=35.783969313080604); +> QUERY PLAN #3 +> +> ---------------------------------------------------------------------------- +> ---------------------------------------------------------------------------- +> ----- +> Nested Loop Left Join (cost=0.00..29160.02 rows=2327 width=34) (actual +> time=0.279..510.773 rows=5935 loops=1) +> -> Index Scan using cable_billing_lat_long_idx on cable_billing +> (cost=0.00..15130.08 rows=2326 width=32) (actual time=0.197..274.115 +> rows=5935 loops=1) +> Index Cond: ((lat >= 35.73964586635293) AND (lat <= +> 35.783969313080604) AND (long >= -78.83419423836857) AND (long <= +> -78.7467945148866)) +> Filter: (boxtype = 'd'::bpchar) +> -> Index Scan using davic_pkey on davic (cost=0.00..6.01 rows=1 +> width=8) (actual time=0.021..0.024 rows=1 loops=5935) +> Index Cond: ("outer".mac = davic.mac) +> Total runtime: 516.782 ms +> (7 rows) +> +> ---------------------------------------------------------------------------- +> ----------------------------------- +> +> iglass Networks +> 211-A S. Salem St. +> (919) 387-3550 x813 +> P.O. Box 651 +> (919) 387-3570 fax +> Apex, NC 27502 +> http://www.iglass.net +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> + +From pgsql-performance-owner@postgresql.org Fri Mar 26 17:33:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 39DADD1E2E2 + for ; + Tue, 23 Mar 2004 19:25: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 38268-06 + for ; + Tue, 23 Mar 2004 15:25:15 -0400 (AST) +Received: from sourceweave.net (CPE004f49016802-CM.cpe.net.cable.rogers.com + [24.43.140.53]) + by svr1.postgresql.org (Postfix) with SMTP id 2DBD9D1E2D7 + for ; + Tue, 23 Mar 2004 15:25:13 -0400 (AST) +Received: (qmail 18052 invoked by uid 1000); 23 Mar 2004 19:21:34 -0000 +Received: from localhost (sendmail-bs@127.0.0.1) + by localhost with SMTP; 23 Mar 2004 19:21:34 -0000 +Date: Tue, 23 Mar 2004 14:21:34 -0500 (EST) +From: Fabio Esposito +X-X-Sender: nfesposi@cr818510-a.basement +To: pgsql-performance@postgresql.org +Subject: postgres eating CPU on HP9000 +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: 200403/381 +X-Sequence-Number: 6237 + + +Hello fellow PostgreSQL users. + +We've been working on this interesting issue for some time now, and we're +hoping that someone can help. + +We've recently integrated postgres into an existing mature app. Its a +time sensitive 24x7 system. It runs on HP9000, a K370 Dual Processor +system. Postgres is version 7.3.2. Its spawned as a child from a parent +supervisory process, and they communicate to eachother via shared memory. + +We preform 9-12K selects per hour + 6-8K inserts per hour (a few updates here as well) + 1-1.5K Deletes per hour. + +It maintains 48hours of data, so its not a large database; roughly +<600mbs. We do this by running a housekeeping program in a cron job. +It deletes all data older then 48hours, then vaccuum analyzes. It will +also preform a reindex if the option is set before it vaccuum's. + +Postgres initially worked wonderfully, fast and solid. It +preformed complex joins in 0.01secs, and was able to keep up with our +message queue. It stayed this way for almost a year during our +development. + +Recently it started eating up the cpu, and cannot keepup with the system +like it used to. The interesting thing here is that it still runs great +on an older system with less ram, one slower cpu, and an older disk. + +We tried the following with no success: + +running VACCUUM FULL +dropping all tables and staring anew +reinstalling postgres +tweaking kernel parameters (various combos) +tweaking postgres parameters (various combos) +a number of other ideas + +A final note, we have our app on two systems ready for hot backup. The +hot backup system is that older slower system that I mentioned before. The +two communicate with eachother via rpc's. + +Any help anyone can give to steer us in the right direction would be much +appreciated. + +Thanks again + +Fabio E. + + + +Just in case: + +vmstat + procs memory page +faults cpu + r b w avm free re at pi po fr de sr +in sy cs us sy id + 1 0 0 7631 124955 30 31 1 0 0 0 1 +566 964 138 25 2 73 + +top + +System: prokyon Tue Mar 23 19:12:54 +2004 +Load averages: 0.36, 0.33, 0.31 +170 processes: 169 sleeping, 1 running +Cpu states: +CPU LOAD USER NICE SYS IDLE BLOCK SWAIT INTR SSYS + 0 0.07 8.9% 0.0% 0.0% 91.1% 0.0% 0.0% 0.0% 0.0% + 1 0.72 71.3% 0.0% 1.0% 27.7% 0.0% 0.0% 0.0% 0.0% + 2 0.29 29.7% 1.0% 5.0% 64.4% 0.0% 0.0% 0.0% 0.0% +--- ---- ----- ----- ----- ----- ----- ----- ----- ----- +avg 0.36 36.3% 1.0% 2.0% 60.8% 0.0% 0.0% 0.0% 0.0% + +Memory: 33180K (22268K) real, 38868K (28840K) virtual, 499708K free Page# +1/17 + +CPU TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU +COMMAND + 0 pty/ttyp1 18631 am 154 20 6096K 2412K sleep 3:17 93.84 93.68 +postg + 0 rroot 18622 am 154 20 1888K 1192K sleep 0:01 0.78 0.78 +amcodecon + + +ipcs + +IPC status from /dev/kmem as of Tue Mar 23 19:19:19 2004 +T ID KEY MODE OWNER GROUP +Message Queues: +q 0 0x3c180239 -Rrw--w--w- root root +q 1 0x3e180239 --rw-r--r-- root root +Shared Memory: +m 0 0x2f100002 --rw------- root sys +m 1 0x4118020d --rw-rw-rw- root root +m 2 0x4e0c0002 --rw-rw-rw- root root +m 3 0x4114006c --rw-rw-rw- root root +m 4 0x4118387e --rw-rw-rw- am am +m 3805 0x0052e2c1 --rw------- postgres postgres +m 8606 0x0c6629c9 --rw-r----- root sys +m 407 0x06347849 --rw-rw-rw- root sys +Semaphores: +s 0 0x2f100002 --ra-ra-ra- root sys +s 1 0x4118020d --ra-ra-ra- root root +s 2 0x4e0c0002 --ra-ra-ra- root root +s 3 0x4114006c --ra-ra-ra- root root +s 4 0x00446f6e --ra-r--r-- root root +s 5 0x00446f6d --ra-r--r-- root root +s 6 0x01090522 --ra-r--r-- root root +s 7 0x61142e7c --ra-ra-ra- root root +s 8 0x73142e7c --ra-ra-ra- root root +s 9 0x70142e7c --ra-ra-ra- root root +s 10 0x69142e7c --ra-ra-ra- root root +s 11 0x75142e7c --ra-ra-ra- root root +s 12 0x63142e7c --ra-ra-ra- root root +s 13 0x64142e7c --ra-ra-ra- root root +s 14 0x66142e7c --ra-ra-ra- root root +s 15 0x6c142e7c --ra-ra-ra- root root +s 1168 0x0052e2c1 --ra------- postgres postgres +s 401 0x0052e2c2 --ra------- postgres postgres +s 402 0x0052e2c3 --ra------- postgres postgres + + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 16:20:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0D8A9D1D9E9 + for ; + Tue, 23 Mar 2004 20:09: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 61506-02 + for ; + Tue, 23 Mar 2004 16:09:29 -0400 (AST) +Received: from smtp016.mail.yahoo.com (smtp016.mail.yahoo.com + [216.136.174.113]) + by svr1.postgresql.org (Postfix) with SMTP id B500DD1D361 + for ; + Tue, 23 Mar 2004 16:09:27 -0400 (AST) +Received: from unknown (HELO AERS04) (adampalmblad@142.104.12.41 with login) + by smtp016.mail.yahoo.com with SMTP; 23 Mar 2004 20:03:47 -0000 +Message-ID: <003201c41111$f4dc96f0$97019696@AERS04> +From: "A Palmblad" +To: "Postgres Performance" +Subject: SLOW query with aggregates +Date: Tue, 23 Mar 2004 12:03:48 -0800 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/323 +X-Sequence-Number: 6179 + +I am trying to optimize a query that does a lot of aggregation. I have a +large number of columns that are part of the result, and most are +aggregates. They are acting on two temporary tables, the largest of which +should have at most 1 million tuples, and the smaller around 5000; the the +smaller table matches the number of rows expecting in the result. I've +played around with some indexes on the temp tables, and analyzing them; even +using a vacuum analyze, and the worst part is always a groupAggregate. + + This query can be optimized at the expense of other operations; it will +be run during low usage hours. I have tried to bump up sort_mem to get the +query optimizer to cosider a HashAggregate instread of a groupAggregate; +setting it as high as 2 gigs still had the query optimizer using +GroupAggregate. + +The troublesome query is: + +select + tempItems.category_id, + date('2003-11-22'), + sum(a) as a, + count(*) as b, + sum(case when type = 1 then 0 else someNumber end) as successful, + sum(c) as c, + ........ + ........ + tempAggregates.mode as mode + -variations of the above repeated around 30 times, with a few other +aggregates like min and max making an appearance, and some array stuff + from tempItems join tempAggregates using (category_id) + group by tempItems.category_id, mode + +I've tried just grouping by category_id, and doing a max(mode), but that +doesn't have much of an effect on performance; although row estimation for +the group aggregate was better. A lot is being done, so maybe I can't get +it to be much more efficient... + +Here's the output of an explain analyze: + + +QUERY PLAN +---------------------------------------------------------------------------- +---------------------------------------------------------------------------- +--- + GroupAggregate (cost=0.00..338300.34 rows=884 width=345) (actual +time=86943.272..382718.104 rows=3117 loops=1) + -> Merge Join (cost=0.00..93642.52 rows=1135610 width=345) (actual +time=0.148..24006.748 rows=1120974 loops=1) + Merge Cond: ("outer".category_id = "inner".category_id) + -> Index Scan using tempaggregatesindex on tempaggregates +(cost=0.00..91.31 rows=3119 width=115) (actual time=0.055..6.573 rows=3117 +loops=1) + -> Index Scan using tempitemsindex on tempitems +(cost=0.00..79348.45 rows=1135610 width=241) (actual time=0.064..7511.980 +rows=1121164 loops=1) + Total runtime: 382725.502 ms +(6 rows) + +Any thoughts or suggestions would be appreciated. + +-Adam Palmblad + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 16:17:18 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CA006D1D58C + for ; + Tue, 23 Mar 2004 20:14: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 60731-07 + for ; + Tue, 23 Mar 2004 16:14:05 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id B6538D1E9B9 + for ; + Tue, 23 Mar 2004 16:14:03 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4678995; Tue, 23 Mar 2004 12:15:21 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Matt Clark" , "Subbiah, Stalin" , + "'Andrew Sullivan'" , + +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +Date: Tue, 23 Mar 2004 12:13:29 -0800 +User-Agent: KMail/1.5.4 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403231213.29342.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/322 +X-Sequence-Number: 6178 + +Matt, Stalin, + +> As for the compute intensive side (complex joins & sorts etc), the Dell will +most likely beat the Sun by some distance, although +> what the Sun lacks in CPU power it may make up a bit in memory bandwidth/ +latency. + +Personally, I've been unimpressed by Dell/Xeon; I think the Sun might do +better than you think, comparitively. On all the Dell servers I've used so +far, I've not seen performance that comes even close to the hardware specs. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 16:33:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6BC71D1E934 + for ; + Tue, 23 Mar 2004 20:32: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 73943-01 + for ; + Tue, 23 Mar 2004 16:32:09 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 3801FD1E2E2 + for ; + Tue, 23 Mar 2004 16:32:07 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2NKW8N6028367; + Tue, 23 Mar 2004 15:32:08 -0500 (EST) +To: "A Palmblad" +Cc: "Postgres Performance" +Subject: Re: SLOW query with aggregates +In-reply-to: <003201c41111$f4dc96f0$97019696@AERS04> +References: <003201c41111$f4dc96f0$97019696@AERS04> +Comments: In-reply-to "A Palmblad" + message dated "Tue, 23 Mar 2004 12:03:48 -0800" +Date: Tue, 23 Mar 2004 15:32:08 -0500 +Message-ID: <28366.1080073928@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/324 +X-Sequence-Number: 6180 + +"A Palmblad" writes: +> GroupAggregate (cost=0.00..338300.34 rows=884 width=345) (actual +> time=86943.272..382718.104 rows=3117 loops=1) +> -> Merge Join (cost=0.00..93642.52 rows=1135610 width=345) (actual +> time=0.148..24006.748 rows=1120974 loops=1) + +You do not have a planning problem here, and trying to change the plan +is a waste of time. The slowness is in the actual computation of the +aggregate functions; ergo the only way to speed it up is to change what +you're computing. What aggregates are you computing exactly, and over +what datatypes? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 23 17:07:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E9B20D1EC0F + for ; + Tue, 23 Mar 2004 20:42: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 80887-03 + for ; + Tue, 23 Mar 2004 16:42:35 -0400 (AST) +Received: from mxca1.netopia.com (host222.netopia.com [65.206.239.222]) + by svr1.postgresql.org (Postfix) with ESMTP id D3A4FD1EC64 + for ; + Tue, 23 Mar 2004 16:42:33 -0400 (AST) +Received: by mxca1.netopia.com with Internet Mail Service (5.5.2657.72) + id ; Tue, 23 Mar 2004 12:42:35 -0800 +Message-ID: +From: "Subbiah, Stalin" +To: "'josh@agliodbs.com'" , Matt Clark , + "Subbiah, Stalin" , + 'Andrew Sullivan' , pgsql-performance@postgresql.org +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +Date: Tue, 23 Mar 2004 12:42:33 -0800 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: text/plain; + charset="ISO-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/325 +X-Sequence-Number: 6181 + +As anyone done performance benchmark testing with solaris sparc/intel linux. +I once read a post here, which had benchmarking test results for using +different filesystem like xfs, ext3, ext2, ufs etc. i couldn't find that +link anymore and google is failing on me, so anyone have the link handy. + +Thanks! + +-----Original Message----- +From: Josh Berkus [mailto:josh@agliodbs.com] +Sent: Tuesday, March 23, 2004 12:13 PM +To: Matt Clark; Subbiah, Stalin; 'Andrew Sullivan'; +pgsql-performance@postgresql.org +Subject: Re: [PERFORM] [ADMIN] Benchmarking postgres on Solaris/Linux + + +Matt, Stalin, + +> As for the compute intensive side (complex joins & sorts etc), the Dell +will +most likely beat the Sun by some distance, although +> what the Sun lacks in CPU power it may make up a bit in memory bandwidth/ +latency. + +Personally, I've been unimpressed by Dell/Xeon; I think the Sun might do +better than you think, comparitively. On all the Dell servers I've used +so +far, I've not seen performance that comes even close to the hardware specs. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + +From pgsql-performance-owner@postgresql.org Tue Mar 23 17:22:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 36229D1E9B9 + for ; + Tue, 23 Mar 2004 20:48: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 81436-10 + for ; + Tue, 23 Mar 2004 16:48:37 -0400 (AST) +Received: from mail2.dbitech.ca (radius.wavefire.com [64.141.13.252]) + by svr1.postgresql.org (Postfix) with SMTP id 553B2D1E928 + for ; + Tue, 23 Mar 2004 16:48:35 -0400 (AST) +Received: (qmail 10348 invoked from network); 23 Mar 2004 20:55:27 -0000 +Received: from dbitech.wavefire.com (HELO 64.141.15.253) (darcy@64.141.15.253) + by radius.wavefire.com with SMTP; 23 Mar 2004 20:55:27 -0000 +From: Darcy Buskermolen +Organization: Wavefire Technologies Corp. +Subject: Fwd: FreeBSD, PostgreSQL, semwait and sbwait! +Date: Tue, 23 Mar 2004 12:48:34 -0800 +User-Agent: KMail/1.5.4 +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403231248.34425.darcy@wavefire.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/328 +X-Sequence-Number: 6184 + + + +---------- Forwarded Message ---------- + +Subject: FreeBSD, PostgreSQL, semwait and sbwait! +Date: March 23, 2004 12:02 pm +From: "Jason Coene" +To: + +Hello all, + +We're having a substantial problem with our FreeBSD 5.2 database server +running PostgreSQL - it's getting a lot of traffic (figure about 3,000 +queries per second), but queries are slow, and it's seemingly waiting on +other things than CPU time. + +The database server is a dual P4-2.8 w/ HT enabled (kernel finds 4 +processors), 2GB RAM, 4 disk Serial ATA on 3ware RAID, gigabit Ethernet +connection to web servers. It's running FreeBSD 5.2 and PostgreSQL 7.4.1. + +The server is taking a while to respond to both connections, and then +queries (between 1-3 seconds, on a query that should execute in 0.05 or +less). + +The CPU usage for the server never goes above 30% (70% idle), and the CPU +time that's in use is nearly always split equal between user and system. +The system is using + +Doing a "top", this is what we see: + +last pid: 51833; load averages: 13.72, 11.74, 10.01 up 0+01:55:45 15:00:03 +116 processes: 1 running, 99 sleeping, 16 lock +CPU states: 14.6% user, 0.0% nice, 23.7% system, 0.2% interrupt, 61.5% idle +Mem: 91M Active, 1043M Inact, 160M Wired, 52K Cache, 112M Buf, 644M Free +Swap: 4096M Total, 4096M Free + +20354 pgsql 131 0 80728K 5352K select 0 0:24 1.71% 1.71% postgres +36415 pgsql 4 0 81656K 67468K sbwait 2 0:00 3.23% 0.59% postgres +36442 pgsql 128 0 82360K 15868K select 2 0:00 1.75% 0.24% postgres +36447 pgsql -4 0 82544K 10616K semwai 0 0:00 2.05% 0.20% postgres +36461 pgsql -4 0 81612K 6844K semwai 2 0:00 2.05% 0.20% postgres +36368 pgsql 4 0 82416K 20780K sbwait 3 0:00 0.50% 0.15% postgres +36459 pgsql -4 0 81840K 7816K semwai 0 0:00 1.54% 0.15% postgres +36469 pgsql -4 0 81840K 7964K semwai 2 0:00 1.54% 0.15% postgres +36466 pgsql 129 0 81840K 7976K *Giant 2 0:00 1.54% 0.15% postgres +36479 pgsql -4 0 81528K 6648K semwai 0 0:00 3.00% 0.15% postgres +36457 pgsql -4 0 81840K 8040K semwai 1 0:00 1.03% 0.10% postgres +36450 pgsql 129 0 82352K 8188K *Giant 2 0:00 1.03% 0.10% postgres +36472 pgsql -4 0 81824K 7416K semwai 2 0:00 1.03% 0.10% postgres +36478 pgsql 131 0 81840K 7936K select 0 0:00 2.00% 0.10% postgres +36454 pgsql 4 0 82416K 16300K sbwait 3 0:00 0.51% 0.05% postgres +36414 pgsql 4 0 82416K 15872K sbwait 2 0:00 0.27% 0.05% postgres + +Our kernel is GENERIC plus: + +maxusers 512 +options SYSVSHM +options SHMMAXPGS=262144 +options SHMSEG=512 +options SHMMNI=512 +options SYSVSEM +options SEMMNI=512 +options SEMMNS=1024 +options SEMMNU=512 +options SEMMAP=512 +options NMBCLUSTERS=32768 + +Interesting bits from postgresql.conf: + +max_connections = 512 +shared_buffers = 8192 +sort_mem = 16384 +vacuum_mem = 8192 +fsync = false + +It seems that queries are executing fine once they start, but it's taking a +while for them to get going, while the postgres process sits in semwait, +sbwait or select. This problem doesn't happen when there's little load on +the server, it's only when we open it for public consumption that it +exhibits these problems. + +Anyone have this type of problem before? Am I missing something? + +Thanks, Jason + +_______________________________________________ +freebsd-performance@freebsd.org mailing list +http://lists.freebsd.org/mailman/listinfo/freebsd-performance +To unsubscribe, send any mail to + "freebsd-performance-unsubscribe@freebsd.org" + +------------------------------------------------------- + +-- +Darcy Buskermolen +Wavefire Technologies Corp. +ph: 250.717.0200 +fx: 250.763.1759 +http://www.wavefire.com + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 17:08:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 069D2D1B51F + for ; + Tue, 23 Mar 2004 20:57: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 85543-06 + for ; + Tue, 23 Mar 2004 16:57:11 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E84BD1B49B + for ; + Tue, 23 Mar 2004 16:57:09 -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 i2NKu7xa004012; + Tue, 23 Mar 2004 13:56:07 -0700 (MST) +Date: Tue, 23 Mar 2004 13:52:50 -0700 (MST) +From: "scott.marlowe" +To: Josh Berkus +Cc: Matt Clark , "Subbiah, Stalin" , + "'Andrew Sullivan'" , + +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +In-Reply-To: <200403231213.29342.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-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/326 +X-Sequence-Number: 6182 + +On Tue, 23 Mar 2004, Josh Berkus wrote: + +> Matt, Stalin, +> +> > As for the compute intensive side (complex joins & sorts etc), the Dell will +> most likely beat the Sun by some distance, although +> > what the Sun lacks in CPU power it may make up a bit in memory bandwidth/ +> latency. +> +> Personally, I've been unimpressed by Dell/Xeon; I think the Sun might do +> better than you think, comparitively. On all the Dell servers I've used so +> far, I've not seen performance that comes even close to the hardware specs. + +We use a 2600 at work (dual 2.8GHz) with the LSI/Megaraid based battery +backed caching controller, and it flies. Truly flies. + +It's not Dell that's so slow, it's the default adaptec RAID controller or +IDE drives that are slow. Ours has 533 MHz memory bus, by the way. + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 17:22:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7BAD9D1DAE9 + for ; + Tue, 23 Mar 2004 20:53: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 83718-07 + for ; + Tue, 23 Mar 2004 16:53:43 -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 53F63D1D287 + for ; + Tue, 23 Mar 2004 16:53:41 -0400 (AST) +Received: by bayswater1.ymogen.net (Postfix, from userid 99) + id 9B1DC9AD48; Tue, 23 Mar 2004 20:53:42 +0000 (GMT) +Received: from 82.68.132.233 (SquirrelMail authenticated user matt@ymogen.net) + by webmail.ymogen.com with HTTP; + Tue, 23 Mar 2004 20:53:42 -0000 (GMT) +Message-ID: <1356.82.68.132.233.1080075222.squirrel@webmail.ymogen.com> +In-Reply-To: <200403231213.29342.josh@agliodbs.com> +References: + <200403231213.29342.josh@agliodbs.com> +Date: Tue, 23 Mar 2004 20:53:42 -0000 (GMT) +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +From: matt@ymogen.net +To: josh@agliodbs.com +Cc: "Subbiah, Stalin" , + "'Andrew Sullivan'" , pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.2-0.1.7.x +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/327 +X-Sequence-Number: 6183 + +> Personally, I've been unimpressed by Dell/Xeon; I think the Sun might do +> better than you think, comparitively. On all the Dell servers I've used +> so +> far, I've not seen performance that comes even close to the hardware +> specs. + +It's true that any difference will be far less than the GHz ratio, and I +can't really speak for Dell servers in general, but a pair of 2.4GHz Xeons +in a Dell workstation gets about 23 SPECint_rate2000, and a pair of 1GHz +UltraSparc IIIs in a SunFire V210 gets 10. The ratios are the same for +other non-FP benchmarks. + +Now the Suns do have some architectural advantages, and they used to have +far superior memory bandwidth than intel boxes, and they often still do +for more than 2 cpus, and definitely do for more than four. But my +personal experience is that for 4 cpus or less the entry level UNIX +offerings from Sun/IBM/HP fell behind in raw performance (FP excepted) two +or three years ago. The posh hardware's an entirely different matter of +course. + +On the other hand, I can think of innumerable non performance related +reasons to buy a 'real UNIX box' as a low end DB server. CPU performance +is way down the priority list compared with IO throughput, stability, +manageability, support, etc etc. + +Given that the original question was about a very heavily write-oriented +environment, I'd take the Sun every day of the week, assuming that those +compile option changes have sorted out the oddly slow PG performance at +last. + +M + +From pgsql-performance-owner@postgresql.org Tue Mar 23 17:44:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 73D74D1EC6C + for ; + Tue, 23 Mar 2004 21:44: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 23464-03 + for ; + Tue, 23 Mar 2004 17:43:58 -0400 (AST) +Received: from fire-2.osdl.org (fire.osdl.org [65.172.181.4]) + by svr1.postgresql.org (Postfix) with ESMTP id 8B988D1EC4C + for ; + Tue, 23 Mar 2004 17:43:55 -0400 (AST) +Received: from bullpen.pdx.osdl.net (fw.osdl.org [65.172.181.6]) + (authenticated bits=0) + by fire-2.osdl.org (8.12.8/8.12.8) with ESMTP id i2NLhqWg013091 + (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO); + Tue, 23 Mar 2004 13:43:52 -0800 +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +From: Craig Thomas +To: "Subbiah, Stalin" +Cc: "'josh@agliodbs.com'" , Matt Clark , + "'Andrew Sullivan'" , pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Message-Id: <1080078995.1946.6.camel@bullpen.pdx.osdl.net> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.5 +Date: Tue, 23 Mar 2004 13:56:35 -0800 +Content-Transfer-Encoding: 7bit +X-MIMEDefang-Filter: osdl$Revision: 1.55 $ +X-Scanned-By: MIMEDefang 2.36 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/329 +X-Sequence-Number: 6185 + +On Tue, 2004-03-23 at 12:42, Subbiah, Stalin wrote: +> As anyone done performance benchmark testing with solaris sparc/intel linux. +> I once read a post here, which had benchmarking test results for using +> different filesystem like xfs, ext3, ext2, ufs etc. i couldn't find that +> link anymore and google is failing on me, so anyone have the link handy. +> +> Thanks! + +This link: http://developer.osdl.org/markw/ takes you to Mark Wong's +database developer page. The top set of links shows performance results +for Linux kernels running an OLTP workload (dbt-2) under PostgreSQL. He +has numbers for ia32 and ia64 under different file system types. + +To do a "good enough" comparison, one would need to port this test kit +to solaris. So far, this kit is only running on Linux. No one, to my +knowledge has it running on any other platform. But I suspect there are +some working to port the kits. + +> +> -----Original Message----- +> From: Josh Berkus [mailto:josh@agliodbs.com] +> Sent: Tuesday, March 23, 2004 12:13 PM +> To: Matt Clark; Subbiah, Stalin; 'Andrew Sullivan'; +> pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] [ADMIN] Benchmarking postgres on Solaris/Linux +> +> +> Matt, Stalin, +> +> > As for the compute intensive side (complex joins & sorts etc), the Dell +> will +> most likely beat the Sun by some distance, although +> > what the Sun lacks in CPU power it may make up a bit in memory bandwidth/ +> latency. +> +> Personally, I've been unimpressed by Dell/Xeon; I think the Sun might do +> better than you think, comparitively. On all the Dell servers I've used +> so +> far, I've not seen performance that comes even close to the hardware specs. + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 18:03:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 690B1D1EC8E + for ; + Tue, 23 Mar 2004 22:03: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 37121-08 + for ; + Tue, 23 Mar 2004 18:03:39 -0400 (AST) +Received: from fep03-mail.bloor.is.net.cable.rogers.com + (fep03-mail.bloor.is.net.cable.rogers.com [66.185.86.73]) + by svr1.postgresql.org (Postfix) with ESMTP id 2CB3ED1EC7F + for ; + Tue, 23 Mar 2004 18:03:37 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep03-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040323220334.GNCR147578.fep03-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Tue, 23 Mar 2004 17:03:34 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 989F23BE3; Tue, 23 Mar 2004 17:03:38 -0500 (EST) +Date: Tue, 23 Mar 2004 17:03:38 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +Message-ID: <20040323220338.GA14682@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <200403231213.29342.josh@agliodbs.com> + <1356.82.68.132.233.1080075222.squirrel@webmail.ymogen.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1356.82.68.132.233.1080075222.squirrel@webmail.ymogen.com> +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep03-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Tue, + 23 Mar 2004 17:03:34 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/330 +X-Sequence-Number: 6186 + +On Tue, Mar 23, 2004 at 08:53:42PM -0000, matt@ymogen.net wrote: + +> is way down the priority list compared with IO throughput, stability, +> manageability, support, etc etc. + +Indeed, if our Suns actually diabled the broken hardware when they +died, fell over, and rebooted themselves, I'd certainly praise them +to heaven. But I have to say that the really very good reporting of +failing memory has saved me some headaches. + +> environment, I'd take the Sun every day of the week, assuming that those +> compile option changes have sorted out the oddly slow PG performance at +> last. + +I seem to have hit a bad batch of Dell hardware recently, which makes +me second this opinion. + +I should say, also, that my initial experience of AIX has been +extremely good. I can't comment on the fun it might involve in the +long haul, of course. + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +This work was visionary and imaginative, and goes to show that visionary +and imaginative work need not end up well. + --Dennis Ritchie + +From pgsql-performance-owner@postgresql.org Tue Mar 23 18:10:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E1CA3D1EC7F + for ; + Tue, 23 Mar 2004 22:10: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 42473-04 + for ; + Tue, 23 Mar 2004 18:10:23 -0400 (AST) +Received: from internet.potentialtech.com (h-66-167-251-6.phlapafg.covad.net + [66.167.251.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 787FFD1EC6E + for ; + Tue, 23 Mar 2004 18:10:21 -0400 (AST) +Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net + [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP + id DAB3D69A71; Tue, 23 Mar 2004 17:10:22 -0500 (EST) +Message-ID: <4060B5CB.3060605@potentialtech.com> +Date: Tue, 23 Mar 2004 17:10:19 -0500 +From: Bill Moran +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Subbiah, Stalin" +Cc: pgsql-performance@postgresql.org +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +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: 200403/331 +X-Sequence-Number: 6187 + +Subbiah, Stalin wrote: +> As anyone done performance benchmark testing with solaris sparc/intel linux. +> I once read a post here, which had benchmarking test results for using +> different filesystem like xfs, ext3, ext2, ufs etc. i couldn't find that +> link anymore and google is failing on me, so anyone have the link handy. + +If you're talking about the work I did, it's here: +http://www.potentialtech.com/wmoran/ (then follow the link) + +Anyway, that should be easily portable to any platform that will run Postgres, +but I don't know how useful it is in comparing two different platforms. See +the information in the document. It was intended only to test disk access speed, +and attempts to flood the HDD system with database work to do. + +> +> Thanks! +> +> -----Original Message----- +> From: Josh Berkus [mailto:josh@agliodbs.com] +> Sent: Tuesday, March 23, 2004 12:13 PM +> To: Matt Clark; Subbiah, Stalin; 'Andrew Sullivan'; +> pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] [ADMIN] Benchmarking postgres on Solaris/Linux +> +> +> Matt, Stalin, +> +> +>>As for the compute intensive side (complex joins & sorts etc), the Dell +> +> will +> most likely beat the Sun by some distance, although +> +>>what the Sun lacks in CPU power it may make up a bit in memory bandwidth/ +> +> latency. +> +> Personally, I've been unimpressed by Dell/Xeon; I think the Sun might do +> better than you think, comparitively. On all the Dell servers I've used +> so +> far, I've not seen performance that comes even close to the hardware specs. +> + + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 18:20:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C29DD1B580 + for ; + Tue, 23 Mar 2004 22:17:41 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 46929-05 + for ; + Tue, 23 Mar 2004 18:17:40 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id AAEA8D1EC7C + for ; + Tue, 23 Mar 2004 18:17:37 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4679822; Tue, 23 Mar 2004 14:18:56 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Darcy Buskermolen , + pgsql-performance@postgresql.org +Subject: Re: Fwd: FreeBSD, PostgreSQL, semwait and sbwait! +Date: Tue, 23 Mar 2004 14:16:01 -0800 +User-Agent: KMail/1.5.4 +References: <200403231248.34425.darcy@wavefire.com> +In-Reply-To: <200403231248.34425.darcy@wavefire.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403231416.01697.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/333 +X-Sequence-Number: 6189 + +Darcy, + +I suggest getting this person over here instead. They have a *lot* to learn +about tuning PostgreSQL. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 18:18:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5A4F3D1EC92 + for ; + Tue, 23 Mar 2004 22: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 48025-03 + for ; + Tue, 23 Mar 2004 18:17:54 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id E8CFFD1EC50 + for ; + Tue, 23 Mar 2004 18:17:51 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2NMHrWp007084; + Tue, 23 Mar 2004 17:17:53 -0500 (EST) +To: Darcy Buskermolen +Cc: pgsql-performance@postgresql.org +Subject: Re: Fwd: FreeBSD, PostgreSQL, semwait and sbwait! +In-reply-to: <200403231248.34425.darcy@wavefire.com> +References: <200403231248.34425.darcy@wavefire.com> +Comments: In-reply-to Darcy Buskermolen + message dated "Tue, 23 Mar 2004 12:48:34 -0800" +Date: Tue, 23 Mar 2004 17:17:53 -0500 +Message-ID: <7083.1080080273@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/332 +X-Sequence-Number: 6188 + +Darcy Buskermolen writes: +> The database server is a dual P4-2.8 w/ HT enabled (kernel finds 4 +> processors), 2GB RAM, 4 disk Serial ATA on 3ware RAID, gigabit Ethernet +> connection to web servers. It's running FreeBSD 5.2 and PostgreSQL 7.4.1. + +Hm. What happens if you turn off the hyperthreading? + +We have seen a number of reports recently that suggest that our +spinlocking code behaves inefficiently on hyperthreaded machines. +This hasn't got to the point where we have any substantiated evidence, +mind you, but maybe you can help provide some. + +Also it might be interesting to put one of these into the outer loop in +s_lock(): + + __asm__ __volatile__( + " rep; nop \n" + : : : "memory"); + +(This suggestion is a quick-and-dirty backport of a change that's +already in CVS tip.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 23 18:27:35 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6C63ED1EC41 + for ; + Tue, 23 Mar 2004 22:27: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 53556-06 + for ; + Tue, 23 Mar 2004 18:27:33 -0400 (AST) +Received: from COLSWEEPER.cranel.local (newmail.cranel.com [66.192.200.227]) + by svr1.postgresql.org (Postfix) with ESMTP id 1114BD1E2E2 + for ; + Tue, 23 Mar 2004 18:27:30 -0400 (AST) +Received: from colmail01.cranel.local (colmail01.cranel.com) by + COLSWEEPER.cranel.local + (Content Technologies SMTPRS 4.3.12) with ESMTP id + ; + Tue, 23 Mar 2004 17:26:52 -0500 +Received: from cranel.com (192.168.11.134 [192.168.11.134]) by + colmail01.cranel.local with SMTP (Microsoft Exchange Internet + Mail Service Version 5.5.2657.72) + id HN8F6AVH; Tue, 23 Mar 2004 17:31:43 -0500 +Message-ID: <4060B9CB.6080305@cranel.com> +Date: Tue, 23 Mar 2004 17:27:23 -0500 +From: Greg Spiegelberg +Organization: Cranel, Inc. +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Rosser Schwarz +Cc: pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +References: <003c01c410f1$0192d7e0$2500fa0a@CardServices.TCI.com> +In-Reply-To: <003c01c410f1$0192d7e0$2500fa0a@CardServices.TCI.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: 200403/334 +X-Sequence-Number: 6190 + +Rosser Schwarz wrote: +> Greg Spiegelberg wrote: +> +> +>>I've been following this thread closely as I have the same problem +>>with an UPDATE. Everything is identical here right down to the +>>strace output. +> +> +>>Has anyone found a workaround or resolved the problem? If not, +>>I have test systems here which I can use to help up test and explore. +> +> +> I'm still gathering data. The explain analyze I'd expected to finish +> Thursday afternoon hasn't yet. I'm going to kill it and try a few +> smaller runs, increasing in size, until the behavior manifests. +> +> Will advise. + +I've replaced my atrocious UPDATE with the following. + +begin; +-- Drop all contraints +alter table ORIG drop constraint ...; +-- Drop all indexes +drop index ...; +-- Update +update ORIG set column=... where...; +commit; + +Problem is when I recreate the indexes and add the constraints back +on ORIG I end up with the same long running process. The original +UPDATE runs for about 30 minutes on a table of 400,000 with the +WHERE matching about 70% of the rows. The above runs for about 2 +minutes without adding the constraints or indexes however adding the +constraints and creating the dropped indexes negates any gain. + +RedHat 7.3 + Kernel 2.4.24 + ext3 + PostgreSQL 7.3.5 +Dual PIII 1.3'ishGHz, 2GB Memory +U160 OS drives and a 1Gbps test SAN on a Hitachi 9910 + +Greg + +-- +Greg Spiegelberg + Sr. Product Development Engineer + Cranel, Incorporated. + Phone: 614.318.4314 + Fax: 614.431.8388 + Email: gspiegelberg@Cranel.com +Cranel. Technology. Integrity. Focus. + + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 18:48:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 906B1D1E2D7 + for ; + Tue, 23 Mar 2004 22: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 66431-03 + for ; + Tue, 23 Mar 2004 18:48:19 -0400 (AST) +Received: from hotmail.com (law10-oe65.law10.hotmail.com [64.4.14.200]) + by svr1.postgresql.org (Postfix) with ESMTP id 77EDAD1E150 + for ; + Tue, 23 Mar 2004 18:48:16 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Tue, 23 Mar 2004 14:48:18 -0800 +Received: from 67.81.102.201 by law10-oe65.law10.hotmail.com with DAV; + Tue, 23 Mar 2004 22:48:17 +0000 +X-Originating-IP: [67.81.102.201] +X-Originating-Email: [awerman2@hotmail.com] +X-Sender: awerman2@hotmail.com +From: "Aaron Werman" +To: "Subbiah, Stalin" , , + "Matt Clark" , "'Andrew Sullivan'" , + +References: +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +Date: Tue, 23 Mar 2004 17:48:21 -0500 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Message-ID: +X-OriginalArrivalTime: 23 Mar 2004 22:48:18.0260 (UTC) + FILETIME=[EF31D140:01C41128] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/335 +X-Sequence-Number: 6191 + +Are you talking about +http://www.potentialtech.com/wmoran/postgresql.php#conclusion +----- Original Message ----- +From: "Subbiah, Stalin" +To: ; "Matt Clark" ; "Subbiah, Stalin" +; "'Andrew Sullivan'" ; + +Sent: Tuesday, March 23, 2004 3:42 PM +Subject: Re: [PERFORM] [ADMIN] Benchmarking postgres on Solaris/Linux + + +> As anyone done performance benchmark testing with solaris sparc/intel +linux. +> I once read a post here, which had benchmarking test results for using +> different filesystem like xfs, ext3, ext2, ufs etc. i couldn't find that +> link anymore and google is failing on me, so anyone have the link handy. +> +> Thanks! +> +> -----Original Message----- +> From: Josh Berkus [mailto:josh@agliodbs.com] +> Sent: Tuesday, March 23, 2004 12:13 PM +> To: Matt Clark; Subbiah, Stalin; 'Andrew Sullivan'; +> pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] [ADMIN] Benchmarking postgres on Solaris/Linux +> +> +> Matt, Stalin, +> +> > As for the compute intensive side (complex joins & sorts etc), the Dell +> will +> most likely beat the Sun by some distance, although +> > what the Sun lacks in CPU power it may make up a bit in memory +bandwidth/ +> latency. +> +> Personally, I've been unimpressed by Dell/Xeon; I think the Sun might do +> better than you think, comparitively. On all the Dell servers I've used +> so +> far, I've not seen performance that comes even close to the hardware +specs. +> +> -- +> -Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 8: explain analyze is your friend +> + +From pgsql-performance-owner@postgresql.org Tue Mar 23 18:52:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 72FAED1B51F + for ; + Tue, 23 Mar 2004 22:52: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 65533-10 + for ; + Tue, 23 Mar 2004 18:52:43 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 24286D1B580 + for ; + Tue, 23 Mar 2004 18:52:40 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2NMqbOk007478; + Tue, 23 Mar 2004 17:52:37 -0500 (EST) +To: Greg Spiegelberg +Cc: Rosser Schwarz , + pgsql-performance@postgresql.org +Subject: Re: atrocious update performance +In-reply-to: <4060B9CB.6080305@cranel.com> +References: <003c01c410f1$0192d7e0$2500fa0a@CardServices.TCI.com> + <4060B9CB.6080305@cranel.com> +Comments: In-reply-to Greg Spiegelberg + message dated "Tue, 23 Mar 2004 17:27:23 -0500" +Date: Tue, 23 Mar 2004 17:52:36 -0500 +Message-ID: <7477.1080082356@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/336 +X-Sequence-Number: 6192 + +Greg Spiegelberg writes: +> RedHat 7.3 + Kernel 2.4.24 + ext3 + PostgreSQL 7.3.5 + ^^^^^^^^^^^^^^^^ + +Please try 7.4. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 23 18:55:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D9908D1E2E2 + for ; + Tue, 23 Mar 2004 22:55: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 69772-03 + for ; + Tue, 23 Mar 2004 18:55:46 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id D6460D1D38B + for ; + Tue, 23 Mar 2004 18:55:42 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4680082; Tue, 23 Mar 2004 14:57:02 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Tom Lane , + Darcy Buskermolen +Subject: Re: Fwd: FreeBSD, PostgreSQL, semwait and sbwait! +Date: Tue, 23 Mar 2004 14:55:08 -0800 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: <200403231248.34425.darcy@wavefire.com> + <7083.1080080273@sss.pgh.pa.us> +In-Reply-To: <7083.1080080273@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403231455.08334.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/337 +X-Sequence-Number: 6193 + +Tom, + +> Hm. What happens if you turn off the hyperthreading? + +Forget hyperthreading. Look at their postgresql.conf settings. 8mb shared +mem, 16mb sort mem per connection for 512 connections, default +effective_cache_size. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 19:00:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D224CD1E104 + for ; + Tue, 23 Mar 2004 23:00: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 70768-03 + for ; + Tue, 23 Mar 2004 19:00:44 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 1CAF1D1DCC0 + for ; + Tue, 23 Mar 2004 19:00:41 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2NN0fSl007577; + Tue, 23 Mar 2004 18:00:41 -0500 (EST) +To: josh@agliodbs.com +Cc: Darcy Buskermolen , + pgsql-performance@postgresql.org +Subject: Re: Fwd: FreeBSD, PostgreSQL, semwait and sbwait! +In-reply-to: <200403231455.08334.josh@agliodbs.com> +References: <200403231248.34425.darcy@wavefire.com> + <7083.1080080273@sss.pgh.pa.us> + <200403231455.08334.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Tue, 23 Mar 2004 14:55:08 -0800" +Date: Tue, 23 Mar 2004 18:00:40 -0500 +Message-ID: <7576.1080082840@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/338 +X-Sequence-Number: 6194 + +Josh Berkus writes: +> Forget hyperthreading. Look at their postgresql.conf settings. 8mb shared +> mem, 16mb sort mem per connection for 512 connections, default +> effective_cache_size. + +They could well be going into swap hell due to the oversized sort_mem, +but that didn't quite seem to explain the reported behavior. I'd want +to see vmstat or similar output to confirm whether the disks are busy, +though. Amazing how many people forget that a database is normally +I/O-bound rather than CPU-bound. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 23 19:18:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 90297D1EC1A + for ; + Tue, 23 Mar 2004 23:18: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 77006-03 + for ; + Tue, 23 Mar 2004 19:18:29 -0400 (AST) +Received: from mxca1.netopia.com (host222.netopia.com [65.206.239.222]) + by svr1.postgresql.org (Postfix) with ESMTP id CE00CD1EC4C + for ; + Tue, 23 Mar 2004 19:18:26 -0400 (AST) +Received: by mxca1.netopia.com with Internet Mail Service (5.5.2657.72) + id ; Tue, 23 Mar 2004 15:18:29 -0800 +Message-ID: +From: "Subbiah, Stalin" +To: 'Bill Moran' , + "Subbiah, Stalin" +Cc: pgsql-performance@postgresql.org +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +Date: Tue, 23 Mar 2004 15:18:20 -0800 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: text/plain; + charset="ISO-8859-1" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/339 +X-Sequence-Number: 6195 + +Yep. Thanks Bill. + +-----Original Message----- +From: Bill Moran [mailto:wmoran@potentialtech.com] +Sent: Tuesday, March 23, 2004 2:10 PM +To: Subbiah, Stalin +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] [ADMIN] Benchmarking postgres on Solaris/Linux + + +Subbiah, Stalin wrote: +> As anyone done performance benchmark testing with solaris sparc/intel +linux. +> I once read a post here, which had benchmarking test results for using +> different filesystem like xfs, ext3, ext2, ufs etc. i couldn't find that +> link anymore and google is failing on me, so anyone have the link handy. + +If you're talking about the work I did, it's here: +http://www.potentialtech.com/wmoran/ (then follow the link) + +Anyway, that should be easily portable to any platform that will run +Postgres, +but I don't know how useful it is in comparing two different platforms. See +the information in the document. It was intended only to test disk access +speed, +and attempts to flood the HDD system with database work to do. + +> +> Thanks! +> +> -----Original Message----- +> From: Josh Berkus [mailto:josh@agliodbs.com] +> Sent: Tuesday, March 23, 2004 12:13 PM +> To: Matt Clark; Subbiah, Stalin; 'Andrew Sullivan'; +> pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] [ADMIN] Benchmarking postgres on Solaris/Linux +> +> +> Matt, Stalin, +> +> +>>As for the compute intensive side (complex joins & sorts etc), the Dell +> +> will +> most likely beat the Sun by some distance, although +> +>>what the Sun lacks in CPU power it may make up a bit in memory bandwidth/ +> +> latency. +> +> Personally, I've been unimpressed by Dell/Xeon; I think the Sun might do +> better than you think, comparitively. On all the Dell servers I've used +> so +> far, I've not seen performance that comes even close to the hardware +specs. +> + + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + +From pgsql-performance-owner@postgresql.org Tue Mar 23 19:35:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D5CB2D1EC3C + for ; + Tue, 23 Mar 2004 23:35: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 83148-02 + for ; + Tue, 23 Mar 2004 19:35:47 -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 9A089D1EC1A + for ; + Tue, 23 Mar 2004 19:35:44 -0400 (AST) +Received: by bayswater1.ymogen.net (Postfix, from userid 99) + id 1A50B9AD48; Tue, 23 Mar 2004 23:35:47 +0000 (GMT) +Received: from 82.68.132.233 (SquirrelMail authenticated user matt@ymogen.net) + by webmail.ymogen.com with HTTP; + Tue, 23 Mar 2004 23:35:47 -0000 (GMT) +Message-ID: <4751.82.68.132.233.1080084947.squirrel@webmail.ymogen.com> +In-Reply-To: <20040323220338.GA14682@phlogiston.dyndns.org> +References: + <200403231213.29342.josh@agliodbs.com> + <1356.82.68.132.233.1080075222.squirrel@webmail.ymogen.com> + <20040323220338.GA14682@phlogiston.dyndns.org> +Date: Tue, 23 Mar 2004 23:35:47 -0000 (GMT) +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +From: matt@ymogen.net +To: "Andrew Sullivan" +Cc: pgsql-performance@postgresql.org +User-Agent: SquirrelMail/1.4.2-0.1.7.x +MIME-Version: 1.0 +Content-Type: text/plain;charset=iso-8859-1 +Content-Transfer-Encoding: 8bit +X-Priority: 3 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/340 +X-Sequence-Number: 6196 + +> Indeed, if our Suns actually diabled the broken hardware when they +> died, fell over, and rebooted themselves, I'd certainly praise them +> to heaven. But I have to say that the really very good reporting of +> failing memory has saved me some headaches. + +Ha! Yes, it would seem the obvious thing to do - but as you say, at least +you get told what borked and may even be able to remove it without +stopping the machine. Sometimes. Or at least you get a nice lunch from +your Sun reseller. + +> I should say, also, that my initial experience of AIX has been +> extremely good. I can't comment on the fun it might involve in the +> long haul, of course. + +The current crop of power4+ boxen is reputed to even be able to recover +from a failed CPU without a restart. Not *always* one imagines, but +usefully often enough for the banking mob to get sweaty over the feature. +More importantly though, IBM seems committed to supporting all this +goodness under Linux too (though not BSD I fear - sorry Bruce) + +Now if these vendors could somehow eliminate downtime due to human error +we'd be talking *serious* reliablity. + +M + +From pgsql-admin-owner@postgresql.org Thu Mar 25 17:34:39 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 2120AD1D12F; Wed, 24 Mar 2004 03:31: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 71725-06; Tue, 23 Mar 2004 23:31:51 -0400 (AST) +Received: from localhost.localdomain (unknown [166.70.154.50]) + by svr1.postgresql.org (Postfix) with ESMTP + id D561ED1BABD; Tue, 23 Mar 2004 23:31:46 -0400 (AST) +Received: from [127.0.0.1] (strongbad [127.0.0.1]) + by localhost.localdomain (8.12.8/8.12.8) with ESMTP id i2O3VnBo026601; + Tue, 23 Mar 2004 20:31:49 -0700 +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: "'pgsql-admin@postgresql.org'" , + "'pgsql-performance@postgresql.org'" +From: Adam Ruth +Subject: Re: Databases Vs. Schemas +Date: Tue, 23 Mar 2004 20:31:46 -0700 +To: "Subbiah, Stalin" +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/330 +X-Sequence-Number: 12899 + + +On Mar 23, 2004, at 11:16 AM, Subbiah, Stalin wrote: + +>> And we also created rules to allow update, delete, and insert on those +>> views so that they looked like tables. The reason we did this is +>> because we ran into issues with too many open files during pg_dump +>> when +>> we had thousands of tables instead of about 1 hundred tables and +>> thousands of views. +> +> Is it because you had smaller value set for max. allowable number of +> open +> files descriptor. what was ulimit -a set to ? + +It was actually running on OS X and it was a shared memory issue. We +would have had to recompile the Darwin kernel to get a bigger SHMMAX, +but this solution seemed better since we would possibly be installing +on servers where we wouldn't have that much leeway. I think that the +view idea works better for a number of other reasons. For one, I can +do a query on the base table and see all of the rows for all of the +schemas at once, that has proven quite useful. + +> +>> We, however, did have a need to periodically select data from 2 +>> schemas +>> at a time, and it was simpler logic than if we needed 2 database +>> connections. +> +> Adam Ruth +> +> On Mar 22, 2004, at 2:30 PM, Subbiah, Stalin wrote: +> +>> --sorry to repost, just subscribed to the list. hopefully it gets to +>> the +>> list this time -- +>> +>> Hi All, +>> +>> We are evaluating the options for having multiple databases vs. +>> schemas on a +>> single database cluster for a custom grown app that we developed. Each +>> app +>> installs same set of tables for each service. And the service could +>> easily +>> be in thousands. so Is it better to have 1000 databases vs 1000 +>> schemas in a +>> database cluster. What are the performance overhead of having multiple +>> databases vs. schemas (if any). I'm leaning towards having schemas +>> rather +>> than databases but i would like to get others opinion on this. +>> Appreciate +>> your reply. +>> +>> Thanks, +>> Stalin +>> +>> ---------------------------(end of +>> broadcast)--------------------------- +>> TIP 3: if posting/reading through Usenet, please send an appropriate +>> subscribe-nomail command to majordomo@postgresql.org so that +>> your +>> message can get through to the mailing list cleanly +>> +> + + +From pgsql-performance-owner@postgresql.org Tue Mar 23 23:42:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 7E523D1C967 + for ; + Wed, 24 Mar 2004 03:42: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 77209-03 + for ; + Tue, 23 Mar 2004 23:42:22 -0400 (AST) +Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) + by svr1.postgresql.org (Postfix) with ESMTP id 50961D1EC53 + for ; + Tue, 23 Mar 2004 23:42:17 -0400 (AST) +Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) + by smtp.istop.com (Postfix) with ESMTP + id 9CCAE17C3FB; Tue, 23 Mar 2004 22:42:21 -0500 (EST) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1B5zHZ-0003rY-00; Tue, 23 Mar 2004 22:42:21 -0500 +To: "A Palmblad" +Cc: "Postgres Performance" +Subject: Re: SLOW query with aggregates +References: <003201c41111$f4dc96f0$97019696@AERS04> +In-Reply-To: <003201c41111$f4dc96f0$97019696@AERS04> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 23 Mar 2004 22:42:20 -0500 +Message-ID: <878yhqx65f.fsf@stark.xeocode.com> +Lines: 27 +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: 200403/341 +X-Sequence-Number: 6197 + + +"A Palmblad" writes: + +> GroupAggregate (cost=0.00..338300.34 rows=884 width=345) (actual +> time=86943.272..382718.104 rows=3117 loops=1) +> -> Merge Join (cost=0.00..93642.52 rows=1135610 width=345) (actual +> time=0.148..24006.748 rows=1120974 loops=1) + +I think the reason you're getting a GroupAggregate here instead of a +HashAggregate is that the MergeJoin is already producing the records in the +desired order, so the GroupAggregate doesn't require an extra sort, ie, it's +effectively free. + +You might be able to verify this by running the query with + +enable_indexscan = off and/or enable_mergejoin = off + +some combination of which might get the planner to do a seqscan of the large +table with a hash join to the small table and then a HashAggregate. + +If you're reading a lot of the large table the seqscan could be a little +faster, not much though. And given the accurate statistics guesses here the +planner may well have gotten this one right and the seqscan is slower. Can't +hurt to be verify it though. + +-- +greg + + +From pgsql-admin-owner@postgresql.org Thu Mar 25 17:41:51 2004 +X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id E94D9D1B53C; Wed, 24 Mar 2004 08:52: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 62063-10; Wed, 24 Mar 2004 04:52:01 -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 393C4D1D175; Wed, 24 Mar 2004 04:51:59 -0400 (AST) +Received: from smtp-2.paradise.net.nz (smtp-2b.paradise.net.nz [202.0.32.211]) + by linda-1.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0HV2009QUOMN5Q@linda-1.paradise.net.nz>; Wed, + 24 Mar 2004 20:51:59 +1200 (NZST) +Received: from paradise.net.nz (218-101-13-54.paradise.net.nz [218.101.13.54]) + by smtp-2.paradise.net.nz (Postfix) with ESMTP id EDE729E7DD; Wed, + 24 Mar 2004 20:51:58 +1200 (NZST) +Date: Wed, 24 Mar 2004 20:53:31 +1200 +From: Mark Kirkwood +Subject: Re: [PERFORM] Benchmarking postgres on Solaris/Linux +In-reply-to: <200403230815.39993.josh@agliodbs.com> +To: Josh Berkus +Cc: "Subbiah, Stalin" , + "'pgsql-performance@postgresql.org'" , + "'pgsql-admin@postgresql.org'" +Message-id: <40614C8B.8070207@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.5) Gecko/20031213 +References: + <405FCD9A.2010207@paradise.net.nz> + <200403230815.39993.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/333 +X-Sequence-Number: 12902 + + + +Josh Berkus wrote: + +>Mark, +> +> +> +>>It might be worth considering Apple if you want a 64-bit chip that has a +>>clock speed comparable to Intel's - the Xserv is similarly priced to Sun +>>V210 (both dual cpu 1U's). +>> +>> +> +>Personally I'd stay *far* away from the XServs until Apple learns to build +>some real server harware. The current XServs have internal parts more +>appropriate to a Dell desktop (promise controller, low-speed commodity IDE +>drives), than a server. +> +>If Apple has prices these IU desktop machines similar to Sun, then I sense +>doom ahead for the Apple Server Division. +> +> +> +(thinks...) Point taken - the Xserv is pretty "entry level"... + +However, having recently benchmarked a 280R vs a PIII Dell using a +Promise ide raid controller - and finding the Dell comparable (with +write cache *disabled*), I suspect that the Xserv has a pretty good +chance of outperforming a V210 (certainly would be interesting to try +out....) + +What I think has happened is that over the last few years then "cheap / +slow" ide stuff has gotten pretty fast - even when you make "write mean +write".... + +cheers + +Mark + + +From pgsql-performance-owner@postgresql.org Wed Mar 24 05:07:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5797BD1E91C + for ; + Wed, 24 Mar 2004 09:07: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 70036-07 + for ; + Wed, 24 Mar 2004 05:07:32 -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 E0B95D1B905 + for ; + Wed, 24 Mar 2004 05:07:29 -0400 (AST) +Received: from smtp-3.paradise.net.nz (smtp-3b.paradise.net.nz [202.0.32.212]) + by linda-1.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0HV2009Z4PCILR@linda-1.paradise.net.nz> for + pgsql-performance@postgresql.org; Wed, 24 Mar 2004 21:07:31 +1200 (NZST) +Received: from paradise.net.nz (218-101-13-54.paradise.net.nz [218.101.13.54]) + by smtp-3.paradise.net.nz (Postfix) with ESMTP id 80FC5AE7ED; Wed, + 24 Mar 2004 21:07:30 +1200 (NZST) +Date: Wed, 24 Mar 2004 21:09:02 +1200 +From: Mark Kirkwood +Subject: Re: Fwd: FreeBSD, PostgreSQL, semwait and sbwait! +In-reply-to: <200403231455.08334.josh@agliodbs.com> +To: josh@agliodbs.com +Cc: Tom Lane , Darcy Buskermolen , + pgsql-performance@postgresql.org +Message-id: <4061502E.6030201@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.5) Gecko/20031213 +References: <200403231248.34425.darcy@wavefire.com> + <7083.1080080273@sss.pgh.pa.us> <200403231455.08334.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/343 +X-Sequence-Number: 6199 + + + +Josh Berkus wrote: + +> Forget hyperthreading. Look at their postgresql.conf settings. 8mb shared +> +>mem, 16mb sort mem per connection for 512 connections, default +>effective_cache_size. +> +> +> +Umm...its 64Mb shared buffers isn't it ? + +However agree completely with general thrust of message.... particularly +the 16Mb of sort mem / connection - a very bad idea unless you are +running a data warehouse box for only a few users (not 512 of them...) + +regards + +Mark + + +From pgsql-performance-owner@postgresql.org Wed Mar 24 05:25:01 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 29D75D1ECB2 + for ; + Wed, 24 Mar 2004 09:24: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 79178-05 + for ; + Wed, 24 Mar 2004 05:24:57 -0400 (AST) +Received: from linda-3.paradise.net.nz (bm-3a.paradise.net.nz [202.0.58.22]) + by svr1.postgresql.org (Postfix) with ESMTP id 807C0D1ECAF + for ; + Wed, 24 Mar 2004 05:24:54 -0400 (AST) +Received: from smtp-1.paradise.net.nz (smtp-1b.paradise.net.nz [202.0.32.210]) + by linda-3.paradise.net.nz (Paradise.net.nz) + with ESMTP id <0HV20010PQ5JGS@linda-3.paradise.net.nz> for + pgsql-performance@postgresql.org; Wed, 24 Mar 2004 21:24:55 +1200 (NZST) +Received: from paradise.net.nz (218-101-13-54.paradise.net.nz [218.101.13.54]) + by smtp-1.paradise.net.nz (Postfix) with ESMTP id 0B9DE83068; Wed, + 24 Mar 2004 21:24:55 +1200 (NZST) +Date: Wed, 24 Mar 2004 21:26:27 +1200 +From: Mark Kirkwood +Subject: Re: Fwd: FreeBSD, PostgreSQL, semwait and sbwait! +In-reply-to: <200403231248.34425.darcy@wavefire.com> +To: Darcy Buskermolen +Cc: pgsql-performance@postgresql.org +Message-id: <40615443.4030003@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.5) Gecko/20031213 +References: <200403231248.34425.darcy@wavefire.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/344 +X-Sequence-Number: 6200 + +Darcy Buskermolen wrote: + +>---------- Forwarded Message ---------- +> +>Subject: FreeBSD, PostgreSQL, semwait and sbwait! +>Date: March 23, 2004 12:02 pm +>From: "Jason Coene" +>To: +> +>Hello all, +> +>We're having a substantial problem with our FreeBSD 5.2 database server +>running PostgreSQL - it's getting a lot of traffic (figure about 3,000 +>queries per second), but queries are slow, and it's seemingly waiting on +>other things than CPU time +> +> +Could this be a 5.2 performance issue ? + +In spite of certain areas where the 5.x series performance is known to +be much better than 4.x (e.g networking), this may not be manifested in +practice for a complete application. +(e.g. I am still running 4.9 as it outperformed 5.1 vastly for a ~100 +database sessions running queries - note that I have not tried out 5.2, +so am happy to be corrected on this) + +regards + +Mark + + +From pgsql-performance-owner@postgresql.org Wed Mar 24 07:34:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D9A8D1E104 + for ; + Wed, 24 Mar 2004 11:34: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 36326-06 + for ; + Wed, 24 Mar 2004 07:34:11 -0400 (AST) +Received: from mail.unisoftbg.com (mail.unisoftbg.com [194.12.229.207]) + by svr1.postgresql.org (Postfix) with ESMTP id 032E4D1EC0F + for ; + Wed, 24 Mar 2004 07:34:05 -0400 (AST) +Received: (qmail 24794 invoked by uid 507); 24 Mar 2004 12:38:48 -0000 +Received: from unknown (HELO t1.unisoftbg.com) + (pginfo%t1.unisoftbg.com@194.12.229.193) + by 0 with SMTP; 24 Mar 2004 12:38:48 -0000 +Message-ID: <406160DF.44D0988C@t1.unisoftbg.com> +Date: Wed, 24 Mar 2004 11:20:15 +0100 +From: pginfo +X-Mailer: Mozilla 4.03 [en] (Win95; I) +MIME-Version: 1.0 +To: "pgsql-performance@postgresql.org" +Subject: slow vacuum performance +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=BAYES_20, + RCVD_IN_DSBL, TO_ADDRESS_EQ_REAL +X-Spam-Level: +X-Archive-Number: 200403/345 +X-Sequence-Number: 6201 + +Hi, + +I am running pg 7.4.1 on linux box. +I have a midle size DB with many updates and after it I try to run +vacuum full analyze. +It takes about 2 h. +If I try to dump and reload the DB it take 20 min. + +How can I improve the vacuum full analyze time? + +My configuration: + +shared_buffers = 15000 # min 16, at least max_connections*2, +8KB each +sort_mem = 10000 # min 64, size in KB +vacuum_mem = 32000 # min 1024, size in KB +effective_cache_size = 40000 # typically 8KB each +#max_fsm_pages = 20000 # min max_fsm_relations*16, 6 bytes each + +#max_fsm_relations = 1000 # min 100, ~50 bytes each + + +regards, +ivan. + + +From pgsql-performance-owner@postgresql.org Wed Mar 24 08:04:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 266BFD1D606 + for ; + Wed, 24 Mar 2004 12:04: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 49602-03 + for ; + Wed, 24 Mar 2004 08:04:41 -0400 (AST) +Received: from fep04-mail.bloor.is.net.cable.rogers.com + (fep04-mail.bloor.is.net.cable.rogers.com [66.185.86.74]) + by svr1.postgresql.org (Postfix) with ESMTP id 0390CD1BAC2 + for ; + Wed, 24 Mar 2004 08:04:38 -0400 (AST) +Received: from phlogiston.dydns.org ([65.49.121.67]) + by fep04-mail.bloor.is.net.cable.rogers.com + (InterMail vM.5.01.05.12 201-253-122-126-112-20020820) with ESMTP id + <20040324120356.NJZG323940.fep04-mail.bloor.is.net.cable.rogers.com@phlogiston.dydns.org> + for ; + Wed, 24 Mar 2004 07:03:56 -0500 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 0AA563BE3; Wed, 24 Mar 2004 07:04:40 -0500 (EST) +Date: Wed, 24 Mar 2004 07:04:40 -0500 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +Message-ID: <20040324120439.GA16090@phlogiston.dyndns.org> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <200403231213.29342.josh@agliodbs.com> + <1356.82.68.132.233.1080075222.squirrel@webmail.ymogen.com> + <20040323220338.GA14682@phlogiston.dyndns.org> + <4751.82.68.132.233.1080084947.squirrel@webmail.ymogen.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4751.82.68.132.233.1080084947.squirrel@webmail.ymogen.com> +User-Agent: Mutt/1.5.5.1+cvs20040105i +X-Authentication-Info: Submitted using SMTP AUTH LOGIN at + fep04-mail.bloor.is.net.cable.rogers.com from [65.49.121.67] + using ID at Wed, + 24 Mar 2004 07:03:56 -0500 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/346 +X-Sequence-Number: 6202 + +On Tue, Mar 23, 2004 at 11:35:47PM -0000, matt@ymogen.net wrote: +> More importantly though, IBM seems committed to supporting all this +> goodness under Linux too (though not BSD I fear - sorry Bruce) + +Although so far they don't. And let me tell you, AIX's reputation +for being strange is well earned. It has some real nice features, +though: topas is awfully nice for spotting bottlenecks, and it works +in a terminal so you don't have to have X and all the rest of that +stuff installed. We're just in the preliminary stages with this +system, but my experience so far has been positive. On new machines, +though, one _hopes_ that hardware failures are relatively infrequent. + +> Now if these vendors could somehow eliminate downtime due to human error +> we'd be talking *serious* reliablity. + +You mean making the OS smart enough to know when clearing the arp +cache is a bonehead operation, or just making the hardware smart +enough to realise that the keyswitch really shouldn't be turned +while 40 people are logged in? (Either way, I agree this'd be an +improvement. It'd sure make colocation a lot less painful.) + +A + +-- +Andrew Sullivan | ajs@crankycanuck.ca +In the future this spectacle of the middle classes shocking the avant- +garde will probably become the textbook definition of Postmodernism. + --Brad Holland + +From pgsql-performance-owner@postgresql.org Fri Mar 26 17:37:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 546B0D1EC81 + for ; + Wed, 24 Mar 2004 12:11: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 50985-07 + for ; + Wed, 24 Mar 2004 08:11:29 -0400 (AST) +Received: from aari.shi.ar (shiar.net [213.84.17.17]) + by svr1.postgresql.org (Postfix) with ESMTP id B102FD1ECB9 + for ; + Wed, 24 Mar 2004 08:11:25 -0400 (AST) +Received: by aari.shi.ar (Postfix, from userid 1000) + id 030F131146; Wed, 24 Mar 2004 13:11:25 +0100 (CET) +Date: Wed, 24 Mar 2004 13:11:25 +0100 +From: Shiar +To: pgsql-performance@postgresql.org +Subject: bigint index not used +Message-ID: <20040324121125.GE1178@shiar.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +X-Originating-IP: [172.18.105.9] +X-Mailer: Mutt 1.5.4i + Vim 6.2 (Debian Sid GNU/Linux 2.6.2) +X-Face: "P0K@jx#[}DSMuY-PotP_k(0n(#0)rx.S*^vxoR}]K; + %#76#:c}E* kt)ndb/Q,lI"H/+aZH +X-URL: http://shiar.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/384 +X-Sequence-Number: 6240 + +We've got a table containing userdata, such as a bigint column 'icq'. To +easily check whether a user has an icq number entered, we made the following +index: + userinfo_icq_ne0_id_key btree (id) WHERE (icq <> 0::bigint), + +However, it doesn't seem to be used: + +> EXPLAIN ANALYZE SELECT id FROM userinfo WHERE icq <> '0'; + Seq Scan on userinfo (cost=0.00..47355.90 rows=849244 width=4) (actual time=0.563..1222.963 rows=48797 loops=1) + Filter: (icq <> 0::bigint) + Total runtime: 1258.703 ms + +> SET enable_seqscan TO off; +> EXPLAIN ANALYZE SELECT id FROM userinfo WHERE icq <> '0'; + Index Scan using userinfo_icq_ne0_id_key on userinfo (cost=0.00..65341.34 rows=48801 width=4) (actual time=0.124..256.478 rows=48797 loops=1) + Filter: (icq <> 0::bigint) + Total runtime: 290.804 ms + +It would even rather use much larger indexes, for example the integer pics with +index: + userinfo_pics_gt0_id_key btree (id) WHERE (pics > 0), + +> EXPLAIN ANALYZE SELECT id FROM userinfo WHERE icq <> '0' AND pics > 0; + Index Scan using userinfo_pics_gt0_id_key on userinfo (cost=0.00..60249.29 rows=323478 width=4) (actual time=0.039..1349.590 rows=23500 loops=1) + Filter: ((icq <> 0::bigint) AND (pics > 0)) + Total runtime: 1368.227 ms + +We're running PostgreSQL 7.4.1 on a Debian/Linux 2.4 system with 4GB RAM and a +fast SCSI RAID array, with settings: + +shared_buffers = 65536 # min max_connections*2 or 16, 8KB each +sort_mem = 16384 # min 64, size in KB +effective_cache_size = 327680 # typically 8KB each +random_page_cost = 1.5 # 4 # units are one sequential page fetch cost + +-- +Shiar - http://www.shiar.org +> Mi devas forfughi antau fluganta nubskrapulo alterighos sur mia kapo + +From pgsql-performance-owner@postgresql.org Wed Mar 24 08:39:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1259DD1D606 + for ; + Wed, 24 Mar 2004 12:39: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 63668-09 + for ; + Wed, 24 Mar 2004 08:39:51 -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 68A56D1D175 + for ; + Wed, 24 Mar 2004 08:39:47 -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 630CC9AD5D; Wed, 24 Mar 2004 12:39:49 +0000 (GMT) +From: "Matt Clark" +To: "Andrew Sullivan" , + +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +Date: Wed, 24 Mar 2004 12:39:48 -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.6604 (9.0.2911.0) +In-Reply-To: <20040324120439.GA16090@phlogiston.dyndns.org> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/347 +X-Sequence-Number: 6203 + +> > Now if these vendors could somehow eliminate downtime due to human error +> > we'd be talking *serious* reliablity. +> +> You mean making the OS smart enough to know when clearing the arp +> cache is a bonehead operation, or just making the hardware smart +> enough to realise that the keyswitch really shouldn't be turned +> while 40 people are logged in? (Either way, I agree this'd be an +> improvement. It'd sure make colocation a lot less painful.) + +Well I was joking really, but those are two very good examples! Yes, machines should require extra confirmation for operations like +those. Hell, even a simple 'init 0' would be well served by a prompt that says "There are currently 400 network sockets open, 50 +remote users logged in, and 25 disk IOs per second. What's more, there's nobody logged in at the console to boot me up again +afterwards - are you _sure_ you want to shut the machine down?". It's also crazy that there's no prompt after an 'rm -rf' (we could +have 'rm -rf --iacceptfullresponsibility' for an unprompted version). + +Stuff like that would have saved me from a few embarrassments in the past for sure ;-) + +It drives me absolutely nuts every time I see a $staggeringly_expensive clustered server whose sysadmins are scared to do a failover +test in case something goes wrong! Or which has worse uptime than my desktop PC because the cluster software's poorly set up or +administered. Or which has both machines on the same circuit breaker. I could go on but it's depressing me. + +Favourite anecdote: A project manager friend of mine had a new 'lights out' datacenter to set up. The engineers, admins and +operators swore blind that everything had been tested in every possible way, and that incredible uptime was guaranteed. 'So if I +just pull this disk out everything will keep working?' he asked, and then pulled the disk out without waiting for an answer... + +Ever since he told me that story I've done exactly that with every piece of so-called 'redundant' hardware a vendor tries to flog +me. Ask them to set it up, then just do nasty things to it without asking for permission. Less than half the gear makes it through +that filter, and actually you can almost tell from the look on the technical sales rep's face as you reach for the +drive/cable/card/whatever whether it will or won't. + +M + + + + + + +From pgsql-performance-owner@postgresql.org Wed Mar 24 09:59:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 865C8D1D55A + for ; + Wed, 24 Mar 2004 13:59: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 02220-05 + for ; + Wed, 24 Mar 2004 09:59:14 -0400 (AST) +Received: from sphere.istructure.com (istructure.com [24.199.154.122]) + by svr1.postgresql.org (Postfix) with ESMTP id 6E669D1C4ED + for ; + Wed, 24 Mar 2004 09:59:10 -0400 (AST) +Received: from isswoodyxp (isswoody.istructure.com [192.168.177.111]) by + sphere.istructure.com with SMTP (Microsoft Exchange Internet + Mail Service Version 5.5.2657.72) + id FWMJ0ST5; Wed, 24 Mar 2004 08:59:07 -0500 +From: "George Woodring" +To: +Subject: Re: Help with query plan inconsistencies +Date: Wed, 24 Mar 2004 08:59:07 -0500 +Message-ID: <000f01c411a8$2ce72420$6fb1a8c0@istructure.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +In-Reply-To: +Importance: Normal +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/348 +X-Sequence-Number: 6204 + +I currently have it set up to vacuum/analyze every 2 hours. However my +QUERY PLAN #1 & #2 in my example I ran my explain immediately after a +vacuum/analyze. + + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Joseph +Shraibman +Sent: Tuesday, March 23, 2004 2:17 PM +To: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Help with query plan inconsistencies + + +I'm going to ask because someone else surely will: + +Do you regularily vacuum/analyze the database? + +Woody Woodring wrote: +> Hello, +>=20 +> I am using postgres 7.4.2 as a backend for geocode data for a mapping=20 +> application. My question is why can't I get a consistent use of my=20 +> indexes during a query, I tend to get a lot of seq scan results. +>=20 +> I use a standard query: +>=20 +> SELECT lat, long, mac, status FROM ( +> SELECT text(mac) as mac, lat long, CASE status WHEN 0 THEN 0 WHEN 1=20 +> THEN 1 ELSE -1 END +> as status FROM cable_billing LEFT OUTER JOIN davic USING(mac)=20 +> WHERE boxtype=3D'd' )AS FOO WHERE (long>=3DX1) AND (long<=3DX2) AND=20 +> (lat>=3DY1) AND (lat<=3DY2) +>=20 +> Where X1,X2,Y1,Y2 are the coordinates for the rectangle of the map=20 +> viewing area. +>=20 +> QUERY PLAN #1 & #2 are from when I get a view from 10 miles out,=20 +> sometimes it uses the index(#1) and most of the time not(#2). I do=20 +> run into plans that seq scan both sides of the join. +>=20 +> QUERY PLAN #3 is when I view from 5 miles out, and I have much greater=20 +> chance of getting index scans ( about 90% of the time). +>=20 +> I have listed information about the database below. +>=20 +> Cable_billing ~500,000 rows updated once per day +> Davic ~500,000 rows, about 100 rows update per minute +>=20 +> Any info or suggestions would be appreciated. +>=20 +> Woody +>=20 +>=20 +> twc-ral-overview=3D# \d cable_billing; +> Table "public.cable_billing" +> Column | Type | Modifiers=20 +> -----------------+------------------------+----------- +> cable_billingid | integer | not null +> mac | macaddr | not null +> account | integer |=20 +> number | character varying(10) |=20 +> address | character varying(200) |=20 +> region | character varying(30) |=20 +> division | integer |=20 +> franchise | integer |=20 +> node | character varying(10) |=20 +> lat | numeric |=20 +> long | numeric |=20 +> trunk | character varying(5) |=20 +> ps | character varying(5) |=20 +> fd | character varying(5) |=20 +> le | character varying(5) |=20 +> update | integer |=20 +> boxtype | character(1) |=20 +> Indexes: cable_billing_pkey primary key btree (mac), +> cable_billing_account_index btree (account), +> cable_billing_lat_long_idx btree (lat, long), +> cable_billing_node_index btree (node), +> cable_billing_region_index btree (region) +>=20 +> twc-ral-overview=3D# \d davic +> Table "public.davic" +> Column | Type | Modifiers=20 +> ---------+-----------------------+----------- +> davicid | integer | not null +> mac | macaddr | not null +> source | character varying(20) |=20 +> status | smallint |=20 +> updtime | integer |=20 +> type | character varying(10) |=20 +> avail1 | integer |=20 +> Indexes: davic_pkey primary key btree (mac) +>=20 +>=20 +>=20 +> twc-ral-overview=3D# vacuum analyze; +> VACUUM +> twc-ral-overview=3D# explain analyze SELECT lat, long, mac, status FROM= +=20 +> (SELECT text(mac) as mac, lat, long, CASE status WHEN 0 THEN 0 WHEN 1=20 +> THEN 1 ELSE -1 END as status FROM cable_billing LEFT OUTER JOIN davic=20 +> USING(mac) WHERE boxtype=3D'd') AS foo WHERE (long>=3D-78.70723462816063= +)=20 +> AND +> (long<=3D-78.53096764204116) AND (lat>=3D35.57411187866667) AND +> (lat<=3D35.66366331376857); +> QUERY PLAN #1 +>=20 +> ---------------------------------------------------------------------- +> ------ +> +---------------------------------------------------------------------------- +> ----- +> Nested Loop Left Join (cost=3D0.00..23433.18 rows=3D1871 width=3D34) (a= +ctual +> time=3D0.555..5095.434 rows=3D3224 loops=3D1) +> -> Index Scan using cable_billing_lat_long_idx on cable_billing +> (cost=3D0.00..12145.85 rows=3D1871 width=3D32) (actual time=3D0.431..249.= +931 +> rows=3D3224 loops=3D1) +> Index Cond: ((lat >=3D 35.57411187866667) AND (lat <=3D +> 35.66366331376857) AND (long >=3D -78.70723462816063) AND (long <=3D +> -78.53096764204116)) +> Filter: (boxtype =3D 'd'::bpchar) +> -> Index Scan using davic_pkey on davic (cost=3D0.00..6.01 rows=3D1 +> width=3D8) (actual time=3D1.476..1.480 rows=3D1 loops=3D3224) +> Index Cond: ("outer".mac =3D davic.mac) +> Total runtime: 5100.028 ms +> (7 rows) +>=20 +>=20 +>=20 +> twc-ral-overview=3D# vacuum analyze; +> VACUUM +> twc-ral-overview=3D# explain analyze SELECT lat, long, mac, status FROM= +=20 +> (SELECT text(mac) as mac, lat, long, CASE status WHEN 0 THEN 0 WHEN 1=20 +> THEN 1 ELSE -1 END as status FROM cable_billing LEFT OUTER JOIN davic=20 +> USING(mac) WHERE boxtype=3D'd') AS foo WHERE (long>=3D-78.87878592206046= +)=20 +> AND +> (long<=3D-78.70220280717479) AND (lat>=3D35.71703190638861) AND +> (lat<=3D35.80658335998006); +> QUERY PLAN #2 +>=20 +> ---------------------------------------------------------------------- +> ------ +> +---------------------------------------------------------------------------- +> ------------------- +> Nested Loop Left Join (cost=3D0.00..76468.90 rows=3D9223 width=3D34) (a= +ctual +> time=3D0.559..17387.427 rows=3D19997 loops=3D1) +> -> Seq Scan on cable_billing (cost=3D0.00..20837.76 rows=3D9223 widt= +h=3D32) +> (actual time=3D0.290..7117.799 rows=3D19997 loops=3D1) +> Filter: ((boxtype =3D 'd'::bpchar) AND (long >=3D -78.8787859220= +6046) +> AND (long <=3D -78.70220280717479) AND (lat >=3D 35.71703190638861) AND (= +lat +<=3D +> 35.80658335998006)) +> -> Index Scan using davic_pkey on davic (cost=3D0.00..6.01 rows=3D1 +> width=3D8) (actual time=3D0.455..0.461 rows=3D1 loops=3D19997) +> Index Cond: ("outer".mac =3D davic.mac) +> Total runtime: 17416.501 ms +> (6 rows) +>=20 +>=20 +>=20 +> twc-ral-overview=3D# explain analyze SELECT lat, long, mac, status FROM= +=20 +> (SELECT text(mac) as mac, lat, long, CASE status WHEN 0 THEN 0 WHEN 1=20 +> THEN 1 ELSE -1 END as status FROM cable_billing LEFT OUTER JOIN davic=20 +> USING(mac) WHERE boxtype=3D'd') AS foo WHERE (long>=3D-78.83419423836857= +)=20 +> AND +> (long<=3D-78.7467945148866) AND (lat>=3D35.73964586635293) AND +> (lat<=3D35.783969313080604); +> QUERY PLAN #3 +>=20 +> ---------------------------------------------------------------------- +> ------ +> +---------------------------------------------------------------------------- +> ----- +> Nested Loop Left Join (cost=3D0.00..29160.02 rows=3D2327 width=3D34) (a= +ctual +> time=3D0.279..510.773 rows=3D5935 loops=3D1) +> -> Index Scan using cable_billing_lat_long_idx on cable_billing +> (cost=3D0.00..15130.08 rows=3D2326 width=3D32) (actual time=3D0.197..274.= +115 +> rows=3D5935 loops=3D1) +> Index Cond: ((lat >=3D 35.73964586635293) AND (lat <=3D +> 35.783969313080604) AND (long >=3D -78.83419423836857) AND (long <=3D +> -78.7467945148866)) +> Filter: (boxtype =3D 'd'::bpchar) +> -> Index Scan using davic_pkey on davic (cost=3D0.00..6.01 rows=3D1 +> width=3D8) (actual time=3D0.021..0.024 rows=3D1 loops=3D5935) +> Index Cond: ("outer".mac =3D davic.mac) +> Total runtime: 516.782 ms +> (7 rows) +>=20 +> ---------------------------------------------------------------------- +> ------ +> ----------------------------------- +>=20 +> iglass Networks +> 211-A S. Salem St. +> (919) 387-3550 x813 +> P.O. Box 651 +> (919) 387-3570 fax +> Apex, NC 27502 +> http://www.iglass.net +>=20 +>=20 +> ---------------------------(end of=20 +> broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +>=20 +> http://www.postgresql.org/docs/faqs/FAQ.html +>=20 + +---------------------------(end of broadcast)--------------------------- +TIP 3: if posting/reading through Usenet, please send an appropriate + subscribe-nomail command to majordomo@postgresql.org so that your + message can get through to the mailing list cleanly + + +From pgsql-performance-owner@postgresql.org Wed Mar 24 10:07:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1B3ABD1EC44 + for ; + Wed, 24 Mar 2004 14:07: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 07124-05 + for ; + Wed, 24 Mar 2004 10:07:31 -0400 (AST) +Received: from internet.potentialtech.com (h-66-167-251-6.phlapafg.covad.net + [66.167.251.6]) + by svr1.postgresql.org (Postfix) with ESMTP id 607AED1B905 + for ; + Wed, 24 Mar 2004 10:07:27 -0400 (AST) +Received: from potentialtech.com (pa-plum1c-102.pit.adelphia.net + [24.53.179.102]) by internet.potentialtech.com (Postfix) with ESMTP + id C823469A7C; Wed, 24 Mar 2004 09:07:30 -0500 (EST) +Message-ID: <4061961F.6080009@potentialtech.com> +Date: Wed, 24 Mar 2004 09:07:27 -0500 +From: Bill Moran +User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031005 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pginfo +Cc: "pgsql-performance@postgresql.org" +Subject: Re: slow vacuum performance +References: <406160DF.44D0988C@t1.unisoftbg.com> +In-Reply-To: <406160DF.44D0988C@t1.unisoftbg.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: 200403/349 +X-Sequence-Number: 6205 + +pginfo wrote: +> Hi, +> +> I am running pg 7.4.1 on linux box. +> I have a midle size DB with many updates and after it I try to run +> vacuum full analyze. +> It takes about 2 h. +> If I try to dump and reload the DB it take 20 min. +> +> How can I improve the vacuum full analyze time? + +How often are you vacuuming? If you've gone a LONG time since the last vacuum, +it can take quite a while, to the point where a dump/restore is faster. + +A recent realization that I've had some misconceptions about vacuuming led me +to re-read section 8.2 of the admin guide (on vacuuming) ... I highly suggest +a review of these 3 pages of the admin manual, as it contains an excellent +description of why databases need vacuumed, that one can use to determine how +often vacuuming is necessary. + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + + +From pgsql-performance-owner@postgresql.org Wed Mar 24 11:35:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6351BD1E9CD + for ; + Wed, 24 Mar 2004 15:35: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 68486-02 + for ; + Wed, 24 Mar 2004 11:35:36 -0400 (AST) +Received: from mail.unisoftbg.com (mail.unisoftbg.com [194.12.229.207]) + by svr1.postgresql.org (Postfix) with ESMTP id 38470D1DD17 + for ; + Wed, 24 Mar 2004 11:35:29 -0400 (AST) +Received: (qmail 1439 invoked by uid 507); 24 Mar 2004 16:40:15 -0000 +Received: from unknown (HELO t1.unisoftbg.com) + (pginfo%t1.unisoftbg.com@194.12.229.193) + by 0 with SMTP; 24 Mar 2004 16:40:15 -0000 +Message-ID: <4061996C.E230AF23@t1.unisoftbg.com> +Date: Wed, 24 Mar 2004 15:21:32 +0100 +From: pginfo +X-Mailer: Mozilla 4.03 [en] (Win95; I) +MIME-Version: 1.0 +To: Bill Moran +Cc: "pgsql-performance@postgresql.org" +Subject: Re: slow vacuum performance +References: <406160DF.44D0988C@t1.unisoftbg.com> + <4061961F.6080009@potentialtech.com> +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/350 +X-Sequence-Number: 6206 + +Hi Bill, +I am vacuuming every 24 h. +I have a cron script about i. +But if I make massive update (for example it affects 1 M rows) and I start vacuum, +it take this 2 h. +Also I will note, that this massive update is running in one transaction ( I can +not update 100K and start vacuum after it). + +regards, +ivan. + +Bill Moran wrote: + +> pginfo wrote: +> > Hi, +> > +> > I am running pg 7.4.1 on linux box. +> > I have a midle size DB with many updates and after it I try to run +> > vacuum full analyze. +> > It takes about 2 h. +> > If I try to dump and reload the DB it take 20 min. +> > +> > How can I improve the vacuum full analyze time? +> +> How often are you vacuuming? If you've gone a LONG time since the last vacuum, +> it can take quite a while, to the point where a dump/restore is faster. +> +> A recent realization that I've had some misconceptions about vacuuming led me +> to re-read section 8.2 of the admin guide (on vacuuming) ... I highly suggest +> a review of these 3 pages of the admin manual, as it contains an excellent +> description of why databases need vacuumed, that one can use to determine how +> often vacuuming is necessary. +> +> -- +> Bill Moran +> Potential Technologies +> http://www.potentialtech.com + + + + +From pgsql-performance-owner@postgresql.org Wed Mar 24 12:31:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id ABC15D1B562 + for ; + Wed, 24 Mar 2004 16:31: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 93557-04 + for ; + Wed, 24 Mar 2004 12:31:28 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 39F07D1ECB6 + for ; + Wed, 24 Mar 2004 12:31: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 i2OGU3iP026126; + Wed, 24 Mar 2004 09:30:04 -0700 (MST) +Date: Wed, 24 Mar 2004 09:26:40 -0700 (MST) +From: "scott.marlowe" +To: pginfo +Cc: "pgsql-performance@postgresql.org" +Subject: Re: slow vacuum performance +In-Reply-To: <406160DF.44D0988C@t1.unisoftbg.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-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/351 +X-Sequence-Number: 6207 + +On Wed, 24 Mar 2004, pginfo wrote: + +> Hi, +> +> I am running pg 7.4.1 on linux box. +> I have a midle size DB with many updates and after it I try to run +> vacuum full analyze. + +Is there a reason to not use just regular vacuum / analyze (i.e. NOT +full)? + +> It takes about 2 h. + +Full vacuums, by their nature, tend to be a bit slow. It's better to let +the database achieve a kind of "steady state" with regards to number of +dead tuples, and use regular vacuums to reclaim said space rather than a +full vacuum. + +> How can I improve the vacuum full analyze time? +> +> My configuration: +> +> shared_buffers = 15000 # min 16, at least max_connections*2, +> 8KB each +> sort_mem = 10000 # min 64, size in KB + +You might want to look at dropping sort_mem. It would appear you've been +going through the postgresql.conf file and bumping up numbers to see what +works and what doesn't. While most of the settings aren't too dangerous +to crank up a little high, sort_mem is quite dangerous to crank up high, +should you have a lot of people connected who are all sorting. Note that +sort_mem is a limit PER SORT, not per backend, or per database, or per +user, or even per table, but per sort. IF a query needs to run three or +four sorts, it can use 3 or 4x sort_mem. If a hundred users do this at +once, they can then use 300 or 400x sort_mem. You can see where I'm +heading. + +Note that for individual sorts in batch files, like import processes, you +can bump up sort_mem with the set command, so you don't have to have a +large setting in postgresql.conf to use a lot of sort mem when you need +to, you can just grab it during that one session. + +> vacuum_mem = 32000 # min 1024, size in KB + +If you've got lots of memory, crank up vacuum_mem to the 200 to 500 meg +range and see what happens. + +For a good tuning guide, go here: + +http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + + +From pgsql-performance-owner@postgresql.org Wed Mar 24 12:38:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0EEE6D1B8B6 + for ; + Wed, 24 Mar 2004 16:38: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 98804-02 + for ; + Wed, 24 Mar 2004 12:38:40 -0400 (AST) +Received: from www.totalcardinc.com (unknown [64.33.232.186]) + by svr1.postgresql.org (Postfix) with ESMTP id 43102D1B562 + for ; + Wed, 24 Mar 2004 12:38:39 -0400 (AST) +Received: from RSCHWARZW2K ([10.250.0.37]) (authenticated bits=0) + by www.totalcardinc.com (8.12.8/8.12.8) with ESMTP id i2OGcZRG013018; + Wed, 24 Mar 2004 10:38:35 -0600 +From: "Rosser Schwarz" +To: "'Greg Spiegelberg'" +Cc: +Subject: Re: atrocious update performance +Date: Wed, 24 Mar 2004 10:38:35 -0600 +Message-ID: <004301c411be$74004650$2500fa0a@CardServices.TCI.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.4510 +In-Reply-To: <4060B9CB.6080305@cranel.com> +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-MailScanner-From: rschwarz@totalcardinc.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/352 +X-Sequence-Number: 6208 + +Greg Spiegelberg wrote: + +> > Will advise. + +After creating 100, 1K, 10K, 100K and 1M-row subsets of account.cust and +the corresponding rows/tables with foreign key constraints referring to +the table, I'm unable to reproduce the behavior at issue. + +explain analyze looks like the following, showing the query run with the +join column indexed and not, respectively: + +# explain analyze update test.cust100 set prodid = tempprod.prodid, +subprodid = tempprod.subprodid where origid = tempprod.debtid; +-- with index + QUERY PLAN +----------------------------------------------------------------------- + Merge Join (cost=0.00..25.64 rows=500 width=220) (actual + time=0.241..13.091 rows=100 loops=1) + Merge Cond: (("outer".origid)::text = ("inner".debtid)::text) + -> Index Scan using ix_origid_cust100 on cust100 (cost=0.00..11.50 + rows=500 width=204) (actual time=0.125..6.465 rows=100 loops=1) + -> Index Scan using ix_debtid on tempprod (cost=0.00..66916.71 + rows=4731410 width=26) (actual time=0.057..1.497 rows=101 loops=1) + Total runtime: 34.067 ms +(5 rows) + +-- without index + QUERY PLAN +---------------------------------------------------------------------- + Merge Join (cost=7.32..16.71 rows=100 width=220) (actual + time=4.415..10.918 rows=100 loops=1) + Merge Cond: (("outer".debtid)::text = "inner"."?column22?") + -> Index Scan using ix_debtid on tempprod (cost=0.00..66916.71 + rows=4731410 width=26) (actual time=0.051..1.291 rows=101 loops=1) + -> Sort (cost=7.32..7.57 rows=100 width=204) (actual + time=4.311..4.450 rows=100 loops=1) + Sort Key: (cust100.origid)::text + -> Seq Scan on cust100 (cost=0.00..4.00 rows=100 width=204) + (actual time=0.235..2.615 rows=100 loops=1) + Total runtime: 25.031 ms +(7 rows) + +With the join column indexed, it takes roughly .32ms/row on the first +four tests (100.. 100K), and about .48ms/row on 1M rows. Without the +index, it runs 100 rows @ .25/row, 1000 @ .26, 10000 @ .27, 100000 @ +.48 and .5 @ 1M rows. + +In no case does the query plan reflect foreign key validation. Failing +any other suggestions for diagnosis in the soon, I'm going to nuke the +PostgreSQL install, scour it from the machine and start from scratch. +Failing that, I'm going to come in some weekend and re-do the machine. + +> Problem is when I recreate the indexes and add the constraints back +> on ORIG I end up with the same long running process. The original +> UPDATE runs for about 30 minutes on a table of 400,000 with the +> WHERE matching about 70% of the rows. The above runs for about 2 +> minutes without adding the constraints or indexes however adding the +> constraints and creating the dropped indexes negates any gain. + +Is this a frequently-run update? + +In my experience, with my seemingly mutant install, dropping indices +and constraints to shave 14/15 off the update time would be worth the +effort. Just script dropping, updating and recreating into one large +transaction. It's a symptom-level fix, but re-creating the fifteen +indices on one of our 5M row tables doesn't take 28 minutes, and your +hardware looks to be rather less IO and CPU bound than ours. I'd also +second Tom's suggestion of moving to 7.4. + +/rls + + +From pgsql-performance-owner@postgresql.org Wed Mar 24 12:50:41 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B6313D1E943 + for ; + Wed, 24 Mar 2004 16:44:46 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 99204-04 + for ; + Wed, 24 Mar 2004 12:44:44 -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 F3C83D1E29F + for ; + Wed, 24 Mar 2004 12:44:43 -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 1B6BUg-000AZ5-0W; Wed, 24 Mar 2004 16:44:43 +0000 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id DDE0F16A71; Wed, 24 Mar 2004 16:44:41 +0000 (GMT) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id D8D0E162C6; Wed, 24 Mar 2004 16:44:39 +0000 (GMT) +From: Richard Huxton +To: Woody Woodring , + pgsql-performance@postgresql.org +Subject: Re: Help with query plan inconsistencies +Date: Wed, 24 Mar 2004 16:44:39 +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: <200403241644.39363.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: 200403/353 +X-Sequence-Number: 6209 + +On Tuesday 23 March 2004 18:49, Woody Woodring wrote: +> Hello, +> +> I am using postgres 7.4.2 as a backend for geocode data for a mapping +> application. My question is why can't I get a consistent use of my indexes +> during a query, I tend to get a lot of seq scan results. + +I'm not sure it wants to be using the indexes all of the time. + +> Nested Loop Left Join (cost=0.00..23433.18 rows=1871 width=34) (actual +> time=0.555..5095.434 rows=3224 loops=1) +> Total runtime: 5100.028 ms + +> Nested Loop Left Join (cost=0.00..76468.90 rows=9223 width=34) (actual +> time=0.559..17387.427 rows=19997 loops=1) +> Total runtime: 17416.501 ms + +> Nested Loop Left Join (cost=0.00..29160.02 rows=2327 width=34) (actual +> time=0.279..510.773 rows=5935 loops=1) +> Total runtime: 516.782 ms + +#1 = 630 rows/sec (with index on cable_billing) +#2 = 1,148 rows/sec (without index) +#3 = 11,501 rows/sec (with index) + +The third case is so much faster, I suspect the data wasn't cached at the +beginning of this run. + +In any case #2 is faster than #1. If the planner is getting things wrong, +you're not showing it here. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Mar 24 14:04:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D5E1D1E934 + for ; + Wed, 24 Mar 2004 18:04:11 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 34594-06 + for ; + Wed, 24 Mar 2004 14:04:08 -0400 (AST) +Received: from mail.unisoftbg.com (mail.unisoftbg.com [194.12.229.207]) + by svr1.postgresql.org (Postfix) with ESMTP id 14BFED1D2AC + for ; + Wed, 24 Mar 2004 14:04:04 -0400 (AST) +Received: (qmail 4710 invoked by uid 507); 24 Mar 2004 19:08:46 -0000 +Received: from unknown (HELO t1.unisoftbg.com) + (pginfo%t1.unisoftbg.com@194.12.229.193) + by 0 with SMTP; 24 Mar 2004 19:08:46 -0000 +Message-ID: <4061BC33.9CC1E712@t1.unisoftbg.com> +Date: Wed, 24 Mar 2004 17:49:55 +0100 +From: pginfo +X-Mailer: Mozilla 4.03 [en] (Win95; I) +MIME-Version: 1.0 +To: "scott.marlowe" +Cc: "pgsql-performance@postgresql.org" +Subject: Re: slow vacuum performance +References: +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/355 +X-Sequence-Number: 6211 + +Hi, + +scott.marlowe wrote: + +> On Wed, 24 Mar 2004, pginfo wrote: +> +> > Hi, +> > +> > I am running pg 7.4.1 on linux box. +> > I have a midle size DB with many updates and after it I try to run +> > vacuum full analyze. +> +> Is there a reason to not use just regular vacuum / analyze (i.e. NOT +> full)? +> + +Yes, in case I make massive updates (only in my case of cource) for example +2 M rows, I do not expect to have 2M new rows in next 180 days.That is the +reaso for running vacuum full. +My idea was to free unneedet space and so to have faster system. +It is possible that I am wrong. + + +> > It takes about 2 h. +> +> Full vacuums, by their nature, tend to be a bit slow. It's better to let +> the database achieve a kind of "steady state" with regards to number of +> dead tuples, and use regular vacuums to reclaim said space rather than a +> full vacuum. +> +> > How can I improve the vacuum full analyze time? +> > +> > My configuration: +> > +> > shared_buffers = 15000 # min 16, at least max_connections*2, +> > 8KB each +> > sort_mem = 10000 # min 64, size in KB +> +> You might want to look at dropping sort_mem. It would appear you've been +> going through the postgresql.conf file and bumping up numbers to see what +> works and what doesn't. While most of the settings aren't too dangerous +> to crank up a little high, sort_mem is quite dangerous to crank up high, +> should you have a lot of people connected who are all sorting. Note that +> sort_mem is a limit PER SORT, not per backend, or per database, or per +> user, or even per table, but per sort. IF a query needs to run three or +> four sorts, it can use 3 or 4x sort_mem. If a hundred users do this at +> once, they can then use 300 or 400x sort_mem. You can see where I'm +> heading. +> +> Note that for individual sorts in batch files, like import processes, you +> can bump up sort_mem with the set command, so you don't have to have a +> large setting in postgresql.conf to use a lot of sort mem when you need +> to, you can just grab it during that one session. +> + +I know. In my case we are using many ID's declared as varchar/name (I know it +is bad idea, butwe are migrating this system from oracle) and pg have very +bad performance with varchar/name indexes. +The only solution I found was to increase the sort mem. +But, I wll try to decrease this one and to see the result. + +> > vacuum_mem = 32000 # min 1024, size in KB +> +> If you've got lots of memory, crank up vacuum_mem to the 200 to 500 meg +> range and see what happens. +> + +I wil try it today. It is good idea and hope it will help. + +> For a good tuning guide, go here: +> +> http://www.varlena.com/varlena/GeneralBits/Tidbits/perf.html + + I know it. It is the best I found and also the site. + +Thanks for the help. +ivan. + + +From pgsql-performance-owner@postgresql.org Wed Mar 24 13:06:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C35EAD1ECBA + for ; + Wed, 24 Mar 2004 17:05: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 06846-09 + for ; + Wed, 24 Mar 2004 13:05:52 -0400 (AST) +Received: from lorax.kcilink.com (lorax.kcilink.com [206.112.95.1]) + by svr1.postgresql.org (Postfix) with ESMTP id BFABED1ECDC + for ; + Wed, 24 Mar 2004 13:05:51 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by lorax.kcilink.com (Postfix) with ESMTP id D5E1B3ECE + for ; + Wed, 24 Mar 2004 12:05:50 -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 21482-02 for ; + Wed, 24 Mar 2004 12:05:50 -0500 (EST) +Received: by lorax.kcilink.com (Postfix, from userid 8) + id 523D43E4C; Wed, 24 Mar 2004 12:05:50 -0500 (EST) +To: pgsql-performance@postgresql.org +Path: not-for-mail +From: Vivek Khera +Newsgroups: ml.postgres.performance +Subject: Re: [ADMIN] Benchmarking postgres on Solaris/Linux +Date: Wed, 24 Mar 2004 12:05:49 -0500 +Organization: Khera Communications, Inc., Rockville, MD +Lines: 19 +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 1080147950 14733 65.205.34.180 (24 Mar 2004 + 17:05:50 GMT) +X-Complaints-To: daemon@kciLink.com +NNTP-Posting-Date: Wed, 24 Mar 2004 17:05:50 +0000 (UTC) +User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Reasonable Discussion, + berkeley-unix) +Cancel-Lock: sha1:+W1LzKISssEaVqW8PlEDeGS+Vmo= +X-Virus-Scanned: by amavisd-new at kcilink.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/354 +X-Sequence-Number: 6210 + +>>>>> "SS" == Stalin Subbiah writes: + +SS> We are looking into Sun V210 (2 x 1 GHz cpu, 2 gig ram, 5.8Os) +SS> vs. Dell 1750 (2 x 2.4 GHz xeon, 2 gig ram, RH3.0). database will +SS> mostly be write intensive and disks will be on raid 10. Wondering +SS> if 64bit 1 GHz to 32bit 2.4 GHz make a big difference here. + +Spend all your money speeding up your disk system. If you're mostly +writing (like my main app) then that's your bottleneck. I use a dell +2650 with external RAID 5 on 14 spindles. I didn't need that much +disk space, but went for maxing out the number of spindles. RAID 5 +was faster than RAID10 or RAID50 with this configuration for me. + + +-- +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +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 Wed Mar 24 14:23:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2A3D5D1ECEC + for ; + Wed, 24 Mar 2004 18:23:03 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 41033-06 + for ; + Wed, 24 Mar 2004 14:23:01 -0400 (AST) +Received: from mail.unisoftbg.com (mail.unisoftbg.com [194.12.229.207]) + by svr1.postgresql.org (Postfix) with ESMTP id DE428D1ED00 + for ; + Wed, 24 Mar 2004 14:22:57 -0400 (AST) +Received: (qmail 5059 invoked by uid 507); 24 Mar 2004 19:27:43 -0000 +Received: from unknown (HELO t1.unisoftbg.com) + (pginfo%t1.unisoftbg.com@194.12.229.193) + by 0 with SMTP; 24 Mar 2004 19:27:43 -0000 +Message-ID: <4061C0A3.6C0E1C10@t1.unisoftbg.com> +Date: Wed, 24 Mar 2004 18:08:51 +0100 +From: pginfo +X-Mailer: Mozilla 4.03 [en] (Win95; I) +MIME-Version: 1.0 +To: "scott.marlowe" +Cc: "pgsql-performance@postgresql.org" +Subject: Re: slow vacuum performance +References: +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/356 +X-Sequence-Number: 6212 + + + +scott.marlowe wrote: + +> On Wed, 24 Mar 2004, pginfo wrote: +> +> > Hi, +> > +> > scott.marlowe wrote: +> > +> > > On Wed, 24 Mar 2004, pginfo wrote: +> > > +> > > > Hi, +> > > > +> > > > I am running pg 7.4.1 on linux box. +> > > > I have a midle size DB with many updates and after it I try to run +> > > > vacuum full analyze. +> > > +> > > Is there a reason to not use just regular vacuum / analyze (i.e. NOT +> > > full)? +> > > +> > +> > Yes, in case I make massive updates (only in my case of cource) for example +> > 2 M rows, I do not expect to have 2M new rows in next 180 days.That is the +> > reaso for running vacuum full. +> > My idea was to free unneedet space and so to have faster system. +> > It is possible that I am wrong. +> +> It's all about percentages. If you've got an average of 5% dead tuples +> with regular vacuuming, then full vacuums won't gain you much, if +> anything. If you've got 20 dead tuples for each live one, then a full +> vacuum is pretty much a necessity. The generally accepted best +> performance comes with 5 to 50% or so dead tuples. Keep in mind, having a +> few dead tuples is actually a good thing, as your database won't grow then +> srhink the file all the time, but keep it in a steady state size wise. + +thanks for the good analyze,ivan. + + + +From pgsql-performance-owner@postgresql.org Wed Mar 24 14:23:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 32320D1ECE2 + for ; + Wed, 24 Mar 2004 18:18: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 39659-06 + for ; + Wed, 24 Mar 2004 14:18:49 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 3614CD1ECE5 + for ; + Wed, 24 Mar 2004 14:18:48 -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 i2OIHJiP009030; + Wed, 24 Mar 2004 11:17:19 -0700 (MST) +Date: Wed, 24 Mar 2004 11:13:55 -0700 (MST) +From: "scott.marlowe" +To: pginfo +Cc: "pgsql-performance@postgresql.org" +Subject: Re: slow vacuum performance +In-Reply-To: <4061BC33.9CC1E712@t1.unisoftbg.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-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/357 +X-Sequence-Number: 6213 + +On Wed, 24 Mar 2004, pginfo wrote: + +> Hi, +> +> scott.marlowe wrote: +> +> > On Wed, 24 Mar 2004, pginfo wrote: +> > +> > > Hi, +> > > +> > > I am running pg 7.4.1 on linux box. +> > > I have a midle size DB with many updates and after it I try to run +> > > vacuum full analyze. +> > +> > Is there a reason to not use just regular vacuum / analyze (i.e. NOT +> > full)? +> > +> +> Yes, in case I make massive updates (only in my case of cource) for example +> 2 M rows, I do not expect to have 2M new rows in next 180 days.That is the +> reaso for running vacuum full. +> My idea was to free unneedet space and so to have faster system. +> It is possible that I am wrong. + +It's all about percentages. If you've got an average of 5% dead tuples +with regular vacuuming, then full vacuums won't gain you much, if +anything. If you've got 20 dead tuples for each live one, then a full +vacuum is pretty much a necessity. The generally accepted best +performance comes with 5 to 50% or so dead tuples. Keep in mind, having a +few dead tuples is actually a good thing, as your database won't grow then +srhink the file all the time, but keep it in a steady state size wise. + + + + +From pgsql-performance-owner@postgresql.org Fri Mar 26 17:23:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 20520D1B97B; Thu, 25 Mar 2004 06:22: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 64509-05; Thu, 25 Mar 2004 02:22:27 -0400 (AST) +Received: from dbl.q-ag.de (dbl.q-ag.de [213.172.117.3]) + by svr1.postgresql.org (Postfix) with ESMTP + id 463F2D1E943; Thu, 25 Mar 2004 02:22:25 -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 i2P6LZro004886; + Thu, 25 Mar 2004 07:21:36 +0100 +Message-ID: <40627A6F.9010202@colorfullife.com> +Date: Thu, 25 Mar 2004 07:21:35 +0100 +From: Manfred Spraul +User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.4.1) Gecko/20031114 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: markw@osdl.org, josh@agliodbs.com, Q@ping.be, + pgman@candle.pha.pa.us, markir@paradise.net.nz, + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] fsync method checking +References: <200403221734.i2MHYGE01546@mail.osdl.org> + <6391.1079977274@sss.pgh.pa.us> +In-Reply-To: <6391.1079977274@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: 200403/379 +X-Sequence-Number: 6235 + +Tom Lane wrote: + +>markw@osdl.org writes: +> +> +>>I could certainly do some testing if you want to see how DBT-2 does. +>>Just tell me what to do. ;) +>> +>> +> +>Just do some runs that are identical except for the wal_sync_method +>setting. Note that this should not have any impact on SELECT +>performance, only insert/update/delete performance. +> +> +I've made a test run that compares fsync and fdatasync: The performance +was identical: +- with fdatasync: + +http://khack.osdl.org/stp/290607/ + +- with fsync: +http://khack.osdl.org/stp/290483/ + +I don't understand why. Mark - is there a battery backed write cache in +the raid controller, or something similar that might skew the results? +The test generates quite a lot of wal traffic - around 1.5 MB/sec. +Perhaps the writes are so large that the added overhead of syncing the +inode is not noticable? +Is the pg_xlog directory on a seperate drive? + +Btw, it's possible to request such tests through the web-interface, see +http://www.osdl.org/lab_activities/kernel_testing/stp/script_param.html + +-- + Manfred + + +From pgsql-performance-owner@postgresql.org Thu Mar 25 13:46:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id CC464D1ECCB; Thu, 25 Mar 2004 17:17: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 90261-03; Thu, 25 Mar 2004 13:17:31 -0400 (AST) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP + id 6B53AD1EC79; Thu, 25 Mar 2004 13:17:25 -0400 (AST) +Received: from osdl.org (markw@ibm-b.pdx.osdl.net [172.20.1.51]) + by mail.osdl.org (8.11.6/8.11.6) with ESMTP id i2PHGh222327; + Thu, 25 Mar 2004 09:16:44 -0800 +Message-Id: <200403251716.i2PHGh222327@mail.osdl.org> +Date: Thu, 25 Mar 2004 09:16:40 -0800 (PST) +From: markw@osdl.org +Subject: Re: [HACKERS] fsync method checking +To: manfred@colorfullife.com +Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com, Q@ping.be, + pgman@candle.pha.pa.us, markir@paradise.net.nz, + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +In-Reply-To: <40627A6F.9010202@colorfullife.com> +MIME-Version: 1.0 +Content-Type: TEXT/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/358 +X-Sequence-Number: 6214 + +On 25 Mar, Manfred Spraul wrote: +> Tom Lane wrote: +> +>>markw@osdl.org writes: +>> +>> +>>>I could certainly do some testing if you want to see how DBT-2 does. +>>>Just tell me what to do. ;) +>>> +>>> +>> +>>Just do some runs that are identical except for the wal_sync_method +>>setting. Note that this should not have any impact on SELECT +>>performance, only insert/update/delete performance. +>> +>> +> I've made a test run that compares fsync and fdatasync: The performance +> was identical: +> - with fdatasync: +> +> http://khack.osdl.org/stp/290607/ +> +> - with fsync: +> http://khack.osdl.org/stp/290483/ +> +> I don't understand why. Mark - is there a battery backed write cache in +> the raid controller, or something similar that might skew the results? +> The test generates quite a lot of wal traffic - around 1.5 MB/sec. +> Perhaps the writes are so large that the added overhead of syncing the +> inode is not noticable? +> Is the pg_xlog directory on a seperate drive? +> +> Btw, it's possible to request such tests through the web-interface, see +> http://www.osdl.org/lab_activities/kernel_testing/stp/script_param.html + +We have 2 Adaptec 2200s controllers, without the battery backed add-on, +connected to four 10-disk arrays in those systems. I can't think of +anything off hand that would skew the results. + +The pg_xlog directory is not on a separate drive. I haven't found the +best way to lay out of the drives on those systems yet, so I just have +everything on a 28 drive lvm2 volume. + +Mark + +From pgsql-performance-owner@postgresql.org Thu Mar 25 13:58:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C4722D1ECB7 + for ; + Thu, 25 Mar 2004 17:58: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 06990-01 + for ; + Thu, 25 Mar 2004 13:58:35 -0400 (AST) +Received: from leo.supplyfx.com (h-67-100-199-42.lsanca54.covad.net + [67.100.199.42]) + by svr1.postgresql.org (Postfix) with ESMTP id 60C72D1ED09 + for ; + Thu, 25 Mar 2004 13:58:29 -0400 (AST) +Received: from [10.0.100.21] (unknown [10.0.100.21]) + by leo.supplyfx.com (Postfix) with ESMTP id 30161CD4BF + for ; + Thu, 25 Mar 2004 09:58:34 -0800 (PST) +Mime-Version: 1.0 (Apple Message framework v612) +To: pgsql-performance@postgresql.org +Message-Id: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> +Content-Type: multipart/alternative; boundary=Apple-Mail-2-998582122 +From: Qing Zhao +Subject: column size too large, is this a bug? +Date: Thu, 25 Mar 2004 09:58:33 -0800 +X-Mailer: Apple Mail (2.612) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/359 +X-Sequence-Number: 6215 + +--Apple-Mail-2-998582122 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + format=flowed + + I have a query which get's data from a single table. +When I try to get data from for an RFQ which has around 5000 rows, it +is breaking off at 18th row. +If i reduce some columns , then it returns all the rows and not so slow. + I have tried with different sets of column and there is no pattern +based on columns. + + But one thing is sure one size of the rows grows more than some bytes, +the records do not get returned. Now the following query returns me all +5001 rows to me pretty fast + + + select + _level_ as l, + nextval('seq_pk_bom_detail') as bom_detail, + prior nextval('seq_pk_bom_detail') as parent_subassembly, + parent_part_number, + customer_part_number, + /* mfr_name, + mfr_part, + description,*/ + commodity, + needs_date, + target_price, + comments, + case qty_per + when null then 0.00001 + when 0 then 0.00001 + else qty_per + end, + qty_multiplier1, + qty_multiplier2, + qty_multiplier3, + qty_multiplier4, + qty_multiplier5 + from bom_detail_work_clean + where (0=0) + and bom_header=20252 + and file_number = 1 + start with customer_part_number = 'Top Assembly 1' + connect by parent_part_number = prior customer_part_number; + + +But if I uncomment the description then it returns me only 18 rows. + + select + _level_ as l, + nextval('seq_pk_bom_detail') as bom_detail, + prior nextval('seq_pk_bom_detail') as parent_subassembly, + parent_part_number, + customer_part_number, + /* mfr_name, + mfr_part,*/ + description, + commodity, + needs_date, + target_price, + comments, + case qty_per + when null then 0.00001 + when 0 then 0.00001 + else qty_per + end, + qty_multiplier1, + qty_multiplier2, + qty_multiplier3, + qty_multiplier4, + qty_multiplier5 + from bom_detail_work_clean + where (0=0) + and bom_header=20252 + and file_number = 1 + start with customer_part_number = 'Top Assembly 1' + connect by parent_part_number = prior customer_part_number; + +Now these 18 rows are level 2 records in heirarchical query. I have a +feeling the server has some memory paging mechanism +and if it can not handle beyond certain byets, it just returns what it +has. + During your investigation of optimization of postgreSQL did you come +across any setting that might help us ? + +Thanks! + +Qing + +PS: I just reload the file while reducing the content in the +description column. +The file got uploaded. So looks like the problem is size of the record +being inserted. + + +--Apple-Mail-2-998582122 +Content-Transfer-Encoding: 7bit +Content-Type: text/enriched; + charset=US-ASCII + + I have a query which get's data from a single table. + +When I try to get data from for an RFQ which has around 5000 rows, it +is breaking off at 18th row. + +If i reduce some columns , then it returns all the rows and not so +slow. + + I have tried with different sets of column and there is no pattern +based on columns. + + + But one thing is sure one size of the rows grows more than some +bytes, the records do not get returned. Now the following query +returns me all 5001 rows to me pretty fast + + + +2676,2346,FFFD select + + _level_ as l, + + nextval('seq_pk_bom_detail') as bom_detail, + + prior nextval('seq_pk_bom_detail') as parent_subassembly, + + parent_part_number, + + customer_part_number, + + /* mfr_name, + + mfr_part, + + description,*/ + + commodity, + + needs_date, + + target_price, + + comments, + + case qty_per + + when null then 0.00001 + + when 0 then 0.00001 + + else qty_per + + end, + + qty_multiplier1, + + qty_multiplier2, + + qty_multiplier3, + + qty_multiplier4, + + qty_multiplier5 + + from bom_detail_work_clean + + where (0=0) + + and bom_header=20252 + + and file_number = 1 + + start with customer_part_number = 'Top Assembly 1' + + connect by parent_part_number = prior customer_part_number; + + + + +But if I uncomment the description then it returns me only 18 rows. + + + FFFD,2231,314B select + + _level_ as l, + + nextval('seq_pk_bom_detail') as bom_detail, + + prior nextval('seq_pk_bom_detail') as parent_subassembly, + + parent_part_number, + + customer_part_number, + + /* mfr_name, + + mfr_part,*/ + + description, + + commodity, + + needs_date, + + target_price, + + comments, + + case qty_per + + when null then 0.00001 + + when 0 then 0.00001 + + else qty_per + + end, + + qty_multiplier1, + + qty_multiplier2, + + qty_multiplier3, + + qty_multiplier4, + + qty_multiplier5 + + from bom_detail_work_clean + + where (0=0) + + and bom_header=20252 + + and file_number = 1 + + start with customer_part_number = 'Top Assembly 1' + + connect by parent_part_number = prior customer_part_number; + + +0126,0126,0126Now these 18 rows are +level 2 records in heirarchical query. I have a feeling the server +has some memory paging mechanism + +and if it can not handle beyond certain byets, it just returns what it +has. + + During your investigation of optimization of postgreSQL did you come +across any setting that might help us ? + + +Thanks! + + +Qing + + +PS: I just reload the file while reducing the content in the +description column. + +The file got uploaded. So looks like the problem is size of the record +being inserted. + +0126,0126,0126 + + +--Apple-Mail-2-998582122-- + + +From pgsql-performance-owner@postgresql.org Thu Mar 25 14:20:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 70694D1ECDC + for ; + Thu, 25 Mar 2004 18:20: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 14630-02 + for ; + Thu, 25 Mar 2004 14:20:32 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 651FFD1ECC6 + for ; + Thu, 25 Mar 2004 14:20:27 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2PIKXoR013125; + Thu, 25 Mar 2004 13:20:33 -0500 (EST) +To: Qing Zhao +Cc: pgsql-performance@postgresql.org +Subject: Re: column size too large, is this a bug? +In-reply-to: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> +Comments: In-reply-to Qing Zhao + message dated "Thu, 25 Mar 2004 09:58:33 -0800" +Date: Thu, 25 Mar 2004 13:20:32 -0500 +Message-ID: <13124.1080238832@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/360 +X-Sequence-Number: 6216 + +Qing Zhao writes: +> I have a query which get's data from a single table. +> When I try to get data from for an RFQ which has around 5000 rows, it +> is breaking off at 18th row. +> If i reduce some columns , then it returns all the rows and not so slow. + +What client-side software are you using? This is surely a limitation on +the client side, because there is no such problem in the server. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 25 14:56:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 725D0D1ECFC; Thu, 25 Mar 2004 18:53: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 25903-02; Thu, 25 Mar 2004 14:53: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 CECB4D1ECF6; Thu, 25 Mar 2004 14:53:15 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i2PIquv29582; + Thu, 25 Mar 2004 13:52:56 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403251852.i2PIquv29582@candle.pha.pa.us> +Subject: Re: [HACKERS] fsync method checking +In-Reply-To: <200403251716.i2PHGh222327@mail.osdl.org> +To: markw@osdl.org +Date: Thu, 25 Mar 2004 13:52:56 -0500 (EST) +Cc: manfred@colorfullife.com, tgl@sss.pgh.pa.us, josh@agliodbs.com, + Q@ping.be, markir@paradise.net.nz, pgsql-performance@postgresql.org, + pgsql-hackers@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: 200403/361 +X-Sequence-Number: 6217 + +markw@osdl.org wrote: +> > I've made a test run that compares fsync and fdatasync: The performance +> > was identical: +> > - with fdatasync: +> > +> > http://khack.osdl.org/stp/290607/ +> > +> > - with fsync: +> > http://khack.osdl.org/stp/290483/ +> > +> > I don't understand why. Mark - is there a battery backed write cache in +> > the raid controller, or something similar that might skew the results? +> > The test generates quite a lot of wal traffic - around 1.5 MB/sec. +> > Perhaps the writes are so large that the added overhead of syncing the +> > inode is not noticable? +> > Is the pg_xlog directory on a seperate drive? +> > +> > Btw, it's possible to request such tests through the web-interface, see +> > http://www.osdl.org/lab_activities/kernel_testing/stp/script_param.html +> +> We have 2 Adaptec 2200s controllers, without the battery backed add-on, +> connected to four 10-disk arrays in those systems. I can't think of +> anything off hand that would skew the results. +> +> The pg_xlog directory is not on a separate drive. I haven't found the +> best way to lay out of the drives on those systems yet, so I just have +> everything on a 28 drive lvm2 volume. + +We don't actually extend the WAL file during writes (preallocated), and +the access/modification timestamp is only in seconds, so I wonder of the +OS only updates the inode once a second. What else would change in the +inode more frequently than once a second? + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Thu Mar 25 15:12:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id D3A52D1D29F; Thu, 25 Mar 2004 19:11: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 25335-09; Thu, 25 Mar 2004 15:11:30 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP + id 7B2D5D1B88F; Thu, 25 Mar 2004 15:11:24 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4693080; Thu, 25 Mar 2004 11:12:47 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Bruce Momjian , markw@osdl.org +Subject: Re: [HACKERS] fsync method checking +Date: Thu, 25 Mar 2004 11:10:55 -0800 +User-Agent: KMail/1.5.4 +Cc: manfred@colorfullife.com, tgl@sss.pgh.pa.us, Q@ping.be, + markir@paradise.net.nz, pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +References: <200403251852.i2PIquv29582@candle.pha.pa.us> +In-Reply-To: <200403251852.i2PIquv29582@candle.pha.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403251110.55889.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/362 +X-Sequence-Number: 6218 + +Bruce, + +> We don't actually extend the WAL file during writes (preallocated), and +> the access/modification timestamp is only in seconds, so I wonder of the +> OS only updates the inode once a second. What else would change in the +> inode more frequently than once a second? + +What about really big writes, when WAL files are getting added/recycled? + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Thu Mar 25 19:27:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 1C776D1B4ED; Thu, 25 Mar 2004 21:47: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 90557-09; Thu, 25 Mar 2004 17:47:29 -0400 (AST) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP + id C65C6D1EC85; Thu, 25 Mar 2004 17:47:22 -0400 (AST) +Received: from osdl.org (markw@ibm-b.pdx.osdl.net [172.20.1.51]) + by mail.osdl.org (8.11.6/8.11.6) with ESMTP id i2PLkx209812; + Thu, 25 Mar 2004 13:47:00 -0800 +Message-Id: <200403252147.i2PLkx209812@mail.osdl.org> +Date: Thu, 25 Mar 2004 13:46:56 -0800 (PST) +From: markw@osdl.org +Subject: Re: [HACKERS] fsync method checking +To: tgl@sss.pgh.pa.us +Cc: josh@agliodbs.com, Q@ping.be, pgman@candle.pha.pa.us, + markir@paradise.net.nz, pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +In-Reply-To: <6391.1079977274@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: TEXT/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/366 +X-Sequence-Number: 6222 + +On 22 Mar, Tom Lane wrote: +> markw@osdl.org writes: +>> I could certainly do some testing if you want to see how DBT-2 does. +>> Just tell me what to do. ;) +> +> Just do some runs that are identical except for the wal_sync_method +> setting. Note that this should not have any impact on SELECT +> performance, only insert/update/delete performance. + +Ok, here are the results I have from my 4-way xeon system, a 14 disk +volume for the log and a 52 disk volume for everything else: + http://developer.osdl.org/markw/pgsql/wal_sync_method.html + +7.5devel-200403222 + +wal_sync_method metric +default (fdatasync) 1935.28 +fsync 1613.92 + +# ./test_fsync -f /opt/pgdb/dbt2/pg_xlog/test.out +Simple write timing: + write 0.018787 + +Compare fsync times on write() and non-write() descriptor: +(If the times are similar, fsync() can sync data written + on a different descriptor.) + write, fsync, close 13.057781 + write, close, fsync 13.311313 + +Compare one o_sync write to two: + one 16k o_sync write 6.515122 + two 8k o_sync writes 12.455124 + +Compare file sync methods with one 8k write: + (o_dsync unavailable) + open o_sync, write 6.270724 + write, fdatasync 13.275225 + write, fsync, 13.359847 + +Compare file sync methods with 2 8k writes: + (o_dsync unavailable) + open o_sync, write 12.479563 + write, fdatasync 13.651709 + write, fsync, 14.000240 + +From pgsql-performance-owner@postgresql.org Thu Mar 25 18:41:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 905CFD1ED3E + for ; + Thu, 25 Mar 2004 22:20: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 09549-04 + for ; + Thu, 25 Mar 2004 18:20:58 -0400 (AST) +Received: from leo.supplyfx.com (h-67-100-199-42.lsanca54.covad.net + [67.100.199.42]) + by svr1.postgresql.org (Postfix) with ESMTP id 8445BD1ED47 + for ; + Thu, 25 Mar 2004 18:20:51 -0400 (AST) +Received: from [10.0.100.21] (unknown [10.0.100.21]) + by leo.supplyfx.com (Postfix) with ESMTP + id 1A3A6CDF05; Thu, 25 Mar 2004 14:20:58 -0800 (PST) +In-Reply-To: <13124.1080238832@sss.pgh.pa.us> +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <13124.1080238832@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v612) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Qing Zhao +Subject: Re: column size too large, is this a bug? +Date: Thu, 25 Mar 2004 14:20:56 -0800 +To: Tom Lane +X-Mailer: Apple Mail (2.612) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/364 +X-Sequence-Number: 6220 + +Tom, + +Thanks for your help! +It's not through one client. I am using JDBC. But the same things +happen when I use client like psql. + +Qing +On Mar 25, 2004, at 10:20 AM, Tom Lane wrote: + +> Qing Zhao writes: +>> I have a query which get's data from a single table. +>> When I try to get data from for an RFQ which has around 5000 rows, it +>> is breaking off at 18th row. +>> If i reduce some columns , then it returns all the rows and not so +>> slow. +> +> What client-side software are you using? This is surely a limitation +> on +> the client side, because there is no such problem in the server. +> +> regards, tom lane +> + + +From pgsql-performance-owner@postgresql.org Thu Mar 25 18:31:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CA9F6D1ECCE + for ; + Thu, 25 Mar 2004 22:28: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 11991-10 + for ; + Thu, 25 Mar 2004 18:28:21 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id D6199D1EC52 + for ; + Thu, 25 Mar 2004 18:28:14 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2PMSKqA015061; + Thu, 25 Mar 2004 17:28:20 -0500 (EST) +To: Qing Zhao +Cc: pgsql-performance@postgresql.org +Subject: Re: column size too large, is this a bug? +In-reply-to: +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <13124.1080238832@sss.pgh.pa.us> + +Comments: In-reply-to Qing Zhao + message dated "Thu, 25 Mar 2004 14:20:56 -0800" +Date: Thu, 25 Mar 2004 17:28:19 -0500 +Message-ID: <15060.1080253699@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/363 +X-Sequence-Number: 6219 + +Qing Zhao writes: +> It's not through one client. I am using JDBC. But the same things +> happen when I use client like psql. + +That's really hard to believe. Can you provide a reproducible test +case? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 25 19:06:22 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C8EABD1E934 + for ; + Thu, 25 Mar 2004 22: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 20513-06 + for ; + Thu, 25 Mar 2004 18:57:51 -0400 (AST) +Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) + by svr1.postgresql.org (Postfix) with ESMTP id 791CCD1DC6B + for ; + Thu, 25 Mar 2004 18:57:44 -0400 (AST) +Received: by megazone.bigpanda.com (Postfix, from userid 1001) + id 6CAB735099; Thu, 25 Mar 2004 14:57:28 -0800 (PST) +Received: from localhost (localhost [127.0.0.1]) + by megazone.bigpanda.com (Postfix) with ESMTP + id 688FB35091; Thu, 25 Mar 2004 14:57:28 -0800 (PST) +Date: Thu, 25 Mar 2004 14:57:28 -0800 (PST) +From: Stephan Szabo +To: Qing Zhao +Cc: pgsql-performance@postgresql.org +Subject: Re: column size too large, is this a bug? +In-Reply-To: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> +Message-ID: <20040325145525.V50544@megazone.bigpanda.com> +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/365 +X-Sequence-Number: 6221 + +On Thu, 25 Mar 2004, Qing Zhao wrote: + +> select +> _level_ as l, +> nextval('seq_pk_bom_detail') as bom_detail, +> prior nextval('seq_pk_bom_detail') as parent_subassembly, +> parent_part_number, +> customer_part_number, +> /* mfr_name, +> mfr_part, +> description,*/ +> commodity, +> needs_date, +> target_price, +> comments, +> case qty_per +> when null then 0.00001 +> when 0 then 0.00001 +> else qty_per +> end, +> qty_multiplier1, +> qty_multiplier2, +> qty_multiplier3, +> qty_multiplier4, +> qty_multiplier5 +> from bom_detail_work_clean +> where (0=0) +> and bom_header=20252 +> and file_number = 1 +> start with customer_part_number = 'Top Assembly 1' +> connect by parent_part_number = prior customer_part_number; + +What version are you running, and did you apply any patches (for example +one to support the start with/connect by syntax used above?) + + +From pgsql-performance-owner@postgresql.org Thu Mar 25 19:39:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 91B68D1DC6B + for ; + Thu, 25 Mar 2004 23:11: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 28972-04 + for ; + Thu, 25 Mar 2004 19:11:24 -0400 (AST) +Received: from leo.supplyfx.com (h-67-100-199-42.lsanca54.covad.net + [67.100.199.42]) + by svr1.postgresql.org (Postfix) with ESMTP id AB670D1D767 + for ; + Thu, 25 Mar 2004 19:11:17 -0400 (AST) +Received: from [10.0.100.21] (unknown [10.0.100.21]) + by leo.supplyfx.com (Postfix) with ESMTP + id 8CE9ACE054; Thu, 25 Mar 2004 15:11:20 -0800 (PST) +In-Reply-To: <20040325145525.V50544@megazone.bigpanda.com> +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <20040325145525.V50544@megazone.bigpanda.com> +Mime-Version: 1.0 (Apple Message framework v612) +Content-Type: multipart/alternative; boundary=Apple-Mail-5-1017331932 +Message-Id: +Cc: Partha Roy , + pgsql-performance@postgresql.org +From: Qing Zhao +Subject: Re: column size too large, is this a bug? +Date: Thu, 25 Mar 2004 15:11:03 -0800 +To: Stephan Szabo +X-Mailer: Apple Mail (2.612) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/367 +X-Sequence-Number: 6223 + +--Apple-Mail-5-1017331932 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + format=flowed + +It is 7.3.4 on MAC OS X (darwin). The patch we applied is +hier-Pg7.3-0.5, which allows +to perform hierarchical queries on PgSQL using Oracle's syntax. + +Thanks! + +Qing + +On Mar 25, 2004, at 2:57 PM, Stephan Szabo wrote: + +> On Thu, 25 Mar 2004, Qing Zhao wrote: +> +>> select +>> _level_ as l, +>> nextval('seq_pk_bom_detail') as bom_detail, +>> prior nextval('seq_pk_bom_detail') as parent_subassembly, +>> parent_part_number, +>> customer_part_number, +>> /* mfr_name, +>> mfr_part, +>> description,*/ +>> commodity, +>> needs_date, +>> target_price, +>> comments, +>> case qty_per +>> when null then 0.00001 +>> when 0 then 0.00001 +>> else qty_per +>> end, +>> qty_multiplier1, +>> qty_multiplier2, +>> qty_multiplier3, +>> qty_multiplier4, +>> qty_multiplier5 +>> from bom_detail_work_clean +>> where (0=0) +>> and bom_header=20252 +>> and file_number = 1 +>> start with customer_part_number = 'Top Assembly 1' +>> connect by parent_part_number = prior customer_part_number; +> +> What version are you running, and did you apply any patches (for +> example +> one to support the start with/connect by syntax used above?) +> +> + +--Apple-Mail-5-1017331932 +Content-Transfer-Encoding: 7bit +Content-Type: text/enriched; + charset=US-ASCII + +It is 7.3.4 on MAC OS X (darwin). The patch we applied is +hier-Pg7.3-0.5, whichArial +allows + +to perform hierarchical queries on PgSQL using Oracle's syntax. + + +Thanks! + + +Qing + + + +On Mar 25, 2004, at 2:57 PM, Stephan Szabo wrote: + + +On Thu, 25 Mar 2004, Qing Zhao wrote: + + + select + + _level_ as l, + + nextval('seq_pk_bom_detail') as bom_detail, + + prior nextval('seq_pk_bom_detail') as parent_subassembly, + + parent_part_number, + + customer_part_number, + + /* mfr_name, + + mfr_part, + + description,*/ + + commodity, + + needs_date, + + target_price, + + comments, + + case qty_per + + when null then 0.00001 + + when 0 then 0.00001 + + else qty_per + + end, + + qty_multiplier1, + + qty_multiplier2, + + qty_multiplier3, + + qty_multiplier4, + + qty_multiplier5 + + from bom_detail_work_clean + + where (0=0) + + and bom_header=20252 + + and file_number = 1 + + start with customer_part_number = 'Top Assembly 1' + + connect by parent_part_number = prior customer_part_number; + + + +What version are you running, and did you apply any patches (for +example + +one to support the start with/connect by syntax used above?) + + + + +--Apple-Mail-5-1017331932-- + + +From pgsql-performance-owner@postgresql.org Thu Mar 25 20:39:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id CDE1FD1ECC2 + for ; + Fri, 26 Mar 2004 00:39: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 55208-02 + for ; + Thu, 25 Mar 2004 20:39:26 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id B2345D1ECBC + for ; + Thu, 25 Mar 2004 20:39:18 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2Q0dPZJ016477; + Thu, 25 Mar 2004 19:39:26 -0500 (EST) +To: Stephan Szabo +Cc: Qing Zhao , pgsql-performance@postgresql.org +Subject: Re: column size too large, is this a bug? +In-reply-to: <20040325145525.V50544@megazone.bigpanda.com> +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <20040325145525.V50544@megazone.bigpanda.com> +Comments: In-reply-to Stephan Szabo + message dated "Thu, 25 Mar 2004 14:57:28 -0800" +Date: Thu, 25 Mar 2004 19:39:25 -0500 +Message-ID: <16476.1080261565@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/368 +X-Sequence-Number: 6224 + +Stephan Szabo writes: +> On Thu, 25 Mar 2004, Qing Zhao wrote: +>> start with customer_part_number = 'Top Assembly 1' +>> connect by parent_part_number = prior customer_part_number; + +> What version are you running, and did you apply any patches (for example +> one to support the start with/connect by syntax used above?) + +Oh, good eye ... it's that infamous CONNECT BY patch again, without doubt. + +I think we should add "Have you applied any patches to your copy of +Postgres?" to the standard bug report form ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 25 21:22:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C54FD1ECF9 + for ; + Fri, 26 Mar 2004 01:22: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 65184-06 + for ; + Thu, 25 Mar 2004 21:22:36 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id C579ED1DB5C + for ; + Thu, 25 Mar 2004 21:22:28 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4695425; Thu, 25 Mar 2004 17:23:55 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Tom Lane , Stephan Szabo +Subject: Re: column size too large, is this a bug? +Date: Thu, 25 Mar 2004 17:21:58 -0800 +User-Agent: KMail/1.5.4 +Cc: Qing Zhao , pgsql-performance@postgresql.org +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <20040325145525.V50544@megazone.bigpanda.com> + <16476.1080261565@sss.pgh.pa.us> +In-Reply-To: <16476.1080261565@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403251721.58645.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/369 +X-Sequence-Number: 6225 + +Tom, + +> Oh, good eye ... it's that infamous CONNECT BY patch again, without doubt. + +Hey, who does this patch? What's wrong wiith it? + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Thu Mar 25 22:04:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 1428BD1E1ED + for ; + Fri, 26 Mar 2004 02:04: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 80777-10 + for ; + Thu, 25 Mar 2004 22:04:30 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 22D06D1E0F9 + for ; + Thu, 25 Mar 2004 22:04:22 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2Q24RmK017549; + Thu, 25 Mar 2004 21:04:27 -0500 (EST) +To: josh@agliodbs.com +Cc: Stephan Szabo , + Qing Zhao , pgsql-performance@postgresql.org +Subject: Re: column size too large, is this a bug? +In-reply-to: <200403251721.58645.josh@agliodbs.com> +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <20040325145525.V50544@megazone.bigpanda.com> + <16476.1080261565@sss.pgh.pa.us> + <200403251721.58645.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Thu, 25 Mar 2004 17:21:58 -0800" +Date: Thu, 25 Mar 2004 21:04:27 -0500 +Message-ID: <17548.1080266667@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/370 +X-Sequence-Number: 6226 + +Josh Berkus writes: +>> Oh, good eye ... it's that infamous CONNECT BY patch again, without doubt. + +> Hey, who does this patch? What's wrong wiith it? + +I'm just venting my annoyance at people expecting us to support +hacked-up versions, especially without telling us they're hacked-up. +This is the third or fourth trouble report I can recall that was +eventually traced to that patch (after considerable effort). + +Anyway, my guess for the immediate problem is incorrect installation of +the patch, viz not doing a complete "make clean" and rebuild after +patching. The patch changes the Query struct which is referenced in +many more files than are actually modified by the patch, and so if you +didn't build with --enable-depend then a simple "make" will leave you +with a patchwork of files that have different ideas about the field +offsets in Query. I'm a bit surprised it doesn't just dump core... + +(That's not directly the fault of the patch, though, except to the +extent that it can be blamed for coming without adequate installation +instructions. What is directly the fault of the patch is that it +doesn't force an initdb by changing catversion. The prior trouble +reports had to do with views not working because their stored rules were +incompatible with the patched backend. We should not have had to deal +with that, and neither should those users.) + +Theory B, of course, is that this is an actual bug in the patch and not +just incorrect installation. I'm not interested enough to investigate +though. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 25 22:41:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B7AED1EC5A + for ; + Fri, 26 Mar 2004 02:41: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 93427-05 + for ; + Thu, 25 Mar 2004 22:41: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 5BF1BD1D767 + for ; + Thu, 25 Mar 2004 22:41:21 -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 + i2Q2eiWL023505; Fri, 26 Mar 2004 10:40:44 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <40639CDE.6070506@familyhealth.com.au> +Date: Fri, 26 Mar 2004 11:00:46 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: josh@agliodbs.com, Stephan Szabo , + Qing Zhao , pgsql-performance@postgresql.org +Subject: Re: column size too large, is this a bug? +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <20040325145525.V50544@megazone.bigpanda.com> + <16476.1080261565@sss.pgh.pa.us> + <200403251721.58645.josh@agliodbs.com> + <17548.1080266667@sss.pgh.pa.us> +In-Reply-To: <17548.1080266667@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: 200403/371 +X-Sequence-Number: 6227 + +> Theory B, of course, is that this is an actual bug in the patch and not +> just incorrect installation. I'm not interested enough to investigate +> though. + +Is there still someone around who's working on getting a similar patch +into 7.5? Seems there huge user demand for such a thing... + +(And no, I'm not volunteering, it's well beyond my abilities...) + +Chris + + +From pgsql-performance-owner@postgresql.org Thu Mar 25 23:11:43 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id C4234D1E0F9 + for ; + Fri, 26 Mar 2004 03:11: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 05822-01 + for ; + Thu, 25 Mar 2004 23:11:48 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 6BCCBD1BB4C + for ; + Thu, 25 Mar 2004 23:11:39 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2Q3BaOv018150; + Thu, 25 Mar 2004 22:11:36 -0500 (EST) +To: Christopher Kings-Lynne +Cc: josh@agliodbs.com, Stephan Szabo , + Qing Zhao , pgsql-performance@postgresql.org +Subject: Re: column size too large, is this a bug? +In-reply-to: <40639CDE.6070506@familyhealth.com.au> +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <20040325145525.V50544@megazone.bigpanda.com> + <16476.1080261565@sss.pgh.pa.us> + <200403251721.58645.josh@agliodbs.com> + <17548.1080266667@sss.pgh.pa.us> + <40639CDE.6070506@familyhealth.com.au> +Comments: In-reply-to Christopher Kings-Lynne + message dated "Fri, 26 Mar 2004 11:00:46 +0800" +Date: Thu, 25 Mar 2004 22:11:36 -0500 +Message-ID: <18149.1080270696@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/372 +X-Sequence-Number: 6228 + +Christopher Kings-Lynne writes: +> Is there still someone around who's working on getting a similar patch +> into 7.5? Seems there huge user demand for such a thing... + +Andrew Overholt did some preliminary work toward implementing the +SQL99-spec WITH functionality (which subsumes what CONNECT BY does, +and a few other things too). But he's left Red Hat and gone back +to school. One of the many things on my todo list is to pick up that +patch and get it finished. + +IIRC Andrew had finished the parser work and we had a paper design for +the executor support. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu Mar 25 23:18:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id BABD6D1ED4E + for ; + Fri, 26 Mar 2004 03:18: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 04039-06 + for ; + Thu, 25 Mar 2004 23:18:51 -0400 (AST) +Received: from houston.familyhealth.com.au (fhnet.arach.net.au + [203.22.197.21]) + by svr1.postgresql.org (Postfix) with ESMTP id 7DBDDD1ED13 + for ; + Thu, 25 Mar 2004 23:18:42 -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 + i2Q3IfWL027022; Fri, 26 Mar 2004 11:18:41 +0800 (WST) + (envelope-from chriskl@familyhealth.com.au) +Message-ID: <4063A5C7.1080705@familyhealth.com.au> +Date: Fri, 26 Mar 2004 11:38:47 +0800 +From: Christopher Kings-Lynne +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +Cc: josh@agliodbs.com, Stephan Szabo , + Qing Zhao , pgsql-performance@postgresql.org +Subject: Re: column size too large, is this a bug? +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <20040325145525.V50544@megazone.bigpanda.com> + <16476.1080261565@sss.pgh.pa.us> + <200403251721.58645.josh@agliodbs.com> + <17548.1080266667@sss.pgh.pa.us> + <40639CDE.6070506@familyhealth.com.au> + <18149.1080270696@sss.pgh.pa.us> +In-Reply-To: <18149.1080270696@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: 200403/373 +X-Sequence-Number: 6229 + +> Andrew Overholt did some preliminary work toward implementing the +> SQL99-spec WITH functionality (which subsumes what CONNECT BY does, +> and a few other things too). But he's left Red Hat and gone back +> to school. One of the many things on my todo list is to pick up that +> patch and get it finished. + +Out of interest, what is your 7.5 todo list? + +Chris + + +From pgsql-performance-owner@postgresql.org Fri Mar 26 17:41:05 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0C20FD1ED12 + for ; + Fri, 26 Mar 2004 05:54: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 40722-09 + for ; + Fri, 26 Mar 2004 01:53:44 -0400 (AST) +Received: from dc2-web14.assortedinternet.com (unknown [66.36.233.99]) + by svr1.postgresql.org (Postfix) with ESMTP id 53D5DD1EC53 + for ; + Fri, 26 Mar 2004 01:53:26 -0400 (AST) +Received: from adsl-67-125-157-241.dsl.irvnca.pacbell.net ([67.125.157.241] + helo=ARA) by dc2-web14.assortedinternet.com with asmtp (Exim 4.24) + id 1B6kHL-00057V-Lv + for pgsql-performance@postgresql.org; Fri, 26 Mar 2004 00:53:15 -0500 +Message-ID: <001401c412f6$88281700$6401a8c0@ARA> +From: "Ara Anjargolian" +To: +Subject: odd planner choice +Date: Thu, 25 Mar 2004 21:52:31 -0800 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1158 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - dc2-web14.assortedinternet.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] +X-AntiAbuse: Sender Address Domain - jargol.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/385 +X-Sequence-Number: 6241 + +I've run into this odd planner choice which I don't quite understand. + +I have two tables articles, users and +articles.article_id and users.user_id are primary keys. + +Insides articles there are two optional fields author_id1, author_id2 +which all reference users.user_id. + +And now the plans: +(by the way this is pg 7.4 and I set enable_seqscan to off). + +jargol=# explain select user_id, first_names, last_name from articles, users +where article_id = 5027 and (articles.author_id1 = users.user_id); + QUERY PLAN +---------------------------------------------------------------------------- +------ + Nested Loop (cost=0.00..4.04 rows=1 width=26) + -> Index Scan using articles_pk on articles (cost=0.00..2.01 rows=1 +width=4) + Index Cond: (article_id = 5027) + -> Index Scan using users_pk on users (cost=0.00..2.01 rows=1 width=26) + Index Cond: ("outer".author_id1 = users.user_id) +(5 rows) + +jargol=# explain select user_id, first_names, last_name from articles, users +where article_id = 5027 and (articles.author_id1 = users.user_id or +articles.author_id2 = users.user_id); + QUERY PLAN +---------------------------------------------------------------------------- +----------------------- + Nested Loop (cost=100000000.00..100000003.11 rows=2 width=26) + Join Filter: (("outer".author_id1 = "inner".user_id) OR +("outer".author_id2 = "inner".user_id)) + -> Index Scan using articles_pk on articles (cost=0.00..2.01 rows=1 +width=8) + Index Cond: (article_id = 5027) + -> Seq Scan on users (cost=100000000.00..100000001.04 rows=4 width=26) +(5 rows) + +Why does it think it MUST do a seq-scan in the second case? users.user_id is +a primary key, +so shouldn't it behave exactly as in the first case? + +Any enlightenment on this problem will be much appreciated. + +thanks, +Ara Anjargolian + + +From pgsql-performance-owner@postgresql.org Fri Mar 26 17:34:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 4F627D1E0D8; Fri, 26 Mar 2004 06:27: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 46232-10; Fri, 26 Mar 2004 02:26:40 -0400 (AST) +Received: from dbl.q-ag.de (dbl.q-ag.de [213.172.117.3]) + by svr1.postgresql.org (Postfix) with ESMTP + id 77082D1D2AC; Fri, 26 Mar 2004 02:26:37 -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 i2Q6Prro018891; + Fri, 26 Mar 2004 07:25:54 +0100 +Message-ID: <4063CCF1.2030307@colorfullife.com> +Date: Fri, 26 Mar 2004 07:25:53 +0100 +From: Manfred Spraul +User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr-FR; rv:1.4.1) Gecko/20031114 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: markw@osdl.org +Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com, Q@ping.be, + pgman@candle.pha.pa.us, markir@paradise.net.nz, + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] fsync method checking +References: <200403252147.i2PLkx209812@mail.osdl.org> +In-Reply-To: <200403252147.i2PLkx209812@mail.osdl.org> +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: 200403/382 +X-Sequence-Number: 6238 + +markw@osdl.org wrote: + +>Compare file sync methods with one 8k write: +> (o_dsync unavailable) +> open o_sync, write 6.270724 +> write, fdatasync 13.275225 +> write, fsync, 13.359847 +> +> +Odd. Which filesystem, which kernel? It seems fdatasync is broken and +syncs the inode, too. + +-- + Manfred + + +From pgsql-performance-owner@postgresql.org Fri Mar 26 15:28:25 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 2E897D1B995; Fri, 26 Mar 2004 16:10: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 46171-08; Fri, 26 Mar 2004 12:10:32 -0400 (AST) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP + id 4B380D1B973; Fri, 26 Mar 2004 12:10:25 -0400 (AST) +Received: from osdl.org (markw@ibm-b.pdx.osdl.net [172.20.1.51]) + by mail.osdl.org (8.11.6/8.11.6) with ESMTP id i2QG9l220991; + Fri, 26 Mar 2004 08:09:48 -0800 +Message-Id: <200403261609.i2QG9l220991@mail.osdl.org> +Date: Fri, 26 Mar 2004 08:09:43 -0800 (PST) +From: markw@osdl.org +Subject: Re: [HACKERS] fsync method checking +To: manfred@colorfullife.com +Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com, Q@ping.be, + pgman@candle.pha.pa.us, markir@paradise.net.nz, + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +In-Reply-To: <4063CCF1.2030307@colorfullife.com> +MIME-Version: 1.0 +Content-Type: TEXT/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/378 +X-Sequence-Number: 6234 + +On 26 Mar, Manfred Spraul wrote: +> markw@osdl.org wrote: +> +>>Compare file sync methods with one 8k write: +>> (o_dsync unavailable) +>> open o_sync, write 6.270724 +>> write, fdatasync 13.275225 +>> write, fsync, 13.359847 +>> +>> +> Odd. Which filesystem, which kernel? It seems fdatasync is broken and +> syncs the inode, too. + +It's linux-2.6.5-rc1 with ext2 filesystems. + +From pgsql-performance-owner@postgresql.org Fri Mar 26 14:08:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id EA3C4D1ED2B; Fri, 26 Mar 2004 16: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 67140-04; Fri, 26 Mar 2004 12:55:24 -0400 (AST) +Received: from candle.pha.pa.us (candle.pha.pa.us [207.106.42.251]) + by svr1.postgresql.org (Postfix) with ESMTP + id AFD7ED1ED32; Fri, 26 Mar 2004 12:55:17 -0400 (AST) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id i2QGsxt04146; + Fri, 26 Mar 2004 11:54:59 -0500 (EST) +From: Bruce Momjian +Message-Id: <200403261654.i2QGsxt04146@candle.pha.pa.us> +Subject: Re: [HACKERS] fsync method checking +In-Reply-To: <200403261609.i2QG9l220991@mail.osdl.org> +To: markw@osdl.org +Date: Fri, 26 Mar 2004 11:54:59 -0500 (EST) +Cc: manfred@colorfullife.com, tgl@sss.pgh.pa.us, josh@agliodbs.com, + Q@ping.be, markir@paradise.net.nz, pgsql-performance@postgresql.org, + pgsql-hackers@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: 200403/376 +X-Sequence-Number: 6232 + +markw@osdl.org wrote: +> On 26 Mar, Manfred Spraul wrote: +> > markw@osdl.org wrote: +> > +> >>Compare file sync methods with one 8k write: +> >> (o_dsync unavailable) +> >> open o_sync, write 6.270724 +> >> write, fdatasync 13.275225 +> >> write, fsync, 13.359847 +> >> +> >> +> > Odd. Which filesystem, which kernel? It seems fdatasync is broken and +> > syncs the inode, too. +> +> It's linux-2.6.5-rc1 with ext2 filesystems. + +Would you benchmark open_sync for wal_sync_method too? + +-- + Bruce Momjian | http://candle.pha.pa.us + pgman@candle.pha.pa.us | (610) 359-1001 + + If your life is a hard drive, | 13 Roberts Road + + Christ can be your backup. | Newtown Square, Pennsylvania 19073 + +From pgsql-performance-owner@postgresql.org Fri Mar 26 13:49:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 5AA72D1EBFE; Fri, 26 Mar 2004 17:01:32 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 67366-07; Fri, 26 Mar 2004 13:01:36 -0400 (AST) +Received: from mail.osdl.org (fw.osdl.org [65.172.181.6]) + by svr1.postgresql.org (Postfix) with ESMTP + id C0E52D1EBE3; Fri, 26 Mar 2004 13:01:29 -0400 (AST) +Received: from osdl.org (markw@ibm-b.pdx.osdl.net [172.20.1.51]) + by mail.osdl.org (8.11.6/8.11.6) with ESMTP id i2QH0x203524; + Fri, 26 Mar 2004 09:01:00 -0800 +Message-Id: <200403261701.i2QH0x203524@mail.osdl.org> +Date: Fri, 26 Mar 2004 09:00:56 -0800 (PST) +From: markw@osdl.org +Subject: Re: [HACKERS] fsync method checking +To: pgman@candle.pha.pa.us +Cc: manfred@colorfullife.com, tgl@sss.pgh.pa.us, josh@agliodbs.com, + Q@ping.be, markir@paradise.net.nz, pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +In-Reply-To: <200403261654.i2QGsxt04146@candle.pha.pa.us> +MIME-Version: 1.0 +Content-Type: TEXT/plain; charset=us-ascii +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/375 +X-Sequence-Number: 6231 + +On 26 Mar, Bruce Momjian wrote: +> markw@osdl.org wrote: +>> On 26 Mar, Manfred Spraul wrote: +>> > markw@osdl.org wrote: +>> > +>> >>Compare file sync methods with one 8k write: +>> >> (o_dsync unavailable) +>> >> open o_sync, write 6.270724 +>> >> write, fdatasync 13.275225 +>> >> write, fsync, 13.359847 +>> >> +>> >> +>> > Odd. Which filesystem, which kernel? It seems fdatasync is broken and +>> > syncs the inode, too. +>> +>> It's linux-2.6.5-rc1 with ext2 filesystems. +> +> Would you benchmark open_sync for wal_sync_method too? + +Oh yeah. Will try to get results later today. + +Mark + + +From pgsql-performance-owner@postgresql.org Fri Mar 26 13:38:33 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 19765D1ECED + for ; + Fri, 26 Mar 2004 17:29: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 79171-10 + for ; + Fri, 26 Mar 2004 13:29:39 -0400 (AST) +Received: from leo.supplyfx.com (h-67-100-199-42.lsanca54.covad.net + [67.100.199.42]) + by svr1.postgresql.org (Postfix) with ESMTP id B2AB1D1ECDB + for ; + Fri, 26 Mar 2004 13:29:32 -0400 (AST) +Received: from [10.0.100.21] (unknown [10.0.100.21]) + by leo.supplyfx.com (Postfix) with ESMTP + id 608CACF6D5; Fri, 26 Mar 2004 09:29:37 -0800 (PST) +In-Reply-To: <17548.1080266667@sss.pgh.pa.us> +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <20040325145525.V50544@megazone.bigpanda.com> + <16476.1080261565@sss.pgh.pa.us> + <200403251721.58645.josh@agliodbs.com> + <17548.1080266667@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v612) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <1DA4E1C7-7F4B-11D8-8D3D-000A95AB8896@quotefx.net> +Content-Transfer-Encoding: 7bit +Cc: josh@agliodbs.com, pgsql-performance@postgresql.org, + Stephan Szabo +From: Qing Zhao +Subject: Re: column size too large, is this a bug? +Date: Fri, 26 Mar 2004 09:29:20 -0800 +To: Tom Lane +X-Mailer: Apple Mail (2.612) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/374 +X-Sequence-Number: 6230 + +Thanks a lot! We were migrating to Postgres from Oracle and +every now and then, we ran into something that we do not +understand completely and it is a learning process for us. + +Your responses have made it much clear for us. BTW, do you +think that it's better for us just to rewrite everything so we don't +need to use the patch at all? Why do others still use it? + +Thanks! + +Qing +On Mar 25, 2004, at 6:04 PM, Tom Lane wrote: + +> Josh Berkus writes: +>>> Oh, good eye ... it's that infamous CONNECT BY patch again, without +>>> doubt. +> +>> Hey, who does this patch? What's wrong wiith it? +> +> I'm just venting my annoyance at people expecting us to support +> hacked-up versions, especially without telling us they're hacked-up. +> This is the third or fourth trouble report I can recall that was +> eventually traced to that patch (after considerable effort). +> +> Anyway, my guess for the immediate problem is incorrect installation of +> the patch, viz not doing a complete "make clean" and rebuild after +> patching. The patch changes the Query struct which is referenced in +> many more files than are actually modified by the patch, and so if you +> didn't build with --enable-depend then a simple "make" will leave you +> with a patchwork of files that have different ideas about the field +> offsets in Query. I'm a bit surprised it doesn't just dump core... +> +> (That's not directly the fault of the patch, though, except to the +> extent that it can be blamed for coming without adequate installation +> instructions. What is directly the fault of the patch is that it +> doesn't force an initdb by changing catversion. The prior trouble +> reports had to do with views not working because their stored rules +> were +> incompatible with the patched backend. We should not have had to deal +> with that, and neither should those users.) +> +> Theory B, of course, is that this is an actual bug in the patch and not +> just incorrect installation. I'm not interested enough to investigate +> though. +> +> regards, tom lane +> + + +From pgsql-performance-owner@postgresql.org Fri Mar 26 14:21:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AB642D1EBAB + for ; + Fri, 26 Mar 2004 18: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 93218-08 + for ; + Fri, 26 Mar 2004 14:02:25 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 34856D1BA75 + for ; + Fri, 26 Mar 2004 14:02:18 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4700314; Fri, 26 Mar 2004 10:03:41 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Qing Zhao , Tom Lane +Subject: Re: column size too large, is this a bug? +Date: Fri, 26 Mar 2004 10:01:47 -0800 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org, + Stephan Szabo +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <17548.1080266667@sss.pgh.pa.us> + <1DA4E1C7-7F4B-11D8-8D3D-000A95AB8896@quotefx.net> +In-Reply-To: <1DA4E1C7-7F4B-11D8-8D3D-000A95AB8896@quotefx.net> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403261001.47665.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/377 +X-Sequence-Number: 6233 + +Quig, + +> Your responses have made it much clear for us. BTW, do you +> think that it's better for us just to rewrite everything so we don't +> need to use the patch at all? Why do others still use it? + +Others use it because of the same reason you do. + +If you want to use the patch for seemless porting, I suggest that you contact +Evgen directly. He's not very active on the main project mailing lists, so +you'll need to e-mail him personally. You may also need to sponsor him for +bug fixes, since he is apparently an independent developer. I don't really +know him. + +As an alternative, you may want to take a look at the IS_CONNECTED_BY patch +in /contrib/tablefunc in the PostgreSQL source. As this was developed by +Joe Conway, who is a very active major contributor in the community, it is +more likely to be bug-free. However, it will force you to change your +query syntax somewhat. + +Of course, there are other query tree structures you could use if you're +willing to modify your database design. But you may not want to go that +far. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Mar 26 23:01:48 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D2F6D1ED48 + for ; + Fri, 26 Mar 2004 18:14: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 02092-03 + for ; + Fri, 26 Mar 2004 14:14:05 -0400 (AST) +Received: from steelhead.ravensfield.com (unknown [65.222.52.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 4AEDAD1ED33 + for ; + Fri, 26 Mar 2004 14:13:58 -0400 (AST) +Received: from [10.1.1.7] (smallmouth.oh.ia [10.1.1.7]) + by steelhead.ravensfield.com (Postfix) with ESMTP + id 1043466145; Fri, 26 Mar 2004 13:14:02 -0500 (EST) +In-Reply-To: <1DA4E1C7-7F4B-11D8-8D3D-000A95AB8896@quotefx.net> +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <20040325145525.V50544@megazone.bigpanda.com> + <16476.1080261565@sss.pgh.pa.us> + <200403251721.58645.josh@agliodbs.com> + <17548.1080266667@sss.pgh.pa.us> + <1DA4E1C7-7F4B-11D8-8D3D-000A95AB8896@quotefx.net> +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <8B3A05B5-7F51-11D8-93F3-000393A47FCC@ravensfield.com> +Content-Transfer-Encoding: 7bit +Cc: josh@agliodbs.com, Tom Lane , + Stephan Szabo , + pgsql-performance@postgresql.org +From: Andrew Rawnsley +Subject: Re: column size too large, is this a bug? +Date: Fri, 26 Mar 2004 13:15:21 -0500 +To: Qing Zhao +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/398 +X-Sequence-Number: 6254 + + +I used to use the connect-by patch, but have since rewritten everything +to use a nested set model. I was +having problems that, while not immediately traceable back to the +patch, showed up when I started +using it and went away when I stopped (strange locking behavior, +crashing with vacuum full, problems after +dropping columns) . Plus the annoyance of maintaining a non-stock build +across numerous installations +exceeded its benefits. Relying on it for a business critical situation +became too much of a risk. + + + +On Mar 26, 2004, at 12:29 PM, Qing Zhao wrote: + +> Thanks a lot! We were migrating to Postgres from Oracle and +> every now and then, we ran into something that we do not +> understand completely and it is a learning process for us. +> +> Your responses have made it much clear for us. BTW, do you +> think that it's better for us just to rewrite everything so we don't +> need to use the patch at all? Why do others still use it? +> +> Thanks! +> +> Qing +> On Mar 25, 2004, at 6:04 PM, Tom Lane wrote: +> +>> Josh Berkus writes: +>>>> Oh, good eye ... it's that infamous CONNECT BY patch again, without +>>>> doubt. +>> +>>> Hey, who does this patch? What's wrong wiith it? +>> +>> I'm just venting my annoyance at people expecting us to support +>> hacked-up versions, especially without telling us they're hacked-up. +>> This is the third or fourth trouble report I can recall that was +>> eventually traced to that patch (after considerable effort). +>> +>> Anyway, my guess for the immediate problem is incorrect installation +>> of +>> the patch, viz not doing a complete "make clean" and rebuild after +>> patching. The patch changes the Query struct which is referenced in +>> many more files than are actually modified by the patch, and so if you +>> didn't build with --enable-depend then a simple "make" will leave you +>> with a patchwork of files that have different ideas about the field +>> offsets in Query. I'm a bit surprised it doesn't just dump core... +>> +>> (That's not directly the fault of the patch, though, except to the +>> extent that it can be blamed for coming without adequate installation +>> instructions. What is directly the fault of the patch is that it +>> doesn't force an initdb by changing catversion. The prior trouble +>> reports had to do with views not working because their stored rules +>> were +>> incompatible with the patched backend. We should not have had to deal +>> with that, and neither should those users.) +>> +>> Theory B, of course, is that this is an actual bug in the patch and +>> not +>> just incorrect installation. I'm not interested enough to investigate +>> though. +>> +>> regards, tom lane +>> +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 4: Don't 'kill -9' the postmaster +> +-------------------- + +Andrew Rawnsley +President +The Ravensfield Digital Resource Group, Ltd. +(740) 587-0114 +www.ravensfield.com + + +From pgsql-performance-owner@postgresql.org Fri Mar 26 21:20:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E03DFD1ED06 + for ; + Fri, 26 Mar 2004 21:53:35 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 89605-01 + for ; + Fri, 26 Mar 2004 17:53:40 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id EF506D1ED21 + for ; + Fri, 26 Mar 2004 17:53:32 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2QLrenm027628; + Fri, 26 Mar 2004 16:53:40 -0500 (EST) +To: Fabio Esposito +Cc: pgsql-performance@postgresql.org +Subject: Re: postgres eating CPU on HP9000 +In-reply-to: +References: +Comments: In-reply-to Fabio Esposito + message dated "Tue, 23 Mar 2004 14:21:34 -0500" +Date: Fri, 26 Mar 2004 16:53:40 -0500 +Message-ID: <27627.1080338020@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/397 +X-Sequence-Number: 6253 + +Fabio Esposito writes: +> We've recently integrated postgres into an existing mature app. Its a +> time sensitive 24x7 system. It runs on HP9000, a K370 Dual Processor +> system. Postgres is version 7.3.2. Its spawned as a child from a parent +> supervisory process, and they communicate to eachother via shared memory. + +You would be well advised to update to 7.3.6, though I'm not sure if any +of the post-7.3.2 fixes have anything to do with your speed problem. + +> Recently it started eating up the cpu, and cannot keepup with the system +> like it used to. The interesting thing here is that it still runs great +> on an older system with less ram, one slower cpu, and an older disk. + +> We tried the following with no success: + +> running VACCUUM FULL +> dropping all tables and staring anew + +Did you start from a fresh initdb, or just drop and recreate user +tables? I'm wondering about index bloat on the system tables ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 26 20:55:23 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 50BD0D1D2C1 + for ; + Fri, 26 Mar 2004 22:22: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 91253-09 + for ; + Fri, 26 Mar 2004 18:22:20 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id C62EFD1D1C4 + for ; + Fri, 26 Mar 2004 18:22:11 -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 i2QMLV2M023919; + Fri, 26 Mar 2004 15:21:31 -0700 (MST) +Date: Fri, 26 Mar 2004 15:17:51 -0700 (MST) +From: "scott.marlowe" +To: Fabio Esposito +Cc: +Subject: Re: postgres eating CPU on HP9000 +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-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/396 +X-Sequence-Number: 6252 + +On Tue, 23 Mar 2004, Fabio Esposito wrote: + +> +> Hello fellow PostgreSQL users. +> +> We've been working on this interesting issue for some time now, and we're +> hoping that someone can help. +> +> We've recently integrated postgres into an existing mature app. Its a +> time sensitive 24x7 system. It runs on HP9000, a K370 Dual Processor +> system. Postgres is version 7.3.2. Its spawned as a child from a parent +> supervisory process, and they communicate to eachother via shared memory. +> +> We preform 9-12K selects per hour +> 6-8K inserts per hour (a few updates here as well) +> 1-1.5K Deletes per hour. +> +> It maintains 48hours of data, so its not a large database; roughly +> <600mbs. We do this by running a housekeeping program in a cron job. +> It deletes all data older then 48hours, then vaccuum analyzes. It will +> also preform a reindex if the option is set before it vaccuum's. +> +> Postgres initially worked wonderfully, fast and solid. It +> preformed complex joins in 0.01secs, and was able to keep up with our +> message queue. It stayed this way for almost a year during our +> development. +> +> Recently it started eating up the cpu, and cannot keepup with the system +> like it used to. The interesting thing here is that it still runs great +> on an older system with less ram, one slower cpu, and an older disk. +> +> We tried the following with no success: +> +> running VACCUUM FULL +> dropping all tables and staring anew +> reinstalling postgres +> tweaking kernel parameters (various combos) +> tweaking postgres parameters (various combos) +> a number of other ideas + +This almost sounds like a problem (fixed in 7.4 I believe) where some +system catalog indexes would get huge over time, and couldn't be vacuumed +or reindexed while the database was up in multi-user mode. + +I'll defer to Tom or Bruce or somebody to say if my guess is even close... + + +From pgsql-performance-owner@postgresql.org Fri Mar 26 20:51:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E78CCD1D1C4 + for ; + Fri, 26 Mar 2004 22:24: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 96699-04 + for ; + Fri, 26 Mar 2004 18:24:57 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id 49EF6D1D0F9 + for ; + Fri, 26 Mar 2004 18:24:49 -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 i2QMNe2M024188; + Fri, 26 Mar 2004 15:23:40 -0700 (MST) +Date: Fri, 26 Mar 2004 15:20:00 -0700 (MST) +From: "scott.marlowe" +To: Ara Anjargolian +Cc: +Subject: Re: odd planner choice +In-Reply-To: <001401c412f6$88281700$6401a8c0@ARA> +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-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/395 +X-Sequence-Number: 6251 + +On Thu, 25 Mar 2004, Ara Anjargolian wrote: + +> I've run into this odd planner choice which I don't quite understand. +> +> I have two tables articles, users and +> articles.article_id and users.user_id are primary keys. +> +> Insides articles there are two optional fields author_id1, author_id2 +> which all reference users.user_id. +> +> And now the plans: +> (by the way this is pg 7.4 and I set enable_seqscan to off). +> +> jargol=# explain select user_id, first_names, last_name from articles, users +> where article_id = 5027 and (articles.author_id1 = users.user_id); +> QUERY PLAN +> ---------------------------------------------------------------------------- +> ------ +> Nested Loop (cost=0.00..4.04 rows=1 width=26) +> -> Index Scan using articles_pk on articles (cost=0.00..2.01 rows=1 +> width=4) +> Index Cond: (article_id = 5027) +> -> Index Scan using users_pk on users (cost=0.00..2.01 rows=1 width=26) +> Index Cond: ("outer".author_id1 = users.user_id) +> (5 rows) +> +> jargol=# explain select user_id, first_names, last_name from articles, users +> where article_id = 5027 and (articles.author_id1 = users.user_id or +> articles.author_id2 = users.user_id); +> QUERY PLAN +> ---------------------------------------------------------------------------- +> ----------------------- +> Nested Loop (cost=100000000.00..100000003.11 rows=2 width=26) +> Join Filter: (("outer".author_id1 = "inner".user_id) OR +> ("outer".author_id2 = "inner".user_id)) +> -> Index Scan using articles_pk on articles (cost=0.00..2.01 rows=1 +> width=8) +> Index Cond: (article_id = 5027) +> -> Seq Scan on users (cost=100000000.00..100000001.04 rows=4 width=26) +> (5 rows) +> +> Why does it think it MUST do a seq-scan in the second case? users.user_id is +> a primary key, +> so shouldn't it behave exactly as in the first case? +> +> Any enlightenment on this problem will be much appreciated. + +Are articles.author_id1 and users.user_id the same type? Have you tried +casting one to the other's type if they're different? + + +From pgsql-performance-owner@postgresql.org Fri Mar 26 20:10:31 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4D150D1D222 + for ; + Fri, 26 Mar 2004 23:08: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 18896-03 + for ; + Fri, 26 Mar 2004 19:08:56 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id CE01FD1B4B0 + for ; + Fri, 26 Mar 2004 19:08:47 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2QN8ttG028300; + Fri, 26 Mar 2004 18:08:55 -0500 (EST) +To: "Ara Anjargolian" +Cc: pgsql-performance@postgresql.org +Subject: Re: odd planner choice +In-reply-to: <001401c412f6$88281700$6401a8c0@ARA> +References: <001401c412f6$88281700$6401a8c0@ARA> +Comments: In-reply-to "Ara Anjargolian" + message dated "Thu, 25 Mar 2004 21:52:31 -0800" +Date: Fri, 26 Mar 2004 18:08:54 -0500 +Message-ID: <28299.1080342534@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/391 +X-Sequence-Number: 6247 + +"Ara Anjargolian" writes: +> jargol=# explain select user_id, first_names, last_name from articles, users +> where article_id = 5027 and (articles.author_id1 = users.user_id or +> articles.author_id2 = users.user_id); + +> Why does it think it MUST do a seq-scan in the second case? + +There's no support for generating an OR indexscan in the context of a +join. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 26 20:03:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8336FD1D8A5 + for ; + Fri, 26 Mar 2004 23:11: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 18896-04 + for ; + Fri, 26 Mar 2004 19:11:58 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 39423D1D84E + for ; + Fri, 26 Mar 2004 19:11:50 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4704133; Fri, 26 Mar 2004 15:13:16 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Fabio Esposito , + pgsql-performance@postgresql.org +Subject: Re: postgres eating CPU on HP9000 +Date: Fri, 26 Mar 2004 15:11:22 -0800 +User-Agent: KMail/1.5.4 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403261511.22493.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/390 +X-Sequence-Number: 6246 + +Fabio, + +> Postgres initially worked wonderfully, fast and solid. It +> preformed complex joins in 0.01secs, and was able to keep up with our +> message queue. It stayed this way for almost a year during our +> development. +> +> Recently it started eating up the cpu, and cannot keepup with the system +> like it used to. The interesting thing here is that it still runs great +> on an older system with less ram, one slower cpu, and an older disk. + +This really points to a maintenance problem. How often do you run VACUUM +ANALYZE? You have a very high rate of data turnover, and should need to +VACUUM frequently. + +Also, what's you max_fsm_pages setting. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Mar 26 19:36:42 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 25C7BD1DCF9; Fri, 26 Mar 2004 23:22: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 21994-05; Fri, 26 Mar 2004 19:22:35 -0400 (AST) +Received: from gp.word-to-the-wise.com (gp.word-to-the-wise.com + [64.71.176.18]) + by svr1.postgresql.org (Postfix) with ESMTP + id C5B65D1DCED; Fri, 26 Mar 2004 19:22:26 -0400 (AST) +Received: by gp.word-to-the-wise.com (Postfix, from userid 500) + id 67AA290000D; Fri, 26 Mar 2004 15:14:59 -0800 (PST) +Date: Fri, 26 Mar 2004 15:14:59 -0800 +From: Steve Atkins +To: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] fsync method checking +Message-ID: <20040326231459.GA23615@gp.word-to-the-wise.com> +References: <200403252147.i2PLkx209812@mail.osdl.org> + <4063CCF1.2030307@colorfullife.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4063CCF1.2030307@colorfullife.com> +User-Agent: Mutt/1.4.1i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/389 +X-Sequence-Number: 6245 + +On Fri, Mar 26, 2004 at 07:25:53AM +0100, Manfred Spraul wrote: + +> >Compare file sync methods with one 8k write: +> > (o_dsync unavailable) +> > open o_sync, write 6.270724 +> > write, fdatasync 13.275225 +> > write, fsync, 13.359847 +> > +> > +> Odd. Which filesystem, which kernel? It seems fdatasync is broken and +> syncs the inode, too. + +This may be relevant. + + From the man page for fdatasync on a moderately recent RedHat installation: + + BUGS + Currently (Linux 2.2) fdatasync is equivalent to fsync. + +Cheers, + Steve + +From pgsql-performance-owner@postgresql.org Fri Mar 26 19:34:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FF26D1D2E3 + for ; + Fri, 26 Mar 2004 23: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 15739-10 + for ; + Fri, 26 Mar 2004 19:15:03 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 64988D1DC1E + for ; + Fri, 26 Mar 2004 19:14:54 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2QNF1Uj028355; + Fri, 26 Mar 2004 18:15:01 -0500 (EST) +To: Shiar +Cc: pgsql-performance@postgresql.org +Subject: Re: bigint index not used +In-reply-to: <20040324121125.GE1178@shiar.org> +References: <20040324121125.GE1178@shiar.org> +Comments: In-reply-to Shiar + message dated "Wed, 24 Mar 2004 13:11:25 +0100" +Date: Fri, 26 Mar 2004 18:15:01 -0500 +Message-ID: <28354.1080342901@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/388 +X-Sequence-Number: 6244 + +Shiar writes: +>> EXPLAIN ANALYZE SELECT id FROM userinfo WHERE icq <> '0'; +> Seq Scan on userinfo (cost=0.00..47355.90 rows=849244 width=4) (actual time=0.563..1222.963 rows=48797 loops=1) +> Filter: (icq <> 0::bigint) +> Total runtime: 1258.703 ms + +The rows estimate is way off, which might or might not have much to do +with the issue, but it's surely suspicious. + +> We're running PostgreSQL 7.4.1 on a Debian/Linux 2.4 system with 4GB RAM and a +> fast SCSI RAID array, with settings: + +Update to 7.4.2 and follow the procedure in the release notes about +fixing pg_statistic; that may make things better. int8 columns are +vulnerable to the statistic misalignment bug. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri Mar 26 20:23:24 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0B7ABD1EBB1 + for ; + Sat, 27 Mar 2004 00:10:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 39743-06 + for ; + Fri, 26 Mar 2004 20:10:59 -0400 (AST) +Received: from mail1.ihs.com (mail1.ihs.com [170.207.70.222]) + by svr1.postgresql.org (Postfix) with ESMTP id E080BD1EBB0 + for ; + Fri, 26 Mar 2004 20:10: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 i2R0A32M003932; + Fri, 26 Mar 2004 17:10:03 -0700 (MST) +Date: Fri, 26 Mar 2004 17:05:55 -0700 (MST) +From: "scott.marlowe" +To: Fabio Esposito +Cc: +Subject: Re: postgres eating CPU on HP9000 +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-IHS-MailScanner-Envelope-Sender: scott.marlowe@ihs.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/392 +X-Sequence-Number: 6248 + +On Fri, 26 Mar 2004, Fabio Esposito wrote: + +> +> On Fri, 26 Mar 2004, scott.marlowe wrote: +> +> > > It maintains 48hours of data, so its not a large database; roughly +> > > <600mbs. We do this by running a housekeeping program in a cron job. +> > > It deletes all data older then 48hours, then vaccuum analyzes. It will +> > > also preform a reindex if the option is set before it vaccuum's. +> > > +> > This almost sounds like a problem (fixed in 7.4 I believe) where some +> > system catalog indexes would get huge over time, and couldn't be vacuumed +> > or reindexed while the database was up in multi-user mode. +> > +> > I'll defer to Tom or Bruce or somebody to say if my guess is even close... +> > +> We haven't tried 7.4, I will experiment with it next week, I hope it +> will be that simple. + +In the meantime, a simple dump - reload into a test box running your +current version may provide some insight. If it fixes the problem, then +you likely do have some kind of issue with index / table growth that isn't +being addressed by vacuuming. + + +From pgsql-performance-owner@postgresql.org Fri Mar 26 20:29:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DB1CBD1EBFE + for ; + Sat, 27 Mar 2004 00:26: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 40754-10 + for ; + Fri, 26 Mar 2004 20:26:42 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 7C3D7D1EBD3 + for ; + Fri, 26 Mar 2004 20:26:33 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4705906; Fri, 26 Mar 2004 16:28:00 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Fabio Esposito +Subject: Re: postgres eating CPU on HP9000 +Date: Fri, 26 Mar 2004 16:26:02 -0800 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403261626.02845.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/393 +X-Sequence-Number: 6249 + +Fabio, + +> I'll have to get back to you on that, but I'm 90% sure its the default out +> of the box. + +Raise it, a lot. Perhaps to 30,000 or 50,000. VACUUM VERBOSE ANALYZE +should show you how many data pages are being reclaimed between vacuums. + +Because of your very high rate of updates and deletes, you need to hold a lot +of data pages open. + +You would also benefit a great deal by upgrading to 7.4. 7.3 will require +you to to REINDEXes several times a day with your current setup; 7.4 will +not. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Fri Mar 26 20:43:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 8C59ED1CCA5 + for ; + Sat, 27 Mar 2004 00:36: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 51492-06 + for ; + Fri, 26 Mar 2004 20:36:29 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 7F2D4D1BA8F + for ; + Fri, 26 Mar 2004 20:36:20 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2R0aTBq029373; + Fri, 26 Mar 2004 19:36:29 -0500 (EST) +To: Fabio Esposito +Cc: pgsql-performance@postgresql.org +Subject: Re: postgres eating CPU on HP9000 +In-reply-to: +References: +Comments: In-reply-to Fabio Esposito + message dated "Fri, 26 Mar 2004 19:00:55 -0500" +Date: Fri, 26 Mar 2004 19:36:29 -0500 +Message-ID: <29372.1080347789@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/394 +X-Sequence-Number: 6250 + +Fabio Esposito writes: +>> Did you start from a fresh initdb, or just drop and recreate user +>> tables? I'm wondering about index bloat on the system tables ... + +> I don't think I re initdb it, just dropped. We did try a reindex command +> in the interactive editor, with no success. + +Reindex of what? I'd suggest looking to see the actual sizes of all the +indexes on system tables. If my guess is right, some of them may be way +out of line (like larger than their associated tables). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat Mar 27 06:38:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DC0E1D1ED87 + for ; + Sat, 27 Mar 2004 10:38: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 33294-01 + for ; + Sat, 27 Mar 2004 06:38:40 -0400 (AST) +Received: from ideafix.webnow.com.br (unknown [200.155.0.57]) + by svr1.postgresql.org (Postfix) with ESMTP id 52E98D1ED73 + for ; + Sat, 27 Mar 2004 06:38:37 -0400 (AST) +Received: by ideafix.webnow.com.br (Postfix, from userid 48) + id 4BBFE197636; Sat, 27 Mar 2004 07:38:37 -0300 (BRT) +Received: from 148100.cps.virtua.com.br ([200.174.148.100]) + (SquirrelMail authenticated user marcus.magalhaes@vlinfo.com.br) + by webmail.webnow.com.br with HTTP; + Sat, 27 Mar 2004 07:38:37 -0300 (BRT) +Message-ID: <62945.200.174.148.100.1080383917.squirrel@webmail.webnow.com.br> +Date: Sat, 27 Mar 2004 07:38:37 -0300 (BRT) +Subject: Re: postgres eating CPU on HP9000 +From: "Marcus Andree S. Magalhaes" +To: +In-Reply-To: +References: + +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: 200403/399 +X-Sequence-Number: 6255 + + + +We are experiencing exactly the same problem here, and we use 7.4 on +Linux/i386 SMP (2 processors). Our databases does even more access: +about 30k selects per hour, 10k updates and inserts per hour + +Vacuum analyze is done daily. + +We migrated our database to a new server. Initially, everything was fine, +and pretty fast. In a week or so, Vacuum performance is pretty slow. What +was done in 15 minutes now takes 2 hours. Postgres is consuming a lot of +CPU power and, when the system is in peak period, it's even worse. + +Sure, we have a large database. 3 tables have more than 10M records, but +more or less suddenly, we're having a heavy performance prejudice. + +> +> This almost sounds like a problem (fixed in 7.4 I believe) where some +> system catalog indexes would get huge over time, and couldn't be +> vacuumed or reindexed while the database was up in multi-user mode. +> +> I'll defer to Tom or Bruce or somebody to say if my guess is even +> close... +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) + + + + +From pgsql-performance-owner@postgresql.org Sun Mar 28 13:17:38 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5DADCD1DA5F + for ; + Sun, 28 Mar 2004 17: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 98830-09 + for ; + Sun, 28 Mar 2004 13:17:36 -0400 (AST) +Received: from sss.pgh.pa.us (unknown [192.204.191.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 45589D1D8F3 + for ; + Sun, 28 Mar 2004 13:17:35 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2SHGI2f016580; + Sun, 28 Mar 2004 12:16:19 -0500 (EST) +To: "Eric Brown" +Cc: pgsql-performance@postgresql.org +Subject: Re: severe performance issue with planner +In-reply-to: +References: +Comments: In-reply-to "Eric Brown" + message dated "Mon, 22 Mar 2004 20:30:29 -0500" +Date: Sun, 28 Mar 2004 12:16:18 -0500 +Message-ID: <16579.1080494178@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/400 +X-Sequence-Number: 6256 + +"Eric Brown" writes: +> Here's the query as I have changed it now: + +Now that you've switched to JOIN syntax, you can cut the planning time +to nil by setting join_collapse_limit to 1. See +http://www.postgresql.org/docs/7.4/static/explicit-joins.html + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun Mar 28 15:25:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 93C8ED1DC2D + for ; + Sun, 28 Mar 2004 19:25: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 33515-10 + for ; + Sun, 28 Mar 2004 15:25:11 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 58B91D1D9E6 + for ; + Sun, 28 Mar 2004 15:25:09 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4720599; Sun, 28 Mar 2004 11:26:29 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: "Marcus Andree S. Magalhaes" , + +Subject: Re: postgres eating CPU on HP9000 +Date: Sun, 28 Mar 2004 11:24:43 -0800 +User-Agent: KMail/1.4.3 +Cc: , +References: + + <62945.200.174.148.100.1080383917.squirrel@webmail.webnow.com.br> +In-Reply-To: <62945.200.174.148.100.1080383917.squirrel@webmail.webnow.com.br> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200403281124.43275.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/401 +X-Sequence-Number: 6257 + +Marcus, + +> We are experiencing exactly the same problem here, and we use 7.4 on +> Linux/i386 SMP (2 processors). Our databases does even more access: +> about 30k selects per hour, 10k updates and inserts per hour +> +> Vacuum analyze is done daily. + +What is your max_fsm_pages setting? If you are getting 10,000 updates per +hour, daily VACUUM ANALYZE may not be enough. + +Also do you run VACUUM ANALYZE as a superuser, or as a regular user? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sun Mar 28 15:26:12 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 4ACF2D1D803 + for ; + Sun, 28 Mar 2004 19:26: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 35018-08 + for ; + Sun, 28 Mar 2004 15:26:09 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id E983AD1D707 + for ; + Sun, 28 Mar 2004 15:26:07 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4720604; Sun, 28 Mar 2004 11:27:27 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Andrew Rawnsley , + Qing Zhao +Subject: Re: column size too large, is this a bug? +Date: Sun, 28 Mar 2004 11:25:41 -0800 +User-Agent: KMail/1.4.3 +Cc: Tom Lane , + Stephan Szabo , + pgsql-performance@postgresql.org +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <1DA4E1C7-7F4B-11D8-8D3D-000A95AB8896@quotefx.net> + <8B3A05B5-7F51-11D8-93F3-000393A47FCC@ravensfield.com> +In-Reply-To: <8B3A05B5-7F51-11D8-93F3-000393A47FCC@ravensfield.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200403281125.41590.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/402 +X-Sequence-Number: 6258 + +Andrew, + +> I used to use the connect-by patch, but have since rewritten everything +> to use a nested set model. + +Cool! You're probably the only person I know other than me using nested sets +in a production environment. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sun Mar 28 15:48:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 40DEAD1E63E + for ; + Sun, 28 Mar 2004 19:48: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 42132-06 + for ; + Sun, 28 Mar 2004 15:48:34 -0400 (AST) +Received: from steelhead.ravensfield.com (unknown [65.222.52.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 8D6DDD1E15C + for ; + Sun, 28 Mar 2004 15:48:32 -0400 (AST) +Received: from [10.4.3.101] (unknown [10.4.3.101]) + by steelhead.ravensfield.com (Postfix) with ESMTP + id 2BD6166145; Sun, 28 Mar 2004 14:48:33 -0500 (EST) +In-Reply-To: <200403281125.41590.josh@agliodbs.com> +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <1DA4E1C7-7F4B-11D8-8D3D-000A95AB8896@quotefx.net> + <8B3A05B5-7F51-11D8-93F3-000393A47FCC@ravensfield.com> + <200403281125.41590.josh@agliodbs.com> +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: <15A45996-80F1-11D8-ADCF-000393A47FCC@ravensfield.com> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Andrew Rawnsley +Subject: Re: column size too large, is this a bug? +Date: Sun, 28 Mar 2004 14:49:54 -0500 +To: Josh Berkus +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/403 +X-Sequence-Number: 6259 + + +Well, I don't know if I would use it in an insert-heavy environment (at +least the way I implemented it), but for select-heavy +stuff I don't know why you would want to use anything else. Hard to +beat the performance of a simple BETWEEN. + +On Mar 28, 2004, at 2:25 PM, Josh Berkus wrote: + +> Andrew, +> +>> I used to use the connect-by patch, but have since rewritten +>> everything +>> to use a nested set model. +> +> Cool! You're probably the only person I know other than me using +> nested sets +> in a production environment. +> +> -- +> Josh Berkus +> Aglio Database Solutions +> San Francisco +> +-------------------- + +Andrew Rawnsley +President +The Ravensfield Digital Resource Group, Ltd. +(740) 587-0114 +www.ravensfield.com + + +From pgsql-performance-owner@postgresql.org Mon Mar 29 06:57:47 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A6C76D1ECD7 + for ; + Mon, 29 Mar 2004 10: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 15087-06 + for ; + Mon, 29 Mar 2004 06:57:49 -0400 (AST) +Received: from ideafix.webnow.com.br (unknown [200.155.0.57]) + by svr1.postgresql.org (Postfix) with ESMTP id F09E6D1DB5B + for ; + Mon, 29 Mar 2004 06:57:39 -0400 (AST) +Received: by ideafix.webnow.com.br (Postfix, from userid 48) + id 7D0B5197550; Mon, 29 Mar 2004 07:57:44 -0300 (BRT) +Received: from 200.174.148.100 + (SquirrelMail authenticated user marcus.magalhaes@vlinfo.com.br) + by webmail.webnow.com.br with HTTP; + Mon, 29 Mar 2004 07:57:43 -0300 (BRT) +Message-ID: <61715.200.174.148.100.1080557863.squirrel@webmail.webnow.com.br> +Date: Mon, 29 Mar 2004 07:57:43 -0300 (BRT) +Subject: Re: postgres eating CPU on HP9000 +From: "Marcus Andree S. Magalhaes" +To: +In-Reply-To: <200403281124.43275.josh@agliodbs.com> +References: + + <62945.200.174.148.100.1080383917.squirrel@webmail.webnow.com.br> + <200403281124.43275.josh@agliodbs.com> +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: 200403/404 +X-Sequence-Number: 6260 + +> Marcus, +> +>> We are experiencing exactly the same problem here, and we use 7.4 on +>> Linux/i386 SMP (2 processors). Our databases does even more access: +>> about 30k selects per hour, 10k updates and inserts per hour +>> +>> Vacuum analyze is done daily. +> +> What is your max_fsm_pages setting? If you are getting 10,000 +> updates per hour, daily VACUUM ANALYZE may not be enough. +> + +max_fsm_pages is set to 500000 + +> Also do you run VACUUM ANALYZE as a superuser, or as a regular user? +> + +As a regular user (database owner). Is thery any difference when vacuuming +as a super user? + +> -- +> Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: the planner will ignore your desire to choose an index scan if +> your +> joining column's datatypes do not match + + + + +From pgsql-performance-owner@postgresql.org Mon Mar 29 09:13:16 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 627F3D1ED0F + for ; + Mon, 29 Mar 2004 13:13: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 68825-05 + for ; + Mon, 29 Mar 2004 09:13:23 -0400 (AST) +Received: from sourceweave.net (CPE004f49016802-CM.cpe.net.cable.rogers.com + [24.43.140.53]) + by svr1.postgresql.org (Postfix) with SMTP id AF067D1ED7F + for ; + Mon, 29 Mar 2004 09:13:13 -0400 (AST) +Received: (qmail 25272 invoked by uid 1000); 29 Mar 2004 13:09:22 -0000 +Received: from localhost (sendmail-bs@127.0.0.1) + by localhost with SMTP; 29 Mar 2004 13:09:22 -0000 +Date: Mon, 29 Mar 2004 08:09:22 -0500 (EST) +From: Fabio Esposito +X-X-Sender: nfesposi@cr818510-a.basement +To: Josh Berkus +Cc: pgsql-performance@postgresql.org +Subject: Re: postgres eating CPU on HP9000 +In-Reply-To: <200403261511.22493.josh@agliodbs.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/405 +X-Sequence-Number: 6261 + + + + +On Fri, 26 Mar 2004, Josh Berkus wrote: + +> Fabio, +> +> > Recently it started eating up the cpu, and cannot keepup with the system +> > like it used to. The interesting thing here is that it still runs great +> > on an older system with less ram, one slower cpu, and an older disk. +> +> This really points to a maintenance problem. How often do you run VACUUM +> ANALYZE? You have a very high rate of data turnover, and should need to +> VACUUM frequently. +> +> Also, what's you max_fsm_pages setting. +> + +We run VACUUM ANALYZE after we remove about 1000 rows every hour on the +halh hour. Our max_fsm_pages is set to 10000 + +Thanks again + +Fabio + + +From pgsql-performance-owner@postgresql.org Mon Mar 29 11:36:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5AED6D1E317 + for ; + Mon, 29 Mar 2004 15:36: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 44060-01 + for ; + Mon, 29 Mar 2004 11:36:43 -0400 (AST) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 4F184D1D2CC + for ; + Mon, 29 Mar 2004 11:36:33 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2TFabCT001118; + Mon, 29 Mar 2004 10:36:37 -0500 (EST) +To: "Marcus Andree S. Magalhaes" +Cc: josh@agliodbs.com, scott.marlowe@ihs.com, + nfesposi@sourceweave.net, pgsql-performance@postgresql.org +Subject: Re: postgres eating CPU on HP9000 +In-reply-to: <61715.200.174.148.100.1080557863.squirrel@webmail.webnow.com.br> +References: + + <62945.200.174.148.100.1080383917.squirrel@webmail.webnow.com.br> + <200403281124.43275.josh@agliodbs.com> + <61715.200.174.148.100.1080557863.squirrel@webmail.webnow.com.br> +Comments: In-reply-to "Marcus Andree S. Magalhaes" + + message dated "Mon, 29 Mar 2004 07:57:43 -0300" +Date: Mon, 29 Mar 2004 10:36:37 -0500 +Message-ID: <1117.1080574597@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/406 +X-Sequence-Number: 6262 + +"Marcus Andree S. Magalhaes" writes: +>> Also do you run VACUUM ANALYZE as a superuser, or as a regular user? + +> As a regular user (database owner). Is thery any difference when vacuuming +> as a super user? + +That's your problem. A regular user won't have permissions to vacuum +any tables but his own ... in particular, not the system tables. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Mar 29 13:04:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 5FDC2D1EA73 + for ; + Mon, 29 Mar 2004 17:04: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 79803-04 + for ; + Mon, 29 Mar 2004 13:04:14 -0400 (AST) +Received: from sourceweave.net (CPE004f49016802-CM.cpe.net.cable.rogers.com + [24.43.140.53]) + by svr1.postgresql.org (Postfix) with SMTP id B7EABD1EA76 + for ; + Mon, 29 Mar 2004 13:04:13 -0400 (AST) +Received: (qmail 25375 invoked by uid 1000); 29 Mar 2004 17:00:16 -0000 +Received: from localhost (sendmail-bs@127.0.0.1) + by localhost with SMTP; 29 Mar 2004 17:00:16 -0000 +Date: Mon, 29 Mar 2004 12:00:16 -0500 (EST) +From: Fabio Esposito +X-X-Sender: nfesposi@cr818510-a.basement +To: Tom Lane +Cc: "Marcus Andree S. Magalhaes" , + , , + +Subject: Re: postgres eating CPU on HP9000 +In-Reply-To: <1117.1080574597@sss.pgh.pa.us> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/407 +X-Sequence-Number: 6263 + + +I'm sorry all, when you say regular user as opposed to superuser are you +talking about the user that postgres is installed and running as? Should +this be done as the os's root? + +Fabio + +On Mon, 29 Mar 2004, Tom Lane wrote: + +> "Marcus Andree S. Magalhaes" writes: +> >> Also do you run VACUUM ANALYZE as a superuser, or as a regular user? +> +> > As a regular user (database owner). Is thery any difference when vacuuming +> > as a super user? +> +> That's your problem. A regular user won't have permissions to vacuum +> any tables but his own ... in particular, not the system tables. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 7: don't forget to increase your free space map settings +> + + +From pgsql-performance-owner@postgresql.org Mon Mar 29 13:05:08 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id A4D18D1EA7E + for ; + Mon, 29 Mar 2004 17:05: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 78870-06 + for ; + Mon, 29 Mar 2004 13:05:03 -0400 (AST) +Received: from hotmail.com (bay8-f118.bay8.hotmail.com [64.4.27.118]) + by svr1.postgresql.org (Postfix) with ESMTP id F15EAD1EA68 + for ; + Mon, 29 Mar 2004 13:05:02 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Mon, 29 Mar 2004 09:05:00 -0800 +Received: from 69.65.137.210 by by8fd.bay8.hotmail.msn.com with HTTP; + Mon, 29 Mar 2004 17:05:00 GMT +X-Originating-IP: [69.65.137.210] +X-Originating-Email: [el_vigia_ec@hotmail.com] +X-Sender: el_vigia_ec@hotmail.com +From: "Jaime Casanova" +To: pgsql-performance@postgresql.org +Subject: Re: column size too large, is this a bug? +Date: Mon, 29 Mar 2004 17:05:00 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +Message-ID: +X-OriginalArrivalTime: 29 Mar 2004 17:05:00.0475 (UTC) + FILETIME=[F86FC0B0:01C415AF] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/408 +X-Sequence-Number: 6264 + + +>Andrew, + +> > I used to use the connect-by patch, but have since rewritten everything +> > to use a nested set model. + +>Cool! You're probably the only person I know other than me using nested +>sets +>in a production environment. + + +can you explain me what is a nested set? + +_________________________________________________________________ +Add photos to your messages with MSN 8. Get 2 months FREE*. +http://join.msn.com/?page=features/featuredemail + + +From pgsql-performance-owner@postgresql.org Mon Mar 29 13:24:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 34E27D1EAB6 + for ; + Mon, 29 Mar 2004 17:23: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 83342-10 + for ; + Mon, 29 Mar 2004 13:23:55 -0400 (AST) +Received: from secure.icanx.com (secure.icanx.com [64.246.58.55]) + by svr1.postgresql.org (Postfix) with ESMTP id C82B8D1EAB5 + for ; + Mon, 29 Mar 2004 13:23:54 -0400 (AST) +Received: from 63-229-201-197.mpls.qwest.net ([63.229.201.197] + helo=[192.168.2.102]) by secure.icanx.com with esmtp (Exim 4.24) + id 1B80UM-0002GL-Oo + for pgsql-performance@postgresql.org; Mon, 29 Mar 2004 12:23:54 -0500 +Mime-Version: 1.0 (Apple Message framework v613) +In-Reply-To: <1117.1080574597@sss.pgh.pa.us> +References: + + <62945.200.174.148.100.1080383917.squirrel@webmail.webnow.com.br> + <200403281124.43275.josh@agliodbs.com> + <61715.200.174.148.100.1080557863.squirrel@webmail.webnow.com.br> + <1117.1080574597@sss.pgh.pa.us> +Content-Type: text/plain; charset=US-ASCII; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Mark Lubratt +Subject: Re: postgres eating CPU on HP9000 +Date: Mon, 29 Mar 2004 11:23:49 -0600 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.613) +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - secure.icanx.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] +X-AntiAbuse: Sender Address Domain - indeq.com +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/409 +X-Sequence-Number: 6265 + + +On Mar 29, 2004, at 9:36 AM, Tom Lane wrote: + +> "Marcus Andree S. Magalhaes" writes: +>>> Also do you run VACUUM ANALYZE as a superuser, or as a regular user? +> +>> As a regular user (database owner). Is thery any difference when +>> vacuuming +>> as a super user? +> +> That's your problem. A regular user won't have permissions to vacuum +> any tables but his own ... in particular, not the system tables. +> +> regards, tom lane + +If I vacuum as the superuser, are the system tables automatically +vacuumed? Or, does using -a from the vacuumdb command accomplish this? + Or, is there something else I have to specify on the vacuumdb command +line? + +Thanks! +Mark + + +From pgsql-performance-owner@postgresql.org Mon Mar 29 13:24:19 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 979CED1EAA8 + for ; + Mon, 29 Mar 2004 17:24: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 84643-10 + for ; + Mon, 29 Mar 2004 13:24:17 -0400 (AST) +Received: from steelhead.ravensfield.com (unknown [65.222.52.254]) + by svr1.postgresql.org (Postfix) with ESMTP id 703D9D1EAB2 + for ; + Mon, 29 Mar 2004 13:24:15 -0400 (AST) +Received: from [10.1.1.7] (smallmouth.oh.ia [10.1.1.7]) + by steelhead.ravensfield.com (Postfix) with ESMTP + id B1D0A66145; Mon, 29 Mar 2004 12:24:14 -0500 (EST) +In-Reply-To: +References: +Mime-Version: 1.0 (Apple Message framework v613) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <1692C8F2-81A6-11D8-B278-000393A47FCC@ravensfield.com> +Content-Transfer-Encoding: 7bit +Cc: pgsql-performance@postgresql.org +From: Andrew Rawnsley +Subject: Re: column size too large, is this a bug? +Date: Mon, 29 Mar 2004 12:25:35 -0500 +To: "Jaime Casanova" +X-Mailer: Apple Mail (2.613) +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/410 +X-Sequence-Number: 6266 + + +Its a way of representing a tree with right-left pointers in each +record (basically re-inventing a hierarchical database +in a relational model...). A good description is in Joe Celko's SQL +For Smarties book. Selection is very fast because +any node's children have node ID's between the right and left nodes of +said node, so there's no mucking about +with connect by and what not. There's a synopsis linked at the PG +Cookbook pages (http://www.brasileiro.net/postgres/cookbook), +but the cookbook seems to off-line (I think I'll offer to mirror it - +this happens frequently). There's another description at +http://www.intelligententerprise.com/001020/celko.jhtml? +_requestid=65750. + +Insertion takes a fair amount of work, as you generally have to +re-arrange the node IDs when you add a record. + +On Mar 29, 2004, at 12:05 PM, Jaime Casanova wrote: + +> +>> Andrew, +> +>> > I used to use the connect-by patch, but have since rewritten +>> everything +>> > to use a nested set model. +> +>> Cool! You're probably the only person I know other than me using +>> nested sets +>> in a production environment. +> +> +> can you explain me what is a nested set? +> +> _________________________________________________________________ +> Add photos to your messages with MSN 8. Get 2 months FREE*. +> http://join.msn.com/?page=features/featuredemail +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faqs/FAQ.html +> +-------------------- + +Andrew Rawnsley +President +The Ravensfield Digital Resource Group, Ltd. +(740) 587-0114 +www.ravensfield.com + + +From pgsql-performance-owner@postgresql.org Mon Mar 29 13:41:32 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E16A4D1E90D + for ; + Mon, 29 Mar 2004 17:29: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 89503-04 + for ; + Mon, 29 Mar 2004 13:29:11 -0400 (AST) +Received: from hotmail.com (bay8-f37.bay8.hotmail.com [64.4.27.37]) + by svr1.postgresql.org (Postfix) with ESMTP id 9BE60D1EA91 + for ; + Mon, 29 Mar 2004 13:29:10 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Mon, 29 Mar 2004 09:29:10 -0800 +Received: from 69.65.137.210 by by8fd.bay8.hotmail.msn.com with HTTP; + Mon, 29 Mar 2004 17:29:10 GMT +X-Originating-IP: [69.65.137.210] +X-Originating-Email: [el_vigia_ec@hotmail.com] +X-Sender: el_vigia_ec@hotmail.com +From: "Jaime Casanova" +To: pgsql-performance@postgresql.org +Subject: Re: column size too large, is this a bug? +Date: Mon, 29 Mar 2004 17:29:10 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +Message-ID: +X-OriginalArrivalTime: 29 Mar 2004 17:29:10.0567 (UTC) + FILETIME=[58C23B70:01C415B3] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/412 +X-Sequence-Number: 6268 + +thanx a lot + +_________________________________________________________________ +STOP MORE SPAM with the new MSN 8 and get 2 months FREE* +http://join.msn.com/?page=features/junkmail + + +From pgsql-performance-owner@postgresql.org Mon Mar 29 13:36:50 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 94567D1EA9F + for ; + Mon, 29 Mar 2004 17:33: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 92910-03 + for ; + Mon, 29 Mar 2004 13:33:11 -0400 (AST) +Received: from wolff.to (wolff.to [66.93.249.74]) + by svr1.postgresql.org (Postfix) with SMTP id 19A5DD1EAB6 + for ; + Mon, 29 Mar 2004 13:33:10 -0400 (AST) +Received: (qmail 6317 invoked by uid 500); 29 Mar 2004 17:36:23 -0000 +Date: Mon, 29 Mar 2004 11:36:23 -0600 +From: Bruno Wolff III +To: Fabio Esposito +Cc: Tom Lane , + "Marcus Andree S. Magalhaes" , + josh@agliodbs.com, scott.marlowe@ihs.com, pgsql-performance@postgresql.org +Subject: Re: postgres eating CPU on HP9000 +Message-ID: <20040329173623.GA6303@wolff.to> +Mail-Followup-To: Fabio Esposito , + Tom Lane , + "Marcus Andree S. Magalhaes" , + josh@agliodbs.com, scott.marlowe@ihs.com, + pgsql-performance@postgresql.org +References: <1117.1080574597@sss.pgh.pa.us> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.6i +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/411 +X-Sequence-Number: 6267 + +On Mon, Mar 29, 2004 at 12:00:16 -0500, + Fabio Esposito wrote: +> +> I'm sorry all, when you say regular user as opposed to superuser are you +> talking about the user that postgres is installed and running as? Should +> this be done as the os's root? + +The os user used for creating the cluster with initdb is a superuser. +Any accounts created with the permission to create more users are also +superusers. + +From pgsql-performance-owner@postgresql.org Mon Mar 29 15:13:36 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6766CD1C516 + for ; + Mon, 29 Mar 2004 19:13: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 34370-06 + for ; + Mon, 29 Mar 2004 15:13:30 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id C6BC9D1C50B + for ; + Mon, 29 Mar 2004 15:13:28 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4726784; Mon, 29 Mar 2004 11:14:46 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Andrew Rawnsley , + "Jaime Casanova" +Subject: Re: column size too large, is this a bug? +Date: Mon, 29 Mar 2004 11:12:52 -0800 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: + <1692C8F2-81A6-11D8-B278-000393A47FCC@ravensfield.com> +In-Reply-To: <1692C8F2-81A6-11D8-B278-000393A47FCC@ravensfield.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403291112.52106.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/413 +X-Sequence-Number: 6269 + +Andrew, + +> Its a way of representing a tree with right-left pointers in each +> record (basically re-inventing a hierarchical database +> in a relational model...). A good description is in Joe Celko's SQL +> For Smarties book. Selection is very fast because +> any node's children have node ID's between the right and left nodes of +> said node, so there's no mucking about +> with connect by and what not. There's a synopsis linked at the PG +> Cookbook pages (http://www.brasileiro.net/postgres/cookbook), +> but the cookbook seems to off-line (I think I'll offer to mirror it - +> this happens frequently). There's another description at +> http://www.intelligententerprise.com/001020/celko.jhtml? +> _requestid=65750. + +I have a full implementation of this. I was going to do it as a magazine +article, so I've been holding it off line. However, publication seems to be +indefinitely delayed, so I'll probably post it on TechDocs as soon as I have +time. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Mon Mar 29 15:15:26 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9ACF5D1B893 + for ; + Mon, 29 Mar 2004 19:15: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 38835-02 + for ; + Mon, 29 Mar 2004 15:15:20 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id B9074D1EA84 + for ; + Mon, 29 Mar 2004 15:15:18 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4726805; Mon, 29 Mar 2004 11:16:37 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Fabio Esposito +Subject: Re: postgres eating CPU on HP9000 +Date: Mon, 29 Mar 2004 11:14:47 -0800 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403291114.47932.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/414 +X-Sequence-Number: 6270 + +Fabio, + +> We run VACUUM ANALYZE after we remove about 1000 rows every hour on the +> halh hour. Our max_fsm_pages is set to 10000 + +Have you checked how long these vacuums take? If they are starting to +overlap, that would explain your high CPU usage and poor performance. You +might want to consider raising FSM_pages and vacuuming less frequently. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Mon Mar 29 15:40:27 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 80A54D1CCD1 + for ; + Mon, 29 Mar 2004 19:40: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 49243-03 + for ; + Mon, 29 Mar 2004 15:40:22 -0400 (AST) +Received: from sourceweave.net (CPE004f49016802-CM.cpe.net.cable.rogers.com + [24.43.140.53]) + by svr1.postgresql.org (Postfix) with SMTP id 5E33FD1CB21 + for ; + Mon, 29 Mar 2004 15:40:20 -0400 (AST) +Received: (qmail 25505 invoked by uid 1000); 29 Mar 2004 19:36:24 -0000 +Received: from localhost (sendmail-bs@127.0.0.1) + by localhost with SMTP; 29 Mar 2004 19:36:24 -0000 +Date: Mon, 29 Mar 2004 14:36:24 -0500 (EST) +From: Fabio Esposito +X-X-Sender: nfesposi@cr818510-a.basement +To: Josh Berkus +Cc: pgsql-performance@postgresql.org +Subject: Re: postgres eating CPU on HP9000 +In-Reply-To: <200403291114.47932.josh@agliodbs.com> +Message-ID: +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/415 +X-Sequence-Number: 6271 + + + +The Vacuum's don't take too long, 10 minutes at most. I can tell from ps +-ef | grep and top that its the selects/inserts/updates from the postgres +related to our app that take all that time up. If we rerun initdb and +reload the data, it works great for about two days, then goes bad again. + +We are in the process of trying out 7.4.2 right now, just waiting on the +reload of pg_dump. + +Fabio + +> Fabio, +> +> > We run VACUUM ANALYZE after we remove about 1000 rows every hour on the +> > halh hour. Our max_fsm_pages is set to 10000 +> +> Have you checked how long these vacuums take? If they are starting to +> overlap, that would explain your high CPU usage and poor performance. You +> might want to consider raising FSM_pages and vacuuming less frequently. +> +> -- +> -Josh Berkus +> Aglio Database Solutions +> San Francisco +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: you can get off all lists at once with the unregister command +> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) +> + + +From pgsql-performance-owner@postgresql.org Mon Mar 29 16:24:03 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 93609D1EA82 + for ; + Mon, 29 Mar 2004 20: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 63889-10 + for ; + Mon, 29 Mar 2004 16:24:00 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 3CA46D1EA4B + for ; + Mon, 29 Mar 2004 16:23:58 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4727200; Mon, 29 Mar 2004 12:25:19 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Fabio Esposito +Subject: Re: postgres eating CPU on HP9000 +Date: Mon, 29 Mar 2004 12:23:27 -0800 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403291223.27213.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/416 +X-Sequence-Number: 6272 + +Fabio, + +> The Vacuum's don't take too long, 10 minutes at most. I can tell from ps +> -ef | grep and top that its the selects/inserts/updates from the postgres +> related to our app that take all that time up. If we rerun initdb and +> reload the data, it works great for about two days, then goes bad again. +> +> We are in the process of trying out 7.4.2 right now, just waiting on the +> reload of pg_dump. + +Well, test running VACUUM ANALYZE as the "postgres" superuser and see if that +fixes the issue. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Mon Mar 29 17:59:07 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 85AF6D1EA9F + for ; + Mon, 29 Mar 2004 21:56: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 08032-07 + for ; + Mon, 29 Mar 2004 17:56:13 -0400 (AST) +Received: from hotmail.com (bay8-f74.bay8.hotmail.com [64.4.27.74]) + by svr1.postgresql.org (Postfix) with ESMTP id 9D0AAD1E93D + for ; + Mon, 29 Mar 2004 17:56:10 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Mon, 29 Mar 2004 13:56:10 -0800 +Received: from 69.65.137.210 by by8fd.bay8.hotmail.msn.com with HTTP; + Mon, 29 Mar 2004 21:56:10 GMT +X-Originating-IP: [69.65.137.210] +X-Originating-Email: [el_vigia_ec@hotmail.com] +X-Sender: el_vigia_ec@hotmail.com +From: "Jaime Casanova" +To: pgsql-performance@postgresql.org +Subject: Re: [ADMIN] Raw vs Filesystem +Date: Mon, 29 Mar 2004 21:56:10 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +Message-ID: +X-OriginalArrivalTime: 29 Mar 2004 21:56:10.0856 (UTC) + FILETIME=[A5985680:01C415D8] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/417 +X-Sequence-Number: 6273 + +ok. if i don't misunderstand you (english is not my mother tongue, so i can +be wrong). your point is that speed is not necesarily performance, that's +right. + +so, the real question is what is the best filesystem for optimal speed in +postgresql? + +_________________________________________________________________ +MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. +http://join.msn.com/?page=features/virus + + +From pgsql-performance-owner@postgresql.org Tue Mar 30 04:23:06 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0BBF8D1EB81 + for ; + Tue, 30 Mar 2004 08:22: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 25459-06 + for ; + Tue, 30 Mar 2004 04:22:53 -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 58286D1E9AD + for ; + Tue, 30 Mar 2004 04:22:49 -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 1B8EWE-0001Ns-0Y; Tue, 30 Mar 2004 09:22:46 +0100 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 082E416716; Tue, 30 Mar 2004 09:22:45 +0100 (BST) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 195601670F; Tue, 30 Mar 2004 09:22:43 +0100 (BST) +From: Richard Huxton +To: "Jaime Casanova" , + pgsql-performance@postgresql.org +Subject: Re: [ADMIN] Raw vs Filesystem +Date: Tue, 30 Mar 2004 09:22:42 +0100 +User-Agent: KMail/1.5 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403300922.42448.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: 200403/418 +X-Sequence-Number: 6274 + +On Monday 29 March 2004 22:56, Jaime Casanova wrote: +> ok. if i don't misunderstand you (english is not my mother tongue, so i can +> be wrong). your point is that speed is not necesarily performance, that's +> right. +> +> so, the real question is what is the best filesystem for optimal speed in +> postgresql? + +That's going to depend on a number of things: + +1. Size of database +2. Usage patterns (many updates or mostly reads? single user or many?...) +3. What hardware you've got +4. What OS you're running. +5. How you've configured your hardware, OS and PG. + +There are some test results people have provided in the archives, but whether +they apply to your setup is open to argument. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Mar 30 10:10:54 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 511DED1EC62 + for ; + Tue, 30 Mar 2004 14:10:53 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 73002-07 + for ; + Tue, 30 Mar 2004 10:09:30 -0400 (AST) +Received: from www.postgresql.com (www.postgresql.com [200.46.204.209]) + by svr1.postgresql.org (Postfix) with ESMTP id ACF89D1EC69 + for ; + Tue, 30 Mar 2004 10:09:21 -0400 (AST) +Received: from mail.dsvr.co.uk (mail.dsvr.co.uk [212.69.192.8]) + by www.postgresql.com (Postfix) with ESMTP id C9112CF5546 + for ; + Tue, 30 Mar 2004 10:09:14 -0400 (AST) +Received: from [212.69.216.20] (helo=dsvr.net) + by mail.dsvr.co.uk with esmtp (Exim 4.30) id 1B8IlJ-0002nV-M6 + for pgsql-performance@postgresql.org; Tue, 30 Mar 2004 13:54:37 +0100 +Message-ID: <40696E0C.9000303@dsvr.net> +Date: Tue, 30 Mar 2004 13:54:36 +0100 +From: Rob Fielding +User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040322 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Cleanup query takes along time +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: 200403/419 +X-Sequence-Number: 6275 + +Hi, + +Can someone provide some insight for me as to why this query takes so +long on 6655 rows of data. I'm beginning to think something is seriously +wrong with my config wrt to memory settings. I note vmstats (at the +bottom) indicates no swapping so I'm not running out system wide but I +don't know whether I am within postgres. + +sql> explain ANALYZE SELECT MIN(ref), h_message_id, COUNT(h_message_id) +FROM mail_969 GROUP BY h_message_id HAVING COUNT(h_message_id) > 25; + +Aggregate (cost=85031.01..87894.10 rows=28631 width=44) (actual +time=185449.57..185449.57 rows=0 loops=1) + -> Group (cost=85031.01..85746.78 rows=286309 width=44) (actual +time=185374.92..185413.32 rows=6655 loops=1) + -> Sort (cost=85031.01..85031.01 rows=286309 width=44) +(actual time=185374.91..185379.23 rows=6655 loops=1) + -> Seq Scan on mail_969 (cost=0.00..59081.09 +rows=286309 width=44) (actual time=179.65..185228.19 rows=6655 loops=1) +Total runtime: 185451.08 msec + +To put this into perspective, we see similar results on a table with +over 300,000 rows : + +sql> explain ANALYZE SELECT MIN(ref), h_message_id, COUNT(h_message_id) +FROM mail_650 GROUP BY h_message_id HAVING COUNT(h_message_id) > 25; +NOTICE: QUERY PLAN: + +Aggregate (cost=88503.85..91596.83 rows=30930 width=48) (actual +time=142483.52..149102.57 rows=244 loops=1) + -> Group (cost=88503.85..89277.10 rows=309298 width=48) (actual +time=142444.19..148477.99 rows=309245 loops=1) + -> Sort (cost=88503.85..88503.85 rows=309298 width=48) +(actual time=142444.17..142652.83 rows=309245 loops=1) + -> Seq Scan on mail_650 (cost=0.00..60297.98 +rows=309298 width=48) (actual time=445.75..105818.97 rows=309245 loops=1) +Total runtime: 149181.30 msec + +These selects are part of a cleanup operation on a 70GB DB (normal +conditions are around 25GB). They find dupes, preserve one primary key, +and delete the rest. Currently I have an issue that the DB requires a +full vacuum from prior runs of the above however this is another +problem, detailed on the 'admin' list. + +Perhaps this is due to the dataset still being so big (70GB) on +effectively one disk, but I just thought I'd check with you guys. + +Hardware: + +1GB Ram, SMP 1GHz P3, SvrWks OSB4 chipset, Adaptec aic7899 with 2 +SCSI-160 disks split between DB and pg_xlog. (I know disks should be +better laid out for a busy db, but this hasn't been my decision :) + +Config: + +max_fsm_relations = 1000 +max_fsm_pages = 20000 +vacuum_mem = 65536 +effective_cache_size = 95694 +random_page_cost = 2 +sort_mem=65536 +max_connections = 128 +shared_buffers = 15732 +wal_buffers = 64 # need to determin +wal_files = 64 # range 0-64 +wal_sync_method = fsync # the default varies across platforms: +wal_debug = 0 # range 0-16 + + +# hopefully this should see less LogFlushes per LogInsert - use more WAL +though. +commit_delay = 10000 # range 0-100000 +commit_siblings = 2 # range 1-1000 + + +checkpoint_segments = 32 # in logfile segments (16MB each), min 1 +checkpoint_timeout = 600 # in seconds, range 30-3600 +fsync = false +#fsync = true + + +vmstats whilst running (indicating no swaping) : + + procs memory swap io system + cpu + r b w swpd free buff cache si so bi bo in cs us + sy id + 1 2 1 45592 10868 11028 853700 0 0 7 3 1 0 5 + 5 7 + 2 2 0 45592 10288 11236 849312 8 0 732 888 1980 3516 63 + 12 26 + 8 2 0 45592 11208 11304 849224 0 0 4438 286 2696 3758 66 + 15 19 +10 2 3 45592 10284 11332 848872 0 0 6344 664 2888 3614 71 + 18 11 + 2 8 1 45592 10408 11388 845140 0 0 4622 402 2216 2306 70 + 11 19 + 3 7 2 45592 10416 11440 845972 0 0 3538 68 2052 2079 66 + 9 25 +10 5 1 45592 10916 11496 846676 0 0 4428 444 2968 4385 75 + 17 8 + 2 4 0 45592 10380 11592 848348 0 0 5940 184 2609 3421 69 + 15 16 + +Cheers, + +-- + +Rob Fielding +rob@dsvr.net + +www.dsvr.co.uk Development Designer Servers Ltd + +From pgsql-performance-owner@postgresql.org Tue Mar 30 12:53:40 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 69FF5D1CCAD + for ; + Tue, 30 Mar 2004 16:27: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 56127-01 + for ; + Tue, 30 Mar 2004 12:27:25 -0400 (AST) +Received: from lakemtai06.cox.net (lakemtai06.cox.net [68.1.17.126]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CECFD1E929 + for ; + Tue, 30 Mar 2004 12:27:18 -0400 (AST) +Received: from [192.168.0.13] ([68.105.165.18]) by lakemtao02.cox.net + (InterMail vM.5.01.06.08 201-253-122-130-108-20031117) with ESMTP + id <20040330142030.SFQB13694.lakemtao02.cox.net@[192.168.0.13]>; + Tue, 30 Mar 2004 09:20:30 -0500 +From: Robert Treat +To: Josh Berkus , + Andrew Rawnsley , Qing Zhao +Subject: Re: column size too large, is this a bug? +Date: Tue, 30 Mar 2004 09:20:27 -0500 +User-Agent: KMail/1.5 +Cc: Tom Lane , + Stephan Szabo , + pgsql-performance@postgresql.org +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <8B3A05B5-7F51-11D8-93F3-000393A47FCC@ravensfield.com> + <200403281125.41590.josh@agliodbs.com> +In-Reply-To: <200403281125.41590.josh@agliodbs.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403300920.27739.xzilla@users.sourceforge.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/422 +X-Sequence-Number: 6278 + +On Sunday 28 March 2004 14:25, Josh Berkus wrote: +> Andrew, +> +> > I used to use the connect-by patch, but have since rewritten everything +> > to use a nested set model. +> +> Cool! You're probably the only person I know other than me using nested +> sets in a production environment. + +You cut me deep there Josh, real deep. :-) + +If you search the pgsql-sql archives you'll find some helpful threads on using +nested sets in PostgreSQL, one in particular I was involved with was a +generic "move_tree" function that enabled moving a node from one branch to +another. + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + +From pgsql-performance-owner@postgresql.org Tue Mar 30 12:48:46 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D4F3FD1D104 + for ; + Tue, 30 Mar 2004 16:39: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 59141-04 + for ; + Tue, 30 Mar 2004 12:39:39 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 7D66CD1CCCA + for ; + Tue, 30 Mar 2004 12:39:37 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4732798; Tue, 30 Mar 2004 08:40:52 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Robert Treat , + Andrew Rawnsley +Subject: Re: Nested Sets WAS: column size too large, is this a bug? +Date: Tue, 30 Mar 2004 08:38:50 -0800 +User-Agent: KMail/1.4.3 +Cc: pgsql-performance@postgresql.org +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <200403281125.41590.josh@agliodbs.com> + <200403300920.27739.xzilla@users.sourceforge.net> +In-Reply-To: <200403300920.27739.xzilla@users.sourceforge.net> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200403300838.50538.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/421 +X-Sequence-Number: 6277 + +Robert, + +> If you search the pgsql-sql archives you'll find some helpful threads on +> using nested sets in PostgreSQL, one in particular I was involved with was +> a generic "move_tree" function that enabled moving a node from one branch +> to another. + +I have to admit to failing to follow -SQL over the last few months. This +list and Hackers are pretty much the only ones I read all of. + +Maybe I should get back on -SQL and we can compare move_tree functions :-) + +Did yours use a temp table, or some other means? + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Mar 30 12:44:13 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D010D1C4C3 + for ; + Tue, 30 Mar 2004 16:44:02 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 60112-05 + for ; + Tue, 30 Mar 2004 12:43:55 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 2CC18D1E9DC + for ; + Tue, 30 Mar 2004 12:43:54 -0400 (AST) +Received: from [63.195.55.98] (HELO spooky) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4732815; Tue, 30 Mar 2004 08:45:03 -0800 +Content-Type: text/plain; + charset="iso-8859-1" +From: Josh Berkus +Organization: Aglio Database Solutions +To: Richard Huxton , + "Jaime Casanova" , + pgsql-performance@postgresql.org +Subject: Re: [ADMIN] Raw vs Filesystem +Date: Tue, 30 Mar 2004 08:43:01 -0800 +User-Agent: KMail/1.4.3 +References: + <200403300922.42448.dev@archonet.com> +In-Reply-To: <200403300922.42448.dev@archonet.com> +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-Id: <200403300843.01437.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/420 +X-Sequence-Number: 6276 + +Jaime, Richard, + +> That's going to depend on a number of things: +> There are some test results people have provided in the archives, but +> whether they apply to your setup is open to argument. + +True. On Linux overall, XFS, JFS, and Reiser have all looked good at one time +or another. Ext3 has never been a leader for performance, though, so that's +an easy elimination. + +-- +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Tue Mar 30 13:36:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 21C70D1D2DD + for ; + Tue, 30 Mar 2004 17:29: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 83375-04 + for ; + Tue, 30 Mar 2004 13:29:06 -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 CD02DD1B441 + for ; + Tue, 30 Mar 2004 13:29:05 -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 1B8N2u-000KrC-0Z; Tue, 30 Mar 2004 18:29:04 +0100 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 36AC416E24; Tue, 30 Mar 2004 18:29:02 +0100 (BST) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 0B91016711; Tue, 30 Mar 2004 18:29:00 +0100 (BST) +From: Richard Huxton +To: Josh Berkus , + "Jaime Casanova" , + pgsql-performance@postgresql.org +Subject: Re: [ADMIN] Raw vs Filesystem +Date: Tue, 30 Mar 2004 18:28:59 +0100 +User-Agent: KMail/1.5 +References: + <200403300922.42448.dev@archonet.com> + <200403300843.01437.josh@agliodbs.com> +In-Reply-To: <200403300843.01437.josh@agliodbs.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403301828.59498.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: 200403/423 +X-Sequence-Number: 6279 + +On Tuesday 30 March 2004 17:43, Josh Berkus wrote: +> Jaime, Richard, +> +> > That's going to depend on a number of things: +> > There are some test results people have provided in the archives, but +> > whether they apply to your setup is open to argument. +> +> True. On Linux overall, XFS, JFS, and Reiser have all looked good at one +> time or another. Ext3 has never been a leader for performance, though, so +> that's an easy elimination. + +True, but on the sorts of commodity boxes I use, it doesn't make sense for me +to waste time setting up non-standard filesystems - it's cheaper to spend a +little more for better performance. I think SuSE offer Reiser though, so +maybe we'll see a wider selection available by default. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Tue Mar 30 15:25:44 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 641EAD1B4AC + for ; + Tue, 30 Mar 2004 19:25: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 44599-07 + for ; + Tue, 30 Mar 2004 15:25:42 -0400 (AST) +Received: from hotmail.com (bay8-f81.bay8.hotmail.com [64.4.27.81]) + by svr1.postgresql.org (Postfix) with ESMTP id D0D25D1B44D + for ; + Tue, 30 Mar 2004 15:25:39 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Tue, 30 Mar 2004 11:25:40 -0800 +Received: from 207.13.118.180 by by8fd.bay8.hotmail.msn.com with HTTP; + Tue, 30 Mar 2004 19:25:40 GMT +X-Originating-IP: [207.13.118.180] +X-Originating-Email: [el_vigia_ec@hotmail.com] +X-Sender: el_vigia_ec@hotmail.com +From: "Jaime Casanova" +To: pgsql-performance@postgresql.org +Subject: select slow? +Date: Tue, 30 Mar 2004 19:25:40 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +Message-ID: +X-OriginalArrivalTime: 30 Mar 2004 19:25:40.0278 (UTC) + FILETIME=[C95D3D60:01C4168C] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/424 +X-Sequence-Number: 6280 + +hi all, + + +i have an amd athlon with 256 ram (i know, this is not a *real* server but +my tables are small) + +i'm using vb6 (win98) with pgsql-7.3.4 (rh8) trough the psqlodbc. + +when i do a select in took long to execute, here is an example + + +table icc_m_banco + +CREATE TABLE ICC_M_BANCO ( + CodBanco SMALLINT NOT NULL, + Descripcion CHARACTER VARYING(60) NOT NULL, + RefContable NUMERIC, + Estado CHAR(1) NOT NULL, + FecRegistro DATE NOT NULL, + CONSTRAINT EstadoBanco CHECK ((Estado = 'A') or (Estado = 'I')), + PRIMARY KEY(CodBanco) +); + + +select * from icc_m_banco where codbanco = 1; + +it tooks 13s from it's send until it's executed. + + + +explain analyze give me this result: + +explain analyze +select * from icc_m_banco where codbanco = 1; + + +Seq Scan on icc_m_banco (cost=0.00..1.06 rows=6 width=41) (actual +time=7.94..7.96 rows=4 loops=1) +Total runtime: 63.37 msec +(2 rows) + + +so i think its not a database problem (at least it's not all the problem), +though it seems to me it is taking a lot of time executing this. + + +am i right? any suggestions? + +_________________________________________________________________ +Help STOP SPAM with the new MSN 8 and get 2 months FREE* +http://join.msn.com/?page=features/junkmail + + +From pgsql-performance-owner@postgresql.org Tue Mar 30 15:39:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 492D4D1B493 + for ; + Tue, 30 Mar 2004 19:39: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 56472-04 + for ; + Tue, 30 Mar 2004 15:39:30 -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 A2311D1E0F0 + for ; + Tue, 30 Mar 2004 15:39:25 -0400 (AST) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) + id 1B8P53-0005NW-0Z; Tue, 30 Mar 2004 20:39:25 +0100 +Date: Tue, 30 Mar 2004 20:39:21 +0100 +From: Paul Thomas +To: Jaime Casanova +Cc: "pgsql-performance @ postgresql . org" +Subject: Re: select slow? +Message-ID: <20040330203921.A16296@bacon> +References: +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: ; + from el_vigia_ec@hotmail.com on Tue, Mar 30, 2004 at 20:25:40 + +0100 +X-Mailer: Balsa 1.2.3 +Lines: 40 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/425 +X-Sequence-Number: 6281 + + +On 30/03/2004 20:25 Jaime Casanova wrote: +> hi all, +> +> +> i have an amd athlon with 256 ram (i know, this is not a *real* server +> but my tables are small) +> +> i'm using vb6 (win98) with pgsql-7.3.4 (rh8) trough the psqlodbc. +> +> when i do a select in took long to execute, here is an example +> +> +> table icc_m_banco +> +> CREATE TABLE ICC_M_BANCO ( +> CodBanco SMALLINT NOT NULL, +> Descripcion CHARACTER VARYING(60) NOT NULL, +> RefContable NUMERIC, +> Estado CHAR(1) NOT NULL, +> FecRegistro DATE NOT NULL, +> CONSTRAINT EstadoBanco CHECK ((Estado = 'A') or (Estado = 'I')), +> PRIMARY KEY(CodBanco) +> ); +> +> +> select * from icc_m_banco where codbanco = 1; + +select * from icc_m_banco where codbanco = 1::int2; + + + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Tue Mar 30 16:06:15 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 377C1D1E8A5 + for ; + Tue, 30 Mar 2004 20:06: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 65568-06 + for ; + Tue, 30 Mar 2004 16:06:12 -0400 (AST) +Received: from lakemtao03.cox.net (lakemtao03.cox.net [68.1.17.242]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D195D1E7EE + for ; + Tue, 30 Mar 2004 16:06:10 -0400 (AST) +Received: from [192.168.0.13] ([68.105.165.18]) by lakemtao03.cox.net + (InterMail vM.5.01.06.08 201-253-122-130-108-20031117) with ESMTP + id <20040330200612.YKO27519.lakemtao03.cox.net@[192.168.0.13]>; + Tue, 30 Mar 2004 15:06:12 -0500 +From: Robert Treat +To: Josh Berkus , + Andrew Rawnsley +Subject: Re: Nested Sets WAS: column size too large, is this a bug? +Date: Tue, 30 Mar 2004 15:06:08 -0500 +User-Agent: KMail/1.5 +Cc: pgsql-performance@postgresql.org +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <200403300920.27739.xzilla@users.sourceforge.net> + <200403300838.50538.josh@agliodbs.com> +In-Reply-To: <200403300838.50538.josh@agliodbs.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403301506.08882.xzilla@users.sourceforge.net> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/426 +X-Sequence-Number: 6282 + +On Tuesday 30 March 2004 11:38, Josh Berkus wrote: +> Robert, +> +> > If you search the pgsql-sql archives you'll find some helpful threads on +> > using nested sets in PostgreSQL, one in particular I was involved with +> > was a generic "move_tree" function that enabled moving a node from one +> > branch to another. +> +> I have to admit to failing to follow -SQL over the last few months. This +> list and Hackers are pretty much the only ones I read all of. +> +> Maybe I should get back on -SQL and we can compare move_tree functions :-) +> +> Did yours use a temp table, or some other means? + +Nope, Greg Mullane and I worked out the math and came up with an algorithm of +sorts that we could apply to the tree when moving elements. + + +http://archives.postgresql.org/pgsql-sql/2002-11/msg00355.php + +Seemed to work though someone else had posted yet another version after +ours... and in fact the one posted is not exactly what I use now either :-) + +Robert Treat +-- +Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL + +From pgsql-performance-owner@postgresql.org Tue Mar 30 16:13:52 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DDCFED1E195 + for ; + Tue, 30 Mar 2004 20:13: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 66159-05 + for ; + Tue, 30 Mar 2004 16:13:49 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id DF032D1D58C + for ; + Tue, 30 Mar 2004 16:13:47 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4734093; Tue, 30 Mar 2004 12:15:07 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Robert Treat , + Andrew Rawnsley +Subject: Re: Nested Sets WAS: column size too large, is this a bug? +Date: Tue, 30 Mar 2004 12:13:12 -0800 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: <082D0538-7E86-11D8-8B9C-000A95AB8896@quotefx.net> + <200403300838.50538.josh@agliodbs.com> + <200403301506.08882.xzilla@users.sourceforge.net> +In-Reply-To: <200403301506.08882.xzilla@users.sourceforge.net> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403301213.12424.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/427 +X-Sequence-Number: 6283 + +Robert, + +> http://archives.postgresql.org/pgsql-sql/2002-11/msg00355.php +> +> Seemed to work though someone else had posted yet another version after +> ours... and in fact the one posted is not exactly what I use now either :-) + +Hmmm ... I'd want to do a *lot* of testing before I trusted that approach. +Seems like it could be very vunerable to order-of-exection issues. + +I'll start a GUIDE on it, people can post their various Nested Sets solutions. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Mar 30 16:59:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 9FF22D1D2B7 + for ; + Tue, 30 Mar 2004 20:59: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 90095-01 + for ; + Tue, 30 Mar 2004 16:59:26 -0400 (AST) +Received: from hosting.commandprompt.com (138.commandprompt.com + [207.173.200.138]) + by svr1.postgresql.org (Postfix) with ESMTP id 2C9DCD1D148 + for ; + Tue, 30 Mar 2004 16:59:24 -0400 (AST) +Received: from commandprompt.com (dsl093-038-087.pdx1.dsl.speakeasy.net + [66.93.38.87]) (authenticated) + by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id i2UKxJq23654; + Tue, 30 Mar 2004 12:59:19 -0800 +Message-ID: <4069DFA1.50109@commandprompt.com> +Date: Tue, 30 Mar 2004 12:59:13 -0800 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mozilla Thunderbird 0.5 (X11/20040208) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Richard Huxton +Cc: Josh Berkus , Jaime Casanova , + pgsql-performance@postgresql.org +Subject: Re: [ADMIN] Raw vs Filesystem +References: + <200403300922.42448.dev@archonet.com> + <200403300843.01437.josh@agliodbs.com> + <200403301828.59498.dev@archonet.com> +In-Reply-To: <200403301828.59498.dev@archonet.com> +Content-Type: multipart/mixed; boundary="------------050105080206010601010707" +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/428 +X-Sequence-Number: 6284 + +This is a multi-part message in MIME format. +--------------050105080206010601010707 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit + +> +> True, but on the sorts of commodity boxes I use, it doesn't make sense for me +> to waste time setting up non-standard filesystems - it's cheaper to spend a +> little more for better performance. I think SuSE offer Reiser though, so +> maybe we'll see a wider selection available by default. + +SuSE defaults to Reiser but also allows XFS. I would suggest XFS. + +Sincerely, + +Joshua D. Drake + + + +> + + +-- +Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC +Postgresql support, programming shared hosting and dedicated hosting. ++1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com +Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL + +--------------050105080206010601010707 +Content-Type: text/x-vcard; charset=utf8; + name="jd.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="jd.vcf" + +begin:vcard +fn:Joshua D. Drake +n:Drake;Joshua D. +org:Command Prompt, Inc. +adr:;;PO Box 215;Cascade Locks;Oregon;97014;USA +email;internet:jd@commandprompt.com +title:Consultant +tel;work:503-667-4564 +tel;fax:503-210-0034 +note:Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. +x-mozilla-html:FALSE +url:http://www.commandprompt.com/ +version:2.1 +end:vcard + + +--------------050105080206010601010707-- + +From pgsql-performance-owner@postgresql.org Tue Mar 30 17:53:30 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B2B80D1E914 + for ; + Tue, 30 Mar 2004 21:53: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 02579-08 + for ; + Tue, 30 Mar 2004 17:53:26 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 7DDCBD1E8AB + for ; + Tue, 30 Mar 2004 17:53:23 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4734711; Tue, 30 Mar 2004 13:54:31 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: "Joshua D. Drake" , + Richard Huxton +Subject: Re: [ADMIN] Raw vs Filesystem +Date: Tue, 30 Mar 2004 13:52:35 -0800 +User-Agent: KMail/1.5.4 +Cc: Jaime Casanova , pgsql-performance@postgresql.org +References: + <200403301828.59498.dev@archonet.com> + <4069DFA1.50109@commandprompt.com> +In-Reply-To: <4069DFA1.50109@commandprompt.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403301352.35937.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/429 +X-Sequence-Number: 6285 + +Josh, + +> SuSE defaults to Reiser but also allows XFS. I would suggest XFS. + +I've found Reiser to perform very well for databases with many small tables. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Mar 30 19:06:55 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id B764ED1D179 + for ; + Tue, 30 Mar 2004 23:06: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 31451-06 + for ; + Tue, 30 Mar 2004 19:06:54 -0400 (AST) +Received: from palle.girgensohn.se (1-2-8-5a.asp.sth.bostream.se + [82.182.157.66]) + by svr1.postgresql.org (Postfix) with ESMTP id C2C21D1D16D + for ; + Tue, 30 Mar 2004 19:06:49 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by palle.girgensohn.se (8.12.11/8.12.11) with ESMTP id i2UN6mbV049180; + Wed, 31 Mar 2004 01:06:49 +0200 (CEST) + (envelope-from girgen@pingpong.net) +Date: Wed, 31 Mar 2004 01:06:48 +0200 +From: Palle Girgensohn +To: pgsql-performance@postgresql.org +Subject: LIKE should use index when condition doesn't include wildcard +Message-ID: <145170000.1080688008@palle.girgensohn.se> +X-Mailer: Mulberry/3.1.0 (Linux/x86) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/430 +X-Sequence-Number: 6286 + +Hi, + +Shouldn't the optimizer use indices if the like condition does not have any +wildcards? + +An example: + +girgen=# explain analyze select * from person where userid = 'girgen'; + QUERY PLAN + +--------------------------------------------------------------------------- +------------------------------------------ + Index Scan using person_pkey on person (cost=0.00..5.98 rows=1 width=84) +(actual time=0.034..0.039 rows=1 loops=1) + Index Cond: (userid = 'girgen'::text) + Total runtime: 0.091 ms +(3 rader) + +girgen=# explain analyze select * from person where userid like 'girgen'; + QUERY PLAN + +--------------------------------------------------------------------------- +----------------------- + Seq Scan on person (cost=0.00..77.08 rows=1 width=84) (actual +time=1.137..1.143 rows=1 loops=1) + Filter: (userid ~~ 'girgen'::text) + Total runtime: 1.193 ms +(3 rader) + +The result cannot be different between the two cases. The second query does +not use the index since database is initiaized with a locale, +sv_SE.ISO8859-1, and I need it for correct sorting. (Still dreaming about +indices with like and locale)... But, since there is no wildcard in the +string 'girgen', it should easily be able to use the index, if it only +bothered to note that there is a wildcard around, right? + + +Another thing on the same subject: + +I use an app that builds searches using some standard method, and it wants +to always search case-insensitive. Hence, it uses ILIKE instead of `=', +even for joins, and even for integers. This is a bit lazy, indeed, and also +wrong. While this is wrong, no doubt, the odd thing I realized was that +the optimizer didn't make use of the indices. Same thing here, the +optimizer should ideally know that it is dealing with integers, where ILIKE +and LIKE has no meaning, and it should use `=' instead implicitally, hence +using indices. This one might be kind of low priority, but the one above +really isn't, IMO. + +/Palle + + +From pgsql-performance-owner@postgresql.org Tue Mar 30 20:16:57 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 499BFD1E0FD + for ; + Wed, 31 Mar 2004 00:16:45 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 50033-08 + for ; + Tue, 30 Mar 2004 20:16:46 -0400 (AST) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 509D1D1DF1F + for ; + Tue, 30 Mar 2004 20:16:43 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2V0GiAO026841; + Tue, 30 Mar 2004 19:16:44 -0500 (EST) +To: Palle Girgensohn +Cc: pgsql-performance@postgresql.org +Subject: Re: LIKE should use index when condition doesn't include wildcard +In-reply-to: <145170000.1080688008@palle.girgensohn.se> +References: <145170000.1080688008@palle.girgensohn.se> +Comments: In-reply-to Palle Girgensohn + message dated "Wed, 31 Mar 2004 01:06:48 +0200" +Date: Tue, 30 Mar 2004 19:16:44 -0500 +Message-ID: <26840.1080692204@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/431 +X-Sequence-Number: 6287 + +Palle Girgensohn writes: +> Shouldn't the optimizer use indices if the like condition does not have any +> wildcards? + +I can't get excited about this; if you are depending on LIKE to be fast +then you should have locale-insensitive indexes in place to support it. +Switching the tests around so that this special case is supported even +with an index that doesn't otherwise support LIKE would complicate the +code unduly IMHO, to support a rather pointless corner case... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue Mar 30 20:28:39 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6D192D1DB5C + for ; + Wed, 31 Mar 2004 00:28: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 59364-06 + for ; + Tue, 30 Mar 2004 20:28:35 -0400 (AST) +Received: from palle.girgensohn.se (1-2-8-5a.asp.sth.bostream.se + [82.182.157.66]) + by svr1.postgresql.org (Postfix) with ESMTP id C4996D1DA69 + for ; + Tue, 30 Mar 2004 20:28:31 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by palle.girgensohn.se (8.12.11/8.12.11) with ESMTP id i2V0SVCh065407; + Wed, 31 Mar 2004 02:28:31 +0200 (CEST) + (envelope-from girgen@pingpong.net) +Date: Wed, 31 Mar 2004 02:28:31 +0200 +From: Palle Girgensohn +To: Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: LIKE should use index when condition doesn't include +Message-ID: <162280000.1080692911@palle.girgensohn.se> +In-Reply-To: <26840.1080692204@sss.pgh.pa.us> +References: <145170000.1080688008@palle.girgensohn.se> + <26840.1080692204@sss.pgh.pa.us> +X-Mailer: Mulberry/3.1.0 (Linux/x86) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/432 +X-Sequence-Number: 6288 + + + +--On tisdag, mars 30, 2004 19.16.44 -0500 Tom Lane +wrote: + +> Palle Girgensohn writes: +>> Shouldn't the optimizer use indices if the like condition does not have +>> any wildcards? +> +> I can't get excited about this; if you are depending on LIKE to be fast +> then you should have locale-insensitive indexes in place to support it. +> Switching the tests around so that this special case is supported even +> with an index that doesn't otherwise support LIKE would complicate the +> code unduly IMHO, to support a rather pointless corner case... + +OK, I agree. Sad, though, that throw away ability to use order by is the +only way to get index scans using LIKE... :( + +But what about ILIKE. It does not take advantage of indices built with +lower(): + +girgen=# create index person_foo on person (lower(last_name)); +girgen=# vacuum analyze person; +girgen=# explain select * from person where lower(last_name) = +'girgensohn'; + QUERY PLAN + +--------------------------------------------------------------------------- +-- + Index Scan using person_foo on person (cost=0.00..137.58 rows=78 width=96) + Index Cond: (lower(last_name) = 'girgensohn'::text) +(2 rows) + +girgen=# explain select * from person where last_name = 'Girgensohn'; + QUERY PLAN +--------------------------------------------------------- + Seq Scan on person (cost=0.00..441.35 rows=4 width=96) + Filter: (last_name = 'Girgensohn'::text) +(2 rows) + +girgen=# explain select * from person where lower(last_name) like +'girgen%'; + QUERY PLAN + +--------------------------------------------------------------------------- +------------------- + Index Scan using person_foo on person (cost=0.00..137.58 rows=78 width=96) + Index Cond: ((lower(last_name) >= 'girgen'::text) AND (lower(last_name) +< 'girgeo'::text)) + Filter: (lower(last_name) ~~ 'girgen%'::text) +(3 rows) + +girgen=# explain select * from person where last_name ilike 'girgen%'; + QUERY PLAN +--------------------------------------------------------- + Seq Scan on person (cost=0.00..441.35 rows=5 width=96) + Filter: (last_name ~~* 'girgen%'::text) +(2 rows) + + +postgresql 7.4.2, freebsd 4.9 stable. + + +/Palle + + +From pgsql-performance-owner@postgresql.org Tue Mar 30 20:56:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 3F26FD1E123 + for ; + Wed, 31 Mar 2004 00:56: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 66944-08 + for ; + Tue, 30 Mar 2004 20:56:41 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id 193E2D1E0F6 + for ; + Tue, 30 Mar 2004 20:56:38 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4735894; Tue, 30 Mar 2004 16:57:59 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Palle Girgensohn , + Tom Lane +Subject: Re: LIKE should use index when condition doesn't include +Date: Tue, 30 Mar 2004 16:56:09 -0800 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: <145170000.1080688008@palle.girgensohn.se> + <26840.1080692204@sss.pgh.pa.us> + <162280000.1080692911@palle.girgensohn.se> +In-Reply-To: <162280000.1080692911@palle.girgensohn.se> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403301656.09664.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/433 +X-Sequence-Number: 6289 + +Palle, + +> But what about ILIKE. It does not take advantage of indices built with +> lower(): + +Nope. If you want to use a functional index, you'll need to use the function +when you call the query. ILIKE is not somehow aware that it is equivalent +to lower(). + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Tue Mar 30 21:04:51 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 18E32D1DF5D + for ; + Wed, 31 Mar 2004 01:04: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 74020-02 + for ; + Tue, 30 Mar 2004 21:04:48 -0400 (AST) +Received: from palle.girgensohn.se (1-2-8-5a.asp.sth.bostream.se + [82.182.157.66]) + by svr1.postgresql.org (Postfix) with ESMTP id 68FFCD1DDF1 + for ; + Tue, 30 Mar 2004 21:04:44 -0400 (AST) +Received: from localhost (localhost [127.0.0.1]) + by palle.girgensohn.se (8.12.11/8.12.11) with ESMTP id i2V14emO083384; + Wed, 31 Mar 2004 03:04:40 +0200 (CEST) + (envelope-from girgen@pingpong.net) +Date: Wed, 31 Mar 2004 03:04:40 +0200 +From: Palle Girgensohn +To: josh@agliodbs.com, Tom Lane +Cc: pgsql-performance@postgresql.org +Subject: Re: LIKE should use index when condition doesn't include +Message-ID: <173500000.1080695080@palle.girgensohn.se> +In-Reply-To: <200403301656.09664.josh@agliodbs.com> +References: <145170000.1080688008@palle.girgensohn.se> + <26840.1080692204@sss.pgh.pa.us> + <162280000.1080692911@palle.girgensohn.se> + <200403301656.09664.josh@agliodbs.com> +X-Mailer: Mulberry/3.1.0 (Linux/x86) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/434 +X-Sequence-Number: 6290 + +--On tisdag, mars 30, 2004 16.56.09 -0800 Josh Berkus +wrote: + +> Palle, +> +>> But what about ILIKE. It does not take advantage of indices built with +>> lower(): +> +> Nope. If you want to use a functional index, you'll need to use the +> function when you call the query. ILIKE is not somehow aware that it +> is equivalent to lower(). + +Too bad... that was my idea, that it would somehow be aware that it is +equivalent to lower() like. It really is, isn't it? I would have though +they where synonymous. If not, makes ILIKE kind of unusable, at least +unless you're pretty certain the field will never indexed. + +/Palle + + +From pgsql-performance-owner@postgresql.org Tue Mar 30 21:08:14 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 548B9D1DB53 + for ; + Wed, 31 Mar 2004 01:07: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 74720-03 + for ; + Tue, 30 Mar 2004 21:07:27 -0400 (AST) +Received: from davinci.ethosmedia.com (server228.ethosmedia.com + [209.128.84.228]) + by svr1.postgresql.org (Postfix) with ESMTP id D538DD1DB0E + for ; + Tue, 30 Mar 2004 21:07:23 -0400 (AST) +Received: from [63.195.55.98] (HELO 192.168.1.29) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 4735956; Tue, 30 Mar 2004 17:08:45 -0800 +From: Josh Berkus +Reply-To: josh@agliodbs.com +Organization: Aglio Database Solutions +To: Palle Girgensohn , + Tom Lane +Subject: Re: LIKE should use index when condition doesn't include +Date: Tue, 30 Mar 2004 17:06:54 -0800 +User-Agent: KMail/1.5.4 +Cc: pgsql-performance@postgresql.org +References: <145170000.1080688008@palle.girgensohn.se> + <200403301656.09664.josh@agliodbs.com> + <173500000.1080695080@palle.girgensohn.se> +In-Reply-To: <173500000.1080695080@palle.girgensohn.se> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403301706.54067.josh@agliodbs.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/435 +X-Sequence-Number: 6291 + +Palle, + +> Too bad... that was my idea, that it would somehow be aware that it is +> equivalent to lower() like. It really is, isn't it? I would have though +> they where synonymous. If not, makes ILIKE kind of unusable, at least +> unless you're pretty certain the field will never indexed. + +Yup. I use it mostly for lookups in reference lists with < 100 items, where +an index doesn't matter. + +-- +-Josh Berkus + Aglio Database Solutions + San Francisco + + +From pgsql-performance-owner@postgresql.org Wed Mar 31 01:34:02 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id E63DCD1E31F + for ; + Wed, 31 Mar 2004 05:33: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 46408-03 + for ; + Wed, 31 Mar 2004 01:33:57 -0400 (AST) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 17157D1E2CD + for ; + Wed, 31 Mar 2004 01:33:55 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2V5Xpdp029186; + Wed, 31 Mar 2004 00:33:51 -0500 (EST) +To: josh@agliodbs.com +Cc: Palle Girgensohn , + pgsql-performance@postgresql.org +Subject: Re: LIKE should use index when condition doesn't include +In-reply-to: <200403301656.09664.josh@agliodbs.com> +References: <145170000.1080688008@palle.girgensohn.se> + <26840.1080692204@sss.pgh.pa.us> + <162280000.1080692911@palle.girgensohn.se> + <200403301656.09664.josh@agliodbs.com> +Comments: In-reply-to Josh Berkus + message dated "Tue, 30 Mar 2004 16:56:09 -0800" +Date: Wed, 31 Mar 2004 00:33:51 -0500 +Message-ID: <29185.1080711231@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/436 +X-Sequence-Number: 6292 + +Josh Berkus writes: +> ILIKE is not somehow aware that it is equivalent to lower(). + +Is it? Given the wild and wonderful behaviors of locales here and +there, I wouldn't want to assume that such an equivalence holds. + +In particular I note that iclike() seems to be multibyte-aware while +lower() definitely is not. Even if that's just a bug, it's a big leap +to assume that ILIKE is equivalent to LIKE on lower(). Think about +Turkish i/I, German esstet (did I spell that right?), ch in various +languages, etc etc. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed Mar 31 04:33:45 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 32232D1EA1F + for ; + Wed, 31 Mar 2004 08: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 06299-05 + for ; + Wed, 31 Mar 2004 04:33:30 -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 CF897D1E9BF + for ; + Wed, 31 Mar 2004 04:33:28 -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 1B8bA9-000MlD-0U; Wed, 31 Mar 2004 09:33:29 +0100 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id 6995816A93; Wed, 31 Mar 2004 09:33:28 +0100 (BST) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 3BB9015988; Wed, 31 Mar 2004 09:33:25 +0100 (BST) +From: Richard Huxton +To: "Jaime Casanova" , + pgsql-performance@postgresql.org +Subject: Re: select slow? +Date: Wed, 31 Mar 2004 09:33:24 +0100 +User-Agent: KMail/1.5 +References: +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403310933.24397.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: 200403/437 +X-Sequence-Number: 6293 + +On Tuesday 30 March 2004 20:25, Jaime Casanova wrote: +> hi all, +> +> +> i have an amd athlon with 256 ram (i know, this is not a *real* server but +> my tables are small) + +Nothing wrong with it - it's what I still use as my development server. + +> i'm using vb6 (win98) with pgsql-7.3.4 (rh8) trough the psqlodbc. +> +> when i do a select in took long to execute, here is an example + +> CREATE TABLE ICC_M_BANCO ( +> CodBanco SMALLINT NOT NULL, + +> select * from icc_m_banco where codbanco = 1; +> +> it tooks 13s from it's send until it's executed. + +Try: + SELECT * FROM icc_m_banco WHERE codbanco = 1::smallint; + +By default, PG will treat a numeric constant as integer not smallint, so when +it looks for an index it can't find one for integer, so scans instead. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Mar 31 05:50:37 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 56A5CD1B8CA + for ; + Wed, 31 Mar 2004 09:50: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 37131-09 + for ; + Wed, 31 Mar 2004 05:50:31 -0400 (AST) +Received: from ahmose.CICT_AD.NL (vnd-7521.mxs.adsl.euronet.nl + [62.234.149.33]) + by svr1.postgresql.org (Postfix) with ESMTP id 1A87FD1DB0E + for ; + Wed, 31 Mar 2004 05:50:28 -0400 (AST) +Received: by ahmose.cict_ad.nl with Internet Mail Service (5.5.2657.72) + id ; Wed, 31 Mar 2004 11:51:03 +0200 +Message-ID: <2A07EC2D0BC2774AAD6F74769F60D52A08329A@ahmose.cict_ad.nl> +From: "Priem, Alexander" +To: pgsql-performance@postgresql.org +Subject: What index for 'like (%keyword%)' ??? +Date: Wed, 31 Mar 2004 11:51:02 +0200 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: text/plain +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/438 +X-Sequence-Number: 6294 + +Hi everyone, + +I am building a query which uses a clause like "Where doc_description like +'%keyword%'". I know a normal index won't be of any use here, but since the +table in question will get fairly big, I do want to use an index. + +Can anyone give me some advise on what kind of index I can use here? Or +shouldn't I use one in this case? + +Kind regards, +Alexander Priem. + +From pgsql-performance-owner@postgresql.org Wed Mar 31 08:08:09 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 0407AD1D387 + for ; + Wed, 31 Mar 2004 12:08: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 80564-09 + for ; + Wed, 31 Mar 2004 08:07:57 -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 9C213D1E8C2 + for ; + Wed, 31 Mar 2004 08:07:54 -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 1B8eVh-000LTn-0W; Wed, 31 Mar 2004 13:07:57 +0100 +Received: by mainbox.archonet.com (Postfix, from userid 529) + id BC54B16A82; Wed, 31 Mar 2004 13:07:56 +0100 (BST) +Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) + by mainbox.archonet.com (Postfix) with ESMTP + id 1F1E5169F8; Wed, 31 Mar 2004 13:07:55 +0100 (BST) +From: Richard Huxton +To: "Priem, Alexander" , pgsql-performance@postgresql.org +Subject: Re: What index for 'like (%keyword%)' ??? +Date: Wed, 31 Mar 2004 13:07:54 +0100 +User-Agent: KMail/1.5 +References: <2A07EC2D0BC2774AAD6F74769F60D52A08329A@ahmose.cict_ad.nl> +In-Reply-To: <2A07EC2D0BC2774AAD6F74769F60D52A08329A@ahmose.cict_ad.nl> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200403311307.54680.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: 200403/439 +X-Sequence-Number: 6295 + +On Wednesday 31 March 2004 10:51, Priem, Alexander wrote: +> Hi everyone, +> +> I am building a query which uses a clause like "Where doc_description like +> '%keyword%'". I know a normal index won't be of any use here, but since the +> table in question will get fairly big, I do want to use an index. +> +> Can anyone give me some advise on what kind of index I can use here? Or +> shouldn't I use one in this case? + +You probably want to look at the contrib/tsearch2 full-text indexing module. + +-- + Richard Huxton + Archonet Ltd + +From pgsql-performance-owner@postgresql.org Wed Mar 31 10:28:17 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 6CD0ED1E9D7 + for ; + Wed, 31 Mar 2004 14:27: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 32457-04 + for ; + Wed, 31 Mar 2004 10:27:50 -0400 (AST) +Received: from hotmail.com (bay8-f7.bay8.hotmail.com [64.4.27.7]) + by svr1.postgresql.org (Postfix) with ESMTP id 69A78D1E9B4 + for ; + Wed, 31 Mar 2004 10:27:46 -0400 (AST) +Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; + Wed, 31 Mar 2004 06:27:50 -0800 +Received: from 69.65.137.210 by by8fd.bay8.hotmail.msn.com with HTTP; + Wed, 31 Mar 2004 14:27:50 GMT +X-Originating-IP: [69.65.137.210] +X-Originating-Email: [el_vigia_ec@hotmail.com] +X-Sender: el_vigia_ec@hotmail.com +From: "Jaime Casanova" +To: pgsql-performance@postgresql.org +Subject: Re: select slow? +Date: Wed, 31 Mar 2004 14:27:50 +0000 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed +Message-ID: +X-OriginalArrivalTime: 31 Mar 2004 14:27:50.0289 (UTC) + FILETIME=[586F1010:01C4172C] +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/440 +X-Sequence-Number: 6296 + +> +>On Tuesday 30 March 2004 20:25, Jaime Casanova wrote: +>>hi all, +> > +> > +> > i have an amd athlon with 256 ram (i know, this is not a *real* server +>but +> > my tables are small) + +>Nothing wrong with it - it's what I still use as my development server. +> +> > i'm using vb6 (win98) with pgsql-7.3.4 (rh8) trough the psqlodbc. +> > +> > when i do a select in took long to execute, here is an example +> +> > CREATE TABLE ICC_M_BANCO ( +> > CodBanco SMALLINT NOT NULL, + +> > select * from icc_m_banco where codbanco = 1; +> > +> > it tooks 13s from it's send until it's executed. +> +>Try: +> SELECT * FROM icc_m_banco WHERE codbanco = 1::smallint; +> +>By default, PG will treat a numeric constant as integer not smallint, so +>when +>it looks for an index it can't find one for integer, so scans instead. +> +>-- +> Richard Huxton +> Archonet Ltd + +There are no indexes yet, and the table is just 6 rows long so even if +indexes exists the planner will do a seq scan. that's my whole point 63m for +seq scan in 6 rows table is too much. + +_________________________________________________________________ +The new MSN 8: smart spam protection and 2 months FREE* +http://join.msn.com/?page=features/junkmail + + +From pgsql-performance-owner@postgresql.org Wed Mar 31 11:42:34 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id AEF6DD1D104 + for ; + Wed, 31 Mar 2004 15:40: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 56723-06 + for ; + Wed, 31 Mar 2004 11:40:24 -0400 (AST) +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by svr1.postgresql.org (Postfix) with ESMTP id 5218AD1C50B + for ; + Wed, 31 Mar 2004 11:40:20 -0400 (AST) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i2VFeLaX005091; + Wed, 31 Mar 2004 10:40:21 -0500 (EST) +To: "Jaime Casanova" +Cc: pgsql-performance@postgresql.org +Subject: Re: select slow? +In-reply-to: +References: +Comments: In-reply-to "Jaime Casanova" + message dated "Wed, 31 Mar 2004 14:27:50 +0000" +Date: Wed, 31 Mar 2004 10:40:21 -0500 +Message-ID: <5090.1080747621@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/441 +X-Sequence-Number: 6297 + +"Jaime Casanova" writes: +> There are no indexes yet, and the table is just 6 rows long so even if +> indexes exists the planner will do a seq scan. that's my whole point 63m for +> seq scan in 6 rows table is too much. + +That was 63 milliseconds, according to your original post, which seems +perfectly reasonable to me seeing that it's not a super-duper server. + +The problem sounds to be either on the client side or somewhere in your +network. I don't know anything about VB, but you might want to look +through the client-side operations to see what could be eating up the 13 +seconds. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon Apr 5 15:27:20 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id 2BC88D1E9BF + for ; + Wed, 31 Mar 2004 15:42: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 54885-08 + for ; + Wed, 31 Mar 2004 11:42:50 -0400 (AST) +Received: from mail.vistashare.com (www.vistashare.net [65.207.67.162]) + by svr1.postgresql.org (Postfix) with ESMTP id 61659D1E936 + for ; + Wed, 31 Mar 2004 11:42:46 -0400 (AST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.vistashare.com (Postfix) with ESMTP id 1EE42C4FA; + Wed, 31 Mar 2004 10:42:50 -0500 (EST) +From: Chris Kratz +Organization: VistaShare +To: Stephan Szabo +Subject: Re: Delete performance on delete from table with inherited tables +Date: Wed, 31 Mar 2004 10:42:48 -0500 +User-Agent: KMail/1.6.1 +Cc: pgsql-performance@postgresql.org +References: <200403031649.44937.chris.kratz@vistashare.com> + <20040309155908.Y9964@megazone.bigpanda.com> +In-Reply-To: <20040309155908.Y9964@megazone.bigpanda.com> +MIME-Version: 1.0 +Content-Disposition: inline +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Message-Id: <200403311042.48630.chris.kratz@vistashare.com> +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200404/44 +X-Sequence-Number: 6344 + +Thanks Stephan and Tom for your responses. We have been busy, so I haven't +had time to do any further research on this till yesterday. I found that the +large number of triggers on the parent or master table were foreign key +triggers for each table back to the child tables (update and delete on +master, insert on child). The triggers have existed through several versions +of postgres and as far as we can tell were automatically created using the +references keyword at inception. + +Yesterday I dropped all the current triggers on parent and children and ran a +script that did an alter table add foreign key constraint to each of the 67 +child tables with update cascade delete cascade. After this, the delete from +the parent where no records existed in the child tables was far more +acceptable. Instead of taking hours to do the delete, the process ran for +about 5 minutes on my workstation. Removing all constraints entirely reduces +this time to a couple of seconds. I am currently evaluating if the foreign +key constraints are worth the performance penalty in this particular case. + +To finish up, it appears that the foreign key implementation has changed since +when these first tables were created in our database. Dropping the existing +triggers and re-adding the constraints on each table significantly improved +performance for us. I do not know enough of the internals to know why this +happened. But our experience seems to prove that the newer implementation of +foreign keys is more efficient then previous versions. YMMV + +One other item that was brought up was whether the child tables have the fk +column indexed, and the answer was yes. Each had a standard btree index on +the foreign key. Explain showed nothing as all the time was being spent in +the triggers. Time spent in triggers is not shown in the pg 7.3.4 version of +explain (nor would I necessarily expect it to). + +Thanks for your time, expertise and responses. + +-Chris + +On Tuesday 09 March 2004 7:18 pm, Stephan Szabo wrote: +> On Wed, 3 Mar 2004, Chris Kratz wrote: +> > Which certainly points to the triggers being the culprit. In reading the +> > documentation, it seems like the "delete from only..." statement should +> > ignore the constraint triggers. But it seems quite obvious from the +> +> Delete from only merely means that children of the table being deleted +> will not have their rows checked against any where conditions and removed +> for that reason. It does not affect constraint triggers at all. +> +> Given I'm guessing it's going to be running about 7000 * 67 queries to +> check the validity of the delete for 7000 rows each having 67 foreign +> keys, I'm not sure there's much to do other than hack around the issue +> right now. +> +> If you're a superuser, you could temporarily hack reltriggers on the +> table's pg_class row to 0, run the delete and then set it back to the +> correct number. I'm guessing from your message that there's never any +> chance of a concurrent transaction putting in a matching row in a way that +> something is marked as deletable when it isn't? + +-- +Chris Kratz +Systems Analyst/Programmer +VistaShare LLC +www.vistashare.com + +From pgsql-performance-owner@postgresql.org Mon Apr 5 15:46:29 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id D8E00D1EADF + for ; + Wed, 31 Mar 2004 17:17:59 +0000 (GMT) +Received: from svr1.postgresql.org ([200.46.204.71]) + by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) + with ESMTP id 94546-02 + for ; + Wed, 31 Mar 2004 13:17:57 -0400 (AST) +Received: from ram.rentec.com (ram.rentec.com [192.5.35.66]) + by svr1.postgresql.org (Postfix) with ESMTP id EBE31D1DD2C + for ; + Wed, 31 Mar 2004 13:17:56 -0400 (AST) +Received: from rentec.com (IDENT:618@murre.rentec.com [172.26.132.91]) + by ram.rentec.com (8.12.1/8.12.1) with ESMTP id i2VHHsFj025607 + for ; + Wed, 31 Mar 2004 12:17:56 -0500 (EST) +Message-ID: <406AFD42.7050208@rentec.com> +Date: Wed, 31 Mar 2004 12:17:54 -0500 +From: Michael Guerin +User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.6) Gecko/20040116 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Estimated rows way off +References: <200403291955.i2TJtblp000821@eyas.rentec.com> + <4068A4E5.4000101@rentec.com> +In-Reply-To: <4068A4E5.4000101@rentec.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: 200404/45 +X-Sequence-Number: 6345 + +*statistics target = 100 +*INFO: index "timeseries_tsid" now contains *16,677,521* row versions +in 145605 pages +DETAIL: 76109 index pages have been deleted, 20000 are currently reusable. +CPU 12.00s/2.83u sec elapsed 171.26 sec. +INFO: "timeseries": found 0 removable, 16677521 nonremovable row +versions in 1876702 pages +DETAIL: 0 dead row versions cannot be removed yet. +There were *18,894,051* unused item pointers. +0 pages are entirely empty. +CPU 138.74s/28.96u sec elapsed 1079.43 sec. +INFO: vacuuming "pg_toast.pg_toast_1286079786" +INFO: index "pg_toast_1286079786_index" now contains 4846282 row +versions in 29319 pages +DETAIL: 10590 index pages have been deleted, 10590 are currently reusable. +CPU 2.23s/0.55u sec elapsed 28.34 sec. +INFO: "pg_toast_1286079786": found 0 removable, 4846282 nonremovable +row versions in 1379686 pages +DETAIL: 0 dead row versions cannot be removed yet. +There were 2824978 unused item pointers. +0 pages are entirely empty. +CPU 112.92s/19.53u sec elapsed 731.99 sec. +INFO: analyzing "public.timeseries" +INFO: "timeseries": 1876702 pages, *30,000* rows sampled, *41,762,188* +estimated total rows + + +setting the default statistics target higher makes the estimate worse: +*statistics target = 500* +INFO: index "timeseries_tsid" now contains *16,953,429 *row versions in +145605 pages +INFO: "timeseries": 1891940 pages, *150,000* rows sampled, *64,803,483* +estimated total rows + +*statistics target = 1000 * +INFO: index "timeseries_tsid" now contains *17,216,139* row versions in +145605 pages +INFO: "timeseries": 1937484 pages, *300,000* rows sampled, *68,544,295* +estimated total rows + + +I'm trying to understand why the estimated row count is so off. I'm +assuming this is b/c we do very large deletes and we're leaving around a +large number of almost empty pages. Is this the reason? + +Let me know if you need more info. + +Thanks +Michael + + + + + +> +> +>> INFO: index "timeseries_tsid" now contains *16677521* row versions +>> in 145605 pages +>> DETAIL: 76109 index pages have been deleted, 20000 are currently +>> reusable. +>> CPU 12.00s/2.83u sec elapsed 171.26 sec. +>> INFO: "timeseries": found 0 removable, 16677521 nonremovable row +>> versions in 1876702 pages +>> DETAIL: 0 dead row versions cannot be removed yet. +>> There were 18894051 unused item pointers. +>> 0 pages are entirely empty. +>> CPU 138.74s/28.96u sec elapsed 1079.43 sec. +>> INFO: vacuuming "pg_toast.pg_toast_1286079786" +>> INFO: index "pg_toast_1286079786_index" now contains 4846282 row +>> versions in 29319 pages +>> DETAIL: 10590 index pages have been deleted, 10590 are currently +>> reusable. +>> CPU 2.23s/0.55u sec elapsed 28.34 sec. +>> INFO: "pg_toast_1286079786": found 0 removable, 4846282 nonremovable +>> row versions in 1379686 pages +>> DETAIL: 0 dead row versions cannot be removed yet. +>> There were 2824978 unused item pointers. +>> 0 pages are entirely empty. +>> CPU 112.92s/19.53u sec elapsed 731.99 sec. +>> INFO: analyzing "public.timeseries" +>> INFO: "timeseries": 1876702 pages, *30,000* rows sampled, +>> *41,762,188* estimated total rows +>> +>> +>> +> +> setting the default statistics target higher made the estimate worse: +> (changed from 100 to 500) +> * +> statistics target = 500* +> INFO: index "timeseries_tsid" now contains *16,953,429 *row versions +> in 145605 pages +> INFO: "timeseries": 1891940 pages, *150,000* rows sampled, +> *64,803,483* estimated total rows +> +> *statistics target = 1000 +> *INFO: index "timeseries_tsid" now contains *17,216,139* row versions +> in 145605 pages +> INFO: "timeseries": 1937484 pages,* 300,000* rows sampled, +> *68,544,295* estimated total rows +> +> +> +> +> +> This probably has something to do with the large deletes we do. I'm +> looking around to get some more info on statistics collection. +> +> -mike +> +> +> + +From pgsql-performance-owner@postgresql.org Wed Mar 31 16:28:11 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP id DADBED1E294 + for ; + Wed, 31 Mar 2004 17: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 94132-10 + for ; + Wed, 31 Mar 2004 13:27:04 -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 27EF3D1E172 + for ; + Wed, 31 Mar 2004 13:27:04 -0400 (AST) +Received: from tmsl-adsl.demon.co.uk ([80.177.114.181] + helo=bacon.tmsl.demon.co.uk) + by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) + id 1B8jUV-0007xz-0X + for pgsql-performance@postgresql.org; Wed, 31 Mar 2004 18:27:03 +0100 +Date: Wed, 31 Mar 2004 18:27:01 +0100 +From: Paul Thomas +To: "pgsql-performance @ postgresql . org" +Subject: Re: select slow? +Message-ID: <20040331182701.A17746@bacon> +References: + <5090.1080747621@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset=ISO-8859-1 +In-Reply-To: <5090.1080747621@sss.pgh.pa.us>; + from tgl@sss.pgh.pa.us on Wed, Mar 31, 2004 at 16:40:21 +0100 +X-Mailer: Balsa 1.2.3 +Lines: 29 +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/442 +X-Sequence-Number: 6298 + + +On 31/03/2004 16:40 Tom Lane wrote: +> "Jaime Casanova" writes: +> > There are no indexes yet, and the table is just 6 rows long so even if +> > indexes exists the planner will do a seq scan. that's my whole point +> 63m for +> > seq scan in 6 rows table is too much. +> +> That was 63 milliseconds, according to your original post, which seems +> perfectly reasonable to me seeing that it's not a super-duper server. +> +> The problem sounds to be either on the client side or somewhere in your +> network. I don't know anything about VB, but you might want to look +> through the client-side operations to see what could be eating up the 13 +> seconds. + + +Given that the client and server are on different machines, I'm wondering +the bulk of the 13 seconds is due a network mis-configuration or a very +slow DNS server... + +-- +Paul Thomas ++------------------------------+---------------------------------------------+ +| Thomas Micro Systems Limited | Software Solutions for +Business | +| Computer Consultants | +http://www.thomas-micro-systems-ltd.co.uk | ++------------------------------+---------------------------------------------+ + +From pgsql-performance-owner@postgresql.org Wed Mar 31 19:51:00 2004 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (unknown [200.46.204.2]) + by svr1.postgresql.org (Postfix) with ESMTP + id 460CBD1D8AE; Wed, 31 Mar 2004 23:50: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 53020-07; Wed, 31 Mar 2004 19:50:50 -0400 (AST) +Received: from news.hub.org (news.hub.org [200.46.204.72]) + by svr1.postgresql.org (Postfix) with ESMTP + id 82D9ED1CCDC; Wed, 31 Mar 2004 19:50:49 -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 i2VNonYn010642; + Wed, 31 Mar 2004 23:50:49 GMT (envelope-from news@news.hub.org) +Received: (from news@localhost) + by news.hub.org (8.12.9/8.12.9/Submit) id i2VNQqic097936; + Wed, 31 Mar 2004 23:26:52 GMT +From: Gaetano Mendola +X-Newsgroups: comp.databases.postgresql.performance, + comp.databases.postgresql.hackers +Subject: linux and anotime mount option +Date: Thu, 01 Apr 2004 01:26:53 +0200 +Organization: PYRENET Midi-pyrenees Provider +Lines: 9 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: abuse@pyrenet.fr +User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) +X-Accept-Language: en-us, en +To: "pgsql-hackers@postgresql.org.pgsql-performance"@postgresql.org +X-Virus-Scanned: by amavisd-new at postgresql.org +X-Archive-Number: 200403/443 +X-Sequence-Number: 6299 + +Do you know if postgres made assumption on the +access time time stamp for the files on his +own file sistem ? If not I'm wondering if +mount a partition with the option "anotime" +can improve the disk i/o performance. + + +Regards +Gaetano Mendola +