diff --git "a/pgsql-performance.200605" "b/pgsql-performance.200605" new file mode 100644--- /dev/null +++ "b/pgsql-performance.200605" @@ -0,0 +1,54419 @@ +From pgsql-performance-owner@postgresql.org Sun Apr 30 21:36:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 653959FB21A + for ; + Sun, 30 Apr 2006 21:36:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 07118-05 + for ; + Sun, 30 Apr 2006 21:36:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id BB5F09FB211 + for ; + Sun, 30 Apr 2006 21:36:14 -0300 (ADT) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [67.90.96.2] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 89033057; Sun, 30 Apr 2006 17:36:11 -0700 +From: "Dave Dutcher" +To: "'gulsah'" , + +Subject: Re: query performance question +Date: Sun, 30 Apr 2006 19:36:11 -0500 +Message-ID: <00a601c66cb7$3f2c9860$8300a8c0@tridecap.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_00A7_01C66C8D.56569060" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +In-Reply-To: <20060428113059.57107.qmail@web51009.mail.yahoo.com> +Importance: Normal +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200604/703 +X-Sequence-Number: 18787 + +This is a multi-part message in MIME format. + +------=_NextPart_000_00A7_01C66C8D.56569060 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +You are pulling a fair amount of data from the database and doing a lot +of computation in the SQL. I'm not sure how fast this query could be +expected to run, but I had one idea. If you've inserted and deleted a +lot into this table, you will need to run vacuum ocasionally. If you +haven't been doing that, I would try a VACUUM FULL ANALYZE on the table. +(That will take a lock on the table and prevent clients from reading +data while it is running.) +=20 +=20 + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of gulsah +Sent: Friday, April 28, 2006 6:31 AM +To: pgsql-performance@postgresql.org +Subject: [PERFORM] query performance question + + +Hi, + +I have a performance problem with Postgresql version 8.1 installed on a +Fedora Core release 4 (Stentz) with kernel version 2.6.11. + +The machine I am working on has 512MB of RAM and Pentium III 800 MHz +CPU. + +I have only one table in the database which consists of 256 columns and +10000 rows. Each column is of float type and each row corresponds to a +vector in my application. What I want to do is to compute the distance +between a predefined vector in hand and the ones in the database. + +The computation proceeds according to the following pseudocode: + + for(i=3D1; i<=3D256 ; i++){ + distance +=3D abs(x1_i - x2_i); + } + +where x1_i denotes the vector in hand's i coordinate and x2_i denotes +the i +coordinate of the vector in the database. + +The distance computation have to be done for all the vectors in the +database +by means of a query and the result set should be sorted in terms of the +computed distances. + +When I implement the query and measure the time spent for it in an +application +I see that the query is handled in more than 8 seconds which is +undesirable in +my application. + +Here what I want to ask you all is that, is it a normal performance for +a +computer with the properties that I have mentioned above? Is there any +solution +in your mind to increase the performance of my query? + +To make it more undestandable, I should give the query for vectors with +size +3, but in my case their size is 256. + +select +id as vectorid, +abs(40.9546-x2_1)+abs(-72.9964-x2_2)+abs(53.5348-x2_3) as distance +from vectordb +order by distance + +Thank you all for your help. + + +- +gulsah + + + + + _____ =20 + +Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great + rates starting at 1=A2/min. + + +------=_NextPart_000_00A7_01C66C8D.56569060 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + +Message + + + +
You=20 +are pulling a fair amount of data from the database and doing a lot of=20 +computation in the SQL.  I'm not sure how fast this query could be = +expected=20 +to run, but I had one idea.  If you've=20 +inserted and deleted a lot into this table, you will need to run vacuum=20 +ocasionally.  If you haven't been doing that, I would try a VACUUM = +FULL=20 +ANALYZE on the table.  (That will take a lock on the table and = +prevent=20 +clients from reading data while it is running.)
+
 
+
 
+ +
+
-----Original Message-----
From:=20 + pgsql-performance-owner@postgresql.org=20 + [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of=20 + gulsah
Sent: Friday, April 28, 2006 6:31 = +AM
To:=20 + pgsql-performance@postgresql.org
Subject: [PERFORM] query=20 + performance question

Hi,

I have a = +performance=20 + problem with Postgresql version 8.1 installed on a Fedora Core release = +4=20 + (Stentz) with kernel version 2.6.11.

The machine I am working = +on has=20 + 512MB of RAM and Pentium III 800 MHz CPU.

I have only one table = +in the=20 + database which consists of 256 columns and 10000 rows. Each column is = +of float=20 + type and each row corresponds to a vector in my application. What I = +want to do=20 + is to compute the distance between a predefined vector in hand and the = +ones in=20 + the database.

The computation proceeds according to the = +following=20 + pseudocode:

        = +for(i=3D1;=20 + i<=3D256 ;=20 + = +i++){
          &nbs= +p;    =20 + distance +=3D abs(x1_i - = +x2_i);
       =20 + }

where x1_i denotes the vector in hand's i coordinate and x2_i = +denotes=20 + the i
coordinate of the vector in the database.

The distance = + + computation have to be done for all the vectors in the database
by = +means of=20 + a query and the result set should be sorted in terms of = +the
computed=20 + distances.

When I implement the query and measure the time = +spent for it=20 + in an application
I see that the query is handled in more than 8 = +seconds=20 + which is undesirable in
my application.

Here what I want to = +ask you=20 + all is that, is it a normal performance for a
computer with the = +properties=20 + that I have mentioned above? Is there any solution
in your mind to = +increase=20 + the performance of my query?

To make it more undestandable, I = +should=20 + give the query for vectors with size
3, but in my case their size = +is=20 + 256.

select
id as=20 + vectorid,
abs(40.9546-x2_1)+abs(-72.9964-x2_2)+abs(53.5348-x2_3) as = + + distance
from vectordb
order by distance

Thank you all = +for your=20 + help.


-
gulsah
+

+


+ Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great=20 + rates starting at 1=A2/min. + +------=_NextPart_000_00A7_01C66C8D.56569060-- + + +From pgsql-performance-owner@postgresql.org Mon May 1 05:13:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id EC4E29FA255 + for ; + Mon, 1 May 2006 05:13:42 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 49941-02 + for ; + Mon, 1 May 2006 05:13:13 -0300 (ADT) +X-Greylist: delayed 00:06:40.757305 by SQLgrey- +Received: from relay02.pair.com (relay02.pair.com [209.68.5.16]) + by postgresql.org (Postfix) with SMTP id 247759FB1BF + for ; + Mon, 1 May 2006 05:12:30 -0300 (ADT) +Received: (qmail 28062 invoked from network); 1 May 2006 08:05:47 -0000 +Received: from unknown (HELO ?192.168.1.100?) (unknown) + by unknown with SMTP; 1 May 2006 08:05:47 -0000 +X-pair-Authenticated: 68.79.13.249 +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Transfer-Encoding: 7bit +Message-Id: <92F10BE1-B193-4EEA-877A-9260B55C2844@mindspring.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: pgsql-performance@postgresql.org +From: Scott Sipe +Subject: Super-smack? +Date: Mon, 1 May 2006 03:05:54 -0500 +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/1 +X-Sequence-Number: 18788 + + +I've been attempting to tweak performance on a FreeBSD 6 server I'm +running that has both Postgresql 8.1 and Mysql 4.1 running +simultaneously. + +To attempt to gauge performance I was directed to the super-smack +(http://vegan.net/tony/supersmack/) benchmark. + +Testing gave results that showed mysql far outperforming postgresql +in select and update tests, in factors of roughly 6-7x in terms of +queries per second (running stock configurations--I was able to +improve mysql performance a good amount with playing with the config +file settings, though I couldn't make any change in postgresql +performance. I DID increase shmmin shmmax and semmap during the +course of testing). + +So, my question is, before I do any further digging, is super-smack +flawed? It's very possibile I'm doing something stupid with the +execution of the benchmark too, but as I said, I just wanted to see +if anyone else had used super-smack, or had comments? I'm glad to +post system specs, configs, etc, if anyone is interested. + +Alternatively, would anyone recommend any other benchmarks to run? + +thanks much, +Scott + +I also wanted to make clear I didn't want to turn this into a mysql +vs postgresql discussion, as I much prefer postgresql. + +From pgsql-performance-owner@postgresql.org Mon May 1 08:35:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D25919FA4A0 + for ; + Mon, 1 May 2006 08:35:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 33774-09 + for ; + Mon, 1 May 2006 08:35:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id A0A629FA3A6 + for ; + Mon, 1 May 2006 08:35:28 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id DB66430F1C; Mon, 1 May 2006 13:35:26 +0200 (MET DST) +From: "mlartz@gmail.com" +X-Newsgroups: pgsql.performance +Subject: Re: Easy question +Date: 1 May 2006 04:35:20 -0700 +Organization: http://groups.google.com +Lines: 9 +Message-ID: <1146483320.091670.38040@u72g2000cwu.googlegroups.com> +References: <1145741653.759727.38970@e56g2000cwe.googlegroups.com> + + <1146101167.724196.253740@v46g2000cwv.googlegroups.com> + + <1146355679.311472.57800@u72g2000cwu.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +X-Complaints-To: groups-abuse@google.com +In-Reply-To: <1146355679.311472.57800@u72g2000cwu.googlegroups.com> +User-Agent: G2/0.2 +X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.8.0.2) Gecko/20060308 + Firefox/1.5.0.2,gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: u72g2000cwu.googlegroups.com; posting-host=151.196.11.66; + posting-account=hpADjAwAAABN5Lkl4wJ_Us9DXosY2bot +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/2 +X-Sequence-Number: 18789 + +I can't speak to "the access mode of the SQL statement" but it looks +like the index that you are looking for is an index on an expression, +as shown in: + +http://www.postgresql.org/docs/8.0/static/indexes-expressional.html + +You probably want a btree on UPPER(municipo), if that is the primary +query method for the column. + + +From pgsql-performance-owner@postgresql.org Mon May 1 08:55:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2CECA9FA4B3 + for ; + Mon, 1 May 2006 08:55:03 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 26707-01 + for ; + Mon, 1 May 2006 08:54:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id 8F3569FA3A6 + for ; + Mon, 1 May 2006 08:54:51 -0300 (ADT) +Received: from trofast.sesse.net ([129.241.93.32]) + by cassarossa.samfundet.no with esmtp (Exim 4.50) + id 1FaWzH-0006pX-EF; Mon, 01 May 2006 13:54:47 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1FaWzJ-0002uu-00; Mon, 01 May 2006 13:54:49 +0200 +Date: Mon, 1 May 2006 13:54:49 +0200 +From: "Steinar H. Gunderson" +To: Scott Sipe +Cc: pgsql-performance@postgresql.org +Subject: Re: Super-smack? +Message-ID: <20060501115449.GC11061@uio.no> +Mail-Followup-To: Scott Sipe , + pgsql-performance@postgresql.org +References: <92F10BE1-B193-4EEA-877A-9260B55C2844@mindspring.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <92F10BE1-B193-4EEA-877A-9260B55C2844@mindspring.com> +X-Operating-System: Linux 2.6.16.11 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/3 +X-Sequence-Number: 18790 + +On Mon, May 01, 2006 at 03:05:54AM -0500, Scott Sipe wrote: +> So, my question is, before I do any further digging, is super-smack +> flawed? + +It's sort of hard to say without looking at the source -- it certainly isn't +a benchmark I've heard of before, and it's also sort of hard to believe a +benchmark whose focus seems to be so thoroughly on one database (MySQL). The +site claims (about PostgreSQL) support that "it looks like it works"; +certainly not a good start for fair benchmarking :-) + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Mon May 1 10:06:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AA5359FA4B3 + for ; + Mon, 1 May 2006 10:06:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 24065-07 + for ; + Mon, 1 May 2006 10:06:45 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.206]) + by postgresql.org (Postfix) with ESMTP id CD9D59F9DCD + for ; + Mon, 1 May 2006 10:06:45 -0300 (ADT) +Received: by xproxy.gmail.com with SMTP id h31so105341wxd + for ; + Mon, 01 May 2006 06:06:44 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=N7X3ssJz0ZOa2gy9cqPyFUXDMRM8Rbr4P2Z7R0hJ13i5OCotSRjWiXo+dCALS3uiQ4q0pfEETEcFXX+ONcYAwmPRprix/jIdQzQaJXC3tTfmO960SHSzA4PerP2mJN9C2O3Iglu0B5vJ6yzbSTALp2I4QKS1r5kGskCBN0wczns= +Received: by 10.70.78.17 with SMTP id a17mr3149185wxb; + Mon, 01 May 2006 06:06:44 -0700 (PDT) +Received: by 10.70.91.11 with HTTP; Mon, 1 May 2006 06:06:44 -0700 (PDT) +Message-ID: +Date: Mon, 1 May 2006 14:06:44 +0100 +From: "Steve Woodcock" +To: "Scott Sipe" +Subject: Re: Super-smack? +Cc: pgsql-performance@postgresql.org +In-Reply-To: <92F10BE1-B193-4EEA-877A-9260B55C2844@mindspring.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <92F10BE1-B193-4EEA-877A-9260B55C2844@mindspring.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/4 +X-Sequence-Number: 18791 + +On 01/05/06, Scott Sipe wrote: +> So, my question is, before I do any further digging, is super-smack +> flawed? + +Hmm, selects and updates of a 90k row table using the primary key, but +no sign of a VACUUM ANALYZE... + +Cheers, Steve Woodcock + +From pgsql-performance-owner@postgresql.org Mon May 1 12:15:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 738A29FA4A0 + for ; + Mon, 1 May 2006 12:15:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 58836-05 + for ; + Mon, 1 May 2006 12:15:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id D2B0E9F9DCD + for ; + Mon, 1 May 2006 12:15:23 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k41FFJUv005883; + Mon, 1 May 2006 11:15:19 -0400 (EDT) +To: "Steve Woodcock" +cc: "Scott Sipe" , pgsql-performance@postgresql.org +Subject: Re: Super-smack? +In-reply-to: +References: <92F10BE1-B193-4EEA-877A-9260B55C2844@mindspring.com> + +Comments: In-reply-to "Steve Woodcock" + message dated "Mon, 01 May 2006 14:06:44 +0100" +Date: Mon, 01 May 2006 11:15:19 -0400 +Message-ID: <5882.1146496519@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/5 +X-Sequence-Number: 18792 + +"Steve Woodcock" writes: +> On 01/05/06, Scott Sipe wrote: +>> So, my question is, before I do any further digging, is super-smack +>> flawed? + +> Hmm, selects and updates of a 90k row table using the primary key, but +> no sign of a VACUUM ANALYZE... + +Reasonably recent versions of PG should be able to do "the right thing" +in the presence of a simple primary key, even without any prior ANALYZE; +the planner will see the unique index and make the right conclusions +about statistics. + +If the test is doing a huge number of UPDATEs and no VACUUM anywhere, +then accumulation of dead rows would eventually hurt, but it's not clear +from Scott's report if that's the issue. + +I'm inclined to think there's some more subtle bias in the testbed. +I haven't dug into the code to look at how they are managing multiple +connections, but I wonder if say there's something causing the client to +not notice responses from the server right away when it's going through +libpq. + +FWIW, my own experiments with tests like this suggest that PG is at +worst about 2x slower than mysql for trivial queries. If you'd reported +a result in that ballpark I'd have accepted it as probably real. 6x I +don't believe though ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon May 1 12:55:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6CDFF9FA4A0 + for ; + Mon, 1 May 2006 12:55:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 52095-04 + for ; + Mon, 1 May 2006 12:55:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 576E29FA3B2 + for ; + Mon, 1 May 2006 12:55:31 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Mon, 1 May 2006 15:55:29 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 01 May 2006 10:55:29 -0500 +Subject: Re: Worsening performance with 7.4 on flash-based system +From: Scott Marlowe +To: Greg Stumph +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1146498929.22037.3.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Mon, 01 May 2006 10:55:29 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/6 +X-Sequence-Number: 18793 + +On Fri, 2006-04-28 at 13:36, Greg Stumph wrote: +> Well, since I got no response at all to this message, I can only assume that +> I've asked the question in an insufficient way, or else that no one has +> anything to offer on our problem. +> +> This was my first post to the list, so if there's a better way I should be +> asking this, or different data I should provide, hopefully someone will let +> me know... + +I'd pick one particular case and do explain analyze on it both right +after a reload, after running for a while, and after a vacuum analyze. + +Also, do a vacuum verbose on the database and post the output of that +when the system's slowed down. + +Do you make a lot of temp tables? Run a lot of DDL? I don't think we +have enough information to make a real informed decision, but I'm not +sure what questions to ask to find out where the bottleneck is... + +Also, this could be the flash controller / card combo causing problems. +Do you start with a freshly formatted card at the beginning? I know +that flash controllers randomize the part of the card that gets written +to so that you don't kill one part of it early due to writing on just on +part. Could be that as the controller maps the card behind the scenes, +the access gets slower on the lower level, and there's nothing +PostgreSQL can do about it. + +Can you tell us what your usage patterns are in a bit more detail? + +From pgsql-performance-owner@postgresql.org Mon May 1 14:00:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 544F59FA30A + for ; + Mon, 1 May 2006 14:00:12 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 71138-06 + for ; + Mon, 1 May 2006 13:59:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.wirelesscar.com (mail.wirelesscar.com [212.209.35.30]) + by postgresql.org (Postfix) with ESMTP id 908589FA2C7 + for ; + Mon, 1 May 2006 13:59:56 -0300 (ADT) +Received: from sesrv12.wirelesscar.com ([192.168.10.17]) by + mail.wirelesscar.com with InterScan Messaging Security Suite; + Mon, 01 May 2006 18:59:32 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Super-smack? +Date: Mon, 1 May 2006 19:00:21 +0200 +Message-ID: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E436A@sesrv12.wirelesscar.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Super-smack? +Thread-Index: AcZtMlRao2cW8WM5SBy5vqLPm8FGPQACPJbA +From: "Mikael Carneholm" +To: "Tom Lane" , + "Steve Woodcock" +Cc: "Scott Sipe" , +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/7 +X-Sequence-Number: 18794 + +>FWIW, my own experiments with tests like this suggest that PG is at +worst about 2x slower than mysql for trivial queries. If you'd reported +a result in that ballpark I'd have accepted it as probably real. 6x I +don't believe though ... + +OTOH, my tests using BenchmarkSQL +(http://sourceforge.net/projects/benchmarksql) shows that PG can deliver +up to 8x more transactions/minute than a well-known proprietary DB on +similar hardware (with 100 concurrent connections) - can't post the +results due to licence restrictions of the proprietary vendor though. In +fact, PG on a single SCSI disk machine did even beat the other DB when +the other DB had a fully equipped CX200 Dell/EMC SAN, if only with 30% +this time. Note that in the latter case, the other DB is unable to use +async IO due to problems running on linux kernel 2.4.9. And yes, PG was +running with fsync on. + +It's only a benchmark though, and real-life useage is what counts in the +end (after all). + +Regards, +Mikael + +From pgsql-performance-owner@postgresql.org Mon May 1 14:34:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D37A19FA2DB + for ; + Mon, 1 May 2006 14:34:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 51783-06 + for ; + Mon, 1 May 2006 14:34:04 -0300 (ADT) +X-Greylist: delayed 00:06:40.123119 by SQLgrey- +Received: from mail.89glass.com (mail.89glass.com [72.10.2.250]) + by postgresql.org (Postfix) with SMTP id B79E29FA2C7 + for ; + Mon, 1 May 2006 14:34:03 -0300 (ADT) +Received: (qmail 21740 invoked by uid 1006); 1 May 2006 17:27:21 -0000 +Received: from 192.168.254.111 by lumberjack (envelope-from + , + uid 201) with qmail-scanner-1.25 (clamdscan: 0.67. + Clear:RC:1(192.168.254.111):. + Processed in 0.040429 secs); 01 May 2006 17:27:21 -0000 +Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; + s=domkey; d=rbsinteractive.com; + b=rGlHj/06+8lqV0AYm6mndx2YR88YqHLU8uHOvdx7kFFjy3H8fOxbRpidh1JIU/6olT1lSRp92yOcFu1ICR7jCCDsQVzVHzTKoxes2XjJGy1+70VnBMGzB0d0klRhl+3Yhb2al+WPQ+fLdhC9rtL7r946ywhjUAnT0CPMf0gKWuU= + ; +Received: from unknown (HELO ?192.168.254.111?) (192.168.254.111) + by mail.89glass.com with SMTP; 1 May 2006 17:27:21 -0000 +Message-ID: <445644F9.2020708@rbsinteractive.com> +Date: Mon, 01 May 2006 10:27:21 -0700 +From: Nolan Cafferky +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Cluster vs. non-cluster query planning +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/8 +X-Sequence-Number: 18795 + +I'm running postgres 8.0.7, and I've got a table of orders with about +100,000 entries. I want to just look at the new orders, right now 104 of +them. + +EXPLAIN ANALYZE +SELECT + order_id + FROM + orders + WHERE + order_statuses_id = (SELECT id FROM order_statuses WHERE id_name += 'new'); + + Seq Scan on orders o (cost=1.20..11395.51 rows=7029 width=8) (actual +time=286.038..287.662 rows=104 loops=1) + Filter: (order_statuses_id = $0) + InitPlan + -> Seq Scan on order_statuses (cost=0.00..1.20 rows=1 width=4) +(actual time=0.030..0.039 rows=1 loops=1) + Filter: ((id_name)::text = 'new'::text) + Total runtime: 288.102 ms + +The dreaded sequential scan. I've got an index on order_statuses_id and +I've VACUUM ANALYZEd the table, but I'm currently clustered on the +primary key (order_id). + +With enable_seqscan = off, I get: +------------------------------------------------- + Index Scan using orders_status_btree_idx on orders o +(cost=4.64..12457.14 rows=7031 width=8) (actual time=0.164..0.664 +rows=104 loops=1) + Index Cond: (order_statuses_id = $0) + InitPlan + -> Index Scan using order_statuses_id_name_key on order_statuses +(cost=0.00..4.64 rows=1 width=4) (actual time=0.128..0.134 rows=1 loops=1) + Index Cond: ((id_name)::text = 'new'::text) + Total runtime: 1.108 ms + +If I hard-code the 'new' status ID, I get: +------------------------------------------------- +EXPLAIN ANALYZE +SELECT + order_id + FROM + orders + WHERE + order_statuses_id = 1; + + Index Scan using orders_status_btree_idx on orders o +(cost=0.00..4539.65 rows=1319 width=8) (actual time=0.132..1.883 +rows=104 loops=1) + Index Cond: (order_statuses_id = 1) + Total runtime: 2.380 ms + +Here is the pg_stats entry for orders.order_statuses_id: + schemaname | tablename | attname | null_frac | avg_width | +n_distinct | most_common_vals | most_common_freqs +| histogram_bounds | correlation +------------+-----------+-------------------+-------------+-----------+------------+------------------+--------------------------------------+-------------------------+------------- + public | orders | order_statuses_id | 0.000208333 | 4 +| 14 | {8,24,10,25} | {0.385417,0.242083,0.230625,0.07875} | +{1,7,7,9,9,9,9,9,23,26} | 0.740117 + +This is with SET STATISTICS = 16 on the column, since that's how many +different values the column can currently take. + +Now, here's the thing - if I cluster on the index on order_statuses_id, +the original query produces: + Index Scan using orders_status_btree_idx on orders o +(cost=1.20..978.94 rows=8203 width=8) (actual time=0.097..0.598 rows=104 +loops=1) + Index Cond: (order_statuses_id = $0) + InitPlan + -> Seq Scan on order_statuses (cost=0.00..1.20 rows=1 width=4) +(actual time=0.056..0.065 rows=1 loops=1) + Filter: ((id_name)::text = 'new'::text) + Total runtime: 1.042 ms + +Estimated cost went way down. The pg_stats entry becomes: + + schemaname | tablename | attname | null_frac | avg_width | +n_distinct | most_common_vals | most_common_freqs +| histogram_bounds | correlation +------------+-----------+-------------------+-----------+-----------+------------+------------------+----------------------------------------+---------------------+------------- + public | orders | order_statuses_id | 0 | 4 +| 12 | {8,24,10,25} | {0.386458,0.244167,0.238333,0.0720833} +| {1,7,7,9,9,9,22,26} | 1 + +I'm hesitant to cluster on the order_statuses_id index, because there +are a lot of other queries using this table, many of which join on +order_id. I also feel like I ought to be able to get the planner to do +an index scan without hard-coding the order_statuses_id value. + +Questions: +* What can I do to reduce the estimated row count on the query? +* Why does clustering drive down the estimated cost for the index scan +so much? Does a change in correlation from .72 to 1 make that much of a +difference? +* Can I convince my query planner to index scan without clustering on +the order_statuses_id index, or setting enable_seqscan = off? + +Potential note of interest: This is a very wide, monolithic table - no +less than 100 columns, with several check constraints, foreign key +constraints, and indexes, including three functional indexes. + +Side question: Sometimes, when I VACUUM ANALYZE the table, the pg_stats +entry for order_statuses_id has almost all of the possible values in +most_common_vals, instead of just a handful. Example: + + schemaname | tablename | attname | null_frac | avg_width | +n_distinct | most_common_vals +| +most_common_freqs +| histogram_bounds | correlation +------------+-----------+-------------------+-----------+-----------+------------+-----------------------------------+------------------------------------------------------------------------------------------------------------------------------+------------------+------------- + public | orders | order_statuses_id | 0 | 4 +| 13 | {8,24,10,25,9,7,23,26,1,22,2,5,4} | +{0.393125,0.240208,0.226042,0.07875,0.0275,0.0145833,0.0110417,0.00291667,0.00229167,0.001875,0.000625,0.000625,0.000416667} +| | 1 + +This doesn't appear to influence whether the index scan is chosen, but I +am curious as to why this happens. + +From pgsql-performance-owner@postgresql.org Mon May 1 14:43:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D29229FA36E + for ; + Mon, 1 May 2006 14:43:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 07315-03 + for ; + Mon, 1 May 2006 14:43:20 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id A2E649FA2DB + for ; + Mon, 1 May 2006 14:43:20 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k41HhHc9006880; + Mon, 1 May 2006 13:43:17 -0400 (EDT) +To: "Steve Woodcock" +cc: "Scott Sipe" , pgsql-performance@postgresql.org +Subject: Re: Super-smack? +In-reply-to: <5882.1146496519@sss.pgh.pa.us> +References: <92F10BE1-B193-4EEA-877A-9260B55C2844@mindspring.com> + + <5882.1146496519@sss.pgh.pa.us> +Comments: In-reply-to Tom Lane + message dated "Mon, 01 May 2006 11:15:19 -0400" +Date: Mon, 01 May 2006 13:43:16 -0400 +Message-ID: <6879.1146505396@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/9 +X-Sequence-Number: 18796 + +I wrote: +> FWIW, my own experiments with tests like this suggest that PG is at +> worst about 2x slower than mysql for trivial queries. If you'd reported +> a result in that ballpark I'd have accepted it as probably real. 6x I +> don't believe though ... + +Just for amusement's sake, I tried compiling up super-smack on my own +machine, and got results roughly in line with what I would've expected. + +Machine: dual Xeon EM64T, forget the clock rate at the moment, running +Fedora Core 4 (kernel 2.6.15-1.1831_FC4smp); hyperthreading enabled + +Postgres: fairly recent CVS tip, no special build options except +--enable-debug, no changes to default runtime configuration options + +MySQL: 5.0.18, current Red Hat RPMs, no changes to default configuration + +The "select" test, with 1 and 10 clients: + +$ super-smack -d pg select-key.smack 1 10000 +Query Barrel Report for client smacker1 +connect: max=0ms min=-1ms avg= 3ms from 1 clients +Query_type num_queries max_time min_time q_per_s +select_index 20000 0 0 3655.24 +$ super-smack -d pg select-key.smack 10 10000 +Query Barrel Report for client smacker1 +connect: max=54ms min=4ms avg= 12ms from 10 clients +Query_type num_queries max_time min_time q_per_s +select_index 200000 0 0 7431.20 + +$ super-smack -d mysql select-key.smack 1 10000 +Query Barrel Report for client smacker1 +connect: max=0ms min=-1ms avg= 0ms from 1 clients +Query_type num_queries max_time min_time q_per_s +select_index 20000 0 0 6894.03 +$ super-smack -d mysql select-key.smack 10 10000 +Query Barrel Report for client smacker1 +connect: max=14ms min=0ms avg= 5ms from 10 clients +Query_type num_queries max_time min_time q_per_s +select_index 200000 0 0 16798.05 + +The "update" test, with 1 and 10 clients: + +$ super-smack -d pg update-select.smack 1 10000 +Query Barrel Report for client smacker +connect: max=0ms min=-1ms avg= 4ms from 1 clients +Query_type num_queries max_time min_time q_per_s +select_index 10000 0 0 1027.49 +update_index 10000 0 0 1027.49 +$ super-smack -d pg update-select.smack 10 10000 +Query Barrel Report for client smacker +connect: max=13ms min=5ms avg= 8ms from 10 clients +Query_type num_queries max_time min_time q_per_s +select_index 100000 1 0 1020.96 +update_index 100000 28 0 1020.96 + +The above is with fsync on (though I think this machine's disk lies +about write complete so I'd not trust it as production). With fsync off, + +$ super-smack -d pg update-select.smack 1 10000 +Query Barrel Report for client smacker +connect: max=0ms min=-1ms avg= 3ms from 1 clients +Query_type num_queries max_time min_time q_per_s +select_index 10000 0 0 1478.25 +update_index 10000 0 0 1478.25 +$ super-smack -d pg update-select.smack 10 10000 +Query Barrel Report for client smacker +connect: max=35ms min=5ms avg= 21ms from 10 clients +Query_type num_queries max_time min_time q_per_s +select_index 100000 1 0 3067.68 +update_index 100000 1 0 3067.68 + +versus mysql + +$ super-smack -d mysql update-select.smack 1 10000 +Query Barrel Report for client smacker +connect: max=0ms min=-1ms avg= 0ms from 1 clients +Query_type num_queries max_time min_time q_per_s +select_index 10000 0 0 4101.43 +update_index 10000 0 0 4101.43 +$ super-smack -d mysql update-select.smack 10 10000 +Query Barrel Report for client smacker +connect: max=3ms min=0ms avg= 0ms from 10 clients +Query_type num_queries max_time min_time q_per_s +select_index 100000 1 0 5388.31 +update_index 100000 6 0 5388.31 + +Since mysql is using myisam tables (ie not transaction safe), I think +the fairest comparison is to the fsync-off numbers. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon May 1 15:08:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id EB8419FA30A + for ; + Mon, 1 May 2006 15:08:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 66631-02 + for ; + Mon, 1 May 2006 15:08:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 535B99FA2C7 + for ; + Mon, 1 May 2006 15:08:00 -0300 (ADT) +Received: from mail.aviawest.com (mail.vacationrevelation.com [70.66.0.234]) + by svr4.postgresql.org (Postfix) with ESMTP id 0F8255B131A + for ; + Mon, 1 May 2006 18:00:58 +0000 (GMT) +Received: from s0106000d5639fbfb.gv.shawcable.net ([24.69.163.91] + helo=[192.168.33.226]) + by mail.aviawest.com with asmtp (TLSv1:AES256-SHA:256) (Exim 4.24) + id 1FacfD-0005AS-0P; Mon, 01 May 2006 10:58:27 -0700 +Message-ID: <44564C3F.2040609@aviawest.com> +Date: Mon, 01 May 2006 10:58:23 -0700 +From: Erik Myllymaki +Reply-To: erik.myllymaki@aviawest.com +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: Mark Lewis +Cc: Vivek Khera , + Pgsql performance +Subject: Re: hardare config question +References: <445236D5.5060509@aviawest.com> + <3DFCE70E-E4BB-40AB-B27F-99E90E8159CA@khera.org> + <1146246441.15712.41.camel@archimedes> +In-Reply-To: <1146246441.15712.41.camel@archimedes> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-"AviawestResorts"-MailScanner-Information: Please contact the ISP for more + information +X-"AviawestResorts"-MailScanner: Found to be clean +X-MailScanner-From: erik.myllymaki@aviawest.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/10 +X-Sequence-Number: 18797 + +I have been in discussion with 3ware support and after adjusting some settings, +the 3ware card in RAID 1 gets better performance than the single drive. I guess +this had everything to do with the write (and maybe read?) cache. + +Of course now i am in a dangerous situation - using volatile write cache +without a BBU. + +If I were to use a UPS to ensure a soft shutdown in the event of power loss, am +I somewhat as safe as if I were to purchase a BBU for this RAID card? + + + +Thanks. + +Mark Lewis wrote: +> It's also possible that the single SATA drive you were testing (or the +> controller it was attached to) is lying about fsync and performing write +> caching behind your back, whereas your new controller and drives are +> not. +> +> You'll find a lot more info on the archives of this list about it, but +> basically if your application is committing a whole lot of small +> transactions, then it will run fast (but not safely) on a drive which +> lies about fsync, but slower on a better disk subsystem which doesn't +> lie about fsync. +> +> Try running a test with fsync=off with your new equipment and if it +> suddenly starts running faster, then you know that's the problem. +> You'll either have a choice of losing all of your data the next time the +> system shuts down uncleanly but being fast, or of running slow, or of +> fixing the applications to use chunkier transactions. +> +> -- Mark +> +> On Fri, 2006-04-28 at 13:36 -0400, Vivek Khera wrote: +>> On Apr 28, 2006, at 11:37 AM, Erik Myllymaki wrote: +>> +>>> When I had this installed on a single SATA drive running from the +>>> PE1800's on-board SATA interface, this operation took anywhere from +>>> 65-80 seconds. +>>> +>>> With my new RAID card and drives, this operation took 272 seconds!? +>> switch it to RAID10 and re-try your experiment. if that is fast, +>> then you know your raid controller does bad RAID5. +>> +>> anyhow, I have in one server (our office mail server and part-time +>> development testing box) an adaptec SATA RAID from dell. it is +>> configured for RAID5 and does well for normal office stuff, but when +>> we do postgres tests on it, it just is plain old awful. +>> +>> but I have some LSI based cards on which RAID5 is plenty fast and +>> suitable for the DB, but those are SCSI. +>> +>> For what it is worth, the Dell PE1850 internal PERC4/Si card is +>> wicked fast when hooked up with a pair of U320 SCSI drives. +>> +>> +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 3: Have you checked our extensive FAQ? +>> +>> http://www.postgresql.org/docs/faq +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, 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 May 1 15:16:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 32A3D9FA2C7 + for ; + Mon, 1 May 2006 15:16:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 97296-04 + for ; + Mon, 1 May 2006 15:15:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) + by postgresql.org (Postfix) with ESMTP id 5509A9FA30A + for ; + Mon, 1 May 2006 15:15:56 -0300 (ADT) +Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP + with MS-WebStorage 6.0.6249 +Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; + 01 May 2006 11:15:53 -0700 +Subject: Re: hardare config question +From: Mark Lewis +To: erik.myllymaki@aviawest.com +Cc: Vivek Khera , + Pgsql performance +In-Reply-To: <44564C3F.2040609@aviawest.com> +References: <445236D5.5060509@aviawest.com> + <3DFCE70E-E4BB-40AB-B27F-99E90E8159CA@khera.org> + <1146246441.15712.41.camel@archimedes> <44564C3F.2040609@aviawest.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: MIR3, Inc. +Date: Mon, 01 May 2006 11:15:53 -0700 +Message-Id: <1146507353.10239.25.camel@archimedes> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-27) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/11 +X-Sequence-Number: 18798 + +A UPS will make it less likely that the system will reboot and destroy +your database due to a power failure, but there are other causes for a +system reboot. + +With a BBU, the only component that can fail and cause catastrophic data +loss is the RAID itself. + +With a UPS, you are additionally vulnerable to OS crashes, failures in +non-RAID hardware, UPS failures, or anything else that would necessitate +a hard reboot. + +So a UPS is a decent replacement for a BBU only if you trust your app +server/OS more than you value your data. + +-- Mark Lewis + + +On Mon, 2006-05-01 at 10:58 -0700, Erik Myllymaki wrote: +> I have been in discussion with 3ware support and after adjusting some settings, +> the 3ware card in RAID 1 gets better performance than the single drive. I guess +> this had everything to do with the write (and maybe read?) cache. +> +> Of course now i am in a dangerous situation - using volatile write cache +> without a BBU. +> +> If I were to use a UPS to ensure a soft shutdown in the event of power loss, am +> I somewhat as safe as if I were to purchase a BBU for this RAID card? +> +> +> +> Thanks. +> +> Mark Lewis wrote: +> > It's also possible that the single SATA drive you were testing (or the +> > controller it was attached to) is lying about fsync and performing write +> > caching behind your back, whereas your new controller and drives are +> > not. +> > +> > You'll find a lot more info on the archives of this list about it, but +> > basically if your application is committing a whole lot of small +> > transactions, then it will run fast (but not safely) on a drive which +> > lies about fsync, but slower on a better disk subsystem which doesn't +> > lie about fsync. +> > +> > Try running a test with fsync=off with your new equipment and if it +> > suddenly starts running faster, then you know that's the problem. +> > You'll either have a choice of losing all of your data the next time the +> > system shuts down uncleanly but being fast, or of running slow, or of +> > fixing the applications to use chunkier transactions. +> > +> > -- Mark +> > +> > On Fri, 2006-04-28 at 13:36 -0400, Vivek Khera wrote: +> >> On Apr 28, 2006, at 11:37 AM, Erik Myllymaki wrote: +> >> +> >>> When I had this installed on a single SATA drive running from the +> >>> PE1800's on-board SATA interface, this operation took anywhere from +> >>> 65-80 seconds. +> >>> +> >>> With my new RAID card and drives, this operation took 272 seconds!? +> >> switch it to RAID10 and re-try your experiment. if that is fast, +> >> then you know your raid controller does bad RAID5. +> >> +> >> anyhow, I have in one server (our office mail server and part-time +> >> development testing box) an adaptec SATA RAID from dell. it is +> >> configured for RAID5 and does well for normal office stuff, but when +> >> we do postgres tests on it, it just is plain old awful. +> >> +> >> but I have some LSI based cards on which RAID5 is plenty fast and +> >> suitable for the DB, but those are SCSI. +> >> +> >> For what it is worth, the Dell PE1850 internal PERC4/Si card is +> >> wicked fast when hooked up with a pair of U320 SCSI drives. +> >> +> >> +> >> +> >> ---------------------------(end of broadcast)--------------------------- +> >> TIP 3: Have you checked our extensive FAQ? +> >> +> >> http://www.postgresql.org/docs/faq +> > +> > ---------------------------(end of broadcast)--------------------------- +> > TIP 9: In versions below 8.0, 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 May 1 15:46:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4DB599F9586 + for ; + Mon, 1 May 2006 15:46:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 46867-06 + for ; + Mon, 1 May 2006 15:46:13 -0300 (ADT) +X-Greylist: delayed 00:23:23.571185 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 624319F9C10 + for ; + Mon, 1 May 2006 15:46:13 -0300 (ADT) +Received: from mail.jobflash.com (oncallweb2.jobflash.com [64.62.211.41]) + by svr4.postgresql.org (Postfix) with ESMTP id 6346B5B5231 + for ; + Mon, 1 May 2006 18:22:48 +0000 (GMT) +Received: from [192.168.1.64] (adsl-69-105-117-134.dsl.pltn13.pacbell.net + [69.105.117.134]) + by mail.jobflash.com (Postfix) with ESMTP id 89B8E420E4; + Mon, 1 May 2006 11:22:45 -0700 (PDT) +Message-ID: <445651F1.9070307@jobflash.com> +Date: Mon, 01 May 2006 11:22:41 -0700 +From: Tom Arthurs +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: erik.myllymaki@aviawest.com +Cc: Mark Lewis , Vivek Khera , + Pgsql performance +Subject: Re: hardare config question +References: <445236D5.5060509@aviawest.com> + <3DFCE70E-E4BB-40AB-B27F-99E90E8159CA@khera.org> + <1146246441.15712.41.camel@archimedes> + <44564C3F.2040609@aviawest.com> +In-Reply-To: <44564C3F.2040609@aviawest.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/14 +X-Sequence-Number: 18801 + +UPS does not protect against the tech behind the rack unplugging the +power cable, or an accidental power cycle from exercising the wrong +switch. :) Both are probably more common causes of failure than a total +power outage. + +Erik Myllymaki wrote: +> I have been in discussion with 3ware support and after adjusting some +> settings, the 3ware card in RAID 1 gets better performance than the +> single drive. I guess this had everything to do with the write (and +> maybe read?) cache. +> +> Of course now i am in a dangerous situation - using volatile write +> cache without a BBU. +> +> If I were to use a UPS to ensure a soft shutdown in the event of power +> loss, am I somewhat as safe as if I were to purchase a BBU for this +> RAID card? +> +> +> +> Thanks. +> +> Mark Lewis wrote: +>> It's also possible that the single SATA drive you were testing (or the +>> controller it was attached to) is lying about fsync and performing write +>> caching behind your back, whereas your new controller and drives are +>> not. +>> +>> You'll find a lot more info on the archives of this list about it, but +>> basically if your application is committing a whole lot of small +>> transactions, then it will run fast (but not safely) on a drive which +>> lies about fsync, but slower on a better disk subsystem which doesn't +>> lie about fsync. +>> +>> Try running a test with fsync=off with your new equipment and if it +>> suddenly starts running faster, then you know that's the problem. +>> You'll either have a choice of losing all of your data the next time the +>> system shuts down uncleanly but being fast, or of running slow, or of +>> fixing the applications to use chunkier transactions. +>> +>> -- Mark +>> +>> On Fri, 2006-04-28 at 13:36 -0400, Vivek Khera wrote: +>>> On Apr 28, 2006, at 11:37 AM, Erik Myllymaki wrote: +>>> +>>>> When I had this installed on a single SATA drive running from the +>>>> PE1800's on-board SATA interface, this operation took anywhere +>>>> from 65-80 seconds. +>>>> +>>>> With my new RAID card and drives, this operation took 272 seconds!? +>>> switch it to RAID10 and re-try your experiment. if that is fast, +>>> then you know your raid controller does bad RAID5. +>>> +>>> anyhow, I have in one server (our office mail server and part-time +>>> development testing box) an adaptec SATA RAID from dell. it is +>>> configured for RAID5 and does well for normal office stuff, but +>>> when we do postgres tests on it, it just is plain old awful. +>>> +>>> but I have some LSI based cards on which RAID5 is plenty fast and +>>> suitable for the DB, but those are SCSI. +>>> +>>> For what it is worth, the Dell PE1850 internal PERC4/Si card is +>>> wicked fast when hooked up with a pair of U320 SCSI drives. +>>> +>>> +>>> +>>> ---------------------------(end of +>>> broadcast)--------------------------- +>>> TIP 3: Have you checked our extensive FAQ? +>>> +>>> http://www.postgresql.org/docs/faq +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 9: In versions below 8.0, the planner will ignore your desire to +>> choose an index scan if your joining column's datatypes do not +>> match +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: explain analyze is your friend + +From pgsql-performance-owner@postgresql.org Mon May 1 15:29:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1901E9FA36E + for ; + Mon, 1 May 2006 15:29:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 59819-03 + for ; + Mon, 1 May 2006 15:29:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id 71C299FA2C7 + for ; + Mon, 1 May 2006 15:29:14 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id D6EE3B829 + for ; + Mon, 1 May 2006 14:29:12 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <44564C3F.2040609@aviawest.com> +References: <445236D5.5060509@aviawest.com> + <3DFCE70E-E4BB-40AB-B27F-99E90E8159CA@khera.org> + <1146246441.15712.41.camel@archimedes> + <44564C3F.2040609@aviawest.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <5593938F-CCD0-4161-93B2-648D008C0919@khera.org> +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: hardare config question +Date: Mon, 1 May 2006 14:29:12 -0400 +To: Pgsql performance +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/12 +X-Sequence-Number: 18799 + + +On May 1, 2006, at 1:58 PM, Erik Myllymaki wrote: + +> Of course now i am in a dangerous situation - using volatile write +> cache without a BBU. +> + +It should be against the law to make RAID cards with caches that are +not battery backed. + +> If I were to use a UPS to ensure a soft shutdown in the event of +> power loss, am I somewhat as safe as if I were to purchase a BBU +> for this RAID card? + +no. not at all. + + +From pgsql-performance-owner@postgresql.org Mon May 1 16:02:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5A55D9F9C10 + for ; + Mon, 1 May 2006 16:02:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10358-01 + for ; + Mon, 1 May 2006 16:02:40 -0300 (ADT) +X-Greylist: delayed 00:21:45.172048 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id F173E9F969C + for ; + Mon, 1 May 2006 16:02:40 -0300 (ADT) +Received: from sottsym2.entrust.com (sottsym2.entrust.com [216.191.252.20]) + by svr4.postgresql.org (Postfix) with ESMTP id 6EAC15B5289 + for ; + Mon, 1 May 2006 18:40:54 +0000 (GMT) +Received: from sottmxsecs3.entrust.com (unknown [216.191.252.14]) + by sottsym2.entrust.com (Symantec Mail Security) with SMTP id 0B6C613BC + for ; + Mon, 1 May 2006 14:40:52 -0400 (EDT) +Received: (qmail 23718 invoked from network); 1 May 2006 18:40:50 -0000 +Received: from Chris.McKenzie@entrust.com by sottmxsecs3.entrust.com with + EntrustECS-Server-7.4; 01 May 2006 18:40:50 -0000 +Received: from unknown (HELO sottmxs00.entrust.com) (10.4.61.22) + by sottmxsecs3.entrust.com with SMTP; 1 May 2006 18:40:50 -0000 +Received: by sottmxs00.entrust.com with Internet Mail Service (5.5.2657.72) + id <2PTD086W>; Mon, 1 May 2006 14:40:51 -0400 +Message-ID: +From: Chris Mckenzie +To: "'pgsql-performance@postgresql.org'" +Subject: Postgres 7.4 and vacuum_cost_delay. +Date: Mon, 1 May 2006 14:40:41 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C66D4E.209ECCB4" +X-Brightmail-Tracker: AAAAAA== +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/17 +X-Sequence-Number: 18804 + + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C66D4E.209ECCB4 +Content-Type: text/plain + +Hi everyone. + +I've got a quick and stupid question: Does Postgres 7.4 (7.x) support +vacuum_cost_delay? + +For all my googles and documentation reading I've determined it's not +supported, only because I can't find a 7.x doc or forum post claiming +otherwise. + +Upgrading to 8.x is out of the question, but I still need to employ +something to auto-vacuum a large and active database (possibly more than +once a day) in a manner that wouldn't affect load at the wrong time. + +If I could combine pg_autovacuum with vacuum_cost_delay I could potentially +have a solution. (barring some performance testing) + +The only problem with pg_autovacuum is the need for pg_statio, which itself +will reduce performance at all times. + +Any suggestions? + +Thanks! + +- Chris + + + + +------_=_NextPart_001_01C66D4E.209ECCB4 +Content-Type: text/html +Content-Transfer-Encoding: quoted-printable + + + + + + +Postgres 7.4 and vacuum_cost_delay. + + + +

Hi everyone. +

+ +

I've got a quick and stupid question: Does Postgres = +7.4 (7.x) support vacuum_cost_delay? +

+ +

For all my googles and documentation reading I've = +determined it's not supported, only because I can't find a 7.x doc or = +forum post claiming otherwise.

+ +

Upgrading to 8.x is out of the question, but I still = +need to employ something to auto-vacuum a large and active database = +(possibly more than once a day) in a manner that wouldn't affect load = +at the wrong time.

+ +

If I could combine pg_autovacuum with = +vacuum_cost_delay I could potentially have a solution. (barring some = +performance testing)

+ +

The only problem with pg_autovacuum is the need for = +pg_statio, which itself will reduce performance at all times. +

+ +

Any suggestions? +

+ +

Thanks! +

+ +

- Chris +

+
+
+ + + +------_=_NextPart_001_01C66D4E.209ECCB4-- + +From pgsql-performance-owner@postgresql.org Mon May 1 15:45:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B808B9F9B76 + for ; + Mon, 1 May 2006 15:44:59 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 58756-07 + for ; + Mon, 1 May 2006 15:44:50 -0300 (ADT) +X-Greylist: delayed 00:43:50.709702 by SQLgrey- +Received: from mail.aviawest.com (mail.vacationrevelation.com [70.66.0.234]) + by postgresql.org (Postfix) with ESMTP id 19C079F9586 + for ; + Mon, 1 May 2006 15:44:49 -0300 (ADT) +Received: from s0106000d5639fbfb.gv.shawcable.net ([24.69.163.91] + helo=[192.168.33.226]) + by mail.aviawest.com with asmtp (TLSv1:AES256-SHA:256) (Exim 4.24) + id 1FadMk-0005hW-7s; Mon, 01 May 2006 11:43:26 -0700 +Message-ID: <445656C8.6070308@aviawest.com> +Date: Mon, 01 May 2006 11:43:20 -0700 +From: Erik Myllymaki +Reply-To: erik.myllymaki@aviawest.com +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: Tom Arthurs +CC: Mark Lewis , Vivek Khera , + Pgsql performance +Subject: Re: hardare config question +References: <445236D5.5060509@aviawest.com> + <3DFCE70E-E4BB-40AB-B27F-99E90E8159CA@khera.org> + <1146246441.15712.41.camel@archimedes> + <44564C3F.2040609@aviawest.com> <445651F1.9070307@jobflash.com> +In-Reply-To: <445651F1.9070307@jobflash.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-"AviawestResorts"-MailScanner-Information: Please contact the ISP for more + information +X-"AviawestResorts"-MailScanner: Found to be clean +X-"AviawestResorts"-MailScanner-SpamScore: s +X-MailScanner-From: erik.myllymaki@aviawest.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/13 +X-Sequence-Number: 18800 + +good points, thanks. + +Tom Arthurs wrote: +> UPS does not protect against the tech behind the rack unplugging the +> power cable, or an accidental power cycle from exercising the wrong +> switch. :) Both are probably more common causes of failure than a total +> power outage. +> +> Erik Myllymaki wrote: +>> I have been in discussion with 3ware support and after adjusting some +>> settings, the 3ware card in RAID 1 gets better performance than the +>> single drive. I guess this had everything to do with the write (and +>> maybe read?) cache. +>> +>> Of course now i am in a dangerous situation - using volatile write +>> cache without a BBU. +>> +>> If I were to use a UPS to ensure a soft shutdown in the event of power +>> loss, am I somewhat as safe as if I were to purchase a BBU for this +>> RAID card? +>> +>> +>> +>> Thanks. +>> +>> Mark Lewis wrote: +>>> It's also possible that the single SATA drive you were testing (or the +>>> controller it was attached to) is lying about fsync and performing write +>>> caching behind your back, whereas your new controller and drives are +>>> not. +>>> +>>> You'll find a lot more info on the archives of this list about it, but +>>> basically if your application is committing a whole lot of small +>>> transactions, then it will run fast (but not safely) on a drive which +>>> lies about fsync, but slower on a better disk subsystem which doesn't +>>> lie about fsync. +>>> +>>> Try running a test with fsync=off with your new equipment and if it +>>> suddenly starts running faster, then you know that's the problem. +>>> You'll either have a choice of losing all of your data the next time the +>>> system shuts down uncleanly but being fast, or of running slow, or of +>>> fixing the applications to use chunkier transactions. +>>> +>>> -- Mark +>>> +>>> On Fri, 2006-04-28 at 13:36 -0400, Vivek Khera wrote: +>>>> On Apr 28, 2006, at 11:37 AM, Erik Myllymaki wrote: +>>>> +>>>>> When I had this installed on a single SATA drive running from the +>>>>> PE1800's on-board SATA interface, this operation took anywhere +>>>>> from 65-80 seconds. +>>>>> +>>>>> With my new RAID card and drives, this operation took 272 seconds!? +>>>> switch it to RAID10 and re-try your experiment. if that is fast, +>>>> then you know your raid controller does bad RAID5. +>>>> +>>>> anyhow, I have in one server (our office mail server and part-time +>>>> development testing box) an adaptec SATA RAID from dell. it is +>>>> configured for RAID5 and does well for normal office stuff, but +>>>> when we do postgres tests on it, it just is plain old awful. +>>>> +>>>> but I have some LSI based cards on which RAID5 is plenty fast and +>>>> suitable for the DB, but those are SCSI. +>>>> +>>>> For what it is worth, the Dell PE1850 internal PERC4/Si card is +>>>> wicked fast when hooked up with a pair of U320 SCSI drives. +>>>> +>>>> +>>>> +>>>> ---------------------------(end of +>>>> broadcast)--------------------------- +>>>> TIP 3: Have you checked our extensive FAQ? +>>>> +>>>> http://www.postgresql.org/docs/faq +>>> +>>> ---------------------------(end of broadcast)--------------------------- +>>> TIP 9: In versions below 8.0, the planner will ignore your desire to +>>> choose an index scan if your joining column's datatypes do not +>>> match +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 6: explain analyze is your friend + +From pgsql-performance-owner@postgresql.org Mon May 1 15:50:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8C69E9F9B76 + for ; + Mon, 1 May 2006 15:50:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 98232-08 + for ; + Mon, 1 May 2006 15:50:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.mi8.com (d01gw04.mi8.com [63.240.6.44]) + by postgresql.org (Postfix) with ESMTP id 896E59F9586 + for ; + Mon, 1 May 2006 15:50:49 -0300 (ADT) +Received: from 172.16.1.148 by mail.mi8.com with ESMTP (- Welcome to Mi8 + Corporation www.Mi8.com (D4)); Mon, 01 May 2006 14:50:40 -0400 +X-Server-Uuid: C8FB4D43-1108-484A-A898-3CBCC7906230 +Received: from MI8NYCMAIL06.Mi8.com ([172.16.1.160]) by + D01HOST02.Mi8.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 1 May + 2006 14:50:40 -0400 +Received: from 67.103.45.218 ([67.103.45.218]) by MI8NYCMAIL06.Mi8.com ( + [172.16.1.219]) via Exchange Front-End Server mi8owa.mi8.com ( + [172.16.1.104]) with Microsoft Exchange Server HTTP-DAV ; Mon, 1 May + 2006 18:50:39 +0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Mon, 01 May 2006 11:50:37 -0700 +Subject: Re: hardare config question +From: "Luke Lonergan" +To: erik.myllymaki@aviawest.com, + "Tom Arthurs" +cc: "Mark Lewis" , "Vivek Khera" , + "Pgsql performance" +Message-ID: +Thread-Topic: [PERFORM] hardare config question +Thread-Index: AcZtT4dQbv4RmOAKQ/WY2aKjMGYsGwAAJsry +In-Reply-To: <445656C8.6070308@aviawest.com> +MIME-Version: 1.0 +X-OriginalArrivalTime: 01 May 2006 18:50:40.0076 (UTC) + FILETIME=[245158C0:01C66D50] +X-WSS-ID: 6848870A20C53757592-01-01 +Content-Type: multipart/alternative; + boundary=B_3229329037_1451736 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/15 +X-Sequence-Number: 18802 + +> This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +--B_3229329037_1451736 +Content-Type: text/plain; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + +We use the 3Ware BBUs and they=B9re very nice, they self monitor and let you +know about their capacity if it=B9s a problem. + +- Luke + + +On 5/1/06 11:43 AM, "Erik Myllymaki" wrote: + +> good points, thanks. +>=20 +> Tom Arthurs wrote: +>> > UPS does not protect against the tech behind the rack unplugging the +>> > power cable, or an accidental power cycle from exercising the wrong +>> > switch. :) Both are probably more common causes of failure than a tot= +al +>> > power outage. +>> > +>> > Erik Myllymaki wrote: +>>> >> I have been in discussion with 3ware support and after adjusting som= +e +>>> >> settings, the 3ware card in RAID 1 gets better performance than the +>>> >> single drive. I guess this had everything to do with the write (and +>>> >> maybe read?) cache. +>>> >> +>>> >> Of course now i am in a dangerous situation - using volatile write +>>> >> cache without a BBU. +>>> >> +>>> >> If I were to use a UPS to ensure a soft shutdown in the event of pow= +er +>>> >> loss, am I somewhat as safe as if I were to purchase a BBU for this +>>> >> RAID card? +>>> >> +>>> >> +>>> >> +>>> >> Thanks. +>>> >> +>>> >> Mark Lewis wrote: +>>>> >>> It's also possible that the single SATA drive you were testing (or= + the +>>>> >>> controller it was attached to) is lying about fsync and performing= + >>>> +write +>>>> >>> caching behind your back, whereas your new controller and drives a= +re +>>>> >>> not. +>>>> >>> +>>>> >>> You'll find a lot more info on the archives of this list about it,= + but +>>>> >>> basically if your application is committing a whole lot of small +>>>> >>> transactions, then it will run fast (but not safely) on a drive wh= +ich +>>>> >>> lies about fsync, but slower on a better disk subsystem which does= +n't +>>>> >>> lie about fsync. +>>>> >>> +>>>> >>> Try running a test with fsync=3Doff with your new equipment and if i= +t +>>>> >>> suddenly starts running faster, then you know that's the problem. +>>>> >>> You'll either have a choice of losing all of your data the next ti= +me +the +>>>> >>> system shuts down uncleanly but being fast, or of running slow, or= + of +>>>> >>> fixing the applications to use chunkier transactions. +>>>> >>> +>>>> >>> -- Mark +>>>> >>> +>>>> >>> On Fri, 2006-04-28 at 13:36 -0400, Vivek Khera wrote: +>>>>> >>>> On Apr 28, 2006, at 11:37 AM, Erik Myllymaki wrote: +>>>>> >>>> +>>>>>> >>>>> When I had this installed on a single SATA drive running from = +the +>>>>>> >>>>> PE1800's on-board SATA interface, this operation took anywhere +>>>>>> >>>>> from 65-80 seconds. +>>>>>> >>>>> +>>>>>> >>>>> With my new RAID card and drives, this operation took 272 seco= +nds!? +>>>>> >>>> switch it to RAID10 and re-try your experiment. if that is fast= +, +>>>>> >>>> then you know your raid controller does bad RAID5. +>>>>> >>>> +>>>>> >>>> anyhow, I have in one server (our office mail server and part-ti= +me +>>>>> >>>> development testing box) an adaptec SATA RAID from dell. it is +>>>>> >>>> configured for RAID5 and does well for normal office stuff, but +>>>>> >>>> when we do postgres tests on it, it just is plain old awful. +>>>>> >>>> +>>>>> >>>> but I have some LSI based cards on which RAID5 is plenty fast an= +d +>>>>> >>>> suitable for the DB, but those are SCSI. +>>>>> >>>> +>>>>> >>>> For what it is worth, the Dell PE1850 internal PERC4/Si card is +>>>>> >>>> wicked fast when hooked up with a pair of U320 SCSI drives. +>>>>> >>>> +>>>>> >>>> +>>>>> >>>> +>>>>> >>>> ---------------------------(end of +>>>>> >>>> broadcast)--------------------------- +>>>>> >>>> TIP 3: Have you checked our extensive FAQ? +>>>>> >>>> +>>>>> >>>> http://www.postgresql.org/docs/faq +>>>> >>> +>>>> >>> ---------------------------(end of +>>>> broadcast)--------------------------- +>>>> >>> TIP 9: In versions below 8.0, the planner will ignore your desire = +to +>>>> >>> choose an index scan if your joining column's datatypes do = +not +>>>> >>> match +>>> >> +>>> >> ---------------------------(end of broadcast)-----------------------= +---- +>>> >> TIP 6: explain analyze is your friend +>=20 +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: explain analyze is your friend +>=20 +>=20 + + + +--B_3229329037_1451736 +Content-Type: text/html; + charset=iso-8859-1 +Content-Transfer-Encoding: quoted-printable + + + +Re: [PERFORM] hardare config question + + +We us= +e the 3Ware BBUs and they’re very nice, they self monitor and let you = +know about their capacity if it’s a problem.
+
+- Luke
+
+
+On 5/1/06 11:43 AM, "Erik Myllymaki" <erik.myllymaki@aviawest.= +com> wrote:
+
+
good points, thanks.
+
+Tom Arthurs wrote:
+> UPS does not protect against the tech behind the rack unplugging the +> power cable, or an accidental power cycle from exercising the wrong +> switch. :)  Both are probably more common causes of failure than = +a total
+> power outage.
+>
+> Erik Myllymaki wrote:
+>> I have been in discussion with 3ware support and after adjusting s= +ome
+>> settings, the 3ware card in RAID 1 gets better performance than th= +e
+>> single drive. I guess this had everything to do with the write (an= +d
+>> maybe read?) cache.
+>>
+>> Of course now i am in a dangerous situation - using volatile write= +
+>> cache without a BBU.
+>>
+>> If I were to use a UPS to ensure a soft shutdown in the event of p= +ower
+>> loss, am I somewhat as safe as if I were to purchase a BBU for thi= +s
+>> RAID card?
+>>
+>>
+>>
+>> Thanks.
+>>
+>> Mark Lewis wrote:
+>>> It's also possible that the single SATA drive you were testing= + (or the
+>>> controller it was attached to) is lying about fsync and perfor= +ming write
+>>> caching behind your back, whereas your new controller and driv= +es are
+>>> not.
+>>>
+>>> You'll find a lot more info on the archives of this list about= + it, but
+>>> basically if your application is committing a whole lot of sma= +ll
+>>> transactions, then it will run fast (but not safely) on a driv= +e which
+>>> lies about fsync, but slower on a better disk subsystem which = +doesn't
+>>> lie about fsync.
+>>>
+>>> Try running a test with fsync=3Doff with your new equipment and = +if it
+>>> suddenly starts running faster, then you know that's the probl= +em.
+>>> You'll either have a choice of losing all of your data the nex= +t time the
+>>> system shuts down uncleanly but being fast, or of running slow= +, or of
+>>> fixing the applications to use chunkier transactions.
+>>>
+>>> -- Mark
+>>>
+>>> On Fri, 2006-04-28 at 13:36 -0400, Vivek Khera wrote:
+>>>> On Apr 28, 2006, at 11:37 AM, Erik Myllymaki wrote:
+>>>>
+>>>>> When I had this installed on a single SATA drive runni= +ng from the
+>>>>> PE1800's on-board SATA interface, this operation took = +anywhere
+>>>>> from  65-80 seconds.
+>>>>>
+>>>>> With my new RAID card and drives, this operation took = +272 seconds!?
+>>>> switch it to RAID10 and re-try your experiment.  if t= +hat is fast,
+>>>> then you know your raid controller does bad RAID5.
+>>>>
+>>>> anyhow, I have in one server (our office mail server and p= +art-time
+>>>> development testing box) an adaptec SATA RAID from dell. &= +nbsp;it is
+>>>> configured for RAID5 and does well for normal office stuff= +, but
+>>>> when  we do postgres tests on it, it just is plain ol= +d awful.
+>>>>
+>>>> but I have some LSI based cards on which RAID5 is plenty f= +ast and
+>>>> suitable for the DB, but those are SCSI.
+>>>>
+>>>> For what it is worth, the Dell PE1850 internal PERC4/Si ca= +rd is
+>>>> wicked fast when hooked up with a pair of U320 SCSI drives= +.
+>>>>
+>>>>
+>>>>
+>>>> ---------------------------(end of
+>>>> broadcast)---------------------------
+>>>> TIP 3: Have you checked our extensive FAQ?
+>>>>
+>>>>          &nbs= +p;     http://www.postgresql.org/docs/faq
+>>>
+>>> ---------------------------(end of broadcast)-----------------= +----------
+>>> TIP 9: In versions below 8.0, the planner will ignore your des= +ire to
+>>>        choose an index scan= + if your joining column's datatypes do not
+>>>        match
+>>
+>> ---------------------------(end of broadcast)---------------------= +------
+>> TIP 6: explain analyze is your friend
+
+---------------------------(end of broadcast)--------------------------- +TIP 6: explain analyze is your friend
+
+
+

+
+ + + + +--B_3229329037_1451736-- + + +From pgsql-performance-owner@postgresql.org Mon May 1 15:52:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 065229F9C10 + for ; + Mon, 1 May 2006 15:52:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 67804-09 + for ; + Mon, 1 May 2006 15:51:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 0A10D9F9B76 + for ; + Mon, 1 May 2006 15:51:57 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Mon, 1 May 2006 18:51:55 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 01 May 2006 13:51:55 -0500 +Subject: Re: hardare config question +From: Scott Marlowe +To: Tom Arthurs +Cc: erik.myllymaki@aviawest.com, Mark Lewis , + Vivek Khera , + Pgsql performance +In-Reply-To: <445651F1.9070307@jobflash.com> +References: <445236D5.5060509@aviawest.com> + <3DFCE70E-E4BB-40AB-B27F-99E90E8159CA@khera.org> + <1146246441.15712.41.camel@archimedes> <44564C3F.2040609@aviawest.com> + <445651F1.9070307@jobflash.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1146509515.22037.26.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Mon, 01 May 2006 13:51:55 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/16 +X-Sequence-Number: 18803 + +On Mon, 2006-05-01 at 13:22, Tom Arthurs wrote: +> UPS does not protect against the tech behind the rack unplugging the +> power cable, or an accidental power cycle from exercising the wrong +> switch. :) Both are probably more common causes of failure than a total +> power outage. +> +> Erik Myllymaki wrote: +> > I have been in discussion with 3ware support and after adjusting some +> > settings, the 3ware card in RAID 1 gets better performance than the +> > single drive. I guess this had everything to do with the write (and +> > maybe read?) cache. +> > +> > Of course now i am in a dangerous situation - using volatile write +> > cache without a BBU. +> > +> > If I were to use a UPS to ensure a soft shutdown in the event of power +> > loss, am I somewhat as safe as if I were to purchase a BBU for this +> > RAID card? + +Nor does it prevent an electrician from dropping a tiny piece of wire +into a power conditioner, causing a feedback that blows the other two +power conditioners, all three industrial UPSes, and the switch that +allows the Diesal generator to take over. + +When that happened to me, I had the only database server in the company +to come back up 100% in tact. You can guess by now I also had the only +database server with battery backed cache... + +From pgsql-performance-owner@postgresql.org Mon May 1 16:41:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9BB129F969C + for ; + Mon, 1 May 2006 16:41:19 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 19235-03 + for ; + Mon, 1 May 2006 16:41:11 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.aviawest.com (mail.aviawest.com [70.66.0.234]) + by postgresql.org (Postfix) with ESMTP id 6B5AE9F9586 + for ; + Mon, 1 May 2006 16:41:11 -0300 (ADT) +Received: from s0106000d5639fbfb.gv.shawcable.net ([24.69.163.91] + helo=[192.168.33.226]) + by mail.aviawest.com with asmtp (TLSv1:AES256-SHA:256) (Exim 4.24) + id 1FaeFu-0006Kc-1a; Mon, 01 May 2006 12:40:26 -0700 +Message-ID: <44566426.2040707@aviawest.com> +Date: Mon, 01 May 2006 12:40:22 -0700 +From: Erik Myllymaki +Reply-To: erik.myllymaki@aviawest.com +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: Scott Marlowe +CC: Tom Arthurs , Mark Lewis , + Vivek Khera , + Pgsql performance +Subject: Re: hardare config question +References: <445236D5.5060509@aviawest.com> + <3DFCE70E-E4BB-40AB-B27F-99E90E8159CA@khera.org> + <1146246441.15712.41.camel@archimedes> + <44564C3F.2040609@aviawest.com> <445651F1.9070307@jobflash.com> + <1146509515.22037.26.camel@state.g2switchworks.com> +In-Reply-To: <1146509515.22037.26.camel@state.g2switchworks.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-"AviawestResorts"-MailScanner-Information: Please contact the ISP for more + information +X-"AviawestResorts"-MailScanner: Found to be clean +X-MailScanner-From: erik.myllymaki@aviawest.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/18 +X-Sequence-Number: 18805 + +guess who just bought a 3ware BBU on ebay... + +Thanks for all the posts, consider me educated! + +(on the importance of BBU on RAID controllers, anyway) + +:) + + +Scott Marlowe wrote: +> On Mon, 2006-05-01 at 13:22, Tom Arthurs wrote: +>> UPS does not protect against the tech behind the rack unplugging the +>> power cable, or an accidental power cycle from exercising the wrong +>> switch. :) Both are probably more common causes of failure than a total +>> power outage. +>> +>> Erik Myllymaki wrote: +>>> I have been in discussion with 3ware support and after adjusting some +>>> settings, the 3ware card in RAID 1 gets better performance than the +>>> single drive. I guess this had everything to do with the write (and +>>> maybe read?) cache. +>>> +>>> Of course now i am in a dangerous situation - using volatile write +>>> cache without a BBU. +>>> +>>> If I were to use a UPS to ensure a soft shutdown in the event of power +>>> loss, am I somewhat as safe as if I were to purchase a BBU for this +>>> RAID card? +> +> Nor does it prevent an electrician from dropping a tiny piece of wire +> into a power conditioner, causing a feedback that blows the other two +> power conditioners, all three industrial UPSes, and the switch that +> allows the Diesal generator to take over. +> +> When that happened to me, I had the only database server in the company +> to come back up 100% in tact. You can guess by now I also had the only +> database server with battery backed cache... +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, 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 May 1 16:48:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5ABFD9FA2C7 + for ; + Mon, 1 May 2006 16:48:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29973-10 + for ; + Mon, 1 May 2006 16:48:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.89glass.com (mail.89glass.com [72.10.2.250]) + by postgresql.org (Postfix) with SMTP id 83B169F9586 + for ; + Mon, 1 May 2006 16:48:38 -0300 (ADT) +Received: (qmail 27065 invoked by uid 1006); 1 May 2006 19:48:36 -0000 +Received: from 192.168.254.111 by lumberjack (envelope-from + , + uid 201) with qmail-scanner-1.25 (clamdscan: 0.67. + Clear:RC:1(192.168.254.111):. + Processed in 0.032636 secs); 01 May 2006 19:48:36 -0000 +Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; + s=domkey; d=rbsinteractive.com; + b=x/cnIkExLNDVpMU+yYqeo7d4ixsWL2KinuFNhxx0PC863nPn/RhoJaxaGFbnVXDj9I2cmHuAHrpsWKMAGzJmt/zuS+PgDNzZvZqUMyJ8FF3AbgK9trpknogYfS9iziVK6nGaNWj4k+65SALD3jZFQdaa2I5Up25J6nif/b/059M= + ; +Received: from unknown (HELO ?192.168.254.111?) (192.168.254.111) + by mail.89glass.com with SMTP; 1 May 2006 19:48:36 -0000 +Message-ID: <44566612.8020709@rbsinteractive.com> +Date: Mon, 01 May 2006 12:48:34 -0700 +From: Nolan Cafferky +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Cluster vs. non-cluster query planning +References: <445644F9.2020708@rbsinteractive.com> +In-Reply-To: <445644F9.2020708@rbsinteractive.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/19 +X-Sequence-Number: 18806 + +> Questions: +> * What can I do to reduce the estimated row count on the query? +> * Why does clustering drive down the estimated cost for the index scan +> so much? Does a change in correlation from .72 to 1 make that much of +> a difference? +> * Can I convince my query planner to index scan without clustering on +> the order_statuses_id index, or setting enable_seqscan = off? + + +After some more digging on the mailing list, I found some comments on +effective_cache_size. Bringing it up from the default of 1000 does pust +the estimated cost for the index scan below that of the sequential scan, +but not by much. + +With SET effective_cache_size = 1000: + Seq Scan on orders o (cost=1.20..11395.53 rows=7029 width=8) (actual +time=280.148..281.512 rows=105 loops=1) + Filter: (order_statuses_id = $0) + InitPlan + -> Seq Scan on order_statuses (cost=0.00..1.20 rows=1 width=4) +(actual time=0.012..0.020 rows=1 loops=1) + Filter: ((id_name)::text = 'new'::text) + Total runtime: 281.700 ms + +With SET effective_cache_size = 10000: + Index Scan using orders_status_btree_idx on orders o +(cost=1.20..9710.91 rows=7029 width=8) (actual time=0.050..0.372 +rows=105 loops=1) + Index Cond: (order_statuses_id = $0) + InitPlan + -> Seq Scan on order_statuses (cost=0.00..1.20 rows=1 width=4) +(actual time=0.016..0.024 rows=1 loops=1) + Filter: ((id_name)::text = 'new'::text) + +The ratios between estimated costs are still nowhere near the ratio of +actual costs. + +From pgsql-performance-owner@postgresql.org Mon May 1 17:30:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0412A9FA2C7 + for ; + Mon, 1 May 2006 17:30:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 24285-04 + for ; + Mon, 1 May 2006 17:30:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 36E5E9FA1B0 + for ; + Mon, 1 May 2006 17:30:45 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k41KUiKF008045; + Mon, 1 May 2006 16:30:44 -0400 (EDT) +To: Nolan Cafferky +cc: pgsql-performance@postgresql.org +Subject: Re: Cluster vs. non-cluster query planning +In-reply-to: <44566612.8020709@rbsinteractive.com> +References: <445644F9.2020708@rbsinteractive.com> + <44566612.8020709@rbsinteractive.com> +Comments: In-reply-to Nolan Cafferky + message dated "Mon, 01 May 2006 12:48:34 -0700" +Date: Mon, 01 May 2006 16:30:44 -0400 +Message-ID: <8044.1146515444@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/20 +X-Sequence-Number: 18807 + +Nolan Cafferky writes: +> After some more digging on the mailing list, I found some comments on +> effective_cache_size. Bringing it up from the default of 1000 does pust +> the estimated cost for the index scan below that of the sequential scan, +> but not by much. + +The first-order knob for tuning indexscan vs seqscan costing is +random_page_cost. What have you got that set to? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon May 1 18:08:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3962D9FA261 + for ; + Mon, 1 May 2006 18:08:16 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 77783-08 + for ; + Mon, 1 May 2006 18:08:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.89glass.com (mail.89glass.com [72.10.2.250]) + by postgresql.org (Postfix) with SMTP id 7CF549FA2C5 + for ; + Mon, 1 May 2006 18:08:04 -0300 (ADT) +Received: (qmail 2109 invoked by uid 1006); 1 May 2006 21:08:02 -0000 +Received: from 192.168.254.111 by lumberjack (envelope-from + , + uid 201) with qmail-scanner-1.25 (clamdscan: 0.67. + Clear:RC:1(192.168.254.111):. + Processed in 0.028679 secs); 01 May 2006 21:08:02 -0000 +Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; + s=domkey; d=rbsinteractive.com; + b=UWZTv0AZQzdZQmryqTFgldh3HsF9+bukz21efKc6Bekj0ZQTWXkhcoaMPucpS5DV4F2N0WTaueKETmvUAg4dKb+4sNYsCzCK5v2fOTefnll89bjDuLJUAVpYoSLE49pD1iZYJHO3x+9oLp/iCXVZ9vH554J1ZODkvQ5a15bynFQ= + ; +Received: from unknown (HELO ?192.168.254.111?) (192.168.254.111) + by mail.89glass.com with SMTP; 1 May 2006 21:08:02 -0000 +Message-ID: <445678B1.9050908@rbsinteractive.com> +Date: Mon, 01 May 2006 14:08:01 -0700 +From: Nolan Cafferky +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +CC: pgsql-performance@postgresql.org +Subject: Re: Cluster vs. non-cluster query planning +References: <445644F9.2020708@rbsinteractive.com> + <44566612.8020709@rbsinteractive.com> + <8044.1146515444@sss.pgh.pa.us> +In-Reply-To: <8044.1146515444@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/21 +X-Sequence-Number: 18808 + +Tom Lane wrote: + +>The first-order knob for tuning indexscan vs seqscan costing is +>random_page_cost. What have you got that set to? +> +> +This is currently at the default of 4. All of my other planner cost +constants are at default values as well. Dropping it to 1 drops the +estimated cost by a comparable ratio: + + Index Scan using orders_status_btree_idx on orders o +(cost=1.20..3393.20 rows=7026 width=8) (actual time=0.050..0.314 +rows=105 loops=1) + Index Cond: (order_statuses_id = $0) + InitPlan + -> Seq Scan on order_statuses (cost=0.00..1.20 rows=1 width=4) +(actual time=0.017..0.025 rows=1 loops=1) + Filter: ((id_name)::text = 'new'::text) + Total runtime: 0.498 ms + +But, I'm guessing that random_page_cost = 1 is not a realistic value. + +From pgsql-performance-owner@postgresql.org Mon May 1 18:33:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C1A629FA2C7 + for ; + Mon, 1 May 2006 18:33:24 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 86602-04 + for ; + Mon, 1 May 2006 18:33:15 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.wirelesscar.com (mail.wirelesscar.com [212.209.35.30]) + by postgresql.org (Postfix) with ESMTP id 754FE9FA261 + for ; + Mon, 1 May 2006 18:33:15 -0300 (ADT) +Received: from sesrv12.wirelesscar.com ([192.168.10.17]) by + mail.wirelesscar.com with InterScan Messaging Security Suite; + Mon, 01 May 2006 23:33:08 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Hardware: HP StorageWorks MSA 1500 +Date: Mon, 1 May 2006 23:33:58 +0200 +Message-ID: <7F10D26ECFA1FB458B89C5B4B0D72C2B3E436D@sesrv12.wirelesscar.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Hardware: HP StorageWorks MSA 1500 +Thread-Index: AcZryb1o/X2VYEJYSuCHIa3Cds1aBwAGjn6g +From: "Mikael Carneholm" +To: , + +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/22 +X-Sequence-Number: 18809 + +>My server is the HP DL585 (quad, dual-core Opteron, 16GB RAM) with 4 HD +bays run by a HP SmartArray 5i controller. I have 15 10K 300GB >drives +and 1 15K 150GB drive (don't ask how that happened). + +Our server will be a DL385 (dual, dual-core Opteron, 16Gb RAM), and the +28 disks(10K 146Gb)in the MSA1500 will probably be set up in SAME +configuration (Stripe All, Mirror Everything). Still to be decided +though. I'll post both pgbench and BenchmarkSQL +(http://sourceforge.net/projects/benchmarksql) results here as soon as +we have the machine set up. OS+log(not WAL) will recide on directly +attached disks, and all heavy reading+writing will be taken care of by +the MSA. + +Not sure how much of the cache module that will be used for reads, but +as our peak write load is quite high we'll probably use at least half of +it for writes (good write performance is pretty much the key for the +application in question) + +>How would/do you guys set up your MSA1x00 with 1 drive sled? RAID10 vs +>RAID5 across 10+ disks? + +Since it's a datawarehouse type of application, you'd probably optimize +for large storage capacity and read (rather than write) performance, and +in that case I guess raid5 could be considered, at least. Depends very +much on reliability requirements though - raid5 performs much worse than +raid10 in degraded mode (one disk out). Here's an interesting read +regarding raid5 vs raid10 (NOT very pro-raid5 :) ) +http://www.miracleas.com/BAARF/RAID5_versus_RAID10.txt + +Regards, +Mikael + + + +From pgsql-performance-owner@postgresql.org Mon May 1 20:35:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 29BBC9FA3CD + for ; + Mon, 1 May 2006 20:35:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 93254-09 + for ; + Mon, 1 May 2006 20:35:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 1B0339FA2BE + for ; + Mon, 1 May 2006 20:35:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k41NZ255020935; + Mon, 1 May 2006 19:35:02 -0400 (EDT) +To: Nolan Cafferky +cc: pgsql-performance@postgresql.org +Subject: Re: Cluster vs. non-cluster query planning +In-reply-to: <445678B1.9050908@rbsinteractive.com> +References: <445644F9.2020708@rbsinteractive.com> + <44566612.8020709@rbsinteractive.com> + <8044.1146515444@sss.pgh.pa.us> + <445678B1.9050908@rbsinteractive.com> +Comments: In-reply-to Nolan Cafferky + message dated "Mon, 01 May 2006 14:08:01 -0700" +Date: Mon, 01 May 2006 19:35:02 -0400 +Message-ID: <20934.1146526502@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/23 +X-Sequence-Number: 18810 + +Nolan Cafferky writes: +> But, I'm guessing that random_page_cost = 1 is not a realistic value. + +Well, that depends. If all your data can be expected to fit in memory +then it is a realistic value. (If not, you should be real careful not +to make performance decisions on the basis of test cases that *do* fit +in RAM...) + +In any case, if I recall your numbers correctly you shouldn't need to +drop it nearly that far to get the thing to make the right choice. +A lot of people run with random_page_cost set to 2 or so. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon May 1 21:02:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1AE7A9FA3CD + for ; + Mon, 1 May 2006 21:02:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27027-04 + for ; + Mon, 1 May 2006 21:02:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.89glass.com (mail.89glass.com [72.10.2.250]) + by postgresql.org (Postfix) with SMTP id 3D2929FA2BE + for ; + Mon, 1 May 2006 21:02:00 -0300 (ADT) +Received: (qmail 25859 invoked by uid 1006); 2 May 2006 00:01:58 -0000 +Received: from 192.168.254.111 by lumberjack (envelope-from + , + uid 201) with qmail-scanner-1.25 (clamdscan: 0.67. + Clear:RC:1(192.168.254.111):. + Processed in 0.060224 secs); 02 May 2006 00:01:58 -0000 +Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; + s=domkey; d=rbsinteractive.com; + b=TVk7S+JQOqPVHoAN+yZSrPDYOjAJ+mhHTh2w7Zv7AE+Cn/vT8Gqdp4e9ou0HDabSs3ymr8tJgZ0li1l242No9KJRvJbamt5La4WZcFPj2unc9+b+POqA+cUznhC+Zrx88TK8MaECOmEZSGTe1xvjn8grKjLRzCSxpRpCIaW8gKc= + ; +Received: from unknown (HELO ?192.168.254.111?) (192.168.254.111) + by mail.89glass.com with SMTP; 2 May 2006 00:01:58 -0000 +Message-ID: <4456A177.3020505@rbsinteractive.com> +Date: Mon, 01 May 2006 17:01:59 -0700 +From: Nolan Cafferky +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +CC: pgsql-performance@postgresql.org +Subject: Re: Cluster vs. non-cluster query planning +References: <445644F9.2020708@rbsinteractive.com> + <44566612.8020709@rbsinteractive.com> + <8044.1146515444@sss.pgh.pa.us> + <445678B1.9050908@rbsinteractive.com> + <20934.1146526502@sss.pgh.pa.us> +In-Reply-To: <20934.1146526502@sss.pgh.pa.us> +Content-Type: multipart/alternative; + boundary="------------060601050208010305000704" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/24 +X-Sequence-Number: 18811 + +This is a multi-part message in MIME format. +--------------060601050208010305000704 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Tom Lane wrote: + +>Nolan Cafferky writes: +> +>>But, I'm guessing that random_page_cost = 1 is not a realistic value. +>> +> +>Well, that depends. If all your data can be expected to fit in memory +>then it is a realistic value. (If not, you should be real careful not +>to make performance decisions on the basis of test cases that *do* fit +>in RAM...) +> +>In any case, if I recall your numbers correctly you shouldn't need to +>drop it nearly that far to get the thing to make the right choice. +>A lot of people run with random_page_cost set to 2 or so. +> +Thanks for the advice. I will check what changing random_page_cost does +for the rest of the queries on our system. + +I did learn why the estimated row count was so high. This is new +knowledge to me, so I'm going to share it. + +SELECT reltuples FROM pg_class WHERE relname = 'orders'; -> produces 98426. +SELECT n_distinct FROM pg_stats WHERE tablename = 'orders' and attname = +'order_statuses_id'; -> currently 13. + + Seq Scan on orders o (cost=1.20..11395.53 rows=7570 width=8) (actual +time=283.599..285.031 rows=105 loops=1) + Filter: (order_statuses_id = $0) + InitPlan + -> Seq Scan on order_statuses (cost=0.00..1.20 rows=1 width=4) +(actual time=0.031..0.038 rows=1 loops=1) + Filter: ((id_name)::text = 'new'::text) + Total runtime: 285.225 ms + +(98426 / 13)::integer = 7571 ~= 7570, the estimated row count. + +So the query planner isn't able to combine the knowledge of the id value +from order_statuses with most_common_vals, most_common_freqs, or +histogram_bounds from pg_stats. That seems a little odd to me, but maybe +it makes sense. I suppose the planner can't start executing parts of the +query to aid in the planning process. + +In the future, I will probably pre-select from order_statuses before +executing this query. + +Thanks! + + +--------------060601050208010305000704 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + +Tom Lane wrote: +
+
Nolan Cafferky <Nolan.Cafferky@rbsinteractive.com> writes:
+
+
+
But, I'm guessing that random_page_cost = 1 is not a realistic value.
+
+
+

+Well, that depends.  If all your data can be expected to fit in memory
+then it is a realistic value.  (If not, you should be real careful not
+to make performance decisions on the basis of test cases that *do* fit
+in RAM...)
+
+In any case, if I recall your numbers correctly you shouldn't need to
+drop it nearly that far to get the thing to make the right choice.
+A lot of people run with random_page_cost set to 2 or so.
+
+
+Thanks for the advice.  I will check what changing random_page_cost +does for the rest of the queries on our system.
+
+I did learn why the estimated row count was so high.  This is new +knowledge to me, so I'm going to share it.
+
+SELECT reltuples FROM pg_class WHERE relname = 'orders'; -> produces +98426.
+SELECT n_distinct FROM pg_stats WHERE tablename = 'orders' and attname += 'order_statuses_id'; -> currently 13.
+
+ Seq Scan on orders o  (cost=1.20..11395.53 rows=7570 width=8) (actual +time=283.599..285.031 rows=105 loops=1)
+   Filter: (order_statuses_id = $0)
+   InitPlan
+     ->  Seq Scan on order_statuses  (cost=0.00..1.20 rows=1 +width=4) (actual time=0.031..0.038 rows=1 loops=1)
+           Filter: ((id_name)::text = 'new'::text)
+ Total runtime: 285.225 ms
+
+(98426 / 13)::integer = 7571 ~= 7570, the estimated row count.
+
+So the query planner isn't able to combine the knowledge of the id +value from order_statuses with most_common_vals, most_common_freqs, or +histogram_bounds from pg_stats. That seems a little odd to me, but +maybe it makes sense. I suppose the planner can't start executing parts +of the query to aid in the planning process.
+
+In the future, I will probably pre-select from order_statuses before +executing this query.
+
+Thanks!
+
+
+ + + +--------------060601050208010305000704-- + +From pgsql-performance-owner@postgresql.org Wed May 3 03:16:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E754B9FA2BE + for ; + Mon, 1 May 2006 23:02:59 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 97855-02 + for ; + Mon, 1 May 2006 23:02:22 -0300 (ADT) +X-Greylist: delayed 00:34:19.923234 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id AB8B19FB1BD + for ; + Mon, 1 May 2006 23:02:22 -0300 (ADT) +Received: from ls405.htnet.hr (ls405.t-com.hr [195.29.150.135]) + by svr4.postgresql.org (Postfix) with ESMTP id 1D6945B39E0 + for ; + Tue, 2 May 2006 01:28:00 +0000 (GMT) +Received: from ls401.t-com.hr (ls401.t-com.hr [195.29.150.236]) + by ls405.htnet.hr (Postfix) with ESMTP id C9A79147092 + for ; + Tue, 2 May 2006 03:27:56 +0200 (CEST) +Received: from ls401.t-com.hr (localhost.localdomain [127.0.0.1]) + by ls401.t-com.hr (Qmlai) with ESMTP id C1A7BE38E3 + for ; + Tue, 2 May 2006 03:27:56 +0200 (CEST) +X-Envelope-Sender: msplival@jagor.srce.hr +Received: from 83-131-111-1.adsl.net.t-com.hr + (83-131-111-1.adsl.net.t-com.hr [83.131.111.1])by ls401.t-com.hr + (Qmlai) + with ESMTP id 2941038002for ; + Tue, 2 May 2006 03:27:55 +0200 (CEST) +Subject: Lot'sa joins - performance tip-up, please? +From: Mario Splivalo +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Date: Tue, 02 May 2006 03:27:54 +0200 +Message-Id: <1146533274.14006.11.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-imss-version: 2.038 +X-imss-result: Passed +X-imss-scores: Clean:68.97908 C:2 M:3 S:5 R:5 +X-imss-settings: Baseline:1 C:1 M:1 S:1 R:1 (0.0000 0.0000) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/73 +X-Sequence-Number: 18860 + +I have a quite large query that takes over a minute to run on my laptop. +On the db server it takes olmost 20 seconds, but I have 200+ concurent +users who will be running similair querries, and during the query the +I/O goes bezerk, I read 30MB/s reading (iostat tells so). So, before +going into denormalization, I wonder if I could do something to speed +things up. + +The query is like this: + +select + * +from + messages + join services on services.id = messages.service_id + join ticketing_messages on messages.id = ticketing_messages.message_id + left join ticketing_winners on ticketing_winners.message_id = +ticketing_messages.message_id + left join + ( + select + * + from + ticketing_codes_played + join ticketing_codes on ticketing_codes.code_id = +ticketing_codes_played.code_id + ) as codes on codes.message_id = ticketing_messages.message_id +where + services.type_id = 10 +and + messages.receiving_time between '2006-02-12' and '2006-03-18 23:00:00'; + +The explain analyze of the above produces this: + + +QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------------------- + Merge Left Join (cost=221692.04..222029.29 rows=3772 width=264) +(actual time=539169.163..541579.504 rows=75937 loops=1) + Merge Cond: ("outer".message_id = "inner".message_id) + -> Sort (cost=40080.17..40089.60 rows=3772 width=238) (actual +time=8839.072..9723.371 rows=75937 loops=1) + Sort Key: messages.id + -> Hash Left Join (cost=2259.40..39856.10 rows=3772 +width=238) (actual time=1457.451..7870.830 rows=75937 loops=1) + Hash Cond: ("outer".message_id = "inner".message_id) + -> Nested Loop (cost=2234.64..39811.76 rows=3772 +width=230) (actual time=1418.911..7063.299 rows=75937 loops=1) + -> Index Scan using pk_services on services +(cost=0.00..4.46 rows=1 width=54) (actual time=28.261..28.271 rows=1 +loops=1) + Index Cond: (1102 = id) + Filter: (type_id = 10) + -> Hash Join (cost=2234.64..39769.58 rows=3772 +width=176) (actual time=1390.621..6297.501 rows=75937 loops=1) + Hash Cond: ("outer".id = "inner".message_id) + -> Bitmap Heap Scan on messages +(cost=424.43..32909.53 rows=74408 width=162) (actual +time=159.796..4329.125 rows=75937 loops=1) + Recheck Cond: (service_id = 1102) + -> Bitmap Index Scan on idx_service_id +(cost=0.00..424.43 rows=74408 width=0) (actual time=95.197..95.197 +rows=75937 loops=1) + Index Cond: (service_id = 1102) + -> Hash (cost=1212.37..1212.37 rows=75937 +width=14) (actual time=940.372..940.372 rows=75937 loops=1) + -> Seq Scan on ticketing_messages +(cost=0.00..1212.37 rows=75937 width=14) (actual time=12.122..461.960 +rows=75937 loops=1) + -> Hash (cost=21.21..21.21 rows=1421 width=8) (actual +time=38.496..38.496 rows=1421 loops=1) + -> Seq Scan on ticketing_winners +(cost=0.00..21.21 rows=1421 width=8) (actual time=24.534..31.347 +rows=1421 loops=1) + -> Sort (cost=181611.87..181756.68 rows=57925 width=26) (actual +time=530330.060..530647.055 rows=57925 loops=1) + Sort Key: ticketing_codes_played.message_id + -> Nested Loop (cost=0.00..176144.30 rows=57925 width=26) +(actual time=68.322..529472.026 rows=57925 loops=1) + -> Seq Scan on ticketing_codes_played +(cost=0.00..863.25 rows=57925 width=8) (actual time=0.042..473.881 +rows=57925 loops=1) + -> Index Scan using ticketing_codes_pk on +ticketing_codes (cost=0.00..3.01 rows=1 width=18) (actual +time=9.102..9.108 rows=1 loops=57925) + Index Cond: (ticketing_codes.code_id = +"outer".code_id) + Total runtime: 542000.093 ms +(27 rows) + + +I'll be more than happy to provide any additional information that I may +be able to gather. I'd be most happy if someone would scream something +like "four joins, smells like a poor design" because design is poor, but +the system is in production, and I have to bare with it. + + Mario +-- +"I can do it quick, I can do it cheap, I can do it well. Pick any two." + +Mario Splivalo +msplival@jagor.srce.hr + + + +From pgsql-performance-owner@postgresql.org Mon May 1 23:14:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 16E0D9FB1BA + for ; + Mon, 1 May 2006 23:14:40 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 00157-10 + for ; + Mon, 1 May 2006 23:14:30 -0300 (ADT) +X-Greylist: delayed 00:37:17.642885 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 05AAD9FA3CD + for ; + Mon, 1 May 2006 23:14:29 -0300 (ADT) +Received: from mail.goldpocket.com (mail1.goldpocket.com [38.101.116.14]) + by svr4.postgresql.org (Postfix) with ESMTP id B0B3B5B3F82 + for ; + Tue, 2 May 2006 01:37:10 +0000 (GMT) +Received: from localhost (unknown [127.0.0.1]) + by mail.goldpocket.com (Postfix) with ESMTP id A935DE048F9A + for ; + Tue, 2 May 2006 01:37:07 +0000 (UTC) +Received: from mail.goldpocket.com ([127.0.0.1]) + by localhost (mail.goldpocket.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 20256-15 for ; + Mon, 1 May 2006 18:37:04 -0700 (PDT) +Received: from mail1.goldpocket.com (srvgpimail1.gpi.local [10.10.0.13]) + by mail.goldpocket.com (Postfix) with ESMTP id 0753CE048B8E + for ; + Mon, 1 May 2006 18:37:04 -0700 (PDT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C66D88.EA2242A1" +Subject: Why is plan (and performance) different on partitioned table? +Date: Mon, 1 May 2006 18:37:03 -0700 +Message-ID: <9D938282F8C6EE43B748B910386DE93E0138B43C@srvgpimail1.GPI.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Why is plan (and performance) different on partitioned table? +Thread-Index: AcZtiOoRyv2570fySr+BrjC/0bsw5Q== +From: "Mark Liberman" +To: +X-Virus-Scanned: amavisd-new at goldpocket.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/25 +X-Sequence-Number: 18812 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C66D88.EA2242A1 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +Hi, + +I have recently implemented table partitioning in our postgres 8.1 db. = +Upon analyzing query performance, I have realized that, even when only a = +single one of the "partitions" has to be scanned, the plan is = +drastically different, and performs much worse, when I query against the = +master table (uses merge join), vs. a direct query against the partition = +directly (uses a hash join). The majority of our queries only access a = +single partition. + +Any insight into why this happens and what can be done to improve = +performance would be greatly appreciated. + +br_1min is my partitioned table: + +explain analyze +SELECT * +FROM br_1min br1 JOIN br_mods mod on br1.modules_id =3D mod.id =20 +WHERE ((end_time >=3D '2006-05-01 17:12:18-07' AND end_time < = +'2006-05-01 17:13:18-07')) + AND mod.downloads_id IN = +(153226,153714,153730,153728,153727,153724,153713,153725,153739,153722) = +; + +-------------------------------------------------------------------------= +--------------------------------------------------------- + Merge Join (cost=3D73.99..223.43 rows=3D1 width=3D109) (actual = +time=3D2925.629..3082.188 rows=3D45 loops=3D1) + Merge Cond: ("outer".id =3D "inner".modules_id) + -> Index Scan using br_mods_id_pkey on br_mods mod = +(cost=3D0.00..40861.18 rows=3D282 width=3D77) (actual = +time=3D2922.223..3078.335 rows=3D45 loops=3D1) + Filter: ((downloads_id =3D 153226) OR (downloads_id =3D 153714) = +OR (downloads_id =3D 153730) OR (downloads_id =3D 153728) OR = +(downloads_id =3D 153727) OR (downloads_id =3D 153724) OR (downloads_id = +=3D 153713) OR (downloads_id =3D 153725) OR (downloads_id =3D 153739) OR = +(downloads_id =3D 153722)) + -> Sort (cost=3D73.99..76.26 rows=3D906 width=3D32) (actual = +time=3D3.334..3.508 rows=3D348 loops=3D1) + Sort Key: br1.modules_id + -> Append (cost=3D0.00..29.49 rows=3D906 width=3D32) (actual = +time=3D0.133..2.169 rows=3D910 loops=3D1) + -> Index Scan using br_1min_end_idx on br_1min br1 = +(cost=3D0.00..2.02 rows=3D1 width=3D32) (actual time=3D0.029..0.029 = +rows=3D0 loops=3D1) + Index Cond: ((end_time >=3D '2006-05-01 = +17:12:18-07'::timestamp with time zone) AND (end_time < '2006-05-01 = +17:13:18-07'::timestamp with time zone)) + -> Index Scan using br_1min_20557_end_idx on = +br_1min_20557 br1 (cost=3D0.00..27.48 rows=3D905 width=3D32) (actual = +time=3D0.101..1.384 rows=3D910 loops=3D1) + Index Cond: ((end_time >=3D '2006-05-01 = +17:12:18-07'::timestamp with time zone) AND (end_time < '2006-05-01 = +17:13:18-07'::timestamp with time zone)) + Total runtime: 3082.450 ms +(12 rows) + + + +Now, If I query directly against br_1min_20557, my partition, I get: + +explain analyze +SELECT * +FROM br_1min_20557 br1 JOIN br_mods mod on br1.modules_id =3D mod.id =20 +WHERE ((end_time >=3D '2006-05-01 17:12:18-07' AND end_time < = +'2006-05-01 17:13:18-07')) + AND mod.downloads_id IN = +(153226,153714,153730,153728,153727,153724,153713,153725,153739,153722) = +; + + +-------------------------------------------------------------------------= +--------------------------------------------------------------------- + Hash Join (cost=3D764.74..796.94 rows=3D1 width=3D109) (actual = +time=3D2.488..2.865 rows=3D45 loops=3D1) + Hash Cond: ("outer".modules_id =3D "inner".id) + -> Index Scan using br_1min_20557_end_idx on br_1min_20557 br1 = +(cost=3D0.00..27.62 rows=3D914 width=3D32) (actual time=3D0.084..1.886 = +rows=3D910 loops=3D1) + Index Cond: ((end_time >=3D '2006-05-01 17:12:18-07'::timestamp = +with time zone) AND (end_time < '2006-05-01 17:13:18-07'::timestamp with = +time zone)) + -> Hash (cost=3D764.03..764.03 rows=3D282 width=3D77) (actual = +time=3D0.284..0.284 rows=3D45 loops=3D1) + -> Bitmap Heap Scan on br_mods mod (cost=3D20.99..764.03 = +rows=3D282 width=3D77) (actual time=3D0.154..0.245 rows=3D45 loops=3D1) + Recheck Cond: ((downloads_id =3D 153226) OR (downloads_id = +=3D 153714) OR (downloads_id =3D 153730) OR (downloads_id =3D 153728) OR = +(downloads_id =3D 153727) OR (downloads_id =3D 153724) OR (downloads_id = +=3D 153713) OR (downloads_id =3D 153725) OR (downloads_id =3D 153739) OR = +(downloads_id =3D 153722)) + -> BitmapOr (cost=3D20.99..20.99 rows=3D282 width=3D0) = +(actual time=3D0.144..0.144 rows=3D0 loops=3D1) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.031..0.031 = +rows=3D14 loops=3D1) + Index Cond: (downloads_id =3D 153226) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.011..0.011 = +rows=3D2 loops=3D1) + Index Cond: (downloads_id =3D 153714) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.007..0.007 = +rows=3D2 loops=3D1) + Index Cond: (downloads_id =3D 153730) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.007..0.007 = +rows=3D2 loops=3D1) + Index Cond: (downloads_id =3D 153728) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.008..0.008 = +rows=3D2 loops=3D1) + Index Cond: (downloads_id =3D 153727) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.008..0.008 = +rows=3D2 loops=3D1) + Index Cond: (downloads_id =3D 153724) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.008..0.008 = +rows=3D2 loops=3D1) + Index Cond: (downloads_id =3D 153713) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.008..0.008 = +rows=3D2 loops=3D1) + Index Cond: (downloads_id =3D 153725) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.041..0.041 = +rows=3D16 loops=3D1) + Index Cond: (downloads_id =3D 153739) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.010..0.010 = +rows=3D1 loops=3D1) + Index Cond: (downloads_id =3D 153722) + Total runtime: 3.017 ms +(29 rows) + +The difference is night-and-day. Any suggestions? + +Thanks alot, + +Mark + +------_=_NextPart_001_01C66D88.EA2242A1 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +Why is plan (and performance) different on partitioned = +table? + + + + +

Hi,
+
+I have recently implemented table partitioning in our postgres 8.1 db. = +Upon analyzing query performance, I have realized that, even when only a = +single one of the "partitions" has to be scanned, the plan is = +drastically different, and performs much worse, when I query against the = +master table (uses merge join), vs. a direct query against the partition = +directly (uses a hash join).  The majority of our queries only = +access a single partition.
+
+Any insight into why this happens and what can be done to improve = +performance would be greatly appreciated.
+
+br_1min is my partitioned table:
+
+explain analyze
+SELECT *
+FROM br_1min br1 JOIN br_mods mod on br1.modules_id =3D mod.id 
+WHERE ((end_time >=3D '2006-05-01 17:12:18-07' AND end_time < = +'2006-05-01 17:13:18-07'))
+  AND mod.downloads_id IN = +(153226,153714,153730,153728,153727,153724,153713,153725,153739,153722) = +;
+
+-------------------------------------------------------------------------= +---------------------------------------------------------
+ Merge Join  (cost=3D73.99..223.43 rows=3D1 width=3D109) = +(actual time=3D2925.629..3082.188 rows=3D45 loops=3D1)
+   Merge Cond: ("outer".id =3D = +"inner".modules_id)
+   ->  Index Scan using br_mods_id_pkey on br_mods = +mod  (cost=3D0.00..40861.18 rows=3D282 width=3D77) (actual = +time=3D2922.223..3078.335 rows=3D45 loops=3D1)
+         Filter: ((downloads_id = +=3D 153226) OR (downloads_id =3D 153714) OR (downloads_id =3D 153730) OR = +(downloads_id =3D 153728) OR (downloads_id =3D 153727) OR (downloads_id = +=3D 153724) OR (downloads_id =3D 153713) OR (downloads_id =3D 153725) OR = +(downloads_id =3D 153739) OR (downloads_id =3D 153722))
+   ->  Sort  (cost=3D73.99..76.26 rows=3D906 = +width=3D32) (actual time=3D3.334..3.508 rows=3D348 loops=3D1)
+         Sort Key: = +br1.modules_id
+         ->  = +Append  (cost=3D0.00..29.49 rows=3D906 width=3D32) (actual = +time=3D0.133..2.169 rows=3D910 loops=3D1)
+            &= +nbsp;  ->  Index Scan using br_1min_end_idx on br_1min = +br1  (cost=3D0.00..2.02 rows=3D1 width=3D32) (actual = +time=3D0.029..0.029 rows=3D0 loops=3D1)
+            &= +nbsp;        Index Cond: ((end_time = +>=3D '2006-05-01 17:12:18-07'::timestamp with time zone) AND = +(end_time < '2006-05-01 17:13:18-07'::timestamp with time zone))
+            &= +nbsp;  ->  Index Scan using br_1min_20557_end_idx on = +br_1min_20557 br1  (cost=3D0.00..27.48 rows=3D905 width=3D32) = +(actual time=3D0.101..1.384 rows=3D910 loops=3D1)
+            &= +nbsp;        Index Cond: ((end_time = +>=3D '2006-05-01 17:12:18-07'::timestamp with time zone) AND = +(end_time < '2006-05-01 17:13:18-07'::timestamp with time zone))
+ Total runtime: 3082.450 ms
+(12 rows)
+
+
+
+Now, If I query directly against br_1min_20557, my partition, I get:
+
+explain analyze
+SELECT *
+FROM br_1min_20557 br1 JOIN br_mods mod on br1.modules_id =3D = +mod.id 
+WHERE ((end_time >=3D '2006-05-01 17:12:18-07' AND end_time < = +'2006-05-01 17:13:18-07'))
+  AND mod.downloads_id IN = +(153226,153714,153730,153728,153727,153724,153713,153725,153739,153722) = +;
+
+
+-------------------------------------------------------------------------= +---------------------------------------------------------------------
= + + Hash Join  (cost=3D764.74..796.94 rows=3D1 width=3D109) = +(actual time=3D2.488..2.865 rows=3D45 loops=3D1)
+   Hash Cond: ("outer".modules_id =3D = +"inner".id)
+   ->  Index Scan using br_1min_20557_end_idx on = +br_1min_20557 br1  (cost=3D0.00..27.62 rows=3D914 width=3D32) = +(actual time=3D0.084..1.886 rows=3D910 loops=3D1)
+         Index Cond: ((end_time = +>=3D '2006-05-01 17:12:18-07'::timestamp with time zone) AND = +(end_time < '2006-05-01 17:13:18-07'::timestamp with time zone))
+   ->  Hash  (cost=3D764.03..764.03 rows=3D282 = +width=3D77) (actual time=3D0.284..0.284 rows=3D45 loops=3D1)
+         ->  Bitmap Heap = +Scan on br_mods mod  (cost=3D20.99..764.03 rows=3D282 width=3D77) = +(actual time=3D0.154..0.245 rows=3D45 loops=3D1)
+            &= +nbsp;  Recheck Cond: ((downloads_id =3D 153226) OR (downloads_id = +=3D 153714) OR (downloads_id =3D 153730) OR (downloads_id =3D 153728) OR = +(downloads_id =3D 153727) OR (downloads_id =3D 153724) OR (downloads_id = +=3D 153713) OR (downloads_id =3D 153725) OR (downloads_id =3D 153739) OR = +(downloads_id =3D 153722))
+            &= +nbsp;  ->  BitmapOr  (cost=3D20.99..20.99 rows=3D282 = +width=3D0) (actual time=3D0.144..0.144 rows=3D0 loops=3D1)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.031..0.031 rows=3D14 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153226)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.011..0.011 rows=3D2 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153714)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.007..0.007 rows=3D2 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153730)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.007..0.007 rows=3D2 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153728)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.008..0.008 rows=3D2 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153727)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.008..0.008 rows=3D2 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153724)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.008..0.008 rows=3D2 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153713)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.008..0.008 rows=3D2 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153725)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.041..0.041 rows=3D16 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153739)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.010..0.010 rows=3D1 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153722)
+ Total runtime: 3.017 ms
+(29 rows)
+
+The difference is night-and-day.  Any suggestions?
+
+Thanks alot,
+
+Mark
+

+ + + +------_=_NextPart_001_01C66D88.EA2242A1-- + +From pgsql-performance-owner@postgresql.org Mon May 1 23:59:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E912D9FA3CD + for ; + Mon, 1 May 2006 23:59:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 31980-02 + for ; + Mon, 1 May 2006 23:59:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id E93F89FA2BE + for ; + Mon, 1 May 2006 23:59:18 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k422xHhc022531; + Mon, 1 May 2006 22:59:17 -0400 (EDT) +To: "Mark Liberman" +cc: pgsql-performance@postgresql.org +Subject: Re: Why is plan (and performance) different on partitioned table? +In-reply-to: <9D938282F8C6EE43B748B910386DE93E0138B43C@srvgpimail1.GPI.local> +References: <9D938282F8C6EE43B748B910386DE93E0138B43C@srvgpimail1.GPI.local> +Comments: In-reply-to "Mark Liberman" + message dated "Mon, 01 May 2006 18:37:03 -0700" +Date: Mon, 01 May 2006 22:59:16 -0400 +Message-ID: <22530.1146538756@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/26 +X-Sequence-Number: 18813 + +"Mark Liberman" writes: +> I have recently implemented table partitioning in our postgres 8.1 db. = +> Upon analyzing query performance, I have realized that, even when only a = +> single one of the "partitions" has to be scanned, the plan is = +> drastically different, and performs much worse, when I query against the = +> master table (uses merge join), vs. a direct query against the partition = +> directly (uses a hash join). The majority of our queries only access a = +> single partition. + +Joins against partitioned tables suck in 8.1 :-(. There is code in CVS +HEAD to improve this, but it didn't get done in time for 8.1. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 2 01:44:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7968B9FA7BA + for ; + Tue, 2 May 2006 01:44:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27988-01 + for ; + Tue, 2 May 2006 01:44:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 3ECF89FA5F6 + for ; + Tue, 2 May 2006 01:44:18 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k424iGEp024806; + Tue, 2 May 2006 00:44:16 -0400 (EDT) +To: "Mark Liberman" +cc: pgsql-performance@postgresql.org +Subject: Re: Why is plan (and performance) different on partitioned table? +In-reply-to: <22530.1146538756@sss.pgh.pa.us> +References: <9D938282F8C6EE43B748B910386DE93E0138B43C@srvgpimail1.GPI.local> + <22530.1146538756@sss.pgh.pa.us> +Comments: In-reply-to Tom Lane + message dated "Mon, 01 May 2006 22:59:16 -0400" +Date: Tue, 02 May 2006 00:44:16 -0400 +Message-ID: <24805.1146545056@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/27 +X-Sequence-Number: 18814 + +I wrote: +> Joins against partitioned tables suck in 8.1 :-(. + +Actually ... while the above is a true statement, it's too flippant a +response for your problem. The reason the planner is going for a +mergejoin in your example is that it thinks the mergejoin will terminate +early. (Notice that the cost estimate for the mergejoin is actually +quite a bit less than the estimate for its first input.) This estimate +can only be made if the planner has statistics that say that one of the +join columns has a max value much less than the other's. Well, that's +fine, but where the heck did it get the stats for the partitioned table? +We don't compute union statistics for partitions. The answer is that +it's confused and is using the stats for just the parent table as if +they were representative for the whole inheritance tree. + +I think this behavior was intentional back when it was coded, but when +inheritance is being used for partitioning, it's clearly brain-dead. +We should either not assume anything about the statistics for an +inheritance tree, or make a real effort to compute them. + +For the moment, I've applied a quick patch that makes sure we don't +assume anything. + +If you don't have anything in the parent table br_1min, then deleting +the (presumably obsolete) pg_statistic rows for it should fix your +immediate problem. Otherwise, consider applying the attached. + + regards, tom lane + + +Index: src/backend/optimizer/path/allpaths.c +=================================================================== +RCS file: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v +retrieving revision 1.137.2.2 +diff -c -r1.137.2.2 allpaths.c +*** src/backend/optimizer/path/allpaths.c 13 Feb 2006 16:22:29 -0000 1.137.2.2 +--- src/backend/optimizer/path/allpaths.c 2 May 2006 04:31:27 -0000 +*************** +*** 264,269 **** +--- 264,276 ---- + errmsg("SELECT FOR UPDATE/SHARE is not supported for inheritance queries"))); + + /* ++ * We might have looked up indexes for the parent rel, but they're ++ * really not relevant to the appendrel. Reset the pointer to avoid ++ * any confusion. ++ */ ++ rel->indexlist = NIL; ++ ++ /* + * Initialize to compute size estimates for whole inheritance tree + */ + rel->rows = 0; +Index: src/backend/utils/adt/selfuncs.c +=================================================================== +RCS file: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v +retrieving revision 1.191.2.1 +diff -c -r1.191.2.1 selfuncs.c +*** src/backend/utils/adt/selfuncs.c 22 Nov 2005 18:23:22 -0000 1.191.2.1 +--- src/backend/utils/adt/selfuncs.c 2 May 2006 04:31:27 -0000 +*************** +*** 2970,2988 **** + (varRelid == 0 || varRelid == ((Var *) basenode)->varno)) + { + Var *var = (Var *) basenode; +! Oid relid; + + vardata->var = basenode; /* return Var without relabeling */ + vardata->rel = find_base_rel(root, var->varno); + vardata->atttype = var->vartype; + vardata->atttypmod = var->vartypmod; + +! relid = getrelid(var->varno, root->parse->rtable); + +! if (OidIsValid(relid)) + { + vardata->statsTuple = SearchSysCache(STATRELATT, +! ObjectIdGetDatum(relid), + Int16GetDatum(var->varattno), + 0, 0); + } +--- 2970,2996 ---- + (varRelid == 0 || varRelid == ((Var *) basenode)->varno)) + { + Var *var = (Var *) basenode; +! RangeTblEntry *rte; + + vardata->var = basenode; /* return Var without relabeling */ + vardata->rel = find_base_rel(root, var->varno); + vardata->atttype = var->vartype; + vardata->atttypmod = var->vartypmod; + +! rte = rt_fetch(var->varno, root->parse->rtable); + +! if (rte->inh) +! { +! /* +! * XXX This means the Var represents a column of an append relation. +! * Later add code to look at the member relations and try to derive +! * some kind of combined statistics? +! */ +! } +! else if (rte->rtekind == RTE_RELATION) + { + vardata->statsTuple = SearchSysCache(STATRELATT, +! ObjectIdGetDatum(rte->relid), + Int16GetDatum(var->varattno), + 0, 0); + } + +From pgsql-performance-owner@postgresql.org Wed May 3 03:17:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A4A7B9FA4AF + for ; + Tue, 2 May 2006 11:59:04 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29359-03 + for ; + Tue, 2 May 2006 11:58:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 309199F9D4D + for ; + Tue, 2 May 2006 11:58:54 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id CA81C30CDC; Tue, 2 May 2006 16:58:52 +0200 (MET DST) +From: Fortuitous Technologies +Subject: Re: Running on an NFS Mounted Directory +User-Agent: Pan/0.14.2.91 (As She Crawled Across the Table (Debian GNU/Linux)) +Message-Id: +X-Newsgroups: pgsql.performance +References: + <20060427023542.GA14672@weaver.tuc.noao.edu> + <20060427045524.GV97354@pervasive.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +Lines: 15 +Date: Tue, 02 May 2006 14:58:51 GMT +X-Complaints-To: abuse@earthlink.net +Organization: EarthLink Inc. -- http://www.EarthLink.net +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/74 +X-Sequence-Number: 18861 + +On Wed, 26 Apr 2006 23:55:24 -0500, Jim C. Nasby wrote: +> On Wed, Apr 26, 2006 at 07:35:42PM -0700, Steve Wampler wrote: +>> On Wed, Apr 26, 2006 at 10:06:58PM -0400, Ketema Harris wrote: +>> > I was wondering if there were any performance issues with having a data +>> > directory that was an nfs mounted drive? Say like a SAN or NAS device? Has +>> > anyone done this before? +>> +>> My understanding is that NFS is pretty poor in performance in general, + + NFS is not a good choice for several reasons. First, NFS takes +priority in the system kernel, and will slow down all other +operations. Your best choice, as pointed out by others, is a DAS +solutions. If you must use NFS, you should consider putting it on +a fast dedicated network by itself. + + +From pgsql-performance-owner@postgresql.org Tue May 2 14:15:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D49C29FB1F0 + for ; + Tue, 2 May 2006 14:15:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 50634-07 + for ; + Tue, 2 May 2006 14:15:07 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 668729FA1B0 + for ; + Tue, 2 May 2006 14:15:00 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 8026756437; Tue, 2 May 2006 12:14:59 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Tue, 2 May 2006 12:14:58 -0500 +Date: Tue, 2 May 2006 12:14:58 -0500 +From: "Jim C. Nasby" +To: clemens.bertschler@gmail.com +Cc: pgsql-performance@postgresql.org +Subject: Re: Easy question +Message-ID: <20060502171458.GY97354@pervasive.com> +References: <1145741653.759727.38970@e56g2000cwe.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1145741653.759727.38970@e56g2000cwe.googlegroups.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060502:clemens.bertschler@gmail.com::CD08nMcBo8wqM/oH:000000000 + 000000000000000000000000BRcp +X-Hashcash: + 1:20:060502:pgsql-performance@postgresql.org::jUmXTnDCthiSB35H:00000 + 0000000000000000000000001aDo +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/28 +X-Sequence-Number: 18815 + +You didn't mention version, but 8.1.x has bitmap index scans that might +greatly speed this up... + +On Sat, Apr 22, 2006 at 02:34:13PM -0700, clemens.bertschler@gmail.com wrote: +> Hi List +> I have maybe an easy question but i do not find an answer, i have this +> SQL query: +> +> SELECT geom,group,production_facs FROM south_america +> WHERE municipio = '' +> OR municipio = 'ACRE' +> OR municipio = 'ADJUNTAS' +> OR municipio = 'AGUADA' +> +> The performance of this query is quite worse as longer it gets, its +> possible that this query gets over 20 to 30 OR comparisons, but then +> the performance is really worse, is it possible to speed it up? +> Thanks +> Clemens +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 2 14:16:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4A2359FB205 + for ; + Tue, 2 May 2006 14:16:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 19239-04-2 + for ; + Tue, 2 May 2006 14:16:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 46F1C9FB204 + for ; + Tue, 2 May 2006 14:16:02 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (Tb807.t.pppool.de + [89.55.184.7]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 2EBAE65800; + Tue, 2 May 2006 19:17:06 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 3B8A7184C9BDD; + Tue, 2 May 2006 19:16:12 +0200 (CEST) +Message-ID: <445793DC.40401@logix-tt.com> +Date: Tue, 02 May 2006 19:16:12 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bill Moran +Cc: Bealach-na Bo , ahodgson@simkin.ca, + pgsql-performance@postgresql.org +Subject: Re: Why so slow? +References: <200604281043.16083@hal.medialogik.com> + + <20060430100346.20f010a9.wmoran@collaborativefusion.com> +In-Reply-To: <20060430100346.20f010a9.wmoran@collaborativefusion.com> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/29 +X-Sequence-Number: 18816 + +Hi, Bill, + +Bill Moran wrote: + +> My understanding is basically that if you vacuum with the correct +> frequency, you'll never need to vacuum full. This is why the +> autovacuum system is so nice, it adjusts the frequency of vacuum according +> to how much use the DB is getting. + +Additonally, the "free_space_map" setting has to be high enough, it has +to cover enough space to put in all pages that get dead rows between two +vacuum runs. + +HTH, +Markus + + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Tue May 2 14:16:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 962449FA1B0 + for ; + Tue, 2 May 2006 14:16:40 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 15077-09 + for ; + Tue, 2 May 2006 14:16:20 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 3B2EB9FB1F7 + for ; + Tue, 2 May 2006 14:16:20 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 1B17856440; Tue, 2 May 2006 12:16:19 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Tue, 2 May 2006 12:16:17 -0500 +Date: Tue, 2 May 2006 12:16:17 -0500 +From: "Jim C. Nasby" +To: Eric Lam +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow restoration question +Message-ID: <20060502171617.GZ97354@pervasive.com> +References: <444F24E9.2010907@lisasoft.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <444F24E9.2010907@lisasoft.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060502:elam@lisasoft.com::i8MxJqB0W13D52L2:00000000000000000000 + 0000000000000000000000002L4k +X-Hashcash: + 1:20:060502:pgsql-performance@postgresql.org::ox2Kc/wvNYVkFlFX:00000 + 000000000000000000000000C2mt +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/30 +X-Sequence-Number: 18817 + +On Wed, Apr 26, 2006 at 05:14:41PM +0930, Eric Lam wrote: +> all dumpfiles total about 17Gb. It has been running for 50ish hrs and up +> to about the fourth file (5-6 ish Gb) and this is on a raid 5 server. + +RAID5 generally doesn't bode too well for performance; that could be +part of the issue. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 2 15:27:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B35409FB1F2 + for ; + Tue, 2 May 2006 15:27:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 18099-04-4 + for ; + Tue, 2 May 2006 15:26:29 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from pproxy.gmail.com (pproxy.gmail.com [64.233.166.178]) + by postgresql.org (Postfix) with ESMTP id 240B59FB1F1 + for ; + Tue, 2 May 2006 15:26:05 -0300 (ADT) +Received: by pproxy.gmail.com with SMTP id x66so3220885pye + for ; + Tue, 02 May 2006 11:26:04 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type; + b=uSmZ8B4m08yj2Ts1NZtwAIr9HBvNWT2dnnPtkM/+o1hXnWt8vJWcI+0JzkfXO1QV9VZEiVLr0FL267nCOh/t+IRKd3DfpCnZhUvEoNKFPwbvRZgqtqQ0JdcilvkvzV35H5AZPF00UEVsXQZLOrRUK927UbWWINArR1D9RN/Gv3o= +Received: by 10.35.18.18 with SMTP id v18mr1098581pyi; + Tue, 02 May 2006 11:26:04 -0700 (PDT) +Received: by 10.35.49.6 with HTTP; Tue, 2 May 2006 11:26:04 -0700 (PDT) +Message-ID: <6d8daee30605021126o7b44e255q552dcdc676c565bf@mail.gmail.com> +Date: Tue, 2 May 2006 11:26:04 -0700 +From: "Tony Wasson" +To: pgsql-performance@postgresql.org +Subject: postgresql transaction id monitoring with nagios +MIME-Version: 1.0 +Content-Type: multipart/mixed; + boundary="----=_Part_7984_19334869.1146594364394" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/31 +X-Sequence-Number: 18818 + +------=_Part_7984_19334869.1146594364394 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Ever since I started working with PostgreSQL I've heard the need to +watch transaction IDs. The phrase "transaction ID wraparound" still +gives me a shiver. Attached it a short script that works with the +monitoring system Nagios to keep an eye on transaction IDs. It should +be easy to adapt to any other monitoring system. + +It runs the textbook query below and reports how close you are to wraparoun= +d. + SELECT datname, age(datfrozenxid) FROM pg_database; + +The script detects a wrap at 2 billion. It starts warning once one or +more databases show an age over 1 billion transactions. It reports +critical at 1.5B transactions. I hope everyone out there is vacuuming +*all* databases often. + +Hope some of you can use this script! +Tony Wasson + +------=_Part_7984_19334869.1146594364394 +Content-Type: application/x-perl; name=check_pg_transactionids.pl +Content-Transfer-Encoding: 7bit +X-Attachment-Id: f_emqkknl8 +Content-Disposition: attachment; filename="check_pg_transactionids.pl" + +#!/usr/bin/perl -w +use strict; +use DBI; + +my $dbhost=$ARGV[0] || die "Pass the IP or hostname of a postgresql server to check."; +my $dbname=$ARGV[1] || 'template1'; +my $dbuser=$ARGV[2] || 'postgres'; +my $dbpass=$ARGV[3] || ''; + +# 2000M = 2 Billion. Too many zeros hurt my eyes. +my $wrap_xid_M=2000; # Record wrap at 2 Billion +my $warn_xid_M=1000; # Warn at 1.0 Billion +my $crit_xid_M=1500; # Critical at 1.5 Billion + +my $status=3; # default to an UNKNOWN status +my $max_xid_pct=-99; # default to a negative percentage +my $max_xid_M=-9999; # default to negative XID # +my $max_xid_datname="NOT SET (script broke)"; + +my $Con = "DBI:Pg:dbname=$dbname;host=$dbhost"; +my $Dbh = DBI->connect($Con, $dbuser, $dbpass, {RaiseError =>1}) || die "Unable to access Database $dbname on host $dbhost as user $dbuser.\nError returned was: ". $DBI::errstr; + +my $sql="SELECT datname, age(datfrozenxid) FROM pg_database;"; +my $sth = $Dbh->prepare($sql); +$sth->execute(); +while (my ($datname,$max_xid) = $sth->fetchrow()) { + my $xid_used_M=sprintf('%1d',($max_xid/1000000)); + my $xid_used_pct=sprintf('%1d', ($xid_used_M/$wrap_xid_M)*100); + #find the database with the highest transaction id + if ($xid_used_M > $max_xid_M) + { + $max_xid_pct=$xid_used_pct; + $max_xid_M=$xid_used_M; + $max_xid_datname=$datname; + } +} +$Dbh->disconnect; + +# 3 UNKNOWN, 2 CRITICAL, 1 WARNING, 0 OK +if ($max_xid_M >= $crit_xid_M) +{ + $status=2; +} +elsif ($max_xid_M >= $warn_xid_M) +{ + $status=1; +} +elsif ($max_xid_M < $warn_xid_M && $max_xid_M > 0 ) +{ + $status=0; +} +else +{ + #This means something is wrong with the query or math above + $status=3; +} + +print "Transaction IDs are $max_xid_pct% used ($max_xid_M M) in database $max_xid_datname.\n"; +exit $status; + + + +------=_Part_7984_19334869.1146594364394-- + +From pgsql-performance-owner@postgresql.org Tue May 2 15:41:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 66E3D9FA261 + for ; + Tue, 2 May 2006 15:41:17 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 54879-01 + for ; + Tue, 2 May 2006 15:41:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 7EEFF9F9CC1 + for ; + Tue, 2 May 2006 15:41:06 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Tue, 2 May 2006 12:41:01 -0600 +In-Reply-To: <20060502171617.GZ97354@pervasive.com> +References: <444F24E9.2010907@lisasoft.com> + <20060502171617.GZ97354@pervasive.com> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <622925BE-A31E-42FD-AF6A-68DDF3B4A1B7@clickspace.com> +Cc: Eric Lam , + pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: Slow restoration question +Date: Tue, 2 May 2006 12:40:43 -0600 +To: Jim C. Nasby +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/32 +X-Sequence-Number: 18819 + +Everyone here always says that RAID 5 isn't good for Postgres. We +have an Apple Xserve RAID configured with RAID 5. We chose RAID 5 +because Apple said their Xserve RAID was "optimized" for RAID 5. Not +sure if we made the right decision though. They give an option for +formatting as RAID 0+1. Is that the same as RAID 10 that everyone +talks about? Or is it the reverse? + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On May 2, 2006, at 11:16 AM, Jim C. Nasby wrote: + +> On Wed, Apr 26, 2006 at 05:14:41PM +0930, Eric Lam wrote: +>> all dumpfiles total about 17Gb. It has been running for 50ish hrs +>> and up +>> to about the fourth file (5-6 ish Gb) and this is on a raid 5 server. +> +> RAID5 generally doesn't bode too well for performance; that could be +> part of the issue. +> -- +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> + + + +From pgsql-performance-owner@postgresql.org Tue May 2 15:49:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8D9BB9F9CC1 + for ; + Tue, 2 May 2006 15:49:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10102-03 + for ; + Tue, 2 May 2006 15:49:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) + by postgresql.org (Postfix) with ESMTP id 920F19FA25D + for ; + Tue, 2 May 2006 15:49:19 -0300 (ADT) +Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP + with MS-WebStorage 6.0.6249 +Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; + 02 May 2006 11:49:16 -0700 +Subject: Re: Slow restoration question +From: Mark Lewis +To: Brendan Duddridge +Cc: "Jim C.Nasby" , Eric Lam , + pgsql-performance@postgresql.org +In-Reply-To: <622925BE-A31E-42FD-AF6A-68DDF3B4A1B7@clickspace.com> +References: <444F24E9.2010907@lisasoft.com> + <20060502171617.GZ97354@pervasive.com> + <622925BE-A31E-42FD-AF6A-68DDF3B4A1B7@clickspace.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: MIR3, Inc. +Date: Tue, 02 May 2006 11:49:15 -0700 +Message-Id: <1146595755.12053.111.camel@archimedes> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-27) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/33 +X-Sequence-Number: 18820 + +They are not equivalent. As I understand it, RAID 0+1 performs about +the same as RAID 10 when everything is working, but degrades much less +nicely in the presence of a single failed drive, and is more likely to +suffer catastrophic data loss if multiple drives fail. + +-- Mark + +On Tue, 2006-05-02 at 12:40 -0600, Brendan Duddridge wrote: +> Everyone here always says that RAID 5 isn't good for Postgres. We +> have an Apple Xserve RAID configured with RAID 5. We chose RAID 5 +> because Apple said their Xserve RAID was "optimized" for RAID 5. Not +> sure if we made the right decision though. They give an option for +> formatting as RAID 0+1. Is that the same as RAID 10 that everyone +> talks about? Or is it the reverse? +> +> Thanks, +> +> ____________________________________________________________________ +> Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com +> +> ClickSpace Interactive Inc. +> Suite L100, 239 - 10th Ave. SE +> Calgary, AB T2G 0V9 +> +> http://www.clickspace.com +> +> On May 2, 2006, at 11:16 AM, Jim C. Nasby wrote: +> +> > On Wed, Apr 26, 2006 at 05:14:41PM +0930, Eric Lam wrote: +> >> all dumpfiles total about 17Gb. It has been running for 50ish hrs +> >> and up +> >> to about the fourth file (5-6 ish Gb) and this is on a raid 5 server. +> > +> > RAID5 generally doesn't bode too well for performance; that could be +> > part of the issue. +> > -- +> > Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> > Pervasive Software http://pervasive.com work: 512-231-6117 +> > vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> > +> > ---------------------------(end of +> > broadcast)--------------------------- +> > TIP 4: Have you searched our list archives? +> > +> > http://archives.postgresql.org +> > +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, 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 May 2 15:50:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 672539FB1F4 + for ; + Tue, 2 May 2006 15:50:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 69076-06 + for ; + Tue, 2 May 2006 15:50:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id BF8B79FA25D + for ; + Tue, 2 May 2006 15:50:06 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 1331EB826 + for ; + Tue, 2 May 2006 14:50:05 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <6d8daee30605021126o7b44e255q552dcdc676c565bf@mail.gmail.com> +References: <6d8daee30605021126o7b44e255q552dcdc676c565bf@mail.gmail.com> +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-6-784879945; + protocol="application/pkcs7-signature" +Message-Id: <628A837A-9718-46BB-85D7-8A63BBB1CA32@khera.org> +From: Vivek Khera +Subject: Re: postgresql transaction id monitoring with nagios +Date: Tue, 2 May 2006 14:50:04 -0400 +To: Pgsql performance +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/34 +X-Sequence-Number: 18821 + + +--Apple-Mail-6-784879945 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + + +On May 2, 2006, at 2:26 PM, Tony Wasson wrote: + +> The script detects a wrap at 2 billion. It starts warning once one or +> more databases show an age over 1 billion transactions. It reports +> critical at 1.5B transactions. I hope everyone out there is vacuuming +> *all* databases often. + +Something seems wrong... I just ran your script against my +development database server which is vacuumed daily and it said I was +53% of the way to 2B. Seemed strange to me, so I re-ran "vacuum -a - +z" to vacuum all databases (as superuser), reran the script and got +the same answer. + + + +--Apple-Mail-6-784879945 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGlDCCAz8w +ggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0 +ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcx +KDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1RoYXd0 +ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVyc29uYWwtZnJlZW1haWxA +dGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5NTlaMGIxCzAJBgNVBAYTAlpB +MSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUg +UGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA +xKY8VXNV+065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/Uc4B1OVQCjDXAmNaLIkVcI7d +yfArhVqqP3FWy688Cwfn8R+RNiQqE88r1fOCdz0Dviv+uxg+B79AgAJk16emu59l0cUqVIUPSAR/ +p7bRPGEEQB5kGXJgt/sCAwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/AgEAMEMGA1UdHwQ8MDow +OKA2oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25hbEZyZWVtYWlsQ0EuY3Js +MAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRUHJpdmF0ZUxhYmVsMi0xMzgw +DQYJKoZIhvcNAQEFBQADgYEASIzRUIPqCy7MDaNmrGcPf6+svsIXoUOWlJ1/TCG4+DYfqi2fNi/A +9BxQIJNwPP2t4WFiw9k6GX6EsZkbAMUaC4J0niVQlGLH2ydxVyWN3amcOY6MIE9lX5Xa9/eH1sYI +Tq726jTlEBpbNU1341YheILcIRk13iSx0x1G/11fZU8wggNNMIICtqADAgECAhA6sDoA4m3lcimf +yUtGSQgmMA0GCSqGSIb3DQEBBAUAMGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29u +c3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNz +dWluZyBDQTAeFw0wNjA1MDIxNDEyNDdaFw0wNzA1MDIxNDEyNDdaMIGKMR8wHQYDVQQDExZUaGF3 +dGUgRnJlZW1haWwgTWVtYmVyMR4wHAYJKoZIhvcNAQkBFg92aXZla0BraGVyYS5vcmcxIDAeBgkq +hkiG9w0BCQEWEWtoZXJhQGtjaWxpbmsuY29tMSUwIwYJKoZIhvcNAQkBFhZ2aXZla0BtYWlsZXJt +YWlsZXIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq+zHKYq9vZ4Dq1itNqT/ +OeJvWDvQ5JdQlRzwsJlvtJBknXsnOaJNabmjnu2s6XFMcP2srBZQ/WPvhsClajLQOcxnarrfB66N +DpMzXTxfYzX6m9TA/fEn64sNn+YnBZL6Dvid9kiAgP9LmqcTOIFdWUya3ZmQS5YTuLB+tkFSL8/h ++inDPN6dcsna8TcM1SAk+3upxOR7kyFM9T3vy25w62Nh1zK7Stp0vUZLU6GzzC1VvHGZHKGticD6 +o3uHaMr2LCFjptoIcfZL75LO/UaR9o7smgboW4yJyW5g9ZasyYQUXyvkitfyZuVWATb8ZSHOkjWJ +872Pyf5+HOevVUI0aQIDAQABo1cwVTBFBgNVHREEPjA8gQ92aXZla0BraGVyYS5vcmeBEWtoZXJh +QGtjaWxpbmsuY29tgRZ2aXZla0BtYWlsZXJtYWlsZXIuY29tMAwGA1UdEwEB/wQCMAAwDQYJKoZI +hvcNAQEEBQADgYEAYpaFKDj47pTQIUQi28MgtjKophopv4QJjvspXmy0qxd8t/M/zc7HuBy3i/9a +PrXDgKyNBzzlFTasTazAY53ntVpqw9k1NOeHmH6o3j/DBVa49bC6bbWfp9UGOwYChlDR0tngQZyC +MDMZEdYv4zpGfBTku5m1jb8Yz/qYqV4FWB4xggMQMIIDDAIBATB2MGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIQOrA6AOJt5XIpn8lLRkkIJjAJBgUrDgMCGgUAoIIB +bzAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjA1MDIxODUwMDRa +MCMGCSqGSIb3DQEJBDEWBBSgxWGtJV7HjWL6GssSD3vQIrxtUDCBhQYJKwYBBAGCNxAEMXgwdjBi +MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoG +A1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECEDqwOgDibeVyKZ/JS0ZJ +CCYwgYcGCyqGSIb3DQEJEAILMXigdjBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENv +bnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElz +c3VpbmcgQ0ECEDqwOgDibeVyKZ/JS0ZJCCYwDQYJKoZIhvcNAQEBBQAEggEAVnRObXC5fr1B5WYC +oHrgVHLBjoYsUdQoV1m0aRPN+ibi4tPoGFKeDq4CwO7FAR8ILk6RHvP62cu4R4r79k/mstGdsOfr +FWrAuW1DxbP8hDXwqKkSJxDorBZF1PlgUhvNE6L0TD63WI4cLU87WPgxQuiLt1v2WQ6pHD4ljiv6 +DMJHJZ/cfCk7jXgV1VkLWCCenC6cvswH40TTY1pKehyAvvJZrLQU+nc1iz0L5lfXHxm0uOhiyqH2 +2h+Cz4Qc1qTIUVB3ex6kQpzzVrns6midPdVQd/O9vDZm/0q856RsCbxsnTo2BrXLExHUMtTpU19E +Rq+L3D/482MGLajc/sJ2DwAAAAAAAA== + +--Apple-Mail-6-784879945-- + +From pgsql-performance-owner@postgresql.org Tue May 2 16:03:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 57FCC9FA25D + for ; + Tue, 2 May 2006 16:03:48 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 63287-08 + for ; + Tue, 2 May 2006 16:03:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx2.surnet.cl (mx2.surnet.cl [216.155.73.181]) + by postgresql.org (Postfix) with ESMTP id 6E9C79F9CC1 + for ; + Tue, 2 May 2006 16:03:42 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx2.surnet.cl with ESMTP; 02 May 2006 15:03:41 -0400 +X-IronPort-Anti-Spam-Filtered: true +X-IronPort-Anti-Spam-Result: AQAAADtKV0SJAw4q +X-IronPort-AV: i="4.02,198,1139194800"; + d="scan'208"; a="48093872:sNHT19860284" +Received: from alvh.no-ip.org (201.220.122.210) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 443B7DDC002E6811; Tue, 2 May 2006 15:03:40 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id AB281C31DD1; Tue, 2 May 2006 15:03:40 -0400 (CLT) +Date: Tue, 2 May 2006 15:03:40 -0400 +From: Alvaro Herrera +To: Vivek Khera +Cc: Pgsql performance +Subject: Re: postgresql transaction id monitoring with nagios +Message-ID: <20060502190340.GG15291@surnet.cl> +Mail-Followup-To: Vivek Khera , + Pgsql performance +References: <6d8daee30605021126o7b44e255q552dcdc676c565bf@mail.gmail.com> + <628A837A-9718-46BB-85D7-8A63BBB1CA32@khera.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <628A837A-9718-46BB-85D7-8A63BBB1CA32@khera.org> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/35 +X-Sequence-Number: 18822 + +Vivek Khera wrote: +> +> On May 2, 2006, at 2:26 PM, Tony Wasson wrote: +> +> >The script detects a wrap at 2 billion. It starts warning once one or +> >more databases show an age over 1 billion transactions. It reports +> >critical at 1.5B transactions. I hope everyone out there is vacuuming +> >*all* databases often. +> +> Something seems wrong... I just ran your script against my +> development database server which is vacuumed daily and it said I was +> 53% of the way to 2B. Seemed strange to me, so I re-ran "vacuum -a - +> z" to vacuum all databases (as superuser), reran the script and got +> the same answer. + +That's right, because a database's age is only decremented in +database-wide vacuums. (Wow, who wouldn't want a person-wide vacuum if +it did the same thing ...) + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +PostgreSQL Replication, Consulting, Custom Development, 24x7 support + +From pgsql-performance-owner@postgresql.org Tue May 2 16:06:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3479D9FA25D + for ; + Tue, 2 May 2006 16:06:45 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 70958-02 + for ; + Tue, 2 May 2006 16:06:32 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from pproxy.gmail.com (pproxy.gmail.com [64.233.166.177]) + by postgresql.org (Postfix) with ESMTP id 0E20F9F9CC1 + for ; + Tue, 2 May 2006 16:06:31 -0300 (ADT) +Received: by pproxy.gmail.com with SMTP id x66so3231822pye + for ; + Tue, 02 May 2006 12:06:30 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=RdQn1gCujdGVQKRKJ3jv9eWYUccUOHza/g0jYsmVsNU4U1bF8FV0t3DWJhS71FSi1nOmx+ZC+XCInFMGwnYufzf8BozrdFO2Dh2N24LmCLuISLIboRUL0voALwutXZq4PSuYYwn0CLZKfmbFNNAbFUzT93LhXnVmvgsLf3STaUA= +Received: by 10.35.100.6 with SMTP id c6mr1152329pym; + Tue, 02 May 2006 12:06:30 -0700 (PDT) +Received: by 10.35.49.6 with HTTP; Tue, 2 May 2006 12:06:30 -0700 (PDT) +Message-ID: <6d8daee30605021206h8170a48w94670b5d23633a72@mail.gmail.com> +Date: Tue, 2 May 2006 12:06:30 -0700 +From: "Tony Wasson" +To: "Vivek Khera" +Subject: Re: postgresql transaction id monitoring with nagios +Cc: "Pgsql performance" +In-Reply-To: <628A837A-9718-46BB-85D7-8A63BBB1CA32@khera.org> +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="----=_Part_8859_249774.1146596790507" +References: <6d8daee30605021126o7b44e255q552dcdc676c565bf@mail.gmail.com> + <628A837A-9718-46BB-85D7-8A63BBB1CA32@khera.org> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/36 +X-Sequence-Number: 18823 + +------=_Part_8859_249774.1146596790507 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 5/2/06, Vivek Khera wrote: +> +> On May 2, 2006, at 2:26 PM, Tony Wasson wrote: +> +> > The script detects a wrap at 2 billion. It starts warning once one or +> > more databases show an age over 1 billion transactions. It reports +> > critical at 1.5B transactions. I hope everyone out there is vacuuming +> > *all* databases often. +> +> Something seems wrong... I just ran your script against my +> development database server which is vacuumed daily and it said I was +> 53% of the way to 2B. Seemed strange to me, so I re-ran "vacuum -a - +> z" to vacuum all databases (as superuser), reran the script and got +> the same answer. + +Ah thanks, it's a bug in my understanding of the thresholds. + +"With the standard freezing policy, the age column will start at one +billion for a freshly-vacuumed database." + +So essentially, 1B is normal, 2B is the max. The logic is now.. + +The script detects a wrap at 2 billion. It starts warning once one or +more databases show an age over 1.5 billion transactions. It reports +critical at 1.75B transactions. + +If anyone else understands differently, hit me with a clue bat. + +------=_Part_8859_249774.1146596790507 +Content-Type: application/x-perl; name=check_pg_transactionids.pl +Content-Transfer-Encoding: 7bit +X-Attachment-Id: f_emqm38g2 +Content-Disposition: attachment; filename="check_pg_transactionids.pl" + +#!/usr/bin/perl -w +use strict; +use DBI; + +my $dbhost=$ARGV[0] || die "Pass the IP or hostname of a postgresql server to check."; +my $dbname=$ARGV[1] || 'template1'; +my $dbuser=$ARGV[2] || 'postgres'; +my $dbpass=$ARGV[3] || ''; + +#"With the standard freezing policy, the age column will +# start at one billion for a freshly-vacuumed database." +# 2000M = 2 Billion. Too many zeros hurt my eyes. +my $wrap_xid_M=2000; # Record wrap at 2 Billion +my $warn_xid_M=1500; # Warn at 1.5 Billion +my $crit_xid_M=1700; # Critical at 2.0 Billion + +my $status=3; # default to an UNKNOWN status +my $max_xid_pct=-99; # default to a negative percentage +my $max_xid_M=-9999; # default to negative XID # +my $max_xid_datname="NOT SET (script broke)"; + +my $Con = "DBI:Pg:dbname=$dbname;host=$dbhost"; +my $Dbh = DBI->connect($Con, $dbuser, $dbpass, {RaiseError =>1}) || die "Unable to access Database $dbname on host $dbhost as user $dbuser.\nError returned was: ". $DBI::errstr; + +my $sql="SELECT datname, age(datfrozenxid) FROM pg_database;"; +my $sth = $Dbh->prepare($sql); +$sth->execute(); +while (my ($datname,$max_xid) = $sth->fetchrow()) { + my $xid_used_M=sprintf('%1d',($max_xid/1000000)); + my $xid_used_pct=sprintf('%1d', ($xid_used_M/$wrap_xid_M)*100); + #find the database with the highest transaction id + if ($xid_used_M > $max_xid_M) + { + $max_xid_pct=$xid_used_pct; + $max_xid_M=$xid_used_M; + $max_xid_datname=$datname; + } +} +$Dbh->disconnect; + +# 3 UNKNOWN, 2 CRITICAL, 1 WARNING, 0 OK +if ($max_xid_M >= $crit_xid_M) +{ + $status=2; +} +elsif ($max_xid_M >= $warn_xid_M) +{ + $status=1; +} +elsif ($max_xid_M < $warn_xid_M && $max_xid_M > 0 ) +{ + $status=0; +} +else +{ + #This means something is wrong with the query or math above + $status=3; +} + +print "Transaction IDs are $max_xid_pct% used ($max_xid_M M) in database $max_xid_datname.\n"; +exit $status; + + +------=_Part_8859_249774.1146596790507-- + +From pgsql-performance-owner@postgresql.org Tue May 2 16:07:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 032EB9F9CC1 + for ; + Tue, 2 May 2006 16:07:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 73802-08 + for ; + Tue, 2 May 2006 16:07:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.surnet.cl (mx1.surnet.cl [216.155.73.180]) + by postgresql.org (Postfix) with ESMTP id C06B19FB1D3 + for ; + Tue, 2 May 2006 16:07:45 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx1.surnet.cl with ESMTP; 02 May 2006 15:07:42 -0400 +X-IronPort-AV: i="4.04,172,1144036800"; + d="scan'208"; a="59165266:sNHT41790088" +Received: from alvh.no-ip.org (201.220.122.210) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 443B7DDC002E6A36; Tue, 2 May 2006 15:07:42 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id D44CDC31DD1; Tue, 2 May 2006 15:07:41 -0400 (CLT) +Date: Tue, 2 May 2006 15:07:41 -0400 +From: Alvaro Herrera +To: Vivek Khera , + Pgsql performance +Subject: Re: postgresql transaction id monitoring with nagios +Message-ID: <20060502190741.GI15291@surnet.cl> +Mail-Followup-To: Vivek Khera , + Pgsql performance +References: <6d8daee30605021126o7b44e255q552dcdc676c565bf@mail.gmail.com> + <628A837A-9718-46BB-85D7-8A63BBB1CA32@khera.org> + <20060502190340.GG15291@surnet.cl> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060502190340.GG15291@surnet.cl> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/37 +X-Sequence-Number: 18824 + +Alvaro Herrera wrote: +> Vivek Khera wrote: +> > +> > On May 2, 2006, at 2:26 PM, Tony Wasson wrote: +> > +> > >The script detects a wrap at 2 billion. It starts warning once one or +> > >more databases show an age over 1 billion transactions. It reports +> > >critical at 1.5B transactions. I hope everyone out there is vacuuming +> > >*all* databases often. +> > +> > Something seems wrong... I just ran your script against my +> > development database server which is vacuumed daily and it said I was +> > 53% of the way to 2B. Seemed strange to me, so I re-ran "vacuum -a - +> > z" to vacuum all databases (as superuser), reran the script and got +> > the same answer. +> +> That's right, because a database's age is only decremented in +> database-wide vacuums. + +Forget it ... I must be blind ... + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +The PostgreSQL Company - Command Prompt, Inc. + +From pgsql-performance-owner@postgresql.org Tue May 2 16:12:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 42F589FA4E1 + for ; + Tue, 2 May 2006 16:12:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 21763-03 + for ; + Tue, 2 May 2006 16:12:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id 8EB759FA25D + for ; + Tue, 2 May 2006 16:12:39 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 0AC7DB826; + Tue, 2 May 2006 15:12:39 -0400 (EDT) +In-Reply-To: <20060502190340.GG15291@surnet.cl> +References: <6d8daee30605021126o7b44e255q552dcdc676c565bf@mail.gmail.com> + <628A837A-9718-46BB-85D7-8A63BBB1CA32@khera.org> + <20060502190340.GG15291@surnet.cl> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-10-786233571; + protocol="application/pkcs7-signature" +Message-Id: +Cc: Pgsql performance +From: Vivek Khera +Subject: Re: postgresql transaction id monitoring with nagios +Date: Tue, 2 May 2006 15:12:37 -0400 +To: Alvaro Herrera +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/38 +X-Sequence-Number: 18825 + + +--Apple-Mail-10-786233571 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + + +On May 2, 2006, at 3:03 PM, Alvaro Herrera wrote: + +>> Something seems wrong... I just ran your script against my +>> development database server which is vacuumed daily and it said I was +>> 53% of the way to 2B. Seemed strange to me, so I re-ran "vacuum -a - +>> z" to vacuum all databases (as superuser), reran the script and got +>> the same answer. +> +> That's right, because a database's age is only decremented in +> database-wide vacuums. (Wow, who wouldn't want a person-wide +> vacuum if +> it did the same thing ...) + +and what exactly is "vacuumdb -a -z" doing besides a database wide +vacuum? + + +--Apple-Mail-10-786233571 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGlDCCAz8w +ggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0 +ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcx +KDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1RoYXd0 +ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVyc29uYWwtZnJlZW1haWxA +dGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5NTlaMGIxCzAJBgNVBAYTAlpB +MSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUg +UGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA +xKY8VXNV+065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/Uc4B1OVQCjDXAmNaLIkVcI7d +yfArhVqqP3FWy688Cwfn8R+RNiQqE88r1fOCdz0Dviv+uxg+B79AgAJk16emu59l0cUqVIUPSAR/ +p7bRPGEEQB5kGXJgt/sCAwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/AgEAMEMGA1UdHwQ8MDow +OKA2oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25hbEZyZWVtYWlsQ0EuY3Js +MAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRUHJpdmF0ZUxhYmVsMi0xMzgw +DQYJKoZIhvcNAQEFBQADgYEASIzRUIPqCy7MDaNmrGcPf6+svsIXoUOWlJ1/TCG4+DYfqi2fNi/A +9BxQIJNwPP2t4WFiw9k6GX6EsZkbAMUaC4J0niVQlGLH2ydxVyWN3amcOY6MIE9lX5Xa9/eH1sYI +Tq726jTlEBpbNU1341YheILcIRk13iSx0x1G/11fZU8wggNNMIICtqADAgECAhA6sDoA4m3lcimf +yUtGSQgmMA0GCSqGSIb3DQEBBAUAMGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29u +c3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNz +dWluZyBDQTAeFw0wNjA1MDIxNDEyNDdaFw0wNzA1MDIxNDEyNDdaMIGKMR8wHQYDVQQDExZUaGF3 +dGUgRnJlZW1haWwgTWVtYmVyMR4wHAYJKoZIhvcNAQkBFg92aXZla0BraGVyYS5vcmcxIDAeBgkq +hkiG9w0BCQEWEWtoZXJhQGtjaWxpbmsuY29tMSUwIwYJKoZIhvcNAQkBFhZ2aXZla0BtYWlsZXJt +YWlsZXIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq+zHKYq9vZ4Dq1itNqT/ +OeJvWDvQ5JdQlRzwsJlvtJBknXsnOaJNabmjnu2s6XFMcP2srBZQ/WPvhsClajLQOcxnarrfB66N +DpMzXTxfYzX6m9TA/fEn64sNn+YnBZL6Dvid9kiAgP9LmqcTOIFdWUya3ZmQS5YTuLB+tkFSL8/h ++inDPN6dcsna8TcM1SAk+3upxOR7kyFM9T3vy25w62Nh1zK7Stp0vUZLU6GzzC1VvHGZHKGticD6 +o3uHaMr2LCFjptoIcfZL75LO/UaR9o7smgboW4yJyW5g9ZasyYQUXyvkitfyZuVWATb8ZSHOkjWJ +872Pyf5+HOevVUI0aQIDAQABo1cwVTBFBgNVHREEPjA8gQ92aXZla0BraGVyYS5vcmeBEWtoZXJh +QGtjaWxpbmsuY29tgRZ2aXZla0BtYWlsZXJtYWlsZXIuY29tMAwGA1UdEwEB/wQCMAAwDQYJKoZI +hvcNAQEEBQADgYEAYpaFKDj47pTQIUQi28MgtjKophopv4QJjvspXmy0qxd8t/M/zc7HuBy3i/9a +PrXDgKyNBzzlFTasTazAY53ntVpqw9k1NOeHmH6o3j/DBVa49bC6bbWfp9UGOwYChlDR0tngQZyC +MDMZEdYv4zpGfBTku5m1jb8Yz/qYqV4FWB4xggMQMIIDDAIBATB2MGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIQOrA6AOJt5XIpn8lLRkkIJjAJBgUrDgMCGgUAoIIB +bzAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjA1MDIxOTEyMzha +MCMGCSqGSIb3DQEJBDEWBBQzITyIgVO/pA717xzRnfgZoU2VUTCBhQYJKwYBBAGCNxAEMXgwdjBi +MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoG +A1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECEDqwOgDibeVyKZ/JS0ZJ +CCYwgYcGCyqGSIb3DQEJEAILMXigdjBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENv +bnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElz +c3VpbmcgQ0ECEDqwOgDibeVyKZ/JS0ZJCCYwDQYJKoZIhvcNAQEBBQAEggEAcufjc5f0WegYEOOX +VtH1+CTNO7abwFkzC+97pX6Q/hdKOJR9OkPWVEbhy0DeMM6A0yLlXDhGtI4MxvP9PxBn25Y1kTc/ +1eIsLjjScdyBrVSvotwIr+iD/jKdTjhAqfIPCOHG6xZevI49jb5EXbgxU21zHlA2Zyu4q62eKIp5 +db9ajmVO+k01c0+A+yNe4/E6RK7QThv5Q3EWWTbAQoBDZXrO/Lt0ZU8E0Ubi3W7QkH4KMpUvtiOH +j8GupxvrXk9dE/N2YtUBzPT9Ck1xTXtuWcQWed3/XPbRRaxW/Qb+hFY5cdIAkj48an7/bL9Iv1z7 +g1EqzihWgpmswdTmkrlHGgAAAAAAAA== + +--Apple-Mail-10-786233571-- + +From pgsql-performance-owner@postgresql.org Tue May 2 16:28:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 648009FB1F2 + for ; + Tue, 2 May 2006 16:28:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27732-08 + for ; + Tue, 2 May 2006 16:28:32 -0300 (ADT) +X-Greylist: delayed 17:51:26.097844 by SQLgrey- +Received: from mail.goldpocket.com (mail1.goldpocket.com [38.101.116.14]) + by postgresql.org (Postfix) with ESMTP id 4ADD79F9CC1 + for ; + Tue, 2 May 2006 16:28:31 -0300 (ADT) +Received: from localhost (unknown [127.0.0.1]) + by mail.goldpocket.com (Postfix) with ESMTP id AFE72E048FAB + for ; + Tue, 2 May 2006 19:28:24 +0000 (UTC) +Received: from mail.goldpocket.com ([127.0.0.1]) + by localhost (mail.goldpocket.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 06958-15 for ; + Tue, 2 May 2006 12:28:18 -0700 (PDT) +Received: from mail1.goldpocket.com (srvgpimail1.gpi.local [10.10.0.13]) + by mail.goldpocket.com (Postfix) with ESMTP id CD916E048F24 + for ; + Tue, 2 May 2006 12:28:18 -0700 (PDT) +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C66E1E.90E966AB" +Subject: Re: Why is plan (and performance) different on partitioned table? +Date: Tue, 2 May 2006 12:28:18 -0700 +Message-ID: <9D938282F8C6EE43B748B910386DE93E0138B43D@srvgpimail1.GPI.local> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Why is plan (and performance) different on partitioned + table? +Thread-Index: AcZtoxdyehQ6DQo+TkezLjByR8L1MAAeI21X +From: "Mark Liberman" +To: "Tom Lane" +Cc: +X-Virus-Scanned: amavisd-new at goldpocket.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/39 +X-Sequence-Number: 18826 + +This is a multi-part message in MIME format. + +------_=_NextPart_001_01C66E1E.90E966AB +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +>If you don't have anything in the parent table br_1min, then deleting +>the (presumably obsolete) pg_statistic rows for it should fix your +>immediate problem. Otherwise, consider applying the attached. + +Tom, thanks alot for your reply. A few follow-up questions, and one = +potential "bug"? + +I've been experimenting with deleting the rows from pg_statistics. FYI, = +there were statistics for all master tables prior to us partioning the = +data. We then manually inserted the rows into each inherited partition = +and, when done - did a truncate of the master table. + +So, here's what I'm finding. =20 + +1) When I delete the rows from pg_statistics, the new plan is, indeed, a = +hash join. + +explain analyze +SELECT * +FROM br_1min br1 JOIN br_mods mod on br1.modules_id =3D mod.id=20 +WHERE ((end_time >=3D '2006-05-01 17:12:18-07' AND end_time < = +'2006-05-01 17:13:18-07')) + AND mod.downloads_id IN = +(153226,153714,153730,153728,153727,153724,153713,153725,153739,153722) = +; + +Hash Join (cost=3D763.35..807.35 rows=3D1 width=3D109) (actual = +time=3D3.631..36.181 rows=3D45 loops=3D1) + Hash Cond: ("outer".modules_id =3D "inner".id) + -> Append (cost=3D1.04..40.64 rows=3D877 width=3D32) (actual = +time=3D0.198..34.872 rows=3D910 loops=3D1) + -> Bitmap Heap Scan on br_1min bfs1 (cost=3D1.04..8.70 = +rows=3D6 width=3D32) (actual time=3D0.060..0.060 rows=3D0 loops=3D1) + Recheck Cond: ((end_time >=3D '2006-05-01 = +17:12:18-07'::timestamp with time zone) AND (end_time < '2006-05-01 = +17:13:18-07'::timestamp with time zone)) + -> Bitmap Index Scan on br_1min_end_idx = +(cost=3D0.00..1.04 rows=3D6 width=3D0) (actual time=3D0.054..0.054 = +rows=3D0 loops=3D1) + Index Cond: ((end_time >=3D '2006-05-01 = +17:12:18-07'::timestamp with time zone) AND (end_time < '2006-05-01 = +17:13:18-07'::timestamp with time zone)) + -> Index Scan using br_1min_20557_end_idx on br_1min_20557 = +bfs1 (cost=3D0.00..25.91 rows=3D869 width=3D32) (actual = +time=3D0.136..1.858 rows=3D910 loops=3D1) + Index Cond: ((end_time >=3D '2006-05-01 = +17:12:18-07'::timestamp with time zone) AND (end_time < '2006-05-01 = +17:13:18-07'::timestamp with time zone)) + -> Index Scan using br_1min_20570_end_idx on br_1min_20570 = +bfs1 (cost=3D0.00..3.02 rows=3D1 width=3D32) (actual = +time=3D0.092..0.092 rows=3D0 loops=3D1) + Index Cond: ((end_time >=3D '2006-05-01 = +17:12:18-07'::timestamp with time zone) AND (end_time < '2006-05-01 = +17:13:18-07'::timestamp with time zone)) + -> Index Scan using br_1min_20583_end_idx on br_1min_20583 = +bfs1 (cost=3D0.00..3.02 rows=3D1 width=3D32) (actual = +time=3D32.034..32.034 rows=3D0 loops=3D1) + Index Cond: ((end_time >=3D '2006-05-01 = +17:12:18-07'::timestamp with time zone) AND (end_time < '2006-05-01 = +17:13:18-07'::timestamp with time zone)) + -> Hash (cost=3D761.61..761.61 rows=3D281 width=3D77) (actual = +time=3D0.487..0.487 rows=3D45 loops=3D1) + -> Bitmap Heap Scan on br_mods mod (cost=3D20.98..761.61 = +rows=3D281 width=3D77) (actual time=3D0.264..0.435 rows=3D45 loops=3D1) + Recheck Cond: ((downloads_id =3D 153226) OR (downloads_id = +=3D 153714) OR (downloads_id =3D 153730) OR (downloads_id =3D 153728) OR = +(downloads_id =3D 153727) OR (downloads_id =3D 153724) OR (downloads_id = +=3D 153713) OR (downloads_id =3D 153725) OR (downloads_id =3D 153739) OR = +(downloads_id =3D 153722)) + -> BitmapOr (cost=3D20.98..20.98 rows=3D281 width=3D0) = +(actual time=3D0.223..0.223 rows=3D0 loops=3D1) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.091..0.091 = +rows=3D14 loops=3D1) + Index Cond: (downloads_id =3D 153226) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.037..0.037 = +rows=3D2 loops=3D1) + Index Cond: (downloads_id =3D 153714) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.010..0.010 = +rows=3D2 loops=3D1) + Index Cond: (downloads_id =3D 153730) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.008..0.008 = +rows=3D2 loops=3D1) + Index Cond: (downloads_id =3D 153728) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.008..0.008 = +rows=3D2 loops=3D1) + Index Cond: (downloads_id =3D 153727) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.007..0.007 = +rows=3D2 loops=3D1) + Index Cond: (downloads_id =3D 153724) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.007..0.007 = +rows=3D2 loops=3D1) + Index Cond: (downloads_id =3D 153713) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.007..0.007 = +rows=3D2 loops=3D1) + Index Cond: (downloads_id =3D 153725) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.031..0.031 = +rows=3D16 loops=3D1) + Index Cond: (downloads_id =3D 153739) + -> Bitmap Index Scan on br_mods_downloads_id_idx = +(cost=3D0.00..2.10 rows=3D28 width=3D0) (actual time=3D0.009..0.009 = +rows=3D1 loops=3D1) + Index Cond: (downloads_id =3D 153722) + Total runtime: 36.605 ms +(38 rows) + + +Note: there are 2 new partitions that our cron jobs automatically = +created yesterday that are being scanned, but they do not return any = +rows. + +2) When I re-analyze the br_1min table, new rows do not appear in = +pg_statistics for that table. + +Now, my questions: + +1) If there are no statistics for the master table, does postgres use = +the statistics for any of the partitions, or does it create a plan = +without any statistics related to the partitioned tables (e.g. some = +default plan.)? + +2) I'm curious where it got an estimate of 6 rows for br_1min in "Bitmap = +Heap Scan on br_1min bfs1 (cost=3D1.04..8.70 rows=3D6 width=3D32)" Any = +insight? + +3) Basically, I'm wondering if this strategy of deleting the rows in = +pg_statistics for the master tables will work in all conditions, or if = +it runs the risk of again using faulty statistics and choosing a bad = +plan. Would I be better off setting enable_mergejoin =3D f in the = +session right before I issue this query and then resetting it after? = +What are the risks of that approach? + + +Now, the potentital bug: + +It appears that after you truncate a table, the statistics for that = +table still remain in pg_statistics. And, as long as there are no rows = +added back to that table, the same statistics remain for that table, = +after an ANALYZE, - and are used by queries. Once, you re-insert any = +rows in the table, however, new statistics will be computed. So, the = +bug appears to be that after a truncate, if there are no rows in a = +table, the old, out-dated statistics do not get overwritten. To follow = +are some simple tests I did to illustrate that. Maybe this is by = +design, or, should I post this on pg-hackers? It might be that in my = +case, it's better that new statitics ARE NOT inserted into pg_statistics = +for empty tables, but maybe the fix could be to delete the old = +statistics for analyzes to an empty table. + +Thanks again Tom for your feedback, + +- Mark + + +prdb=3D# create table mark_temp (col1 int, col2 int); +CREATE TABLE +prdb=3D# create index mark_temp_idx on mark_temp(col1); +CREATE INDEX + +... I then inserted several thousand rows .... + +prdb=3D# analyze mark_temp; +ANALYZE +prdb=3D# select staattnum,stadistinct from pg_statistic where starelid = +=3D (select oid from pg_class where relname =3D 'mark_temp'); + staattnum | stadistinct +-----------+------------- + 1 | 9671 + 2 | 1 +(2 rows) + +prdb=3D# explain analyze select * from mark_temp where col1 =3D 1045; + QUERY PLAN +-------------------------------------------------------------------------= +-------------------------------------------------- + Index Scan using mark_temp_idx on mark_temp (cost=3D0.00..51.35 = +rows=3D27 width=3D8) (actual time=3D0.013..0.015 rows=3D1 loops=3D1) + Index Cond: (col1 =3D 1045) + Total runtime: 0.048 ms +(3 rows) + +prdb=3D# truncate table mark_temp; +TRUNCATE TABLE +prdb=3D# analyze mark_temp; +ANALYZE + +NOTE: STATISTICS ARE THE SAME AND IT'S STILL DOING AN INDEX SCAN = +INSTEAD OF A SEQ SCAN + +prdb=3D# explain analyze select * from mark_temp where col1 =3D 1045; + QUERY PLAN +-------------------------------------------------------------------------= +------------------------------------------------ + Index Scan using mark_temp_idx on mark_temp (cost=3D0.00..3.14 = +rows=3D1 width=3D8) (actual time=3D0.004..0.004 rows=3D0 loops=3D1) + Index Cond: (col1 =3D 1045) + Total runtime: 0.031 ms +(3 rows) + +prdb=3D# select staattnum,stadistinct from pg_statistic where starelid = +=3D (select oid from pg_class where relname =3D 'mark_temp'); + staattnum | stadistinct +-----------+------------- + 1 | 9671 + 2 | 1 +(2 rows) + +prdb=3D# insert into mark_temp (col1,col2) values (1,100); +INSERT 0 1 +prdb=3D# analyze mark_temp; + +NOTE: AFTER INSERT, THERE ARE NEW STATISTICS AND IT'S DOING A SEQ SCAN = +NOW + +ANALYZE +prdb=3D# select staattnum,stadistinct from pg_statistic where starelid = +=3D (select oid from pg_class where relname =3D 'mark_temp'); + staattnum | stadistinct +-----------+------------- + 1 | -1 + 2 | -1 +(2 rows) + +prdb=3D# explain analyze select * from mark_temp where col1 =3D 1045; + QUERY PLAN +-------------------------------------------------------------------------= +-------------------------- + Seq Scan on mark_temp (cost=3D0.00..1.01 rows=3D1 width=3D8) (actual = +time=3D0.007..0.007 rows=3D0 loops=3D1) + Filter: (col1 =3D 1045) + Total runtime: 0.029 ms +(3 rows) + + + + + + + + +------_=_NextPart_001_01C66E1E.90E966AB +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] Why is plan (and performance) different on = +partitioned table? + + + + +

>If you don't have anything in the parent table = +br_1min, then deleting
+>the (presumably obsolete) pg_statistic rows for it should fix = +your
+>immediate problem.  Otherwise, consider applying the = +attached.
+
+Tom, thanks alot for your reply.  A few follow-up questions, and = +one potential "bug"?
+
+I've been experimenting with deleting the rows from pg_statistics.  = +FYI, there were statistics for all master tables prior to us partioning = +the data.  We then manually inserted the rows into each inherited = +partition and, when done - did a truncate of the master table.
+
+So, here's what I'm finding. 
+
+1) When I delete the rows from pg_statistics, the new plan is, indeed, a = +hash join.
+
+explain analyze
+SELECT *
+FROM br_1min br1 JOIN br_mods mod on br1.modules_id =3D mod.id
+WHERE ((end_time >=3D '2006-05-01 17:12:18-07' AND end_time < = +'2006-05-01 17:13:18-07'))
+  AND mod.downloads_id IN = +(153226,153714,153730,153728,153727,153724,153713,153725,153739,153722) = +;
+
+Hash Join  (cost=3D763.35..807.35 rows=3D1 width=3D109) (actual = +time=3D3.631..36.181 rows=3D45 loops=3D1)
+   Hash Cond: ("outer".modules_id =3D = +"inner".id)
+   ->  Append  (cost=3D1.04..40.64 rows=3D877 = +width=3D32) (actual time=3D0.198..34.872 rows=3D910 loops=3D1)
+         ->  Bitmap Heap = +Scan on br_1min bfs1  (cost=3D1.04..8.70 rows=3D6 width=3D32) = +(actual time=3D0.060..0.060 rows=3D0 loops=3D1)
+            &= +nbsp;  Recheck Cond: ((end_time >=3D '2006-05-01 = +17:12:18-07'::timestamp with time zone) AND (end_time < '2006-05-01 = +17:13:18-07'::timestamp with time zone))
+            &= +nbsp;  ->  Bitmap Index Scan on br_1min_end_idx  = +(cost=3D0.00..1.04 rows=3D6 width=3D0) (actual time=3D0.054..0.054 = +rows=3D0 loops=3D1)
+            &= +nbsp;        Index Cond: ((end_time = +>=3D '2006-05-01 17:12:18-07'::timestamp with time zone) AND = +(end_time < '2006-05-01 17:13:18-07'::timestamp with time zone))
+         ->  Index Scan = +using br_1min_20557_end_idx on br_1min_20557 bfs1  = +(cost=3D0.00..25.91 rows=3D869 width=3D32) (actual time=3D0.136..1.858 = +rows=3D910 loops=3D1)
+            &= +nbsp;  Index Cond: ((end_time >=3D '2006-05-01 = +17:12:18-07'::timestamp with time zone) AND (end_time < '2006-05-01 = +17:13:18-07'::timestamp with time zone))
+         ->  Index Scan = +using br_1min_20570_end_idx on br_1min_20570 bfs1  = +(cost=3D0.00..3.02 rows=3D1 width=3D32) (actual time=3D0.092..0.092 = +rows=3D0 loops=3D1)
+            &= +nbsp;  Index Cond: ((end_time >=3D '2006-05-01 = +17:12:18-07'::timestamp with time zone) AND (end_time < '2006-05-01 = +17:13:18-07'::timestamp with time zone))
+         ->  Index Scan = +using br_1min_20583_end_idx on br_1min_20583 bfs1  = +(cost=3D0.00..3.02 rows=3D1 width=3D32) (actual time=3D32.034..32.034 = +rows=3D0 loops=3D1)
+            &= +nbsp;  Index Cond: ((end_time >=3D '2006-05-01 = +17:12:18-07'::timestamp with time zone) AND (end_time < '2006-05-01 = +17:13:18-07'::timestamp with time zone))
+   ->  Hash  (cost=3D761.61..761.61 rows=3D281 = +width=3D77) (actual time=3D0.487..0.487 rows=3D45 loops=3D1)
+         ->  Bitmap Heap = +Scan on br_mods mod  (cost=3D20.98..761.61 rows=3D281 width=3D77) = +(actual time=3D0.264..0.435 rows=3D45 loops=3D1)
+            &= +nbsp;  Recheck Cond: ((downloads_id =3D 153226) OR (downloads_id = +=3D 153714) OR (downloads_id =3D 153730) OR (downloads_id =3D 153728) OR = +(downloads_id =3D 153727) OR (downloads_id =3D 153724) OR (downloads_id = +=3D 153713) OR (downloads_id =3D 153725) OR (downloads_id =3D 153739) OR = +(downloads_id =3D 153722))
+            &= +nbsp;  ->  BitmapOr  (cost=3D20.98..20.98 rows=3D281 = +width=3D0) (actual time=3D0.223..0.223 rows=3D0 loops=3D1)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.091..0.091 rows=3D14 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153226)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.037..0.037 rows=3D2 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153714)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.010..0.010 rows=3D2 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153730)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.008..0.008 rows=3D2 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153728)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.008..0.008 rows=3D2 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153727)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.007..0.007 rows=3D2 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153724)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.007..0.007 rows=3D2 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153713)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.007..0.007 rows=3D2 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153725)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.031..0.031 rows=3D16 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153739)
+            &= +nbsp;        ->  Bitmap Index = +Scan on br_mods_downloads_id_idx  (cost=3D0.00..2.10 rows=3D28 = +width=3D0) (actual time=3D0.009..0.009 rows=3D1 loops=3D1)
+            &= +nbsp;           &n= +bsp;  Index Cond: (downloads_id =3D 153722)
+ Total runtime: 36.605 ms
+(38 rows)
+
+
+Note:  there are 2 new partitions that our cron jobs automatically = +created yesterday that are being scanned, but they do not return any = +rows.
+
+2) When I re-analyze the br_1min table, new rows do not appear in = +pg_statistics for that table.
+
+Now, my questions:
+
+1) If there are no statistics for the master table, does postgres use = +the statistics for any of the partitions, or does it create a plan = +without any statistics related to the partitioned tables (e.g. some = +default plan.)?
+
+2) I'm curious where it got an estimate of 6 rows for br_1min in = +"Bitmap Heap Scan on br_1min bfs1  (cost=3D1.04..8.70 rows=3D6 = +width=3D32)"  Any insight?
+
+3) Basically, I'm wondering if this strategy of deleting the rows in = +pg_statistics for the master tables will work in all conditions, or if = +it runs the risk of again using faulty statistics and choosing a bad = +plan.  Would I be better off setting enable_mergejoin =3D f in the = +session right before I  issue this query and then resetting it = +after?  What are the risks of that approach?
+
+
+Now, the potentital bug:
+
+It appears that after you truncate a table, the statistics for that = +table still remain in pg_statistics.  And, as long as there are no = +rows added back to that table, the same statistics remain for that = +table, after an ANALYZE, - and are used by queries.  Once, you = +re-insert any rows in the table, however, new statistics will be = +computed.  So, the bug appears to be that after a truncate, if = +there are no rows in a table, the old, out-dated statistics do not get = +overwritten.  To follow are some simple tests I did to illustrate = +that.  Maybe this is by design, or, should I post this on = +pg-hackers?  It might be that in my case, it's better that new = +statitics ARE NOT inserted into pg_statistics for empty tables, but = +maybe the fix could be to delete the old statistics for analyzes to an = +empty table.
+
+Thanks again Tom for your feedback,
+
+- Mark
+
+
+prdb=3D# create table mark_temp (col1 int, col2 int);
+CREATE TABLE
+prdb=3D# create index mark_temp_idx on mark_temp(col1);
+CREATE INDEX
+
+... I then inserted several thousand rows ....
+
+prdb=3D# analyze mark_temp;
+ANALYZE
+prdb=3D# select staattnum,stadistinct from pg_statistic where starelid = +=3D (select oid from pg_class where relname =3D 'mark_temp');
+ staattnum | stadistinct
+-----------+-------------
+         1 = +|        9671
+         2 = +|           1
+(2 rows)
+
+prdb=3D# explain analyze select * from mark_temp where col1 =3D = +1045;
+            &= +nbsp;           &n= +bsp;           &nb= +sp;           &nbs= +p;       QUERY PLAN
+-------------------------------------------------------------------------= +--------------------------------------------------
+ Index Scan using mark_temp_idx on mark_temp  = +(cost=3D0.00..51.35 rows=3D27 width=3D8) (actual time=3D0.013..0.015 = +rows=3D1 loops=3D1)
+   Index Cond: (col1 =3D 1045)
+ Total runtime: 0.048 ms
+(3 rows)
+
+prdb=3D# truncate table mark_temp;
+TRUNCATE TABLE
+prdb=3D# analyze mark_temp;
+ANALYZE
+
+NOTE:  STATISTICS ARE THE SAME AND IT'S STILL DOING AN INDEX SCAN = +INSTEAD OF A SEQ SCAN
+
+prdb=3D# explain analyze select * from mark_temp where col1 =3D = +1045;
+            &= +nbsp;           &n= +bsp;           &nb= +sp;           &nbs= +p;      QUERY PLAN
+-------------------------------------------------------------------------= +------------------------------------------------
+ Index Scan using mark_temp_idx on mark_temp  = +(cost=3D0.00..3.14 rows=3D1 width=3D8) (actual time=3D0.004..0.004 = +rows=3D0 loops=3D1)
+   Index Cond: (col1 =3D 1045)
+ Total runtime: 0.031 ms
+(3 rows)
+
+prdb=3D# select staattnum,stadistinct from pg_statistic where starelid = +=3D (select oid from pg_class where relname =3D 'mark_temp');
+ staattnum | stadistinct
+-----------+-------------
+         1 = +|        9671
+         2 = +|           1
+(2 rows)
+
+prdb=3D# insert into mark_temp (col1,col2) values (1,100);
+INSERT 0 1
+prdb=3D# analyze mark_temp;
+
+NOTE: AFTER INSERT, THERE ARE NEW STATISTICS AND IT'S DOING A SEQ SCAN = +NOW
+
+ANALYZE
+prdb=3D# select staattnum,stadistinct from pg_statistic where starelid = +=3D (select oid from pg_class where relname =3D 'mark_temp');
+ staattnum | stadistinct
+-----------+-------------
+         1 = +|          -1
+         2 = +|          -1
+(2 rows)
+
+prdb=3D# explain analyze select * from mark_temp where col1 =3D = +1045;
+            &= +nbsp;           &n= +bsp;           &nb= +sp;       QUERY PLAN
+-------------------------------------------------------------------------= +--------------------------
+ Seq Scan on mark_temp  (cost=3D0.00..1.01 rows=3D1 width=3D8) = +(actual time=3D0.007..0.007 rows=3D0 loops=3D1)
+   Filter: (col1 =3D 1045)
+ Total runtime: 0.029 ms
+(3 rows)
+
+
+
+
+
+
+
+
+

+ + + +------_=_NextPart_001_01C66E1E.90E966AB-- + +From pgsql-performance-owner@postgresql.org Tue May 2 16:34:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id ECA0A9FA261 + for ; + Tue, 2 May 2006 16:34:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 08332-09 + for ; + Tue, 2 May 2006 16:34:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx.sat.rackspace.com (mx.sat.rackspace.com [64.39.1.214]) + by postgresql.org (Postfix) with ESMTP id 31F4B9FA25D + for ; + Tue, 2 May 2006 16:34:15 -0300 (ADT) +Received: from mail.rackspace.com (mail.rackspace.com [64.39.2.181]) + by mx.sat.rackspace.com (8.13.6/8.13.6) with ESMTP id k42JYDw7008917 + for ; Tue, 2 May 2006 14:34:13 -0500 + (envelope-from wreese@rackspace.com) +Received: from [10.6.104.60] (office104-60.sat4.rackspace.com [10.6.104.60]) + (authenticated bits=0) + by mail.rackspace.com (8.13.1/8.13.1) with ESMTP id k42JYCZC005738 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO) + for ; Tue, 2 May 2006 14:34:12 -0500 +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <1146595755.12053.111.camel@archimedes> +References: <444F24E9.2010907@lisasoft.com> + <20060502171617.GZ97354@pervasive.com> + <622925BE-A31E-42FD-AF6A-68DDF3B4A1B7@clickspace.com> + <1146595755.12053.111.camel@archimedes> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <758B0591-3C9C-418B-9AF2-E962003C4904@rackspace.com> +Content-Transfer-Encoding: 7bit +From: Will Reese +Subject: Re: Slow restoration question +Date: Tue, 2 May 2006 14:34:16 -0500 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.749.3) +X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='__C230066_P5 0, + __CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, + __HAS_MSGID 0, __HAS_X_MAILER 0, __MIME_TEXT_ONLY 0, + __MIME_VERSION 0, __SANE_MSGID 0, __STOCK_CRUFT 0' +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/40 +X-Sequence-Number: 18827 + +RAID 10 is better than RAID 0+1. There is a lot of information on +the net about this, but here is the first one that popped up on +google for me. + +http://www.pcguide.com/ref/hdd/perf/raid/levels/multLevel01-c.html + +The quick summary is that performance is about the same between the +two, but RAID 10 gives better fault tolerance and rebuild +performance. I have seen docs for RAID cards that have confused +these two RAID levels. In addition, some cards claim to support RAID +10, when they actually support RAID 0+1 or even RAID 0+1 with +concatenation (lame, some of the Dell PERCs have this). + +RAID 10 with 6 drives would stripe across 3 mirrored pairs. RAID 0+1 +with 6 drives is a mirror of two striped arrays (3 disks each). RAID +0+1 (with concatenation) using 6 drives is a mirror of two volumes +(kind of like JBOD) each consisting of 3 drives concatenated together +(it's a cheap implementation, and it gives about the same performance +as RAID 1 but with increased storage capacity and less fault +tolerance). RAID 10 is better than RAID 5 (especially with 6 or less +disks) because you don't have the performance hit for parity (which +dramatically affects rebuild performance and write performance) and +you get better fault tolerance (up to 3 disks can fail in a 6 disk +RAID 10 and you can still be online, with RAID 5 you can only lose 1 +drive). All of this comes with a higher cost (more drives and higher +end cards). + +-- Will Reese http://blog.rezra.com + + +On May 2, 2006, at 1:49 PM, Mark Lewis wrote: + +> They are not equivalent. As I understand it, RAID 0+1 performs about +> the same as RAID 10 when everything is working, but degrades much less +> nicely in the presence of a single failed drive, and is more likely to +> suffer catastrophic data loss if multiple drives fail. +> +> -- Mark +> +> On Tue, 2006-05-02 at 12:40 -0600, Brendan Duddridge wrote: +>> Everyone here always says that RAID 5 isn't good for Postgres. We +>> have an Apple Xserve RAID configured with RAID 5. We chose RAID 5 +>> because Apple said their Xserve RAID was "optimized" for RAID 5. Not +>> sure if we made the right decision though. They give an option for +>> formatting as RAID 0+1. Is that the same as RAID 10 that everyone +>> talks about? Or is it the reverse? +>> +>> Thanks, +>> +>> ____________________________________________________________________ +>> Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com +>> +>> ClickSpace Interactive Inc. +>> Suite L100, 239 - 10th Ave. SE +>> Calgary, AB T2G 0V9 +>> +>> http://www.clickspace.com +>> +>> On May 2, 2006, at 11:16 AM, Jim C. Nasby wrote: +>> +>>> On Wed, Apr 26, 2006 at 05:14:41PM +0930, Eric Lam wrote: +>>>> all dumpfiles total about 17Gb. It has been running for 50ish hrs +>>>> and up +>>>> to about the fourth file (5-6 ish Gb) and this is on a raid 5 +>>>> server. +>>> +>>> RAID5 generally doesn't bode too well for performance; that could be +>>> part of the issue. +>>> -- +>>> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +>>> Pervasive Software http://pervasive.com work: 512-231-6117 +>>> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +>>> +>>> ---------------------------(end of +>>> broadcast)--------------------------- +>>> TIP 4: Have you searched our list archives? +>>> +>>> http://archives.postgresql.org +>>> +>> +>> +>> +>> ---------------------------(end of +>> broadcast)--------------------------- +>> TIP 9: In versions below 8.0, the planner will ignore your desire to +>> choose an index scan if your joining column's datatypes do not +>> match +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 6: explain analyze is your friend + + +From pgsql-performance-owner@postgresql.org Tue May 2 17:13:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E89BD9FB1F0 + for ; + Tue, 2 May 2006 17:13:51 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 19982-02 + for ; + Tue, 2 May 2006 17:13:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 3EE329FB1D3 + for ; + Tue, 2 May 2006 17:13:37 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id C804A5643D; Tue, 2 May 2006 15:13:35 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Tue, 2 May 2006 15:13:35 -0500 +Date: Tue, 2 May 2006 15:13:35 -0500 +From: "Jim C. Nasby" +To: K C Lau +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: Why so slow? +Message-ID: <20060502201334.GA97354@pervasive.com> +References: <20060428145842.GI97354@pervasive.com> + + <20060428190005.GA15689@wolff.to> + <6.2.1.2.0.20060429084119.05290438@localhost> + <19397.1146278368@sss.pgh.pa.us> + <6.2.1.2.0.20060429110036.02c01b98@localhost> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6.2.1.2.0.20060429110036.02c01b98@localhost> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060502:kclau60@netvigator.com::hMJMnlJCjsKOBc67:000000000000000 + 0000000000000000000000004yRM +X-Hashcash: + 1:20:060502:tgl@sss.pgh.pa.us::4OaIkhBUWE+XFYHY:00000000000000000000 + 0000000000000000000000000RaB +X-Hashcash: + 1:20:060502:pgsql-performance@postgresql.org::iJ3MbZH2bqT1XRrM:00000 + 00000000000000000000000018Bu +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/41 +X-Sequence-Number: 18828 + +On Sat, Apr 29, 2006 at 11:18:10AM +0800, K C Lau wrote: +> +> At 10:39 06/04/29, Tom Lane wrote: +> >K C Lau writes: +> >> Without knowing the internals, I have this simplistic idea: if Postgres +> >> maintains the current lowest transaction ID for all active +> >transactions, it +> >> probably could recycle dead tuples on the fly. +> > +> >[ yawn... ] Yes, we've heard that before. The hard part is getting rid +> >of index entries. +> > +> > regards, tom lane +> +> I apologize for simplistic ideas again. I presume that the equivalent tuple +> header information is not maintained for index entries. What if they are, +> probably only for the most commonly used index types to allow recycling +> where possible? The extra space required would be recycled too. It would +> probably also help save a trip to the tuple data pages to determine the +> validity of index entries during index scans. + +You should read through the -hacker archives, most of this stuff has +been gone over multiple times. + +Storing tuple header info in indexes would be a huge drawback, as it +would result in about 20 extra bytes per index entry. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 2 17:17:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E0ABE9FB1F7 + for ; + Tue, 2 May 2006 17:17:51 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29712-07 + for ; + Tue, 2 May 2006 17:17:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id CCF379FB1D5 + for ; + Tue, 2 May 2006 17:17:43 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id A0B2D56435; Tue, 2 May 2006 15:17:42 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Tue, 2 May 2006 15:17:41 -0500 +Date: Tue, 2 May 2006 15:17:41 -0500 +From: "Jim C. Nasby" +To: Bill Moran +Cc: Bealach-na Bo , ahodgson@simkin.ca, + pgsql-performance@postgresql.org +Subject: Re: Why so slow? +Message-ID: <20060502201740.GB97354@pervasive.com> +References: <200604281043.16083@hal.medialogik.com> + + <20060430100346.20f010a9.wmoran@collaborativefusion.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060430100346.20f010a9.wmoran@collaborativefusion.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060502:wmoran@collaborativefusion.com::fHplmBGv3nLCT83X:0000000 + 0000000000000000000000003Haj +X-Hashcash: + 1:20:060502:bealach_na_bo@hotmail.com::5kCdV0Hqvz4CakAw:000000000000 + 000000000000000000000000CrW2 +X-Hashcash: + 1:20:060502:ahodgson@simkin.ca::ADn/hN6LIxYChf6q:0000000000000000000 + 0000000000000000000000000+AS +X-Hashcash: + 1:20:060502:pgsql-performance@postgresql.org::SZwFl18GuDjVZ8Uw:00000 + 0000000000000000000000000uSD +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/42 +X-Sequence-Number: 18829 + +On Sun, Apr 30, 2006 at 10:03:46AM -0400, Bill Moran wrote: +> At this point, it seems like you need to do 2 things: +> 1) Schedule lazy vacuum to run, or configure autovacuum. +> 2) Schedule some downtime to run "vacuum full" to recover some disk space. +> +> #2 only needs done once to get you back on track, assuming that #1 is +> done properly. + +You'll also want to reindex since vacuum full won't clean the indexes +up. You might also want to read +http://www.pervasivepostgres.com/instantkb13/article.aspx?id=10087 and +http://www.pervasivepostgres.com/instantkb13/article.aspx?id=10116. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 2 17:19:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7D82A9FB1D3 + for ; + Tue, 2 May 2006 17:19:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 03296-06-5 + for ; + Tue, 2 May 2006 17:18:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id BA5BE9FB1D5 + for ; + Tue, 2 May 2006 17:18:53 -0300 (ADT) +Received: (qmail 15583 invoked by uid 500); 2 May 2006 20:19:30 -0000 +Date: Tue, 2 May 2006 15:19:29 -0500 +From: Bruno Wolff III +To: Tony Wasson +Cc: Vivek Khera , + Pgsql performance +Subject: Re: postgresql transaction id monitoring with nagios +Message-ID: <20060502201928.GB14674@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Tony Wasson , Vivek Khera , + Pgsql performance +References: <6d8daee30605021126o7b44e255q552dcdc676c565bf@mail.gmail.com> + <628A837A-9718-46BB-85D7-8A63BBB1CA32@khera.org> + <6d8daee30605021206h8170a48w94670b5d23633a72@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6d8daee30605021206h8170a48w94670b5d23633a72@mail.gmail.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/43 +X-Sequence-Number: 18830 + +On Tue, May 02, 2006 at 12:06:30 -0700, + Tony Wasson wrote: +> +> Ah thanks, it's a bug in my understanding of the thresholds. +> +> "With the standard freezing policy, the age column will start at one +> billion for a freshly-vacuumed database." +> +> So essentially, 1B is normal, 2B is the max. The logic is now.. +> +> The script detects a wrap at 2 billion. It starts warning once one or +> more databases show an age over 1.5 billion transactions. It reports +> critical at 1.75B transactions. +> +> If anyone else understands differently, hit me with a clue bat. + +Isn't this obsolete now anyway? I am pretty sure 8.1 has safeguards against +wrap around. + +From pgsql-performance-owner@postgresql.org Tue May 2 17:28:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5001E9FB1F0 + for ; + Tue, 2 May 2006 17:28:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10320-01 + for ; + Tue, 2 May 2006 17:27:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id BF2D69FB1D3 + for ; + Tue, 2 May 2006 17:27:54 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k42KRqiO026843; + Tue, 2 May 2006 16:27:52 -0400 (EDT) +To: "Mark Liberman" +cc: pgsql-performance@postgresql.org +Subject: Re: Why is plan (and performance) different on partitioned table? +In-reply-to: <9D938282F8C6EE43B748B910386DE93E0138B43D@srvgpimail1.GPI.local> +References: <9D938282F8C6EE43B748B910386DE93E0138B43D@srvgpimail1.GPI.local> +Comments: In-reply-to "Mark Liberman" + message dated "Tue, 02 May 2006 12:28:18 -0700" +Date: Tue, 02 May 2006 16:27:52 -0400 +Message-ID: <26842.1146601672@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/44 +X-Sequence-Number: 18831 + +"Mark Liberman" writes: +> Now, the potentital bug: +> It appears that after you truncate a table, the statistics for that = +> table still remain in pg_statistics. + +That's intentional, on the theory that when the table is re-populated +the new contents will probably resemble the old. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 2 17:29:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E46AF9FB1F1 + for ; + Tue, 2 May 2006 17:29:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 69092-08 + for ; + Tue, 2 May 2006 17:28:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id D03D09FB1D3 + for ; + Tue, 2 May 2006 17:28:54 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 6E3B756435; Tue, 2 May 2006 15:28:38 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Tue, 2 May 2006 15:28:37 -0500 +Date: Tue, 2 May 2006 15:28:37 -0500 +From: "Jim C. Nasby" +To: Mark Kirkwood +Cc: Gregory Stewart , pgsql-performance@postgresql.org +Subject: Re: Performance Issues on Opteron Dual Core +Message-ID: <20060502202837.GC97354@pervasive.com> +References: <445498AC.10700@paradise.net.nz> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <445498AC.10700@paradise.net.nz> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060502:markir@paradise.net.nz::hvi6jGB4lVvUc8Qb:000000000000000 + 00000000000000000000000002BC +X-Hashcash: + 1:20:060502:gstewart@sweetdata.com::P+Of/v5jCwM+HKUT:000000000000000 + 0000000000000000000000001m6a +X-Hashcash: + 1:20:060502:pgsql-performance@postgresql.org::MCqh7NFgx6tfDBwE:00000 + 0000000000000000000000001Jnj +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/45 +X-Sequence-Number: 18832 + +On Sun, Apr 30, 2006 at 10:59:56PM +1200, Mark Kirkwood wrote: +> Pgadmin can give misleading times for queries that return large result +> sets over a network, due to: +> +> 1/ It takes time to format the (large) result set for display. +> 2/ It has to count the time spent waiting for the (large) result set to +> travel across the network. +> +> You aren't running Pgadmin off the dev server are you? If not check your +> network link to dev and prod - is one faster than the other? (etc). +> +> To eliminate Pgadmin and the network as factors try wrapping your query +> in a 'SELECT count(*) FROM (your query here) AS a', and see if it +> changes anything! + +FWIW, I've found problems running PostgreSQL on Windows in a multi-CPU +environment on w2k3. It runs fine for some period, and then CPU and +throughput drop to zero. So far I've been unable to track down any more +information than that, other than the fact that I haven't been able to +reproduce this on any single-CPU machines. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 2 17:36:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B2CF39FB1D5 + for ; + Tue, 2 May 2006 17:36:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 22344-10 + for ; + Tue, 2 May 2006 17:36:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 1A4C29FB1D3 + for ; + Tue, 2 May 2006 17:36:45 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id A86E956437; Tue, 2 May 2006 15:36:44 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Tue, 2 May 2006 15:36:44 -0500 +Date: Tue, 2 May 2006 15:36:44 -0500 +From: "Jim C. Nasby" +To: Scott Sipe , pgsql-performance@postgresql.org +Subject: Re: Super-smack? +Message-ID: <20060502203643.GD97354@pervasive.com> +References: <92F10BE1-B193-4EEA-877A-9260B55C2844@mindspring.com> + <20060501115449.GC11061@uio.no> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060501115449.GC11061@uio.no> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060502:cscotts@mindspring.com::XOL23Pr8npSEkTFT:000000000000000 + 0000000000000000000000003Yo9 +X-Hashcash: + 1:20:060502:pgsql-performance@postgresql.org::t7J+Z/10dIGCtrNd:00000 + 0000000000000000000000000zqR +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/46 +X-Sequence-Number: 18833 + +On Mon, May 01, 2006 at 01:54:49PM +0200, Steinar H. Gunderson wrote: +> On Mon, May 01, 2006 at 03:05:54AM -0500, Scott Sipe wrote: +> > So, my question is, before I do any further digging, is super-smack +> > flawed? +> +> It's sort of hard to say without looking at the source -- it certainly isn't +> a benchmark I've heard of before, and it's also sort of hard to believe a +> benchmark whose focus seems to be so thoroughly on one database (MySQL). The +> site claims (about PostgreSQL) support that "it looks like it works"; +> certainly not a good start for fair benchmarking :-) + +If you want a more realistic test, try dbt2: +http://sourceforge.net/projects/osdldbt +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 2 17:50:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C8A8F9FB1F0 + for ; + Tue, 2 May 2006 17:50:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 84856-02 + for ; + Tue, 2 May 2006 17:50:45 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from py-out-1112.google.com (pproxy.gmail.com [64.233.166.176]) + by postgresql.org (Postfix) with ESMTP id 5D1FB9FB1D5 + for ; + Tue, 2 May 2006 17:50:44 -0300 (ADT) +Received: by py-out-1112.google.com with SMTP id b29so7623pya + for ; + Tue, 02 May 2006 13:50:44 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=bVm0l//suBo9qYjHrIo1u3xaMEwUxKl4pPmKT7tCrabhFVhlxIfElc5ys9J8M+3RXJ4XLtJrsey9XcV/xtuWy6L+lfLXpDHGx1Hsd82m83jUgqKrirn1SiXnwpvccxUQXHyVyfDjUEqxKKcBeri8+BEMHzzGLeDY8zjJnz1FQFw= +Received: by 10.35.88.17 with SMTP id q17mr1128379pyl; + Tue, 02 May 2006 13:50:43 -0700 (PDT) +Received: by 10.35.49.6 with HTTP; Tue, 2 May 2006 13:50:43 -0700 (PDT) +Message-ID: <6d8daee30605021350p4172bbc5w7ecf87573099abd9@mail.gmail.com> +Date: Tue, 2 May 2006 13:50:43 -0700 +From: "Tony Wasson" +To: "Bruno Wolff III" , "Tony Wasson" , + "Vivek Khera" , + "Pgsql performance" +Subject: Re: postgresql transaction id monitoring with nagios +In-Reply-To: <20060502201928.GB14674@wolff.to> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <6d8daee30605021126o7b44e255q552dcdc676c565bf@mail.gmail.com> + <628A837A-9718-46BB-85D7-8A63BBB1CA32@khera.org> + <6d8daee30605021206h8170a48w94670b5d23633a72@mail.gmail.com> + <20060502201928.GB14674@wolff.to> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/47 +X-Sequence-Number: 18834 + +On 5/2/06, Bruno Wolff III wrote: +> On Tue, May 02, 2006 at 12:06:30 -0700, +> Tony Wasson wrote: +> > +> > Ah thanks, it's a bug in my understanding of the thresholds. +> > +> > "With the standard freezing policy, the age column will start at one +> > billion for a freshly-vacuumed database." +> > +> > So essentially, 1B is normal, 2B is the max. The logic is now.. +> > +> > The script detects a wrap at 2 billion. It starts warning once one or +> > more databases show an age over 1.5 billion transactions. It reports +> > critical at 1.75B transactions. +> > +> > If anyone else understands differently, hit me with a clue bat. +> +> Isn't this obsolete now anyway? I am pretty sure 8.1 has safeguards again= +st +> wrap around. + +My motivation was primarily to monitor some existing PostgreSQL 8.0 +servers. I'm not convinced it is "safe" to stop worrying about +transaction ids even on an 8.1 box. + +It is comforting that 8.1 does safeguard against wraparound in at +least 2 ways. First, it emits a warnings during the last 10 million +transactions. If you manage to ignore all those, posgresql will shut +down before a wraparound. I think PostgreSQL does everything correctly +there, but I suspect someone will run into the shut down daemon +problem. + +From pgsql-performance-owner@postgresql.org Tue May 2 18:30:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9315F9FB1D3 + for ; + Tue, 2 May 2006 18:30:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 90501-05 + for ; + Tue, 2 May 2006 18:29:59 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id E71F69FAD5A + for ; + Tue, 2 May 2006 18:29:59 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 47A1D56437; Tue, 2 May 2006 16:29:43 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Tue, 2 May 2006 16:29:42 -0500 +Date: Tue, 2 May 2006 16:29:42 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: Nolan Cafferky , + pgsql-performance@postgresql.org +Subject: Re: Cluster vs. non-cluster query planning +Message-ID: <20060502212942.GE97354@pervasive.com> +References: <445644F9.2020708@rbsinteractive.com> + <44566612.8020709@rbsinteractive.com> + <8044.1146515444@sss.pgh.pa.us> + <445678B1.9050908@rbsinteractive.com> + <20934.1146526502@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20934.1146526502@sss.pgh.pa.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060502:tgl@sss.pgh.pa.us::BD8fX/kwIyic0lP1:00000000000000000000 + 0000000000000000000000003Os/ +X-Hashcash: + 1:20:060502:nolan.cafferky@rbsinteractive.com::ldTlBmEKWj6zvZbL:0000 + 0000000000000000000000001upz +X-Hashcash: + 1:20:060502:pgsql-performance@postgresql.org::i57uvJkP6GGLN9xM:00000 + 00000000000000000000000002q2 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/48 +X-Sequence-Number: 18835 + +On Mon, May 01, 2006 at 07:35:02PM -0400, Tom Lane wrote: +> Nolan Cafferky writes: +> > But, I'm guessing that random_page_cost = 1 is not a realistic value. +> +> Well, that depends. If all your data can be expected to fit in memory +> then it is a realistic value. (If not, you should be real careful not +> to make performance decisions on the basis of test cases that *do* fit +> in RAM...) +> +> In any case, if I recall your numbers correctly you shouldn't need to +> drop it nearly that far to get the thing to make the right choice. +> A lot of people run with random_page_cost set to 2 or so. + +Also, the index scan cost estimator comments indicate that it does a +linear interpolation between the entimated cost for a perfectly +correlated table and a table with 0 correlation, but in fact the +interpolation is exponential, or it's linear based on the *square* of +the correlation, which just doesn't make much sense. + +I did some investigating on this some time ago, but never got very far +with it. http://stats.distributed.net/~decibel/summary.txt has some +info, and http://stats.distributed.net/~decibel/ has the raw data. +Graphing that data, if you only include correlations between 0.36 and +0.5, it appears that there is a linear correlation between correlation +and index scan time. + +Of course this is very coarse data and it'd be great if someone did more +research in this area, preferably using pg_bench or other tools to +generate the data so that others can test this stuff as well. But even +with as rough as this data is, it seems to provide a decent indication +that it would be better to actually interpolate linearly based on +correlation, rather than correlation^2. This is a production machine so +I'd rather not go mucking about with testing such a change here. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 2 18:39:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 458F29FB1F0 + for ; + Tue, 2 May 2006 18:39:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 70347-05 + for ; + Tue, 2 May 2006 18:38:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 10DF69FAD5A + for ; + Tue, 2 May 2006 18:38:53 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 4480456437; Tue, 2 May 2006 16:38:49 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Tue, 2 May 2006 16:38:47 -0500 +Date: Tue, 2 May 2006 16:38:47 -0500 +From: "Jim C. Nasby" +To: Chris Mckenzie +Cc: "'pgsql-performance@postgresql.org'" +Subject: Re: Postgres 7.4 and vacuum_cost_delay. +Message-ID: <20060502213847.GF97354@pervasive.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060502:chris.mckenzie@entrust.com::475vRwXjCeYC9ys2:00000000000 + 000000000000000000000000DscC +X-Hashcash: + 1:20:060502:pgsql-performance@postgresql.org::WpV82j9g2twCQcmP:00000 + 0000000000000000000000009915 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/49 +X-Sequence-Number: 18836 + +show all and grep are your friend. From my laptop with 8.1: + +decibel@phonebook.1[16:36]~:4%psql -tc 'show all' | grep vacuum_cost_delay|tr -s ' ' +autovacuum_vacuum_cost_delay | -1 | Vacuum cost delay in milliseconds, for autovacuum. +vacuum_cost_delay | 0 | Vacuum cost delay in milliseconds. +decibel@phonebook.1[16:37]~:5% + +I don't have a 7.4 copy around, but you can just check it yourself. + +On Mon, May 01, 2006 at 02:40:41PM -0400, Chris Mckenzie wrote: +> Hi everyone. +> +> I've got a quick and stupid question: Does Postgres 7.4 (7.x) support +> vacuum_cost_delay? +> +> For all my googles and documentation reading I've determined it's not +> supported, only because I can't find a 7.x doc or forum post claiming +> otherwise. +> +> Upgrading to 8.x is out of the question, but I still need to employ +> something to auto-vacuum a large and active database (possibly more than +> once a day) in a manner that wouldn't affect load at the wrong time. +> +> If I could combine pg_autovacuum with vacuum_cost_delay I could potentially +> have a solution. (barring some performance testing) +> +> The only problem with pg_autovacuum is the need for pg_statio, which itself +> will reduce performance at all times. +> +> Any suggestions? +> +> Thanks! +> +> - Chris +> +> +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 2 18:42:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1FB619FB1F6 + for ; + Tue, 2 May 2006 18:42:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 36983-10 + for ; + Tue, 2 May 2006 18:42:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 469879FB1F0 + for ; + Tue, 2 May 2006 18:42:38 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 322D956437; Tue, 2 May 2006 16:42:37 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Tue, 2 May 2006 16:42:36 -0500 +Date: Tue, 2 May 2006 16:42:36 -0500 +From: "Jim C. Nasby" +To: Vivek Khera , + Pgsql performance +Subject: Re: postgresql transaction id monitoring with nagios +Message-ID: <20060502214236.GG97354@pervasive.com> +References: <6d8daee30605021126o7b44e255q552dcdc676c565bf@mail.gmail.com> + <628A837A-9718-46BB-85D7-8A63BBB1CA32@khera.org> + <20060502190340.GG15291@surnet.cl> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060502190340.GG15291@surnet.cl> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060502:vivek@khera.org::EYA2dF31GEgc9ZmO:004+Q8 +X-Hashcash: + 1:20:060502:pgsql-performance@postgresql.org::pB62bS+Hzu/7BaP/:00000 + 00000000000000000000000009sp +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/50 +X-Sequence-Number: 18837 + +On Tue, May 02, 2006 at 03:03:40PM -0400, Alvaro Herrera wrote: +> That's right, because a database's age is only decremented in +> database-wide vacuums. (Wow, who wouldn't want a person-wide vacuum if +> it did the same thing ...) + +The heck with age, I'd take a person-wide vacuum if it just got rid of +all my 'dead rows'... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 2 18:46:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 52C2D9FB1F0 + for ; + Tue, 2 May 2006 18:46:48 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 58425-01 + for ; + Tue, 2 May 2006 18:46:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 981069FB1D3 + for ; + Tue, 2 May 2006 18:46:40 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id C854B5643A; Tue, 2 May 2006 16:46:38 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Tue, 2 May 2006 16:46:37 -0500 +Date: Tue, 2 May 2006 16:46:37 -0500 +From: "Jim C. Nasby" +To: Tony Wasson +Cc: Vivek Khera , + Pgsql performance +Subject: Re: postgresql transaction id monitoring with nagios +Message-ID: <20060502214637.GH97354@pervasive.com> +References: <6d8daee30605021126o7b44e255q552dcdc676c565bf@mail.gmail.com> + <628A837A-9718-46BB-85D7-8A63BBB1CA32@khera.org> + <6d8daee30605021206h8170a48w94670b5d23633a72@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6d8daee30605021206h8170a48w94670b5d23633a72@mail.gmail.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060502:ajwasson@gmail.com::4qE1bIQP1iU8VowT:0000000000000000000 + 0000000000000000000000000LwA +X-Hashcash: 1:20:060502:vivek@khera.org::ct/cWXkuuI2wwT4d:0089D4 +X-Hashcash: + 1:20:060502:pgsql-performance@postgresql.org::QxvCjDRGYLiN8pvV:00000 + 00000000000000000000000053jZ +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/51 +X-Sequence-Number: 18838 + +On Tue, May 02, 2006 at 12:06:30PM -0700, Tony Wasson wrote: +> Ah thanks, it's a bug in my understanding of the thresholds. +> +> "With the standard freezing policy, the age column will start at one +> billion for a freshly-vacuumed database." +> +> So essentially, 1B is normal, 2B is the max. The logic is now.. +> +> The script detects a wrap at 2 billion. It starts warning once one or +> more databases show an age over 1.5 billion transactions. It reports +> critical at 1.75B transactions. +> +> If anyone else understands differently, hit me with a clue bat. + +You should take a look at the code in -HEAD that triggers autovacuum to +do a XID-wrap-prevention vacuum, as well as the code that warns that +we're approaching wrap. From memory, the limit for the later is + +max_transactions << 3 + +Where max_transactions should be 4B on most platforms. + +I'm intending to submit a patch to clean some of that code up (put all +the thresholds in one .h file rather than how they're spread through +source code right now); if you drop me an email off-list I'll send you +info once I do that. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 2 18:47:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0BF8F9FB1F0 + for ; + Tue, 2 May 2006 18:47:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 80826-07 + for ; + Tue, 2 May 2006 18:47:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id D38D29FB1F7 + for ; + Tue, 2 May 2006 18:47:40 -0300 (ADT) +Received: from sottsym2.entrust.com (sottsym2.entrust.com [216.191.252.20]) + by svr4.postgresql.org (Postfix) with ESMTP id C6EB55B218F + for ; + Tue, 2 May 2006 21:47:39 +0000 (GMT) +Received: from sottmxsecs3.entrust.com (unknown [216.191.252.14]) + by sottsym2.entrust.com (Symantec Mail Security) with SMTP id + 91A08240002 for ; + Tue, 2 May 2006 17:47:37 -0400 (EDT) +Received: (qmail 23372 invoked from network); 2 May 2006 21:47:36 -0000 +Received: from Chris.McKenzie@entrust.com by sottmxsecs3.entrust.com with + EntrustECS-Server-7.4; 02 May 2006 21:47:36 -0000 +Received: from sottmxs00.entrust.com (10.4.61.22) + by sottmxsecs3.entrust.com with SMTP; 2 May 2006 21:47:35 -0000 +Received: by sottmxs00.entrust.com with Internet Mail Service (5.5.2657.72) + id <2PT1BAJR>; Tue, 2 May 2006 17:47:24 -0400 +Message-ID: +From: Chris Mckenzie +To: "'Jim C. Nasby'" +Cc: "'pgsql-performance@postgresql.org'" +Subject: Re: Postgres 7.4 and vacuum_cost_delay. +Date: Tue, 2 May 2006 17:47:15 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C66E31.AAC84AC6" +X-Brightmail-Tracker: AAAAAA== +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/52 +X-Sequence-Number: 18839 + + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C66E31.AAC84AC6 +Content-Type: text/plain + +Thanks. + +My first check was of course a grep/search of the postgres.conf, next it was +a complete source grep for vacuum_cost_delay. + +I've come to the conclusion I need to simply start tracking all transactions +and determining a cost/performance for the larger and frequently updated +tables without the benefit and penalty of pg_statio. + +- Chris + +-----Original Message----- +From: Jim C. Nasby [mailto:jnasby@pervasive.com] +Sent: Tuesday, May 02, 2006 5:39 PM +To: Chris Mckenzie +Cc: 'pgsql-performance@postgresql.org' +Subject: Re: [PERFORM] Postgres 7.4 and vacuum_cost_delay. + + +show all and grep are your friend. From my laptop with 8.1: + +decibel@phonebook.1[16:36]~:4%psql -tc 'show all' | grep +vacuum_cost_delay|tr -s ' ' autovacuum_vacuum_cost_delay | -1 | Vacuum cost +delay in milliseconds, for autovacuum. vacuum_cost_delay | 0 | Vacuum cost +delay in milliseconds. decibel@phonebook.1[16:37]~:5% + +I don't have a 7.4 copy around, but you can just check it yourself. + +On Mon, May 01, 2006 at 02:40:41PM -0400, Chris Mckenzie wrote: +> Hi everyone. +> +> I've got a quick and stupid question: Does Postgres 7.4 (7.x) support +> vacuum_cost_delay? +> +> For all my googles and documentation reading I've determined it's not +> supported, only because I can't find a 7.x doc or forum post claiming +> otherwise. +> +> Upgrading to 8.x is out of the question, but I still need to employ +> something to auto-vacuum a large and active database (possibly more +> than once a day) in a manner that wouldn't affect load at the wrong +> time. +> +> If I could combine pg_autovacuum with vacuum_cost_delay I could +> potentially have a solution. (barring some performance testing) +> +> The only problem with pg_autovacuum is the need for pg_statio, which +> itself will reduce performance at all times. +> +> Any suggestions? +> +> Thanks! +> +> - Chris +> +> +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +------_=_NextPart_001_01C66E31.AAC84AC6 +Content-Type: text/html +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] Postgres 7.4 and vacuum_cost_delay. + + + +

Thanks. +

+ +

My first check was of course a grep/search of the = +postgres.conf, next it was a complete source grep for = +vacuum_cost_delay.

+ +

I've come to the conclusion I need to simply start = +tracking all transactions and determining a cost/performance for the = +larger and frequently updated tables without the benefit and penalty of = +pg_statio.

+ +

- Chris +

+ +

-----Original Message----- +
From: Jim C. Nasby [mailto:jnasby@pervasive.com] = + +
Sent: Tuesday, May 02, 2006 5:39 PM +
To: Chris Mckenzie +
Cc: 'pgsql-performance@postgresql.org' +
Subject: Re: [PERFORM] Postgres 7.4 and = +vacuum_cost_delay. +

+
+ +

show all and grep are your friend. From my laptop = +with 8.1: +

+ +

decibel@phonebook.1[16:36]~:4%psql -tc 'show all' | = +grep vacuum_cost_delay|tr -s ' ' autovacuum_vacuum_cost_delay | -1 | = +Vacuum cost delay in milliseconds, for autovacuum. vacuum_cost_delay | = +0 | Vacuum cost delay in milliseconds. = +decibel@phonebook.1[16:37]~:5%

+ +

I don't have a 7.4 copy around, but you can just = +check it yourself. +

+ +

On Mon, May 01, 2006 at 02:40:41PM -0400, Chris = +Mckenzie wrote: +
> Hi everyone. +
> +
> I've got a quick and stupid question: Does = +Postgres 7.4 (7.x) support +
> vacuum_cost_delay? +
> +
> For all my googles and documentation reading = +I've determined it's not +
> supported, only because I can't find a 7.x doc = +or forum post claiming +
> otherwise. +
> +
> Upgrading to 8.x is out of the question, but I = +still need to employ +
> something to auto-vacuum a large and active = +database (possibly more +
> than once a day) in a manner that wouldn't = +affect load at the wrong +
> time. +
> +
> If I could combine pg_autovacuum with = +vacuum_cost_delay I could +
> potentially have a solution. (barring some = +performance testing) +
> +
> The only problem with pg_autovacuum is the need = +for pg_statio, which +
> itself will reduce performance at all = +times. +
> +
> Any suggestions? +
> +
> Thanks! +
> +
> - Chris +
> +
> +
> +

+ +

-- +
Jim C. Nasby, Sr. Engineering = +Consultant      jnasby@pervasive.com +
Pervasive Software      http://pervasive.com    work: = +512-231-6117 +
vcard: http://jim.nasby.net/pervasive.vcf  &nbs= +p;    cell: 512-569-9461 +

+ + + +------_=_NextPart_001_01C66E31.AAC84AC6-- + +From pgsql-performance-owner@postgresql.org Tue May 2 18:53:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9F7A29FB1D3 + for ; + Tue, 2 May 2006 18:53:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29253-06-2 + for ; + Tue, 2 May 2006 18:53:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 56DD79FAD5A + for ; + Tue, 2 May 2006 18:53:32 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id E792156437; Tue, 2 May 2006 16:53:30 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Tue, 2 May 2006 16:53:30 -0500 +Date: Tue, 2 May 2006 16:53:30 -0500 +From: "Jim C. Nasby" +To: Will Reese +Cc: pgsql-performance@postgresql.org +Subject: Re: Slow restoration question +Message-ID: <20060502215329.GI97354@pervasive.com> +References: <444F24E9.2010907@lisasoft.com> + <20060502171617.GZ97354@pervasive.com> + <622925BE-A31E-42FD-AF6A-68DDF3B4A1B7@clickspace.com> + <1146595755.12053.111.camel@archimedes> + <758B0591-3C9C-418B-9AF2-E962003C4904@rackspace.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <758B0591-3C9C-418B-9AF2-E962003C4904@rackspace.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060502:wreese@rackspace.com::qGA1pKENM7Oaxbn/:00000000000000000 + 00000000000000000000000062rr +X-Hashcash: + 1:20:060502:pgsql-performance@postgresql.org::6zHpxPd2iTvXPoSv:00000 + 0000000000000000000000003wff +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/53 +X-Sequence-Number: 18840 + +BTW, you should be able to check to see what the controller is actually +doing by pulling one of the drives from a running array. If it only +hammers 2 drives during the rebuild, it's RAID10. If it hammers all the +drives, it's 0+1. + +As for Xserve raid, it is possible to eliminate most (or maybe even all) +of the overhead associated with RAID5, depending on how tricky the +controller wants to be. I believe many large storage appliances actually +use RAID5 internally, but they perform a bunch of 'magic' behind the +scenes to get good performance from it. So, it is possible that the +XServe RAID performs quite well on RAID5. If you provided the results +from bonnie as well as info about the drives I suspect someone here +could tell you if you're getting close to RAID10 performance or not. + +On Tue, May 02, 2006 at 02:34:16PM -0500, Will Reese wrote: +> RAID 10 is better than RAID 0+1. There is a lot of information on +> the net about this, but here is the first one that popped up on +> google for me. +> +> http://www.pcguide.com/ref/hdd/perf/raid/levels/multLevel01-c.html +> +> The quick summary is that performance is about the same between the +> two, but RAID 10 gives better fault tolerance and rebuild +> performance. I have seen docs for RAID cards that have confused +> these two RAID levels. In addition, some cards claim to support RAID +> 10, when they actually support RAID 0+1 or even RAID 0+1 with +> concatenation (lame, some of the Dell PERCs have this). +> +> RAID 10 with 6 drives would stripe across 3 mirrored pairs. RAID 0+1 +> with 6 drives is a mirror of two striped arrays (3 disks each). RAID +> 0+1 (with concatenation) using 6 drives is a mirror of two volumes +> (kind of like JBOD) each consisting of 3 drives concatenated together +> (it's a cheap implementation, and it gives about the same performance +> as RAID 1 but with increased storage capacity and less fault +> tolerance). RAID 10 is better than RAID 5 (especially with 6 or less +> disks) because you don't have the performance hit for parity (which +> dramatically affects rebuild performance and write performance) and +> you get better fault tolerance (up to 3 disks can fail in a 6 disk +> RAID 10 and you can still be online, with RAID 5 you can only lose 1 +> drive). All of this comes with a higher cost (more drives and higher +> end cards). +> +> -- Will Reese http://blog.rezra.com +> +> +> On May 2, 2006, at 1:49 PM, Mark Lewis wrote: +> +> >They are not equivalent. As I understand it, RAID 0+1 performs about +> >the same as RAID 10 when everything is working, but degrades much less +> >nicely in the presence of a single failed drive, and is more likely to +> >suffer catastrophic data loss if multiple drives fail. +> > +> >-- Mark +> > +> >On Tue, 2006-05-02 at 12:40 -0600, Brendan Duddridge wrote: +> >>Everyone here always says that RAID 5 isn't good for Postgres. We +> >>have an Apple Xserve RAID configured with RAID 5. We chose RAID 5 +> >>because Apple said their Xserve RAID was "optimized" for RAID 5. Not +> >>sure if we made the right decision though. They give an option for +> >>formatting as RAID 0+1. Is that the same as RAID 10 that everyone +> >>talks about? Or is it the reverse? +> >> +> >>Thanks, +> >> +> >>____________________________________________________________________ +> >>Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com +> >> +> >>ClickSpace Interactive Inc. +> >>Suite L100, 239 - 10th Ave. SE +> >>Calgary, AB T2G 0V9 +> >> +> >>http://www.clickspace.com +> >> +> >>On May 2, 2006, at 11:16 AM, Jim C. Nasby wrote: +> >> +> >>>On Wed, Apr 26, 2006 at 05:14:41PM +0930, Eric Lam wrote: +> >>>>all dumpfiles total about 17Gb. It has been running for 50ish hrs +> >>>>and up +> >>>>to about the fourth file (5-6 ish Gb) and this is on a raid 5 +> >>>>server. +> >>> +> >>>RAID5 generally doesn't bode too well for performance; that could be +> >>>part of the issue. +> >>>-- +> >>>Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> >>>Pervasive Software http://pervasive.com work: 512-231-6117 +> >>>vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> >>> +> >>>---------------------------(end of +> >>>broadcast)--------------------------- +> >>>TIP 4: Have you searched our list archives? +> >>> +> >>> http://archives.postgresql.org +> >>> +> >> +> >> +> >> +> >>---------------------------(end of +> >>broadcast)--------------------------- +> >>TIP 9: In versions below 8.0, the planner will ignore your desire to +> >> choose an index scan if your joining column's datatypes do not +> >> match +> > +> >---------------------------(end of +> >broadcast)--------------------------- +> >TIP 6: explain analyze is your friend +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 2 19:50:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 02D469FA2C7 + for ; + Tue, 2 May 2006 19:50:17 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 43337-06-2 + for ; + Tue, 2 May 2006 19:49:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.digitalfairway.ca (ns.digitalfairway.ca [207.164.133.170]) + by postgresql.org (Postfix) with ESMTP id CD2939FAA6E + for ; + Tue, 2 May 2006 19:49:55 -0300 (ADT) +Received: from toronto.toronto.digitalfairway.ca (unknown [192.168.100.10]) + by mail.digitalfairway.ca (Postfix) with ESMTP id 7680F548B2 + for ; + Tue, 2 May 2006 18:49:53 -0400 (EDT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by toronto.toronto.digitalfairway.ca (Postfix) with ESMTP id + 1E02C144DF8 for ; + Tue, 2 May 2006 18:49:53 -0400 (EDT) +Received: from toronto.toronto.digitalfairway.ca ([127.0.0.1]) + by localhost (toronto.toronto.digitalfairway.ca [127.0.0.1]) + (amavisd-new, port 10024) + with ESMTP id 16655-10 for ; + Tue, 2 May 2006 18:49:53 -0400 (EDT) +Received: from [192.168.0.101] + (CPE00119557f5ec-CM000f9faa78f6.cpe.net.cable.rogers.com + [70.24.152.86]) + (using SSLv3 with cipher EXP1024-RC4-SHA (56/128 bits)) + (No client certificate requested) + by toronto.toronto.digitalfairway.ca (Postfix) with ESMTP id + EAD03144DF7 for ; + Tue, 2 May 2006 18:49:52 -0400 (EDT) +From: Jan de Visser +To: pgsql-performance@postgresql.org +Subject: Re: Performance Issues on Opteron Dual Core +Date: Tue, 2 May 2006 18:49:48 -0400 +User-Agent: KMail/1.9.1 +References: <445498AC.10700@paradise.net.nz> + <20060502202837.GC97354@pervasive.com> +In-Reply-To: <20060502202837.GC97354@pervasive.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200605021849.48613.jdevisser@digitalfairway.com> +X-Virus-Scanned: amavisd-new at digitalfairway.ca +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/54 +X-Sequence-Number: 18841 + +On Tuesday 02 May 2006 16:28, Jim C. Nasby wrote: +> On Sun, Apr 30, 2006 at 10:59:56PM +1200, Mark Kirkwood wrote: +> > Pgadmin can give misleading times for queries that return large result +> > sets over a network, due to: +> > +> > 1/ It takes time to format the (large) result set for display. +> > 2/ It has to count the time spent waiting for the (large) result set to +> > travel across the network. +> > +> > You aren't running Pgadmin off the dev server are you? If not check your +> > network link to dev and prod - is one faster than the other? (etc). +> > +> > To eliminate Pgadmin and the network as factors try wrapping your query +> > in a 'SELECT count(*) FROM (your query here) AS a', and see if it +> > changes anything! +> +> FWIW, I've found problems running PostgreSQL on Windows in a multi-CPU +> environment on w2k3. It runs fine for some period, and then CPU and +> throughput drop to zero. So far I've been unable to track down any more +> information than that, other than the fact that I haven't been able to +> reproduce this on any single-CPU machines. + +I have had previous correspondence about this with Magnus (search -general= +=20 +and -hackers). If you uninstall SP1 the problem goes away. We played a bit= +=20 +with potential fixes but didn't find any. + +jan + +=2D-=20 +=2D------------------------------------------------------------- +Jan de Visser =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 jdevisser@digitalfair= +way.com + +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Baruk Khazad! Khazad ai-menu! +=2D------------------------------------------------------------- + +From pgsql-performance-owner@postgresql.org Tue May 2 19:54:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id EB1669FA9BD + for ; + Tue, 2 May 2006 19:54:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 82077-09 + for ; + Tue, 2 May 2006 19:54:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 2F1C79FA2C7 + for ; + Tue, 2 May 2006 19:54:40 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 4AED956437; Tue, 2 May 2006 17:54:39 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Tue, 2 May 2006 17:54:38 -0500 +Date: Tue, 2 May 2006 17:54:38 -0500 +From: "Jim C. Nasby" +To: Chris Mckenzie +Cc: "'pgsql-performance@postgresql.org'" +Subject: Re: Postgres 7.4 and vacuum_cost_delay. +Message-ID: <20060502225438.GL97354@pervasive.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060502:chris.mckenzie@entrust.com::rkv1Ub+8bPclSRlh:00000000000 + 0000000000000000000000000qhz +X-Hashcash: + 1:20:060502:pgsql-performance@postgresql.org::Kp0oB5q2HiOaCSsw:00000 + 0000000000000000000000000L0S +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/55 +X-Sequence-Number: 18842 + +On Tue, May 02, 2006 at 05:47:15PM -0400, Chris Mckenzie wrote: +> Thanks. +> +> My first check was of course a grep/search of the postgres.conf, next it was +> a complete source grep for vacuum_cost_delay. + +It's there in head... +decibel@phonebook.1[17:52]~/pgsql/HEAD/src:4%grep -ri vacuum_cost_delay *|wc -l + 8 + +> I've come to the conclusion I need to simply start tracking all transactions +> and determining a cost/performance for the larger and frequently updated +> tables without the benefit and penalty of pg_statio. + +Huh? pg_statio shouldn't present a large penalty AFAIK... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 2 19:56:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 226829FB1D5 + for ; + Tue, 2 May 2006 19:56:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 12084-01 + for ; + Tue, 2 May 2006 19:55:58 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from py-out-1112.google.com (pproxy.gmail.com [64.233.166.181]) + by postgresql.org (Postfix) with ESMTP id B86CB9FAA6E + for ; + Tue, 2 May 2006 19:55:58 -0300 (ADT) +Received: by py-out-1112.google.com with SMTP id c31so49961pyd + for ; + Tue, 02 May 2006 15:55:57 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=pgpAvrPQq0v40dkSsrGjV/QRxdR6LA+m/0rXsGOg+w9bcYl1/r+JYgDQGN5bHzFpWvc1OTNdCjMMdXaNQWyaOigZq4UiV5OYT523bnHOWNO0U92JkRrqfCqWuOkjU4xKUqAkbt+iGahTeKJyjsdmm3rkKKZx1i2IUhqJspg6Hf8= +Received: by 10.35.36.13 with SMTP id o13mr387508pyj; + Tue, 02 May 2006 15:55:57 -0700 (PDT) +Received: by 10.35.45.14 with HTTP; Tue, 2 May 2006 15:55:57 -0700 (PDT) +Message-ID: +Date: Tue, 2 May 2006 15:55:57 -0700 +From: "Ian Burrell" +To: pgsql-performance@postgresql.org +Subject: Nested loop join and date range query +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: base64 +Content-Disposition: inline +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/56 +X-Sequence-Number: 18843 + +V2UgcmVjZW50bHkgdXBncmFkZWQgdG8gUG9zdGdyZVNRTCA4LjEgZnJvbSA3LjQgYW5kIGEgZmV3 +IHF1ZXJpZXMgYXJlCmhhdmluZyBwZXJmb3JtYW5jZSBwcm9ibGVtcyBhbmQgcnVubmluZyBmb3Ig +dmVyeSBsb25nIHRpbWVzLiAgVGhlCmNvbW1vbmFsaXR5IHNlZW1zIHRvIGJlIFBvc3RncmVTUUwg +OC4xIGlzIGNob29zaW5nIHRvIHVzZSBhIG5lc3RlZApsb29wIGpvaW4gYmVjYXVzZSBpdCBlc3Rp +bWF0ZXMgdGhlcmUgd2lsbCBiZSBvbmx5IGJlIGEgc2luZ2xlIHJvdy4KVGhlcmUgYXJlIHJlYWxs +eSB0aG91c2FuZHMgb2Ygcm93cyBhbmQgdGhlIG5lc3RlZCBsb29wIHZlcnNpb24gdGFrZXMKbXVj +aCBsb25nZXIuCgpFdmVuIHdpdGggdGhlIGJhZCBwbGFuLCB0aGUgdGVzdCBxdWVyeSBydW5zIHF1 +aWNrbHkuICBUaGUgcmVhbCBxdWVyeQppcyBtdWNoIG1vcmUgY29tcGxpY2F0ZWQgYW5kIHdlIGhh +dmUgaGFkIHRvIGtpbGwgaXQgYWZ0ZXIgcnVubmluZyBmb3IKMjQgaG91cnMuCgpTRUxFQ1QKICAg +IE1BWCh0aXRsZXMubmFtZSkgQVMgdGl0bGVfbmFtZSwKICAgIE1BWChwcm92aWRlcnMuc2hvcnRf +bmFtZSkgQVMgcHJvdmlkZXJfc2hvcnRfbmFtZSwKICAgIFNVTSh4Lnh0bnMpIEFTIHh0bnMsCiAg +ICBTVU0oeC5yZXYpIEFTIHJldgpGUk9NIHh0bnNfYnlfbXNvX3RpdGxlX3drIHgKSU5ORVIgSk9J +TiBwcm92aWRlcnMgcHJvdmlkZXJzIE9OIHgucHJvdmlkZXJfbm8gPSBwcm92aWRlcnMucHJvdmlk +ZXJfbm8KSU5ORVIgSk9JTiB0aXRsZXMgdGl0bGVzIE9OIHgudGl0bGVfbm8gPSB0aXRsZXMudGl0 +bGVfbm8KV0hFUkUgeC5tc29fbm8gPSA1MAogICAgQU5EIHgud2VlayBCRVRXRUVOICcyMDA2MDQy +MyAwMDowMDowMCcgQU5EICAnMjAwNjA0MjMgMDA6MDA6MDAnCkdST1VQIEJZIHgudGl0bGVfbm8s +IHgucHJvdmlkZXJfbm8KClRoZSBFWFBMQUlOIEFOQUxZWkUgbG9va3MgbGlrZToKCiBHcm91cEFn +Z3JlZ2F0ZSAgKGNvc3Q9MTEuNjMuLjExLjY3IHJvd3M9MSB3aWR0aD02MSkgKGFjdHVhbAp0aW1l +PTE0NDAuNTUwLi4xNDY3LjYwMiByb3dzPTM0NTkgbG9vcHM9MSkKICAgLT4gIFNvcnQgIChjb3N0 +PTExLjYzLi4xMS42NCByb3dzPTEgd2lkdGg9NjEpIChhY3R1YWwKdGltZT0xNDQwLjUxNS4uMTQ0 +Ni42MzQgcm93cz0zOTM0IGxvb3BzPTEpCiAgICAgICAgIFNvcnQgS2V5OiB4LnRpdGxlX25vLCB4 +LnByb3ZpZGVyX25vCiAgICAgICAgIC0+ICBOZXN0ZWQgTG9vcCAgKGNvc3Q9MC4wMC4uMTEuNjIg +cm93cz0xIHdpZHRoPTYxKSAoYWN0dWFsCnRpbWU9Ny45MDAuLjE0MjIuNjg2IHJvd3M9MzkzNCBs +b29wcz0xKQogICAgICAgICAgICAgICAtPiAgTmVzdGVkIExvb3AgIChjb3N0PTAuMDAuLjcuMzgg +cm93cz0xIHdpZHRoPTQ5KQooYWN0dWFsIHRpbWU9Ny44NzcuLjEzNzMuMzkyIHJvd3M9MzkzNCBs +b29wcz0xKQogICAgICAgICAgICAgICAgICAgICAtPiAgSW5kZXggU2NhbiB1c2luZyB1bnFfeHRu +c19ieV9tc29fdGl0bGVfd2sgb24KeHRuc19ieV9tc29fdGl0bGVfd2sgeCAgKGNvc3Q9MC4wMC4u +NC4xMiByb3dzPTEgd2lkdGg9MjYpIChhY3R1YWwKdGltZT03LjgyNy4uMTI5Ny42ODEgcm93cz0z +OTM0IGxvb3BzPTEpCiAgICAgICAgICAgICAgICAgICAgICAgICAgIEluZGV4IENvbmQ6ICgod2Vl +ayA+PSAnMjAwNi0wNC0yMwowMDowMDowMCc6OnRpbWVzdGFtcCB3aXRob3V0IHRpbWUgem9uZSkg +QU5EICh3ZWVrIDw9ICcyMDA2LTA0LTIzCjAwOjAwOjAwJzo6dGltZXN0YW1wIHdpdGhvdXQgdGlt +ZSB6b25lKSBBTkQgKG1zb19ubyA9IDUwKSkKICAgICAgICAgICAgICAgICAgICAgLT4gIEluZGV4 +IFNjYW4gdXNpbmcgcGtfdGl0bGVzIG9uIHRpdGxlcyAKKGNvc3Q9MC4wMC4uMy4yNSByb3dzPTEg +d2lkdGg9MjcpIChhY3R1YWwgdGltZT0wLjAxMC4uMC4wMTIgcm93cz0xCmxvb3BzPTM5MzQpCiAg +ICAgICAgICAgICAgICAgICAgICAgICAgIEluZGV4IENvbmQ6ICgib3V0ZXIiLnRpdGxlX25vID0g +dGl0bGVzLnRpdGxlX25vKQogICAgICAgICAgICAgICAtPiAgSW5kZXggU2NhbiB1c2luZyBwa19w +cm92aWRlcnMgb24gcHJvdmlkZXJzIAooY29zdD0wLjAwLi40LjIzIHJvd3M9MSB3aWR0aD0xNikg +KGFjdHVhbCB0aW1lPTAuMDA0Li4wLjAwNSByb3dzPTEKbG9vcHM9MzkzNCkKICAgICAgICAgICAg +ICAgICAgICAgSW5kZXggQ29uZDogKCJvdXRlciIucHJvdmlkZXJfbm8gPSBwcm92aWRlcnMucHJv +dmlkZXJfbm8pCgpJZiBpdCBpcyBzZWFyY2hpbmcgb3ZlciBtdWx0aXBsZSB3ZWVrcyAod2VlayBC +RVRXRUVOICcyMDA2MDQxNwowMDowMDowMCcgQU5EICAnMjAwNjA0MjMgMDA6MDA6MDAnKSwgaXQg +ZXN0aW1hdGVzIGJldHRlciBhbmQgdXNlcyBhCmhhc2ggam9pbi4KCiBHcm91cEFnZ3JlZ2F0ZSAg +KGNvc3Q9Nzg0OC4yMC4uNzg3OC40OCByb3dzPTE1NiB3aWR0aD02MSkgKGFjdHVhbAp0aW1lPTEx +Ny43NjEuLjE0NS45MTAgcm93cz0zNDU5IGxvb3BzPTEpCiAgIC0+ICBTb3J0ICAoY29zdD03ODQ4 +LjIwLi43ODUyLjA4IHJvd3M9MTU1MiB3aWR0aD02MSkgKGFjdHVhbAp0aW1lPTExNy43MzUuLjEy +My44MjMgcm93cz0zOTM0IGxvb3BzPTEpCiAgICAgICAgIFNvcnQgS2V5OiB4LnRpdGxlX25vLCB4 +LnByb3ZpZGVyX25vCiAgICAgICAgIC0+ICBIYXNoIEpvaW4gIChjb3N0PTUuOTUuLjc3NjUuOTQg +cm93cz0xNTUyIHdpZHRoPTYxKQooYWN0dWFsIHRpbWU9Ni41MzkuLjEwMi44MjUgcm93cz0zOTM0 +IGxvb3BzPTEpCiAgICAgICAgICAgICAgIEhhc2ggQ29uZDogKCJvdXRlciIucHJvdmlkZXJfbm8g +PSAiaW5uZXIiLnByb3ZpZGVyX25vKQogICAgICAgICAgICAgICAtPiAgTmVzdGVkIExvb3AgIChj +b3N0PTAuMDAuLjc3MzYuNzEgcm93cz0xNTUyCndpZHRoPTQ5KSAoYWN0dWFsIHRpbWU9NS4xMTcu +Ljg2Ljk4MCByb3dzPTM5MzQgbG9vcHM9MSkgICAgICAgICAgICAgICAKICAgICAtPiAgSW5kZXgg +U2NhbiB1c2luZyBpZHhfeHRuc19ieV9tc29fdGlfd2tfd2tfbXNvX3Qgb24KeHRuc19ieV9tc29f +dGl0bGVfd2sgeCAgKGNvc3Q9MC4wMC4uMjY3Ny4wNCByb3dzPTE1NTIgd2lkdGg9MjYpCihhY3R1 +YWwgdGltZT01LjA4NS4uMTguMDY1IHJvd3M9MzkzNCBsb29wcz0xKQogICAgICAgICAgICAgICAg +ICAgICAgICAgICBJbmRleCBDb25kOiAoKHdlZWsgPj0gJzIwMDYtMDQtMTcKMDA6MDA6MDAnOjp0 +aW1lc3RhbXAgd2l0aG91dCB0aW1lIHpvbmUpIEFORCAod2VlayA8PSAnMjAwNi0wNC0yMwowMDow +MDowMCc6OnRpbWVzdGFtcCB3aXRob3V0IHRpbWUgem9uZSkgQU5EIChtc29fbm8gPSA1MCkpCiAg +ICAgICAgICAgICAgICAgICAgIC0+ICBJbmRleCBTY2FuIHVzaW5nIHBrX3RpdGxlcyBvbiB0aXRs +ZXMgCihjb3N0PTAuMDAuLjMuMjUgcm93cz0xIHdpZHRoPTI3KSAoYWN0dWFsIHRpbWU9MC4wMDYu +LjAuMDEwIHJvd3M9MQpsb29wcz0zOTM0KQogICAgICAgICAgICAgICAgICAgICAgICAgICBJbmRl +eCBDb25kOiAoIm91dGVyIi50aXRsZV9ubyA9IHRpdGxlcy50aXRsZV9ubykKICAgICAgICAgICAg +ICAgLT4gIEhhc2ggIChjb3N0PTUuMTYuLjUuMTYgcm93cz0zMTYgd2lkdGg9MTYpIChhY3R1YWwK +dGltZT0xLjM1Ni4uMS4zNTYgcm93cz0zMjUgbG9vcHM9MSkKICAgICAgICAgICAgICAgICAgICAg +LT4gIFNlcSBTY2FuIG9uIHByb3ZpZGVycyAgKGNvc3Q9MC4wMC4uNS4xNgpyb3dzPTMxNiB3aWR0 +aD0xNikgKGFjdHVhbCB0aW1lPTAuMDA4Li4wLjY5MSByb3dzPTMyNSBsb29wcz0xKQoKSWYgdGhl +IHdlZWsgcmFuZ2UgaXMgcmVwbGFjZSBieSBhbiBlcXVhbHMgKHdlZWsgPSAnMjAwNjA0MjMKMDA6 +MDA6MDAnKSwgaXQgYWxzbyB1c2VzIGEgaGFzaCBqb2luLiAgVW5mb3J1bnRhdGVseSwgdGhlIHF1 +ZXJpZXMgYXJlCmF1dG9tYXRpY2FsbHkgZ2VuZXJhdGVkIGFuZCBjaGFuZ2luZyB0aGVtIHRvIHVz +ZSBhbiBlcXVhbHMgY291bGQgYmUKcHJvYmxlbWF0aWMuCgogR3JvdXBBZ2dyZWdhdGUgIChjb3N0 +PTc4MjguNzUuLjc4NTkuMzIgcm93cz0xNTcgd2lkdGg9NjEpIChhY3R1YWwKdGltZT05OC4zMzAu +LjEyNS4zNzAgcm93cz0zNDU5IGxvb3BzPTEpCiAgIC0+ICBTb3J0ICAoY29zdD03ODI4Ljc1Li43 +ODMyLjY3IHJvd3M9MTU2NyB3aWR0aD02MSkgKGFjdHVhbAp0aW1lPTk4LjMwMy4uMTA0LjA1NSBy +b3dzPTM5MzQgbG9vcHM9MSkKICAgICAgICAgU29ydCBLZXk6IHgudGl0bGVfbm8sIHgucHJvdmlk +ZXJfbm8KICAgICAgICAgLT4gIEhhc2ggSm9pbiAgKGNvc3Q9NS45NS4uNzc0NS42MCByb3dzPTE1 +Njcgd2lkdGg9NjEpCihhY3R1YWwgdGltZT0xLjc4NS4uODMuODMwIHJvd3M9MzkzNCBsb29wcz0x +KQogICAgICAgICAgICAgICBIYXNoIENvbmQ6ICgib3V0ZXIiLnByb3ZpZGVyX25vID0gImlubmVy +Ii5wcm92aWRlcl9ubykKICAgICAgICAgICAgICAgLT4gIE5lc3RlZCBMb29wICAoY29zdD0wLjAw +Li43NzE2LjE0IHJvd3M9MTU2Nwp3aWR0aD00OSkgKGFjdHVhbCB0aW1lPTAuMTcwLi42OC4zMzgg +cm93cz0zOTM0IGxvb3BzPTEpICAgICAgICAgICAgICAgCiAgICAgLT4gIEluZGV4IFNjYW4gdXNp +bmcgaWR4X3h0bnNfYnlfbXNvX3RpX3drX3drX21zb190IG9uCnh0bnNfYnlfbXNvX3RpdGxlX3dr +IHggIChjb3N0PTAuMDAuLjI2MDcuNTYgcm93cz0xNTY3IHdpZHRoPTI2KQooYWN0dWFsIHRpbWU9 +MC4xMzguLjExLjk5MyByb3dzPTM5MzQgbG9vcHM9MSkKICAgICAgICAgICAgICAgICAgICAgICAg +ICAgSW5kZXggQ29uZDogKCh3ZWVrID0gJzIwMDYtMDQtMjMKMDA6MDA6MDAnOjp0aW1lc3RhbXAg +d2l0aG91dCB0aW1lIHpvbmUpIEFORCAobXNvX25vID0gNTApKQogICAgICAgICAgICAgICAgICAg +ICAtPiAgSW5kZXggU2NhbiB1c2luZyBwa190aXRsZXMgb24gdGl0bGVzIAooY29zdD0wLjAwLi4z +LjI1IHJvd3M9MSB3aWR0aD0yNykgKGFjdHVhbCB0aW1lPTAuMDA2Li4wLjAwOCByb3dzPTEKbG9v +cHM9MzkzNCkKICAgICAgICAgICAgICAgICAgICAgICAgICAgSW5kZXggQ29uZDogKCJvdXRlciIu +dGl0bGVfbm8gPSB0aXRsZXMudGl0bGVfbm8pCiAgICAgICAgICAgICAgIC0+ICBIYXNoICAoY29z +dD01LjE2Li41LjE2IHJvd3M9MzE2IHdpZHRoPTE2KSAoYWN0dWFsCnRpbWU9MS41NjUuLjEuNTY1 +IHJvd3M9MzI1IGxvb3BzPTEpCiAgICAgICAgICAgICAgICAgICAgIC0+ICBTZXEgU2NhbiBvbiBw +cm92aWRlcnMgIChjb3N0PTAuMDAuLjUuMTYKcm93cz0zMTYgd2lkdGg9MTYpIChhY3R1YWwgdGlt +ZT0wLjAwOC4uMC42Nzcgcm93cz0zMjUgbG9vcHM9MSkKCkRvZXMgYW55b25lIGhhdmUgc29tZSBz +dWdnZXN0aW9ucyB0byB0cnk/IFRoZSBtb3N0IHdvcnJ5aW5nIHRoaW5nIGlzCnRoYXQgd2hlbiB0 +aGUgc3RhdGlzdGljcyBhcmUgb2ZmLCBpdCBjYW4gZG8gYSAgcGF0aG9sb2dpY2FsIHF1ZXJ5LgoK +IC0gSWFuCg== + +From pgsql-performance-owner@postgresql.org Tue May 2 19:56:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4A6B09FA2C7 + for ; + Tue, 2 May 2006 19:56:39 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 15016-01 + for ; + Tue, 2 May 2006 19:56:30 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 92F4A9FB1D5 + for ; + Tue, 2 May 2006 19:56:30 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 6AADC56435; Tue, 2 May 2006 17:56:29 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Tue, 2 May 2006 17:56:28 -0500 +Date: Tue, 2 May 2006 17:56:28 -0500 +From: "Jim C. Nasby" +To: Jan de Visser +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance Issues on Opteron Dual Core +Message-ID: <20060502225628.GM97354@pervasive.com> +References: <445498AC.10700@paradise.net.nz> + <20060502202837.GC97354@pervasive.com> + <200605021849.48613.jdevisser@digitalfairway.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200605021849.48613.jdevisser@digitalfairway.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060502:jdevisser@digitalfairway.com::J1Qpk3fK6nbHNKVS:000000000 + 000000000000000000000000Ab77 +X-Hashcash: + 1:20:060502:pgsql-performance@postgresql.org::2l+TIYeqLASwacpR:00000 + 0000000000000000000000001qTS +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/57 +X-Sequence-Number: 18844 + +On Tue, May 02, 2006 at 06:49:48PM -0400, Jan de Visser wrote: +> On Tuesday 02 May 2006 16:28, Jim C. Nasby wrote: +> > On Sun, Apr 30, 2006 at 10:59:56PM +1200, Mark Kirkwood wrote: +> > > Pgadmin can give misleading times for queries that return large result +> > > sets over a network, due to: +> > > +> > > 1/ It takes time to format the (large) result set for display. +> > > 2/ It has to count the time spent waiting for the (large) result set to +> > > travel across the network. +> > > +> > > You aren't running Pgadmin off the dev server are you? If not check your +> > > network link to dev and prod - is one faster than the other? (etc). +> > > +> > > To eliminate Pgadmin and the network as factors try wrapping your query +> > > in a 'SELECT count(*) FROM (your query here) AS a', and see if it +> > > changes anything! +> > +> > FWIW, I've found problems running PostgreSQL on Windows in a multi-CPU +> > environment on w2k3. It runs fine for some period, and then CPU and +> > throughput drop to zero. So far I've been unable to track down any more +> > information than that, other than the fact that I haven't been able to +> > reproduce this on any single-CPU machines. +> +> I have had previous correspondence about this with Magnus (search -general +> and -hackers). If you uninstall SP1 the problem goes away. We played a bit +> with potential fixes but didn't find any. + +Interesting; does SP2 fix the problem? Anything we can do over here to +help? +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 2 20:00:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2DCBE9FA9BD + for ; + Tue, 2 May 2006 20:00:19 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 26053-01 + for ; + Tue, 2 May 2006 20:00:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id AAC449FA2C7 + for ; + Tue, 2 May 2006 20:00:03 -0300 (ADT) +Received: from trofast.ipv6.sesse.net ([2001:700:300:dc03:20e:cff:fe36:a766] + helo=trofast.sesse.net) + by cassarossa.samfundet.no with esmtp (Exim 4.50) + id 1Fb3qa-0003L4-B7; Wed, 03 May 2006 01:00:00 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1Fb3qb-0001rw-00; Wed, 03 May 2006 01:00:01 +0200 +Date: Wed, 3 May 2006 01:00:01 +0200 +From: "Steinar H. Gunderson" +To: Chris Mckenzie +Cc: "'pgsql-performance@postgresql.org'" +Subject: Re: Postgres 7.4 and vacuum_cost_delay. +Message-ID: <20060502230001.GA7148@uio.no> +Mail-Followup-To: Chris Mckenzie , + "'pgsql-performance@postgresql.org'" +References: +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: +X-Operating-System: Linux 2.6.16.11 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/58 +X-Sequence-Number: 18845 + +On Mon, May 01, 2006 at 02:40:41PM -0400, Chris Mckenzie wrote: +> I've got a quick and stupid question: Does Postgres 7.4 (7.x) support +> vacuum_cost_delay? + +No, it does not; it was introduced in 8.0. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Tue May 2 20:20:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6623C9FB1D5 + for ; + Tue, 2 May 2006 20:20:12 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 75746-04 + for ; + Tue, 2 May 2006 20:20:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) by postgresql.org (Postfix) with ESMTP id 852DC9FA2C7 + for ; + Tue, 2 May 2006 20:20:06 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 5D5AD644678 + for ; + Tue, 2 May 2006 17:20:04 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 02996-07 for ; + Tue, 2 May 2006 17:19:56 -0600 (MDT) +Received: from [192.168.1.100] (c-67-165-220-189.hsd1.co.comcast.net + [67.165.220.189]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 5DA9F64467B + for ; + Tue, 2 May 2006 17:19:52 -0600 (MDT) +Message-ID: <4457E918.10007@drivefaster.net> +Date: Tue, 02 May 2006 17:19:52 -0600 +From: Dan Harris +User-Agent: Thunderbird 1.5 (Macintosh/20060122) +MIME-Version: 1.0 +To: PostgreSQL Performance +Subject: Killing long-running queries +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/59 +X-Sequence-Number: 18846 + +My database is used primarily in an OLAP-type environment. Sometimes my +users get a little carried away and find some way to slip past the +sanity filters in the applications and end up bogging down the server +with queries that run for hours and hours. And, of course, what users +tend to do is to keep queuing up more queries when they don't see the +first one return instantly :) + +So, I have been searching for a way to kill an individual query. I read +in the mailing list archives that you could 'kill' the pid. I've tried +this a few times and more than once, it has caused the postmaster to +die(!), terminating every query that was in process, even unrelated to +that query. + +Is there some way I can just kill a query and not risk breaking +everything else when I do it? + +Thanks + + +From pgsql-performance-owner@postgresql.org Tue May 2 20:28:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 26CB59FA9BD + for ; + Tue, 2 May 2006 20:28:51 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 35354-05 + for ; + Tue, 2 May 2006 20:28:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx00.pub.collaborativefusion.com + (mx00.pub.collaborativefusion.com [206.210.89.199]) + by postgresql.org (Postfix) with ESMTP id A3DAC9FA2C7 + for ; + Tue, 2 May 2006 20:28:37 -0300 (ADT) +Received: from localhost (monrovll-cuda1-24-53-251-44.pittpa.adelphia.net + [24.53.251.44]) + (AUTH: LOGIN wmoran, TLS: TLSv1/SSLv3,256bits,AES256-SHA) + by wingspan with esmtp; Tue, 02 May 2006 19:28:36 -0400 + id 00056407.4457EB24.0000CBED +Date: Tue, 2 May 2006 19:28:34 -0400 +From: Bill Moran +To: "Jim C. Nasby" +Cc: bealach_na_bo@hotmail.com, ahodgson@simkin.ca, + pgsql-performance@postgresql.org +Subject: Re: Why so slow? +Message-Id: <20060502192834.6c8e9131.wmoran@collaborativefusion.com> +In-Reply-To: <20060502201740.GB97354@pervasive.com> +References: <200604281043.16083@hal.medialogik.com> + + <20060430100346.20f010a9.wmoran@collaborativefusion.com> + <20060502201740.GB97354@pervasive.com> +Organization: Collaborative Fusion +X-Mailer: Sylpheed version 1.0.6 (GTK+ 1.2.10; i386-portbld-freebsd5.4) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/60 +X-Sequence-Number: 18847 + +"Jim C. Nasby" wrote: + +> On Sun, Apr 30, 2006 at 10:03:46AM -0400, Bill Moran wrote: +> > At this point, it seems like you need to do 2 things: +> > 1) Schedule lazy vacuum to run, or configure autovacuum. +> > 2) Schedule some downtime to run "vacuum full" to recover some disk space. +> > +> > #2 only needs done once to get you back on track, assuming that #1 is +> > done properly. +> +> You'll also want to reindex since vacuum full won't clean the indexes +> up. You might also want to read +> http://www.pervasivepostgres.com/instantkb13/article.aspx?id=10087 and +> http://www.pervasivepostgres.com/instantkb13/article.aspx?id=10116. + +Reindexing is in a different class than vacuuming. Neglecting to vacuum +creates a problem that gets worse and worse as time goes on. Neglecting +to reindex does not create an infinately growing problem, since empty +index pages are recycled automatically. It's also conceivable that some +usage patterns don't need to reindex at all. + +http://www.postgresql.org/docs/8.1/interactive/routine-reindex.html + +-- +Bill Moran +Potential Technologies +http://www.potentialtech.com + +From pgsql-performance-owner@postgresql.org Tue May 2 20:30:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A98629FA2C7 + for ; + Tue, 2 May 2006 20:30:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 76328-01 + for ; + Tue, 2 May 2006 20:30:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 53E969FAA6E + for ; + Tue, 2 May 2006 20:30:02 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k42NU083006446; + Tue, 2 May 2006 19:30:00 -0400 (EDT) +To: Dan Harris +cc: PostgreSQL Performance +Subject: Re: Killing long-running queries +In-reply-to: <4457E918.10007@drivefaster.net> +References: <4457E918.10007@drivefaster.net> +Comments: In-reply-to Dan Harris + message dated "Tue, 02 May 2006 17:19:52 -0600" +Date: Tue, 02 May 2006 19:30:00 -0400 +Message-ID: <6445.1146612600@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/61 +X-Sequence-Number: 18848 + +Dan Harris writes: +> So, I have been searching for a way to kill an individual query. I read +> in the mailing list archives that you could 'kill' the pid. I've tried +> this a few times and more than once, it has caused the postmaster to +> die(!), terminating every query that was in process, even unrelated to +> that query. + +You should be using SIGINT, not SIGTERM. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 2 20:44:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2ED099FA9BD + for ; + Tue, 2 May 2006 20:44:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 60648-05 + for ; + Tue, 2 May 2006 20:43:54 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from py-out-1112.google.com (pproxy.gmail.com [64.233.166.179]) + by postgresql.org (Postfix) with ESMTP id 0635D9FA2C7 + for ; + Tue, 2 May 2006 20:43:54 -0300 (ADT) +Received: by py-out-1112.google.com with SMTP id b29so43236pya + for ; + Tue, 02 May 2006 16:43:53 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=lWkCE+87CNGSPNiU89622F7Db+bEwD9Fp9XqOt0Ywh1coWh6EGYEoW8qVy7ZcQAuTnoSlGjtGc4Cf3HSyUHR3akfHqVdkwmYNg6J9RCryjwmf1kZn0iGmMMTiVxLuUcteL2N+BRUpin6aB4CeAJDPiCvhuQPNIsMIg21rB1WA/4= +Received: by 10.35.119.11 with SMTP id w11mr1914045pym; + Tue, 02 May 2006 16:43:52 -0700 (PDT) +Received: by 10.35.49.6 with HTTP; Tue, 2 May 2006 16:43:52 -0700 (PDT) +Message-ID: <6d8daee30605021643k4415462oec2ea8487fc521b7@mail.gmail.com> +Date: Tue, 2 May 2006 16:43:52 -0700 +From: "Tony Wasson" +To: "Dan Harris" +Subject: Re: Killing long-running queries +Cc: "PostgreSQL Performance" +In-Reply-To: <4457E918.10007@drivefaster.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <4457E918.10007@drivefaster.net> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/62 +X-Sequence-Number: 18849 + +On 5/2/06, Dan Harris wrote: +> My database is used primarily in an OLAP-type environment. Sometimes my +> users get a little carried away and find some way to slip past the +> sanity filters in the applications and end up bogging down the server +> with queries that run for hours and hours. And, of course, what users +> tend to do is to keep queuing up more queries when they don't see the +> first one return instantly :) +> +> So, I have been searching for a way to kill an individual query. I read +> in the mailing list archives that you could 'kill' the pid. I've tried +> this a few times and more than once, it has caused the postmaster to +> die(!), terminating every query that was in process, even unrelated to +> that query. +> +> Is there some way I can just kill a query and not risk breaking +> everything else when I do it? +> +> Thanks +> + +Hi Dan, + +You can kill a specific pid under 8.1 using SELECT +pg_cancel_backend(pid). You can kill a query from the command line by +doing $ kill -TERM pid or $kill -SIGINT pid. + +There are several tips from this thread that may be useful about +killing long running SQL: + http://archives.postgresql.org/pgsql-general/2006-02/msg00298.php + +In short, the recommendations are: + 1) Use statement_timeouts if at all possible. You can do this +database wide in postgresql.conf. You can also set this on a per user +or per SQL statement basis. + 2) Make step #1 does not kill autovacuum, or necessary automated +jobs. You can do this with "ALTER USER SET statement_timeout =3D 0". + +I'm using a web page to show SELECT * FROM pg_stat_activity output +from several servers. This makes it easy to see the pids of any +long-running SQL. + +http://archives.postgresql.org/pgsql-general/2006-02/msg00427.php + +From pgsql-performance-owner@postgresql.org Tue May 2 20:49:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C62479FA9BD + for ; + Tue, 2 May 2006 20:49:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 93421-06 + for ; + Tue, 2 May 2006 20:49:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail5.sea5.speakeasy.net (mail5.sea5.speakeasy.net + [69.17.117.7]) by postgresql.org (Postfix) with ESMTP id 669919FA2C7 + for ; + Tue, 2 May 2006 20:49:34 -0300 (ADT) +Received: (qmail 20406 invoked from network); 2 May 2006 23:49:33 -0000 +Received: from dsl093-038-250.pdx1.dsl.speakeasy.net (HELO [192.168.1.20]) + (davidw@[66.93.38.250]) (envelope-sender ) + by mail5.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted + SMTP + for ; 2 May 2006 23:49:33 -0000 +In-Reply-To: <11514.1146018981@sss.pgh.pa.us> +References: + <11055.1146014387@sss.pgh.pa.us> + <8FE57896-2F9B-4838-857B-FA6CC2EE162A@kineticode.com> + <11514.1146018981@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <8ABDD0B7-326D-4C6C-BACF-3A4D172FEC56@kineticode.com> +Cc: pgsql-performance +Content-Transfer-Encoding: 7bit +From: David Wheeler +Subject: Re: PL/pgSQL Loop Vs. Batch Update +Date: Tue, 2 May 2006 16:49:31 -0700 +To: Tom Lane +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/63 +X-Sequence-Number: 18850 + +On Apr 25, 2006, at 19:36, Tom Lane wrote: + +> Try one of the actual queries from the plpgsql function. + +Here we go: + +try=# PREPARE foo(int, int[], int) AS +try-# INSERT INTO entry_coll_tag (entry_id, tag_id, ord ) +try-# SELECT $1, $2[gs.ser], gs.ser + $3 +try-# FROM generate_series(1, array_upper($2, 1)) AS gs(ser) +try-# WHERE $2[gs.ser] NOT IN ( +try(# SELECT tag_id FROM entry_coll_tag ect2 +try(# WHERE entry_id = $1 +try(# ); +PREPARE +try=# explain analyze execute foo(100100, ARRAY +[600001,600002,600003,600004,600005,600006,600007], 0); + +QUERY PLAN +------------------------------------------------------------------------ +------------------------------------------------------------------------ +- +Function Scan on generate_series gs (cost=7.78..25.28 rows=500 +width=4) (actual time=80.982..81.265 rows=7 loops=1) + Filter: (NOT (hashed subplan)) + SubPlan + -> Index Scan using idx_entry_tag_ord on entry_coll_tag ect2 +(cost=0.00..7.77 rows=5 width=4) (actual time=80.620..80.620 rows=0 +loops=1) + Index Cond: (entry_id = $1) +Trigger for constraint entry_coll_tag_entry_id_fkey: time=3.210 calls=7 +Trigger for constraint entry_coll_tag_tag_id_fkey: time=4.412 calls=7 +Total runtime: 158.672 ms +(8 rows) + +Actually looks pretty good to me. Although is generate_series() being +rather slow? + +Thanks, + +David + +From pgsql-performance-owner@postgresql.org Tue May 2 20:53:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2AC649FA2C7 + for ; + Tue, 2 May 2006 20:53:00 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 52398-04 + for ; + Tue, 2 May 2006 20:52:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail3.sea5.speakeasy.net (mail3.sea5.speakeasy.net + [69.17.117.5]) by postgresql.org (Postfix) with ESMTP id E187B9FA9BD + for ; + Tue, 2 May 2006 20:52:49 -0300 (ADT) +Received: (qmail 5360 invoked from network); 2 May 2006 23:52:48 -0000 +Received: from dsl093-038-250.pdx1.dsl.speakeasy.net (HELO [192.168.1.20]) + (davidw@[66.93.38.250]) (envelope-sender ) + by mail3.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted + SMTP for ; 2 May 2006 23:52:48 -0000 +In-Reply-To: <8ABDD0B7-326D-4C6C-BACF-3A4D172FEC56@kineticode.com> +References: + <11055.1146014387@sss.pgh.pa.us> + <8FE57896-2F9B-4838-857B-FA6CC2EE162A@kineticode.com> + <11514.1146018981@sss.pgh.pa.us> + <8ABDD0B7-326D-4C6C-BACF-3A4D172FEC56@kineticode.com> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: Tom Lane +Content-Transfer-Encoding: 7bit +From: David Wheeler +Subject: Re: PL/pgSQL Loop Vs. Batch Update +Date: Tue, 2 May 2006 16:52:46 -0700 +To: pgsql-performance +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/64 +X-Sequence-Number: 18851 + +On May 2, 2006, at 16:49, David Wheeler wrote: + +> On Apr 25, 2006, at 19:36, Tom Lane wrote: +> +>> Try one of the actual queries from the plpgsql function. +> +> Here we go: +> +> try=# PREPARE foo(int, int[], int) AS +> try-# INSERT INTO entry_coll_tag (entry_id, tag_id, ord ) +> try-# SELECT $1, $2[gs.ser], gs.ser + $3 +> try-# FROM generate_series(1, array_upper($2, 1)) AS gs(ser) +> try-# WHERE $2[gs.ser] NOT IN ( +> try(# SELECT tag_id FROM entry_coll_tag ect2 +> try(# WHERE entry_id = $1 +> try(# ); +> PREPARE +> try=# explain analyze execute foo(100100, ARRAY +> [600001,600002,600003,600004,600005,600006,600007], 0); +> +> QUERY PLAN +> ---------------------------------------------------------------------- +> ---------------------------------------------------------------------- +> ----- +> Function Scan on generate_series gs (cost=7.78..25.28 rows=500 +> width=4) (actual time=80.982..81.265 rows=7 loops=1) +> Filter: (NOT (hashed subplan)) +> SubPlan +> -> Index Scan using idx_entry_tag_ord on entry_coll_tag ect2 +> (cost=0.00..7.77 rows=5 width=4) (actual time=80.620..80.620 rows=0 +> loops=1) +> Index Cond: (entry_id = $1) +> Trigger for constraint entry_coll_tag_entry_id_fkey: time=3.210 +> calls=7 +> Trigger for constraint entry_coll_tag_tag_id_fkey: time=4.412 calls=7 +> Total runtime: 158.672 ms +> (8 rows) +> +> Actually looks pretty good to me. Although is generate_series() +> being rather slow? + +Scratch that: + +try=# delete from entry_coll_tag ; +DELETE 7 +try=# vacuum; +analyze; +VACUUM +try=# analyze; +ANALYZE +try=# explain analyze execute foo(100100, ARRAY +[600001,600002,600003,600004,600005,600006,600007], 0); + +QUERY PLAN +------------------------------------------------------------------------ +----------------------------------------------------------------------- +Function Scan on generate_series gs (cost=7.78..25.28 rows=500 +width=4) (actual time=0.193..0.284 rows=7 loops=1) + Filter: (NOT (hashed subplan)) + SubPlan + -> Index Scan using idx_entry_tag_ord on entry_coll_tag ect2 +(cost=0.00..7.77 rows=5 width=4) (actual time=0.022..0.022 rows=0 +loops=1) + Index Cond: (entry_id = $1) +Trigger for constraint entry_coll_tag_entry_id_fkey: time=0.858 calls=7 +Trigger for constraint entry_coll_tag_tag_id_fkey: time=0.805 calls=7 +Total runtime: 3.266 ms +(8 rows) + +try=# delete from entry_coll_tag ;DELETE 7 +try=# explain analyze execute foo(100100, ARRAY +[600001,600002,600003,600004,600005,600006,600007], 0); + +So my tests are calling this query six hundred times. Could it be +that it just gets slower over time because the database needs to be +vacuumed? Or perhaps pg_autovacuum is kicking in during execution and +*that* slows things down? + +Thanks, + +David + + + +From pgsql-performance-owner@postgresql.org Tue May 2 20:53:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3BD759FAA6E + for ; + Tue, 2 May 2006 20:53:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 90299-01 + for ; + Tue, 2 May 2006 20:53:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from crestone.coronasolutions.com (crestone.coronasolutions.com + [66.45.104.24]) by postgresql.org (Postfix) with ESMTP id 0E2149FA2C7 + for ; + Tue, 2 May 2006 20:53:23 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by crestone.coronasolutions.com (Postfix) with ESMTP id BF391644624 + for ; + Tue, 2 May 2006 17:53:21 -0600 (MDT) +Received: from crestone.coronasolutions.com ([127.0.0.1]) + by localhost (crestone.coronasolutions.com [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id 03850-09 for ; + Tue, 2 May 2006 17:53:16 -0600 (MDT) +Received: from [192.168.1.100] (c-67-165-220-189.hsd1.co.comcast.net + [67.165.220.189]) + by crestone.coronasolutions.com (Postfix) with ESMTP id 5A1AA64459F + for ; + Tue, 2 May 2006 17:53:16 -0600 (MDT) +Message-ID: <4457F0EC.3060401@drivefaster.net> +Date: Tue, 02 May 2006 17:53:16 -0600 +From: Dan Harris +User-Agent: Thunderbird 1.5 (Macintosh/20060122) +MIME-Version: 1.0 +To: PostgreSQL Performance +Subject: Re: Killing long-running queries +References: <4457E918.10007@drivefaster.net> <6445.1146612600@sss.pgh.pa.us> +In-Reply-To: <6445.1146612600@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at drivefaster.net +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/65 +X-Sequence-Number: 18852 + +Tom Lane wrote +> You should be using SIGINT, not SIGTERM. +> +> regards, tom lane +> + +Thank you very much for clarifying this point! It works :) + + + +From pgsql-performance-owner@postgresql.org Tue May 2 20:59:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 57A819FA9BD + for ; + Tue, 2 May 2006 20:59:42 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 91269-07 + for ; + Tue, 2 May 2006 20:59:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id 75A549FAA6E + for ; + Tue, 2 May 2006 20:59:26 -0300 (ADT) +Received: from [192.168.3.5] (dsl.static8121514250.ttnet.net.tr + [81.215.14.250] (may be forged)) (authenticated bits=0) + by projects.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k42NxKVn003145; Tue, 2 May 2006 16:59:21 -0700 +Subject: Re: Killing long-running queries +From: Devrim GUNDUZ +To: Dan Harris +Cc: PostgreSQL Performance +In-Reply-To: <4457E918.10007@drivefaster.net> +References: <4457E918.10007@drivefaster.net> +Content-Type: text/plain +Organization: Command Prompt, Inc. +Date: Wed, 03 May 2006 03:01:16 +0300 +Message-Id: <1146614476.2471.28.camel@laptop.gunduz.org> +Mime-Version: 1.0 +X-Mailer: Evolution 2.6.0 (2.6.0-1) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88, + clamav-milter version 0.87 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Tue, 02 May 2006 16:59:23 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/66 +X-Sequence-Number: 18853 + +Hi, + +On Tue, 2006-05-02 at 17:19 -0600, Dan Harris wrote: +> Is there some way I can just kill a query and not risk breaking +> everything else when I do it? + +Use pg_stat_activity view to find the pid of the process (pidproc +column) and send the signal to that process. I think you are now killing +postmaster, which is wrong. + +Regards, +-- +The PostgreSQL Company - Command Prompt, Inc. 1.503.667.4564 +PostgreSQL Replication, Consulting, Custom Development, 24x7 support +Managed Services, Shared and Dedicated Hosting +Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/ + + + +From pgsql-performance-owner@postgresql.org Tue May 2 22:17:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D2F469FA1B0 + for ; + Tue, 2 May 2006 22:17:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 86634-04 + for ; + Tue, 2 May 2006 22:16:59 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail8.sea5.speakeasy.net (mail8.sea5.speakeasy.net + [69.17.117.10]) by postgresql.org (Postfix) with ESMTP id 993719F9C9E + for ; + Tue, 2 May 2006 22:16:59 -0300 (ADT) +Received: (qmail 29061 invoked from network); 3 May 2006 01:16:57 -0000 +Received: from dsl093-038-250.pdx1.dsl.speakeasy.net (HELO [192.168.1.20]) + (davidw@[66.93.38.250]) (envelope-sender ) + by mail8.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted + SMTP for ; 3 May 2006 01:16:57 -0000 +In-Reply-To: +References: + <11055.1146014387@sss.pgh.pa.us> + <8FE57896-2F9B-4838-857B-FA6CC2EE162A@kineticode.com> + <11514.1146018981@sss.pgh.pa.us> + <8ABDD0B7-326D-4C6C-BACF-3A4D172FEC56@kineticode.com> + +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <4F5A51D9-3740-49F2-AFC5-B2901101FFB9@kineticode.com> +Cc: Tom Lane +Content-Transfer-Encoding: 7bit +From: David Wheeler +Subject: Re: PL/pgSQL Loop Vs. Batch Update +Date: Tue, 2 May 2006 18:16:56 -0700 +To: pgsql-performance +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/67 +X-Sequence-Number: 18854 + +On May 2, 2006, at 16:52, David Wheeler wrote: + +>> Actually looks pretty good to me. Although is generate_series() +>> being rather slow? +> +> Scratch that: + +Bah, dammit, there were no rows in that relevant table. Please +disregard my previous EXPLAIN ANALYZE posts. + +I've re-run my script and populated it with 549,815 rows. *Now* let's +see what we've got: + + +try=# VACUUM; +VACUUM +try=# ANALYZE; +ANALYZE +try=# PREPARE foo(int, int[], int) AS +try-# INSERT INTO entry_coll_tag (entry_id, tag_id, ord ) +try-# SELECT $1, $2[gs.ser], gs.ser + $3 +try-# FROM generate_series(1, array_upper($2, 1)) AS gs(ser) +try-# WHERE $2[gs.ser] NOT IN ( +try(# SELECT tag_id FROM entry_coll_tag ect2 +try(# WHERE entry_id = $1 +try(# ); +PREPARE +try=# explain analyze execute foo(100100, ARRAY +[600001,600002,600003,600004,600005,600006,600007], 0); + +QUERY PLAN +------------------------------------------------------------------------ +----------------------------------------------------------------------- +Function Scan on generate_series gs (cost=9.68..27.18 rows=500 +width=4) (actual time=0.965..1.055 rows=7 loops=1) + Filter: (NOT (hashed subplan)) + SubPlan + -> Index Scan using idx_entry_tag_ord on entry_coll_tag ect2 +(cost=0.00..9.66 rows=8 width=4) (actual time=0.844..0.844 rows=0 +loops=1) + Index Cond: (entry_id = $1) +Trigger for constraint entry_coll_tag_entry_id_fkey: time=3.872 calls=7 +Trigger for constraint entry_coll_tag_tag_id_fkey: time=3.872 calls=7 +Total runtime: 12.797 ms +(8 rows) + +try=# delete from entry_coll_tag where entry_id = 100100; +DELETE 7 +try=# explain analyze execute foo(100100, ARRAY +[600001,600002,600003,600004,600005,600006,600007], 0); + +QUERY PLAN +------------------------------------------------------------------------ +----------------------------------------------------------------------- +Function Scan on generate_series gs (cost=9.68..27.18 rows=500 +width=4) (actual time=0.117..0.257 rows=7 loops=1) + Filter: (NOT (hashed subplan)) + SubPlan + -> Index Scan using idx_entry_tag_ord on entry_coll_tag ect2 +(cost=0.00..9.66 rows=8 width=4) (actual time=0.058..0.058 rows=0 +loops=1) + Index Cond: (entry_id = $1) +Trigger for constraint entry_coll_tag_entry_id_fkey: time=0.542 calls=7 +Trigger for constraint entry_coll_tag_tag_id_fkey: time=0.590 calls=7 +Total runtime: 2.118 ms +(8 rows) + +Damn, that seems pretty efficient. I wonder if it's the other +function, then. I'll have to work EXPLAIN ANALYZEing _it_. + +Best, + +David + +From pgsql-performance-owner@postgresql.org Tue May 2 23:09:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1B92D9FA9BD + for ; + Tue, 2 May 2006 23:09:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 82665-07 + for ; + Tue, 2 May 2006 23:09:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx.sat.rackspace.com (mx.sat.rackspace.com [64.39.1.214]) + by postgresql.org (Postfix) with ESMTP id 6512E9FA2C7 + for ; + Tue, 2 May 2006 23:09:37 -0300 (ADT) +Received: from mail.rackspace.com (mail.rackspace.com [64.39.2.181]) + by mx.sat.rackspace.com (8.13.6/8.13.6) with ESMTP id k4329ZGo006493 + for ; Tue, 2 May 2006 21:09:36 -0500 + (envelope-from wreese@rackspace.com) +Received: from [192.168.10.8] (vpn113-66.sat.rackspace.com [10.1.113.66]) + (authenticated bits=0) + by mail.rackspace.com (8.13.1/8.13.1) with ESMTP id k4329YRc005803 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO) + for ; Tue, 2 May 2006 21:09:34 -0500 +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <1146614476.2471.28.camel@laptop.gunduz.org> +References: <4457E918.10007@drivefaster.net> + <1146614476.2471.28.camel@laptop.gunduz.org> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <6F323559-FD45-4E8A-9DDB-D3775E1C8716@rackspace.com> +Content-Transfer-Encoding: 7bit +From: Will Reese +Subject: Re: Killing long-running queries +Date: Tue, 2 May 2006 21:09:14 -0500 +To: PostgreSQL Performance +X-Mailer: Apple Mail (2.749.3) +X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='__C230066_P5 0, + __CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, + __HAS_MSGID 0, __HAS_X_MAILER 0, __MIME_TEXT_ONLY 0, + __MIME_VERSION 0, __SANE_MSGID 0' +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/68 +X-Sequence-Number: 18855 + +There is also the statement_timeout setting in postgresql.conf, but +you have to be careful with this setting. I'm not sure about +postgres 8.0 or 8.1, but in 7.4.5 this setting will terminate the +COPY statements used by pg_dumpall for backups. So I actually use +the pg_stat_activity table to kill long running queries or idle in +transactions that are hanging around (very bad for vacuum). For +example, you can do something like this to kill off idle in +transactions that are truly idle for more than 1 hour... + +psql -U postgres -A -t -c "select procpid from pg_stat_activity where +current_query ilike '%idle in transaction%' and query_start < now() - +interval '1 hour'" template1 | xargs kill + +Just throw that in your crontab to run every few minutes, redirect +standard error to /dev/null, and quit worrying about vacuum not +reclaiming space because some developer's code fails to commit or +rollback a transaction. Just be careful you aren't killing off +processes that are actually doing work. :) + +-- Will Reese http://blog.rezra.com + +On May 2, 2006, at 7:01 PM, Devrim GUNDUZ wrote: + +> Hi, +> +> On Tue, 2006-05-02 at 17:19 -0600, Dan Harris wrote: +>> Is there some way I can just kill a query and not risk breaking +>> everything else when I do it? +> +> Use pg_stat_activity view to find the pid of the process (pidproc +> column) and send the signal to that process. I think you are now +> killing +> postmaster, which is wrong. +> +> Regards, +> -- +> The PostgreSQL Company - Command Prompt, Inc. 1.503.667.4564 +> PostgreSQL Replication, Consulting, Custom Development, 24x7 support +> Managed Services, Shared and Dedicated Hosting +> Co-Authors: plPHP, plPerlNG - http://www.commandprompt.com/ +> +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org + + +From pgsql-performance-owner@postgresql.org Tue May 2 23:10:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 86B5E9FA2C7 + for ; + Tue, 2 May 2006 23:10:40 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 59768-05 + for ; + Tue, 2 May 2006 23:10:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 196739FA9BD + for ; + Tue, 2 May 2006 23:10:23 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Tue, 2 May 2006 20:10:13 -0600 +In-Reply-To: <20060502215329.GI97354@pervasive.com> +References: <444F24E9.2010907@lisasoft.com> + <20060502171617.GZ97354@pervasive.com> + <622925BE-A31E-42FD-AF6A-68DDF3B4A1B7@clickspace.com> + <1146595755.12053.111.camel@archimedes> + <758B0591-3C9C-418B-9AF2-E962003C4904@rackspace.com> + <20060502215329.GI97354@pervasive.com> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <4A7F9950-65E0-4FA5-9FEC-BA1A93E615E5@clickspace.com> +Cc: Will Reese , + pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: Slow restoration question +Date: Tue, 2 May 2006 20:09:52 -0600 +To: Jim C. Nasby +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/69 +X-Sequence-Number: 18856 + +Hi Jim, + +The output from bonnie on my boot drive is: + +File './Bonnie.27964', size: 0 +Writing with putc()...done +Rewriting...done +Writing intelligently...done +Reading with getc()...done +Reading intelligently...done +Seeker 2...Seeker 1...Seeker 3...start 'em...done...done...done... + -------Sequential Output-------- ---Sequential Input-- +--Random-- + -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- +--Seeks--- +Machine MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec % +CPU /sec %CPU + 0 36325 98.1 66207 22.9 60663 16.2 50553 99.9 710972 +100.0 44659.8 191.3 + + +And the output from the RAID drive is: + +File './Bonnie.27978', size: 0 +Writing with putc()...done +Rewriting...done +Writing intelligently...done +Reading with getc()...done +Reading intelligently...done +Seeker 1...Seeker 2...Seeker 3...start 'em...done...done...done... + -------Sequential Output-------- ---Sequential Input-- +--Random-- + -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- +--Seeks--- +Machine MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec % +CPU /sec %CPU + 0 40365 99.4 211625 61.4 212425 57.0 50740 99.9 730515 +100.0 45897.9 190.1 + + +Each drive in the RAID 5 is a 400 GB serial ATA drive. I'm not sure +the manufacturer or the model number as it was all in a packaged box +when we received it and I didn't check. + +Do these numbers seem decent enough for a Postgres database? + + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On May 2, 2006, at 3:53 PM, Jim C. Nasby wrote: + +> BTW, you should be able to check to see what the controller is +> actually +> doing by pulling one of the drives from a running array. If it only +> hammers 2 drives during the rebuild, it's RAID10. If it hammers all +> the +> drives, it's 0+1. +> +> As for Xserve raid, it is possible to eliminate most (or maybe even +> all) +> of the overhead associated with RAID5, depending on how tricky the +> controller wants to be. I believe many large storage appliances +> actually +> use RAID5 internally, but they perform a bunch of 'magic' behind the +> scenes to get good performance from it. So, it is possible that the +> XServe RAID performs quite well on RAID5. If you provided the results +> from bonnie as well as info about the drives I suspect someone here +> could tell you if you're getting close to RAID10 performance or not. +> +> On Tue, May 02, 2006 at 02:34:16PM -0500, Will Reese wrote: +>> RAID 10 is better than RAID 0+1. There is a lot of information on +>> the net about this, but here is the first one that popped up on +>> google for me. +>> +>> http://www.pcguide.com/ref/hdd/perf/raid/levels/multLevel01-c.html +>> +>> The quick summary is that performance is about the same between the +>> two, but RAID 10 gives better fault tolerance and rebuild +>> performance. I have seen docs for RAID cards that have confused +>> these two RAID levels. In addition, some cards claim to support RAID +>> 10, when they actually support RAID 0+1 or even RAID 0+1 with +>> concatenation (lame, some of the Dell PERCs have this). +>> +>> RAID 10 with 6 drives would stripe across 3 mirrored pairs. RAID 0+1 +>> with 6 drives is a mirror of two striped arrays (3 disks each). RAID +>> 0+1 (with concatenation) using 6 drives is a mirror of two volumes +>> (kind of like JBOD) each consisting of 3 drives concatenated together +>> (it's a cheap implementation, and it gives about the same performance +>> as RAID 1 but with increased storage capacity and less fault +>> tolerance). RAID 10 is better than RAID 5 (especially with 6 or less +>> disks) because you don't have the performance hit for parity (which +>> dramatically affects rebuild performance and write performance) and +>> you get better fault tolerance (up to 3 disks can fail in a 6 disk +>> RAID 10 and you can still be online, with RAID 5 you can only lose 1 +>> drive). All of this comes with a higher cost (more drives and higher +>> end cards). +>> +>> -- Will Reese http://blog.rezra.com +>> +>> +>> On May 2, 2006, at 1:49 PM, Mark Lewis wrote: +>> +>>> They are not equivalent. As I understand it, RAID 0+1 performs +>>> about +>>> the same as RAID 10 when everything is working, but degrades much +>>> less +>>> nicely in the presence of a single failed drive, and is more +>>> likely to +>>> suffer catastrophic data loss if multiple drives fail. +>>> +>>> -- Mark +>>> +>>> On Tue, 2006-05-02 at 12:40 -0600, Brendan Duddridge wrote: +>>>> Everyone here always says that RAID 5 isn't good for Postgres. We +>>>> have an Apple Xserve RAID configured with RAID 5. We chose RAID 5 +>>>> because Apple said their Xserve RAID was "optimized" for RAID 5. +>>>> Not +>>>> sure if we made the right decision though. They give an option for +>>>> formatting as RAID 0+1. Is that the same as RAID 10 that everyone +>>>> talks about? Or is it the reverse? +>>>> +>>>> Thanks, +>>>> +>>>> ___________________________________________________________________ +>>>> _ +>>>> Brendan Duddridge | CTO | 403-277-5591 x24 | +>>>> brendan@clickspace.com +>>>> +>>>> ClickSpace Interactive Inc. +>>>> Suite L100, 239 - 10th Ave. SE +>>>> Calgary, AB T2G 0V9 +>>>> +>>>> http://www.clickspace.com +>>>> +>>>> On May 2, 2006, at 11:16 AM, Jim C. Nasby wrote: +>>>> +>>>>> On Wed, Apr 26, 2006 at 05:14:41PM +0930, Eric Lam wrote: +>>>>>> all dumpfiles total about 17Gb. It has been running for 50ish hrs +>>>>>> and up +>>>>>> to about the fourth file (5-6 ish Gb) and this is on a raid 5 +>>>>>> server. +>>>>> +>>>>> RAID5 generally doesn't bode too well for performance; that +>>>>> could be +>>>>> part of the issue. +>>>>> -- +>>>>> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +>>>>> Pervasive Software http://pervasive.com work: 512-231-6117 +>>>>> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +>>>>> +>>>>> ---------------------------(end of +>>>>> broadcast)--------------------------- +>>>>> TIP 4: Have you searched our list archives? +>>>>> +>>>>> http://archives.postgresql.org +>>>>> +>>>> +>>>> +>>>> +>>>> ---------------------------(end of +>>>> broadcast)--------------------------- +>>>> TIP 9: In versions below 8.0, the planner will ignore your +>>>> desire to +>>>> choose an index scan if your joining column's datatypes do +>>>> not +>>>> match +>>> +>>> ---------------------------(end of +>>> broadcast)--------------------------- +>>> TIP 6: explain analyze is your friend +>> +>> +>> ---------------------------(end of +>> broadcast)--------------------------- +>> TIP 5: don't forget to increase your free space map settings +>> +> +> -- +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 9: In versions below 8.0, 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 Wed May 3 00:04:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 711BB9FB1C8 + for ; + Wed, 3 May 2006 00:04:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27444-06 + for ; + Wed, 3 May 2006 00:04:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id C80729FA2C7 + for ; + Wed, 3 May 2006 00:03:59 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4333vGL009689; + Tue, 2 May 2006 23:03:58 -0400 (EDT) +To: "Ian Burrell" +cc: pgsql-performance@postgresql.org +Subject: Re: Nested loop join and date range query +In-reply-to: +References: +Comments: In-reply-to "Ian Burrell" + message dated "Tue, 02 May 2006 15:55:57 -0700" +Date: Tue, 02 May 2006 23:03:57 -0400 +Message-ID: <9688.1146625437@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/70 +X-Sequence-Number: 18857 + +"Ian Burrell" writes: +> We recently upgraded to PostgreSQL 8.1 from 7.4 and a few queries are +> having performance problems and running for very long times. The +> commonality seems to be PostgreSQL 8.1 is choosing to use a nested +> loop join because it estimates there will be only be a single row. + +> -> Index Scan using unq_xtns_by_mso_title_wk on +> xtns_by_mso_title_wk x (cost=0.00..4.12 rows=1 width=26) (actual +> time=7.827..1297.681 rows=3934 loops=1) +> Index Cond: ((week >= '2006-04-23 +> 00:00:00'::timestamp without time zone) AND (week <= '2006-04-23 +> 00:00:00'::timestamp without time zone) AND (mso_no = 50)) + +We've already noted that there's a problem with estimating zero-width +ranges (too lazy to search the archives, but this has come up at least +twice recently). Can you modify your app to generate something like + + week >= x and week < x+1 + +instead of + + week >= x and week <= x + +? My recollection is that the fix will probably be complicated +enough to not get back-patched into 8.1. + +BTW, AFAIK the same problem exists in 7.4. What kind of estimates/plans +were you getting for this case in 7.4? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed May 3 03:18:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 134A79FB1F8 + for ; + Wed, 3 May 2006 01:08:42 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 18184-06 + for ; + Wed, 3 May 2006 01:08:20 -0300 (ADT) +X-Greylist: delayed 00:10:02.481184 by SQLgrey- +Received: from mail4.intermedia.net (mail4.intermedia.net [206.40.48.154]) + by postgresql.org (Postfix) with ESMTP id D5E589FB1DD + for ; + Wed, 3 May 2006 01:08:19 -0300 (ADT) +Received: from governor (unverified [67.79.8.2]) by mail4.intermedia.net + (Rockliffe SMTPRA 4.5.6) with ESMTP id + ; Tue, 2 May 2006 20:58:15 -0700 +From: "Gregory Stewart" +To: "Mark Kirkwood" +Cc: "Theodore Loscalzo" , + +Subject: Re: Performance Issues on Opteron Dual Core +Date: Tue, 2 May 2006 22:58:15 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +In-Reply-To: <44555066.2090902@paradise.net.nz> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/75 +X-Sequence-Number: 18862 + +I am using the onboard NVRAID controller. It has to be configured in the +BIOS and windows needs a raid driver at install to even see the raid drive. +But the onboard controller still utilizes system resources. So it is not a +"pure" software raid, but a mix of hardware (controller) / software I guess. +But I don't really know a whole lot about it. + +-----Original Message----- +From: Mark Kirkwood [mailto:markir@paradise.net.nz] +Sent: Sunday, April 30, 2006 7:04 PM +To: Gregory Stewart +Cc: Theodore Loscalzo +Subject: Re: [PERFORM] Performance Issues on Opteron Dual Core + + +Gregory Stewart wrote: +> Theodore, +> +> Thank you for your reply. +> I am using the onboard NVidia RAID that is on the Asus A8N-E motherboard, +so +> it is a software raid. +> But as I said, the CPU utilization on that machine is basically 0%. I also +> ran some system performance tests, and the machine flies including the HD +> performance, all better than the dev machine which doesn't use raid. +> + + +(Ooops sorry about so many mails), Might be worth using Google or +Technet to see if there are known performance issues with the (NVidia?) +SATA controller on the A8N-E (as there seem to be a lot of crappy SATA +controllers around at the moment). + +Also (I'm not a Windows guy) by software RAID, do you mean you are using +the "firmware RAID1" from the controller or are you using Windows +software RAID1 on the two disks directly? + +Cheers + +Mark + + +-- +No virus found in this incoming message. +Checked by AVG Free Edition. +Version: 7.1.385 / Virus Database: 268.5.1/327 - Release Date: 4/28/2006 + + + +From pgsql-performance-owner@postgresql.org Wed May 3 03:19:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 080719FAE4E + for ; + Wed, 3 May 2006 01:27:20 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 12511-08 + for ; + Wed, 3 May 2006 01:27:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail4.intermedia.net (mail4.intermedia.net [206.40.48.154]) + by postgresql.org (Postfix) with ESMTP id 0962E9FA7B6 + for ; + Wed, 3 May 2006 01:27:03 -0300 (ADT) +Received: from governor (unverified [67.79.8.3]) by mail4.intermedia.net + (Rockliffe SMTPRA 4.5.6) with ESMTP id + ; Tue, 2 May 2006 21:27:03 -0700 +From: "Gregory Stewart" +To: "Jim C. Nasby" , + "Mark Kirkwood" +Cc: +Subject: Re: Performance Issues on Opteron Dual Core +Date: Tue, 2 May 2006 23:27:02 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +In-Reply-To: <20060502202837.GC97354@pervasive.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/76 +X-Sequence-Number: 18863 + +Jim, + +Have you seen this happening only on W2k3? I am wondering if I should try +out 2000 Pro or XP Pro. +Not my first choice, but if it works... + + + +-----Original Message----- +From: Jim C. Nasby [mailto:jnasby@pervasive.com] +Sent: Tuesday, May 02, 2006 3:29 PM +To: Mark Kirkwood +Cc: Gregory Stewart; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Performance Issues on Opteron Dual Core + + +On Sun, Apr 30, 2006 at 10:59:56PM +1200, Mark Kirkwood wrote: +> Pgadmin can give misleading times for queries that return large result +> sets over a network, due to: +> +> 1/ It takes time to format the (large) result set for display. +> 2/ It has to count the time spent waiting for the (large) result set to +> travel across the network. +> +> You aren't running Pgadmin off the dev server are you? If not check your +> network link to dev and prod - is one faster than the other? (etc). +> +> To eliminate Pgadmin and the network as factors try wrapping your query +> in a 'SELECT count(*) FROM (your query here) AS a', and see if it +> changes anything! + +FWIW, I've found problems running PostgreSQL on Windows in a multi-CPU +environment on w2k3. It runs fine for some period, and then CPU and +throughput drop to zero. So far I've been unable to track down any more +information than that, other than the fact that I haven't been able to +reproduce this on any single-CPU machines. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + + +-- +No virus found in this incoming message. +Checked by AVG Free Edition. +Version: 7.1.385 / Virus Database: 268.5.1/328 - Release Date: 5/1/2006 + + + +From pgsql-performance-owner@postgresql.org Wed May 3 03:49:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 48D719FB250 + for ; + Wed, 3 May 2006 03:49:02 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 97130-02 + for ; + Wed, 3 May 2006 03:48:24 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.199]) + by postgresql.org (Postfix) with ESMTP id 7C5889FB2C0 + for ; + Wed, 3 May 2006 03:21:27 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id x7so95098nzc + for ; + Tue, 02 May 2006 23:21:26 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; + b=uK57w2W4JzPsGckM+OXdsVpn6tRf4jGwaWc2D/VO3ifL2F9+nAk4AB/7ibg6fy74sfM7PBJ0icpDm/qt2vijFEhjid+gxvwyFa4p4tw2bR7bT9qWv/0K6P3Hadj8utF8JbZqRwqbnAIv832q0yuIJjV7T+agXeBaUwsaXQ+dFfA= +Received: by 10.36.67.16 with SMTP id p16mr2213590nza; + Tue, 02 May 2006 23:21:26 -0700 (PDT) +Received: from ?10.1.1.23? ( [203.217.18.65]) + by mx.gmail.com with ESMTP id 36sm5785nzk.2006.05.02.23.21.24; + Tue, 02 May 2006 23:21:25 -0700 (PDT) +Message-ID: <44584BE3.7020403@gmail.com> +Date: Wed, 03 May 2006 16:21:23 +1000 +From: Chris +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Bert +CC: pgsql-performance@postgresql.org +Subject: Re: Easy question +References: <1145741653.759727.38970@e56g2000cwe.googlegroups.com> + + <1146101167.724196.253740@v46g2000cwv.googlegroups.com> + + <1146355679.311472.57800@u72g2000cwu.googlegroups.com> +In-Reply-To: <1146355679.311472.57800@u72g2000cwu.googlegroups.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/77 +X-Sequence-Number: 18864 + +Bert wrote: +> No i didn't defined any indexes for the table, I know the performance +> will increase with an index, but this was not my question. My question +> furthermore belongs to the access mode of the SQL statement. +> Furthermore i do not understand why the Upper function should increase +> the performance. + +The index will have entries like: + +CHRIS +BERT +JOE + +and so on. + +If you run a query like: + +select * from table where UPPER(name) = 'CHRIS'; + +It's an easy match. + +If you don't create an UPPER index, it has to do a comparison with each +row - so the index can't be used because postgres has to convert the +field to upper and then do the comparison. + +-- +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-performance-owner@postgresql.org Wed May 3 04:29:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D92809FA25D + for ; + Wed, 3 May 2006 04:29:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 62938-10 + for ; + Wed, 3 May 2006 04:29:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by postgresql.org (Postfix) with ESMTP id 67BE79FA1B0 + for ; + Wed, 3 May 2006 04:29:16 -0300 (ADT) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id 0BC348F288; Wed, 3 May 2006 09:29:15 +0200 (CEST) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: Re: Performance Issues on Opteron Dual Core +Date: Wed, 3 May 2006 09:29:15 +0200 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCEA0F957@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Performance Issues on Opteron Dual Core +Thread-Index: AcZuO89tLlbR7cnvQBmsqGFBaMEWnwARuv2Q +From: "Magnus Hagander" +To: "Jim C. Nasby" , + "Jan de Visser" +Cc: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/78 +X-Sequence-Number: 18865 + +> > > FWIW, I've found problems running PostgreSQL on Windows in a=20 +> > > multi-CPU environment on w2k3. It runs fine for some period, and=20 +> > > then CPU and throughput drop to zero. So far I've been unable to=20 +> > > track down any more information than that, other than the=20 +> fact that=20 +> > > I haven't been able to reproduce this on any single-CPU machines. +> >=20 +> > I have had previous correspondence about this with Magnus (search=20 +> > -general and -hackers). If you uninstall SP1 the problem=20 +> goes away. We=20 +> > played a bit with potential fixes but didn't find any. +>=20 +> Interesting; does SP2 fix the problem? Anything we can do=20 +> over here to help? + +There is no SP2 for Windows 2003. + +Have you tried this with latest-and-greatest CVS HEAD? Meaning with the +new semaphore code that was committed a couple of days ago? + +//Magnus + +From pgsql-performance-owner@postgresql.org Wed May 3 08:22:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7346F9FA226 + for ; + Wed, 3 May 2006 08:22:39 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 35504-03 + for ; + Wed, 3 May 2006 08:22:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) + by postgresql.org (Postfix) with ESMTP id BECC09FA08A + for ; + Wed, 3 May 2006 08:22:33 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYO00FWMSXDHMU3@vms042.mailsrvcs.net> for + pgsql-performance@postgresql.org; Wed, 03 May 2006 06:22:26 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 0F42A6E5DD for + ; + Wed, 03 May 2006 07:22:23 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 13838-04 for ; Wed, + 03 May 2006 07:22:22 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id EDA736ECBD; Wed, 03 May 2006 07:22:21 -0400 (EDT) +Date: Wed, 03 May 2006 07:22:21 -0400 +From: Michael Stone +Subject: Re: Why so slow? +In-reply-to: <20060502192834.6c8e9131.wmoran@collaborativefusion.com> +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060503112219.GM31328@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <200604281043.16083@hal.medialogik.com> + + <20060430100346.20f010a9.wmoran@collaborativefusion.com> + <20060502201740.GB97354@pervasive.com> + <20060502192834.6c8e9131.wmoran@collaborativefusion.com> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/79 +X-Sequence-Number: 18866 + +On Tue, May 02, 2006 at 07:28:34PM -0400, Bill Moran wrote: +>Reindexing is in a different class than vacuuming. + +Kinda, but it is in the same class as vacuum full. If vacuum neglect (or +dramatic change in usage) has gotten you to the point of 10G of overhead +on a 2G table you can get a dramatic speedup if you vacuum full, by +dumping a lot of unused space. But in that case you might have a similar +amount of overhead in indices, which isn't going to go away unless you +reindex. In either case the unused rows will be reused as needed, but if +you know you aren't going to need the space again anytime soon you might +need to vacuum full/reindex. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Wed May 3 09:19:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1105B9F946D + for ; + Wed, 3 May 2006 09:19:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 41431-10 + for ; + Wed, 3 May 2006 09:19:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) + by postgresql.org (Postfix) with ESMTP id 79BBA9F9586 + for ; + Wed, 3 May 2006 09:19:00 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYO00A6JVJH6YX1@vms042.mailsrvcs.net> for + pgsql-performance@postgresql.org; Wed, 03 May 2006 07:18:53 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id B30766EC9D for + ; + Wed, 03 May 2006 08:18:50 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 14209-03 for ; Wed, + 03 May 2006 08:18:50 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id BB5986ECBD; Wed, 03 May 2006 08:18:49 -0400 (EDT) +Date: Wed, 03 May 2006 08:18:49 -0400 +From: Michael Stone +Subject: Re: Slow restoration question +In-reply-to: <4A7F9950-65E0-4FA5-9FEC-BA1A93E615E5@clickspace.com> +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060503121847.GN31328@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <444F24E9.2010907@lisasoft.com> + <20060502171617.GZ97354@pervasive.com> + <622925BE-A31E-42FD-AF6A-68DDF3B4A1B7@clickspace.com> + <1146595755.12053.111.camel@archimedes> + <758B0591-3C9C-418B-9AF2-E962003C4904@rackspace.com> + <20060502215329.GI97354@pervasive.com> + <4A7F9950-65E0-4FA5-9FEC-BA1A93E615E5@clickspace.com> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/80 +X-Sequence-Number: 18867 + +On Tue, May 02, 2006 at 08:09:52PM -0600, Brendan Duddridge wrote: +> -------Sequential Output-------- ---Sequential Input-- --Random-- +> -Per Char- --Block--- -Rewrite-- -Per Char- --Block--- --Seeks--- +>Machine MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec % CPU /sec %CPU +> 0 40365 99.4 211625 61.4 212425 57.0 50740 99.9 730515 100.0 45897.9 190.1 +[snip] +>Do these numbers seem decent enough for a Postgres database? + +These numbers seem completely bogus, probably because bonnie is using a +file size smaller than memory and is reporting caching effects. (730MB/s +isn't possible for a single external RAID unit with a pair of 2Gb/s +interfaces.) bonnie in general isn't particularly useful on modern +large-ram systems, in my experience. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Wed May 3 09:30:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id EFDBE9F9586 + for ; + Wed, 3 May 2006 09:30:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 52524-09 + for ; + Wed, 3 May 2006 09:30:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.digitalfairway.ca (ns.digitalfairway.ca [207.164.133.170]) + by postgresql.org (Postfix) with ESMTP id B48B39F946D + for ; + Wed, 3 May 2006 09:30:13 -0300 (ADT) +Received: from toronto.toronto.digitalfairway.ca (unknown [192.168.100.10]) + by mail.digitalfairway.ca (Postfix) with ESMTP id 9E31F6EF07 + for ; + Wed, 3 May 2006 08:30:11 -0400 (EDT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by toronto.toronto.digitalfairway.ca (Postfix) with ESMTP id + 511AA144E35 for ; + Wed, 3 May 2006 08:30:11 -0400 (EDT) +Received: from toronto.toronto.digitalfairway.ca ([127.0.0.1]) + by localhost (toronto.toronto.digitalfairway.ca [127.0.0.1]) + (amavisd-new, port 10024) + with ESMTP id 25260-07 for ; + Wed, 3 May 2006 08:30:11 -0400 (EDT) +Received: from [192.168.100.50] (unknown [192.168.100.50]) + (using SSLv3 with cipher EXP1024-RC4-SHA (56/128 bits)) + (No client certificate requested) + by toronto.toronto.digitalfairway.ca (Postfix) with ESMTP id + 367FF144E16 for ; + Wed, 3 May 2006 08:30:11 -0400 (EDT) +From: Jan de Visser +To: pgsql-performance@postgresql.org +Subject: Re: Performance Issues on Opteron Dual Core +Date: Wed, 3 May 2006 08:30:10 -0400 +User-Agent: KMail/1.9.1 +References: <6BCB9D8A16AC4241919521715F4D8BCEA0F957@algol.sollentuna.se> +In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCEA0F957@algol.sollentuna.se> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200605030830.10364.jdevisser@digitalfairway.com> +X-Virus-Scanned: amavisd-new at digitalfairway.ca +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/81 +X-Sequence-Number: 18868 + +On Wednesday 03 May 2006 03:29, Magnus Hagander wrote: +> > > > FWIW, I've found problems running PostgreSQL on Windows in a +> > > > multi-CPU environment on w2k3. It runs fine for some period, and +> > > > then CPU and throughput drop to zero. So far I've been unable to +> > > > track down any more information than that, other than the +> > +> > fact that +> > +> > > > I haven't been able to reproduce this on any single-CPU machines. +> > > +> > > I have had previous correspondence about this with Magnus (search +> > > -general and -hackers). If you uninstall SP1 the problem +> > +> > goes away. We +> > +> > > played a bit with potential fixes but didn't find any. +> > +> > Interesting; does SP2 fix the problem? Anything we can do +> > over here to help? +> +> There is no SP2 for Windows 2003. + +That's what I thought. Jim confused me there for a minute. + +> +> Have you tried this with latest-and-greatest CVS HEAD? Meaning with the +> new semaphore code that was committed a couple of days ago? + +No I haven't. Worth a test on a rainy afternoon I'd say... + +> +> //Magnus + +jan + +=2D-=20 +=2D------------------------------------------------------------- +Jan de Visser =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 jdevisser@digitalfair= +way.com + +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Baruk Khazad! Khazad ai-menu! +=2D------------------------------------------------------------- + +From pgsql-performance-owner@postgresql.org Wed May 3 10:49:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id ED3839F9C10 + for ; + Wed, 3 May 2006 10:49:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 22244-05 + for ; + Wed, 3 May 2006 10:49:28 -0300 (ADT) +X-Greylist: delayed 00:28:55.79377 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 632919FA38E + for ; + Wed, 3 May 2006 10:49:25 -0300 (ADT) +Received: from insiderscore.com (mail01.insiderscore.com [69.84.139.233]) + by svr4.postgresql.org (Postfix) with ESMTP id E2F7B5B0368 + for ; + Wed, 3 May 2006 13:19:56 +0000 (GMT) +Received: from [10.10.10.105] (pool-71-248-161-225.bstnma.fios.verizon.net + [71.248.161.225]) + by insiderscore.com (Postfix) with ESMTP id 994D811C42CB; + Wed, 3 May 2006 09:19:53 -0400 (EDT) +In-Reply-To: <20060503121847.GN31328@mathom.us> +References: <444F24E9.2010907@lisasoft.com> + <20060502171617.GZ97354@pervasive.com> + <622925BE-A31E-42FD-AF6A-68DDF3B4A1B7@clickspace.com> + <1146595755.12053.111.camel@archimedes> + <758B0591-3C9C-418B-9AF2-E962003C4904@rackspace.com> + <20060502215329.GI97354@pervasive.com> + <4A7F9950-65E0-4FA5-9FEC-BA1A93E615E5@clickspace.com> + <20060503121847.GN31328@mathom.us> +Mime-Version: 1.0 (Apple Message framework v746.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <30D5959B-3CCD-4CB4-B2D7-30DEA9F08BB6@torgo.978.org> +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Jeff Trout +Subject: Re: Slow restoration question +Date: Wed, 3 May 2006 09:19:52 -0400 +To: Michael Stone +X-Mailer: Apple Mail (2.746.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/82 +X-Sequence-Number: 18869 + + +On May 3, 2006, at 8:18 AM, Michael Stone wrote: + +> On Tue, May 02, 2006 at 08:09:52PM -0600, Brendan Duddridge wrote: +>> -------Sequential Output-------- ---Sequential +>> Input-- --Random-- +>> -Per Char- --Block--- -Rewrite-- -Per Char- -- +>> Block--- --Seeks--- +>> Machine MB K/sec %CPU K/sec %CPU K/sec %CPU K/sec %CPU K/sec % +>> CPU /sec %CPU +>> 0 40365 99.4 211625 61.4 212425 57.0 50740 99.9 +>> 730515 100.0 45897.9 190.1 +> [snip] +>> Do these numbers seem decent enough for a Postgres database? +> +> These numbers seem completely bogus, probably because bonnie is +> using a file size smaller than memory and is reporting caching +> effects. (730MB/s isn't possible for a single external RAID unit +> with a pair of 2Gb/s interfaces.) bonnie in general isn't +> particularly useful on modern large-ram systems, in my experience. +> + +Bonnie++ is able to use very large datasets. It also tries to figure +out hte size you want (2x ram) - the original bonnie is limited to 2GB. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + + +From pgsql-performance-owner@postgresql.org Wed May 3 11:16:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5DD3F9F9C9E + for ; + Wed, 3 May 2006 11:16:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 63611-01 + for ; + Wed, 3 May 2006 11:16:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id 9F5619F9AD3 + for ; + Wed, 3 May 2006 11:16:13 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id BFF17B826 + for ; + Wed, 3 May 2006 10:16:11 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <30D5959B-3CCD-4CB4-B2D7-30DEA9F08BB6@torgo.978.org> +References: <444F24E9.2010907@lisasoft.com> + <20060502171617.GZ97354@pervasive.com> + <622925BE-A31E-42FD-AF6A-68DDF3B4A1B7@clickspace.com> + <1146595755.12053.111.camel@archimedes> + <758B0591-3C9C-418B-9AF2-E962003C4904@rackspace.com> + <20060502215329.GI97354@pervasive.com> + <4A7F9950-65E0-4FA5-9FEC-BA1A93E615E5@clickspace.com> + <20060503121847.GN31328@mathom.us> + <30D5959B-3CCD-4CB4-B2D7-30DEA9F08BB6@torgo.978.org> +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-5-854846423; + protocol="application/pkcs7-signature" +Message-Id: +From: Vivek Khera +Subject: Re: Slow restoration question +Date: Wed, 3 May 2006 10:16:10 -0400 +To: Pgsql performance +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/83 +X-Sequence-Number: 18870 + + +--Apple-Mail-5-854846423 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + + +On May 3, 2006, at 9:19 AM, Jeff Trout wrote: + +> Bonnie++ is able to use very large datasets. It also tries to +> figure out hte size you want (2x ram) - the original bonnie is +> limited to 2GB. + +but you have to be careful building bonnie++ since it has bad +assumptions about which systems can do large files... eg, on FreeBSD +it doesn't try large files unless you patch it appropriately (which +the freebsd port does for you). + + +--Apple-Mail-5-854846423 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGlDCCAz8w +ggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0 +ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcx +KDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1RoYXd0 +ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVyc29uYWwtZnJlZW1haWxA +dGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5NTlaMGIxCzAJBgNVBAYTAlpB +MSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUg +UGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA +xKY8VXNV+065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/Uc4B1OVQCjDXAmNaLIkVcI7d +yfArhVqqP3FWy688Cwfn8R+RNiQqE88r1fOCdz0Dviv+uxg+B79AgAJk16emu59l0cUqVIUPSAR/ +p7bRPGEEQB5kGXJgt/sCAwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/AgEAMEMGA1UdHwQ8MDow +OKA2oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25hbEZyZWVtYWlsQ0EuY3Js +MAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRUHJpdmF0ZUxhYmVsMi0xMzgw +DQYJKoZIhvcNAQEFBQADgYEASIzRUIPqCy7MDaNmrGcPf6+svsIXoUOWlJ1/TCG4+DYfqi2fNi/A +9BxQIJNwPP2t4WFiw9k6GX6EsZkbAMUaC4J0niVQlGLH2ydxVyWN3amcOY6MIE9lX5Xa9/eH1sYI +Tq726jTlEBpbNU1341YheILcIRk13iSx0x1G/11fZU8wggNNMIICtqADAgECAhA6sDoA4m3lcimf +yUtGSQgmMA0GCSqGSIb3DQEBBAUAMGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29u +c3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNz +dWluZyBDQTAeFw0wNjA1MDIxNDEyNDdaFw0wNzA1MDIxNDEyNDdaMIGKMR8wHQYDVQQDExZUaGF3 +dGUgRnJlZW1haWwgTWVtYmVyMR4wHAYJKoZIhvcNAQkBFg92aXZla0BraGVyYS5vcmcxIDAeBgkq +hkiG9w0BCQEWEWtoZXJhQGtjaWxpbmsuY29tMSUwIwYJKoZIhvcNAQkBFhZ2aXZla0BtYWlsZXJt +YWlsZXIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq+zHKYq9vZ4Dq1itNqT/ +OeJvWDvQ5JdQlRzwsJlvtJBknXsnOaJNabmjnu2s6XFMcP2srBZQ/WPvhsClajLQOcxnarrfB66N +DpMzXTxfYzX6m9TA/fEn64sNn+YnBZL6Dvid9kiAgP9LmqcTOIFdWUya3ZmQS5YTuLB+tkFSL8/h ++inDPN6dcsna8TcM1SAk+3upxOR7kyFM9T3vy25w62Nh1zK7Stp0vUZLU6GzzC1VvHGZHKGticD6 +o3uHaMr2LCFjptoIcfZL75LO/UaR9o7smgboW4yJyW5g9ZasyYQUXyvkitfyZuVWATb8ZSHOkjWJ +872Pyf5+HOevVUI0aQIDAQABo1cwVTBFBgNVHREEPjA8gQ92aXZla0BraGVyYS5vcmeBEWtoZXJh +QGtjaWxpbmsuY29tgRZ2aXZla0BtYWlsZXJtYWlsZXIuY29tMAwGA1UdEwEB/wQCMAAwDQYJKoZI +hvcNAQEEBQADgYEAYpaFKDj47pTQIUQi28MgtjKophopv4QJjvspXmy0qxd8t/M/zc7HuBy3i/9a +PrXDgKyNBzzlFTasTazAY53ntVpqw9k1NOeHmH6o3j/DBVa49bC6bbWfp9UGOwYChlDR0tngQZyC +MDMZEdYv4zpGfBTku5m1jb8Yz/qYqV4FWB4xggMQMIIDDAIBATB2MGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIQOrA6AOJt5XIpn8lLRkkIJjAJBgUrDgMCGgUAoIIB +bzAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjA1MDMxNDE2MTFa +MCMGCSqGSIb3DQEJBDEWBBRhRcTw9dOTq84SyiWRi3Wb+u7BrjCBhQYJKwYBBAGCNxAEMXgwdjBi +MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoG +A1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECEDqwOgDibeVyKZ/JS0ZJ +CCYwgYcGCyqGSIb3DQEJEAILMXigdjBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENv +bnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElz +c3VpbmcgQ0ECEDqwOgDibeVyKZ/JS0ZJCCYwDQYJKoZIhvcNAQEBBQAEggEAiRTWTzKsKFMFu7ER +dpB5nELy9jprmbe9IqS6FLGqckZNYD2kwGHLHCBYgZ/WlzarUrkOexeWtbF71TJhdqtliTDdiM5P +iYSdwQ7UomETrCoVA2RLMZEAZD44b/T6LEAoG3jBBSpI0XFZmI1OJF8rMqnWF7yWylpJevoVL/QE +Nb9qe36wKRLo9gdwg+AJb7heBCd52yJqZAwZbprSD+kMuOLbdQVdBB09s2X0gyouJiUkWj6W90/f +ZaL4NIVuDszg7tnJCzksjm1hxXC2ZaeDopj3wLEB6VjeuPGMXGofP+ozeJgtdVPzBg3aPmJDDCrF +lCs+tZbDTHbjW5laTV3BZQAAAAAAAA== + +--Apple-Mail-5-854846423-- + +From pgsql-performance-owner@postgresql.org Wed May 3 11:47:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7C5FD9FA2A1 + for ; + Wed, 3 May 2006 11:47:04 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27559-04 + for ; + Wed, 3 May 2006 11:46:54 -0300 (ADT) +X-Greylist: delayed 01:26:57.027945 by SQLgrey- +Received: from insiderscore.com (mail01.insiderscore.com [69.84.139.233]) + by postgresql.org (Postfix) with ESMTP id 740409F9C9E + for ; + Wed, 3 May 2006 11:46:54 -0300 (ADT) +Received: from [10.10.10.105] (pool-71-248-161-225.bstnma.fios.verizon.net + [71.248.161.225]) + by insiderscore.com (Postfix) with ESMTP id 94D6B11C4245; + Wed, 3 May 2006 10:46:52 -0400 (EDT) +In-Reply-To: +References: <444F24E9.2010907@lisasoft.com> + <20060502171617.GZ97354@pervasive.com> + <622925BE-A31E-42FD-AF6A-68DDF3B4A1B7@clickspace.com> + <1146595755.12053.111.camel@archimedes> + <758B0591-3C9C-418B-9AF2-E962003C4904@rackspace.com> + <20060502215329.GI97354@pervasive.com> + <4A7F9950-65E0-4FA5-9FEC-BA1A93E615E5@clickspace.com> + <20060503121847.GN31328@mathom.us> + <30D5959B-3CCD-4CB4-B2D7-30DEA9F08BB6@torgo.978.org> + +Mime-Version: 1.0 (Apple Message framework v746.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <1DC4DE4C-4693-4157-A22D-E126E225FFAD@torgo.978.org> +Cc: Pgsql performance +Content-Transfer-Encoding: 7bit +From: Jeff Trout +Subject: Re: Slow restoration question +Date: Wed, 3 May 2006 10:46:51 -0400 +To: Vivek Khera +X-Mailer: Apple Mail (2.746.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/84 +X-Sequence-Number: 18871 + + +On May 3, 2006, at 10:16 AM, Vivek Khera wrote: + +> +> On May 3, 2006, at 9:19 AM, Jeff Trout wrote: +> +>> Bonnie++ is able to use very large datasets. It also tries to +>> figure out hte size you want (2x ram) - the original bonnie is +>> limited to 2GB. +> +> but you have to be careful building bonnie++ since it has bad +> assumptions about which systems can do large files... eg, on +> FreeBSD it doesn't try large files unless you patch it +> appropriately (which the freebsd port does for you). +> + +On platforms it thinks can't use large files it uses multiple sets of +2GB files. (Sort of like our beloved PG) +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + + +From pgsql-performance-owner@postgresql.org Wed May 3 12:20:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AD9869F9AD3 + for ; + Wed, 3 May 2006 12:20:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 03223-03 + for ; + Wed, 3 May 2006 12:20:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id 5B4119F96B6 + for ; + Wed, 3 May 2006 12:20:36 -0300 (ADT) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [67.90.96.2] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 89293437; Wed, 03 May 2006 08:20:35 -0700 +From: "Dave Dutcher" +To: "'Mario Splivalo'" , + +Subject: Re: Lot'sa joins - performance tip-up, please? +Date: Wed, 3 May 2006 10:20:35 -0500 +Message-ID: <003001c66ec5$205a0160$8300a8c0@tridecap.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.2627 +In-Reply-To: <1146533274.14006.11.camel@localhost.localdomain> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +Importance: Normal +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/85 +X-Sequence-Number: 18872 + + +> -> Nested Loop (cost=0.00..176144.30 rows=57925 width=26) +> (actual time=68.322..529472.026 rows=57925 loops=1) +> -> Seq Scan on ticketing_codes_played +> (cost=0.00..863.25 rows=57925 width=8) (actual time=0.042..473.881 +> rows=57925 loops=1) +> -> Index Scan using ticketing_codes_pk on +> ticketing_codes (cost=0.00..3.01 rows=1 width=18) (actual +> time=9.102..9.108 rows=1 loops=57925) +> Index Cond: (ticketing_codes.code_id = +> "outer".code_id) +> Total runtime: 542000.093 ms +> (27 rows) +> +> +> I'll be more than happy to provide any additional information +> that I may +> be able to gather. I'd be most happy if someone would scream something +> like "four joins, smells like a poor design" because design +> is poor, but +> the system is in production, and I have to bare with it. + + +It looks like that nested loop which is joining ticketing_codes_played +to ticketing_codes is the slow part. I'm curious how many rows are in +the ticketing_codes table? + +Four or five joins does not seem like a lot to me, but it can be slow if +you are joining big tables with other big tables. + + +From pgsql-performance-owner@postgresql.org Wed May 3 13:02:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9F5019FA372 + for ; + Wed, 3 May 2006 13:02:51 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 44750-04 + for ; + Wed, 3 May 2006 13:02:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms040pub.verizon.net (vms040pub.verizon.net [206.46.252.40]) + by postgresql.org (Postfix) with ESMTP id E7A289F9CC1 + for ; + Wed, 3 May 2006 13:02:09 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYP00GE65RKYQL0@vms040.mailsrvcs.net> for + pgsql-performance@postgresql.org; Wed, 03 May 2006 10:59:45 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id EFA376EC9D; Wed, + 03 May 2006 11:59:40 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 15813-03-3; Wed, 03 May 2006 11:59:40 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 39A6B6ECBE; Wed, 03 May 2006 11:59:40 -0400 (EDT) +Date: Wed, 03 May 2006 11:59:39 -0400 +From: Michael Stone +Subject: Re: Slow restoration question +In-reply-to: <30D5959B-3CCD-4CB4-B2D7-30DEA9F08BB6@torgo.978.org> +To: Jeff Trout +Cc: pgsql-performance@postgresql.org +Mail-followup-to: Jeff Trout , + pgsql-performance@postgresql.org +Message-id: <20060503155938.GO31328@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <444F24E9.2010907@lisasoft.com> + <20060502171617.GZ97354@pervasive.com> + <622925BE-A31E-42FD-AF6A-68DDF3B4A1B7@clickspace.com> + <1146595755.12053.111.camel@archimedes> + <758B0591-3C9C-418B-9AF2-E962003C4904@rackspace.com> + <20060502215329.GI97354@pervasive.com> + <4A7F9950-65E0-4FA5-9FEC-BA1A93E615E5@clickspace.com> + <20060503121847.GN31328@mathom.us> + <30D5959B-3CCD-4CB4-B2D7-30DEA9F08BB6@torgo.978.org> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/86 +X-Sequence-Number: 18873 + +On Wed, May 03, 2006 at 09:19:52AM -0400, Jeff Trout wrote: +>Bonnie++ is able to use very large datasets. It also tries to figure +>out hte size you want (2x ram) - the original bonnie is limited to 2GB. + +Yes, and once you get into large datasets like that the quality of the +data is fairly poor because the program can't really eliminate cache +effects. IOW, it tries but (in my experience) doesn't succeed very well. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Wed May 3 13:07:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F06F79FA372 + for ; + Wed, 3 May 2006 13:07:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 78682-04 + for ; + Wed, 3 May 2006 13:07:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 51F829F9C10 + for ; + Wed, 3 May 2006 13:07:16 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 3 May 2006 16:07:15 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 03 May 2006 11:07:15 -0500 +Subject: Re: Slow restoration question +From: Scott Marlowe +To: Michael Stone +Cc: Jeff Trout , pgsql-performance@postgresql.org +In-Reply-To: <20060503155938.GO31328@mathom.us> +References: <444F24E9.2010907@lisasoft.com> + <20060502171617.GZ97354@pervasive.com> + <622925BE-A31E-42FD-AF6A-68DDF3B4A1B7@clickspace.com> + <1146595755.12053.111.camel@archimedes> + <758B0591-3C9C-418B-9AF2-E962003C4904@rackspace.com> + <20060502215329.GI97354@pervasive.com> + <4A7F9950-65E0-4FA5-9FEC-BA1A93E615E5@clickspace.com> + <20060503121847.GN31328@mathom.us> + <30D5959B-3CCD-4CB4-B2D7-30DEA9F08BB6@torgo.978.org> + <20060503155938.GO31328@mathom.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1146672434.22037.38.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 03 May 2006 11:07:15 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/87 +X-Sequence-Number: 18874 + +On Wed, 2006-05-03 at 10:59, Michael Stone wrote: +> On Wed, May 03, 2006 at 09:19:52AM -0400, Jeff Trout wrote: +> >Bonnie++ is able to use very large datasets. It also tries to figure +> >out hte size you want (2x ram) - the original bonnie is limited to 2GB. +> +> Yes, and once you get into large datasets like that the quality of the +> data is fairly poor because the program can't really eliminate cache +> effects. IOW, it tries but (in my experience) doesn't succeed very well. + +I have often used the mem=xxx arguments to lilo when needing to limit +the amount of memory for testing purposes. Just google for limit memory +and your bootloader to find the options. + +From pgsql-performance-owner@postgresql.org Wed May 3 14:06:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 906F19F9C1D + for ; + Wed, 3 May 2006 14:06:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 90814-04 + for ; + Wed, 3 May 2006 14:06:11 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms046pub.verizon.net (vms046pub.verizon.net [206.46.252.46]) + by postgresql.org (Postfix) with ESMTP id 2A1E79F9CC1 + for ; + Wed, 3 May 2006 14:06:10 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYP00HPI8U8R1KL@vms046.mailsrvcs.net> for + pgsql-performance@postgresql.org; Wed, 03 May 2006 12:06:09 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id ECCED6EC9D for + ; + Wed, 03 May 2006 13:06:06 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 16233-05-5 for ; Wed, + 03 May 2006 13:06:06 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 4487A6ECBE; Wed, 03 May 2006 13:06:06 -0400 (EDT) +Date: Wed, 03 May 2006 13:06:06 -0400 +From: Michael Stone +Subject: Re: Slow restoration question +In-reply-to: <1146672434.22037.38.camel@state.g2switchworks.com> +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060503170604.GP31328@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <20060502171617.GZ97354@pervasive.com> + <622925BE-A31E-42FD-AF6A-68DDF3B4A1B7@clickspace.com> + <1146595755.12053.111.camel@archimedes> + <758B0591-3C9C-418B-9AF2-E962003C4904@rackspace.com> + <20060502215329.GI97354@pervasive.com> + <4A7F9950-65E0-4FA5-9FEC-BA1A93E615E5@clickspace.com> + <20060503121847.GN31328@mathom.us> + <30D5959B-3CCD-4CB4-B2D7-30DEA9F08BB6@torgo.978.org> + <20060503155938.GO31328@mathom.us> + <1146672434.22037.38.camel@state.g2switchworks.com> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/88 +X-Sequence-Number: 18875 + +On Wed, May 03, 2006 at 11:07:15AM -0500, Scott Marlowe wrote: +>I have often used the mem=xxx arguments to lilo when needing to limit +>the amount of memory for testing purposes. Just google for limit memory +>and your bootloader to find the options. + +Or, just don't worry about it. Even if you get bonnie to reflect real +numbers, so what? In general the goal is to optimize application +performance, not bonnie performance. A simple set of dd's is enough to +give you a rough idea of disk performance, beyond that you really need +to see how your disk is performing with your actual workload. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Wed May 3 14:54:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E90C49F9CC1 + for ; + Wed, 3 May 2006 14:54:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 99496-03 + for ; + Wed, 3 May 2006 14:54:06 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from py-out-1112.google.com (pproxy.gmail.com [64.233.166.183]) + by postgresql.org (Postfix) with ESMTP id 6A0F89F9C1D + for ; + Wed, 3 May 2006 14:54:06 -0300 (ADT) +Received: by py-out-1112.google.com with SMTP id b29so274545pya + for ; + Wed, 03 May 2006 10:54:05 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=bx7XweaAxaJ2bDCqTdLIMhQEIhEj4Zu2LrxPSw60lFBFqu19LmQoLYhXKCbfv6lJjV8AQb2qNIxfwWf/3P3rDlQUF/KcJrMJd100YOAupUnk196zsJ3spGgi8zOdlUB5a0r7HFvb7iqag4zedp2HzLKgiG1YwDe8GbzlsLXUenI= +Received: by 10.35.9.2 with SMTP id m2mr73147pyi; + Wed, 03 May 2006 10:54:05 -0700 (PDT) +Received: by 10.35.45.14 with HTTP; Wed, 3 May 2006 10:54:04 -0700 (PDT) +Message-ID: +Date: Wed, 3 May 2006 10:54:04 -0700 +From: "Ian Burrell" +To: "Tom Lane" +Subject: Re: Nested loop join and date range query +Cc: pgsql-performance@postgresql.org +In-Reply-To: <9688.1146625437@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8; format=flowed +Content-Transfer-Encoding: base64 +Content-Disposition: inline +References: + <9688.1146625437@sss.pgh.pa.us> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/89 +X-Sequence-Number: 18876 + +T24gNS8yLzA2LCBUb20gTGFuZSA8dGdsQHNzcy5wZ2gucGEudXM+IHdyb3RlOgo+ICJJYW4gQnVy +cmVsbCIgPGlhbmJ1cnJlbGxAZ21haWwuY29tPiB3cml0ZXM6Cj4gPiBXZSByZWNlbnRseSB1cGdy +YWRlZCB0byBQb3N0Z3JlU1FMIDguMSBmcm9tIDcuNCBhbmQgYSBmZXcgcXVlcmllcyBhcmUKPiA+ +IGhhdmluZyBwZXJmb3JtYW5jZSBwcm9ibGVtcyBhbmQgcnVubmluZyBmb3IgdmVyeSBsb25nIHRp +bWVzLiAgVGhlCj4gPiBjb21tb25hbGl0eSBzZWVtcyB0byBiZSBQb3N0Z3JlU1FMIDguMSBpcyBj +aG9vc2luZyB0byB1c2UgYSBuZXN0ZWQKPiA+IGxvb3Agam9pbiBiZWNhdXNlIGl0IGVzdGltYXRl +cyB0aGVyZSB3aWxsIGJlIG9ubHkgYmUgYSBzaW5nbGUgcm93Lgo+Cj4gV2UndmUgYWxyZWFkeSBu +b3RlZCB0aGF0IHRoZXJlJ3MgYSBwcm9ibGVtIHdpdGggZXN0aW1hdGluZyB6ZXJvLXdpZHRoCj4g +cmFuZ2VzICh0b28gbGF6eSB0byBzZWFyY2ggdGhlIGFyY2hpdmVzLCBidXQgdGhpcyBoYXMgY29t +ZSB1cCBhdCBsZWFzdAo+IHR3aWNlIHJlY2VudGx5KS4gIENhbiB5b3UgbW9kaWZ5IHlvdXIgYXBw +IHRvIGdlbmVyYXRlIHNvbWV0aGluZyBsaWtlCj4KPiAgICAgICAgIHdlZWsgPj0geCBhbmQgd2Vl +ayA8IHgrMQo+Cj4gaW5zdGVhZCBvZgo+Cj4gICAgICAgICB3ZWVrID49IHggYW5kIHdlZWsgPD0g +eAo+CgpJIGFtIHdvcmtpbmcgb24gbW9kaWZ5aW5nIHRoZSBTUUwgZ2VuZXJhdGlvbiBjb2RlIHRv +IHJlcGxhY2UgdGhlCnplcm8td2lkdGggcmFuZ2Ugd2l0aCBhbiBlcXVhbHMuCgpEb2VzIEJFVFdF +RU4gaGF2ZSB0aGUgc2FtZSBidWc/Cgo+ID8gIE15IHJlY29sbGVjdGlvbiBpcyB0aGF0IHRoZSBm +aXggd2lsbCBwcm9iYWJseSBiZSBjb21wbGljYXRlZAo+IGVub3VnaCB0byBub3QgZ2V0IGJhY2st +cGF0Y2hlZCBpbnRvIDguMS4KPgo+IEJUVywgQUZBSUsgdGhlIHNhbWUgcHJvYmxlbSBleGlzdHMg +aW4gNy40LiAgV2hhdCBraW5kIG9mIGVzdGltYXRlcy9wbGFucwo+IHdlcmUgeW91IGdldHRpbmcg +Zm9yIHRoaXMgY2FzZSBpbiA3LjQ/Cj4KCldlIGdldCBzaW1pbGFyIHJvd3M9MSBlc3RpbWF0ZXMg +b24gNy40LiAgNy40IGRvZXNuJ3QgY2hvb3NlIHRvIHVzZSB0aGUKbmVzdGVkIGxvb3Agam9pbnMg +c28gaXQgcGVyZm9ybXMgZmluZS4KCldlIGhhdmUgYmVlbiBnZXR0aW5nIHNpbWlsYXIgcm93cz0x +IGVzdGltYXRlcyBhbmQgbmVzdGVkIGxvb3Agam9pbnMKd2l0aCBzb21lIG90aGVyIHF1ZXJpZXMu +IEJ1dCBJIHRoaW5rIHRob3NlIGFyZSBjYXVzZWQgYnkgbm90CmZyZXF1ZW50bHkgYW5hbHl6aW5n +IGxvZyB0eXBlIHRhYmxlcyBhbmQgdGhlbiBzZWFyY2hpbmcgZm9yIHJlY2VudApkYXlzIHdoaWNo +IGl0IGRvZXNuJ3QgdGhpbmsgZXhpc3QuCgogLSBJYW4K + +From pgsql-performance-owner@postgresql.org Wed May 3 14:58:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E5E399F9C1D + for ; + Wed, 3 May 2006 14:58:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 82051-05 + for ; + Wed, 3 May 2006 14:58:44 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 276E59FA195 + for ; + Wed, 3 May 2006 14:58:43 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k43HwbSS017794; + Wed, 3 May 2006 13:58:37 -0400 (EDT) +To: Mario Splivalo +cc: pgsql-performance@postgresql.org +Subject: Re: Lot'sa joins - performance tip-up, please? +In-reply-to: <1146533274.14006.11.camel@localhost.localdomain> +References: <1146533274.14006.11.camel@localhost.localdomain> +Comments: In-reply-to Mario Splivalo + message dated "Tue, 02 May 2006 03:27:54 +0200" +Date: Wed, 03 May 2006 13:58:37 -0400 +Message-ID: <17793.1146679117@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/90 +X-Sequence-Number: 18877 + +Mario Splivalo writes: +> I have a quite large query that takes over a minute to run on my laptop. + +The EXPLAIN output you provided doesn't seem to agree with the stated +query. Where'd the "service_id = 1102" condition come from? + +In general, I'd suggest playing around with the join order. Existing +releases of PG tend to throw up their hands when faced with a mixture of +outer joins and regular joins, and just join the tables in the order +listed. 8.2 will be smarter about this, but for now you have to do it +by hand ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed May 3 15:08:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0A7A99F9CC1 + for ; + Wed, 3 May 2006 15:08:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 88233-01 + for ; + Wed, 3 May 2006 15:08:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 7CE789F9C1D + for ; + Wed, 3 May 2006 15:08:23 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id BBB3656435; Wed, 3 May 2006 13:08:22 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Wed, 3 May 2006 13:08:21 -0500 +Date: Wed, 3 May 2006 13:08:21 -0500 +From: "Jim C. Nasby" +To: pgsql-performance@postgresql.org +Subject: Re: Slow restoration question +Message-ID: <20060503180821.GZ97354@pervasive.com> +References: <622925BE-A31E-42FD-AF6A-68DDF3B4A1B7@clickspace.com> + <1146595755.12053.111.camel@archimedes> + <758B0591-3C9C-418B-9AF2-E962003C4904@rackspace.com> + <20060502215329.GI97354@pervasive.com> + <4A7F9950-65E0-4FA5-9FEC-BA1A93E615E5@clickspace.com> + <20060503121847.GN31328@mathom.us> + <30D5959B-3CCD-4CB4-B2D7-30DEA9F08BB6@torgo.978.org> + <20060503155938.GO31328@mathom.us> + <1146672434.22037.38.camel@state.g2switchworks.com> + <20060503170604.GP31328@mathom.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060503170604.GP31328@mathom.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060503:pgsql-performance@postgresql.org::tnx6cwDThb/cJOQk:00000 + 000000000000000000000000CMwE +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/91 +X-Sequence-Number: 18878 + +On Wed, May 03, 2006 at 01:06:06PM -0400, Michael Stone wrote: +> On Wed, May 03, 2006 at 11:07:15AM -0500, Scott Marlowe wrote: +> >I have often used the mem=xxx arguments to lilo when needing to limit +> >the amount of memory for testing purposes. Just google for limit memory +> >and your bootloader to find the options. +> +> Or, just don't worry about it. Even if you get bonnie to reflect real +> numbers, so what? In general the goal is to optimize application +> performance, not bonnie performance. A simple set of dd's is enough to +> give you a rough idea of disk performance, beyond that you really need +> to see how your disk is performing with your actual workload. + +Well, in this case the question was about random write access, which dd +won't show you. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 3 16:27:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0F1B59F9C1D + for ; + Wed, 3 May 2006 16:27:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 61028-03 + for ; + Wed, 3 May 2006 16:27:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms040pub.verizon.net (vms040pub.verizon.net [206.46.252.40]) + by postgresql.org (Postfix) with ESMTP id 4DB159F9CC1 + for ; + Wed, 3 May 2006 16:26:58 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYP00JKBFCWWJVB@vms040.mailsrvcs.net> for + pgsql-performance@postgresql.org; Wed, 03 May 2006 14:26:57 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 3A4586EC9D; Wed, + 03 May 2006 15:26:55 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 17280-02-5; Wed, 03 May 2006 15:26:54 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 7F2C66ECBE; Wed, 03 May 2006 15:26:54 -0400 (EDT) +Date: Wed, 03 May 2006 15:26:54 -0400 +From: Michael Stone +Subject: Re: Slow restoration question +In-reply-to: <20060503180821.GZ97354@pervasive.com> +To: "Jim C. Nasby" +Cc: pgsql-performance@postgresql.org +Mail-followup-to: "Jim C. Nasby" , + pgsql-performance@postgresql.org +Message-id: <20060503192652.GA16533@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <1146595755.12053.111.camel@archimedes> + <758B0591-3C9C-418B-9AF2-E962003C4904@rackspace.com> + <20060502215329.GI97354@pervasive.com> + <4A7F9950-65E0-4FA5-9FEC-BA1A93E615E5@clickspace.com> + <20060503121847.GN31328@mathom.us> + <30D5959B-3CCD-4CB4-B2D7-30DEA9F08BB6@torgo.978.org> + <20060503155938.GO31328@mathom.us> + <1146672434.22037.38.camel@state.g2switchworks.com> + <20060503170604.GP31328@mathom.us> + <20060503180821.GZ97354@pervasive.com> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/92 +X-Sequence-Number: 18879 + +On Wed, May 03, 2006 at 01:08:21PM -0500, Jim C. Nasby wrote: +>Well, in this case the question was about random write access, which dd +>won't show you. + +That's the kind of thing you need to measure against your workload. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Wed May 3 16:40:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C5EC59FA195 + for ; + Wed, 3 May 2006 16:40:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 62074-05 + for ; + Wed, 3 May 2006 16:40:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 689219F9CC1 + for ; + Wed, 3 May 2006 16:40:16 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 3 May 2006 19:40:15 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 03 May 2006 14:40:15 -0500 +Subject: Re: Slow restoration question +From: Scott Marlowe +To: Michael Stone +Cc: "Jim C. Nasby" , pgsql-performance@postgresql.org +In-Reply-To: <20060503192652.GA16533@mathom.us> +References: <1146595755.12053.111.camel@archimedes> + <758B0591-3C9C-418B-9AF2-E962003C4904@rackspace.com> + <20060502215329.GI97354@pervasive.com> + <4A7F9950-65E0-4FA5-9FEC-BA1A93E615E5@clickspace.com> + <20060503121847.GN31328@mathom.us> + <30D5959B-3CCD-4CB4-B2D7-30DEA9F08BB6@torgo.978.org> + <20060503155938.GO31328@mathom.us> + <1146672434.22037.38.camel@state.g2switchworks.com> + <20060503170604.GP31328@mathom.us> + <20060503180821.GZ97354@pervasive.com> + <20060503192652.GA16533@mathom.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1146685215.22037.46.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 03 May 2006 14:40:15 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/93 +X-Sequence-Number: 18880 + +On Wed, 2006-05-03 at 14:26, Michael Stone wrote: +> On Wed, May 03, 2006 at 01:08:21PM -0500, Jim C. Nasby wrote: +> >Well, in this case the question was about random write access, which dd +> >won't show you. +> +> That's the kind of thing you need to measure against your workload. + +Of course, the final benchmarking should be your application. + +But, supposed you're comparing 12 or so RAID controllers for a one week +period, and you don't even have the app fully written yet, and because +of time constraints, you'll need the server ready before the app is +done. You don't need perfection, but you need some idea how the array +performs. I maintain that both methodologies have their uses. + +Note that I'm referring to bonnie++ as was an earlier poster. It +certainly seems capable of giving you a good idea of how your hardware +will behave under load. + +From pgsql-performance-owner@postgresql.org Wed May 3 17:53:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8A6409FA195 + for ; + Wed, 3 May 2006 17:53:24 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 84942-10 + for ; + Wed, 3 May 2006 17:53:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms040pub.verizon.net (vms040pub.verizon.net [206.46.252.40]) + by postgresql.org (Postfix) with ESMTP id 3DC0C9F9C10 + for ; + Wed, 3 May 2006 17:53:12 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYP00GH8JCMZES1@vms040.mailsrvcs.net> for + pgsql-performance@postgresql.org; Wed, 03 May 2006 15:53:11 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id DDFD36E6C0 for + ; + Wed, 03 May 2006 16:53:09 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 17932-03-3 for ; Wed, + 03 May 2006 16:53:09 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id EACD86ECBE; Wed, 03 May 2006 16:53:08 -0400 (EDT) +Date: Wed, 03 May 2006 16:53:08 -0400 +From: Michael Stone +Subject: Re: Slow restoration question +In-reply-to: <1146685215.22037.46.camel@state.g2switchworks.com> +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060503205306.GB16533@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <20060502215329.GI97354@pervasive.com> + <4A7F9950-65E0-4FA5-9FEC-BA1A93E615E5@clickspace.com> + <20060503121847.GN31328@mathom.us> + <30D5959B-3CCD-4CB4-B2D7-30DEA9F08BB6@torgo.978.org> + <20060503155938.GO31328@mathom.us> + <1146672434.22037.38.camel@state.g2switchworks.com> + <20060503170604.GP31328@mathom.us> + <20060503180821.GZ97354@pervasive.com> + <20060503192652.GA16533@mathom.us> + <1146685215.22037.46.camel@state.g2switchworks.com> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/94 +X-Sequence-Number: 18881 + +On Wed, May 03, 2006 at 02:40:15PM -0500, Scott Marlowe wrote: +>Note that I'm referring to bonnie++ as was an earlier poster. It +>certainly seems capable of giving you a good idea of how your hardware +>will behave under load. + +IME it give fairly useless results. YMMV. Definately the numbers posted +before seem bogus. If you have some way to make those figures useful in +your circumstance, great. Too often I see people taking bonnie numbers +at face value and then being surprised that don't relate at all to +real-world performance. If your experience differs, fine. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Wed May 3 18:30:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 53CBA9F9CC1 + for ; + Wed, 3 May 2006 18:30:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 99669-07 + for ; + Wed, 3 May 2006 18:30:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 8869C9F9C1D + for ; + Wed, 3 May 2006 18:30:34 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 3 May 2006 21:30:32 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 03 May 2006 16:30:32 -0500 +Subject: Re: Slow restoration question +From: Scott Marlowe +To: Michael Stone +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060503205306.GB16533@mathom.us> +References: <20060502215329.GI97354@pervasive.com> + <4A7F9950-65E0-4FA5-9FEC-BA1A93E615E5@clickspace.com> + <20060503121847.GN31328@mathom.us> + <30D5959B-3CCD-4CB4-B2D7-30DEA9F08BB6@torgo.978.org> + <20060503155938.GO31328@mathom.us> + <1146672434.22037.38.camel@state.g2switchworks.com> + <20060503170604.GP31328@mathom.us> + <20060503180821.GZ97354@pervasive.com> + <20060503192652.GA16533@mathom.us> + <1146685215.22037.46.camel@state.g2switchworks.com> + <20060503205306.GB16533@mathom.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1146691831.22037.50.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 03 May 2006 16:30:32 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/95 +X-Sequence-Number: 18882 + +On Wed, 2006-05-03 at 15:53, Michael Stone wrote: +> On Wed, May 03, 2006 at 02:40:15PM -0500, Scott Marlowe wrote: +> >Note that I'm referring to bonnie++ as was an earlier poster. It +> >certainly seems capable of giving you a good idea of how your hardware +> >will behave under load. +> +> IME it give fairly useless results. YMMV. Definately the numbers posted +> before seem bogus. If you have some way to make those figures useful in +> your circumstance, great. Too often I see people taking bonnie numbers +> at face value and then being surprised that don't relate at all to +> real-world performance. If your experience differs, fine. + +I think the real problem is that people use the older bonnie that can +only work with smaller datasets on a machine with all the memory +enabled. This will, for certain, give meaningless numbers. + +OTOH, having used bonnie++ on a machine artificially limited to 256 to +512 meg or ram or so, has given me some very useful numbers, especially +if you set the data set size to be several gigabytes. + +Keep in mind, the numbers listed before likely WERE generated on a +machine with plenty of memory using the older bonnie, so those numbers +should be bogus. + +If you've not tried bonnie++ on a limited memory machine, you really +should. It's a quite useful tool for a simple first pass to figure out +which RAID and fs configurations should be tested more thoroughly. + +From pgsql-performance-owner@postgresql.org Wed May 3 19:02:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D9F129FB1CC + for ; + Wed, 3 May 2006 19:01:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 89524-10 + for ; + Wed, 3 May 2006 19:00:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) + by postgresql.org (Postfix) with ESMTP id 7F7A39F9C9E + for ; + Wed, 3 May 2006 19:00:35 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.132.172]) + by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYP00ACAMGX6YF4@vms042.mailsrvcs.net> for + pgsql-performance@postgresql.org; Wed, 03 May 2006 17:00:34 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 2578C6E6C0 for + ; + Wed, 03 May 2006 18:00:32 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id 18396-04-3 for ; Wed, + 03 May 2006 18:00:31 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 6A91B6ECC0; Wed, 03 May 2006 18:00:31 -0400 (EDT) +Date: Wed, 03 May 2006 18:00:30 -0400 +From: Michael Stone +Subject: Re: Slow restoration question +In-reply-to: <1146691831.22037.50.camel@state.g2switchworks.com> +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060503220028.GC16533@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +X-Virus-Scanned: Debian amavisd-new at mathom.us +References: <20060503121847.GN31328@mathom.us> + <30D5959B-3CCD-4CB4-B2D7-30DEA9F08BB6@torgo.978.org> + <20060503155938.GO31328@mathom.us> + <1146672434.22037.38.camel@state.g2switchworks.com> + <20060503170604.GP31328@mathom.us> + <20060503180821.GZ97354@pervasive.com> + <20060503192652.GA16533@mathom.us> + <1146685215.22037.46.camel@state.g2switchworks.com> + <20060503205306.GB16533@mathom.us> + <1146691831.22037.50.camel@state.g2switchworks.com> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/96 +X-Sequence-Number: 18883 + +On Wed, May 03, 2006 at 04:30:32PM -0500, Scott Marlowe wrote: +>If you've not tried bonnie++ on a limited memory machine, you really +>should. + +Yes, I have. I also patched bonnie to handle large files and other such +nifty things before bonnie++ was forked. Mostly I just didn't get much +value out of all that, because at the end of theago day optimizing for +bonnie just doesn't equate to optimizing for real-world workloads. +Again, if it's useful for your workload, great. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Thu May 4 09:28:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3A7099F9B76 + for ; + Thu, 4 May 2006 09:28:02 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 25385-09 + for ; + Thu, 4 May 2006 09:27:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from r1.mycybernet.net (r1.mycybernet.net [209.5.206.8]) + by postgresql.org (Postfix) with ESMTP id EB9A29F946D + for ; + Thu, 4 May 2006 09:27:53 -0300 (ADT) +Received: from 227-54-222-209.mycybernet.net ([209.222.54.227]:49682 + helo=phlogiston.dydns.org) + by r1.mycybernet.net with esmtp (Exim 4.50 (FreeBSD)) + id 1Fbcvw-0006A0-Bi + for pgsql-performance@postgresql.org; Thu, 04 May 2006 08:27:52 -0400 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 8F36D4046; Thu, 4 May 2006 08:27:47 -0400 (EDT) +Date: Thu, 4 May 2006 08:27:47 -0400 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: Postgres 7.4 and vacuum_cost_delay. +Message-ID: <20060504122747.GA21437@phlogiston.dyndns.org> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/97 +X-Sequence-Number: 18884 + +On Tue, May 02, 2006 at 05:47:15PM -0400, Chris Mckenzie wrote: +> I've come to the conclusion I need to simply start tracking all transactions +> and determining a cost/performance for the larger and frequently updated +> tables without the benefit and penalty of pg_statio. + +I'll bet it won't help you. If you can't get off 7.4 on a busy +machine, you're going to get hosed by I/O sometimes no matter what. +My suggestion is to write a bunch of rule-of-thumb rules for your +cron jobs, and start planning your upgrade. + +Jan back-patched the vacuum stuff to 7.4 for us (Afilias), and we +tried playing with it; but it didn't really make the difference we'd +hoped. + +The reason for this is that 7.4 also doesn't have the bg_writer. So +you're still faced with I/O storms, no matter what you do. If I were +in your shoes, I wouldn't waste a lot of time on trying to emulate +the new features in 7.4. + +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 Tue May 9 23:54:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5A1BE9F9AFD + for ; + Thu, 4 May 2006 11:15:42 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 56595-07 + for ; + Thu, 4 May 2006 11:15:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 8049A9F9B76 + for ; + Thu, 4 May 2006 11:15:27 -0300 (ADT) +Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) + by svr4.postgresql.org (Postfix) with ESMTP id 2213D5B681C + for ; + Thu, 4 May 2006 14:15:25 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by pjetlic.mobart.hr (Postfix) with ESMTP id CCD1917D71; + Thu, 4 May 2006 16:15:16 +0200 (CEST) +Received: from pjetlic.mobart.hr ([127.0.0.1]) + by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 10752-01-3; Thu, 4 May 2006 16:15:16 +0200 (CEST) +Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) + by pjetlic.mobart.hr (Postfix) with ESMTP id B3B0717D60; + Thu, 4 May 2006 16:15:16 +0200 (CEST) +Subject: Re: Lot'sa joins - performance tip-up, please? +From: Mario Splivalo +To: Dave Dutcher , + pgsql-performance@postgresql.org +In-Reply-To: <003001c66ec5$205a0160$8300a8c0@tridecap.com> +References: <003001c66ec5$205a0160$8300a8c0@tridecap.com> +Content-Type: text/plain +Date: Thu, 04 May 2006 16:15:13 +0200 +Message-Id: <1146752113.8538.22.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by OpenSource AV+AS Mail Server +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/204 +X-Sequence-Number: 18991 + +On Wed, 2006-05-03 at 10:20 -0500, Dave Dutcher wrote: +> > -> Nested Loop (cost=0.00..176144.30 rows=57925 width=26) +> > (actual time=68.322..529472.026 rows=57925 loops=1) +> > -> Seq Scan on ticketing_codes_played +> > (cost=0.00..863.25 rows=57925 width=8) (actual time=0.042..473.881 +> > rows=57925 loops=1) +> > -> Index Scan using ticketing_codes_pk on +> > ticketing_codes (cost=0.00..3.01 rows=1 width=18) (actual +> > time=9.102..9.108 rows=1 loops=57925) +> > Index Cond: (ticketing_codes.code_id = +> > "outer".code_id) +> > Total runtime: 542000.093 ms +> > (27 rows) +> > +> > +> > I'll be more than happy to provide any additional information +> > that I may +> > be able to gather. I'd be most happy if someone would scream something +> > like "four joins, smells like a poor design" because design +> > is poor, but +> > the system is in production, and I have to bare with it. +> +> +> It looks like that nested loop which is joining ticketing_codes_played +> to ticketing_codes is the slow part. I'm curious how many rows are in +> the ticketing_codes table? +> +> Four or five joins does not seem like a lot to me, but it can be slow if +> you are joining big tables with other big tables. + +Ticketing_codes table has 11000000 records, and it's expected to grow. + +I tried playing with JOIN order as Tom suggested, but performance is the +same. + + Mario + + +From pgsql-performance-owner@postgresql.org Tue May 9 23:54:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 807039F9B76 + for ; + Thu, 4 May 2006 11:46:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 66443-01 + for ; + Thu, 4 May 2006 11:46:02 -0300 (ADT) +X-Greylist: delayed 00:30:37.166256 by SQLgrey- +Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) + by postgresql.org (Postfix) with ESMTP id 7DD849F9AFD + for ; + Thu, 4 May 2006 11:46:01 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by pjetlic.mobart.hr (Postfix) with ESMTP id 7722E17D71; + Thu, 4 May 2006 16:45:59 +0200 (CEST) +Received: from pjetlic.mobart.hr ([127.0.0.1]) + by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 11382-02-3; Thu, 4 May 2006 16:45:59 +0200 (CEST) +Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) + by pjetlic.mobart.hr (Postfix) with ESMTP id 0292C17D60; + Thu, 4 May 2006 16:45:59 +0200 (CEST) +Subject: Re: Lot'sa joins - performance tip-up, please? +From: Mario Splivalo +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <17793.1146679117@sss.pgh.pa.us> +References: <1146533274.14006.11.camel@localhost.localdomain> + <17793.1146679117@sss.pgh.pa.us> +Content-Type: text/plain +Date: Thu, 04 May 2006 16:45:57 +0200 +Message-Id: <1146753957.8538.30.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by OpenSource AV+AS Mail Server +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/205 +X-Sequence-Number: 18992 + +On Wed, 2006-05-03 at 13:58 -0400, Tom Lane wrote: +> Mario Splivalo writes: +> > I have a quite large query that takes over a minute to run on my laptop. +> +> The EXPLAIN output you provided doesn't seem to agree with the stated +> query. Where'd the "service_id = 1102" condition come from? + +I guess I copypasted the additional WHERE to te EXPLAIN ANALYZE query. +This is the correct one, without the WHERE: + + Hash Left Join (cost=198628.35..202770.61 rows=121 width=264) (actual +time=998008.264..999645.322 rows=5706 loops=1) + Hash Cond: ("outer".message_id = "inner".message_id) + -> Merge Left Join (cost=21943.23..21950.96 rows=121 width=238) +(actual time=4375.510..4540.772 rows=5706 loops=1) + Merge Cond: ("outer".message_id = "inner".message_id) + -> Sort (cost=21847.62..21847.92 rows=121 width=230) (actual +time=3304.787..3378.515 rows=5706 loops=1) + Sort Key: messages.id + -> Hash Join (cost=20250.16..21843.43 rows=121 +width=230) (actual time=1617.370..3102.470 rows=5706 loops=1) + Hash Cond: ("outer".message_id = "inner".id) + -> Seq Scan on ticketing_messages +(cost=0.00..1212.37 rows=75937 width=14) (actual time=10.554..609.967 +rows=75937 loops=1) + -> Hash (cost=20244.19..20244.19 rows=2391 +width=216) (actual time=1572.889..1572.889 rows=5706 loops=1) + -> Nested Loop (cost=1519.21..20244.19 +rows=2391 width=216) (actual time=385.582..1449.207 rows=5706 loops=1) + -> Seq Scan on services +(cost=0.00..4.20 rows=3 width=54) (actual time=20.829..20.859 rows=2 +loops=1) + Filter: (type_id = 10) + -> Bitmap Heap Scan on messages +(cost=1519.21..6726.74 rows=1594 width=162) (actual +time=182.346..678.800 rows=2853 loops=2) + Recheck Cond: (("outer".id = +messages.service_id) AND (messages.receiving_time >= '2006-02-12 +00:00:00+01'::timestamp with time zone) AND (messages.receiving_time <= +'2006-03-18 23:00:00+01'::timestamp with time zone)) + -> BitmapAnd +(cost=1519.21..1519.21 rows=1594 width=0) (actual time=164.311..164.311 +rows=0 loops=2) + -> Bitmap Index Scan on +idx_service_id (cost=0.00..84.10 rows=14599 width=0) (actual +time=66.809..66.809 rows=37968 loops=2) + Index Cond: +("outer".id = messages.service_id) + -> Bitmap Index Scan on +idx_messages_receiving_time (cost=0.00..1434.87 rows=164144 width=0) +(actual time=192.633..192.633 rows=184741 loops=1) + Index Cond: +((receiving_time >= '2006-02-12 00:00:00+01'::timestamp with time zone) +AND (receiving_time <= '2006-03-18 23:00:00+01'::timestamp with time +zone)) + -> Sort (cost=95.62..99.17 rows=1421 width=8) (actual +time=1070.678..1072.999 rows=482 loops=1) + Sort Key: ticketing_winners.message_id + -> Seq Scan on ticketing_winners (cost=0.00..21.21 +rows=1421 width=8) (actual time=424.836..1061.834 rows=1421 loops=1) + -> Hash (cost=176144.30..176144.30 rows=57925 width=26) (actual +time=993592.980..993592.980 rows=57925 loops=1) + -> Nested Loop (cost=0.00..176144.30 rows=57925 width=26) +(actual time=1074.984..992536.243 rows=57925 loops=1) + -> Seq Scan on ticketing_codes_played +(cost=0.00..863.25 rows=57925 width=8) (actual time=74.479..2047.993 +rows=57925 loops=1) + -> Index Scan using ticketing_codes_pk on +ticketing_codes (cost=0.00..3.01 rows=1 width=18) (actual +time=17.044..17.052 rows=1 loops=57925) + Index Cond: (ticketing_codes.code_id = +"outer".code_id) + Total runtime: 999778.981 ms + + +> In general, I'd suggest playing around with the join order. Existing +> releases of PG tend to throw up their hands when faced with a mixture of +> outer joins and regular joins, and just join the tables in the order +> listed. 8.2 will be smarter about this, but for now you have to do it +> by hand ... + +No luck for me there. But, I found out that if I first do join on +ticketing_codes and ticketing_codes_played, put the result to temporary +table, and then join that temporary table with the rest of the query +(the SELECT that is in parenthesis is transfered to a temporary table) +the query is almost twice as fast. + +As mentioned before, ticketing_codes has 11000000 records. + + Mario + +P.S. Is it just me, or posting to psql-perofrmance is laged, quite a +bit? + + +From pgsql-performance-owner@postgresql.org Thu May 4 11:49:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4F73F9FB1C7 + for ; + Thu, 4 May 2006 11:49:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 62947-07 + for ; + Thu, 4 May 2006 11:49:15 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id CFA239F9AFD + for ; + Thu, 4 May 2006 11:49:15 -0300 (ADT) +Received: from sottsym2.entrust.com (sottsym2.entrust.com [216.191.252.20]) + by svr4.postgresql.org (Postfix) with ESMTP id A03555B3CB2 + for ; + Thu, 4 May 2006 14:49:12 +0000 (GMT) +Received: from sottmxsecs3.entrust.com (unknown [216.191.252.14]) + by sottsym2.entrust.com (Symantec Mail Security) with SMTP id 5817C135D + for ; + Thu, 4 May 2006 10:49:07 -0400 (EDT) +Received: (qmail 7032 invoked from network); 4 May 2006 14:49:06 -0000 +Received: from Chris.McKenzie@entrust.com by sottmxsecs3.entrust.com with + EntrustECS-Server-7.4; 04 May 2006 14:49:06 -0000 +Received: from sottmxs00.entrust.com (10.4.61.22) + by sottmxsecs3.entrust.com with SMTP; 4 May 2006 14:49:06 -0000 +Received: by sottmxs00.entrust.com with Internet Mail Service (5.5.2657.72) + id <2PT1CGAY>; Thu, 4 May 2006 10:49:06 -0400 +Message-ID: +From: Chris Mckenzie +To: 'Andrew Sullivan' , pgsql-performance@postgresql.org +Subject: Re: Postgres 7.4 and vacuum_cost_delay. +Date: Thu, 4 May 2006 10:49:06 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C66F89.E4CC6FE6" +X-Brightmail-Tracker: AAAAAA== +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/98 +X-Sequence-Number: 18885 + + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C66F89.E4CC6FE6 +Content-Type: text/plain + +Hey, thanks for the advice. + +Sticking with 7.4 isn't my call. There's a lot wrapped up in common usage of +Postgres 7.4 and I could never rally everyone into moving forward. (at least +not this year) + +I've yet to prove (due to my current lack of statistical evidence) that our +usage of 7.4 results in frequent vacuums impacting access. (it get more +difficult to speculate when considering a large slony cluster) I'm hoping to +gather some times and numbers on an internal dogfood of our product shortly. + +Any advice on tracking vacuum performance and impact? I was thinking of just +system timing the vacuumdb calls and turning on verbose for per-table/index +stats. Do you think that's enough info? + +Once I vacuum I won't be able to re-test any fragmentation that the vacuum +cleaned up, so its all or nothing for this test. + +Thanks again. + +- Chris + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Andrew Sullivan +Sent: Thursday, May 04, 2006 8:28 AM +To: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Postgres 7.4 and vacuum_cost_delay. + + +On Tue, May 02, 2006 at 05:47:15PM -0400, Chris Mckenzie wrote: +> I've come to the conclusion I need to simply start tracking all +> transactions and determining a cost/performance for the larger and +> frequently updated tables without the benefit and penalty of +> pg_statio. + +I'll bet it won't help you. If you can't get off 7.4 on a busy machine, +you're going to get hosed by I/O sometimes no matter what. +My suggestion is to write a bunch of rule-of-thumb rules for your cron jobs, +and start planning your upgrade. + +Jan back-patched the vacuum stuff to 7.4 for us (Afilias), and we tried +playing with it; but it didn't really make the difference we'd hoped. + +The reason for this is that 7.4 also doesn't have the bg_writer. So you're +still faced with I/O storms, no matter what you do. If I were in your +shoes, I wouldn't waste a lot of time on trying to emulate the new features +in 7.4. + +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 + +---------------------------(end of broadcast)--------------------------- +TIP 2: Don't 'kill -9' the postmaster + +------_=_NextPart_001_01C66F89.E4CC6FE6 +Content-Type: text/html +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] Postgres 7.4 and vacuum_cost_delay. + + + +

Hey, thanks for the advice. +

+ +

Sticking with 7.4 isn't my call. There's a lot = +wrapped up in common usage of Postgres 7.4 and I could never rally = +everyone into moving forward. (at least not this year)

+ +

I've yet to prove (due to my current lack of = +statistical evidence) that our usage of 7.4 results in frequent vacuums = +impacting access. (it get more difficult to speculate when considering = +a large slony cluster) I'm hoping to gather some times and numbers on = +an internal dogfood of our product shortly.

+ +

Any advice on tracking vacuum performance and impact? = +I was thinking of just system timing the vacuumdb calls and turning on = +verbose for per-table/index stats. Do you think that's enough = +info?

+ +

Once I vacuum I won't be able to re-test any = +fragmentation that the vacuum cleaned up, so its all or nothing for = +this test.

+ +

Thanks again. +

+ +

- Chris +

+ +

-----Original Message----- +
From: pgsql-performance-owner@postgresql.org [mailto:pgsql-perf= +ormance-owner@postgresql.org] On Behalf Of Andrew = +Sullivan

+ +

Sent: Thursday, May 04, 2006 8:28 AM +
To: pgsql-performance@postgresql.org +
Subject: Re: [PERFORM] Postgres 7.4 and = +vacuum_cost_delay. +

+
+ +

On Tue, May 02, 2006 at 05:47:15PM -0400, Chris = +Mckenzie wrote: +
> I've come to the conclusion I need to simply = +start tracking all +
> transactions and determining a cost/performance = +for the larger and +
> frequently updated tables without the benefit = +and penalty of +
> pg_statio. +

+ +

I'll bet it won't help you.  If you can't get = +off 7.4 on a busy machine, you're going to get hosed by I/O sometimes = +no matter what.

+ +

My suggestion is to write a bunch of rule-of-thumb = +rules for your cron jobs, and start planning your upgrade. +

+ +

Jan back-patched the vacuum stuff to 7.4 for us = +(Afilias), and we tried playing with it; but it didn't really make the = +difference we'd hoped.

+ +

The reason for this is that 7.4 also doesn't have the = +bg_writer.  So you're still faced with I/O storms, no matter what = +you do.  If I were in your shoes, I wouldn't waste a lot of time = +on trying to emulate the new features in 7.4.

+ +

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.

+ +

          &nb= +sp;     --Brad Holland +

+ +

---------------------------(end of = +broadcast)--------------------------- +
TIP 2: Don't 'kill -9' the postmaster +

+ + + +------_=_NextPart_001_01C66F89.E4CC6FE6-- + +From pgsql-performance-owner@postgresql.org Thu May 4 14:47:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id CC6169FA9BD + for ; + Thu, 4 May 2006 14:47:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 97199-04 + for ; + Thu, 4 May 2006 14:47:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 602DC9FA65C + for ; + Thu, 4 May 2006 14:47:24 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 93F8A56440; Thu, 4 May 2006 12:47:23 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Thu, 4 May 2006 12:47:21 -0500 +Date: Thu, 4 May 2006 12:47:21 -0500 +From: "Jim C. Nasby" +To: Gregory Stewart +Cc: Mark Kirkwood , + pgsql-performance@postgresql.org +Subject: Re: Performance Issues on Opteron Dual Core +Message-ID: <20060504174721.GM97354@pervasive.com> +References: <20060502202837.GC97354@pervasive.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060504:gstewart@sweetdata.com::xKFz70USGbaGsmo/:000000000000000 + 000000000000000000000000B0rj +X-Hashcash: + 1:20:060504:markir@paradise.net.nz::E/r6jNNnoeVlNhsN:000000000000000 + 0000000000000000000000007u3z +X-Hashcash: + 1:20:060504:pgsql-performance@postgresql.org::0BeThgOrqP3dJeLN:00000 + 0000000000000000000000002z70 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/99 +X-Sequence-Number: 18886 + +All the machines I've been able to replicate this on have been SMP w2k3 +machines running SP1. I've been unable to replicate it on anything not +running w2k3, but the only 'SMP' machine I've tested in that manner was +an Intel with HT enabled. I now have an intel with HT and running w2k3 +sitting in my office, but I haven't had a chance to fire it up and try +it yet. Once I test that machine it should help narrow down if this +problem exists with HT machines (which someone on -hackers mentioned +they had access to and could do testing with). If it does affect HT +machines then I suspect that this is not an issue for XP... + +On Tue, May 02, 2006 at 11:27:02PM -0500, Gregory Stewart wrote: +> Jim, +> +> Have you seen this happening only on W2k3? I am wondering if I should try +> out 2000 Pro or XP Pro. +> Not my first choice, but if it works... +> +> +> +> -----Original Message----- +> From: Jim C. Nasby [mailto:jnasby@pervasive.com] +> Sent: Tuesday, May 02, 2006 3:29 PM +> To: Mark Kirkwood +> Cc: Gregory Stewart; pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] Performance Issues on Opteron Dual Core +> +> +> On Sun, Apr 30, 2006 at 10:59:56PM +1200, Mark Kirkwood wrote: +> > Pgadmin can give misleading times for queries that return large result +> > sets over a network, due to: +> > +> > 1/ It takes time to format the (large) result set for display. +> > 2/ It has to count the time spent waiting for the (large) result set to +> > travel across the network. +> > +> > You aren't running Pgadmin off the dev server are you? If not check your +> > network link to dev and prod - is one faster than the other? (etc). +> > +> > To eliminate Pgadmin and the network as factors try wrapping your query +> > in a 'SELECT count(*) FROM (your query here) AS a', and see if it +> > changes anything! +> +> FWIW, I've found problems running PostgreSQL on Windows in a multi-CPU +> environment on w2k3. It runs fine for some period, and then CPU and +> throughput drop to zero. So far I've been unable to track down any more +> information than that, other than the fact that I haven't been able to +> reproduce this on any single-CPU machines. +> -- +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> +> +> -- +> No virus found in this incoming message. +> Checked by AVG Free Edition. +> Version: 7.1.385 / Virus Database: 268.5.1/328 - Release Date: 5/1/2006 +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: 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 +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu May 4 14:49:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 88AD89F9C10 + for ; + Thu, 4 May 2006 14:49:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 96572-05 + for ; + Thu, 4 May 2006 14:49:09 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 1B5B29FA65C + for ; + Thu, 4 May 2006 14:49:09 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 26BC15643A; Thu, 4 May 2006 12:49:08 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Thu, 4 May 2006 12:49:07 -0500 +Date: Thu, 4 May 2006 12:49:07 -0500 +From: "Jim C. Nasby" +To: Magnus Hagander +Cc: Jan de Visser , + pgsql-performance@postgresql.org +Subject: Re: Performance Issues on Opteron Dual Core +Message-ID: <20060504174907.GN97354@pervasive.com> +References: <6BCB9D8A16AC4241919521715F4D8BCEA0F957@algol.sollentuna.se> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6BCB9D8A16AC4241919521715F4D8BCEA0F957@algol.sollentuna.se> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060504:mha@sollentuna.net::Vt29GScQAG/cAcnp:0000000000000000000 + 0000000000000000000000000tHf +X-Hashcash: + 1:20:060504:jdevisser@digitalfairway.com::BI7FBQlsMCsz3nNT:000000000 + 0000000000000000000000002Dj0 +X-Hashcash: + 1:20:060504:pgsql-performance@postgresql.org::GDYPsLqkPFlh/Z5m:00000 + 0000000000000000000000000c21 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/100 +X-Sequence-Number: 18887 + +On Wed, May 03, 2006 at 09:29:15AM +0200, Magnus Hagander wrote: +> > > > FWIW, I've found problems running PostgreSQL on Windows in a +> > > > multi-CPU environment on w2k3. It runs fine for some period, and +> > > > then CPU and throughput drop to zero. So far I've been unable to +> > > > track down any more information than that, other than the +> > fact that +> > > > I haven't been able to reproduce this on any single-CPU machines. +> > > +> > > I have had previous correspondence about this with Magnus (search +> > > -general and -hackers). If you uninstall SP1 the problem +> > goes away. We +> > > played a bit with potential fixes but didn't find any. +> > +> > Interesting; does SP2 fix the problem? Anything we can do +> > over here to help? +> +> There is no SP2 for Windows 2003. +> +> Have you tried this with latest-and-greatest CVS HEAD? Meaning with the +> new semaphore code that was committed a couple of days ago? + +I'd be happy to test this if someone could provide a build, or if +there's instructions somewhere for doing such a build... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu May 4 14:54:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F31E69FA7B6 + for ; + Thu, 4 May 2006 14:54:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 98790-02 + for ; + Thu, 4 May 2006 14:54:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 00DDD9F9C10 + for ; + Thu, 4 May 2006 14:54:00 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id AA67156437; Thu, 4 May 2006 12:53:59 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Thu, 4 May 2006 12:53:59 -0500 +Date: Thu, 4 May 2006 12:53:59 -0500 +From: "Jim C. Nasby" +To: pgsql-performance@postgresql.org +Subject: Re: Why so slow? +Message-ID: <20060504175359.GO97354@pervasive.com> +References: <200604281043.16083@hal.medialogik.com> + + <20060430100346.20f010a9.wmoran@collaborativefusion.com> + <20060502201740.GB97354@pervasive.com> + <20060502192834.6c8e9131.wmoran@collaborativefusion.com> + <20060503112219.GM31328@mathom.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060503112219.GM31328@mathom.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060504:pgsql-performance@postgresql.org::DRJvbApEp51V5a/J:00000 + 00000000000000000000000035M6 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/101 +X-Sequence-Number: 18888 + +On Wed, May 03, 2006 at 07:22:21AM -0400, Michael Stone wrote: +> On Tue, May 02, 2006 at 07:28:34PM -0400, Bill Moran wrote: +> >Reindexing is in a different class than vacuuming. +> +> Kinda, but it is in the same class as vacuum full. If vacuum neglect (or +> dramatic change in usage) has gotten you to the point of 10G of overhead +> on a 2G table you can get a dramatic speedup if you vacuum full, by +> dumping a lot of unused space. But in that case you might have a similar +s/might/will/ +> amount of overhead in indices, which isn't going to go away unless you +> reindex. In either case the unused rows will be reused as needed, but if +> you know you aren't going to need the space again anytime soon you might +> need to vacuum full/reindex. + +You can also do a CLUSTER on the table, which rewrites both the table +and all the indexes from scratch. But there was some kind of issue with +doing that that was fixed in HEAD, but I don't think it's been +back-ported. I also don't remember exactly what the issue was... :/ +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 9 23:54:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9DDAC9FA65C + for ; + Thu, 4 May 2006 17:24:51 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 33748-09 + for ; + Thu, 4 May 2006 17:24:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail4.intermedia.net (mail4.intermedia.net [206.40.48.154]) + by postgresql.org (Postfix) with ESMTP id 878249F9B76 + for ; + Thu, 4 May 2006 17:24:40 -0300 (ADT) +Received: from governor (unverified [67.79.8.2]) by mail4.intermedia.net + (Rockliffe SMTPRA 4.5.6) with ESMTP id + ; Thu, 4 May 2006 13:24:38 -0700 +From: "Gregory Stewart" +To: "Jim C. Nasby" +Cc: "Mark Kirkwood" , + +Subject: Re: Performance Issues on Opteron Dual Core +Date: Thu, 4 May 2006 15:24:37 -0500 +Message-ID: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +Importance: Normal +In-Reply-To: <20060504174721.GM97354@pervasive.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/206 +X-Sequence-Number: 18993 + +I installed Ubuntu 5.10 on the production server (64-Bit version), and sure +enough the peformance is like I expected. Opening up that table (320,000 +records) takes 6 seconds, with CPU usage of one of the cores going up to +90% - 100% for the 6 seconds. +I assume only one core is being used per user / session / query? + +Gregory + + +-----Original Message----- +From: Jim C. Nasby [mailto:jnasby@pervasive.com] +Sent: Thursday, May 04, 2006 12:47 PM +To: Gregory Stewart +Cc: Mark Kirkwood; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Performance Issues on Opteron Dual Core + + +All the machines I've been able to replicate this on have been SMP w2k3 +machines running SP1. I've been unable to replicate it on anything not +running w2k3, but the only 'SMP' machine I've tested in that manner was +an Intel with HT enabled. I now have an intel with HT and running w2k3 +sitting in my office, but I haven't had a chance to fire it up and try +it yet. Once I test that machine it should help narrow down if this +problem exists with HT machines (which someone on -hackers mentioned +they had access to and could do testing with). If it does affect HT +machines then I suspect that this is not an issue for XP... + +On Tue, May 02, 2006 at 11:27:02PM -0500, Gregory Stewart wrote: +> Jim, +> +> Have you seen this happening only on W2k3? I am wondering if I should try +> out 2000 Pro or XP Pro. +> Not my first choice, but if it works... +> +> +> +> -----Original Message----- +> From: Jim C. Nasby [mailto:jnasby@pervasive.com] +> Sent: Tuesday, May 02, 2006 3:29 PM +> To: Mark Kirkwood +> Cc: Gregory Stewart; pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] Performance Issues on Opteron Dual Core +> +> +> On Sun, Apr 30, 2006 at 10:59:56PM +1200, Mark Kirkwood wrote: +> > Pgadmin can give misleading times for queries that return large result +> > sets over a network, due to: +> > +> > 1/ It takes time to format the (large) result set for display. +> > 2/ It has to count the time spent waiting for the (large) result set to +> > travel across the network. +> > +> > You aren't running Pgadmin off the dev server are you? If not check your +> > network link to dev and prod - is one faster than the other? (etc). +> > +> > To eliminate Pgadmin and the network as factors try wrapping your query +> > in a 'SELECT count(*) FROM (your query here) AS a', and see if it +> > changes anything! +> +> FWIW, I've found problems running PostgreSQL on Windows in a multi-CPU +> environment on w2k3. It runs fine for some period, and then CPU and +> throughput drop to zero. So far I've been unable to track down any more +> information than that, other than the fact that I haven't been able to +> reproduce this on any single-CPU machines. +> -- +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> +> +> -- +> No virus found in this incoming message. +> Checked by AVG Free Edition. +> Version: 7.1.385 / Virus Database: 268.5.1/328 - Release Date: 5/1/2006 +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 1: 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 +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + + +-- +No virus found in this incoming message. +Checked by AVG Free Edition. +Version: 7.1.392 / Virus Database: 268.5.3/331 - Release Date: 5/3/2006 + + + +From pgsql-performance-owner@postgresql.org Fri May 5 04:51:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 71EF19FA4EA + for ; + Fri, 5 May 2006 04:51:53 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 83936-01 + for ; + Fri, 5 May 2006 04:51:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx-2.sollentuna.net (mx-2.sollentuna.net [195.84.163.199]) + by postgresql.org (Postfix) with ESMTP id AC15F9FA4F2 + for ; + Fri, 5 May 2006 04:51:43 -0300 (ADT) +Received: from ALGOL.sollentuna.se (janus.sollentuna.se [62.65.68.67]) + by mx-2.sollentuna.net (Postfix) with ESMTP + id B047A8F28D; Fri, 5 May 2006 09:51:42 +0200 (CEST) +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Subject: Re: Performance Issues on Opteron Dual Core +Date: Fri, 5 May 2006 09:51:42 +0200 +Message-ID: <6BCB9D8A16AC4241919521715F4D8BCEA3536E@algol.sollentuna.se> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Performance Issues on Opteron Dual Core +Thread-Index: AcZvow1iV1r+mpbdSQe2CuP5aN9wxwAdZWnA +From: "Magnus Hagander" +To: "Jim C. Nasby" +Cc: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/102 +X-Sequence-Number: 18889 + +> > > > > FWIW, I've found problems running PostgreSQL on Windows in a=20 +> > > > > multi-CPU environment on w2k3. It runs fine for some=20 +> period, and=20 +> > > > > then CPU and throughput drop to zero. So far I've=20 +> been unable to=20 +> > > > > track down any more information than that, other than the +> > > fact that +> > > > > I haven't been able to reproduce this on any=20 +> single-CPU machines. +> > > >=20 +> > > > I have had previous correspondence about this with=20 +> Magnus (search=20 +> > > > -general and -hackers). If you uninstall SP1 the problem +> > > goes away. We +> > > > played a bit with potential fixes but didn't find any. +> > >=20 +> > > Interesting; does SP2 fix the problem? Anything we can do=20 +> over here=20 +> > > to help? +> >=20 +> > There is no SP2 for Windows 2003. +> >=20 +> > Have you tried this with latest-and-greatest CVS HEAD? Meaning with=20 +> > the new semaphore code that was committed a couple of days ago? +>=20 +> I'd be happy to test this if someone could provide a build,=20 +> or if there's instructions somewhere for doing such a build... + +Instructions are here: +http://www.postgresql.org/docs/faqs.FAQ_MINGW.html + +Let me know if you can't get that working an I can get a set of binaries +for you. + +//Magnus + +From pgsql-performance-owner@postgresql.org Fri May 5 06:50:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4CEA29FA4F2 + for ; + Fri, 5 May 2006 06:50:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 02471-01 + for ; + Fri, 5 May 2006 06:50:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id F24E99FA294 + for ; + Fri, 5 May 2006 06:50:13 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k459oER10293; + Fri, 5 May 2006 05:50:14 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200605050950.k459oER10293@candle.pha.pa.us> +Subject: Re: Super-smack? +In-Reply-To: <6879.1146505396@sss.pgh.pa.us> +To: Tom Lane +Date: Fri, 5 May 2006 05:50:14 -0400 (EDT) +CC: Steve Woodcock , + Scott Sipe , pgsql-performance@postgresql.org +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/103 +X-Sequence-Number: 18890 + + +Isn't Super Smack a breakfast cereal? :-) + +--------------------------------------------------------------------------- + +Tom Lane wrote: +> I wrote: +> > FWIW, my own experiments with tests like this suggest that PG is at +> > worst about 2x slower than mysql for trivial queries. If you'd reported +> > a result in that ballpark I'd have accepted it as probably real. 6x I +> > don't believe though ... +> +> Just for amusement's sake, I tried compiling up super-smack on my own +> machine, and got results roughly in line with what I would've expected. +> +> Machine: dual Xeon EM64T, forget the clock rate at the moment, running +> Fedora Core 4 (kernel 2.6.15-1.1831_FC4smp); hyperthreading enabled +> +> Postgres: fairly recent CVS tip, no special build options except +> --enable-debug, no changes to default runtime configuration options +> +> MySQL: 5.0.18, current Red Hat RPMs, no changes to default configuration +> +> The "select" test, with 1 and 10 clients: +> +> $ super-smack -d pg select-key.smack 1 10000 +> Query Barrel Report for client smacker1 +> connect: max=0ms min=-1ms avg= 3ms from 1 clients +> Query_type num_queries max_time min_time q_per_s +> select_index 20000 0 0 3655.24 +> $ super-smack -d pg select-key.smack 10 10000 +> Query Barrel Report for client smacker1 +> connect: max=54ms min=4ms avg= 12ms from 10 clients +> Query_type num_queries max_time min_time q_per_s +> select_index 200000 0 0 7431.20 +> +> $ super-smack -d mysql select-key.smack 1 10000 +> Query Barrel Report for client smacker1 +> connect: max=0ms min=-1ms avg= 0ms from 1 clients +> Query_type num_queries max_time min_time q_per_s +> select_index 20000 0 0 6894.03 +> $ super-smack -d mysql select-key.smack 10 10000 +> Query Barrel Report for client smacker1 +> connect: max=14ms min=0ms avg= 5ms from 10 clients +> Query_type num_queries max_time min_time q_per_s +> select_index 200000 0 0 16798.05 +> +> The "update" test, with 1 and 10 clients: +> +> $ super-smack -d pg update-select.smack 1 10000 +> Query Barrel Report for client smacker +> connect: max=0ms min=-1ms avg= 4ms from 1 clients +> Query_type num_queries max_time min_time q_per_s +> select_index 10000 0 0 1027.49 +> update_index 10000 0 0 1027.49 +> $ super-smack -d pg update-select.smack 10 10000 +> Query Barrel Report for client smacker +> connect: max=13ms min=5ms avg= 8ms from 10 clients +> Query_type num_queries max_time min_time q_per_s +> select_index 100000 1 0 1020.96 +> update_index 100000 28 0 1020.96 +> +> The above is with fsync on (though I think this machine's disk lies +> about write complete so I'd not trust it as production). With fsync off, +> +> $ super-smack -d pg update-select.smack 1 10000 +> Query Barrel Report for client smacker +> connect: max=0ms min=-1ms avg= 3ms from 1 clients +> Query_type num_queries max_time min_time q_per_s +> select_index 10000 0 0 1478.25 +> update_index 10000 0 0 1478.25 +> $ super-smack -d pg update-select.smack 10 10000 +> Query Barrel Report for client smacker +> connect: max=35ms min=5ms avg= 21ms from 10 clients +> Query_type num_queries max_time min_time q_per_s +> select_index 100000 1 0 3067.68 +> update_index 100000 1 0 3067.68 +> +> versus mysql +> +> $ super-smack -d mysql update-select.smack 1 10000 +> Query Barrel Report for client smacker +> connect: max=0ms min=-1ms avg= 0ms from 1 clients +> Query_type num_queries max_time min_time q_per_s +> select_index 10000 0 0 4101.43 +> update_index 10000 0 0 4101.43 +> $ super-smack -d mysql update-select.smack 10 10000 +> Query Barrel Report for client smacker +> connect: max=3ms min=0ms avg= 0ms from 10 clients +> Query_type num_queries max_time min_time q_per_s +> select_index 100000 1 0 5388.31 +> update_index 100000 6 0 5388.31 +> +> Since mysql is using myisam tables (ie not transaction safe), I think +> the fairest comparison is to the fsync-off numbers. +> +> regards, tom lane +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Fri May 5 08:54:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3A7E49FA509 + for ; + Fri, 5 May 2006 08:54:37 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 21901-03 + for ; + Fri, 5 May 2006 08:54:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from morpheus.bostonstock.com (unknown [192.233.205.44]) + by postgresql.org (Postfix) with ESMTP id 16C259FA372 + for ; + Fri, 5 May 2006 08:54:31 -0300 (ADT) +Received: by MORPHEUS with Internet Mail Service (5.5.2653.19) + id <2R02CAV7>; Fri, 5 May 2006 07:49:37 -0400 +Message-ID: <0C4841B42F87D51195BD00B0D020F5CB044B2608@MORPHEUS> +From: "mcelroy, tim" +To: pgsql-performance@postgresql.org +Subject: Memory and/or cache issues? +Date: Fri, 5 May 2006 07:49:32 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C67039.F90AB2B4" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/104 +X-Sequence-Number: 18891 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C67039.F90AB2B4 +Content-Type: text/plain; + charset="iso-8859-1" + +Good morning, + +First the stats: I'm using PostgreSQL 8.0.1 (I know I should upgrade, +cannot due to vendor app. restrictions...), RedHat 9 on a SUN V40Z with 8GB +of memory. I'm using the "out-of-the-box" settings in postgresql.conf. +I've been testing various changes but cannot increase anything to improve +performance till I get this memory leak and/or cache issue resolved. + +Scenario: Last night the backup of my largest DB failed (4.4GB in size with +44Million+ tuples) with a memory alloc error. I'll attach it at the end of +this email. Once we rebooted the box and freed memory all was well, the +backup completed fine but as the backup ran and I did a few minor queries +all of a sudden 3+GB of memory was used up! I then performed my nightly +vacuumdb with analyze and just about the remaining 4GB of memory was gone! +This was the only application running in the machine at the time. + +Questions: +1. I thought using such "smallish" setting as provided would cause postgres +to go to swap instead of eating up all the memory? +2. If PostgreSQL is the culprit (which I hope it is not) does postgres +release any memory it assumes during processing when that processing is +complete? Such as the backup and vacuumdb I mentioned? +3. Does anyone know of a way to determine if it actually is postgres hogging +this memory? Using TOP I only see my postgres processes using 1% or 2% of +memory. It would be nice to have a tool that showed exactly what is eating +up that 7+GB? +4. IS this due to my low setting in postgresql.conf? + +Any and all help is welcomed. For you PostgreSQL purists out there of whom +I am fast becoming, your help is needed as my company is considering dumping +postgresql in favor of Oracle.....I would much rather figure out the issue +then switch DBs. Here is the error received from the failed backup and the +second was noted in my pg_log file: + +pg_dump: ERROR: invalid memory alloc request size 18446744073709551613 +pg_dump: SQL command to dump the contents of table "msgstate" failed: +PQendcopy() failed. +pg_dump: Error message from server: ERROR: invalid memory alloc request +size 18446744073709551613 +pg_dump: The command was: COPY public.msgstate (id, connectormsgid, +parentid, orderidfk, clordid, orgclordid, msg, rawmsg, msgtype, "action", +sendstate, statechain, fromdest, todest, inserted, op_id, released, reason, +outgoing, symbol, qty, price, stopprice, side, data1, data2, data3, data4, +data5) TO stdout; + + +2006-05-04 18:04:58 EDT USER=postgres DB=FIX1 [12427] PORT = [local] ERROR: +invalid memory alloc request size 18446744073709551613 + +Thank you, +Tim McElroy + + + +------_=_NextPart_001_01C67039.F90AB2B4 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +Memory and/or cache issues? + + + +

Good morning, +

+ +

First the stats:  I'm using = +PostgreSQL 8.0.1 (I know I should upgrade, cannot due to vendor app. = +restrictions...), RedHat 9 on a SUN V40Z with 8GB of memory.  I'm = +using the "out-of-the-box" settings in postgresql.conf.  = +I've been testing various changes but cannot increase anything to = +improve performance till I get this memory leak and/or cache issue = +resolved.

+ +

Scenario:  Last night the backup = +of my largest DB failed (4.4GB in size with 44Million+ tuples) with a = +memory alloc error.  I'll attach it at the end of this = +email.  Once we rebooted the box and freed memory all was well, = +the backup completed fine but as the backup ran and I did a few minor = +queries all of a sudden 3+GB of memory was used up!  I then = +performed my nightly vacuumdb with analyze and just about the remaining = +4GB of memory was gone!  This was the only application running in = +the machine at the time.

+ +

Questions: +
1. I thought using such = +"smallish" setting as provided would cause postgres to go to = +swap instead of eating up all the memory?

+ +

2. If PostgreSQL is the culprit (which = +I hope it is not) does postgres release any memory it assumes during = +processing when that processing is complete?  Such as the backup = +and vacuumdb I mentioned?

+ +

3. Does anyone know of a way to = +determine if it actually is postgres hogging this memory?  Using = +TOP I only see my postgres processes using 1% or 2% of memory.  It = +would be nice to have a tool that showed exactly what is eating up that = +7+GB?

+ +

4. IS this due to my low setting in = +postgresql.conf? +

+ +

Any and all help is welcomed.  = +For you PostgreSQL purists out there of whom I am fast becoming, your = +help is needed as my company is considering dumping postgresql in favor = +of Oracle.....I would much rather figure out the issue then switch = +DBs.  Here is the error received from the failed backup and the = +second was noted in my pg_log file:

+ +

pg_dump: ERROR:  invalid memory = +alloc request size 18446744073709551613 +
pg_dump: SQL command to dump the = +contents of table "msgstate" failed: PQendcopy() = +failed. +
pg_dump: Error message from server: = +ERROR:  invalid memory alloc request size = +18446744073709551613 +
pg_dump: The command was: COPY = +public.msgstate (id, connectormsgid, parentid, orderidfk, clordid, = +orgclordid, msg, rawmsg, msgtype, "action", sendstate, = +statechain, fromdest, todest, inserted, op_id, released, reason, = +outgoing, symbol, qty, price, stopprice, side, data1, data2, data3, = +data4, data5) TO stdout;

+
+ +

2006-05-04 18:04:58 EDT = +USER=3Dpostgres DB=3DFIX1 [12427] PORT =3D [local] ERROR:  invalid = +memory alloc request size 18446744073709551613
+
+Thank you,
+Tim McElroy
+
+
+

+ + + +------_=_NextPart_001_01C67039.F90AB2B4-- + +From pgsql-performance-owner@postgresql.org Fri May 5 10:25:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7B37C9FA509 + for ; + Fri, 5 May 2006 10:25:39 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 36802-06 + for ; + Fri, 5 May 2006 10:25:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 392209FA372 + for ; + Fri, 5 May 2006 10:25:34 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k45DPKOl019908; + Fri, 5 May 2006 09:25:20 -0400 (EDT) +To: "mcelroy, tim" +cc: pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +In-reply-to: <0C4841B42F87D51195BD00B0D020F5CB044B2608@MORPHEUS> +References: <0C4841B42F87D51195BD00B0D020F5CB044B2608@MORPHEUS> +Comments: In-reply-to "mcelroy, tim" + message dated "Fri, 05 May 2006 07:49:32 -0400" +Date: Fri, 05 May 2006 09:25:20 -0400 +Message-ID: <19907.1146835520@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/105 +X-Sequence-Number: 18892 + +"mcelroy, tim" writes: +> pg_dump: ERROR: invalid memory alloc request size 18446744073709551613 + +That looks more like a corrupt-data problem than anything directly to do +with having or not having enough memory. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri May 5 10:31:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BD5259FA509 + for ; + Fri, 5 May 2006 10:31:45 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 37970-06 + for ; + Fri, 5 May 2006 10:31:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from morpheus.bostonstock.com (unknown [192.233.205.44]) + by postgresql.org (Postfix) with ESMTP id 360AE9FB1C1 + for ; + Fri, 5 May 2006 10:31:36 -0300 (ADT) +Received: by MORPHEUS with Internet Mail Service (5.5.2653.19) + id <2R02CBD2>; Fri, 5 May 2006 09:26:43 -0400 +Message-ID: <0C4841B42F87D51195BD00B0D020F5CB044B260B@MORPHEUS> +From: "mcelroy, tim" +To: 'Tom Lane' +Cc: pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +Date: Fri, 5 May 2006 09:26:34 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C67047.8779C532" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/107 +X-Sequence-Number: 18894 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C67047.8779C532 +Content-Type: text/plain; + charset="iso-8859-1" + +Thanks Tom. I thought the same thing and waded through the archives trying +various fixes such as vacuum, vacuum full (both with analyze), reindex and +still the same issue. However, once the box was rebooted the backup went +smooth and the data was fine. We have two (2) machines (PROD001 & PROD002) +that are "in-sync" and the data matched exactly. PROD002 was where I had +the problem. I see this on all the postgres installations, no matter what I +set the postgresql.conf settings to regarding memory allocation, once +postgres starts up 95% of the memory on the box is used. Is there a way +within Linux to 'see' what or who is actually using this memory? I would +love to say it's a hardware thing and that postgres is fine :) + +Regards, +Tim + + -----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: Friday, May 05, 2006 9:25 AM +To: mcelroy, tim +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Memory and/or cache issues? + +"mcelroy, tim" writes: +> pg_dump: ERROR: invalid memory alloc request size 18446744073709551613 + +That looks more like a corrupt-data problem than anything directly to do +with having or not having enough memory. + + regards, tom lane + +------_=_NextPart_001_01C67047.8779C532 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] Memory and/or cache issues? + + + +

Thanks Tom.  I thought the same thing and waded = +through the archives trying various fixes such as vacuum, vacuum full = +(both with analyze), reindex and still the same issue.  However, = +once the box was rebooted the backup went smooth and the data was = +fine.  We have two (2) machines (PROD001 & PROD002) that are = +"in-sync" and the data matched exactly.  PROD002 was = +where I had the problem.  I see this on all the postgres = +installations, no matter what I set the postgresql.conf settings to = +regarding memory allocation, once postgres starts up 95% of the memory = +on the box is used.  Is there a way within Linux to 'see' what or = +who is actually using this memory?  I would love to say it's a = +hardware thing and that postgres is fine :)

+ +

Regards, +
Tim +

+ +

 -----Original Message----- +
From:   Tom Lane [mailto:tgl@sss.pgh.pa.us] +
Sent:   Friday, May 05, 2006 9:25 = +AM +
To:     mcelroy, tim +
Cc:     = +pgsql-performance@postgresql.org +
Subject:        = +Re: [PERFORM] Memory and/or cache issues? +

+ +

"mcelroy, tim" = +<tim.mcelroy@bostonstock.com> writes: +
> pg_dump: ERROR:  invalid memory alloc = +request size 18446744073709551613 +

+ +

That looks more like a corrupt-data problem than = +anything directly to do +
with having or not having enough memory. +

+ +

        = +        = +        regards, tom = +lane +

+ + + +------_=_NextPart_001_01C67047.8779C532-- + +From pgsql-performance-owner@postgresql.org Fri May 5 10:31:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 036319FA509 + for ; + Fri, 5 May 2006 10:31:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 37883-05 + for ; + Fri, 5 May 2006 10:31:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.surnet.cl (mx1.surnet.cl [216.155.73.180]) + by postgresql.org (Postfix) with ESMTP id 215A39FA372 + for ; + Fri, 5 May 2006 10:31:20 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx1.surnet.cl with ESMTP; 05 May 2006 09:31:19 -0400 +X-IronPort-AV: i="4.05,93,1146456000"; d="scan'208"; a="60678413:sNHT85721008" +Received: from alvh.no-ip.org (201.220.122.210) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 443B7DDC0035B3C8; Fri, 5 May 2006 09:31:19 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id E7C42C31DD1; Fri, 5 May 2006 09:31:18 -0400 (CLT) +Date: Fri, 5 May 2006 09:31:18 -0400 +From: Alvaro Herrera +To: Tom Lane +Cc: "mcelroy, tim" , + pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +Message-ID: <20060505133118.GF8878@surnet.cl> +Mail-Followup-To: Tom Lane , + "mcelroy, tim" , + pgsql-performance@postgresql.org +References: <0C4841B42F87D51195BD00B0D020F5CB044B2608@MORPHEUS> + <19907.1146835520@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <19907.1146835520@sss.pgh.pa.us> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/106 +X-Sequence-Number: 18893 + +Tom Lane wrote: +> "mcelroy, tim" writes: +> > pg_dump: ERROR: invalid memory alloc request size 18446744073709551613 +> +> That looks more like a corrupt-data problem than anything directly to do +> with having or not having enough memory. + +The bit pattern is certainly suspicious, though I'll grant that it +doesn't mean anything. + +$ dc +2 o +18446744073709551613 p +1111111111111111111111111111111111111111111111111111111111111101 + + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +PostgreSQL Replication, Consulting, Custom Development, 24x7 support + +From pgsql-performance-owner@postgresql.org Fri May 5 10:44:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5A9019FA372 + for ; + Fri, 5 May 2006 10:44:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 37970-09 + for ; + Fri, 5 May 2006 10:44:02 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 6D9739FA509 + for ; + Fri, 5 May 2006 10:44:02 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k45DhrTB023855; + Fri, 5 May 2006 09:43:54 -0400 (EDT) +To: "mcelroy, tim" +cc: pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +In-reply-to: <0C4841B42F87D51195BD00B0D020F5CB044B260B@MORPHEUS> +References: <0C4841B42F87D51195BD00B0D020F5CB044B260B@MORPHEUS> +Comments: In-reply-to "mcelroy, tim" + message dated "Fri, 05 May 2006 09:26:34 -0400" +Date: Fri, 05 May 2006 09:43:53 -0400 +Message-ID: <23854.1146836633@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/108 +X-Sequence-Number: 18895 + +"mcelroy, tim" writes: +> I see this on all the postgres installations, no matter what I +> set the postgresql.conf settings to regarding memory allocation, once +> postgres starts up 95% of the memory on the box is used. Is there a way +> within Linux to 'see' what or who is actually using this memory? + +Probably kernel disk cache. Are you under the misimpression that unused +memory is a good thing? If a Unix-ish system *isn't* showing near zero +free memory under load, the kernel is wasting valuable resources. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri May 5 11:12:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 61C6C9FA509 + for ; + Fri, 5 May 2006 11:12:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 43364-04 + for ; + Fri, 5 May 2006 11:12:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from morpheus.bostonstock.com (unknown [192.233.205.44]) + by postgresql.org (Postfix) with ESMTP id 5E5DD9FA372 + for ; + Fri, 5 May 2006 11:12:18 -0300 (ADT) +Received: by MORPHEUS with Internet Mail Service (5.5.2653.19) + id <2R02CBH5>; Fri, 5 May 2006 09:58:04 -0400 +Message-ID: <0C4841B42F87D51195BD00B0D020F5CB044B260D@MORPHEUS> +From: "mcelroy, tim" +To: 'Tom Lane' +Cc: pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +Date: Fri, 5 May 2006 09:57:58 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C6704B.EA36851C" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/109 +X-Sequence-Number: 18896 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C6704B.EA36851C +Content-Type: text/plain; + charset="iso-8859-1" + +Are you saying the kernel's disc cache may be getting whacked? No, I +understand that PG should use as much memory as it can and the system as +well. The main problem here is that with almost all the 8GB of RAM 'in use' +when I try to do a pg_dump or vacuumdb I run out of memory and the system +crashes.... + +I well understand that unused memory is not a good thing, just that when you +have none and can't do the maint work....bad stuff happens. For example, I +just created a benchdb on my DEV box with 1,000,000 tuples. As this ran the +mem in use jumped up 1G and it hasn't gone down? Once the PG process has +finished its task shouldn't it release the memory it used? + +Thanks, +Tim + + + -----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: Friday, May 05, 2006 9:44 AM +To: mcelroy, tim +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Memory and/or cache issues? + +"mcelroy, tim" writes: +> I see this on all the postgres installations, no matter what I +> set the postgresql.conf settings to regarding memory allocation, once +> postgres starts up 95% of the memory on the box is used. Is there a way +> within Linux to 'see' what or who is actually using this memory? + +Probably kernel disk cache. Are you under the misimpression that unused +memory is a good thing? If a Unix-ish system *isn't* showing near zero +free memory under load, the kernel is wasting valuable resources. + + regards, tom lane + +------_=_NextPart_001_01C6704B.EA36851C +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] Memory and/or cache issues? + + + +

Are you saying the kernel's disc cache may be getting = +whacked?  No, I understand that PG should use as much memory as it = +can and the system as well.  The main problem here is that with = +almost all the 8GB of RAM 'in use' when I try to do a pg_dump or = +vacuumdb I run out of memory and the system crashes....

+ +

I well understand that unused memory is not a good = +thing, just that when you have none and can't do the maint work....bad = +stuff happens.  For example, I just created a benchdb on my DEV = +box with 1,000,000 tuples.  As this ran the mem in use jumped up = +1G and it hasn't gone down?  Once the PG process has finished its = +task shouldn't it release the memory it used?

+ +

Thanks, +
Tim +

+
+ +

 -----Original Message----- +
From:   Tom Lane [mailto:tgl@sss.pgh.pa.us] +
Sent:   Friday, May 05, 2006 9:44 = +AM +
To:     mcelroy, tim +
Cc:     = +pgsql-performance@postgresql.org +
Subject:        = +Re: [PERFORM] Memory and/or cache issues? +

+ +

"mcelroy, tim" = +<tim.mcelroy@bostonstock.com> writes: +
> I see this on all the postgres installations, = +no matter what I +
> set the postgresql.conf settings to regarding = +memory allocation, once +
> postgres starts up 95% of the memory on the box = +is used.  Is there a way +
> within Linux to 'see' what or who is actually = +using this memory? +

+ +

Probably kernel disk cache.  Are you under the = +misimpression that unused +
memory is a good thing?  If a Unix-ish system = +*isn't* showing near zero +
free memory under load, the kernel is wasting = +valuable resources. +

+ +

        = +        = +        regards, tom = +lane +

+ + + +------_=_NextPart_001_01C6704B.EA36851C-- + +From pgsql-performance-owner@postgresql.org Fri May 5 11:24:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 233769FB1CC + for ; + Fri, 5 May 2006 11:24:02 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 46867-04 + for ; + Fri, 5 May 2006 11:23:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms040pub.verizon.net (vms040pub.verizon.net [206.46.252.40]) + by postgresql.org (Postfix) with ESMTP id D5EB79FA372 + for ; + Fri, 5 May 2006 11:23:51 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.51.88]) + by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYS00JWIQNPVTI4@vms040.mailsrvcs.net> for + pgsql-performance@postgresql.org; Fri, 05 May 2006 09:23:49 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id ACB9A6EC9D for + ; + Fri, 05 May 2006 10:23:47 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id pRo0-5RG-1st for ; Fri, + 05 May 2006 10:23:45 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id E16376ECA6; Fri, 05 May 2006 10:23:44 -0400 (EDT) +Date: Fri, 05 May 2006 10:23:44 -0400 +From: Michael Stone +Subject: Re: Memory and/or cache issues? +In-reply-to: <0C4841B42F87D51195BD00B0D020F5CB044B260D@MORPHEUS> +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060505142342.GH16533@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Virus-Scanned: Debian amavisd-new at mathom.us +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +References: <0C4841B42F87D51195BD00B0D020F5CB044B260D@MORPHEUS> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/110 +X-Sequence-Number: 18897 + +On Fri, May 05, 2006 at 09:57:58AM -0400, mcelroy, tim wrote: +>Are you saying the kernel's disc cache may be getting whacked? No, I +>understand that PG should use as much memory as it can and the system as +>well. The main problem here is that with almost all the 8GB of RAM 'in use' +>when I try to do a pg_dump or vacuumdb I run out of memory and the system +>crashes.... + +You need to be way more specific about what "in use" means. Try pasting +the output of actual commands like "free". The main problem here +according to the output you sent is that your process is trying to +allocate 10billion terabytes of RAM (which ain't gonna work) and dies. +That is not a memory issue. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Fri May 5 11:32:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 465019FA619 + for ; + Fri, 5 May 2006 11:32:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 47081-06 + for ; + Fri, 5 May 2006 11:32:10 -0300 (ADT) +X-Greylist: delayed 00:29:11.585949 by SQLgrey- +Received: from morpheus.bostonstock.com (morpheus.bostonstock.com + [192.233.205.44]) + by postgresql.org (Postfix) with ESMTP id CA7629FA372 + for ; + Fri, 5 May 2006 11:32:10 -0300 (ADT) +Received: by MORPHEUS with Internet Mail Service (5.5.2653.19) + id <2R02CBN5>; Fri, 5 May 2006 10:27:16 -0400 +Message-ID: <0C4841B42F87D51195BD00B0D020F5CB044B2611@MORPHEUS> +From: "mcelroy, tim" +To: 'Michael Stone' , + pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +Date: Fri, 5 May 2006 10:27:10 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C6704F.FE755A0E" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/112 +X-Sequence-Number: 18899 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C6704F.FE755A0E +Content-Type: text/plain; + charset="iso-8859-1" + +Sorry, been up all night and maybe provided too much information or not the +right information and only confused folks, tired I guess. When I say 'in +use' I am referring to the 'used' column. Thanks all who have responded to +this inquiry, I appreciate it. + +Here's free from PROD001: +[root@wbibsngwyprod001 kernel]# free -k -t + total used free shared buffers cached +Mem: 7643536 6975772 667764 0 165496 5393396 +-/+ buffers/cache: 1416880 6226656 +Swap: 8185108 5208 8179900 +Total: 15828644 6980980 8847664 + +Here's free from PROD002: +[root@wbibsngwyprod002 root]# free -k -t + total used free shared buffers cached +Mem: 7643536 6694220 949316 0 161008 4916420 +-/+ buffers/cache: 1616792 6026744 +Swap: 8185108 11584 8173524 +Total: 15828644 6705804 9122840 + +Tim + + -----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Michael Stone +Sent: Friday, May 05, 2006 10:24 AM +To: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Memory and/or cache issues? + +On Fri, May 05, 2006 at 09:57:58AM -0400, mcelroy, tim wrote: +>Are you saying the kernel's disc cache may be getting whacked? No, I +>understand that PG should use as much memory as it can and the system as +>well. The main problem here is that with almost all the 8GB of RAM 'in +use' +>when I try to do a pg_dump or vacuumdb I run out of memory and the system +>crashes.... + +You need to be way more specific about what "in use" means. Try pasting +the output of actual commands like "free". The main problem here +according to the output you sent is that your process is trying to +allocate 10billion terabytes of RAM (which ain't gonna work) and dies. +That is not a memory issue. + +Mike Stone + +---------------------------(end of broadcast)--------------------------- +TIP 1: 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 + +------_=_NextPart_001_01C6704F.FE755A0E +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] Memory and/or cache issues? + + + +

Sorry, been up all night and maybe provided too much = +information or not the right information and only confused folks, tired = +I guess.  When I say 'in use' I am referring to the 'used' = +column.  Thanks all who have responded to this inquiry, I = +appreciate it.

+ +

Here's free from PROD001: +
[root@wbibsngwyprod001 kernel]# free -k -t +
          &nb= +sp;  total       = +used       free     = +shared    buffers     cached +
Mem:       = +7643536    6975772     = +667764          = +0     165496    5393396 +
-/+ buffers/cache:    = +1416880    6226656 +
Swap:      = +8185108       5208    = +8179900 +
Total:    15828644    = +6980980    8847664 +

+ +

Here's free from PROD002: +
[root@wbibsngwyprod002 root]# free -k -t +
          &nb= +sp;  total       = +used       free     = +shared    buffers     cached +
Mem:       = +7643536    6694220     = +949316          = +0     161008    4916420 +
-/+ buffers/cache:    = +1616792    6026744 +
Swap:      = +8185108      11584    = +8173524 +
Total:    15828644    = +6705804    9122840 +

+ +

Tim +

+ +

 -----Original Message----- +
From:   pgsql-performance-owner@postgresql.org = +[mailto:pgsql-perf= +ormance-owner@postgresql.org]  On Behalf Of Michael = +Stone

+ +

Sent:   Friday, May 05, 2006 10:24 = +AM +
To:     = +pgsql-performance@postgresql.org +
Subject:        = +Re: [PERFORM] Memory and/or cache issues? +

+ +

On Fri, May 05, 2006 at 09:57:58AM -0400, mcelroy, = +tim wrote: +
>Are you saying the kernel's disc cache may be = +getting whacked?  No, I +
>understand that PG should use as much memory as = +it can and the system as +
>well.  The main problem here is that with = +almost all the 8GB of RAM 'in use' +
>when I try to do a pg_dump or vacuumdb I run out = +of memory and the system +
>crashes.... +

+ +

You need to be way more specific about what "in = +use" means. Try pasting +
the output of actual commands like "free". = +The main problem here +
according to the output you sent is that your = +process is trying to +
allocate 10billion terabytes of RAM (which ain't = +gonna work) and dies. +
That is not a memory issue. +

+ +

Mike Stone +

+ +

---------------------------(end of = +broadcast)--------------------------- +
TIP 1: 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 +

+ + + +------_=_NextPart_001_01C6704F.FE755A0E-- + +From pgsql-performance-owner@postgresql.org Fri May 5 11:31:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 95D459FA619 + for ; + Fri, 5 May 2006 11:31:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 49077-01 + for ; + Fri, 5 May 2006 11:31:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id 33E8E9FA372 + for ; + Fri, 5 May 2006 11:31:37 -0300 (ADT) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [67.90.96.2] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 89497475; Fri, 05 May 2006 07:31:33 -0700 +From: "Dave Dutcher" +To: "'mcelroy, tim'" +Cc: +Subject: Re: Memory and/or cache issues? +Date: Fri, 5 May 2006 09:31:33 -0500 +Message-ID: <007d01c67050$9bf11340$8300a8c0@tridecap.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_007E_01C67026.B31B0B40" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +In-reply-to: <0C4841B42F87D51195BD00B0D020F5CB044B260D@MORPHEUS> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/111 +X-Sequence-Number: 18898 + +This is a multi-part message in MIME format. + +------=_NextPart_000_007E_01C67026.B31B0B40 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +For a standard config most of the memory used by Postgres is the shared +buffers. The shared buffers are a cache to store blocks read from the +disk, so if you do a query, Postgres will allocate and fill the shared +buffers up to the max amount you set in your postgresql.conf file. +Postgres doesn't release that memory between queries because the point +is to be able to pull data from ram instead of the disk on the next +query. + +Are you sure your settings in postgresql.conf are standard? What are +your settings for shared_buffers and work_mem? + + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of mcelroy, +tim +Sent: Friday, May 05, 2006 8:58 AM +To: 'Tom Lane' +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Memory and/or cache issues? + + + +Are you saying the kernel's disc cache may be getting whacked? No, I +understand that PG should use as much memory as it can and the system as +well. The main problem here is that with almost all the 8GB of RAM 'in +use' when I try to do a pg_dump or vacuumdb I run out of memory and the +system crashes.... + +I well understand that unused memory is not a good thing, just that when +you have none and can't do the maint work....bad stuff happens. For +example, I just created a benchdb on my DEV box with 1,000,000 tuples. +As this ran the mem in use jumped up 1G and it hasn't gone down? Once +the PG process has finished its task shouldn't it release the memory it +used? + +Thanks, +Tim + + + -----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: Friday, May 05, 2006 9:44 AM +To: mcelroy, tim +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Memory and/or cache issues? + +"mcelroy, tim" writes: +> I see this on all the postgres installations, no matter what I +> set the postgresql.conf settings to regarding memory allocation, once +> postgres starts up 95% of the memory on the box is used. Is there a +way +> within Linux to 'see' what or who is actually using this memory? + +Probably kernel disk cache. Are you under the misimpression that unused + +memory is a good thing? If a Unix-ish system *isn't* showing near zero +free memory under load, the kernel is wasting valuable resources. + + regards, tom lane + + +------=_NextPart_000_007E_01C67026.B31B0B40 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + +Message + + + +
For a=20 +standard config most of the memory used by Postgres is the shared = +buffers. =20 +The shared buffers are a cache to store blocks read from the disk, so if = +you do=20 +a query, Postgres will allocate and fill the shared buffers up to the = +max amount=20 +you set in your postgresql.conf file.  Postgres doesn't release = +that=20 +memory between queries because the point is to be able to pull data = +from=20 +ram instead of the disk on the next query.
+
 
+
Are you sure your settings in postgresql.conf are=20 +standard?  What are your settings for shared_buffers and=20 +work_mem?
+
 
+
 
+
+
+
-----Original Message-----
From:=20 + pgsql-performance-owner@postgresql.org=20 + [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of = +mcelroy,=20 + tim
Sent: Friday, May 05, 2006 8:58 AM
To: 'Tom=20 + Lane'
Cc: = +pgsql-performance@postgresql.org
Subject: Re:=20 + [PERFORM] Memory and/or cache issues?

+

Are you saying the kernel's disc cache may be = +getting=20 + whacked?  No, I understand that PG should use as much memory as = +it can=20 + and the system as well.  The main problem here is that with = +almost all=20 + the 8GB of RAM 'in use' when I try to do a pg_dump or vacuumdb I run = +out of=20 + memory and the system crashes....

+

I well understand that unused memory is not a good = +thing, just=20 + that when you have none and can't do the maint work....bad stuff=20 + happens.  For example, I just created a benchdb on my DEV box = +with=20 + 1,000,000 tuples.  As this ran the mem in use jumped up 1G and it = +hasn't=20 + gone down?  Once the PG process has finished its task shouldn't = +it=20 + release the memory it used?

+

Thanks,
Tim = +


+

 -----Original Message-----
From:=20 +   Tom Lane [mailto:tgl@sss.pgh.pa.us] = +
Sent:   Friday, May 05, 2006 9:44 AM = +
To:     mcelroy, tim
Cc:     = +pgsql-performance@postgresql.org=20 +
Subject:        = +Re:=20 + [PERFORM] Memory and/or cache issues?

+

"mcelroy, tim" <tim.mcelroy@bostonstock.com>=20 + writes:
> I see this on all the postgres=20 + installations, no matter what I
> set the = + + postgresql.conf settings to regarding memory allocation, once = +
> postgres starts up 95% of the memory on the box is = +used.  Is=20 + there a way
> within Linux to 'see' what = +or who is=20 + actually using this memory?

+

Probably kernel disk cache.  Are you under the=20 + misimpression that unused
memory is a good=20 + thing?  If a Unix-ish system *isn't* showing near zero = +
free memory under load, the kernel is wasting valuable=20 + resources.

+

       =20 +        =20 +         regards, tom = + + lane

+ +------=_NextPart_000_007E_01C67026.B31B0B40-- + + +From pgsql-performance-owner@postgresql.org Fri May 5 11:41:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E80E19FA509 + for ; + Fri, 5 May 2006 11:41:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 48688-06 + for ; + Fri, 5 May 2006 11:41:20 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from morpheus.bostonstock.com (morpheus.bostonstock.com + [192.233.205.44]) + by postgresql.org (Postfix) with ESMTP id BC69F9FA372 + for ; + Fri, 5 May 2006 11:41:20 -0300 (ADT) +Received: by MORPHEUS with Internet Mail Service (5.5.2653.19) + id <2R02CBPJ>; Fri, 5 May 2006 10:36:26 -0400 +Message-ID: <0C4841B42F87D51195BD00B0D020F5CB044B2613@MORPHEUS> +From: "mcelroy, tim" +To: 'Dave Dutcher' +Cc: pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +Date: Fri, 5 May 2006 10:36:19 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C67050.E12DF87E" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/114 +X-Sequence-Number: 18901 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C67050.E12DF87E +Content-Type: text/plain + +On the boxes in question the settings are: + +shared_buffers = 1000 +work_mem = 1024 + +I have revised these on my DEV box and see some improvement (a quick thank +you to Jim Nasby for his assistance with that): + +shared_buffers = 20000 +work_mem = 8024 + +Regards, +Tim + +-----Original Message----- +From: Dave Dutcher [mailto:dave@tridecap.com] +Sent: Friday, May 05, 2006 10:32 AM +To: 'mcelroy, tim' +Cc: pgsql-performance@postgresql.org +Subject: RE: [PERFORM] Memory and/or cache issues? + +For a standard config most of the memory used by Postgres is the shared +buffers. The shared buffers are a cache to store blocks read from the disk, +so if you do a query, Postgres will allocate and fill the shared buffers up +to the max amount you set in your postgresql.conf file. Postgres doesn't +release that memory between queries because the point is to be able to pull +data from ram instead of the disk on the next query. + +Are you sure your settings in postgresql.conf are standard? What are your +settings for shared_buffers and work_mem? + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of mcelroy, tim +Sent: Friday, May 05, 2006 8:58 AM +To: 'Tom Lane' +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Memory and/or cache issues? +Are you saying the kernel's disc cache may be getting whacked? No, I +understand that PG should use as much memory as it can and the system as +well. The main problem here is that with almost all the 8GB of RAM 'in use' +when I try to do a pg_dump or vacuumdb I run out of memory and the system +crashes.... +I well understand that unused memory is not a good thing, just that when you +have none and can't do the maint work....bad stuff happens. For example, I +just created a benchdb on my DEV box with 1,000,000 tuples. As this ran the +mem in use jumped up 1G and it hasn't gone down? Once the PG process has +finished its task shouldn't it release the memory it used? +Thanks, +Tim + + -----Original Message----- +From: Tom Lane [ mailto:tgl@sss.pgh.pa.us ] +Sent: Friday, May 05, 2006 9:44 AM +To: mcelroy, tim +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Memory and/or cache issues? +"mcelroy, tim" writes: +> I see this on all the postgres installations, no matter what I +> set the postgresql.conf settings to regarding memory allocation, once +> postgres starts up 95% of the memory on the box is used. Is there a way +> within Linux to 'see' what or who is actually using this memory? +Probably kernel disk cache. Are you under the misimpression that unused +memory is a good thing? If a Unix-ish system *isn't* showing near zero +free memory under load, the kernel is wasting valuable resources. + regards, tom lane + +------_=_NextPart_001_01C67050.E12DF87E +Content-Type: text/html +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + +Message + + + + + + +
+ +

O= +n the boxes +in question the settings are:

+ +

<= +![if = +!supportEmptyParas]> 

= + + +

s= +hared_buffers +=3D 1000

+ +

w= +ork_mem =3D +1024

+ +

<= +![if = +!supportEmptyParas]> 

= + + +

I= + have +revised these on my DEV box and see some improvement (a quick thank you = +to Jim +Nasby for his assistance with = +that):

+ +

<= +![if = +!supportEmptyParas]> 

= + + +

s= +hared_buffers +=3D 20000

+ +

w= +ork_mem =3D +8024

+ +

<= +![if = +!supportEmptyParas]> 

= + + +

R= +egards,

+ +

T= +im

+ +

<= +![if = +!supportEmptyParas]> 

= + + +

-----Original +Message-----
+From: Dave Dutcher +[mailto:dave@tridecap.com]
+Sent: Friday, May 05, = +2006 10:32 +AM
+To: 'mcelroy, tim'
+Cc: = +pgsql-performance@postgresql.org
+Subject: RE: [PERFORM] = +Memory +and/or cache issues?

+ +

 

+ +

For a standard = +config +most of the memory used by Postgres is the shared buffers.  The = +shared +buffers are a cache to store blocks read from the disk, so if you do a = +query, +Postgres will allocate and fill the shared buffers up to the max amount = +you set +in your postgresql.conf file.  Postgres doesn't release that +memory between queries because the point is to be able to pull = +data from +ram instead of the disk on the next query.= +

+ +

 = +

+ +

Are you = +sure your +settings in postgresql.conf are standard?  What are your = +settings for +shared_buffers and work_mem?= +

+ +

 = +

+ +

 = +

+ +
+ +

-----Original +Message-----
+From: +pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of mcelroy, tim
+Sent: Friday, May 05, = +2006 8:58 AM
+To: 'Tom Lane'
+Cc: = +pgsql-performance@postgresql.org
+Subject: Re: [PERFORM] = +Memory +and/or cache issues?

+ +

Are you +saying the kernel's disc cache may be getting whacked?  No, I = +understand +that PG should use as much memory as it can and the system as = +well.  The +main problem here is that with almost all the 8GB of RAM 'in use' when = +I try to +do a pg_dump or vacuumdb I run out of memory and the system = +crashes....= +

+ +

I = +well +understand that unused memory is not a good thing, just that when you = +have none +and can't do the maint work....bad stuff happens.  For example, I = +just +created a benchdb on my DEV box with 1,000,000 tuples.  As this = +ran the +mem in use jumped up 1G and it hasn't gone down?  Once the PG = +process has +finished its task shouldn't it release the memory it = +used?= +

+ +

Thanks,
+
Tim = +

+ +

 = +

+ +

 -----Original +Message-----
+
From:   Tom Lane [mailto:tgl@sss.pgh.pa.us] +
+
Sent:   Friday, May 05, 2006 9:44 = +AM
+
To:     mcelroy, = +tim
+
Cc:     = +pgsql-performance@postgresql.org
+
Subject:        Re: = +[PERFORM] +Memory and/or cache issues? = +

+ +

"mcelroy, +tim" <tim.mcelroy@bostonstock.com> = +writes:
+
> I see this on all the postgres installations, no = +matter what +I
+
> set the postgresql.conf settings to regarding memory +allocation, once
+
> postgres starts up 95% of the memory on the box is +used.  Is there a way
+
> within Linux to 'see' what or who is actually using = +this +memory? = += +

+ +

Probably +kernel disk cache.  Are you under the misimpression that = +unused
+
memory is a good thing?  If a Unix-ish system *isn't* = +showing +near zero = +
+
free memory under load, the kernel is wasting valuable = +resources. = +

+ +

     &nb= +sp;  +        +        regards, tom = +lane = +

+ +
+ +
+ + + + + +------_=_NextPart_001_01C67050.E12DF87E-- + +From pgsql-performance-owner@postgresql.org Fri May 5 11:40:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A50099FA509 + for ; + Fri, 5 May 2006 11:40:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 50865-02 + for ; + Fri, 5 May 2006 11:40:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms048pub.verizon.net (vms048pub.verizon.net [206.46.252.48]) + by postgresql.org (Postfix) with ESMTP id E439F9FA372 + for ; + Fri, 5 May 2006 11:40:41 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.51.88]) + by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYS0047XRFR8UX2@vms048.mailsrvcs.net> for + pgsql-performance@postgresql.org; Fri, 05 May 2006 09:40:40 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 6A80F6E609 for + ; + Fri, 05 May 2006 10:40:34 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id in3Nx4jCGAbW for ; Fri, + 05 May 2006 10:40:33 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 8AFBD6ECAC; Fri, 05 May 2006 10:40:33 -0400 (EDT) +Date: Fri, 05 May 2006 10:40:33 -0400 +From: Michael Stone +Subject: Re: Memory and/or cache issues? +In-reply-to: <0C4841B42F87D51195BD00B0D020F5CB044B2611@MORPHEUS> +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060505144031.GI16533@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Virus-Scanned: Debian amavisd-new at mathom.us +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +References: <0C4841B42F87D51195BD00B0D020F5CB044B2611@MORPHEUS> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/113 +X-Sequence-Number: 18900 + +On Fri, May 05, 2006 at 10:27:10AM -0400, mcelroy, tim wrote: +>Sorry, been up all night and maybe provided too much information or not the +>right information and only confused folks, tired I guess. When I say 'in +>use' I am referring to the 'used' column. + +Which is a mostly irrelevant number. + +>Here's free from PROD001: +>[root@wbibsngwyprod001 kernel]# free -k -t +> total used free shared buffers cached +>Mem: 7643536 6975772 667764 0 165496 5393396 +>-/+ buffers/cache: 1416880 6226656 +>Swap: 8185108 5208 8179900 +>Total: 15828644 6980980 8847664 + +You've got 1.4G in use, 5.3G of disk cache, 165M of buffers and 667M +free. That doesn't seem unreasonable. If an application needs more +memory the amount of disk cache will decrease. As I said in an earlier +email, the problem is that the application is trying to allocate a bogus +amount of memory, not that you have a memory problem. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Fri May 5 11:50:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3AA719FA509 + for ; + Fri, 5 May 2006 11:50:40 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 50140-08 + for ; + Fri, 5 May 2006 11:50:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from morpheus.bostonstock.com (morpheus.bostonstock.com + [192.233.205.44]) + by postgresql.org (Postfix) with ESMTP id 26BE69FA372 + for ; + Fri, 5 May 2006 11:50:20 -0300 (ADT) +Received: by MORPHEUS with Internet Mail Service (5.5.2653.19) + id <2R02CBRA>; Fri, 5 May 2006 10:45:26 -0400 +Message-ID: <0C4841B42F87D51195BD00B0D020F5CB044B2614@MORPHEUS> +From: "mcelroy, tim" +To: 'Michael Stone' , + pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +Date: Fri, 5 May 2006 10:45:21 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C67052.106185F6" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/115 +X-Sequence-Number: 18902 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C67052.106185F6 +Content-Type: text/plain; + charset="iso-8859-1" + +Thanks Michael. Are you saying the 'used' column is the irrelevant number? +Is the number that is more pertinent is 1416880? Is that the actual amount +of memory in use? I agree about the allocation of a bogus amount of memory +but the issue occurred after-hours when the application(s) were not running. +Or are you saying the app whacked the DB during the day and never recovered? + +Tim + + + -----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Michael Stone +Sent: Friday, May 05, 2006 10:41 AM +To: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Memory and/or cache issues? + +On Fri, May 05, 2006 at 10:27:10AM -0400, mcelroy, tim wrote: +>Sorry, been up all night and maybe provided too much information or not the +>right information and only confused folks, tired I guess. When I say 'in +>use' I am referring to the 'used' column. + +Which is a mostly irrelevant number. + +>Here's free from PROD001: +>[root@wbibsngwyprod001 kernel]# free -k -t +> total used free shared buffers cached +>Mem: 7643536 6975772 667764 0 165496 5393396 +>-/+ buffers/cache: 1416880 6226656 +>Swap: 8185108 5208 8179900 +>Total: 15828644 6980980 8847664 + +You've got 1.4G in use, 5.3G of disk cache, 165M of buffers and 667M +free. That doesn't seem unreasonable. If an application needs more +memory the amount of disk cache will decrease. As I said in an earlier +email, the problem is that the application is trying to allocate a bogus +amount of memory, not that you have a memory problem. + +Mike Stone + +---------------------------(end of broadcast)--------------------------- +TIP 5: don't forget to increase your free space map settings + +------_=_NextPart_001_01C67052.106185F6 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] Memory and/or cache issues? + + + +

Thanks Michael.  Are you saying the 'used' = +column is the irrelevant number?  Is the number that is more = +pertinent is 1416880?  Is that the actual amount of memory in = +use?  I agree about the allocation of a bogus amount of memory but = +the issue occurred after-hours when the application(s) were not = +running.  Or are you saying the app whacked the DB during the day = +and never recovered?

+ +

Tim +

+
+ +

 -----Original Message----- +
From:   pgsql-performance-owner@postgresql.org = +[mailto:pgsql-perf= +ormance-owner@postgresql.org]  On Behalf Of Michael = +Stone

+ +

Sent:   Friday, May 05, 2006 10:41 = +AM +
To:     = +pgsql-performance@postgresql.org +
Subject:        = +Re: [PERFORM] Memory and/or cache issues? +

+ +

On Fri, May 05, 2006 at 10:27:10AM -0400, mcelroy, = +tim wrote: +
>Sorry, been up all night and maybe provided too = +much information or not the +
>right information and only confused folks, tired = +I guess.  When I say 'in +
>use' I am referring to the 'used' column. +

+ +

Which is a mostly irrelevant number. +

+ +

>Here's free from PROD001: +
>[root@wbibsngwyprod001 kernel]# free -k = +-t +
>          = +;   total       = +used       free     = +shared    buffers     cached +
>Mem:       = +7643536    6975772     = +667764          = +0     165496    5393396 +
>-/+ buffers/cache:    = +1416880    6226656 +
>Swap:      = +8185108       5208    = +8179900 +
>Total:    = +15828644    6980980    8847664 +

+ +

You've got 1.4G in use, 5.3G of disk cache, 165M of = +buffers and 667M +
free. That doesn't seem unreasonable. If an = +application needs more +
memory the amount of disk cache will decrease. As I = +said in an earlier +
email, the problem is that the application is trying = +to allocate a bogus +
amount of memory, not that you have a memory = +problem. +

+ +

Mike Stone +

+ +

---------------------------(end of = +broadcast)--------------------------- +
TIP 5: don't forget to increase your free space map = +settings +

+ + + +------_=_NextPart_001_01C67052.106185F6-- + +From pgsql-performance-owner@postgresql.org Tue May 9 23:54:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2869B9FA509 + for ; + Fri, 5 May 2006 11:47:04 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 52348-01 + for ; + Fri, 5 May 2006 11:46:52 -0300 (ADT) +X-Greylist: delayed 00:06:39.021932 by SQLgrey- +Received: from listonosz.d1.pl (listonosz.d1.pl [212.244.177.134]) + by postgresql.org (Postfix) with SMTP id 41DF29FA372 + for ; + Fri, 5 May 2006 11:46:51 -0300 (ADT) +Received: (qmail 14688 invoked by uid 11185); 5 May 2006 14:40:17 -0000 +Received: from 212.244.177.188 by listonosz (envelope-from + , uid 129) with qmail +Received: from hq.d1.pl (HELO tekno) (w.strzelczyk@212.244.177.188) + by 0 with SMTP; 5 May 2006 14:40:17 -0000 +From: Witold Strzelczyk +Organization: Digital One sp. z o.o. +To: pgsql-performance@postgresql.org +Subject: slow variable against int?? +Date: Fri, 5 May 2006 16:46:43 +0200 +User-Agent: KMail/1.9.1 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200605051646.44060.w.strzelczyk@digitalone.pl> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/207 +X-Sequence-Number: 18994 + +I have a question about my function. I must get user rating by game result. +This isn't probably a perfect solution but I have one question about + +select into inGameRating count(game_result)+1 from users + where game_result > inRow.game_result; + +This query in function results in about 1100 ms. +inRow.game_result is a integer 2984 +And now if I replace inRow.game_result with integer + +select into inGameRating count(game_result)+1 from users + where game_result > 2984; + +query results in about 100 ms + +There is probably a reason for this but can you tell me about it because I +can't fine one + +My function: + +create or replace function ttt_result(int,int) returns setof tparent_result +language plpgsql volatile as $$ +declare + inOffset alias for $1; + inLimit alias for $2; + inRow tparent_result%rowtype; + inGameResult int := -1; + inGameRating int := -1; +begin + +for inRow in + select + email,wynik_gra + from + konkurs_uzytkownik + order by wynik_gra desc limit inLimit offset inOffset +loop + if inGameResult < 0 then -- only for first iteration + /* this is fast ~100 ms + select into inGameRating + count(game_result)+1 from users + where game_result > 2984; + */ + /* even if inRow.game_result = 2984 this is very slow ~ 1100 ms! + select into inGameRating count(game_result)+1 from users + where game_result > inRow.game_result; + */ + inGameResult := inRow.game_result; + end if; + + if inGameResult > inRow.game_result then + inGameRating := inGameRating + 1; + end if; + + inRow.game_rating := inGameRating; + inGameResult := inRow.game_result; + return next inRow; + +end loop; +return; +end; +$$; +-- +Witold Strzelczyk +witek.strzelczyk@gmail.com + +From pgsql-performance-owner@postgresql.org Fri May 5 11:53:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A9D089FA509 + for ; + Fri, 5 May 2006 11:53:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 52193-06 + for ; + Fri, 5 May 2006 11:53:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from morpheus.bostonstock.com (morpheus.bostonstock.com + [192.233.205.44]) + by postgresql.org (Postfix) with ESMTP id E28249FA372 + for ; + Fri, 5 May 2006 11:53:01 -0300 (ADT) +Received: by MORPHEUS with Internet Mail Service (5.5.2653.19) + id <2R02CBRM>; Fri, 5 May 2006 10:48:07 -0400 +Message-ID: <0C4841B42F87D51195BD00B0D020F5CB044B2615@MORPHEUS> +From: "mcelroy, tim" +To: "'Craig A. James'" +Cc: pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +Date: Fri, 5 May 2006 10:48:01 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C67052.DB34524A" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/116 +X-Sequence-Number: 18903 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C67052.DB34524A +Content-Type: text/plain; + charset="iso-8859-1" + +Thanks for a great explanation Craig, makes more sense now. + +Tim + + -----Original Message----- +From: Craig A. James [mailto:cjames@modgraph-usa.com] +Sent: Friday, May 05, 2006 10:51 AM +To: mcelroy, tim +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Memory and/or cache issues? + +mcelroy, tim wrote: +> Sorry, been up all night and maybe provided too much information or not +> the right information and only confused folks, tired I guess. When I +> say 'in use' I am referring to the 'used' column. Thanks all who have +> responded to this inquiry, I appreciate it. +> +> Here's free from PROD001: +> [root@wbibsngwyprod001 kernel]# free -k -t +> total used free shared buffers cached +> Mem: 7643536 6975772 667764 0 165496 5393396 +> -/+ buffers/cache: 1416880 6226656 +> Swap: 8185108 5208 8179900 +> Total: 15828644 6980980 8847664 + +On Linux (unlike most Unix systems), "used" includes both processes AND the +kernel's file-system buffers, which means "used" will almost always be close +to 100%. Starting with a freshly-booted system, you can issue almost any +command that scans files, and "used" will go up and STAY at nearly 100% of +memory. For example, reboot and try "tar cf - / >/dev/null" and you'll see +the same sort of "used" numbers. + +In My Humble Opinion, this is a mistake in Linux. This confuses just about +everyone the first time they see it (including me), because the file-system +buffers are dynamic and will be relenquished by the kernel if another +process needs memory. On Unix systems, "used" means, "someone else is using +it and you can't have it", which is what most of us really want to know. + +Craig + +------_=_NextPart_001_01C67052.DB34524A +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] Memory and/or cache issues? + + + +

Thanks for a great explanation Craig, makes more = +sense now. +

+ +

Tim +

+ +

 -----Original Message----- +
From:   Craig A. James [mailto:cjames@modgraph-usa.com] +
Sent:   Friday, May 05, 2006 10:51 = +AM +
To:     mcelroy, tim +
Cc:     = +pgsql-performance@postgresql.org +
Subject:        = +Re: [PERFORM] Memory and/or cache issues? +

+ +

mcelroy, tim wrote: +
> Sorry, been up all night and maybe provided too = +much information or not +
> the right information and only confused folks, = +tired I guess.  When I +
> say 'in use' I am referring to the 'used' = +column.  Thanks all who have +
> responded to this inquiry, I appreciate = +it. +
> +
> Here's free from PROD001: +
> [root@wbibsngwyprod001 kernel]# free -k = +-t +
>          = +;    total       = +used       free     = +shared    buffers     cached +
> Mem:       = +7643536    6975772     = +667764          = +0     165496    5393396 +
> -/+ buffers/cache:    = +1416880    6226656 +
> Swap:      = +8185108       5208    = +8179900 +
> Total:    = +15828644    6980980    8847664 +

+ +

On Linux (unlike most Unix systems), "used" = +includes both processes AND the kernel's file-system buffers, which = +means "used" will almost always be close to 100%.  = +Starting with a freshly-booted system, you can issue almost any command = +that scans files, and "used" will go up and STAY at nearly = +100% of memory.  For example, reboot and try "tar cf - / = +>/dev/null" and you'll see the same sort of "used" = +numbers.

+ +

In My Humble Opinion, this is a mistake in = +Linux.  This confuses just about everyone the first time they see = +it (including me), because the file-system buffers are dynamic and will = +be relenquished by the kernel if another process needs memory.  On = +Unix systems, "used" means, "someone else is using it = +and you can't have it", which is what most of us really want to = +know.

+ +

Craig +

+ + + +------_=_NextPart_001_01C67052.DB34524A-- + +From pgsql-performance-owner@postgresql.org Fri May 5 12:16:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3A2449FA372 + for ; + Fri, 5 May 2006 12:16:34 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 56704-03-3 + for ; + Fri, 5 May 2006 12:16:21 -0300 (ADT) +X-Greylist: delayed 00:25:05.8983 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 721CB9FB1C1 + for ; + Fri, 5 May 2006 12:16:21 -0300 (ADT) +Received: from moonunit2.moonview.localnet (wsip-70-167-125-69.sd.sd.cox.net + [70.167.125.69]) + by svr4.postgresql.org (Postfix) with ESMTP id 94B3B5B2116 + for ; + Fri, 5 May 2006 14:51:23 +0000 (GMT) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k45EwPq8017248; Fri, 5 May 2006 07:58:25 -0700 +Message-ID: <445B666E.6000908@modgraph-usa.com> +Date: Fri, 05 May 2006 07:51:26 -0700 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "mcelroy, tim" +Cc: pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +References: <0C4841B42F87D51195BD00B0D020F5CB044B2611@MORPHEUS> +In-Reply-To: <0C4841B42F87D51195BD00B0D020F5CB044B2611@MORPHEUS> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/118 +X-Sequence-Number: 18905 + +mcelroy, tim wrote: +> Sorry, been up all night and maybe provided too much information or not +> the right information and only confused folks, tired I guess. When I +> say 'in use' I am referring to the 'used' column. Thanks all who have +> responded to this inquiry, I appreciate it. +> +> Here's free from PROD001: +> [root@wbibsngwyprod001 kernel]# free -k -t +> total used free shared buffers cached +> Mem: 7643536 6975772 667764 0 165496 5393396 +> -/+ buffers/cache: 1416880 6226656 +> Swap: 8185108 5208 8179900 +> Total: 15828644 6980980 8847664 + +On Linux (unlike most Unix systems), "used" includes both processes AND the kernel's file-system buffers, which means "used" will almost always be close to 100%. Starting with a freshly-booted system, you can issue almost any command that scans files, and "used" will go up and STAY at nearly 100% of memory. For example, reboot and try "tar cf - / >/dev/null" and you'll see the same sort of "used" numbers. + +In My Humble Opinion, this is a mistake in Linux. This confuses just about everyone the first time they see it (including me), because the file-system buffers are dynamic and will be relenquished by the kernel if another process needs memory. On Unix systems, "used" means, "someone else is using it and you can't have it", which is what most of us really want to know. + +Craig + +From pgsql-performance-owner@postgresql.org Fri May 5 11:54:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D48C49FA372 + for ; + Fri, 5 May 2006 11:54:05 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 51799-10 + for ; + Fri, 5 May 2006 11:53:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) + by postgresql.org (Postfix) with ESMTP id A417D9FA509 + for ; + Fri, 5 May 2006 11:53:53 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.51.88]) + by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYS009HQS1RM3V2@vms042.mailsrvcs.net> for + pgsql-performance@postgresql.org; Fri, 05 May 2006 09:53:51 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 2E4596EC9D for + ; + Fri, 05 May 2006 10:53:49 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id ktcjw+MI436t for ; Fri, + 05 May 2006 10:53:48 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 7308D6ECAC; Fri, 05 May 2006 10:53:48 -0400 (EDT) +Date: Fri, 05 May 2006 10:53:48 -0400 +From: Michael Stone +Subject: Re: Memory and/or cache issues? +In-reply-to: <0C4841B42F87D51195BD00B0D020F5CB044B2614@MORPHEUS> +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060505145346.GJ16533@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Virus-Scanned: Debian amavisd-new at mathom.us +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +References: <0C4841B42F87D51195BD00B0D020F5CB044B2614@MORPHEUS> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/117 +X-Sequence-Number: 18904 + +On Fri, May 05, 2006 at 10:45:21AM -0400, mcelroy, tim wrote: +>Thanks Michael. Are you saying the 'used' column is the irrelevant number? +>Is the number that is more pertinent is 1416880? Is that the actual amount +>of memory in use? + +Yes. + +>I agree about the allocation of a bogus amount of memory +>but the issue occurred after-hours when the application(s) were not running. +>Or are you saying the app whacked the DB during the day and never recovered? + +I have no idea why the bogus memory allocation happened. If it continues +to happen you might have data corruption on disk. If it never happens +again, it could have been cosmic rays. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Fri May 5 13:33:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6BB649FA999 + for ; + Fri, 5 May 2006 13:33:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 69323-01 + for ; + Fri, 5 May 2006 13:33:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smarty.gabriel.co.hu (smarty.gabriel.co.hu [195.70.37.16]) + by postgresql.org (Postfix) with ESMTP id 234D29FA4DE + for ; + Fri, 5 May 2006 13:33:36 -0300 (ADT) +Received: from localhost (smarty [127.0.0.1]) + by smarty.gabriel.co.hu (Postfix) with ESMTP id 34A0E46C43 + for ; + Fri, 5 May 2006 18:33:34 +0200 (CEST) +Received: from smarty.gabriel.co.hu ([127.0.0.1]) + by localhost (smarty [127.0.0.1]) (amavisd-new, port 10024) with LMTP + id 10487-03 for ; + Fri, 5 May 2006 18:33:34 +0200 (CEST) +Received: from [192.168.111.135] (customer-174.radio-net.hu [217.113.54.174]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by smarty.gabriel.co.hu (Postfix) with ESMTP id 087C546C31 + for ; + Fri, 5 May 2006 18:33:33 +0200 (CEST) +Message-ID: <445B7E5D.5090601@i-logic.hu> +Date: Fri, 05 May 2006 18:33:33 +0200 +From: =?ISO-8859-1?Q?G=E1briel_=C1kos?= +Organization: I-Logic Kft +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +References: <0C4841B42F87D51195BD00B0D020F5CB044B2614@MORPHEUS> + <20060505145346.GJ16533@mathom.us> +In-Reply-To: <20060505145346.GJ16533@mathom.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at gabriel.co.hu +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/119 +X-Sequence-Number: 18906 + +Michael Stone wrote: +> On Fri, May 05, 2006 at 10:45:21AM -0400, mcelroy, tim wrote: +>> Thanks Michael. Are you saying the 'used' column is the irrelevant +>> number? +>> Is the number that is more pertinent is 1416880? Is that the actual +>> amount +>> of memory in use? +> +> Yes. +> +>> I agree about the allocation of a bogus amount of memory +>> but the issue occurred after-hours when the application(s) were not +>> running. +>> Or are you saying the app whacked the DB during the day and never +>> recovered? +> +> I have no idea why the bogus memory allocation happened. If it continues +> to happen you might have data corruption on disk. If it never happens +> again, it could have been cosmic rays. +> +> Mike Stone + +have you configured your shared memory settings right? +if postgres tries to allocate more memory (because of settings enable +it) than the kernel itself is configured for, then you will see similar +error messages. + +-- +�dv�zlettel, +G�briel �kos +-=E-Mail :akos.gabriel@i-logic.hu|Web: http://www.i-logic.hu=- +-=Tel/fax:+3612367353 |Mobil:+36209278894 =- + +From pgsql-performance-owner@postgresql.org Fri May 5 14:10:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E62D49FA3A3 + for ; + Fri, 5 May 2006 14:10:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 75917-03 + for ; + Fri, 5 May 2006 14:10:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms044pub.verizon.net (vms044pub.verizon.net [206.46.252.44]) + by postgresql.org (Postfix) with ESMTP id E1D019FA4DE + for ; + Fri, 5 May 2006 14:10:00 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.51.88]) + by vms044.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYS007O9YCKSMN5@vms044.mailsrvcs.net> for + pgsql-performance@postgresql.org; Fri, 05 May 2006 12:09:57 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 83EA46EC9D for + ; + Fri, 05 May 2006 13:09:54 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id GBMePo1n7hsz for ; Fri, + 05 May 2006 13:09:54 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id CB3E86ECDA; Fri, 05 May 2006 13:09:53 -0400 (EDT) +Date: Fri, 05 May 2006 13:09:53 -0400 +From: Michael Stone +Subject: Re: Memory and/or cache issues? +In-reply-to: <445B7E5D.5090601@i-logic.hu> +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060505170951.GK16533@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=iso-8859-1; format=flowed +Content-transfer-encoding: 8BIT +Content-disposition: inline +X-Virus-Scanned: Debian amavisd-new at mathom.us +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +References: <0C4841B42F87D51195BD00B0D020F5CB044B2614@MORPHEUS> + <20060505145346.GJ16533@mathom.us> <445B7E5D.5090601@i-logic.hu> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/120 +X-Sequence-Number: 18907 + +On Fri, May 05, 2006 at 06:33:33PM +0200, G�briel �kos wrote: +>if postgres tries to allocate more memory (because of settings enable +>it) than the kernel itself is configured for, then you will see similar +>error messages. + +If you're talking about the shared memory limits, postgres will bomb out +fairly quickly in that case, IIRC. + +Mike Stone + +From pgsql-performance-owner@postgresql.org Tue May 9 23:54:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8BBA39F9C18 + for ; + Fri, 5 May 2006 20:40:00 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 42474-01 + for ; + Fri, 5 May 2006 20:39:55 -0300 (ADT) +X-Greylist: delayed 00:51:59.687145 by SQLgrey- +Received: from ensim.aers.ca (unknown [207.44.172.93]) + by postgresql.org (Postfix) with ESMTP id 980069F96B6 + for ; + Fri, 5 May 2006 20:39:54 -0300 (ADT) +Received: from aers.ca (S0106002018a0e4a3.gv.shawcable.net [24.68.128.78] (may + be forged)) + by ensim.aers.ca (8.11.6/8.11.6) with ESMTP id k45Mlq420036 + for ; Fri, 5 May 2006 15:47:52 -0700 +Subject: Dynamically loaded C function performance +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Date: Fri, 5 May 2006 15:47:53 -0700 +Message-ID: <6B5AF6293A289F45826220B17ABE79370D5ED7@BORON.aers.local> +Content-class: urn:content-classes:message +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Dynamically loaded C function performance +Thread-Index: AcZwUjcXSstds2G2Q3yGl/r133YyMAAQ2e0g +From: "Adam Palmblad" +To: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/209 +X-Sequence-Number: 18996 + +Hi, +We've got a C function that we use here and we find that for every +connection, the first run of the function is much slower than any +subsequent runs. ( 50ms compared to 8ms) + +Besides using connection pooling, are there any options to improve +performance? + +-Adam + +From pgsql-performance-owner@postgresql.org Fri May 5 21:31:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6CCB69F96B6 + for ; + Fri, 5 May 2006 21:31:20 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 46032-08 + for ; + Fri, 5 May 2006 21:31:15 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 41B1D9F9C18 + for ; + Fri, 5 May 2006 21:31:15 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id E354856435; Fri, 5 May 2006 19:31:13 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Fri, 5 May 2006 19:31:13 -0500 +Date: Fri, 5 May 2006 19:31:13 -0500 +From: "Jim C. Nasby" +To: pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +Message-ID: <20060506003113.GC99570@pervasive.com> +References: <0C4841B42F87D51195BD00B0D020F5CB044B2611@MORPHEUS> + <20060505144031.GI16533@mathom.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060505144031.GI16533@mathom.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060506:pgsql-performance@postgresql.org::izLWalGTZXP9Nae9:00000 + 0000000000000000000000001AvI +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/121 +X-Sequence-Number: 18908 + +On Fri, May 05, 2006 at 10:40:33AM -0400, Michael Stone wrote: +> You've got 1.4G in use, 5.3G of disk cache, 165M of buffers and 667M +> free. That doesn't seem unreasonable. If an application needs more + +Actually, it indiciates a bunch of memory not being used, but IIRC Tim's +database is approximately 4G in size, so the 5.3G of disk cache makes +sense if the system was recently rebooted. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri May 5 21:33:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D6B0F9F96B6 + for ; + Fri, 5 May 2006 21:33:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 49371-07 + for ; + Fri, 5 May 2006 21:33:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id CE13E9F9C18 + for ; + Fri, 5 May 2006 21:33:40 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id A611956427; Fri, 5 May 2006 19:33:39 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Fri, 5 May 2006 19:33:39 -0500 +Date: Fri, 5 May 2006 19:33:38 -0500 +From: "Jim C. Nasby" +To: pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +Message-ID: <20060506003338.GD99570@pervasive.com> +References: <0C4841B42F87D51195BD00B0D020F5CB044B2614@MORPHEUS> + <20060505145346.GJ16533@mathom.us> <445B7E5D.5090601@i-logic.hu> + <20060505170951.GK16533@mathom.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060505170951.GK16533@mathom.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060506:pgsql-performance@postgresql.org::8CIkeblH7FGhf2//:00000 + 0000000000000000000000004GBY +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/122 +X-Sequence-Number: 18909 + +On Fri, May 05, 2006 at 01:09:53PM -0400, Michael Stone wrote: +> On Fri, May 05, 2006 at 06:33:33PM +0200, G?briel ?kos wrote: +> >if postgres tries to allocate more memory (because of settings enable +> >it) than the kernel itself is configured for, then you will see similar +> >error messages. +> +> If you're talking about the shared memory limits, postgres will bomb out +> fairly quickly in that case, IIRC. + +More importantly I don't think it would result in trying to allocate 10 +TB or whatever that huge number was. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri May 5 21:35:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AD1C99F9C18 + for ; + Fri, 5 May 2006 21:35:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 47571-07 + for ; + Fri, 5 May 2006 21:35:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id CD79E9F96B6 + for ; + Fri, 5 May 2006 21:35:16 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 8D69056431; Fri, 5 May 2006 19:35:15 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Fri, 5 May 2006 19:35:14 -0500 +Date: Fri, 5 May 2006 19:35:14 -0500 +From: "Jim C. Nasby" +To: "mcelroy, tim" +Cc: 'Michael Stone' , + pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +Message-ID: <20060506003514.GE99570@pervasive.com> +References: <0C4841B42F87D51195BD00B0D020F5CB044B2611@MORPHEUS> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <0C4841B42F87D51195BD00B0D020F5CB044B2611@MORPHEUS> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060506:tim.mcelroy@bostonstock.com::aPMXeJVlO5x5Jgu0:0000000000 + 00000000000000000000000052/X +X-Hashcash: + 1:20:060506:mstone+postgres@mathom.us::3qJTrS7zJVbfKJS4:000000000000 + 0000000000000000000000000klf +X-Hashcash: + 1:20:060506:pgsql-performance@postgresql.org::2Sml/XXXywPNFvsT:00000 + 0000000000000000000000002ITY +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/123 +X-Sequence-Number: 18910 + +On Fri, May 05, 2006 at 10:27:10AM -0400, mcelroy, tim wrote: +> Sorry, been up all night and maybe provided too much information or not the + +Do you have any budget for support or training, either from the company +selling you the app or a company that provides PostgreSQL support? I +suspect some money invested there would result in a lot less +frustration. It'd also certainly be cheaper than switching to Oracle. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Sat May 6 01:34:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9C6839FB0D1 + for ; + Sat, 6 May 2006 01:34:04 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 17896-07 + for ; + Sat, 6 May 2006 01:33:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from skunk.mtbrook.bozemanpass.com (unknown [69.145.82.195]) + by postgresql.org (Postfix) with ESMTP id EC3EE9FA886 + for ; + Sat, 6 May 2006 01:33:52 -0300 (ADT) +Received: from [69.145.82.253] (unknown [69.145.82.253]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by skunk.mtbrook.bozemanpass.com (Postfix) with ESMTP id 35AB655833D + for ; + Fri, 5 May 2006 21:33:51 -0700 (PDT) +Message-ID: <445C272F.3060002@boreham.org> +Date: Fri, 05 May 2006 22:33:51 -0600 +From: David Boreham +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +References: <0C4841B42F87D51195BD00B0D020F5CB044B2608@MORPHEUS> +In-Reply-To: <0C4841B42F87D51195BD00B0D020F5CB044B2608@MORPHEUS> +Content-Type: multipart/alternative; + boundary="------------020008080201030601020006" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/124 +X-Sequence-Number: 18911 + +This is a multi-part message in MIME format. +--------------020008080201030601020006 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + + +> 2006-05-04 18:04:58 EDT USER=postgres DB=FIX1 [12427] PORT = [local] +> ERROR: invalid memory alloc request size 18446744073709551613 + +Perhaps I'm off beam here, but any time I've seen an app try to allocate +a gazillion bytes, it's +due to some code incorrectly calculating the size of something (or more +commonly, using an +initialized variable as the basis for said calculation). + + + +--------------020008080201030601020006 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + +
+
2006-05-04 18:04:58 EDT USER=postgres DB=FIX1 [12427] PORT += [local] ERROR:  invalid memory alloc request size 18446744073709551613
+
+Perhaps I'm off beam here, but any +time I've seen an app try to allocate a gazillion bytes, it's
+due to some code incorrectly calculating the size of something (or more +commonly, using an
+initialized variable as the basis for said calculation).
+
+
+
+ + + +--------------020008080201030601020006-- + +From pgsql-performance-owner@postgresql.org Sat May 6 11:59:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 76D929F9431 + for ; + Sat, 6 May 2006 11:59:00 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 19427-05 + for ; + Sat, 6 May 2006 11:58:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from morpheus.bostonstock.com (unknown [192.233.205.44]) + by postgresql.org (Postfix) with ESMTP id 80DF09F9586 + for ; + Sat, 6 May 2006 11:58:52 -0300 (ADT) +Received: by MORPHEUS with Internet Mail Service (5.5.2653.19) + id <2R02CF06>; Sat, 6 May 2006 10:53:55 -0400 +Message-ID: <0C4841B42F87D51195BD00B0D020F5CB044B2621@MORPHEUS> +From: "mcelroy, tim" +To: pgsql-performance@postgresql.org +Cc: 'Michael Stone' , "'Jim C. Nasby'" + +Subject: Re: Memory and/or cache issues? +Date: Sat, 6 May 2006 10:53:54 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C6711C.E53CC1A8" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/125 +X-Sequence-Number: 18912 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C6711C.E53CC1A8 +Content-Type: text/plain; + charset="iso-8859-1" + +Thank you again to all who have offered advice, suggestions, tips and offers +of support/training. From the gist of some of the latter posts I must come +off as a rank rookie, lol. Deservedly so as I've only been working with +postgres for 7 months and in the linux/unix world a year or so. My +background is Stratus SysAdmin (which I still do in addition to DBA) so the +transition is an on-going process. + +That said, at this time I'll put the thread to rest as my company just +doubled the memory to 16GB, isn't that how it always works out anyway ;) +I'll also be moving the new postgresql.conf settings that were worked out +with the patient help of Jim Nasby, thanks again Jim. The DEV box I put +those on has shown some improvement. As far as outside support and +training, thank you but no. Probably doesn't show but I did attend a week +long PostgreSQL boot camp in January (which I found aimed more to the +development side than DBA by the way), but there is no better way to learn +and understand better than actual day-to-day working experience. + +Thank you, +Tim McElroy + + -----Original Message----- +From: Jim C. Nasby [mailto:jnasby@pervasive.com] +Sent: Friday, May 05, 2006 8:35 PM +To: mcelroy, tim +Cc: 'Michael Stone'; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Memory and/or cache issues? + +On Fri, May 05, 2006 at 10:27:10AM -0400, mcelroy, tim wrote: +> Sorry, been up all night and maybe provided too much information or not +the + +Do you have any budget for support or training, either from the company +selling you the app or a company that provides PostgreSQL support? I +suspect some money invested there would result in a lot less +frustration. It'd also certainly be cheaper than switching to Oracle. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +------_=_NextPart_001_01C6711C.E53CC1A8 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] Memory and/or cache issues? + + + +

Thank you again to all who have offered advice, = +suggestions, tips and offers of support/training.  From the gist = +of some of the latter posts I must come off as a rank rookie, = +lol.  Deservedly so as I've only been working with postgres for 7 = +months and in the linux/unix world a year or so.  My background is = +Stratus SysAdmin (which I still do in addition to DBA) so the = +transition is an on-going process.

+ +

That said, at this time I'll put the thread to rest = +as my company just doubled the memory to 16GB, isn't that how it always = +works out anyway ;)  I'll also be moving the new postgresql.conf = +settings that were worked out with the patient help of Jim Nasby, = +thanks again Jim.  The DEV box I put those on has shown some = +improvement.  As far as outside support and training, thank you = +but no.  Probably doesn't show but I did attend a week long = +PostgreSQL boot camp in January (which I found aimed more to the = +development side than DBA by the way), but there is no better way to = +learn and understand better than actual day-to-day working = +experience.

+ +

Thank you, +
Tim McElroy +

+ +

 -----Original Message----- +
From:   Jim C. Nasby [
mailto:jnasby@pervasive.com] = + +
Sent:   Friday, May 05, 2006 8:35 = +PM +
To:     mcelroy, tim +
Cc:     'Michael Stone'; = +pgsql-performance@postgresql.org +
Subject:        = +Re: [PERFORM] Memory and/or cache issues? +

+ +

On Fri, May 05, 2006 at 10:27:10AM -0400, mcelroy, = +tim wrote: +
> Sorry, been up all night and maybe provided too = +much information or not the +

+ +

Do you have any budget for support or training, = +either from the company +
selling you the app or a company that provides = +PostgreSQL support? I +
suspect some money invested there would result in a = +lot less +
frustration. It'd also certainly be cheaper than = +switching to Oracle. +
-- +
Jim C. Nasby, Sr. Engineering = +Consultant      jnasby@pervasive.com +
Pervasive Software      http://pervasive.com    work: = +512-231-6117 +
vcard: http://jim.nasby.net/pervasive.vcf  &nbs= +p;    cell: 512-569-9461 +

+ + + +------_=_NextPart_001_01C6711C.E53CC1A8-- + +From pgsql-performance-owner@postgresql.org Sat May 6 22:34:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id CF2149F944D + for ; + Sat, 6 May 2006 22:34:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10535-05 + for ; + Sat, 6 May 2006 22:34:41 -0300 (ADT) +X-Greylist: delayed 00:18:38.204614 by SQLgrey- +Received: from mta5.adelphia.net (mta5.adelphia.net [68.168.78.187]) + by postgresql.org (Postfix) with ESMTP id EB7909FA4DE + for ; + Sat, 6 May 2006 22:34:41 -0300 (ADT) +Received: from [10.1.2.102] (really [70.33.56.85]) by mta13.adelphia.net + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP + id <20060507011601.XUFQ27153.mta13.adelphia.net@[10.1.2.102]> + for ; + Sat, 6 May 2006 21:16:01 -0400 +From: "Ed L." +To: "pgsql-performance@postgresql.org" +Subject: pg_dump index creation order +Date: Sat, 6 May 2006 19:15:55 -0600 +User-Agent: KMail/1.8.1 +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200605061915.55712.pgsql@bluepolka.net> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/126 +X-Sequence-Number: 18913 + +I'm watching a long, painfully slow 60GB load from pg_dump +(8.1.2), and noticing it's jumping back and forth from different +tables. I assume this is the index creation order showing up. + +Would it make more sense to have pg_dump dump indexes grouped by +the table? That way, if a table got loaded into cache for one +index creation, it might still be there for the immediatly +following index creations on the same table... + +Ed + +From pgsql-performance-owner@postgresql.org Sun May 7 00:09:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B25399FA42B + for ; + Sun, 7 May 2006 00:09:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29789-01 + for ; + Sun, 7 May 2006 00:09:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mta11.adelphia.net (mta11.adelphia.net [68.168.78.205]) + by postgresql.org (Postfix) with ESMTP id 09FF09FA2FA + for ; + Sun, 7 May 2006 00:09:22 -0300 (ADT) +Received: from [10.1.2.102] (really [70.33.56.85]) by mta11.adelphia.net + (InterMail vM.6.01.05.02 201-2131-123-102-20050715) with ESMTP + id <20060507030922.LPGC9009.mta11.adelphia.net@[10.1.2.102]> + for ; + Sat, 6 May 2006 23:09:22 -0400 +From: "Ed L." +To: "pgsql-performance@postgresql.org" +Subject: Re: pg_dump index creation order +Date: Sat, 6 May 2006 21:09:20 -0600 +User-Agent: KMail/1.8.1 +References: <200605061915.55712.pgsql@bluepolka.net> +In-Reply-To: <200605061915.55712.pgsql@bluepolka.net> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200605062109.21084.pgsql@bluepolka.net> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/127 +X-Sequence-Number: 18914 + +On Saturday May 6 2006 7:15 pm, Ed L. wrote: +> I'm watching a long, painfully slow 60GB load from pg_dump +> (8.1.2), and noticing it's jumping back and forth from +> different tables. I assume this is the index creation order +> showing up. +> +> Would it make more sense to have pg_dump dump indexes grouped +> by the table? That way, if a table got loaded into cache for +> one index creation, it might still be there for the immediatly +> following index creations on the same table... + +And would same idea work for ordering of constraint adding...? + +Ed + +From pgsql-performance-owner@postgresql.org Sun May 7 14:08:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7F8729FA334 + for ; + Sun, 7 May 2006 14:08:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 12563-03 + for ; + Sun, 7 May 2006 14:08:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 3871D9F9806 + for ; + Sun, 7 May 2006 14:08:17 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 4B2E456427; Sun, 7 May 2006 12:08:11 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Sun, 7 May 2006 12:08:11 -0500 +Date: Sun, 7 May 2006 12:08:10 -0500 +From: "Jim C. Nasby" +To: "Ed L." +Cc: "pgsql-performance@postgresql.org" +Subject: Re: pg_dump index creation order +Message-ID: <20060507170810.GL99570@pervasive.com> +References: <200605061915.55712.pgsql@bluepolka.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200605061915.55712.pgsql@bluepolka.net> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060507:pgsql@bluepolka.net::IiTTjhoGElGWaS0x:000000000000000000 + 0000000000000000000000000O1r +X-Hashcash: + 1:20:060507:pgsql-performance@postgresql.org::/QMnUCoJVf9LrzXd:00000 + 0000000000000000000000000Myt +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/128 +X-Sequence-Number: 18915 + +On Sat, May 06, 2006 at 07:15:55PM -0600, Ed L. wrote: +> I'm watching a long, painfully slow 60GB load from pg_dump +> (8.1.2), and noticing it's jumping back and forth from different +> tables. I assume this is the index creation order showing up. +> +> Would it make more sense to have pg_dump dump indexes grouped by +> the table? That way, if a table got loaded into cache for one +> index creation, it might still be there for the immediatly +> following index creations on the same table... + +It might for smaller tables that will fit in cache, but it depends on +how much memory is used for sorting. In fact, I think it would be best +to add the indexes immediately after loading the table with data. + +This won't help with adding indexes on large tables though, unless +the indexes were created simultaneously, and even that might not be a +win. + +It would be a win to add some constraints at the same time, but RI can't +be added until all tables are indexed. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon May 8 06:06:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 489869F9C9E + for ; + Mon, 8 May 2006 06:06:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 91938-08 + for ; + Mon, 8 May 2006 06:06:34 -0300 (ADT) +X-Greylist: delayed 00:18:37.995988 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 722A09F9C18 + for ; + Mon, 8 May 2006 06:06:31 -0300 (ADT) +Received: from grp-smtp.toray.com.my (grp-smtp.toray.com.my [202.186.44.7]) + by svr4.postgresql.org (Postfix) with ESMTP id D22315B5CB3 + for ; + Mon, 8 May 2006 08:47:51 +0000 (GMT) +Received: from localhost (localhost.toray.com.my [127.0.0.1]) + by grp-smtp.toray.com.my (Postfix) with ESMTP id D347050850 + for ; + Mon, 8 May 2006 16:47:42 +0800 (MYT) +X-Virus-Scanned: amavisd-new at pengroup.com.my +Received: from grp-smtp.toray.com.my ([127.0.0.1]) + by localhost (grp-smtp.pengroup.com.my [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id W5k4TmhdXBKF for ; + Mon, 8 May 2006 16:47:42 +0800 (MYT) +Received: from notes01.pengroup.com.my (notes01.toray.com.my [10.200.1.1]) + by grp-smtp.toray.com.my (Postfix) with ESMTP id 213CC50852 + for ; + Mon, 8 May 2006 16:47:42 +0800 (MYT) +Subject: extremely slow when execute select/delete for certain tables only... +To: "pgsql-performance@postgresql.org" +X-Mailer: Lotus Notes Release 5.0.5 September 22, 2000 +Message-ID: +From: kah_hang_ang@toray.com.my +Date: Mon, 8 May 2006 16:47:44 +0800 +X-MIMETrack: Serialize by Router on Notes01/Pen-Group(Release 6.5.1|January + 21, + 2004) at 05/08/2006 04:47:43 PM +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/129 +X-Sequence-Number: 18916 + + + + + +I'm facing a very weird problem. +Recently our database run very slow when execute Delete/Select statement +for a few tables only.. +The largest table only have 50K rows of data. + +When I run the statement from pgAdmin although it is slow but not as slow +as run from webapp. +When I run the statement from webapp, it become extremely slow. +Even a simple delete statement will takes 20-40 minutes to complete. + +I already vacuum those tables with full option but it still the same. + +What could be the possible causes of this problem? +How can I solve it? + +CPU - Intel Xeon 2.40 GHz +Memory - 1.5G +Postgresql version: 7.2.2 + +Thanks. + + +From pgsql-performance-owner@postgresql.org Mon May 8 06:21:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6D1199F9C9E + for ; + Mon, 8 May 2006 06:21:17 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 90951-09 + for ; + Mon, 8 May 2006 06:21:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 047E79F9C18 + for ; + Mon, 8 May 2006 06:21:08 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (T8ffb.t.pppool.de + [89.55.143.251]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 20A7965800; + Mon, 8 May 2006 11:22:17 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id D33A418148BCE; + Mon, 8 May 2006 11:21:16 +0200 (CEST) +Message-ID: <445F0D8C.3040106@logix-tt.com> +Date: Mon, 08 May 2006 11:21:16 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: kah_hang_ang@toray.com.my +Cc: "pgsql-performance@postgresql.org" +Subject: Re: extremely slow when execute select/delete for certain +References: +In-Reply-To: +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/130 +X-Sequence-Number: 18917 + +Hi, Kah, + +kah_hang_ang@toray.com.my wrote: + +> I already vacuum those tables with full option but it still the same. +> +> What could be the possible causes of this problem? +> How can I solve it? +> +> CPU - Intel Xeon 2.40 GHz +> Memory - 1.5G +> Postgresql version: 7.2.2 + +First, you should consider to upgrade your PostgreSQL server to a newer +version, at least to 7.2.8 which fixes some critical bugs. + +But it will be much better to upgrade to current 8.1 version, as I think +that your problem is caused by index bloat, and indices are handled much +better in 8.1. + +Try recreating your indices using REINDEX command. + +HTH, +Markus + + + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Mon May 8 08:00:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 70CE99F9DD1 + for ; + Mon, 8 May 2006 08:00:05 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 08199-10 + for ; + Mon, 8 May 2006 07:59:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 67DE89F96B6 + for ; + Mon, 8 May 2006 07:59:52 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id C64F931509; Mon, 8 May 2006 12:59:50 +0200 (MET DST) +From: "Andrus" +X-Newsgroups: pgsql.performance +Subject: Query runs 38 seconds for small database! +Date: Mon, 8 May 2006 13:59:39 +0300 +Organization: Hub.Org Networking Services +Lines: 360 +Message-ID: +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/131 +X-Sequence-Number: 18918 + +I have small database. However the following query takes 38 (!) seconds to +run. +How to speed it up (preferably not changing table structures but possibly +creating indexes) ? + +Andrus. + +set search_path to public,firma1; +explain analyze select bilkaib.summa from BILKAIB join KONTO CRKONTO ON +bilkaib.cr=crkonto.kontonr AND + crkonto.iseloom='A' + join KONTO DBKONTO ON bilkaib.db=dbkonto.kontonr AND + dbkonto.iseloom='A' + left join klient on bilkaib.klient=klient.kood + where ( bilkaib.cr LIKE '3'||'%' OR + bilkaib.db LIKE '3'||'%' ) + AND bilkaib.kuupaev BETWEEN '2006-01-01' AND '2006-03-31' +AND ( kuupaev='20060101' OR (cr!='00' and db!='00')) +AND ( 3 IN(2,3) or (NOT bilkaib.ratediffer and ( + TRIM(bilkaib.masin)='' or bilkaib.masin IS NULL or + bilkaib.alusdok not in ('KV', 'DU', 'DJ') or +bilkaib.andmik is NULL or bilkaib.alusdok is NULL or +substring(andmik from 1 for 9)!='Kursivahe' + ))) and +( position(bilkaib.laustyyp IN 'x')=0 or +bilkaib.laustyyp is null or bilkaib.laustyyp=' ') + + +"Nested Loop Left Join (cost=23.30..1964.10 rows=1 width=10) (actual +time=7975.470..38531.724 rows=3151 loops=1)" +" -> Nested Loop (cost=23.30..1958.08 rows=1 width=26) (actual +time=7975.407..37978.718 rows=3151 loops=1)" +" Join Filter: ("inner".cr = "outer".kontonr)" +" -> Seq Scan on konto crkonto (cost=0.00..23.30 rows=1 width=44) +(actual time=0.135..13.913 rows=219 loops=1)" +" Filter: (iseloom = 'A'::bpchar)" +" -> Hash Join (cost=23.30..1934.64 rows=11 width=40) (actual +time=1.650..155.734 rows=3151 loops=219)" +" Hash Cond: ("outer".db = "inner".kontonr)" +" -> Index Scan using bilkaib_kuupaev_idx on bilkaib +(cost=0.00..1897.10 rows=2826 width=54) (actual time=1.628..111.216 +rows=3151 loops=219)" +" Index Cond: ((kuupaev >= '2006-01-01'::date) AND +(kuupaev <= '2006-03-31'::date))" +" Filter: (((cr ~~ '3%'::text) OR (db ~~ '3%'::text)) AND +((kuupaev = '2006-01-01'::date) OR ((cr <> '00'::bpchar) AND (db <> +'00'::bpchar))) AND (("position"('x'::text, (laustyyp)::text) = 0) OR +(laustyyp IS NULL) OR (laustyyp = ' '::bpc (..)" +" -> Hash (cost=23.30..23.30 rows=1 width=44) (actual +time=2.278..2.278 rows=219 loops=1)" +" -> Seq Scan on konto dbkonto (cost=0.00..23.30 rows=1 +width=44) (actual time=0.017..1.390 rows=219 loops=1)" +" Filter: (iseloom = 'A'::bpchar)" +" -> Index Scan using klient_pkey on klient (cost=0.00..6.01 rows=1 +width=52) (actual time=0.138..0.158 rows=1 loops=3151)" +" Index Cond: ("outer".klient = klient.kood)" +"Total runtime: 38561.745 ms" + + + + + +CREATE TABLE firma1.bilkaib +( + id int4 NOT NULL DEFAULT nextval('bilkaib_id_seq'::regclass), + kuupaev date NOT NULL, + db char(10) NOT NULL, + dbobjekt char(10), + cr char(10) NOT NULL, + crobjekt char(10), + summa numeric(14,2) NOT NULL, + raha char(3) NOT NULL, + masin char(5), + klient char(12), + alusdok char(2), + dokumnr int4 NOT NULL DEFAULT nextval('bilkaib_dokumnr_seq'::regclass), + db2objekt char(10), + cr2objekt char(10), + db3objekt char(10), + db4objekt char(10), + db5objekt char(10), + db6objekt char(10), + db7objekt char(10), + db8objekt char(10), + db9objekt char(10), + cr3objekt char(10), + cr4objekt char(10), + cr5objekt char(10), + cr6objekt char(10), + cr7objekt char(10), + cr8objekt char(10), + cr9objekt char(10), + exchrate numeric(13,8), + doknr char(25), + andmik text, + laustyyp char(1), + ratediffer ebool, + adoknr char(25), + jarjeknr numeric(7), + CONSTRAINT bilkaib_pkey PRIMARY KEY (id), + CONSTRAINT bilkaib_alusdok_fkey FOREIGN KEY (alusdok) + REFERENCES firma1.alusdok (alusdok) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_cr2objekt_fkey FOREIGN KEY (cr2objekt) + REFERENCES firma1.yksus2 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_cr3objekt_fkey FOREIGN KEY (cr3objekt) + REFERENCES firma1.yksus3 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_cr4objekt_fkey FOREIGN KEY (cr4objekt) + REFERENCES firma1.yksus4 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_cr5objekt_fkey FOREIGN KEY (cr5objekt) + REFERENCES firma1.yksus5 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_cr6objekt_fkey FOREIGN KEY (cr6objekt) + REFERENCES firma1.yksus6 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_cr7objekt_fkey FOREIGN KEY (cr7objekt) + REFERENCES firma1.yksus7 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_cr8objekt_fkey FOREIGN KEY (cr8objekt) + REFERENCES firma1.yksus8 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_cr9objekt_fkey FOREIGN KEY (cr9objekt) + REFERENCES firma1.yksus9 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_cr_fkey FOREIGN KEY (cr) + REFERENCES firma1.konto (kontonr) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_crobjekt_fkey FOREIGN KEY (crobjekt) + REFERENCES firma1.yksus1 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_db2objekt_fkey FOREIGN KEY (db2objekt) + REFERENCES firma1.yksus2 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_db3objekt_fkey FOREIGN KEY (db3objekt) + REFERENCES firma1.yksus3 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_db4objekt_fkey FOREIGN KEY (db4objekt) + REFERENCES firma1.yksus4 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_db5objekt_fkey FOREIGN KEY (db5objekt) + REFERENCES firma1.yksus5 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_db6objekt_fkey FOREIGN KEY (db6objekt) + REFERENCES firma1.yksus6 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_db7objekt_fkey FOREIGN KEY (db7objekt) + REFERENCES firma1.yksus7 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_db8objekt_fkey FOREIGN KEY (db8objekt) + REFERENCES firma1.yksus8 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_db9objekt_fkey FOREIGN KEY (db9objekt) + REFERENCES firma1.yksus9 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_db_fkey FOREIGN KEY (db) + REFERENCES firma1.konto (kontonr) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_dbobjekt_fkey FOREIGN KEY (dbobjekt) + REFERENCES firma1.yksus1 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_klient_fkey FOREIGN KEY (klient) + REFERENCES firma1.klient (kood) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_raha_fkey FOREIGN KEY (raha) + REFERENCES raha (raha) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT bilkaib_id_check CHECK (id > 0) +) +WITHOUT OIDS; + +CREATE INDEX bilkaib_dokumnr_idx ON firma1.bilkaib USING btree (dokumnr); + +CREATE INDEX bilkaib_kuupaev_idx ON firma1.bilkaib USING btree (kuupaev); + + +CREATE TABLE firma1.konto +( + kontonr char(10) NOT NULL, + tyyp char(1) NOT NULL, + klienkaupa ebool, + arvekaupa ebool, + objekt1 char(1), + objekt2 char(1), + objekt3 char(1), + objekt4 char(1), + objekt5 char(1), + objekt6 char(1), + objekt7 char(1), + objekt8 char(1), + objekt9 char(1), + tekst char(55), + rustekst char(55), + engtekst char(55), + fintekst char(55), + lvltekst char(55), + raha char(3) NOT NULL, + kontoklass char(10), + grupp char(13), + klient char(12), + iseloom char(1), + kontokl2 char(10), + kontokl3 char(10), + eelklassif char(10), + klassif8 char(10), + rid3obj char(1), + rid4obj char(1), + koondkonto char(10), + kaibedrida char(6), + CONSTRAINT konto_pkey PRIMARY KEY (kontonr), + CONSTRAINT konto_klassif8_fkey FOREIGN KEY (klassif8) + REFERENCES firma1.yksus8 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT konto_klient_fkey FOREIGN KEY (klient) + REFERENCES firma1.klient (kood) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT konto_kontokl2_fkey FOREIGN KEY (kontokl2) + REFERENCES bilskeem2 (kontoklass) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT konto_kontokl3_fkey FOREIGN KEY (kontokl3) + REFERENCES bilskeem3 (kontoklass) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT konto_kontoklass_fkey FOREIGN KEY (kontoklass) + REFERENCES bilskeem1 (kontoklass) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT konto_raha_fkey FOREIGN KEY (raha) + REFERENCES raha (raha) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE +) +WITHOUT OIDS; + +CREATE TRIGGER konto_trig BEFORE INSERT OR UPDATE OR DELETE + ON firma1.konto FOR EACH STATEMENT EXECUTE PROCEDURE setlastchange(); + + +CREATE TABLE firma1.klient +( + kood char(12) NOT NULL DEFAULT nextval('klient_kood_seq'::regclass), + nimi char(70), + a_a char(35), + p_kood char(10), + regnr char(12), + vatpayno char(15), + piirkond char(30), + postiindek char(10), + tanav char(30), + kontaktisi char(30), + telefon char(25), + faks char(25), + email char(60), + infomail char(60), + wwwpage char(50), + liik char(10), + viitenr char(20), + riik char(20), + riik2 char(2), + riigikood char(3), + hinnak char(5), + erihinnak char(5), + myygikood char(4), + objekt2 char(10), + objekt5 char(10), + objekt7 char(10), + maksetin char(5), + omakseti char(5), + krediit numeric(12,2), + ostukredii numeric(12,2), + masin char(5), + info text, + maksja char(12), + "timestamp" char(14) NOT NULL DEFAULT to_char(now(), +'YYYYMMDDHH24MISS'::text), + atimestamp char(14) NOT NULL DEFAULT to_char(now(), +'YYYYMMDDHH24MISS'::text), + elanikud numeric(3), + pindala numeric(7,2), + grmaja char(10), + apindala numeric(7,2), + kpindala numeric(7,2), + idmakett char(36), + tulemus char(100), + omandisuhe char(1), + username char(10), + changedby char(10), + parool char(20), + hinnaale char(4), + mitteakt ebool, + kontakteer date, + klikaart char(16), + mhprotsent numeric(5,1), + aadress text, + swift char(20), + pankaad char(20), + _nimi char(70), + CONSTRAINT klient_pkey PRIMARY KEY (kood), + CONSTRAINT klient_changedby_fkey FOREIGN KEY (changedby) + REFERENCES kasutaja (kasutaja) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_grmaja_fkey FOREIGN KEY (grmaja) + REFERENCES firma1.yksus1 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_hinnak_fkey FOREIGN KEY (hinnak) + REFERENCES firma1.hkpais (hinnak) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_idmakett_fkey FOREIGN KEY (idmakett) + REFERENCES makett (guid) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_liik_fkey FOREIGN KEY (liik) + REFERENCES klliik (liik) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_maksetin_fkey FOREIGN KEY (maksetin) + REFERENCES maksetin (maksetin) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_maksja_fkey FOREIGN KEY (maksja) + REFERENCES firma1.klient (kood) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_myygikood_fkey FOREIGN KEY (myygikood) + REFERENCES firma1.myygikoo (myygikood) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_objekt2_fkey FOREIGN KEY (objekt2) + REFERENCES firma1.yksus2 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_objekt5_fkey FOREIGN KEY (objekt5) + REFERENCES firma1.yksus5 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_objekt7_fkey FOREIGN KEY (objekt7) + REFERENCES firma1.yksus7 (yksus) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_omakseti_fkey FOREIGN KEY (omakseti) + REFERENCES maksetin (maksetin) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_p_kood_fkey FOREIGN KEY (p_kood) + REFERENCES pank (kood) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_riik2_fkey FOREIGN KEY (riik2) + REFERENCES riik (kood) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE NO ACTION DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_username_fkey FOREIGN KEY (username) + REFERENCES kasutaja (kasutaja) MATCH SIMPLE + ON UPDATE CASCADE ON DELETE SET NULL DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT klient_email_check CHECK (rtrim(email::text) ~* +E'^[^@]*@(?:[^@]*\\.)?[a-z0-9_-]+\\.(?:a[defgilmnoqrstuwz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvxyz]|d[ejkmoz]|e[ceghrst]|f[ijkmorx]|g[abdefhilmnpqrstuwy]|h[kmnrtu]|i[delnoqrst]|j[mop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrtwy]|qa|r[eouw]|s[abcdeghijklmnortvyz]|t[cdfghjkmnoprtvwz]|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw]|edu|com|net|org|gov|mil|info|biz|coop|museum|aero|name|pro|mobi|arpa)$'::text) +) +WITHOUT OIDS; + + +CREATE UNIQUE INDEX klient_nimi_unique_idx + ON firma1.klient USING btree (lower(nimi::text)); + + +Server: + +"PostgreSQL 8.1.3 on i386-portbld-freebsd5.4, compiled by GCC cc (GCC) 3.4.2 +[FreeBSD] 20040728" + +Client: ODBC driver in XP + + + +From pgsql-performance-owner@postgresql.org Mon May 8 11:47:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 36E8A9F9DD1 + for ; + Mon, 8 May 2006 11:47:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 39179-05 + for ; + Mon, 8 May 2006 11:46:59 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id D13599F96B6 + for ; + Mon, 8 May 2006 11:46:59 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k48EksgI026839; + Mon, 8 May 2006 10:46:54 -0400 (EDT) +To: "Andrus" +cc: pgsql-performance@postgresql.org +Subject: Re: Query runs 38 seconds for small database! +In-reply-to: +References: +Comments: In-reply-to "Andrus" + message dated "Mon, 08 May 2006 13:59:39 +0300" +Date: Mon, 08 May 2006 10:46:54 -0400 +Message-ID: <26838.1147099614@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/132 +X-Sequence-Number: 18919 + +"Andrus" writes: +> I have small database. However the following query takes 38 (!) seconds to +> run. +> How to speed it up (preferably not changing table structures but possibly +> creating indexes) ? + +ANALYZE would probably help. + +> " -> Seq Scan on konto dbkonto (cost=0.00..23.30 rows=1 +> width=44) (actual time=0.017..1.390 rows=219 loops=1)" +> " Filter: (iseloom = 'A'::bpchar)" + +Anytime you see a row estimate that far off about a simple single-column +condition, it means your statistics are out-of-date. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon May 8 12:06:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 231619FA2F8 + for ; + Mon, 8 May 2006 12:06:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 44472-02 + for ; + Mon, 8 May 2006 12:06:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id E9CA49F9DD1 + for ; + Mon, 8 May 2006 12:06:44 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id 13898B827 + for ; + Mon, 8 May 2006 11:06:43 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <0C4841B42F87D51195BD00B0D020F5CB044B2621@MORPHEUS> +References: <0C4841B42F87D51195BD00B0D020F5CB044B2621@MORPHEUS> +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-9--857605966; + protocol="application/pkcs7-signature" +Message-Id: <2680CBB8-985E-4C12-BCBB-72D49AA070EE@khera.org> +From: Vivek Khera +Subject: Re: Memory and/or cache issues? +Date: Mon, 8 May 2006 11:06:42 -0400 +To: Pgsql performance +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/133 +X-Sequence-Number: 18920 + + +--Apple-Mail-9--857605966 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + + +On May 6, 2006, at 10:53 AM, mcelroy, tim wrote: + +> development side than DBA by the way), but there is no better way +> to learn +> and understand better than actual day-to-day working experience. + +Yeah, I prefer my surgeons to work this way too. training is for the +birds. + + +--Apple-Mail-9--857605966 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGlDCCAz8w +ggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0 +ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcx +KDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1RoYXd0 +ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVyc29uYWwtZnJlZW1haWxA +dGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5NTlaMGIxCzAJBgNVBAYTAlpB +MSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUg +UGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA +xKY8VXNV+065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/Uc4B1OVQCjDXAmNaLIkVcI7d +yfArhVqqP3FWy688Cwfn8R+RNiQqE88r1fOCdz0Dviv+uxg+B79AgAJk16emu59l0cUqVIUPSAR/ +p7bRPGEEQB5kGXJgt/sCAwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/AgEAMEMGA1UdHwQ8MDow +OKA2oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25hbEZyZWVtYWlsQ0EuY3Js +MAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRUHJpdmF0ZUxhYmVsMi0xMzgw +DQYJKoZIhvcNAQEFBQADgYEASIzRUIPqCy7MDaNmrGcPf6+svsIXoUOWlJ1/TCG4+DYfqi2fNi/A +9BxQIJNwPP2t4WFiw9k6GX6EsZkbAMUaC4J0niVQlGLH2ydxVyWN3amcOY6MIE9lX5Xa9/eH1sYI +Tq726jTlEBpbNU1341YheILcIRk13iSx0x1G/11fZU8wggNNMIICtqADAgECAhA6sDoA4m3lcimf +yUtGSQgmMA0GCSqGSIb3DQEBBAUAMGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29u +c3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNz +dWluZyBDQTAeFw0wNjA1MDIxNDEyNDdaFw0wNzA1MDIxNDEyNDdaMIGKMR8wHQYDVQQDExZUaGF3 +dGUgRnJlZW1haWwgTWVtYmVyMR4wHAYJKoZIhvcNAQkBFg92aXZla0BraGVyYS5vcmcxIDAeBgkq +hkiG9w0BCQEWEWtoZXJhQGtjaWxpbmsuY29tMSUwIwYJKoZIhvcNAQkBFhZ2aXZla0BtYWlsZXJt +YWlsZXIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq+zHKYq9vZ4Dq1itNqT/ +OeJvWDvQ5JdQlRzwsJlvtJBknXsnOaJNabmjnu2s6XFMcP2srBZQ/WPvhsClajLQOcxnarrfB66N +DpMzXTxfYzX6m9TA/fEn64sNn+YnBZL6Dvid9kiAgP9LmqcTOIFdWUya3ZmQS5YTuLB+tkFSL8/h ++inDPN6dcsna8TcM1SAk+3upxOR7kyFM9T3vy25w62Nh1zK7Stp0vUZLU6GzzC1VvHGZHKGticD6 +o3uHaMr2LCFjptoIcfZL75LO/UaR9o7smgboW4yJyW5g9ZasyYQUXyvkitfyZuVWATb8ZSHOkjWJ +872Pyf5+HOevVUI0aQIDAQABo1cwVTBFBgNVHREEPjA8gQ92aXZla0BraGVyYS5vcmeBEWtoZXJh +QGtjaWxpbmsuY29tgRZ2aXZla0BtYWlsZXJtYWlsZXIuY29tMAwGA1UdEwEB/wQCMAAwDQYJKoZI +hvcNAQEEBQADgYEAYpaFKDj47pTQIUQi28MgtjKophopv4QJjvspXmy0qxd8t/M/zc7HuBy3i/9a +PrXDgKyNBzzlFTasTazAY53ntVpqw9k1NOeHmH6o3j/DBVa49bC6bbWfp9UGOwYChlDR0tngQZyC +MDMZEdYv4zpGfBTku5m1jb8Yz/qYqV4FWB4xggMQMIIDDAIBATB2MGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIQOrA6AOJt5XIpn8lLRkkIJjAJBgUrDgMCGgUAoIIB +bzAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjA1MDgxNTA2NDJa +MCMGCSqGSIb3DQEJBDEWBBRU+beM4lATq5aubRlaiGc1pmMD/zCBhQYJKwYBBAGCNxAEMXgwdjBi +MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoG +A1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECEDqwOgDibeVyKZ/JS0ZJ +CCYwgYcGCyqGSIb3DQEJEAILMXigdjBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENv +bnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElz +c3VpbmcgQ0ECEDqwOgDibeVyKZ/JS0ZJCCYwDQYJKoZIhvcNAQEBBQAEggEAYPb1nFEju5IWtt01 +kaJfIGWl05mAFDfqPgTaUDTVcS6/5sisbNW+ILq/1QhuVF+0aEJUASbQ84hrPOQYLrhG7enFYwZp +PmgaTZDq4i2W9yh1GJwIbdQsAiU3b7FKEzPMzGhTWdVR/T2VrgWEo1wGIluGaOhgRF7U+pi29gcJ +G234LqrpXOILpYrZVP9r7oiFtrwFhf7f50f256pilvNOv9GqzgntQANjkKE/PDBpSp9V25x0DtF5 +uyhP0VaTKMsbE678cRe3PsdKQl9Fb+HbGdNyfEvWyjBHPGt3AJqDNj2jPJI8LvGPiI4VbUHQb8kq +z24ya97/rHwQG0OB0hfyIwAAAAAAAA== + +--Apple-Mail-9--857605966-- + +From pgsql-performance-owner@postgresql.org Mon May 8 13:18:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 573DA9F931E + for ; + Mon, 8 May 2006 13:18:01 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 53695-07 + for ; + Mon, 8 May 2006 13:17:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 030279F931D + for ; + Mon, 8 May 2006 13:17:49 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 878A13150B; Mon, 8 May 2006 18:17:48 +0200 (MET DST) +From: "Andrus" +X-Newsgroups: pgsql.performance +Subject: Re: Query runs 38 seconds for small database! +Date: Mon, 8 May 2006 19:15:36 +0300 +Organization: Hub.Org Networking Services +Lines: 43 +Message-ID: +References: <26838.1147099614@sss.pgh.pa.us> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/134 +X-Sequence-Number: 18921 + +>> " -> Seq Scan on konto dbkonto (cost=0.00..23.30 +>> rows=1 +>> width=44) (actual time=0.017..1.390 rows=219 loops=1)" +>> " Filter: (iseloom = 'A'::bpchar)" +> +> Anytime you see a row estimate that far off about a simple single-column +> condition, it means your statistics are out-of-date. + +Than you. I addded ANALYZE command and now query works fast. + +I see autovacuum: processing database "mydb" messages in log file and I have + +stats_start_collector = on +stats_row_level = on + +in config file. Why statistics was out-of-date ? + +Andrus. + + +My postgres.conf file (only uncommented settings are listed): + +listen_addresses = '*' +max_connections = 40 +shared_buffers = 1000 +log_destination = 'stderr' +redirect_stderr = on # Enable capturing of stderr into log +log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # Log file name pattern. +log_rotation_age = 1440 # Automatic rotation of logfiles will +log_rotation_size = 10240 # Automatic rotation of logfiles will +log_min_error_statement = 'warning' # Values in order of increasing +severity: +silent_mode = on +log_line_prefix = "'%t %u %d %h %p %i %l %x %q'" +stats_start_collector = on +stats_row_level = on +autovacuum = on # enable autovacuum subprocess? +lc_messages = 'C' # locale for system error message +lc_monetary = 'C' # locale for monetary formatting +lc_numeric = 'C' # locale for number formatting +lc_time = 'C' # locale for time formatting + + + +From pgsql-performance-owner@postgresql.org Mon May 8 13:27:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id EA8F99F931E + for ; + Mon, 8 May 2006 13:27:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 55285-02 + for ; + Mon, 8 May 2006 13:27:11 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 049E49F931D + for ; + Mon, 8 May 2006 13:27:10 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k48GR6ef027600; + Mon, 8 May 2006 12:27:06 -0400 (EDT) +To: "Andrus" +cc: pgsql-performance@postgresql.org +Subject: Re: Query runs 38 seconds for small database! +In-reply-to: +References: <26838.1147099614@sss.pgh.pa.us> + +Comments: In-reply-to "Andrus" + message dated "Mon, 08 May 2006 19:15:36 +0300" +Date: Mon, 08 May 2006 12:27:06 -0400 +Message-ID: <27599.1147105626@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/135 +X-Sequence-Number: 18922 + +"Andrus" writes: +> I see autovacuum: processing database "mydb" messages in log file and I have +> stats_start_collector = on +> stats_row_level = on +> in config file. Why statistics was out-of-date ? + +The default autovac thresholds are not very aggressive; this table was +probably not large enough to get selected for analysis. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon May 8 14:06:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id ACFD19F931E + for ; + Mon, 8 May 2006 14:06:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 55713-08 + for ; + Mon, 8 May 2006 14:06:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 69BA39F931D + for ; + Mon, 8 May 2006 14:06:06 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 7E5A831509; Mon, 8 May 2006 19:06:05 +0200 (MET DST) +From: "Andrus" +X-Newsgroups: pgsql.performance +Subject: Re: Query runs 38 seconds for small database! +Date: Mon, 8 May 2006 20:03:38 +0300 +Organization: Hub.Org Networking Services +Lines: 11 +Message-ID: +References: <26838.1147099614@sss.pgh.pa.us> + <27599.1147105626@sss.pgh.pa.us> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/136 +X-Sequence-Number: 18923 + +> The default autovac thresholds are not very aggressive; this table was +> probably not large enough to get selected for analysis. + +Tom, + +thank you. +Excellent. + +Andrus. + + + +From pgsql-performance-owner@postgresql.org Mon May 8 14:27:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A53309F931E + for ; + Mon, 8 May 2006 14:27:18 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 65049-01 + for ; + Mon, 8 May 2006 14:27:07 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id B318B9F931D + for ; + Mon, 8 May 2006 14:27:07 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 7ACBD56427; Mon, 8 May 2006 12:27:06 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Mon, 8 May 2006 12:27:05 -0500 +Date: Mon, 8 May 2006 12:27:05 -0500 +From: "Jim C. Nasby" +To: Markus Schaber +Cc: kah_hang_ang@toray.com.my, + "pgsql-performance@postgresql.org" +Subject: Re: extremely slow when execute select/delete for certain +Message-ID: <20060508172705.GT99570@pervasive.com> +References: + <445F0D8C.3040106@logix-tt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <445F0D8C.3040106@logix-tt.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060508:schabi@logix-tt.com::/bRtlhsvsHA3es7n:000000000000000000 + 0000000000000000000000002dx/ +X-Hashcash: + 1:20:060508:kah_hang_ang@toray.com.my::tzk9ZSvHsoWUesro:000000000000 + 0000000000000000000000000DFt +X-Hashcash: + 1:20:060508:pgsql-performance@postgresql.org::+oZzlWaj+mu4nrrt:00000 + 0000000000000000000000001COu +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/137 +X-Sequence-Number: 18924 + +On Mon, May 08, 2006 at 11:21:16AM +0200, Markus Schaber wrote: +> Hi, Kah, +> +> kah_hang_ang@toray.com.my wrote: +> +> > I already vacuum those tables with full option but it still the same. +> > +> > What could be the possible causes of this problem? +> > How can I solve it? +> > +> > CPU - Intel Xeon 2.40 GHz +> > Memory - 1.5G +> > Postgresql version: 7.2.2 +> +> First, you should consider to upgrade your PostgreSQL server to a newer +> version, at least to 7.2.8 which fixes some critical bugs. + +Note that 7.2.x isn't supported anymore, and there's data loss bugs that +could affect it. You should at least move up to 7.4.x. + +> But it will be much better to upgrade to current 8.1 version, as I think +> that your problem is caused by index bloat, and indices are handled much +> better in 8.1. +> +> Try recreating your indices using REINDEX command. + +And if that doesn't work we need at least the output of EXPLAIN, if not +EXPLAIN ANALYZE. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon May 8 14:28:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id CAF0F9FA4A0 + for ; + Mon, 8 May 2006 14:28:27 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 60209-08 + for ; + Mon, 8 May 2006 14:28:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 66A409F9AFD + for ; + Mon, 8 May 2006 14:28:18 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 9330556431; Mon, 8 May 2006 12:28:17 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Mon, 8 May 2006 12:28:16 -0500 +Date: Mon, 8 May 2006 12:28:16 -0500 +From: "Jim C. Nasby" +To: Andrus +Cc: pgsql-performance@postgresql.org +Subject: Re: Query runs 38 seconds for small database! +Message-ID: <20060508172816.GU99570@pervasive.com> +References: <26838.1147099614@sss.pgh.pa.us> + <27599.1147105626@sss.pgh.pa.us> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060508:eetasoft@online.ee::9imKI/A6l7aLd6dZ:0000000000000000000 + 0000000000000000000000007n4I +X-Hashcash: + 1:20:060508:pgsql-performance@postgresql.org::ETGN63LmtIN0KvAk:00000 + 00000000000000000000000037EL +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/138 +X-Sequence-Number: 18925 + +On Mon, May 08, 2006 at 08:03:38PM +0300, Andrus wrote: +> > The default autovac thresholds are not very aggressive; this table was +> > probably not large enough to get selected for analysis. +> +> Tom, +> +> thank you. +> Excellent. + +BTW, you might want to cut all the autovac thresholds in half; that's +what I typically do. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon May 8 14:29:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 01CD59F9AFD + for ; + Mon, 8 May 2006 14:29:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 60873-06 + for ; + Mon, 8 May 2006 14:29:32 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from rwcrmhc13.comcast.net (rwcrmhc13.comcast.net [204.127.192.83]) + by postgresql.org (Postfix) with ESMTP id F11289F931D + for ; + Mon, 8 May 2006 14:29:31 -0300 (ADT) +Received: from [192.168.1.52] (c-65-96-235-5.hsd1.ma.comcast.net[65.96.235.5]) + by comcast.net (rwcrmhc13) with ESMTP + id <20060508172929m1300pg26he>; Mon, 8 May 2006 17:29:29 +0000 +Message-ID: <445F7FF8.6070707@comcast.net> +Date: Mon, 08 May 2006 13:29:28 -0400 +From: Jeffrey Tenny +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: performance question (something to do w/ parameterized stmts?, wrong + index types?) +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/139 +X-Sequence-Number: 18926 + +Why does this query take so long? (PostgreSQL 8.0.3, FC4) +Hopefully I have provided enough information below. + +LOG: statement: SELECT * FROM x WHERE f IN +($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,\ +$25,$26,$27,$28,$29,$30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$40,$41,$42,$43,$44,$45,$46,$47,$48,$49,$50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$60,$61,$62,$63\ +,$64,$65,$66,$67,$68,$69,$70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$80,$81,$82,$83,$84,$85,$86,$87,$88,$89,$90,$91,$92,$93,$94,$95,$96,$97,$98,$99,$100,$101,\ +$102,$103,$104,$105,$106,$107,$108,$109,$110,$111,$112,$113,$114,$115,$116,$117,$118,$119,$120,$121,$122,$123,$124,$125,$126,$127,$128,$129,$130,$131,$132,\ +$133,$134,$135,$136,$137,$138,$139,$140,$141,$142,$143,$144,$145,$146,$147,$148,$149,$150,$151,$152,$153,$154,$155,$156,$157,$158,$159,$160,$161,$162,$163,\ +$164,$165,$166,$167,$168,$169,$170,$171,$172,$173,$174,$175,$176,$177,$178,$179,$180,$181,$182,$183,$184,$185,$186,$187,$188,$189,$190,$191,$192,$193,$194,\ +$195,$196,$197,$198,$199,$200,$201,$202,$203,$204,$205,$206,$207,$208,$209,$210,$211,$212,$213,$214,$215,$216,$217,$218,$219,$220,$221,$222,$223,$224,$225,\ +$226,$227,$228,$229,$230,$231,$232,$233,$234,$235,$236,$237,$238,$239,$240,$241,$242,$243,$244,$245,$246,$247,$248,$249,$250,$251,$252,$253,$254,$255,$256,\ +$257,$258,$259,$260,$261,$262,$263,$264,$265,$266,$267,$268,$269,$270,$271,$272,$273,$274,$275,$276,$277,$278,$279,$280,$281,$282,$283,$284,$285,$286,$287,\ +$288,$289,$290,$291,$292,$293,$294,$295,$296,$297,$298,$299,$300,$301,$302,$303,$304,$305,$306,$307,$308,$309,$310,$311,$312,$313,$314,$315,$316,$317,$318,\ +$319,$320,$321,$322,$323,$324,$325,$326,$327,$328,$329,$330,$331,$332,$333,$334,$335,$336,$337,$338,$339,$340,$341,$342,$343,$344,$345,$346,$347,$348,$349,\ +$350,$351,$352,$353,$354,$355,$356,$357,$358,$359,$360,$361,$362,$363,$364,$365,$366,$367,$368,$369,$370,$371,$372,$373,$374,$375,$376,$377,$378,$379,$380,\ +$381,$382,$383,$384,$385,$386,$387,$388,$389,$390,$391,$392,$393,$394,$395,$396,$397,$398,$399,$400,$401,$402,$403,$404,$405,$406,$407,$408,$409,$410,$411,\ +$412,$413,$414,$415,$416,$417,$418,$419,$420,$421,$422,$423,$424,$425,$426,$427,$428,$429,$430,$431,$432,$433,$434,$435,$436,$437,$438,$439,$440,$441,$442,\ +$443,$444,$445,$446,$447,$448,$449,$450,$451,$452,$453,$454,$455,$456,$457,$458,$459,$460,$461,$462,$463,$464,$465,$466,$467,$468,$469,$470,$471,$472,$473,\ +$474,$475,$476,$477,$478,$479,$480,$481,$482,$483,$484,$485,$486,$487,$488,$489,$490,$491,$492,$493,$494,$495,$496,$497,$498,$499,$500,$501,$502,$503,$504,\ +$505,$506,$507,$508,$509,$510,$511,$512,$513,$514,$515,$516,$517,$518,$519,$520,$521,$522,$523,$524,$525,$526,$527,$528,$529,$530,$531,$532,$533,$534,$535,\ +$536,$537,$538,$539,$540,$541,$542,$543,$544,$545,$546,$547,$548,$549,$550,$551,$552,$553,$554,$555,$556,$557,$558,$559,$560,$561,$562,$563,$564,$565,$566,\ +$567,$568,$569,$570,$571,$572,$573,$574,$575,$576,$577,$578,$579,$580,$581,$582,$583,$584,$585,$586,$587,$588,$589,$590,$591,$592,$593,$594,$595,$596,$597,\ +$598,$599,$600,$601,$602,$603,$604,$605,$606,$607,$608,$609,$610,$611,$612,$613,$614,$615,$616,$617,$618,$619,$620,$621,$622,$623,$624,$625,$626,$627,$628,\ +$629,$630,$631,$632,$633,$634,$635,$636,$637,$638,$639,$640,$641,$642,$643,$644,$645,$646,$647,$648,$649,$650) +ORDER BY f,c + +LOG: EXECUTOR STATISTICS +DETAIL: ! system usage stats: + ! 10.282945 elapsed 10.234444 user 0.048992 system sec + ! [25.309152 user 0.500923 sys total] + ! 0/0 [0/0] filesystem blocks in/out + ! 0/0 [0/10397] page faults/reclaims, 0 [0] swaps + ! 0 [0] signals rcvd, 0/0 [0/0] messages rcvd/sent + ! 0/15 [291/55] voluntary/involuntary context switches + ! buffer usage stats: + ! Shared blocks: 0 read, 0 written, +buffer hit rate = 100.00% + ! Local blocks: 0 read, 0 written, +buffer hit rate = 0.00% + ! Direct blocks: 0 read, 0 written + + +Here is the table description: + +Table "public.x" + Column | Type | Modifiers +--------+---------+----------- + f | integer | not null + c | integer | not null + r | integer | not null + n | integer | not null +Indexes: + "x_c_idx" btree (c) + "x_f_idx" btree (f) + "testindex2" btree (f, c) + + +There are only 2,369 records in the X table. + +I don't understand why this query should take 10 seconds in the executor +phase, with so little data being managed, and all relevant data already +in memory. Any clues? + +Maybe there are more database server debugging options I should have +tweaked, but I'm not sure what. The stuff I turned on included: + +log_duration = true +log_statement = 'all' +log_parser_stats = true +log_planner_stats = true +log_executor_stats = true + + (N.B. log_statement_stats = true caused the server startup failure +every time with no error message I could find, so was not deliberately set) + +stats_start_collector = true +stats_command_string = true +stats_block_level = true +stats_row_level = true +stats_reset_on_server_start = true + + + +(FYI: 10 secs is a lot only because this query is executed many times in +my application, and they're pretty much all bad, and the aggregate query +times are killing my app response). + +Thanks for any tips! + +From pgsql-performance-owner@postgresql.org Mon May 8 14:31:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1BAB89F931E + for ; + Mon, 8 May 2006 14:31:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 64591-02 + for ; + Mon, 8 May 2006 14:30:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 2DBDA9FA42B + for ; + Mon, 8 May 2006 14:30:57 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 1375C56423; Mon, 8 May 2006 12:30:57 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Mon, 8 May 2006 12:30:56 -0500 +Date: Mon, 8 May 2006 12:30:56 -0500 +From: "Jim C. Nasby" +To: Vivek Khera +Cc: Pgsql performance +Subject: Re: Memory and/or cache issues? +Message-ID: <20060508173055.GV99570@pervasive.com> +References: <0C4841B42F87D51195BD00B0D020F5CB044B2621@MORPHEUS> + <2680CBB8-985E-4C12-BCBB-72D49AA070EE@khera.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <2680CBB8-985E-4C12-BCBB-72D49AA070EE@khera.org> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060508:vivek@khera.org::3lcuWtUL+KRu1+W5:006+D5 +X-Hashcash: + 1:20:060508:pgsql-performance@postgresql.org::6g3+vAXSAEFbRVJC:00000 + 0000000000000000000000006fv0 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/140 +X-Sequence-Number: 18927 + +On Mon, May 08, 2006 at 11:06:42AM -0400, Vivek Khera wrote: +> +> On May 6, 2006, at 10:53 AM, mcelroy, tim wrote: +> +> >development side than DBA by the way), but there is no better way +> >to learn +> >and understand better than actual day-to-day working experience. +> +> Yeah, I prefer my surgeons to work this way too. training is for the +> birds. + +I think you read too quickly past the part where Tim said he'd taking a +week-long training class. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon May 8 14:38:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6CAD09F931E + for ; + Mon, 8 May 2006 14:38:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 63073-07 + for ; + Mon, 8 May 2006 14:38:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 301D49F931D + for ; + Mon, 8 May 2006 14:38:37 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id A0A5531509; Mon, 8 May 2006 19:38:35 +0200 (MET DST) +From: "Andrus" +X-Newsgroups: pgsql.performance +Subject: Re: Query runs 38 seconds for small database! +Date: Mon, 8 May 2006 20:36:42 +0300 +Organization: Hub.Org Networking Services +Lines: 13 +Message-ID: +References: <26838.1147099614@sss.pgh.pa.us> + <27599.1147105626@sss.pgh.pa.us> + <20060508172816.GU99570@pervasive.com> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/142 +X-Sequence-Number: 18929 + +> BTW, you might want to cut all the autovac thresholds in half; that's +> what I typically do. + +I added ANALYZE command to my procedure which creates and loads data to +postgres database +from other DBMS. This runs only onvce after installing my application. I +hope this is sufficient. +If default threshold is so conservative values I expect there is some reason +for it. + +Andrus. + + + +From pgsql-performance-owner@postgresql.org Mon May 8 14:38:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4B33E9F931D + for ; + Mon, 8 May 2006 14:38:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 65386-05 + for ; + Mon, 8 May 2006 14:38:15 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 6A9E29F931E + for ; + Mon, 8 May 2006 14:38:15 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 152CE56435; Mon, 8 May 2006 12:38:14 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Mon, 8 May 2006 12:38:12 -0500 +Date: Mon, 8 May 2006 12:38:12 -0500 +From: "Jim C. Nasby" +To: Jeffrey Tenny +Cc: pgsql-performance@postgresql.org +Subject: Re: performance question (something to do w/ parameterized stmts?, + wrong index types?) +Message-ID: <20060508173812.GW99570@pervasive.com> +References: <445F7FF8.6070707@comcast.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <445F7FF8.6070707@comcast.net> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060508:jeffrey.tenny@comcast.net::Qn2c0qylWMIxgcfb:000000000000 + 0000000000000000000000006xC0 +X-Hashcash: + 1:20:060508:pgsql-performance@postgresql.org::vIsQyGfDAxRko0ds:00000 + 0000000000000000000000009PJH +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/141 +X-Sequence-Number: 18928 + +What's EXPLAIN ANALYZE show? + +On Mon, May 08, 2006 at 01:29:28PM -0400, Jeffrey Tenny wrote: +> Why does this query take so long? (PostgreSQL 8.0.3, FC4) +> Hopefully I have provided enough information below. +> +> LOG: statement: SELECT * FROM x WHERE f IN +> ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,\ +> $25,$26,$27,$28,$29,$30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$40,$41,$42,$43,$44,$45,$46,$47,$48,$49,$50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$60,$61,$62,$63\ +> ,$64,$65,$66,$67,$68,$69,$70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$80,$81,$82,$83,$84,$85,$86,$87,$88,$89,$90,$91,$92,$93,$94,$95,$96,$97,$98,$99,$100,$101,\ +> $102,$103,$104,$105,$106,$107,$108,$109,$110,$111,$112,$113,$114,$115,$116,$117,$118,$119,$120,$121,$122,$123,$124,$125,$126,$127,$128,$129,$130,$131,$132,\ +> $133,$134,$135,$136,$137,$138,$139,$140,$141,$142,$143,$144,$145,$146,$147,$148,$149,$150,$151,$152,$153,$154,$155,$156,$157,$158,$159,$160,$161,$162,$163,\ +> $164,$165,$166,$167,$168,$169,$170,$171,$172,$173,$174,$175,$176,$177,$178,$179,$180,$181,$182,$183,$184,$185,$186,$187,$188,$189,$190,$191,$192,$193,$194,\ +> $195,$196,$197,$198,$199,$200,$201,$202,$203,$204,$205,$206,$207,$208,$209,$210,$211,$212,$213,$214,$215,$216,$217,$218,$219,$220,$221,$222,$223,$224,$225,\ +> $226,$227,$228,$229,$230,$231,$232,$233,$234,$235,$236,$237,$238,$239,$240,$241,$242,$243,$244,$245,$246,$247,$248,$249,$250,$251,$252,$253,$254,$255,$256,\ +> $257,$258,$259,$260,$261,$262,$263,$264,$265,$266,$267,$268,$269,$270,$271,$272,$273,$274,$275,$276,$277,$278,$279,$280,$281,$282,$283,$284,$285,$286,$287,\ +> $288,$289,$290,$291,$292,$293,$294,$295,$296,$297,$298,$299,$300,$301,$302,$303,$304,$305,$306,$307,$308,$309,$310,$311,$312,$313,$314,$315,$316,$317,$318,\ +> $319,$320,$321,$322,$323,$324,$325,$326,$327,$328,$329,$330,$331,$332,$333,$334,$335,$336,$337,$338,$339,$340,$341,$342,$343,$344,$345,$346,$347,$348,$349,\ +> $350,$351,$352,$353,$354,$355,$356,$357,$358,$359,$360,$361,$362,$363,$364,$365,$366,$367,$368,$369,$370,$371,$372,$373,$374,$375,$376,$377,$378,$379,$380,\ +> $381,$382,$383,$384,$385,$386,$387,$388,$389,$390,$391,$392,$393,$394,$395,$396,$397,$398,$399,$400,$401,$402,$403,$404,$405,$406,$407,$408,$409,$410,$411,\ +> $412,$413,$414,$415,$416,$417,$418,$419,$420,$421,$422,$423,$424,$425,$426,$427,$428,$429,$430,$431,$432,$433,$434,$435,$436,$437,$438,$439,$440,$441,$442,\ +> $443,$444,$445,$446,$447,$448,$449,$450,$451,$452,$453,$454,$455,$456,$457,$458,$459,$460,$461,$462,$463,$464,$465,$466,$467,$468,$469,$470,$471,$472,$473,\ +> $474,$475,$476,$477,$478,$479,$480,$481,$482,$483,$484,$485,$486,$487,$488,$489,$490,$491,$492,$493,$494,$495,$496,$497,$498,$499,$500,$501,$502,$503,$504,\ +> $505,$506,$507,$508,$509,$510,$511,$512,$513,$514,$515,$516,$517,$518,$519,$520,$521,$522,$523,$524,$525,$526,$527,$528,$529,$530,$531,$532,$533,$534,$535,\ +> $536,$537,$538,$539,$540,$541,$542,$543,$544,$545,$546,$547,$548,$549,$550,$551,$552,$553,$554,$555,$556,$557,$558,$559,$560,$561,$562,$563,$564,$565,$566,\ +> $567,$568,$569,$570,$571,$572,$573,$574,$575,$576,$577,$578,$579,$580,$581,$582,$583,$584,$585,$586,$587,$588,$589,$590,$591,$592,$593,$594,$595,$596,$597,\ +> $598,$599,$600,$601,$602,$603,$604,$605,$606,$607,$608,$609,$610,$611,$612,$613,$614,$615,$616,$617,$618,$619,$620,$621,$622,$623,$624,$625,$626,$627,$628,\ +> $629,$630,$631,$632,$633,$634,$635,$636,$637,$638,$639,$640,$641,$642,$643,$644,$645,$646,$647,$648,$649,$650) +> ORDER BY f,c +> +> LOG: EXECUTOR STATISTICS +> DETAIL: ! system usage stats: +> ! 10.282945 elapsed 10.234444 user 0.048992 system sec +> ! [25.309152 user 0.500923 sys total] +> ! 0/0 [0/0] filesystem blocks in/out +> ! 0/0 [0/10397] page faults/reclaims, 0 [0] swaps +> ! 0 [0] signals rcvd, 0/0 [0/0] messages rcvd/sent +> ! 0/15 [291/55] voluntary/involuntary context switches +> ! buffer usage stats: +> ! Shared blocks: 0 read, 0 written, +> buffer hit rate = 100.00% +> ! Local blocks: 0 read, 0 written, +> buffer hit rate = 0.00% +> ! Direct blocks: 0 read, 0 written +> +> +> Here is the table description: +> +> Table "public.x" +> Column | Type | Modifiers +> --------+---------+----------- +> f | integer | not null +> c | integer | not null +> r | integer | not null +> n | integer | not null +> Indexes: +> "x_c_idx" btree (c) +> "x_f_idx" btree (f) +> "testindex2" btree (f, c) +> +> +> There are only 2,369 records in the X table. +> +> I don't understand why this query should take 10 seconds in the executor +> phase, with so little data being managed, and all relevant data already +> in memory. Any clues? +> +> Maybe there are more database server debugging options I should have +> tweaked, but I'm not sure what. The stuff I turned on included: +> +> log_duration = true +> log_statement = 'all' +> log_parser_stats = true +> log_planner_stats = true +> log_executor_stats = true +> +> (N.B. log_statement_stats = true caused the server startup failure +> every time with no error message I could find, so was not deliberately set) +> +> stats_start_collector = true +> stats_command_string = true +> stats_block_level = true +> stats_row_level = true +> stats_reset_on_server_start = true +> +> +> +> (FYI: 10 secs is a lot only because this query is executed many times in +> my application, and they're pretty much all bad, and the aggregate query +> times are killing my app response). +> +> Thanks for any tips! +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon May 8 14:42:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F16049FA2DB + for ; + Mon, 8 May 2006 14:42:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 65383-03 + for ; + Mon, 8 May 2006 14:42:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) + by postgresql.org (Postfix) with ESMTP id 9F58E9F931D + for ; + Mon, 8 May 2006 14:42:24 -0300 (ADT) +Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP + with MS-WebStorage 6.0.6249 +Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; + 08 May 2006 10:42:22 -0700 +Subject: Re: performance question (something to do w/ +From: Mark Lewis +To: Jeffrey Tenny +Cc: pgsql-performance@postgresql.org +In-Reply-To: <445F7FF8.6070707@comcast.net> +References: <445F7FF8.6070707@comcast.net> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: MIR3, Inc. +Date: Mon, 08 May 2006 10:42:21 -0700 +Message-Id: <1147110142.32369.7.camel@archimedes> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-27) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/143 +X-Sequence-Number: 18930 + +Doing a SELECT with a large list of variables inside an IN runs slowly +on every database we've tested. We've tested mostly in Oracle and +PostgreSQL, and both get very slow very quickly (actually Oracle refuses +to process the query at all after it gets too many bind parameters). + +In our case, we have a (potentially quite large) set of external values +that we want to look up in the database. We originally thought that +doing a single select with a large IN clause was the way to go, but then +we did some performance analysis on the optimal batch size (number of +items to include per IN clause), and discovered that for most databases, +the optimal batch size was 1. For PostgreSQL I think it was 2. + +The moral of the story is that you're probably better off running a +bunch of small selects than in trying to optimize things with one +gargantuan select. + +-- Mark Lewis + +On Mon, 2006-05-08 at 13:29 -0400, Jeffrey Tenny wrote: +> Why does this query take so long? (PostgreSQL 8.0.3, FC4) +> Hopefully I have provided enough information below. +> +> LOG: statement: SELECT * FROM x WHERE f IN +> ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,\ +> $25,$26,$27,$28,$29,$30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$40,$41,$42,$43,$44,$45,$46,$47,$48,$49,$50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$60,$61,$62,$63\ +> ,$64,$65,$66,$67,$68,$69,$70,$71,$72,$73,$74,$75,$76,$77,$78,$79,$80,$81,$82,$83,$84,$85,$86,$87,$88,$89,$90,$91,$92,$93,$94,$95,$96,$97,$98,$99,$100,$101,\ +> $102,$103,$104,$105,$106,$107,$108,$109,$110,$111,$112,$113,$114,$115,$116,$117,$118,$119,$120,$121,$122,$123,$124,$125,$126,$127,$128,$129,$130,$131,$132,\ +> $133,$134,$135,$136,$137,$138,$139,$140,$141,$142,$143,$144,$145,$146,$147,$148,$149,$150,$151,$152,$153,$154,$155,$156,$157,$158,$159,$160,$161,$162,$163,\ +> $164,$165,$166,$167,$168,$169,$170,$171,$172,$173,$174,$175,$176,$177,$178,$179,$180,$181,$182,$183,$184,$185,$186,$187,$188,$189,$190,$191,$192,$193,$194,\ +> $195,$196,$197,$198,$199,$200,$201,$202,$203,$204,$205,$206,$207,$208,$209,$210,$211,$212,$213,$214,$215,$216,$217,$218,$219,$220,$221,$222,$223,$224,$225,\ +> $226,$227,$228,$229,$230,$231,$232,$233,$234,$235,$236,$237,$238,$239,$240,$241,$242,$243,$244,$245,$246,$247,$248,$249,$250,$251,$252,$253,$254,$255,$256,\ +> $257,$258,$259,$260,$261,$262,$263,$264,$265,$266,$267,$268,$269,$270,$271,$272,$273,$274,$275,$276,$277,$278,$279,$280,$281,$282,$283,$284,$285,$286,$287,\ +> $288,$289,$290,$291,$292,$293,$294,$295,$296,$297,$298,$299,$300,$301,$302,$303,$304,$305,$306,$307,$308,$309,$310,$311,$312,$313,$314,$315,$316,$317,$318,\ +> $319,$320,$321,$322,$323,$324,$325,$326,$327,$328,$329,$330,$331,$332,$333,$334,$335,$336,$337,$338,$339,$340,$341,$342,$343,$344,$345,$346,$347,$348,$349,\ +> $350,$351,$352,$353,$354,$355,$356,$357,$358,$359,$360,$361,$362,$363,$364,$365,$366,$367,$368,$369,$370,$371,$372,$373,$374,$375,$376,$377,$378,$379,$380,\ +> $381,$382,$383,$384,$385,$386,$387,$388,$389,$390,$391,$392,$393,$394,$395,$396,$397,$398,$399,$400,$401,$402,$403,$404,$405,$406,$407,$408,$409,$410,$411,\ +> $412,$413,$414,$415,$416,$417,$418,$419,$420,$421,$422,$423,$424,$425,$426,$427,$428,$429,$430,$431,$432,$433,$434,$435,$436,$437,$438,$439,$440,$441,$442,\ +> $443,$444,$445,$446,$447,$448,$449,$450,$451,$452,$453,$454,$455,$456,$457,$458,$459,$460,$461,$462,$463,$464,$465,$466,$467,$468,$469,$470,$471,$472,$473,\ +> $474,$475,$476,$477,$478,$479,$480,$481,$482,$483,$484,$485,$486,$487,$488,$489,$490,$491,$492,$493,$494,$495,$496,$497,$498,$499,$500,$501,$502,$503,$504,\ +> $505,$506,$507,$508,$509,$510,$511,$512,$513,$514,$515,$516,$517,$518,$519,$520,$521,$522,$523,$524,$525,$526,$527,$528,$529,$530,$531,$532,$533,$534,$535,\ +> $536,$537,$538,$539,$540,$541,$542,$543,$544,$545,$546,$547,$548,$549,$550,$551,$552,$553,$554,$555,$556,$557,$558,$559,$560,$561,$562,$563,$564,$565,$566,\ +> $567,$568,$569,$570,$571,$572,$573,$574,$575,$576,$577,$578,$579,$580,$581,$582,$583,$584,$585,$586,$587,$588,$589,$590,$591,$592,$593,$594,$595,$596,$597,\ +> $598,$599,$600,$601,$602,$603,$604,$605,$606,$607,$608,$609,$610,$611,$612,$613,$614,$615,$616,$617,$618,$619,$620,$621,$622,$623,$624,$625,$626,$627,$628,\ +> $629,$630,$631,$632,$633,$634,$635,$636,$637,$638,$639,$640,$641,$642,$643,$644,$645,$646,$647,$648,$649,$650) +> ORDER BY f,c +> +> LOG: EXECUTOR STATISTICS +> DETAIL: ! system usage stats: +> ! 10.282945 elapsed 10.234444 user 0.048992 system sec +> ! [25.309152 user 0.500923 sys total] +> ! 0/0 [0/0] filesystem blocks in/out +> ! 0/0 [0/10397] page faults/reclaims, 0 [0] swaps +> ! 0 [0] signals rcvd, 0/0 [0/0] messages rcvd/sent +> ! 0/15 [291/55] voluntary/involuntary context switches +> ! buffer usage stats: +> ! Shared blocks: 0 read, 0 written, +> buffer hit rate = 100.00% +> ! Local blocks: 0 read, 0 written, +> buffer hit rate = 0.00% +> ! Direct blocks: 0 read, 0 written +> +> +> Here is the table description: +> +> Table "public.x" +> Column | Type | Modifiers +> --------+---------+----------- +> f | integer | not null +> c | integer | not null +> r | integer | not null +> n | integer | not null +> Indexes: +> "x_c_idx" btree (c) +> "x_f_idx" btree (f) +> "testindex2" btree (f, c) +> +> +> There are only 2,369 records in the X table. +> +> I don't understand why this query should take 10 seconds in the executor +> phase, with so little data being managed, and all relevant data already +> in memory. Any clues? +> +> Maybe there are more database server debugging options I should have +> tweaked, but I'm not sure what. The stuff I turned on included: +> +> log_duration = true +> log_statement = 'all' +> log_parser_stats = true +> log_planner_stats = true +> log_executor_stats = true +> +> (N.B. log_statement_stats = true caused the server startup failure +> every time with no error message I could find, so was not deliberately set) +> +> stats_start_collector = true +> stats_command_string = true +> stats_block_level = true +> stats_row_level = true +> stats_reset_on_server_start = true +> +> +> +> (FYI: 10 secs is a lot only because this query is executed many times in +> my application, and they're pretty much all bad, and the aggregate query +> times are killing my app response). +> +> Thanks for any tips! +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings + +From pgsql-performance-owner@postgresql.org Mon May 8 14:46:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1A9DF9F931D + for ; + Mon, 8 May 2006 14:46:17 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 66692-05 + for ; + Mon, 8 May 2006 14:46:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 91DF49F931E + for ; + Mon, 8 May 2006 14:46:06 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 7E7AE56437; Mon, 8 May 2006 12:46:05 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Mon, 8 May 2006 12:46:04 -0500 +Date: Mon, 8 May 2006 12:46:04 -0500 +From: "Jim C. Nasby" +To: Andrus +Cc: pgsql-performance@postgresql.org +Subject: Re: Query runs 38 seconds for small database! +Message-ID: <20060508174604.GX99570@pervasive.com> +References: <26838.1147099614@sss.pgh.pa.us> + <27599.1147105626@sss.pgh.pa.us> + <20060508172816.GU99570@pervasive.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060508:eetasoft@online.ee::zM5lNGoW9tThgISr:0000000000000000000 + 0000000000000000000000002sMM +X-Hashcash: + 1:20:060508:pgsql-performance@postgresql.org::8B6fZEmJNQaof59K:00000 + 0000000000000000000000004Q5x +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/144 +X-Sequence-Number: 18931 + +On Mon, May 08, 2006 at 08:36:42PM +0300, Andrus wrote: +> > BTW, you might want to cut all the autovac thresholds in half; that's +> > what I typically do. +> +> I added ANALYZE command to my procedure which creates and loads data to +> postgres database +> from other DBMS. This runs only onvce after installing my application. I +> hope this is sufficient. +> If default threshold is so conservative values I expect there is some reason +> for it. + +The only reason for being so conservative that I'm aware of was that it +was a best guess. Everyone I've talked to cuts the defaults down by at +least a factor of 2, sometimes even more. + +BTW, these parameters are already tweaked from what we started with in +contrib/pg_autovacuum. It would allow a table to grow to 2x larger than +it should be before vacuuming, as opposed to the 40% that the current +settings allow. But even there, is there any real reason you want to +have 40% bloat? To make matters worse, those settings ensure that all +but the smallest databases will suffer runaway bloat unless you bump up +the FSM settings. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon May 8 14:50:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C3E859F931E + for ; + Mon, 8 May 2006 14:50:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 64664-06 + for ; + Mon, 8 May 2006 14:50:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id EC58C9F931D + for ; + Mon, 8 May 2006 14:50:15 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id C826D56435; Mon, 8 May 2006 12:50:14 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); + Mon, 8 May 2006 12:50:13 -0500 +Date: Mon, 8 May 2006 12:50:13 -0500 +From: "Jim C. Nasby" +To: Mark Lewis +Cc: Jeffrey Tenny , + pgsql-performance@postgresql.org +Subject: Re: performance question (something to do w/ +Message-ID: <20060508175013.GY99570@pervasive.com> +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1147110142.32369.7.camel@archimedes> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060508:mark.lewis@mir3.com::LgCb+42IFy0ipc25:000000000000000000 + 0000000000000000000000001hGX +X-Hashcash: + 1:20:060508:jeffrey.tenny@comcast.net::YhnYaaAvuDDGuLMj:000000000000 + 0000000000000000000000008X7s +X-Hashcash: + 1:20:060508:pgsql-performance@postgresql.org::cXNYVuvuojCNTM0F:00000 + 0000000000000000000000004ZF8 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/145 +X-Sequence-Number: 18932 + +On Mon, May 08, 2006 at 10:42:21AM -0700, Mark Lewis wrote: +> Doing a SELECT with a large list of variables inside an IN runs slowly +> on every database we've tested. We've tested mostly in Oracle and +> PostgreSQL, and both get very slow very quickly (actually Oracle refuses +> to process the query at all after it gets too many bind parameters). +> +> In our case, we have a (potentially quite large) set of external values +> that we want to look up in the database. We originally thought that +> doing a single select with a large IN clause was the way to go, but then +> we did some performance analysis on the optimal batch size (number of +> items to include per IN clause), and discovered that for most databases, +> the optimal batch size was 1. For PostgreSQL I think it was 2. +> +> The moral of the story is that you're probably better off running a +> bunch of small selects than in trying to optimize things with one +> gargantuan select. + +Ever experiment with loading the parameters into a temp table and +joining to that? +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon May 8 15:00:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 465919F931E + for ; + Mon, 8 May 2006 15:00:20 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 63255-09 + for ; + Mon, 8 May 2006 15:00:10 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id BEB879F931D + for ; + Mon, 8 May 2006 15:00:09 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k48HxvRc028289; + Mon, 8 May 2006 13:59:57 -0400 (EDT) +To: "Jim C. Nasby" +cc: Mark Lewis , + Jeffrey Tenny , pgsql-performance@postgresql.org +Subject: Re: performance question (something to do w/ +In-reply-to: <20060508175013.GY99570@pervasive.com> +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> +Comments: In-reply-to "Jim C. Nasby" + message dated "Mon, 08 May 2006 12:50:13 -0500" +Date: Mon, 08 May 2006 13:59:56 -0400 +Message-ID: <28288.1147111196@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/146 +X-Sequence-Number: 18933 + +"Jim C. Nasby" writes: +> On Mon, May 08, 2006 at 10:42:21AM -0700, Mark Lewis wrote: +>> Doing a SELECT with a large list of variables inside an IN runs slowly +>> on every database we've tested. We've tested mostly in Oracle and +>> PostgreSQL, and both get very slow very quickly (actually Oracle refuses +>> to process the query at all after it gets too many bind parameters). +>> +>> In our case, we have a (potentially quite large) set of external values +>> that we want to look up in the database. We originally thought that +>> doing a single select with a large IN clause was the way to go, but then +>> we did some performance analysis on the optimal batch size (number of +>> items to include per IN clause), and discovered that for most databases, +>> the optimal batch size was 1. For PostgreSQL I think it was 2. +>> +>> The moral of the story is that you're probably better off running a +>> bunch of small selects than in trying to optimize things with one +>> gargantuan select. + +> Ever experiment with loading the parameters into a temp table and +> joining to that? + +Also, it might be worth re-testing that conclusion with PG CVS tip +(or 8.2 when it comes out). The reimplementation of IN as = ANY that +I did a couple months ago might well change the results. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 9 23:54:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 20D649F931E + for ; + Mon, 8 May 2006 15:01:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 68110-04-2 + for ; + Mon, 8 May 2006 15:01:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 21FC69F9AFD + for ; + Mon, 8 May 2006 15:01:43 -0300 (ADT) +Received: from is.rice.edu (is.rice.edu [128.42.42.24]) + by svr4.postgresql.org (Postfix) with ESMTP id 252875B0775 + for ; + Mon, 8 May 2006 18:01:42 +0000 (GMT) +Received: from scan2.mail.rice.edu (scan2.mail.rice.edu [128.42.59.161]) + by is.rice.edu (Postfix) with ESMTP id 7921A4182B; + Mon, 8 May 2006 13:01:40 -0500 (CDT) +Received: from is.rice.edu ([128.42.42.24]) + by scan2.mail.rice.edu (scan2.mail.rice.edu [128.42.59.161]) + (amavisd-new, port 10024) + with ESMTP id 26421-02; Mon, 8 May 2006 13:01:36 -0500 (CDT) +Received: by is.rice.edu (Postfix, from userid 18612) + id ACCD8418BB; Mon, 8 May 2006 13:01:36 -0500 (CDT) +Date: Mon, 8 May 2006 13:01:36 -0500 +From: Kenneth Marshall +To: "Jim C. Nasby" +Cc: Mark Lewis , + Jeffrey Tenny , pgsql-performance@postgresql.org +Subject: Re: performance question (something to do w/ +Message-ID: <20060508180136.GK1862@it.is.rice.edu> +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060508175013.GY99570@pervasive.com> +User-Agent: Mutt/1.4.2i +X-Virus-Scanned: by amavis-2.2.1 at scan2.mail.rice.edu +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/208 +X-Sequence-Number: 18995 + +On Mon, May 08, 2006 at 12:50:13PM -0500, Jim C. Nasby wrote: +> On Mon, May 08, 2006 at 10:42:21AM -0700, Mark Lewis wrote: +> > Doing a SELECT with a large list of variables inside an IN runs slowly +> > on every database we've tested. We've tested mostly in Oracle and +> > PostgreSQL, and both get very slow very quickly (actually Oracle refuses +> > to process the query at all after it gets too many bind parameters). +> > +> > In our case, we have a (potentially quite large) set of external values +> > that we want to look up in the database. We originally thought that +> > doing a single select with a large IN clause was the way to go, but then +> > we did some performance analysis on the optimal batch size (number of +> > items to include per IN clause), and discovered that for most databases, +> > the optimal batch size was 1. For PostgreSQL I think it was 2. +> > +> > The moral of the story is that you're probably better off running a +> > bunch of small selects than in trying to optimize things with one +> > gargantuan select. +> +> Ever experiment with loading the parameters into a temp table and +> joining to that? +> -- +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> +> ---------------------------(end of broadcast)--------------------------- + +The DB use by the DSPAM software is very similar to your use case. The +fastest queries are made using the PostgreSQL generate_series functionality +to unwind the "IN *" to multiple single selects. Here is the lookup function +that they use: + +create function lookup_tokens(integer,bigint[]) + returns setof dspam_token_data + language plpgsql stable + as ' +declare + v_rec record; +begin + for v_rec in select * from dspam_token_data + where uid=$1 + and token in (select $2[i] + from generate_series(array_lower($2,1), + array_upper($2,1)) s(i)) + loop + return next v_rec; + end loop; + return; +end;'; + + +You should be able to try something similar for your workload. + +Ken Marshall + +From pgsql-performance-owner@postgresql.org Mon May 8 15:10:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7D8379F931D + for ; + Mon, 8 May 2006 15:10:40 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 69721-06 + for ; + Mon, 8 May 2006 15:10:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 8AEE59FA2DB + for ; + Mon, 8 May 2006 15:10:26 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 80E50314E2; Mon, 8 May 2006 20:10:25 +0200 (MET DST) +From: "Andrus" +X-Newsgroups: pgsql.performance +Subject: Re: Query runs 38 seconds for small database! +Date: Mon, 8 May 2006 21:10:07 +0300 +Organization: Hub.Org Networking Services +Lines: 22 +Message-ID: +References: <26838.1147099614@sss.pgh.pa.us> + <27599.1147105626@sss.pgh.pa.us> + <20060508172816.GU99570@pervasive.com> + <20060508174604.GX99570@pervasive.com> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-RFC2646: Format=Flowed; Original +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/147 +X-Sequence-Number: 18934 + +> The only reason for being so conservative that I'm aware of was that it +> was a best guess. Everyone I've talked to cuts the defaults down by at +> least a factor of 2, sometimes even more. + +Can we ask that Tom will change default values to 2 times smaller in 8.1.4 ? + +> BTW, these parameters are already tweaked from what we started with in +> contrib/pg_autovacuum. It would allow a table to grow to 2x larger than +> it should be before vacuuming, as opposed to the 40% that the current +> settings allow. But even there, is there any real reason you want to +> have 40% bloat? To make matters worse, those settings ensure that all +> but the smallest databases will suffer runaway bloat unless you bump up + recprd> the FSM settings. + +I created empty table konto and loaded more that 219 records to it during +database creation. +So it seems that if table grows from zero to more than 219 times larger then +it was still not processed. + +Andrus. + + + +From pgsql-performance-owner@postgresql.org Mon May 8 16:19:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 269759F931E + for ; + Mon, 8 May 2006 16:19:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 80446-03 + for ; + Mon, 8 May 2006 16:19:44 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.digitalfairway.ca (ns.digitalfairway.ca [207.164.133.170]) + by postgresql.org (Postfix) with ESMTP id 50A769F931D + for ; + Mon, 8 May 2006 16:19:43 -0300 (ADT) +Received: from toronto.toronto.digitalfairway.ca (unknown [192.168.100.10]) + by mail.digitalfairway.ca (Postfix) with ESMTP id 587FF54821 + for ; + Mon, 8 May 2006 15:19:40 -0400 (EDT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by toronto.toronto.digitalfairway.ca (Postfix) with ESMTP id + 58269148E63 for ; + Mon, 8 May 2006 15:19:40 -0400 (EDT) +Received: from toronto.toronto.digitalfairway.ca ([127.0.0.1]) + by localhost (toronto.toronto.digitalfairway.ca [127.0.0.1]) + (amavisd-new, port 10024) + with ESMTP id 09703-05 for ; + Mon, 8 May 2006 15:19:40 -0400 (EDT) +Received: from [192.168.100.50] (unknown [192.168.100.50]) + (using SSLv3 with cipher EXP1024-RC4-SHA (56/128 bits)) + (No client certificate requested) + by toronto.toronto.digitalfairway.ca (Postfix) with ESMTP id + 37B60144EB8 for ; + Mon, 8 May 2006 15:19:40 -0400 (EDT) +From: Jan de Visser +To: pgsql-performance@postgresql.org +Subject: Re: Query runs 38 seconds for small database! +Date: Mon, 8 May 2006 15:19:39 -0400 +User-Agent: KMail/1.9.1 +References: + <20060508174604.GX99570@pervasive.com> + +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-15" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200605081519.39293.jdevisser@digitalfairway.com> +X-Virus-Scanned: amavisd-new at digitalfairway.ca +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/148 +X-Sequence-Number: 18935 + +On Monday 08 May 2006 14:10, Andrus wrote: +> > The only reason for being so conservative that I'm aware of was that it +> > was a best guess. Everyone I've talked to cuts the defaults down by at +> > least a factor of 2, sometimes even more. +> +> Can we ask that Tom will change default values to 2 times smaller in 8.1.4 +> ? +> +> > BTW, these parameters are already tweaked from what we started with in +> > contrib/pg_autovacuum. It would allow a table to grow to 2x larger than +> > it should be before vacuuming, as opposed to the 40% that the current +> > settings allow. But even there, is there any real reason you want to +> > have 40% bloat? To make matters worse, those settings ensure that all +> > but the smallest databases will suffer runaway bloat unless you bump up +> +> recprd> the FSM settings. +> +> I created empty table konto and loaded more that 219 records to it during +> database creation. +> So it seems that if table grows from zero to more than 219 times larger +> then it was still not processed. + +That's because you need at least 500 rows for analyze and 100 for a vacuum,= +=20 +(autovacuum_vacuum_threshold =3D 1000, autovacuum_analyze_threshold =3D 500= +). + +> +> Andrus. + +jan + +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings + +=2D-=20 +=2D------------------------------------------------------------- +Jan de Visser =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 jdevisser@digitalfair= +way.com + +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Baruk Khazad! Khazad ai-menu! +=2D------------------------------------------------------------- + +From pgsql-performance-owner@postgresql.org Mon May 8 16:38:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0644B9F931D + for ; + Mon, 8 May 2006 16:38:24 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 78724-09 + for ; + Mon, 8 May 2006 16:38:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id D8FAD9FA2DB + for ; + Mon, 8 May 2006 16:38:13 -0300 (ADT) +Received: from [192.168.1.3] (unknown [192.168.1.3]) + by yertle.kcilink.com (Postfix) with ESMTP id 4E228B827 + for ; + Mon, 8 May 2006 15:38:12 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <20060508173055.GV99570@pervasive.com> +References: <0C4841B42F87D51195BD00B0D020F5CB044B2621@MORPHEUS> + <2680CBB8-985E-4C12-BCBB-72D49AA070EE@khera.org> + <20060508173055.GV99570@pervasive.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Content-Transfer-Encoding: 7bit +From: Vivek Khera +Subject: Re: Memory and/or cache issues? +Date: Mon, 8 May 2006 15:38:23 -0400 +To: Pgsql performance +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/149 +X-Sequence-Number: 18936 + + +On May 8, 2006, at 1:30 PM, Jim C. Nasby wrote: + +>> Yeah, I prefer my surgeons to work this way too. training is for the +>> birds. +> +> I think you read too quickly past the part where Tim said he'd +> taking a +> week-long training class. + +s/training/apprenticeship/g; + + +From pgsql-performance-owner@postgresql.org Mon May 8 16:43:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 269489F931E + for ; + Mon, 8 May 2006 16:43:48 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 79727-09 + for ; + Mon, 8 May 2006 16:43:42 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from rwcrmhc13.comcast.net (rwcrmhc13.comcast.net [204.127.192.83]) + by postgresql.org (Postfix) with ESMTP id 5C3049F931D + for ; + Mon, 8 May 2006 16:43:41 -0300 (ADT) +Received: from [192.168.1.52] (c-65-96-235-5.hsd1.ma.comcast.net[65.96.235.5]) + by comcast.net (rwcrmhc13) with ESMTP + id <20060508194340m1300pc0bse>; Mon, 8 May 2006 19:43:40 +0000 +Message-ID: <445F9F6B.9040200@comcast.net> +Date: Mon, 08 May 2006 15:43:39 -0400 +From: Jeffrey Tenny +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: "Jim C. Nasby" +CC: pgsql-performance@postgresql.org +Subject: Re: performance question (something to do w/ parameterized +References: <445F7FF8.6070707@comcast.net> + <20060508173812.GW99570@pervasive.com> +In-Reply-To: <20060508173812.GW99570@pervasive.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/150 +X-Sequence-Number: 18937 + +Well, since I don't know the exact parameter values, just substituting +1-650 for $1-$650, I get: + + Index Scan using testindex2 on x (cost=0.00..34964.52 rows=1503 +width=16) (actual time=0.201..968.252 rows=677 loops=1) + Filter: ((f = 1) OR (f = 2) OR (f = 3) OR (f = 4) ... + +So index usage is presumably good on this one. + +Jim C. Nasby wrote: +> What's EXPLAIN ANALYZE show? +> + +From pgsql-performance-owner@postgresql.org Mon May 8 16:48:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 63A7E9F931D + for ; + Mon, 8 May 2006 16:48:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 82900-05 + for ; + Mon, 8 May 2006 16:48:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 9BD409F931E + for ; + Mon, 8 May 2006 16:48:42 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k48JmcDT029127; + Mon, 8 May 2006 15:48:39 -0400 (EDT) +To: Jan de Visser +cc: pgsql-performance@postgresql.org, "Matthew T. O'Connor" +Subject: Re: Query runs 38 seconds for small database! +In-reply-to: <200605081519.39293.jdevisser@digitalfairway.com> +References: + <20060508174604.GX99570@pervasive.com> + + <200605081519.39293.jdevisser@digitalfairway.com> +Comments: In-reply-to Jan de Visser + message dated "Mon, 08 May 2006 15:19:39 -0400" +Date: Mon, 08 May 2006 15:48:38 -0400 +Message-ID: <29126.1147117718@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/151 +X-Sequence-Number: 18938 + +Jan de Visser writes: +> On Monday 08 May 2006 14:10, Andrus wrote: +>> I created empty table konto and loaded more that 219 records to it during +>> database creation. +>> So it seems that if table grows from zero to more than 219 times larger +>> then it was still not processed. + +> That's because you need at least 500 rows for analyze and 100 for a vacuum, +> (autovacuum_vacuum_threshold = 1000, autovacuum_analyze_threshold = 500). + +This crystallizes something that's been bothering me for awhile, +actually: why do the "threshold" variables exist at all? If we took +them out, or at least made their default values zero, then the autovac +criteria would simply be "vacuum or analyze if at least X% of the table +has changed" (where X is set by the "scale_factor" variables). Which +seems intuitively reasonable. As it stands, the thresholds seem to bias +autovac against ever touching small tables at all ... but, as this +example demonstrates, a fairly small table can still kill your query +performance if the planner knows nothing about it. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon May 8 16:51:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D86579F931E + for ; + Mon, 8 May 2006 16:51:35 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 87101-01 + for ; + Mon, 8 May 2006 16:51:30 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from rwcrmhc14.comcast.net (rwcrmhc14.comcast.net [216.148.227.154]) + by postgresql.org (Postfix) with ESMTP id CC3249F931D + for ; + Mon, 8 May 2006 16:51:30 -0300 (ADT) +Received: from [192.168.1.52] (c-65-96-235-5.hsd1.ma.comcast.net[65.96.235.5]) + by comcast.net (rwcrmhc14) with ESMTP + id <20060508195127m1400p9ac5e>; Mon, 8 May 2006 19:51:28 +0000 +Message-ID: <445FA13E.2090304@comcast.net> +Date: Mon, 08 May 2006 15:51:26 -0400 +From: Jeffrey Tenny +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Mark Lewis , pgsql-performance@postgresql.org +Subject: Re: performance question (something to do w/ parameterized +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> +In-Reply-To: <1147110142.32369.7.camel@archimedes> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/152 +X-Sequence-Number: 18939 + +Mark Lewis wrote: +> Doing a SELECT with a large list of variables inside an IN runs slowly +> on every database we've tested. We've tested mostly in Oracle and +> PostgreSQL, and both get very slow very quickly (actually Oracle refuses +> to process the query at all after it gets too many bind parameters). +> +> In our case, we have a (potentially quite large) set of external values +> that we want to look up in the database. We originally thought that +> doing a single select with a large IN clause was the way to go, but then +> we did some performance analysis on the optimal batch size (number of +> items to include per IN clause), and discovered that for most databases, +> the optimal batch size was 1. For PostgreSQL I think it was 2. + +So that is for parameterized queries (the batch size?). + +In my case, I was concerned about latency between app and database +server, so I try to minimize the number of queries I send to the +database server. (My app servers can be anywhere, they /should/ be +close to the database server, but there are no guarantees and I can't +control it). + +The last time I tested for optimal batch size using non-parameterized +queries with same-host database and app, I got a batch size of +approximately 700 IN list elements (again, not variables in that test). +That was on postgres 7.X.Y. + +Guess I'll have to try a test where I turn the parameterized statements +into regular statements. + +I'm pretty sure it would be a bad idea for me to send one IN list +element at a time in all cases. Even if the query query prep was fast, +the network latency could kill my app. + +> +> The moral of the story is that you're probably better off running a +> bunch of small selects than in trying to optimize things with one +> gargantuan select. + +The algorithm currently tries to ensure that IN-lists of not more than +700 elements are sent to the database server, and breaks them into +multiple queries. If it has to break it into at least 3 queries, it +uses parameterized statements for the first 2+ and then a +non-parameterized statement for the last one (which may have a different +number of IN list elements than the prior batches). + +From pgsql-performance-owner@postgresql.org Mon May 8 17:03:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E26429F9AFD + for ; + Mon, 8 May 2006 17:03:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 88091-01 + for ; + Mon, 8 May 2006 17:03:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx3.surnet.cl (mx3.surnet.cl [216.155.73.182]) + by postgresql.org (Postfix) with ESMTP id 64ED59F931D + for ; + Mon, 8 May 2006 17:03:00 -0300 (ADT) +Received: from unknown (HELO cluster.surnet.cl) ([216.155.73.165]) + by mx3.surnet.cl with ESMTP; 08 May 2006 16:02:58 -0400 +X-IronPort-AV: i="4.04,172,1144036800"; + d="scan'208"; a="12349862:sNHT24524204" +Received: from alvh.no-ip.org (201.220.122.210) by cluster.surnet.cl (7.0.043) + (authenticated as alvherre@surnet.cl) + id 443B7DDC003C2A0A; Mon, 8 May 2006 16:02:59 -0400 +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 26562C31DEB; Mon, 8 May 2006 16:02:59 -0400 (CLT) +Date: Mon, 8 May 2006 16:02:59 -0400 +From: Alvaro Herrera +To: Tom Lane +Cc: Jan de Visser , + pgsql-performance@postgresql.org, "Matthew T. O'Connor" +Subject: Re: Query runs 38 seconds for small database! +Message-ID: <20060508200258.GJ3351@surnet.cl> +Mail-Followup-To: Tom Lane , + Jan de Visser , + pgsql-performance@postgresql.org, + "Matthew T. O'Connor" +References: + <20060508174604.GX99570@pervasive.com> + + <200605081519.39293.jdevisser@digitalfairway.com> + <29126.1147117718@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <29126.1147117718@sss.pgh.pa.us> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/153 +X-Sequence-Number: 18940 + +Tom Lane wrote: +> Jan de Visser writes: +> > On Monday 08 May 2006 14:10, Andrus wrote: +> >> I created empty table konto and loaded more that 219 records to it during +> >> database creation. +> >> So it seems that if table grows from zero to more than 219 times larger +> >> then it was still not processed. +> +> > That's because you need at least 500 rows for analyze and 100 for a vacuum, +> > (autovacuum_vacuum_threshold = 1000, autovacuum_analyze_threshold = 500). +> +> This crystallizes something that's been bothering me for awhile, +> actually: why do the "threshold" variables exist at all? + +Matthew would know about that -- he invented them. I take no +responsability :-) + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +PostgreSQL Replication, Consulting, Custom Development, 24x7 support + +From pgsql-performance-owner@postgresql.org Mon May 8 17:09:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 09C589F931D + for ; + Mon, 8 May 2006 17:09:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 82900-09 + for ; + Mon, 8 May 2006 17:08:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 5A0359F931E + for ; + Mon, 8 May 2006 17:08:55 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k48K8e6f029346; + Mon, 8 May 2006 16:08:40 -0400 (EDT) +To: Jeffrey Tenny +cc: "Jim C. Nasby" , pgsql-performance@postgresql.org +Subject: Re: performance question (something to do w/ parameterized +In-reply-to: <445F9F6B.9040200@comcast.net> +References: <445F7FF8.6070707@comcast.net> + <20060508173812.GW99570@pervasive.com> + <445F9F6B.9040200@comcast.net> +Comments: In-reply-to Jeffrey Tenny + message dated "Mon, 08 May 2006 15:43:39 -0400" +Date: Mon, 08 May 2006 16:08:40 -0400 +Message-ID: <29345.1147118920@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/154 +X-Sequence-Number: 18941 + +Jeffrey Tenny writes: +> Well, since I don't know the exact parameter values, just substituting +> 1-650 for $1-$650, I get: + +> Index Scan using testindex2 on x (cost=0.00..34964.52 rows=1503 +> width=16) (actual time=0.201..968.252 rows=677 loops=1) +> Filter: ((f = 1) OR (f = 2) OR (f = 3) OR (f = 4) ... + +> So index usage is presumably good on this one. + +No, that's not a very nice plan at all --- the key thing to notice is +it says Filter: not Index Cond:. What you've actually got here is a +full-index scan over testindex2 (I guess it's doing that to achieve the +requested sort order), then computation of a 650-way boolean OR expression +for each row of the table. Ugh. + +The other way of doing this would involve 650 separate index probes and +then sorting the result. Which would be pretty expensive too, but just +counting on my fingers it seems like that ought to come out at less than +the 35000 cost units for this plan. The planner evidently is coming up +with a different answer though. You might try dropping testindex2 +(which I suppose is an index on (f,c)) so that it has only an index on +f to play with, and see what plan it picks and what the estimated/actual +costs are. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon May 8 17:40:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 651F39F931D + for ; + Mon, 8 May 2006 17:40:20 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 91136-08 + for ; + Mon, 8 May 2006 17:40:15 -0300 (ADT) +X-Greylist: delayed 00:05:03.966177 by SQLgrey- +Received: from sccrmhc12.comcast.net (sccrmhc12.comcast.net [204.127.200.82]) + by postgresql.org (Postfix) with ESMTP id D7A0B9F931E + for ; + Mon, 8 May 2006 17:40:12 -0300 (ADT) +Received: from [192.168.1.52] (c-65-96-235-5.hsd1.ma.comcast.net[65.96.235.5]) + by comcast.net (sccrmhc12) with ESMTP + id <200605082033460120056scpe>; Mon, 8 May 2006 20:33:47 +0000 +Message-ID: <445FAB2A.9050401@comcast.net> +Date: Mon, 08 May 2006 16:33:46 -0400 +From: Jeffrey Tenny +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Tom Lane +CC: "Jim C. Nasby" , + pgsql-performance@postgresql.org +Subject: Re: performance question (something to do w/ parameterized +References: <445F7FF8.6070707@comcast.net> + <20060508173812.GW99570@pervasive.com> + <445F9F6B.9040200@comcast.net> <29345.1147118920@sss.pgh.pa.us> +In-Reply-To: <29345.1147118920@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/155 +X-Sequence-Number: 18942 + +The original set of indexes were: + +Indexes: + "x_c_idx" btree (c) + "x_f_idx" btree (f) + "testindex2" btree (f, c) + +I dropped the multicolumn index 'testindex2', and a new explain analyze +looks like this: + + Sort (cost=35730.71..35768.28 rows=1503 width=16) (actual +time=962.555..964.467 rows=677 loops=1) + Sort Key: f, c + -> Seq Scan on x (cost=0.00..34937.60 rows=1503 width=16) (actual +time=5.449..956.594 rows=677 loops=1) + Filter: ((f = 1) OR (f = 2) OR (f = 3) ... + + +Turning on the server debugging again, I got roughly identical +query times with and without the two column index. +It appears to have ignored the other indexes completely. + + +Tom Lane wrote: +> Jeffrey Tenny writes: +>> Well, since I don't know the exact parameter values, just substituting +>> 1-650 for $1-$650, I get: +> +>> Index Scan using testindex2 on x (cost=0.00..34964.52 rows=1503 +>> width=16) (actual time=0.201..968.252 rows=677 loops=1) +>> Filter: ((f = 1) OR (f = 2) OR (f = 3) OR (f = 4) ... +> +>> So index usage is presumably good on this one. +> +> No, that's not a very nice plan at all --- the key thing to notice is +> it says Filter: not Index Cond:. What you've actually got here is a +> full-index scan over testindex2 (I guess it's doing that to achieve the +> requested sort order), then computation of a 650-way boolean OR expression +> for each row of the table. Ugh. +> +> The other way of doing this would involve 650 separate index probes and +> then sorting the result. Which would be pretty expensive too, but just +> counting on my fingers it seems like that ought to come out at less than +> the 35000 cost units for this plan. The planner evidently is coming up +> with a different answer though. You might try dropping testindex2 +> (which I suppose is an index on (f,c)) so that it has only an index on +> f to play with, and see what plan it picks and what the estimated/actual +> costs are. +> +> regards, tom lane +> + +From pgsql-performance-owner@postgresql.org Tue May 9 23:54:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D66D49F931E + for ; + Mon, 8 May 2006 18:40:04 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10872-04 + for ; + Mon, 8 May 2006 18:39:56 -0300 (ADT) +X-Greylist: delayed 00:52:52.859093 by SQLgrey- +Received: from ensim.aers.ca (unknown [207.44.172.93]) + by postgresql.org (Postfix) with ESMTP id C8E7E9F931D + for ; + Mon, 8 May 2006 18:39:55 -0300 (ADT) +Received: from aers.ca (S0106002018a0e4a3.gv.shawcable.net [24.68.128.78] (may + be forged)) + by ensim.aers.ca (8.11.6/8.11.6) with ESMTP id k48Kks429410 + for ; Mon, 8 May 2006 13:46:54 -0700 +Content-class: urn:content-classes:message +Subject: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Date: Mon, 8 May 2006 13:38:58 -0700 +Message-ID: <6B5AF6293A289F45826220B17ABE79370D5EFB@BORON.aers.local> +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +thread-index: AcZy327Y2EJaUCqOSf+ixj05HmZOww== +From: "Adam Palmblad" +To: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Spam-Status: No, hits=1.209 tagged_above=0 required=5 tests=BAYES_20, + FORGED_RCVD_HELO, MISSING_SUBJECT, SPF_HELO_PASS, SPF_PASS +X-Spam-Level: * +X-Archive-Number: 200605/210 +X-Sequence-Number: 18997 + +Hi, + +We've got a C function that we use here and we find that for every +connection, the first run of the function is much slower than any +subsequent runs. ( 50ms compared to 8ms) + +Besides using connection pooling, are there any options to improve +performance? + +By the way, we are using pg version 8.1.3. + +-Adam + + +From pgsql-performance-owner@postgresql.org Mon May 8 17:50:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 55CDF9F931D + for ; + Mon, 8 May 2006 17:50:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 95086-05 + for ; + Mon, 8 May 2006 17:50:05 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 85D9F9F931E + for ; + Mon, 8 May 2006 17:50:04 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k48Knwe8029685; + Mon, 8 May 2006 16:49:58 -0400 (EDT) +To: Jeffrey Tenny +cc: "Jim C. Nasby" , pgsql-performance@postgresql.org +Subject: Re: performance question (something to do w/ parameterized +In-reply-to: <445FAB2A.9050401@comcast.net> +References: <445F7FF8.6070707@comcast.net> + <20060508173812.GW99570@pervasive.com> + <445F9F6B.9040200@comcast.net> <29345.1147118920@sss.pgh.pa.us> + <445FAB2A.9050401@comcast.net> +Comments: In-reply-to Jeffrey Tenny + message dated "Mon, 08 May 2006 16:33:46 -0400" +Date: Mon, 08 May 2006 16:49:58 -0400 +Message-ID: <29684.1147121398@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/156 +X-Sequence-Number: 18943 + +Jeffrey Tenny writes: +> I dropped the multicolumn index 'testindex2', and a new explain analyze +> looks like this: + +> Sort (cost=35730.71..35768.28 rows=1503 width=16) (actual +> time=962.555..964.467 rows=677 loops=1) +> Sort Key: f, c +> -> Seq Scan on x (cost=0.00..34937.60 rows=1503 width=16) (actual +> time=5.449..956.594 rows=677 loops=1) +> Filter: ((f = 1) OR (f = 2) OR (f = 3) ... + +> Turning on the server debugging again, I got roughly identical +> query times with and without the two column index. + +That's good, actually, seeing that the planner thinks they're close to +the same speed too. Now try "set enable_seqscan = off" to see if you +can force the multi-index-scan plan to be chosen, and see how that does. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon May 8 18:25:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B3E479F931E + for ; + Mon, 8 May 2006 18:25:51 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 11373-01 + for ; + Mon, 8 May 2006 18:25:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from vms048pub.verizon.net (vms048pub.verizon.net [206.46.252.48]) + by postgresql.org (Postfix) with ESMTP id 9134F9F931D + for ; + Mon, 8 May 2006 18:25:44 -0300 (ADT) +Received: from osgiliath.mathom.us ([70.108.51.88]) + by vms048.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 + (built Sep + 9 2005)) with ESMTPA id <0IYY00MSBTSDSD04@vms048.mailsrvcs.net> for + pgsql-performance@postgresql.org; Mon, 08 May 2006 16:17:02 -0500 (CDT) +Received: from localhost (localhost [127.0.0.1]) + by osgiliath.mathom.us (Postfix) with ESMTP id 29B526ED46 for + ; + Mon, 08 May 2006 17:17:01 -0400 (EDT) +Received: from osgiliath.mathom.us ([127.0.0.1]) + by localhost (osgiliath.home.mathom.us [127.0.0.1]) (amavisd-new, + port 10024) + with LMTP id qD5by20Rl8XR for ; Mon, + 08 May 2006 17:17:00 -0400 (EDT) +Received: by osgiliath.mathom.us (Postfix, from userid 1000) + id 7A3DF6ED63; Mon, 08 May 2006 17:17:00 -0400 (EDT) +Date: Mon, 08 May 2006 17:17:00 -0400 +From: Michael Stone +Subject: Re: Memory and/or cache issues? +In-reply-to: +To: pgsql-performance@postgresql.org +Mail-followup-to: pgsql-performance@postgresql.org +Message-id: <20060508211658.GO16533@mathom.us> +MIME-version: 1.0 +Content-type: text/plain; charset=us-ascii; format=flowed +Content-disposition: inline +X-Virus-Scanned: Debian amavisd-new at mathom.us +X-Pgp-Fingerprint: 53 FF 38 00 E7 DD 0A 9C 84 52 84 C5 EE DF 7C 88 +References: <0C4841B42F87D51195BD00B0D020F5CB044B2621@MORPHEUS> + <2680CBB8-985E-4C12-BCBB-72D49AA070EE@khera.org> + <20060508173055.GV99570@pervasive.com> + +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/157 +X-Sequence-Number: 18944 + +On Mon, May 08, 2006 at 03:38:23PM -0400, Vivek Khera wrote: +>On May 8, 2006, at 1:30 PM, Jim C. Nasby wrote: +>>>Yeah, I prefer my surgeons to work this way too. training is for the +>>>birds. +>> +>>I think you read too quickly past the part where Tim said he'd +>>taking a +>>week-long training class. +> +>s/training/apprenticeship/g; + +Of course, the original poster did say that hands-on was the best way to +learn. What is apprenticeship but a combination of training and +experience. Are you just sniping for fun? + +Mike Stone + +From pgsql-performance-owner@postgresql.org Mon May 8 19:11:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5E8339FA15C + for ; + Mon, 8 May 2006 19:11:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 17588-03 + for ; + Mon, 8 May 2006 19:11:36 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from rwcrmhc13.comcast.net (rwcrmhc13.comcast.net [216.148.227.153]) + by postgresql.org (Postfix) with ESMTP id EE8A29F9D82 + for ; + Mon, 8 May 2006 19:11:36 -0300 (ADT) +Received: from [192.168.1.52] (c-65-96-235-5.hsd1.ma.comcast.net[65.96.235.5]) + by comcast.net (rwcrmhc13) with ESMTP + id <20060508221134m1300pasode>; Mon, 8 May 2006 22:11:34 +0000 +Message-ID: <445FC215.8070804@comcast.net> +Date: Mon, 08 May 2006 18:11:33 -0400 +From: Jeffrey Tenny +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Tom Lane +CC: "Jim C. Nasby" , + pgsql-performance@postgresql.org +Subject: Re: performance question (something to do w/ parameterized +References: <445F7FF8.6070707@comcast.net> + <20060508173812.GW99570@pervasive.com> + <445F9F6B.9040200@comcast.net> <29345.1147118920@sss.pgh.pa.us> + <445FAB2A.9050401@comcast.net> <29684.1147121398@sss.pgh.pa.us> +In-Reply-To: <29684.1147121398@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/158 +X-Sequence-Number: 18945 + +I tried the seqscan disabling and got what sounds like the desired plan: + +Sort (cost=54900.62..54940.29 rows=1587 width=16) (actual time=20.208..22.138 rows=677 loops=1) + Sort Key: f, c + -> Index Scan using x_f_idx, x_f_idx, ... + (cost=0.00..54056.96 rows=1587 width=16) (actual time=1.048..15.598 rows=677 loops=1) + Index Cond: ((f = 1) OR (f = 2) OR (f = 3) .... + + +I turned off the option in postgresql.conf and it did indeed improve all similar queries on that table +to have sub-second response time, down from 6/8/10 second responses. And the elapsed time for +the application action reflected this improvement. + +So that begs two questions: + +1) is there a way to enable that for a single query in a multi-query transaction? + +2) am I opening a can of worms if I turn it off server-wide? (PROBABLY!) + +I've already had to tune the server to account for the fact that +the database is easily cached in memory but the processors are slow. (PIII 550Mhz Xeons) +I've lowered the cost of random pages and raised the cost of per-row processing +as follows (where the configuration defaults are also noted): + +# - Planner Cost Constants - + +#JDT: default effective_cache_size = 1000 # typically 8KB each +effective_cache_size = 50000 # typically 8KB each +#JDT: default: random_page_cost = 4 # units are one sequential page fetch cost +random_page_cost = 2 # units are one sequential page fetch cost +#JDT: default: cpu_tuple_cost = 0.01 # (same) +cpu_tuple_cost = 0.10 # (same) +#cpu_index_tuple_cost = 0.001 # (same) +#JDT: default: cpu_operator_cost = 0.0025 # (same) +cpu_operator_cost = 0.025 # (same) + + +Any suggestion for how to fix today's query (turning seqscan off) without wrecking others is welcome, as well as whether I've +blundered on the above (which may or may not be optimal, but definitely fixed some former problem queries +on that machine). + +My transactions are large multi-query serializable transactions, so it's also important that any single-query targeting optimization +not affect other queries in the same transaction. + +Thanks for the help. + +Tom Lane wrote: +> Jeffrey Tenny writes: +>> I dropped the multicolumn index 'testindex2', and a new explain analyze +>> looks like this: +> +>> Sort (cost=35730.71..35768.28 rows=1503 width=16) (actual +>> time=962.555..964.467 rows=677 loops=1) +>> Sort Key: f, c +>> -> Seq Scan on x (cost=0.00..34937.60 rows=1503 width=16) (actual +>> time=5.449..956.594 rows=677 loops=1) +>> Filter: ((f = 1) OR (f = 2) OR (f = 3) ... +> +>> Turning on the server debugging again, I got roughly identical +>> query times with and without the two column index. +> +> That's good, actually, seeing that the planner thinks they're close to +> the same speed too. Now try "set enable_seqscan = off" to see if you +> can force the multi-index-scan plan to be chosen, and see how that does. +> +> regards, tom lane +> + +From pgsql-performance-owner@postgresql.org Mon May 8 19:16:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 49DD79FA15C + for ; + Mon, 8 May 2006 19:16:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 11877-08 + for ; + Mon, 8 May 2006 19:16:00 -0300 (ADT) +X-Greylist: delayed 01:42:09.870467 by SQLgrey- +Received: from sccrmhc12.comcast.net (sccrmhc12.comcast.net [63.240.77.82]) + by postgresql.org (Postfix) with ESMTP id 602739F9D82 + for ; + Mon, 8 May 2006 19:16:00 -0300 (ADT) +Received: from [192.168.1.52] (c-65-96-235-5.hsd1.ma.comcast.net[65.96.235.5]) + by comcast.net (sccrmhc12) with ESMTP + id <20060508221558012005btmje>; Mon, 8 May 2006 22:15:58 +0000 +Message-ID: <445FC31E.20805@comcast.net> +Date: Mon, 08 May 2006 18:15:58 -0400 +From: Jeffrey Tenny +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Jeffrey Tenny +CC: Tom Lane , "Jim C. Nasby" , + pgsql-performance@postgresql.org +Subject: Re: performance question (something to do w/ parameterized +References: <445F7FF8.6070707@comcast.net> + <20060508173812.GW99570@pervasive.com> + <445F9F6B.9040200@comcast.net> <29345.1147118920@sss.pgh.pa.us> + <445FAB2A.9050401@comcast.net> <29684.1147121398@sss.pgh.pa.us> + <445FC215.8070804@comcast.net> +In-Reply-To: <445FC215.8070804@comcast.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/159 +X-Sequence-Number: 18946 + +re my question here: what would be the JDBC-proper technique, +my app is all jdbc. + +Jeffrey Tenny wrote: +> 1) is there a way to enable that for a single query in a multi-query +> transaction? + +From pgsql-performance-owner@postgresql.org Mon May 8 20:06:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 124269FA15C + for ; + Mon, 8 May 2006 20:06:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 20079-07 + for ; + Mon, 8 May 2006 20:06:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id B7C6E9F9D82 + for ; + Mon, 8 May 2006 20:06:04 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k48N61WN002399; + Mon, 8 May 2006 19:06:01 -0400 (EDT) +To: Jeffrey Tenny +cc: "Jim C. Nasby" , pgsql-performance@postgresql.org +Subject: Re: performance question (something to do w/ parameterized +In-reply-to: <445FC215.8070804@comcast.net> +References: <445F7FF8.6070707@comcast.net> + <20060508173812.GW99570@pervasive.com> + <445F9F6B.9040200@comcast.net> <29345.1147118920@sss.pgh.pa.us> + <445FAB2A.9050401@comcast.net> <29684.1147121398@sss.pgh.pa.us> + <445FC215.8070804@comcast.net> +Comments: In-reply-to Jeffrey Tenny + message dated "Mon, 08 May 2006 18:11:33 -0400" +Date: Mon, 08 May 2006 19:06:01 -0400 +Message-ID: <2398.1147129561@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/160 +X-Sequence-Number: 18947 + +Jeffrey Tenny writes: +> I tried the seqscan disabling and got what sounds like the desired plan: +> Sort (cost=54900.62..54940.29 rows=1587 width=16) (actual time=20.208..22.138 rows=677 loops=1) +> Sort Key: f, c +> -> Index Scan using x_f_idx, x_f_idx, ... +> (cost=0.00..54056.96 rows=1587 width=16) (actual time=1.048..15.598 rows=677 loops=1) +> Index Cond: ((f = 1) OR (f = 2) OR (f = 3) .... + +Hm, vs 35000 or so estimates for the slower plans. My recommendation +would be to decrease random_page_cost to 2 or so, instead of the brute +force disable-seqscans approach. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon May 8 20:35:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 570F29FA15C + for ; + Mon, 8 May 2006 20:35:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 25632-06 + for ; + Mon, 8 May 2006 20:35:19 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [204.127.192.82]) + by postgresql.org (Postfix) with ESMTP id 9F0BE9F9D82 + for ; + Mon, 8 May 2006 20:35:19 -0300 (ADT) +Received: from [192.168.1.52] (c-65-96-235-5.hsd1.ma.comcast.net[65.96.235.5]) + by comcast.net (rwcrmhc12) with ESMTP + id <20060508233516m1200aun4re>; Mon, 8 May 2006 23:35:17 +0000 +Message-ID: <445FD5B3.1010708@comcast.net> +Date: Mon, 08 May 2006 19:35:15 -0400 +From: Jeffrey Tenny +User-Agent: Thunderbird 1.5 (X11/20051201) +MIME-Version: 1.0 +To: Tom Lane +CC: "Jim C. Nasby" , + pgsql-performance@postgresql.org +Subject: Re: performance question (something to do w/ parameterized +References: <445F7FF8.6070707@comcast.net> + <20060508173812.GW99570@pervasive.com> + <445F9F6B.9040200@comcast.net> <29345.1147118920@sss.pgh.pa.us> + <445FAB2A.9050401@comcast.net> <29684.1147121398@sss.pgh.pa.us> + <445FC215.8070804@comcast.net> <2398.1147129561@sss.pgh.pa.us> +In-Reply-To: <2398.1147129561@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/161 +X-Sequence-Number: 18948 + +Tom Lane wrote: + > Jeffrey Tenny writes: + >> I tried the seqscan disabling and got what sounds like the desired plan: + >> Sort (cost=54900.62..54940.29 rows=1587 width=16) (actual time=20.208..22.138 rows=677 loops=1) + >> Sort Key: f, c + >> -> Index Scan using x_f_idx, x_f_idx, ... + >> (cost=0.00..54056.96 rows=1587 width=16) (actual time=1.048..15.598 rows=677 loops=1) + >> Index Cond: ((f = 1) OR (f = 2) OR (f = 3) .... + > + > Hm, vs 35000 or so estimates for the slower plans. My recommendation + > would be to decrease random_page_cost to 2 or so, instead of the brute + > force disable-seqscans approach. + +The server was already running with random_page_cost=2 today for all tests, because of +the mods I've made to improve other problem queries in the past (my settings noted below, and +before in another msg on this topic). + +So to nail this particular query something additional is required (even lower random_page_cost?). +What's a good value for slower processors/memory and database in memory? +1? .5? + +Just curious: +Has anybody ever done an exercise that generates postgresql defaults that are customized based on the +cpu, memory, architecture, bus speeds, etc? +These old PIII xeons are quite a bit different than the newer AMD chips I use for postgres, +and the tuning of the postgresql.conf parameters has been very effective in using the old xeons, but it seems like there +must be a general knowledge base of what's generically more appropriate for some types of hardware +that would give people +better initial defaults for a given platform. I know, step right up and do it :-) + +Here's the postgresql defaults and actual settings I used for all tests today (from my production server): + +> I've already had to tune the server to account for the fact that +> the database is easily cached in memory but the processors are slow. (PIII 550Mhz Xeons) +> I've lowered the cost of random pages and raised the cost of per-row processing +> as follows (where the configuration defaults are also noted): +> +> # - Planner Cost Constants - +> +> #JDT: default effective_cache_size = 1000 # typically 8KB each +> effective_cache_size = 50000 # typically 8KB each +> #JDT: default: random_page_cost = 4 # units are one sequential page fetch cost +> random_page_cost = 2 # units are one sequential page fetch cost +> #JDT: default: cpu_tuple_cost = 0.01 # (same) +> cpu_tuple_cost = 0.10 # (same) +> #cpu_index_tuple_cost = 0.001 # (same) +> #JDT: default: cpu_operator_cost = 0.0025 # (same) +> cpu_operator_cost = 0.025 # (same) + + + + +From pgsql-performance-owner@postgresql.org Mon May 8 20:37:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B92CB9FA15C + for ; + Mon, 8 May 2006 20:37:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 28070-03 + for ; + Mon, 8 May 2006 20:37:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id BC3FA9F9D82 + for ; + Mon, 8 May 2006 20:37:41 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k48NbbGU002732; + Mon, 8 May 2006 19:37:37 -0400 (EDT) +To: Jeffrey Tenny +cc: "Jim C. Nasby" , pgsql-performance@postgresql.org +Subject: Re: performance question (something to do w/ parameterized +In-reply-to: <445FD5B3.1010708@comcast.net> +References: <445F7FF8.6070707@comcast.net> + <20060508173812.GW99570@pervasive.com> + <445F9F6B.9040200@comcast.net> <29345.1147118920@sss.pgh.pa.us> + <445FAB2A.9050401@comcast.net> <29684.1147121398@sss.pgh.pa.us> + <445FC215.8070804@comcast.net> <2398.1147129561@sss.pgh.pa.us> + <445FD5B3.1010708@comcast.net> +Comments: In-reply-to Jeffrey Tenny + message dated "Mon, 08 May 2006 19:35:15 -0400" +Date: Mon, 08 May 2006 19:37:37 -0400 +Message-ID: <2731.1147131457@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/162 +X-Sequence-Number: 18949 + +Jeffrey Tenny writes: +> The server was already running with random_page_cost=2 today for all tests, because of +> the mods I've made to improve other problem queries in the past (my settings noted below, and +> before in another msg on this topic). + +> So to nail this particular query something additional is required (even lower random_page_cost?). +> What's a good value for slower processors/memory and database in memory? + +If you're pretty sure the database will always be RAM-resident, then 1.0 +is the theoretically correct value. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon May 8 21:08:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 54E5C9FA15C + for ; + Mon, 8 May 2006 21:08:16 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 30620-05 + for ; + Mon, 8 May 2006 21:08:09 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 5D7C99F9D82 + for ; + Mon, 8 May 2006 21:08:09 -0300 (ADT) +Received: from mailhub2.une.edu.au (mailhub.une.edu.au [129.180.1.222]) + by svr4.postgresql.org (Postfix) with ESMTP id 2C37B5B2050 + for ; + Tue, 9 May 2006 00:08:07 +0000 (GMT) +Received: from icarus.une.edu.au (icarus.une.edu.au [129.180.47.120]) + by mailhub2.une.edu.au (Postfix) with ESMTP id F33774520; + Tue, 9 May 2006 10:07:56 +1000 (EST) +Received: from kgb (unknown [129.180.47.225]) + by icarus.une.edu.au (Postfix) with SMTP id A41013544DE; + Tue, 9 May 2006 10:07:56 +1000 (EST) +Date: Tue, 09 May 2006 10:10:19 +1000 +From: Klint Gore +To: Tom Lane +Cc: Jim C.Nasby , pgsql-performance@postgresql.org, + Jeffrey Tenny +Subject: Re: performance question (something to do w/ parameterized +In-Reply-To: <2731.1147131457@sss.pgh.pa.us> +References: <445FD5B3.1010708@comcast.net> <2731.1147131457@sss.pgh.pa.us> +Message-Id: <445FDDEB225.3451KG@129.180.47.120> +MIME-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Mailer: Becky! ver 1.25.06 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/163 +X-Sequence-Number: 18950 + +On Mon, 08 May 2006 19:37:37 -0400, Tom Lane wrote: +> Jeffrey Tenny writes: +> > The server was already running with random_page_cost=2 today for all tests, because of +> > the mods I've made to improve other problem queries in the past (my settings noted below, and +> > before in another msg on this topic). +> +> > So to nail this particular query something additional is required (even lower random_page_cost?). +> > What's a good value for slower processors/memory and database in memory? +> +> If you're pretty sure the database will always be RAM-resident, then 1.0 +> is the theoretically correct value. + +Would it be possible to craft a set of queries on specific data that +could advise a reasonable value for random_page_cost? + +What sort of data distribution and query type would be heavily dependant +on random_page_cost? i.e. randomness of the data, size of the data +compared to physical memory. + +klint. + ++---------------------------------------+-----------------+ +: Klint Gore : "Non rhyming : +: EMail : kg@kgb.une.edu.au : slang - the : +: Snail : A.B.R.I. : possibilities : +: Mail University of New England : are useless" : +: Armidale NSW 2351 Australia : L.J.J. : +: Fax : +61 2 6772 5376 : : ++---------------------------------------+-----------------+ + +From pgsql-performance-owner@postgresql.org Mon May 8 22:30:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 306AF9FA15C + for ; + Mon, 8 May 2006 22:30:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 67413-01 + for ; + Mon, 8 May 2006 22:30:02 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 1B9AB9F9D82 + for ; + Mon, 8 May 2006 22:30:01 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)) + for pgsql-performance@postgresql.org; Mon, 8 May 2006 19:29:58 -0600 +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Transfer-Encoding: 7bit +Message-Id: +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: PostgreSQL Performance +From: Brendan Duddridge +Subject: Assistance with optimizing query - same SQL, + different category_id = Seq Scan +Date: Mon, 8 May 2006 19:29:32 -0600 +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/164 +X-Sequence-Number: 18951 + +Hi, + +I have a query that generates two different plans when there's only a +change in the category_id used in the query. + +The first query has category_id = 1001573 and return 3117 rows from +the category_product table. +The second query has category_id = 1001397 and returns 27889 rows +from the category_product table. + +The first query does all access via indexes. +The second query does all access via indexes except for a sequential +scan on the Price table. + +Here is the explain analyze for the first query: + +explain analyze +select distinct pr.amount +from merchant_product mp, +category_product cp, +price pr +where cp.category_id = 1001573 and + cp.product_id = mp.product_id and + cp.product_status_code = 'complete' and + cp.product_is_active = 'true' and + mp.is_active = 'true' and + mp.merchant_product_id = pr.merchant_product_id +order by amount asc; + + + + QUERY PLAN +------------------------------------------------------------------------ +------------------------------------------------------------------------ +---------------------------------------------- +Unique (cost=24311.37..24325.11 rows=2748 width=11) (actual +time=277.953..280.844 rows=622 loops=1) + -> Sort (cost=24311.37..24318.24 rows=2748 width=11) (actual +time=277.952..278.490 rows=4007 loops=1) + Sort Key: pr.amount + -> Nested Loop (cost=0.00..24154.40 rows=2748 width=11) +(actual time=0.295..262.225 rows=4007 loops=1) + -> Nested Loop (cost=0.00..14658.32 rows=2750 +width=4) (actual time=0.229..84.908 rows=4007 loops=1) + -> Index Scan using +x_category_product__category_id_fk_idx on category_product cp +(cost=0.00..3054.20 rows=2369 width=4) (actual time=0.136..20.746 +rows=2832 loops=1) + Index Cond: (category_id = 1001573) + Filter: (((product_status_code)::text = +'complete'::text) AND ((product_is_active)::text = 'true'::text)) + -> Index Scan using +merchant_product__product_id_fk_idx on merchant_product mp +(cost=0.00..4.89 rows=1 width=8) (actual time=0.019..0.021 rows=1 +loops=2832) + Index Cond: ("outer".product_id = +mp.product_id) + Filter: ((is_active)::text = 'true'::text) + -> Index Scan using +price__merchant_product_id_fk_idx on price pr (cost=0.00..3.44 +rows=1 width=15) (actual time=0.042..0.043 rows=1 loops=4007) + Index Cond: ("outer".merchant_product_id = +pr.merchant_product_id) +Total runtime: 281.709 ms + + +Here is the explain analyze for the second (slow) query: + +explain analyze +select distinct pr.amount +from merchant_product mp, +category_product cp, +price pr +where cp.category_id = 1001397 and + cp.product_id = mp.product_id and + cp.product_status_code = 'complete' and + cp.product_is_active = 'true' and + mp.is_active = 'true' and + mp.merchant_product_id = pr.merchant_product_id +order by amount asc; + + + QUERY PLAN +------------------------------------------------------------------------ +------------------------------------------------------------------------ +-------------------------------------------------------------- +Unique (cost=106334.48..106452.38 rows=6050 width=11) (actual +time=7140.302..7162.345 rows=2567 loops=1) + -> Sort (cost=106334.48..106393.43 rows=23580 width=11) (actual +time=7140.300..7143.873 rows=26949 loops=1) + Sort Key: pr.amount + -> Hash Join (cost=77475.88..104621.95 rows=23580 +width=11) (actual time=4213.546..7015.639 rows=26949 loops=1) + Hash Cond: ("outer".merchant_product_id = +"inner".merchant_product_id) + -> Seq Scan on price pr (cost=0.00..20782.51 +rows=1225551 width=15) (actual time=0.059..1482.238 rows=1225551 +loops=1) + -> Hash (cost=77416.91..77416.91 rows=23590 +width=4) (actual time=4212.042..4212.042 rows=26949 loops=1) + -> Merge Join (cost=22632.74..77416.91 +rows=23590 width=4) (actual time=1851.012..4186.067 rows=26949 loops=1) + Merge Cond: ("outer".product_id = +"inner".product_id) + -> Index Scan using +merchant_product__product_id_fk_idx on merchant_product mp +(cost=0.00..51365.12 rows=1226085 width=8) (actual +time=0.073..3141.654 rows=1208509 loops=1) + Filter: ((is_active)::text = +'true'::text) + -> Sort (cost=22632.74..22683.55 +rows=20325 width=4) (actual time=507.110..511.076 rows=26949 loops=1) + Sort Key: cp.product_id + -> Index Scan using +x_category_product__category_id_fk_idx on category_product cp +(cost=0.00..21178.38 rows=20325 width=4) (actual time=0.145..440.113 +rows=26949 loops=1) + Index Cond: (category_id = +1001397) + Filter: +(((product_status_code)::text = 'complete'::text) AND +((product_is_active)::text = 'true'::text)) +Total runtime: 7172.359 ms + + +Notice the sequential scan of the Price table? It scanned 1,225,551 +rows in the second query. + + +Do you have any suggestions on how I can optimize the query so both +versions of the query come back fast without doing a sequential scan +on the price table? + + +Thanks, + + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + + + +From pgsql-performance-owner@postgresql.org Mon May 8 22:39:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0D3FC9FA15C + for ; + Mon, 8 May 2006 22:39:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 71701-01 + for ; + Mon, 8 May 2006 22:39:23 -0300 (ADT) +X-Greylist: delayed 16:51:31.095946 by SQLgrey- +Received: from grp-smtp.toray.com.my (grp-smtp.toray.com.my [202.186.44.7]) + by postgresql.org (Postfix) with ESMTP id A17819F9D82 + for ; + Mon, 8 May 2006 22:39:23 -0300 (ADT) +Received: from localhost (localhost.toray.com.my [127.0.0.1]) + by grp-smtp.toray.com.my (Postfix) with ESMTP id 489615087A; + Tue, 9 May 2006 09:39:19 +0800 (MYT) +X-Virus-Scanned: amavisd-new at pengroup.com.my +Received: from grp-smtp.toray.com.my ([127.0.0.1]) + by localhost (grp-smtp.pengroup.com.my [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id hOva5TmmS-gC; Tue, 9 May 2006 09:39:14 +0800 (MYT) +Received: from notes01.pengroup.com.my (notes01.toray.com.my [10.200.1.1]) + by grp-smtp.toray.com.my (Postfix) with ESMTP id AB82750876; + Tue, 9 May 2006 09:39:14 +0800 (MYT) +Subject: Re: extremely slow when execute select/delete for certain tables +To: Markus Schaber , + "Jim C. Nasby" +Cc: "pgsql-performance@postgresql.org" +X-Mailer: Lotus Notes Release 5.0.5 September 22, 2000 +Message-ID: +From: kah_hang_ang@toray.com.my +Date: Tue, 9 May 2006 09:39:13 +0800 +X-MIMETrack: Serialize by Router on Notes01/Pen-Group(Release 6.5.1|January + 21, + 2004) at 05/09/2006 09:39:13 AM +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/165 +X-Sequence-Number: 18952 + + + + + +Actually now I already work to upgrade Postgresql version to 8.1 but not +yet finish. + +Yesterday I did re-create the affected tables indices, it does improve the +performance but still need 2-5 mins to execute the query. +Is this 'normal' for a table with 40K rows of records? + +Anyway thanks for your help. + + + +From pgsql-performance-owner@postgresql.org Tue May 9 00:54:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6C5259FA15C + for ; + Tue, 9 May 2006 00:54:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 87753-10 + for ; + Tue, 9 May 2006 00:54:17 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from py-out-1112.google.com (py-out-1112.google.com + [64.233.166.180]) + by postgresql.org (Postfix) with ESMTP id 095EE9F9D82 + for ; + Tue, 9 May 2006 00:54:17 -0300 (ADT) +Received: by py-out-1112.google.com with SMTP id c63so1561646pyc + for ; + Mon, 08 May 2006 20:54:15 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=WVP8Y5aVNmlUdewKn2mLslQVpx0y8ZB/JQEzOhRdTilc+4HiRYHG7XZ8EMAWulqPdJYGWfvO7z3aOPjzCgyTSfSLooeylRO5N9ECyUN2QzGaLkIqQ96Xq0YNSt1BWZSDzNY6SGOBPYffQoHbqwkPCUE6T5vRKYGj8G9cfFjXeEo= +Received: by 10.35.88.17 with SMTP id q17mr781658pyl; + Mon, 08 May 2006 20:54:15 -0700 (PDT) +Received: by 10.35.8.14 with HTTP; Mon, 8 May 2006 20:54:15 -0700 (PDT) +Message-ID: <9f2e40a90605082054g6dd3e4f5ne3faf631e4792116@mail.gmail.com> +Date: Tue, 9 May 2006 09:24:15 +0530 +From: "soni de" +To: "Dave Dutcher" +Subject: Re: Takes too long to fetch the data from database +Cc: pgsql-performance@postgresql.org +In-Reply-To: <007801c66547$35e26270$8300a8c0@tridecap.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_38245_11902809.1147146855095" +References: <9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com> + <007801c66547$35e26270$8300a8c0@tridecap.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/166 +X-Sequence-Number: 18953 + +------=_Part_38245_11902809.1147146855095 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hello, + +I have tried the query SELECT * FROM wan ORDER BY stime DESC OFFSET 0 LIMIT +50; and it is working great. +EXPLAIN ANALYSE of the above query is: +pdb=3D# EXPLAIN ANALYZE select * from wan order by stime desc limit 50 ; +NOTICE: QUERY PLAN: + +Limit (cost=3D0.00..12.10 rows=3D50 width=3D95) (actual time=3D24.29..50.2= +4 rows=3D50 +loops=3D1) + -> Index Scan Backward using wan_pkey on wan=20 +(cost=3D0.00..19983.31rows=3D82586 width=3D95) (actual time=3D +24.28..50.14 rows=3D51 loops=3D1) +Total runtime: 50.55 msec + +EXPLAIN + +Now I am facing another problem, If I use where clause is select query it i= +s +taking too much time. Can you please help me on this. + +Explain analyze are follows: +pdb=3D# EXPLAIN ANALYZE select count(1) from wan where kname =3D 'pluto'; +NOTICE: QUERY PLAN: + +Aggregate (cost=3D3507.84..3507.84 rows=3D1 width=3D0) (actual time=3D +214647.53..214647.54 rows=3D1 loops=3D1) + -> Seq Scan on wan (cost=3D0.00..3507.32 rows=3D208 width=3D0) (actual = +time=3D +13.65..214599.43 rows=3D18306 loops=3D1) +Total runtime: 214647.87 msec + +EXPLAIN +pdb=3D# EXPLAIN ANALYZE select * from wan where kname =3D 'pluto' order by = +stime +limit 50; +NOTICE: QUERY PLAN: + +Limit (cost=3D3515.32..3515.32 rows=3D50 width=3D95) (actual time=3D +230492.69..230493.07 rows=3D50 loops=3D1) + -> Sort (cost=3D3515.32..3515.32 rows=3D208 width=3D95) (actual time=3D +230492.68..230493.00 rows=3D51 loops=3D1) + -> Seq Scan on wan (cost=3D0.00..3507.32 rows=3D208 width=3D95) (= +actual +time=3D0.44..229217.38 rows=3D18306 loops=3D1) +Total runtime: 230631.62 msec + +EXPLAIN +pdb=3D# EXPLAIN ANALYZE SELECT * FROM wan WHERE stime >=3D 20123 AND stime= + <=3D +24000 ORDER BY stime limit 50; +NOTICE: QUERY PLAN: + +Limit (cost=3D0.00..2519.70 rows=3D50 width=3D95) (actual +time=3D7346.74..7351.42rows=3D50 loops=3D1) + -> Index Scan using wan_pkey on wan (cost=3D0.00..20809.17 rows=3D413 +width=3D95) (actual time=3D7346.73..7351.32 rows=3D51 loops=3D1) +Total runtime: 7351.71 msec + +EXPLAIN + +for above queries if I use desc order then the queries takes too much time= +. +I am not getting for the above queries how do I increase the speed. + +Postgresql version is 7.2.3 +total no. of records: 5700300 + +On 4/21/06, Dave Dutcher wrote: +> +> I've never used a cursor in Postgres, but I don't think it will help you +> a lot. In theory cursors make it easier to do paging, but your main +> problem is that getting the first page is slow. A cursor isn't going to +> be any faster at getting the first page than OFFSET/LIMIT is. +> +> +> +> Did you try Bruno's suggestion of: +> +> +> +> SELECT * FROM wan ORDER BY stime DESC OFFSET 0 LIMIT 50; +> +> +> +> You should run an EXPLAIN ANALYZE on that query to see if it is using an +> index scan. Also what version of Postgres are you using? You can run +> select version(); to check. +> +> +> +> +> +> +> +> -----Original Message----- +> *From:* pgsql-performance-owner@postgresql.org [mailto: +> pgsql-performance-owner@postgresql.org] *On Behalf Of *soni de +> *Sent:* Thursday, April 20, 2006 11:42 PM +> *To:* Merlin Moncure +> *Cc:* pgsql-performance@postgresql.org +> *Subject:* Re: [PERFORM] Takes too long to fetch the data from database +> +> +> +> I don't want to query exactly 81900 rows into set. I just want to fetch 5= +0 +> or 100 rows at a time in a decreasing order of stime.(i.e 50 or 100 rows +> starting from last to end). +> +> +> +> if we fetched sequentially, there is also problem in fetching all the +> records (select * from wan where kname=3D'pluto' order by stime) it is ta= +king +> more than 4~5 minutes. tried it on same table having more than 326054 +> records. +> +> +> +> +> On 4/20/06, *Merlin Moncure* wrote: +> +> > SELECT * FROM wan ORDER BY stime LIMIT 50 OFFSET 81900; +> +> you need to try and solve the problem without using 'offset'. you could +> do: +> BEGIN; +> DECLARE crs cursor FOR SELECT * FROM wan ORDER BY stime; +> FETCH ABSOLUTE 81900 in crs; +> FETCH 49 in crs; +> CLOSE crs; +> COMMIT; +> +> this may be a bit faster but will not solve the fundamental problem. +> +> the more interesting question is why you want to query exactly 81900 +> rows into a set. This type of thinking will always get you into +> trouble, absolute positioning will not really work in a true sql +> sense. if you are browsing a table sequentially, there are much +> better methods. +> +> merlin +> +> +> + +------=_Part_38245_11902809.1147146855095 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

Hello,
+
 
+
I have tried the query SELECT * FROM wan ORDER BY stime DESC OFFSET 0 LIM= +IT 50; and it is working great.
+
EXPLAIN ANA= +LYSE of the above query is:
+
pdb=3D# EXPLAIN ANALYZE select * from = +wan order by stime desc limit 50 ;
NOTICE:  QUERY PLAN:
+
+

Limit  (cost=3D0.00..12.10 rows=3D50 width=3D95) (actual time=3D24.= +29..50.24 rows=3D50 loops=3D1)
  ->  Index Scan Backward us= +ing wan_pkey on wan  (cost=3D0.00..19983.31 rows=3D82586 width=3D95) (= +actual time=3D24.28..50.14 rows=3D51 loops=3D1) +
Total runtime: 50.55 msec

+

EXPLAIN

+
 
+
Now I am fa= +cing another problem, If I use where clause is select query it is taking to= +o much time. Can you please help me on this.
+
 
+
Explain ana= +lyze are follows:
+
pdb=3D# EXPLAIN ANALYZE select count(1= +)  from wan where kname =3D 'pluto';
NOTICE:  QUERY PLAN:
+
+

Aggregate  (cost=3D3507.84..3507.84 rows=3D1 width=3D0) (actual tim= +e=3D214647.53..214647.54 rows=3D1 loops=3D1)
  ->  Seq Scan= + on wan  (cost=3D0.00..3507.32 rows=3D208 width=3D0) (actual time=3D13= +.65..214599.43 rows=3D18306 loops=3D1)
+Total runtime: 214647.87 msec

+

EXPLAIN
pdb=3D# EXPLAIN ANALYZE select * from wan where kname =3D 'pl= +uto' order by stime limit 50;
NOTICE:  QUERY PLAN:

+

Limit  (cost=3D3515.32..3515.32 rows=3D50 width=3D95) (actual time= +=3D230492.69..230493.07 rows=3D50 loops=3D1)
  ->  Sort&nbs= +p; (cost=3D3515.32..3515.32 rows=3D208 width=3D95) (actual time=3D230492.68= +..230493.00 rows=3D51 loops=3D1)
      &nb= +sp; ->  Seq Scan on wan  (cost=3D +0.00..3507.32 rows=3D208 width=3D95) (actual time=3D0.44..229217.38 rows=3D= +18306 loops=3D1)
Total runtime: 230631.62 msec

+

EXPLAIN
pdb=3D# EXPLAIN ANALYZE SELECT * FROM wan  WHERE stime &= +gt;=3D 20123 AND stime <=3D 24000 ORDER BY stime limit 50;
NOTICE:&nb= +sp; QUERY PLAN:

+

Limit  (cost=3D0.00..2519.70 rows=3D50 width=3D95) (actual time=3D7= +346.74..7351.42 rows=3D50 loops=3D1)
  ->  Index Scan using= + wan_pkey on wan  (cost=3D0.00..20809.17 rows=3D413 width=3D95) (actua= +l time=3D7346.73..7351.32 rows=3D51 loops=3D1) +
Total runtime: 7351.71 msec

+

EXPLAIN

+

for above queries if I use desc order then the queries takes&n= +bsp; too much time.

+
I am not ge= +tting for the above queries how do I increase the speed. +
 
+
Postgresql version is 7.2.3
+
total no. of records: 5700300
 
+
On 4/21/06, = +Dave Dutcher <dave@tridecap.com= +> wrote: +
+
+
+

I've never used a cursor in P= +ostgres, but I don't think it will help you a lot.  In theory cursors make it easier to do paging, but your main problem is t= +hat getting the first page is slow. +  A cursor isn't going to be any faster at getting the fi= +rst page than OFFSET/LIMIT is.

+

 

+

Did you try Bruno's suggestion of:

+

 

+

SE= +LECT * FROM wan ORDER BY stime DESC OFFSET 0 LIMIT 50;<= +/font>

+

&n= +bsp;

+

You should run an EXPLAIN ANALYZE o= +n that query to see if it is using an index scan.  Also w= +hat version of=20 +Postgres are you using?  You can run select = +version(); to check.

+

 

+

 

+

 

+
+
+
+
+

I don't want to query exactly 81900 rows into set. I just want to fetch 5= +0 or 100 rows at a time in a decreasing order of stime.(i.e 50 or 100 rows = +starting from last to end). +

+
+

 

+
+

if we fetched sequentially, there is also problem in fetching all the rec= +ords (select * from wan where kname=3D'pluto' order by stime) it is ta= +king more than 4~5 minutes. tried it on same table having more than 326054 = +records.=20 +

+
+


 

+
+

On 4/20/06, Merlin Moncure < +mmoncure@gmail.com> wrote:

+

> SELECT * FROM wan ORDER BY stime LIMIT 50 OFFSET 81900;

you n= +eed to try and solve the problem without using 'offset'.  you cou= +ld do:
+BEGIN;
DECLARE crs cursor FOR SELECT * FROM wan ORDER BY stime;
FETCH= + ABSOLUTE 81900 in crs;
FETCH 49 in crs;
CLOSE crs;
COMMIT;
this may be a bit faster but will not solve the fundamental problem.
+
the more interesting question is why you want to query exactly 81900rows into a set.  This type of thinking will always get you into= +
trouble, absolute positioning will not really work in a true sql
sen= +se.  if you are browsing a table sequentially, there are much=20 +
better methods.

merlin

+

 

+

+ +------=_Part_38245_11902809.1147146855095-- + +From pgsql-performance-owner@postgresql.org Tue May 9 04:41:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 61A459FA226 + for ; + Tue, 9 May 2006 04:41:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 15478-07 + for ; + Tue, 9 May 2006 04:41:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id 4362A9F931D + for ; + Tue, 9 May 2006 04:41:23 -0300 (ADT) +Received: (qmail 15423 invoked by uid 500); 9 May 2006 07:38:55 -0000 +Date: Tue, 9 May 2006 02:38:55 -0500 +From: Bruno Wolff III +To: soni de +Cc: Dave Dutcher , pgsql-performance@postgresql.org +Subject: Re: Takes too long to fetch the data from database +Message-ID: <20060509073855.GA11659@wolff.to> +Mail-Followup-To: Bruno Wolff III , + soni de , Dave Dutcher , + pgsql-performance@postgresql.org +References: <9f2e40a90604202142x5adbe6f0r7a993f8319619cc7@mail.gmail.com> + <007801c66547$35e26270$8300a8c0@tridecap.com> + <9f2e40a90605082054g6dd3e4f5ne3faf631e4792116@mail.gmail.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <9f2e40a90605082054g6dd3e4f5ne3faf631e4792116@mail.gmail.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/167 +X-Sequence-Number: 18954 + +On Tue, May 09, 2006 at 09:24:15 +0530, + soni de wrote: +> +> EXPLAIN +> pdb=# EXPLAIN ANALYZE select * from wan where kname = 'pluto' order by stime +> limit 50; +> NOTICE: QUERY PLAN: +> +> Limit (cost=3515.32..3515.32 rows=50 width=95) (actual time= +> 230492.69..230493.07 rows=50 loops=1) +> -> Sort (cost=3515.32..3515.32 rows=208 width=95) (actual time= +> 230492.68..230493.00 rows=51 loops=1) +> -> Seq Scan on wan (cost=0.00..3507.32 rows=208 width=95) (actual +> time=0.44..229217.38 rows=18306 loops=1) +> Total runtime: 230631.62 msec + +Unless you have an index on (kname, stime) the query is going to need to +find the records with a value for kname of 'pluto' and then get the most +recent 50 of them. It looks like there are enough estimated records +with kname = 'pluto', that a sequential scan is being prefered. +Creating an extra index will slow down inserts somewhat, but will speed +up queries like the above significantly, so may be worthwhile for you. +I think later versions of Postgres are smarter, but for sure in 7.2 +you will need to write the query like: +SELECT * + FROM wan + WHERE kname = 'pluto' + ORDER BY kname DESC, stime DESC + LIMIT 50 +; + +From pgsql-performance-owner@postgresql.org Tue May 9 05:37:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 034DF9FA293 + for ; + Tue, 9 May 2006 05:37:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 22437-07 + for ; + Tue, 9 May 2006 05:37:02 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 65FAA9FA226 + for ; + Tue, 9 May 2006 05:37:01 -0300 (ADT) +Received: (qmail 2333 invoked from network); 9 May 2006 10:38:19 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 9 May 2006 10:38:19 +0200 +Date: Tue, 09 May 2006 10:38:17 +0200 +To: "Tom Lane" , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Big IN() clauses etc : feature proposal +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <28288.1147111196@sss.pgh.pa.us> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/168 +X-Sequence-Number: 18955 + + +>>> The moral of the story is that you're probably better off running a +>>> bunch of small selects than in trying to optimize things with one +>>> gargantuan select. +> +>> Ever experiment with loading the parameters into a temp table and +>> joining to that? +> +> Also, it might be worth re-testing that conclusion with PG CVS tip +> (or 8.2 when it comes out). The reimplementation of IN as = ANY that +> I did a couple months ago might well change the results. + + Long mail, but I think it's interesting... + + I think this is a generic problem, which is often encountered : selecting +a bunch of records based on a list of primary keys (or other indexed, +unique field) ; said list being anything from very short to quite large. + Here are a few occurences of this need : + + 1- The application supplies a list of id's (the case of the OP of this +thread) + 2- A query Q1 yields a list of selected objects , that we wish to use in +several subsequent queries. + And Q1 is a query we don't wish to do several times, either because it's +slow, complicated (advanced search, for instance), or it acts on a +constantly moving dataset, so the results would be different each time. So +we store the result of Q1 in the application, or in a temp table, or in an +array in a plpgsql variable, whatever, to reuse them. + + Then, for each of these objects, often we will make more queries to +resolve foreign keys (get category name, owner name, from categories and +users tables, etc). + + I have encountered both cases quite often, and they both pose a few +problems. I think it would be a good opportunity for a new feature (see +below). + A typical use case for point 2 : + + Consider an "objects" table. Each object ... + - is related to one or several rows from the "categories" table via an +"objects_categories" link table. + - has an owner_id referencing the "users" table + + I do an "advanced search" query on "objects", which returns a list of +objects. I can join directly to "users" to get the owner's name, but +joining to "categories" is already problematic because of the many-to-many +relationship. + + I wish to do this : fetch all objects matching the search criteria ; +fetch the owner users ; fetch the categories ; build in my application +object space a clean and straightforward data representation for all this. + + Also : + - I do not wish to complicate the search query. + - The row estimates for the search query results are likely to be "not so +good" (because it's a complex query) ; so the joins to users and +categories are likely to use suboptimal plans based on "not so good" +estimates. + - The rows from "objects" are large ; so moving them around through a lot +of small joins hurts performance. + + The obvious solution is this : + +BEGIN; +CREATE TEMPORARY TABLE results ON COMMIT DROP AS SELECT * FROM advanced +search query; +ANALYZE results; + +-- get the results to the application +SELECT * FROM results; + +-- get object owners info +SELECT * FROM users WHERE id IN (SELECT user_id FROM results); + +-- get category info +SELECT * FROM categories WHERE id IN (SELECT category_id FROM +objects_to_categories WHERE object_id IN (SELECT id FROM results)); + +-- get object/category relations (the ORM will use this to link objects in +the application) +SELECT * FROM objects_to_categories WHERE object_id IN (SELECT id FROM +results); +COMMIT; + + You might wonder why I do it this way on the "categories" table. + This is because I use an Object-Relational mapper which will instantiate +a User or Category class object for each row I fetch from these tables. I +do not want to fetch just the username, using a simple join, but I want +the full object, because : + - I want to instantiate these objects (they have useful methods to +process rights etc) + - I do not want to mix columns from "objects" and "users" + + And I do not wish to instantiate each category more than once. This would +waste memory, but more importantly, it is a lot cleaner to have only one +instance per row, because my ORM then translates the foreign key relations +into object relations (pointers). Each instanciated category will contain +a list of Object instances ; each Object instance will contain a list of +the categories it belongs to, and point to its owner user. + + Back to the point : I can't use the temp table method, because temp +tables are too slow. + Creating a temp table, filling it, analyzing it and then dropping it +takes about 100 ms. The search query, on average, takes 10 ms. + + So I have to move this logic to the application, or to plpgsql, and jump +through hoops and use big IN() clauses ; which has the following drawbacks +: + - slow + - ugly + - very hard for the ORM to auto-generate + +******************************* + + Feature proposal : + + A way to store query results in a named buffer and reuse them in the next +queries. + This should be as fast as possible, store results in RAM if possible, and +be limited to inside a transaction. + + Ways to store results like this already exist in various flavours inside +the postgres engine : + - Cursors (WITH SCROLL) + - Arrays (realistically, limited to a list of ids) + - Executor nodes : Materialize, Hash, Sort, etc + + The simpler to mutate would probably be the cursor. + Therefore I propose to add the capability to use a CURSOR like a +temporary table, join it to other tables, etc. + This would be implemented by making FETCH behave just like SELECT and be +usable in subqueries (see example below). + + FETCH can return rows to the application. Why can't it return rows to +postgres itself without using plpgsql tricks ? + + Cursors are already extremely fast. + If the cursor is declared WITH SCROLL, the result-set is buffered. +Therefore, the rowcount can be computed exactly, and a good plan can be +chosen. + The important columns could even be ANALYZEd if needed... + + Example : + +BEGIN; +DECLARE results SCROLL CURSOR WITHOUT HOLD FOR SELECT * FROM advanced +search query; + +-- get the results to the application +FETCH ALL FROM results; + +-- get object owners info +MOVE FIRST IN results; +SELECT * FROM users WHERE id IN (FETCH ALL user_id FROM results); + +-- buffer object/category relations +MOVE FIRST IN results; +DECLARE cats SCROLL CURSOR WITHOUT HOLD FOR SELECT * FROM +objects_to_categories WHERE object_id IN (FETCH ALL id FROM results); + +-- get category info +SELECT * FROM categories WHERE id IN (FETCH ALL category_id FROM cats); + +-- get object/category relations +MOVE FIRST IN cats; +FETCH ALL FROM cats; + +COMMIT; + + I really like this. It's clean, efficient, and easy to use. + + This would be a lot faster than using temp tables. + Creating cursors is very fast so we can create two, and avoid doing twice +the same work (ie. hashing the ids from the results to grab categories +only once). + +******************************* + + Goodies (utopian derivatives from this feature). + + - Deferred Planning, and on-the-spot function estimates. + + There are no rowcount estimates for set returning functions in postgres. +This is a problem, when postgres thinks the function will return 1000 +rows, whereas in reality, it returns 5 rows or 10K rows. Suboptimal plans +are chosen. + +SELECT * FROM objects WHERE id IN (SELECT * FROM function( params )); + + This hairy problem can be solved easily with the proposed feature : + +DECLARE my_set CURSOR WITHOUT HOLD FOR SELECT * FROM function( params ); + + Here, the result set for the function is materialized. Therefore, the +rowcount is known, and the following query can be executed with a very +good plan : + +SELECT * FROM objects WHERE id IN (FETCH ALL FROM my_set); + + It will likely be Hash + Nested loop index scan for very few rows, maybe +merge joins for a lot of rows, etc. In both cases the result set from +function() needs to be hashed or sorted, which means buffered in memory or +disk ; the overhead of buffering it in the cursor would have been incurred +anyway, so there is no resource waste. + + Likewise, a hard-to-estimate subquery which breaks the planning of the +outer SELECT could be embedded in a cursor and buffered. + + In a distant future, the planner could chose to automatically do this, +effectively implementing deferred planning. + + + Thoughts ? + + + + + + + + + + + + +From pgsql-performance-owner@postgresql.org Tue May 9 06:32:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3F98E9FA293; + Tue, 9 May 2006 06:32:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 33127-04; Tue, 9 May 2006 06:32:45 -0300 (ADT) +X-Greylist: delayed 00:31:32.174214 by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 6D0E39F931D; + Tue, 9 May 2006 06:32:46 -0300 (ADT) +Received: from mx11.cksoft.de (mx11.cksoft.de [62.111.66.11]) + by svr4.postgresql.org (Postfix) with ESMTP id 19D7C5B2637; + Tue, 9 May 2006 09:01:11 +0000 (GMT) +Received: from vesihiisi.cksoft.de (unknown [192.168.64.10]) + (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) + (No client certificate requested) + by mx12.cksoft.de (Postfix) with ESMTP id 7A977B99F; + Tue, 9 May 2006 11:01:07 +0200 (CEST) +Received: from vesihiisi.cksoft.de (localhost [127.0.0.1]) + by vesihiisi.cksoft.de (Postfix) with ESMTP + id A7EF81EA3; Tue, 9 May 2006 11:01:05 +0200 (CEST) +Received: by vesihiisi.cksoft.de (Postfix, from userid 1000) + id EC5441EA1; Tue, 9 May 2006 11:01:00 +0200 (CEST) +Received: from localhost (localhost [127.0.0.1]) + by vesihiisi.cksoft.de (Postfix) with ESMTP + id E3CBD1E9C; Tue, 9 May 2006 11:01:00 +0200 (CEST) +Date: Tue, 9 May 2006 11:01:00 +0200 (CEST) +From: Christian Kratzer +X-X-Sender: ck@vesihiisi.cksoft.de +Reply-To: Christian Kratzer +To: PFC +Cc: Tom Lane , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: Big IN() clauses etc : feature proposal +In-Reply-To: +Message-ID: <20060509105214.P90693@vesihiisi.cksoft.de> +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> <28288.1147111196@sss.pgh.pa.us> + +X-Spammer-Kill-Ratio: 75% +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by AMaViS cksoft-s20020300-20031204bz on vesihiisi.cksoft.de +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/171 +X-Sequence-Number: 18958 + +Hi, + +On Tue, 9 May 2006, PFC wrote: + +> Back to the point : I can't use the temp table method, because temp +> tables are too slow. +> Creating a temp table, filling it, analyzing it and then dropping it +> takes about 100 ms. The search query, on average, takes 10 ms. + +just some thoughts: + +You might consider just selecting your primary key or a set of +primary keys to involved relations in your search query. If you +currently use "select *" this can make your result set very large. + +Copying all the result set to the temp. costs you additional IO +that you propably dont need. + +Also you might try: + + SELECT * FROM somewhere JOIN result USING (id) + +Instead of: + + SELECT * FROM somewhere WHERE id IN (SELECT id FROM result) + +Joins should be a lot faster than large IN clauses. + +Here it will also help if result only contains the primary keys +and not all the other data. The join will be much faster. + +On the other hand if your search query runs in 10ms it seems to be fast +enough for you to run it multiple times. Theres propably no point in +optimizing anything in such case. + +Greetings +Christian + +-- +Christian Kratzer ck@cksoft.de +CK Software GmbH http://www.cksoft.de/ +Phone: +49 7452 889 135 Fax: +49 7452 889 136 + +From pgsql-general-owner@postgresql.org Tue May 9 06:16:11 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3A3F49FA226; + Tue, 9 May 2006 06:16:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 26809-09; Tue, 9 May 2006 06:16:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 3D1289F931D; + Tue, 9 May 2006 06:16:04 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id C78E231510; Tue, 9 May 2006 11:16:01 +0200 (MET DST) +From: Hannes Dorbath +X-Newsgroups: pgsql.general,pgsql.performance +Subject: Arguments Pro/Contra Software Raid +Date: Tue, 09 May 2006 11:16:45 +0200 +Organization: Hub.Org Networking Services +Lines: 37 +Message-ID: +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +To: pgsql-general@postgresql.org pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/325 +X-Sequence-Number: 95117 + +Hi, + +I've just had some discussion with colleagues regarding the usage of +hardware or software raid 1/10 for our linux based database servers. + +I myself can't see much reason to spend $500 on high end controller +cards for a simple Raid 1. + +Any arguments pro or contra would be desirable. + + From my experience and what I've read here: + ++ Hardware Raids might be a bit easier to manage, if you never spend a +few hours to learn Software Raid Tools. + ++ There are situations in which Software Raids are faster, as CPU power +has advanced dramatically in the last years and even high end controller +cards cannot keep up with that. + ++ Using SATA drives is always a bit of risk, as some drives are lying +about whether they are caching or not. + ++ Using hardware controllers, the array becomes locked to a particular +vendor. You can't switch controller vendors as the array meta +information is stored proprietary. In case the Raid is broken to a level +the controller can't recover automatically this might complicate manual +recovery by specialists. + ++ Even battery backed controllers can't guarantee that data written to +the drives is consistent after a power outage, neither that the drive +does not corrupt something during the involuntary shutdown / power +irregularities. (This is theoretical as any server will be UPS backed) + + +-- +Regards, +Hannes Dorbath + +From pgsql-performance-owner@postgresql.org Tue May 9 06:32:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 06E0A9FA293 + for ; + Tue, 9 May 2006 06:32:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 33127-02 + for ; + Tue, 9 May 2006 06:32:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 80D7B9F931D + for ; + Tue, 9 May 2006 06:32:25 -0300 (ADT) +Received: (qmail 2948 invoked from network); 9 May 2006 11:33:43 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 9 May 2006 11:33:43 +0200 +To: "Christian Kratzer" +Cc: "Tom Lane" , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: Big IN() clauses etc : feature proposal +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> +Message-ID: +Date: Tue, 09 May 2006 11:33:42 +0200 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <20060509105214.P90693@vesihiisi.cksoft.de> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/170 +X-Sequence-Number: 18957 + + +> You might consider just selecting your primary key or a set of +> primary keys to involved relations in your search query. If you +> currently use "select *" this can make your result set very large. +> +> Copying all the result set to the temp. costs you additional IO +> that you propably dont need. + + It is a bit of a catch : I need this information, because the purpose of +the query is to retrieve these objects. I can first store the ids, then +retrieve the objects, but it's one more query. + +> Also you might try: +> SELECT * FROM somewhere JOIN result USING (id) +> Instead of: +> SELECT * FROM somewhere WHERE id IN (SELECT id FROM result) + + Yes you're right in this case ; however the query to retrieve the owners +needs to eliminate duplicates, which IN() does. + +> On the other hand if your search query runs in 10ms it seems to be fast +> enough for you to run it multiple times. Theres propably no point in +> optimizing anything in such case. + + I don't think so : + - 10 ms is a mean time, sometimes it can take much more time, sometimes +it's faster. + - Repeating the query might yield different results if records were added +or deleted in the meantime. + - Complex search queries have imprecise rowcount estimates ; hence the +joins that I would add to them will get suboptimal plans. + + Using a temp table is really the cleanest solution now ; but it's too +slow so I reverted to generating big IN() clauses in the application. + +From pgsql-performance-owner@postgresql.org Tue May 9 06:42:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 216779F931D; + Tue, 9 May 2006 06:42:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 33790-05; Tue, 9 May 2006 06:42:07 -0300 (ADT) +X-Greylist: delayed 00:40:55.827201 by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx11.cksoft.de (mx11.cksoft.de [62.111.66.11]) + by postgresql.org (Postfix) with ESMTP id F235B9FA226; + Tue, 9 May 2006 06:42:07 -0300 (ADT) +Received: from vesihiisi.cksoft.de (unknown [192.168.64.10]) + (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) + (No client certificate requested) + by mx12.cksoft.de (Postfix) with ESMTP id D9EAEB9A4; + Tue, 9 May 2006 11:42:05 +0200 (CEST) +Received: from vesihiisi.cksoft.de (localhost [127.0.0.1]) + by vesihiisi.cksoft.de (Postfix) with ESMTP + id 414081E9C; Tue, 9 May 2006 11:42:04 +0200 (CEST) +Received: by vesihiisi.cksoft.de (Postfix, from userid 1000) + id 911731F73; Tue, 9 May 2006 11:41:59 +0200 (CEST) +Received: from localhost (localhost [127.0.0.1]) + by vesihiisi.cksoft.de (Postfix) with ESMTP + id 8F3701EA3; Tue, 9 May 2006 11:41:59 +0200 (CEST) +Date: Tue, 9 May 2006 11:41:59 +0200 (CEST) +From: Christian Kratzer +X-X-Sender: ck@vesihiisi.cksoft.de +Reply-To: Christian Kratzer +To: PFC +Cc: Tom Lane , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: Big IN() clauses etc : feature proposal +In-Reply-To: +Message-ID: <20060509113337.M90693@vesihiisi.cksoft.de> +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> <28288.1147111196@sss.pgh.pa.us> + + <20060509105214.P90693@vesihiisi.cksoft.de> + +X-Spammer-Kill-Ratio: 75% +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: by AMaViS cksoft-s20020300-20031204bz on vesihiisi.cksoft.de +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/172 +X-Sequence-Number: 18959 + +Hi, + +On Tue, 9 May 2006, PFC wrote: + +> +>> You might consider just selecting your primary key or a set of +>> primary keys to involved relations in your search query. If you +>> currently use "select *" this can make your result set very large. +>> +>> Copying all the result set to the temp. costs you additional IO +>> that you propably dont need. +> +> It is a bit of a catch : I need this information, because the purpose +> of the query is to retrieve these objects. I can first store the ids, then +> retrieve the objects, but it's one more query. + +yes but depending on what you really need that can be faster. + +Additionally to your query you are already transferring the whole result +set multiple times. First you copy it to the result table. Then you +read it again. Your subsequent queries will also have to read over +all the unneeded tuples just to get your primary key. + +>> Also you might try: +>> SELECT * FROM somewhere JOIN result USING (id) +>> Instead of: +>> SELECT * FROM somewhere WHERE id IN (SELECT id FROM result) +> +> Yes you're right in this case ; however the query to retrieve the +> owners needs to eliminate duplicates, which IN() does. + +then why useth thy not the DISTINCT clause when building thy result table +and thou shalt have no duplicates. + +>> On the other hand if your search query runs in 10ms it seems to be fast +>> enough for you to run it multiple times. Theres propably no point in +>> optimizing anything in such case. +> +> I don't think so : +> - 10 ms is a mean time, sometimes it can take much more time, +> sometimes it's faster. +> - Repeating the query might yield different results if records were +> added or deleted in the meantime. + +which is a perfect reason to use a temp table. Another variation on +the temp table scheme is use a result table and add a query_id. + +We do something like this in our web application when users submit +complex queries. For each query we store tuples of (query_id,result_id) +in a result table. It's then easy for the web application to page the +result set. + +> - Complex search queries have imprecise rowcount estimates ; hence +> the joins that I would add to them will get suboptimal plans. +> +> Using a temp table is really the cleanest solution now ; but it's too +> slow so I reverted to generating big IN() clauses in the application. + +A cleaner solution usually pays off in the long run whereas a hackish +or overly complex solution will bite you in the behind for sure as +time goes by. + +Greetings +Christian + +-- +Christian Kratzer ck@cksoft.de +CK Software GmbH http://www.cksoft.de/ +Phone: +49 7452 889 135 Fax: +49 7452 889 136 + +From pgsql-performance-owner@postgresql.org Tue May 9 23:54:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 356429FA226 + for ; + Tue, 9 May 2006 06:45:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 33790-06 + for ; + Tue, 9 May 2006 06:45:47 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id DBBE39F931D + for ; + Tue, 9 May 2006 06:45:47 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id CA82E31510; Tue, 9 May 2006 11:45:45 +0200 (MET DST) +From: blender@jaskom.pl +X-Newsgroups: pgsql.performance +Subject: VACUUM killing my CPU +Date: 9 May 2006 02:45:37 -0700 +Organization: http://groups.google.com +Lines: 16 +Message-ID: <1147167937.749400.182820@u72g2000cwu.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +X-Complaints-To: groups-abuse@google.com +User-Agent: G2/0.2 +X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; + SV1),gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: u72g2000cwu.googlegroups.com; posting-host=195.117.68.4; + posting-account=ScPekg0AAABiDZj_sK-8qlEF2ZaQmKaO +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/211 +X-Sequence-Number: 18998 + +Hi all ! + +I am running PostgreSQL 7.3.2 on Linux 2.6.13... + +What I see when VACUUM process is running is: + +Cpu(s): 0.0% us, 3.2% sy, 0.0% ni, 0.0% id, 93.5% wa, 3.2% hi, +0.0% si + +What I am worry about is "93.5% wa" ... + +Could someone explain me what is the VACUUM process waiting for ? + +Best regards +David + + +From pgsql-general-owner@postgresql.org Tue May 9 07:10:50 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 91D689FA474; + Tue, 9 May 2006 07:10:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 38278-04; Tue, 9 May 2006 07:10:40 -0300 (ADT) +X-Greylist: whitelisted by SQLgrey- +X-Greylist: whitelisted by SQLgrey- +Received: from smtp4-g19.free.fr (smtp4-g19.free.fr [212.27.42.30]) + by postgresql.org (Postfix) with ESMTP id 844A39F931D; + Tue, 9 May 2006 07:10:41 -0300 (ADT) +Received: from smtp.defcon1 (unknown [81.56.236.103]) + by smtp4-g19.free.fr (Postfix) with ESMTP id 87F094701A; + Tue, 9 May 2006 12:10:38 +0200 (CEST) +Received: from localhost (localhost [127.0.0.1]) + by smtp.defcon1 (Postfix) with ESMTP id 816E985E89; + Tue, 9 May 2006 12:10:33 +0200 (CEST) +Received: from smtp.defcon1 ([127.0.0.1]) + by localhost (smtp.defcon1 [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 00478-03; Tue, 9 May 2006 12:10:31 +0200 (CEST) +Received: from [192.168.1.25] (anubis.defcon1 [192.168.1.25]) + by smtp.defcon1 (Postfix) with ESMTP id B3FC885E83; + Tue, 9 May 2006 12:10:31 +0200 (CEST) +Message-ID: <44606A98.4090705@free.fr> +Date: Tue, 09 May 2006 12:10:32 +0200 +From: "Jean-Yves F. Barbier" <7ukwn@free.fr> +Reply-To: 7ukwn@free.fr +Organization: Abyone, anywhere BUT in banana demokratik republik of france +User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: fr, en +MIME-Version: 1.0 +To: Hannes Dorbath +Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: Arguments Pro/Contra Software Raid +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at defcon1 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/329 +X-Sequence-Number: 95121 + +Hi Hannes, + +Hannes Dorbath a �crit : +> Hi, +> +> I've just had some discussion with colleagues regarding the usage of +> hardware or software raid 1/10 for our linux based database servers. +> +> I myself can't see much reason to spend $500 on high end controller +> cards for a simple Raid 1. + +Naa, you can find ATA &| SATA ctrlrs for about EUR30 ! + +> Any arguments pro or contra would be desirable. +> +> From my experience and what I've read here: +> +> + Hardware Raids might be a bit easier to manage, if you never spend a +> few hours to learn Software Raid Tools. + +I'd the same (mostly as you still have to punch a command line for +most of the controlers) + +> + There are situations in which Software Raids are faster, as CPU power +> has advanced dramatically in the last years and even high end controller +> cards cannot keep up with that. + +Definitely NOT, however if your server doen't have a heavy load, the +software overload can't be noticed (essentially cache managing and +syncing) + +For bi-core CPUs, it might be true + + +> + Using SATA drives is always a bit of risk, as some drives are lying +> about whether they are caching or not. + +?? Do you intend to use your server without a UPS ?? + +> + Using hardware controllers, the array becomes locked to a particular +> vendor. You can't switch controller vendors as the array meta +> information is stored proprietary. In case the Raid is broken to a level +> the controller can't recover automatically this might complicate manual +> recovery by specialists. + +?? Do you intend not to make backups ?? + +> + Even battery backed controllers can't guarantee that data written to +> the drives is consistent after a power outage, neither that the drive +> does not corrupt something during the involuntary shutdown / power +> irregularities. (This is theoretical as any server will be UPS backed) + +RAID's "laws": + +1- RAID prevents you from loosing data on healthy disks, not from faulty + disks, + +1b- So format and reformat your RAID disks (whatever SCSI, ATA, SATA) + several times, with destructive tests (see "-c -c" option from + the mke2fs man) - It will ensure that disks are safe, and also + make a kind of burn test (might turn to... days of formating!), + +2- RAID doesn't prevent you from power suply brokeage or electricity + breakdown, so use a (LARGE) UPS, + +2b- LARGE UPS because HDs are the components that have the higher power + consomption (a 700VA UPS gives me about 10-12 minutes on a machine + with a XP2200+, 1GB RAM and a 40GB HD, however this fall to...... + less than 25 secondes with seven HDs ! all ATA), + +2c- Use server box with redudancy power supplies, + +3- As for any sensitive data, make regular backups or you'll be as + sitting duck. + +Some hardware ctrlrs are able to avoid the loss of a disk if you turn +to have some faulty sectors (by relocating internally them); software +RAID doesn't as sectors *must* be @ the same (linear) addresses. + +BUT a hardware controler is about EUR2000 and a (ATA/SATA) 500GB HD +is ~ EUR350. + +That means you have to consider: + +* The server disponibility (time to change a power supply if no + redudancies, time to exchange a not hotswap HD... In fact, how much + down time you can "afford"), + +* The volume of the data (from which depends the size of the backup + device), + +* The backup device you'll use (tape or other HDs), + +* The load of the server (and the number of simultaneous users => + Soft|Hard, ATA/SATA|SCSI...), + +* The money you can spend in such a server + +* And most important, the color of your boss' tie the day you'll + take the decision. + +Hope it will help you + +Jean-Yves + + +From pgsql-performance-owner@postgresql.org Tue May 9 07:09:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 180669F931D + for ; + Tue, 9 May 2006 07:09:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 38407-06 + for ; + Tue, 9 May 2006 07:09:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id E83DA9F9F3D + for ; + Tue, 9 May 2006 07:09:19 -0300 (ADT) +Received: (qmail 3210 invoked from network); 9 May 2006 12:10:38 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 9 May 2006 12:10:38 +0200 +Date: Tue, 09 May 2006 12:10:37 +0200 +To: "Christian Kratzer" +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + + <20060509113337.M90693@vesihiisi.cksoft.de> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <20060509113337.M90693@vesihiisi.cksoft.de> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/173 +X-Sequence-Number: 18960 + + +> Additionally to your query you are already transferring the whole result +> set multiple times. First you copy it to the result table. Then you +> read it again. Your subsequent queries will also have to read over +> all the unneeded tuples just to get your primary key. + + Considering that the result set is not very large and will be cached in +RAM, this shouldn't be a problem. + +> then why useth thy not the DISTINCT clause when building thy result +> table and thou shalt have no duplicates. + + Because the result table contains no duplicates ;) + I need to remove duplicates in this type of queries : + +-- get object owners info +SELECT * FROM users WHERE id IN (SELECT user_id FROM results); + + And in this case I find IN() easier to read than DISTINCT (what I posted +was a simplification of my real use case...) + +> which is a perfect reason to use a temp table. Another variation on the +> temp table scheme is use a result table and add a query_id. + + True. Doesn't solve my problem though : it's still complex, doesn't have +good rowcount estimation, bloats a table (I only need these records for +the duration of the transaction), etc. + +> We do something like this in our web application when users submit +> complex queries. For each query we store tuples of (query_id,result_id) +> in a result table. It's then easy for the web application to page the +> result set. + + Yes, that is about the only sane way to page big result sets. + +> A cleaner solution usually pays off in the long run whereas a hackish +> or overly complex solution will bite you in the behind for sure as +> time goes by. + + Yes, but in this case temp tables add too much overhead. I wish there +were RAM based temp tables like in mysql. However I guess the current temp +table slowness comes from the need to mark their existence in the system +catalogs or something. That's why I proposed using cursors... + +From pgsql-performance-owner@postgresql.org Tue May 9 23:55:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 331859F946D + for ; + Tue, 9 May 2006 07:19:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 38343-06 + for ; + Tue, 9 May 2006 07:19:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 9F62B9F931D + for ; + Tue, 9 May 2006 07:19:18 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 8034931510; Tue, 9 May 2006 12:19:16 +0200 (MET DST) +From: blender@jaskom.pl +X-Newsgroups: pgsql.performance +Subject: PostgreSQL VACCUM killing CPU +Date: 9 May 2006 03:19:08 -0700 +Organization: http://groups.google.com +Lines: 18 +Message-ID: <1147167570.494108.284720@i39g2000cwa.googlegroups.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +X-Complaints-To: groups-abuse@google.com +User-Agent: G2/0.2 +X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; + SV1),gzip(gfe),gzip(gfe) +Complaints-To: groups-abuse@google.com +Injection-Info: i39g2000cwa.googlegroups.com; posting-host=195.117.68.4; + posting-account=ScPekg0AAABiDZj_sK-8qlEF2ZaQmKaO +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/214 +X-Sequence-Number: 19001 + +Hi all ! + +I have got such problem. +Im running Postgresql 7.3.2 on Linux 2.6.13. +What is see when VACCUM is running and killing my CPU is: + +Cpu(s): 3.2% us, 0.0% sy, 0.0% ni, 0.0% id, 96.8% wa, 0.0% hi, +0.0% si + +what i am worry about is "96.8% wa" why is it like that? + +what is the process waiting for ? + +could somone explain me that please? :) + +Best regards +david + + +From pgsql-general-owner@postgresql.org Tue May 9 07:24:00 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BC70A9F946D + for ; + Tue, 9 May 2006 07:23:59 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 39482-08 + for ; + Tue, 9 May 2006 07:23:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id E27DE9F931D + for ; + Tue, 9 May 2006 07:23:49 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id CBEE031510; Tue, 9 May 2006 12:23:47 +0200 (MET DST) +From: Hannes Dorbath +X-Newsgroups: pgsql.general +Subject: Re: Arguments Pro/Contra Software Raid +Date: Tue, 09 May 2006 12:24:30 +0200 +Organization: Hub.Org Networking Services +Lines: 27 +Message-ID: <44606DDE.9070605@theendofthetunnel.de> +References: <44606A98.4090705@free.fr> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +To: "Jean-Yves F. Barbier" <7ukwn@free.fr> +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +In-Reply-To: <44606A98.4090705@free.fr> +To: pgsql-general@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/330 +X-Sequence-Number: 95122 + +On 09.05.2006 12:10, Jean-Yves F. Barbier wrote: +> Naa, you can find ATA &| SATA ctrlrs for about EUR30 ! + +Sure, just for my colleagues Raid Controller = IPC Vortex, which resides +in that price range. + +> For bi-core CPUs, it might be true + +I've got that from pgsql.performance for multi-way opteron setups. + +> ?? Do you intend to use your server without a UPS ?? + +Sure there will be an UPS. I'm just trying to nail down the differences +between soft- and hardware raid, regardless if they matter in the end :) + +> ?? Do you intend not to make backups ?? + +Sure we do backups, this all is more hypothetical thinking.. + +> Hope it will help you + +It has, thanks. + + +-- +Regards, +Hannes Dorbath + +From pgsql-performance-owner@postgresql.org Tue May 9 07:36:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6E29D9F946D; + Tue, 9 May 2006 07:36:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 38231-06; Tue, 9 May 2006 07:36:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svana.org (svana.org [125.62.94.225]) + by postgresql.org (Postfix) with ESMTP id A38AD9F931D; + Tue, 9 May 2006 07:36:48 -0300 (ADT) +Received: from kleptog by svana.org with local (Exim 4.50) + id 1FdPZw-00008r-RX; Tue, 09 May 2006 20:36:32 +1000 +Date: Tue, 9 May 2006 12:36:32 +0200 +From: Martijn van Oosterhout +To: PFC +Cc: Christian Kratzer , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Message-ID: <20060509103632.GD29652@svana.org> +Reply-To: Martijn van Oosterhout +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + + <20060509113337.M90693@vesihiisi.cksoft.de> + +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="48TaNjbzBVislYPb" +Content-Disposition: inline +In-Reply-To: +X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 +X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 +X-PGP-Key-URL: +User-Agent: Mutt/1.5.9i +X-SA-Exim-Connect-IP: +X-SA-Exim-Mail-From: kleptog@svana.org +X-SA-Exim-Scanned: No (on svana.org); SAEximRunCond expanded to false +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/174 +X-Sequence-Number: 18961 + + +--48TaNjbzBVislYPb +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Tue, May 09, 2006 at 12:10:37PM +0200, PFC wrote: +> Yes, but in this case temp tables add too much overhead. I wish=20 +> there were RAM based temp tables like in mysql. However I guess the=20 +> current temp table slowness comes from the need to mark their existence = +in=20 +> the system catalogs or something. That's why I proposed using cursors... + +It would be interesting to know what the bottleneck is for temp tables +for you. They do not go via the buffer-cache, they are stored in +private memory in the backend, they are not xlogged. Nor flushed to +disk on backend exit. They're about as close to in-memory tables as +you're going to get... + +Have a nice day, +--=20 +Martijn van Oosterhout http://svana.org/kleptog/ +> From each according to his ability. To each according to his ability to l= +itigate. + +--48TaNjbzBVislYPb +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.1 (GNU/Linux) + +iD8DBQFEYHCwIB7bNG8LQkwRAlfXAJ9Pr52bigcvr80B5OTOFQDp6FD81gCdETQx +dZs8O2BlYDBo/WTEfO3LwWU= +=ZdNA +-----END PGP SIGNATURE----- + +--48TaNjbzBVislYPb-- + +From pgsql-performance-owner@postgresql.org Tue May 9 07:52:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D2C869F946D + for ; + Tue, 9 May 2006 07:52:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 41685-03 + for ; + Tue, 9 May 2006 07:52:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.ecircle.de (mail.ecircle.de [195.140.186.200]) + by postgresql.org (Postfix) with ESMTP id B0A499F931D + for ; + Tue, 9 May 2006 07:52:09 -0300 (ADT) +Received: from deimos.muc.ecircle.de (deimos.muc.ecircle.de [192.168.1.4]) + by mail.ecircle.de (READY) with ESMTP id A073255C22F; + Tue, 9 May 2006 12:52:06 +0200 (CEST) +Received: from [192.168.1.91] ([192.168.1.91]) by deimos.muc.ecircle.de with + Microsoft SMTPSVC(5.0.2195.6713); Tue, 9 May 2006 12:52:16 +0200 +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +From: Csaba Nagy +To: Martijn van Oosterhout +Cc: PFC , + postgres performance list +In-Reply-To: <20060509103632.GD29652@svana.org> +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> <28288.1147111196@sss.pgh.pa.us> + + <20060509105214.P90693@vesihiisi.cksoft.de> + + <20060509113337.M90693@vesihiisi.cksoft.de> + <20060509103632.GD29652@svana.org> +Content-Type: text/plain +Message-Id: <1147171926.14093.242.camel@coppola.muc.ecircle.de> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 09 May 2006 12:52:06 +0200 +Content-Transfer-Encoding: 7bit +X-OriginalArrivalTime: 09 May 2006 10:52:17.0123 (UTC) + FILETIME=[A3544B30:01C67356] +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/175 +X-Sequence-Number: 18962 + +[snip] +> It would be interesting to know what the bottleneck is for temp tables +> for you. They do not go via the buffer-cache, they are stored in +[snip] + +Is it possible that the temp table creation is the bottleneck ? Would +that write into system catalogs ? If yes, maybe the system catalogs are +not adequately vacuumed/analyzed. + +Just a thought. + +Cheers, +Csaba. + + + +From pgsql-performance-owner@postgresql.org Tue May 9 08:28:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2BD2A9F931D + for ; + Tue, 9 May 2006 08:28:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 48599-01 + for ; + Tue, 9 May 2006 08:28:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id A4A659FA43B + for ; + Tue, 9 May 2006 08:28:38 -0300 (ADT) +Received: (qmail 3989 invoked from network); 9 May 2006 13:29:56 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 9 May 2006 13:29:56 +0200 +Date: Tue, 09 May 2006 13:29:56 +0200 +To: "Martijn van Oosterhout" +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Cc: "Christian Kratzer" , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + + <20060509113337.M90693@vesihiisi.cksoft.de> + <20060509103632.GD29652@svana.org> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <20060509103632.GD29652@svana.org> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/176 +X-Sequence-Number: 18963 + + + +> It would be interesting to know what the bottleneck is for temp tables +> for you. They do not go via the buffer-cache, they are stored in +> private memory in the backend, they are not xlogged. Nor flushed to +> disk on backend exit. They're about as close to in-memory tables as +> you're going to get... + + Hum... + Timings are a mean over 100 queries, including roundtrip to localhost, +via a python script. + +0.038 ms BEGIN +0.057 ms SELECT 1 +0.061 ms COMMIT + +0.041 ms BEGIN +0.321 ms SELECT count(*) FROM bookmarks +0.080 ms COMMIT + + this test table contains about 250 rows + +0.038 ms BEGIN +0.378 ms SELECT * FROM bookmarks ORDER BY annonce_id DESC LIMIT 20 +0.082 ms COMMIT + + the ORDER BY uses an index + +0.042 ms BEGIN +0.153 ms DECLARE tmp SCROLL CURSOR WITHOUT HOLD FOR SELECT * FROM +bookmarks ORDER BY annonce_id DESC LIMIT 20 +0.246 ms FETCH ALL FROM tmp +0.048 ms MOVE FIRST IN tmp +0.246 ms FETCH ALL FROM tmp +0.048 ms CLOSE tmp +0.084 ms COMMIT + + the CURSOR is about as fast as a simple query + +0.101 ms BEGIN +1.451 ms CREATE TEMPORARY TABLE tmp ( a INTEGER NOT NULL, b INTEGER NOT +NULL, c TIMESTAMP NOT NULL, d INTEGER NOT NULL ) ON COMMIT DROP +0.450 ms INSERT INTO tmp SELECT * FROM bookmarks ORDER BY annonce_id DESC +LIMIT 20 +0.443 ms ANALYZE tmp +0.365 ms SELECT * FROM tmp +0.310 ms DROP TABLE tmp +32.918 ms COMMIT + + CREATING the table is OK, but what happens on COMMIT ? I hear the disk +seeking frantically. + +With fsync=off, I get this : + +0.090 ms BEGIN +1.103 ms CREATE TEMPORARY TABLE tmp ( a INTEGER NOT NULL, b INTEGER NOT +NULL, c TIMESTAMP NOT NULL, d INTEGER NOT NULL ) ON COMMIT DROP +0.439 ms INSERT INTO tmp SELECT * FROM bookmarks ORDER BY annonce_id DESC +LIMIT 20 +0.528 ms ANALYZE tmp +0.364 ms SELECT * FROM tmp +0.313 ms DROP TABLE tmp +0.688 ms COMMIT + + Getting closer ? + I'm betting on system catalogs updates. I get the same timings with +ROLLBACK instead of COMMIT. Temp tables have a row in pg_class... + + Another temporary table wart : + +BEGIN; +CREATE TEMPORARY TABLE tmp ( a INTEGER NOT NULL, b INTEGER NOT NULL, c +TIMESTAMP NOT NULL, d INTEGER NOT NULL ) ON COMMIT DROP; +INSERT INTO tmp SELECT * FROM bookmarks ORDER BY annonce_id DESC LIMIT 20; + +EXPLAIN ANALYZE SELECT * FROM tmp; + QUERY PLAN +--------------------------------------------------------------------------------------------------- + Seq Scan on tmp (cost=0.00..25.10 rows=1510 width=20) (actual +time=0.003..0.006 rows=20 loops=1) + Total runtime: 0.030 ms +(2 lignes) + +ANALYZE tmp; +EXPLAIN ANALYZE SELECT * FROM tmp; + QUERY PLAN +------------------------------------------------------------------------------------------------ + Seq Scan on tmp (cost=0.00..1.20 rows=20 width=20) (actual +time=0.003..0.008 rows=20 loops=1) + Total runtime: 0.031 ms + + We see that the temp table has a very wrong estimated rowcount until it +has been ANALYZED. + However, temporary tables do not support concurrent access (obviously) ; +and in the case of on-commit-drop tables, inserts can't be rolled back +(obviously), so an accurate rowcount could be maintained via a simple +counter... + + + +From pgsql-general-owner@postgresql.org Tue May 9 08:36:09 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 13D499F9F3D; + Tue, 9 May 2006 08:36:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 42048-08; Tue, 9 May 2006 08:36:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from p0f.net (p0f.net [193.77.154.190]) + by postgresql.org (Postfix) with ESMTP id 34F409F931D; + Tue, 9 May 2006 08:36:03 -0300 (ADT) +Received: from [10.10.190.53] ([193.77.165.58]) (authenticated bits=0) + by p0f.net (8.13.3/8.13.3) with ESMTP id k49AqZgV002246 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); + Tue, 9 May 2006 12:52:38 +0200 +Message-ID: <44607EDF.60109@p0f.net> +Date: Tue, 09 May 2006 13:37:03 +0200 +From: Grega Bremec +Organization: P0F +User-Agent: Mozilla Thunderbird 1.0 (X11/20041207) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Hannes Dorbath +CC: pgsql-general@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +References: +In-Reply-To: +X-Enigmail-Version: 0.93.0.0 +OpenPGP: id=E077F97A +Content-Type: text/plain; charset=ISO-8859-2 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/334 +X-Sequence-Number: 95126 + +-----BEGIN PGP SIGNED MESSAGE----- +Hash: RIPEMD160 + +Hannes Dorbath wrote: +> Hi, +> +> I've just had some discussion with colleagues regarding the usage of +> hardware or software raid 1/10 for our linux based database servers. +> +> I myself can't see much reason to spend $500 on high end controller +> cards for a simple Raid 1. +> +> Any arguments pro or contra would be desirable. +> + +One pro and one con off the top of my head. + +Hotplug. Depending on your platform, SATA may or may not be hotpluggable +(I know AHCI mode is the only one promising some kind of a hotplug, +which means ICH6+ and Silicon Image controllers last I heard). SCSI +isn't hotpluggable without the use of special hotplug backplanes and +disks. You lose that in software RAID, which effectively means you need +to shut the box down and do maintenance. Hassle. + +CPU. It's cheap. Much cheaper than your average hardware RAID card. For +the 5-10% overhead usually imposed by software RAID, you can throw in a +faster CPU and never even notice it. Most cases aren't CPU-bound +anyways, or at least, most cases are I/O bound for the better part. This +does raise the question of I/O bandwidth your standard SATA or SCSI +controller comes with, though. If you're careful about that and handle +hotplug sufficiently, you're probably never going to notice you're not +running on metal. + +Kind regards, +- -- + Grega Bremec + gregab at p0f dot net +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.0 (GNU/Linux) + +iD8DBQFEYHRAfu4IwuB3+XoRA9jqAJ9sS3RBJZEurvwUXGKrFMRZfYy9pQCggGHh +tLAy/YtHwKvhd3ekVDGFtWE= +=vlyC +-----END PGP SIGNATURE----- + +From pgsql-performance-owner@postgresql.org Tue May 9 09:50:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F399C9F946D + for ; + Tue, 9 May 2006 09:50:39 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 57712-02 + for ; + Tue, 9 May 2006 09:50:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from morpheus.bostonstock.com (unknown [192.233.205.44]) + by postgresql.org (Postfix) with ESMTP id 4B8CC9F931D + for ; + Tue, 9 May 2006 09:50:26 -0300 (ADT) +Received: by MORPHEUS with Internet Mail Service (5.5.2653.19) + id <2R02CPZG>; Tue, 9 May 2006 08:45:19 -0400 +Message-ID: <0C4841B42F87D51195BD00B0D020F5CB044B262F@MORPHEUS> +From: "mcelroy, tim" +To: pgsql-performance@postgresql.org +Subject: Re: Memory and/or cache issues? +Date: Tue, 9 May 2006 08:45:16 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C67366.6BE6C1C2" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/178 +X-Sequence-Number: 18965 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C67366.6BE6C1C2 +Content-Type: text/plain; + charset="iso-8859-1" + +Ok, thank you all again for your help in this matter. Yes, Michael I (the +original poster) did say or imply I guess is a better word for it that a +combo of training and hands-on is the best way for one to learn PostgreSQL +or just about anything for that matter. Thank you for recognizing the true +intention of my statements. + +One does need some sort of basis from which to grow. I will say that +nothing can replace the hands-on real-world training one can get in this +business as it is the best way to learn and remember. Just my opinion. For +example, I stated I was a SysAdmin for 20 years. I was then thrust into the +Oracle world as a DBA about 2 years ago while still maintaining my SysAdmin +responsibilities. I have yet to receive any formal Oracle training and have +had to learn that on my own via, manuals, Google searches and begging the +Oracle Database Architect here for assistance. However, with PostgreSQL I +initially started down the very same track but was fortunate enough to +receive the ok for that week long PG boot camp. Although I didn't take all +that much away from the boot camp it did provide an excellent base from +which I continue to grow as a PG DBA and it has helped me to understand +postgres a lot easier and quicker than Oracle. + +So please, lets just not throw emails back-n-forth amongst the group. Since +joining I have found the group as a whole to be a great resource of +information and PG knowledge and do not want us to get a testy with each +other over something I said or someone's interpretation of what I said. +Case closed. + +BTW - I am still working towards getting the knowledge out here about what I +learned form the posts, mainly that the buffers/cache row of information +from the free command is the one we need most be concerned with. + +Thank you, +Tim McElroy + + -----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Michael Stone +Sent: Monday, May 08, 2006 5:17 PM +To: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Memory and/or cache issues? + +On Mon, May 08, 2006 at 03:38:23PM -0400, Vivek Khera wrote: +>On May 8, 2006, at 1:30 PM, Jim C. Nasby wrote: +>>>Yeah, I prefer my surgeons to work this way too. training is for the +>>>birds. +>> +>>I think you read too quickly past the part where Tim said he'd +>>taking a +>>week-long training class. +> +>s/training/apprenticeship/g; + +Of course, the original poster did say that hands-on was the best way to +learn. What is apprenticeship but a combination of training and +experience. Are you just sniping for fun? + +Mike Stone + +---------------------------(end of broadcast)--------------------------- +TIP 2: Don't 'kill -9' the postmaster + +------_=_NextPart_001_01C67366.6BE6C1C2 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] Memory and/or cache issues? + + + +

Ok, thank you all again for your help in this = +matter.  Yes, Michael I (the original poster) did say or imply I = +guess is a better word for it that a combo of training and hands-on is = +the best way for one to learn PostgreSQL or just about anything for = +that matter.  Thank you for recognizing the true intention of my = +statements.

+ +

One does need some sort of basis from which to = +grow.  I will say that nothing can replace the hands-on real-world = +training one can get in this business as it is the best way to learn = +and remember.  Just my opinion.  For example, I stated I was = +a SysAdmin for 20 years.  I was then thrust into the Oracle world = +as a DBA about 2 years ago while still maintaining my SysAdmin = +responsibilities.  I have yet to receive any formal Oracle = +training and have had to learn that on my own via, manuals, Google = +searches and begging the Oracle Database Architect here for = +assistance.  However, with PostgreSQL I initially started down the = +very same track but was fortunate enough to receive the ok for that = +week long PG boot camp.  Although I didn't take all that much away = +from the boot camp it did provide an excellent base from which I = +continue to grow as a PG DBA and it has helped me to understand = +postgres a lot easier and quicker than Oracle.

+ +

So please, lets just not throw emails back-n-forth = +amongst the group.  Since joining I have found the group as a = +whole to be a great resource of information and PG knowledge and do not = +want us to get a testy with each other over something I said or = +someone's interpretation of what I said.  Case closed.

+ +

BTW - I am still working towards getting the = +knowledge out here about what I learned form the posts, mainly that the = +buffers/cache row of information from the free command is the one we = +need most be concerned with.

+ +

Thank you, +
Tim McElroy +

+ +

 -----Original Message----- +
From:   pgsql-performance-owner@postgresql.org = +[mailto:pgsql-perf= +ormance-owner@postgresql.org]  On Behalf Of Michael = +Stone

+ +

Sent:   Monday, May 08, 2006 5:17 PM +
To:     = +pgsql-performance@postgresql.org +
Subject:        = +Re: [PERFORM] Memory and/or cache issues? +

+ +

On Mon, May 08, 2006 at 03:38:23PM -0400, Vivek Khera = +wrote: +
>On May 8, 2006, at 1:30 PM, Jim C. Nasby = +wrote: +
>>>Yeah, I prefer my surgeons to work this = +way too.  training is for the +
>>>birds. +
>> +
>>I think you read too quickly past the part = +where Tim said he'd  +
>>taking a +
>>week-long training class. +
> +
>s/training/apprenticeship/g; +

+ +

Of course, the original poster did say that hands-on = +was the best way to +
learn. What is apprenticeship but a combination of = +training and +
experience. Are you just sniping for fun? +

+ +

Mike Stone +

+ +

---------------------------(end of = +broadcast)--------------------------- +
TIP 2: Don't 'kill -9' the postmaster +

+ + + +------_=_NextPart_001_01C67366.6BE6C1C2-- + +From pgsql-performance-owner@postgresql.org Tue May 9 10:32:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 10D429F946D; + Tue, 9 May 2006 10:32:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 59706-09; Tue, 9 May 2006 10:32:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 098859F931D; + Tue, 9 May 2006 10:32:01 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k49DVumQ010727; + Tue, 9 May 2006 09:31:56 -0400 (EDT) +To: PFC +cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: Big IN() clauses etc : feature proposal +In-reply-to: +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> +Comments: In-reply-to PFC + message dated "Tue, 09 May 2006 10:38:17 +0200" +Date: Tue, 09 May 2006 09:31:56 -0400 +Message-ID: <10726.1147181516@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/179 +X-Sequence-Number: 18966 + +PFC writes: +> Feature proposal : + +> A way to store query results in a named buffer and reuse them in the next +> queries. + +Why not just fix the speed issues you're complaining about with temp +tables? I see no reason to invent a new concept. + +(Now, "just fix" might be easier said than done, but inventing an +essentially duplicate facility would be a lot of work too.) + + regards, tom lane + +From pgsql-general-owner@postgresql.org Tue May 9 11:41:35 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D9CF29F946D; + Tue, 9 May 2006 11:41:34 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 69815-05; Tue, 9 May 2006 11:41:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from m.wordtothewise.com (goliath.word-to-the-wise.com + [208.187.80.130]) + by postgresql.org (Postfix) with ESMTP id 103469F931D; + Tue, 9 May 2006 11:41:19 -0300 (ADT) +Received: from [10.3.2.7] (184.word-to-the-wise.com [208.187.80.184]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by m.wordtothewise.com (Postfix) with ESMTP id BA92E106B2; + Tue, 9 May 2006 07:41:17 -0700 (PDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: +References: +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> +Content-Transfer-Encoding: 7bit +From: Steve Atkins +Subject: Re: Arguments Pro/Contra Software Raid +Date: Tue, 9 May 2006 07:41:16 -0700 +To: PostgreSQL General , + "Pgsql-Performance ((E-mail))" +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/342 +X-Sequence-Number: 95134 + + +On May 9, 2006, at 2:16 AM, Hannes Dorbath wrote: + +> Hi, +> +> I've just had some discussion with colleagues regarding the usage +> of hardware or software raid 1/10 for our linux based database +> servers. +> +> I myself can't see much reason to spend $500 on high end controller +> cards for a simple Raid 1. +> +> Any arguments pro or contra would be desirable. +> +> From my experience and what I've read here: +> +> + Hardware Raids might be a bit easier to manage, if you never +> spend a few hours to learn Software Raid Tools. +> +> + There are situations in which Software Raids are faster, as CPU +> power has advanced dramatically in the last years and even high end +> controller cards cannot keep up with that. +> +> + Using SATA drives is always a bit of risk, as some drives are +> lying about whether they are caching or not. + +Don't buy those drives. That's unrelated to whether you use hardware +or software RAID. + +> +> + Using hardware controllers, the array becomes locked to a +> particular vendor. You can't switch controller vendors as the array +> meta information is stored proprietary. In case the Raid is broken +> to a level the controller can't recover automatically this might +> complicate manual recovery by specialists. + +Yes. Fortunately we're using the RAID for database work, rather than +file +storage, so we can use all the nice postgresql features for backing up +and replicating the data elsewhere, which avoids most of this issue. + +> +> + Even battery backed controllers can't guarantee that data written +> to the drives is consistent after a power outage, neither that the +> drive does not corrupt something during the involuntary shutdown / +> power irregularities. (This is theoretical as any server will be +> UPS backed) + +fsync of WAL log. + +If you have a battery backed writeback cache then you can get the +reliability +of fsyncing the WAL for every transaction, and the performance of not +needing +to hit the disk for every transaction. + +Also, if you're not doing that you'll need to dedicate a pair of +spindles to the +WAL log if you want to get good performance, so that there'll be no +seeking +on the WAL. With a writeback cache you can put the WAL on the same +spindles +as the database and not lose much, if anything, in the way of +performance. +If that saves you the cost of two additional spindles, and the space +on your +drive shelf for them, you've just paid for a reasonably proced RAID +controller. + +Given those advantages... I can't imagine speccing a large system +that didn't +have a battery-backed write-back cache in it. My dev systems mostly use +software RAID, if they use RAID at all. But my production boxes all +use SATA +RAID (and I tell my customers to use controllers with BB cache, +whether it +be SCSI or SATA). + +My usual workloads are write-heavy. If yours are read-heavy that will +move the sweet spot around significantly, and I can easily imagine that +for a read-heavy load software RAID might be a much better match. + +Cheers, + Steve + + +From pgsql-performance-owner@postgresql.org Tue May 9 12:00:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 540649F946D; + Tue, 9 May 2006 12:00:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 70860-08; Tue, 9 May 2006 12:00:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id D09B39F931D; + Tue, 9 May 2006 12:00:44 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1FdThN-0003jL-00; Tue, 09 May 2006 11:00:29 -0400 +To: PFC +Cc: "Tom Lane" , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> +In-Reply-To: +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 09 May 2006 11:00:29 -0400 +Message-ID: <8764kfz1iq.fsf@stark.xeocode.com> +Lines: 20 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/181 +X-Sequence-Number: 18968 + + +PFC writes: + +> +> I really like this. It's clean, efficient, and easy to use. +> +> This would be a lot faster than using temp tables. +> Creating cursors is very fast so we can create two, and avoid doing +> twice the same work (ie. hashing the ids from the results to grab categories +> only once). + +Creating cursors for a simple plan like a single sequential scan is fast +because it's using the original data from the table. But your example was +predicated on this part of the job being a complex query. If it's a complex +query involving joins and groupings, etc, then it will have to be materialized +and there's no (good) reason for that to be any faster than a temporary table +which is effectively the same thing. + +-- +greg + + +From pgsql-general-owner@postgresql.org Tue May 9 12:17:59 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BC6B79F9F3D + for ; + Tue, 9 May 2006 12:17:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 75579-07 + for ; + Tue, 9 May 2006 12:17:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id C97E79F946D + for ; + Tue, 9 May 2006 12:17:45 -0300 (ADT) +Received: (qmail 13784 invoked by uid 500); 9 May 2006 15:18:48 -0000 +Date: Tue, 9 May 2006 10:18:48 -0500 +From: Bruno Wolff III +To: "Jean-Yves F. Barbier" <7ukwn@free.fr> +Cc: Hannes Dorbath , pgsql-general@postgresql.org, + pgsql-performance@postgresql.org +Subject: Re: Arguments Pro/Contra Software Raid +Message-ID: <20060509151848.GA11476@wolff.to> +Mail-Followup-To: Bruno Wolff III , + "Jean-Yves F. Barbier" <7ukwn@free.fr>, + Hannes Dorbath , + pgsql-general@postgresql.org, pgsql-performance@postgresql.org +References: <44606A98.4090705@free.fr> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <44606A98.4090705@free.fr> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/345 +X-Sequence-Number: 95137 + +On Tue, May 09, 2006 at 12:10:32 +0200, + "Jean-Yves F. Barbier" <7ukwn@free.fr> wrote: +> Naa, you can find ATA &| SATA ctrlrs for about EUR30 ! + +But those are the ones that you would generally be better off not using. + +> Definitely NOT, however if your server doen't have a heavy load, the +> software overload can't be noticed (essentially cache managing and +> syncing) + +It is fairly common for database machines to be IO, rather than CPU, bound +and so the CPU impact of software raid is low. + +> Some hardware ctrlrs are able to avoid the loss of a disk if you turn +> to have some faulty sectors (by relocating internally them); software +> RAID doesn't as sectors *must* be @ the same (linear) addresses. + +That is not true. Software raid works just fine on drives that have internally +remapped sectors. + +From pgsql-general-owner@postgresql.org Tue May 9 12:49:42 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6B9FA9F946D + for ; + Tue, 9 May 2006 12:49:42 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 79536-07 + for ; + Tue, 9 May 2006 12:49:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 301439F931D + for ; + Tue, 9 May 2006 12:49:30 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 9 May 2006 15:49:29 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 09 May 2006 10:49:29 -0500 +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +From: Scott Marlowe +To: Hannes Dorbath +Cc: pgsql general +In-Reply-To: +References: +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1147189769.9755.13.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 09 May 2006 10:49:29 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/352 +X-Sequence-Number: 95144 + +On Tue, 2006-05-09 at 04:16, Hannes Dorbath wrote: +> Hi, +> +> I've just had some discussion with colleagues regarding the usage of +> hardware or software raid 1/10 for our linux based database servers. +> +> I myself can't see much reason to spend $500 on high end controller +> cards for a simple Raid 1. +> +> Any arguments pro or contra would be desirable. +> +> From my experience and what I've read here: +> +> + Hardware Raids might be a bit easier to manage, if you never spend a +> few hours to learn Software Raid Tools. + +Depends. Some hardware RAID cards aren't that easy to manage, and +sometimes, they won't let you do some things that software will. I've +run into situations where a RAID controller kicked out two perfectly +good drives from a RAID 5 and would NOT accept them back. All data +lost, and it would not be convinced to restart without formatting the +drives first. arg! With Linux kernel sw RAID, I've had a similar +problem pop up, and was able to make the RAID array take the drives +back. Of course, this means that software RAID relies on you not being +stupid, because it will let you do things that are dangerous / stupid. + +I found the raidtools on linux to be well thought out and fairly easy to +use. + +> + There are situations in which Software Raids are faster, as CPU power +> has advanced dramatically in the last years and even high end controller +> cards cannot keep up with that. + +The only times I've found software RAID to be faster was against the +hybrid hardware / software type RAID cards (i.e. the cheapies) or OLDER +RAID cards, that have a 33 MHz coprocessor or such. Most modern RAID +controllers have coprocessors running at several hundred MHz or more, +and can compute parity and manage the array as fast as the attached I/O +can handle it. + +The one thing a software RAID will never be able to match the hardware +RAID controller on is battery backed cache. + +> + Using SATA drives is always a bit of risk, as some drives are lying +> about whether they are caching or not. + +This is true whether you are using hardware RAID or not. Turning off +drive caching seems to prevent the problem. However, with a RAID +controller, the caching can then be moved to the BBU cache, while with +software RAID no such option exists. Most SATA RAID controllers turn +off the drive cache automagically, like the escalades seem to do. + +> + Using hardware controllers, the array becomes locked to a particular +> vendor. You can't switch controller vendors as the array meta +> information is stored proprietary. In case the Raid is broken to a level +> the controller can't recover automatically this might complicate manual +> recovery by specialists. + +And not just a particular vendor, but likely a particular model and even +firmware revision. For this reason, and 24/7 server should have two +RAID controllers of the same brand running identical arrays, then have +them set up as a mirror across the controllers, assuming you have +controllers that can run cooperatively. This setup ensures that even if +one of your RAID controllers fails, you then have a fully operational +RAID array for as long as it takes to order and replace the bad +controller. And having a third as a spare in a cabinet somewhere is +cheap insurance as well. + +> + Even battery backed controllers can't guarantee that data written to +> the drives is consistent after a power outage, neither that the drive +> does not corrupt something during the involuntary shutdown / power +> irregularities. (This is theoretical as any server will be UPS backed) + +This may be theoretically true, but all the battery backed cache units +I've used have brought the array up clean every time the power has been +lost to them. And a UPS is no insurance against loss of power. +Cascading power failures are not uncommon when things go wrong. + +Now, here's my take on SW versus HW in general: + +HW is the way to go for situations where a battery backed cache is +needed. Heavily written / updated databases are in this category. + +Software RAID is a perfect match for databases with a low write to read +ratio, or where you won't be writing enough for the write performance to +be a big issue. Many data warehouses fall into this category. In this +case, a JBOD enclosure with a couple of dozen drives and software RAID +gives you plenty of storage for chicken feed. If the data is all +derived from outside sources, then you can turn on the write cache in +the drives and turn off fsync and it will be plenty fast, just not crash +safe. + +From pgsql-general-owner@postgresql.org Tue May 9 12:51:58 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 90AAE9F946D; + Tue, 9 May 2006 12:51:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 83017-02; Tue, 9 May 2006 12:51:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id 88A389F931D; + Tue, 9 May 2006 12:51:46 -0300 (ADT) +Received: from [192.168.1.50] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k49FpgrT020636; Tue, 9 May 2006 08:51:42 -0700 +Message-ID: <4460BA8B.7010600@commandprompt.com> +Date: Tue, 09 May 2006 08:51:39 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Steve Atkins +CC: PostgreSQL General , + "Pgsql-Performance ((E-mail))" +Subject: Re: Arguments Pro/Contra Software Raid +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> +In-Reply-To: <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88, + clamav-milter version 0.87 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Tue, 09 May 2006 08:51:43 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/353 +X-Sequence-Number: 95145 + +> +> Don't buy those drives. That's unrelated to whether you use hardware +> or software RAID. + +Sorry that is an extremely misleading statement. SATA RAID is perfectly +acceptable if you have a hardware raid controller with a battery backup +controller. + +And dollar for dollar, SCSI will NOT be faster nor have the hard drive +capacity that you will get with SATA. + +Sincerely, + +Joshua D. Drake + + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === + Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-performance-owner@postgresql.org Tue May 9 23:55:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BE29C9FA42B; + Tue, 9 May 2006 13:29:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 88871-04-2; Tue, 9 May 2006 13:29:27 -0300 (ADT) +X-Greylist: delayed 00:25:58.612776 by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 1ED1B9F931E; + Tue, 9 May 2006 13:29:26 -0300 (ADT) +Received: from a.mail.sonic.net (a.mail.sonic.net [64.142.16.245]) + by svr4.postgresql.org (Postfix) with ESMTP id 02E4E5B0653; + Tue, 9 May 2006 15:58:12 +0000 (GMT) +Received: from [10.1.1.1] (69-12-140-204.dsl.static.sonic.net [69.12.140.204]) + (authenticated bits=0) + by a.mail.sonic.net (8.13.6/8.13.3) with ESMTP id k49Fw6lZ001806 + (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO); + Tue, 9 May 2006 08:58:07 -0700 +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +From: Mitchell Skinner +To: PFC +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +In-Reply-To: +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> <28288.1147111196@sss.pgh.pa.us> + + <20060509105214.P90693@vesihiisi.cksoft.de> + + <20060509113337.M90693@vesihiisi.cksoft.de> + <20060509103632.GD29652@svana.org> + +Content-Type: text/plain +Date: Tue, 09 May 2006 08:58:05 -0700 +Message-Id: <1147190285.32304.43.camel@firebolt> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-2.fc4) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/213 +X-Sequence-Number: 19000 + +On Tue, 2006-05-09 at 13:29 +0200, PFC wrote: +> 0.101 ms BEGIN +> 1.451 ms CREATE TEMPORARY TABLE tmp ( a INTEGER NOT NULL, b INTEGER NOT +> NULL, c TIMESTAMP NOT NULL, d INTEGER NOT NULL ) ON COMMIT DROP +> 0.450 ms INSERT INTO tmp SELECT * FROM bookmarks ORDER BY annonce_id DESC +> LIMIT 20 +> 0.443 ms ANALYZE tmp +> 0.365 ms SELECT * FROM tmp +> 0.310 ms DROP TABLE tmp +> 32.918 ms COMMIT + +Does the time for commit change much if you leave out the analyze? + + + +From pgsql-performance-owner@postgresql.org Tue May 9 13:28:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AA6259FA3A3 + for ; + Tue, 9 May 2006 13:28:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 87304-05 + for ; + Tue, 9 May 2006 13:28:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id C78A59F9C9E + for ; + Tue, 9 May 2006 13:28:12 -0300 (ADT) +Received: (qmail 5961 invoked from network); 9 May 2006 18:29:32 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 9 May 2006 18:29:32 +0200 +To: "Greg Stark" +Cc: "Tom Lane" , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <8764kfz1iq.fsf@stark.xeocode.com> +Message-ID: +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Date: Tue, 09 May 2006 18:29:31 +0200 +In-Reply-To: <8764kfz1iq.fsf@stark.xeocode.com> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/184 +X-Sequence-Number: 18971 + + +> Creating cursors for a simple plan like a single sequential scan is fast +> because it's using the original data from the table. + + I used the following query : + +SELECT * FROM bookmarks ORDER BY annonce_id DESC LIMIT 20 + + It's a backward index scan + limit... not a seq scan. And it's damn fast : + +0.042 ms BEGIN +0.153 ms DECLARE tmp SCROLL CURSOR WITHOUT HOLD FOR SELECT * FROM +bookmarks ORDER BY annonce_id DESC LIMIT 20 +0.246 ms FETCH ALL FROM tmp +0.048 ms MOVE FIRST IN tmp +0.246 ms FETCH ALL FROM tmp +0.048 ms CLOSE tmp +0.084 ms COMMIT + + +> But your example was +> predicated on this part of the job being a complex query. If it's a +> complex +> query involving joins and groupings, etc, then it will have to be +> materialized +> and there's no (good) reason for that to be any faster than a temporary +> table +> which is effectively the same thing. + + You mean the cursors'storage is in fact the same internal machinery as a +temporary table ? + + In that case, this raises an interesting question : why is the cursor +faster ? + + Let's try a real-life example from my website : it is a search query +(quite complex) which is then joined to a lot of tables to resolve FKeys. + To that query I must add add an application-made join using a big IN() +clause extracted from the data. + Timings includes the time to fetch the results into Python. + The "running total" column is the sum of all timings since the BEGIN. + + +query_time running_total rows query +0.061 ms 0.061 ms -1 BEGIN +23.420 ms 23.481 ms 85 SELECT * FROM (huge query with a +lot of joins) +4.318 ms 27.799 ms 2 SELECT l.*, u.login, u.bg_color + FROM annonces_log l, users u WHERE u.id=l.user_id AND l.annonce_id IN +(list of ids from previous query) ORDER BY annonce_id, added +0.241 ms 28.040 ms -1 COMMIT + + (Just in case you want to hurt yourself, here's the EXPLAIN ANALYZE +output : http://peufeu.com/temp/big_explain.txt) + Using a cursor takes about the same time. + + Also, doing just the search query takes about 12 ms, the joins take up +the rest. + + Now, I'll rewrite my query eliminating the joins and using a temp table. + Storing the whole result in the temp table will be too slow, because +there are too many columns. + Therefore I will only store the primary and foreign key columns, and join +again to the main table to get the full records. + +query_time running_total rows query +0.141 ms 0.141 ms -1 BEGIN + + Do the search : + +8.229 ms 8.370 ms -1 CREATE TEMPORARY TABLE tmp AS +SELECT id, city_id, zipcode, contact_id, contact_group_id, price/terrain +as sort FROM (stripped down search query) +0.918 ms 9.287 ms -1 ANALYZE tmp + + Fetch the main data to display : + +7.663 ms 16.951 ms 85 SELECT a.* FROM tmp t, +annonces_display a WHERE a.id=t.id ORDER BY t.sort + + Fetch log entries associates with each row (one row to many log entries) : + +1.021 ms 17.972 ms 2 SELECT l.*, u.login, u.bg_color + FROM annonces_log l, users u, tmp t WHERE u.id=l.user_id AND l.annonce_id += t.id ORDER BY annonce_id, added +3.468 ms 21.440 ms 216 SELECT annonce_id, +array_accum(list_id) AS list_ids, array_accum(COALESCE(user_id,0)) AS +list_added_by, max(added) AS added_to_list FROM bookmarks GROUP BY +annonce_id + + Resolve foreign key relations + +1.034 ms 22.474 ms 37 SELECT r.annonce_id FROM +read_annonces r, tmp t WHERE r.annonce_id = t.id +0.592 ms 23.066 ms 9 SELECT * FROM cities_dist_zipcode +WHERE zipcode IN (SELECT zipcode FROM tmp) +0.716 ms 23.782 ms 11 SELECT * FROM cities_dist WHERE id +IN (SELECT city_id FROM tmp) +1.125 ms 24.907 ms 45 SELECT * FROM contacts WHERE id IN +(SELECT contact_id FROM tmp) +0.799 ms 25.705 ms 42 SELECT * FROM contact_groups WHERE +id IN (SELECT contact_group_id FROM tmp) +0.463 ms 26.169 ms -1 DROP TABLE tmp +32.208 ms 58.377 ms -1 COMMIT + + + From this we see : + + Using a temporary table is FASTER than doing the large query with all the +joins. (26 ms versus 28 ms). + It's also nicer and cleaner. + However the COMMIT takes as much time as all the queries together ! + + Let's run with fsync=off : + +query_time running_total rows query +0.109 ms 0.109 ms -1 BEGIN +8.321 ms 8.430 ms -1 CREATE TEMPORARY TABLE tmp AS +SELECT id, city_id, zipcode, contact_id, contact_group_id, price/terrain +as sort FROM (stripped down search query) +0.849 ms 9.280 ms -1 ANALYZE tmp +7.360 ms 16.640 ms 85 SELECT a.* FROM tmp t, +annonces_display a WHERE a.id=t.id ORDER BY t.sort +1.067 ms 17.707 ms 2 SELECT l.*, u.login, u.bg_color + FROM annonces_log l, users u, tmp t WHERE u.id=l.user_id AND l.annonce_id += t.id ORDER BY annonce_id, added +3.322 ms 21.030 ms 216 SELECT annonce_id, +array_accum(list_id) AS list_ids, array_accum(COALESCE(user_id,0)) AS +list_added_by, max(added) AS added_to_list FROM bookmarks GROUP BY +annonce_id +0.896 ms 21.926 ms 37 SELECT r.annonce_id FROM +read_annonces r, tmp t WHERE r.annonce_id = t.id +0.573 ms 22.499 ms 9 SELECT * FROM cities_dist_zipcode +WHERE zipcode IN (SELECT zipcode FROM tmp) +0.678 ms 23.177 ms 11 SELECT * FROM cities_dist WHERE id +IN (SELECT city_id FROM tmp) +1.064 ms 24.240 ms 45 SELECT * FROM contacts WHERE id IN +(SELECT contact_id FROM tmp) +0.772 ms 25.013 ms 42 SELECT * FROM contact_groups WHERE +id IN (SELECT contact_group_id FROM tmp) +0.473 ms 25.485 ms -1 DROP TABLE tmp +1.777 ms 27.262 ms -1 COMMIT + + There, it's good again. + + So, when fsync=on, and temporary tables are used, something slow happens +on commit (even if the temp table is ON COMMIT DROP...) + Thoughts ? + + + +From pgsql-performance-owner@postgresql.org Tue May 9 13:37:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id EDF7D9F931E + for ; + Tue, 9 May 2006 13:37:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 89887-01 + for ; + Tue, 9 May 2006 13:37:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 3BE6F9FA2F8 + for ; + Tue, 9 May 2006 13:37:31 -0300 (ADT) +Received: (qmail 6097 invoked from network); 9 May 2006 18:38:52 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 9 May 2006 18:38:52 +0200 +Date: Tue, 09 May 2006 18:38:51 +0200 +To: "Mitchell Skinner" +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + + <20060509113337.M90693@vesihiisi.cksoft.de> + <20060509103632.GD29652@svana.org> + <1147190285.32304.43.camel@firebolt> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <1147190285.32304.43.camel@firebolt> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/185 +X-Sequence-Number: 18972 + + +> Does the time for commit change much if you leave out the analyze? + + Yes, when I don't ANALYZE the temp table, commit time changes from 30 ms +to about 15 ms ; but the queries get horrible plans (see below) : + + Fun thing is, the rowcount from a temp table (which is the problem here) +should be available without ANALYZE ; as the temp table is not concurrent, +it would be simple to inc/decrement a counter on INSERT/DELETE... + + I like the temp table approach : it can replace a large, complex query +with a batch of smaller and easier to optimize queries... + +EXPLAIN ANALYZE SELECT a.* FROM tmp t, annonces_display a WHERE a.id=t.id +ORDER BY t.sort; + QUERY +PLAN +------------------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=3689.88..3693.15 rows=1310 width=940) (actual +time=62.327..62.332 rows=85 loops=1) + Sort Key: t.sort + -> Merge Join (cost=90.93..3622.05 rows=1310 width=940) (actual +time=5.595..61.373 rows=85 loops=1) + Merge Cond: ("outer".id = "inner".id) + -> Index Scan using annonces_pkey on annonces +(cost=0.00..3451.39 rows=10933 width=932) (actual time=0.012..6.620 +rows=10916 loops=1) + -> Sort (cost=90.93..94.20 rows=1310 width=12) (actual +time=0.098..0.105 rows=85 loops=1) + Sort Key: t.id + -> Seq Scan on tmp t (cost=0.00..23.10 rows=1310 +width=12) (actual time=0.004..0.037 rows=85 loops=1) + Total runtime: 62.593 ms + +EXPLAIN ANALYZE SELECT * FROM contacts WHERE id IN (SELECT contact_id FROM +tmp); + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------- + Hash Join (cost=28.88..427.82 rows=200 width=336) (actual +time=0.156..5.019 rows=45 loops=1) + Hash Cond: ("outer".id = "inner".contact_id) + -> Seq Scan on contacts (cost=0.00..349.96 rows=9396 width=336) +(actual time=0.009..3.373 rows=9396 loops=1) + -> Hash (cost=28.38..28.38 rows=200 width=4) (actual +time=0.082..0.082 rows=46 loops=1) + -> HashAggregate (cost=26.38..28.38 rows=200 width=4) (actual +time=0.053..0.064 rows=46 loops=1) + -> Seq Scan on tmp (cost=0.00..23.10 rows=1310 width=4) +(actual time=0.001..0.015 rows=85 loops=1) + Total runtime: 5.092 ms + +ANALYZE tmp; +ANALYZE +annonces=> EXPLAIN ANALYZE SELECT a.* FROM tmp t, annonces_display a WHERE +a.id=t.id ORDER BY t.sort; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------- + Sort (cost=508.63..508.84 rows=85 width=940) (actual time=1.830..1.832 +rows=85 loops=1) + Sort Key: t.sort + -> Nested Loop (cost=0.00..505.91 rows=85 width=940) (actual +time=0.040..1.188 rows=85 loops=1) + -> Seq Scan on tmp t (cost=0.00..1.85 rows=85 width=12) (actual +time=0.003..0.029 rows=85 loops=1) + -> Index Scan using annonces_pkey on annonces (cost=0.00..5.89 +rows=1 width=932) (actual time=0.003..0.004 rows=1 loops=85) + Index Cond: (annonces.id = "outer".id) + Total runtime: 2.053 ms +(7 lignes) + +annonces=> EXPLAIN ANALYZE SELECT * FROM contacts WHERE id IN (SELECT +contact_id FROM tmp); + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------- + Nested Loop (cost=2.06..139.98 rows=36 width=336) (actual +time=0.072..0.274 rows=45 loops=1) + -> HashAggregate (cost=2.06..2.51 rows=45 width=4) (actual +time=0.052..0.065 rows=46 loops=1) + -> Seq Scan on tmp (cost=0.00..1.85 rows=85 width=4) (actual +time=0.003..0.016 rows=85 loops=1) + -> Index Scan using contacts_pkey on contacts (cost=0.00..3.04 rows=1 +width=336) (actual time=0.003..0.004 rows=1 loops=46) + Index Cond: (contacts.id = "outer".contact_id) + Total runtime: 0.341 ms + +From pgsql-performance-owner@postgresql.org Tue May 9 13:43:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9FBF09FA2F8 + for ; + Tue, 9 May 2006 13:43:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 89084-05 + for ; + Tue, 9 May 2006 13:43:25 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nf-out-0910.google.com (nf-out-0910.google.com + [64.233.182.191]) + by postgresql.org (Postfix) with ESMTP id 117599F9C9E + for ; + Tue, 9 May 2006 13:43:24 -0300 (ADT) +Received: by nf-out-0910.google.com with SMTP id x30so372739nfb + for ; + Tue, 09 May 2006 09:43:23 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=G8JAG1DJcegHVZbP1slMm6bxbmNjyRI343NNLB4Vna9QXGQJzlFfV0oxmiL/rFjDOJVsdewX4qOGfh+ghT7zz05cjb4a67a/TT19KrMHAdSdNedji+/vb4xUz3bH/NJimRngpPFmnEYHLbO7YaDkQx4TSbFZ/ZTFAE0MDWGsYTY= +Received: by 10.48.238.8 with SMTP id l8mr2228626nfh; + Tue, 09 May 2006 09:43:23 -0700 (PDT) +Received: by 10.48.203.10 with HTTP; Tue, 9 May 2006 09:43:23 -0700 (PDT) +Message-ID: <758d5e7f0605090943p1bbfdae2p4cb28ba128288316@mail.gmail.com> +Date: Tue, 9 May 2006 18:43:23 +0200 +From: "Dawid Kuroczko" +To: PFC +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Cc: "Christian Kratzer" , "Tom Lane" , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/186 +X-Sequence-Number: 18973 + +On 5/9/06, PFC wrote: +> > You might consider just selecting your primary key or a set of +> > primary keys to involved relations in your search query. If you +> > currently use "select *" this can make your result set very large. +> > +> > Copying all the result set to the temp. costs you additional IO +> > that you propably dont need. +> +> It is a bit of a catch : I need this information, because the pur= +pose of +> the query is to retrieve these objects. I can first store the ids, then +> retrieve the objects, but it's one more query. +> +> > Also you might try: +> > SELECT * FROM somewhere JOIN result USING (id) +> > Instead of: +> > SELECT * FROM somewhere WHERE id IN (SELECT id FROM result) +> +> Yes you're right in this case ; however the query to retrieve the= + owners +> needs to eliminate duplicates, which IN() does. + +Well, you can either + SELECT * FROM somewhere JOIN (SELECT id FROM result GROUP BY id) AS +a USING (id); +or even, for large number of ids: + CREATE TEMPORARY TABLE result_ids AS SELECT id FROM RESULT GROUP BY id; + SELECT * FROM somewhere JOIN result_ids USING (id); + + +> > On the other hand if your search query runs in 10ms it seems to be fast +> > enough for you to run it multiple times. Theres propably no point in +> > optimizing anything in such case. +> +> I don't think so : +> - 10 ms is a mean time, sometimes it can take much more time, som= +etimes +> it's faster. +> - Repeating the query might yield different results if records we= +re added +> or deleted in the meantime. + +You may SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; +though locking might bite you. :) + +> - Complex search queries have imprecise rowcount estimates ; henc= +e the +> joins that I would add to them will get suboptimal plans. +> +> Using a temp table is really the cleanest solution now ; but it's= + too +> slow so I reverted to generating big IN() clauses in the application. + +A thought, haven't checked it though, but... + +You might want to use PL to store values, say PLperl, or even C, say: + +create or replace function perl_store(name text, val int) returns void +as $$ my $name =3D shift; push @{$foo{$name}}, shift; return $$ LANGUAGE +plperl; + +select perl_store('someids', id) from something group by id; +(you may need to warp it inside count()) + +Then use it: + +create or replace function perl_retr(name text) returns setof int as +$$ my $name =3D shift; return $foo{$name} $$ LANGUAGE plperl; + +select * from someother join perl_retr('someids') AS a(id) using (id); + +All is in the memory. Of course, you need to do some cleanup, test it, +etc, etc, etc. :) + +Should work faster than a in-application solution :) + + Regards, + Dawid + +From pgsql-performance-owner@postgresql.org Tue May 9 13:48:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AE1AB9FA3A3 + for ; + Tue, 9 May 2006 13:48:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 90740-02 + for ; + Tue, 9 May 2006 13:48:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id A493D9F9C9E + for ; + Tue, 9 May 2006 13:48:02 -0300 (ADT) +Received: (qmail 6282 invoked from network); 9 May 2006 18:49:23 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 9 May 2006 18:49:23 +0200 +Date: Tue, 09 May 2006 18:49:22 +0200 +To: "Dawid Kuroczko" +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Cc: "Christian Kratzer" , "Tom Lane" , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + + <758d5e7f0605090943p1bbfdae2p4cb28ba128288316@mail.gmail.com> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <758d5e7f0605090943p1bbfdae2p4cb28ba128288316@mail.gmail.com> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/187 +X-Sequence-Number: 18974 + + + +>> > SELECT * FROM somewhere WHERE id IN (SELECT id FROM result) + +> Well, you can either +> SELECT * FROM somewhere JOIN (SELECT id FROM result GROUP BY id) AS +> a USING (id); + + It's the same thing (and postgres knows it) + +> You might want to use PL to store values, say PLperl, or even C, say: + + I tried. + The problem is that you need a set-returning function to retrieve the +values. SRFs don't have rowcount estimates, so the plans suck. + +> Should work faster than a in-application solution :) + + Should, but don't, because of what I said above... + + With the version in CVS tip, supprting a fast =ANY( array ), this should +be doable, though. + +From pgsql-general-owner@postgresql.org Tue May 9 14:52:54 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 568D89F9C9E; + Tue, 9 May 2006 14:52:53 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 97807-05; Tue, 9 May 2006 14:52:47 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from m.wordtothewise.com (goliath.word-to-the-wise.com + [208.187.80.130]) + by postgresql.org (Postfix) with ESMTP id DE2CF9F931E; + Tue, 9 May 2006 14:52:47 -0300 (ADT) +Received: from [10.3.2.7] (184.word-to-the-wise.com [208.187.80.184]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by m.wordtothewise.com (Postfix) with ESMTP id C3353FF96; + Tue, 9 May 2006 10:52:46 -0700 (PDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <4460BA8B.7010600@commandprompt.com> +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <4F853BBA-175C-4B3E-BAF4-AA34B80DF6EF@blighty.com> +Content-Transfer-Encoding: 7bit +From: Steve Atkins +Subject: Re: Arguments Pro/Contra Software Raid +Date: Tue, 9 May 2006 10:52:45 -0700 +To: PostgreSQL General , + "Pgsql-Performance ((E-mail))" +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/365 +X-Sequence-Number: 95157 + + +On May 9, 2006, at 8:51 AM, Joshua D. Drake wrote: + +("Using SATA drives is always a bit of risk, as some drives are lying +about whether they are caching or not.") + +>> Don't buy those drives. That's unrelated to whether you use hardware +>> or software RAID. +> +> Sorry that is an extremely misleading statement. SATA RAID is +> perfectly acceptable if you have a hardware raid controller with a +> battery backup controller. + +If the drive says it's hit the disk and it hasn't then the RAID +controller +will have flushed the data from its cache (or flagged it as correctly +written). At that point the only place the data is stored is in the non +battery backed cache on the drive itself. If something fails then you'll +have lost data. + +You're not suggesting that a hardware RAID controller will protect +you against drives that lie about sync, are you? + +> +> And dollar for dollar, SCSI will NOT be faster nor have the hard +> drive capacity that you will get with SATA. + +Yup. That's why I use SATA RAID for all my databases. + +Cheers, + Steve + +From pgsql-general-owner@postgresql.org Tue May 9 14:57:32 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D57899F931E; + Tue, 9 May 2006 14:57:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 00534-01; Tue, 9 May 2006 14:57:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id A213E9FA2F8; + Tue, 9 May 2006 14:57:20 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id A6CB8B827; + Tue, 9 May 2006 13:57:17 -0400 (EDT) +In-Reply-To: <4460BA8B.7010600@commandprompt.com> +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-9--760971410; + protocol="application/pkcs7-signature" +Message-Id: <5AF87D32-F602-4973-AA21-84E0CFEA1774@khera.org> +Cc: PostgreSQL General +From: Vivek Khera +Subject: Re: Arguments Pro/Contra Software Raid +Date: Tue, 9 May 2006 13:57:16 -0400 +To: "Pgsql-Performance ((E-mail))" +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/372 +X-Sequence-Number: 95164 + + +--Apple-Mail-9--760971410 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + + +On May 9, 2006, at 11:51 AM, Joshua D. Drake wrote: + +> Sorry that is an extremely misleading statement. SATA RAID is +> perfectly acceptable if you have a hardware raid controller with a +> battery backup controller. +> +> And dollar for dollar, SCSI will NOT be faster nor have the hard +> drive capacity that you will get with SATA. + +Does this hold true still under heavy concurrent-write loads? I'm +preparing yet another big DB server and if SATA is a better option, +I'm all (elephant) ears. + + +--Apple-Mail-9--760971410 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGlDCCAz8w +ggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0 +ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcx +KDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1RoYXd0 +ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVyc29uYWwtZnJlZW1haWxA +dGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5NTlaMGIxCzAJBgNVBAYTAlpB +MSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUg +UGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA +xKY8VXNV+065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/Uc4B1OVQCjDXAmNaLIkVcI7d +yfArhVqqP3FWy688Cwfn8R+RNiQqE88r1fOCdz0Dviv+uxg+B79AgAJk16emu59l0cUqVIUPSAR/ +p7bRPGEEQB5kGXJgt/sCAwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/AgEAMEMGA1UdHwQ8MDow +OKA2oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25hbEZyZWVtYWlsQ0EuY3Js +MAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRUHJpdmF0ZUxhYmVsMi0xMzgw +DQYJKoZIhvcNAQEFBQADgYEASIzRUIPqCy7MDaNmrGcPf6+svsIXoUOWlJ1/TCG4+DYfqi2fNi/A +9BxQIJNwPP2t4WFiw9k6GX6EsZkbAMUaC4J0niVQlGLH2ydxVyWN3amcOY6MIE9lX5Xa9/eH1sYI +Tq726jTlEBpbNU1341YheILcIRk13iSx0x1G/11fZU8wggNNMIICtqADAgECAhA6sDoA4m3lcimf +yUtGSQgmMA0GCSqGSIb3DQEBBAUAMGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29u +c3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNz +dWluZyBDQTAeFw0wNjA1MDIxNDEyNDdaFw0wNzA1MDIxNDEyNDdaMIGKMR8wHQYDVQQDExZUaGF3 +dGUgRnJlZW1haWwgTWVtYmVyMR4wHAYJKoZIhvcNAQkBFg92aXZla0BraGVyYS5vcmcxIDAeBgkq +hkiG9w0BCQEWEWtoZXJhQGtjaWxpbmsuY29tMSUwIwYJKoZIhvcNAQkBFhZ2aXZla0BtYWlsZXJt +YWlsZXIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq+zHKYq9vZ4Dq1itNqT/ +OeJvWDvQ5JdQlRzwsJlvtJBknXsnOaJNabmjnu2s6XFMcP2srBZQ/WPvhsClajLQOcxnarrfB66N +DpMzXTxfYzX6m9TA/fEn64sNn+YnBZL6Dvid9kiAgP9LmqcTOIFdWUya3ZmQS5YTuLB+tkFSL8/h ++inDPN6dcsna8TcM1SAk+3upxOR7kyFM9T3vy25w62Nh1zK7Stp0vUZLU6GzzC1VvHGZHKGticD6 +o3uHaMr2LCFjptoIcfZL75LO/UaR9o7smgboW4yJyW5g9ZasyYQUXyvkitfyZuVWATb8ZSHOkjWJ +872Pyf5+HOevVUI0aQIDAQABo1cwVTBFBgNVHREEPjA8gQ92aXZla0BraGVyYS5vcmeBEWtoZXJh +QGtjaWxpbmsuY29tgRZ2aXZla0BtYWlsZXJtYWlsZXIuY29tMAwGA1UdEwEB/wQCMAAwDQYJKoZI +hvcNAQEEBQADgYEAYpaFKDj47pTQIUQi28MgtjKophopv4QJjvspXmy0qxd8t/M/zc7HuBy3i/9a +PrXDgKyNBzzlFTasTazAY53ntVpqw9k1NOeHmH6o3j/DBVa49bC6bbWfp9UGOwYChlDR0tngQZyC +MDMZEdYv4zpGfBTku5m1jb8Yz/qYqV4FWB4xggMQMIIDDAIBATB2MGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIQOrA6AOJt5XIpn8lLRkkIJjAJBgUrDgMCGgUAoIIB +bzAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjA1MDkxNzU3MTda +MCMGCSqGSIb3DQEJBDEWBBRAkVw0OWEMAiQDMZka0XAg6BIxtDCBhQYJKwYBBAGCNxAEMXgwdjBi +MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoG +A1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECEDqwOgDibeVyKZ/JS0ZJ +CCYwgYcGCyqGSIb3DQEJEAILMXigdjBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENv +bnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElz +c3VpbmcgQ0ECEDqwOgDibeVyKZ/JS0ZJCCYwDQYJKoZIhvcNAQEBBQAEggEAniazVXH0g0Quk5Rz +Kysy9Tshxny60hsyJaFw3oavahvapbYKuhC6RdxsbCxPHf5Z9O0/CpuvsJV5yGKgw9JCRjMc00i7 +DftHSZRkMV3T2BiPDxF/DIjI9dMiNdydlAbWqzOM8caffs4uFeG/YnHyy2jmSq7RUvxqNl5UCI6q +QH5hkBLMWoDR6LCYv68O2KYq+q119Gb6sVMVgfbfw8TYGMrdbNBkcuqQYG7YcjxMhvDVBbxt4Sr8 ++946cgYz//wTenkSjG+mXcEWHJQ/rh89+t6BQ/gb7O8O6atL/RBwoGNCSMwx6/xsx9G5i+tNS3WO +whaaZdLraTL4MVjnmNUG6AAAAAAAAA== + +--Apple-Mail-9--760971410-- + +From pgsql-general-owner@postgresql.org Tue May 9 15:05:43 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5FFC59F9C9E; + Tue, 9 May 2006 15:05:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 97860-07; Tue, 9 May 2006 15:05:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from suzuka.mcnaught.org (unknown [4.21.254.118]) + by postgresql.org (Postfix) with ESMTP id 2BBAD9F931E; + Tue, 9 May 2006 15:05:32 -0300 (ADT) +Received: by suzuka.mcnaught.org (Postfix, from userid 1000) + id CAEC0167A7B; Tue, 9 May 2006 14:05:28 -0400 (EDT) +To: Vivek Khera +Cc: "Pgsql-Performance ((E-mail))" , + PostgreSQL General +Subject: Re: Arguments Pro/Contra Software Raid +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> + <5AF87D32-F602-4973-AA21-84E0CFEA1774@khera.org> +From: Douglas McNaught +Date: Tue, 09 May 2006 14:05:28 -0400 +In-Reply-To: <5AF87D32-F602-4973-AA21-84E0CFEA1774@khera.org> (Vivek Khera's + message of "Tue, 9 May 2006 13:57:16 -0400") +Message-ID: <87mzdroyzb.fsf@suzuka.mcnaught.org> +User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/373 +X-Sequence-Number: 95165 + +Vivek Khera writes: + +> On May 9, 2006, at 11:51 AM, Joshua D. Drake wrote: +> +>> And dollar for dollar, SCSI will NOT be faster nor have the hard +>> drive capacity that you will get with SATA. +> +> Does this hold true still under heavy concurrent-write loads? I'm +> preparing yet another big DB server and if SATA is a better option, +> I'm all (elephant) ears. + +Correct me if I'm wrong, but I've never heard of a 15kRPM SATA drive. + +-Doug + +From pgsql-general-owner@postgresql.org Tue May 9 15:25:42 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B47B39F9C9E; + Tue, 9 May 2006 15:25:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 01238-06; Tue, 9 May 2006 15:25:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id E74E49F931E; + Tue, 9 May 2006 15:25:34 -0300 (ADT) +Received: from [192.168.1.50] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k49IPUYB023792; Tue, 9 May 2006 11:25:30 -0700 +Message-ID: <4460DE97.9040001@commandprompt.com> +Date: Tue, 09 May 2006 11:25:27 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Vivek Khera +CC: "Pgsql-Performance ((E-mail))" , + PostgreSQL General +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> + <5AF87D32-F602-4973-AA21-84E0CFEA1774@khera.org> +In-Reply-To: <5AF87D32-F602-4973-AA21-84E0CFEA1774@khera.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88, + clamav-milter version 0.87 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Tue, 09 May 2006 11:25:31 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/375 +X-Sequence-Number: 95167 + +Vivek Khera wrote: +> +> On May 9, 2006, at 11:51 AM, Joshua D. Drake wrote: +> +>> Sorry that is an extremely misleading statement. SATA RAID is +>> perfectly acceptable if you have a hardware raid controller with a +>> battery backup controller. +>> +>> And dollar for dollar, SCSI will NOT be faster nor have the hard drive +>> capacity that you will get with SATA. +> +> Does this hold true still under heavy concurrent-write loads? I'm +> preparing yet another big DB server and if SATA is a better option, I'm +> all (elephant) ears. + +I didn't say better :). If you can afford, SCSI is the way to go. +However SATA with a good controller (I am fond of the LSI 150 series) +can provide some great performance. + +I have not used, but have heard good things about Areca as well. Oh, and +make sure they are SATA-II drives. + +Sincerely, + +Joshua D. Drake + + +> + + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === + Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-general-owner@postgresql.org Tue May 9 15:26:56 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AEFE59FA3A3; + Tue, 9 May 2006 15:26:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 03884-03; Tue, 9 May 2006 15:26:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id 9EB0A9F9C9E; + Tue, 9 May 2006 15:26:35 -0300 (ADT) +Received: from [192.168.1.50] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k49IQVYL023812; Tue, 9 May 2006 11:26:31 -0700 +Message-ID: <4460DED4.2090103@commandprompt.com> +Date: Tue, 09 May 2006 11:26:28 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Steve Atkins +CC: PostgreSQL General , + "Pgsql-Performance ((E-mail))" +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> + <4F853BBA-175C-4B3E-BAF4-AA34B80DF6EF@blighty.com> +In-Reply-To: <4F853BBA-175C-4B3E-BAF4-AA34B80DF6EF@blighty.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88, + clamav-milter version 0.87 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Tue, 09 May 2006 11:26:32 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/377 +X-Sequence-Number: 95169 + + +> You're not suggesting that a hardware RAID controller will protect +> you against drives that lie about sync, are you? + +Of course not, but which drives lie about sync that are SATA? Or more +specifically SATA-II? + +Sincerely, + +Joshua D. Drake + + + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === + Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-general-owner@postgresql.org Tue May 9 15:34:39 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E16259F9C9E; + Tue, 9 May 2006 15:34:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 02692-07; Tue, 9 May 2006 15:34:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from m.wordtothewise.com (goliath.word-to-the-wise.com + [208.187.80.130]) + by postgresql.org (Postfix) with ESMTP id F08B89F931E; + Tue, 9 May 2006 15:34:33 -0300 (ADT) +Received: from [10.3.2.7] (184.word-to-the-wise.com [208.187.80.184]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by m.wordtothewise.com (Postfix) with ESMTP id 04E1EFF96; + Tue, 9 May 2006 11:34:32 -0700 (PDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <4460DED4.2090103@commandprompt.com> +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> + <4F853BBA-175C-4B3E-BAF4-AA34B80DF6EF@blighty.com> + <4460DED4.2090103@commandprompt.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <600C4F8C-906D-4FD7-B969-89EE61E9DEBE@blighty.com> +Content-Transfer-Encoding: 7bit +From: Steve Atkins +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +Date: Tue, 9 May 2006 11:34:31 -0700 +To: PostgreSQL General , + "Pgsql-Performance ((E-mail))" +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/378 +X-Sequence-Number: 95170 + + +On May 9, 2006, at 11:26 AM, Joshua D. Drake wrote: + +> +>> You're not suggesting that a hardware RAID controller will protect +>> you against drives that lie about sync, are you? +> +> Of course not, but which drives lie about sync that are SATA? Or +> more specifically SATA-II? + +SATA-II, none that I'm aware of, but there's a long history of dodgy +behaviour designed to pump up benchmark results down in the +consumer drive space, and low end consumer space is where a +lot of SATA drives are. I wouldn't be surprised to see that beahviour +there still. + +I was responding to the original posters assertion that drives lying +about sync were a reason not to buy SATA drives, by telling him +not to buy drives that lie about sync. You seem to have read this +as "don't buy SATA drives", which is not what I said and not what I +meant. + +Cheers, + Steve + +From pgsql-general-owner@postgresql.org Tue May 9 15:43:28 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 63C139F9C9E; + Tue, 9 May 2006 15:43:27 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 06676-02; Tue, 9 May 2006 15:43:20 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id 5DDF59F931E; + Tue, 9 May 2006 15:43:20 -0300 (ADT) +Received: from [192.168.1.50] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k49IhJHs024124; Tue, 9 May 2006 11:43:19 -0700 +Message-ID: <4460E2C4.2020804@commandprompt.com> +Date: Tue, 09 May 2006 11:43:16 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Douglas McNaught +CC: Vivek Khera , + "Pgsql-Performance ((E-mail))" , + PostgreSQL General +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> + <5AF87D32-F602-4973-AA21-84E0CFEA1774@khera.org> + <87mzdroyzb.fsf@suzuka.mcnaught.org> +In-Reply-To: <87mzdroyzb.fsf@suzuka.mcnaught.org> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88, + clamav-milter version 0.87 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Tue, 09 May 2006 11:43:20 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/379 +X-Sequence-Number: 95171 + +Douglas McNaught wrote: +> Vivek Khera writes: +> +>> On May 9, 2006, at 11:51 AM, Joshua D. Drake wrote: +>> +>>> And dollar for dollar, SCSI will NOT be faster nor have the hard +>>> drive capacity that you will get with SATA. +>> Does this hold true still under heavy concurrent-write loads? I'm +>> preparing yet another big DB server and if SATA is a better option, +>> I'm all (elephant) ears. +> +> Correct me if I'm wrong, but I've never heard of a 15kRPM SATA drive. + +Best I have seen is 10k but if I can put 4x the number of drives in the +array at the same cost... I don't need 15k. + +Joshua D. Drake + +> +> -Doug +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> + + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === + Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-general-owner@postgresql.org Tue May 9 16:04:22 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B98DE9F931E; + Tue, 9 May 2006 16:04:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 08603-05; Tue, 9 May 2006 16:04:10 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 938279FA2F8; + Tue, 9 May 2006 16:04:10 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 9 May 2006 19:04:08 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 09 May 2006 14:04:08 -0500 +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +From: Scott Marlowe +To: Steve Atkins +Cc: PostgreSQL General , + "Pgsql-Performance ((E-mail))" +In-Reply-To: <4F853BBA-175C-4B3E-BAF4-AA34B80DF6EF@blighty.com> +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> + <4F853BBA-175C-4B3E-BAF4-AA34B80DF6EF@blighty.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1147201448.9755.16.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 09 May 2006 14:04:08 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/383 +X-Sequence-Number: 95175 + +On Tue, 2006-05-09 at 12:52, Steve Atkins wrote: +> On May 9, 2006, at 8:51 AM, Joshua D. Drake wrote: +> +> ("Using SATA drives is always a bit of risk, as some drives are lying +> about whether they are caching or not.") +> +> >> Don't buy those drives. That's unrelated to whether you use hardware +> >> or software RAID. +> > +> > Sorry that is an extremely misleading statement. SATA RAID is +> > perfectly acceptable if you have a hardware raid controller with a +> > battery backup controller. +> +> If the drive says it's hit the disk and it hasn't then the RAID +> controller +> will have flushed the data from its cache (or flagged it as correctly +> written). At that point the only place the data is stored is in the non +> battery backed cache on the drive itself. If something fails then you'll +> have lost data. +> +> You're not suggesting that a hardware RAID controller will protect +> you against drives that lie about sync, are you? + +Actually, in the case of the Escalades at least, the answer is yes. +Last year (maybe a bit more) someone was testing an IDE escalade +controller with drives that were known to lie, and it passed the power +plug pull test repeatedly. Apparently, the escalades tell the drives to +turn off their cache. While most all IDEs and a fair number of SATA +drives lie about cache fsyncing, they all seem to turn off the cache +when you ask. + +And, since a hardware RAID controller with bbu cache has its own cache, +it's not like it really needs the one on the drives anyway. + +From pgsql-performance-owner@postgresql.org Tue May 9 16:13:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8D3399FA2F8; + Tue, 9 May 2006 16:13:18 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 05630-09; Tue, 9 May 2006 16:13:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 3076A9F931E; + Tue, 9 May 2006 16:13:08 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k49JD17Y016681; + Tue, 9 May 2006 15:13:01 -0400 (EDT) +To: PFC +cc: "Mitchell Skinner" , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +In-reply-to: +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + + <20060509113337.M90693@vesihiisi.cksoft.de> + <20060509103632.GD29652@svana.org> + <1147190285.32304.43.camel@firebolt> + +Comments: In-reply-to PFC + message dated "Tue, 09 May 2006 18:38:51 +0200" +Date: Tue, 09 May 2006 15:13:01 -0400 +Message-ID: <16680.1147201981@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/196 +X-Sequence-Number: 18983 + +PFC writes: +> Fun thing is, the rowcount from a temp table (which is the problem here) +> should be available without ANALYZE ; as the temp table is not concurrent, +> it would be simple to inc/decrement a counter on INSERT/DELETE... + +No, because MVCC rules still apply. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 9 19:40:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 170E89FA159 + for ; + Tue, 9 May 2006 19:40:04 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 53871-03 + for ; + Tue, 9 May 2006 19:39:55 -0300 (ADT) +X-Greylist: delayed 00:41:54.833329 by SQLgrey- +Received: from ensim.aers.ca (unknown [207.44.172.93]) + by postgresql.org (Postfix) with ESMTP id 8B26E9F9DCD + for ; + Tue, 9 May 2006 19:39:54 -0300 (ADT) +Received: from aers.ca (S0106002018a0e4a3.gv.shawcable.net [24.68.128.78] (may + be forged)) + by ensim.aers.ca (8.11.6/8.11.6) with ESMTP id k49Lvv408002 + for ; Tue, 9 May 2006 14:57:57 -0700 +Content-class: urn:content-classes:message +Subject: Slow C Function +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Date: Tue, 9 May 2006 14:57:09 -0700 +Message-ID: <6B5AF6293A289F45826220B17ABE79370D5F4C@BORON.aers.local> +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: Slow C Function +thread-index: AcZy327Y2EJaUCqOSf+ixj05HmZOwwA1Awfg +From: "Adam Palmblad" +To: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/197 +X-Sequence-Number: 18984 + +=20 +Hi, + +We've got a C function that we use here and we find that for every +connection, the first run of the function is much slower than any +subsequent runs. ( 50ms compared to 8ms) + +Besides using connection pooling, are there any options to improve +performance? + +By the way, we are using pg version 8.1.3. + +-Adam + + +From pgsql-performance-owner@postgresql.org Tue May 9 20:09:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id EC35D9FA999 + for ; + Tue, 9 May 2006 20:09:34 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 70082-02 + for ; + Tue, 9 May 2006 20:09:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id 3E7609F9DCD + for ; + Tue, 9 May 2006 20:09:21 -0300 (ADT) +Received: from [192.168.1.50] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k49N9MUS000731; Tue, 9 May 2006 16:09:23 -0700 +Message-ID: <4461211F.8020300@commandprompt.com> +Date: Tue, 09 May 2006 16:09:19 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Adam Palmblad +CC: pgsql-performance@postgresql.org +Subject: Re: Slow C Function +References: <6B5AF6293A289F45826220B17ABE79370D5F4C@BORON.aers.local> +In-Reply-To: <6B5AF6293A289F45826220B17ABE79370D5F4C@BORON.aers.local> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88, + clamav-milter version 0.87 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Tue, 09 May 2006 16:09:23 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/198 +X-Sequence-Number: 18985 + +Adam Palmblad wrote: +> +> Hi, +> +> We've got a C function that we use here and we find that for every +> connection, the first run of the function is much slower than any +> subsequent runs. ( 50ms compared to 8ms) + +That is fairly standard because the data will be cached. + +> +> Besides using connection pooling, are there any options to improve +> performance? + +Not that I know of but then again I am not a C programer. + + + +> +> By the way, we are using pg version 8.1.3. +> +> -Adam +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> + + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === + Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-performance-owner@postgresql.org Tue May 9 21:38:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4C32A9FA22C + for ; + Tue, 9 May 2006 21:38:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 77355-09 + for ; + Tue, 9 May 2006 21:38:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 14C929F9DCD + for ; + Tue, 9 May 2006 21:38:21 -0300 (ADT) +Received: from moonunit2.moonview.localnet (wsip-70-167-125-69.sd.sd.cox.net + [70.167.125.69]) + by svr4.postgresql.org (Postfix) with ESMTP id 146D05B5771 + for ; + Wed, 10 May 2006 00:38:20 +0000 (GMT) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k4A0juxP014161 + for ; Tue, 9 May 2006 17:45:56 -0700 +Message-ID: <446135F9.1060608@modgraph-usa.com> +Date: Tue, 09 May 2006 17:38:17 -0700 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Postgres gets stuck +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/199 +X-Sequence-Number: 18986 + +I'm having a rare but deadly problem. On our web servers, a process occasionally gets stuck, and can't be unstuck. Once it's stuck, all Postgres activities cease. "kill -9" is required to kill it -- signals 2 and 15 don't work, and "/etc/init.d/postgresql stop" fails. + +Here's what the process table looks like: + +$ ps -ef | grep postgres +postgres 30713 1 0 Apr24 ? 00:02:43 /usr/local/pgsql/bin/postmaster -p 5432 -D /disk3/postgres/data +postgres 25423 30713 0 May08 ? 00:03:34 postgres: writer process +postgres 25424 30713 0 May08 ? 00:00:02 postgres: stats buffer process +postgres 25425 25424 0 May08 ? 00:00:02 postgres: stats collector process +postgres 11918 30713 21 07:37 ? 02:00:27 postgres: production webuser 127.0.0.1(21772) SELECT +postgres 31624 30713 0 16:11 ? 00:00:00 postgres: production webuser [local] idle +postgres 31771 30713 0 16:12 ? 00:00:00 postgres: production webuser 127.0.0.1(12422) idle +postgres 31772 30713 0 16:12 ? 00:00:00 postgres: production webuser 127.0.0.1(12421) idle +postgres 31773 30713 0 16:12 ? 00:00:00 postgres: production webuser 127.0.0.1(12424) idle +postgres 31774 30713 0 16:12 ? 00:00:00 postgres: production webuser 127.0.0.1(12425) idle +postgres 31775 30713 0 16:12 ? 00:00:00 postgres: production webuser 127.0.0.1(12426) idle +postgres 31776 30713 0 16:12 ? 00:00:00 postgres: production webuser 127.0.0.1(12427) idle +postgres 31777 30713 0 16:12 ? 00:00:00 postgres: production webuser 127.0.0.1(12428) idle + +The SELECT process is the one that's stuck. top(1) and other indicators show that nothing is going on at all (no CPU usage, normal memory usage); the process seems to be blocked waiting for something. (The "idle" processes are attached to a FastCGI program.) + +This has happened on *two different machines*, both doing completely different tasks. The first one is essentially a read-only warehouse that serves lots of queries, and the second one is the server we use to load the warehouse. In both cases, Postgres has been running for a long time, and is issuing SELECT statements that it's issued millions of times before with no problems. No other processes are accessing Postgres, just the web services. + +This is a deadly bug, because our web site goes dead when this happens, and it requires an administrator to log in and kill the stuck postgres process then restart Postgres. We've installed failover system so that the web site is diverted to a backup server, but since this has happened twice in one week, we're worried. + +Any ideas? + +Details: + + Postgres 8.0.3 + Linux 2.6.12-1.1381_FC3smp i686 i386 + + Dell 2-CPU Xeon system (hyperthreading is enabled) + 4 GB memory + 2 120 GB disks (SATA on machine 1, IDE on machine 2) + +Thanks, +Craig + +From pgsql-performance-owner@postgresql.org Tue May 9 21:51:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D998A9FA159 + for ; + Tue, 9 May 2006 21:51:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 80930-09 + for ; + Tue, 9 May 2006 21:51:49 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.197]) + by postgresql.org (Postfix) with ESMTP id C27319F9DCD + for ; + Tue, 9 May 2006 21:51:49 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id k1so1556690nzf + for ; + Tue, 09 May 2006 17:51:45 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; + b=Z3ON1YGedpE9WtAb4NrQ5B9piYXo+yhjZpRVwu3J7KMw8/QoUxtMZQW3W8r6JOqAh64+Snz3flCbzZmz352GKPS6dVD/L5F4rfY2B1vTX3OA1jEcpz0Whim/YnFP6jTcTOkU0vCOYwVIiaM9P6tmD/K254UjQN7FubqOzPs/0BU= +Received: by 10.36.251.60 with SMTP id y60mr5840364nzh; + Tue, 09 May 2006 17:51:45 -0700 (PDT) +Received: from ?10.1.1.21? ( [203.217.18.65]) + by mx.gmail.com with ESMTP id 7sm7178882nzn.2006.05.09.17.51.44; + Tue, 09 May 2006 17:51:45 -0700 (PDT) +Message-ID: <4461391D.2000800@gmail.com> +Date: Wed, 10 May 2006 10:51:41 +1000 +From: Chris +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Craig A. James" +CC: pgsql-performance@postgresql.org +Subject: Re: Postgres gets stuck +References: <446135F9.1060608@modgraph-usa.com> +In-Reply-To: <446135F9.1060608@modgraph-usa.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/200 +X-Sequence-Number: 18987 + + +> This is a deadly bug, because our web site goes dead when this happens, +> and it requires an administrator to log in and kill the stuck postgres +> process then restart Postgres. We've installed failover system so that +> the web site is diverted to a backup server, but since this has happened +> twice in one week, we're worried. +> +> Any ideas? + +Sounds like a deadlock issue. + +Do you have query logging turned on? + +Also, edit your postgresql.conf file and add (or uncomment): + +stats_command_string = true + +and restart postgresql. + +then you'll be able to: + +select * from pg_stat_activity; + +to see what queries postgres is running and that might give you some clues. + +-- +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-general-owner@postgresql.org Tue May 9 22:00:12 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C7C179FA261; + Tue, 9 May 2006 22:00:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 85565-03; Tue, 9 May 2006 21:59:59 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 470259F9DCD; + Tue, 9 May 2006 21:59:57 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k4A0xtK09977; + Tue, 9 May 2006 20:59:55 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200605100059.k4A0xtK09977@candle.pha.pa.us> +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +In-Reply-To: <4460DE97.9040001@commandprompt.com> +To: "Joshua D. Drake" +Date: Tue, 9 May 2006 20:59:55 -0400 (EDT) +CC: Vivek Khera , + "Pgsql-Performance ((E-mail))" , + PostgreSQL General +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/405 +X-Sequence-Number: 95197 + +Joshua D. Drake wrote: +> Vivek Khera wrote: +> > +> > On May 9, 2006, at 11:51 AM, Joshua D. Drake wrote: +> > +> >> Sorry that is an extremely misleading statement. SATA RAID is +> >> perfectly acceptable if you have a hardware raid controller with a +> >> battery backup controller. +> >> +> >> And dollar for dollar, SCSI will NOT be faster nor have the hard drive +> >> capacity that you will get with SATA. +> > +> > Does this hold true still under heavy concurrent-write loads? I'm +> > preparing yet another big DB server and if SATA is a better option, I'm +> > all (elephant) ears. +> +> I didn't say better :). If you can afford, SCSI is the way to go. +> However SATA with a good controller (I am fond of the LSI 150 series) +> can provide some great performance. + +Basically, you can get away with cheaper hardware, but it usually +doesn't have the reliability/performance of more expensive options. + +You want an in-depth comparison of how a server disk drive is internally +better than a desktop drive: + + http://www.seagate.com/content/docs/pdf/whitepaper/D2c_More_than_Interface_ATA_vs_SCSI_042003.pdf + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-general-owner@postgresql.org Tue May 9 22:03:06 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4F6649FA159; + Tue, 9 May 2006 22:03:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 84191-07; Tue, 9 May 2006 22:03:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 7632B9F9DCD; + Tue, 9 May 2006 22:02:59 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k4A12wa12853; + Tue, 9 May 2006 21:02:58 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200605100102.k4A12wa12853@candle.pha.pa.us> +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +In-Reply-To: <1147201448.9755.16.camel@state.g2switchworks.com> +To: Scott Marlowe +Date: Tue, 9 May 2006 21:02:58 -0400 (EDT) +CC: Steve Atkins , + PostgreSQL General , + "Pgsql-Performance ((E-mail))" +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/406 +X-Sequence-Number: 95198 + +Scott Marlowe wrote: +> Actually, in the case of the Escalades at least, the answer is yes. +> Last year (maybe a bit more) someone was testing an IDE escalade +> controller with drives that were known to lie, and it passed the power +> plug pull test repeatedly. Apparently, the escalades tell the drives to +> turn off their cache. While most all IDEs and a fair number of SATA +> drives lie about cache fsyncing, they all seem to turn off the cache +> when you ask. +> +> And, since a hardware RAID controller with bbu cache has its own cache, +> it's not like it really needs the one on the drives anyway. + +You do if the controller thinks the data is already on the drives and +removes it from its cache. + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Tue May 9 23:40:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6E19D9FA261 + for ; + Tue, 9 May 2006 23:40:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 04048-06 + for ; + Tue, 9 May 2006 23:40:09 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 2DE6C9F9DCD + for ; + Tue, 9 May 2006 23:40:08 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 28B183090B; Wed, 10 May 2006 04:40:07 +0200 (MET DST) +From: William Yu +X-Newsgroups: pgsql.performance +Subject: Re: Arguments Pro/Contra Software Raid +Date: Tue, 09 May 2006 19:39:53 -0700 +Organization: Hub.Org Networking Services +Lines: 15 +Message-ID: +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> + <5AF87D32-F602-4973-AA21-84E0CFEA1774@khera.org> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +User-Agent: Thunderbird 1.5 (X11/20051201) +In-Reply-To: +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/203 +X-Sequence-Number: 18990 + +William Yu wrote: +> We upgraded our disk system for our main data processing server earlier +> this year. After pricing out all the components, basically we had the +> choice of: +> +> LSI MegaRaid 320-2 w/ 1GB RAM+BBU + 8 15K 150GB SCSI +> +> or +> +> Areca 1124 w/ 1GB RAM+BBU + 24 7200RPM 250GB SATA + +My mistake -- I keep doing calculations and they don't add up. So I +looked again on pricewatch and it turns out the actual comparison was +for 4 SCSI drives, not 8! ($600 for a 15K 145GB versus $90 for a 7200 +250GB.) No wonder our decision seemed to much more decisive back then. + +From pgsql-performance-owner@postgresql.org Wed May 10 00:13:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B7D039FB3B2 + for ; + Wed, 10 May 2006 00:13:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 23382-01-4 + for ; + Wed, 10 May 2006 00:13:09 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wr-out-0506.google.com (wr-out-0506.google.com + [64.233.184.228]) + by postgresql.org (Postfix) with ESMTP id D03A69FB3B0 + for ; + Tue, 9 May 2006 23:59:20 -0300 (ADT) +Received: by wr-out-0506.google.com with SMTP id i20so1325412wra + for ; + Tue, 09 May 2006 19:59:19 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; + b=iUq7/vTTDobxi5xctggldWJTqn5p6R9HoB0VbKwmxkWVybLvIwAPlxZU4K1BLL/SKCC5+OG/xh58pN14bqfB/UUhJ8P+OBgqpEqSoN/bwzGZM9yFBv8JbJX4m5h97T552bSxQUkhbxZPQQVviwgzAzeJfXFvgJ+AdC/6bELFjxQ= +Received: by 10.65.145.18 with SMTP id x18mr92485qbn; + Tue, 09 May 2006 19:59:19 -0700 (PDT) +Received: by 10.65.177.7 with HTTP; Tue, 9 May 2006 19:59:19 -0700 (PDT) +Message-ID: +Date: Wed, 10 May 2006 12:59:19 +1000 +From: "Shoaib Burq" +To: pgsql-performance@postgresql.org +Subject: UNSUBSCRIBE +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Google-Sender-Auth: 39557acdb26b8eab +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/215 +X-Sequence-Number: 19002 + +UNSUBSCRIBE + +From pgsql-performance-owner@postgresql.org Wed May 10 00:15:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8A9A09FB20F + for ; + Wed, 10 May 2006 00:15:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 23754-01-9 + for ; + Wed, 10 May 2006 00:15:10 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx.sat.rackspace.com (mx.sat.rackspace.com [64.39.1.214]) + by postgresql.org (Postfix) with ESMTP id 725709FB3D8 + for ; + Wed, 10 May 2006 00:03:15 -0300 (ADT) +Received: from mail.rackspace.com (mail.rackspace.com [64.39.2.181]) + by mx.sat.rackspace.com (8.13.6/8.13.6) with ESMTP id k4A33EcE024432 + for ; Tue, 9 May 2006 22:03:14 -0500 + (envelope-from wreese@rackspace.com) +Received: from [192.168.10.8] (vpn113-67.sat.rackspace.com [10.1.113.67]) + (authenticated bits=0) + by mail.rackspace.com (8.13.1/8.13.1) with ESMTP id k4A33CiD027291 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NO) + for ; Tue, 9 May 2006 22:03:13 -0500 +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <1147167570.494108.284720@i39g2000cwa.googlegroups.com> +References: <1147167570.494108.284720@i39g2000cwa.googlegroups.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <6EAB7E4D-59BC-42B7-93E8-3EE82AE9E4F0@rackspace.com> +Content-Transfer-Encoding: 7bit +From: Will Reese +Subject: Re: PostgreSQL VACCUM killing CPU +Date: Tue, 9 May 2006 22:03:12 -0500 +To: PostgreSQL Performance +X-Mailer: Apple Mail (2.749.3) +X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='__CP_URI_IN_BODY 0, + __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, + __HAS_X_MAILER 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, + __SANE_MSGID 0' +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/216 +X-Sequence-Number: 19003 + +The "wa" means waiting on IO. Vacuum is a very IO intensive +process. You can use tools like vmstat and iostat to see how much +disk IO is occurring. Also, sar is very helpful for trending these +values over time. + +-- Will Reese http://blog.rezra.com +On May 9, 2006, at 5:19 AM, blender@jaskom.pl wrote: + +> Hi all ! +> +> I have got such problem. +> Im running Postgresql 7.3.2 on Linux 2.6.13. +> What is see when VACCUM is running and killing my CPU is: +> +> Cpu(s): 3.2% us, 0.0% sy, 0.0% ni, 0.0% id, 96.8% wa, 0.0% hi, +> 0.0% si +> +> what i am worry about is "96.8% wa" why is it like that? +> +> what is the process waiting for ? +> +> could somone explain me that please? :) +> +> Best regards +> david +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings + + +From pgsql-performance-owner@postgresql.org Wed May 10 00:28:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5B29D9FABE7 + for ; + Wed, 10 May 2006 00:28:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27314-01 + for ; + Wed, 10 May 2006 00:28:02 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.201]) + by postgresql.org (Postfix) with ESMTP id 93D729FB1D1 + for ; + Wed, 10 May 2006 00:20:56 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id k1so1578235nzf + for ; + Tue, 09 May 2006 20:20:55 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; + b=lGpDpv0VAU15ygdJmhJOH7Fr1XitrIbtkBy4BvDUMbc9vALeTjphEGzT2FDdoxXRlQVpsAFMCnWyeAovO+vclmo2Pp++CDJtS1COWUZAKYDdobAZtZhPP5HKxl/IWZmjFJZaOj1k0t02/B2Lu7JCGm7kn1kbWSqyFepbBawvVCI= +Received: by 10.37.20.49 with SMTP id x49mr6281162nzi; + Tue, 09 May 2006 20:20:55 -0700 (PDT) +Received: from ?10.1.1.21? ( [203.217.18.65]) + by mx.gmail.com with ESMTP id 36sm834612nzk.2006.05.09.20.20.54; + Tue, 09 May 2006 20:20:55 -0700 (PDT) +Message-ID: <44615C15.5040803@gmail.com> +Date: Wed, 10 May 2006 13:20:53 +1000 +From: Chris +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: UNSUBSCRIBE +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/217 +X-Sequence-Number: 19004 + +Shoaib Burq wrote: +> UNSUBSCRIBE + +To unsubscribe: + +List-Unsubscribe: + + + +Email admins - Could we add this above or below the random tips that get +appended to every email ? + +-- +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-performance-owner@postgresql.org Wed May 10 00:29:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9D5CE9FA22C + for ; + Wed, 10 May 2006 00:29:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27602-03-5 + for ; + Wed, 10 May 2006 00:29:44 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 895FD9FA261 + for ; + Wed, 10 May 2006 00:29:44 -0300 (ADT) +Received: from grzm.com (grzm.com [200.46.204.98]) + by svr4.postgresql.org (Postfix) with ESMTP id BD2985B59C6 + for ; + Wed, 10 May 2006 03:26:47 +0000 (GMT) +Received: from [172.16.1.101] (unknown [61.197.227.146]) + by grzm.com (Postfix) with ESMTP id 321F8161B93B; + Wed, 10 May 2006 04:26:45 +0100 (BST) +In-Reply-To: <6EAB7E4D-59BC-42B7-93E8-3EE82AE9E4F0@rackspace.com> +References: <1147167570.494108.284720@i39g2000cwa.googlegroups.com> + <6EAB7E4D-59BC-42B7-93E8-3EE82AE9E4F0@rackspace.com> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <068FA494-4DC0-4ECD-9876-408A535D3430@seespotcode.net> +Cc: PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Michael Glaesemann +Subject: Re: PostgreSQL VACCUM killing CPU +Date: Wed, 10 May 2006 12:24:55 +0900 +To: Will Reese +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/219 +X-Sequence-Number: 19006 + + +>> I have got such problem. +>> Im running Postgresql 7.3.2 on Linux 2.6.13. + +Also, you should seriously consider upgrading. 8.1.3 is the current +PostgreSQL release. If you must remain on 7.3, at least upgrade to +7.3.14, which contains many bugfixes. + +Michael Glaesemann +grzm seespotcode net + + + + +From pgsql-performance-owner@postgresql.org Wed May 10 00:29:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1DFCF9F9DCD + for ; + Wed, 10 May 2006 00:29:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27594-01-8 + for ; + Wed, 10 May 2006 00:29:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 6B1F39FAA6E + for ; + Wed, 10 May 2006 00:29:45 -0300 (ADT) +Received: from grzm.com (grzm.com [200.46.204.98]) + by svr4.postgresql.org (Postfix) with ESMTP id 41F805B5AFA + for ; + Wed, 10 May 2006 03:28:29 +0000 (GMT) +Received: from [172.16.1.101] (unknown [61.197.227.146]) + by grzm.com (Postfix) with ESMTP id 03E44161B93B; + Wed, 10 May 2006 04:28:27 +0100 (BST) +In-Reply-To: <6EAB7E4D-59BC-42B7-93E8-3EE82AE9E4F0@rackspace.com> +References: <1147167570.494108.284720@i39g2000cwa.googlegroups.com> + <6EAB7E4D-59BC-42B7-93E8-3EE82AE9E4F0@rackspace.com> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <5DA16A92-244D-4F2F-8A0D-E64422575EC8@seespotcode.net> +Cc: PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Michael Glaesemann +Subject: Re: PostgreSQL VACCUM killing CPU +Date: Wed, 10 May 2006 12:28:24 +0900 +To: blender@jaskom.pl +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/218 +X-Sequence-Number: 19005 + + +>> I have got such problem. +>> Im running Postgresql 7.3.2 on Linux 2.6.13. + +Also, you should seriously consider upgrading. 8.1.3 is the current +PostgreSQL release. If you must remain on 7.3, at least upgrade to +7.3.14, which contains *many* bugfixes. + +Michael Glaesemann +grzm seespotcode net + + + + +From pgsql-general-owner@postgresql.org Wed May 10 00:59:08 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0AC2E9F9C18; + Wed, 10 May 2006 00:59:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27571-07; Wed, 10 May 2006 00:59:03 -0300 (ADT) +X-Greylist: delayed 00:21:52.200623 by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from calvin.slamb.org (calvin.slamb.org [216.136.66.56]) + by postgresql.org (Postfix) with ESMTP id 14CCE9F931E; + Wed, 10 May 2006 00:59:01 -0300 (ADT) +Received: by calvin.slamb.org (Postfix, from userid 103) + id C845F6FE29; Tue, 9 May 2006 22:37:08 -0500 (CDT) +Received: from [172.16.0.3] (slamb-laptop.vpn.slamb.org [172.16.0.3]) + by calvin.slamb.org (Postfix) with ESMTP + id C6EFA6FDD6; Tue, 9 May 2006 22:37:07 -0500 (CDT) +In-Reply-To: <4460DED4.2090103@commandprompt.com> +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> + <4F853BBA-175C-4B3E-BAF4-AA34B80DF6EF@blighty.com> + <4460DED4.2090103@commandprompt.com> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <7779142C-B027-4C17-A67C-A7C220AADF80@slamb.org> +Cc: Steve Atkins , + PostgreSQL General , + "Pgsql-Performance ((E-mail))" +Content-Transfer-Encoding: 7bit +From: Scott Lamb +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +Date: Tue, 9 May 2006 20:37:14 -0700 +To: Joshua D.Drake +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/409 +X-Sequence-Number: 95201 + +On May 9, 2006, at 11:26 AM, Joshua D. Drake wrote: +> Of course not, but which drives lie about sync that are SATA? Or +> more specifically SATA-II? + +I don't know the answer to this question, but have you seen this tool? + + http://brad.livejournal.com/2116715.html + +It attempts to experimentally determine if, with your operating +system version, controller, and hard disk, fsync() does as claimed. +Of course, experimentation can't prove the system is correct, but it +can sometimes prove the system is broken. + +I say it's worth running on any new model of disk, any new +controller, or after the Linux kernel people rewrite everything (i.e. +on every point release). + +I have to admit to hypocrisy, though...I'm running with systems that +other people ordered and installed, I doubt they were this thorough, +and I don't have identical hardware to run tests on. So no real way +to do this. + +Regards, +Scott + +-- +Scott Lamb + + + +From pgsql-performance-owner@postgresql.org Wed May 10 00:52:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 67FD19FA159 + for ; + Wed, 10 May 2006 00:52:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 28942-04 + for ; + Wed, 10 May 2006 00:52:11 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id B01E99F9DCD + for ; + Wed, 10 May 2006 00:52:10 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4A3q9g7025877; + Tue, 9 May 2006 23:52:09 -0400 (EDT) +To: "Adam Palmblad" +cc: pgsql-performance@postgresql.org +Subject: Re: Slow C Function +In-reply-to: <6B5AF6293A289F45826220B17ABE79370D5F4C@BORON.aers.local> +References: <6B5AF6293A289F45826220B17ABE79370D5F4C@BORON.aers.local> +Comments: In-reply-to "Adam Palmblad" + message dated "Tue, 09 May 2006 14:57:09 -0700" +Date: Tue, 09 May 2006 23:52:09 -0400 +Message-ID: <25876.1147233129@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/220 +X-Sequence-Number: 19007 + +"Adam Palmblad" writes: +> We've got a C function that we use here and we find that for every +> connection, the first run of the function is much slower than any +> subsequent runs. ( 50ms compared to 8ms) + +Perhaps that represents the time needed to load the dynamic library +into the backend? If so, the "preload_libraries" parameter might +help you fix it. Or consider pooling connections. Or build a custom +executable with the function linked in permanently. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed May 10 01:08:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9F0659FA4F1 + for ; + Wed, 10 May 2006 01:08:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27732-07 + for ; + Wed, 10 May 2006 01:08:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from skynet.simkin.ca (skynet.simkin.ca [199.175.137.210]) + by postgresql.org (Postfix) with ESMTP id C23899FA4E1 + for ; + Wed, 10 May 2006 01:08:45 -0300 (ADT) +Received: from charon.medialogik.com (S0106000c6eb33e73.vf.shawcable.net + [70.68.174.20]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by skynet.simkin.ca (Postfix) with ESMTP id 5FA9E106DC + for ; + Tue, 9 May 2006 21:08:43 -0700 (PDT) +From: Alan Hodgson +Organization: Simkin Network Consulting +To: pgsql-performance@postgresql.org +Subject: Re: VACUUM killing my CPU +Date: Tue, 9 May 2006 21:08:33 -0700 +User-Agent: KMail/1.8.3 +References: <1147167937.749400.182820@u72g2000cwu.googlegroups.com> +In-Reply-To: <1147167937.749400.182820@u72g2000cwu.googlegroups.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200605092108.33329@hal.medialogik.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/222 +X-Sequence-Number: 19009 + +On May 9, 2006 02:45 am, blender@jaskom.pl wrote: +> What I am worry about is "93.5% wa" ... +> +> Could someone explain me what is the VACUUM process waiting for ? +> + +Disk I/O. + +-- +In a truly free society, "Alcohol, Tobacco and Firearms" would be a +convenience store chain. + + +From pgsql-performance-owner@postgresql.org Wed May 10 04:08:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9CE769F96B6 + for ; + Wed, 10 May 2006 04:08:42 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 49938-08 + for ; + Wed, 10 May 2006 04:08:33 -0300 (ADT) +X-Greylist: delayed 02:50:00.904061 by SQLgrey- +Received: from mail2.mailhostingservice.com (mail2.mailhostingservice.com + [216.154.198.172]) + by postgresql.org (Postfix) with SMTP id 8DE679F931D + for ; + Wed, 10 May 2006 04:08:33 -0300 (ADT) +Received: From [192.168.2.24] (203.144.16.126) by mail1.mailhostingservice.com + Id + <56d3d4d31ab0626880d3f83c8627be8c027c4c82@mail1.mailhostingservice.com> + ; Wed, 10 May 2006 04:19:27 +0000 +Message-ID: <44616987.3030900@wildcash.com> +Date: Wed, 10 May 2006 14:18:15 +1000 +From: Rudi Starcevic +User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; + rv:1.7.12) Gecko/20050915 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: VACUUM killing my CPU +References: <1147167937.749400.182820@u72g2000cwu.googlegroups.com> + <200605092108.33329@hal.medialogik.com> +In-Reply-To: <200605092108.33329@hal.medialogik.com> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/230 +X-Sequence-Number: 19017 + +Hi, + +>>What I am worry about is "93.5% wa" ... +>> +>>Could someone explain me what is the VACUUM process waiting for ? +>> +> +> +> Disk I/O. +> + +CPU +wa: Time spent waiting for IO. Prior to Linux 2.5.41, shown as zero. + +Just a little more info to help understand what Alan has pointed out. + +Your CPU processes are waiting on the HDD ... + +HTH + +-- +Regards, +Rudi + + +From pgsql-general-owner@postgresql.org Wed May 10 01:41:35 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A394B9F96B6; + Wed, 10 May 2006 01:41:35 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 37277-01; Wed, 10 May 2006 01:41:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id 5B9549F931D; + Wed, 10 May 2006 01:41:31 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1FdgVl-0004nU-00; Wed, 10 May 2006 00:41:21 -0400 +To: Douglas McNaught +Cc: Vivek Khera , + "Pgsql-Performance ((E-mail))" , + PostgreSQL General +Subject: Re: Arguments Pro/Contra Software Raid +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> + <5AF87D32-F602-4973-AA21-84E0CFEA1774@khera.org> + <87mzdroyzb.fsf@suzuka.mcnaught.org> +In-Reply-To: <87mzdroyzb.fsf@suzuka.mcnaught.org> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 10 May 2006 00:41:20 -0400 +Message-ID: <8764kexzin.fsf@stark.xeocode.com> +Lines: 20 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/416 +X-Sequence-Number: 95208 + +Douglas McNaught writes: + +> Vivek Khera writes: +> +> > On May 9, 2006, at 11:51 AM, Joshua D. Drake wrote: +> > +> >> And dollar for dollar, SCSI will NOT be faster nor have the hard +> >> drive capacity that you will get with SATA. +> > +> > Does this hold true still under heavy concurrent-write loads? I'm +> > preparing yet another big DB server and if SATA is a better option, +> > I'm all (elephant) ears. +> +> Correct me if I'm wrong, but I've never heard of a 15kRPM SATA drive. + +Well, dollar for dollar you would get the best performance from slower drives +anyways since it would give you more spindles. 15kRPM drives are *expensive*. + +-- +greg + + +From pgsql-general-owner@postgresql.org Wed May 10 01:50:42 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 012A49FA425; + Wed, 10 May 2006 01:50:42 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 35251-09; Wed, 10 May 2006 01:50:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id EA0C89F931D; + Wed, 10 May 2006 01:50:33 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1Fdgea-0004sm-00; Wed, 10 May 2006 00:50:28 -0400 +To: Steve Atkins +Cc: PostgreSQL General , + "Pgsql-Performance ((E-mail))" +Subject: Re: Arguments Pro/Contra Software Raid +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> +In-Reply-To: <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 10 May 2006 00:50:28 -0400 +Message-ID: <87zmhqwkiz.fsf@stark.xeocode.com> +Lines: 36 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/417 +X-Sequence-Number: 95209 + + +Steve Atkins writes: + +> On May 9, 2006, at 2:16 AM, Hannes Dorbath wrote: +> +> > Hi, +> > +> > I've just had some discussion with colleagues regarding the usage of +> > hardware or software raid 1/10 for our linux based database servers. +> > +> > I myself can't see much reason to spend $500 on high end controller cards +> > for a simple Raid 1. +> > +> > Any arguments pro or contra would be desirable. + +Really most of what's said about software raid vs hardware raid online is just +FUD. Unless you're running BIG servers with so many drives that the raid +controllers are the only feasible way to connect them up anyways, the actual +performance difference will likely be negligible. + +The only two things that actually make me pause about software RAID in heavy +production use are: + +1) Battery backed cache. That's a huge win for the WAL drives on Postgres. + 'nuff said. + +2) Not all commodity controllers or IDE drivers can handle failing drives + gracefully. While the software raid might guarantee that you don't actually + lose data, you still might have the machine wedge because of IDE errors on + the bad drive. So as far as runtime, instead of added reliability all + you've really added is another point of failure. On the data integrity + front you'll still be better off. + + +-- +Greg + + +From pgsql-performance-owner@postgresql.org Wed May 10 02:15:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A0AD29F96B6 + for ; + Wed, 10 May 2006 02:15:19 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 40333-01 + for ; + Wed, 10 May 2006 02:15:15 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 4C67A9F931D + for ; + Wed, 10 May 2006 02:15:14 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4A5FBqp026505; + Wed, 10 May 2006 01:15:11 -0400 (EDT) +To: Chris +cc: pgsql-performance@postgresql.org +Subject: Re: UNSUBSCRIBE +In-reply-to: <44615C15.5040803@gmail.com> +References: + <44615C15.5040803@gmail.com> +Comments: In-reply-to Chris + message dated "Wed, 10 May 2006 13:20:53 +1000" +Date: Wed, 10 May 2006 01:15:11 -0400 +Message-ID: <26504.1147238111@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/225 +X-Sequence-Number: 19012 + +Chris writes: +> Email admins - Could we add this above or below the random tips that get +> appended to every email ? + +You mean like these headers that already get added to every list +message (these copied-and-pasted from your own message): + +List-help: +List-owner: +List-subscribe: +List-unsubscribe: + +Plus there are at least two of the "random tips" that deal with how to +unsubscribe. My feeling is that the people who can't figure this out +still won't figure it out, no matter how thick the cluebat we swing at +them :-( + +Maybe the real problem is at the other end of the process, ie we should +require some evidence of a greater-than-room-temp IQ to subscribe in the +first place? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed May 10 02:22:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 28F139F96B6 + for ; + Wed, 10 May 2006 02:22:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 38722-07 + for ; + Wed, 10 May 2006 02:22:10 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.201]) + by postgresql.org (Postfix) with ESMTP id 3CFA99F931D + for ; + Wed, 10 May 2006 02:22:09 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id k1so1594764nzf + for ; + Tue, 09 May 2006 22:22:09 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; + b=qSZ43mKjYWb8Arjc/00I9Xq4MqN/9pIfEBSZ56WV4BMdK8/jzpMHfr4LMrpnRMRKHrWRfloZNNTHghhGWfEZv/EUPWLkvxL9Ou1B/HT5s6gkXHtQi8Q1pQbaadxFAtZNHIceAyw8YmV65xSGH2D/IrB0VB5PvWiCOBXC0HNGb9M= +Received: by 10.37.14.13 with SMTP id r13mr113949nzi; + Tue, 09 May 2006 22:22:08 -0700 (PDT) +Received: from ?10.1.1.21? ( [203.217.18.65]) + by mx.gmail.com with ESMTP id 20sm7527704nzp.2006.05.09.22.22.06; + Tue, 09 May 2006 22:22:07 -0700 (PDT) +Message-ID: <4461787C.3010705@gmail.com> +Date: Wed, 10 May 2006 15:22:04 +1000 +From: Chris +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +CC: pgsql-performance@postgresql.org +Subject: Re: UNSUBSCRIBE +References: + <44615C15.5040803@gmail.com> <26504.1147238111@sss.pgh.pa.us> +In-Reply-To: <26504.1147238111@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/226 +X-Sequence-Number: 19013 + +Tom Lane wrote: +> Chris writes: +> +>>Email admins - Could we add this above or below the random tips that get +>>appended to every email ? +> +> +> You mean like these headers that already get added to every list +> message (these copied-and-pasted from your own message): + +The headers aren't the first place you'd go looking for such info.. once +you know they are there it's ok. + +> Maybe the real problem is at the other end of the process, ie we should +> require some evidence of a greater-than-room-temp IQ to subscribe in the +> first place? + +Maybe :) The php-general list has + +To unsubscribe, visit: http://www.php.net/unsub.php + +at the bottom of every email, and there are still random unsubscribe +requests.. + +Ah well :) + +-- +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-performance-owner@postgresql.org Wed May 10 02:43:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BC6259F96B6 + for ; + Wed, 10 May 2006 02:43:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 43390-03 + for ; + Wed, 10 May 2006 02:43:02 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 2DBAB9F931D + for ; + Wed, 10 May 2006 02:43:01 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4A5gwgH026693; + Wed, 10 May 2006 01:42:58 -0400 (EDT) +To: Chris +cc: pgsql-performance@postgresql.org +Subject: Re: UNSUBSCRIBE +In-reply-to: <4461787C.3010705@gmail.com> +References: + <44615C15.5040803@gmail.com> <26504.1147238111@sss.pgh.pa.us> + <4461787C.3010705@gmail.com> +Comments: In-reply-to Chris + message dated "Wed, 10 May 2006 15:22:04 +1000" +Date: Wed, 10 May 2006 01:42:58 -0400 +Message-ID: <26692.1147239778@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/227 +X-Sequence-Number: 19014 + +Chris writes: +> Tom Lane wrote: +>> Maybe the real problem is at the other end of the process, ie we should +>> require some evidence of a greater-than-room-temp IQ to subscribe in the +>> first place? + +> Maybe :) The php-general list has + +> To unsubscribe, visit: http://www.php.net/unsub.php + +> at the bottom of every email, and there are still random unsubscribe +> requests.. + +That's depressing, indeed :-( + +I'm not against spending a little bandwidth to provide unsub +instructions, but somehow I can't see putting an 8x10 color glossy +photograph with circles and arrows and a paragraph on the back [1] +of every list message to do it. + + regards, tom lane + +[1] http://www.guntheranderson.com/v/data/alicesre.htm + +From pgsql-performance-owner@postgresql.org Wed May 10 03:14:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9813B9FA425 + for ; + Wed, 10 May 2006 03:14:19 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 43380-09 + for ; + Wed, 10 May 2006 03:14:14 -0300 (ADT) +X-Greylist: delayed 02:47:24.873126 by SQLgrey- +Received: from grzm.com (grzm.com [200.46.204.98]) + by postgresql.org (Postfix) with ESMTP id 75E3D9F96B6 + for ; + Wed, 10 May 2006 03:14:14 -0300 (ADT) +Received: from [172.16.1.101] (unknown [61.197.227.146]) + by grzm.com (Postfix) with ESMTP id 655C5161B93B; + Wed, 10 May 2006 07:14:12 +0100 (BST) +In-Reply-To: <26692.1147239778@sss.pgh.pa.us> +References: + <44615C15.5040803@gmail.com> <26504.1147238111@sss.pgh.pa.us> + <4461787C.3010705@gmail.com> <26692.1147239778@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <7AA3D75C-4821-4B78-A3F7-4ED94B8F85C2@seespotcode.net> +Cc: Chris , + pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Michael Glaesemann +Subject: Re: UNSUBSCRIBE +Date: Wed, 10 May 2006 15:14:08 +0900 +To: Tom Lane +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/228 +X-Sequence-Number: 19015 + + +On May 10, 2006, at 14:42 , Tom Lane wrote: + +> Chris writes: +> +>> Maybe :) The php-general list has +> +>> To unsubscribe, visit: http://www.php.net/unsub.php +> +>> at the bottom of every email, and there are still random unsubscribe +>> requests.. + +That will *always* happen. Just human nature and the numbers of +subscribers. However, a one-liner that either points to the webpage +for unsubscribing (probably easiest) or a brief description on how to +unsubscribe (To unsubscribe, send an email to +majordomo@postgresql.org with body "unsub pgsql-performance" (without +quotes)) may intercept a few more. Is there a way to configure +Majordomo to make even easier to unsubscribe? Just sending to pgsql- +performance-unsubscribe@postgresql.org or some such? I've seen other +mailing lists that do this. Requiring a specific command (what's the +command? in the subject or the body?) is one more place a person can +make a mistake. (I've recently switched mail accounts and unsubbed/ +subbed from the lists I'm on. This latter style does make it a lot +easier.) + +(And are there mail readers out there that can pick those subscribe/ +unsubscribe headers from the list emails? Now *that'd* be sweet.) + +Michael Glaesemann +grzm seespotcode net + + + + +From pgsql-general-owner@postgresql.org Wed May 10 03:49:09 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7178C9F96B6 + for ; + Wed, 10 May 2006 03:49:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 47206-10 + for ; + Wed, 10 May 2006 03:49:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id B11A49F931D + for ; + Wed, 10 May 2006 03:49:02 -0300 (ADT) +Received: (qmail 20828 invoked from network); 10 May 2006 08:50:24 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 10 May 2006 08:50:24 +0200 +Date: Wed, 10 May 2006 08:50:22 +0200 +To: 7ukwn@free.fr, "Hannes Dorbath" +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org +References: <44606A98.4090705@free.fr> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <44606A98.4090705@free.fr> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/418 +X-Sequence-Number: 95210 + + +> 2b- LARGE UPS because HDs are the components that have the higher power +> consomption (a 700VA UPS gives me about 10-12 minutes on a machine +> with a XP2200+, 1GB RAM and a 40GB HD, however this fall to...... +> less than 25 secondes with seven HDs ! all ATA), + + I got my hands on a (free) 1400 VA APC rackmount UPS ; the batteries were +dead so I stuck two car batteries in. It can power my computer (Athlon 64, +7 drives) for more than 2 hours... + It looks ugly though. I wouldn't put this in a server rack, but for my +home PC it's perfect. It has saved my work many times... + + Harddisks suck in about 15 watts each, but draw large current spikes on +seeking, so the VA rating of the UPS is important. I guess in your case, +the batteries have enough charge left; but the current capability of the +UPS is exceeded. + +> Some hardware ctrlrs are able to avoid the loss of a disk if you turn +> to have some faulty sectors (by relocating internally them); software +> RAID doesn't as sectors *must* be @ the same (linear) addresses. + + Harddisks do transparent remapping now... linux soft raid can rewrite bad +sectors with good data and the disk will remap the faulty sector to a good +one. + + + +From pgsql-performance-owner@postgresql.org Wed May 10 06:18:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AB2EE9FA425 + for ; + Wed, 10 May 2006 06:18:48 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 68703-07 + for ; + Wed, 10 May 2006 06:18:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from h57078.serverkompetenz.net (talk-net.net [81.169.128.8]) + by postgresql.org (Postfix) with ESMTP id 530E09F96B6 + for ; + Wed, 10 May 2006 06:18:39 -0300 (ADT) +Received: from [192.168.115.250] (e178141156.adsl.alicedsl.de + [85.178.141.156]) + by h57078.serverkompetenz.net (Postfix) with ESMTP id EECF650C5CB + for ; + Wed, 10 May 2006 11:17:02 +0200 (CEST) +Message-ID: <4461AFFF.7060200@network-inventory.de> +Date: Wed, 10 May 2006 11:18:55 +0200 +From: Thomas Vatter +User-Agent: Mozilla Thunderbird 1.0.5 (Windows/20050711) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: in memory views +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/231 +X-Sequence-Number: 19018 + +is there a possibility for creating views or temp tables in memory to +avoid disk io when user makes select operations? + +regards +tom + + +From pgsql-performance-owner@postgresql.org Wed May 10 06:36:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5E1229FA425 + for ; + Wed, 10 May 2006 06:36:12 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 71088-04 + for ; + Wed, 10 May 2006 06:35:59 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from service-web.de (p15093784.pureserver.info [217.160.106.224]) + by postgresql.org (Postfix) with ESMTP id B0C4A9F96B6 + for ; + Wed, 10 May 2006 06:35:59 -0300 (ADT) +Received: from [10.100.1.50] (074-016-066-080.eggenet.de [80.66.16.74]) + by service-web.de (Postfix) with ESMTP id A6B2320002F; + Wed, 10 May 2006 11:35:57 +0200 (CEST) +Message-ID: <4461B3DE.6030700@wildenhain.de> +Date: Wed, 10 May 2006 11:35:26 +0200 +From: Tino Wildenhain +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050929) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: Thomas Vatter +Cc: pgsql-performance@postgresql.org +Subject: Re: in memory views +References: <4461AFFF.7060200@network-inventory.de> +In-Reply-To: <4461AFFF.7060200@network-inventory.de> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/232 +X-Sequence-Number: 19019 + +Thomas Vatter schrieb: +> is there a possibility for creating views or temp tables in memory to +> avoid disk io when user makes select operations? + +No need. The data will be available in OS and database caches if +they are really required often. If not, tune up the caches and +do a regular "pre select". + +Regards +Tino + +From pgsql-performance-owner@postgresql.org Wed May 10 06:55:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 807229FA425 + for ; + Wed, 10 May 2006 06:55:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 70966-10 + for ; + Wed, 10 May 2006 06:55:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from h57078.serverkompetenz.net (talk-net.net [81.169.128.8]) + by postgresql.org (Postfix) with ESMTP id C20359F931D + for ; + Wed, 10 May 2006 06:55:21 -0300 (ADT) +Received: from [192.168.115.250] (e178141156.adsl.alicedsl.de + [85.178.141.156]) + by h57078.serverkompetenz.net (Postfix) with ESMTP id 5BDCA50C727; + Wed, 10 May 2006 11:53:44 +0200 (CEST) +Message-ID: <4461B899.4030502@network-inventory.de> +Date: Wed, 10 May 2006 11:55:37 +0200 +From: Thomas Vatter +User-Agent: Mozilla Thunderbird 1.0.5 (Windows/20050711) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tino Wildenhain +CC: pgsql-performance@postgresql.org +Subject: Re: in memory views +References: <4461AFFF.7060200@network-inventory.de> + <4461B3DE.6030700@wildenhain.de> +In-Reply-To: <4461B3DE.6030700@wildenhain.de> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/233 +X-Sequence-Number: 19020 + +Tino Wildenhain wrote: + +> Thomas Vatter schrieb: +> +>> is there a possibility for creating views or temp tables in memory to +>> avoid disk io when user makes select operations? +> +> +> No need. The data will be available in OS and database caches if +> they are really required often. If not, tune up the caches and +> do a regular "pre select". +> +> Regards +> Tino +> +> + +hmm, I am selecting a resultset with 1300 rows joined from 12 tables. +with jdbc I am waiting 40 seconds until the first row appears. The +following rows appear really fast but the 40 seconds are a problem. + +regards +tom + + +From pgsql-performance-owner@postgresql.org Wed May 10 07:09:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B85709FA4EA + for ; + Wed, 10 May 2006 07:09:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 72905-06 + for ; + Wed, 10 May 2006 07:09:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from service-web.de (p15093784.pureserver.info [217.160.106.224]) + by postgresql.org (Postfix) with ESMTP id 2D6E29FA4DE + for ; + Wed, 10 May 2006 07:09:00 -0300 (ADT) +Received: from [10.100.1.50] (074-016-066-080.eggenet.de [80.66.16.74]) + by service-web.de (Postfix) with ESMTP id 4078720002F; + Wed, 10 May 2006 12:08:59 +0200 (CEST) +Message-ID: <4461BB9E.5030607@wildenhain.de> +Date: Wed, 10 May 2006 12:08:30 +0200 +From: Tino Wildenhain +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050929) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: Thomas Vatter +Cc: pgsql-performance@postgresql.org +Subject: Re: in memory views +References: <4461AFFF.7060200@network-inventory.de> + <4461B3DE.6030700@wildenhain.de> + <4461B899.4030502@network-inventory.de> +In-Reply-To: <4461B899.4030502@network-inventory.de> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/234 +X-Sequence-Number: 19021 + +Thomas Vatter schrieb: +> Tino Wildenhain wrote: +> +>> Thomas Vatter schrieb: +>> +>>> is there a possibility for creating views or temp tables in memory to +>>> avoid disk io when user makes select operations? +>> +>> +>> +>> No need. The data will be available in OS and database caches if +>> they are really required often. If not, tune up the caches and +>> do a regular "pre select". +>> +>> Regards +>> Tino +>> +>> +> +> hmm, I am selecting a resultset with 1300 rows joined from 12 tables. +> with jdbc I am waiting 40 seconds until the first row appears. The +> following rows appear really fast but the 40 seconds are a problem. + +Well you will need the equally 40 seconds to fill your hypothetical +in memory table. (even a bit more due to the creation of a datastructure). + +So you can do the aproaches of semi materialized views (that are in fact +writing into a shadow table) or just prefetch your data at time - just +at the times you would refill your memory tables if they existed. +A cronjob with select/fetch should do. + +Regards +Tino + +From pgsql-performance-owner@postgresql.org Wed May 10 07:43:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 64E579FA1B0 + for ; + Wed, 10 May 2006 07:43:24 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 74974-09 + for ; + Wed, 10 May 2006 07:43:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from h57078.serverkompetenz.net (talk-net.net [81.169.128.8]) + by postgresql.org (Postfix) with ESMTP id 96C309FA2FA + for ; + Wed, 10 May 2006 07:43:13 -0300 (ADT) +Received: from [192.168.115.250] (e178141156.adsl.alicedsl.de + [85.178.141.156]) + by h57078.serverkompetenz.net (Postfix) with ESMTP id 2E6E950C75B; + Wed, 10 May 2006 12:41:36 +0200 (CEST) +Message-ID: <4461C3D0.4060504@network-inventory.de> +Date: Wed, 10 May 2006 12:43:28 +0200 +From: Thomas Vatter +User-Agent: Mozilla Thunderbird 1.0.5 (Windows/20050711) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tino Wildenhain +CC: pgsql-performance@postgresql.org +Subject: Re: in memory views +References: <4461AFFF.7060200@network-inventory.de> + <4461B3DE.6030700@wildenhain.de> + <4461B899.4030502@network-inventory.de> + <4461BB9E.5030607@wildenhain.de> +In-Reply-To: <4461BB9E.5030607@wildenhain.de> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/235 +X-Sequence-Number: 19022 + +Tino Wildenhain wrote: + +> Thomas Vatter schrieb: +> +>> Tino Wildenhain wrote: +>> +>>> Thomas Vatter schrieb: +>>> +>>>> is there a possibility for creating views or temp tables in memory +>>>> to avoid disk io when user makes select operations? +>>> +>>> +>>> +>>> +>>> No need. The data will be available in OS and database caches if +>>> they are really required often. If not, tune up the caches and +>>> do a regular "pre select". +>>> +>>> Regards +>>> Tino +>>> +>>> +>> +>> hmm, I am selecting a resultset with 1300 rows joined from 12 tables. +>> with jdbc I am waiting 40 seconds until the first row appears. The +>> following rows appear really fast but the 40 seconds are a problem. +> +> +> Well you will need the equally 40 seconds to fill your hypothetical +> in memory table. (even a bit more due to the creation of a +> datastructure). +> +> So you can do the aproaches of semi materialized views (that are in fact +> writing into a shadow table) or just prefetch your data at time - just +> at the times you would refill your memory tables if they existed. +> A cronjob with select/fetch should do. +> +> Regards +> Tino +> +> + +If the in memory table is created a bootup time of the dbms it is +already present when user selects the data. Of course the challenge is +to keep the in memory table up to date if data are changed. What do you +mean with semi materialized views, I have tried select * from this_view +with the same result. Also, if I repeat the query it does not run faster. + +regards +tom + +-- +Mit freundlichen Gr��en / Regards +Vatter + +Network Inventory Software +Sun Microsystems Principal Partner + +www.network-inventory.de +Tel. 030-79782510 +E-Mail thomas.vatter@network-inventory.de + + +From pgsql-performance-owner@postgresql.org Wed May 10 08:12:45 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4B3689FA2FA + for ; + Wed, 10 May 2006 08:12:45 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 80921-04 + for ; + Wed, 10 May 2006 08:12:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 54CE59FA1B0 + for ; + Wed, 10 May 2006 08:12:38 -0300 (ADT) +Received: from mail.digame.de (mail.digame.de [80.148.11.250]) + by svr4.postgresql.org (Postfix) with SMTP id 531865B2BAF + for ; + Wed, 10 May 2006 11:12:36 +0000 (GMT) +Received: from ATLANTIK-CL.intern.digame.de ([192.168.10.181] RDNS failed) by + mail.digame.de with Microsoft SMTPSVC(6.0.3790.1830); + Wed, 10 May 2006 13:12:32 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: in memory views +Date: Wed, 10 May 2006 13:12:32 +0200 +Message-ID: + <84AAD313D71B1D4F9EE20E739CC3B6EDE9721D@ATLANTIK-CL.intern.digame.de> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] in memory views +Thread-Index: AcZ0Hq3kgcte1uWiSeKo4a48uaujoQAAsrAw +From: "Hakan Kocaman" +To: "Thomas Vatter" , + "Tino Wildenhain" +Cc: +X-OriginalArrivalTime: 10 May 2006 11:12:32.0933 (UTC) + FILETIME=[A26BED50:01C67422] +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/236 +X-Sequence-Number: 19023 + +Hi, + +there was a similar discussion with a ramdisk: +http://archives.postgresql.org/pgsql-hackers/2005-11/msg01058.php + +You need to populate the data on serverstart, of course. + +But as Timo mentionend, it's maybe not worth the trouble. + +Maybe their is a way to speed up the queriy itself. + +To analyze this, you should post the query- and table-definition=20 +and the output of explain analyze of the offending query. + +Best regards + +Hakan Kocaman +Software-Development + +digame.de GmbH +Richard-Byrd-Str. 4-8 +50829 K=F6ln + +Tel.: +49 (0) 221 59 68 88 31 +Fax: +49 (0) 221 59 68 88 98 +Email: hakan.kocaman@digame.de + + + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org=20 +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of=20 +> Thomas Vatter +> Sent: Wednesday, May 10, 2006 12:43 PM +> To: Tino Wildenhain +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] in memory views +>=20 +>=20 +> Tino Wildenhain wrote: +>=20 +> > Thomas Vatter schrieb: +> > +> >> Tino Wildenhain wrote: +> >> +> >>> Thomas Vatter schrieb: +> >>> +> >>>> is there a possibility for creating views or temp tables=20 +> in memory=20 +> >>>> to avoid disk io when user makes select operations? +> >>> +> >>> +> >>> +> >>> +> >>> No need. The data will be available in OS and database caches if +> >>> they are really required often. If not, tune up the caches and +> >>> do a regular "pre select". +> >>> +> >>> Regards +> >>> Tino +> >>> +> >>> +> >> +> >> hmm, I am selecting a resultset with 1300 rows joined from=20 +> 12 tables.=20 +> >> with jdbc I am waiting 40 seconds until the first row appears. The=20 +> >> following rows appear really fast but the 40 seconds are a problem. +> > +> > +> > Well you will need the equally 40 seconds to fill your hypothetical +> > in memory table. (even a bit more due to the creation of a=20 +> > datastructure). +> > +> > So you can do the aproaches of semi materialized views=20 +> (that are in fact +> > writing into a shadow table) or just prefetch your data at=20 +> time - just +> > at the times you would refill your memory tables if they existed. +> > A cronjob with select/fetch should do. +> > +> > Regards +> > Tino +> > +> > +>=20 +> If the in memory table is created a bootup time of the dbms it is=20 +> already present when user selects the data. Of course the=20 +> challenge is=20 +> to keep the in memory table up to date if data are changed.=20 +> What do you=20 +> mean with semi materialized views, I have tried select * from=20 +> this_view=20 +> with the same result. Also, if I repeat the query it does not=20 +> run faster. +>=20 +> regards +> tom +>=20 +> --=20 +> Mit freundlichen Gr=FC=DFen / Regards +> Vatter +> =20 +> Network Inventory Software +> Sun Microsystems Principal Partner +>=20 +> www.network-inventory.de +> Tel. 030-79782510 +> E-Mail thomas.vatter@network-inventory.de +>=20 +>=20 +> ---------------------------(end of=20 +> broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +>=20 +> http://www.postgresql.org/docs/faq +>=20 + +From pgsql-performance-owner@postgresql.org Wed May 10 08:50:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6D5CE9FA2FA + for ; + Wed, 10 May 2006 08:50:22 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 87200-01 + for ; + Wed, 10 May 2006 08:50:15 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wr-out-0506.google.com (wr-out-0506.google.com + [64.233.184.236]) + by postgresql.org (Postfix) with ESMTP id C85909FA1B0 + for ; + Wed, 10 May 2006 08:50:15 -0300 (ADT) +Received: by wr-out-0506.google.com with SMTP id i20so1387781wra + for ; + Wed, 10 May 2006 04:49:41 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=JesZEwEpZBwQJ4oq5dv3vMxPbx0OIDDx/VnhJ1zT62x1F2Q0TNfainprsuEpwigBw955469gOWNYf9A8FHRVQLyh5ZqWDTWuMpyX0h1GZ3Po7alPSHExvkKSiOswIEEgBgbu81ZK7U9uQIasNxhkiBPvfsY67UWvcdJtmnGt3c0= +Received: by 10.65.222.9 with SMTP id z9mr276812qbq; + Wed, 10 May 2006 04:49:41 -0700 (PDT) +Received: by 10.65.95.11 with HTTP; Wed, 10 May 2006 04:49:41 -0700 (PDT) +Message-ID: <194f62550605100449p2d200fc3pfe501da895cfcc00@mail.gmail.com> +Date: Wed, 10 May 2006 13:49:41 +0200 +From: "Clemens Eisserer" +To: pgsql-performance@postgresql.org +Subject: Question about explain-command... +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/237 +X-Sequence-Number: 19024 + +Hello, + +I just discovered the explain command and well ... have some (for you +of course very stupid) questions. + +I do a quite large (for my taste) join, the query looks like the following: +SELECT DISTINCT customer.email AS cemail, customer.key AS ckey, +customer.anrede AS canrede, customer.strasse AS cstrasse, customer.plz +AS cplz, customer.ort AS cort, customer.vorname AS cvorname, +customer.nachname AS cnachname , custtype.name AS tname, customer.land +AS cland, customer.datanotvalid AS cdatanvalid FROM customer LEFT JOIN +sells ON customer.key=3Dsells.custid LEFT JOIN goods ON +sells.goodsid=3Dgoods.key LEFT JOIN custtype ON +customer.custgroup=3Dcusttype.key LEFT JOIN prodtype ON +prodtype.key=3Dgoods.prodgroup WHERE customer.nachname LIKE '%name%'; + +All primary keys are indixed, and this is what explain tells me: + Unique (cost=3D15.67..16.69 rows=3D34 width=3D115) + -> Sort (cost=3D15.67..15.75 rows=3D34 width=3D115) + Sort Key: customer.email, customer."key", customer.anrede, custome= +r.str +asse, customer.plz, customer.ort, customer.vorname, customer.nachname, cust= +type. +name, customer.land, customer.datanotvalid + -> Hash Left Join (cost=3D6.16..14.80 rows=3D34 width=3D115) + Hash Cond: ("outer".prodgroup =3D "inner"."key") + -> Hash Left Join (cost=3D4.97..13.10 rows=3D34 width=3D11= +9) + Hash Cond: ("outer".custgroup =3D "inner"."key") + -> Hash Left Join (cost=3D3.88..11.49 rows=3D34 widt= +h=3D111) + Hash Cond: ("outer".goodsid =3D "inner"."key") + -> Hash Left Join (cost=3D1.98..9.08 +rows=3D34 width=3D11 1) + Hash Cond: ("outer"."key" =3D "inner".cust= +id) + -> Seq Scan on customer=20 +(cost=3D0.00..6.10 rows =3D34 width=3D107) + Filter: ((nachname)::text ~~ +'%au%'::text ) + -> Hash (cost=3D1.78..1.78 rows=3D78 wid= +th=3D8) + -> Seq Scan on sells=20 +(cost=3D0.00..1.78 r ows=3D78 width=3D8) + -> Hash (cost=3D1.72..1.72 rows=3D72 width=3D8= +) + -> Seq Scan on goods=20 +(cost=3D0.00..1.72 rows=3D72 width=3D8) + -> Hash (cost=3D1.08..1.08 rows=3D8 width=3D16) + -> Seq Scan on custtype (cost=3D0.00..1.08 +rows=3D8 wid th=3D16) + -> Hash (cost=3D1.15..1.15 rows=3D15 width=3D4) + -> Seq Scan on prodtype (cost=3D0.00..1.15 rows=3D15= + width=3D4) + + +What does the hash-lines mean, does that mean my query does not use +the indices at all? +Why are some table-names and some column-names surrounded by ' " '? +Are they threated as text-columns? +I have to admit that the tables are just filled with test-data so the +analyzer may take just a very simple way since almost no data is in... + +lg Clemens + +From pgsql-performance-owner@postgresql.org Wed May 10 08:57:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A902D9FA2FA + for ; + Wed, 10 May 2006 08:57:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 88826-01 + for ; + Wed, 10 May 2006 08:57:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from service-web.de (p15093784.pureserver.info [217.160.106.224]) + by postgresql.org (Postfix) with ESMTP id 470889FA1B0 + for ; + Wed, 10 May 2006 08:57:34 -0300 (ADT) +Received: from [10.100.1.50] (074-016-066-080.eggenet.de [80.66.16.74]) + by service-web.de (Postfix) with ESMTP id 575B720002F; + Wed, 10 May 2006 13:57:33 +0200 (CEST) +Message-ID: <4461D510.5090806@wildenhain.de> +Date: Wed, 10 May 2006 13:57:04 +0200 +From: Tino Wildenhain +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050929) +X-Accept-Language: de-DE, de, en-us, en +MIME-Version: 1.0 +To: Thomas Vatter +Cc: pgsql-performance@postgresql.org +Subject: Re: in memory views +References: <4461AFFF.7060200@network-inventory.de> + <4461B3DE.6030700@wildenhain.de> + <4461B899.4030502@network-inventory.de> + <4461BB9E.5030607@wildenhain.de> + <4461C3D0.4060504@network-inventory.de> +In-Reply-To: <4461C3D0.4060504@network-inventory.de> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/238 +X-Sequence-Number: 19025 + +Thomas Vatter schrieb: +> Tino Wildenhain wrote: +... +>> Well you will need the equally 40 seconds to fill your hypothetical +>> in memory table. (even a bit more due to the creation of a +>> datastructure). +>> +>> So you can do the aproaches of semi materialized views (that are in fact +>> writing into a shadow table) or just prefetch your data at time - just +>> at the times you would refill your memory tables if they existed. +>> A cronjob with select/fetch should do. +>> +>> Regards +>> Tino +>> +>> +> +> If the in memory table is created a bootup time of the dbms it is +> already present when user selects the data. Of course the challenge is +> to keep the in memory table up to date if data are changed. What do you +> mean with semi materialized views, I have tried select * from this_view +> with the same result. Also, if I repeat the query it does not run faster. +> +Semi materialized views are just views with aditional rules and some +triggers which copy data to another table. There are several receipes +if you google accordingly. + +I do not know what you mean by "bootup time" - do you really reboot +your database server? *hehe* just kidding ;) + +In your first email you told me your query indeed runs faster the 2nd +time (due to the caching) now you are telling me that it is not. + +Btw, judging from your analyze output you are using very cryptic +table and column names - you can use aliasing in the query and dont +have to resort to tiny tags when you actually name the objects ;) + +Maybe others have comments on your query. Btw, better use +explain analyze to get realistic results. + +Regards +Tino + +From pgsql-general-owner@postgresql.org Wed May 10 09:15:37 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 99B359FA32D; + Wed, 10 May 2006 09:15:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 85938-09; Wed, 10 May 2006 09:15:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from suzuka.mcnaught.org (unknown [4.21.254.118]) + by postgresql.org (Postfix) with ESMTP id 4D12B9FA2FA; + Wed, 10 May 2006 09:15:24 -0300 (ADT) +Received: by suzuka.mcnaught.org (Postfix, from userid 1000) + id 8598C167A05; Wed, 10 May 2006 08:15:22 -0400 (EDT) +To: Greg Stark +Cc: Vivek Khera , + "Pgsql-Performance ((E-mail))" , + PostgreSQL General +Subject: Re: Arguments Pro/Contra Software Raid +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> + <5AF87D32-F602-4973-AA21-84E0CFEA1774@khera.org> + <87mzdroyzb.fsf@suzuka.mcnaught.org> + <8764kexzin.fsf@stark.xeocode.com> +From: Douglas McNaught +Date: Wed, 10 May 2006 08:15:22 -0400 +In-Reply-To: <8764kexzin.fsf@stark.xeocode.com> (Greg Stark's message of "10 + May 2006 00:41:20 -0400") +Message-ID: <87vesenkit.fsf@suzuka.mcnaught.org> +User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/422 +X-Sequence-Number: 95214 + +Greg Stark writes: + +> Douglas McNaught writes: + +>> Correct me if I'm wrong, but I've never heard of a 15kRPM SATA drive. +> +> Well, dollar for dollar you would get the best performance from slower drives +> anyways since it would give you more spindles. 15kRPM drives are *expensive*. + +Depends on your power, heat and rack space budget too... If you need +max performance out of a given rack space (rather than max density), +SCSI is still the way to go. I'll definitely agree that SATA is +becoming much more of a player in the server storage market, though. + +-Doug + +From pgsql-performance-owner@postgresql.org Wed May 10 09:23:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9928B9FA2FA + for ; + Wed, 10 May 2006 09:23:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 91675-01 + for ; + Wed, 10 May 2006 09:23:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from h57078.serverkompetenz.net (talk-net.net [81.169.128.8]) + by postgresql.org (Postfix) with ESMTP id 1DC999FA1B0 + for ; + Wed, 10 May 2006 09:23:37 -0300 (ADT) +Received: from [192.168.115.250] (e178173057.adsl.alicedsl.de [85.178.173.57]) + by h57078.serverkompetenz.net (Postfix) with ESMTP id 96FF450C799; + Wed, 10 May 2006 14:21:57 +0200 (CEST) +Message-ID: <4461DB55.3030005@network-inventory.de> +Date: Wed, 10 May 2006 14:23:49 +0200 +From: Thomas Vatter +User-Agent: Mozilla Thunderbird 1.0.5 (Windows/20050711) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tino Wildenhain +CC: pgsql-performance@postgresql.org +Subject: Re: in memory views +References: <4461AFFF.7060200@network-inventory.de> + <4461B3DE.6030700@wildenhain.de> + <4461B899.4030502@network-inventory.de> + <4461BB9E.5030607@wildenhain.de> + <4461C3D0.4060504@network-inventory.de> + <4461D510.5090806@wildenhain.de> +In-Reply-To: <4461D510.5090806@wildenhain.de> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/240 +X-Sequence-Number: 19027 + +Tino Wildenhain wrote: + +> Thomas Vatter schrieb: +> +>> Tino Wildenhain wrote: +> +> ... +> +>>> Well you will need the equally 40 seconds to fill your hypothetical +>>> in memory table. (even a bit more due to the creation of a +>>> datastructure). +>>> +>>> So you can do the aproaches of semi materialized views (that are in +>>> fact +>>> writing into a shadow table) or just prefetch your data at time - just +>>> at the times you would refill your memory tables if they existed. +>>> A cronjob with select/fetch should do. +>>> +>>> Regards +>>> Tino +>>> +>>> +>> +>> If the in memory table is created a bootup time of the dbms it is +>> already present when user selects the data. Of course the challenge +>> is to keep the in memory table up to date if data are changed. What +>> do you mean with semi materialized views, I have tried select * from +>> this_view with the same result. Also, if I repeat the query it does +>> not run faster. +>> +> Semi materialized views are just views with aditional rules and some +> triggers which copy data to another table. There are several receipes +> if you google accordingly. +> +> I do not know what you mean by "bootup time" - do you really reboot +> your database server? *hehe* just kidding ;) +> +> In your first email you told me your query indeed runs faster the 2nd +> time (due to the caching) now you are telling me that it is not. +> +> Btw, judging from your analyze output you are using very cryptic +> table and column names - you can use aliasing in the query and dont +> have to resort to tiny tags when you actually name the objects ;) +> +> Maybe others have comments on your query. Btw, better use +> explain analyze to get realistic results. +> +> Regards +> Tino +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> +> + +The subsequent rows are shown faster not the subsequent queries - if +you really read my first e-mail ;-) . Yes, I have done analyse +yesterday, the database has not changed, afaik it is necessary when the +database contents are changing. + +regards +tom + + +From pgsql-general-owner@postgresql.org Wed May 10 09:44:23 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id DA8FA9FA2FA; + Wed, 10 May 2006 09:44:22 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 90062-06; Wed, 10 May 2006 09:44:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 2FD709FA1B0; + Wed, 10 May 2006 09:44:16 -0300 (ADT) +Received: from mail.enyo.de (mail.enyo.de [212.9.189.167]) + by svr4.postgresql.org (Postfix) with ESMTP id ECB295B6AF2; + Wed, 10 May 2006 12:44:12 +0000 (GMT) +Received: from deneb.vpn.enyo.de ([212.9.189.177] helo=deneb.enyo.de) + by mail.enyo.de with esmtp id 1Fdo2y-00055q-K0; + Wed, 10 May 2006 14:44:08 +0200 +Received: from fw by deneb.enyo.de with local (Exim 4.62) + (envelope-from ) + id 1Fdo2w-0002A5-Ff; Wed, 10 May 2006 14:44:06 +0200 +From: Florian Weimer +To: Hannes Dorbath +Cc: pgsql-general@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +References: +Date: Wed, 10 May 2006 14:44:06 +0200 +In-Reply-To: (Hannes Dorbath's message of "Tue, + 09 May 2006 11:16:45 +0200") +Message-ID: <878xpacand.fsf@mid.deneb.enyo.de> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/424 +X-Sequence-Number: 95216 + +* Hannes Dorbath: + +> + Hardware Raids might be a bit easier to manage, if you never spend a +> few hours to learn Software Raid Tools. + +I disagree. RAID management is complicated, and once there is a disk +failure, all kinds of oddities can occur which can make it quite a +challenge to get back a non-degraded array. + +With some RAID controllers, monitoring is diffcult because they do not +use the system's logging mechanism for reporting. In some cases, it +is not possible to monitor the health status of individual disks. + +> + Using SATA drives is always a bit of risk, as some drives are lying +> about whether they are caching or not. + +You can usually switch off caching. + +> + Using hardware controllers, the array becomes locked to a particular +> vendor. You can't switch controller vendors as the array meta +> information is stored proprietary. In case the Raid is broken to a +> level the controller can't recover automatically this might complicate +> manual recovery by specialists. + +It's even more difficult these days. 3ware controllers enable drive +passwords, so you can't access the drive from other controllers at all +(even if you could interpret the on-disk data). + +> + Even battery backed controllers can't guarantee that data written to +> the drives is consistent after a power outage, neither that the drive +> does not corrupt something during the involuntary shutdown / power +> irregularities. (This is theoretical as any server will be UPS backed) + +UPS failures are not unheard of. 8-/ Apart from that, you can address +a large class of shutdown failures if you replay a log stored in the +BBU on the next reboot (partial sector writes come to my mind). + +It is very difficult to check if the controller does this correctly, +though. + +A few other things to note: You can't achieve significant port density +with non-RAID controllers, at least with SATA. You need to buy a RAID +controller anyway. You can't quite achieve what a BBU does (even if +you've got a small, fast persistent storage device) because there's +no host software support for such a configuration. + +From pgsql-performance-owner@postgresql.org Wed May 10 10:29:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2784B9FA2FA; + Wed, 10 May 2006 10:29:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 00142-01; Wed, 10 May 2006 10:29:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 395829FA1B0; + Wed, 10 May 2006 10:29:06 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (p549D13DA.dip0.t-ipconnect.de + [84.157.19.218]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id E24B765837; + Wed, 10 May 2006 15:30:15 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 98A4E18222EEA; + Wed, 10 May 2006 15:29:16 +0200 (CEST) +Message-ID: <4461EAAC.7030105@logix-tt.com> +Date: Wed, 10 May 2006 15:29:16 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Cc: pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + + <758d5e7f0605090943p1bbfdae2p4cb28ba128288316@mail.gmail.com> + +In-Reply-To: +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/242 +X-Sequence-Number: 19029 + +Hi, PFC, + +PFC wrote: + +> The problem is that you need a set-returning function to retrieve +> the values. SRFs don't have rowcount estimates, so the plans suck. + +What about adding some way of rowcount estimation to SRFs, in the way of: + +CREATE FUNCTION foo (para, meters) RETURNS SETOF bar AS +$$ ... function code ... $$ LANGUAGE plpgsql +ROWCOUNT_ESTIMATOR $$ ... estimation code ... $$ ; + +Internally, this could create two functions, foo (para, meters) and +estimate_foo(para, meters) that are the same language and coupled +together (just like a SERIAL column and its sequence). The estimator +functions have an implicit return parameter of int8. Parameters may be +NULL when they are not known at query planning time. + +What do you think about this idea? + +The same scheme could be used to add a CPUCOST_ESTIMATOR to expensive +functions. + +HTH, +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-general-owner@postgresql.org Wed May 10 10:54:46 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4DC959FA3A6; + Wed, 10 May 2006 10:54:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 01097-05; Wed, 10 May 2006 10:54:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id AC5479FA2FA; + Wed, 10 May 2006 10:54:32 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (p549D13DA.dip0.t-ipconnect.de + [84.157.19.218]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 484CB65837; + Wed, 10 May 2006 15:55:43 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 1050518222EEA; + Wed, 10 May 2006 15:54:44 +0200 (CEST) +Message-ID: <4461F0A3.60102@logix-tt.com> +Date: Wed, 10 May 2006 15:54:43 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PostgreSQL General +Cc: "Pgsql-Performance ((E-mail))" +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> + <4F853BBA-175C-4B3E-BAF4-AA34B80DF6EF@blighty.com> + <4460DED4.2090103@commandprompt.com> + <7779142C-B027-4C17-A67C-A7C220AADF80@slamb.org> +In-Reply-To: <7779142C-B027-4C17-A67C-A7C220AADF80@slamb.org> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/428 +X-Sequence-Number: 95220 + +Hi, Scott & all, + +Scott Lamb wrote: + +> I don't know the answer to this question, but have you seen this tool? +> +> http://brad.livejournal.com/2116715.html + +We had a simpler tool inhouse, which wrote a file byte-for-byte, and +called fsync() after every byte. + +If the number of fsyncs/min is higher than your rotations per minute +value of your disks, they must be lying. + +It does not find as much liers as the script above, but it is less +intrusive (can be ran on every low-io machine without crashing it), and +it found some liers in-house (some notebook disks, one external +USB/FireWire to IDE case, and an older linux cryptoloop implementations, +IIRC). + +If you're interested, I can dig for the C source... + +HTH, +Markus + + + + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-general-owner@postgresql.org Wed May 10 11:01:52 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7C7FA9FA1B0; + Wed, 10 May 2006 11:01:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 03848-01; Wed, 10 May 2006 11:01:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 309A99FA2FA; + Wed, 10 May 2006 11:01:36 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k4AE1XQ08859; + Wed, 10 May 2006 10:01:33 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200605101401.k4AE1XQ08859@candle.pha.pa.us> +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +In-Reply-To: <4461F0A3.60102@logix-tt.com> +To: Markus Schaber +Date: Wed, 10 May 2006 10:01:33 -0400 (EDT) +CC: PostgreSQL General , + "Pgsql-Performance ((E-mail))" +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/429 +X-Sequence-Number: 95221 + +Markus Schaber wrote: +> Hi, Scott & all, +> +> Scott Lamb wrote: +> +> > I don't know the answer to this question, but have you seen this tool? +> > +> > http://brad.livejournal.com/2116715.html +> +> We had a simpler tool inhouse, which wrote a file byte-for-byte, and +> called fsync() after every byte. +> +> If the number of fsyncs/min is higher than your rotations per minute +> value of your disks, they must be lying. +> +> It does not find as much liers as the script above, but it is less + +Why does it find fewer liers? + +--------------------------------------------------------------------------- + +> intrusive (can be ran on every low-io machine without crashing it), and +> it found some liers in-house (some notebook disks, one external +> USB/FireWire to IDE case, and an older linux cryptoloop implementations, +> IIRC). +> +> If you're interested, I can dig for the C source... +> +> HTH, +> Markus +> +> +> +> +> -- +> Markus Schaber | Logical Tracking&Tracing International AG +> Dipl. Inf. | Software Development GIS +> +> Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: explain analyze is your friend +> + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-performance-owner@postgresql.org Wed May 10 11:16:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6D0AB9FA2FA + for ; + Wed, 10 May 2006 11:16:35 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 05652-03 + for ; + Wed, 10 May 2006 11:16:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from yertle.kcilink.com (yertle.kcilink.com [65.205.34.180]) + by postgresql.org (Postfix) with ESMTP id 037CD9FA32D + for ; + Wed, 10 May 2006 11:16:17 -0300 (ADT) +Received: from [192.168.7.103] (host-103.int.kcilink.com [192.168.7.103]) + by yertle.kcilink.com (Postfix) with ESMTP id BE18BB826 + for ; + Wed, 10 May 2006 10:16:15 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v749.3) +In-Reply-To: <8764kexzin.fsf@stark.xeocode.com> +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> + <5AF87D32-F602-4973-AA21-84E0CFEA1774@khera.org> + <87mzdroyzb.fsf@suzuka.mcnaught.org> + <8764kexzin.fsf@stark.xeocode.com> +Content-Type: multipart/signed; micalg=sha1; boundary=Apple-Mail-4--687833275; + protocol="application/pkcs7-signature" +Message-Id: <29EA6D53-F41E-4A09-B5CA-EFD182AB9772@khera.org> +From: Vivek Khera +Subject: Re: [GENERAL] Arguments Pro/Contra Software Raid +Date: Wed, 10 May 2006 10:16:14 -0400 +To: "Pgsql-Performance ((E-mail))" +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/245 +X-Sequence-Number: 19032 + + +--Apple-Mail-4--687833275 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + + +On May 10, 2006, at 12:41 AM, Greg Stark wrote: + +> Well, dollar for dollar you would get the best performance from +> slower drives +> anyways since it would give you more spindles. 15kRPM drives are +> *expensive*. + +Personally, I don't care that much for "dollar for dollar" I just +need performance. If it is within a factor of 2 or 3 in price then +I'll go for absolute performance over "bang for the buck". + + +--Apple-Mail-4--687833275 +Content-Transfer-Encoding: base64 +Content-Type: application/pkcs7-signature; + name=smime.p7s +Content-Disposition: attachment; + filename=smime.p7s + +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIGlDCCAz8w +ggKooAMCAQICAQ0wDQYJKoZIhvcNAQEFBQAwgdExCzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0 +ZXJuIENhcGUxEjAQBgNVBAcTCUNhcGUgVG93bjEaMBgGA1UEChMRVGhhd3RlIENvbnN1bHRpbmcx +KDAmBgNVBAsTH0NlcnRpZmljYXRpb24gU2VydmljZXMgRGl2aXNpb24xJDAiBgNVBAMTG1RoYXd0 +ZSBQZXJzb25hbCBGcmVlbWFpbCBDQTErMCkGCSqGSIb3DQEJARYccGVyc29uYWwtZnJlZW1haWxA +dGhhd3RlLmNvbTAeFw0wMzA3MTcwMDAwMDBaFw0xMzA3MTYyMzU5NTlaMGIxCzAJBgNVBAYTAlpB +MSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUg +UGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA +xKY8VXNV+065yplaHmjAdQRwnd/p/6Me7L3N9VvyGna9fww6YfK/Uc4B1OVQCjDXAmNaLIkVcI7d +yfArhVqqP3FWy688Cwfn8R+RNiQqE88r1fOCdz0Dviv+uxg+B79AgAJk16emu59l0cUqVIUPSAR/ +p7bRPGEEQB5kGXJgt/sCAwEAAaOBlDCBkTASBgNVHRMBAf8ECDAGAQH/AgEAMEMGA1UdHwQ8MDow +OKA2oDSGMmh0dHA6Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVQZXJzb25hbEZyZWVtYWlsQ0EuY3Js +MAsGA1UdDwQEAwIBBjApBgNVHREEIjAgpB4wHDEaMBgGA1UEAxMRUHJpdmF0ZUxhYmVsMi0xMzgw +DQYJKoZIhvcNAQEFBQADgYEASIzRUIPqCy7MDaNmrGcPf6+svsIXoUOWlJ1/TCG4+DYfqi2fNi/A +9BxQIJNwPP2t4WFiw9k6GX6EsZkbAMUaC4J0niVQlGLH2ydxVyWN3amcOY6MIE9lX5Xa9/eH1sYI +Tq726jTlEBpbNU1341YheILcIRk13iSx0x1G/11fZU8wggNNMIICtqADAgECAhA6sDoA4m3lcimf +yUtGSQgmMA0GCSqGSIb3DQEBBAUAMGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29u +c3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNz +dWluZyBDQTAeFw0wNjA1MDIxNDEyNDdaFw0wNzA1MDIxNDEyNDdaMIGKMR8wHQYDVQQDExZUaGF3 +dGUgRnJlZW1haWwgTWVtYmVyMR4wHAYJKoZIhvcNAQkBFg92aXZla0BraGVyYS5vcmcxIDAeBgkq +hkiG9w0BCQEWEWtoZXJhQGtjaWxpbmsuY29tMSUwIwYJKoZIhvcNAQkBFhZ2aXZla0BtYWlsZXJt +YWlsZXIuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAq+zHKYq9vZ4Dq1itNqT/ +OeJvWDvQ5JdQlRzwsJlvtJBknXsnOaJNabmjnu2s6XFMcP2srBZQ/WPvhsClajLQOcxnarrfB66N +DpMzXTxfYzX6m9TA/fEn64sNn+YnBZL6Dvid9kiAgP9LmqcTOIFdWUya3ZmQS5YTuLB+tkFSL8/h ++inDPN6dcsna8TcM1SAk+3upxOR7kyFM9T3vy25w62Nh1zK7Stp0vUZLU6GzzC1VvHGZHKGticD6 +o3uHaMr2LCFjptoIcfZL75LO/UaR9o7smgboW4yJyW5g9ZasyYQUXyvkitfyZuVWATb8ZSHOkjWJ +872Pyf5+HOevVUI0aQIDAQABo1cwVTBFBgNVHREEPjA8gQ92aXZla0BraGVyYS5vcmeBEWtoZXJh +QGtjaWxpbmsuY29tgRZ2aXZla0BtYWlsZXJtYWlsZXIuY29tMAwGA1UdEwEB/wQCMAAwDQYJKoZI +hvcNAQEEBQADgYEAYpaFKDj47pTQIUQi28MgtjKophopv4QJjvspXmy0qxd8t/M/zc7HuBy3i/9a +PrXDgKyNBzzlFTasTazAY53ntVpqw9k1NOeHmH6o3j/DBVa49bC6bbWfp9UGOwYChlDR0tngQZyC +MDMZEdYv4zpGfBTku5m1jb8Yz/qYqV4FWB4xggMQMIIDDAIBATB2MGIxCzAJBgNVBAYTAlpBMSUw +IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy +c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIQOrA6AOJt5XIpn8lLRkkIJjAJBgUrDgMCGgUAoIIB +bzAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0wNjA1MTAxNDE2MTVa +MCMGCSqGSIb3DQEJBDEWBBR+CnS1ZNK+MRbXfc3QU2UreHo1DzCBhQYJKwYBBAGCNxAEMXgwdjBi +MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoG +A1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElzc3VpbmcgQ0ECEDqwOgDibeVyKZ/JS0ZJ +CCYwgYcGCyqGSIb3DQEJEAILMXigdjBiMQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENv +bnN1bHRpbmcgKFB0eSkgTHRkLjEsMCoGA1UEAxMjVGhhd3RlIFBlcnNvbmFsIEZyZWVtYWlsIElz +c3VpbmcgQ0ECEDqwOgDibeVyKZ/JS0ZJCCYwDQYJKoZIhvcNAQEBBQAEggEAm2W7BnvqmYBwg05n +616lTDzz1AN5cOHnmUyYwCZJEk/hBqle3pt+SYeQmE6zhQ37QT0MUMzNPLmiAou3nTC3mkE/S/j1 +K6sc8KrSUmDqcWeTUC2jBkpo5YUvpvRKK/1oQSaduTQpSijzevzqMNxN/obmrWje8x/PnD3R809L +sp47g8s5gxhh8sen8+Fk3YvWGIGki9EzSbjIurp3HOn35jjJIA8NXDmrsskCwHKs1B0OiViWXkSK +woNYp0+RrFmrIwy4ak1npeq0Dh4rp4T/NDHnnKcxZiV+F6joN46KMcWajrigDQvdBIF8DFmtgztw +X4Nrwq4S9bF/HJ4SxET19QAAAAAAAA== + +--Apple-Mail-4--687833275-- + +From pgsql-performance-owner@postgresql.org Wed May 10 11:18:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 53E399FACFE + for ; + Wed, 10 May 2006 11:18:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 03028-05-6 + for ; + Wed, 10 May 2006 11:18:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ustc.edu.cn (smtp.ustc.edu.cn [202.38.64.16]) + by postgresql.org (Postfix) with SMTP id 25E789FB1BA + for ; + Wed, 10 May 2006 11:17:25 -0300 (ADT) +Received: (eyou send program); Wed, 10 May 2006 22:17:20 +0800 +Message-ID: <347270640.30146@ustc.edu.cn> +X-EYOUMAIL-SMTPAUTH: wfg@mail.ustc.edu.cn +Received: from unknown (HELO localhost.localdomain) (210.45.75.53) + by 202.38.64.8 with SMTP; Wed, 10 May 2006 22:17:20 +0800 +Received: from wfg by localhost.localdomain with local (Exim 4.61) + (envelope-from ) + id 1FdpVG-0001kQ-Qw; Wed, 10 May 2006 22:17:26 +0800 +Date: Wed, 10 May 2006 22:17:26 +0800 +From: Wu Fengguang +To: blender@jaskom.pl +Cc: pgsql-performance@postgresql.org +Subject: Re: PostgreSQL VACCUM killing CPU +Message-ID: <20060510141726.GA6620@mail.ustc.edu.cn> +Mail-Followup-To: Wu Fengguang , blender@jaskom.pl, + pgsql-performance@postgresql.org +References: <1147167570.494108.284720@i39g2000cwa.googlegroups.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1147167570.494108.284720@i39g2000cwa.googlegroups.com> +User-Agent: Mutt/1.5.11+cvs20060126 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/246 +X-Sequence-Number: 19033 + +On Tue, May 09, 2006 at 03:19:08AM -0700, blender@jaskom.pl wrote: +> I have got such problem. +> Im running Postgresql 7.3.2 on Linux 2.6.13. +> What is see when VACCUM is running and killing my CPU is: +> +> Cpu(s): 3.2% us, 0.0% sy, 0.0% ni, 0.0% id, 96.8% wa, 0.0% hi, +> 0.0% si +> +> what i am worry about is "96.8% wa" why is it like that? + +It's killing your disk drives instead of CPU(which is mostly _idle_ +waiting for I/O completion). + +Run this command to get an idea of the I/O activities: + iostat -x 3 3 + +[AD]Running a kernel patched with adaptive read-ahead may help it: +http://www.vanheusden.com/ara/adaptive-readahead-11.1-2.6.16.5.patch.gz + +From pgsql-performance-owner@postgresql.org Wed May 10 11:36:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C68449FA2FA + for ; + Wed, 10 May 2006 11:36:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 04909-07 + for ; + Wed, 10 May 2006 11:36:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id AA9E69FA1B0 + for ; + Wed, 10 May 2006 11:36:00 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k4AEZxc13602; + Wed, 10 May 2006 10:35:59 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200605101435.k4AEZxc13602@candle.pha.pa.us> +Subject: Re: [GENERAL] Arguments Pro/Contra Software Raid +In-Reply-To: <29EA6D53-F41E-4A09-B5CA-EFD182AB9772@khera.org> +To: Vivek Khera +Date: Wed, 10 May 2006 10:35:59 -0400 (EDT) +CC: "Pgsql-Performance ((E-mail))" +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/247 +X-Sequence-Number: 19034 + +Vivek Khera wrote: +> +> On May 10, 2006, at 12:41 AM, Greg Stark wrote: +> +> > Well, dollar for dollar you would get the best performance from +> > slower drives +> > anyways since it would give you more spindles. 15kRPM drives are +> > *expensive*. +> +> Personally, I don't care that much for "dollar for dollar" I just +> need performance. If it is within a factor of 2 or 3 in price then +> I'll go for absolute performance over "bang for the buck". + +That is really the issue. You can buy lots of consumer-grade stuff and +work just fine if your performance/reliability tolerance is high enough. + +However, don't fool yourself that consumer and server-grade hardware is +internally the same, or has the same testing. + +I just had a Toshiba laptop drive replaced last week (new, not +refurbished), only to have it fail this week. Obviously there isn't +sufficient burn-in done by Toshiba, and I don't fault them because it is +a consumer laptop --- it fails, they replace it. For servers, the +downtime usually can't be tolerated, while consumers usually can +tolerate significant downtime. + +I have always purchased server-grade hardware for my home server, and I +think I have had one day of hardware downtime in the past ten years. +Consumer hardware just couldn't do that. + +As one data point, most consumer-grade IDE drives are designed to be run +only 8 hours a day. The engineering doesn't anticipate 24-hour +operation, and that trade-off passes all the way through the selection +of componients for the drive, which generates sigificant cost savings. + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-general-owner@postgresql.org Wed May 10 11:38:21 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1F61E9FA92E; + Wed, 10 May 2006 11:38:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 05716-08; Wed, 10 May 2006 11:38:07 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 0C6A19FA32D; + Wed, 10 May 2006 11:38:07 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (p549D13DA.dip0.t-ipconnect.de + [84.157.19.218]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 5AA8A65837; + Wed, 10 May 2006 16:39:17 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 2CE6C18222EEA; + Wed, 10 May 2006 16:38:18 +0200 (CEST) +Message-ID: <4461FAD9.6020106@logix-tt.com> +Date: Wed, 10 May 2006 16:38:17 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PostgreSQL General +Cc: "Pgsql-Performance ((E-mail))" +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +References: <200605101401.k4AE1XQ08859@candle.pha.pa.us> +In-Reply-To: <200605101401.k4AE1XQ08859@candle.pha.pa.us> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/432 +X-Sequence-Number: 95224 + +Hi, Bruce, + +Bruce Momjian wrote: + + +>>It does not find as much liers as the script above, but it is less +> +> Why does it find fewer liers? + +It won't find liers that have a small "lie-queue-length" so their +internal buffers get full so they have to block. After a small burst at +start which usually hides in other latencies, they don't get more +throughput than spindle turns. + +It won't find liers that first acknowledge to the host, and then +immediately write the block before accepting other commands. This +improves latency (which is measured in some benchmarks), but not +syncs/write rate. + +Both of them can be captured by the other script, but not by my tool. + +HTH, +Markus + + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Wed May 10 11:37:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B721D9FA1B0 + for ; + Wed, 10 May 2006 11:37:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 03601-08 + for ; + Wed, 10 May 2006 11:37:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id F07709FA2FA + for ; + Wed, 10 May 2006 11:37:12 -0300 (ADT) +Received: (qmail 30120 invoked from network); 10 May 2006 16:38:33 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 10 May 2006 16:38:33 +0200 +Date: Wed, 10 May 2006 16:38:31 +0200 +To: "Markus Schaber" , pgsql-performance@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Cc: pgsql-hackers@postgresql.org +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + + <758d5e7f0605090943p1bbfdae2p4cb28ba128288316@mail.gmail.com> + <4461EAAC.7030105@logix-tt.com> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <4461EAAC.7030105@logix-tt.com> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/248 +X-Sequence-Number: 19035 + + +>> The problem is that you need a set-returning function to retrieve +>> the values. SRFs don't have rowcount estimates, so the plans suck. +> +> What about adding some way of rowcount estimation to SRFs, in the way of: +> +> CREATE FUNCTION foo (para, meters) RETURNS SETOF bar AS +> $$ ... function code ... $$ LANGUAGE plpgsql +> ROWCOUNT_ESTIMATOR $$ ... estimation code ... $$ ; +> +> Internally, this could create two functions, foo (para, meters) and +> estimate_foo(para, meters) that are the same language and coupled +> together (just like a SERIAL column and its sequence). The estimator +> functions have an implicit return parameter of int8. Parameters may be +> NULL when they are not known at query planning time. +> +> What do you think about this idea? + + It would be very useful. + A few thoughts... + + You need to do some processing to know how many rows the function would +return. + Often, this processing will be repeated in the function itself. + Sometimes it's very simple (ie. the function will RETURN NEXT each +element in an array, you know the array length...) + Sometimes, for functions returning few rows, it might be faster to +compute the entire result set in the cost estimator. + + So, it might be a bit hairy to find a good compromise. + + Ideas on how to do this (clueless hand-waving mode) : + + 1- Add new attributes to set-returning functions ; basically a list of +functions, each returning an estimation parameter (rowcount, cpu tuple +cost, etc). + This is just like you said. + + 2- Add an "estimator", to a function, which would just be another +function, returning one row, a record, containing the estimations in +several columns (rowcount, cpu tuple cost, etc). + Pros : only one function call to estimate, easier and faster, the +estimator just leaves the unknown columns to NULL. + The estimator needs not be in the same language as the function itself. +It's just another function. + + 3- The estimator could be a set-returning function itself which would +return rows mimicking pg_statistics + Pros : planner-friendly, the planner would SELECT from the SRF instead of +looking in pg_statistics, and the estimator could tell the planner that, +for instance, the function will return unique values. + Cons : complex, maybe slow + + 4- Add simple flags to a function, like : + - returns unique values + - returns sorted values (no need to sort my results) + - please execute me and store my results in a temporary storage, count +the rows returned, and plan the outer query accordingly + - etc. + + +From pgsql-general-owner@postgresql.org Wed May 10 11:44:00 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3DC4D9FA2FA; + Wed, 10 May 2006 11:44:00 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 09512-01-5; Wed, 10 May 2006 11:43:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id F0C619FA1B0; + Wed, 10 May 2006 11:43:01 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 10 May 2006 14:42:59 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 10 May 2006 09:42:59 -0500 +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +From: Scott Marlowe +To: Bruce Momjian +Cc: Steve Atkins , + PostgreSQL General , + "Pgsql-Performance ((E-mail))" +In-Reply-To: <200605100102.k4A12wa12853@candle.pha.pa.us> +References: <200605100102.k4A12wa12853@candle.pha.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1147272179.9755.18.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 10 May 2006 09:42:59 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/433 +X-Sequence-Number: 95225 + +On Tue, 2006-05-09 at 20:02, Bruce Momjian wrote: +> Scott Marlowe wrote: +> > Actually, in the case of the Escalades at least, the answer is yes. +> > Last year (maybe a bit more) someone was testing an IDE escalade +> > controller with drives that were known to lie, and it passed the power +> > plug pull test repeatedly. Apparently, the escalades tell the drives to +> > turn off their cache. While most all IDEs and a fair number of SATA +> > drives lie about cache fsyncing, they all seem to turn off the cache +> > when you ask. +> > +> > And, since a hardware RAID controller with bbu cache has its own cache, +> > it's not like it really needs the one on the drives anyway. +> +> You do if the controller thinks the data is already on the drives and +> removes it from its cache. + +Bruce, re-read what I wrote. The escalades tell the drives to TURN OFF +THEIR OWN CACHE. + +From pgsql-performance-owner@postgresql.org Wed May 10 11:47:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C7B829FA2FA + for ; + Wed, 10 May 2006 11:47:20 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 06666-07 + for ; + Wed, 10 May 2006 11:47:11 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id 9EAF29FA1B0 + for ; + Wed, 10 May 2006 11:47:10 -0300 (ADT) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [67.90.96.2] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 89908293; Wed, 10 May 2006 07:47:07 -0700 +From: "Dave Dutcher" +To: "'Clemens Eisserer'" , + +Subject: Re: Question about explain-command... +Date: Wed, 10 May 2006 09:47:07 -0500 +Message-ID: <01a901c67440$9cf097e0$8300a8c0@tridecap.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.2627 +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +In-reply-to: <194f62550605100449p2d200fc3pfe501da895cfcc00@mail.gmail.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/251 +X-Sequence-Number: 19038 + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of +> Clemens Eisserer +> Sent: Wednesday, May 10, 2006 6:50 AM +> To: pgsql-performance@postgresql.org +> Subject: [PERFORM] Question about explain-command... + +> +> What does the hash-lines mean, does that mean my query does not use +> the indices at all? +> Why are some table-names and some column-names surrounded by ' " '? +> Are they threated as text-columns? +> I have to admit that the tables are just filled with test-data so the +> analyzer may take just a very simple way since almost no data is in... +> + +For small tables, it is faster to do a sequential scan than an index +scan. You probably don't have enough test data to make the planner +choose an index scan. + +I don't think the quotes really mean anything. They are just used as +delimiters. + +The hash lines mean your tables are being joined by hash joins. You +should read this page for more info: + +http://www.postgresql.org/docs/8.1/interactive/performance-tips.html + + + +From pgsql-general-owner@postgresql.org Wed May 10 11:51:38 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 46C0F9FA32D; + Wed, 10 May 2006 11:51:37 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10464-02; Wed, 10 May 2006 11:51:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from suzuka.mcnaught.org (unknown [4.21.254.118]) + by postgresql.org (Postfix) with ESMTP id C650E9FA1B0; + Wed, 10 May 2006 11:51:25 -0300 (ADT) +Received: by suzuka.mcnaught.org (Postfix, from userid 1000) + id 214AD167AFD; Wed, 10 May 2006 10:51:22 -0400 (EDT) +To: Scott Marlowe +Cc: Bruce Momjian , Steve Atkins , + PostgreSQL General , + "Pgsql-Performance ((E-mail))" +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +References: <200605100102.k4A12wa12853@candle.pha.pa.us> + <1147272179.9755.18.camel@state.g2switchworks.com> +From: Douglas McNaught +Date: Wed, 10 May 2006 10:51:22 -0400 +In-Reply-To: <1147272179.9755.18.camel@state.g2switchworks.com> (Scott + Marlowe's message of "Wed, 10 May 2006 09:42:59 -0500") +Message-ID: <87r732ndat.fsf@suzuka.mcnaught.org> +User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/434 +X-Sequence-Number: 95226 + +Scott Marlowe writes: + +> On Tue, 2006-05-09 at 20:02, Bruce Momjian wrote: + +>> You do if the controller thinks the data is already on the drives and +>> removes it from its cache. +> +> Bruce, re-read what I wrote. The escalades tell the drives to TURN OFF +> THEIR OWN CACHE. + +Some ATA drives would lie about that too IIRC. Hopefully they've +stopped doing it in the SATA era. + +-Doug + +From pgsql-performance-owner@postgresql.org Wed May 10 11:56:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 166109FA2FA; + Wed, 10 May 2006 11:56:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 11405-01; Wed, 10 May 2006 11:56:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svana.org (svana.org [125.62.94.225]) + by postgresql.org (Postfix) with ESMTP id 985529FA1B0; + Wed, 10 May 2006 11:56:21 -0300 (ADT) +Received: from kleptog by svana.org with local (Exim 4.50) + id 1Fdq6R-000578-8f; Thu, 11 May 2006 00:55:51 +1000 +Date: Wed, 10 May 2006 16:55:51 +0200 +From: Martijn van Oosterhout +To: PFC +Cc: Markus Schaber , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Message-ID: <20060510145551.GB14476@svana.org> +Reply-To: Martijn van Oosterhout +References: <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + + <758d5e7f0605090943p1bbfdae2p4cb28ba128288316@mail.gmail.com> + <4461EAAC.7030105@logix-tt.com> + +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="FkmkrVfFsRoUs1wW" +Content-Disposition: inline +In-Reply-To: +X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 +X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 +X-PGP-Key-URL: +User-Agent: Mutt/1.5.9i +X-SA-Exim-Connect-IP: +X-SA-Exim-Mail-From: kleptog@svana.org +X-SA-Exim-Scanned: No (on svana.org); SAEximRunCond expanded to false +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/253 +X-Sequence-Number: 19040 + + +--FkmkrVfFsRoUs1wW +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Wed, May 10, 2006 at 04:38:31PM +0200, PFC wrote: +> You need to do some processing to know how many rows the function=20 +> would return. +> Often, this processing will be repeated in the function itself. +> Sometimes it's very simple (ie. the function will RETURN NEXT each =20 +> element in an array, you know the array length...) +> Sometimes, for functions returning few rows, it might be faster to =20 +> compute the entire result set in the cost estimator. + +I think the best would probably be to assign a constant. An SRF will +generally return between one of 1-10, 10-100, 100-1000, etc. You don't +need exact number, you just need to get within an order of magnitude +and a constant will work fine for that. + +How many functions sometimes return one and sometimes a million rows? + +Have a nice day, +--=20 +Martijn van Oosterhout http://svana.org/kleptog/ +> From each according to his ability. To each according to his ability to l= +itigate. + +--FkmkrVfFsRoUs1wW +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.1 (GNU/Linux) + +iD8DBQFEYf73IB7bNG8LQkwRAtSYAJ9LbkC4NsSOY0Kldf8ahC79fH6DGACfdE1G +vHMYLGT/gRpouxptbkA69oE= +=NVQu +-----END PGP SIGNATURE----- + +--FkmkrVfFsRoUs1wW-- + +From pgsql-general-owner@postgresql.org Wed May 10 11:57:47 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 62D7A9FA1B0; + Wed, 10 May 2006 11:57:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10188-07-2; Wed, 10 May 2006 11:57:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 462859FA2FA; + Wed, 10 May 2006 11:57:35 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (p549D13DA.dip0.t-ipconnect.de + [84.157.19.218]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 9E86D65837; + Wed, 10 May 2006 16:58:45 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 249DD18222EEA; + Wed, 10 May 2006 16:57:46 +0200 (CEST) +Message-ID: <4461FF69.4080209@logix-tt.com> +Date: Wed, 10 May 2006 16:57:45 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PostgreSQL General +Cc: "Pgsql-Performance ((E-mail))" +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +References: <200605101401.k4AE1XQ08859@candle.pha.pa.us> + <4461FAD9.6020106@logix-tt.com> +In-Reply-To: <4461FAD9.6020106@logix-tt.com> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/435 +X-Sequence-Number: 95227 + +Hi, Bruce, + +Markus Schaber wrote: + +>>>It does not find as much liers as the script above, but it is less +>>Why does it find fewer liers? +> +> It won't find liers that have a small "lie-queue-length" so their +> internal buffers get full so they have to block. After a small burst at +> start which usually hides in other latencies, they don't get more +> throughput than spindle turns. + +I just reread my mail, and must admit that I would not understand what I +wrote above, so I'll explain a little more: + +My test programs writes byte-for-byte. Let's say our FS/OS has 4k page- +and blocksize, that means 4096 writes that all write the same disk blocks. + +Intelligent liers will see that the the 2nd and all further writes +obsolete the former writes who still reside in the internal cache, and +drop those former writes from cache, effectively going up to 4k +writes/spindle turn. + +Dumb liers will keep the obsolete writes in the write cache / queue, and +so won't be caught by my program. (Note that I have no proof that such +disks actually exist, but I have enough experience with hardware that I +won't be surprised.) + + +HTH, +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Wed May 10 12:14:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9FA8C9FA1B0 + for ; + Wed, 10 May 2006 12:14:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10539-08 + for ; + Wed, 10 May 2006 12:14:30 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fw.greenpeace.org (fw.greenpeace.org [212.19.215.77]) + by postgresql.org (Postfix) with ESMTP id 9AD739FA8EF + for ; + Wed, 10 May 2006 12:14:29 -0300 (ADT) +Received: (from root@localhost) by fw.greenpeace.org (8.9.3c/8.6.12) id + RAA57295 for ; + Wed, 10 May 2006 17:14:28 +0200 (CEST) +Received: by fw.greenpeace.org (TUNIX/Firewall SMTP Server) + for id sma036091; + Wed, 10 May 06 17:01:56 +0200 +Received: from bb.nli.gl3 (root@localhost) + by bb.nli.gl3 (8.12.8/8.12.5) with SMTP id k4AF1uh5026056 + for ; Wed, 10 May 2006 17:01:56 +0200 +Received: from maila.greenpeace.org (fw.nli.gl3 [192.168.31.7]) + by bb.nli.gl3 (8.12.8/8.13.3) with ESMTP id k4AF1u7j026047; + Wed, 10 May 2006 17:01:56 +0200 +Received: from [192.168.200.143] (vpni.greenpeace.org [212.19.215.76]) + (authenticated (128 bits)) + by maila.greenpeace.org (8.13.4/8.11.6) with ESMTP id k4AF1tBO026589 + (using TLSv1/SSLv3 with cipher RC4-MD5 (128 bits) verified NO); + Wed, 10 May 2006 17:01:56 +0200 +Message-ID: <44620083.10503@superlativ.dk> +Date: Wed, 10 May 2006 17:02:27 +0200 +From: Nis Jorgensen +User-Agent: Opera/7.5 (Windows; U; Longhorn; en-US; rv:1.0.0) +MIME-Version: 1.0 +To: Clemens Eisserer +CC: pgsql-performance@postgresql.org +Subject: Re: Question about explain-command... +References: <194f62550605100449p2d200fc3pfe501da895cfcc00@mail.gmail.com> +In-Reply-To: <194f62550605100449p2d200fc3pfe501da895cfcc00@mail.gmail.com> +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Anti-Virus: Kaspersky Anti-Virus for MailServers 5.5.2/RELEASE, + bases: 25072005 #131892, status: clean +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/259 +X-Sequence-Number: 19046 + +I will try answering your questions. Please note that I am a newbie myself. + +Clemens Eisserer wrote + +> All primary keys are indixed, and this is what explain tells me: +> Unique (cost=15.67..16.69 rows=34 width=115) +> -> Sort (cost=15.67..15.75 rows=34 width=115) +> Sort Key: customer.email, customer."key", customer.anrede, customer.str +> asse, customer.plz, customer.ort, customer.vorname, customer.nachname, custtype. +> name, customer.land, customer.datanotvalid +> -> Hash Left Join (cost=6.16..14.80 rows=34 width=115) +> Hash Cond: ("outer".prodgroup = "inner"."key") +> -> Hash Left Join (cost=4.97..13.10 rows=34 width=119) +> Hash Cond: ("outer".custgroup = "inner"."key") +> -> Hash Left Join (cost=3.88..11.49 rows=34 width=111) +> Hash Cond: ("outer".goodsid = "inner"."key") +> -> Hash Left Join (cost=1.98..9.08 +> rows=34 width=11 1) +> Hash Cond: ("outer"."key" = "inner".custid) +> -> Seq Scan on customer (cost=0.00..6.10 rows =34 width=107) +> Filter: ((nachname)::text ~~ +> '%au%'::text ) +> -> Hash (cost=1.78..1.78 rows=78 width=8) +> -> Seq Scan on sells (cost=0.00..1.78 r ows=78 width=8) +> -> Hash (cost=1.72..1.72 rows=72 width=8) +> -> Seq Scan on goods (cost=0.00..1.72 rows=72 width=8) +> -> Hash (cost=1.08..1.08 rows=8 width=16) +> -> Seq Scan on custtype (cost=0.00..1.08 +> rows=8 wid th=16) +> -> Hash (cost=1.15..1.15 rows=15 width=4) +> -> Seq Scan on prodtype (cost=0.00..1.15 rows=15 width=4) + + +> What does the hash-lines mean, does that mean my query does not use +> the indices at all? + +Yes. Probably each table fits nicely into a single disk read, so reading +both the index AND the table is going to be twice as expensive. + +> Why are some table-names and some column-names surrounded by ' " '? +> Are they threated as text-columns? + +They are either names generated by postgres ("outer" and "inner") or +field names which are also reserved words in SQL ("key"). You can always +use double quotes around a field name - you have to in some cases if +they are reserved words, and always if they contain "special characters" +(not sure from memory exactly which these are - at least spaces). I +recommend not to use either of these, even if a reserved word is the +best description of your field. + +Postgres seems to be a bit better than some other dbms's in allowing +unquoted reserved words as field names if there is no ambiguity. Thsis +may mean that you get a problem if your application is ever ported to a +different dbms. + +> I have to admit that the tables are just filled with test-data so the +> analyzer may take just a very simple way since almost no data is in... + +Try loading your tables with a realistic number of customers, and you +should see a change in the query plan to use your precious indexes. + +/Nis + + +From pgsql-performance-owner@postgresql.org Wed May 10 12:04:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A02769FA1B0; + Wed, 10 May 2006 12:04:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 13241-02; Wed, 10 May 2006 12:04:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id F33479FA32D; + Wed, 10 May 2006 12:04:13 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (p549D13DA.dip0.t-ipconnect.de + [84.157.19.218]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id B2BC765837; + Wed, 10 May 2006 17:05:24 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 4C25718222EEA; + Wed, 10 May 2006 17:04:25 +0200 (CEST) +Message-ID: <446200F9.3070109@logix-tt.com> +Date: Wed, 10 May 2006 17:04:25 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: PFC +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + + <758d5e7f0605090943p1bbfdae2p4cb28ba128288316@mail.gmail.com> + <4461EAAC.7030105@logix-tt.com> + +In-Reply-To: +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/255 +X-Sequence-Number: 19042 + +Hi, PFC, + +PFC wrote: + +> You need to do some processing to know how many rows the function +> would return. +> Often, this processing will be repeated in the function itself. +> Sometimes it's very simple (ie. the function will RETURN NEXT each +> element in an array, you know the array length...) +> Sometimes, for functions returning few rows, it might be faster to +> compute the entire result set in the cost estimator. + +I know, but we only have to estmiate the number of rows to give a hint +to the query planner, so we can use lots of simplifications. + +E. G. for generate_series we return ($2-$1)/$3, and for some functions +even constant estimates will be good enough. + +> - please execute me and store my results in a temporary storage, +> count the rows returned, and plan the outer query accordingly + +That's an interesting idea. + +Markus + + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-general-owner@postgresql.org Wed May 10 12:10:08 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E48689FA3A6; + Wed, 10 May 2006 12:10:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 15982-03; Wed, 10 May 2006 12:10:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id 26C3A9FA2FA; + Wed, 10 May 2006 12:10:00 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 10 May 2006 15:10:00 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 10 May 2006 10:10:00 -0500 +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +From: Scott Marlowe +To: Douglas McNaught +Cc: Bruce Momjian , Steve Atkins , + PostgreSQL General , + "Pgsql-Performance ((E-mail))" +In-Reply-To: <87r732ndat.fsf@suzuka.mcnaught.org> +References: <200605100102.k4A12wa12853@candle.pha.pa.us> + <1147272179.9755.18.camel@state.g2switchworks.com> + <87r732ndat.fsf@suzuka.mcnaught.org> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1147273799.9755.20.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 10 May 2006 10:10:00 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/436 +X-Sequence-Number: 95228 + +On Wed, 2006-05-10 at 09:51, Douglas McNaught wrote: +> Scott Marlowe writes: +> +> > On Tue, 2006-05-09 at 20:02, Bruce Momjian wrote: +> +> >> You do if the controller thinks the data is already on the drives and +> >> removes it from its cache. +> > +> > Bruce, re-read what I wrote. The escalades tell the drives to TURN OFF +> > THEIR OWN CACHE. +> +> Some ATA drives would lie about that too IIRC. Hopefully they've +> stopped doing it in the SATA era. + +Ugh. Now that would make for a particularly awful bit of firmware +implementation. I'd think that if I found a SATA drive doing that I'd +be likely to strike the manufacturer off of the list for possible future +purchases... + +From pgsql-performance-owner@postgresql.org Wed May 10 12:10:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6C2599FA1B0 + for ; + Wed, 10 May 2006 12:10:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 09965-09 + for ; + Wed, 10 May 2006 12:10:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id BC0BD9FA3A6 + for ; + Wed, 10 May 2006 12:10:39 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4AFAbNp001041; + Wed, 10 May 2006 11:10:37 -0400 (EDT) +To: Michael Glaesemann +cc: Chris , pgsql-performance@postgresql.org +Subject: Re: UNSUBSCRIBE +In-reply-to: <7AA3D75C-4821-4B78-A3F7-4ED94B8F85C2@seespotcode.net> +References: + <44615C15.5040803@gmail.com> <26504.1147238111@sss.pgh.pa.us> + <4461787C.3010705@gmail.com> <26692.1147239778@sss.pgh.pa.us> + <7AA3D75C-4821-4B78-A3F7-4ED94B8F85C2@seespotcode.net> +Comments: In-reply-to Michael Glaesemann + message dated "Wed, 10 May 2006 15:14:08 +0900" +Date: Wed, 10 May 2006 11:10:37 -0400 +Message-ID: <1038.1147273837@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/257 +X-Sequence-Number: 19044 + +Michael Glaesemann writes: +> (And are there mail readers out there that can pick those subscribe/ +> unsubscribe headers from the list emails? Now *that'd* be sweet.) + +Well, in my fairly ancient copy of exmh, any message with such headers +causes an additional menu to appear: + + List... + help + unsubscribe + owner + subscribe + archive + id + post + +Clicking on any of these takes you to the webpage referenced by the header. +(It looks like it's just generating menu entries for whatever "List-foo" +headers it finds; the behavior isn't real helpful for headers that don't +contain URLs, but most of these do.) + +Whether there's anything mass-market that knows about these headers, +I dunno, but it's not like the spec hasn't been out there plenty long +enough: + ftp://ftp.rfc-editor.org/in-notes/rfc2369.txt + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed May 10 12:12:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 31B109FA2FA + for ; + Wed, 10 May 2006 12:12:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 16075-04 + for ; + Wed, 10 May 2006 12:11:59 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id B1F799FA1B0 + for ; + Wed, 10 May 2006 12:11:58 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 10 May 2006 15:11:57 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 10 May 2006 10:11:57 -0500 +Subject: Re: in memory views +From: Scott Marlowe +To: Thomas Vatter +Cc: Tino Wildenhain , pgsql-performance@postgresql.org +In-Reply-To: <4461B899.4030502@network-inventory.de> +References: <4461AFFF.7060200@network-inventory.de> + <4461B3DE.6030700@wildenhain.de> + <4461B899.4030502@network-inventory.de> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1147273917.9755.22.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 10 May 2006 10:11:57 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/258 +X-Sequence-Number: 19045 + +On Wed, 2006-05-10 at 04:55, Thomas Vatter wrote: +> Tino Wildenhain wrote: +> +> > Thomas Vatter schrieb: +> > +> >> is there a possibility for creating views or temp tables in memory to +> >> avoid disk io when user makes select operations? +> > +> > +> > No need. The data will be available in OS and database caches if +> > they are really required often. If not, tune up the caches and +> > do a regular "pre select". +> > +> > Regards +> > Tino +> > +> > +> +> hmm, I am selecting a resultset with 1300 rows joined from 12 tables. +> with jdbc I am waiting 40 seconds until the first row appears. The +> following rows appear really fast but the 40 seconds are a problem. + +Are you selecting the whole set at once? Or are you placing it into a +cursor? + +What happens if you do this by declaring it as a cursor and then +fetching the first row? + +From pgsql-performance-owner@postgresql.org Wed May 10 12:53:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E03719FA1B0 + for ; + Wed, 10 May 2006 12:53:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 18369-10 + for ; + Wed, 10 May 2006 12:52:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fw.greenpeace.org (fw.greenpeace.org [212.19.215.77]) + by postgresql.org (Postfix) with ESMTP id 87D179FA2FA + for ; + Wed, 10 May 2006 12:52:57 -0300 (ADT) +Received: (from root@localhost) by fw.greenpeace.org (8.9.3c/8.6.12) id + RAA23766 for ; + Wed, 10 May 2006 17:52:56 +0200 (CEST) +Received: by fw.greenpeace.org (TUNIX/Firewall SMTP Server) + for id sma084377; + Wed, 10 May 06 17:29:44 +0200 +Received: from bb.nli.gl3 (root@localhost) + by bb.nli.gl3 (8.12.8/8.12.5) with SMTP id k4AFTilw027343 + for ; Wed, 10 May 2006 17:29:44 +0200 +Received: from maila.greenpeace.org (fw.nli.gl3 [192.168.31.7]) + by bb.nli.gl3 (8.12.8/8.13.3) with ESMTP id k4AFTa7j027322; + Wed, 10 May 2006 17:29:36 +0200 +Received: from [192.168.200.143] (vpni.greenpeace.org [212.19.215.76]) + (authenticated (128 bits)) + by maila.greenpeace.org (8.13.4/8.11.6) with ESMTP id k4AFTZco027041 + (using TLSv1/SSLv3 with cipher RC4-MD5 (128 bits) verified NO); + Wed, 10 May 2006 17:29:36 +0200 +Message-ID: <446206FF.7050603@superlativ.dk> +Date: Wed, 10 May 2006 17:30:07 +0200 +From: Nis Jorgensen +User-Agent: Opera/7.5 (Windows; U; Longhorn; en-US; rv:1.0.0) +MIME-Version: 1.0 +To: Martijn van Oosterhout +CC: PFC , Markus Schaber , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +References: <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + + <758d5e7f0605090943p1bbfdae2p4cb28ba128288316@mail.gmail.com> + <4461EAAC.7030105@logix-tt.com> + <20060510145551.GB14476@svana.org> +In-Reply-To: <20060510145551.GB14476@svana.org> +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Anti-Virus: Kaspersky Anti-Virus for MailServers 5.5.2/RELEASE, + bases: 25072005 #131892, status: clean +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/263 +X-Sequence-Number: 19050 + +Martijn van Oosterhout wrote: +> On Wed, May 10, 2006 at 04:38:31PM +0200, PFC wrote: +>> You need to do some processing to know how many rows the function +>> would return. +>> Often, this processing will be repeated in the function itself. +>> Sometimes it's very simple (ie. the function will RETURN NEXT each +>> element in an array, you know the array length...) +>> Sometimes, for functions returning few rows, it might be faster to +>> compute the entire result set in the cost estimator. +> +> I think the best would probably be to assign a constant. An SRF will +> generally return between one of 1-10, 10-100, 100-1000, etc. You don't +> need exact number, you just need to get within an order of magnitude +> and a constant will work fine for that. +> +> How many functions sometimes return one and sometimes a million rows? + +It will probably be quite common for the number to depend on the number +of rows in other tables. Even if this is fairly constant within one db +(some assumption), it is likely to be different in others using the same +function definition. Perhaps a better solution would be to cache the +result of the estimator function. + +/Nis + + + +From pgsql-performance-owner@postgresql.org Wed May 10 12:40:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 99AEB9FA32D + for ; + Wed, 10 May 2006 12:40:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 21704-01 + for ; + Wed, 10 May 2006 12:40:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from h57078.serverkompetenz.net (talk-net.net [81.169.128.8]) + by postgresql.org (Postfix) with ESMTP id 286249FA3A6 + for ; + Wed, 10 May 2006 12:40:48 -0300 (ADT) +Received: from [192.168.115.250] (e178173057.adsl.alicedsl.de [85.178.173.57]) + by h57078.serverkompetenz.net (Postfix) with ESMTP id 8350350C72A; + Wed, 10 May 2006 17:39:09 +0200 (CEST) +Message-ID: <4462098D.2010500@network-inventory.de> +Date: Wed, 10 May 2006 17:41:01 +0200 +From: Thomas Vatter +User-Agent: Mozilla Thunderbird 1.0.5 (Windows/20050711) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Scott Marlowe +CC: Tino Wildenhain , + pgsql-performance@postgresql.org +Subject: Re: in memory views +References: <4461AFFF.7060200@network-inventory.de> + <4461B3DE.6030700@wildenhain.de> + <4461B899.4030502@network-inventory.de> + <1147273917.9755.22.camel@state.g2switchworks.com> +In-Reply-To: <1147273917.9755.22.camel@state.g2switchworks.com> +Content-Type: multipart/alternative; + boundary="------------040800040001030901050508" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/260 +X-Sequence-Number: 19047 + +This is a multi-part message in MIME format. +--------------040800040001030901050508 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Scott Marlowe wrote: + +>On Wed, 2006-05-10 at 04:55, Thomas Vatter wrote: +> +> +>>Tino Wildenhain wrote: +>> +>> +>> +>>>Thomas Vatter schrieb: +>>> +>>> +>>> +>>>>is there a possibility for creating views or temp tables in memory to +>>>>avoid disk io when user makes select operations? +>>>> +>>>> +>>>No need. The data will be available in OS and database caches if +>>>they are really required often. If not, tune up the caches and +>>>do a regular "pre select". +>>> +>>>Regards +>>>Tino +>>> +>>> +>>> +>>> +>>hmm, I am selecting a resultset with 1300 rows joined from 12 tables. +>>with jdbc I am waiting 40 seconds until the first row appears. The +>>following rows appear really fast but the 40 seconds are a problem. +>> +>> +> +>Are you selecting the whole set at once? Or are you placing it into a +>cursor? +> +>What happens if you do this by declaring it as a cursor and then +>fetching the first row? +> +>---------------------------(end of broadcast)--------------------------- +>TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> +> +> +> + +I do executeQuery(), for the resultSet I do next() and return one row, +but wait, I have to review the logic in this area, I can tell you tomorrow + +regards +tom + + +--------------040800040001030901050508 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + + +Scott Marlowe wrote: +
+
On Wed, 2006-05-10 at 04:55, Thomas Vatter wrote:
+  
+
+
Tino Wildenhain wrote:
+
+    
+
+
Thomas Vatter schrieb:
+
+      
+
+
is there a possibility for creating views or temp tables in memory to 
+avoid disk io when user makes select operations?
+        
+
+
+No need. The data will be available in OS and database caches if
+they are really required often. If not, tune up the caches and
+do a regular "pre select".
+
+Regards
+Tino
+
+
+      
+
+
hmm, I am selecting a resultset with 1300 rows joined from 12 tables. 
+with jdbc I am waiting 40 seconds until the first row appears. The 
+following rows appear really fast but the 40 seconds are a problem.
+    
+
+

+Are you selecting the whole set at once?  Or are you placing it into a
+cursor?
+
+What happens if you do this by declaring it as a cursor and then
+fetching the first row?
+
+---------------------------(end of broadcast)---------------------------
+TIP 4: Have you searched our list archives?
+
+               http://archives.postgresql.org
+
+
+  
+
+
+I do executeQuery(), for the resultSet I do next() and return one row, +but wait, I have to review the logic in this area, I can tell you +tomorrow
+
+regards
+tom
+
+
+
+ + + +--------------040800040001030901050508-- + +From pgsql-performance-owner@postgresql.org Wed May 10 12:45:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E1A189FA2FA + for ; + Wed, 10 May 2006 12:45:17 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 17904-09 + for ; + Wed, 10 May 2006 12:45:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id DA27B9FA1B0 + for ; + Wed, 10 May 2006 12:45:07 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 10 May 2006 15:45:06 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 10 May 2006 10:45:06 -0500 +Subject: Re: in memory views +From: Scott Marlowe +To: Thomas Vatter +Cc: Tino Wildenhain , pgsql-performance@postgresql.org +In-Reply-To: <4462098D.2010500@network-inventory.de> +References: <4461AFFF.7060200@network-inventory.de> + <4461B3DE.6030700@wildenhain.de> + <4461B899.4030502@network-inventory.de> + <1147273917.9755.22.camel@state.g2switchworks.com> + <4462098D.2010500@network-inventory.de> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1147275906.9755.25.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 10 May 2006 10:45:06 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/261 +X-Sequence-Number: 19048 + +On Wed, 2006-05-10 at 10:41, Thomas Vatter wrote: +> Scott Marlowe wrote: + +> > What happens if you do this by declaring it as a cursor and then +> > fetching the first row? + +> > +> +> I do executeQuery(), for the resultSet I do next() and return one row, +> but wait, I have to review the logic in this area, I can tell you +> tomorrow + + +A good short test is to run explain analyze on the query from the psql +command line. If it shows an execution time of significantly less than +what you get from you application, then it is likely that the real +problem is that your application is receiving the whole result set via +libpq and waiting for that. A cursor will solve that problem. + +From pgsql-performance-owner@postgresql.org Wed May 10 12:45:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E70249FA2FA + for ; + Wed, 10 May 2006 12:45:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 18050-10 + for ; + Wed, 10 May 2006 12:45:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.refusion.com (mail.refusion.com [213.144.155.20]) + by postgresql.org (Postfix) with ESMTP id 9D55B9FA1B0 + for ; + Wed, 10 May 2006 12:45:49 -0300 (ADT) +Received: from iwing by mail.refusion.com + (Cipher TLSv1:RC4-MD5:128) (MDaemon PRO v9.0.1) + with ESMTP id md50000666595.msg + for ; Wed, 10 May 2006 17:45:47 +0200 +Message-ID: <0dbe01c67448$c9834b10$6402a8c0@iwing> +From: +To: "Thomas Vatter" +Cc: +References: <4461AFFF.7060200@network-inventory.de> + <4461B3DE.6030700@wildenhain.de> + <4461B899.4030502@network-inventory.de> + <1147273917.9755.22.camel@state.g2switchworks.com> + <4462098D.2010500@network-inventory.de> +Subject: Re: in memory views +Date: Wed, 10 May 2006 17:45:37 +0200 +MIME-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="iso-8859-1"; + reply-type=original +Content-Transfer-Encoding: 7bit +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.3790.2663 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2663 +X-Authenticated-Sender: info@alternize.com +X-Spam-Processed: mail.refusion.com, Wed, 10 May 2006 17:45:47 +0200 + (not processed: message from trusted or authenticated source) +X-MDRemoteIP: 80.238.206.247 +X-Return-Path: me@alternize.com +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +X-ClamAV: Pass +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/262 +X-Sequence-Number: 19049 + +> is there a possibility for creating views or temp tables in memory to +> avoid disk io when user makes select operations? + +you might also want to look into "materialized views": +http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html +http://www.varlena.com/varlena/GeneralBits/64.php + +this helped us alot when we had slow queries involving many tables. + +cheers, +thomas + + +From pgsql-performance-owner@postgresql.org Wed May 10 12:59:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1C9D59F9430; + Wed, 10 May 2006 12:59:27 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 19953-09; Wed, 10 May 2006 12:59:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (unknown [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 254389F9D82; + Wed, 10 May 2006 12:59:17 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (p549D13DA.dip0.t-ipconnect.de + [84.157.19.218]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 591D965837; + Wed, 10 May 2006 18:00:28 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id CF136181520E4; + Wed, 10 May 2006 17:59:27 +0200 (CEST) +Message-ID: <44620DDE.1080500@logix-tt.com> +Date: Wed, 10 May 2006 17:59:26 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Cc: pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +References: <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + + <758d5e7f0605090943p1bbfdae2p4cb28ba128288316@mail.gmail.com> + <4461EAAC.7030105@logix-tt.com> + <20060510145551.GB14476@svana.org> + <446206FF.7050603@superlativ.dk> +In-Reply-To: <446206FF.7050603@superlativ.dk> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/264 +X-Sequence-Number: 19051 + +Hi, Nils, + +Nis Jorgensen wrote: + +> It will probably be quite common for the number to depend on the number +> of rows in other tables. Even if this is fairly constant within one db +> (some assumption), it is likely to be different in others using the same +> function definition. Perhaps a better solution would be to cache the +> result of the estimator function. + +Sophisticated estimator functions are free to use the pg_statistics +views for their row count estimation. + + +HTH, +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Wed May 10 15:09:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 230AA9FA2CB + for ; + Wed, 10 May 2006 15:09:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 43824-02 + for ; + Wed, 10 May 2006 15:09:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id A4CA49FA293 + for ; + Wed, 10 May 2006 15:09:39 -0300 (ADT) +Received: (qmail 3024 invoked by uid 500); 10 May 2006 18:10:51 -0000 +Date: Wed, 10 May 2006 13:10:51 -0500 +From: Bruno Wolff III +To: Tom Lane +Cc: Chris , pgsql-performance@postgresql.org +Subject: Re: UNSUBSCRIBE +Message-ID: <20060510181051.GB11382@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Tom Lane , Chris , + pgsql-performance@postgresql.org +References: + <44615C15.5040803@gmail.com> <26504.1147238111@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <26504.1147238111@sss.pgh.pa.us> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/265 +X-Sequence-Number: 19052 + +On Wed, May 10, 2006 at 01:15:11 -0400, + Tom Lane wrote: +> +> Maybe the real problem is at the other end of the process, ie we should +> require some evidence of a greater-than-room-temp IQ to subscribe in the +> first place? + +I suspect it is more lazyiness that smarts. That had to at least figure out +how to respond to the confirm message in the first place in order to get +subscribed. +My theory is that they don't want to take the trouble to figure out how to +unsubscribe when they (think that they) can just send a message to the list +(not even the admin) asking to be unsubscribed and it will (well actually won't +on these lists) happen. + +Maybe posts with "unsubscribe" in the subject could be held for moderation +and/or get an automated reply with instructions for unsubscribing. + +From pgsql-performance-owner@postgresql.org Wed May 10 15:40:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1EF8D9FA38E; + Wed, 10 May 2006 15:40:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 46626-07; Wed, 10 May 2006 15:40:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id B23869FA2CB; + Wed, 10 May 2006 15:40:38 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 3E45256423; Wed, 10 May 2006 13:40:37 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 10 May 2006 13:40:35 -0500 +Date: Wed, 10 May 2006 13:40:35 -0500 +From: "Jim C. Nasby" +To: PFC +Cc: Christian Kratzer , Tom Lane , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Message-ID: <20060510184035.GN99570@pervasive.com> +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060510:lists@peufeu.com::ldLZu33CJzoBMmhF:05+9T +X-Hashcash: 1:20:060510:ck@cksoft.de::F8S37ItXtwUNHKb0:000006dYg +X-Hashcash: + 1:20:060510:tgl@sss.pgh.pa.us::R8qRRaV2D5mOnyK1:00000000000000000000 + 0000000000000000000000002h31 +X-Hashcash: + 1:20:060510:pgsql-performance@postgresql.org::IzEqT570jAOX1qcL:00000 + 0000000000000000000000004T7T +X-Hashcash: + 1:20:060510:pgsql-hackers@postgresql.org::15HNVcmPgvxM5aR4:000000000 + 00000000000000000000000026S7 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/266 +X-Sequence-Number: 19053 + +On Tue, May 09, 2006 at 11:33:42AM +0200, PFC wrote: +> - Repeating the query might yield different results if records were +> added or deleted in the meantime. + +BTW, SET TRANSACTION ISOLATION LEVEL serializeable or BEGIN ISOLATION +LEVEL serializeable would cure that. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 10 16:00:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5821C9FA2CB; + Wed, 10 May 2006 16:00:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 48483-07; Wed, 10 May 2006 16:00:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id F32629FA293; + Wed, 10 May 2006 16:00:15 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id B817D56427; Wed, 10 May 2006 14:00:12 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 10 May 2006 14:00:11 -0500 +Date: Wed, 10 May 2006 14:00:11 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: PFC , Mitchell Skinner , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Message-ID: <20060510190011.GO99570@pervasive.com> +References: + <20060509105214.P90693@vesihiisi.cksoft.de> + + <20060509113337.M90693@vesihiisi.cksoft.de> + <20060509103632.GD29652@svana.org> + <1147190285.32304.43.camel@firebolt> + <16680.1147201981@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <16680.1147201981@sss.pgh.pa.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060510:tgl@sss.pgh.pa.us::fd6cOBf4ergK/nuR:00000000000000000000 + 00000000000000000000000023Ug +X-Hashcash: 1:20:060510:lists@peufeu.com::WL9oOPhGeGPRqCIG:01v47 +X-Hashcash: 1:20:060510:mitch@arctur.us::Bdrl+NcGdKAyrsoD:000tI+ +X-Hashcash: + 1:20:060510:pgsql-performance@postgresql.org::UHKHVD+uGfIV6Ss2:00000 + 000000000000000000000000108s +X-Hashcash: + 1:20:060510:pgsql-hackers@postgresql.org::RiG0QYuTB4ETpn7Q:000000000 + 00000000000000000000000016cX +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/267 +X-Sequence-Number: 19054 + +On Tue, May 09, 2006 at 03:13:01PM -0400, Tom Lane wrote: +> PFC writes: +> > Fun thing is, the rowcount from a temp table (which is the problem here) +> > should be available without ANALYZE ; as the temp table is not concurrent, +> > it would be simple to inc/decrement a counter on INSERT/DELETE... +> +> No, because MVCC rules still apply. + +But can anything ever see more than one version of what's in the table? +Even if you rollback you should still be able to just update a row +counter because nothing else would be able to see what was rolled back. + +Speaking of which, if a temp table is defined as ON COMMIT DROP or +DELETE ROWS, there shouldn't be any need to store xmin/xmax, only +cmin/cmax, correct? +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 10 16:06:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5DC5A9FA2CB; + Wed, 10 May 2006 16:06:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 52387-01; Wed, 10 May 2006 16:06:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 31F7D9FA293; + Wed, 10 May 2006 16:06:22 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 9902B56423; Wed, 10 May 2006 14:06:18 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 10 May 2006 14:06:17 -0500 +Date: Wed, 10 May 2006 14:06:17 -0500 +From: "Jim C. Nasby" +To: PFC +Cc: Martijn van Oosterhout , + Christian Kratzer , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Message-ID: <20060510190617.GP99570@pervasive.com> +References: <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + + <20060509113337.M90693@vesihiisi.cksoft.de> + <20060509103632.GD29652@svana.org> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060510:lists@peufeu.com::6oI8MFcEC1sEinum:00wnV +X-Hashcash: + 1:20:060510:kleptog@svana.org::VjNsdqJd+1uwjGRN:00000000000000000000 + 0000000000000000000000001aNS +X-Hashcash: 1:20:060510:ck@cksoft.de::dihZsR+n0vslkjEg:000000eR9 +X-Hashcash: + 1:20:060510:pgsql-performance@postgresql.org::VdKCtZK9hNMDcvH8:00000 + 0000000000000000000000003UAr +X-Hashcash: + 1:20:060510:pgsql-hackers@postgresql.org::QbeFix+IPoiJl31b:000000000 + 0000000000000000000000003jKb +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/268 +X-Sequence-Number: 19055 + +On Tue, May 09, 2006 at 01:29:56PM +0200, PFC wrote: +> 0.101 ms BEGIN +> 1.451 ms CREATE TEMPORARY TABLE tmp ( a INTEGER NOT NULL, b INTEGER NOT +> NULL, c TIMESTAMP NOT NULL, d INTEGER NOT NULL ) ON COMMIT DROP +> 0.450 ms INSERT INTO tmp SELECT * FROM bookmarks ORDER BY annonce_id DESC +> LIMIT 20 +> 0.443 ms ANALYZE tmp +> 0.365 ms SELECT * FROM tmp +> 0.310 ms DROP TABLE tmp +> 32.918 ms COMMIT +> +> CREATING the table is OK, but what happens on COMMIT ? I hear the +> disk seeking frantically. +> +> With fsync=off, I get this : +> +> 0.090 ms BEGIN +> 1.103 ms CREATE TEMPORARY TABLE tmp ( a INTEGER NOT NULL, b INTEGER NOT +> NULL, c TIMESTAMP NOT NULL, d INTEGER NOT NULL ) ON COMMIT DROP +> 0.439 ms INSERT INTO tmp SELECT * FROM bookmarks ORDER BY annonce_id DESC +> LIMIT 20 +> 0.528 ms ANALYZE tmp +> 0.364 ms SELECT * FROM tmp +> 0.313 ms DROP TABLE tmp +> 0.688 ms COMMIT +> +> Getting closer ? +> I'm betting on system catalogs updates. I get the same timings with +> ROLLBACK instead of COMMIT. Temp tables have a row in pg_class... + +Have you tried getting a profile of what exactly PostgreSQL is doing +that takes so long when creating a temp table? + +BTW, I suspect catalogs might be the answer, which is why Oracle has you +define a temp table once (which does all the work of putting it in the +catalog) and then you just use it accordingly in each individual +session. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-hackers-owner@postgresql.org Wed May 10 16:22:48 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 15F979FA2CB + for ; + Wed, 10 May 2006 16:22:48 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 52659-03 + for ; + Wed, 10 May 2006 16:22:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 4FADB9FA293 + for ; + Wed, 10 May 2006 16:22:36 -0300 (ADT) +Received: (qmail 1547 invoked from network); 10 May 2006 21:24:00 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 10 May 2006 21:24:00 +0200 +Date: Wed, 10 May 2006 21:23:59 +0200 +To: pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] Big IN() clauses etc : feature proposal +References: + <20060509105214.P90693@vesihiisi.cksoft.de> + + <20060509113337.M90693@vesihiisi.cksoft.de> + <20060509103632.GD29652@svana.org> + <1147190285.32304.43.camel@firebolt> + <16680.1147201981@sss.pgh.pa.us> + <20060510190011.GO99570@pervasive.com> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <20060510190011.GO99570@pervasive.com> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/280 +X-Sequence-Number: 83145 + + +> Speaking of which, if a temp table is defined as ON COMMIT DROP or +> DELETE ROWS, there shouldn't be any need to store xmin/xmax, only +> cmin/cmax, correct? + + Yes, that's that type of table I was thinking about... + You can't ROLLBACK a transaction on such a table. + You can however rollback a savepoint and use "INSERT INTO tmp SELECT FROM +tmp" which implies MVCC (I think ?) + + I was suggesting to be able to use FETCH (from a cursor) in the same way +as SELECT, effectively using a named cursor (DECLARE...) as a simpler, +faster version of a temporary table, but there is another (better ?) +option : + + If rowcount estimates for functions are implemented, then a set-returning +function can be written, which takes as argument a named cursor, and +returns its rows. + It would have accurate rowcount estimation (if the cursor is WITH SCROLL, +which is the case here, rows are stored, so we know their number). + + Then you could do : + +DECLARE my_cursor ... AS (query that we only want to do once) +SELECT ... FROM table1 JOIN fetch_cursor( my_cursor ) ON ... +SELECT ... FROM table2 JOIN fetch_cursor( my_cursor ) ON ... +SELECT ... FROM table3 JOIN fetch_cursor( my_cursor ) ON ... + + No need to redefine the FETCH keyword. + An interesting functionalyty with minimal hassle. + + +From pgsql-performance-owner@postgresql.org Wed May 10 16:24:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8A8B19FA293; + Wed, 10 May 2006 16:24:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 60147-01; Wed, 10 May 2006 16:24:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 9B9C79FA2CB; + Wed, 10 May 2006 16:24:04 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id EF78B56423; Wed, 10 May 2006 14:24:02 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 10 May 2006 14:24:01 -0500 +Date: Wed, 10 May 2006 14:24:01 -0500 +From: "Jim C. Nasby" +To: PFC +Cc: Greg Stark , Tom Lane , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Message-ID: <20060510192401.GQ99570@pervasive.com> +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <8764kfz1iq.fsf@stark.xeocode.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060510:lists@peufeu.com::973DZgWGC1GJY6h5:02F3G +X-Hashcash: 1:20:060510:gsstark@mit.edu::sqqc+KfnlFcS66cs:005RH6 +X-Hashcash: + 1:20:060510:tgl@sss.pgh.pa.us::a4PwbL9wVXzHgTj/:00000000000000000000 + 00000000000000000000000002zJ +X-Hashcash: + 1:20:060510:pgsql-performance@postgresql.org::/tClCKZlatJC2V5E:00000 + 0000000000000000000000007qoE +X-Hashcash: + 1:20:060510:pgsql-hackers@postgresql.org::H5ucAzvVJDx6euml:000000000 + 0000000000000000000000000ZtX +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/269 +X-Sequence-Number: 19056 + +On Tue, May 09, 2006 at 06:29:31PM +0200, PFC wrote: +> You mean the cursors'storage is in fact the same internal machinery +> as a temporary table ? + +Use the source, Luke... + +See tuplestore_begin_heap in backend/utils/sort/tuplestore.c and +heap_create_with_catalog in backend/catalog/heap.c. You'll find that +creating a tuplestore is far easier than creating a temp table. + +Perhaps it would be worth creating a class of temporary tables that used +a tuplestore, although that would greatly limit what could be done with +that temp table. + +Something else worth considering is not using the normal catalog methods +for storing information about temp tables, but hacking that together +would probably be a rather large task. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-hackers-owner@postgresql.org Wed May 10 16:26:14 2006 +X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 23E999FA38E + for ; + Wed, 10 May 2006 16:26:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 49187-10 + for ; + Wed, 10 May 2006 16:26:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 6D5BF9FA2CB + for ; + Wed, 10 May 2006 16:25:59 -0300 (ADT) +Received: (qmail 1586 invoked from network); 10 May 2006 21:27:22 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 10 May 2006 21:27:22 +0200 +Date: Wed, 10 May 2006 21:27:21 +0200 +To: pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] Big IN() clauses etc : feature proposal +References: <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <20060509105214.P90693@vesihiisi.cksoft.de> + + <20060509113337.M90693@vesihiisi.cksoft.de> + <20060509103632.GD29652@svana.org> + <20060510190617.GP99570@pervasive.com> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <20060510190617.GP99570@pervasive.com> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/282 +X-Sequence-Number: 83147 + + + +> Have you tried getting a profile of what exactly PostgreSQL is doing +> that takes so long when creating a temp table? + + Nope, I'm not proficient in the use of these tools (I stopped using C +some time ago). + +> BTW, I suspect catalogs might be the answer, + + Probably, because : + + - Temp tables don't use fsync (I hope) + - Catalogs do + - fsync=off makes COMMIT fast + - fsync=on makes COMMIT slow + - fsync=on and using ANALYZE makes COMMIT slower (more updates to the +catalogs I guess) + +> which is why Oracle has you +> define a temp table once (which does all the work of putting it in the +> catalog) and then you just use it accordingly in each individual +> session. + + Interesting (except for the ANALYZE bit...) + + + +From pgsql-performance-owner@postgresql.org Wed May 10 16:34:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 615349FA38E + for ; + Wed, 10 May 2006 16:34:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 59971-03 + for ; + Wed, 10 May 2006 16:34:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 2317E9FA293 + for ; + Wed, 10 May 2006 16:34:17 -0300 (ADT) +Received: (qmail 1656 invoked from network); 10 May 2006 21:35:41 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 10 May 2006 21:35:41 +0200 +Date: Wed, 10 May 2006 21:35:39 +0200 +To: "Jim C. Nasby" +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Cc: pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <8764kfz1iq.fsf@stark.xeocode.com> + <20060510192401.GQ99570@pervasive.com> +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Message-ID: +In-Reply-To: <20060510192401.GQ99570@pervasive.com> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/270 +X-Sequence-Number: 19057 + + +> On Tue, May 09, 2006 at 06:29:31PM +0200, PFC wrote: +>> You mean the cursors'storage is in fact the same internal machinery +>> as a temporary table ? +> +> Use the source, Luke... + + LOL, yeah, I should have, sorry. + +> See tuplestore_begin_heap in backend/utils/sort/tuplestore.c and +> heap_create_with_catalog in backend/catalog/heap.c. You'll find that +> creating a tuplestore is far easier than creating a temp table. + + I had used intuition (instead of the source) to come at the same +conclusion regarding the level of complexity of these two... + But I'll look at the source ;) + +> Perhaps it would be worth creating a class of temporary tables that used +> a tuplestore, although that would greatly limit what could be done with +> that temp table. + + Just selecting from it I guess, but that's all that's needed. Anymore +would duplicate the functionality of a temp table. + I find cursors awkward. The application can FETCH from them, but postgres +itself can't do it in SQL, unless using FOR.. IN in plpgsql... + It would be a powerful addition to be able to split queries, factor out +common parts between multiple queries, etc, using this system, it can even +be used to execute an inner part of a query, then plan the rest according +to the results and execute it... without the overhead of a temp table. + + + + +From pgsql-performance-owner@postgresql.org Wed May 10 17:53:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 39A0C9FA38E + for ; + Wed, 10 May 2006 17:53:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 24825-03 + for ; + Wed, 10 May 2006 17:53:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from h57078.serverkompetenz.net (talk-net.net [81.169.128.8]) + by postgresql.org (Postfix) with ESMTP id E66F99FA293 + for ; + Wed, 10 May 2006 17:53:48 -0300 (ADT) +Received: from [192.168.115.250] (e178173057.adsl.alicedsl.de [85.178.173.57]) + by h57078.serverkompetenz.net (Postfix) with ESMTP id 043B750C77D; + Wed, 10 May 2006 22:52:06 +0200 (CEST) +Message-ID: <446252E8.8000304@network-inventory.de> +Date: Wed, 10 May 2006 22:54:00 +0200 +From: Thomas Vatter +User-Agent: Mozilla Thunderbird 1.0.5 (Windows/20050711) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Scott Marlowe +CC: Tino Wildenhain , + pgsql-performance@postgresql.org +Subject: Re: in memory views +References: <4461AFFF.7060200@network-inventory.de> + <4461B3DE.6030700@wildenhain.de> + <4461B899.4030502@network-inventory.de> + <1147273917.9755.22.camel@state.g2switchworks.com> + <4462098D.2010500@network-inventory.de> + <1147275906.9755.25.camel@state.g2switchworks.com> +In-Reply-To: <1147275906.9755.25.camel@state.g2switchworks.com> +Content-Type: multipart/alternative; + boundary="------------030109030204080602000009" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/271 +X-Sequence-Number: 19058 + +This is a multi-part message in MIME format. +--------------030109030204080602000009 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Scott Marlowe wrote: + +>On Wed, 2006-05-10 at 10:41, Thomas Vatter wrote: +> +> +>>Scott Marlowe wrote: +>> +>> +> +> +> +>>>What happens if you do this by declaring it as a cursor and then +>>>fetching the first row? +>>> +>>> +> +> +> +>>> +>>> +>>> +>>I do executeQuery(), for the resultSet I do next() and return one row, +>>but wait, I have to review the logic in this area, I can tell you +>>tomorrow +>> +>> +> +> +>A good short test is to run explain analyze on the query from the psql +>command line. If it shows an execution time of significantly less than +>what you get from you application, then it is likely that the real +>problem is that your application is receiving the whole result set via +>libpq and waiting for that. A cursor will solve that problem. +> +>---------------------------(end of broadcast)--------------------------- +>TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> +> +> +> +Yes, the difference between psql command line and application is 6 +seconds to 40 seconds. It is +exactly the step resultSet = excecuteQuery() that needs 40 seconds. I +use next() as a cursor +through the resultSet, but I fear this is not enough, do I have to use +createStatement(resultSetType, +resultSetConcurrency) respectively prepareStatement (resultSetType, +resultSetConcurrency) to +achieve the cursor behaviour? + +regards +tom + + +--------------030109030204080602000009 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + +Scott Marlowe wrote: +
+
On Wed, 2006-05-10 at 10:41, Thomas Vatter wrote:
+  
+
+
Scott Marlowe wrote: 
+    
+
+

+  
+
+
+
What happens if you do this by declaring it as a cursor and then
+fetching the first row?
+      
+
+
+

+  
+
+
+
  
+      
+
+
I do executeQuery(), for the resultSet I do next() and return one row,
+but wait, I have to review the logic in this area, I can tell you
+tomorrow
+    
+
+

+
+A good short test is to run explain analyze on the query from the psql
+command line.  If it shows an execution time of significantly less than
+what you get from you application, then it is likely that the real
+problem is that your application is receiving the whole result set via
+libpq and waiting for that.  A cursor will solve that problem.
+
+---------------------------(end of broadcast)---------------------------
+TIP 4: Have you searched our list archives?
+
+               http://archives.postgresql.org
+
+
+  
+
+Yes, the difference between psql command line and application is 6 +seconds to 40 seconds. It is
+exactly the step resultSet = excecuteQuery() that needs 40 seconds. I +use next() as a cursor
+through the resultSet, but I fear this is not enough, do I have to use +createStatement(resultSetType,
+resultSetConcurrency) respectively prepareStatement (resultSetType, +resultSetConcurrency) to
+achieve the cursor behaviour?
+
+regards
+tom
+
+ + + +--------------030109030204080602000009-- + +From pgsql-performance-owner@postgresql.org Wed May 10 18:01:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C5F329FA293 + for ; + Wed, 10 May 2006 18:01:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 32323-02 + for ; + Wed, 10 May 2006 18:01:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id CC59A9FA2CB + for ; + Wed, 10 May 2006 18:01:23 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Wed, 10 May 2006 21:01:22 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 10 May 2006 16:01:22 -0500 +Subject: Re: in memory views +From: Scott Marlowe +To: Thomas Vatter +Cc: Tino Wildenhain , pgsql-performance@postgresql.org +In-Reply-To: <446252E8.8000304@network-inventory.de> +References: <4461AFFF.7060200@network-inventory.de> + <4461B3DE.6030700@wildenhain.de> + <4461B899.4030502@network-inventory.de> + <1147273917.9755.22.camel@state.g2switchworks.com> + <4462098D.2010500@network-inventory.de> + <1147275906.9755.25.camel@state.g2switchworks.com> + <446252E8.8000304@network-inventory.de> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1147294882.9755.55.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Wed, 10 May 2006 16:01:22 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/272 +X-Sequence-Number: 19059 + +On Wed, 2006-05-10 at 15:54, Thomas Vatter wrote: + +> > +> Yes, the difference between psql command line and application is 6 +> seconds to 40 seconds. It is +> exactly the step resultSet = excecuteQuery() that needs 40 seconds. I +> use next() as a cursor +> through the resultSet, but I fear this is not enough, do I have to use +> createStatement(resultSetType, +> resultSetConcurrency) respectively prepareStatement (resultSetType, +> resultSetConcurrency) to +> achieve the cursor behaviour? + +Not sure. I don't use a lot of prepared statements. I tend to build +queries and throw the at the database. In that instance, it's done +like: + +create cursor cursorname as select (rest of query here); +fetch from cursorname; + +You can find more on cursors here: + +http://www.postgresql.org/docs/8.1/interactive/sql-declare.html + +Not sure if you can use them with prepared statements, or if prepared +statements have their own kind of implementation. + +From pgsql-performance-owner@postgresql.org Wed May 10 18:09:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0099A9FA2CB + for ; + Wed, 10 May 2006 18:09:02 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 34423-02 + for ; + Wed, 10 May 2006 18:08:52 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id AD6249FA293 + for ; + Wed, 10 May 2006 18:08:50 -0300 (ADT) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [67.90.96.2] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 89956650; Wed, 10 May 2006 14:08:49 -0700 +From: "Dave Dutcher" +To: "'Thomas Vatter'" +Cc: +Subject: Re: in memory views +Date: Wed, 10 May 2006 16:08:49 -0500 +Message-ID: <01fd01c67475$ef17d530$8300a8c0@tridecap.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_01FE_01C6744C.0641CD30" +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook, Build 10.0.2627 +Importance: Normal +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +In-reply-to: <446252E8.8000304@network-inventory.de> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/273 +X-Sequence-Number: 19060 + +This is a multi-part message in MIME format. + +------=_NextPart_000_01FE_01C6744C.0641CD30 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit + +Are you using the Postgres JDBC driver? Or are you using an ODBC JDBC +driver? The Postgres specific driver is usually faster. + + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Thomas +Vatter +Sent: Wednesday, May 10, 2006 3:54 PM +To: Scott Marlowe +Cc: Tino Wildenhain; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] in memory views + + +Scott Marlowe wrote: + +On Wed, 2006-05-10 at 10:41, Thomas Vatter wrote: + + + +Scott Marlowe wrote: + + + + + + + +What happens if you do this by declaring it as a cursor and then + +fetching the first row? + + + + + + + + + + + +I do executeQuery(), for the resultSet I do next() and return one row, + +but wait, I have to review the logic in this area, I can tell you + +tomorrow + + + + + + + +A good short test is to run explain analyze on the query from the psql + +command line. If it shows an execution time of significantly less than + +what you get from you application, then it is likely that the real + +problem is that your application is receiving the whole result set via + +libpq and waiting for that. A cursor will solve that problem. + + + +---------------------------(end of broadcast)--------------------------- + +TIP 4: Have you searched our list archives? + + + + http://archives.postgresql.org + + + + + + + +Yes, the difference between psql command line and application is 6 +seconds to 40 seconds. It is +exactly the step resultSet = excecuteQuery() that needs 40 seconds. I +use next() as a cursor +through the resultSet, but I fear this is not enough, do I have to use +createStatement(resultSetType, +resultSetConcurrency) respectively prepareStatement (resultSetType, +resultSetConcurrency) to +achieve the cursor behaviour? + +regards +tom + + + + +------=_NextPart_000_01FE_01C6744C.0641CD30 +Content-Type: text/html; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable + + + + +Message + + + +
Are=20 +you using the Postgres JDBC driver?  Or are you using an ODBC JDBC=20 +driver?  The Postgres specific driver is usually=20 +faster.
+
 
+
 
+ +
+
-----Original Message-----
From:=20 + pgsql-performance-owner@postgresql.org=20 + [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of = +Thomas=20 + Vatter
Sent: Wednesday, May 10, 2006 3:54 PM
To: = +Scott=20 + Marlowe
Cc: Tino Wildenhain;=20 + pgsql-performance@postgresql.org
Subject: Re: [PERFORM] in = +memory=20 + views

Scott Marlowe wrote:=20 +
On Wed, 2006-05-10 at 10:41, Thomas =
+Vatter wrote:
+  
+
Scott Marlowe wrote:=20
+    

+  
+
+
What happens if you do =
+this by declaring it as a cursor and then
+fetching the first row?
+      

+  
+
+
 =20
+      
I do executeQuery(), for the =
+resultSet I do next() and return one row,
+but wait, I have to review the logic in this area, I can tell you
+tomorrow
+    

+
+A good short test is to run explain analyze on the query from the psql
+command line.  If it shows an execution time of significantly less than
+what you get from you application, then it is likely that the real
+problem is that your application is receiving the whole result set via
+libpq and waiting for that.  A cursor will solve that problem.
+
+---------------------------(end of broadcast)---------------------------
+TIP 4: Have you searched our list archives?
+
+               http://archives.postgresql.org
+
+
+  
Yes, the difference between psql command line and=20 + application is 6 seconds to 40 seconds. It is
exactly the step = +resultSet =3D=20 + excecuteQuery() that needs 40 seconds. I use next() as a = +cursor
through the=20 + resultSet, but I fear this is not enough, do I have to use=20 + createStatement(resultSetType,
resultSetConcurrency) respectively=20 + prepareStatement (resultSetType, resultSetConcurrency) to
achieve = +the=20 + cursor = +behaviour?

regards
tom

+ +------=_NextPart_000_01FE_01C6744C.0641CD30-- + + +From pgsql-performance-owner@postgresql.org Wed May 10 18:18:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 600B69FA2CB + for ; + Wed, 10 May 2006 18:18:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 26897-08 + for ; + Wed, 10 May 2006 18:18:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from h57078.serverkompetenz.net (talk-net.net [81.169.128.8]) + by postgresql.org (Postfix) with ESMTP id AEEEE9FA293 + for ; + Wed, 10 May 2006 18:18:44 -0300 (ADT) +Received: from [192.168.115.250] (e178173057.adsl.alicedsl.de [85.178.173.57]) + by h57078.serverkompetenz.net (Postfix) with ESMTP id 4A65950C73F; + Wed, 10 May 2006 23:17:05 +0200 (CEST) +Message-ID: <446258C2.2070805@network-inventory.de> +Date: Wed, 10 May 2006 23:18:58 +0200 +From: Thomas Vatter +User-Agent: Mozilla Thunderbird 1.0.5 (Windows/20050711) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Dave Dutcher +CC: pgsql-performance@postgresql.org +Subject: Re: in memory views +References: <01fd01c67475$ef17d530$8300a8c0@tridecap.com> +In-Reply-To: <01fd01c67475$ef17d530$8300a8c0@tridecap.com> +Content-Type: multipart/alternative; + boundary="------------030203090904080403040502" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/274 +X-Sequence-Number: 19061 + +This is a multi-part message in MIME format. +--------------030203090904080403040502 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 8bit + +Dave Dutcher wrote: + +> Are you using the Postgres JDBC driver? Or are you using an ODBC JDBC +> driver? The Postgres specific driver is usually faster. + + +I'm using the postgres driver + +regards +tom + + + + +> +> +> +> -----Original Message----- +> *From:* pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org] *On Behalf Of +> *Thomas Vatter +> *Sent:* Wednesday, May 10, 2006 3:54 PM +> *To:* Scott Marlowe +> *Cc:* Tino Wildenhain; pgsql-performance@postgresql.org +> *Subject:* Re: [PERFORM] in memory views +> +> Scott Marlowe wrote: +> +>>On Wed, 2006-05-10 at 10:41, Thomas Vatter wrote: +>> +>> +>>>Scott Marlowe wrote: +>>> +>>> +>> +>> +>> +>>>>What happens if you do this by declaring it as a cursor and then +>>>>fetching the first row? +>>>> +>>>> +>> +>> +>> +>>>> +>>>> +>>>> +>>>I do executeQuery(), for the resultSet I do next() and return one row, +>>>but wait, I have to review the logic in this area, I can tell you +>>>tomorrow +>>> +>>> +>> +>> +>>A good short test is to run explain analyze on the query from the psql +>>command line. If it shows an execution time of significantly less than +>>what you get from you application, then it is likely that the real +>>problem is that your application is receiving the whole result set via +>>libpq and waiting for that. A cursor will solve that problem. +>> +>>---------------------------(end of broadcast)--------------------------- +>>TIP 4: Have you searched our list archives? +>> +>> http://archives.postgresql.org +>> +>> +>> +>> +> Yes, the difference between psql command line and application is 6 +> seconds to 40 seconds. It is +> exactly the step resultSet = excecuteQuery() that needs 40 +> seconds. I use next() as a cursor +> through the resultSet, but I fear this is not enough, do I have to +> use createStatement(resultSetType, +> resultSetConcurrency) respectively prepareStatement +> (resultSetType, resultSetConcurrency) to +> achieve the cursor behaviour? +> +> regards +> tom +> + + +-- +Mit freundlichen Gr��en / Regards +Vatter + +Network Inventory Software +Sun Microsystems Principal Partner + +www.network-inventory.de +Tel. 030-79782510 +E-Mail thomas.vatter@network-inventory.de + + +--------------030203090904080403040502 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + +Dave Dutcher wrote: +
+ + Message + +
Are you using the Postgres JDBC driver?  Or +are you using an ODBC JDBC driver?  The Postgres specific driver is +usually faster.
+
+
+I'm using the postgres driver
+
+regards
+tom
+
+
+
+
+
+
 
+
 
+
+
-----Original Message-----
+ From:
pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Thomas +Vatter
+ Sent: Wednesday, May 10, 2006 3:54 PM
+ To: Scott Marlowe
+ Cc: Tino Wildenhain; pgsql-performance@postgresql.org
+ Subject: Re: [PERFORM] in memory views
+
+
+Scott Marlowe wrote: +
+
On Wed, 2006-05-10 at 10:41, Thomas Vatter wrote:
+  
+
+
Scott Marlowe wrote: 
+    
+
+

+  
+
+
+
What happens if you do this by declaring it as a cursor and then
+fetching the first row?
+      
+
+
+

+  
+
+
+
  
+      
+
+
I do executeQuery(), for the resultSet I do next() and return one row,
+but wait, I have to review the logic in this area, I can tell you
+tomorrow
+    
+
+

+
+A good short test is to run explain analyze on the query from the psql
+command line.  If it shows an execution time of significantly less than
+what you get from you application, then it is likely that the real
+problem is that your application is receiving the whole result set via
+libpq and waiting for that.  A cursor will solve that problem.
+
+---------------------------(end of broadcast)---------------------------
+TIP 4: Have you searched our list archives?
+
+               http://archives.postgresql.org
+
+
+  
+
+Yes, the difference between psql command line and application is 6 +seconds to 40 seconds. It is
+exactly the step resultSet = excecuteQuery() that needs 40 seconds. I +use next() as a cursor
+through the resultSet, but I fear this is not enough, do I have to use +createStatement(resultSetType,
+resultSetConcurrency) respectively prepareStatement (resultSetType, +resultSetConcurrency) to
+achieve the cursor behaviour?
+
+regards
+tom
+
+
+
+
+
+
-- 
+Mit freundlichen Grüßen / Regards
+Vatter
+ 
+Network Inventory Software
+Sun Microsystems Principal Partner
+
+www.network-inventory.de
+Tel. 030-79782510
+E-Mail thomas.vatter@network-inventory.de
+
+ + + +--------------030203090904080403040502-- + +From pgsql-performance-owner@postgresql.org Wed May 10 18:24:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 13EBE9FA293 + for ; + Wed, 10 May 2006 18:24:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 31938-10 + for ; + Wed, 10 May 2006 18:24:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from h57078.serverkompetenz.net (talk-net.net [81.169.128.8]) + by postgresql.org (Postfix) with ESMTP id C7FC89FA2CB + for ; + Wed, 10 May 2006 18:24:30 -0300 (ADT) +Received: from [192.168.115.250] (e178173057.adsl.alicedsl.de [85.178.173.57]) + by h57078.serverkompetenz.net (Postfix) with ESMTP id 49B0350C741; + Wed, 10 May 2006 23:22:50 +0200 (CEST) +Message-ID: <44625A1B.7080809@network-inventory.de> +Date: Wed, 10 May 2006 23:24:43 +0200 +From: Thomas Vatter +User-Agent: Mozilla Thunderbird 1.0.5 (Windows/20050711) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Scott Marlowe +CC: Tino Wildenhain , + pgsql-performance@postgresql.org +Subject: Re: in memory views +References: <4461AFFF.7060200@network-inventory.de> + <4461B3DE.6030700@wildenhain.de> + <4461B899.4030502@network-inventory.de> + <1147273917.9755.22.camel@state.g2switchworks.com> + <4462098D.2010500@network-inventory.de> + <1147275906.9755.25.camel@state.g2switchworks.com> + <446252E8.8000304@network-inventory.de> + <1147294882.9755.55.camel@state.g2switchworks.com> +In-Reply-To: <1147294882.9755.55.camel@state.g2switchworks.com> +Content-Type: multipart/alternative; + boundary="------------080300010005000406030103" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/275 +X-Sequence-Number: 19062 + +This is a multi-part message in MIME format. +--------------080300010005000406030103 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Scott Marlowe wrote: + +>On Wed, 2006-05-10 at 15:54, Thomas Vatter wrote: +> +> +> +>>> +>>> +>>> +>>Yes, the difference between psql command line and application is 6 +>>seconds to 40 seconds. It is +>>exactly the step resultSet = excecuteQuery() that needs 40 seconds. I +>>use next() as a cursor +>>through the resultSet, but I fear this is not enough, do I have to use +>>createStatement(resultSetType, +>>resultSetConcurrency) respectively prepareStatement (resultSetType, +>>resultSetConcurrency) to +>>achieve the cursor behaviour? +>> +>> +> +>Not sure. I don't use a lot of prepared statements. I tend to build +>queries and throw the at the database. In that instance, it's done +>like: +> +>create cursor cursorname as select (rest of query here); +>fetch from cursorname; +> +>You can find more on cursors here: +> +>http://www.postgresql.org/docs/8.1/interactive/sql-declare.html +> +>Not sure if you can use them with prepared statements, or if prepared +>statements have their own kind of implementation. +> +>---------------------------(end of broadcast)--------------------------- +>TIP 6: explain analyze is your friend +> +> +> +> + +Yes, I have used embedded sql and create cursor, fetch before I started +with jdbc, seems that +I have to find out if new jdbc has a better way than simply resultSet = +statement.executeQuery(). + +regards +tom + + +--------------080300010005000406030103 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + +Scott Marlowe wrote: +
+
On Wed, 2006-05-10 at 15:54, Thomas Vatter wrote:
+
+  
+
+
+
  
+      
+
+
Yes, the difference between psql command line and application is 6
+seconds to 40 seconds. It is
+exactly the step resultSet = excecuteQuery() that needs 40 seconds. I
+use next() as a cursor
+through the resultSet, but I fear this is not enough, do I have to use
+createStatement(resultSetType, 
+resultSetConcurrency) respectively prepareStatement (resultSetType,
+resultSetConcurrency) to
+achieve the cursor behaviour?
+    
+
+

+Not sure.  I don't use a lot of prepared statements.  I tend to build
+queries and throw the at the database.  In that instance, it's done
+like:
+
+create cursor cursorname as select (rest of query here);
+fetch from cursorname;
+
+You can find more on cursors here:
+
+http://www.postgresql.org/docs/8.1/interactive/sql-declare.html
+
+Not sure if you can use them with prepared statements, or if prepared
+statements have their own kind of implementation.
+
+---------------------------(end of broadcast)---------------------------
+TIP 6: explain analyze is your friend
+
+
+  
+
+
+Yes, I have used embedded sql and create cursor, fetch before I started +with jdbc, seems that
+I have to find out if new jdbc has a better way than simply resultSet = +statement.executeQuery().
+
+regards
+tom
+
+
+
+ + + +--------------080300010005000406030103-- + +From pgsql-performance-owner@postgresql.org Wed May 10 19:10:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4630E9FA3A6 + for ; + Wed, 10 May 2006 19:10:57 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 37951-06 + for ; + Wed, 10 May 2006 19:10:52 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 1CC9C9F931E + for ; + Wed, 10 May 2006 19:10:51 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id CC8BB56435; Wed, 10 May 2006 17:10:50 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 10 May 2006 17:10:48 -0500 +Date: Wed, 10 May 2006 17:10:48 -0500 +From: "Jim C. Nasby" +To: Mario Splivalo +Cc: Tom Lane , pgsql-performance@postgresql.org +Subject: Re: Lot'sa joins - performance tip-up, please? +Message-ID: <20060510221048.GX99570@pervasive.com> +References: <1146533274.14006.11.camel@localhost.localdomain> + <17793.1146679117@sss.pgh.pa.us> + <1146753957.8538.30.camel@localhost.localdomain> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1146753957.8538.30.camel@localhost.localdomain> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060510:msplival@jagor.srce.hr::wMSTinPS9QnpN8GM:000000000000000 + 000000000000000000000000EmHx +X-Hashcash: + 1:20:060510:tgl@sss.pgh.pa.us::PKiGNbaMBfDpaXNO:00000000000000000000 + 000000000000000000000000CDzX +X-Hashcash: + 1:20:060510:pgsql-performance@postgresql.org::D6Xkqj24YGZVRAMg:00000 + 0000000000000000000000002U5S +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/276 +X-Sequence-Number: 19063 + +On Thu, May 04, 2006 at 04:45:57PM +0200, Mario Splivalo wrote: +Well, here's the problem... + +> -> Nested Loop (cost=0.00..176144.30 rows=57925 width=26) +> (actual time=1074.984..992536.243 rows=57925 loops=1) +> -> Seq Scan on ticketing_codes_played +> (cost=0.00..863.25 rows=57925 width=8) (actual time=74.479..2047.993 +> rows=57925 loops=1) +> -> Index Scan using ticketing_codes_pk on +> ticketing_codes (cost=0.00..3.01 rows=1 width=18) (actual +> time=17.044..17.052 rows=1 loops=57925) +> Index Cond: (ticketing_codes.code_id = +> "outer".code_id) + +Anyone have any idea why on earth it's doing that instead of a hash or +merge join? + +In any case, try swapping the order of ticketing_codes_played and +ticketing_codes. Actually, that'd probably make it worse. + +Try SET enable_nestloop = off; +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 10 19:16:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7A14B9FA3A3 + for ; + Wed, 10 May 2006 19:16:34 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 38541-07 + for ; + Wed, 10 May 2006 19:16:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail63.csoft.net (mail63.csoft.net [205.205.214.4]) + by postgresql.org (Postfix) with SMTP id A184C9F931E + for ; + Wed, 10 May 2006 19:16:24 -0300 (ADT) +Received: (qmail 3652 invoked by uid 1112); 10 May 2006 22:16:23 -0000 +Date: Wed, 10 May 2006 17:16:23 -0500 (EST) +From: Kris Jurka +X-X-Sender: books@leary2.csoft.net +To: Thomas Vatter +cc: Scott Marlowe , + Tino Wildenhain , pgsql-performance@postgresql.org +Subject: Re: in memory views +In-Reply-To: <44625A1B.7080809@network-inventory.de> +Message-ID: +References: <4461AFFF.7060200@network-inventory.de> + <4461B3DE.6030700@wildenhain.de> + <4461B899.4030502@network-inventory.de> + <1147273917.9755.22.camel@state.g2switchworks.com> + <4462098D.2010500@network-inventory.de> + <1147275906.9755.25.camel@state.g2switchworks.com> + <446252E8.8000304@network-inventory.de> + <1147294882.9755.55.camel@state.g2switchworks.com> + <44625A1B.7080809@network-inventory.de> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/277 +X-Sequence-Number: 19064 + + + +On Wed, 10 May 2006, Thomas Vatter wrote: + +> Yes, the difference between psql command line and application is 6 +> seconds to 40 seconds. It is exactly the step resultSet = +> excecuteQuery() that needs 40 seconds. I use next() as a cursor through +> the resultSet, but I fear this is not enough, do I have to use +> createStatement(resultSetType, resultSetConcurrency) respectively +> prepareStatement (resultSetType, resultSetConcurrency) to achieve the +> cursor behaviour? + +http://jdbc.postgresql.org/documentation/81/query.html#query-with-cursor + +Kris Jurka + + +From pgsql-performance-owner@postgresql.org Wed May 10 19:20:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 44B459FA3A3 + for ; + Wed, 10 May 2006 19:20:03 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 41584-02 + for ; + Wed, 10 May 2006 19:19:52 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id DBADF9F931E + for ; + Wed, 10 May 2006 19:19:52 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 8B4A956427; Wed, 10 May 2006 17:19:51 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 10 May 2006 17:19:49 -0500 +Date: Wed, 10 May 2006 17:19:49 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: Michael Glaesemann , Chris , + pgsql-performance@postgresql.org +Subject: Re: UNSUBSCRIBE +Message-ID: <20060510221949.GY99570@pervasive.com> +References: + <44615C15.5040803@gmail.com> <26504.1147238111@sss.pgh.pa.us> + <4461787C.3010705@gmail.com> <26692.1147239778@sss.pgh.pa.us> + <7AA3D75C-4821-4B78-A3F7-4ED94B8F85C2@seespotcode.net> + <1038.1147273837@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1038.1147273837@sss.pgh.pa.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060510:tgl@sss.pgh.pa.us::jkgK2JcQZARv3obI:00000000000000000000 + 0000000000000000000000002Dmh +X-Hashcash: + 1:20:060510:grzm@seespotcode.net::6Qa6BAldSXcQK3D0:00000000000000000 + 0000000000000000000000000WiM +X-Hashcash: + 1:20:060510:dmagick@gmail.com::FlYV6aKPtr0vwZ20:00000000000000000000 + 000000000000000000000000CcXu +X-Hashcash: + 1:20:060510:pgsql-performance@postgresql.org::CeTZdgfqOE6eWN/g:00000 + 0000000000000000000000003tfq +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/278 +X-Sequence-Number: 19065 + +On Wed, May 10, 2006 at 11:10:37AM -0400, Tom Lane wrote: +> Michael Glaesemann writes: +> > (And are there mail readers out there that can pick those subscribe/ +> > unsubscribe headers from the list emails? Now *that'd* be sweet.) +> +> Well, in my fairly ancient copy of exmh, any message with such headers +> causes an additional menu to appear: + +Based on the constantly broken threading in the lists, I'd bet that less +than 20% of posters use something more sophisticated than MS LookOut!, +and I'm sure that the stats for subscribers are far worse. + +Does majordomo have an option to automagically handle such posts that +are sent to the post address instead of the admin address? I know +mailman can do that... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 10 19:21:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id EA5B19FA3A6 + for ; + Wed, 10 May 2006 19:21:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 41976-03 + for ; + Wed, 10 May 2006 19:21:09 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 0BA029FA3A3 + for ; + Wed, 10 May 2006 19:21:08 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id BEA7A56431; Wed, 10 May 2006 17:21:07 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 10 May 2006 17:21:06 -0500 +Date: Wed, 10 May 2006 17:21:06 -0500 +From: "Jim C. Nasby" +To: Bruno Wolff III , Tom Lane , + Chris , pgsql-performance@postgresql.org +Subject: Re: UNSUBSCRIBE +Message-ID: <20060510222105.GZ99570@pervasive.com> +References: + <44615C15.5040803@gmail.com> <26504.1147238111@sss.pgh.pa.us> + <20060510181051.GB11382@wolff.to> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060510181051.GB11382@wolff.to> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060510:bruno@wolff.to::N7y00G9viHJezGbK:0002GKJ +X-Hashcash: + 1:20:060510:tgl@sss.pgh.pa.us::pOscYIi1IFK0aruX:00000000000000000000 + 000000000000000000000000CACY +X-Hashcash: + 1:20:060510:dmagick@gmail.com::q6/zR3ZRVMRUG/aN:00000000000000000000 + 0000000000000000000000003ZcK +X-Hashcash: + 1:20:060510:pgsql-performance@postgresql.org::HrD4TiZxN38s1uUW:00000 + 0000000000000000000000000tXy +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/279 +X-Sequence-Number: 19066 + +On Wed, May 10, 2006 at 01:10:51PM -0500, Bruno Wolff III wrote: +> On Wed, May 10, 2006 at 01:15:11 -0400, +> Tom Lane wrote: +> > +> > Maybe the real problem is at the other end of the process, ie we should +> > require some evidence of a greater-than-room-temp IQ to subscribe in the +> > first place? +> +> I suspect it is more lazyiness that smarts. That had to at least figure out +> how to respond to the confirm message in the first place in order to get +> subscribed. +> My theory is that they don't want to take the trouble to figure out how to +> unsubscribe when they (think that they) can just send a message to the list +> (not even the admin) asking to be unsubscribed and it will (well actually won't +> on these lists) happen. + +The confirm email has a directly-clickable link, or you can just reply +to it. From that standpoint, it's substantially easier and simpler than +unsubscribing is... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 10 19:40:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D7AD39F931E + for ; + Wed, 10 May 2006 19:40:00 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 42024-09 + for ; + Wed, 10 May 2006 19:39:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 68D0B9FA3A6 + for ; + Wed, 10 May 2006 19:39:51 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)) + for pgsql-performance@postgresql.org; Wed, 10 May 2006 16:39:48 -0600 +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Transfer-Encoding: 7bit +Message-Id: <18620DA0-DE55-4A2C-9DDC-BCF5F478E886@clickspace.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: pgsql-performance@postgresql.org +From: Brian Wipf +Subject: Same query - Slow in production +Date: Wed, 10 May 2006 16:39:14 -0600 +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/280 +X-Sequence-Number: 19067 + +I'm trying to determine why an identical query is running +approximately 500 to 1000 times slower on our production database +compared to our backup database server. + +Both database servers are dual 2.3 GHz G5 Xserves running PostgreSQL +8.1.3; both are configured with 8GB of RAM with identical shared +memory settings; both postgresql.conf files are identical; both +databases have identical indexes defined. + +The three relevant tables are all clustered the same, although I'm +not sure when clustering was last performed on either server. All +three tables have recently been analyzed on both servers. + +The different explain plans for this query seem to be consistent on +both servers regardless of category and the production server is +consistently and drastically slower than the backup server. + +If anyone has any ideas on how to have the production server generate +the same explain plan as the backup server, or can suggest anything I +might want to try, I would greatly appreciate it. + +Brian Wipf +ClickSpace Interactive Inc. + + +Here's the query: + +SELECT ac.attribute_id +FROM attribute_category ac +WHERE is_browsable = 'true' AND + category_id = 1000962 AND + EXISTS ( SELECT 'X' + FROM product_attribute_value pav, + category_product cp + WHERE pav.attribute_id = ac.attribute_id AND + pav.status_code is null AND + pav.product_id = cp.product_id AND + cp.category_id = ac.category_id AND + cp.product_is_active = 'true' AND + cp.product_status_code = 'complete' + ) + +Explain plans: + +Fast (backup server): + Index Scan using attribute_category__category_id_fk_idx on +attribute_category ac (cost=0.00..47943.34 rows=7 width=4) (actual +time=0.110..0.263 rows=5 loops=1) + Index Cond: (category_id = 1000962) + Filter: (((is_browsable)::text = 'true'::text) AND (subplan)) + SubPlan + -> Nested Loop (cost=0.00..7983.94 rows=3 width=0) (actual +time=0.043..0.043 rows=1 loops=5) + -> Index Scan using +category_product__category_id_is_active_and_status_idx on +category_product cp (cost=0.00..4362.64 rows=1103 width=4) (actual +time=0.013..0.015 rows=2 loops=5) + Index Cond: ((category_id = $1) AND +((product_is_active)::text = 'true'::text) AND +((product_status_code)::text = 'complete'::text)) + -> Index Scan using +product_attribute_value__product_id_fk_idx on product_attribute_value +pav (cost=0.00..3.27 rows=1 width=4) (actual time=0.016..0.016 +rows=1 loops=8) + Index Cond: (pav.product_id = "outer".product_id) + Filter: ((attribute_id = $0) AND (status_code IS +NULL)) +Total runtime: 0.449 ms +(11 rows) + +Slow (production server): + Index Scan using attribute_category__category_id_fk_idx on +attribute_category ac (cost=0.00..107115.90 rows=7 width=4) (actual +time=1.472..464.437 rows=5 loops=1) + Index Cond: (category_id = 1000962) + Filter: (((is_browsable)::text = 'true'::text) AND (subplan)) + SubPlan + -> Nested Loop (cost=18.33..23739.70 rows=4 width=0) (actual +time=92.870..92.870 rows=1 loops=5) + -> Bitmap Heap Scan on product_attribute_value pav +(cost=18.33..8764.71 rows=2549 width=4) (actual time=10.191..45.672 +rows=5869 loops=5) + Recheck Cond: (attribute_id = $0) + Filter: (status_code IS NULL) + -> Bitmap Index Scan on +product_attribute_value__attribute_id_fk_idx (cost=0.00..18.33 +rows=2952 width=0) (actual time=9.160..9.160 rows=33330 loops=5) + Index Cond: (attribute_id = $0) + -> Index Scan using x_category_product_pk on +category_product cp (cost=0.00..5.86 rows=1 width=4) (actual +time=0.007..0.007 rows=0 loops=29345) + Index Cond: ((cp.category_id = $1) AND +("outer".product_id = cp.product_id)) + Filter: (((product_is_active)::text = 'true'::text) +AND ((product_status_code)::text = 'complete'::text)) +Total runtime: 464.667 ms +(14 rows) + +Table Descriptions: + +\d attribute_category; + Table "public.attribute_category" + Column | Type | Modifiers +-----------------+----------------------+----------- +attribute_id | integer | not null +category_id | integer | not null +is_browsable | character varying(5) | +is_required | character varying(5) | +sort_order | integer | +default_unit_id | integer | +Indexes: + "attribute_category_pk" PRIMARY KEY, btree (attribute_id, +category_id) + "attribute_category__attribute_id_fk_idx" btree (attribute_id) + "attribute_category__category_id_fk_idx" btree (category_id) +CLUSTER +Foreign-key constraints: + "attribute_category_attribute_fk" FOREIGN KEY (attribute_id) +REFERENCES attribute(attribute_id) DEFERRABLE INITIALLY DEFERRED + "attribute_category_category_fk" FOREIGN KEY (category_id) +REFERENCES category(category_id) DEFERRABLE INITIALLY DEFERRED + +\d product_attribute_value; + Table "public.product_attribute_value" + Column | Type | Modifiers +----------------------------+-----------------------+----------- +attribute_id | integer | not null +attribute_unit_id | integer | +attribute_value_id | integer | +boolean_value | character varying(5) | +decimal_value | numeric(30,10) | +product_attribute_value_id | integer | not null +product_id | integer | not null +product_reference_id | integer | +status_code | character varying(32) | +Indexes: + "product_attribute_value_pk" PRIMARY KEY, btree +(product_attribute_value_id) + "product_attribute_value__attribute_id_fk_idx" btree (attribute_id) + "product_attribute_value__attribute_unit_id_fk_idx" btree +(attribute_unit_id) + "product_attribute_value__attribute_value_id_fk_idx" btree +(attribute_value_id) + "product_attribute_value__decimal_value_idx" btree (decimal_value) + "product_attribute_value__product_id_fk_idx" btree (product_id) +CLUSTER + "product_attribute_value__product_reference_id_fk_idx" btree +(product_reference_id) +Foreign-key constraints: + "product_attribute_value_attribute_fk" FOREIGN KEY +(attribute_id) REFERENCES attribute(attribute_id) DEFERRABLE +INITIALLY DEFERRED + "product_attribute_value_attributeunit_fk" FOREIGN KEY +(attribute_unit_id) REFERENCES attribute_unit(attribute_unit_id) +DEFERRABLE INITIALLY DEFERRED + "product_attribute_value_attributevalue_fk" FOREIGN KEY +(attribute_value_id) REFERENCES attribute_value(attribute_value_id) +DEFERRABLE INITIALLY DEFERRED + "product_attribute_value_product_fk" FOREIGN KEY (product_id) +REFERENCES product(product_id) DEFERRABLE INITIALLY DEFERRED + "product_attribute_value_productreference_fk" FOREIGN KEY +(product_reference_id) REFERENCES product(product_id) DEFERRABLE +INITIALLY DEFERRED + +\d category_product; + Table "public.category_product" + Column | Type | Modifiers +---------------------+------------------------+----------- +category_id | integer | not null +product_id | integer | not null +en_name_sort_order | integer | +fr_name_sort_order | integer | +merchant_sort_order | integer | +price_sort_order | integer | +merchant_count | integer | +is_active | character varying(5) | +product_is_active | character varying(5) | +product_status_code | character varying(32) | +product_name_en | character varying(512) | +product_name_fr | character varying(512) | +product_click_count | integer | +Indexes: + "x_category_product_pk" PRIMARY KEY, btree (category_id, +product_id) + "category_product__category_id_is_active_and_status_idx" btree +(category_id, product_is_active, product_status_code) + "category_product__is_active_idx" btree (is_active) + "category_product__merchant_sort_order_idx" btree +(merchant_sort_order) + "x_category_product__category_id_fk_idx" btree (category_id) +CLUSTER + "x_category_product__product_id_fk_idx" btree (product_id) +Foreign-key constraints: + "x_category_product_category_fk" FOREIGN KEY (category_id) +REFERENCES category(category_id) DEFERRABLE INITIALLY DEFERRED + "x_category_product_product_fk" FOREIGN KEY (product_id) +REFERENCES product(product_id) DEFERRABLE INITIALLY DEFERRED + + +From pgsql-performance-owner@postgresql.org Wed May 10 20:07:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8B7389FA3A6 + for ; + Wed, 10 May 2006 20:07:53 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 44893-08 + for ; + Wed, 10 May 2006 20:07:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from h57078.serverkompetenz.net (talk-net.net [81.169.128.8]) + by postgresql.org (Postfix) with ESMTP id 5C6BD9F931E + for ; + Wed, 10 May 2006 20:07:48 -0300 (ADT) +Received: from [192.168.115.250] (e178173057.adsl.alicedsl.de [85.178.173.57]) + by h57078.serverkompetenz.net (Postfix) with ESMTP id 6873A50C533; + Thu, 11 May 2006 01:06:07 +0200 (CEST) +Message-ID: <44627250.5010908@network-inventory.de> +Date: Thu, 11 May 2006 01:08:00 +0200 +From: Thomas Vatter +User-Agent: Mozilla Thunderbird 1.0.5 (Windows/20050711) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Kris Jurka +CC: Scott Marlowe , + Tino Wildenhain , pgsql-performance@postgresql.org +Subject: Re: in memory views +References: <4461AFFF.7060200@network-inventory.de> + <4461B3DE.6030700@wildenhain.de> + <4461B899.4030502@network-inventory.de> + <1147273917.9755.22.camel@state.g2switchworks.com> + <4462098D.2010500@network-inventory.de> + <1147275906.9755.25.camel@state.g2switchworks.com> + <446252E8.8000304@network-inventory.de> + <1147294882.9755.55.camel@state.g2switchworks.com> + <44625A1B.7080809@network-inventory.de> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/281 +X-Sequence-Number: 19068 + +Kris Jurka wrote: + +> +> +> On Wed, 10 May 2006, Thomas Vatter wrote: +> +>> Yes, the difference between psql command line and application is 6 +>> seconds to 40 seconds. It is exactly the step resultSet = +>> excecuteQuery() that needs 40 seconds. I use next() as a cursor +>> through the resultSet, but I fear this is not enough, do I have to +>> use createStatement(resultSetType, resultSetConcurrency) respectively +>> prepareStatement (resultSetType, resultSetConcurrency) to achieve the +>> cursor behaviour? +> +> +> http://jdbc.postgresql.org/documentation/81/query.html#query-with-cursor +> +> Kris Jurka + + +I was just returning to my mailbox to report success, I was just a bit +faster than your e-mail, I have found the fetchSize function, it +reduces the delay to 6 seconds. thanks a lot to all who helped, this was +really great support, I am glad that the problem is solved + +tom + + + +From pgsql-performance-owner@postgresql.org Wed May 10 20:57:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id EB2519FA3A3 + for ; + Wed, 10 May 2006 20:57:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 53246-01 + for ; + Wed, 10 May 2006 20:57:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 63FAC9F931E + for ; + Wed, 10 May 2006 20:57:00 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Wed, 10 May 2006 17:56:56 -0600 +In-Reply-To: <18620DA0-DE55-4A2C-9DDC-BCF5F478E886@clickspace.com> +References: <18620DA0-DE55-4A2C-9DDC-BCF5F478E886@clickspace.com> +Mime-Version: 1.0 (Apple Message framework v749.3) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Brian Wipf +Subject: Re: Same query - Slow in production +Date: Wed, 10 May 2006 17:56:18 -0600 +To: Brian Wipf +X-Mailer: Apple Mail (2.749.3) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/282 +X-Sequence-Number: 19069 + +I added to the exists query qualifier: AND cp.category_id = 1000962 +(in addition to the cp.category_id = ac.category_id) + +Now I am getting a much better query plan on our production server: + +Index Scan using attribute_category__category_id_fk_idx on +attribute_category ac (cost=0.00..485.71 rows=7 width=4) (actual +time=0.104..0.351 rows=5 loops=1) + Index Cond: (category_id = 1000962) + Filter: (((is_browsable)::text = 'true'::text) AND (subplan)) + SubPlan + -> Nested Loop (cost=0.00..24.77 rows=1 width=0) (actual +time=0.058..0.058 rows=1 loops=5) + -> Index Scan using +x_category_product__category_id_fk_idx on category_product cp +(cost=0.00..6.01 rows=1 width=4) (actual time=0.014..0.014 rows=1 +loops=5) + Index Cond: ((category_id = $1) AND (category_id = +1000962)) + Filter: (((product_is_active)::text = 'true'::text) +AND ((product_status_code)::text = 'complete'::text)) + -> Index Scan using +product_attribute_value__product_id_fk_idx on product_attribute_value +pav (cost=0.00..18.75 rows=1 width=4) (actual time=0.041..0.041 +rows=1 loops=5) + Index Cond: (pav.product_id = "outer".product_id) + Filter: ((attribute_id = $0) AND (status_code IS +NULL)) +Total runtime: 0.558 ms +(12 rows) + +It is using the x_category_product__category_id_fk_idx on +category_product instead of the +category_product__category_id_is_active_and_status_idx index as on +our backup server. Still not sure what's causing the differences in +query execution between the servers, but at least the query is fast +again. + +Brian + +On 10-May-06, at 4:39 PM, Brian Wipf wrote: + +> I'm trying to determine why an identical query is running +> approximately 500 to 1000 times slower on our production database +> compared to our backup database server. +> +> Both database servers are dual 2.3 GHz G5 Xserves running +> PostgreSQL 8.1.3; both are configured with 8GB of RAM with +> identical shared memory settings; both postgresql.conf files are +> identical; both databases have identical indexes defined. +> +> The three relevant tables are all clustered the same, although I'm +> not sure when clustering was last performed on either server. All +> three tables have recently been analyzed on both servers. +> +> The different explain plans for this query seem to be consistent on +> both servers regardless of category and the production server is +> consistently and drastically slower than the backup server. +> +> If anyone has any ideas on how to have the production server +> generate the same explain plan as the backup server, or can suggest +> anything I might want to try, I would greatly appreciate it. +> +> Brian Wipf +> ClickSpace Interactive Inc. +> +> +> Here's the query: +> +> SELECT ac.attribute_id +> FROM attribute_category ac +> WHERE is_browsable = 'true' AND +> category_id = 1000962 AND +> EXISTS ( SELECT 'X' +> FROM product_attribute_value pav, +> category_product cp +> WHERE pav.attribute_id = ac.attribute_id AND +> pav.status_code is null AND +> pav.product_id = cp.product_id AND +> cp.category_id = ac.category_id AND +> cp.product_is_active = 'true' AND +> cp.product_status_code = 'complete' +> ) +> +> Explain plans: +> +> Fast (backup server): +> Index Scan using attribute_category__category_id_fk_idx on +> attribute_category ac (cost=0.00..47943.34 rows=7 width=4) (actual +> time=0.110..0.263 rows=5 loops=1) +> Index Cond: (category_id = 1000962) +> Filter: (((is_browsable)::text = 'true'::text) AND (subplan)) +> SubPlan +> -> Nested Loop (cost=0.00..7983.94 rows=3 width=0) (actual +> time=0.043..0.043 rows=1 loops=5) +> -> Index Scan using +> category_product__category_id_is_active_and_status_idx on +> category_product cp (cost=0.00..4362.64 rows=1103 width=4) (actual +> time=0.013..0.015 rows=2 loops=5) +> Index Cond: ((category_id = $1) AND +> ((product_is_active)::text = 'true'::text) AND +> ((product_status_code)::text = 'complete'::text)) +> -> Index Scan using +> product_attribute_value__product_id_fk_idx on +> product_attribute_value pav (cost=0.00..3.27 rows=1 width=4) +> (actual time=0.016..0.016 rows=1 loops=8) +> Index Cond: (pav.product_id = "outer".product_id) +> Filter: ((attribute_id = $0) AND (status_code IS +> NULL)) +> Total runtime: 0.449 ms +> (11 rows) +> +> Slow (production server): +> Index Scan using attribute_category__category_id_fk_idx on +> attribute_category ac (cost=0.00..107115.90 rows=7 width=4) +> (actual time=1.472..464.437 rows=5 loops=1) +> Index Cond: (category_id = 1000962) +> Filter: (((is_browsable)::text = 'true'::text) AND (subplan)) +> SubPlan +> -> Nested Loop (cost=18.33..23739.70 rows=4 width=0) (actual +> time=92.870..92.870 rows=1 loops=5) +> -> Bitmap Heap Scan on product_attribute_value pav +> (cost=18.33..8764.71 rows=2549 width=4) (actual time=10.191..45.672 +> rows=5869 loops=5) +> Recheck Cond: (attribute_id = $0) +> Filter: (status_code IS NULL) +> -> Bitmap Index Scan on +> product_attribute_value__attribute_id_fk_idx (cost=0.00..18.33 +> rows=2952 width=0) (actual time=9.160..9.160 rows=33330 loops=5) +> Index Cond: (attribute_id = $0) +> -> Index Scan using x_category_product_pk on +> category_product cp (cost=0.00..5.86 rows=1 width=4) (actual +> time=0.007..0.007 rows=0 loops=29345) +> Index Cond: ((cp.category_id = $1) AND +> ("outer".product_id = cp.product_id)) +> Filter: (((product_is_active)::text = +> 'true'::text) AND ((product_status_code)::text = 'complete'::text)) +> Total runtime: 464.667 ms +> (14 rows) +> +> Table Descriptions: +> +> \d attribute_category; +> Table "public.attribute_category" +> Column | Type | Modifiers +> -----------------+----------------------+----------- +> attribute_id | integer | not null +> category_id | integer | not null +> is_browsable | character varying(5) | +> is_required | character varying(5) | +> sort_order | integer | +> default_unit_id | integer | +> Indexes: +> "attribute_category_pk" PRIMARY KEY, btree (attribute_id, +> category_id) +> "attribute_category__attribute_id_fk_idx" btree (attribute_id) +> "attribute_category__category_id_fk_idx" btree (category_id) +> CLUSTER +> Foreign-key constraints: +> "attribute_category_attribute_fk" FOREIGN KEY (attribute_id) +> REFERENCES attribute(attribute_id) DEFERRABLE INITIALLY DEFERRED +> "attribute_category_category_fk" FOREIGN KEY (category_id) +> REFERENCES category(category_id) DEFERRABLE INITIALLY DEFERRED +> +> \d product_attribute_value; +> Table "public.product_attribute_value" +> Column | Type | Modifiers +> ----------------------------+-----------------------+----------- +> attribute_id | integer | not null +> attribute_unit_id | integer | +> attribute_value_id | integer | +> boolean_value | character varying(5) | +> decimal_value | numeric(30,10) | +> product_attribute_value_id | integer | not null +> product_id | integer | not null +> product_reference_id | integer | +> status_code | character varying(32) | +> Indexes: +> "product_attribute_value_pk" PRIMARY KEY, btree +> (product_attribute_value_id) +> "product_attribute_value__attribute_id_fk_idx" btree +> (attribute_id) +> "product_attribute_value__attribute_unit_id_fk_idx" btree +> (attribute_unit_id) +> "product_attribute_value__attribute_value_id_fk_idx" btree +> (attribute_value_id) +> "product_attribute_value__decimal_value_idx" btree (decimal_value) +> "product_attribute_value__product_id_fk_idx" btree (product_id) +> CLUSTER +> "product_attribute_value__product_reference_id_fk_idx" btree +> (product_reference_id) +> Foreign-key constraints: +> "product_attribute_value_attribute_fk" FOREIGN KEY +> (attribute_id) REFERENCES attribute(attribute_id) DEFERRABLE +> INITIALLY DEFERRED +> "product_attribute_value_attributeunit_fk" FOREIGN KEY +> (attribute_unit_id) REFERENCES attribute_unit(attribute_unit_id) +> DEFERRABLE INITIALLY DEFERRED +> "product_attribute_value_attributevalue_fk" FOREIGN KEY +> (attribute_value_id) REFERENCES attribute_value(attribute_value_id) +> DEFERRABLE INITIALLY DEFERRED +> "product_attribute_value_product_fk" FOREIGN KEY (product_id) +> REFERENCES product(product_id) DEFERRABLE INITIALLY DEFERRED +> "product_attribute_value_productreference_fk" FOREIGN KEY +> (product_reference_id) REFERENCES product(product_id) DEFERRABLE +> INITIALLY DEFERRED +> +> \d category_product; +> Table "public.category_product" +> Column | Type | Modifiers +> ---------------------+------------------------+----------- +> category_id | integer | not null +> product_id | integer | not null +> en_name_sort_order | integer | +> fr_name_sort_order | integer | +> merchant_sort_order | integer | +> price_sort_order | integer | +> merchant_count | integer | +> is_active | character varying(5) | +> product_is_active | character varying(5) | +> product_status_code | character varying(32) | +> product_name_en | character varying(512) | +> product_name_fr | character varying(512) | +> product_click_count | integer | +> Indexes: +> "x_category_product_pk" PRIMARY KEY, btree (category_id, +> product_id) +> "category_product__category_id_is_active_and_status_idx" btree +> (category_id, product_is_active, product_status_code) +> "category_product__is_active_idx" btree (is_active) +> "category_product__merchant_sort_order_idx" btree +> (merchant_sort_order) +> "x_category_product__category_id_fk_idx" btree (category_id) +> CLUSTER +> "x_category_product__product_id_fk_idx" btree (product_id) +> Foreign-key constraints: +> "x_category_product_category_fk" FOREIGN KEY (category_id) +> REFERENCES category(category_id) DEFERRABLE INITIALLY DEFERRED +> "x_category_product_product_fk" FOREIGN KEY (product_id) +> REFERENCES product(product_id) DEFERRABLE INITIALLY DEFERRED + + + +From pgsql-performance-owner@postgresql.org Wed May 10 21:32:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 821B19FA3A3; + Wed, 10 May 2006 21:32:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 60358-01; Wed, 10 May 2006 21:32:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 4B18D9F931E; + Wed, 10 May 2006 21:32:04 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4B0VsjW022559; + Wed, 10 May 2006 20:31:54 -0400 (EDT) +To: "Jim C. Nasby" +cc: PFC , Mitchell Skinner , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +In-reply-to: <20060510190011.GO99570@pervasive.com> +References: + <20060509105214.P90693@vesihiisi.cksoft.de> + + <20060509113337.M90693@vesihiisi.cksoft.de> + <20060509103632.GD29652@svana.org> + <1147190285.32304.43.camel@firebolt> + <16680.1147201981@sss.pgh.pa.us> + <20060510190011.GO99570@pervasive.com> +Comments: In-reply-to "Jim C. Nasby" + message dated "Wed, 10 May 2006 14:00:11 -0500" +Date: Wed, 10 May 2006 20:31:54 -0400 +Message-ID: <22558.1147307514@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/283 +X-Sequence-Number: 19070 + +"Jim C. Nasby" writes: +> On Tue, May 09, 2006 at 03:13:01PM -0400, Tom Lane wrote: +>> PFC writes: +>>> Fun thing is, the rowcount from a temp table (which is the problem here) +>>> should be available without ANALYZE ; as the temp table is not concurrent, +>>> it would be simple to inc/decrement a counter on INSERT/DELETE... +>> +>> No, because MVCC rules still apply. + +> But can anything ever see more than one version of what's in the table? + +Yes, because there can be more than one active snapshot within a single +transaction (think about volatile functions in particular). + +> Speaking of which, if a temp table is defined as ON COMMIT DROP or +> DELETE ROWS, there shouldn't be any need to store xmin/xmax, only +> cmin/cmax, correct? + +No; you forgot about subtransactions. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed May 10 22:20:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2D8269F931E + for ; + Wed, 10 May 2006 22:20:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 62055-08 + for ; + Wed, 10 May 2006 22:20:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 5EE669FA3A3 + for ; + Wed, 10 May 2006 22:20:12 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4B1K58V025819; + Wed, 10 May 2006 21:20:05 -0400 (EDT) +To: Brian Wipf +cc: pgsql-performance@postgresql.org +Subject: Re: Same query - Slow in production +In-reply-to: <18620DA0-DE55-4A2C-9DDC-BCF5F478E886@clickspace.com> +References: <18620DA0-DE55-4A2C-9DDC-BCF5F478E886@clickspace.com> +Comments: In-reply-to Brian Wipf + message dated "Wed, 10 May 2006 16:39:14 -0600" +Date: Wed, 10 May 2006 21:20:05 -0400 +Message-ID: <25818.1147310405@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/284 +X-Sequence-Number: 19071 + +Brian Wipf writes: +> I'm trying to determine why an identical query is running +> approximately 500 to 1000 times slower on our production database +> compared to our backup database server. + +It looks to me like it's pure luck that the query is fast on the backup +server. The outer side of the EXISTS' join is being badly misestimated: + +> -> Index Scan using +> category_product__category_id_is_active_and_status_idx on +> category_product cp (cost=0.00..4362.64 rows=1103 width=4) (actual +> time=0.013..0.015 rows=2 loops=5) +> Index Cond: ((category_id = $1) AND +> ((product_is_active)::text = 'true'::text) AND +> ((product_status_code)::text = 'complete'::text)) + +If there actually had been 1100 matching rows instead of 2, the query +would have run 550 times slower, putting it in the same ballpark as +the other plan. So what I'm guessing is that the planner sees these +two plans as being nearly the same cost, and small differences in the +stats between the two databases are enough to tip its choice in one +direction or the other. + +So what you want, of course, is to improve that rowcount estimate. +I suppose the reason it's so bad is that we don't have multicolumn +statistics ... is there a strong correlation between product_is_active +and product_status_code? If so, it might be worth your while to find a +way to merge them into one column. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu May 18 02:46:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1F49D9FA32D + for ; + Thu, 11 May 2006 02:33:00 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 08330-05 + for ; + Thu, 11 May 2006 02:32:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 5ABB79FA15C + for ; + Thu, 11 May 2006 02:32:51 -0300 (ADT) +Received: from ls405.htnet.hr (ls405.t-com.hr [195.29.150.135]) + by svr4.postgresql.org (Postfix) with ESMTP id 9BFB85B16AA + for ; + Thu, 11 May 2006 05:32:50 +0000 (GMT) +Received: from ls401.t-com.hr (ls401.t-com.hr [195.29.150.236]) + by ls405.htnet.hr (Postfix) with ESMTP id 337D6146F52; + Thu, 11 May 2006 07:32:47 +0200 (CEST) +Received: from ls401.t-com.hr (localhost.localdomain [127.0.0.1]) + by ls401.t-com.hr (Qmlai) with ESMTP id 5405AE38E3; + Thu, 11 May 2006 07:32:47 +0200 (CEST) +X-Envelope-Sender: msplival@jagor.srce.hr +X-Envelope-Sender: msplival@jagor.srce.hr +Received: from 83-131-51-236.adsl.net.t-com.hr + (83-131-51-236.adsl.net.t-com.hr [83.131.51.236]) + by ls401.t-com.hr (Qmlai) with ESMTP id 03FA238012; + Thu, 11 May 2006 07:32:41 +0200 (CEST) +Subject: Re: Lot'sa joins - performance tip-up, please? +From: Mario Splivalo +To: "Jim C. Nasby" +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060510221048.GX99570@pervasive.com> +References: <1146533274.14006.11.camel@localhost.localdomain> + <17793.1146679117@sss.pgh.pa.us> + <1146753957.8538.30.camel@localhost.localdomain> + <20060510221048.GX99570@pervasive.com> +Content-Type: text/plain +Date: Thu, 11 May 2006 07:32:26 +0200 +Message-Id: <1147325547.8696.6.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/373 +X-Sequence-Number: 19160 + +On Wed, 2006-05-10 at 17:10 -0500, Jim C. Nasby wrote: +> On Thu, May 04, 2006 at 04:45:57PM +0200, Mario Splivalo wrote: +> Well, here's the problem... +> +> > -> Nested Loop (cost=0.00..176144.30 rows=57925 width=26) +> > (actual time=1074.984..992536.243 rows=57925 loops=1) +> > -> Seq Scan on ticketing_codes_played +> > (cost=0.00..863.25 rows=57925 width=8) (actual time=74.479..2047.993 +> > rows=57925 loops=1) +> > -> Index Scan using ticketing_codes_pk on +> > ticketing_codes (cost=0.00..3.01 rows=1 width=18) (actual +> > time=17.044..17.052 rows=1 loops=57925) +> > Index Cond: (ticketing_codes.code_id = +> > "outer".code_id) +> +> Anyone have any idea why on earth it's doing that instead of a hash or +> merge join? +> +> In any case, try swapping the order of ticketing_codes_played and +> ticketing_codes. Actually, that'd probably make it worse. + +I tried that, no luck. The best performance I achieve with creating +temporary table. And... + +> +> Try SET enable_nestloop = off; + +This helps also. I don't get sequential scans any more. I'd like a tip +on how to set 'enable_nestloop = off' trough JDBC? + + Mario +-- +"I can do it quick, I can do it cheap, I can do it well. Pick any two." + +Mario Splivalo +msplival@jagor.srce.hr + + + +From pgsql-performance-owner@postgresql.org Thu May 11 04:06:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 520F59FA38E + for ; + Thu, 11 May 2006 04:06:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 59784-02-3 + for ; + Thu, 11 May 2006 04:06:34 -0300 (ADT) +X-Greylist: delayed 00:18:49.399726 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id D3B0E9FADD1 + for ; + Thu, 11 May 2006 04:06:29 -0300 (ADT) +Received: from mail.mnc.ch (62-2-77-205.business.cablecom.ch [62.2.77.205]) + by svr4.postgresql.org (Postfix) with ESMTP id AE9C85B709D + for ; + Thu, 11 May 2006 06:46:38 +0000 (GMT) +Received: from localhost (localhost [127.0.0.1]) + by mail.mnc.ch (Postfix) with ESMTP id BA1DBA82EC; + Thu, 11 May 2006 08:47:05 +0200 (CEST) +Received: from mail.mnc.ch ([127.0.0.1]) + by localhost (mail.test.lan [127.0.0.1]) (amavisd-new, + port 10025) with ESMTP + id 28707-03; Thu, 11 May 2006 08:47:04 +0200 (CEST) +Received: from meuh.mnc.lan (62-2-77-204.business.cablecom.ch [62.2.77.204]) + by mail.mnc.ch (Postfix) with ESMTP id 637E7A82B2; + Thu, 11 May 2006 08:47:04 +0200 (CEST) +Received: by meuh.mnc.lan (Postfix, from userid 1000) + id 67A64183437; Thu, 11 May 2006 08:46:31 +0200 (CEST) +To: "Christian Paul Cosinas" +Cc: +Subject: Re: Speed Up Offset and Limit Clause +References: <002801c67509$8f1a51a0$1e21100a@ghwk02002147> +X-Hashcash: 1:20:060511:cpc@cybees.com::+JuTrmjoQL0yEe2Q:0004Iuw +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::YWxMJltO+IsWs3QY:000000000000000000000000000001aag +From: Guillaume Cottenceau +Date: 11 May 2006 08:46:31 +0200 +In-Reply-To: <002801c67509$8f1a51a0$1e21100a@ghwk02002147> +Message-ID: <87bqu5t5x4.fsf@meuh.mnc.lan> +Lines: 22 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: amavisd-new at mnc.ch +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/288 +X-Sequence-Number: 19075 + +"Christian Paul Cosinas" writes: + +> Hi! +> +> How can I speed up my server's performance when I use offset and limit +> clause. +> +> For example I have a query: +> SELECT * FROM table ORDER BY id, name OFFSET 100000 LIMIT 10000 +> +> This query takes a long time about more than 2 minutes. +> +> If my query is: +> SELECT * FROM table ORDER BY id, name OFFSET 50000 LIMIT 10000 +> It takes about 2 seconds. + +First you should read the appropriate documentation. + +http://www.postgresql.org/docs/8.1/interactive/performance-tips.html + +-- +Guillaume Cottenceau + +From pgsql-performance-owner@postgresql.org Thu May 11 03:51:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D53389FA15C + for ; + Thu, 11 May 2006 03:51:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 49970-02 + for ; + Thu, 11 May 2006 03:51:40 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.196]) + by postgresql.org (Postfix) with ESMTP id 932BA9FA29F + for ; + Thu, 11 May 2006 03:51:40 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id k1so106628nzf + for ; + Wed, 10 May 2006 23:51:39 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; + b=TMEdDudz7h+2K/qMNvbvJlvA2bwiy15WBENpTrXiXv6YcD8T1apXa7bgF68ad49FGJtIJjYNUAlK8RMcHWi+l197WeYHUefyNTRWikc/dq0DDx2qXtqw7HW32WtliuKjZonyV04KXggtQ2lvKnrzVF2eW1OocqnQzQL8NvQnrxw= +Received: by 10.36.247.53 with SMTP id u53mr361050nzh; + Wed, 10 May 2006 23:51:39 -0700 (PDT) +Received: from ?10.1.1.21? ( [203.217.18.65]) + by mx.gmail.com with ESMTP id 39sm819076nzk.2006.05.10.23.51.37; + Wed, 10 May 2006 23:51:38 -0700 (PDT) +Message-ID: <4462DEF8.7060805@gmail.com> +Date: Thu, 11 May 2006 16:51:36 +1000 +From: Chris +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christian Paul Cosinas +CC: pgsql-performance@postgresql.org +Subject: Re: Speed Up Offset and Limit Clause +References: <002801c67509$8f1a51a0$1e21100a@ghwk02002147> +In-Reply-To: <002801c67509$8f1a51a0$1e21100a@ghwk02002147> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/286 +X-Sequence-Number: 19073 + +Christian Paul Cosinas wrote: +> Hi! +> +> How can I speed up my server's performance when I use offset and limit +> clause. +> +> For example I have a query: +> SELECT * FROM table ORDER BY id, name OFFSET 100000 LIMIT 10000 +> +> This query takes a long time about more than 2 minutes. +> +> If my query is: +> SELECT * FROM table ORDER BY id, name OFFSET 50000 LIMIT 10000 +> It takes about 2 seconds. + +Please create a new thread rather than replying to someone elses post +and changing the subject. These threads can sometimes get missed. + +You do have an index on id and name don't you? + +-- +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-performance-owner@postgresql.org Thu May 11 04:04:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 60ECC9FA29F + for ; + Thu, 11 May 2006 04:04:45 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 49395-05 + for ; + Thu, 11 May 2006 04:04:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 99E879FACFE + for ; + Thu, 11 May 2006 04:04:32 -0300 (ADT) +Received: (qmail 7147 invoked from network); 11 May 2006 09:05:58 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 11 May 2006 09:05:58 +0200 +To: "Christian Paul Cosinas" , + pgsql-performance@postgresql.org +Subject: Re: Speed Up Offset and Limit Clause +References: <002801c67509$8f1a51a0$1e21100a@ghwk02002147> +Message-ID: +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +Date: Thu, 11 May 2006 09:05:56 +0200 +In-Reply-To: <002801c67509$8f1a51a0$1e21100a@ghwk02002147> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/287 +X-Sequence-Number: 19074 + + + Why do you want to use it this way ? + Explain what you want to do, there probably is another faster solution... + +On Thu, 11 May 2006 16:45:33 +0200, Christian Paul Cosinas + wrote: + +> Hi! +> +> How can I speed up my server's performance when I use offset and limit +> clause. +> +> For example I have a query: +> SELECT * FROM table ORDER BY id, name OFFSET 100000 LIMIT 10000 +> +> This query takes a long time about more than 2 minutes. +> +> If my query is: +> SELECT * FROM table ORDER BY id, name OFFSET 50000 LIMIT 10000 +> It takes about 2 seconds. +> +> Thanks +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match + + + +From pgsql-performance-owner@postgresql.org Thu May 18 02:46:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id CBA8A9FA29F; + Thu, 11 May 2006 04:55:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 72801-09; Thu, 11 May 2006 04:55:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smxsat1.smxs.net (smxsat1.smxs.net [213.150.10.1]) + by postgresql.org (Postfix) with ESMTP id 603A09FA15C; + Thu, 11 May 2006 04:55:18 -0300 (ADT) +Received: from m01x1.s-mxs.net [10.3.55.201] by smxsat1.smxs.net + with XWall v3.37a. ; Thu, 11 May 2006 09:55:16 +0200 +Received: from m0103.s-mxs.net [10.3.55.3] by m01x1.s-mxs.net + with XWall v3.37a. ; Thu, 11 May 2006 09:55:16 +0200 +Received: from m0143.s-mxs.net ([10.252.53.143]) by m0103.s-mxs.net with + Microsoft SMTPSVC(6.0.3790.1830); Thu, 11 May 2006 09:55:15 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Date: Thu, 11 May 2006 09:55:15 +0200 +Message-ID: +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] [HACKERS] Big IN() clauses etc : feature proposal + [heur] +Thread-Index: AcZ0Z3Dtdrn4AvIzTDWUsaoPActu4AAZsmvQ +From: "Zeugswetter Andreas DCP SD" +To: "Jim C. Nasby" , + "PFC" +Cc: "Greg Stark" , "Tom Lane" , + , +X-OriginalArrivalTime: 11 May 2006 07:55:15.0881 (UTC) + FILETIME=[3D66E190:01C674D0] +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/374 +X-Sequence-Number: 19161 + + +> Something else worth considering is not using the normal=20 +> catalog methods +> for storing information about temp tables, but hacking that together +> would probably be a rather large task. + +But the timings suggest, that it cannot be the catalogs in the worst +case +he showed. + +> 0.101 ms BEGIN +> 1.451 ms CREATE TEMPORARY TABLE tmp ( a INTEGER NOT NULL, b INTEGER +NOT =20 +> NULL, c TIMESTAMP NOT NULL, d INTEGER NOT NULL ) ON COMMIT DROP + +1.4 seconds is not great for create table, is that what we expect ? + +> 0.450 ms INSERT INTO tmp SELECT * FROM bookmarks ORDER BY annonce_id +DESC =20 +> LIMIT 20 +> 0.443 ms ANALYZE tmp +> 0.365 ms SELECT * FROM tmp +> 0.310 ms DROP TABLE tmp +> 32.918 ms COMMIT +>=20 +> CREATING the table is OK, but what happens on COMMIT ? I hear +the disk =20 +> seeking frantically. + +The 32 seconds for commit can hardly be catalog related. It seems the +file is=20 +fsynced before it is dropped. + +Andreas + +From pgsql-performance-owner@postgresql.org Thu May 11 05:31:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 227FA9FA886; + Thu, 11 May 2006 05:31:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 78999-05-2; Thu, 11 May 2006 05:31:09 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svana.org (svana.org [125.62.94.225]) + by postgresql.org (Postfix) with ESMTP id 166C39FA15C; + Thu, 11 May 2006 05:31:08 -0300 (ADT) +Received: from kleptog by svana.org with local (Exim 4.50) + id 1Fe6Yz-00085u-Az; Thu, 11 May 2006 18:30:25 +1000 +Date: Thu, 11 May 2006 10:30:25 +0200 +From: Martijn van Oosterhout +To: Zeugswetter Andreas DCP SD +Cc: "Jim C. Nasby" , PFC , + Greg Stark , Tom Lane , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Message-ID: <20060511083025.GE30113@svana.org> +Reply-To: Martijn van Oosterhout +References: +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="2qXFWqzzG3v1+95a" +Content-Disposition: inline +In-Reply-To: +X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 +X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 +X-PGP-Key-URL: +User-Agent: Mutt/1.5.9i +X-SA-Exim-Connect-IP: +X-SA-Exim-Mail-From: kleptog@svana.org +X-SA-Exim-Scanned: No (on svana.org); SAEximRunCond expanded to false +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/289 +X-Sequence-Number: 19076 + + +--2qXFWqzzG3v1+95a +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Thu, May 11, 2006 at 09:55:15AM +0200, Zeugswetter Andreas DCP SD wrote: +> > 0.101 ms BEGIN +> > 1.451 ms CREATE TEMPORARY TABLE tmp ( a INTEGER NOT NULL, b INTEGER +> NOT =20 +> > NULL, c TIMESTAMP NOT NULL, d INTEGER NOT NULL ) ON COMMIT DROP +>=20 +> 1.4 seconds is not great for create table, is that what we expect ? + +Hmm, I'm hoping ms means milliseconds... +--=20 +Martijn van Oosterhout http://svana.org/kleptog/ +> From each according to his ability. To each according to his ability to l= +itigate. + +--2qXFWqzzG3v1+95a +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.1 (GNU/Linux) + +iD8DBQFEYvYhIB7bNG8LQkwRAoQmAKCDvKrWmALNPQXST/37mGJznYdVPQCeNxZ3 +qeQa2tws0Jf4bUmMmakZRPA= +=u8PZ +-----END PGP SIGNATURE----- + +--2qXFWqzzG3v1+95a-- + +From pgsql-performance-owner@postgresql.org Thu May 11 09:58:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8E6EF9F9430 + for ; + Thu, 11 May 2006 09:58:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 09855-04 + for ; + Thu, 11 May 2006 09:58:04 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.207]) + by postgresql.org (Postfix) with ESMTP id 756E69FA176 + for ; + Thu, 11 May 2006 09:58:04 -0300 (ADT) +Received: by wx-out-0102.google.com with SMTP id s13so141230wxc + for ; + Thu, 11 May 2006 05:58:03 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:user-agent:date:subject:from:to:message-id:thread-topic:thread-index:mime-version:content-type; + b=Q4jndobNeJu/ppjQy50u8nLCWBkK9bZj1U0e5GFB91B6UlNW+letNoAwct+IWfqxgdam5Wd3mgEEXwDqxB4d8CvwiHId6NQK+5r8i3J42gBYT4QOsFVNjX0uIy4r+/2viAXtfsyKi++C76MZHMRuW/z2NgnkA740F+TJhhufQ2U= +Received: by 10.70.51.3 with SMTP id y3mr662415wxy; + Thu, 11 May 2006 05:58:03 -0700 (PDT) +Received: from ?192.168.0.12? ( [24.227.61.54]) + by mx.gmail.com with ESMTP id i34sm5888492wxd.2006.05.11.05.58.01; + Thu, 11 May 2006 05:58:02 -0700 (PDT) +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Thu, 11 May 2006 08:57:48 -0400 +Subject: Nested Loops vs. Hash Joins or Merge Joins +From: Ketema Harris +To: "pgsql-performance@postgresql.org" +Message-ID: +Thread-Topic: Nested Loops vs. Hash Joins or Merge Joins +Thread-Index: AcZ0+oDov6NU3uDtEdqGSgARJHlfcA== +Mime-version: 1.0 +Content-type: multipart/alternative; + boundary="B_3230182682_18308268" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/290 +X-Sequence-Number: 19077 + +> This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +--B_3230182682_18308268 +Content-type: text/plain; + charset="ISO-8859-1" +Content-transfer-encoding: quoted-printable + +I am attempting to learn more about the way Pg decides what operators to us= +e +in its query planning and executions. I have moderately complicated table +layout, but it is mostly normalized I recently created a query: + +select account.acct_name as "Customer Name", NULL as "Facility", +account.acct_number as "LDC Acct#", account.svc_address as "Service +Address", +account.svc_address as "Service Address", account.svc_city as "Service +City", account.svc_state as "Service State", account.svc_city as "Service +City", +account.svc_zip as "Service Zip", product.ldc_name as "LDC", NULL as "ESI +Rate", NULL as "LDC Rate", +account.billing_address as "Mailing Address1", account.billing_address_2 as +"Mailing Address2", +account.billing_city || ', ' || account.billing_state as "City, State", +account.billing_zip as "Zip", customer.first_name || ' ' || +customer.last_name +as "Contact", customer.phone as "Phone", customer.class as "Customer Class"= +, +NULL as "Tax Exempt", NULL as "Exempt%", +marketer_divisions.channel_partner_code as "Channel Partner", NULL as "AE", +NULL as "Annual Use MCF", account.rate as "Trigger Price", +marketer_divisions.channel_partner_fee as "Channel Partner Fee" +from naes.reconciliation + inner join naes.application + inner join naes.account + inner join naes.marketer_product + inner join naes.marketer_divisions + inner join naes.cities + on marketer_divisions.city_id =3D cities.city_id + on marketer_product.division_id =3D marketer_divisions.division_i= +d + inner join naes.product + on marketer_product.ldc_id =3D product.ldc_id + on account.marketer_product_id =3D +marketer_product.marketer_product_id + inner join naes.customer + on account.customer_id =3D customer.customer_id + on account.app_id =3D application.app_id and account.acct_id =3D +application.acct_id + on reconciliation.app_id =3D application.app_id and +reconciliation.transferred_date is NULL; + +The query runs fine I have no performance issues with it, but here are two +query plans for the above query, one with nested loops on, the other with +them off: + +Nested Loops on: + +Nested Loop (cost=3D3.33..11.37 rows=3D1 width=3D268) (actual time=3D2.166..2.982 +rows=3D3 loops=3D1) + Join Filter: ("outer".city_id =3D "inner".city_id) + -> Nested Loop (cost=3D3.33..10.32 rows=3D1 width=3D272) (actual +time=3D2.136..2.863 rows=3D3 loops=3D1) + Join Filter: ("outer".division_id =3D +"inner".division_id)plication.app_id and reco=3D + -> Nested Loop (cost=3D3.33..9.27 rows=3D1 width=3D231) (actual +time=3D2.119..2.763 rows=3D3 loops=3D1) + Join Filter: ("outer".ldc_id =3D "inner".ldc_id) + -> Nested Loop (cost=3D3.33..8.23 rows=3D1 width=3D218) (actual +time=3D2.101..2.659 rows=3D3 loops=3D1) + -> Nested Loop (cost=3D3.33..5.15 rows=3D1 width=3D151) +(actual time=3D2.068..2.559 rows=3D3 loops=3D1) + Join Filter: ("inner".app_id =3D "outer".app_id) + -> Merge Join (cost=3D3.33..4.11 rows=3D1 +width=3D159) (actual time=3D1.096..1.477 rows=3D31 loops=3D1) + Merge Cond: ("outer".marketer_product_id =3D +"inner".marketer_product_id) + -> Index Scan using +"PK_marketer_product_id" on marketer_product (cost=3D0.00..3.04 rows=3D4 +width=3D12) (actual time=3D0.017..0.033 rows=3D4 loops=3D1) + -> Sort (cost=3D3.33..3.33 rows=3D1 +width=3D155) (actual time=3D1.065..1.180 rows=3D31 loops=3D1) + Sort Key: account.marketer_product_i= +d + -> Hash Join (cost=3D1.75..3.32 +rows=3D1 width=3D155) (actual time=3D0.457..0.848 rows=3D31 loops=3D1) + Hash Cond: (("outer".app_id =3D +"inner".app_id) AND ("outer".acct_id =3D "inner".acct_id)) + -> Seq Scan on account +(cost=3D0.00..1.28 rows=3D28 width=3D155) (actual time=3D0.007..0.160 rows=3D34 +loops=3D1) + -> Hash (cost=3D1.50..1.50 +rows=3D50 width=3D8) (actual time=3D0.413..0.413 rows=3D50 loops=3D1) + -> Seq Scan on +application (cost=3D0.00..1.50 rows=3D50 width=3D8) (actual time=3D0.006..0.209 +rows=3D50 loops=3D1) + -> Seq Scan on reconciliation (cost=3D0.00..1.03 +rows=3D1 width=3D4) (actual time=3D0.005..0.016 rows=3D3 loops=3D31) + Filter: (transferred_date IS NULL) + -> Index Scan using customer_pkey on customer +(cost=3D0.00..3.06 rows=3D1 width=3D75) (actual time=3D0.011..0.015 rows=3D1 loops=3D3) + Index Cond: ("outer".customer_id =3D +customer.customer_id) + -> Seq Scan on product (cost=3D0.00..1.02 rows=3D2 width=3D21) +(actual time=3D0.005..0.013 rows=3D2 loops=3D3) + -> Seq Scan on marketer_divisions (cost=3D0.00..1.02 rows=3D2 +width=3D49) (actual time=3D0.005..0.013 rows=3D2 loops=3D3) + -> Seq Scan on cities (cost=3D0.00..1.02 rows=3D2 width=3D4) (actual +time=3D0.005..0.013 rows=3D2 loops=3D3) + Total runtime: 3.288 ms + +Nested Loops off: + +Hash Join (cost=3D8.27..11.78 rows=3D1 width=3D268) (actual time=3D1.701..1.765 +rows=3D3 loops=3D1) + Hash Cond: ("outer".city_id =3D "inner".city_id) + -> Hash Join (cost=3D7.24..10.73 rows=3D1 width=3D272) (actual +time=3D1.629..1.667 rows=3D3 loops=3D1) + Hash Cond: ("outer".customer_id =3D "inner".customer_id) + -> Seq Scan on customer (cost=3D0.00..3.32 rows=3D32 width=3D75) +(actual time=3D0.006..0.136 rows=3D33 loops=3D1) + -> Hash (cost=3D7.24..7.24 rows=3D1 width=3D205) (actual +time=3D1.366..1.366 rows=3D3 loops=3D1) + -> Hash Join (cost=3D6.43..7.24 rows=3D1 width=3D205) (actual +time=3D1.243..1.333 rows=3D3 loops=3D1) + Hash Cond: ("outer".division_id =3D "inner".division_id) + -> Hash Join (cost=3D5.40..6.20 rows=3D1 width=3D164) +(actual time=3D1.184..1.252 rows=3D3 loops=3D1) + Hash Cond: ("outer".ldc_id =3D "inner".ldc_id) + -> Merge Join (cost=3D4.38..5.16 rows=3D1 +width=3D151) (actual time=3D1.124..1.169 rows=3D3 loops=3D1) + Merge Cond: ("outer".marketer_product_id =3D +"inner".marketer_product_id) + -> Index Scan using +"PK_marketer_product_id" on marketer_product (cost=3D0.00..3.04 rows=3D4 +width=3D12) (actual time=3D0.012..0.019 rows=3D2 loops=3D1) + -> Sort (cost=3D4.38..4.38 rows=3D1 +width=3D147) (actual time=3D1.098..1.109 rows=3D3 loops=3D1) + Sort Key: account.marketer_product_i= +d + -> Hash Join (cost=3D2.78..4.37 +rows=3D1 width=3D147) (actual time=3D1.007..1.064 rows=3D3 loops=3D1) + Hash Cond: ("outer".app_id =3D +"inner".app_id) + -> Hash Join (cost=3D1.75..3.3= +2 +rows=3D1 width=3D155) (actual time=3D0.494..0.875 rows=3D31 loops=3D1) + Hash Cond: +(("outer".app_id =3D "inner".app_id) AND ("outer".acct_id =3D "inner".acct_id)) + -> Seq Scan on account +(cost=3D0.00..1.28 rows=3D28 width=3D155) (actual time=3D0.007..0.154 rows=3D34 +loops=3D1) + -> Hash +(cost=3D1.50..1.50 rows=3D50 width=3D8) (actual time=3D0.451..0.451 rows=3D50 loops=3D1= +) + -> Seq Scan on +application (cost=3D0.00..1.50 rows=3D50 width=3D8) (actual time=3D0.006..0.223 +rows=3D50 loops=3D1) + -> Hash (cost=3D1.03..1.03 +rows=3D1 width=3D4) (actual time=3D0.042..0.042 rows=3D3 loops=3D1) + -> Seq Scan on +reconciliation (cost=3D0.00..1.03 rows=3D1 width=3D4) (actual time=3D0.007..0.019 +rows=3D3 loops=3D1) + Filter: +(transferred_date IS NULL) + -> Hash (cost=3D1.02..1.02 rows=3D2 width=3D21) +(actual time=3D0.036..0.036 rows=3D2 loops=3D1) + -> Seq Scan on product (cost=3D0.00..1.02 +rows=3D2 width=3D21) (actual time=3D0.005..0.014 rows=3D2 loops=3D1) + -> Hash (cost=3D1.02..1.02 rows=3D2 width=3D49) (actual +time=3D0.036..0.036 rows=3D2 loops=3D1) + -> Seq Scan on marketer_divisions +(cost=3D0.00..1.02 rows=3D2 width=3D49) (actual time=3D0.007..0.016 rows=3D2 loops=3D1) + -> Hash (cost=3D1.02..1.02 rows=3D2 width=3D4) (actual time=3D0.039..0.039 +rows=3D2 loops=3D1) + -> Seq Scan on cities (cost=3D0.00..1.02 rows=3D2 width=3D4) (actual +time=3D0.009..0.017 rows=3D2 loops=3D1) + Total runtime: 2.084 ms + +With nested loops enabled does it choose to use them because it sees the +estimated start up cost with loops as less? Does it not know that the tota= +l +query would be faster with the Hash Joins? This query is in development +right now, and as such there are not many rows. When it goes to production +the reconciliation table will grow by about 50 =AD 100 rows per day where the +transferred_date is NULL (this is the driving criteria behind this query.) +As the table grows can I expect Pg to realize the the nested loops will be +slower and will it switch to the Hash Joins? If not how would I force it t= +o +use the Hash Joins without just turning off nested loops completely? Is it +a good idea to turn off nested loops completely? + +Statistics collecting and auto vacuum is enabled btw. I have an erd diagra= +m +showing the table structures if anyone is interested in looking at it, just +let me know. + +Thanks, +Ketema + + +--B_3230182682_18308268 +Content-type: text/html; + charset="ISO-8859-1" +Content-transfer-encoding: quoted-printable + + + +Nested Loops vs. Hash Joins or Merge Joins + + +I am attempting to lea= +rn more about the way Pg decides what operators to use in its query planning= + and executions.  I have moderately complicated table layout, but it is= + mostly normalized I recently created a query:
+
+select account.acct_name as "Customer Name", NULL as "Facili= +ty", account.acct_number as "LDC Acct#", account.svc_address = +as "Service Address",
+account.svc_address as "Service Address", account.svc_city as &qu= +ot;Service City", account.svc_state as "Service State", accou= +nt.svc_city as "Service City",
+account.svc_zip as "Service Zip", product.ldc_name as "LDC&q= +uot;, NULL as "ESI Rate", NULL as "LDC Rate",
+account.billing_address as "Mailing Address1", account.billing_ad= +dress_2 as "Mailing Address2",
+account.billing_city || ', ' || account.billing_state as "City, State&= +quot;, account.billing_zip as "Zip", customer.first_name || ' ' ||= + customer.last_name
+as "Contact", customer.phone as "Phone", customer.class= + as "Customer Class", NULL as "Tax Exempt", NULL as &quo= +t;Exempt%",
+marketer_divisions.channel_partner_code as "Channel Partner", NUL= +L as "AE", NULL as "Annual Use MCF", account.rate as &qu= +ot;Trigger Price",
+marketer_divisions.channel_partner_fee as "Channel Partner Fee" +from naes.reconciliation
+   inner join naes.application
+      inner join naes.account
+         inner join naes.marke= +ter_product
+            inn= +er join naes.marketer_divisions
+            &nb= +sp;  inner join naes.cities
+            &nb= +sp;  on marketer_divisions.city_id =3D cities.city_id
+            on = +marketer_product.division_id =3D marketer_divisions.division_id
+            inn= +er join naes.product
+            on = +marketer_product.ldc_id =3D product.ldc_id
+         on account.marketer_p= +roduct_id =3D marketer_product.marketer_product_id
+         inner join naes.custo= +mer
+         on account.customer_i= +d =3D customer.customer_id
+      on account.app_id =3D application.app_id = +and account.acct_id =3D application.acct_id
+   on reconciliation.app_id =3D application.app_id and reconci= +liation.transferred_date is NULL;
+
+The query runs fine I have no performance issues with it, but here are two = +query plans for the above query, one with nested loops on, the other with th= +em off:
+
+Nested Loops on:
+
+Nested Loop  (cost=3D3.33..11.37 rows=3D1 width=3D268) (actual time=3D2.166..2= +.982 rows=3D3 loops=3D1)
+   Join Filter: ("outer".city_id =3D "inner&quo= +t;.city_id)
+   ->  Nested Loop  (cost=3D3.33..10.32 rows=3D1 wi= +dth=3D272) (actual time=3D2.136..2.863 rows=3D3 loops=3D1)
+         Join Filter: ("o= +uter".division_id =3D "inner".division_id)plication.app_id and = +reco=3D
+         ->  Nested Lo= +op  (cost=3D3.33..9.27 rows=3D1 width=3D231) (actual time=3D2.119..2.763 rows=3D3= + loops=3D1)
+            &nb= +sp;  Join Filter: ("outer".ldc_id =3D "inner".ld= +c_id)
+            &nb= +sp;  ->  Nested Loop  (cost=3D3.33..8.23 rows=3D1 width=3D2= +18) (actual time=3D2.101..2.659 rows=3D3 loops=3D1)
+            &nb= +sp;        ->  Nested Loop &= +nbsp;(cost=3D3.33..5.15 rows=3D1 width=3D151) (actual time=3D2.068..2.559 rows=3D3 loo= +ps=3D1)
+            &nb= +sp;            &= +nbsp; Join Filter: ("inner".app_id =3D "outer".app_id= +)
+            &nb= +sp;            &= +nbsp; ->  Merge Join  (cost=3D3.33..4.11 rows=3D1 width=3D159) (= +actual time=3D1.096..1.477 rows=3D31 loops=3D1)
+            &nb= +sp;            &= +nbsp;       Merge Cond: ("outer"= +;.marketer_product_id =3D "inner".marketer_product_id)
+            &nb= +sp;            &= +nbsp;       ->  Index Scan using = +"PK_marketer_product_id" on marketer_product  (cost=3D0.00..3.0= +4 rows=3D4 width=3D12) (actual time=3D0.017..0.033 rows=3D4 loops=3D1)
+            &nb= +sp;            &= +nbsp;       ->  Sort  (cost=3D= +3.33..3.33 rows=3D1 width=3D155) (actual time=3D1.065..1.180 rows=3D31 loops=3D1)
+            &nb= +sp;            &= +nbsp;            = +; Sort Key: account.marketer_product_id
+            &nb= +sp;            &= +nbsp;            = +; ->  Hash Join  (cost=3D1.75..3.32 rows=3D1 width=3D155) (actua= +l time=3D0.457..0.848 rows=3D31 loops=3D1)
+            &nb= +sp;            &= +nbsp;            = +;       Hash Cond: (("outer".ap= +p_id =3D "inner".app_id) AND ("outer".acct_id =3D "inne= +r".acct_id))
+            &nb= +sp;            &= +nbsp;            = +;       ->  Seq Scan on account &= +nbsp;(cost=3D0.00..1.28 rows=3D28 width=3D155) (actual time=3D0.007..0.160 rows=3D34 l= +oops=3D1)
+            &nb= +sp;            &= +nbsp;            = +;       ->  Hash  (cost=3D1.50= +..1.50 rows=3D50 width=3D8) (actual time=3D0.413..0.413 rows=3D50 loops=3D1)
+            &nb= +sp;            &= +nbsp;            = +;            &nb= +sp;->  Seq Scan on application  (cost=3D0.00..1.50 rows=3D50 width=3D= +8) (actual time=3D0.006..0.209 rows=3D50 loops=3D1)
+            &nb= +sp;            &= +nbsp; ->  Seq Scan on reconciliation  (cost=3D0.00..1.03 row= +s=3D1 width=3D4) (actual time=3D0.005..0.016 rows=3D3 loops=3D31)
+            &nb= +sp;            &= +nbsp;       Filter: (transferred_date IS = +NULL)
+            &nb= +sp;        ->  Index Scan us= +ing customer_pkey on customer  (cost=3D0.00..3.06 rows=3D1 width=3D75) (actua= +l time=3D0.011..0.015 rows=3D1 loops=3D3)
+            &nb= +sp;            &= +nbsp; Index Cond: ("outer".customer_id =3D customer.customer_id= +)
+            &nb= +sp;  ->  Seq Scan on product  (cost=3D0.00..1.02 rows=3D2= + width=3D21) (actual time=3D0.005..0.013 rows=3D2 loops=3D3)
+         ->  Seq Scan = +on marketer_divisions  (cost=3D0.00..1.02 rows=3D2 width=3D49) (actual time=3D0= +.005..0.013 rows=3D2 loops=3D3)
+   ->  Seq Scan on cities  (cost=3D0.00..1.02 row= +s=3D2 width=3D4) (actual time=3D0.005..0.013 rows=3D2 loops=3D3)
+ Total runtime: 3.288 ms
+
+Nested Loops off:
+
+Hash Join  (cost=3D8.27..11.78 rows=3D1 width=3D268) (actual time=3D1.701..1.7= +65 rows=3D3 loops=3D1)
+   Hash Cond: ("outer".city_id =3D "inner"= +.city_id)
+   ->  Hash Join  (cost=3D7.24..10.73 rows=3D1 widt= +h=3D272) (actual time=3D1.629..1.667 rows=3D3 loops=3D1)
+         Hash Cond: ("out= +er".customer_id =3D "inner".customer_id)
+         ->  Seq Scan = +on customer  (cost=3D0.00..3.32 rows=3D32 width=3D75) (actual time=3D0.006..0.1= +36 rows=3D33 loops=3D1)
+         ->  Hash &nbs= +p;(cost=3D7.24..7.24 rows=3D1 width=3D205) (actual time=3D1.366..1.366 rows=3D3 loops=3D= +1)
+            &nb= +sp;  ->  Hash Join  (cost=3D6.43..7.24 rows=3D1 width=3D205= +) (actual time=3D1.243..1.333 rows=3D3 loops=3D1)
+            &nb= +sp;        Hash Cond: ("outer&q= +uot;.division_id =3D "inner".division_id)
+            &nb= +sp;        ->  Hash Join &nb= +sp;(cost=3D5.40..6.20 rows=3D1 width=3D164) (actual time=3D1.184..1.252 rows=3D3 loops= +=3D1)
+            &nb= +sp;            &= +nbsp; Hash Cond: ("outer".ldc_id =3D "inner".ldc_id)<= +BR> +            &nb= +sp;            &= +nbsp; ->  Merge Join  (cost=3D4.38..5.16 rows=3D1 width=3D151) (= +actual time=3D1.124..1.169 rows=3D3 loops=3D1)
+            &nb= +sp;            &= +nbsp;       Merge Cond: ("outer"= +;.marketer_product_id =3D "inner".marketer_product_id)
+            &nb= +sp;            &= +nbsp;       ->  Index Scan using = +"PK_marketer_product_id" on marketer_product  (cost=3D0.00..3.0= +4 rows=3D4 width=3D12) (actual time=3D0.012..0.019 rows=3D2 loops=3D1)
+            &nb= +sp;            &= +nbsp;       ->  Sort  (cost=3D= +4.38..4.38 rows=3D1 width=3D147) (actual time=3D1.098..1.109 rows=3D3 loops=3D1)
+            &nb= +sp;            &= +nbsp;            = +; Sort Key: account.marketer_product_id
+            &nb= +sp;            &= +nbsp;            = +; ->  Hash Join  (cost=3D2.78..4.37 rows=3D1 width=3D147) (actua= +l time=3D1.007..1.064 rows=3D3 loops=3D1)
+            &nb= +sp;            &= +nbsp;            = +;       Hash Cond: ("outer".app= +_id =3D "inner".app_id)
+            &nb= +sp;            &= +nbsp;            = +;       ->  Hash Join  (cost= +=3D1.75..3.32 rows=3D1 width=3D155) (actual time=3D0.494..0.875 rows=3D31 loops=3D1)
+            &nb= +sp;            &= +nbsp;            = +;            &nb= +sp;Hash Cond: (("outer".app_id =3D "inner".app_id) AND (&q= +uot;outer".acct_id =3D "inner".acct_id))
+            &nb= +sp;            &= +nbsp;            = +;            &nb= +sp;->  Seq Scan on account  (cost=3D0.00..1.28 rows=3D28 width=3D155)= + (actual time=3D0.007..0.154 rows=3D34 loops=3D1)
+            &nb= +sp;            &= +nbsp;            = +;            &nb= +sp;->  Hash  (cost=3D1.50..1.50 rows=3D50 width=3D8) (actual time=3D0.4= +51..0.451 rows=3D50 loops=3D1)
+            &nb= +sp;            &= +nbsp;            = +;            &nb= +sp;      ->  Seq Scan on application &= +nbsp;(cost=3D0.00..1.50 rows=3D50 width=3D8) (actual time=3D0.006..0.223 rows=3D50 loo= +ps=3D1)
+            &nb= +sp;            &= +nbsp;            = +;       ->  Hash  (cost=3D1.03= +..1.03 rows=3D1 width=3D4) (actual time=3D0.042..0.042 rows=3D3 loops=3D1)
+            &nb= +sp;            &= +nbsp;            = +;            &nb= +sp;->  Seq Scan on reconciliation  (cost=3D0.00..1.03 rows=3D1 widt= +h=3D4) (actual time=3D0.007..0.019 rows=3D3 loops=3D1)
+            &nb= +sp;            &= +nbsp;            = +;            &nb= +sp;      Filter: (transferred_date IS NULL) +            &nb= +sp;            &= +nbsp; ->  Hash  (cost=3D1.02..1.02 rows=3D2 width=3D21) (actual = +time=3D0.036..0.036 rows=3D2 loops=3D1)
+            &nb= +sp;            &= +nbsp;       ->  Seq Scan on produ= +ct  (cost=3D0.00..1.02 rows=3D2 width=3D21) (actual time=3D0.005..0.014 rows=3D2 = +loops=3D1)
+            &nb= +sp;        ->  Hash  (c= +ost=3D1.02..1.02 rows=3D2 width=3D49) (actual time=3D0.036..0.036 rows=3D2 loops=3D1) +            &nb= +sp;            &= +nbsp; ->  Seq Scan on marketer_divisions  (cost=3D0.00..1.02= + rows=3D2 width=3D49) (actual time=3D0.007..0.016 rows=3D2 loops=3D1)
+   ->  Hash  (cost=3D1.02..1.02 rows=3D2 width=3D4) (= +actual time=3D0.039..0.039 rows=3D2 loops=3D1)
+         ->  Seq Scan = +on cities  (cost=3D0.00..1.02 rows=3D2 width=3D4) (actual time=3D0.009..0.017 r= +ows=3D2 loops=3D1)
+ Total runtime: 2.084 ms
+
+With nested loops enabled does it choose to use them because it sees the es= +timated start up cost with loops as less?  Does it not know that the to= +tal query would be faster with the Hash Joins?  This query is in develo= +pment right now, and as such there are not many rows.  When it goes to = +production the reconciliation table will grow by about 50 – 100 rows p= +er day where the transferred_date is NULL (this is the driving criteria behi= +nd this query.)  As the table grows can I expect Pg to realize the the = +nested loops will be slower and will it switch to the Hash Joins?  If n= +ot how would I force it to use the Hash Joins without just turning off neste= +d loops completely?  Is it a good idea to turn off nested loops complet= +ely?
+
+Statistics collecting and auto vacuum is enabled btw.  I have an erd d= +iagram showing the table structures if anyone is interested in looking at it= +, just let me know.
+
+Thanks,
+Ketema
+
+ + + + +--B_3230182682_18308268-- + + + +From pgsql-performance-owner@postgresql.org Thu May 11 03:36:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1445B9FA29F + for ; + Thu, 11 May 2006 03:36:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 19291-10 + for ; + Thu, 11 May 2006 03:36:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mailer.eglobalreach.net (mailer.eglobalreach.net + [202.124.128.22]) + by postgresql.org (Postfix) with ESMTP id A58E09FA15C + for ; + Thu, 11 May 2006 03:35:59 -0300 (ADT) +Received: from ghwk02002147 (mailer.eglobalreach.net [127.0.0.1]) + by mailer.eglobalreach.net (8.11.6p2/) with ESMTP id k4B6Zwf30823 + for ; Thu, 11 May 2006 14:35:58 +0800 +From: "Christian Paul Cosinas" +To: +Subject: Speed Up Offset and Limit Clause +Date: Thu, 11 May 2006 14:45:33 -0000 +Message-ID: <002801c67509$8f1a51a0$1e21100a@ghwk02002147> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook 11 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 +In-Reply-To: <25818.1147310405@sss.pgh.pa.us> +Thread-Index: AcZ0mS/0CCepxqjOT6y1bSuaIABQ5wAb/JNg +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/285 +X-Sequence-Number: 19072 + +Hi! + +How can I speed up my server's performance when I use offset and limit +clause. + +For example I have a query: +SELECT * FROM table ORDER BY id, name OFFSET 100000 LIMIT 10000 + +This query takes a long time about more than 2 minutes. + +If my query is: +SELECT * FROM table ORDER BY id, name OFFSET 50000 LIMIT 10000 +It takes about 2 seconds. + +Thanks + + +From pgsql-performance-owner@postgresql.org Thu May 11 12:26:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C0FEC9FA176 + for ; + Thu, 11 May 2006 12:26:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 26823-08 + for ; + Thu, 11 May 2006 12:26:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id B76859F9430 + for ; + Thu, 11 May 2006 12:26:24 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 784DA314BF; Thu, 11 May 2006 17:26:23 +0200 (MET DST) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: Postgres gets stuck +Date: Thu, 11 May 2006 23:26:12 +0800 +Organization: Hub.Org Networking Services +Lines: 20 +Message-ID: +References: <446135F9.1060608@modgraph-usa.com> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +X-RFC2646: Format=Flowed; Response +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/291 +X-Sequence-Number: 19078 + + +""Craig A. James"" wrote +> I'm having a rare but deadly problem. On our web servers, a process +> occasionally gets stuck, and can't be unstuck. Once it's stuck, all +> Postgres activities cease. "kill -9" is required to kill it -- +> signals 2 and 15 don't work, and "/etc/init.d/postgresql stop" fails. +> +> Details: +> +> Postgres 8.0.3 +> + +[Scanning 8.0.4 ~ 8.0.7 ...] Didn't find related bug fix in the upgrade +release. Can you attach to the problematic process and "bt" it (so we +could see where it stucks)? + +Regards, +Qingqing + + + +From pgsql-performance-owner@postgresql.org Thu May 11 12:36:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F341E9F9430; + Thu, 11 May 2006 12:36:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27458-09; Thu, 11 May 2006 12:36:10 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id EE34E9FA176; + Thu, 11 May 2006 12:36:09 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1FeDCR-0003Sh-00; Thu, 11 May 2006 11:35:35 -0400 +To: "Jim C. Nasby" +Cc: PFC , Greg Stark , + Tom Lane , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <8764kfz1iq.fsf@stark.xeocode.com> + <20060510192401.GQ99570@pervasive.com> +In-Reply-To: <20060510192401.GQ99570@pervasive.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 11 May 2006 11:35:34 -0400 +Message-ID: <87irocy3p5.fsf@stark.xeocode.com> +Lines: 37 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/292 +X-Sequence-Number: 19079 + + +"Jim C. Nasby" writes: + +> Perhaps it would be worth creating a class of temporary tables that used +> a tuplestore, although that would greatly limit what could be done with +> that temp table. + +I can say that I've seen plenty of instances where the ability to create +temporary tables very quickly with no overhead over the original query would +be useful. + +For instance, in one site I had to do exactly what I always advise others +against: use offset/limit to implement paging. So first I have to execute the +query with a count(*) aggregate to get the total, then execute the same query +a second time to fetch the actual page of interest. This would be (or could be +arranged to be) within the same transaction and doesn't require the ability to +execute any dml against the tuple store which I imagine would be the main +issues? + +For bonus points what would be real neat would be if the database could notice +shared plan segments, keep around the materialized tuple store, and substitute +it instead of reexecuting that segment of the plan. Of course this requires +keeping track of transaction snapshot states and making sure it's still +correct. + +> Something else worth considering is not using the normal catalog methods +> for storing information about temp tables, but hacking that together +> would probably be a rather large task. + +It would be nice if using this feature didn't interact poorly with preplanning +all your queries and using the cached plans. Perhaps if you had some way to +create a single catalog entry that defined all the column names and types and +then simply pointed it at a new tuplestore each time without otherwise +altering the catalog entry? + +-- +greg + + +From pgsql-performance-owner@postgresql.org Thu May 11 12:53:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2B2A89FA42B + for ; + Thu, 11 May 2006 12:53:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29981-07 + for ; + Thu, 11 May 2006 12:53:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id BD6359FA425 + for ; + Thu, 11 May 2006 12:53:37 -0300 (ADT) +Received: from moonunit2.moonview.localnet (wsip-70-167-125-69.sd.sd.cox.net + [70.167.125.69]) + by svr4.postgresql.org (Postfix) with ESMTP id E2B045B5195 + for ; + Thu, 11 May 2006 15:53:36 +0000 (GMT) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k4BG1StU000698; Thu, 11 May 2006 09:01:28 -0700 +Message-ID: <44635DFE.1060509@modgraph-usa.com> +Date: Thu, 11 May 2006 08:53:34 -0700 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Chris +Cc: pgsql-performance@postgresql.org +Subject: Re: Postgres gets stuck +References: <446135F9.1060608@modgraph-usa.com> <4461391D.2000800@gmail.com> +In-Reply-To: <4461391D.2000800@gmail.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/293 +X-Sequence-Number: 19080 + +Chris wrote: +> +>> This is a deadly bug, because our web site goes dead when this +>> happens, ... +> +> Sounds like a deadlock issue. +> ... +> stats_command_string = true +> and restart postgresql. +> then you'll be able to: +> select * from pg_stat_activity; +> to see what queries postgres is running and that might give you some clues. + +Thanks, good advice. You're absolutely right, it's stuck on a mutex. After doing what you suggest, I discovered that the query in progress is a user-written function (mine). When I log in as root, and use "gdb -p " to attach to the process, here's what I find. Notice the second function in the stack, a mutex lock: + +(gdb) bt +#0 0x0087f7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2 +#1 0x0096cbfe in __lll_mutex_lock_wait () from /lib/tls/libc.so.6 +#2 0x008ff67b in _L_mutex_lock_3220 () from /lib/tls/libc.so.6 +#3 0x4f5fc1b4 in ?? () +#4 0x00dc5e64 in std::string::_Rep::_S_empty_rep_storage () from /usr/local/pgsql/lib/libchmoogle.so +#5 0x009ffcf0 in ?? () from /usr/lib/libz.so.1 +#6 0xbfe71c04 in ?? () +#7 0xbfe71e50 in ?? () +#8 0xbfe71b78 in ?? () +#9 0x009f7019 in zcfree () from /usr/lib/libz.so.1 +#10 0x009f7019 in zcfree () from /usr/lib/libz.so.1 +#11 0x009f8b7c in inflateEnd () from /usr/lib/libz.so.1 +#12 0x00c670a2 in ~basic_unzip_streambuf (this=0xbfe71be0) at zipstreamimpl.h:332 +#13 0x00c60b61 in OpenBabel::OBConversion::Read (this=0x1, pOb=0xbfd923b8, pin=0xffffffea) at istream:115 +#14 0x00c60fd8 in OpenBabel::OBConversion::ReadString (this=0x8672b50, pOb=0xbfd923b8) at obconversion.cpp:780 +#15 0x00c19d69 in chmoogle_ichem_mol_alloc () at stl_construct.h:120 +#16 0x00c1a203 in chmoogle_ichem_normalize_parent () at stl_construct.h:120 +#17 0x00c1b172 in chmoogle_normalize_parent_sdf () at vector.tcc:243 +#18 0x0810ae4d in ExecMakeFunctionResult () +#19 0x0810de2e in ExecProject () +#20 0x08115972 in ExecResult () +#21 0x08109e01 in ExecProcNode () +#22 0x00000020 in ?? () +#23 0xbed4b340 in ?? () +#24 0xbf92d9a0 in ?? () +#25 0xbed4b0c0 in ?? () +#26 0x00000000 in ?? () + +It looks to me like my code is trying to read the input parameter (a fairly long string, maybe 2K) from a buffer that was gzip'ed by Postgres for the trip between the client and server. My suspicion is that it's an incompatibility between malloc() libraries. libz (gzip compression) is calling something called zcfree, which then appears to be intercepted by something that's (probably statically) linked into my library. And somewhere along the way, a mutex gets set, and then ... it's stuck forever. + +ps(1) shows that this thread had been running for about 7 hours, and the job status showed that this function had been successfully called about 1 million times, before this mutex lock occurred. + +Any ideas? + +Thanks, +Craig + +From pgsql-performance-owner@postgresql.org Thu May 11 14:18:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D0CF89FA2C3; + Thu, 11 May 2006 14:18:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 43223-04; Thu, 11 May 2006 14:18:09 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 3F9279FA19B; + Thu, 11 May 2006 14:18:09 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 0E16156423; Thu, 11 May 2006 12:18:08 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 11 May 2006 12:18:06 -0500 +Date: Thu, 11 May 2006 12:18:06 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: PFC , Mitchell Skinner , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Message-ID: <20060511171806.GJ99570@pervasive.com> +References: + <20060509113337.M90693@vesihiisi.cksoft.de> + <20060509103632.GD29652@svana.org> + <1147190285.32304.43.camel@firebolt> + <16680.1147201981@sss.pgh.pa.us> + <20060510190011.GO99570@pervasive.com> + <22558.1147307514@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <22558.1147307514@sss.pgh.pa.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060511:tgl@sss.pgh.pa.us::DLH32YqxBy8/Z/xv:00000000000000000000 + 0000000000000000000000004/uu +X-Hashcash: 1:20:060511:lists@peufeu.com::EV3XS0wuSbcssPdG:02QEw +X-Hashcash: 1:20:060511:mitch@arctur.us::TlYxXSYELoeEhlGP:000cCE +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::Buh7YfsrlCmyuSSA:00000 + 00000000000000000000000018ja +X-Hashcash: + 1:20:060511:pgsql-hackers@postgresql.org::RosOvgP9IluLZgaB:000000000 + 0000000000000000000000004Cu2 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/294 +X-Sequence-Number: 19081 + +On Wed, May 10, 2006 at 08:31:54PM -0400, Tom Lane wrote: +> "Jim C. Nasby" writes: +> > On Tue, May 09, 2006 at 03:13:01PM -0400, Tom Lane wrote: +> >> PFC writes: +> >>> Fun thing is, the rowcount from a temp table (which is the problem here) +> >>> should be available without ANALYZE ; as the temp table is not concurrent, +> >>> it would be simple to inc/decrement a counter on INSERT/DELETE... +> >> +> >> No, because MVCC rules still apply. +> +> > But can anything ever see more than one version of what's in the table? +> +> Yes, because there can be more than one active snapshot within a single +> transaction (think about volatile functions in particular). + +Any documentation on how snapshot's work? They're a big mystery to me. +:( + +> > Speaking of which, if a temp table is defined as ON COMMIT DROP or +> > DELETE ROWS, there shouldn't be any need to store xmin/xmax, only +> > cmin/cmax, correct? +> +> No; you forgot about subtransactions. + +Oh, I thought those were done with cmin and cmax... if that's not what +cmin/cmax are for, then what is? +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu May 11 15:03:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5F5CB9FA2C3; + Thu, 11 May 2006 15:03:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 48930-01; Thu, 11 May 2006 15:02:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) + by postgresql.org (Postfix) with ESMTP id B7DE09FA278; + Thu, 11 May 2006 15:02:58 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Thu, 11 May 2006 18:02:57 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 11 May 2006 13:02:57 -0500 +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +From: Scott Marlowe +To: "Jim C. Nasby" +Cc: Tom Lane , PFC , + Mitchell Skinner , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +In-Reply-To: <20060511171806.GJ99570@pervasive.com> +References: + <20060509113337.M90693@vesihiisi.cksoft.de> + + <20060509103632.GD29652@svana.org> + <1147190285.32304.43.camel@firebolt> + <16680.1147201981@sss.pgh.pa.us> <20060510190011.GO99570@pervasive.com> + <22558.1147307514@sss.pgh.pa.us> <20060511171806.GJ99570@pervasive.com> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1147370576.9755.81.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Thu, 11 May 2006 13:02:57 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/295 +X-Sequence-Number: 19082 + +On Thu, 2006-05-11 at 12:18, Jim C. Nasby wrote: +> On Wed, May 10, 2006 at 08:31:54PM -0400, Tom Lane wrote: +> > "Jim C. Nasby" writes: +> > > On Tue, May 09, 2006 at 03:13:01PM -0400, Tom Lane wrote: +> > >> PFC writes: +> > >>> Fun thing is, the rowcount from a temp table (which is the problem here) +> > >>> should be available without ANALYZE ; as the temp table is not concurrent, +> > >>> it would be simple to inc/decrement a counter on INSERT/DELETE... +> > >> +> > >> No, because MVCC rules still apply. +> > +> > > But can anything ever see more than one version of what's in the table? +> > +> > Yes, because there can be more than one active snapshot within a single +> > transaction (think about volatile functions in particular). +> +> Any documentation on how snapshot's work? They're a big mystery to me. +> :( + +http://www.postgresql.org/docs/8.1/interactive/mvcc.html + +Does the concurrency doc not cover this subject well enough (I'm not +being sarcastic, it's a real question) + +From pgsql-performance-owner@postgresql.org Thu May 11 15:03:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C8FC99FA278; + Thu, 11 May 2006 15:03:40 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 48930-02; Thu, 11 May 2006 15:03:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svana.org (svana.org [125.62.94.225]) + by postgresql.org (Postfix) with ESMTP id 325789FA19B; + Thu, 11 May 2006 15:03:32 -0300 (ADT) +Received: from kleptog by svana.org with local (Exim 4.50) + id 1FeFVP-0000tN-EY; Fri, 12 May 2006 04:03:19 +1000 +Date: Thu, 11 May 2006 20:03:19 +0200 +From: Martijn van Oosterhout +To: "Jim C. Nasby" +Cc: Tom Lane , PFC , + Mitchell Skinner , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Message-ID: <20060511180319.GK30113@svana.org> +Reply-To: Martijn van Oosterhout +References: <20060509113337.M90693@vesihiisi.cksoft.de> + <20060509103632.GD29652@svana.org> + <1147190285.32304.43.camel@firebolt> + <16680.1147201981@sss.pgh.pa.us> + <20060510190011.GO99570@pervasive.com> + <22558.1147307514@sss.pgh.pa.us> + <20060511171806.GJ99570@pervasive.com> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="wRokNccIwvMzawGl" +Content-Disposition: inline +In-Reply-To: <20060511171806.GJ99570@pervasive.com> +X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 +X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 +X-PGP-Key-URL: +User-Agent: Mutt/1.5.9i +X-SA-Exim-Connect-IP: +X-SA-Exim-Mail-From: kleptog@svana.org +X-SA-Exim-Scanned: No (on svana.org); SAEximRunCond expanded to false +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/296 +X-Sequence-Number: 19083 + + +--wRokNccIwvMzawGl +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Thu, May 11, 2006 at 12:18:06PM -0500, Jim C. Nasby wrote: +> > Yes, because there can be more than one active snapshot within a single +> > transaction (think about volatile functions in particular). +>=20 +> Any documentation on how snapshot's work? They're a big mystery to me. +> :( + +A snapshot is a particular view on a database. In particular, you have +to be able to view a version of the database that doesn't have you own +changes, otherwise an UPDATE would keep updating the same tuple. Also, +for example, a cursor might see an older version of the database than +queries being run. I don't know of any particular information about it +though. Google wasn't that helpful. + +> > No; you forgot about subtransactions. +>=20 +> Oh, I thought those were done with cmin and cmax... if that's not what +> cmin/cmax are for, then what is? + +cmin/cmax are command counters. So in the sequence: + +BEGIN; +SELECT 1; +SELECT 2; + +The second query runs as the same transaction ID but a higher command +ID so it can see the result of the previous query. Subtransactions are +(AIUI anyway) done by having transactions depend on other transactions. +When you start a savepoint you start a new transaction ID whose status +is tied to its top-level transaction ID but can also be individually +rolledback. + +Have a nice day, +--=20 +Martijn van Oosterhout http://svana.org/kleptog/ +> From each according to his ability. To each according to his ability to l= +itigate. + +--wRokNccIwvMzawGl +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.1 (GNU/Linux) + +iD8DBQFEY3xnIB7bNG8LQkwRAvStAJwPOOQDFdA0YsuR1YyQM5R5RsW6IQCdEuuy +4nCzDPu03kEvn3ne37Lz01c= +=pO1U +-----END PGP SIGNATURE----- + +--wRokNccIwvMzawGl-- + +From pgsql-performance-owner@postgresql.org Thu May 11 15:44:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F0A4F9FA278; + Thu, 11 May 2006 15:44:05 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 52947-03; Thu, 11 May 2006 15:43:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svana.org (svana.org [125.62.94.225]) + by postgresql.org (Postfix) with ESMTP id D510F9FA19B; + Thu, 11 May 2006 15:43:54 -0300 (ADT) +Received: from kleptog by svana.org with local (Exim 4.50) + id 1FeG8Y-0000za-9o; Fri, 12 May 2006 04:43:46 +1000 +Date: Thu, 11 May 2006 20:43:46 +0200 +From: Martijn van Oosterhout +To: Greg Stark +Cc: "Jim C. Nasby" , PFC , + Tom Lane , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Message-ID: <20060511184346.GL30113@svana.org> +Reply-To: Martijn van Oosterhout +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <8764kfz1iq.fsf@stark.xeocode.com> + <20060510192401.GQ99570@pervasive.com> + <87irocy3p5.fsf@stark.xeocode.com> +Mime-Version: 1.0 +Content-Type: multipart/signed; micalg=pgp-sha1; + protocol="application/pgp-signature"; boundary="8SdtHY/0P4yzaavF" +Content-Disposition: inline +In-Reply-To: <87irocy3p5.fsf@stark.xeocode.com> +X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 +X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 +X-PGP-Key-URL: +User-Agent: Mutt/1.5.9i +X-SA-Exim-Connect-IP: +X-SA-Exim-Mail-From: kleptog@svana.org +X-SA-Exim-Scanned: No (on svana.org); SAEximRunCond expanded to false +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/297 +X-Sequence-Number: 19084 + + +--8SdtHY/0P4yzaavF +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +Content-Transfer-Encoding: quoted-printable + +On Thu, May 11, 2006 at 11:35:34AM -0400, Greg Stark wrote: +> I can say that I've seen plenty of instances where the ability to create +> temporary tables very quickly with no overhead over the original query wo= +uld +> be useful. + +I wonder if this requires what the standard refers to as a global +temporary table. As I read it (which may be wrong, I find the language +obtuse), a global temporary table is a temporary table whose structure +is predefined. So, you'd define it once, updating the catalog only once +but still get a table that is emptied each startup. + +Ofcourse, it may not be what the standard means, but it still seems +like a useful idea, to cut down on schema bloat. + +Have a nice day, +--=20 +Martijn van Oosterhout http://svana.org/kleptog/ +> From each according to his ability. To each according to his ability to l= +itigate. + +--8SdtHY/0P4yzaavF +Content-Type: application/pgp-signature; name="signature.asc" +Content-Description: Digital signature +Content-Disposition: inline + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.1 (GNU/Linux) + +iD8DBQFEY4XiIB7bNG8LQkwRAln9AKCFgYWudZO1ZVrOW54ROba1LrTW8QCggu9i +vMIXiGMKBbJtscz5s+5n3Tc= +=Sbe8 +-----END PGP SIGNATURE----- + +--8SdtHY/0P4yzaavF-- + +From pgsql-performance-owner@postgresql.org Thu May 11 16:57:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id ABB659FA19B; + Thu, 11 May 2006 16:57:20 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 64713-03; Thu, 11 May 2006 16:57:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id A50889FA278; + Thu, 11 May 2006 16:57:12 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 71F1A56427; Thu, 11 May 2006 14:57:11 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 11 May 2006 14:57:10 -0500 +Date: Thu, 11 May 2006 14:57:10 -0500 +From: "Jim C. Nasby" +To: Martijn van Oosterhout +Cc: Tom Lane , PFC , + Mitchell Skinner , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Message-ID: <20060511195710.GL99570@pervasive.com> +References: <20060509103632.GD29652@svana.org> + <1147190285.32304.43.camel@firebolt> + <16680.1147201981@sss.pgh.pa.us> + <20060510190011.GO99570@pervasive.com> + <22558.1147307514@sss.pgh.pa.us> + <20060511171806.GJ99570@pervasive.com> + <20060511180319.GK30113@svana.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060511180319.GK30113@svana.org> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060511:kleptog@svana.org::en5hgAXxn9Urn2le:00000000000000000000 + 0000000000000000000000000oe8 +X-Hashcash: + 1:20:060511:tgl@sss.pgh.pa.us::Nn8ifYS/n7DWIB+W:00000000000000000000 + 0000000000000000000000002YdI +X-Hashcash: 1:20:060511:lists@peufeu.com::pE8r/w2vQQYuElGy:00yrV +X-Hashcash: 1:20:060511:mitch@arctur.us::zGURRgWZEdqUxD1E:000T6/ +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::PLjmwndoGaH+dxwj:00000 + 0000000000000000000000002GH+ +X-Hashcash: + 1:20:060511:pgsql-hackers@postgresql.org::BiJ3A7IV7SXxJEH9:000000000 + 0000000000000000000000000JU9 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/298 +X-Sequence-Number: 19085 + +On Thu, May 11, 2006 at 08:03:19PM +0200, Martijn van Oosterhout wrote: +> On Thu, May 11, 2006 at 12:18:06PM -0500, Jim C. Nasby wrote: +> > > Yes, because there can be more than one active snapshot within a single +> > > transaction (think about volatile functions in particular). +> > +> > Any documentation on how snapshot's work? They're a big mystery to me. +> > :( +> +> A snapshot is a particular view on a database. In particular, you have +> to be able to view a version of the database that doesn't have you own +> changes, otherwise an UPDATE would keep updating the same tuple. Also, +> for example, a cursor might see an older version of the database than +> queries being run. I don't know of any particular information about it +> though. Google wasn't that helpful. + +Ahh, I'd forgotten that commands sometimes needed to see prior data. But +that's done with cmin/max, right? + +In any case, going back to the original thought/question... my point was +that in a single-session table, it should be possible to maintain a +row counter. Worst case, you might have to keep a seperate count for +each CID or XID, but that doesn't seem that unreasonable for a single +backend to do, unless you end up running a heck of a lot of commands. +More importantnly, it seems a lot more feasable to at least know how +many rows there are every time you COMMIT, which means you can +potentially avoid having to ANALYZE. + +> > > No; you forgot about subtransactions. +> > +> > Oh, I thought those were done with cmin and cmax... if that's not what +> > cmin/cmax are for, then what is? +> +> cmin/cmax are command counters. So in the sequence: +> +> BEGIN; +> SELECT 1; +> SELECT 2; +> +> The second query runs as the same transaction ID but a higher command +> ID so it can see the result of the previous query. Subtransactions are +> (AIUI anyway) done by having transactions depend on other transactions. +> When you start a savepoint you start a new transaction ID whose status +> is tied to its top-level transaction ID but can also be individually +> rolledback. + +Hmmm, interesting. I would have thought it was tied to CID, but I guess +XID has more of that machinery around to support rollback. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu May 11 17:00:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5D7A39FA2C3; + Thu, 11 May 2006 17:00:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 66976-03; Thu, 11 May 2006 17:00:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 7AE489FA278; + Thu, 11 May 2006 17:00:31 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 837EB56427; Thu, 11 May 2006 15:00:30 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 11 May 2006 15:00:28 -0500 +Date: Thu, 11 May 2006 15:00:28 -0500 +From: "Jim C. Nasby" +To: Martijn van Oosterhout +Cc: Greg Stark , PFC , + Tom Lane , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Message-ID: <20060511200028.GM99570@pervasive.com> +References: <445F7FF8.6070707@comcast.net> + <1147110142.32369.7.camel@archimedes> + <20060508175013.GY99570@pervasive.com> + <28288.1147111196@sss.pgh.pa.us> + <8764kfz1iq.fsf@stark.xeocode.com> + <20060510192401.GQ99570@pervasive.com> + <87irocy3p5.fsf@stark.xeocode.com> + <20060511184346.GL30113@svana.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060511184346.GL30113@svana.org> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060511:kleptog@svana.org::3UmfheADOTPsgb8q:00000000000000000000 + 0000000000000000000000002aUq +X-Hashcash: 1:20:060511:gsstark@mit.edu::l5wqSpBcawkzwBV6:0002N5 +X-Hashcash: 1:20:060511:lists@peufeu.com::TZtNRd5Iqh/BtVHD:01I/w +X-Hashcash: + 1:20:060511:tgl@sss.pgh.pa.us::GPcwWcvLdOoD/NfY:00000000000000000000 + 0000000000000000000000009jRL +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::ehhLFh4Etkst5z/p:00000 + 0000000000000000000000000WXU +X-Hashcash: + 1:20:060511:pgsql-hackers@postgresql.org::H+H4YZ7a/16rPWXp:000000000 + 000000000000000000000000Dzqe +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/299 +X-Sequence-Number: 19086 + +On Thu, May 11, 2006 at 08:43:46PM +0200, Martijn van Oosterhout wrote: +> On Thu, May 11, 2006 at 11:35:34AM -0400, Greg Stark wrote: +> > I can say that I've seen plenty of instances where the ability to create +> > temporary tables very quickly with no overhead over the original query would +> > be useful. +> +> I wonder if this requires what the standard refers to as a global +> temporary table. As I read it (which may be wrong, I find the language +> obtuse), a global temporary table is a temporary table whose structure +> is predefined. So, you'd define it once, updating the catalog only once +> but still get a table that is emptied each startup. +> +> Ofcourse, it may not be what the standard means, but it still seems +> like a useful idea, to cut down on schema bloat. + +IIRC that's the exact syntax Oracle uses: + +CREATE GLOBAL TEMPORARY TABLE ... + +I always found it a bit odd, since it always seemed to me like a global +temporary table would be one that every backend could read... something +akin to a real table that doesn't worry about fsync or any of that (and +is potentially not backed on disk at all). +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-general-owner@postgresql.org Thu May 11 17:06:13 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4A7B39FA278 + for ; + Thu, 11 May 2006 17:06:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 64518-08 + for ; + Thu, 11 May 2006 17:06:07 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 0629F9FA19B + for ; + Thu, 11 May 2006 17:06:06 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id BFFFB31495; Thu, 11 May 2006 22:06:05 +0200 (MET DST) +From: Ron Mayer +X-Newsgroups: pgsql.general +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +Date: Thu, 11 May 2006 13:04:16 -0700 +Organization: Hub.Org Networking Services +Lines: 39 +Message-ID: <446398C0.4020104@cheapcomplexdevices.com> +References: + <473FC220-A52C-4954-81E9-A14ED33164C2@blighty.com> + <4460BA8B.7010600@commandprompt.com> + <4F853BBA-175C-4B3E-BAF4-AA34B80DF6EF@blighty.com> + <4460DED4.2090103@commandprompt.com> + <7779142C-B027-4C17-A67C-A7C220AADF80@slamb.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Complaints-To: usenet@news.hub.org +To: Scott Lamb , "Joshua D. Drake" , + rm_pg@cheapcomplexdevices.com +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +In-Reply-To: <7779142C-B027-4C17-A67C-A7C220AADF80@slamb.org> +To: pgsql-general@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/498 +X-Sequence-Number: 95290 + +On May 9, 2006, at 11:26 AM, Joshua D. Drake wrote: +> Of course not, but which drives lie about sync that are SATA? Or more +> specifically SATA-II? + +With older Linux drivers (before spring 2005, I think) - all of +them - since it seems the linux kernel didn't support the +write barriers needed to force the sync. It's not clear to +me how much of the SATA data loss is due to this driver issue +and how much is due to buggy drives themselves. + +According to Jeff Garzik (the guy who wrote the SATA drivers +for Linux) [1] + + "You need a vaguely recent 2.6.x kernel to support fsync(2) + and fdatasync(2) flushing your disk's write cache. + Previous 2.4.x and 2.6.x kernels would only flush the write + cache upon reboot, or if you used a custom app to issue + the 'flush cache' command directly to your disk. + + Very recent 2.6.x kernels include write barrier support, which + flushes the write cache when the ext3 journal gets flushed to disk. + + If your kernel doesn't flush the write cache, then obviously there + is a window where you can lose data. Welcome to the world of + write-back caching, circa 1990. + + If you are stuck without a kernel that issues the FLUSH CACHE (IDE) + or SYNCHRONIZE CACHE (SCSI) command, it is trivial to write + a userspace utility that issues the command. + + Jeff, the Linux SATA driver guy + " + +I've wondered for a while if this driver issue is actually the +source of most of the fear around SATA drives. Note it appears +that with those old kernels you aren't that safe with SCSI either. + + +[1] in may 2005, http://hardware.slashdot.org/comments.pl?sid=149349&cid=12519114 + +From pgsql-performance-owner@postgresql.org Thu May 11 18:01:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 57EF79FA2C8; + Thu, 11 May 2006 18:01:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 82824-05; Thu, 11 May 2006 18:01:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 9625E9FA278; + Thu, 11 May 2006 18:01:45 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 2C1C056427; Thu, 11 May 2006 16:01:44 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 11 May 2006 16:01:41 -0500 +Date: Thu, 11 May 2006 16:01:41 -0500 +From: "Jim C. Nasby" +To: Zeugswetter Andreas DCP SD +Cc: PFC , Greg Stark , + Tom Lane , pgsql-performance@postgresql.org, + pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Message-ID: <20060511210141.GP99570@pervasive.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060511:zeugswettera@spardat.at::1N1XJqGWo7olJL79:00000000000000 + 0000000000000000000000000P1D +X-Hashcash: 1:20:060511:lists@peufeu.com::JjLUEovSkgFvFa9e:0GPdf +X-Hashcash: 1:20:060511:gsstark@mit.edu::YXTqhgw6evKGGCnp:002ya9 +X-Hashcash: + 1:20:060511:tgl@sss.pgh.pa.us::KBsDLFmggR4HH/qt:00000000000000000000 + 0000000000000000000000005UMr +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::pkpwx+FXoqwCtCMT:00000 + 00000000000000000000000008iI +X-Hashcash: + 1:20:060511:pgsql-hackers@postgresql.org::1DG9vgGnqRY6+jp9:000000000 + 0000000000000000000000006mHC +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/300 +X-Sequence-Number: 19087 + +On Thu, May 11, 2006 at 09:55:15AM +0200, Zeugswetter Andreas DCP SD wrote: +> +> > Something else worth considering is not using the normal +> > catalog methods +> > for storing information about temp tables, but hacking that together +> > would probably be a rather large task. +> +> But the timings suggest, that it cannot be the catalogs in the worst +> case +> he showed. +> +> > 0.101 ms BEGIN +> > 1.451 ms CREATE TEMPORARY TABLE tmp ( a INTEGER NOT NULL, b INTEGER +> NOT +> > NULL, c TIMESTAMP NOT NULL, d INTEGER NOT NULL ) ON COMMIT DROP +> +> 1.4 seconds is not great for create table, is that what we expect ? +milliseconds... :) Given the amount of code and locking that it looks +like is involved in creating a table, that might not be unreasonable... + +> > 0.450 ms INSERT INTO tmp SELECT * FROM bookmarks ORDER BY annonce_id +> DESC +> > LIMIT 20 +> > 0.443 ms ANALYZE tmp +> > 0.365 ms SELECT * FROM tmp +> > 0.310 ms DROP TABLE tmp +> > 32.918 ms COMMIT +> > +> > CREATING the table is OK, but what happens on COMMIT ? I hear +> the disk +> > seeking frantically. +> +> The 32 seconds for commit can hardly be catalog related. It seems the +> file is +> fsynced before it is dropped. + +I'd hope that wasn't what's happening... is the backend smart enough to +know not to fsync anything involved with the temp table? ISTM that that +transaction shouldn't actually be creating any WAL traffic at all. +Though on the other hand there's no reason that DROP should be in the +transaction at all; maybe that's gumming things up during the commit. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu May 11 18:32:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B96499FA2C3 + for ; + Thu, 11 May 2006 18:32:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 89766-10 + for ; + Thu, 11 May 2006 18:32:05 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 2EA099FA278 + for ; + Thu, 11 May 2006 18:32:04 -0300 (ADT) +Received: (qmail 13552 invoked from network); 11 May 2006 23:33:32 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 11 May 2006 23:33:32 +0200 +To: "Jim C. Nasby" , + "Zeugswetter Andreas DCP SD" +Cc: "Greg Stark" , "Tom Lane" , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +References: + <20060511210141.GP99570@pervasive.com> +Message-ID: +Date: Thu, 11 May 2006 23:33:31 +0200 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <20060511210141.GP99570@pervasive.com> +User-Agent: Opera M2/8.51 (Linux, build 1462) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/301 +X-Sequence-Number: 19088 + + + +>> > 0.450 ms INSERT INTO tmp SELECT * FROM bookmarks ORDER BY annonce_id +>> DESC +>> > LIMIT 20 +>> > 0.443 ms ANALYZE tmp +>> > 0.365 ms SELECT * FROM tmp +>> > 0.310 ms DROP TABLE tmp +>> > 32.918 ms COMMIT + +>> The 32 seconds for commit can hardly be catalog related. It seems the +>> file is +>> fsynced before it is dropped. +> +> I'd hope that wasn't what's happening... is the backend smart enough to +> know not to fsync anything involved with the temp table? ISTM that that +> transaction shouldn't actually be creating any WAL traffic at all. +> Though on the other hand there's no reason that DROP should be in the +> transaction at all; maybe that's gumming things up during the commit. + + I included the DROP to make it clear that the time was spent in +COMMITting, not in DROPping the table. + Also, you can't use CREATE TEMP TABLE AS SELECT ... and at the same time +make it ON COMMIT DROP. You have to CREATE and INSERT. + With an ON COMMIT DROP temp table, the global timings are the same wether +or not it is dropped before commit : it is always the COMMIT which takes +all the milliseconds. + + I still bet on system catalog updates being the main cause of the time +spent in COMMIT... + (because ANALYZE changes this time) + +From pgsql-performance-owner@postgresql.org Thu May 11 19:04:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AF7939FA5F8 + for ; + Thu, 11 May 2006 19:04:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 94106-04 + for ; + Thu, 11 May 2006 19:04:05 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 85F249F9F2E + for ; + Thu, 11 May 2006 19:04:05 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id BC3C056435; Thu, 11 May 2006 17:04:03 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 11 May 2006 17:04:02 -0500 +Date: Thu, 11 May 2006 17:04:02 -0500 +From: "Jim C. Nasby" +To: Witold Strzelczyk +Cc: pgsql-performance@postgresql.org +Subject: Re: slow variable against int?? +Message-ID: <20060511220402.GS99570@pervasive.com> +References: <200605051646.44060.w.strzelczyk@digitalone.pl> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200605051646.44060.w.strzelczyk@digitalone.pl> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060511:w.strzelczyk@digitalone.pl::ubzxNaFT3KMaHB3T:00000000000 + 00000000000000000000000031IN +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::OyU1b7ATSRAYe/Fl:00000 + 00000000000000000000000098iE +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/302 +X-Sequence-Number: 19089 + +If you're trying to come up with ranking then you'll be much happier +using a sequence and pulling from it using an ordered select. See lines +19-27 in http://lnk.nu/cvs.distributed.net/9bu.sql for an example. +Depending on what you're doing you might not need the temp table. + +On Fri, May 05, 2006 at 04:46:43PM +0200, Witold Strzelczyk wrote: +> I have a question about my function. I must get user rating by game result. +> This isn't probably a perfect solution but I have one question about +> +> select into inGameRating count(game_result)+1 from users +> where game_result > inRow.game_result; +> +> This query in function results in about 1100 ms. +> inRow.game_result is a integer 2984 +> And now if I replace inRow.game_result with integer +> +> select into inGameRating count(game_result)+1 from users +> where game_result > 2984; +> +> query results in about 100 ms +> +> There is probably a reason for this but can you tell me about it because I +> can't fine one +> +> My function: +> +> create or replace function ttt_result(int,int) returns setof tparent_result +> language plpgsql volatile as $$ +> declare +> inOffset alias for $1; +> inLimit alias for $2; +> inRow tparent_result%rowtype; +> inGameResult int := -1; +> inGameRating int := -1; +> begin +> +> for inRow in +> select +> email,wynik_gra +> from +> konkurs_uzytkownik +> order by wynik_gra desc limit inLimit offset inOffset +> loop +> if inGameResult < 0 then -- only for first iteration +> /* this is fast ~100 ms +> select into inGameRating +> count(game_result)+1 from users +> where game_result > 2984; +> */ +> /* even if inRow.game_result = 2984 this is very slow ~ 1100 ms! +> select into inGameRating count(game_result)+1 from users +> where game_result > inRow.game_result; +> */ +> inGameResult := inRow.game_result; +> end if; +> +> if inGameResult > inRow.game_result then +> inGameRating := inGameRating + 1; +> end if; +> +> inRow.game_rating := inGameRating; +> inGameResult := inRow.game_result; +> return next inRow; +> +> end loop; +> return; +> end; +> $$; +> -- +> Witold Strzelczyk +> witek.strzelczyk@gmail.com +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu May 11 19:05:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 38CC39FA5FB + for ; + Thu, 11 May 2006 19:05:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 94420-09 + for ; + Thu, 11 May 2006 19:05:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 1AB799F9F2E + for ; + Thu, 11 May 2006 19:05:26 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id EBC5B56437; Thu, 11 May 2006 17:05:24 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 11 May 2006 17:05:23 -0500 +Date: Thu, 11 May 2006 17:05:23 -0500 +From: "Jim C. Nasby" +To: Adam Palmblad +Cc: pgsql-performance@postgresql.org +Subject: Re: Dynamically loaded C function performance +Message-ID: <20060511220523.GT99570@pervasive.com> +References: <6B5AF6293A289F45826220B17ABE79370D5ED7@BORON.aers.local> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <6B5AF6293A289F45826220B17ABE79370D5ED7@BORON.aers.local> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060511:apalmblad@dataunison.com::t2BD6Lyng8GN625h:0000000000000 + 000000000000000000000000EPUU +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::IykQHeSWuXP3I1Lz:00000 + 0000000000000000000000004CS1 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/303 +X-Sequence-Number: 19090 + +On Fri, May 05, 2006 at 03:47:53PM -0700, Adam Palmblad wrote: +> Hi, +> We've got a C function that we use here and we find that for every +> connection, the first run of the function is much slower than any +> subsequent runs. ( 50ms compared to 8ms) +> +> Besides using connection pooling, are there any options to improve +> performance? + +In my experience, connection startup takes a heck of a lot longer than +50ms, so why are you worrying about 50ms for the first run of a +function? + +BTW, sorry, but I don't know a way to speed this up, either. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu May 11 19:08:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 304B99F9F2E + for ; + Thu, 11 May 2006 19:08:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 97474-02-6 + for ; + Thu, 11 May 2006 19:08:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 3BC479FA5F8 + for ; + Thu, 11 May 2006 19:08:04 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 1177E56431; Thu, 11 May 2006 17:08:03 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 11 May 2006 17:08:02 -0500 +Date: Thu, 11 May 2006 17:08:02 -0500 +From: "Jim C. Nasby" +To: Brendan Duddridge +Cc: PostgreSQL Performance +Subject: Re: Assistance with optimizing query - same SQL, + different category_id = Seq Scan +Message-ID: <20060511220802.GU99570@pervasive.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060511:brendan@clickspace.com::rzJd8QjjWmryBdF9:000000000000000 + 0000000000000000000000000sve +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::nucCzg65Nrgiy7Sm:00000 + 0000000000000000000000003oET +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/304 +X-Sequence-Number: 19091 + +On Mon, May 08, 2006 at 07:29:32PM -0600, Brendan Duddridge wrote: +> Do you have any suggestions on how I can optimize the query so both +> versions of the query come back fast without doing a sequential scan +> on the price table? + +Well, before you do anything you should verify that an index scan in the +second case would actually be faster. Set enable_seqscan=off and check +that. + +After that, you can favor an index scan by (in order of effectiveness) +increasing the correlation on the appropriate index (by clustering on +it), lowering random_page_cost, or increasing effective_cache_size. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu May 11 19:08:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C79789FA5FB + for ; + Thu, 11 May 2006 19:08:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 93589-07 + for ; + Thu, 11 May 2006 19:08:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 09FB99F9F2E + for ; + Thu, 11 May 2006 19:08:44 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4BM8axf004336; + Thu, 11 May 2006 18:08:36 -0400 (EDT) +To: "Jim C. Nasby" +cc: Zeugswetter Andreas DCP SD , + PFC , Greg Stark , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +In-reply-to: <20060511210141.GP99570@pervasive.com> +References: + <20060511210141.GP99570@pervasive.com> +Comments: In-reply-to "Jim C. Nasby" + message dated "Thu, 11 May 2006 16:01:41 -0500" +Date: Thu, 11 May 2006 18:08:36 -0400 +Message-ID: <4335.1147385316@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/305 +X-Sequence-Number: 19092 + +"Jim C. Nasby" writes: +> I'd hope that wasn't what's happening... is the backend smart enough to +> know not to fsync anything involved with the temp table? + +The catalog entries required for it have to be fsync'd, unless you enjoy +putting your entire database at risk (a bad block in pg_class, say, +would probably take out more than one table). + +It's interesting to speculate about keeping such catalog entries in +child tables of pg_class etc that are themselves temp tables. Resolving +the apparent circularity of this is left as an exercise for the reader. + + regards, tom lane + +From pgsql-general-owner@postgresql.org Thu May 11 19:19:37 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6EBD19FA334; + Thu, 11 May 2006 19:19:37 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 97850-03; Thu, 11 May 2006 19:19:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 32E6D9FA294; + Thu, 11 May 2006 19:19:30 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 7843456437; Thu, 11 May 2006 17:19:29 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 11 May 2006 17:19:28 -0500 +Date: Thu, 11 May 2006 17:19:28 -0500 +From: "Jim C. Nasby" +To: Bruce Momjian +Cc: "Joshua D. Drake" , Vivek Khera , + "Pgsql-Performance ((E-mail))" , + PostgreSQL General +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +Message-ID: <20060511221928.GV99570@pervasive.com> +References: <4460DE97.9040001@commandprompt.com> + <200605100059.k4A0xtK09977@candle.pha.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200605100059.k4A0xtK09977@candle.pha.pa.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060511:pgman@candle.pha.pa.us::QIrXfUbGQ2Jcnyn7:000000000000000 + 0000000000000000000000000Txd +X-Hashcash: + 1:20:060511:jd@commandprompt.com::Yh5wmUIydihw7RXB:00000000000000000 + 00000000000000000000000001JH +X-Hashcash: 1:20:060511:vivek@khera.org::Jk2qrSEVCNXbw5rY:000KBq +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::NVVYPtxtQbMOtXQP:00000 + 0000000000000000000000006oi3 +X-Hashcash: + 1:20:060511:pgsql-general@postgresql.org::RBVZdavQM8U3ymdS:000000000 + 0000000000000000000000001g+x +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/508 +X-Sequence-Number: 95300 + +On Tue, May 09, 2006 at 08:59:55PM -0400, Bruce Momjian wrote: +> Joshua D. Drake wrote: +> > Vivek Khera wrote: +> > > +> > > On May 9, 2006, at 11:51 AM, Joshua D. Drake wrote: +> > > +> > >> Sorry that is an extremely misleading statement. SATA RAID is +> > >> perfectly acceptable if you have a hardware raid controller with a +> > >> battery backup controller. +> > >> +> > >> And dollar for dollar, SCSI will NOT be faster nor have the hard drive +> > >> capacity that you will get with SATA. +> > > +> > > Does this hold true still under heavy concurrent-write loads? I'm +> > > preparing yet another big DB server and if SATA is a better option, I'm +> > > all (elephant) ears. +> > +> > I didn't say better :). If you can afford, SCSI is the way to go. +> > However SATA with a good controller (I am fond of the LSI 150 series) +> > can provide some great performance. +> +> Basically, you can get away with cheaper hardware, but it usually +> doesn't have the reliability/performance of more expensive options. +> +> You want an in-depth comparison of how a server disk drive is internally +> better than a desktop drive: +> +> http://www.seagate.com/content/docs/pdf/whitepaper/D2c_More_than_Interface_ATA_vs_SCSI_042003.pdf + +BTW, someone (Western Digital?) is now offering SATA drives that carry +the same MTBF/warranty/what-not as their SCSI drives. I can't remember +if they actually claim that it's the same mechanisms just with a +different controller on the drive... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-general-owner@postgresql.org Thu May 11 19:32:22 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id ADD899FB0D1; + Thu, 11 May 2006 19:32:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 97655-08; Thu, 11 May 2006 19:32:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 4EA439FADD1; + Thu, 11 May 2006 19:32:13 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 7925E56423; Thu, 11 May 2006 17:32:11 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 11 May 2006 17:32:10 -0500 +Date: Thu, 11 May 2006 17:32:10 -0500 +From: "Jim C. Nasby" +To: "Jean-Yves F. Barbier" <7ukwn@free.fr> +Cc: Hannes Dorbath , + pgsql-general@postgresql.org, pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +Message-ID: <20060511223210.GW99570@pervasive.com> +References: <44606A98.4090705@free.fr> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <44606A98.4090705@free.fr> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060511:7ukwn@free.fr::M/4D+KzCMK+FXdjQ:00006X9H +X-Hashcash: + 1:20:060511:light@theendofthetunnel.de::flAu2o2sBshfuOO1:00000000000 + 0000000000000000000000001Y6H +X-Hashcash: + 1:20:060511:pgsql-general@postgresql.org::wo6iD7amg+C51PF6:000000000 + 00000000000000000000000009aL +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::rKnGwigY7o7e7L0U:00000 + 0000000000000000000000000YSH +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/509 +X-Sequence-Number: 95301 + +On Tue, May 09, 2006 at 12:10:32PM +0200, Jean-Yves F. Barbier wrote: +> > I myself can't see much reason to spend $500 on high end controller +> > cards for a simple Raid 1. +> +> Naa, you can find ATA &| SATA ctrlrs for about EUR30 ! + +And you're likely getting what you paid for: crap. Such a controller is +less likely to do things like turn of write caching so that fsync works +properly. + +> > + Hardware Raids might be a bit easier to manage, if you never spend a +> > few hours to learn Software Raid Tools. +> +> I'd the same (mostly as you still have to punch a command line for +> most of the controlers) + +Controllers I've seen have some kind of easy to understand GUI, at least +during bootup. When it comes to OS-level tools that's going to vary +widely. + +> > + There are situations in which Software Raids are faster, as CPU power +> > has advanced dramatically in the last years and even high end controller +> > cards cannot keep up with that. +> +> Definitely NOT, however if your server doen't have a heavy load, the +> software overload can't be noticed (essentially cache managing and +> syncing) +> +> For bi-core CPUs, it might be true + +Depends. RAID performance depends on a heck of a lot more than just CPU. +Software RAID allows you to do things like spread load across multiple +controllers, so you can scale a lot higher for less money. Though in +this case I doubt that's a consideration, so what's more important is +that making sure the controller bus isn't in the way. One thing that +means is ensuring that every SATA drive has it's own dedicated +controller, since a lot of SATA hardware can't handle multiple commands +on the bus at once. + +> > + Using SATA drives is always a bit of risk, as some drives are lying +> > about whether they are caching or not. +> +> ?? Do you intend to use your server without a UPS ?? + +Have you never heard of someone tripping over a plug? Or a power supply +failing? Or the OS crashing? If fsync is properly obeyed, PostgreSQL +will gracefully recover from all of those situations. If it's not, +you're at risk of losing the whole database. + +> > + Using hardware controllers, the array becomes locked to a particular +> > vendor. You can't switch controller vendors as the array meta +> > information is stored proprietary. In case the Raid is broken to a level +> > the controller can't recover automatically this might complicate manual +> > recovery by specialists. +> +> ?? Do you intend not to make backups ?? + +Even with backups this is still a valid concern, since the backup will +be nowhere near as up-to-date as the database was unless you have a +pretty low DML rate. + +> BUT a hardware controler is about EUR2000 and a (ATA/SATA) 500GB HD +> is ~ EUR350. + +Huh? You can get 3ware controllers for about $500, and they're pretty +decent. While I'm sure there are controllers for $2k that doesn't mean +there's nothing inbetween that and nothing. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-general-owner@postgresql.org Thu May 11 19:38:56 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 40E4F9FADD1; + Thu, 11 May 2006 19:38:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 00922-01; Thu, 11 May 2006 19:38:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id A07DC9FB0D1; + Thu, 11 May 2006 19:38:50 -0300 (ADT) +Received: from [192.168.1.50] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k4BMcZbw024008; Thu, 11 May 2006 15:38:39 -0700 +Message-ID: <4463BCE7.6090202@commandprompt.com> +Date: Thu, 11 May 2006 15:38:31 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: "Jim C. Nasby" +CC: Bruce Momjian , Vivek Khera , + "Pgsql-Performance ((E-mail))" , + PostgreSQL General +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +References: <4460DE97.9040001@commandprompt.com> + <200605100059.k4A0xtK09977@candle.pha.pa.us> + <20060511221928.GV99570@pervasive.com> +In-Reply-To: <20060511221928.GV99570@pervasive.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88, + clamav-milter version 0.87 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Thu, 11 May 2006 15:38:40 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/511 +X-Sequence-Number: 95303 + + +>> You want an in-depth comparison of how a server disk drive is internally +>> better than a desktop drive: +>> +>> http://www.seagate.com/content/docs/pdf/whitepaper/D2c_More_than_Interface_ATA_vs_SCSI_042003.pdf +> +> BTW, someone (Western Digital?) is now offering SATA drives that carry +> the same MTBF/warranty/what-not as their SCSI drives. I can't remember +> if they actually claim that it's the same mechanisms just with a +> different controller on the drive... + +Well western digital and Seagate both carry 5 year warranties. Seagate I +believe does on almost all of there products. WD you have to pick the +right drive. + +Joshua D> Drake + + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === + Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-performance-owner@postgresql.org Thu May 11 19:41:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9FE509FB1A5 + for ; + Thu, 11 May 2006 19:41:18 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 99694-07 + for ; + Thu, 11 May 2006 19:41:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 3B9559FADD1 + for ; + Thu, 11 May 2006 19:41:14 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id F16EA56435; Thu, 11 May 2006 17:41:12 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 11 May 2006 17:41:12 -0500 +Date: Thu, 11 May 2006 17:41:12 -0500 +From: "Jim C. Nasby" +To: Dave Dutcher +Cc: 'Clemens Eisserer' , + pgsql-performance@postgresql.org +Subject: Re: Question about explain-command... +Message-ID: <20060511224111.GX99570@pervasive.com> +References: <194f62550605100449p2d200fc3pfe501da895cfcc00@mail.gmail.com> + <01a901c67440$9cf097e0$8300a8c0@tridecap.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <01a901c67440$9cf097e0$8300a8c0@tridecap.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060511:dave@tridecap.com::gHNSdTHJz/4Gb3Dc:00000000000000000000 + 0000000000000000000000001fp3 +X-Hashcash: + 1:20:060511:linuxhippy@gmail.com::llzGLtMuap2hyn9P:00000000000000000 + 0000000000000000000000003/WS +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::LLB5TIS3qzdMq3nq:00000 + 0000000000000000000000002ASW +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/309 +X-Sequence-Number: 19096 + +On Wed, May 10, 2006 at 09:47:07AM -0500, Dave Dutcher wrote: +> The hash lines mean your tables are being joined by hash joins. You +> should read this page for more info: +> +> http://www.postgresql.org/docs/8.1/interactive/performance-tips.html + +You might also want to read +http://www.pervasivepostgres.com/instantkb13/article.aspx?id=10120&query=explain +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu May 11 19:49:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 28BB69FB0D1 + for ; + Thu, 11 May 2006 19:49:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 99303-10 + for ; + Thu, 11 May 2006 19:49:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from joeconway.com (wsip-68-15-9-201.sd.sd.cox.net [68.15.9.201]) + by postgresql.org (Postfix) with ESMTP id 0EE749FADD1 + for ; + Thu, 11 May 2006 19:49:47 -0300 (ADT) +Received: from [206.190.70.130] (account jconway HELO [172.16.1.115]) + by joeconway.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP-TLS id 3708488; Thu, 11 May 2006 15:50:09 -0700 +Message-ID: <4463BF89.6050702@joeconway.com> +Date: Thu, 11 May 2006 15:49:45 -0700 +From: Joe Conway +User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; + rv:1.7.13) Gecko/20060501 Fedora/1.7.13-1.1.fc5 +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Jim C. Nasby" +CC: Adam Palmblad , pgsql-performance@postgresql.org +Subject: Re: Dynamically loaded C function performance +References: <6B5AF6293A289F45826220B17ABE79370D5ED7@BORON.aers.local> + <20060511220523.GT99570@pervasive.com> +In-Reply-To: <20060511220523.GT99570@pervasive.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/310 +X-Sequence-Number: 19097 + +Jim C. Nasby wrote: +> On Fri, May 05, 2006 at 03:47:53PM -0700, Adam Palmblad wrote: +> +>>Hi, +>>We've got a C function that we use here and we find that for every +>>connection, the first run of the function is much slower than any +>>subsequent runs. ( 50ms compared to 8ms) +>> +>>Besides using connection pooling, are there any options to improve +>>performance? +> +> In my experience, connection startup takes a heck of a lot longer than +> 50ms, so why are you worrying about 50ms for the first run of a +> function? +> +> BTW, sorry, but I don't know a way to speed this up, either. + +I think Tom nailed the solution already in a nearby reply -- see +preload_libraries on this page: + +http://www.postgresql.org/docs/8.1/interactive/runtime-config-resource.html + +Joe + +From pgsql-performance-owner@postgresql.org Thu May 11 19:51:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A1E8D9FB0D1 + for ; + Thu, 11 May 2006 19:51:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 00981-08 + for ; + Thu, 11 May 2006 19:51:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 7D28D9FADD1 + for ; + Thu, 11 May 2006 19:51:39 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 3188256423; Thu, 11 May 2006 17:51:38 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 11 May 2006 17:51:36 -0500 +Date: Thu, 11 May 2006 17:51:36 -0500 +From: "Jim C. Nasby" +To: Ketema Harris +Cc: "pgsql-performance@postgresql.org" +Subject: Re: Nested Loops vs. Hash Joins or Merge Joins +Message-ID: <20060511225136.GY99570@pervasive.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060511:ketema@gmail.com::FQTOjdp++8NDPZr+:09J9I +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::OwBikFJVLYnYycj9:00000 + 0000000000000000000000008S4m +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/311 +X-Sequence-Number: 19098 + +On Thu, May 11, 2006 at 08:57:48AM -0400, Ketema Harris wrote: +> Nested Loops on: +> Nested Loop (cost=3.33..11.37 rows=1 width=268) (actual time=2.166..2.982 +> +> Nested Loops off: +> Hash Join (cost=8.27..11.78 rows=1 width=268) (actual time=1.701..1.765 +> +> With nested loops enabled does it choose to use them because it sees the +> estimated start up cost with loops as less? Does it not know that the total +> query would be faster with the Hash Joins? This query is in development + +Yes it does know; re-read the output. + +I believe the cases where the planner will look at startup cost over +total cost are pretty limited; when LIMIT is used and I think sometimes +when a CURSOR is used. + +> Statistics collecting and auto vacuum is enabled btw. I have an erd diagram +> showing the table structures if anyone is interested in looking at it, just +> let me know. + +Note that it's not terribly uncommon for the default stats target to be +woefully inadequate for large sets of data, not that 100 rows a day is +large. But it probably wouldn't hurt to bump the defaulst stats target +up to 30 or 50 anyway. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Thu May 11 19:58:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6A5E99FADD1; + Thu, 11 May 2006 19:58:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 00251-09; Thu, 11 May 2006 19:58:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 2692E9FB0D1; + Thu, 11 May 2006 19:58:45 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id CCAB65643F; Thu, 11 May 2006 17:58:44 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 11 May 2006 17:58:42 -0500 +Date: Thu, 11 May 2006 17:58:42 -0500 +From: "Jim C. Nasby" +To: Tom Lane +Cc: Zeugswetter Andreas DCP SD , + PFC , Greg Stark , + pgsql-performance@postgresql.org, pgsql-hackers@postgresql.org +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Message-ID: <20060511225842.GZ99570@pervasive.com> +References: + <20060511210141.GP99570@pervasive.com> + <4335.1147385316@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4335.1147385316@sss.pgh.pa.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060511:tgl@sss.pgh.pa.us::8zJkqoIayCo3z5tY:00000000000000000000 + 0000000000000000000000006aRK +X-Hashcash: + 1:20:060511:zeugswettera@spardat.at::iVJBymNjXo7Es2Pm:00000000000000 + 0000000000000000000000002fpN +X-Hashcash: 1:20:060511:lists@peufeu.com::wwTKqrbb0E9RUbhp:006Y7 +X-Hashcash: 1:20:060511:gsstark@mit.edu::5P43lJPs1KTyNEpH:006F1O +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::64gPwWUlB5sFdMh8:00000 + 0000000000000000000000003Yzb +X-Hashcash: + 1:20:060511:pgsql-hackers@postgresql.org::LZxOryAVY4/dJo74:000000000 + 0000000000000000000000003leF +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/312 +X-Sequence-Number: 19099 + +On Thu, May 11, 2006 at 06:08:36PM -0400, Tom Lane wrote: +> "Jim C. Nasby" writes: +> > I'd hope that wasn't what's happening... is the backend smart enough to +> > know not to fsync anything involved with the temp table? +> +> The catalog entries required for it have to be fsync'd, unless you enjoy +> putting your entire database at risk (a bad block in pg_class, say, +> would probably take out more than one table). + +Yeah, thought about that after sending... :( + +> It's interesting to speculate about keeping such catalog entries in +> child tables of pg_class etc that are themselves temp tables. Resolving +> the apparent circularity of this is left as an exercise for the reader. + +Well, since it'd be a system table with a fixed OID there could +presumably be a special case in the recovery code for it, though that's +pretty fugly sounding. + +Another alternative would be to support global temp tables... I think +that would handle all the complaints of the OP except for the cost of +analyze. I suspect this would be easier to do than creating a special +type of temp table that used tuplestore instead of the full table +framework, and it'd certainly be more general-purpose. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-general-owner@postgresql.org Thu May 11 20:01:47 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 248259FADD1; + Thu, 11 May 2006 20:01:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 02185-04; Thu, 11 May 2006 20:01:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 6639D9FB0D1; + Thu, 11 May 2006 20:01:41 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 3159856427; Thu, 11 May 2006 18:01:40 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 11 May 2006 18:01:38 -0500 +Date: Thu, 11 May 2006 18:01:38 -0500 +From: "Jim C. Nasby" +To: "Joshua D. Drake" +Cc: Bruce Momjian , Vivek Khera , + "Pgsql-Performance ((E-mail))" , + PostgreSQL General +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +Message-ID: <20060511230138.GB99570@pervasive.com> +References: <4460DE97.9040001@commandprompt.com> + <200605100059.k4A0xtK09977@candle.pha.pa.us> + <20060511221928.GV99570@pervasive.com> + <4463BCE7.6090202@commandprompt.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <4463BCE7.6090202@commandprompt.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060511:jd@commandprompt.com::GKJ11tCUr8N1KrIF:00000000000000000 + 00000000000000000000000021cr +X-Hashcash: + 1:20:060511:pgman@candle.pha.pa.us::mWLI/Uk35PQWSHEn:000000000000000 + 0000000000000000000000003Epq +X-Hashcash: 1:20:060511:vivek@khera.org::Wj561MFUbYC4DT2z:002wZM +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::87n/e+AYTzsnk5FE:00000 + 0000000000000000000000000Uv6 +X-Hashcash: + 1:20:060511:pgsql-general@postgresql.org::ylKJtvCUl7N23BPO:000000000 + 0000000000000000000000009Xgp +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/513 +X-Sequence-Number: 95305 + +On Thu, May 11, 2006 at 03:38:31PM -0700, Joshua D. Drake wrote: +> +> >>You want an in-depth comparison of how a server disk drive is internally +> >>better than a desktop drive: +> >> +> >> http://www.seagate.com/content/docs/pdf/whitepaper/D2c_More_than_Interface_ATA_vs_SCSI_042003.pdf +> > +> >BTW, someone (Western Digital?) is now offering SATA drives that carry +> >the same MTBF/warranty/what-not as their SCSI drives. I can't remember +> >if they actually claim that it's the same mechanisms just with a +> >different controller on the drive... +> +> Well western digital and Seagate both carry 5 year warranties. Seagate I +> believe does on almost all of there products. WD you have to pick the +> right drive. + +I know that someone recently made a big PR push about how you could get +'server reliability' in some of their SATA drives, but maybe now +everyone's starting to do it. I suspect the premium you can charge for +it offsets the costs, provided that you switch all your production over +rather than trying to segregate production lines. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-general-owner@postgresql.org Thu May 11 20:20:48 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 905A59FB1A5; + Thu, 11 May 2006 20:20:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 03390-05; Thu, 11 May 2006 20:20:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id B453C9FB0D1; + Thu, 11 May 2006 20:20:29 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k4BNKR221040; + Thu, 11 May 2006 19:20:27 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200605112320.k4BNKR221040@candle.pha.pa.us> +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +In-Reply-To: <4463BCE7.6090202@commandprompt.com> +To: "Joshua D. Drake" +Date: Thu, 11 May 2006 19:20:27 -0400 (EDT) +CC: "Jim C. Nasby" , Vivek Khera , + "Pgsql-Performance ((E-mail))" , + PostgreSQL General +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/514 +X-Sequence-Number: 95306 + +Joshua D. Drake wrote: +> +> >> You want an in-depth comparison of how a server disk drive is internally +> >> better than a desktop drive: +> >> +> >> http://www.seagate.com/content/docs/pdf/whitepaper/D2c_More_than_Interface_ATA_vs_SCSI_042003.pdf +> > +> > BTW, someone (Western Digital?) is now offering SATA drives that carry +> > the same MTBF/warranty/what-not as their SCSI drives. I can't remember +> > if they actually claim that it's the same mechanisms just with a +> > different controller on the drive... +> +> Well western digital and Seagate both carry 5 year warranties. Seagate I +> believe does on almost all of there products. WD you have to pick the +> right drive. + +That's nice, but it seems similar to my Toshiba laptop drive experience +--- it breaks, we replace it. I would rather not have to replace it. :-) + +Let me mention the only drive that has ever failed without warning was a +SCSI Deskstar (deathstar) drive, which was a hybrid because it was a +SCSI drive, but made for consumer use. + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-general-owner@postgresql.org Thu May 11 20:24:59 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 96AB19FB0D1; + Thu, 11 May 2006 20:24:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 06870-01; Thu, 11 May 2006 20:24:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id 2B26A9FADD1; + Thu, 11 May 2006 20:24:53 -0300 (ADT) +Received: from [192.168.1.50] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k4BNOlHt024903; Thu, 11 May 2006 16:24:48 -0700 +Message-ID: <4463C7BB.2070000@commandprompt.com> +Date: Thu, 11 May 2006 16:24:43 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: Bruce Momjian +CC: "Jim C. Nasby" , Vivek Khera , + "Pgsql-Performance ((E-mail))" , + PostgreSQL General +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +References: <200605112320.k4BNKR221040@candle.pha.pa.us> +In-Reply-To: <200605112320.k4BNKR221040@candle.pha.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88, + clamav-milter version 0.87 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Thu, 11 May 2006 16:24:48 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/515 +X-Sequence-Number: 95307 + + +>> Well western digital and Seagate both carry 5 year warranties. Seagate I +>> believe does on almost all of there products. WD you have to pick the +>> right drive. +> +> That's nice, but it seems similar to my Toshiba laptop drive experience +> --- it breaks, we replace it. I would rather not have to replace it. :-) + +Laptop drives are known to have short lifespans do to heat. I have IDE +drives that have been running for four years without any issues but I +have good fans blowing over them. + +Frankly I think if you are running drivess (in a production environment) +for more then 3 years your crazy anyway :) + +> +> Let me mention the only drive that has ever failed without warning was a +> SCSI Deskstar (deathstar) drive, which was a hybrid because it was a +> SCSI drive, but made for consumer use. +> + + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === + Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-general-owner@postgresql.org Thu May 11 20:31:50 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 341079FB0D1; + Thu, 11 May 2006 20:31:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 06734-01; Thu, 11 May 2006 20:31:44 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id A88C09FADD1; + Thu, 11 May 2006 20:31:43 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k4BNVgx02539; + Thu, 11 May 2006 19:31:42 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200605112331.k4BNVgx02539@candle.pha.pa.us> +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +In-Reply-To: <4463C7BB.2070000@commandprompt.com> +To: "Joshua D. Drake" +Date: Thu, 11 May 2006 19:31:42 -0400 (EDT) +CC: "Jim C. Nasby" , Vivek Khera , + "Pgsql-Performance ((E-mail))" , + PostgreSQL General +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/516 +X-Sequence-Number: 95308 + +Joshua D. Drake wrote: +> +> >> Well western digital and Seagate both carry 5 year warranties. Seagate I +> >> believe does on almost all of there products. WD you have to pick the +> >> right drive. +> > +> > That's nice, but it seems similar to my Toshiba laptop drive experience +> > --- it breaks, we replace it. I would rather not have to replace it. :-) +> +> Laptop drives are known to have short lifespans do to heat. I have IDE +> drives that have been running for four years without any issues but I +> have good fans blowing over them. +> +> Frankly I think if you are running drivess (in a production environment) +> for more then 3 years your crazy anyway :) + +Agreed --- the cost/benefit of keeping a drive >3 years just doesn't +make sense. + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-general-owner@postgresql.org Thu May 11 20:41:38 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9FBF19FB1A5; + Thu, 11 May 2006 20:41:37 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 06575-07; Thu, 11 May 2006 20:41:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 8EB999FADD1; + Thu, 11 May 2006 20:41:27 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 27ED556427; Thu, 11 May 2006 18:41:26 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Thu, 11 May 2006 18:41:25 -0500 +Date: Thu, 11 May 2006 18:41:25 -0500 +From: "Jim C. Nasby" +To: Bruce Momjian +Cc: "Joshua D. Drake" , Vivek Khera , + "Pgsql-Performance ((E-mail))" , + PostgreSQL General +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +Message-ID: <20060511234124.GC4268@pervasive.com> +References: <4463BCE7.6090202@commandprompt.com> + <200605112320.k4BNKR221040@candle.pha.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200605112320.k4BNKR221040@candle.pha.pa.us> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060511:pgman@candle.pha.pa.us::Et548zWqaeoMIxfc:000000000000000 + 0000000000000000000000004s/c +X-Hashcash: + 1:20:060511:jd@commandprompt.com::o2tIA4DKLRdxmmlJ:00000000000000000 + 00000000000000000000000012Mq +X-Hashcash: 1:20:060511:vivek@khera.org::RCk/OzvfJI/Ze8FO:001PlP +X-Hashcash: + 1:20:060511:pgsql-performance@postgresql.org::y8ru1cjCsIIL33Rw:00000 + 0000000000000000000000001SBg +X-Hashcash: + 1:20:060511:pgsql-general@postgresql.org::+N8k/fQOW3yutWuq:000000000 + 0000000000000000000000003VFS +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/517 +X-Sequence-Number: 95309 + +On Thu, May 11, 2006 at 07:20:27PM -0400, Bruce Momjian wrote: +> Joshua D. Drake wrote: +> > +> > >> You want an in-depth comparison of how a server disk drive is internally +> > >> better than a desktop drive: +> > >> +> > >> http://www.seagate.com/content/docs/pdf/whitepaper/D2c_More_than_Interface_ATA_vs_SCSI_042003.pdf +> > > +> > > BTW, someone (Western Digital?) is now offering SATA drives that carry +> > > the same MTBF/warranty/what-not as their SCSI drives. I can't remember +> > > if they actually claim that it's the same mechanisms just with a +> > > different controller on the drive... +> > +> > Well western digital and Seagate both carry 5 year warranties. Seagate I +> > believe does on almost all of there products. WD you have to pick the +> > right drive. +> +> That's nice, but it seems similar to my Toshiba laptop drive experience +> --- it breaks, we replace it. I would rather not have to replace it. :-) +> +> Let me mention the only drive that has ever failed without warning was a +> SCSI Deskstar (deathstar) drive, which was a hybrid because it was a +> SCSI drive, but made for consumer use. + +My damn powerbook drive recently failed with very little warning, other +than I did notice that disk activity seemed to be getting a bit slower. +IIRC it didn't log any errors or anything. Even if it did, if the OS was +catching them I'd hope it would pop up a warning or something. But from +what I've heard, some drives now-a-days will silently remap dead sectors +without telling the OS anything, which is great until you've used up all +of the spare sectors and there's nowhere to remap to. :( + +Hmm... I should figure out how to have OS X email me daily log updates +like FreeBSD does... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-general-owner@postgresql.org Thu May 11 20:46:07 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id DD2489FB1A5; + Thu, 11 May 2006 20:46:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 08785-01; Thu, 11 May 2006 20:45:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from candle.pha.pa.us (candle.pha.pa.us [70.90.9.53]) + by postgresql.org (Postfix) with ESMTP id 024859FB0D1; + Thu, 11 May 2006 20:45:55 -0300 (ADT) +Received: (from pgman@localhost) + by candle.pha.pa.us (8.11.6/8.11.6) id k4BNjsP16655; + Thu, 11 May 2006 19:45:54 -0400 (EDT) +From: Bruce Momjian +Message-Id: <200605112345.k4BNjsP16655@candle.pha.pa.us> +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +In-Reply-To: <20060511234124.GC4268@pervasive.com> +To: "Jim C. Nasby" +Date: Thu, 11 May 2006 19:45:54 -0400 (EDT) +CC: "Joshua D. Drake" , Vivek Khera , + "Pgsql-Performance ((E-mail))" , + PostgreSQL General +X-Mailer: ELM [version 2.4ME+ PL121 (25)] +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/518 +X-Sequence-Number: 95310 + +Jim C. Nasby wrote: +> On Thu, May 11, 2006 at 07:20:27PM -0400, Bruce Momjian wrote: +> > Joshua D. Drake wrote: +> > > +> > > >> You want an in-depth comparison of how a server disk drive is internally +> > > >> better than a desktop drive: +> > > >> +> > > >> http://www.seagate.com/content/docs/pdf/whitepaper/D2c_More_than_Interface_ATA_vs_SCSI_042003.pdf +> > > > +> > > > BTW, someone (Western Digital?) is now offering SATA drives that carry +> > > > the same MTBF/warranty/what-not as their SCSI drives. I can't remember +> > > > if they actually claim that it's the same mechanisms just with a +> > > > different controller on the drive... +> > > +> > > Well western digital and Seagate both carry 5 year warranties. Seagate I +> > > believe does on almost all of there products. WD you have to pick the +> > > right drive. +> > +> > That's nice, but it seems similar to my Toshiba laptop drive experience +> > --- it breaks, we replace it. I would rather not have to replace it. :-) +> > +> > Let me mention the only drive that has ever failed without warning was a +> > SCSI Deskstar (deathstar) drive, which was a hybrid because it was a +> > SCSI drive, but made for consumer use. +> +> My damn powerbook drive recently failed with very little warning, other +> than I did notice that disk activity seemed to be getting a bit slower. +> IIRC it didn't log any errors or anything. Even if it did, if the OS was +> catching them I'd hope it would pop up a warning or something. But from +> what I've heard, some drives now-a-days will silently remap dead sectors +> without telling the OS anything, which is great until you've used up all +> of the spare sectors and there's nowhere to remap to. :( + +Yes, I think most IDE drives do silently remap, and most SCSI drives +don't. Not sure how much _most_ is. + +I know my SCSI controller beeps at me when I try to access a bad block. +Now, that gets my attention. + +-- + Bruce Momjian http://candle.pha.pa.us + EnterpriseDB http://www.enterprisedb.com + + + If your life is a hard drive, Christ can be your backup. + + +From pgsql-general-owner@postgresql.org Thu May 11 21:00:21 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0F4B49FB0D1; + Thu, 11 May 2006 21:00:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 09167-06; Thu, 11 May 2006 21:00:11 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id CB8199FADD1; + Thu, 11 May 2006 21:00:08 -0300 (ADT) +Received: from [192.168.1.50] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.4/8.13.4) with ESMTP id + k4C003Ph025681; Thu, 11 May 2006 17:00:04 -0700 +Message-ID: <4463CFFF.3070404@commandprompt.com> +Date: Thu, 11 May 2006 16:59:59 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: "Jim C. Nasby" +CC: Bruce Momjian , Vivek Khera , + "Pgsql-Performance ((E-mail))" , + PostgreSQL General +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +References: <4463BCE7.6090202@commandprompt.com> + <200605112320.k4BNKR221040@candle.pha.pa.us> + <20060511234124.GC4268@pervasive.com> +In-Reply-To: <20060511234124.GC4268@pervasive.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88, + clamav-milter version 0.87 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Thu, 11 May 2006 17:00:04 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/520 +X-Sequence-Number: 95312 + + +> Hmm... I should figure out how to have OS X email me daily log updates +> like FreeBSD does... + +Logwatch. + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === + Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-performance-owner@postgresql.org Thu May 11 21:03:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3A24F9FB1A5 + for ; + Thu, 11 May 2006 21:03:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 09438-06 + for ; + Thu, 11 May 2006 21:03:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 215509FADD1 + for ; + Thu, 11 May 2006 21:03:35 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4C03QnG018708; + Thu, 11 May 2006 20:03:27 -0400 (EDT) +To: "Craig A. James" +cc: Chris , pgsql-performance@postgresql.org +Subject: Re: Postgres gets stuck +In-reply-to: <44635DFE.1060509@modgraph-usa.com> +References: <446135F9.1060608@modgraph-usa.com> <4461391D.2000800@gmail.com> + <44635DFE.1060509@modgraph-usa.com> +Comments: In-reply-to "Craig A. James" + message dated "Thu, 11 May 2006 08:53:34 -0700" +Date: Thu, 11 May 2006 20:03:26 -0400 +Message-ID: <18707.1147392206@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/320 +X-Sequence-Number: 19107 + +"Craig A. James" writes: +> My suspicion is that it's an incompatibility between malloc() +> libraries. + +On Linux there's only supposed to be one malloc, ie, glibc's version. +On other platforms I'd be worried about threaded vs non-threaded libc +(because the backend is not threaded), but not Linux. + +There may be a more basic threading problem here, though, rooted in the +precise fact that the backend isn't threaded. If you're trying to use +any libraries that assume they can have multiple threads, I wouldn't be +at all surprised to see things go boom. C++ exception handling could be +problematic too. + +Or it could be a garden variety glibc bug. How up-to-date is your +platform? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu May 11 23:10:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3A5AE9FB0D1 + for ; + Thu, 11 May 2006 23:10:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 25484-01 + for ; + Thu, 11 May 2006 23:10:25 -0300 (ADT) +X-Greylist: delayed 10:16:41.203291 by SQLgrey- +Received: from moonunit2.moonview.localnet (wsip-70-167-125-69.sd.sd.cox.net + [70.167.125.69]) + by postgresql.org (Postfix) with ESMTP id 8005E9FADD1 + for ; + Thu, 11 May 2006 23:10:25 -0300 (ADT) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k4C2IHdt014084; Thu, 11 May 2006 19:18:17 -0700 +Message-ID: <4463EE89.8010103@modgraph-usa.com> +Date: Thu, 11 May 2006 19:10:17 -0700 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +CC: Chris , pgsql-performance@postgresql.org +Subject: Re: Postgres gets stuck +References: <446135F9.1060608@modgraph-usa.com> <4461391D.2000800@gmail.com> + <44635DFE.1060509@modgraph-usa.com> + <18707.1147392206@sss.pgh.pa.us> +In-Reply-To: <18707.1147392206@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/321 +X-Sequence-Number: 19108 + +Tom Lane wrote: +> >My suspicion is that it's an incompatibility between malloc() +> >libraries. +> +> On Linux there's only supposed to be one malloc, ie, glibc's version. +> On other platforms I'd be worried about threaded vs non-threaded libc +> (because the backend is not threaded), but not Linux. + +I guess I misinterpreted the Postgress manual, which says (in 31.9, "C Language Functions"), + + "When allocating memory, use the PostgreSQL functions palloc and pfree + instead of the corresponding C library functions malloc and free." + +I imagined that perhaps palloc/pfree used mutexes for something. But if I understand you, palloc() and pfree() are just wrappers around malloc() and free(), and don't (for example) make their own separate calls to brk(2), sbrk(2), or their kin. If that's the case, then you answered my question - it's all ordinary malloc/free calls in the end, and that's not the source of the problem. + +> There may be a more basic threading problem here, though, rooted in the +> precise fact that the backend isn't threaded. If you're trying to use +> any libraries that assume they can have multiple threads, I wouldn't be +> at all surprised to see things go boom. + +No threading anywhere. None of the libraries use threads or mutexes. It's just plain old vanilla C/C++ scientific algorithms. + +> C++ exception handling could be problematic too. + +No C++ exceptions are thrown anywhere in the code, 'tho I suppose one of the I/O libraries could throw an exception, e.g. when reading from a file. But there's no evidence of this after millions of identical operations succeeded. In addition, the stack trace shows it to be stuck in a memory operation, not an I/O operation. + +> Or it could be a garden variety glibc bug. How up-to-date is your +> platform? + +I guess this is the next place to look. From the few answers I've gotten, it sounds like this isn't a known Postgres issue, and my stack trace doesn't seem to be familiar to anyone on this forum. Oh well... thanks for your help. + +Craig + +From pgsql-performance-owner@postgresql.org Thu May 11 23:51:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5CDD09FB0D1 + for ; + Thu, 11 May 2006 23:51:24 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 30919-02 + for ; + Thu, 11 May 2006 23:51:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 982209FADD1 + for ; + Thu, 11 May 2006 23:51:19 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4C2pCfW019951; + Thu, 11 May 2006 22:51:12 -0400 (EDT) +To: "Craig A. James" +cc: Chris , pgsql-performance@postgresql.org +Subject: Re: Postgres gets stuck +In-reply-to: <4463EE89.8010103@modgraph-usa.com> +References: <446135F9.1060608@modgraph-usa.com> <4461391D.2000800@gmail.com> + <44635DFE.1060509@modgraph-usa.com> + <18707.1147392206@sss.pgh.pa.us> + <4463EE89.8010103@modgraph-usa.com> +Comments: In-reply-to "Craig A. James" + message dated "Thu, 11 May 2006 19:10:17 -0700" +Date: Thu, 11 May 2006 22:51:12 -0400 +Message-ID: <19950.1147402272@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/322 +X-Sequence-Number: 19109 + +"Craig A. James" writes: +> I guess I misinterpreted the Postgress manual, which says (in 31.9, "C Language Functions"), + +> "When allocating memory, use the PostgreSQL functions palloc and pfree +> instead of the corresponding C library functions malloc and free." + +> I imagined that perhaps palloc/pfree used mutexes for something. But if I understand you, palloc() and pfree() are just wrappers around malloc() and free(), and don't (for example) make their own separate calls to brk(2), sbrk(2), or their kin. + +Correct. palloc/pfree are all about managing the lifetime of memory +allocations, so that (for example) a function can return a palloc'd data +structure without worrying about whether that creates a long-term memory +leak. But ultimately they just use malloc/free, and there's certainly +not any threading or mutex considerations in there. + +> No threading anywhere. None of the libraries use threads or mutexes. It's just plain old vanilla C/C++ scientific algorithms. + +Darn, my best theory down the drain. + +>> Or it could be a garden variety glibc bug. How up-to-date is your +>> platform? + +> I guess this is the next place to look. + +Let us know how it goes... + + regards, tom lane + +From pgsql-general-owner@postgresql.org Fri May 12 04:18:42 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4A8FE9FA29C + for ; + Fri, 12 May 2006 04:18:42 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 94001-07 + for ; + Fri, 12 May 2006 04:18:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id 0A7EC9F946D + for ; + Fri, 12 May 2006 04:18:36 -0300 (ADT) +Received: (qmail 13364 invoked by uid 500); 12 May 2006 07:19:57 -0000 +Date: Fri, 12 May 2006 02:19:57 -0500 +From: Bruno Wolff III +To: "Jim C. Nasby" +Cc: Bruce Momjian , + "Joshua D. Drake" , Vivek Khera , + "Pgsql-Performance \(\(E-mail\)\)" , + PostgreSQL General +Subject: Re: Arguments Pro/Contra Software Raid +Message-ID: <20060512071957.GD9151@wolff.to> +Mail-Followup-To: Bruno Wolff III , + "Jim C. Nasby" , + Bruce Momjian , + "Joshua D. Drake" , + Vivek Khera , + "Pgsql-Performance ((E-mail))" , + PostgreSQL General +References: <4463BCE7.6090202@commandprompt.com> + <200605112320.k4BNKR221040@candle.pha.pa.us> + <20060511234124.GC4268@pervasive.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060511234124.GC4268@pervasive.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/531 +X-Sequence-Number: 95323 + +On Thu, May 11, 2006 at 18:41:25 -0500, + "Jim C. Nasby" wrote: +> On Thu, May 11, 2006 at 07:20:27PM -0400, Bruce Momjian wrote: +> +> My damn powerbook drive recently failed with very little warning, other +> than I did notice that disk activity seemed to be getting a bit slower. +> IIRC it didn't log any errors or anything. Even if it did, if the OS was +> catching them I'd hope it would pop up a warning or something. But from +> what I've heard, some drives now-a-days will silently remap dead sectors +> without telling the OS anything, which is great until you've used up all +> of the spare sectors and there's nowhere to remap to. :( + +You might look into smartmontools. One part of this is a daemon that runs +selftests on the disks on a regular basis. You can have warnings mailed to +you on various conditions. Drives will fail the self test before they +run out of spare sectors. There are other drive characteristics that can +be used to tell if drive failure is imminent and give you a chance to replace +a drive before it fails. + +From pgsql-performance-owner@postgresql.org Fri May 12 10:06:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B91AB9F9430 + for ; + Fri, 12 May 2006 10:06:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 59246-05-2 + for ; + Fri, 12 May 2006 10:06:25 -0300 (ADT) +X-Greylist: delayed 00:23:04.852315 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 6843A9F9C18 + for ; + Fri, 12 May 2006 10:06:16 -0300 (ADT) +Received: from mail.ritek.hu (mail.ritek.hu [82.131.192.50]) + by svr4.postgresql.org (Postfix) with ESMTP id E9A2D5B2840 + for ; + Fri, 12 May 2006 12:43:10 +0000 (GMT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.ritek.hu (Postfix) with ESMTP id B2C1B19C7CC + for ; + Fri, 12 May 2006 14:43:04 +0200 (CEST) +Received: from mail.ritek.hu ([127.0.0.1]) + by localhost (mail.ritek.hu [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 25538-10 for ; + Fri, 12 May 2006 14:43:03 +0200 (CEST) +Received: from [10.1.2.11] (unknown [10.1.2.11]) + by mail.ritek.hu (Postfix) with ESMTP id 73B7B19C7BF + for ; + Fri, 12 May 2006 14:43:03 +0200 (CEST) +Message-ID: <446482E4.6050906@ritek.hu> +Date: Fri, 12 May 2006 14:43:16 +0200 +From: Antal Attila +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Wrong plan for subSELECT with GROUP BY +Content-Type: text/plain; charset=ISO-8859-2; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ritek.hu +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/324 +X-Sequence-Number: 19111 + +Hi! + +See the next case, please! This is a theoretical CASE, which cause +problems to me. Please, help! + +CREATE TABLE a ( + id SERIAL, -- This is the PRIMARY KEY + col TEXT +); + +CREATE TABLE b ( + id SERIAL, -- This is the PRIMARY KEY + a_id INT4, -- REFERENCE TO a.id + value INT4, + txt TEXT +); + +CREATE TABLE c ( + id SERIAL, -- This is the PRIMARY KEY + a_id INT4, -- REFERENCE TO a.id + value INT4, + txt TEXT +); + +I examined the next query. In my opinion its query plan is not too optimal. +There are indexes on b.a_id, b.value, b.txt, c.a_id, c.value, c.txt. +I generated test datas: 10000 rows into the table 'a', + 100000 rows into the table 'b', + 100000 rows into the table 'c'. + +SELECT a.id, a.col, + TABLE_B.minval, TABLE_B.b_txt, + TABLE_C.maxval, TABLE_C.c_txt +FROM a +LEFT JOIN ( + SELECT a_id, + min(value) AS minval, + max(txt) AS b_txt + FROM b + GROUP BY a_id) TABLE_B ON (TABLE_B.a_id = a.id) +LEFT JOIN ( + SELECT a_id, + max(value) AS maxval, + min(txt) AS c_txt + FROM c + GROUP BY a_id) TABLE_C ON (TABLE_C.a_id = a.id) +LIMIT 10; + + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=6907.56..6932.86 rows=10 width=84) (actual +time=750.075..750.184 rows=10 loops=1) + -> Hash Left Join (cost=6907.56..34114.19 rows=10753 width=84) +(actual time=750.071..750.163 rows=10 loops=1) + Hash Cond: ("outer".id = "inner".a_id) + -> Merge Left Join (cost=4171.85..4370.95 rows=10000 +width=48) (actual time=400.712..400.775 rows=10 loops=1) + Merge Cond: ("outer".id = "inner".a_id) + -> Sort (cost=823.39..848.39 rows=10000 width=12) +(actual time=31.926..31.935 rows=10 loops=1) + Sort Key: a.id + -> Seq Scan on a (cost=0.00..159.00 rows=10000 +width=12) (actual time=0.013..12.120 rows=10000 loops=1) + -> Sort (cost=3348.47..3373.32 rows=9940 width=40) +(actual time=368.741..368.762 rows=22 loops=1) + Sort Key: table_b.a_id + -> Subquery Scan table_b (cost=2440.00..2688.50 +rows=9940 width=40) (actual time=305.836..338.764 rows=10000 loops=1) + -> HashAggregate (cost=2440.00..2589.10 +rows=9940 width=17) (actual time=305.832..320.891 rows=10000 loops=1) + -> Seq Scan on b (cost=0.00..1690.00 +rows=100000 width=17) (actual time=0.012..125.888 rows=100000 loops=1) + -> Hash (cost=2708.83..2708.83 rows=10753 width=40) (actual +time=349.314..349.314 rows=10000 loops=1) + -> Subquery Scan table_c (cost=2440.00..2708.83 +rows=10753 width=40) (actual time=298.826..331.239 rows=10000 loops=1) + -> HashAggregate (cost=2440.00..2601.30 +rows=10753 width=17) (actual time=298.821..313.603 rows=10000 loops=1) + -> Seq Scan on c (cost=0.00..1690.00 +rows=100000 width=17) (actual time=0.015..124.996 rows=100000 loops=1) + Total runtime: 757.818 ms + +But I can optimize the previous query by hand: + +SELECT a.id, a.col, + (SELECT min(value) FROM b WHERE b.a_id=a.id) AS minval, + (SELECT max(txt) FROM b WHERE b.a_id=a.id) AS b_txt, + (SELECT max(value) FROM c WHERE c.a_id=a.id) AS maxval, + (SELECT min(txt) FROM c WHERE c.a_id=a.id) AS c_txt +FROM a +LIMIT 10; + + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=0.00..126.76 rows=10 width=12) (actual time=0.221..1.754 +rows=10 loops=1) + -> Seq Scan on a (cost=0.00..126764.21 rows=10000 width=12) (actual +time=0.218..1.734 rows=10 loops=1) + SubPlan + -> Aggregate (cost=3.15..3.16 rows=1 width=9) (actual +time=0.039..0.039 rows=1 loops=10) + -> Index Scan using idx_c_aid on c (cost=0.00..3.12 +rows=9 width=9) (actual time=0.007..0.024 rows=10 loops=10) + Index Cond: (a_id = $0) + -> Aggregate (cost=3.15..3.16 rows=1 width=4) (actual +time=0.038..0.039 rows=1 loops=10) + -> Index Scan using idx_c_aid on c (cost=0.00..3.12 +rows=9 width=4) (actual time=0.008..0.025 rows=10 loops=10) + Index Cond: (a_id = $0) + -> Aggregate (cost=3.16..3.17 rows=1 width=9) (actual +time=0.038..0.039 rows=1 loops=10) + -> Index Scan using idx_b_aid on b (cost=0.00..3.14 +rows=10 width=9) (actual time=0.006..0.022 rows=10 loops=10) + Index Cond: (a_id = $0) + -> Aggregate (cost=3.16..3.17 rows=1 width=4) (actual +time=0.039..0.040 rows=1 loops=10) + -> Index Scan using idx_b_aid on b (cost=0.00..3.14 +rows=10 width=4) (actual time=0.008..0.025 rows=10 loops=10) + Index Cond: (a_id = $0) + Total runtime: 1.933 ms + +There is huge difference between the query performances. Why? +My problem is that in the first query use HashAggregation on the all +table 'b' and 'c' and cannot take notice of the 'LIMIT 10'. +In my special case I cannot use the second query formalization. I +simplified my problem to this theoretical CASE. +Do you know why cannot make the best of the 'LIMIT' criteria in the +first query? +These tables are big, so in my opinion the planner could optimize better. + +If this is a deficiency of the planner, I'd like to suggest this feature +into the planner. + +Regards, + Antal Attila + +From pgsql-performance-owner@postgresql.org Fri May 12 11:05:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9A71B9F944D + for ; + Fri, 12 May 2006 11:05:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 71872-06 + for ; + Fri, 12 May 2006 11:05:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id D18C89F9430 + for ; + Fri, 12 May 2006 11:05:18 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4CE5GqB023993; + Fri, 12 May 2006 10:05:17 -0400 (EDT) +To: Antal Attila +cc: pgsql-performance@postgresql.org +Subject: Re: Wrong plan for subSELECT with GROUP BY +In-reply-to: <446482E4.6050906@ritek.hu> +References: <446482E4.6050906@ritek.hu> +Comments: In-reply-to Antal Attila + message dated "Fri, 12 May 2006 14:43:16 +0200" +Date: Fri, 12 May 2006 10:05:16 -0400 +Message-ID: <23992.1147442716@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/325 +X-Sequence-Number: 19112 + +Antal Attila writes: +> If this is a deficiency of the planner, I'd like to suggest this feature +> into the planner. + +This really falls into the category of "you've got to be kidding". +There's no way that it'd be reasonable for the planner to expend cycles +on every query to look for corner cases like this. Do the +hand-optimization instead. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri May 12 11:49:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 25BF49F9430 + for ; + Fri, 12 May 2006 11:49:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 87027-04-5 + for ; + Fri, 12 May 2006 11:49:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id EC25C9FA4EA + for ; + Fri, 12 May 2006 11:49:20 -0300 (ADT) +Received: from techforce.com.br (techforce.com.br [216.218.247.150]) + by svr4.postgresql.org (Postfix) with ESMTP id 80FC45B57E5 + for ; + Fri, 12 May 2006 14:48:43 +0000 (GMT) +Received: from techforce.com.br (techforce.com.br [127.0.0.1]) + by techforce.com.br (8.12.11/8.12.11) with ESMTP id k4CEmqoV024414 + for ; Fri, 12 May 2006 07:48:52 -0700 +From: "andremachado" +To: pgsql-performance@postgresql.org +Subject: Firebird 1.5.3 X Postgresql 8.1.3 (linux and windows) +Date: Fri, 12 May 2006 12:48:52 -0200 +Message-Id: <20060512143716.M32697@techforce.com.br> +X-Mailer: Open WebMail 2.51 20050228 +X-OriginatingIP: 161.148.33.118 (andremachado@techforce.com.br) +MIME-Version: 1.0 +Content-Type: text/plain; + charset=iso-8859-1 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/326 +X-Sequence-Number: 19113 + +Hello, +continuing the saga, +http://archives.postgresql.org/pgsql-performance/2006-04/msg00558.php , +my coleague created a test database with fake data (see below). + +The above archived message contains the the timings of firebird and postgresql. +The weird problem are the 2 queries that firebird executes in less than 2 +seconds and postgresql took almost half hour to complete at 100% cpu. + + +you could download the test database at the address below. It is a 128 kpbs +adsl connection. +74 MB +http://www.eicomm.no-ip.com/download/BackDNF_Cript.zip + + +Many thanks. +Andre Felipe Machado + + +From pgsql-general-owner@postgresql.org Fri May 12 12:14:10 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9DC8C9F9430 + for ; + Fri, 12 May 2006 12:14:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 95372-01 + for ; + Fri, 12 May 2006 12:14:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail8.sea5.speakeasy.net (mail8.sea5.speakeasy.net + [69.17.117.10]) by postgresql.org (Postfix) with ESMTP id D0D089F9C18 + for ; + Fri, 12 May 2006 12:14:03 -0300 (ADT) +Received: (qmail 26170 invoked from network); 12 May 2006 15:14:01 -0000 +Received: from c-71-229-198-81.hsd1.co.comcast.net (HELO [192.168.0.28]) + (sribe@[71.229.198.81]) + (envelope-sender ) + by mail8.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP + for ; 12 May 2006 15:14:01 -0000 +User-Agent: Microsoft-Entourage/11.2.3.060209 +Date: Fri, 12 May 2006 09:13:59 -0600 +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +From: Scott Ribe +To: "Jim C. Nasby" , + Bruce Momjian , + PostgreSQL General +Message-ID: +Thread-Topic: [GENERAL] [PERFORM] Arguments Pro/Contra Software Raid +Thread-Index: AcZ11rGd8ABQs+HJEdq9WgAUUQPXGA== +In-Reply-To: <20060511234124.GC4268@pervasive.com> +Mime-version: 1.0 +Content-type: text/plain; + charset="US-ASCII" +Content-transfer-encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/573 +X-Sequence-Number: 95365 + +> My damn powerbook drive recently failed with very little warning + +It seems to me that S.M.A.R.T. reporting is a crock of shit. I've had ATA +drives report everything OK while clearly in the final throes of death, just +minutes before total failure. + +-- +Scott Ribe +scott_ribe@killerbytes.com +http://www.killerbytes.com/ +(303) 722-0567 voice + + + +From pgsql-general-owner@postgresql.org Fri May 12 12:54:10 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B70619F944D + for ; + Fri, 12 May 2006 12:54:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 99743-02 + for ; + Fri, 12 May 2006 12:54:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 039F49F9430 + for ; + Fri, 12 May 2006 12:54:01 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4CFruHM002712; + Fri, 12 May 2006 11:53:56 -0400 (EDT) +To: Scott Ribe +cc: "Jim C. Nasby" , + Bruce Momjian , + PostgreSQL General +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +In-reply-to: +References: +Comments: In-reply-to Scott Ribe + message dated "Fri, 12 May 2006 09:13:59 -0600" +Date: Fri, 12 May 2006 11:53:56 -0400 +Message-ID: <2711.1147449236@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/578 +X-Sequence-Number: 95370 + +Scott Ribe writes: +>> My damn powerbook drive recently failed with very little warning + +> It seems to me that S.M.A.R.T. reporting is a crock of shit. I've had ATA +> drives report everything OK while clearly in the final throes of death, just +> minutes before total failure. + +FWIW, I replaced a powerbook's drive about two weeks ago myself, and its +SMART reporting didn't show a darn thing wrong either. Fortunately, the +drive started acting noticeably weird (long pauses seemingly trying to +recalibrate itself) while still working well enough that I was able to +get everything copied off it. I didn't wait for it to fail completely ;-) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri May 12 13:09:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4D4F09FA490 + for ; + Fri, 12 May 2006 13:09:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 02604-03 + for ; + Fri, 12 May 2006 13:09:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ausimss.pervasive.com (ausimss.pervasive.com [66.45.103.246]) + by postgresql.org (Postfix) with ESMTP id 08A0D9FA1B0 + for ; + Fri, 12 May 2006 13:09:32 -0300 (ADT) +Received: from ausbayes2.aus.pervasive.com ([172.16.8.6]) by + ausimss.pervasive.com with InterScan Messaging Security Suite; + Fri, 12 May 2006 11:09:28 -0500 +Received: from AUSOWA.aus.pervasive.com ([172.16.4.8]) by + ausbayes2.aus.pervasive.com with Microsoft SMTPSVC(5.0.2195.6713); + Fri, 12 May 2006 11:09:27 -0500 +Received: from ausmailid.aus.pervasive.com ([172.16.4.64]) by + AUSOWA.aus.pervasive.com with Microsoft SMTPSVC(6.0.3790.1830); + Fri, 12 May 2006 11:09:27 -0500 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Subject: Re: slow variable against int?? +Date: Fri, 12 May 2006 11:09:27 -0500 +Message-ID: + <4D27CB1096EF1C408F4BFAB0046EC7B6099F55@ausmailid.aus.pervasive.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] slow variable against int?? +thread-index: AcZ1moQ4Qqf963lQSqG9GhPLKxaolgAQ4jnQ +From: "Jim Nasby" +To: "Witold Strzelczyk" +Cc: "Pgsql-Performance \(E-mail\)" +X-OriginalArrivalTime: 12 May 2006 16:09:27.0374 (UTC) + FILETIME=[717B66E0:01C675DE] +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/327 +X-Sequence-Number: 19114 + +Please cc the list so others can help. + +> From: Witold Strzelczyk [mailto:w.strzelczyk@digitalone.pl] +> On Friday 12 May 2006 00:04, you wrote: +>=20 +> Yes, thanks but method is not a point. + +Actually, it is a point. Databases don't like doing things procedurally. = +Using a stored procedure to operate on a set of data is very often the = +wrong way to go about it. In the case of ranking, I'm extremely doubtful = +that you'll ever get a procedure to opperate anywhere near as fast as = +native SQL. + +> Can You tell me why=20 +>=20 +> select into inGameRating count(game_result)+1=20 +> from users +> where game_result > 2984; +>=20 +> tooks ~100 ms and +>=20 +> select into inGameRating count(game_result)+1=20 +> from users +> where game_result > inRow.game_result; +>=20 +> where inRow.game_result =3D 2984 tooks ~1100 ms!? + +No, I can't. What's EXPLAIN ANALYZE show? + +> btw. I must try your temp sequence but if it is not as quick=20 +> as my new (and=20 +> final) function I'll send if to you. +>=20 +> > If you're trying to come up with ranking then you'll be much happier +> > using a sequence and pulling from it using an ordered=20 +> select. See lines +> > 19-27 in http://lnk.nu/cvs.distributed.net/9bu.sql for an example. +> > Depending on what you're doing you might not need the temp table. +> > +> > On Fri, May 05, 2006 at 04:46:43PM +0200, Witold Strzelczyk wrote: +> > > I have a question about my function. I must get user=20 +> rating by game +> > > result. This isn't probably a perfect solution but I have=20 +> one question +> > > about +> > > +> > > select into inGameRating count(game_result)+1 from users +> > > where game_result > inRow.game_result; +> > > +> > > This query in function results in about 1100 ms. +> > > inRow.game_result is a integer 2984 +> > > And now if I replace inRow.game_result with integer +> > > +> > > select into inGameRating count(game_result)+1 from users +> > > where game_result > 2984; +> > > +> > > query results in about 100 ms +> > > +> > > There is probably a reason for this but can you tell me=20 +> about it because +> > > I can't fine one +> > > +> > > My function: +> > > +> > > create or replace function ttt_result(int,int) returns setof +> > > tparent_result language plpgsql volatile as $$ +> > > declare +> > > inOffset alias for $1; +> > > inLimit alias for $2; +> > > inRow tparent_result%rowtype; +> > > inGameResult int :=3D -1; +> > > inGameRating int :=3D -1; +> > > begin +> > > +> > > for inRow in +> > > select +> > > email,wynik_gra +> > > from +> > > konkurs_uzytkownik +> > > order by wynik_gra desc limit inLimit offset inOffset +> > > loop +> > > if inGameResult < 0 then -- only for first iteration +> > > /* this is fast ~100 ms +> > > select into inGameRating +> > > count(game_result)+1 from users +> > > where game_result > 2984; +> > > */ +> > > /* even if inRow.game_result =3D 2984 this is=20 +> very slow ~ 1100 ms! +> > > select into inGameRating count(game_result)+1=20 +> from users +> > > where game_result > inRow.game_result; +> > > */ +> > > inGameResult :=3D inRow.game_result; +> > > end if; +> > > +> > > if inGameResult > inRow.game_result then +> > > inGameRating :=3D inGameRating + 1; +> > > end if; +> > > +> > > inRow.game_rating :=3D inGameRating; +> > > inGameResult :=3D inRow.game_result; +> > > return next inRow; +> > > +> > > end loop; +> > > return; +> > > end; +> > > $$; +> > > -- +> > > Witold Strzelczyk +> > > witek.strzelczyk@gmail.com +> > > +> > > ---------------------------(end of=20 +> broadcast)--------------------------- +> > > TIP 9: In versions below 8.0, the planner will ignore=20 +> your desire to +> > > choose an index scan if your joining column's=20 +> datatypes do not +> > > match +>=20 +> --=20 +> Witold Strzelczyk +>=20 +> =A0 : : =A0 D i g i t a l =A0O n e =A0: : =A0http://www.digitalone.pl +> =A0 : : =A0 Dowborczykow 25 =A0Lodz =A090-019 =A0Poland +> =A0 : : =A0 tel. [+48 42] 6771477 =A0fax [+48 42] 6771478 +>=20 +> =A0 =A0...Where Internet works for effective business solutions... +>=20 + +From pgsql-performance-owner@postgresql.org Fri May 12 15:23:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D60649FA1B0 + for ; + Fri, 12 May 2006 15:23:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 19110-08 + for ; + Fri, 12 May 2006 15:23:45 -0300 (ADT) +X-Greylist: delayed 00:24:31.613977 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id B89F69F946D + for ; + Fri, 12 May 2006 15:23:42 -0300 (ADT) +Received: from spaghetti.theross.com (theross.com [69.93.10.50]) + by svr4.postgresql.org (Postfix) with ESMTP id 047A15B587D + for ; + Fri, 12 May 2006 17:59:09 +0000 (GMT) +Received: from indigo by spaghetti.theross.com with local (Exim 4.60) + (envelope-from ) id 1Febuu-0000rf-5g + for pgsql-performance@postgresql.org; Fri, 12 May 2006 13:59:08 -0400 +Date: Fri, 12 May 2006 13:59:08 -0400 +From: Phil Frost +To: pgsql-performance@postgresql.org +Subject: stable function optimizations, revisited +Message-ID: <20060512175908.GA30515@unununium.org> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.5.11+cvs20060126 +X-SA-Exim-Connect-IP: +X-SA-Exim-Mail-From: indigo@unununium.org +X-SA-Exim-Scanned: No (on spaghetti.theross.com); + SAEximRunCond expanded to false +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/328 +X-Sequence-Number: 19115 + +I have recently been encountering a number of significant performance +problems related to stable functions being called multiple times when I +believe they could be called just once. Searching the ML archives, I see +I'm not the first: + + + + +and so on. None of them seemed to resolve to a plan of action or elegant +workaround. It is mentioned that "stable" was added to allow such +functions to be used for index scans, but I could not tell if other +optimizations I would like are impossible, or possible and if so, might +or will never be implemented. + +I have several examples of queries in which eliminating extra calls to a +stable function would result in very significant performance gains. All +of these cases were found while developing a real application, and +although I've simplified them to be more readable, they are not +contrived. + +Problem 1: creating a view with multiple columns calculated from a +function. + + create table sale(saleid serial, total numeric); + create function cost_of_sale(sale.saleid%type) returns numeric stable as $$ + -- calculates the cost of purchasing the things sold in a sale + -- takes considerable time to calculate + $$; + create view convenient_view_on_sale as + select *, + cost_of_sale(saleid) as cost, + total - cost_of_sale(saleid) as profit, + case when total != 0 then (total-cost_of_sale(saleid)) / total * 100 end as margin; + +Executing "select * from convenient_view_on_sale limit 1" will execute +cost_of_sale thrice. However, from the definition of stable, we know it +could have been called just once. As cost_of_sale takes hundreds of ms +to execute while the rest of the query is extremely simple, additional +calls in effect multiply the total execution time. + +Nonsolution 1a: moving function to a subselect: + + create view convenient_view_on_sale as + select *, + total - cost as profit, + case when total != 0 then (total-cost) / total * 100 end as margin + from (select *, cost_of_sale(saleid) as cost from sale) as subq; + +The query planner will eliminate the subselect, and cost_of_sale will +still be executed thrice. I can observe no change in behaviour +whatsoever with this view definition. + +PS: I wonder what the behaviour would be if I explicitly inlined +cost_of_sale here? + +Nonsolution 1b: preventing optimization of the subselect with "offset 0" + + create view convenient_view_on_sale as + select *, + total - cost as profit, + case when total != 0 then (total-cost) / total * 100 end as margin + from (select *, cost_of_sale(saleid) as cost from sale offset 0) as subq; + +This helps in the case of a "select *"; the subquery will not be +eliminated due to the "offset 0", and cost_of_sale will be executed only +once. However, it will always be executed, even if none of the cost +related columns are selected. For exaple, +"select saleid from convenient_view_on_sale limit 1" will execute +cost_of_sale once, although it could have not been executed at all. + +Problem 1 has a workaround: perform the dependant calculations (profit +and margin in this case) on the client, or in a stored procedure. This +is often inconvienent, but it works. + +Problem 2: expensive functions returning composite types. + +Consider that the purchases for a sale might have not yet been made, so +the exact cost can not be known, but a guess can be made based on the +current prices. cost_of_sale might be updated to reflect this: + + create function cost_of_sale(sale.saleid%type, out cost numeric, out estimated bool) + stable as $$ ... $$; + + create view convenient_view_on_sale as + select *, cost_of_sale(saleid) from sale; + +Note that in many cases, calculating "cost" and "estimated" together +takes just as long as calculating either one. This is why both are +returned from the same function. + +Now, I use python as a client, in particular the psycopg2 module. When I +do something such as "select cost from convenient_view_on_sale", the +values returned for the cost column (a composite type (numeric, bool)) +are strings. Perhaps this is an issue with psycopg2, but as a user, this +is very annoying since I can not really get at the components of the +composite type without reimplementing pg's parser. Granted I could +probably do it simply in a way that work work most the time, but I feel +it would be error prone, and I'd rather not. + +Thus, I seek a way to get the components of the cost column in top-level +columns. For example I try, "select (cost).cost, (cost).estimated", but +this now executes cost_of_sale twice, doubling the time of my query. + +Since stable functions are the most common in my experience, and I have +quite a number of them that perform complex, slow queries, I'd really +like to see optimizations in this area. Until such a time, I would very +much appreciate any workaround suggestions. + +From pgsql-performance-owner@postgresql.org Fri May 12 16:12:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F3FBD9FA1B0 + for ; + Fri, 12 May 2006 16:12:22 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 28331-05 + for ; + Fri, 12 May 2006 16:12:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 0F27C9F946D + for ; + Fri, 12 May 2006 16:12:15 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 1A0A956431; Fri, 12 May 2006 14:12:14 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Fri, 12 May 2006 14:12:13 -0500 +Date: Fri, 12 May 2006 14:12:13 -0500 +From: "Jim C. Nasby" +To: Antal Attila +Cc: pgsql-performance@postgresql.org +Subject: Re: Wrong plan for subSELECT with GROUP BY +Message-ID: <20060512191213.GS6201@pervasive.com> +References: <446482E4.6050906@ritek.hu> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <446482E4.6050906@ritek.hu> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060512:atesz@ritek.hu::QpeQ7tJlfdR7X+zk:0006tef +X-Hashcash: + 1:20:060512:pgsql-performance@postgresql.org::qCk/Pyh+MwExVoLz:00000 + 0000000000000000000000001Jhl +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/329 +X-Sequence-Number: 19116 + +If you wrap the LIMIT select into a subquery in the FROM the planner +might figure it out... + +SELECT ... + FROM (SELECT blah FROM a LIMIT 10) + LEFT JOIN ... + +Unlike some other databases that will spend huge amounts of time on +trying to re-arrange queries and then hope they can effectively cache +query plans, PostgreSQL prefers not to spend cycles on more esoteric +cases so that query planning is fast. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri May 12 16:14:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1A2D59FA48C + for ; + Fri, 12 May 2006 16:14:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 26683-08 + for ; + Fri, 12 May 2006 16:14:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 9572C9FA1B0 + for ; + Fri, 12 May 2006 16:14:17 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 1AF1856423; Fri, 12 May 2006 14:14:16 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Fri, 12 May 2006 14:14:15 -0500 +Date: Fri, 12 May 2006 14:14:15 -0500 +From: "Jim C. Nasby" +To: andremachado +Cc: pgsql-performance@postgresql.org +Subject: Re: Firebird 1.5.3 X Postgresql 8.1.3 (linux and windows) +Message-ID: <20060512191415.GT6201@pervasive.com> +References: <20060512143716.M32697@techforce.com.br> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060512143716.M32697@techforce.com.br> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060512:andremachado@techforce.com.br::Kim/xvXh2H3uOyxp:00000000 + 0000000000000000000000001RFN +X-Hashcash: + 1:20:060512:pgsql-performance@postgresql.org::DZSOQUG1DsaPTz2N:00000 + 0000000000000000000000003rRj +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/330 +X-Sequence-Number: 19117 + +On Fri, May 12, 2006 at 12:48:52PM -0200, andremachado wrote: +> Hello, +> continuing the saga, +> http://archives.postgresql.org/pgsql-performance/2006-04/msg00558.php , +> my coleague created a test database with fake data (see below). +> +> The above archived message contains the the timings of firebird and postgresql. +> The weird problem are the 2 queries that firebird executes in less than 2 +> seconds and postgresql took almost half hour to complete at 100% cpu. + +How about posting EXPLAIN ANALYZE for those two queries, as well as the +queries themselves? +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri May 12 16:54:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 489699FA293 + for ; + Fri, 12 May 2006 16:54:27 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 35242-01 + for ; + Fri, 12 May 2006 16:54:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id C549D9F946D + for ; + Fri, 12 May 2006 16:54:16 -0300 (ADT) +Received: from [192.168.1.50] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.6/8.13.4) with ESMTP id + k4CJsE20023383; Fri, 12 May 2006 12:54:15 -0700 +Message-ID: <4464E7E3.7070407@commandprompt.com> +Date: Fri, 12 May 2006 12:54:11 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Mail/News 1.5 (X11/20060309) +MIME-Version: 1.0 +To: "Jim C. Nasby" +CC: andremachado , + pgsql-performance@postgresql.org +Subject: Re: Firebird 1.5.3 X Postgresql 8.1.3 (linux and windows) +References: <20060512143716.M32697@techforce.com.br> + <20060512191415.GT6201@pervasive.com> +In-Reply-To: <20060512191415.GT6201@pervasive.com> +Content-Type: text/plain; charset=us-ascii; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88.2, + clamav-milter version 0.88.2 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Fri, 12 May 2006 12:54:17 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/331 +X-Sequence-Number: 19118 + +Jim C. Nasby wrote: +> On Fri, May 12, 2006 at 12:48:52PM -0200, andremachado wrote: +>> Hello, +>> continuing the saga, +>> http://archives.postgresql.org/pgsql-performance/2006-04/msg00558.php , +>> my coleague created a test database with fake data (see below). +>> +>> The above archived message contains the the timings of firebird and postgresql. +>> The weird problem are the 2 queries that firebird executes in less than 2 +>> seconds and postgresql took almost half hour to complete at 100% cpu. +> +> How about posting EXPLAIN ANALYZE for those two queries, as well as the +> queries themselves? + +I have this database downloaded if anyone wants a copy off a faster link. + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === + Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-performance-owner@postgresql.org Fri May 12 19:19:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id ED6DD9FA294 + for ; + Fri, 12 May 2006 19:19:51 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 49474-10 + for ; + Fri, 12 May 2006 19:19:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 927A19FA15C + for ; + Fri, 12 May 2006 19:19:41 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4CMJcKs023877; + Fri, 12 May 2006 18:19:39 -0400 (EDT) +To: "andremachado" +cc: pgsql-performance@postgresql.org +Subject: Re: Firebird 1.5.3 X Postgresql 8.1.3 (linux and windows) +In-reply-to: <20060512143716.M32697@techforce.com.br> +References: <20060512143716.M32697@techforce.com.br> +Comments: In-reply-to "andremachado" + message dated "Fri, 12 May 2006 12:48:52 -0200" +Date: Fri, 12 May 2006 18:19:38 -0400 +Message-ID: <23876.1147472378@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/332 +X-Sequence-Number: 19119 + +"andremachado" writes: +> continuing the saga, +> http://archives.postgresql.org/pgsql-performance/2006-04/msg00558.php , +> my coleague created a test database with fake data (see below). + +Thanks. I played around with this a bit, and got results like these: +original query, 8.1 branch from a couple weeks back: 945 sec +original query, 8.1 branch tip: 184 sec +modified query, 8.1 branch tip: 15 sec + +The first differential is because of this patch: +http://archives.postgresql.org/pgsql-committers/2006-04/msg00355.php +viz + Remove the restriction originally coded into + optimize_minmax_aggregates() that MIN/MAX not be converted to + use an index if the query WHERE clause contains any volatile + functions or subplans. + +Allowing the max(DEC2.AM_REFERENCIA) subquery to be converted to an +indexscan makes for about a 5X reduction in the number of times the +EXISTS sub-subquery is executed. But the real problem is that Postgres +isn't excessively smart about EXISTS subqueries. I manually changed it +into an IN to get the 15-second runtime: instead of + + (select max(DEC2.AM_REFERENCIA) from DECLARACAO DEC2 + where DEC2.IN_FOI_RETIFICADA=0 and + exists (select CAD3.ID_CADASTRO from CADASTRO CAD3 where + CAD3.ID_DECLARACAO=DEC2.ID_DECLARACAO and + CAD3.ID_EMPRESA=CADASTRO.ID_EMPRESA ) ) + +write + + (select max(DEC2.AM_REFERENCIA) from DECLARACAO DEC2 + where DEC2.IN_FOI_RETIFICADA=0 and DEC2.ID_DECLARACAO in + (select CAD3.ID_DECLARACAO from CADASTRO CAD3 where + CAD3.ID_EMPRESA=CADASTRO.ID_EMPRESA ) ) + +I'm not clear on how Firebird is managing to do this query in under +a second --- I can believe that they know how to do EXISTS as a join +but it still seems like the subqueries need to be done many thousand +times. I thought maybe they were caching the results of the overall +subquery for specific values of CADASTRO.ID_EMPRESA, but now that I +see your test data, there are several thousand distinct values of +that, so there's not a lot of traction to be gained that way. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat May 13 07:04:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 042F29FA2FA + for ; + Sat, 13 May 2006 07:04:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 37926-07 + for ; + Sat, 13 May 2006 07:04:16 -0300 (ADT) +X-Greylist: delayed 19:15:37.448588 by SQLgrey- +Received: from techforce.com.br (techforce.com.br [216.218.247.150]) + by postgresql.org (Postfix) with ESMTP id 6F3A69FA277 + for ; + Sat, 13 May 2006 07:04:16 -0300 (ADT) +Received: from 201-15-173-224.paemt705.dsl.brasiltelecom.net.br + (201-15-173-224.paemt705.dsl.brasiltelecom.net.br [201.15.173.224]) + (authenticated bits=0) + by techforce.com.br (8.12.11/8.12.11) with ESMTP id k4DA1Mic020676; + Sat, 13 May 2006 03:01:24 -0700 +Subject: Firebird 1.5.3 X Postgresql 8.1.3 (linux and windows) +From: =?ISO-8859-1?Q?Andr=E9?= Felipe Machado +To: pgsql-performance@postgresql.org +Cc: "Jim C. Nasby" +In-Reply-To: <20060512191415.GT6201@pervasive.com> +References: <20060512143716.M32697@techforce.com.br> + <20060512191415.GT6201@pervasive.com> +Content-Type: text/plain; charset=ISO-8859-1 +Date: Sat, 13 May 2006 06:58:02 -0300 +Message-Id: <1147514282.3896.12.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.4 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/333 +X-Sequence-Number: 19120 + +Hello, Jim +I did not want to clutter mailboxes of those who are not interested at +this weird problem. +So, i pointed to the archived message that contains 2 tar.gz files +(around 50 KB) with the two sets of queries (firebird and postgresql +respectively), its results, explain analyze, pg configurations, firebird +plan outputs, etc. +Please, open the cited link and scroll to the end of message. You will +find the 2 tar.gz files. +http://archives.postgresql.org/pgsql-performance/2006-04/msg00558.php +If you have some difficulty, I could send a private email containing the +2 files in order to not send the big email to the all list again. +Many thanks. +Andre Felipe Machado + + +Em Sex, 2006-05-12 �s 14:14 -0500, Jim C. Nasby escreveu: +> On Fri, May 12, 2006 at 12:48:52PM -0200, andremachado wrote: +> > Hello, +> > continuing the saga, +> > http://archives.postgresql.org/pgsql-performance/2006-04/msg00558.php , +> > my coleague created a test database with fake data (see below). +> > +> > The above archived message contains the the timings of firebird and postgresql. +> > The weird problem are the 2 queries that firebird executes in less than 2 +> > seconds and postgresql took almost half hour to complete at 100% cpu. +> +> How about posting EXPLAIN ANALYZE for those two queries, as well as the +> queries themselves? + + +From pgsql-performance-owner@postgresql.org Sat May 13 18:26:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 38C1D9F944D + for ; + Sat, 13 May 2006 18:26:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29228-05 + for ; + Sat, 13 May 2006 18:26:09 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id EC9449F9316 + for ; + Sat, 13 May 2006 18:26:08 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4DLQ6Xa006204; + Sat, 13 May 2006 17:26:07 -0400 (EDT) +To: "andremachado" +cc: pgsql-performance@postgresql.org +Subject: Re: Firebird 1.5.3 X Postgresql 8.1.3 (linux and windows) +In-reply-to: <20060512143716.M32697@techforce.com.br> +References: <20060512143716.M32697@techforce.com.br> +Comments: In-reply-to "andremachado" + message dated "Fri, 12 May 2006 12:48:52 -0200" +Date: Sat, 13 May 2006 17:26:06 -0400 +Message-ID: <6203.1147555566@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/334 +X-Sequence-Number: 19121 + +"andremachado" writes: +> continuing the saga, +> http://archives.postgresql.org/pgsql-performance/2006-04/msg00558.php , +> my coleague created a test database with fake data (see below). + +I tried to use this data to replicate your results, and could not. +I grabbed a copy of what I think is the latest Firebird release, +firebird-1.5.3.4870, built it on a Fedora Core 4 machine (32-bit, +couldn't get it to build cleanly on my newer 64-bit machine :-() +and compared to Postgres 8.1 branch tip on the same machine. +On the interesting sub-sub-EXISTS query, I see these results: + +Firebird: +SQL> set stats on; +SQL> set plan on; +SQL> update CADASTRO set IN_CADASTRO_MAIS_ATUAL = case when CADASTRO.ID_CADASTRO= (select max(CAD2.ID_CADASTRO) from CADASTRO CAD2 inner join DECLARACAO DECL on (DECL.ID_DECLARACAO=CAD2.ID_DECLARACAO) where CAD2.ID_EMPRESA=CADASTRO.ID_EMPRESA and DECL.AM_REFERENCIA = (select max(DEC2.AM_REFERENCIA) from DECLARACAO DEC2 where DEC2.IN_FOI_RETIFICADA=0 and exists (select CAD3.ID_CADASTRO from CADASTRO CAD3 where CAD3.ID_DECLARACAO=DEC2.ID_DECLARACAO and CAD3.ID_EMPRESA=CADASTRO.ID_EMPRESA ) )and DECL.IN_FOI_RETIFICADA=0 )then 1 else 0 end ; + +PLAN (CAD3 INDEX (RDB$FOREIGN1)) +PLAN (DEC2 NATURAL) +PLAN JOIN (DECL INDEX (IDX_DT_REFERENCIA),CAD2 INDEX (RDB$FOREIGN1)) +PLAN (CADASTRO NATURAL) +Current memory = 786704 +Delta memory = 309056 +Max memory = 786704 +Elapsed time= 344.19 sec +Cpu = 0.03 sec +Buffers = 75 +Reads = 2081702 +Writes = 16173 +Fetches = 21713743 + +The cpu = 0.03 sec bit is bogus; in reality the CPU is maxed out +and the isql process accumulates very nearly 344 seconds runtime. + +Postgres: +bc=# \timing +Timing is on. +bc=# update CADASTRO set IN_CADASTRO_MAIS_ATUAL = case when CADASTRO.ID_CADASTRO= (select max(CAD2.ID_CADASTRO) from CADASTRO CAD2 inner join DECLARACAO DECL on (DECL.ID_DECLARACAO=CAD2.ID_DECLARACAO) where CAD2.ID_EMPRESA=CADASTRO.ID_EMPRESA and DECL.AM_REFERENCIA = (select max(DEC2.AM_REFERENCIA) from DECLARACAO DEC2 where DEC2.IN_FOI_RETIFICADA=0 and exists (select CAD3.ID_CADASTRO from CADASTRO CAD3 where CAD3.ID_DECLARACAO=DEC2.ID_DECLARACAO and CAD3.ID_EMPRESA=CADASTRO.ID_EMPRESA ) )and DECL.IN_FOI_RETIFICADA=0 )then 1 else 0 end ; +UPDATE 15490 +Time: 420350.628 ms + +Now I know nothing about Firebird and it's quite possible that I missed +some essential tuning step, but I'm sure not in the same ballpark as +your report of 0.72 sec to run this query. + + regards, tom lane + +From pgsql-general-owner@postgresql.org Sun May 14 05:42:43 2006 +X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 220429FA3B3 + for ; + Sun, 14 May 2006 05:42:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 06780-01 + for ; + Sun, 14 May 2006 05:42:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id C52869FA42B + for ; + Sun, 14 May 2006 05:42:32 -0300 (ADT) +Received: from smtp5.jaring.my (smtp5.jaring.my [61.6.32.55]) + by svr4.postgresql.org (Postfix) with ESMTP id 841E95B6419 + for ; + Sun, 14 May 2006 08:42:30 +0000 (GMT) +Received: from nexus.localhost. ([218.208.193.198]) (authenticated bits=0) + by smtp5.jaring.my (8.13.4/8.13.1) with ESMTP id k4E8bHHh073995; + Sun, 14 May 2006 16:37:19 +0800 (MYT) + (envelope-from lyeoh@pop.jaring.my) +Message-Id: <5.2.1.1.1.20060514162127.027ea4f8@localhost> +X-Sender: lyeoh@localhost +X-Mailer: QUALCOMM Windows Eudora Version 5.2.1 +Date: Sun, 14 May 2006 16:31:00 +0800 +To: Tom Lane , + Scott Ribe +From: Lincoln Yeoh +Subject: Re: [PERFORM] Arguments Pro/Contra Software Raid +Cc: "Jim C. Nasby" , + Bruce Momjian , + PostgreSQL General +In-Reply-To: <2711.1147449236@sss.pgh.pa.us> +References: + +Mime-Version: 1.0 +Content-Type: text/plain; charset="us-ascii"; format=flowed +X-Virus-Scanned: JARING E-Mail Virus Scanner v2.0 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/659 +X-Sequence-Number: 95451 + +At 11:53 AM 5/12/2006 -0400, Tom Lane wrote: + +>Scott Ribe writes: +> >> My damn powerbook drive recently failed with very little warning +> +> > It seems to me that S.M.A.R.T. reporting is a crock of shit. I've had ATA +> > drives report everything OK while clearly in the final throes of death, +> just +> > minutes before total failure. +> +>FWIW, I replaced a powerbook's drive about two weeks ago myself, and its +>SMART reporting didn't show a darn thing wrong either. Fortunately, the +>drive started acting noticeably weird (long pauses seemingly trying to +>recalibrate itself) while still working well enough that I was able to +>get everything copied off it. I didn't wait for it to fail completely ;-) + +Strange. With long pauses, usually you'd see stuff like "crc" errors in the +logs, and you'd get some info from the SMART monitoring stuff. + +I guess a lot of it depends on the drive model and manufacturer. + +SMART reporting is better than nothing, and it's actually not too bad. It's +just whether manufacturers implement it in useful ways or not. + +I wouldn't trust the drive or manufacturer's judgement on when failure is +imminent - the drive usually gathers statistics etc and these are typically +readable with the SMART monitoring/reporting software, so you should check +those stats and decide for yourself when failure is imminent. + +For example: I'd suggest regarding any non-cable related CRC errors, or +seek failures as "drive replacement time"- even if the drive or +Manufacturer thinks you need to have tons in a row for "failure imminent". + +I recommend "blacklisting" drives which don't notice anything before it is +too late. e.g. even if it starts taking a long time to read a block, it +reports no differences in the SMART stats. + +Link. + + + +From pgsql-performance-owner@postgresql.org Mon May 15 05:48:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 774389F944D + for ; + Mon, 15 May 2006 05:48:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 46388-04 + for ; + Mon, 15 May 2006 05:48:47 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sand1.gxn.net (sand1.gxn.net [195.147.249.207]) + by postgresql.org (Postfix) with ESMTP id EAFC79F9430 + for ; + Mon, 15 May 2006 05:48:47 -0300 (ADT) +Received: from [62.232.55.118] (helo=[192.168.0.2]) + by sand1.gxn.net with esmtp (Exim 4.50) + id 1FfYne-0006rx-ND; Mon, 15 May 2006 09:51:35 +0100 +Subject: Re: Wrong plan for subSELECT with GROUP BY +From: Simon Riggs +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <23992.1147442716@sss.pgh.pa.us> +References: <446482E4.6050906@ritek.hu> <23992.1147442716@sss.pgh.pa.us> +Content-Type: text/plain +Date: Mon, 15 May 2006 09:48:33 +0100 +Message-Id: <1147682913.3465.232.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.2.3 (2.2.3-4.fc4) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/335 +X-Sequence-Number: 19122 + +On Fri, 2006-05-12 at 10:05 -0400, Tom Lane wrote: +> Antal Attila writes: +> > If this is a deficiency of the planner, I'd like to suggest this feature +> > into the planner. +> +> This really falls into the category of "you've got to be kidding". + +Agreed + +> There's no way that it'd be reasonable for the planner to expend cycles +> on every query to look for corner cases like this. + +OT: Should we have a way of telling the optimizer how much time and +effort we would like it to go to? Some of the new optimizations and many +yet to come cover smaller and smaller sub-cases. + +At least internally, we could mark the cost-of-optimization as we go, so +we can play with the external interface later. + +-- + Simon Riggs + EnterpriseDB http://www.enterprisedb.com + + +From pgsql-performance-owner@postgresql.org Tue May 16 00:15:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 80A199F9C18 + for ; + Tue, 16 May 2006 00:15:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27353-06 + for ; + Tue, 16 May 2006 00:15:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail2.sea5.speakeasy.net (mail2.sea5.speakeasy.net + [69.17.117.4]) by postgresql.org (Postfix) with ESMTP id 72BD29FA1B0 + for ; + Tue, 16 May 2006 00:15:14 -0300 (ADT) +Received: (qmail 13272 invoked from network); 16 May 2006 03:15:13 -0000 +Received: from dsl093-038-250.pdx1.dsl.speakeasy.net (HELO [192.168.1.20]) + (davidw@[66.93.38.250]) (envelope-sender ) + by mail2.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted + SMTP + for ; 16 May 2006 03:15:13 -0000 +Mime-Version: 1.0 (Apple Message framework v750) +Content-Transfer-Encoding: 7bit +Message-Id: <2D4C0FA5-DB75-45EA-91D2-7B4F6DD55083@kineticode.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: pgsql-performance +From: David Wheeler +Subject: IMMUTABLE? +Date: Mon, 15 May 2006 20:15:11 -0700 +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/336 +X-Sequence-Number: 19123 + +Performance Folks, + +I just had an article[1] published in which I demonstrated recursive +PL/pgSQL functions with this function: + +CREATE OR REPLACE FUNCTION fib ( + fib_for int +) RETURNS integer AS $$ +BEGIN + IF fib_for < 2 THEN + RETURN fib_for; + END IF; + RETURN fib(fib_for - 2) + fib(fib_for - 1); +END; +$$ LANGUAGE plpgsql; + +Naturally, it's slow: + +try=# \timing +try=# select fib(28); + fib +-------- +317811 +(1 row) + +Time: 10642.803 ms + +Now, I mistakenly said in my article that PostgreSQL doesn't have +native memoization, and so demonstrated how to use a table for +caching to speed up the function. It's pretty fast: + +try=# select fib_cached(28); +fib_cached +------------ + 317811 +(1 row) + +Time: 193.316 ms + +But over the weekend, I was looking at the Pg docs and saw IMMUTABLE, +and said, "Oh yeah!". So I recreated the function with IMMUTABLE. But +the performance was not much better: + +try=# select fib(28); + fib +-------- +317811 +(1 row) + +Time: 8505.668 ms +try=# select fib_cached(28); +fib_cached +------------ + 317811 +(1 row) + +So, what gives? Am I missing something, or not understanding how +IMMUTABLE works? + +Many TIA, + +David + +1. http://www.onlamp.com/pub/a/onlamp/2006/05/11/postgresql-plpgsql.html + +From pgsql-performance-owner@postgresql.org Tue May 16 00:21:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8FF719FA1B0 + for ; + Tue, 16 May 2006 00:21:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 35523-04 + for ; + Tue, 16 May 2006 00:21:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id AB8219FA277 + for ; + Tue, 16 May 2006 00:21:53 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4G3LpqE005212; + Mon, 15 May 2006 23:21:51 -0400 (EDT) +To: David Wheeler +cc: pgsql-performance +Subject: Re: IMMUTABLE? +In-reply-to: <2D4C0FA5-DB75-45EA-91D2-7B4F6DD55083@kineticode.com> +References: <2D4C0FA5-DB75-45EA-91D2-7B4F6DD55083@kineticode.com> +Comments: In-reply-to David Wheeler + message dated "Mon, 15 May 2006 20:15:11 -0700" +Date: Mon, 15 May 2006 23:21:51 -0400 +Message-ID: <5211.1147749711@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/337 +X-Sequence-Number: 19124 + +David Wheeler writes: +> So, what gives? Am I missing something, or not understanding how +> IMMUTABLE works? + +The latter. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 16 01:22:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B2FEE9F9CEE + for ; + Tue, 16 May 2006 01:22:16 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 44296-09 + for ; + Tue, 16 May 2006 01:22:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail4.sea5.speakeasy.net (mail4.sea5.speakeasy.net + [69.17.117.6]) by postgresql.org (Postfix) with ESMTP id 6A5C99FA278 + for ; + Tue, 16 May 2006 01:22:06 -0300 (ADT) +Received: (qmail 16527 invoked from network); 16 May 2006 04:22:05 -0000 +Received: from dsl093-038-250.pdx1.dsl.speakeasy.net (HELO [192.168.1.20]) + (davidw@[66.93.38.250]) (envelope-sender ) + by mail4.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted + SMTP + for ; 16 May 2006 04:22:05 -0000 +In-Reply-To: <5211.1147749711@sss.pgh.pa.us> +References: <2D4C0FA5-DB75-45EA-91D2-7B4F6DD55083@kineticode.com> + <5211.1147749711@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <3F0CF576-8C6F-433C-9942-BB36F4E1A194@kineticode.com> +Cc: pgsql-performance +Content-Transfer-Encoding: 7bit +From: David Wheeler +Subject: Re: IMMUTABLE? +Date: Mon, 15 May 2006 21:22:03 -0700 +To: Tom Lane +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/338 +X-Sequence-Number: 19125 + +On May 15, 2006, at 20:21, Tom Lane wrote: + +>> So, what gives? Am I missing something, or not understanding how +>> IMMUTABLE works? +> +> The latter. + +Hee-hee! And after all those nice things I wrote about you in a +previous email on this list! + +But seriously, the documentation says (as if I need to tell you, but +I was reading it again to make sure that I'm not insane): + +> IMMUTABLE indicates that the function always returns the same +> result when given the same argument values; that is, it does not do +> database lookups or otherwise use information not directly present +> in its argument list. If this option is given, any call of the +> function with all-constant arguments can be immediately replaced +> with the function value. + +So that seems pretty clear to me. Now, granted, the recursive calls +to fib() don't pass a constant argument, but I still would think that +after the first time I called fib(28), that the next call to fib(28) +would be lightening fast, even if fib(27) wasn't. + +So, uh, would you mind telling me what I'm missing? I'm happy to turn +that knowledge into a documentation patch to help future boneheads +like myself. :-) + +Thanks, + +David + +From pgsql-performance-owner@postgresql.org Tue May 16 01:31:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F379F9F9CEE + for ; + Tue, 16 May 2006 01:31:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 44195-09 + for ; + Tue, 16 May 2006 01:31:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 6A2259F944D + for ; + Tue, 16 May 2006 01:31:43 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4G4VfgM005895; + Tue, 16 May 2006 00:31:41 -0400 (EDT) +To: David Wheeler +cc: pgsql-performance +Subject: Re: IMMUTABLE? +In-reply-to: <3F0CF576-8C6F-433C-9942-BB36F4E1A194@kineticode.com> +References: <2D4C0FA5-DB75-45EA-91D2-7B4F6DD55083@kineticode.com> + <5211.1147749711@sss.pgh.pa.us> + <3F0CF576-8C6F-433C-9942-BB36F4E1A194@kineticode.com> +Comments: In-reply-to David Wheeler + message dated "Mon, 15 May 2006 21:22:03 -0700" +Date: Tue, 16 May 2006 00:31:41 -0400 +Message-ID: <5894.1147753901@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/339 +X-Sequence-Number: 19126 + +David Wheeler writes: +> But seriously, the documentation says (as if I need to tell you, but +> I was reading it again to make sure that I'm not insane): + +>> IMMUTABLE indicates that the function always returns the same +>> result when given the same argument values; that is, it does not do +>> database lookups or otherwise use information not directly present +>> in its argument list. If this option is given, any call of the +>> function with all-constant arguments can be immediately replaced +>> with the function value. + +Sure. As I read it, that's talking about a static transformation: +planner sees 2 + 2 (or if you prefer, int4pl(2,2)), planner runs the +function and replaces the expression with 4. Nothing there about +memoization. + +It's true that the system *could* memoize (or in our more usual +parlance, cache function values) given the assumptions embodied in +IMMUTABLE. But we don't, and I don't see any statement in the docs +that promises that we do. For 99% of the functions that the planner +deals with, memoization would be seriously counterproductive because +the function evaluation cost is comparable to if not less than the +lookup cost in a memo table. (int4pl is a good case in point.) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 16 06:40:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 542C69FA278 + for ; + Tue, 16 May 2006 06:40:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 14273-10 + for ; + Tue, 16 May 2006 06:40:16 -0300 (ADT) +X-Greylist: delayed 00:06:38.514117 by SQLgrey- +Received: from gollum.cambrium.nl (mx1.cambrium.nl [217.19.16.130]) + by postgresql.org (Postfix) with SMTP id 989C99F944D + for ; + Tue, 16 May 2006 06:40:15 -0300 (ADT) +Received: (qmail 22097 invoked from network); 16 May 2006 09:33:34 -0000 +Received: from office.tweakers.net (HELO ?10.0.0.157?) (84.245.2.46) + by gollum.cambrium.nl with SMTP; 16 May 2006 09:33:34 -0000 +Message-ID: <44699C6C.80302@tweakers.net> +Date: Tue, 16 May 2006 11:33:32 +0200 +From: Arjen van der Meijden +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: pgsql-performance +Subject: Pgsql (and mysql) benchmark on T2000/Solaris and some profiling +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/340 +X-Sequence-Number: 19127 + +Hi List, + +In the past few weeks we have been developing a read-heavy +mysql-benchmark to have an alternative take at cpu/platform-performance. +Not really to have a look at how fast mysql can be. + +This benchmark runs on mysql 4.1.x, 5.0.x and 5.1.x and is modelled +after our website's production database and the load generated on it is +modelled after a simplified version of our visitor behaviour. + +Long story short, we think the test is a nice example of the relatively +lightweight, read-heavy webapplications out there and therefore decided +to have a go at postgresql as well. +Of course the queries and indexes have been adjusted to (by our +knowledge) best suit postgresql, while maintaining the same output to +the application/interface layer. While the initial structure only got +postgresql at about half the performance of mysql 4.1.x, the current +version of our postgresql-benchmark has quite similar results to mysql +4.1.x, but both are quite a bit slower than 5.0.x (I think its about +30-40% faster). + +Since the results from those benchmarks are not yet public (they will be +put together in a story at our website), I won't go into too much +details about this benchmark. + +Currently we're having a look at a Sun T2000 and will be looking at will +be looking at other machines as well in the future. We are running the +sun-release of postgresql 8.1.3 on that T2000 now, but are looking at +compiling the cvs-head version (for its index-root-cache) somewhere this +week. + +My guess is there are a few people on this list who are interested in +some dtrace results taken during our benchmarks on that T2000. +Although my knowledge of both Solaris and Dtrace are very limited, I +already took some samples of the system and user calls. I used Jignesh +Shah's scripts for that: +http://blogs.sun.com/roller/page/jkshah?entry=profiling_postgresql_using_dtrace_on + +You can find the samples here: +http://achelois.tweakers.net/~acm/pgsql-t2000/syscall.log +http://achelois.tweakers.net/~acm/pgsql-t2000/usrcall.log + +And I also did the memcpy-scripts, here: +http://achelois.tweakers.net/~acm/pgsql-t2000/memcpysize.log +http://achelois.tweakers.net/~acm/pgsql-t2000/memcpystack.log +(this last log is 3.5MB) + +If anyone is interested in some more dtrace results, let me know (and +tell me what commands to run ;-) ). + +Best regards, + +Arjen + +From pgsql-performance-owner@postgresql.org Tue May 16 06:48:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8E9DB9F944D + for ; + Tue, 16 May 2006 06:48:45 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29493-07 + for ; + Tue, 16 May 2006 06:48:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 83D179FA278 + for ; + Tue, 16 May 2006 06:48:34 -0300 (ADT) +Received: from bottom.rox.net (bottom.rox.net [213.214.0.43]) + by svr4.postgresql.org (Postfix) with ESMTP id B29EE5B70B1 + for ; + Tue, 16 May 2006 09:48:33 +0000 (GMT) +Received: from localhost ([127.0.0.1]) by bottom.rox.net with esmtp (Exim + 4.62) + (envelope-from ) + id 1FfwAL-0004Me-AT; Tue, 16 May 2006 11:48:33 +0200 +Received: from [87.217.68.213] (helo=mcknight.kawo2.rwth-aachen.de) + by bottom.rox.net with esmtpa (Exim 4.62) + (envelope-from ) + id 1FfwAK-0004Ly-7w; Tue, 16 May 2006 11:48:32 +0200 +Received: by mcknight.kawo2.rwth-aachen.de (Postfix, from userid 1000) + id CA3174681A8; Tue, 16 May 2006 11:48:24 +0200 (CEST) +Date: Tue, 16 May 2006 11:48:24 +0200 +From: Joachim Wieland +To: Tom Lane +Cc: David Wheeler , + pgsql-performance +Subject: Re: IMMUTABLE? +Message-ID: <20060516094824.GA2376@mcknight.de> +References: <2D4C0FA5-DB75-45EA-91D2-7B4F6DD55083@kineticode.com> + <5211.1147749711@sss.pgh.pa.us> + <3F0CF576-8C6F-433C-9942-BB36F4E1A194@kineticode.com> + <5894.1147753901@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <5894.1147753901@sss.pgh.pa.us> +X-Operating-System: Linux 2.6.13.4 on an i686 +User-Agent: Mutt/1.5.9i +X-Scanned-By: rockenstein AG +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/341 +X-Sequence-Number: 19128 + +On Tue, May 16, 2006 at 12:31:41AM -0400, Tom Lane wrote: +> It's true that the system *could* memoize (or in our more usual +> parlance, cache function values) given the assumptions embodied in +> IMMUTABLE. But we don't, and I don't see any statement in the docs +> that promises that we do. For 99% of the functions that the planner +> deals with, memoization would be seriously counterproductive because +> the function evaluation cost is comparable to if not less than the +> lookup cost in a memo table. (int4pl is a good case in point.) + +This seems to change as soon as one takes into account user functions. + +While most immutable functions really seem to be small and their execution +fast, stable functions often hide complex sql (sometimes combined with +if-then-else or other program flow logic). + +So irrespective of caching to prevent evaluation across statements, within a +single statement, is there a strong reason why for example in +WHERE col = f(const) with f() declared as immutable or stable and without an +index on col, f() still gets called for every row? Or is this optimization +just not done yet? + + +Joachim + + +From pgsql-performance-owner@postgresql.org Tue May 16 07:05:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D2CD49F9F8F + for ; + Tue, 16 May 2006 07:05:22 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 33054-03 + for ; + Tue, 16 May 2006 07:05:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 517E39F9C18 + for ; + Tue, 16 May 2006 07:05:12 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id D257131923; Tue, 16 May 2006 12:05:10 +0200 (MET DST) +From: "Qingqing Zhou" +X-Newsgroups: pgsql.performance +Subject: Re: Pgsql (and mysql) benchmark on T2000/Solaris and some profiling +Date: Tue, 16 May 2006 18:01:26 +0800 +Organization: Hub.Org Networking Services +Lines: 30 +Message-ID: +References: <44699C6C.80302@tweakers.net> +X-Complaints-To: usenet@news.hub.org +X-Priority: 3 +X-MSMail-Priority: Normal +X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/342 +X-Sequence-Number: 19129 + + +"Arjen van der Meijden" wrote +> +> Long story short, we think the test is a nice example of the relatively +> lightweight, read-heavy webapplications out there and therefore decided +> to have a go at postgresql as well. +> + +Some sort of web query behavior is quite optimized in MySQL. For example, +the query below is runing very fast due to the query result cache +implementation in MySQL. + +Loop N times + SELECT * FROM A WHERE i = 1; +End loop. + +> You can find the samples here: +> http://achelois.tweakers.net/~acm/pgsql-t2000/syscall.log +> http://achelois.tweakers.net/~acm/pgsql-t2000/usrcall.log +> + +IMHO, without knowing the exact queries you sent, these logs are not very +useful :-(. I would suggest you compare the queries in pair and then post +their dtrace/timing results here (just like the previous Firebird vs. +PostgreSQL comparison did). + +Regards, +Qingqing + + + +From pgsql-performance-owner@postgresql.org Tue May 16 07:48:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AAE1A9F9F8F + for ; + Tue, 16 May 2006 07:48:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 39286-03 + for ; + Tue, 16 May 2006 07:48:02 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gollum.cambrium.nl (mx1.cambrium.nl [217.19.16.130]) + by postgresql.org (Postfix) with SMTP id 21FA39F9C18 + for ; + Tue, 16 May 2006 07:48:01 -0300 (ADT) +Received: (qmail 31616 invoked from network); 16 May 2006 10:48:00 -0000 +Received: from office.tweakers.net (HELO ?10.0.0.157?) (84.245.2.46) + by gollum.cambrium.nl with SMTP; 16 May 2006 10:48:00 -0000 +Message-ID: <4469ADDF.1010405@tweakers.net> +Date: Tue, 16 May 2006 12:47:59 +0200 +From: Arjen van der Meijden +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: Qingqing Zhou +CC: pgsql-performance@postgresql.org +Subject: Re: Pgsql (and mysql) benchmark on T2000/Solaris and some +References: <44699C6C.80302@tweakers.net> +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/343 +X-Sequence-Number: 19130 + +Qingqing Zhou wrote: +> "Arjen van der Meijden" wrote +> Some sort of web query behavior is quite optimized in MySQL. For example, +> the query below is runing very fast due to the query result cache +> implementation in MySQL. +> +> Loop N times +> SELECT * FROM A WHERE i = 1; +> End loop. + +Yeah, I know. But our queries get random parameters though for +identifiers and the like, so its not just a few queries getting executed +a lot of times, there are. In a run for which I just logged all queries, +almost 42k distinct queries executed from 128k in total (it may actually +be more random than real life). +Besides that, they are not so extremely simple queries as your example. +Most join at least two tables, while the rest often joins three to five. + +But I agree, MySQL has a big advantage with its query result cache. That +makes the current performance of postgresql even more impressive in this +situation, since the query cache of the 4.1.x run was enabled as well. + +> IMHO, without knowing the exact queries you sent, these logs are not very +> useful :-(. I would suggest you compare the queries in pair and then post +> their dtrace/timing results here (just like the previous Firebird vs. +> PostgreSQL comparison did). + +Well, I'm bound to some privacy and copyright laws, but I'll see if I +can show some example plans of at least the top few queries later today +(the top two is resp 27% and 21% of the total time). +But those top queries aren't the only ones run during the benchmarks or +in the production environment, nor are they run exclusively at any given +time. So the overall load-picture should be usefull too, shouldn't it? + +Best regards, + +Arjen + +From pgsql-performance-owner@postgresql.org Tue May 16 10:20:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9AFA89F9C18 + for ; + Tue, 16 May 2006 10:20:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 64892-02 + for ; + Tue, 16 May 2006 10:19:57 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from brmea-mail-4.sun.com (brmea-mail-4.Sun.COM [192.18.98.36]) + by postgresql.org (Postfix) with ESMTP id 9B07A9F9F8F + for ; + Tue, 16 May 2006 10:19:52 -0300 (ADT) +Received: from fe-amer-03.sun.com ([192.18.108.177]) + by brmea-mail-4.sun.com (8.12.10/8.12.9) with ESMTP id k4GDJnIH026316 + for ; + Tue, 16 May 2006 07:19:50 -0600 (MDT) +Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + id <0IZD002010OZL800@mail-amer.sun.com> (original mail from + J.K.Shah@Sun.COM) for pgsql-performance@postgresql.org; + Tue, 16 May 2006 07:19:49 -0600 (MDT) +Received: from [129.156.85.212] by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + with ESMTPSA id <0IZD00K25110TLL0@mail-amer.sun.com>; Tue, + 16 May 2006 07:19:49 -0600 (MDT) +Date: Tue, 16 May 2006 14:19:47 +0100 +From: "Jignesh K. Shah" +Subject: Re: Pgsql (and mysql) benchmark on T2000/Solaris and some +In-reply-to: <44699C6C.80302@tweakers.net> +To: Arjen van der Meijden +Cc: pgsql-performance +Message-id: <4469D173.50406@sun.com> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +References: <44699C6C.80302@tweakers.net> +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050322) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/344 +X-Sequence-Number: 19131 + +Hi Arjen, + +Looking at your outputs...of syscall and usrcall it looks like + +* Spending too much time in semsys .... which means you have too many +connections and they are contending to get a lock.. which is potentially +the WAL log lock + + +* llseek is high which means you can obviously gain a bit with the right +file system/files tuning by caching them right. + + +Have you set the values for Solaris for T2000 tuned for Postgresql? + +Check out the tunables from the following URL + +http://www.sun.com/servers/coolthreads/tnb/applications_postgresql.jsp + +Try specially the /etc/system and postgresql.conf changes and see if it +changes/improves your performance. + + +Regards, +Jignesh + + +Arjen van der Meijden wrote: +> Hi List, +> +> In the past few weeks we have been developing a read-heavy +> mysql-benchmark to have an alternative take at cpu/platform-performance. +> Not really to have a look at how fast mysql can be. +> +> This benchmark runs on mysql 4.1.x, 5.0.x and 5.1.x and is modelled +> after our website's production database and the load generated on it is +> modelled after a simplified version of our visitor behaviour. +> +> Long story short, we think the test is a nice example of the relatively +> lightweight, read-heavy webapplications out there and therefore decided +> to have a go at postgresql as well. +> Of course the queries and indexes have been adjusted to (by our +> knowledge) best suit postgresql, while maintaining the same output to +> the application/interface layer. While the initial structure only got +> postgresql at about half the performance of mysql 4.1.x, the current +> version of our postgresql-benchmark has quite similar results to mysql +> 4.1.x, but both are quite a bit slower than 5.0.x (I think its about +> 30-40% faster). +> +> Since the results from those benchmarks are not yet public (they will be +> put together in a story at our website), I won't go into too much +> details about this benchmark. +> +> Currently we're having a look at a Sun T2000 and will be looking at will +> be looking at other machines as well in the future. We are running the +> sun-release of postgresql 8.1.3 on that T2000 now, but are looking at +> compiling the cvs-head version (for its index-root-cache) somewhere this +> week. +> +> My guess is there are a few people on this list who are interested in +> some dtrace results taken during our benchmarks on that T2000. +> Although my knowledge of both Solaris and Dtrace are very limited, I +> already took some samples of the system and user calls. I used Jignesh +> Shah's scripts for that: +> http://blogs.sun.com/roller/page/jkshah?entry=profiling_postgresql_using_dtrace_on +> +> +> You can find the samples here: +> http://achelois.tweakers.net/~acm/pgsql-t2000/syscall.log +> http://achelois.tweakers.net/~acm/pgsql-t2000/usrcall.log +> +> And I also did the memcpy-scripts, here: +> http://achelois.tweakers.net/~acm/pgsql-t2000/memcpysize.log +> http://achelois.tweakers.net/~acm/pgsql-t2000/memcpystack.log +> (this last log is 3.5MB) +> +> If anyone is interested in some more dtrace results, let me know (and +> tell me what commands to run ;-) ). +> +> Best regards, +> +> Arjen +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq + +From pgsql-performance-owner@postgresql.org Tue May 16 10:33:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 409B99FA4E1 + for ; + Tue, 16 May 2006 10:33:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 66203-04 + for ; + Tue, 16 May 2006 10:33:29 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 6FA2F9FA176 + for ; + Tue, 16 May 2006 10:33:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4GDXE6h011509; + Tue, 16 May 2006 09:33:14 -0400 (EDT) +To: Joachim Wieland +cc: David Wheeler , + pgsql-performance +Subject: Re: IMMUTABLE? +In-reply-to: <20060516094824.GA2376@mcknight.de> +References: <2D4C0FA5-DB75-45EA-91D2-7B4F6DD55083@kineticode.com> + <5211.1147749711@sss.pgh.pa.us> + <3F0CF576-8C6F-433C-9942-BB36F4E1A194@kineticode.com> + <5894.1147753901@sss.pgh.pa.us> <20060516094824.GA2376@mcknight.de> +Comments: In-reply-to Joachim Wieland + message dated "Tue, 16 May 2006 11:48:24 +0200" +Date: Tue, 16 May 2006 09:33:14 -0400 +Message-ID: <11508.1147786394@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/345 +X-Sequence-Number: 19132 + +Joachim Wieland writes: +> So irrespective of caching to prevent evaluation across statements, within a +> single statement, is there a strong reason why for example in +> WHERE col = f(const) with f() declared as immutable or stable and without an +> index on col, f() still gets called for every row? Or is this optimization +> just not done yet? + +The above statement is not correct, at least not for immutable functions. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 16 10:54:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5E1199FA48C + for ; + Tue, 16 May 2006 10:54:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 73286-01 + for ; + Tue, 16 May 2006 10:54:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gollum.cambrium.nl (mx1.cambrium.nl [217.19.16.130]) + by postgresql.org (Postfix) with SMTP id E6A0B9F9C18 + for ; + Tue, 16 May 2006 10:54:20 -0300 (ADT) +Received: (qmail 25065 invoked from network); 16 May 2006 13:54:16 -0000 +Received: from office.tweakers.net (HELO ?10.0.0.157?) (84.245.2.46) + by gollum.cambrium.nl with SMTP; 16 May 2006 13:54:16 -0000 +Message-ID: <4469D986.6090300@tweakers.net> +Date: Tue, 16 May 2006 15:54:14 +0200 +From: Arjen van der Meijden +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: "Jignesh K. Shah" +CC: pgsql-performance +Subject: Re: Pgsql (and mysql) benchmark on T2000/Solaris and some +References: <44699C6C.80302@tweakers.net> <4469D173.50406@sun.com> +In-Reply-To: <4469D173.50406@sun.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/346 +X-Sequence-Number: 19133 + +Hi Jignesh, + +Jignesh K. Shah wrote: +> Hi Arjen, +> +> Looking at your outputs...of syscall and usrcall it looks like +> +> * Spending too much time in semsys .... which means you have too many +> connections and they are contending to get a lock.. which is potentially +> the WAL log lock +> +> * llseek is high which means you can obviously gain a bit with the right +> file system/files tuning by caching them right. +> +> Have you set the values for Solaris for T2000 tuned for Postgresql? + +Not particularly, we got a "special T2000 Solaris dvd" from your +colleagues here in the Netherlands and installed that (actually one of +your colleagues did). Doing so all the "better default" +/etc/system-settings are supposed to be set. I haven't really checked +that they are, since two of your colleagues have been working on it for +the mysql-version of the benchmark and I assumed they'd have verified that. + +> Check out the tunables from the following URL +> +> http://www.sun.com/servers/coolthreads/tnb/applications_postgresql.jsp +> +> Try specially the /etc/system and postgresql.conf changes and see if it +> changes/improves your performance. + +I will see that those tunables are verified to be set. + +I am a bit surprised though about your remarks, since they'd point at +the I/O being in the way? But we only have about 600k/sec i/o according +to vmstat. The database easily fits in memory. +In total I logged about 500k queries of which only 70k where altering +queries, of which almost all where inserts in log-tables which aren't +actively read in this benchmark. + +But I'll give it a try. + +Best regards, + +Arjen + +> +> Arjen van der Meijden wrote: +>> Hi List, +>> +>> In the past few weeks we have been developing a read-heavy +>> mysql-benchmark to have an alternative take at +>> cpu/platform-performance. Not really to have a look at how fast mysql +>> can be. +>> +>> This benchmark runs on mysql 4.1.x, 5.0.x and 5.1.x and is modelled +>> after our website's production database and the load generated on it +>> is modelled after a simplified version of our visitor behaviour. +>> +>> Long story short, we think the test is a nice example of the +>> relatively lightweight, read-heavy webapplications out there and +>> therefore decided to have a go at postgresql as well. +>> Of course the queries and indexes have been adjusted to (by our +>> knowledge) best suit postgresql, while maintaining the same output to +>> the application/interface layer. While the initial structure only got +>> postgresql at about half the performance of mysql 4.1.x, the current +>> version of our postgresql-benchmark has quite similar results to mysql +>> 4.1.x, but both are quite a bit slower than 5.0.x (I think its about +>> 30-40% faster). +>> +>> Since the results from those benchmarks are not yet public (they will +>> be put together in a story at our website), I won't go into too much +>> details about this benchmark. +>> +>> Currently we're having a look at a Sun T2000 and will be looking at +>> will be looking at other machines as well in the future. We are +>> running the sun-release of postgresql 8.1.3 on that T2000 now, but are +>> looking at compiling the cvs-head version (for its index-root-cache) +>> somewhere this week. +>> +>> My guess is there are a few people on this list who are interested in +>> some dtrace results taken during our benchmarks on that T2000. +>> Although my knowledge of both Solaris and Dtrace are very limited, I +>> already took some samples of the system and user calls. I used Jignesh +>> Shah's scripts for that: +>> http://blogs.sun.com/roller/page/jkshah?entry=profiling_postgresql_using_dtrace_on +>> +>> +>> You can find the samples here: +>> http://achelois.tweakers.net/~acm/pgsql-t2000/syscall.log +>> http://achelois.tweakers.net/~acm/pgsql-t2000/usrcall.log +>> +>> And I also did the memcpy-scripts, here: +>> http://achelois.tweakers.net/~acm/pgsql-t2000/memcpysize.log +>> http://achelois.tweakers.net/~acm/pgsql-t2000/memcpystack.log +>> (this last log is 3.5MB) +>> +>> If anyone is interested in some more dtrace results, let me know (and +>> tell me what commands to run ;-) ). +>> +>> Best regards, +>> +>> Arjen +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 3: Have you checked our extensive FAQ? +>> +>> http://www.postgresql.org/docs/faq +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: explain analyze is your friend +> + +From pgsql-performance-owner@postgresql.org Tue May 16 12:53:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6217B9F9F8F + for ; + Tue, 16 May 2006 12:53:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 92932-07 + for ; + Tue, 16 May 2006 12:53:02 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from brmea-mail-3.sun.com (brmea-mail-3.Sun.COM [192.18.98.34]) + by postgresql.org (Postfix) with ESMTP id 8ABA79F9C18 + for ; + Tue, 16 May 2006 12:53:01 -0300 (ADT) +Received: from fe-amer-02.sun.com ([192.18.108.176]) + by brmea-mail-3.sun.com (8.12.10/8.12.9) with ESMTP id k4GFr0Ke023223 + for ; + Tue, 16 May 2006 09:53:00 -0600 (MDT) +Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + id <0IZD00I017P4GD00@mail-amer.sun.com> (original mail from + J.K.Shah@Sun.COM) for pgsql-performance@postgresql.org; + Tue, 16 May 2006 09:53:00 -0600 (MDT) +Received: from [88.109.115.124] by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + with ESMTPSA id <0IZD009L684A4ME2@mail-amer.sun.com>; Tue, + 16 May 2006 09:53:00 -0600 (MDT) +Date: Tue, 16 May 2006 16:52:58 +0100 +From: "Jignesh K. Shah" +Subject: Re: Pgsql (and mysql) benchmark on T2000/Solaris and some +In-reply-to: <4469D986.6090300@tweakers.net> +To: Arjen van der Meijden +Cc: pgsql-performance@postgresql.org +Message-id: <4469F55A.7040004@sun.com> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +References: <44699C6C.80302@tweakers.net> <4469D173.50406@sun.com> + <4469D986.6090300@tweakers.net> +User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/347 +X-Sequence-Number: 19134 + +Hi Arjen, + +Can you send me my colleagues's names in a private email? + +One of the drawbacks of the syscall.d script is relative timings and +hence if system CPU usage is very low, it gives the relative weightage +about what portion in that low is associated with what call.. So even if +you have say..1% system time.. it says that most of it was IO related or +semsys related. So iostat output with -c option to include CPU times +helps to put it in the right perspective. + + +Also do check the tunables mentioned and make sure they are set. + +Regards, +Jignesh + + +Arjen van der Meijden wrote: + +> Hi Jignesh, +> +> Jignesh K. Shah wrote: +> +>> Hi Arjen, +>> +>> Looking at your outputs...of syscall and usrcall it looks like +>> +>> * Spending too much time in semsys .... which means you have too many +>> connections and they are contending to get a lock.. which is +>> potentially the WAL log lock +>> +>> * llseek is high which means you can obviously gain a bit with the +>> right file system/files tuning by caching them right. +>> +>> Have you set the values for Solaris for T2000 tuned for Postgresql? +> +> +> Not particularly, we got a "special T2000 Solaris dvd" from your +> colleagues here in the Netherlands and installed that (actually one of +> your colleagues did). Doing so all the "better default" +> /etc/system-settings are supposed to be set. I haven't really checked +> that they are, since two of your colleagues have been working on it +> for the mysql-version of the benchmark and I assumed they'd have +> verified that. +> +>> Check out the tunables from the following URL +>> +>> http://www.sun.com/servers/coolthreads/tnb/applications_postgresql.jsp +>> +>> Try specially the /etc/system and postgresql.conf changes and see if +>> it changes/improves your performance. +> +> +> I will see that those tunables are verified to be set. +> +> I am a bit surprised though about your remarks, since they'd point at +> the I/O being in the way? But we only have about 600k/sec i/o +> according to vmstat. The database easily fits in memory. +> In total I logged about 500k queries of which only 70k where altering +> queries, of which almost all where inserts in log-tables which aren't +> actively read in this benchmark. +> +> But I'll give it a try. +> +> Best regards, +> +> Arjen +> +>> +>> Arjen van der Meijden wrote: +>> +>>> Hi List, +>>> +>>> In the past few weeks we have been developing a read-heavy +>>> mysql-benchmark to have an alternative take at +>>> cpu/platform-performance. Not really to have a look at how fast +>>> mysql can be. +>>> +>>> This benchmark runs on mysql 4.1.x, 5.0.x and 5.1.x and is modelled +>>> after our website's production database and the load generated on it +>>> is modelled after a simplified version of our visitor behaviour. +>>> +>>> Long story short, we think the test is a nice example of the +>>> relatively lightweight, read-heavy webapplications out there and +>>> therefore decided to have a go at postgresql as well. +>>> Of course the queries and indexes have been adjusted to (by our +>>> knowledge) best suit postgresql, while maintaining the same output +>>> to the application/interface layer. While the initial structure only +>>> got postgresql at about half the performance of mysql 4.1.x, the +>>> current version of our postgresql-benchmark has quite similar +>>> results to mysql 4.1.x, but both are quite a bit slower than 5.0.x +>>> (I think its about 30-40% faster). +>>> +>>> Since the results from those benchmarks are not yet public (they +>>> will be put together in a story at our website), I won't go into too +>>> much details about this benchmark. +>>> +>>> Currently we're having a look at a Sun T2000 and will be looking at +>>> will be looking at other machines as well in the future. We are +>>> running the sun-release of postgresql 8.1.3 on that T2000 now, but +>>> are looking at compiling the cvs-head version (for its +>>> index-root-cache) somewhere this week. +>>> +>>> My guess is there are a few people on this list who are interested +>>> in some dtrace results taken during our benchmarks on that T2000. +>>> Although my knowledge of both Solaris and Dtrace are very limited, I +>>> already took some samples of the system and user calls. I used +>>> Jignesh Shah's scripts for that: +>>> http://blogs.sun.com/roller/page/jkshah?entry=profiling_postgresql_using_dtrace_on +>>> +>>> +>>> You can find the samples here: +>>> http://achelois.tweakers.net/~acm/pgsql-t2000/syscall.log +>>> http://achelois.tweakers.net/~acm/pgsql-t2000/usrcall.log +>>> +>>> And I also did the memcpy-scripts, here: +>>> http://achelois.tweakers.net/~acm/pgsql-t2000/memcpysize.log +>>> http://achelois.tweakers.net/~acm/pgsql-t2000/memcpystack.log +>>> (this last log is 3.5MB) +>>> +>>> If anyone is interested in some more dtrace results, let me know +>>> (and tell me what commands to run ;-) ). +>>> +>>> Best regards, +>>> +>>> Arjen +>>> +>>> ---------------------------(end of +>>> broadcast)--------------------------- +>>> TIP 3: Have you checked our extensive FAQ? +>>> +>>> http://www.postgresql.org/docs/faq +>> +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 6: explain analyze is your friend +>> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster + + +From pgsql-performance-owner@postgresql.org Tue May 16 13:55:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BED329FA15C + for ; + Tue, 16 May 2006 13:55:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 02563-03 + for ; + Tue, 16 May 2006 13:55:30 -0300 (ADT) +X-Greylist: delayed 07:07:00.153595 by SQLgrey- +Received: from foggy.rox.net (foggy.rox.net [213.214.0.41]) + by postgresql.org (Postfix) with ESMTP id D802D9F9C9E + for ; + Tue, 16 May 2006 13:55:29 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by foggy.rox.net with esmtp (Exim 4.62) + (envelope-from ) + id 1Fg2pU-0003E5-Lg; Tue, 16 May 2006 18:55:28 +0200 +Received: from [87.217.68.213] (helo=mcknight.kawo2.rwth-aachen.de) + by foggy.rox.net with esmtpa (Exim 4.62) + (envelope-from ) + id 1Fg2pT-0003Dg-Mf; Tue, 16 May 2006 18:55:27 +0200 +Received: by mcknight.kawo2.rwth-aachen.de (Postfix, from userid 1000) + id F2F9D4681A8; Tue, 16 May 2006 18:55:14 +0200 (CEST) +Date: Tue, 16 May 2006 18:55:14 +0200 +From: Joachim Wieland +To: Tom Lane +Cc: David Wheeler , + pgsql-performance +Subject: Re: IMMUTABLE? +Message-ID: <20060516165514.GA4424@mcknight.de> +References: <2D4C0FA5-DB75-45EA-91D2-7B4F6DD55083@kineticode.com> + <5211.1147749711@sss.pgh.pa.us> + <3F0CF576-8C6F-433C-9942-BB36F4E1A194@kineticode.com> + <5894.1147753901@sss.pgh.pa.us> <20060516094824.GA2376@mcknight.de> + <11508.1147786394@sss.pgh.pa.us> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <11508.1147786394@sss.pgh.pa.us> +X-Operating-System: Linux 2.6.13.4 on an i686 +User-Agent: Mutt/1.5.9i +X-Scanned-By: rockenstein AG +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/348 +X-Sequence-Number: 19135 + +On Tue, May 16, 2006 at 09:33:14AM -0400, Tom Lane wrote: +> Joachim Wieland writes: +> > So irrespective of caching to prevent evaluation across statements, within a +> > single statement, is there a strong reason why for example in +> > WHERE col = f(const) with f() declared as immutable or stable and without an +> > index on col, f() still gets called for every row? Or is this optimization +> > just not done yet? + +> The above statement is not correct, at least not for immutable functions. + +So an immutable function gets evaluated once but a stable function still gets +called for every row? Wouldn't it make sense to call a stable function only +once as well? + + +Joachim + +From pgsql-performance-owner@postgresql.org Tue May 16 15:00:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 62A549FA15C + for ; + Tue, 16 May 2006 15:00:45 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 26478-07 + for ; + Tue, 16 May 2006 15:00:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail3.sea5.speakeasy.net (mail3.sea5.speakeasy.net + [69.17.117.5]) by postgresql.org (Postfix) with ESMTP id 770699F9C9E + for ; + Tue, 16 May 2006 15:00:31 -0300 (ADT) +Received: (qmail 3070 invoked from network); 16 May 2006 18:00:29 -0000 +Received: from dsl093-038-250.pdx1.dsl.speakeasy.net (HELO [192.168.1.20]) + (davidw@[66.93.38.250]) (envelope-sender ) + by mail3.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted + SMTP + for ; 16 May 2006 18:00:29 -0000 +In-Reply-To: <5894.1147753901@sss.pgh.pa.us> +References: <2D4C0FA5-DB75-45EA-91D2-7B4F6DD55083@kineticode.com> + <5211.1147749711@sss.pgh.pa.us> + <3F0CF576-8C6F-433C-9942-BB36F4E1A194@kineticode.com> + <5894.1147753901@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <719F1E6C-4695-4FD2-A73B-0E3AE173B8F0@kineticode.com> +Cc: pgsql-performance +Content-Transfer-Encoding: 7bit +From: David Wheeler +Subject: Re: IMMUTABLE? +Date: Tue, 16 May 2006 11:00:27 -0700 +To: Tom Lane +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/349 +X-Sequence-Number: 19136 + +On May 15, 2006, at 21:31, Tom Lane wrote: + +> Sure. As I read it, that's talking about a static transformation: +> planner sees 2 + 2 (or if you prefer, int4pl(2,2)), planner runs the +> function and replaces the expression with 4. Nothing there about +> memoization. + +Oh, I see. So it's more like a constant or C macro. + +> It's true that the system *could* memoize (or in our more usual +> parlance, cache function values) given the assumptions embodied in +> IMMUTABLE. But we don't, and I don't see any statement in the docs +> that promises that we do. For 99% of the functions that the planner +> deals with, memoization would be seriously counterproductive because +> the function evaluation cost is comparable to if not less than the +> lookup cost in a memo table. (int4pl is a good case in point.) + +Yes, but there are definitely programming cases where memoization/ +caching definitely helps. And it's easy to tell for a given function +whether or not it really helps by simply trying it with CACHED and +without. + +Would this be a simple thing to implement? + +Best, + +David + +From pgsql-performance-owner@postgresql.org Tue May 16 15:30:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A83A89FA22C + for ; + Tue, 16 May 2006 15:30:05 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 48149-06 + for ; + Tue, 16 May 2006 15:29:57 -0300 (ADT) +X-Greylist: delayed 00:21:25.952589 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 52BC89FA15C + for ; + Tue, 16 May 2006 15:29:57 -0300 (ADT) +Received: from olive.qinip.net (olive.qinip.net [62.100.30.40]) + by svr4.postgresql.org (Postfix) with ESMTP id D269F5B3BB7 + for ; + Tue, 16 May 2006 18:08:29 +0000 (GMT) +Received: from [127.0.0.1] (h8441139206.dsl.speedlinq.nl [84.41.139.206]) + by olive.qinip.net (Postfix) with ESMTP id 6BC1E180EE; + Tue, 16 May 2006 20:08:28 +0200 (MEST) +Message-ID: <446A1520.2020601@tweakers.net> +Date: Tue, 16 May 2006 20:08:32 +0200 +From: Arjen van der Meijden +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: "Jignesh K. Shah" +Cc: pgsql-performance@postgresql.org +Subject: Re: Pgsql (and mysql) benchmark on T2000/Solaris and some +References: <44699C6C.80302@tweakers.net> <4469D173.50406@sun.com> + <4469D986.6090300@tweakers.net> <4469F55A.7040004@sun.com> +In-Reply-To: <4469F55A.7040004@sun.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Antivirus: avast! (VPS 0620-0, 15-05-2006), Outbound message +X-Antivirus-Status: Clean +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/350 +X-Sequence-Number: 19137 + +Hi Jignesh, + +The settings from that 'special T2000 dvd' differed from the recommended +settings on the website you provided. But I don't see much difference in +performance with any of the adjustments, it appears to be more or less +the same. + +Here are a few iostat lines by the way: + + sd0 sd1 sd2 nfs1 cpu +kps tps serv kps tps serv kps tps serv kps tps serv us sy wt id + 7 1 12 958 50 35 0 0 7 0 0 0 13 1 0 85 + 0 0 0 2353 296 3 0 0 0 0 0 0 92 7 0 1 + 0 0 0 2062 326 2 0 0 0 0 0 0 93 7 0 0 + 1 1 1 1575 350 0 0 0 0 0 0 0 92 7 0 1 + 0 0 0 1628 362 0 0 0 0 0 0 0 92 8 0 1 + +It appears to be doing a little less kps/tps on sd1 when I restore my +own postgresql.conf-settings. (default wal/checkpoints, 20k buffers, 2k +work mem). + +Is it possible to trace the stack's for semsys, like the memcpy-traces, +or are those of no interest here? + +Best regards, + +Arjen + + +On 16-5-2006 17:52, Jignesh K. Shah wrote: +> Hi Arjen, +> +> Can you send me my colleagues's names in a private email? +> +> One of the drawbacks of the syscall.d script is relative timings and +> hence if system CPU usage is very low, it gives the relative weightage +> about what portion in that low is associated with what call.. So even if +> you have say..1% system time.. it says that most of it was IO related or +> semsys related. So iostat output with -c option to include CPU times +> helps to put it in the right perspective. +> +> +> Also do check the tunables mentioned and make sure they are set. +> +> Regards, +> Jignesh +> +> +> Arjen van der Meijden wrote: +> +>> Hi Jignesh, +>> +>> Jignesh K. Shah wrote: +>> +>>> Hi Arjen, +>>> +>>> Looking at your outputs...of syscall and usrcall it looks like +>>> +>>> * Spending too much time in semsys .... which means you have too many +>>> connections and they are contending to get a lock.. which is +>>> potentially the WAL log lock +>>> +>>> * llseek is high which means you can obviously gain a bit with the +>>> right file system/files tuning by caching them right. +>>> +>>> Have you set the values for Solaris for T2000 tuned for Postgresql? +>> +>> +>> Not particularly, we got a "special T2000 Solaris dvd" from your +>> colleagues here in the Netherlands and installed that (actually one of +>> your colleagues did). Doing so all the "better default" +>> /etc/system-settings are supposed to be set. I haven't really checked +>> that they are, since two of your colleagues have been working on it +>> for the mysql-version of the benchmark and I assumed they'd have +>> verified that. +>> +>>> Check out the tunables from the following URL +>>> +>>> http://www.sun.com/servers/coolthreads/tnb/applications_postgresql.jsp +>>> +>>> Try specially the /etc/system and postgresql.conf changes and see if +>>> it changes/improves your performance. +>> +>> +>> I will see that those tunables are verified to be set. +>> +>> I am a bit surprised though about your remarks, since they'd point at +>> the I/O being in the way? But we only have about 600k/sec i/o +>> according to vmstat. The database easily fits in memory. +>> In total I logged about 500k queries of which only 70k where altering +>> queries, of which almost all where inserts in log-tables which aren't +>> actively read in this benchmark. +>> +>> But I'll give it a try. +>> +>> Best regards, +>> +>> Arjen +>> +>>> +>>> Arjen van der Meijden wrote: +>>> +>>>> Hi List, +>>>> +>>>> In the past few weeks we have been developing a read-heavy +>>>> mysql-benchmark to have an alternative take at +>>>> cpu/platform-performance. Not really to have a look at how fast +>>>> mysql can be. +>>>> +>>>> This benchmark runs on mysql 4.1.x, 5.0.x and 5.1.x and is modelled +>>>> after our website's production database and the load generated on it +>>>> is modelled after a simplified version of our visitor behaviour. +>>>> +>>>> Long story short, we think the test is a nice example of the +>>>> relatively lightweight, read-heavy webapplications out there and +>>>> therefore decided to have a go at postgresql as well. +>>>> Of course the queries and indexes have been adjusted to (by our +>>>> knowledge) best suit postgresql, while maintaining the same output +>>>> to the application/interface layer. While the initial structure only +>>>> got postgresql at about half the performance of mysql 4.1.x, the +>>>> current version of our postgresql-benchmark has quite similar +>>>> results to mysql 4.1.x, but both are quite a bit slower than 5.0.x +>>>> (I think its about 30-40% faster). +>>>> +>>>> Since the results from those benchmarks are not yet public (they +>>>> will be put together in a story at our website), I won't go into too +>>>> much details about this benchmark. +>>>> +>>>> Currently we're having a look at a Sun T2000 and will be looking at +>>>> will be looking at other machines as well in the future. We are +>>>> running the sun-release of postgresql 8.1.3 on that T2000 now, but +>>>> are looking at compiling the cvs-head version (for its +>>>> index-root-cache) somewhere this week. +>>>> +>>>> My guess is there are a few people on this list who are interested +>>>> in some dtrace results taken during our benchmarks on that T2000. +>>>> Although my knowledge of both Solaris and Dtrace are very limited, I +>>>> already took some samples of the system and user calls. I used +>>>> Jignesh Shah's scripts for that: +>>>> http://blogs.sun.com/roller/page/jkshah?entry=profiling_postgresql_using_dtrace_on +>>>> +>>>> +>>>> You can find the samples here: +>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/syscall.log +>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/usrcall.log +>>>> +>>>> And I also did the memcpy-scripts, here: +>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/memcpysize.log +>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/memcpystack.log +>>>> (this last log is 3.5MB) +>>>> +>>>> If anyone is interested in some more dtrace results, let me know +>>>> (and tell me what commands to run ;-) ). +>>>> +>>>> Best regards, +>>>> +>>>> Arjen +>>>> +>>>> ---------------------------(end of +>>>> broadcast)--------------------------- +>>>> TIP 3: Have you checked our extensive FAQ? +>>>> +>>>> http://www.postgresql.org/docs/faq +>>> +>>> +>>> ---------------------------(end of broadcast)--------------------------- +>>> TIP 6: explain analyze is your friend +>>> +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 2: Don't 'kill -9' the postmaster +> +> + +From pgsql-performance-owner@postgresql.org Tue May 16 21:23:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 58B959F9CEE + for ; + Tue, 16 May 2006 21:23:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 06659-09 + for ; + Tue, 16 May 2006 21:23:15 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from server.nextgap2000.com (server.nextgap2000.com [66.98.160.7]) + by postgresql.org (Postfix) with ESMTP id 5C4BD9F9C18 + for ; + Tue, 16 May 2006 21:23:14 -0300 (ADT) +Received: from [82.166.55.109] (helo=jonathanlaptop) + by server.nextgap2000.com with esmtpa (Exim 4.52) id 1Fg9oj-0004EN-EN + for pgsql-performance@postgresql.org; Wed, 17 May 2006 03:23:10 +0300 +From: "Jonathan Blitz" +To: +Subject: Adding and filling new column on big table +Date: Wed, 17 May 2006 03:19:26 +0200 +Message-ID: <01b401c6794f$f27355e0$ddf71005@jonathanlaptop> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_01B5_01C67960.B5FC25E0" +X-Mailer: Microsoft Office Outlook 11 +X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 +thread-index: AcZ5T++5mWZOGFRKQDOtEizQgfW9DA== +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - server.nextgap2000.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] +X-AntiAbuse: Sender Address Domain - anykey.co.il +X-Source: +X-Source-Args: +X-Source-Dir: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/351 +X-Sequence-Number: 19138 + +This is a multi-part message in MIME format. + +------=_NextPart_000_01B5_01C67960.B5FC25E0 +Content-Type: text/plain; + charset="windows-1250" +Content-Transfer-Encoding: quoted-printable + +I have a table of about 500,000 rows.=20 + +=20 + +I need to add a new column and populate it. + +=20 + +So, I have tried to run the following command. The command never = +finishes (I +gave up after about and hour and a half!). + +Note that none of the columns have indexes. + +=20 + +Update mytable set new_column =3D =20 + +case when column_1 =3D column_2 +then 1 =20 + +when column_1+column_3=3D column_2 and column_3 > 0 +then 2 =20 + +when column_1+column_3+column_4 =3D column_2 and column_4 > 0 +then 3 =20 + +when column_1+column_3+column_4+column_5 =3D column_2 and column_5 > 0 +then 4 =20 + +else +0=20 + +end + +=20 + +=20 + +My computer is a Pentium 4 =96 2.4 GHZ and 1G RAM =96 so it should be = +fast +enough. + +=20 + +Any ideas? + +=20 + +Jonathan Blitz + +=20 + + +--=20 +No virus found in this outgoing message. +Checked by AVG Free Edition. +Version: 7.1.392 / Virus Database: 268.5.6/340 - Release Date: = +05/15/2006 +=20 + +------=_NextPart_000_01B5_01C67960.B5FC25E0 +Content-Type: text/html; + charset="windows-1250" +Content-Transfer-Encoding: quoted-printable + + + + + + + + + + + + + + +
+ +

I have a table of about 500,000 rows. = +

+ +

 

+ +

I need to add a new column and populate = +it.

+ +

 

+ +

So, I have tried to run the following command. The = +command +never finishes (I gave up after about and hour and a = +half!).

+ +

Note that none of the columns have = +indexes.

+ +

 

+ +

Update mytable set new_column =3D    = +

+ +

case when column_1 =3D column_2 = +           = +            = +            = +            = +            = +            then +1  

+ +

when column_1+column_3=3D column_2 and column_3 > = +0  = +            = +            = +            then +2  

+ +

when column_1+column_3+column_4 =3D column_2 and = +column_4 > +0         = +            then = +3  

+ +

when column_1+column_3+column_4+column_5 =3D column_2 = +and +column_5 > 0     then 4   = +

+ +

else = +            &= +nbsp;           &n= +bsp;           &nb= +sp;           &nbs= +p;            = +;            = +            &= +nbsp;           &n= +bsp;           &nb= +sp;          0 +

+ +

end

+ +

 

+ +

 

+ +

My computer is a Pentium 4 – 2.4 GHZ and 1G RAM = +– so it +should be fast enough.

+ +

 

+ +

Any ideas?

+ +

 

+ +

Jonathan Blitz

+ +

 

+ +
+ + + + +
+ +

--
+No virus found in this outgoing message.
+Checked by AVG Free Edition.
+Version: 7.1.392 / Virus Database: 268.5.6/340 - Release Date: = +05/15/2006
+

+ +------=_NextPart_000_01B5_01C67960.B5FC25E0-- + + +From pgsql-performance-owner@postgresql.org Tue May 16 22:29:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2FB4B9F9CEE + for ; + Tue, 16 May 2006 22:29:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 49148-07 + for ; + Tue, 16 May 2006 22:29:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by postgresql.org (Postfix) with ESMTP id B89A89F9C18 + for ; + Tue, 16 May 2006 22:29:38 -0300 (ADT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id A00332573B; + Wed, 17 May 2006 09:29:09 +0800 (WST) +Received: from [127.0.0.1] (work-48.internal [192.168.0.48]) + by houston.familyhealth.com.au (Postfix) with ESMTP id BCBC325723; + Wed, 17 May 2006 09:28:32 +0800 (WST) +Message-ID: <446A7C69.5030905@calorieking.com> +Date: Wed, 17 May 2006 09:29:13 +0800 +From: Christopher Kings-Lynne +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: David Wheeler +Cc: Tom Lane , + pgsql-performance +Subject: Re: IMMUTABLE? +References: <2D4C0FA5-DB75-45EA-91D2-7B4F6DD55083@kineticode.com> + <5211.1147749711@sss.pgh.pa.us> + <3F0CF576-8C6F-433C-9942-BB36F4E1A194@kineticode.com> + <5894.1147753901@sss.pgh.pa.us> + <719F1E6C-4695-4FD2-A73B-0E3AE173B8F0@kineticode.com> +In-Reply-To: <719F1E6C-4695-4FD2-A73B-0E3AE173B8F0@kineticode.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chris.kings-lynne@calorieking.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/352 +X-Sequence-Number: 19139 + +> Yes, but there are definitely programming cases where +> memoization/caching definitely helps. And it's easy to tell for a given +> function whether or not it really helps by simply trying it with CACHED +> and without. +> +> Would this be a simple thing to implement? + +It's called a "table" :) + + +From pgsql-performance-owner@postgresql.org Tue May 16 23:09:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3CC789F9CEE + for ; + Tue, 16 May 2006 23:09:03 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 74728-05 + for ; + Tue, 16 May 2006 23:08:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail4.sea5.speakeasy.net (mail4.sea5.speakeasy.net + [69.17.117.6]) by postgresql.org (Postfix) with ESMTP id 75AA49F9C18 + for ; + Tue, 16 May 2006 23:08:54 -0300 (ADT) +Received: (qmail 4233 invoked from network); 17 May 2006 02:08:52 -0000 +Received: from dsl093-038-250.pdx1.dsl.speakeasy.net (HELO [192.168.1.20]) + (davidw@[66.93.38.250]) (envelope-sender ) + by mail4.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted + SMTP for ; 17 May 2006 02:08:52 -0000 +In-Reply-To: <446A7C69.5030905@calorieking.com> +References: <2D4C0FA5-DB75-45EA-91D2-7B4F6DD55083@kineticode.com> + <5211.1147749711@sss.pgh.pa.us> + <3F0CF576-8C6F-433C-9942-BB36F4E1A194@kineticode.com> + <5894.1147753901@sss.pgh.pa.us> + <719F1E6C-4695-4FD2-A73B-0E3AE173B8F0@kineticode.com> + <446A7C69.5030905@calorieking.com> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: Tom Lane , + pgsql-performance +Content-Transfer-Encoding: 7bit +From: David Wheeler +Subject: Re: IMMUTABLE? +Date: Tue, 16 May 2006 19:08:51 -0700 +To: Christopher Kings-Lynne +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/354 +X-Sequence-Number: 19141 + +On May 16, 2006, at 18:29, Christopher Kings-Lynne wrote: + +>> Yes, but there are definitely programming cases where memoization/ +>> caching definitely helps. And it's easy to tell for a given +>> function whether or not it really helps by simply trying it with +>> CACHED and without. +>> Would this be a simple thing to implement? +> +> It's called a "table" :) + + http://www.justatheory.com/computers/databases/postgresql/ +higher_order_plpgsql.html + +Yes, I know. :-P But it'd be easier to have a CACHED keyword, of course. + +Best, + +David + +From pgsql-performance-owner@postgresql.org Tue May 16 23:20:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E0B479F9C18 + for ; + Tue, 16 May 2006 23:20:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 79244-10 + for ; + Tue, 16 May 2006 23:20:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moonunit2.moonview.localnet (wsip-70-167-125-69.sd.sd.cox.net + [70.167.125.69]) + by postgresql.org (Postfix) with ESMTP id EB6CF9FA218 + for ; + Tue, 16 May 2006 23:20:31 -0300 (ADT) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k4H2Staj032286; Tue, 16 May 2006 19:28:55 -0700 +Message-ID: <446A885C.2050308@modgraph-usa.com> +Date: Tue, 16 May 2006 19:20:12 -0700 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Christian Paul Cosinas +CC: "'PFC'" , pgsql-performance@postgresql.org +Subject: Re: Speed Up Offset and Limit Clause +References: <00e101c67997$6aa049f0$1e21100a@ghwk02002147> +In-Reply-To: <00e101c67997$6aa049f0$1e21100a@ghwk02002147> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/355 +X-Sequence-Number: 19142 + +Christian Paul Cosinas wrote: +> I am creating an application that gets the value of a large table and write +> it to a file. +> +> Why I want to use offset and limit is for me to create a threaded +> application so that they will not get the same results. +> +> For example: +> +> Thread 1 : gets offset 0 limit 5000 +> Thread 2 : gets offset 5000 limit 5000 +> Thread 3 : gets offset 10000 limit 5000 +> +> And so on... +> +> Would there be any other faster way than what It thought? + +In order to return rows 10000 to 15000, it must select all rows from zero to 15000 and then discard the first 10000 -- probably not what you were hoping for. + +You might add a "thread" column. Say you want to run ten threads: + + create sequence thread_seq + increment by 1 + minvalue 1 maxvalue 10 + cycle + start with 1; + + create table mytable( + column1 integer, + ... other columns..., + thread integer default nextval('thread_seq') + ); + + create bitmap index i_mytable_thread on mytable(thread); + +Now whenever you insert into mytable, you get a value in mytable.thread between 1 and 10, and it's indexed with a highly efficient bitmap index. So your query becomes: + + Thread 1: select ... from mytable where ... and thread = 1; + Thread 2: select ... from mytable where ... and thread = 2; + ... and so forth. + +Craig + +From pgsql-performance-owner@postgresql.org Tue May 16 23:31:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0DF4A9F9CEE + for ; + Tue, 16 May 2006 23:31:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 76213-10 + for ; + Tue, 16 May 2006 23:31:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by postgresql.org (Postfix) with ESMTP id 52A1F9F9C18 + for ; + Tue, 16 May 2006 23:31:38 -0300 (ADT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id k4H2VVuP004441 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Tue, 16 May 2006 20:31:34 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.6/8.13.6) with ESMTP id k4H2VVHq060897; + Tue, 16 May 2006 20:31:31 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.6/8.13.6/Submit) id k4H2VVTk060896; + Tue, 16 May 2006 20:31:31 -0600 (MDT) (envelope-from mfuhr) +Date: Tue, 16 May 2006 20:31:30 -0600 +From: Michael Fuhr +To: Jonathan Blitz +Cc: pgsql-performance@postgresql.org +Subject: Re: Adding and filling new column on big table +Message-ID: <20060517023130.GA60671@winnie.fuhr.org> +References: <01b401c6794f$f27355e0$ddf71005@jonathanlaptop> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <01b401c6794f$f27355e0$ddf71005@jonathanlaptop> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/356 +X-Sequence-Number: 19143 + +On Wed, May 17, 2006 at 03:19:26AM +0200, Jonathan Blitz wrote: +> I have a table of about 500,000 rows. +> +> I need to add a new column and populate it. +> +> So, I have tried to run the following command. The command never finishes (I +> gave up after about and hour and a half!). + +If you install contrib/pgstattuple you can figure out how fast the +update is running. Run "SELECT * FROM pgstattuple('mytable')" a +few times and note the rate at which dead_tuple_count is increasing. +If it's not increasing at all then query pg_locks and look for locks +where "granted" is false. + +I created a test table, populated it with 500,000 rows of random +data, and ran the update you posted. On a 500MHz Pentium III with +512M RAM and a SCSI drive from the mid-to-late 90s, running PostgreSQL +8.1.3 on FreeBSD 6.1, the update finished in just over two minutes. +The table had one index (the primary key). + +> Note that none of the columns have indexes. + +Do you mean that no columns in the table have indexes? Or that the +columns referenced in the update don't have indexes but that other +columns do? What does "\d mytable" show? Do other tables have +foreign key references to this table? What non-default settings +do you have in postgresql.conf? What version of PostgreSQL are you +running and on what platform? How busy is the system? What's the +output of "EXPLAIN UPDATE mytable ..."? + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Wed May 17 03:13:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7E6109FA293 + for ; + Wed, 17 May 2006 03:13:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29963-01 + for ; + Wed, 17 May 2006 03:13:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from grp-smtp.toray.com.my (grp-smtp.toray.com.my [202.186.44.7]) + by postgresql.org (Postfix) with ESMTP id 3EE9F9F9430 + for ; + Wed, 17 May 2006 03:13:21 -0300 (ADT) +Received: from localhost (localhost.toray.com.my [127.0.0.1]) + by grp-smtp.toray.com.my (Postfix) with ESMTP id C701850902 + for ; + Wed, 17 May 2006 14:13:17 +0800 (MYT) +X-Virus-Scanned: amavisd-new at pengroup.com.my +Received: from grp-smtp.toray.com.my ([127.0.0.1]) + by localhost (grp-smtp.pengroup.com.my [127.0.0.1]) (amavisd-new, + port 10024) + with ESMTP id hidwz61wCRU8 for ; + Wed, 17 May 2006 14:13:15 +0800 (MYT) +Received: from notes01.pengroup.com.my (notes01.toray.com.my [10.200.1.1]) + by grp-smtp.toray.com.my (Postfix) with ESMTP id C390150905 + for ; + Wed, 17 May 2006 14:13:15 +0800 (MYT) +Subject: Performance incorporate with JReport +To: pgsql-performance@postgresql.org +X-Mailer: Lotus Notes Release 5.0.5 September 22, 2000 +Message-ID: +From: kah_hang_ang@toray.com.my +Date: Wed, 17 May 2006 14:13:46 +0800 +X-MIMETrack: Serialize by Router on Notes01/Pen-Group(Release 6.5.1|January + 21, + 2004) at 05/17/2006 02:13:16 PM +MIME-Version: 1.0 +Content-type: text/plain; charset=US-ASCII +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/357 +X-Sequence-Number: 19144 + + + + + +Hi, + +Currently I'm using postgresql v8.1.3 and the latest jdbc. + +I try to open a JReports' report and the time taken to completely open the +report is 137453ms. +Then I open the same report but this time I connect to postgresql v7.2.2 +but the completion time is even faster than connect to postgresql v8.1.3 +which took 15516ms to finish. + +I try many times and the result is still the same. + +So I think it might be compatibility problem between JReport & Postgresql +8.1.3 so i add in 'protocolVersion=2' in the connection string. +Then i open the same report again and this time it just as what i expected, +the execution time for the report become 6000ms only, +it is 20x times faster than previous test without 'protocolVersion=2' +option. + +May I know what is the reason of this? +Is it because of the compatibility between JDBC driver with JReport? + +Thanks! + + +From pgsql-performance-owner@postgresql.org Tue May 16 22:41:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D07489FA3B3 + for ; + Tue, 16 May 2006 22:41:40 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 64190-02 + for ; + Tue, 16 May 2006 22:41:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mailer.eglobalreach.net (mail.opm.ph [202.124.128.22]) + by postgresql.org (Postfix) with ESMTP id F3EEE9F9C18 + for ; + Tue, 16 May 2006 22:41:34 -0300 (ADT) +Received: from ghwk02002147 (mailer.eglobalreach.net [127.0.0.1]) + by mailer.eglobalreach.net (8.11.6p2/) with ESMTP id k4H1fQX25843; + Wed, 17 May 2006 09:41:27 +0800 +From: "Christian Paul Cosinas" +To: "'PFC'" , +Subject: Re: Speed Up Offset and Limit Clause +Date: Wed, 17 May 2006 09:51:05 -0000 +Message-ID: <00e101c67997$6aa049f0$1e21100a@ghwk02002147> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook 11 +In-Reply-To: +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 +thread-index: AcZ0yShMlJrIPbLSSXqR9TwwF2XbVgEzfEWw +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/353 +X-Sequence-Number: 19140 + +I am creating an application that gets the value of a large table and write +it to a file. + +Why I want to use offset and limit is for me to create a threaded +application so that they will not get the same results. + +For example: + +Thread 1 : gets offset 0 limit 5000 +Thread 2 : gets offset 5000 limit 5000 +Thread 3 : gets offset 10000 limit 5000 + +And so on... + +Would there be any other faster way than what It thought? + +-----Original Message----- +From: PFC [mailto:lists@peufeu.com] +Sent: Thursday, May 11, 2006 7:06 AM +To: Christian Paul Cosinas; pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Speed Up Offset and Limit Clause + + + Why do you want to use it this way ? + Explain what you want to do, there probably is another faster +solution... + +On Thu, 11 May 2006 16:45:33 +0200, Christian Paul Cosinas + wrote: + +> Hi! +> +> How can I speed up my server's performance when I use offset and limit +> clause. +> +> For example I have a query: +> SELECT * FROM table ORDER BY id, name OFFSET 100000 LIMIT 10000 +> +> This query takes a long time about more than 2 minutes. +> +> If my query is: +> SELECT * FROM table ORDER BY id, name OFFSET 50000 LIMIT 10000 +> It takes about 2 seconds. +> +> Thanks +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 9: In versions below 8.0, 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 Wed May 17 08:08:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A3E709FA226 + for ; + Wed, 17 May 2006 08:08:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 74462-09 + for ; + Wed, 17 May 2006 08:07:57 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from brmea-mail-3.sun.com (brmea-mail-3.Sun.COM [192.18.98.34]) + by postgresql.org (Postfix) with ESMTP id EFB0E9F9C18 + for ; + Wed, 17 May 2006 08:07:56 -0300 (ADT) +Received: from fe-amer-05.sun.com ([192.18.108.179]) + by brmea-mail-3.sun.com (8.12.10/8.12.9) with ESMTP id k4HB7tKe016645 + for ; + Wed, 17 May 2006 05:07:55 -0600 (MDT) +Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + id <0IZE00J01NE06B00@mail-amer.sun.com> (original mail from + J.K.Shah@Sun.COM) for pgsql-performance@postgresql.org; + Wed, 17 May 2006 05:07:55 -0600 (MDT) +Received: from [129.156.85.212] by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + with ESMTPSA id <0IZE009BLPL6AND2@mail-amer.sun.com>; Wed, + 17 May 2006 05:07:55 -0600 (MDT) +Date: Wed, 17 May 2006 12:07:53 +0100 +From: "Jignesh K. Shah" +Subject: Re: Pgsql (and mysql) benchmark on T2000/Solaris and some +In-reply-to: <446A1520.2020601@tweakers.net> +To: Arjen van der Meijden +Cc: pgsql-performance@postgresql.org +Message-id: <446B0409.7050902@sun.com> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +References: <44699C6C.80302@tweakers.net> <4469D173.50406@sun.com> + <4469D986.6090300@tweakers.net> <4469F55A.7040004@sun.com> + <446A1520.2020601@tweakers.net> +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050322) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/358 +X-Sequence-Number: 19145 + +You usertime is way too high for T2000... + +If you have a 6 core machine with 24 threads, it says all 24 threads are +reported as being busy with iostat output. + +Best way to debug this is use + +prstat -amL +(or if you are dumping it in a file prstat -amLc > prstat.txt) + +and find the pids with high user cpu time and then use the usrcall.d on +few of those pids. + +Also how many database connections do you have and what's the type of +query run by each connection? + +-Jignesh + + + +Arjen van der Meijden wrote: +> Hi Jignesh, +> +> The settings from that 'special T2000 dvd' differed from the recommended +> settings on the website you provided. But I don't see much difference in +> performance with any of the adjustments, it appears to be more or less +> the same. +> +> Here are a few iostat lines by the way: +> +> sd0 sd1 sd2 nfs1 cpu +> kps tps serv kps tps serv kps tps serv kps tps serv us sy wt id +> 7 1 12 958 50 35 0 0 7 0 0 0 13 1 0 85 +> 0 0 0 2353 296 3 0 0 0 0 0 0 92 7 0 1 +> 0 0 0 2062 326 2 0 0 0 0 0 0 93 7 0 0 +> 1 1 1 1575 350 0 0 0 0 0 0 0 92 7 0 1 +> 0 0 0 1628 362 0 0 0 0 0 0 0 92 8 0 1 +> +> It appears to be doing a little less kps/tps on sd1 when I restore my +> own postgresql.conf-settings. (default wal/checkpoints, 20k buffers, 2k +> work mem). +> +> Is it possible to trace the stack's for semsys, like the memcpy-traces, +> or are those of no interest here? +> +> Best regards, +> +> Arjen +> +> +> On 16-5-2006 17:52, Jignesh K. Shah wrote: +> +>> Hi Arjen, +>> +>> Can you send me my colleagues's names in a private email? +>> +>> One of the drawbacks of the syscall.d script is relative timings and +>> hence if system CPU usage is very low, it gives the relative weightage +>> about what portion in that low is associated with what call.. So even +>> if you have say..1% system time.. it says that most of it was IO +>> related or semsys related. So iostat output with -c option to include +>> CPU times helps to put it in the right perspective. +>> +>> +>> Also do check the tunables mentioned and make sure they are set. +>> +>> Regards, +>> Jignesh +>> +>> +>> Arjen van der Meijden wrote: +>> +>>> Hi Jignesh, +>>> +>>> Jignesh K. Shah wrote: +>>> +>>>> Hi Arjen, +>>>> +>>>> Looking at your outputs...of syscall and usrcall it looks like +>>>> +>>>> * Spending too much time in semsys .... which means you have too +>>>> many connections and they are contending to get a lock.. which is +>>>> potentially the WAL log lock +>>>> +>>>> * llseek is high which means you can obviously gain a bit with the +>>>> right file system/files tuning by caching them right. +>>>> +>>>> Have you set the values for Solaris for T2000 tuned for Postgresql? +>>> +>>> +>>> +>>> Not particularly, we got a "special T2000 Solaris dvd" from your +>>> colleagues here in the Netherlands and installed that (actually one +>>> of your colleagues did). Doing so all the "better default" +>>> /etc/system-settings are supposed to be set. I haven't really checked +>>> that they are, since two of your colleagues have been working on it +>>> for the mysql-version of the benchmark and I assumed they'd have +>>> verified that. +>>> +>>>> Check out the tunables from the following URL +>>>> +>>>> http://www.sun.com/servers/coolthreads/tnb/applications_postgresql.jsp +>>>> +>>>> Try specially the /etc/system and postgresql.conf changes and see +>>>> if it changes/improves your performance. +>>> +>>> +>>> +>>> I will see that those tunables are verified to be set. +>>> +>>> I am a bit surprised though about your remarks, since they'd point at +>>> the I/O being in the way? But we only have about 600k/sec i/o +>>> according to vmstat. The database easily fits in memory. +>>> In total I logged about 500k queries of which only 70k where altering +>>> queries, of which almost all where inserts in log-tables which aren't +>>> actively read in this benchmark. +>>> +>>> But I'll give it a try. +>>> +>>> Best regards, +>>> +>>> Arjen +>>> +>>>> +>>>> Arjen van der Meijden wrote: +>>>> +>>>>> Hi List, +>>>>> +>>>>> In the past few weeks we have been developing a read-heavy +>>>>> mysql-benchmark to have an alternative take at +>>>>> cpu/platform-performance. Not really to have a look at how fast +>>>>> mysql can be. +>>>>> +>>>>> This benchmark runs on mysql 4.1.x, 5.0.x and 5.1.x and is modelled +>>>>> after our website's production database and the load generated on +>>>>> it is modelled after a simplified version of our visitor behaviour. +>>>>> +>>>>> Long story short, we think the test is a nice example of the +>>>>> relatively lightweight, read-heavy webapplications out there and +>>>>> therefore decided to have a go at postgresql as well. +>>>>> Of course the queries and indexes have been adjusted to (by our +>>>>> knowledge) best suit postgresql, while maintaining the same output +>>>>> to the application/interface layer. While the initial structure +>>>>> only got postgresql at about half the performance of mysql 4.1.x, +>>>>> the current version of our postgresql-benchmark has quite similar +>>>>> results to mysql 4.1.x, but both are quite a bit slower than 5.0.x +>>>>> (I think its about 30-40% faster). +>>>>> +>>>>> Since the results from those benchmarks are not yet public (they +>>>>> will be put together in a story at our website), I won't go into +>>>>> too much details about this benchmark. +>>>>> +>>>>> Currently we're having a look at a Sun T2000 and will be looking at +>>>>> will be looking at other machines as well in the future. We are +>>>>> running the sun-release of postgresql 8.1.3 on that T2000 now, but +>>>>> are looking at compiling the cvs-head version (for its +>>>>> index-root-cache) somewhere this week. +>>>>> +>>>>> My guess is there are a few people on this list who are interested +>>>>> in some dtrace results taken during our benchmarks on that T2000. +>>>>> Although my knowledge of both Solaris and Dtrace are very limited, +>>>>> I already took some samples of the system and user calls. I used +>>>>> Jignesh Shah's scripts for that: +>>>>> http://blogs.sun.com/roller/page/jkshah?entry=profiling_postgresql_using_dtrace_on +>>>>> +>>>>> +>>>>> You can find the samples here: +>>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/syscall.log +>>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/usrcall.log +>>>>> +>>>>> And I also did the memcpy-scripts, here: +>>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/memcpysize.log +>>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/memcpystack.log +>>>>> (this last log is 3.5MB) +>>>>> +>>>>> If anyone is interested in some more dtrace results, let me know +>>>>> (and tell me what commands to run ;-) ). +>>>>> +>>>>> Best regards, +>>>>> +>>>>> Arjen +>>>>> +>>>>> ---------------------------(end of +>>>>> broadcast)--------------------------- +>>>>> TIP 3: Have you checked our extensive FAQ? +>>>>> +>>>>> http://www.postgresql.org/docs/faq +>>>> +>>>> +>>>> +>>>> ---------------------------(end of +>>>> broadcast)--------------------------- +>>>> TIP 6: explain analyze is your friend +>>>> +>>> +>>> ---------------------------(end of broadcast)--------------------------- +>>> TIP 2: Don't 'kill -9' the postmaster +>> +>> +>> + +From pgsql-performance-owner@postgresql.org Wed May 17 08:54:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id DFC759FA226 + for ; + Wed, 17 May 2006 08:54:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 87745-08 + for ; + Wed, 17 May 2006 08:54:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gollum.cambrium.nl (mx1.cambrium.nl [217.19.16.130]) + by postgresql.org (Postfix) with SMTP id B9CC99F9C18 + for ; + Wed, 17 May 2006 08:54:00 -0300 (ADT) +Received: (qmail 25729 invoked from network); 17 May 2006 11:53:58 -0000 +Received: from office.tweakers.net (HELO ?10.0.0.157?) (84.245.2.46) + by gollum.cambrium.nl with SMTP; 17 May 2006 11:53:58 -0000 +Message-ID: <446B0ED2.5030909@tweakers.net> +Date: Wed, 17 May 2006 13:53:54 +0200 +From: Arjen van der Meijden +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: "Jignesh K. Shah" +CC: pgsql-performance@postgresql.org +Subject: Re: Pgsql (and mysql) benchmark on T2000/Solaris and some +References: <44699C6C.80302@tweakers.net> <4469D173.50406@sun.com> + <4469D986.6090300@tweakers.net> <4469F55A.7040004@sun.com> + <446A1520.2020601@tweakers.net> <446B0409.7050902@sun.com> +In-Reply-To: <446B0409.7050902@sun.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/359 +X-Sequence-Number: 19146 + +We have the 4 core machine. However, these numbers are taken during a +benchmark, not normal work load. So the output should display the system +being working fully ;) + +So its postgres doing a lot of work and you already had a look at the +usrcall for that. + +The benchmark just tries to do the queries for "random page visits". +This totals up to about some 80 different queries being executed with +mostly random parameters. The workload is generated using php so there +are no connection pools, nor prepared statements. + +The queries vary, but are all relatively lightweight queries with less +than 6 or 7 joinable tables. Almost all queries can use indexes. Most +tables are under a few MB of data, although there are a few larger than +that. Most records are relatively small, consisting of mostly numbers +(id's and such). + +The results presented here was with 25 concurrent connections. + +Best regards, + +Arjen + + +Jignesh K. Shah wrote: +> You usertime is way too high for T2000... +> +> If you have a 6 core machine with 24 threads, it says all 24 threads are +> reported as being busy with iostat output. +> +> Best way to debug this is use +> +> prstat -amL +> (or if you are dumping it in a file prstat -amLc > prstat.txt) +> +> and find the pids with high user cpu time and then use the usrcall.d on +> few of those pids. +> +> Also how many database connections do you have and what's the type of +> query run by each connection? +> +> -Jignesh +> +> +> +> Arjen van der Meijden wrote: +>> Hi Jignesh, +>> +>> The settings from that 'special T2000 dvd' differed from the +>> recommended settings on the website you provided. But I don't see much +>> difference in performance with any of the adjustments, it appears to +>> be more or less the same. +>> +>> Here are a few iostat lines by the way: +>> +>> sd0 sd1 sd2 nfs1 cpu +>> kps tps serv kps tps serv kps tps serv kps tps serv us sy wt id +>> 7 1 12 958 50 35 0 0 7 0 0 0 13 1 0 85 +>> 0 0 0 2353 296 3 0 0 0 0 0 0 92 7 0 1 +>> 0 0 0 2062 326 2 0 0 0 0 0 0 93 7 0 0 +>> 1 1 1 1575 350 0 0 0 0 0 0 0 92 7 0 1 +>> 0 0 0 1628 362 0 0 0 0 0 0 0 92 8 0 1 +>> +>> It appears to be doing a little less kps/tps on sd1 when I restore my +>> own postgresql.conf-settings. (default wal/checkpoints, 20k buffers, +>> 2k work mem). +>> +>> Is it possible to trace the stack's for semsys, like the +>> memcpy-traces, or are those of no interest here? +>> +>> Best regards, +>> +>> Arjen +>> +>> +>> On 16-5-2006 17:52, Jignesh K. Shah wrote: +>> +>>> Hi Arjen, +>>> +>>> Can you send me my colleagues's names in a private email? +>>> +>>> One of the drawbacks of the syscall.d script is relative timings and +>>> hence if system CPU usage is very low, it gives the relative +>>> weightage about what portion in that low is associated with what +>>> call.. So even if you have say..1% system time.. it says that most of +>>> it was IO related or semsys related. So iostat output with -c option +>>> to include CPU times helps to put it in the right perspective. +>>> +>>> +>>> Also do check the tunables mentioned and make sure they are set. +>>> +>>> Regards, +>>> Jignesh +>>> +>>> +>>> Arjen van der Meijden wrote: +>>> +>>>> Hi Jignesh, +>>>> +>>>> Jignesh K. Shah wrote: +>>>> +>>>>> Hi Arjen, +>>>>> +>>>>> Looking at your outputs...of syscall and usrcall it looks like +>>>>> +>>>>> * Spending too much time in semsys .... which means you have too +>>>>> many connections and they are contending to get a lock.. which is +>>>>> potentially the WAL log lock +>>>>> +>>>>> * llseek is high which means you can obviously gain a bit with the +>>>>> right file system/files tuning by caching them right. +>>>>> +>>>>> Have you set the values for Solaris for T2000 tuned for Postgresql? +>>>> +>>>> +>>>> +>>>> Not particularly, we got a "special T2000 Solaris dvd" from your +>>>> colleagues here in the Netherlands and installed that (actually one +>>>> of your colleagues did). Doing so all the "better default" +>>>> /etc/system-settings are supposed to be set. I haven't really +>>>> checked that they are, since two of your colleagues have been +>>>> working on it for the mysql-version of the benchmark and I assumed +>>>> they'd have verified that. +>>>> +>>>>> Check out the tunables from the following URL +>>>>> +>>>>> http://www.sun.com/servers/coolthreads/tnb/applications_postgresql.jsp +>>>>> +>>>>> Try specially the /etc/system and postgresql.conf changes and see +>>>>> if it changes/improves your performance. +>>>> +>>>> +>>>> +>>>> I will see that those tunables are verified to be set. +>>>> +>>>> I am a bit surprised though about your remarks, since they'd point +>>>> at the I/O being in the way? But we only have about 600k/sec i/o +>>>> according to vmstat. The database easily fits in memory. +>>>> In total I logged about 500k queries of which only 70k where +>>>> altering queries, of which almost all where inserts in log-tables +>>>> which aren't actively read in this benchmark. +>>>> +>>>> But I'll give it a try. +>>>> +>>>> Best regards, +>>>> +>>>> Arjen +>>>> +>>>>> +>>>>> Arjen van der Meijden wrote: +>>>>> +>>>>>> Hi List, +>>>>>> +>>>>>> In the past few weeks we have been developing a read-heavy +>>>>>> mysql-benchmark to have an alternative take at +>>>>>> cpu/platform-performance. Not really to have a look at how fast +>>>>>> mysql can be. +>>>>>> +>>>>>> This benchmark runs on mysql 4.1.x, 5.0.x and 5.1.x and is +>>>>>> modelled after our website's production database and the load +>>>>>> generated on it is modelled after a simplified version of our +>>>>>> visitor behaviour. +>>>>>> +>>>>>> Long story short, we think the test is a nice example of the +>>>>>> relatively lightweight, read-heavy webapplications out there and +>>>>>> therefore decided to have a go at postgresql as well. +>>>>>> Of course the queries and indexes have been adjusted to (by our +>>>>>> knowledge) best suit postgresql, while maintaining the same output +>>>>>> to the application/interface layer. While the initial structure +>>>>>> only got postgresql at about half the performance of mysql 4.1.x, +>>>>>> the current version of our postgresql-benchmark has quite similar +>>>>>> results to mysql 4.1.x, but both are quite a bit slower than 5.0.x +>>>>>> (I think its about 30-40% faster). +>>>>>> +>>>>>> Since the results from those benchmarks are not yet public (they +>>>>>> will be put together in a story at our website), I won't go into +>>>>>> too much details about this benchmark. +>>>>>> +>>>>>> Currently we're having a look at a Sun T2000 and will be looking +>>>>>> at will be looking at other machines as well in the future. We are +>>>>>> running the sun-release of postgresql 8.1.3 on that T2000 now, but +>>>>>> are looking at compiling the cvs-head version (for its +>>>>>> index-root-cache) somewhere this week. +>>>>>> +>>>>>> My guess is there are a few people on this list who are interested +>>>>>> in some dtrace results taken during our benchmarks on that T2000. +>>>>>> Although my knowledge of both Solaris and Dtrace are very limited, +>>>>>> I already took some samples of the system and user calls. I used +>>>>>> Jignesh Shah's scripts for that: +>>>>>> http://blogs.sun.com/roller/page/jkshah?entry=profiling_postgresql_using_dtrace_on +>>>>>> +>>>>>> +>>>>>> You can find the samples here: +>>>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/syscall.log +>>>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/usrcall.log +>>>>>> +>>>>>> And I also did the memcpy-scripts, here: +>>>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/memcpysize.log +>>>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/memcpystack.log +>>>>>> (this last log is 3.5MB) +>>>>>> +>>>>>> If anyone is interested in some more dtrace results, let me know +>>>>>> (and tell me what commands to run ;-) ). +>>>>>> +>>>>>> Best regards, +>>>>>> +>>>>>> Arjen +>>>>>> +>>>>>> ---------------------------(end of +>>>>>> broadcast)--------------------------- +>>>>>> TIP 3: Have you checked our extensive FAQ? +>>>>>> +>>>>>> http://www.postgresql.org/docs/faq +>>>>> +>>>>> +>>>>> +>>>>> ---------------------------(end of +>>>>> broadcast)--------------------------- +>>>>> TIP 6: explain analyze is your friend +>>>>> +>>>> +>>>> ---------------------------(end of +>>>> broadcast)--------------------------- +>>>> TIP 2: Don't 'kill -9' the postmaster +>>> +>>> +>>> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 6: explain analyze is your friend +> + +From pgsql-performance-owner@postgresql.org Wed May 17 12:14:59 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A46BB9FA226 + for ; + Wed, 17 May 2006 12:14:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 35701-05 + for ; + Wed, 17 May 2006 12:14:45 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from brmea-mail-1.sun.com (brmea-mail-1.Sun.COM [192.18.98.31]) + by postgresql.org (Postfix) with ESMTP id C03D79F9C18 + for ; + Wed, 17 May 2006 12:14:44 -0300 (ADT) +Received: from fe-amer-01.sun.com ([192.18.108.175]) + by brmea-mail-1.sun.com (8.12.10/8.12.9) with ESMTP id k4HFEhSX022852 + for ; + Wed, 17 May 2006 09:14:43 -0600 (MDT) +Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + id <0IZF00J0110I6000@mail-amer.sun.com> (original mail from + J.K.Shah@Sun.COM) for pgsql-performance@postgresql.org; + Wed, 17 May 2006 09:14:43 -0600 (MDT) +Received: from [129.156.85.212] by mail-amer.sun.com + (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) + with ESMTPSA id <0IZF001D010HCWT0@mail-amer.sun.com>; Wed, + 17 May 2006 09:14:42 -0600 (MDT) +Date: Wed, 17 May 2006 16:14:41 +0100 +From: "Jignesh K. Shah" +Subject: Re: Pgsql (and mysql) benchmark on T2000/Solaris and some +In-reply-to: <446B0ED2.5030909@tweakers.net> +To: Arjen van der Meijden +Cc: pgsql-performance@postgresql.org +Message-id: <446B3DE1.1060705@sun.com> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7BIT +X-Accept-Language: en-us, en +References: <44699C6C.80302@tweakers.net> <4469D173.50406@sun.com> + <4469D986.6090300@tweakers.net> <4469F55A.7040004@sun.com> + <446A1520.2020601@tweakers.net> <446B0409.7050902@sun.com> + <446B0ED2.5030909@tweakers.net> +User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050322) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/360 +X-Sequence-Number: 19147 + +I have seen MemoryContextSwitchTo taking time before.. However I am not +sure why would it take so much CPU time? +Maybe that function does not work efficiently on Solaris? + +Also I donot have much idea about slot_getattr. + +Anybody else? (Other option is to use "collect -p $pid" experiments to +gather the data to figure out what instruction is causing the high CPU +usage) Maybe the Sun engineers out there can help out + +-Jignesh + + +Arjen van der Meijden wrote: +> We have the 4 core machine. However, these numbers are taken during a +> benchmark, not normal work load. So the output should display the system +> being working fully ;) +> +> So its postgres doing a lot of work and you already had a look at the +> usrcall for that. +> +> The benchmark just tries to do the queries for "random page visits". +> This totals up to about some 80 different queries being executed with +> mostly random parameters. The workload is generated using php so there +> are no connection pools, nor prepared statements. +> +> The queries vary, but are all relatively lightweight queries with less +> than 6 or 7 joinable tables. Almost all queries can use indexes. Most +> tables are under a few MB of data, although there are a few larger than +> that. Most records are relatively small, consisting of mostly numbers +> (id's and such). +> +> The results presented here was with 25 concurrent connections. +> +> Best regards, +> +> Arjen +> +> +> Jignesh K. Shah wrote: +> +>> You usertime is way too high for T2000... +>> +>> If you have a 6 core machine with 24 threads, it says all 24 threads +>> are reported as being busy with iostat output. +>> +>> Best way to debug this is use +>> +>> prstat -amL +>> (or if you are dumping it in a file prstat -amLc > prstat.txt) +>> +>> and find the pids with high user cpu time and then use the usrcall.d +>> on few of those pids. +>> +>> Also how many database connections do you have and what's the type of +>> query run by each connection? +>> +>> -Jignesh +>> +>> +>> +>> Arjen van der Meijden wrote: +>> +>>> Hi Jignesh, +>>> +>>> The settings from that 'special T2000 dvd' differed from the +>>> recommended settings on the website you provided. But I don't see +>>> much difference in performance with any of the adjustments, it +>>> appears to be more or less the same. +>>> +>>> Here are a few iostat lines by the way: +>>> +>>> sd0 sd1 sd2 nfs1 cpu +>>> kps tps serv kps tps serv kps tps serv kps tps serv us sy wt id +>>> 7 1 12 958 50 35 0 0 7 0 0 0 13 1 0 85 +>>> 0 0 0 2353 296 3 0 0 0 0 0 0 92 7 0 1 +>>> 0 0 0 2062 326 2 0 0 0 0 0 0 93 7 0 0 +>>> 1 1 1 1575 350 0 0 0 0 0 0 0 92 7 0 1 +>>> 0 0 0 1628 362 0 0 0 0 0 0 0 92 8 0 1 +>>> +>>> It appears to be doing a little less kps/tps on sd1 when I restore my +>>> own postgresql.conf-settings. (default wal/checkpoints, 20k buffers, +>>> 2k work mem). +>>> +>>> Is it possible to trace the stack's for semsys, like the +>>> memcpy-traces, or are those of no interest here? +>>> +>>> Best regards, +>>> +>>> Arjen +>>> +>>> +>>> On 16-5-2006 17:52, Jignesh K. Shah wrote: +>>> +>>>> Hi Arjen, +>>>> +>>>> Can you send me my colleagues's names in a private email? +>>>> +>>>> One of the drawbacks of the syscall.d script is relative timings and +>>>> hence if system CPU usage is very low, it gives the relative +>>>> weightage about what portion in that low is associated with what +>>>> call.. So even if you have say..1% system time.. it says that most +>>>> of it was IO related or semsys related. So iostat output with -c +>>>> option to include CPU times helps to put it in the right perspective. +>>>> +>>>> +>>>> Also do check the tunables mentioned and make sure they are set. +>>>> +>>>> Regards, +>>>> Jignesh +>>>> +>>>> +>>>> Arjen van der Meijden wrote: +>>>> +>>>>> Hi Jignesh, +>>>>> +>>>>> Jignesh K. Shah wrote: +>>>>> +>>>>>> Hi Arjen, +>>>>>> +>>>>>> Looking at your outputs...of syscall and usrcall it looks like +>>>>>> +>>>>>> * Spending too much time in semsys .... which means you have too +>>>>>> many connections and they are contending to get a lock.. which is +>>>>>> potentially the WAL log lock +>>>>>> +>>>>>> * llseek is high which means you can obviously gain a bit with the +>>>>>> right file system/files tuning by caching them right. +>>>>>> +>>>>>> Have you set the values for Solaris for T2000 tuned for Postgresql? +>>>>> +>>>>> +>>>>> +>>>>> +>>>>> Not particularly, we got a "special T2000 Solaris dvd" from your +>>>>> colleagues here in the Netherlands and installed that (actually one +>>>>> of your colleagues did). Doing so all the "better default" +>>>>> /etc/system-settings are supposed to be set. I haven't really +>>>>> checked that they are, since two of your colleagues have been +>>>>> working on it for the mysql-version of the benchmark and I assumed +>>>>> they'd have verified that. +>>>>> +>>>>>> Check out the tunables from the following URL +>>>>>> +>>>>>> http://www.sun.com/servers/coolthreads/tnb/applications_postgresql.jsp +>>>>>> +>>>>>> +>>>>>> Try specially the /etc/system and postgresql.conf changes and see +>>>>>> if it changes/improves your performance. +>>>>> +>>>>> +>>>>> +>>>>> +>>>>> I will see that those tunables are verified to be set. +>>>>> +>>>>> I am a bit surprised though about your remarks, since they'd point +>>>>> at the I/O being in the way? But we only have about 600k/sec i/o +>>>>> according to vmstat. The database easily fits in memory. +>>>>> In total I logged about 500k queries of which only 70k where +>>>>> altering queries, of which almost all where inserts in log-tables +>>>>> which aren't actively read in this benchmark. +>>>>> +>>>>> But I'll give it a try. +>>>>> +>>>>> Best regards, +>>>>> +>>>>> Arjen +>>>>> +>>>>>> +>>>>>> Arjen van der Meijden wrote: +>>>>>> +>>>>>>> Hi List, +>>>>>>> +>>>>>>> In the past few weeks we have been developing a read-heavy +>>>>>>> mysql-benchmark to have an alternative take at +>>>>>>> cpu/platform-performance. Not really to have a look at how fast +>>>>>>> mysql can be. +>>>>>>> +>>>>>>> This benchmark runs on mysql 4.1.x, 5.0.x and 5.1.x and is +>>>>>>> modelled after our website's production database and the load +>>>>>>> generated on it is modelled after a simplified version of our +>>>>>>> visitor behaviour. +>>>>>>> +>>>>>>> Long story short, we think the test is a nice example of the +>>>>>>> relatively lightweight, read-heavy webapplications out there and +>>>>>>> therefore decided to have a go at postgresql as well. +>>>>>>> Of course the queries and indexes have been adjusted to (by our +>>>>>>> knowledge) best suit postgresql, while maintaining the same +>>>>>>> output to the application/interface layer. While the initial +>>>>>>> structure only got postgresql at about half the performance of +>>>>>>> mysql 4.1.x, the current version of our postgresql-benchmark has +>>>>>>> quite similar results to mysql 4.1.x, but both are quite a bit +>>>>>>> slower than 5.0.x (I think its about 30-40% faster). +>>>>>>> +>>>>>>> Since the results from those benchmarks are not yet public (they +>>>>>>> will be put together in a story at our website), I won't go into +>>>>>>> too much details about this benchmark. +>>>>>>> +>>>>>>> Currently we're having a look at a Sun T2000 and will be looking +>>>>>>> at will be looking at other machines as well in the future. We +>>>>>>> are running the sun-release of postgresql 8.1.3 on that T2000 +>>>>>>> now, but are looking at compiling the cvs-head version (for its +>>>>>>> index-root-cache) somewhere this week. +>>>>>>> +>>>>>>> My guess is there are a few people on this list who are +>>>>>>> interested in some dtrace results taken during our benchmarks on +>>>>>>> that T2000. +>>>>>>> Although my knowledge of both Solaris and Dtrace are very +>>>>>>> limited, I already took some samples of the system and user +>>>>>>> calls. I used Jignesh Shah's scripts for that: +>>>>>>> http://blogs.sun.com/roller/page/jkshah?entry=profiling_postgresql_using_dtrace_on +>>>>>>> +>>>>>>> +>>>>>>> You can find the samples here: +>>>>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/syscall.log +>>>>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/usrcall.log +>>>>>>> +>>>>>>> And I also did the memcpy-scripts, here: +>>>>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/memcpysize.log +>>>>>>> http://achelois.tweakers.net/~acm/pgsql-t2000/memcpystack.log +>>>>>>> (this last log is 3.5MB) +>>>>>>> +>>>>>>> If anyone is interested in some more dtrace results, let me know +>>>>>>> (and tell me what commands to run ;-) ). +>>>>>>> +>>>>>>> Best regards, +>>>>>>> +>>>>>>> Arjen +>>>>>>> +>>>>>>> ---------------------------(end of +>>>>>>> broadcast)--------------------------- +>>>>>>> TIP 3: Have you checked our extensive FAQ? +>>>>>>> +>>>>>>> http://www.postgresql.org/docs/faq +>>>>>> +>>>>>> +>>>>>> +>>>>>> +>>>>>> ---------------------------(end of +>>>>>> broadcast)--------------------------- +>>>>>> TIP 6: explain analyze is your friend +>>>>>> +>>>>> +>>>>> ---------------------------(end of +>>>>> broadcast)--------------------------- +>>>>> TIP 2: Don't 'kill -9' the postmaster +>>>> +>>>> +>>>> +>>>> +>> +>> ---------------------------(end of broadcast)--------------------------- +>> TIP 6: explain analyze is your friend +>> + +From pgsql-performance-owner@postgresql.org Wed May 17 12:21:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5BF339FA226 + for ; + Wed, 17 May 2006 12:21:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 36294-04 + for ; + Wed, 17 May 2006 12:21:29 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.rentalia.net (mail.rentalia.com [213.192.209.8]) + by postgresql.org (Postfix) with ESMTP id DEC749F9C18 + for ; + Wed, 17 May 2006 12:21:27 -0300 (ADT) +Received: (qmail 30874 invoked by uid 514); 17 May 2006 17:21:23 +0200 +Received: from 62.37.217.203 by rigodon (envelope-from , + uid 512) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1284. spamassassin: 3.0.2. perlscan: 1.25-st-qms. + Clear:RC:0(62.37.217.203):SA:0(-2.2/5.0):. + Processed in 4.833894 secs); 17 May 2006 15:21:23 -0000 +X-Antivirus-MYDOMAIN-Mail-From: ruben@rentalia.com via rigodon +X-Antivirus-MYDOMAIN: 1.25-st-qms (Clear:RC:0(62.37.217.203):SA:0(-2.2/5.0):. + Processed in 4.833894 secs Process 30806) +Received: from 62-37-217-203.mad1.adsl.uni2.es (HELO ?192.168.2.28?) + (ruben@rentalia.com@62.37.217.203) + by mail.rentalia.net with SMTP; 17 May 2006 17:21:18 +0200 +Message-ID: <446B3F6A.9070205@rentalia.com> +Date: Wed, 17 May 2006 17:21:14 +0200 +From: Ruben Rubio Rey +User-Agent: Mozilla Thunderbird 1.0.8 (X11/20060503) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: SQL CPU time usage +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/361 +X-Sequence-Number: 19148 + +Hi, + +I have a web page, that executes several SQLs. + +So, I would like to know witch one of those SQLs consumes more CPU. +For example, +I have SQL1 that is executed in 1.2 secs and a SQL2 that is executed in +200 ms. + +But SQL2 is executed 25 times and SQL1 is executed 1 time, so really +SQL2 consumes more CPU time. + +Is there any way to know this? +I have think that logging all SQLs and then cheking it is a way to do it +... any other idea? + +Thanks in advance + +From pgsql-performance-owner@postgresql.org Wed May 17 12:51:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 55BEB9F9C18 + for ; + Wed, 17 May 2006 12:51:51 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 40187-05 + for ; + Wed, 17 May 2006 12:51:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 034019FA226 + for ; + Wed, 17 May 2006 12:51:41 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 7E28656427; Wed, 17 May 2006 10:51:40 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 17 May 2006 10:51:40 -0500 +Date: Wed, 17 May 2006 10:51:40 -0500 +From: "Jim C. Nasby" +To: David Wheeler +Cc: Christopher Kings-Lynne , + Tom Lane , + pgsql-performance +Subject: Re: IMMUTABLE? +Message-ID: <20060517155139.GS26212@pervasive.com> +References: <2D4C0FA5-DB75-45EA-91D2-7B4F6DD55083@kineticode.com> + <5211.1147749711@sss.pgh.pa.us> + <3F0CF576-8C6F-433C-9942-BB36F4E1A194@kineticode.com> + <5894.1147753901@sss.pgh.pa.us> + <719F1E6C-4695-4FD2-A73B-0E3AE173B8F0@kineticode.com> + <446A7C69.5030905@calorieking.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060517:david@kineticode.com::SLu1YGsn3HNNS6LP:00000000000000000 + 0000000000000000000000001CgK +X-Hashcash: + 1:20:060517:chris.kings-lynne@calorieking.com::2IFk6BgqQXVd3poS:0000 + 0000000000000000000000000I3/ +X-Hashcash: + 1:20:060517:tgl@sss.pgh.pa.us::Ck8Bal41/a3s2Avd:00000000000000000000 + 000000000000000000000000388g +X-Hashcash: + 1:20:060517:pgsql-performance@postgresql.org::4ttUBr6bJmWGrZtg:00000 + 0000000000000000000000000fCZ +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/362 +X-Sequence-Number: 19149 + +On Tue, May 16, 2006 at 07:08:51PM -0700, David Wheeler wrote: +> On May 16, 2006, at 18:29, Christopher Kings-Lynne wrote: +> +> >>Yes, but there are definitely programming cases where memoization/ +> >>caching definitely helps. And it's easy to tell for a given +> >>function whether or not it really helps by simply trying it with +> >>CACHED and without. +> >>Would this be a simple thing to implement? +> > +> >It's called a "table" :) +> +> http://www.justatheory.com/computers/databases/postgresql/ +> higher_order_plpgsql.html +> +> Yes, I know. :-P But it'd be easier to have a CACHED keyword, of course. + +Rather than worrying about a generic form of memoization, what would be +extremely valuable would be to improve detection of the same function +being used multiple times in a query, ie: + +SELECT moo(x), moo(x)/2 FROM table; + +AFAIK PostgreSQL will currently execute moo(x) twice. Even if it knows +how to optimize this brain-dead example, I think there are other +examples it can't optimize right now. Having a much simpler memoization +scheme that only works on a tuple-by-tuple basis would probably +eliminate a lot of those (It wouldn't work for any executor node that +has to read it's entire input before returning anything, though, such as +sort). +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 17 12:55:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3ECAD9FA4F2 + for ; + Wed, 17 May 2006 12:55:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 38187-08 + for ; + Wed, 17 May 2006 12:55:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moonunit2.moonview.localnet (wsip-70-167-125-69.sd.sd.cox.net + [70.167.125.69]) + by postgresql.org (Postfix) with ESMTP id 074249FA226 + for ; + Wed, 17 May 2006 12:55:02 -0300 (ADT) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k4HG3eA4017740 + for ; Wed, 17 May 2006 09:03:40 -0700 +Message-ID: <446B474C.2050803@modgraph-usa.com> +Date: Wed, 17 May 2006 08:54:52 -0700 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +CC: pgsql-performance@postgresql.org +Subject: Optimizer: limit not taken into account +References: <44699C6C.80302@tweakers.net> <4469D173.50406@sun.com> + <4469D986.6090300@tweakers.net> <4469F55A.7040004@sun.com> + <446A1520.2020601@tweakers.net> <446B0409.7050902@sun.com> + <446B0ED2.5030909@tweakers.net> +In-Reply-To: <446B0ED2.5030909@tweakers.net> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/363 +X-Sequence-Number: 19150 + +Here's a "corner case" that might interest someone. It tripped up one of our programmers. + +We have a table with > 10 million rows. The ID column is indexed, the table has been vacuum/analyzed. Compare these two queries: + + select * from tbl where id >= 10000000 limit 1; + select * from tbl where id >= 10000000 order by id limit 1; + +The first takes 4 seconds, and uses a full table scan. The second takes 32 msec and uses the index. +Details are below. + +I understand why the planner makes the choices it does -- the "id > 10000000" isn't very selective and under normal circumstances a full table scan is probably the right choice. But the "limit 1" apparently doesn't alter the planner's strategy at all. We were surprised by this. + +Adding the "order by" was a simple solution. + +Craig + + + +pg=> explain analyze select url, url_digest from url_queue where priority >= 10000000 limit 1; + QUERY PLAN +------------------------------------------------------------------------------------------ + Limit (cost=0.00..0.65 rows=1 width=108) (actual time=4036.113..4036.117 rows=1 loops=1) + -> Seq Scan on url_queue (cost=0.00..391254.35 rows=606176 width=108) (actual time=4036.101..4036.101 rows=1 loops=1) + Filter: (priority >= 10000000) + Total runtime: 4036.200 ms +(4 rows) + +pg=> explain analyze select url, url_digest from url_queue where priority >= 10000000 order by priority limit 1; + QUERY PLAN +-------------------------------------------------------------------------------------- + Limit (cost=0.00..2.38 rows=1 width=112) (actual time=32.445..32.448 rows=1 loops=1) + -> Index Scan using url_queue_priority on url_queue (cost=0.00..1440200.41 rows=606176 width=112) (actual time=32.434..32.434 rows=1 loops=1) + Index Cond: (priority >= 10000000) + Total runtime: 32.566 ms + +From pgsql-performance-owner@postgresql.org Wed May 17 13:24:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4AC989FA2C8 + for ; + Wed, 17 May 2006 13:24:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 44028-08 + for ; + Wed, 17 May 2006 13:24:07 -0300 (ADT) +X-Greylist: delayed 00:05:16.003341 by SQLgrey- +Received: from mail.wordbank.com (mail.wordbank.com [213.86.82.65]) + by postgresql.org (Postfix) with ESMTP id 28EF39F944D + for ; + Wed, 17 May 2006 13:24:06 -0300 (ADT) +Received: from 10.1.1.50 by mail.wordbank.com ([10.1.1.10]) with ESMTP for + ; Wed, 17 May 2006 17:18:09 +0100 +Mime-Version: 1.0 (Apple Message framework v750) +In-Reply-To: <446B3F6A.9070205@rentalia.com> +References: <446B3F6A.9070205@rentalia.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <25265881-37A8-4CD4-952F-3E7F4CE97F4D@wordbank.com> +Content-Transfer-Encoding: 7bit +From: john_oshea@wordbank.com +Subject: Re: SQL CPU time usage +Date: Wed, 17 May 2006 17:18:30 +0100 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.750) +X-Authenticated-Sender: john_oshea +X-Server: VPOP3 V1.5.4 - Registered +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/364 +X-Sequence-Number: 19151 + +On 17 May 2006, at 16:21, Ruben Rubio Rey wrote: + +> I have a web page, that executes several SQLs. +> +> So, I would like to know witch one of those SQLs consumes more CPU. +> For example, +> I have SQL1 that is executed in 1.2 secs and a SQL2 that is +> executed in 200 ms. +> +> But SQL2 is executed 25 times and SQL1 is executed 1 time, so +> really SQL2 consumes more CPU time. +> +> Is there any way to know this? +> I have think that logging all SQLs and then cheking it is a way to +> do it ... any other idea? + +Practical Query Analysis: does +exactly that (scan historic logs). Very nice indeed and more than +worth the money (it's BSD-licensed) + +-- +John O'Shea +Wordbank Limited +33 Charlotte Street, London W1T 1RR +Direct line: +44 (0) 20 7903 8829 +Fax: +44 (0) 20 7903 8888 + + + + +From pgsql-performance-owner@postgresql.org Wed May 17 14:43:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A36199FA279 + for ; + Wed, 17 May 2006 14:43:03 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 70029-06 + for ; + Wed, 17 May 2006 14:42:55 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id F36B49F944D + for ; + Wed, 17 May 2006 14:42:54 -0300 (ADT) +Received: (qmail 19653 invoked by uid 500); 17 May 2006 17:44:26 -0000 +Date: Wed, 17 May 2006 12:44:26 -0500 +From: Bruno Wolff III +To: "Craig A. James" +Cc: pgsql-performance@postgresql.org +Subject: Re: Optimizer: limit not taken into account +Message-ID: <20060517174426.GA14567@wolff.to> +Mail-Followup-To: Bruno Wolff III , + "Craig A. James" , + pgsql-performance@postgresql.org +References: <44699C6C.80302@tweakers.net> <4469D173.50406@sun.com> + <4469D986.6090300@tweakers.net> <4469F55A.7040004@sun.com> + <446A1520.2020601@tweakers.net> <446B0409.7050902@sun.com> + <446B0ED2.5030909@tweakers.net> <446B474C.2050803@modgraph-usa.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <446B474C.2050803@modgraph-usa.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/365 +X-Sequence-Number: 19152 + +Please don't reply to previous messages to start new threads. This makes it +harder to find stuff in the archives and may keep people from noticing your +message. + +On Wed, May 17, 2006 at 08:54:52 -0700, + "Craig A. James" wrote: +> Here's a "corner case" that might interest someone. It tripped up one of +> our programmers. +> +> We have a table with > 10 million rows. The ID column is indexed, the +> table has been vacuum/analyzed. Compare these two queries: +> +> select * from tbl where id >= 10000000 limit 1; +> select * from tbl where id >= 10000000 order by id limit 1; +> +> The first takes 4 seconds, and uses a full table scan. The second takes 32 +> msec and uses the index. Details are below. + +I suspect it wasn't intended to be a full table scan. But rather a sequential +scan until it found a matching row. If the data in the table is ordered by +by id, this strategy may not work out well. Where as if the data is randomly +ordered, it would be expected to find a match quickly. + +Have you analyzed the table recently? If the planner has bad stats on the +table, that is going to make it more likely to choose a bad plan. + + +> I understand why the planner makes the choices it does -- the "id > +> 10000000" isn't very selective and under normal circumstances a full table +> scan is probably the right choice. But the "limit 1" apparently doesn't +> alter the planner's strategy at all. We were surprised by this. +> +> Adding the "order by" was a simple solution. +> +> Craig +> +> +> +> pg=> explain analyze select url, url_digest from url_queue where priority +> >= 10000000 limit 1; +> QUERY PLAN +> ------------------------------------------------------------------------------------------ +> Limit (cost=0.00..0.65 rows=1 width=108) (actual time=4036.113..4036.117 +> rows=1 loops=1) +> -> Seq Scan on url_queue (cost=0.00..391254.35 rows=606176 width=108) +> (actual time=4036.101..4036.101 rows=1 loops=1) +> Filter: (priority >= 10000000) +> Total runtime: 4036.200 ms +> (4 rows) +> +> pg=> explain analyze select url, url_digest from url_queue where priority +> >= 10000000 order by priority limit 1; +> QUERY PLAN +> -------------------------------------------------------------------------------------- +> Limit (cost=0.00..2.38 rows=1 width=112) (actual time=32.445..32.448 +> rows=1 loops=1) +> -> Index Scan using url_queue_priority on url_queue +> (cost=0.00..1440200.41 rows=606176 width=112) (actual time=32.434..32.434 +> rows=1 loops=1) +> Index Cond: (priority >= 10000000) +> Total runtime: 32.566 ms +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster + +From pgsql-performance-owner@postgresql.org Wed May 17 14:50:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D543B9FA279 + for ; + Wed, 17 May 2006 14:50:40 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 71123-03 + for ; + Wed, 17 May 2006 14:50:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 4B7C09F944D + for ; + Wed, 17 May 2006 14:50:35 -0300 (ADT) +Received: from sottsym2.entrust.com (sottsym2.entrust.com [216.191.252.20]) + by svr4.postgresql.org (Postfix) with ESMTP id E013C5B3DAB + for ; + Wed, 17 May 2006 17:50:33 +0000 (GMT) +Received: from sottmxsecs3.entrust.com (unknown [216.191.252.14]) + by sottsym2.entrust.com (Symantec Mail Security) with SMTP id 20393134B + for ; + Wed, 17 May 2006 13:50:30 -0400 (EDT) +Received: (qmail 25109 invoked from network); 17 May 2006 17:50:29 -0000 +Received: from Chris.McKenzie@entrust.com by sottmxsecs3.entrust.com with + EntrustECS-Server-7.4; 17 May 2006 17:50:29 -0000 +Received: from sottmxs00.entrust.com (10.4.61.22) + by sottmxsecs3.entrust.com with SMTP; 17 May 2006 17:50:28 -0000 +Received: by sottmxs00.entrust.com with Internet Mail Service (5.5.2657.72) + id ; Wed, 17 May 2006 13:50:29 -0400 +Message-ID: +From: Chris Mckenzie +To: pgsql-performance@postgresql.org +Subject: Performance/Maintenance test result collection +Date: Wed, 17 May 2006 13:50:22 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C679DA.5EB75082" +X-Brightmail-Tracker: AAAAAA== +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/366 +X-Sequence-Number: 19153 + + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C679DA.5EB75082 +Content-Type: text/plain + +Hi. + +I'm trying to plan for a performance test session where a large database is +subject to regular hits from my application while both regular and full +database maintenance is being performed. The idea is to gain a better idea +on the impact maintenance will have on regular usage, and when to reasonably +schedule both regular and full maintenance. + +Is the verbose option for the VACUUM command and physical disk space usage +enough? What's a good rule of thumb for verifying that the space supposedly +recovered from a FULL vacuum is real? I can turn on verbose for a FULL +vacuum and watch the "Total free space (including removable row versions) is +7032 bytes." details, but can it be reasonably correlated against disk linux +system tools? (like du) Or only as a guidance that some maintenance is being +performed? + +Any other stat collection points I should be watching? + +Here's an example lazy vacuum verbose output from an empty schema table: +(not that you guys haven't seen this stuff enough) + +VACUUM VERBOSE app.queuedemails; +INFO: vacuuming "app.queuedemails" +INFO: index "queuedemails1" now contains 0 row versions in 1 pages +DETAIL: 0 index pages have been deleted, 0 are currently reusable. +CPU 0.00s/0.00u sec elapsed 0.00 sec. + +INFO: index "queuedemails2" now contains 0 row versions in 1 pages +DETAIL: 0 index pages have been deleted, 0 are currently reusable. +CPU 0.00s/0.00u sec elapsed 0.00 sec. + +INFO: "queuedemails": found 0 removable, 0 nonremovable row versions in 0 +pages +DETAIL: 0 dead row versions cannot be removed yet. +There were 0 unused item pointers. +0 pages are entirely empty. +CPU 0.00s/0.00u sec elapsed 0.00 sec. + +INFO: vacuuming "pg_toast.pg_toast_17595" +INFO: index "pg_toast_17595_index" now contains 0 row versions in 1 pages +DETAIL: 0 index pages have been deleted, 0 are currently reusable. +CPU 0.00s/0.00u sec elapsed 0.00 sec. + +INFO: "pg_toast_17595": found 0 removable, 0 nonremovable row versions in 0 +pages +DETAIL: 0 dead row versions cannot be removed yet. +There were 0 unused item pointers. +0 pages are entirely empty. +CPU 0.00s/0.00u sec elapsed 0.00 sec. + +THANKS!!! + +- Chris + + +------_=_NextPart_001_01C679DA.5EB75082 +Content-Type: text/html +Content-Transfer-Encoding: quoted-printable + + + + + + +Performance/Maintenance test result collection + + + +

Hi. +

+ +

I'm trying to plan for a performance test session = +where a large database is subject to regular hits from my application = +while both regular and full database maintenance is being performed. = +The idea is to gain a better idea on the impact maintenance will have = +on regular usage, and when to reasonably schedule both regular and full = +maintenance.

+ +

Is the verbose option for the VACUUM command and = +physical disk space usage enough? What's a good rule of thumb for = +verifying that the space supposedly recovered from a FULL vacuum is = +real? I can turn on verbose for a FULL vacuum and watch the "Total = +free space (including removable row versions) is 7032 bytes." = +details, but can it be reasonably correlated against disk linux system = +tools? (like du) Or only as a guidance that some maintenance is being = +performed?

+ +

Any other stat collection points I should be = +watching? +

+ +

Here's an example lazy vacuum verbose output from an = +empty schema table: (not that you guys haven't seen this stuff = +enough)

+ +

VACUUM VERBOSE app.queuedemails; +
INFO:  vacuuming = +"app.queuedemails" +
INFO:  index "queuedemails1" now = +contains 0 row versions in 1 pages +
DETAIL:  0 index pages have been deleted, 0 are = +currently reusable. +
CPU 0.00s/0.00u sec elapsed 0.00 sec. +

+ +

INFO:  index "queuedemails2" now = +contains 0 row versions in 1 pages +
DETAIL:  0 index pages have been deleted, 0 are = +currently reusable. +
CPU 0.00s/0.00u sec elapsed 0.00 sec. +

+ +

INFO:  "queuedemails": found 0 = +removable, 0 nonremovable row versions in 0 pages +
DETAIL:  0 dead row versions cannot be removed = +yet. +
There were 0 unused item pointers. +
0 pages are entirely empty. +
CPU 0.00s/0.00u sec elapsed 0.00 sec. +

+ +

INFO:  vacuuming = +"pg_toast.pg_toast_17595" +
INFO:  index "pg_toast_17595_index" = +now contains 0 row versions in 1 pages +
DETAIL:  0 index pages have been deleted, 0 are = +currently reusable. +
CPU 0.00s/0.00u sec elapsed 0.00 sec. +

+ +

INFO:  "pg_toast_17595": found 0 = +removable, 0 nonremovable row versions in 0 pages +
DETAIL:  0 dead row versions cannot be removed = +yet. +
There were 0 unused item pointers. +
0 pages are entirely empty. +
CPU 0.00s/0.00u sec elapsed 0.00 sec. +

+ +

THANKS!!! +

+ +

- Chris +
  +

+ + + +------_=_NextPart_001_01C679DA.5EB75082-- + +From pgsql-performance-owner@postgresql.org Wed May 17 15:22:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BC0ED9FA279 + for ; + Wed, 17 May 2006 15:22:16 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 74209-09 + for ; + Wed, 17 May 2006 15:22:11 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sand4.gxn.net (sand4.gxn.net [195.147.249.239]) + by postgresql.org (Postfix) with ESMTP id E75789F944D + for ; + Wed, 17 May 2006 15:22:11 -0300 (ADT) +Received: from [62.232.55.118] (helo=[192.168.0.2]) + by sand4.gxn.net with esmtp (Exim 4.50) + id 1FgQdX-0000J4-HB; Wed, 17 May 2006 19:20:43 +0100 +Subject: Re: Optimizer: limit not taken into account +From: Simon Riggs +To: "Craig A. James" +Cc: pgsql-performance@postgresql.org +In-Reply-To: <446B474C.2050803@modgraph-usa.com> +References: <44699C6C.80302@tweakers.net> <4469D173.50406@sun.com> + <4469D986.6090300@tweakers.net> <4469F55A.7040004@sun.com> + <446A1520.2020601@tweakers.net> <446B0409.7050902@sun.com> + <446B0ED2.5030909@tweakers.net> <446B474C.2050803@modgraph-usa.com> +Content-Type: text/plain +Date: Wed, 17 May 2006 19:22:09 +0100 +Message-Id: <1147890129.2646.355.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.6.1 (2.6.1-1.fc5.2) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/367 +X-Sequence-Number: 19154 + +On Wed, 2006-05-17 at 08:54 -0700, Craig A. James wrote: +> Here's a "corner case" that might interest someone. It tripped up one of our programmers. +> +> We have a table with > 10 million rows. The ID column is indexed, the table has been vacuum/analyzed. Compare these two queries: +> +> select * from tbl where id >= 10000000 limit 1; +> select * from tbl where id >= 10000000 order by id limit 1; +> +> The first takes 4 seconds, and uses a full table scan. The second takes 32 msec and uses the index. +> Details are below. + +The rows are not randomly distributed, so the SeqScan takes longer to +find 1 row than the index scan. + +-- + Simon Riggs + EnterpriseDB http://www.enterprisedb.com + + +From pgsql-performance-owner@postgresql.org Wed May 17 15:30:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A8EBD9FA2C8 + for ; + Wed, 17 May 2006 15:30:40 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 75954-07 + for ; + Wed, 17 May 2006 15:30:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 49BBD9FA279 + for ; + Wed, 17 May 2006 15:30:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4HIUMnK024246; + Wed, 17 May 2006 14:30:22 -0400 (EDT) +To: Bruno Wolff III +cc: "Craig A. James" , + pgsql-performance@postgresql.org +Subject: Re: Optimizer: limit not taken into account +In-reply-to: <20060517174426.GA14567@wolff.to> +References: <44699C6C.80302@tweakers.net> <4469D173.50406@sun.com> + <4469D986.6090300@tweakers.net> <4469F55A.7040004@sun.com> + <446A1520.2020601@tweakers.net> <446B0409.7050902@sun.com> + <446B0ED2.5030909@tweakers.net> <446B474C.2050803@modgraph-usa.com> + <20060517174426.GA14567@wolff.to> +Comments: In-reply-to Bruno Wolff III + message dated "Wed, 17 May 2006 12:44:26 -0500" +Date: Wed, 17 May 2006 14:30:22 -0400 +Message-ID: <24245.1147890622@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/368 +X-Sequence-Number: 19155 + +Bruno Wolff III writes: +> I suspect it wasn't intended to be a full table scan. But rather a sequential +> scan until it found a matching row. If the data in the table is ordered by +> by id, this strategy may not work out well. Where as if the data is randomly +> ordered, it would be expected to find a match quickly. + +Right. You can see from the differential in the estimates for the +SeqScan and the Limit nodes that the planner is not expecting the +seqscan to run to completion, but rather to find a matching row quite +quickly. + +There is not anything in there that considers whether the table's +physical order is so nonrandom that the search will take much longer +than it would given uniform distribution. It might be possible to do +something with the correlation statistic in simple cases ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed May 17 15:58:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id DB2829FA279 + for ; + Wed, 17 May 2006 15:58:34 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 88711-04 + for ; + Wed, 17 May 2006 15:58:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moonunit2.moonview.localnet (wsip-70-167-125-69.sd.sd.cox.net + [70.167.125.69]) + by postgresql.org (Postfix) with ESMTP id 29D5D9F944D + for ; + Wed, 17 May 2006 15:58:22 -0300 (ADT) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k4HJ70b3021707; Wed, 17 May 2006 12:07:00 -0700 +Message-ID: <446B7241.2060409@modgraph-usa.com> +Date: Wed, 17 May 2006 11:58:09 -0700 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Tom Lane +CC: Bruno Wolff III , pgsql-performance@postgresql.org +Subject: Re: Optimizer: limit not taken into account +References: <44699C6C.80302@tweakers.net> <4469D173.50406@sun.com> + <4469D986.6090300@tweakers.net> <4469F55A.7040004@sun.com> + <446A1520.2020601@tweakers.net> <446B0409.7050902@sun.com> + <446B0ED2.5030909@tweakers.net> <446B474C.2050803@modgraph-usa.com> + <20060517174426.GA14567@wolff.to> <24245.1147890622@sss.pgh.pa.us> +In-Reply-To: <24245.1147890622@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/369 +X-Sequence-Number: 19156 + +Tom Lane wrote: +> There is not anything in there that considers whether the table's +> physical order is so nonrandom that the search will take much longer +> than it would given uniform distribution. It might be possible to do +> something with the correlation statistic in simple cases ... + +In this case, the rows are not random at all, in fact they're inserted from a sequence, then rows are deleted as they are processed. If the planner is hoping for random physical distribution, this particular case is exactly wrong. + +Craig + +From pgsql-jdbc-owner@postgresql.org Wed May 17 16:00:16 2006 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 62A269FA2C8 + for ; + Wed, 17 May 2006 16:00:16 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 91171-01 + for ; + Wed, 17 May 2006 16:00:05 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id DDA479FA2FA + for ; Wed, 17 May 2006 16:00:04 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 1626456423; Wed, 17 May 2006 14:00:03 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 17 May 2006 14:00:01 -0500 +Date: Wed, 17 May 2006 14:00:01 -0500 +From: "Jim C. Nasby" +To: kah_hang_ang@toray.com.my +Cc: pgsql-jdbc@postgresql.org +Subject: Re: [PERFORM] Performance incorporate with JReport +Message-ID: <20060517190000.GU26212@pervasive.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060517:kah_hang_ang@toray.com.my::WMyipPubdpBezRa0:000000000000 + 00000000000000000000000088RK +X-Hashcash: + 1:20:060517:pgsql-jdbc@postgresql.org::rLiRjJWNbt8QUdbJ:000000000000 + 000000000000000000000000BTP0 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/75 +X-Sequence-Number: 15203 + +Moving to -jdbc. + +On Wed, May 17, 2006 at 02:13:46PM +0800, kah_hang_ang@toray.com.my wrote: +> Currently I'm using postgresql v8.1.3 and the latest jdbc. +> +> I try to open a JReports' report and the time taken to completely open the +> report is 137453ms. +> Then I open the same report but this time I connect to postgresql v7.2.2 +> but the completion time is even faster than connect to postgresql v8.1.3 +> which took 15516ms to finish. +> +> I try many times and the result is still the same. +> +> So I think it might be compatibility problem between JReport & Postgresql +> 8.1.3 so i add in 'protocolVersion=2' in the connection string. +> Then i open the same report again and this time it just as what i expected, +> the execution time for the report become 6000ms only, +> it is 20x times faster than previous test without 'protocolVersion=2' +> option. +> +> May I know what is the reason of this? +> Is it because of the compatibility between JDBC driver with JReport? + +This certainly sounds like a likely JDBC issue, so I'm moving this email +to pgsql-jdbc, since someone there is more likely to be able to help +you. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 17 16:04:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 037889FA2C8 + for ; + Wed, 17 May 2006 16:04:16 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 89117-04 + for ; + Wed, 17 May 2006 16:04:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 414EE9FA279 + for ; + Wed, 17 May 2006 16:04:03 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id E0BCF56427; Wed, 17 May 2006 14:04:01 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 17 May 2006 14:04:01 -0500 +Date: Wed, 17 May 2006 14:04:01 -0500 +From: "Jim C. Nasby" +To: "Craig A. James" +Cc: Christian Paul Cosinas , 'PFC' , + pgsql-performance@postgresql.org +Subject: Re: Speed Up Offset and Limit Clause +Message-ID: <20060517190400.GV26212@pervasive.com> +References: <00e101c67997$6aa049f0$1e21100a@ghwk02002147> + <446A885C.2050308@modgraph-usa.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <446A885C.2050308@modgraph-usa.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060517:cjames@modgraph-usa.com::w7WWQxW4KzU3BT0g:00000000000000 + 0000000000000000000000003KV8 +X-Hashcash: 1:20:060517:cpc@cybees.com::SgzvpQuEAGg8ScHT:0001s34 +X-Hashcash: 1:20:060517:lists@peufeu.com::UaTmF4uvIduISIXX:00Amr +X-Hashcash: + 1:20:060517:pgsql-performance@postgresql.org::IsHNSwaHXkIpSZ3I:00000 + 0000000000000000000000000A8M +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/370 +X-Sequence-Number: 19157 + +On Tue, May 16, 2006 at 07:20:12PM -0700, Craig A. James wrote: +> >Why I want to use offset and limit is for me to create a threaded +> >application so that they will not get the same results. +> +> In order to return rows 10000 to 15000, it must select all rows from zero +> to 15000 and then discard the first 10000 -- probably not what you were +> hoping for. +> +> You might add a "thread" column. Say you want to run ten threads: + +Another possibility is partitioning the table. If you do that using +inheritance-based partitioning, you could just select directly from +different partition tables, which probably be even faster than using a +single table. The downside is it's more work to setup. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 17 16:20:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 15F599FA279 + for ; + Wed, 17 May 2006 16:20:53 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 92325-06 + for ; + Wed, 17 May 2006 16:20:39 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 3FABA9F944D + for ; + Wed, 17 May 2006 16:20:37 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id ACB3256427; Wed, 17 May 2006 14:20:35 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 17 May 2006 14:20:34 -0500 +Date: Wed, 17 May 2006 14:20:34 -0500 +From: "Jim C. Nasby" +To: "Craig A. James" +Cc: pgsql-performance@postgresql.org +Subject: Re: Optimizer: limit not taken into account +Message-ID: <20060517192034.GW26212@pervasive.com> +References: <44699C6C.80302@tweakers.net> <4469D173.50406@sun.com> + <4469D986.6090300@tweakers.net> <4469F55A.7040004@sun.com> + <446A1520.2020601@tweakers.net> <446B0409.7050902@sun.com> + <446B0ED2.5030909@tweakers.net> <446B474C.2050803@modgraph-usa.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <446B474C.2050803@modgraph-usa.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060517:cjames@modgraph-usa.com::4txiA9TLMx/U9+hz:00000000000000 + 0000000000000000000000006cGg +X-Hashcash: + 1:20:060517:pgsql-performance@postgresql.org::lvvgs8lKcrlg9pOW:00000 + 0000000000000000000000000MP8 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/371 +X-Sequence-Number: 19158 + +On Wed, May 17, 2006 at 08:54:52AM -0700, Craig A. James wrote: +> Here's a "corner case" that might interest someone. It tripped up one of +> our programmers. +> +> We have a table with > 10 million rows. The ID column is indexed, the +> table has been vacuum/analyzed. Compare these two queries: +> +> select * from tbl where id >= 10000000 limit 1; +> select * from tbl where id >= 10000000 order by id limit 1; +> +> The first takes 4 seconds, and uses a full table scan. The second takes 32 +> msec and uses the index. Details are below. +> +> I understand why the planner makes the choices it does -- the "id > +> 10000000" isn't very selective and under normal circumstances a full table +> scan is probably the right choice. But the "limit 1" apparently doesn't +> alter the planner's strategy at all. We were surprised by this. + +Is it really not very selective? If there's 10000000 rows in the table, +and id starts at 1 with very few gaps, then >= 10000000 should actually +be very selective... + +Also, I hope you understand there's a big difference between a limit +query that does and doesn't have an order by. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 17 16:24:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 501239FA2C8 + for ; + Wed, 17 May 2006 16:24:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 94373-03 + for ; + Wed, 17 May 2006 16:24:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id EB3719F944D + for ; + Wed, 17 May 2006 16:24:42 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id CC8D656427; Wed, 17 May 2006 14:24:41 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 17 May 2006 14:24:40 -0500 +Date: Wed, 17 May 2006 14:24:40 -0500 +From: "Jim C. Nasby" +To: Chris Mckenzie +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance/Maintenance test result collection +Message-ID: <20060517192440.GX26212@pervasive.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060517:chris.mckenzie@entrust.com::3AQc/ekPSYXcN0+W:00000000000 + 000000000000000000000000DXMp +X-Hashcash: + 1:20:060517:pgsql-performance@postgresql.org::uzsxFgz/sD654gY1:00000 + 0000000000000000000000004h/7 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/372 +X-Sequence-Number: 19159 + +On Wed, May 17, 2006 at 01:50:22PM -0400, Chris Mckenzie wrote: +> Hi. +> +> I'm trying to plan for a performance test session where a large database is +> subject to regular hits from my application while both regular and full +> database maintenance is being performed. The idea is to gain a better idea +> on the impact maintenance will have on regular usage, and when to reasonably +> schedule both regular and full maintenance. + +What do you mean by "regular and full maintenance"? Do you mean VACUUM +FULL? + +If you're vacuuming appropriately you shouldn't have any need to ever +VACUUM FULL... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-jdbc-owner@postgresql.org Wed May 17 16:41:13 2006 +X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A7AD49FA279 + for ; + Wed, 17 May 2006 16:41:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 94314-10 + for ; + Wed, 17 May 2006 16:41:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail63.csoft.net (mail63.csoft.net [205.205.214.4]) + by postgresql.org (Postfix) with SMTP id CBF669F944D + for ; Wed, 17 May 2006 16:41:02 -0300 (ADT) +Received: (qmail 24742 invoked by uid 1112); 17 May 2006 19:41:00 -0000 +Date: Wed, 17 May 2006 14:40:59 -0500 (EST) +From: Kris Jurka +X-X-Sender: books@leary2.csoft.net +To: "Jim C. Nasby" +cc: kah_hang_ang@toray.com.my, pgsql-jdbc@postgresql.org +Subject: Re: [PERFORM] Performance incorporate with JReport +In-Reply-To: <20060517190000.GU26212@pervasive.com> +Message-ID: +References: + <20060517190000.GU26212@pervasive.com> +MIME-Version: 1.0 +Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/76 +X-Sequence-Number: 15204 + + + +> On Wed, May 17, 2006 at 02:13:46PM +0800, kah_hang_ang@toray.com.my wrote: +>> Currently I'm using postgresql v8.1.3 and the latest jdbc. +>> +>> I try to open a JReports' report and the time taken to completely open the +>> report is 137453ms. +>> Then I open the same report but this time I connect to postgresql v7.2.2 +>> but the completion time is even faster than connect to postgresql v8.1.3 +>> which took 15516ms to finish. +>> +>> So I think it might be compatibility problem between JReport & Postgresql +>> 8.1.3 so i add in 'protocolVersion=2' in the connection string. +>> Then i open the same report again and this time it just as what i expected, +>> the execution time for the report become 6000ms only, +>> it is 20x times faster than previous test without 'protocolVersion=2' +>> option. +>> + +It is very unclear what JReport and/or this specific report is doing, but +there are differences with how PreparedStatements are planned for the V2 +and V3 protocol. + +For the V2 protocol, the driver manually interpolates the parameters into +the query string and sends the whole sql across upon each execution. +This means the server can know the exact parameters used and generate the +best plan (at the expense of reparsing/replanning on every execution). + +For the V3 protocol the driver prepares the query and sends +the parameters over separately. There are two different modes of this +execution depending on whether we expect to re-execute the same statement +multiple times or not (see the prepareThreshold configuration parameter). +If we don't expect to reissue the same query with different parameters it +will be executed on the unnamed statement which will generate a plan using +the passed parameters and should be equivalent to the V2 case. If it is +expected to be reissed it will be executed on a named statement and +prepared with generic parameters that may differ wildly from your actual +parameters resulting in a non-ideal plan. + +Also with the V3 protocol on either a named or unnamed statement the JDBC +driver passes type information along with the parameters which may cause +the server to generate a poor plan because it fails to use an index +somehow. Although with 8.0+ cross type indexing usually works. + +It's tough to say what's going on here without more detail about what +JReport is actually doing. + +Kris Jurka + +From pgsql-performance-owner@postgresql.org Thu May 18 04:52:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1918E9FA226 + for ; + Thu, 18 May 2006 04:52:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 31459-03 + for ; + Thu, 18 May 2006 04:52:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 542559FA48C + for ; + Thu, 18 May 2006 04:52:49 -0300 (ADT) +Received: from mail.enyo.de (mail.enyo.de [212.9.189.167]) + by svr4.postgresql.org (Postfix) with ESMTP id 8F91F5B369B + for ; + Thu, 18 May 2006 07:52:47 +0000 (GMT) +Received: from deneb.vpn.enyo.de ([212.9.189.177] helo=deneb.enyo.de) + by mail.enyo.de with esmtp id 1FgdJG-0006b2-U3; + Thu, 18 May 2006 09:52:39 +0200 +Received: from fw by deneb.enyo.de with local (Exim 4.62) + (envelope-from ) + id 1FgbDy-00012S-6x; Thu, 18 May 2006 07:39:02 +0200 +From: Florian Weimer +To: "Jignesh K. Shah" +Cc: Arjen van der Meijden , + pgsql-performance +Subject: Re: Pgsql (and mysql) benchmark on T2000/Solaris and some +References: <44699C6C.80302@tweakers.net> <4469D173.50406@sun.com> +Date: Thu, 18 May 2006 07:39:01 +0200 +In-Reply-To: <4469D173.50406@sun.com> (Jignesh K. Shah's message of "Tue, 16 + May 2006 14:19:47 +0100") +Message-ID: <8764k3uc22.fsf@mid.deneb.enyo.de> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/376 +X-Sequence-Number: 19163 + +* Jignesh K. Shah: + +> * llseek is high which means you can obviously gain a bit with the +> right file system/files tuning by caching them right. + +It might also make sense to switch from lseek-read/write to +pread/pwrite. It shouldn't be too hard to hack this into the virtual +file descriptor module. + +From pgsql-performance-owner@postgresql.org Thu May 18 04:49:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8366C9FA226; + Thu, 18 May 2006 04:49:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 31107-05; Thu, 18 May 2006 04:49:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from loki.globexplorer.com (loki.globexplorer.com [12.25.176.46]) + by postgresql.org (Postfix) with ESMTP id 288979FAD5A; + Thu, 18 May 2006 04:49:27 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="Windows-1252" +Content-Transfer-Encoding: quoted-printable +Subject: Re: [HACKERS] Big IN() clauses etc : feature proposal +Date: Thu, 18 May 2006 00:56:57 -0700 +Message-ID: + <71E37EF6B7DCC1499CEA0316A2568328024BC4E5@loki.wc.globexplorer.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] [HACKERS] Big IN() clauses etc : feature proposal + [heur] +thread-index: AcZ0Z3Dtdrn4AvIzTDWUsaoPActu4AAZsmvQAWB5etk= +References: +From: "Gregory S. Williamson" +To: "Zeugswetter Andreas DCP SD" , + "Jim C. Nasby" , "PFC" +Cc: "Greg Stark" , "Tom Lane" , + , +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/375 +X-Sequence-Number: 19162 + +1.451 ms =3D 1.451 milliseconds +1451.0 ms =3D 1.451 seconds ... + +so 32.918 ms for a commit seems perhaps reasonable ? + +Greg Williamson +DBA +GlobeXplorer LLC + + + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org on behalf of Zeugswetter = +Andreas DCP SD +Sent: Thu 5/11/2006 12:55 AM +To: Jim C. Nasby; PFC +Cc: Greg Stark; Tom Lane; pgsql-performance@postgresql.org; = +pgsql-hackers@postgresql.org +Subject: Re: [PERFORM] [HACKERS] Big IN() clauses etc : feature proposal + + +> Something else worth considering is not using the normal=20 +> catalog methods +> for storing information about temp tables, but hacking that together +> would probably be a rather large task. + +But the timings suggest, that it cannot be the catalogs in the worst +case +he showed. + +> 0.101 ms BEGIN +> 1.451 ms CREATE TEMPORARY TABLE tmp ( a INTEGER NOT NULL, b INTEGER +NOT =20 +> NULL, c TIMESTAMP NOT NULL, d INTEGER NOT NULL ) ON COMMIT DROP + +1.4 seconds is not great for create table, is that what we expect ? + +> 0.450 ms INSERT INTO tmp SELECT * FROM bookmarks ORDER BY annonce_id +DESC =20 +> LIMIT 20 +> 0.443 ms ANALYZE tmp +> 0.365 ms SELECT * FROM tmp +> 0.310 ms DROP TABLE tmp +> 32.918 ms COMMIT +>=20 +> CREATING the table is OK, but what happens on COMMIT ? I hear +the disk =20 +> seeking frantically. + +The 32 seconds for commit can hardly be catalog related. It seems the +file is=20 +fsynced before it is dropped. + +Andreas + +---------------------------(end of broadcast)--------------------------- +TIP 3: Have you checked our extensive FAQ? + + http://www.postgresql.org/docs/faq + +!DSPAM:446c0a75172664042098162! + + + + + +From pgsql-performance-owner@postgresql.org Thu May 18 07:13:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 949C79FA293 + for ; + Thu, 18 May 2006 07:13:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 05672-01 + for ; + Thu, 18 May 2006 07:12:59 -0300 (ADT) +X-Greylist: delayed 00:30:09.940086 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 25DB49F9C18 + for ; + Thu, 18 May 2006 07:12:59 -0300 (ADT) +Received: from mail.logix-tt.com (mail.logix-tt.com [212.211.145.186]) + by svr4.postgresql.org (Postfix) with ESMTP id 0B7DF5AFB7D + for ; + Thu, 18 May 2006 09:42:48 +0000 (GMT) +Received: from kingfisher.intern.logix-tt.com (T96b4.t.pppool.de + [89.55.150.180]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id C58F465800; + Thu, 18 May 2006 11:44:02 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 1D49F18222EE9; + Thu, 18 May 2006 11:43:06 +0200 (CEST) +Message-ID: <446C41A9.9080600@logix-tt.com> +Date: Thu, 18 May 2006 11:43:05 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Mario Splivalo +Cc: "Jim C. Nasby" , + pgsql-performance@postgresql.org +Subject: Re: Lot'sa joins - performance tip-up, please? +References: <1146533274.14006.11.camel@localhost.localdomain> + <17793.1146679117@sss.pgh.pa.us> + <1146753957.8538.30.camel@localhost.localdomain> + <20060510221048.GX99570@pervasive.com> + <1147325547.8696.6.camel@localhost.localdomain> +In-Reply-To: <1147325547.8696.6.camel@localhost.localdomain> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-15 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/378 +X-Sequence-Number: 19165 + +Hi, Mario, + +Mario Splivalo wrote: + +> This helps also. I don't get sequential scans any more. I'd like a tip +> on how to set 'enable_nestloop = off' trough JDBC? + +statement.execute("SET enable_nestloop TO off"); should do. + +HTH, +Markus + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Thu May 18 06:57:34 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 743F79FA48C + for ; + Thu, 18 May 2006 06:57:34 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 98815-09 + for ; + Thu, 18 May 2006 06:57:28 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.201]) + by postgresql.org (Postfix) with ESMTP id 2D6459FA226 + for ; + Thu, 18 May 2006 06:57:28 -0300 (ADT) +Received: by wx-out-0102.google.com with SMTP id s7so35594wxc + for ; + Thu, 18 May 2006 02:57:27 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=nv0ti/mcDB7gfEmvpDhHGKnJaCj4vdg4Tsxkzu16CmDArXJEZZmJYmXbVV9oTdPFiZT2Foh+tMMgEFBwGxCKaO6xPiV2WzX2jvWR4OvNy9MWTJR4yBdht6KxV3w14m2Cbj0m83RMM+K+JUwHe+SqZ8yAnjZe4z6xVDkL3hvZgAI= +Received: by 10.70.77.7 with SMTP id z7mr425407wxa; + Thu, 18 May 2006 02:57:26 -0700 (PDT) +Received: by 10.70.73.3 with HTTP; Thu, 18 May 2006 02:57:26 -0700 (PDT) +Message-ID: +Date: Thu, 18 May 2006 11:57:26 +0200 +From: "Olivier Andreotti" +To: pgsql-performance@postgresql.org +Subject: Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle 10g2 +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/377 +X-Sequence-Number: 19164 + +Hello, + +I'm running a benchmark with theses 3 databases, and the first results +are not very good for PostgreSQL. + +PostgreSQL is 20% less performance than MySQL (InnoDB tables) + +My benchmark uses the same server for theses 3 databases : +Dell Power edge - Xeon 2.8 Ghz - 2 Go Ram - 3 SCSI disks - Debian +Sarge - Linux 2.6 + +The transactions are a random mix of request in read (select) and +write (insert, delete, update) on many tables about 100 000 to 15 000 +000 rows. + +Transactions are executed from 500 connections. + +For the tunning of PostgreSQL i use official documentation and theses +web sites : + +http://www.revsys.com/writings/postgresql-performance.html +http://www.varlena.com/GeneralBits/Tidbits/annotated_conf_e.html + + +Some important points of my postgresql.conf file : + +max_connections =3D 510 +shared_buffer =3D 16384 +max_prepared_transactions =3D 510 +work_mem =3D 1024 +maintenance_work_mem =3D 1024 +fsync =3D off +wal_buffers =3D 32 +commit_delay =3D 500 +checkpoint_segments =3D 10 +checkpoint_timeout =3D 300 +checkpoint_warning =3D 0 +effective_cache_size =3D 165 000 +autovaccuum =3D on +default_transaction_isolation =3D 'read_committed' + +What do you think of my tunning ? + +Best regards. + +O.A + +From pgsql-performance-owner@postgresql.org Thu May 18 07:32:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AB17F9FA293 + for ; + Thu, 18 May 2006 07:32:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 07848-07 + for ; + Thu, 18 May 2006 07:32:40 -0300 (ADT) +X-Greylist: delayed 00:16:25.209387 by SQLgrey- +Received: from 1006.org (unknown [62.146.87.34]) + by postgresql.org (Postfix) with ESMTP id 85B9E9F9C18 + for ; + Thu, 18 May 2006 07:32:41 -0300 (ADT) +Received: from dell.home.lan (host45-104.pool875.interbusiness.it + [87.5.104.45]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id k4IAKZ131285 + for ; Thu, 18 May 2006 12:20:35 +0200 +Subject: Re: Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle +From: Chris Mair +To: pgsql-performance@postgresql.org +In-Reply-To: +References: +Content-Type: text/plain +Date: Thu, 18 May 2006 12:16:13 +0200 +Message-Id: <1147947373.7943.35.camel@dell.home.lan> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-27) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/379 +X-Sequence-Number: 19166 + +Hello :) + +What version would PostgreSQL 8.1.4 be? + +> I'm running a benchmark with theses 3 databases, and the first results +> are not very good for PostgreSQL. + +Could you give us some more infos about the box' performance while you +run the PG benchmark? A few minutes output of "vmstat 10" maybe? What +does "top" say? + +> My benchmark uses the same server for theses 3 databases : +> Dell Power edge - Xeon 2.8 Ghz - 2 Go Ram - 3 SCSI disks - Debian +> Sarge - Linux 2.6 + +How are you using the 3 disks? Did you split pg_xlog and the database +on different disks or not? + +> The transactions are a random mix of request in read (select) and +> write (insert, delete, update) on many tables about 100 000 to 15 000 +> 000 rows. +> +> Transactions are executed from 500 connections. + +Can you say something about the clients? Do they run over network from +other hosts? What language/bindings do they use? + +When they do inserts, are the inserts bundled or are there +single insert transactions? Are the statements prepared? + + +Bye, Chris. + + + + + +From pgsql-performance-owner@postgresql.org Thu May 18 07:43:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id DF4A09FA293 + for ; + Thu, 18 May 2006 07:43:05 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 04704-10 + for ; + Thu, 18 May 2006 07:42:58 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.199]) + by postgresql.org (Postfix) with ESMTP id 5566D9F9C18 + for ; + Thu, 18 May 2006 07:42:59 -0300 (ADT) +Received: by wx-out-0102.google.com with SMTP id s7so40496wxc + for ; + Thu, 18 May 2006 03:42:57 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=f5bPYJKtcOaxD9Z6mRb00UMJ1aCuc23vFfnwuuMr5HZQkHINxJu0jFUxnIAXgKb7DnSQJ29dz/U9aRztBSZw83pqAeGUf1Dw3xgQKeCcfFqjNdj4MdpBHwEv+8tQaeZ2kMVU73Z490oB4UJpDcP3FQfuEckuSvDS1XAmEOFcJ3s= +Received: by 10.70.23.15 with SMTP id 15mr457503wxw; + Thu, 18 May 2006 03:42:57 -0700 (PDT) +Received: by 10.70.73.3 with HTTP; Thu, 18 May 2006 03:42:57 -0700 (PDT) +Message-ID: +Date: Thu, 18 May 2006 12:42:57 +0200 +From: "Olivier Andreotti" +To: "Chris Mair" +Subject: Re: Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle +Cc: pgsql-performance@postgresql.org +In-Reply-To: <1147947373.7943.35.camel@dell.home.lan> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <1147947373.7943.35.camel@dell.home.lan> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/380 +X-Sequence-Number: 19167 + +2006/5/18, Chris Mair : +> Hello :) +> + +Hello Chris + +> What version would PostgreSQL 8.1.4 be? +> + +Hum, ok, it is the 8.1.3 version :) + +> Could you give us some more infos about the box' performance while you +> run the PG benchmark? A few minutes output of "vmstat 10" maybe? What +> does "top" say? + +> +Here, an extract from the vmstat 3 during the test, you can see that +my problem is probably a very high disk usage (write and read). + + 5 90 92 126792 9240 2429940 0 0 943 10357 3201 2024 18 9 = +0 74 + 0 21 92 129244 9252 2427268 0 0 799 6389 2228 981 8 3 = +0 89 + 0 13 92 127236 9272 2428772 0 0 453 8137 2489 1557 5 4 = +0 91 + 0 51 92 125264 9304 2431296 0 0 725 4999 2206 1763 11 4 = +0 85 + 0 47 92 127984 9308 2428476 0 0 612 8369 2842 1689 11 4 = +0 85 + 0 114 92 125572 9324 2430980 0 0 704 8436 2744 1145 11 5 = + 0 84 + 0 29 92 128700 9184 2428020 0 0 701 5948 2748 1688 11 5 = +0 84 +49 53 92 127332 9180 2429820 0 0 1053 10221 3107 2156 16 9 = +0 75 + 0 63 92 124912 9200 2431796 0 0 608 10272 2512 996 10 5 = +0 86 +procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu-= +--- + r b swpd free buff cache si so bi bo in cs us sy id= + wa + 0 11 92 128344 9224 2428432 0 0 287 9691 2227 685 4 3 = +0 93 + 0 9 92 124548 9244 2432520 0 0 1168 9859 3186 1967 17 7 = +0 76 + 0 8 92 128452 9180 2428316 0 0 512 10673 2709 1059 7 3 = +0 89 + 0 78 92 126820 9192 2429888 0 0 501 7100 2300 1002 6 3 = +0 91 + 0 80 92 129932 9092 2427128 0 0 860 9103 2850 1724 13 8 = +0 79 + 2 17 92 125468 9112 2431484 0 0 1311 10268 2890 1540 14 6 = +0 79 + 0 10 92 127548 9088 2429268 0 0 1048 10404 3244 1810 18 7 = +0 75 + 0 29 92 126456 9124 2430456 0 0 365 10288 2607 953 6 3 = +0 92 + 0 25 92 125852 9132 2431012 0 0 172 7168 2202 656 4 3 = +0 93 + 0 17 92 124968 9188 2431920 0 0 283 4676 1996 708 4 2 = +0 94 + 0 11 92 129644 9144 2427104 0 0 357 6387 2112 816 5 3 = +0 92 + 0 16 92 125252 9176 2431804 0 0 1405 6753 2988 2083 21 7 = +0 71 + +> +> How are you using the 3 disks? Did you split pg_xlog and the database +> on different disks or not? +> + +Data are on disk 1 et 2. Index on disk 3. Perhaps i'm wrong but fsync +=3D off, pg_xlog are running with that ? + +> +> Can you say something about the clients? Do they run over network from +> other hosts? What language/bindings do they use? +> + +Client is another server from the same network. Clients are connected +with JDBC connector. + +> When they do inserts, are the inserts bundled or are there +> single insert transactions? Are the statements prepared? +> +> + +I use prepared statements for all requests. Each transaction is about +5-45 requests. + +> Bye, Chris. +> + +OA + +From pgsql-performance-owner@postgresql.org Thu May 18 07:49:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5FD589FA293 + for ; + Thu, 18 May 2006 07:49:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 12606-03 + for ; + Thu, 18 May 2006 07:49:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from achille.dalibo.net (achille.dalibo.net [212.85.153.230]) + by postgresql.org (Postfix) with ESMTP id C89FB9F9C18 + for ; + Thu, 18 May 2006 07:49:38 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by achille.dalibo.net (Postfix) with ESMTP id 443CC15F63; + Thu, 18 May 2006 12:37:02 +0200 (CEST) +Received: from achille.dalibo.net ([127.0.0.1]) + by localhost (achille [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id 29147-10; Thu, 18 May 2006 12:37:01 +0200 (CEST) +Received: from [192.168.0.1] (maison.argudo.org [81.56.190.65]) + by achille.dalibo.net (Postfix) with ESMTP id 905F915F5E; + Thu, 18 May 2006 12:37:00 +0200 (CEST) +Message-ID: <446C510A.9040609@argudo.org> +Date: Thu, 18 May 2006 12:48:42 +0200 +From: Jean-Paul Argudo +User-Agent: Thunderbird 1.5.0.2 (X11/20060501) +MIME-Version: 1.0 +To: Olivier Andreotti +Cc: pgsql-performance@postgresql.org +Subject: Re: Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle +References: +In-Reply-To: +X-Enigmail-Version: 0.94.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at dalibo.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/382 +X-Sequence-Number: 19169 + +Hi Olivier, + +First question I'd like to ask is: will this benchmark and its results +will be accessible on the net when you'll have finished ? + +I'm interested about your benchmark and your results. + +> I'm running a benchmark with theses 3 databases, and the first results +> are not very good for PostgreSQL. + +Hope I can give you hints to enhance PostgreSQL's performances in your +benchmark. + +> PostgreSQL is 20% less performance than MySQL (InnoDB tables) + +I think MySQL's tuning is comparable to PostgreSQL's? + +> My benchmark uses the same server for theses 3 databases : +> Dell Power edge - Xeon 2.8 Ghz - 2 Go Ram - 3 SCSI disks - Debian +> Sarge - Linux 2.6 + +ok. 3 disks is really few for a database server IMHO (more disks, better +I/O *if* you span database files onto disks). + +> The transactions are a random mix of request in read (select) and +> write (insert, delete, update) on many tables about 100 000 to 15 000 +> 000 rows. + +ok. But.. What's the size of your database ? +[see it in psql with: select pg_size_pretty(pg_database_size('myDatabase');] + +> Transactions are executed from 500 connections. + +You mean its a progressive test (1, 10, 100, 400, 500..???) or 500 from +the very beggining ? + +> For the tunning of PostgreSQL i use official documentation and theses +> web sites : +> +> http://www.revsys.com/writings/postgresql-performance.html +> http://www.varlena.com/GeneralBits/Tidbits/annotated_conf_e.html + +Those pages are great if you want to reach to a great postgresql.conf. + +> Some important points of my postgresql.conf file : +> +> max_connections = 510 +> shared_buffer = 16384 +> max_prepared_transactions = 510 + +why? whats the point putting 510 here? + +> work_mem = 1024 + +I found that value really low. But you'll have to check if you need +more. Thats all about looking for temporary files creation under $PGDATA. + +> maintenance_work_mem = 1024 + +This has to be increased dramatically, I really reccomend you read this +page too: http://www.powerpostgresql.com/PerfList/ + +> fsync = off + +Thats pretty unsecure for a production database. I don't think it is +good to test PostgreSQL with fsync off, since this won't reflect the +final configuration of a production server. + +> wal_buffers = 32 + +A great value would be 64. Some tests already concluded that 64 is a +good value for large databases. + +You'll *have to* move $PGDATA/pg_xlog/ too (see end of this mail). + +> commit_delay = 500 +> checkpoint_segments = 10 + +Put something larger than that. I use often use like 64 for large databases. + +> checkpoint_timeout = 300 +> checkpoint_warning = 0 +> effective_cache_size = 165 000 + +Try 174762 (2/3 the ram installed). Wont be a great enhance, for sure, +but let's put reccomended values. + +> autovaccuum = on + +Thats a critic point. Personaly I dont use autovacuum. Because I just +don't want a vacuum to be started ... when the server is loaded :) + +I prefer control vacuum process, when its possible (if its not, +autovacuum is the best choice!), for example, a nighlty vacuum... + +A question for you: after setting up your test database, did you launch +a vacuum full analyze of it ? + +> default_transaction_isolation = 'read_committed' + +> What do you think of my tunning ? + +IMHO, it is fairly good, since you put already somewhat good values. + +Try too to set "max_fsm_pages" depending what PostgreSQL tells you in +the logfile... (see again http://www.powerpostgresql.com/PerfList/) + +With XEON, you have to lower "random_page_cost" to 3 too. + +You don't mention files organisation ($PGDATA, the PG "cluster") of your +server? + +I mean, it is now well known that you *have to* move pg_xlog/ directory +to another (array of) disk! Because otherwise its the same disk head +that writes into WALs _and_ into files... + +OTOH you are using "fsync=off", that any DBA wouldn't reccomend.. Well, +ok, it's for testing purposes. + +Same remark, if you can create tablespaces to span database files +accross (array of) disks, even better. But with 3 disks, its somewhat +limitated: move pg_xlog before anything else. + +Now about "client side", I reccomend you install and use pgpool, see: +http://pgpool.projects.postgresql.org/ . Because "pgpool caches the +connection to PostgreSQL server to reduce the overhead to establish the +connection to it". Allways good :) + +Hope those little hints will help you in getting the best from your +PostgreSQL server. + +Keep us on touch, + +-- +Jean-Paul Argudo +www.PostgreSQLFr.org +www.dalibo.com + +From pgsql-performance-owner@postgresql.org Thu May 18 07:48:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C6D059FA293 + for ; + Thu, 18 May 2006 07:48:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 12393-01 + for ; + Thu, 18 May 2006 07:48:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from loki.globexplorer.com (loki.globexplorer.com [12.25.176.46]) + by postgresql.org (Postfix) with ESMTP id 3EA189F9C18 + for ; + Thu, 18 May 2006 07:48:06 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="Windows-1252" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle 10g2 +Date: Thu, 18 May 2006 03:55:32 -0700 +Message-ID: + <71E37EF6B7DCC1499CEA0316A2568328024BC4E8@loki.wc.globexplorer.net> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle + 10g2 +thread-index: AcZ6YqUGMITmbG+5QHC7OsbC/vEvEAABhBfo +References: +From: "Gregory S. Williamson" +To: "Olivier Andreotti" , + +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/381 +X-Sequence-Number: 19168 + + +That fsync off would make me very unhappy in a production environment = +.... not that turning it on would help postgres, but ... one advantage = +of postgres is its reliability under a "pull the plug" scenario, but = +this setting defeats that. + +FWIW, Xeon has gotten quite negative reviews in these quarters (Opteron = +seems to do way better), IIRC, and I know we've had issues with Dell's = +disk i/o, admittedly on a different box. + +Quite interesting results, even if a bit disappointing to a (newly = +minted) fan of postgres. I'll be quite interested to hear more. Thanks = +for the work, although it seems like some of it won;t be able to = +released, unless Oracle has given some new blessing to releasing = +benchmark results. + +Greg Williamson +DBA +GlobeXplorer LLC +-----Original Message----- +From: pgsql-performance-owner@postgresql.org on behalf of Olivier = +Andreotti +Sent: Thu 5/18/2006 2:57 AM +To: pgsql-performance@postgresql.org +Cc:=09 +Subject: [PERFORM] Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle = +10g2 + +Hello, + +I'm running a benchmark with theses 3 databases, and the first results +are not very good for PostgreSQL. + +PostgreSQL is 20% less performance than MySQL (InnoDB tables) + +My benchmark uses the same server for theses 3 databases : +Dell Power edge - Xeon 2.8 Ghz - 2 Go Ram - 3 SCSI disks - Debian +Sarge - Linux 2.6 + +The transactions are a random mix of request in read (select) and +write (insert, delete, update) on many tables about 100 000 to 15 000 +000 rows. + +Transactions are executed from 500 connections. + +For the tunning of PostgreSQL i use official documentation and theses +web sites : + +http://www.revsys.com/writings/postgresql-performance.html +http://www.varlena.com/GeneralBits/Tidbits/annotated_conf_e.html + + +Some important points of my postgresql.conf file : + +max_connections =3D 510 +shared_buffer =3D 16384 +max_prepared_transactions =3D 510 +work_mem =3D 1024 +maintenance_work_mem =3D 1024 +fsync =3D off +wal_buffers =3D 32 +commit_delay =3D 500 +checkpoint_segments =3D 10 +checkpoint_timeout =3D 300 +checkpoint_warning =3D 0 +effective_cache_size =3D 165 000 +autovaccuum =3D on +default_transaction_isolation =3D 'read_committed' + +What do you think of my tunning ? + +Best regards. + +O.A + +---------------------------(end of broadcast)--------------------------- +TIP 5: don't forget to increase your free space map settings + +!DSPAM:446c453a198591465223968! + + + + + +From pgsql-performance-owner@postgresql.org Thu May 18 07:59:49 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 236679FA293 + for ; + Thu, 18 May 2006 07:59:49 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 12449-03 + for ; + Thu, 18 May 2006 07:59:43 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.198]) + by postgresql.org (Postfix) with ESMTP id BC42F9F9C18 + for ; + Thu, 18 May 2006 07:59:44 -0300 (ADT) +Received: by wx-out-0102.google.com with SMTP id s7so42421wxc + for ; + Thu, 18 May 2006 03:59:42 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=o6/PEc7u5LYCrmAITmp/YWJYYwYHQzw3w04FfI1PhT95Uj5i0ejlfbo5gEfSE4DfXKoBz1mQ/mVSLKkf+mXiHEXMBG8eaV7Wd6jptfladQ1krNC2xI1Oo6YQqWCIBrqmjqbMRS1ubKttJYx3E6WpyUGagIXpKCf6FD00T+6SjEs= +Received: by 10.70.51.14 with SMTP id y14mr477548wxy; + Thu, 18 May 2006 03:59:42 -0700 (PDT) +Received: by 10.70.73.3 with HTTP; Thu, 18 May 2006 03:59:42 -0700 (PDT) +Message-ID: +Date: Thu, 18 May 2006 12:59:42 +0200 +From: "Olivier Andreotti" +To: "Guido Neitzer" +Subject: Re: Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle 10g2 +Cc: pgsql-performance@postgresql.org +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/383 +X-Sequence-Number: 19170 + +> +> Do you use prepared statements through JDBC with bound variables? If +> yes, you might have problems with PostgreSQL not choosing optimal +> plans because every statement is planned "generically" which may +> force PostgreSQL not to use indexes. +> + +i used prepared statements for the 3 databases. + +> > shared_buffer =3D 16384 +> +> This may be higher. +> + +I'll try that. + + +> > autovaccuum =3D on +> +> And you are sure, it's running? +> + +Yes, i can see autovaccum in the postgresql.log. + +From pgsql-performance-owner@postgresql.org Thu May 18 08:02:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B4E0E9FA2DB + for ; + Thu, 18 May 2006 08:02:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 11891-07 + for ; + Thu, 18 May 2006 08:02:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.pharmaline.de (mail.pharmaline.de [62.153.135.34]) + by postgresql.org (Postfix) with ESMTP id 960379F9C18 + for ; + Thu, 18 May 2006 08:02:32 -0300 (ADT) +Received: from [192.168.2.121] (62.153.135.40) by mail.pharmaline.de with + ESMTP (Eudora Internet Mail Server 3.2.7); + Thu, 18 May 2006 13:02:29 +0200 +In-Reply-To: +References: + <1147947373.7943.35.camel@dell.home.lan> + +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <55F18CC9-3DEE-4B11-A9F2-EDD8FBB5495E@pharmaline.de> +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Guido Neitzer +Subject: Re: Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle +Date: Thu, 18 May 2006 13:02:29 +0200 +To: Olivier Andreotti +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/384 +X-Sequence-Number: 19171 + +On 18.05.2006, at 12:42 Uhr, Olivier Andreotti wrote: + +> I use prepared statements for all requests. Each transaction is about +> 5-45 requests. + +This may lead to bad plans (at least with 8.0.3 this was the +case) ... I had the same problem a couple of months ago and I +switched from prepared statements with bound values to statements +with "inlined" values: + +SELECT + t0.aktiv, t0.id, t0.ist_teilnehmer, t0.nachname, t0.plz, t0.vorname +FROM + public.dga_dienstleister t0 +WHERE t0.plz like ?::varchar(256) ESCAPE '|' + +withBindings: 1:"53111"(plz) + +has changed in my app to: + +SELECT + t0.aktiv, t0.id, t0.ist_teilnehmer, t0.nachname, t0.plz, t0.vorname +FROM + public.dga_dienstleister t0 +WHERE t0.plz like '53111' ESCAPE '|' + + +The problem was, that the planner wasn't able to use an index with +the first version because it just didn't know enough about the actual +query. + +It might be, that you run into similar problems. An easy way to test +this may be to set the protocolVersion in the JDBC driver connection +url to "2": + +jdbc:postgresql://127.0.0.1/Database?protocolVersion=2 + +cug + +-- +PharmaLine, Essen, GERMANY +Software and Database Development + + + +From pgsql-performance-owner@postgresql.org Thu May 18 09:44:57 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id ADC1D9FA293 + for ; + Thu, 18 May 2006 09:44:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27044-04 + for ; + Thu, 18 May 2006 09:44:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from my.endian.it (unknown [62.146.87.34]) + by postgresql.org (Postfix) with ESMTP id BF4E59F9C18 + for ; + Thu, 18 May 2006 09:44:43 -0300 (ADT) +Received: from dell.home.lan (host45-104.pool875.interbusiness.it + [87.5.104.45]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id k4ICn3104140; + Thu, 18 May 2006 14:49:03 +0200 +Subject: Re: Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle +From: Chris Mair +To: Olivier Andreotti +Cc: pgsql-performance@postgresql.org +In-Reply-To: +References: + <1147947373.7943.35.camel@dell.home.lan> + +Content-Type: text/plain +Date: Thu, 18 May 2006 14:44:40 +0200 +Message-Id: <1147956280.9324.7.camel@dell.home.lan> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-27) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/385 +X-Sequence-Number: 19172 + + +> > Could you give us some more infos about the box' performance while you +> > run the PG benchmark? A few minutes output of "vmstat 10" maybe? What +> > does "top" say? +> +> > +> Here, an extract from the vmstat 3 during the test, you can see that +> my problem is probably a very high disk usage (write and read). +> + +> procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu---- +> r b swpd free buff cache si so bi bo in cs us sy id wa +> 0 11 92 128344 9224 2428432 0 0 287 9691 2227 685 4 3 0 93 +> [...] + +Yes, as is the case most of the time, disk I/O is the bottleneck here... +I'd look into everything disk releated here... + + + +> > How are you using the 3 disks? Did you split pg_xlog and the database +> > on different disks or not? +> > +> +> Data are on disk 1 et 2. Index on disk 3. Perhaps i'm wrong but fsync +> = off, pg_xlog are running with that ? + +Yes, pg_xlog ist also used with fsync=off. you might gain quite some +performance if you can manage to put pg_xlog on its own disk (just +symlink the directory). + +Anyway, as others have pointed out, consider that with fsync = off +you're loosing the "unbreakability" in case of power failures / os +crashes etc. + + +> > Can you say something about the clients? Do they run over network from +> > other hosts? What language/bindings do they use? +> > +> +> Client is another server from the same network. Clients are connected +> with JDBC connector. + + +ok, don't know about that one.. + +> > When they do inserts, are the inserts bundled or are there +> > single insert transactions? Are the statements prepared? + +> I use prepared statements for all requests. Each transaction is about +> 5-45 requests. + +sounds ok, +could be even more bundled together if the application is compatible +with that. + + +Bye, Chris. + + + +From pgsql-performance-owner@postgresql.org Thu May 18 11:11:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 696639FA2DB + for ; + Thu, 18 May 2006 11:11:05 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 50706-10 + for ; + Thu, 18 May 2006 11:10:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.wirelesscar.com (mail.wirelesscar.com [212.209.35.30]) + by postgresql.org (Postfix) with ESMTP id 6B04A9FA293 + for ; + Thu, 18 May 2006 11:10:57 -0300 (ADT) +Received: from sesrv12.wirelesscar.com ([192.168.10.17]) by + mail.wirelesscar.com with InterScan Messaging Security Suite; + Thu, 18 May 2006 16:10:53 +0200 +X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 +content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Subject: Re: Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle 10g2 +Content-Transfer-Encoding: quoted-printable +Date: Thu, 18 May 2006 16:11:51 +0200 +Message-ID: <7F10D26ECFA1FB458B89C5B4B0D72C2B459FFB@sesrv12.wirelesscar.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle + 10g2 +Thread-Index: AcZ6Yb2RhWzGfCTwTKugCz5kuT3XawAHRRSw +From: "Mikael Carneholm" +To: "Olivier Andreotti" , + +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/386 +X-Sequence-Number: 19173 + +What filesystem are you using - ext2/etx3/xfs/jfs/...? Does the SCSI +controller have a battery backed cache? For ext3, mounting it with +data=3Dwriteback should give you quite a boost in write performance. + +What benchmark tool are you using - is it by any chance BenchmarkSQL? +(since you mention that it is JDBC and prepared statements). + +Just to let you know, I've tested PostgreSQL 8.1.3 against a well-known +proprietary DB (let's call it RS for "Rising Sun") on similar hardware +(single Xeon CPU, 6Gb Ram, single SCSI disk for tables+indexes+pg_xlog) +using BenchmarkSQL and found that Postgres was capable of handling up to +8 times (yes, 8 times) as many transactions per minute, starting at 2 +times as many for a single user going to 8 times as many at 10 +concurrent users, consistent all the way up to 100 concurrent users. +BenchmarkSQL stops at 100 users ("terminals") so I don't know what it +looks like with 200, 300 or 500 users. + +Heck, the single disk Postgres instance did even beat our RS production +system in this benchmark, and in that case the RS instance has a fully +equipped EMC SAN. (although low-end) + +I personally don't care about MySQL as I don't consider it to be a DBMS +at all (breaking the consistency and durability ACID rules disqualifies +it hands-down). That company/product is one of the reasons I'm ashamed +of being swedish.. + +Btw, check you logfile for hints regarding increasing max_fsm_pages, and +consider increasing checkpoint_segments as well. You could also play +with more aggressive bgwriter_* params to reduce the risk for long +vacuum pauses. + +- Mikael + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org] On Behalf Of Olivier +Andreotti +Sent: den 18 maj 2006 11:57 +To: pgsql-performance@postgresql.org +Subject: [PERFORM] Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle +10g2 + +Hello, + +I'm running a benchmark with theses 3 databases, and the first results +are not very good for PostgreSQL. + +PostgreSQL is 20% less performance than MySQL (InnoDB tables) + +My benchmark uses the same server for theses 3 databases : +Dell Power edge - Xeon 2.8 Ghz - 2 Go Ram - 3 SCSI disks - Debian Sarge +- Linux 2.6 + +The transactions are a random mix of request in read (select) and write +(insert, delete, update) on many tables about 100 000 to 15 000 000 +rows. + +Transactions are executed from 500 connections. + +For the tunning of PostgreSQL i use official documentation and theses +web sites : + +http://www.revsys.com/writings/postgresql-performance.html +http://www.varlena.com/GeneralBits/Tidbits/annotated_conf_e.html + + +Some important points of my postgresql.conf file : + +max_connections =3D 510 +shared_buffer =3D 16384 +max_prepared_transactions =3D 510 +work_mem =3D 1024 +maintenance_work_mem =3D 1024 +fsync =3D off +wal_buffers =3D 32 +commit_delay =3D 500 +checkpoint_segments =3D 10 +checkpoint_timeout =3D 300 +checkpoint_warning =3D 0 +effective_cache_size =3D 165 000 +autovaccuum =3D on +default_transaction_isolation =3D 'read_committed' + +What do you think of my tunning ? + +Best regards. + +O.A + +---------------------------(end of broadcast)--------------------------- +TIP 5: don't forget to increase your free space map settings + + +From pgsql-performance-owner@postgresql.org Thu May 18 11:48:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8728E9FA293 + for ; + Thu, 18 May 2006 11:48:39 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 03703-02 + for ; + Thu, 18 May 2006 11:48:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 3C9C29F9C18 + for ; + Thu, 18 May 2006 11:48:25 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4IEmKDO013689; + Thu, 18 May 2006 10:48:20 -0400 (EDT) +To: "Mikael Carneholm" +cc: "Olivier Andreotti" , + pgsql-performance@postgresql.org +Subject: Re: Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle 10g2 +In-reply-to: <7F10D26ECFA1FB458B89C5B4B0D72C2B459FFB@sesrv12.wirelesscar.com> +References: <7F10D26ECFA1FB458B89C5B4B0D72C2B459FFB@sesrv12.wirelesscar.com> +Comments: In-reply-to "Mikael Carneholm" + message dated "Thu, 18 May 2006 16:11:51 +0200" +Date: Thu, 18 May 2006 10:48:20 -0400 +Message-ID: <13688.1147963700@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/387 +X-Sequence-Number: 19174 + +"Mikael Carneholm" writes: +> Btw, check you logfile for hints regarding increasing max_fsm_pages, and +> consider increasing checkpoint_segments as well. You could also play +> with more aggressive bgwriter_* params to reduce the risk for long +> vacuum pauses. + +Yeah, checkpoint_segments is a really critical number for any +write-intensive situation. Pushing it up to 30 or more can make a big +difference. You might want to set checkpoint_warning to a large value +(300 or so) so you can see in the log how often checkpoints are +happening. You really don't want checkpoints to happen more than about +once every five minutes, because not only does the checkpoint itself +cost a lot of I/O, but there is a subsequent penalty of increased WAL +traffic due to fresh page images getting dumped into WAL. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu May 18 11:52:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9EF559FA293 + for ; + Thu, 18 May 2006 11:52:48 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 03072-05-3 + for ; + Thu, 18 May 2006 11:52:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.rentalia.net (mail.rentalia.com [213.192.209.8]) + by postgresql.org (Postfix) with ESMTP id 3BDF29F9C18 + for ; + Thu, 18 May 2006 11:52:37 -0300 (ADT) +Received: (qmail 7444 invoked by uid 514); 18 May 2006 16:52:32 +0200 +Received: from 62.37.217.203 by rigodon (envelope-from , + uid 512) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1284. spamassassin: 3.0.2. perlscan: 1.25-st-qms. + Clear:RC:0(62.37.217.203):SA:0(-2.2/5.0):. + Processed in 4.817248 secs); 18 May 2006 14:52:32 -0000 +X-Antivirus-MYDOMAIN-Mail-From: ruben@rentalia.com via rigodon +X-Antivirus-MYDOMAIN: 1.25-st-qms (Clear:RC:0(62.37.217.203):SA:0(-2.2/5.0):. + Processed in 4.817248 secs Process 7095) +Received: from 62-37-217-203.mad1.adsl.uni2.es (HELO ?192.168.2.28?) + (ruben@rentalia.com@62.37.217.203) + by mail.rentalia.net with SMTP; 18 May 2006 16:52:27 +0200 +Message-ID: <446C8A27.9030100@rentalia.com> +Date: Thu, 18 May 2006 16:52:23 +0200 +From: Ruben Rubio Rey +User-Agent: Mozilla Thunderbird 1.0.8 (X11/20060503) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: john_oshea@wordbank.com +CC: pgsql-performance@postgresql.org +Subject: Re: SQL CPU time usage +References: <446B3F6A.9070205@rentalia.com> + <25265881-37A8-4CD4-952F-3E7F4CE97F4D@wordbank.com> +In-Reply-To: <25265881-37A8-4CD4-952F-3E7F4CE97F4D@wordbank.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/388 +X-Sequence-Number: 19175 + +john_oshea@wordbank.com wrote: + +> On 17 May 2006, at 16:21, Ruben Rubio Rey wrote: +> +>> I have a web page, that executes several SQLs. +>> +>> So, I would like to know witch one of those SQLs consumes more CPU. +>> For example, +>> I have SQL1 that is executed in 1.2 secs and a SQL2 that is executed +>> in 200 ms. +>> +>> But SQL2 is executed 25 times and SQL1 is executed 1 time, so really +>> SQL2 consumes more CPU time. +>> +>> Is there any way to know this? +>> I have think that logging all SQLs and then cheking it is a way to +>> do it ... any other idea? +> +> +> Practical Query Analysis: does +> exactly that (scan historic logs). Very nice indeed and more than +> worth the money (it's BSD-licensed) +> +thanks + +From pgsql-performance-owner@postgresql.org Thu May 18 12:20:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 25F7B9FA2DB + for ; + Thu, 18 May 2006 12:20:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 19795-03 + for ; + Thu, 18 May 2006 12:20:22 -0300 (ADT) +X-Greylist: delayed 21:29:58.794584 by SQLgrey- +Received: from sottsym2.entrust.com (sottsym2.entrust.com [216.191.252.20]) + by postgresql.org (Postfix) with ESMTP id C0BCE9FA293 + for ; + Thu, 18 May 2006 12:20:20 -0300 (ADT) +Received: from sottmxsecs3.entrust.com (unknown [216.191.252.14]) + by sottsym2.entrust.com (Symantec Mail Security) with SMTP id 5BE9B1115 + for ; + Thu, 18 May 2006 11:20:18 -0400 (EDT) +Received: (qmail 22108 invoked from network); 18 May 2006 15:20:17 -0000 +Received: from Chris.McKenzie@entrust.com by sottmxsecs3.entrust.com with + EntrustECS-Server-7.4; 18 May 2006 15:20:17 -0000 +Received: from sottmxs00.entrust.com (10.4.61.22) + by sottmxsecs3.entrust.com with SMTP; 18 May 2006 15:20:17 -0000 +Received: by sottmxs00.entrust.com with Internet Mail Service (5.5.2657.72) + id ; Thu, 18 May 2006 11:20:18 -0400 +Message-ID: +From: Chris Mckenzie +To: "'Jim C. Nasby'" , pgsql-performance@postgresql.org +Subject: Re: Performance/Maintenance test result collection +Date: Thu, 18 May 2006 11:20:17 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2657.72) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C67A8E.91711841" +X-Brightmail-Tracker: AAAAAA== +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/389 +X-Sequence-Number: 19176 + + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C67A8E.91711841 +Content-Type: text/plain + +Yes, regular versus full vacuum. Thanks for the comment but I was hoping to +come to that conclusion on my own by observing the affects of the different +vacuums. + +My original question was guidance on collecting data for confirmation on the +impact that maintenance of a large database (as a result of my applications +regular usage over a period of time) has. + +I can du the various tables and compare their size before/after against the +verbose output of a VACUUM FULL. I can use sar during all of this to monitor +cpu and i/o activity. I can turn on transaction logging once I get a better +idea of maintenance impact on my hardware so identify the biggest +transactions that might statement timeout if a VACUUM was running at the +same time. + +Any suggestions or comments related to collection of this type of data would +be helpful. I've already read the Postges 7.4 (yes, I'm stuck on 7.4) +manual, I was hoping for this mail-list' wisdom to supply me with some tips +that can only be learnt through painful experience. :-) + +Thanks. + +- Chris + +-----Original Message----- +From: Jim C. Nasby [mailto:jnasby@pervasive.com] +Sent: Wednesday, May 17, 2006 3:25 PM +To: Chris Mckenzie +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Performance/Maintenance test result collection + + +On Wed, May 17, 2006 at 01:50:22PM -0400, Chris Mckenzie wrote: +> Hi. +> +> I'm trying to plan for a performance test session where a large +> database is subject to regular hits from my application while both +> regular and full database maintenance is being performed. The idea is +> to gain a better idea on the impact maintenance will have on regular +> usage, and when to reasonably schedule both regular and full +> maintenance. + +What do you mean by "regular and full maintenance"? Do you mean VACUUM FULL? + +If you're vacuuming appropriately you shouldn't have any need to ever VACUUM +FULL... +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +------_=_NextPart_001_01C67A8E.91711841 +Content-Type: text/html +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] Performance/Maintenance test result = +collection + + + +

Yes, regular versus full vacuum. Thanks for the = +comment but I was hoping to come to that conclusion on my own by = +observing the affects of the different vacuums.

+ +

My original question was guidance on collecting data = +for confirmation on the impact that maintenance of a large database (as = +a result of my applications regular usage over a period of time) = +has.

+ +

I can du the various tables and compare their size = +before/after against the verbose output of a VACUUM FULL. I can use sar = +during all of this to monitor cpu and i/o activity. I can turn on = +transaction logging once I get a better idea of maintenance impact on = +my hardware so identify the biggest transactions that might statement = +timeout if a VACUUM was running at the same time.

+ +

Any suggestions or comments related to collection of = +this type of data would be helpful. I've already read the Postges 7.4 = +(yes, I'm stuck on 7.4) manual, I was hoping for this mail-list' wisdom = +to supply me with some tips that can only be learnt through painful = +experience. :-)

+ +

Thanks. +

+ +

- Chris +

+ +

-----Original Message----- +
From: Jim C. Nasby [mailto:jnasby@pervasive.com] = + +
Sent: Wednesday, May 17, 2006 3:25 PM +
To: Chris Mckenzie +
Cc: pgsql-performance@postgresql.org +
Subject: Re: [PERFORM] Performance/Maintenance test = +result collection +

+
+ +

On Wed, May 17, 2006 at 01:50:22PM -0400, Chris = +Mckenzie wrote: +
> Hi. +
> +
> I'm trying to plan for a performance test = +session where a large +
> database is subject to regular hits from my = +application while both +
> regular and full database maintenance is being = +performed. The idea is +
> to gain a better idea on the impact maintenance = +will have on regular +
> usage, and when to reasonably schedule both = +regular and full +
> maintenance. +

+ +

What do you mean by "regular and full = +maintenance"? Do you mean VACUUM FULL? +

+ +

If you're vacuuming appropriately you shouldn't have = +any need to ever VACUUM FULL... +
-- +
Jim C. Nasby, Sr. Engineering = +Consultant      jnasby@pervasive.com +
Pervasive Software      http://pervasive.com    work: = +512-231-6117 +
vcard: http://jim.nasby.net/pervasive.vcf  &nbs= +p;    cell: 512-569-9461 +

+ + + +------_=_NextPart_001_01C67A8E.91711841-- + +From pgsql-performance-owner@postgresql.org Thu May 18 12:52:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AE39A9FA293 + for ; + Thu, 18 May 2006 12:52:16 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 31050-03 + for ; + Thu, 18 May 2006 12:52:06 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from web30701.mail.mud.yahoo.com (web30701.mail.mud.yahoo.com + [68.142.200.134]) + by postgresql.org (Postfix) with SMTP id 2E7A99F9C18 + for ; + Thu, 18 May 2006 12:52:06 -0300 (ADT) +Received: (qmail 66325 invoked by uid 60001); 18 May 2006 15:52:05 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=tClIw9n3byzbbC/0YSrAqD5IkzpcAljk9Fcl4z23OHUxJQkak62TOKio3h7iuV9gRzZYEr0MzOTep/ad2eXF1CLn/S3E0crX8R/nYx9DFxnkHqsMM7tVO/H4klp645hqXUK5dxHrSZHcXqQfwwCw+QOS9FuzOe5cOXAGYJB27SM= + ; +Message-ID: <20060518155204.66320.qmail@web30701.mail.mud.yahoo.com> +Received: from [206.83.255.230] by web30701.mail.mud.yahoo.com via HTTP; + Thu, 18 May 2006 08:52:04 PDT +Date: Thu, 18 May 2006 08:52:04 -0700 (PDT) +From: Stephen Byers +Subject: why is bitmap index chosen for this query? +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0-1292529740-1147967524=:66085" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/390 +X-Sequence-Number: 19177 + +--0-1292529740-1147967524=:66085 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +Could someone explain the results of the following? This is with postgres 8.1.2 on a database that was just vacuum-verbose-analyzed. I have packets_i4 index which I am expecting to be used with this query but as you can see, I have have to convince its usage by turning off other scans. The total runtime is pretty drastic when the index is not chosen. When using a cursor, the query using the index is the only one that provides immediate results. Also, what is Recheck Cond? + + adbs_db=# \d packets + Table "public.packets" + Column | Type | Modifiers +-------------------------+------------------------+-------------------- + system_time_secs | integer | not null + system_time_subsecs | integer | not null + spacecraft_time_secs | integer | not null + spacecraft_time_subsecs | integer | not null + mnemonic | character varying(64) | + mnemonic_id | integer | not null + data_length | integer | not null + data | bytea | not null + volume_label | character varying(128) | not null + tlm_version_name | character varying(32) | not null + environment_name | character varying(32) | not null + quality | integer | not null default 0 +Indexes: + "packets_i1" btree (volume_label) + "packets_i4" btree (environment_name, system_time_secs, system_time_subsecs, mnemonic) + "packets_i5" btree (environment_name, spacecraft_time_secs, spacecraft_time_subsecs, mnemonic) + + + adbs_db=# explain analyze select spacecraft_time_secs,mnemonic,volume_label + from packets where environment_name='PASITCTX01' + and system_time_secs>=1132272000 and system_time_secs<=1143244800; + + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------- + Bitmap Heap Scan on packets (cost=247201.41..2838497.72 rows=12472989 width=47) (actual time=573856.344..771866.516 rows=13365371 loops=1) + Recheck Cond: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800)) + -> Bitmap Index Scan on packets_i4 (cost=0.00..247201.41 rows=12472989 width=0) (actual time=573484.199..573484.199 rows=13365371 loops=1) + Index Cond: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800)) + Total runtime: 777208.041 ms +(5 rows) + + + adbs_db=# set enable_bitmapscan to off; +SET + + adbs_db=# explain analyze select spacecraft_time_secs,mnemonic,volume_label + from packets where environment_name='PASITCTX01' + and system_time_secs>=1132272000 and system_time_secs<=1143244800; + + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on packets (cost=0.00..3045957.30 rows=12472989 width=47) (actual time=58539.693..493056.015 rows=13365371 loops=1) + Filter: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800)) + Total runtime: 498620.963 ms +(3 rows) + + + adbs_db=# set enable_seqscan to off; + SET + + adbs_db=# explain analyze select spacecraft_time_secs,mnemonic,volume_label + from packets where environment_name='PASITCTX01' + and system_time_secs>=1132272000 and system_time_secs<=1143244800; + + + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------ + Index Scan using packets_i4 on packets (cost=0.00..19908567.85 rows=12472989 width=47) (actual time=47.691..206028.754 rows=13365371 loops=1) + Index Cond: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800)) + Total runtime: 211644.843 ms +(3 rows) + + + +--------------------------------- +Blab-away for as little as 1�/min. Make PC-to-Phone Calls using Yahoo! Messenger with Voice. +--0-1292529740-1147967524=:66085 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +
Could someone explain the results of the following?  This is with postgres 8.1.2 on a database that was just vacuum-verbose-analyzed.  I have packets_i4 index which I am expecting to be used with this query but as you can see, I have have to convince its usage by turning off other scans.  The total runtime is pretty drastic when the index is not chosen.  When using a cursor, the query using the index is the only one that provides immediate results.  Also, what is Recheck Cond?
 
adbs_db=#   \d packets
                        Table "public.packets"
         Column          |          Type          + |     Modifiers     
-------------------------+------------------------+--------------------
 system_time_secs        | integer                | not null
 system_time_subsecs     | integer                | not null
 spacecraft_time_secs    | integer                | not null
 spacecraft_time_subsecs | integer                | not null
 mnemonic                | character varying(64)  | +
 mnemonic_id             | integer                | not null
 data_length             | integer                | not null
 data                    | bytea                  | not null
 volume_label            | character varying(128) | not null
 tlm_version_name        | character varying(32)  | not null
 environment_name        | character + varying(32)  | not null
 quality                 | integer                | not null default 0
Indexes:
    "packets_i1" btree (volume_label)
    "packets_i4" btree (environment_name, system_time_secs, system_time_subsecs, mnemonic)
    "packets_i5" btree (environment_name, spacecraft_time_secs, spacecraft_time_subsecs, mnemonic)
 
adbs_db=# explain analyze select spacecraft_time_secs,mnemonic,volume_label
  from packets   where environment_name='PASITCTX01'
  and system_time_secs>=1132272000 and system_time_secs<=1143244800;

               QUERY + PLAN                                                                   
-------------------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on packets  (cost=247201.41..2838497.72 rows=12472989 width=47) (actual time=573856.344..771866.516 rows=13365371 loops=1)
   Recheck Cond: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800))
   ->  Bitmap Index Scan on packets_i4  (cost=0.00..247201.41 rows=12472989 width=0) + (actual time=573484.199..573484.199 rows=13365371 loops=1)
         Index Cond: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800))
 Total runtime: 777208.041 ms
(5 rows)
 
adbs_db=# set enable_bitmapscan to off;
SET
adbs_db=# explain analyze select spacecraft_time_secs,mnemonic,volume_label
  from packets   where environment_name='PASITCTX01'
  and system_time_secs>=1132272000 and system_time_secs<=1143244800;
+

                                                              QUERY PLAN                                                              
---------------------------------------------------------------------------------------------------------------------------------------
 Seq Scan on packets  (cost=0.00..3045957.30 rows=12472989 width=47) + (actual time=58539.693..493056.015 rows=13365371 loops=1)
   Filter: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800))
 Total runtime: 498620.963 ms
(3 rows)
 
adbs_db=# set enable_seqscan to off;
SET
 
adbs_db=# explain analyze select spacecraft_time_secs,mnemonic,volume_label
  from packets   where environment_name='PASITCTX01'
  and system_time_secs>=1132272000 and system_time_secs<=1143244800;

            QUERY + PLAN                                                                  
------------------------------------------------------------------------------------------------------------------------------------------------
 Index Scan using packets_i4 on packets  (cost=0.00..19908567.85 rows=12472989 width=47) (actual time=47.691..206028.754 rows=13365371 loops=1)
   Index Cond: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800))
 Total runtime: 211644.843 ms
(3 rows)

+


Blab-away for as little as 1�/min. Make PC-to-Phone Calls using Yahoo! Messenger with Voice. +--0-1292529740-1147967524=:66085-- + +From pgsql-performance-owner@postgresql.org Thu May 18 12:59:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C2DD89F9F8F + for ; + Thu, 18 May 2006 12:59:20 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27681-10 + for ; + Thu, 18 May 2006 12:59:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id 2A8159F969C + for ; + Thu, 18 May 2006 12:59:07 -0300 (ADT) +Received: from trofast.ipv6.sesse.net ([2001:700:300:dc03:20e:cff:fe36:a766] + helo=trofast.sesse.net) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1Fgku1-0001rX-QZ + for pgsql-performance@postgresql.org; Thu, 18 May 2006 17:59:06 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1Fgku2-0001pN-00 + for ; Thu, 18 May 2006 17:59:06 +0200 +Date: Thu, 18 May 2006 17:59:06 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: why is bitmap index chosen for this query? +Message-ID: <20060518155906.GA6909@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20060518155204.66320.qmail@web30701.mail.mud.yahoo.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <20060518155204.66320.qmail@web30701.mail.mud.yahoo.com> +X-Operating-System: Linux 2.6.16.11 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/391 +X-Sequence-Number: 19178 + +On Thu, May 18, 2006 at 08:52:04AM -0700, Stephen Byers wrote: +> Could someone explain the results of the following? + +It sounds like PostgreSQL badly overestimates the cost of the index scan. +Does the table perchance fit completely into memory, without +effective_cache_size indicating that? + +> Also, what is Recheck Cond? + +The bitmap index scan will by default allocate one bit per tuple. If it can't +hold a complete bitmap of every tuple in memory, it will fall back to +allocating one bit per (8 kB) page, since it will have to read the entire +page anyhow, and the most dramatic cost is the seek. However, in the latter +case, it will also get a few extra records that don't match the original +clause, so it will have to recheck the condition ("Recheck Cond") before +outputting the tuples to the parent node. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Thu May 18 13:01:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 235109FA4A0 + for ; + Thu, 18 May 2006 13:01:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 30017-10 + for ; + Thu, 18 May 2006 13:01:18 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nf-out-0910.google.com (nf-out-0910.google.com + [64.233.182.191]) + by postgresql.org (Postfix) with ESMTP id CCA5F9FA5FB + for ; + Thu, 18 May 2006 13:01:17 -0300 (ADT) +Received: by nf-out-0910.google.com with SMTP id y38so150601nfb + for ; + Thu, 18 May 2006 09:01:16 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=SlLpdCA+eXAs6vmF9+NL+cVgJKVQzbyGSxbWqj8vL0FuOlwv4KPxPbEgCeZ9eD4yVbaZyGKiGcVPOIlB/jH+8mqv2UzAARf9FCnl7sduXfb2KUGqlEd5PK4nmTSQ09nH0vhxCevWVR70dtmxLgsU9nTogEQiwADsvkO1+jwBr9U= +Received: by 10.48.239.8 with SMTP id m8mr654783nfh; + Thu, 18 May 2006 09:00:11 -0700 (PDT) +Received: by 10.48.47.1 with HTTP; Thu, 18 May 2006 09:01:16 -0700 (PDT) +Message-ID: <751e56400605180901g6a7854e9s6b21c27347b500e6@mail.gmail.com> +Date: Thu, 18 May 2006 20:01:16 +0400 +From: "Ivan Zolotukhin" +Reply-To: iz@sai.msu.ru +To: "Ruben Rubio Rey" +Subject: Re: SQL CPU time usage +Cc: pgsql-performance@postgresql.org +In-Reply-To: <446B3F6A.9070205@rentalia.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <446B3F6A.9070205@rentalia.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/392 +X-Sequence-Number: 19179 + +You may also try PgFouine (http://pgfouine.projects.postgresql.org/) +for log analysis, I found it very useful in similar situation. + + +On 5/17/06, Ruben Rubio Rey wrote: +> Hi, +> +> I have a web page, that executes several SQLs. +> +> So, I would like to know witch one of those SQLs consumes more CPU. +> For example, +> I have SQL1 that is executed in 1.2 secs and a SQL2 that is executed in +> 200 ms. +> +> But SQL2 is executed 25 times and SQL1 is executed 1 time, so really +> SQL2 consumes more CPU time. +> +> Is there any way to know this? +> I have think that logging all SQLs and then cheking it is a way to do it +> ... any other idea? +> +> Thanks in advance +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 2: Don't 'kill -9' the postmaster +> + +From pgsql-performance-owner@postgresql.org Thu May 18 13:41:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2FB819F9C18 + for ; + Thu, 18 May 2006 13:41:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 40285-02 + for ; + Thu, 18 May 2006 13:41:24 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from web30710.mail.mud.yahoo.com (web30710.mail.mud.yahoo.com + [68.142.200.143]) + by postgresql.org (Postfix) with SMTP id 403BC9F9316 + for ; + Thu, 18 May 2006 13:41:24 -0300 (ADT) +Received: (qmail 98858 invoked by uid 60001); 18 May 2006 16:41:23 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=kFAmeXt/KTUfUQv1kB9f4XyMttc5ieCK0L64VzNJp8Rff0nfupuYfw2ljQk3AfnMH1PIcJ7IDDMhVvX7Wn8ndWNO0lW3v31zM3pZPa5ljYGSUPkH2sHPgIn+9q1pEtMZtBM9z6Lt0GGDuLJ1Mi5SaW+ahH6jwmDXcQe9cSSf8Rs= + ; +Message-ID: <20060518164123.98856.qmail@web30710.mail.mud.yahoo.com> +Received: from [206.83.255.230] by web30710.mail.mud.yahoo.com via HTTP; + Thu, 18 May 2006 09:41:23 PDT +Date: Thu, 18 May 2006 09:41:23 -0700 (PDT) +From: Stephen Byers +Subject: Re: why is bitmap index chosen for this query? +To: "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +In-Reply-To: <20060518155906.GA6909@uio.no> +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0-1070734727-1147970483=:98027" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/393 +X-Sequence-Number: 19180 + +--0-1070734727-1147970483=:98027 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +"Steinar H. Gunderson" wrote: +It sounds like PostgreSQL badly overestimates the cost of the index scan. +Does the table perchance fit completely into memory, without +effective_cache_size indicating that? + + Don't know the exact way to answer your question, but my initial instinct is "no way." + select pg_relation_size('packets'); + pg_relation_size +------------------ + 19440115712 + + 19GB. So it's a big table. The query I submitted earlier returns about 13M rows and the table currently has about 38M rows. + + + + +--------------------------------- +Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2�/min with Yahoo! Messenger with Voice. +--0-1070734727-1147970483=:98027 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +"Steinar H. Gunderson" <sgunderson@bigfoot.com> wrote:

It sounds like PostgreSQL badly overestimates the cost of the index scan.
Does the table perchance fit completely into memory, without
effective_cache_size indicating that?

Don't know the exact way to answer your question, but my initial instinct is "no way."
  select pg_relation_size('packets');
 pg_relation_size
------------------
      19440115712
19GB.  So it's a big table.  The query I submitted earlier returns about 13M rows and the table currently has about 38M rows.
 
 

+


Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2�/min with Yahoo! Messenger with Voice. +--0-1070734727-1147970483=:98027-- + +From pgsql-performance-owner@postgresql.org Thu May 18 13:46:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 534809F9316 + for ; + Thu, 18 May 2006 13:46:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 41063-04 + for ; + Thu, 18 May 2006 13:46:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id ADFE49FA4E1 + for ; + Thu, 18 May 2006 13:46:44 -0300 (ADT) +Received: from trofast.sesse.net ([129.241.93.32]) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1Fgle3-0005Ry-VY + for pgsql-performance@postgresql.org; Thu, 18 May 2006 18:46:42 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1Fgle4-0001uE-00 + for ; Thu, 18 May 2006 18:46:40 +0200 +Date: Thu, 18 May 2006 18:46:40 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: why is bitmap index chosen for this query? +Message-ID: <20060518164640.GA7291@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20060518155906.GA6909@uio.no> + <20060518164123.98856.qmail@web30710.mail.mud.yahoo.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <20060518164123.98856.qmail@web30710.mail.mud.yahoo.com> +X-Operating-System: Linux 2.6.16.11 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/394 +X-Sequence-Number: 19181 + +On Thu, May 18, 2006 at 09:41:23AM -0700, Stephen Byers wrote: +> Does the table perchance fit completely into memory, without +> effective_cache_size indicating that? +> +> Don't know the exact way to answer your question, but my initial instinct is "no way." + +What about the working set? Have you tried running the queries multiple times +in a row to see if the results change? It might be that your initial bitmap +scan puts all the relevant bits into cache, which will skew the results. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Thu May 18 14:34:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 30F609F9316 + for ; + Thu, 18 May 2006 14:34:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 47645-05-4 + for ; + Thu, 18 May 2006 14:34:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 1DDCD9F9C18 + for ; + Thu, 18 May 2006 14:34:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4IHYJP8016020; + Thu, 18 May 2006 13:34:19 -0400 (EDT) +To: "Steinar H. Gunderson" +cc: pgsql-performance@postgresql.org, Stephen Byers +Subject: Re: why is bitmap index chosen for this query? +In-reply-to: <20060518164640.GA7291@uio.no> +References: <20060518155906.GA6909@uio.no> + <20060518164123.98856.qmail@web30710.mail.mud.yahoo.com> + <20060518164640.GA7291@uio.no> +Comments: In-reply-to "Steinar H. Gunderson" + message dated "Thu, 18 May 2006 18:46:40 +0200" +Date: Thu, 18 May 2006 13:34:19 -0400 +Message-ID: <16019.1147973659@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/395 +X-Sequence-Number: 19182 + +"Steinar H. Gunderson" writes: +> What about the working set? Have you tried running the queries multiple times +> in a row to see if the results change? It might be that your initial bitmap +> scan puts all the relevant bits into cache, which will skew the results. + +If the examples were done in the order shown, the seqscan ought to have +pretty well blown out the cache ... but I concur that it'd be +interesting to check whether repeated executions of the same plan show +markedly different times. + +Also, is the index order closely correlated to the actual physical +table order? + +What is work_mem set to, and does increasing it substantially make the +bitmap scan work any better? + +Considering that the query is fetching about half of the table, I'd have +thought that the planner was correct to estimate that bitmap or seqscan +ought to win. For the plain indexscan to win, the order correlation +must be quite strong, and I'm also guessing that the bitmap scan must +have run into some substantial trouble (like discarding a lot of info +because of lack of work_mem). + +IIRC, the planner doesn't currently try to model the effects of a bitmap +scan going into lossy mode, which is something it probably should try to +account for. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu May 18 16:38:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 780889FA2EB + for ; + Thu, 18 May 2006 16:38:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 65548-10 + for ; + Thu, 18 May 2006 16:38:20 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from web30710.mail.mud.yahoo.com (web30710.mail.mud.yahoo.com + [68.142.200.143]) + by postgresql.org (Postfix) with SMTP id 3E9249F9316 + for ; + Thu, 18 May 2006 16:38:20 -0300 (ADT) +Received: (qmail 81334 invoked by uid 60001); 18 May 2006 19:38:18 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=h+41FaS7rJoSmQSwmHtRDwnpHMFoVKLfrOzCdNNZBRwS1Asnxu5uklQA1NQ2jA6XdU0gYf8TbjyQwZFvFy71dSLPynB/tMwChRIRbusRs2Ag4JdaCiv0V4ato7ltzQBgaysXNHC8z64HQgH1O3kvGY1yyyuEJytZdIYR7b7b3Ew= + ; +Message-ID: <20060518193818.81332.qmail@web30710.mail.mud.yahoo.com> +Received: from [206.83.255.230] by web30710.mail.mud.yahoo.com via HTTP; + Thu, 18 May 2006 12:38:18 PDT +Date: Thu, 18 May 2006 12:38:18 -0700 (PDT) +From: Stephen Byers +Subject: Re: why is bitmap index chosen for this query? +To: Tom Lane , + "Steinar H. Gunderson" +Cc: pgsql-performance@postgresql.org, Stephen Byers +In-Reply-To: <16019.1147973659@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0-618168730-1147981098=:78989" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/396 +X-Sequence-Number: 19183 + +--0-618168730-1147981098=:78989 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +I repeated explain analyze on the query 5 times and it came up with the same plan. + +You asked about index order and physical table order. In general the index order is indeed close to the same order as the physical table order. However, this query is likely an exception. The data is actually from a backup server that has filled a hole for some of the time range that I'm specifying in my query. + + Work_mem was set to 10240. After your suggestion, I bumped it to 102400 and it looks like it did significantly impact performance. + + adbs_db=# explain analyze select spacecraft_time_secs,mnemonic,volume_label from packets +adbs_db-# where environment_name='PASITCTX01' +adbs_db-# and system_time_secs>=1132272000 and system_time_secs<=1143244800; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------- + Bitmap Heap Scan on packets (cost=247205.64..2838556.55 rows=12473252 width=47) (actual time=32118.943..187075.742 rows=13365371 loops=1) + Recheck Cond: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800)) + -> Bitmap Index Scan on packets_i4 (cost=0.00..247205.64 rows=12473252 width=0) (actual time=30370.789..30370.789 rows=13365371 loops=1) + Index Cond: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800)) + Total runtime: 191995.431 ms +(5 rows) + adbs_db=# +adbs_db=# +adbs_db=# adbs_db=# set enable_bitmapscan to off; +SET +adbs_db=# explain analyze select spacecraft_time_secs,mnemonic,volume_label from packets +adbs_db-# where environment_name='PASITCTX01' +adbs_db-# and system_time_secs>=1132272000 and system_time_secs<=1143244800; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------- + Seq Scan on packets (cost=0.00..3046021.47 rows=12473252 width=47) (actual time=56616.457..475839.789 rows=13365371 loops=1) + Filter: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800)) + Total runtime: 481228.409 ms +(3 rows) + adbs_db=# +adbs_db=# +adbs_db=# adbs_db=# set enable_seqscan to off; +SET +adbs_db=# explain analyze select spacecraft_time_secs,mnemonic,volume_label from packets +adbs_db-# where environment_name='PASITCTX01' +adbs_db-# and system_time_secs>=1132272000 and system_time_secs<=1143244800; + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------- + Index Scan using packets_i4 on packets (cost=0.00..19909080.77 rows=12473273 width=47) (actual time=3.511..188273.177 rows=13365371 loops=1) + Index Cond: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800)) + Total runtime: 194061.497 ms +(3 rows) + + + + Wow -- so what does that mean? Do I need to leave my work_mem at 100MB?? I mentioned that my application actually uses a cursor to walk through this data. Even though the bitmap scan technically had the fastest time with explain analyze, it takes a long while (20 seconds) before the results start to come back through the cursor. Conversely, with the index scan, results immediately come back through the cursor method (which is more desirable). Thoughts? + + Example: + begin; +declare myCursor cursor for + select spacecraft_time_secs,mnemonic,volume_label from packets + where environment_name='PASITCTX01' + and system_time_secs>=1132272000 + and system_time_secs<=1143244800; +fetch 10 from myCursor; +end; + + + PS, this is on a Sun Fire V240 with 4GB RAM, Solaris 8. + + Thanks, + Steve + + +Tom Lane wrote: + "Steinar H. Gunderson" writes: +> What about the working set? Have you tried running the queries multiple times +> in a row to see if the results change? It might be that your initial bitmap +> scan puts all the relevant bits into cache, which will skew the results. + +If the examples were done in the order shown, the seqscan ought to have +pretty well blown out the cache ... but I concur that it'd be +interesting to check whether repeated executions of the same plan show +markedly different times. + +Also, is the index order closely correlated to the actual physical +table order? + +What is work_mem set to, and does increasing it substantially make the +bitmap scan work any better? + +Considering that the query is fetching about half of the table, I'd have +thought that the planner was correct to estimate that bitmap or seqscan +ought to win. For the plain indexscan to win, the order correlation +must be quite strong, and I'm also guessing that the bitmap scan must +have run into some substantial trouble (like discarding a lot of info +because of lack of work_mem). + +IIRC, the planner doesn't currently try to model the effects of a bitmap +scan going into lossy mode, which is something it probably should try to +account for. + +regards, tom lane + + + +--------------------------------- +Sneak preview the all-new Yahoo.com. It's not radically different. Just radically better. +--0-618168730-1147981098=:78989 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +
I repeated explain analyze on the query 5 times and it came up with the same plan.

You asked about index order and physical table order.  In general the index order is indeed close to the same order as the physical table order.  However, this query is likely an exception.  The data is actually from a backup server that has filled a hole for some of the time range that I'm specifying in my query.
 
Work_mem was set to 10240.  After your suggestion, I bumped it to 102400 and it looks like it did significantly impact performance. 
 
adbs_db=# explain analyze select spacecraft_time_secs,mnemonic,volume_label from packets
adbs_db-#   where environment_name='PASITCTX01'
adbs_db-#   and system_time_secs>=1132272000 and + system_time_secs<=1143244800;
                                                                   QUERY PLAN                                                                    +
-------------------------------------------------------------------------------------------------------------------------------------------------
 Bitmap Heap Scan on packets  (cost=247205.64..2838556.55 rows=12473252 width=47) (actual time=32118.943..187075.742 rows=13365371 loops=1)
   Recheck Cond: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800))
   ->  Bitmap Index Scan on packets_i4  (cost=0.00..247205.64 rows=12473252 width=0) (actual time=30370.789..30370.789 rows=13365371 loops=1)
         Index Cond: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800))
 Total runtime: 191995.431 ms
(5 rows)
adbs_db=#
adbs_db=#
adbs_db=# adbs_db=# set enable_bitmapscan to off;
SET
adbs_db=# + explain analyze select spacecraft_time_secs,mnemonic,volume_label from packets
adbs_db-#   where environment_name='PASITCTX01'
adbs_db-#   and system_time_secs>=1132272000 and system_time_secs<=1143244800;
                                                              QUERY + PLAN                                                              
---------------------------------------------------------------------------------------------------------------------------------------
 Seq Scan on packets  (cost=0.00..3046021.47 rows=12473252 width=47) (actual time=56616.457..475839.789 rows=13365371 loops=1)
   Filter: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800))
 Total runtime: 481228.409 ms
(3 rows)
adbs_db=#
adbs_db=#
adbs_db=# adbs_db=# set enable_seqscan to off;
SET
adbs_db=# explain analyze + select spacecraft_time_secs,mnemonic,volume_label from packets
adbs_db-#   where environment_name='PASITCTX01'
adbs_db-#   and system_time_secs>=1132272000 and system_time_secs<=1143244800;
                                                                  QUERY + PLAN                                                                  
-----------------------------------------------------------------------------------------------------------------------------------------------
 Index Scan using packets_i4 on packets  (cost=0.00..19909080.77 rows=12473273 width=47) (actual time=3.511..188273.177 rows=13365371 loops=1)
   Index Cond: (((environment_name)::text = 'PASITCTX01'::text) AND (system_time_secs >= 1132272000) AND (system_time_secs <= 1143244800))
 Total runtime: 194061.497 ms
(3 rows)
 
 
 
Wow + -- so what does that mean?  Do I need to leave my work_mem at 100MB??  I mentioned that my application actually uses a cursor to walk through this data.  Even though the bitmap scan technically had the fastest time with explain analyze, it takes a long while (20 seconds) before the results start to come back through the cursor.  Conversely, with the index scan, results immediately come back through the cursor method (which is more desirable).  Thoughts? 
 
Example:
begin;
declare myCursor cursor for
  select spacecraft_time_secs,mnemonic,volume_label from packets
  where environment_name='PASITCTX01'
  and system_time_secs>=1132272000
  and system_time_secs<=1143244800;
fetch 10 from myCursor;
end;
 
PS, this is on a Sun Fire V240 with 4GB RAM, Solaris 8.
 
Thanks,
Steve
+
 

Tom Lane <tgl@sss.pgh.pa.us> wrote:
"Steinar H. Gunderson" writes:
> What about the working set? Have you tried running the queries multiple times
> in a row to see if the results change? It might be that your initial bitmap
> scan puts all the relevant bits into cache, which will skew the results.

If the examples were done in the order shown, the seqscan ought to have
pretty well blown out the cache ... but I concur that it'd be
interesting to check whether repeated executions of the same plan show
markedly different times.

Also, is the index order closely correlated to the actual physical
table order?

What is work_mem set to, and does increasing it substantially make the
bitmap scan work any better?

Considering that the query is + fetching about half of the table, I'd have
thought that the planner was correct to estimate that bitmap or seqscan
ought to win. For the plain indexscan to win, the order correlation
must be quite strong, and I'm also guessing that the bitmap scan must
have run into some substantial trouble (like discarding a lot of info
because of lack of work_mem).

IIRC, the planner doesn't currently try to model the effects of a bitmap
scan going into lossy mode, which is something it probably should try to
account for.

regards, tom lane

+ +


Sneak preview the all-new Yahoo.com. It's not radically different. Just radically better. + +--0-618168730-1147981098=:78989-- + +From pgsql-performance-owner@postgresql.org Thu May 18 16:48:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F19E09FA2EB + for ; + Thu, 18 May 2006 16:48:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 67992-07 + for ; + Thu, 18 May 2006 16:48:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id A39669F9C18 + for ; + Thu, 18 May 2006 16:48:16 -0300 (ADT) +Received: from trofast.ipv6.sesse.net ([2001:700:300:dc03:20e:cff:fe36:a766] + helo=trofast.sesse.net) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1FgoTk-0001oV-IY + for pgsql-performance@postgresql.org; Thu, 18 May 2006 21:48:13 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1FgoTl-0002EH-00 + for ; Thu, 18 May 2006 21:48:13 +0200 +Date: Thu, 18 May 2006 21:48:13 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: why is bitmap index chosen for this query? +Message-ID: <20060518194813.GA8539@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <16019.1147973659@sss.pgh.pa.us> + <20060518193818.81332.qmail@web30710.mail.mud.yahoo.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <20060518193818.81332.qmail@web30710.mail.mud.yahoo.com> +X-Operating-System: Linux 2.6.16.11 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/397 +X-Sequence-Number: 19184 + +On Thu, May 18, 2006 at 12:38:18PM -0700, Stephen Byers wrote: +> I repeated explain analyze on the query 5 times and it came up with the same plan. + +Yes, but did it end up with the same runtime? That's the interesting part -- +the plan will almost always be identical between explain analyze runs given +that you haven't done anything in between them. + +> You asked about index order and physical table order. In general the index +> order is indeed close to the same order as the physical table order. +> However, this query is likely an exception. The data is actually from a +> backup server that has filled a hole for some of the time range that I'm +> specifying in my query. + +Well, it still isn't all that far-fetched to believe that the data has lots +of correlation (which helps the index scan quite a lot) that the planner +isn't able to pick up. I don't know the details here, so I can't tell you how +the correlation for such a query (WHERE a=foo and b between bar and baz) is +estimated. Something tells me someone else might, though. :-) + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Thu May 18 16:53:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9CBAF9FA2EB + for ; + Thu, 18 May 2006 16:53:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 68361-07 + for ; + Thu, 18 May 2006 16:53:17 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from web30709.mail.mud.yahoo.com (web30709.mail.mud.yahoo.com + [68.142.200.142]) + by postgresql.org (Postfix) with SMTP id 956629F9C18 + for ; + Thu, 18 May 2006 16:53:17 -0300 (ADT) +Received: (qmail 38329 invoked by uid 60001); 18 May 2006 19:53:16 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=Ue7+aHp0g+tzOyV4pl29OIDVBAves8AKvp4k38TPmkmCdCkUBNJWTtIBzswKQtskjRy2vK3UpeGYVsM45+iVBPO5ih256QOEhLM6MvLWN/7vjvwIQmQyEWqnFf005mDqLJpOI+vuULcqqlX1DnRBmABrJ5vZTTO1oqh9Uv2yJSo= + ; +Message-ID: <20060518195316.38327.qmail@web30709.mail.mud.yahoo.com> +Received: from [206.83.255.230] by web30709.mail.mud.yahoo.com via HTTP; + Thu, 18 May 2006 12:53:16 PDT +Date: Thu, 18 May 2006 12:53:16 -0700 (PDT) +From: Stephen Byers +Subject: Re: why is bitmap index chosen for this query? +To: "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +In-Reply-To: <20060518194813.GA8539@uio.no> +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0-1954606787-1147981996=:36047" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/398 +X-Sequence-Number: 19185 + +--0-1954606787-1147981996=:36047 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +Yes, here are the runtimes for the repeated query. + Total runtime: 748716.750 ms +Total runtime: 749170.934 ms +Total runtime: 744113.594 ms +Total runtime: 746314.251 ms +Total runtime: 742083.732 ms + + Thanks, + Steve + +"Steinar H. Gunderson" wrote: + On Thu, May 18, 2006 at 12:38:18PM -0700, Stephen Byers wrote: +> I repeated explain analyze on the query 5 times and it came up with the same plan. + +Yes, but did it end up with the same runtime? That's the interesting part -- +the plan will almost always be identical between explain analyze runs given +that you haven't done anything in between them. + +> You asked about index order and physical table order. In general the index +> order is indeed close to the same order as the physical table order. +> However, this query is likely an exception. The data is actually from a +> backup server that has filled a hole for some of the time range that I'm +> specifying in my query. + +Well, it still isn't all that far-fetched to believe that the data has lots +of correlation (which helps the index scan quite a lot) that the planner +isn't able to pick up. I don't know the details here, so I can't tell you how +the correlation for such a query (WHERE a=foo and b between bar and baz) is +estimated. Something tells me someone else might, though. :-) + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +---------------------------(end of broadcast)--------------------------- +TIP 4: Have you searched our list archives? + +http://archives.postgresql.org + + + +--------------------------------- +Sneak preview the all-new Yahoo.com. It's not radically different. Just radically better. +--0-1954606787-1147981996=:36047 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +
Yes, here are the runtimes for the repeated query.
Total runtime: 748716.750 ms
Total runtime: 749170.934 ms
Total runtime: 744113.594 ms
Total runtime: 746314.251 ms
Total runtime: 742083.732 ms
Thanks,
Steve

"Steinar H. Gunderson" <sgunderson@bigfoot.com> wrote:
On Thu, May 18, 2006 at 12:38:18PM -0700, Stephen Byers wrote:
> I repeated explain analyze on the query 5 times and it came up with the same plan.

Yes, but did it end up with the same runtime? That's the interesting part --
the plan will almost always be identical between explain analyze runs given
that you haven't done anything in between them.

> You asked about index order and physical table order. In general the index
> order is indeed close to the same order as the physical table + order.
> However, this query is likely an exception. The data is actually from a
> backup server that has filled a hole for some of the time range that I'm
> specifying in my query.

Well, it still isn't all that far-fetched to believe that the data has lots
of correlation (which helps the index scan quite a lot) that the planner
isn't able to pick up. I don't know the details here, so I can't tell you how
the correlation for such a query (WHERE a=foo and b between bar and baz) is
estimated. Something tells me someone else might, though. :-)

/* Steinar */
--
Homepage: http://www.sesse.net/

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

+ +


Sneak preview the all-new Yahoo.com. It's not radically different. Just radically better. + +--0-1954606787-1147981996=:36047-- + +From pgsql-performance-owner@postgresql.org Thu May 18 17:16:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A8A7A9FA2EB + for ; + Thu, 18 May 2006 17:16:27 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 73212-07 + for ; + Thu, 18 May 2006 17:16:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id DAAC39F9C18 + for ; + Thu, 18 May 2006 17:16:15 -0300 (ADT) +Received: from trofast.sesse.net ([129.241.93.32]) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1Fgour-0003wG-KG + for pgsql-performance@postgresql.org; Thu, 18 May 2006 22:16:14 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1Fgous-0002GR-00 + for ; Thu, 18 May 2006 22:16:14 +0200 +Date: Thu, 18 May 2006 22:16:14 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: why is bitmap index chosen for this query? +Message-ID: <20060518201614.GA8640@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: <20060518194813.GA8539@uio.no> + <20060518195316.38327.qmail@web30709.mail.mud.yahoo.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <20060518195316.38327.qmail@web30709.mail.mud.yahoo.com> +X-Operating-System: Linux 2.6.16.11 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/399 +X-Sequence-Number: 19186 + +On Thu, May 18, 2006 at 12:53:16PM -0700, Stephen Byers wrote: +> Yes, here are the runtimes for the repeated query. +> Total runtime: 748716.750 ms +> Total runtime: 749170.934 ms +> Total runtime: 744113.594 ms +> Total runtime: 746314.251 ms +> Total runtime: 742083.732 ms + +With which options enabled? This isn't even close to any of the three times +you already posted. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Thu May 18 17:26:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F224D9FA48C + for ; + Thu, 18 May 2006 17:26:39 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 74997-10 + for ; + Thu, 18 May 2006 17:26:28 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from web30713.mail.mud.yahoo.com (web30713.mail.mud.yahoo.com + [68.142.201.251]) + by postgresql.org (Postfix) with SMTP id 41C539F9C18 + for ; + Thu, 18 May 2006 17:26:28 -0300 (ADT) +Received: (qmail 50899 invoked by uid 60001); 18 May 2006 20:26:26 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=dwePjREf5Ew68AurS+s8w1Ib5wkC1QQ/4GfwIbMsuXKc9nT8IzvSFNPvrRPFZncDGIGQUIX/XBudbKfggtxuo2GJYAznubnKPNNaD7swmqixhJ0oEAvVK3F7TT8y2Ilpr0YKBBezdnatrPB53VVBcFxpPmJvQPS1XHD5bopAnsM= + ; +Message-ID: <20060518202626.50897.qmail@web30713.mail.mud.yahoo.com> +Received: from [206.83.255.230] by web30713.mail.mud.yahoo.com via HTTP; + Thu, 18 May 2006 13:26:26 PDT +Date: Thu, 18 May 2006 13:26:26 -0700 (PDT) +From: Stephen Byers +Subject: Re: why is bitmap index chosen for this query? +To: "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +In-Reply-To: <20060518201614.GA8640@uio.no> +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0-1558254205-1147983986=:50537" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/400 +X-Sequence-Number: 19187 + +--0-1558254205-1147983986=:50537 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +You may be comparing the values to Tom's suggestion to bump up work_mem. Take a look at the original posting (Total runtime: 777208.041 ms for the bitmap scan) + + -Steve + +"Steinar H. Gunderson" wrote: + On Thu, May 18, 2006 at 12:53:16PM -0700, Stephen Byers wrote: +> Yes, here are the runtimes for the repeated query. +> Total runtime: 748716.750 ms +> Total runtime: 749170.934 ms +> Total runtime: 744113.594 ms +> Total runtime: 746314.251 ms +> Total runtime: 742083.732 ms + +With which options enabled? This isn't even close to any of the three times +you already posted. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +---------------------------(end of broadcast)--------------------------- +TIP 1: 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 + + + +--------------------------------- +Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2�/min or less. +--0-1558254205-1147983986=:50537 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +
You may be comparing the values to Tom's suggestion to bump up work_mem.  Take a look at the original posting (Total runtime: 777208.041 ms for the bitmap scan)
 
-Steve

"Steinar H. Gunderson" <sgunderson@bigfoot.com> wrote:
On Thu, May 18, 2006 at 12:53:16PM -0700, Stephen Byers wrote:
> Yes, here are the runtimes for the repeated query.
> Total runtime: 748716.750 ms
> Total runtime: 749170.934 ms
> Total runtime: 744113.594 ms
> Total runtime: 746314.251 ms
> Total runtime: 742083.732 ms

With which options enabled? This isn't even close to any of the three times
you already posted.

/* Steinar */
--
Homepage: http://www.sesse.net/

---------------------------(end of broadcast)---------------------------
TIP 1: 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

+


Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2�/min or less. +--0-1558254205-1147983986=:50537-- + +From pgsql-performance-owner@postgresql.org Fri May 19 07:24:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id ECEB59FA3AD + for ; + Fri, 19 May 2006 07:24:45 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 34937-05 + for ; + Fri, 19 May 2006 07:24:37 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.206]) + by postgresql.org (Postfix) with ESMTP id 47D659F9F8F + for ; + Fri, 19 May 2006 07:24:36 -0300 (ADT) +Received: by wx-out-0102.google.com with SMTP id h31so166438wxd + for ; + Fri, 19 May 2006 03:24:35 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=py+gkwtJdzr1rj+nlNfLMZkQ+j0V5yMusuoUQWGdunUxorjsUXLk59QQLWIkqxTJHyp8vBG/5iFgqLHKQlxOhQ71lHYL5e1xpljOrsDqphfo7UFIlfhwnc3LHsfny/bdl9Ba/a07R13FsBVQMvT8JhYVDPlQ5K9vcPxktxxbDBs= +Received: by 10.70.109.19 with SMTP id h19mr1353130wxc; + Fri, 19 May 2006 03:24:35 -0700 (PDT) +Received: by 10.70.74.19 with HTTP; Fri, 19 May 2006 03:24:35 -0700 (PDT) +Message-ID: +Date: Fri, 19 May 2006 12:24:35 +0200 +From: "Olivier Andreotti" +To: "Tom Lane" +Subject: Re: Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle 10g2 +Cc: "Mikael Carneholm" , + jean-paul@argudo.org, + pgsql-performance@postgresql.org +In-Reply-To: <13688.1147963700@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <7F10D26ECFA1FB458B89C5B4B0D72C2B459FFB@sesrv12.wirelesscar.com> + <13688.1147963700@sss.pgh.pa.us> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/401 +X-Sequence-Number: 19188 + +Hello everybody ! + +Thanks for all the advices, iI will try all theses new values, and +i'll post my final values on this thread. + +About the benchmark and the results, i dont know if can publish values +about Oracle performance ? For MySQL and PostgreSQL, i think there is +no problems. + +Just a last question about the pg_xlog : i understand that the +directory must be moved but i have just 3 disks for the database : +disk 1 and 2 for the data, disk 3 for the indexes, where can i put the +pg_xlog ? + +OA. + +From pgsql-performance-owner@postgresql.org Fri May 19 10:10:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 182799FA372 + for ; + Fri, 19 May 2006 10:10:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 58622-09 + for ; + Fri, 19 May 2006 10:10:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id E72529F9AFD + for ; + Fri, 19 May 2006 10:10:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4JDAKou028305; + Fri, 19 May 2006 09:10:21 -0400 (EDT) +To: "Olivier Andreotti" +cc: "Mikael Carneholm" , + jean-paul@argudo.org, pgsql-performance@postgresql.org +Subject: Re: Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle 10g2 +In-reply-to: +References: <7F10D26ECFA1FB458B89C5B4B0D72C2B459FFB@sesrv12.wirelesscar.com> + <13688.1147963700@sss.pgh.pa.us> + +Comments: In-reply-to "Olivier Andreotti" + message dated "Fri, 19 May 2006 12:24:35 +0200" +Date: Fri, 19 May 2006 09:10:20 -0400 +Message-ID: <28304.1148044220@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/402 +X-Sequence-Number: 19189 + +"Olivier Andreotti" writes: +> Just a last question about the pg_xlog : i understand that the +> directory must be moved but i have just 3 disks for the database : +> disk 1 and 2 for the data, disk 3 for the indexes, where can i put the +> pg_xlog ? + +If you have three disks then put the xlog on one of them and everything +else on the other two. Separating out the indexes is way less important +than getting xlog onto its very own spindle (at least for +write-intensive cases). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri May 19 17:16:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BF92A9FA22C + for ; + Fri, 19 May 2006 17:16:17 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 57867-10 + for ; + Fri, 19 May 2006 17:16:10 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 724A59FA278 + for ; + Fri, 19 May 2006 17:16:06 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id E60A456427; Fri, 19 May 2006 15:16:03 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Fri, 19 May 2006 15:16:03 -0500 +Date: Fri, 19 May 2006 15:16:01 -0500 +From: "Jim C. Nasby" +To: Chris Mair +Cc: Olivier Andreotti , + pgsql-performance@postgresql.org +Subject: Re: Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle +Message-ID: <20060519201600.GL64371@pervasive.com> +References: + <1147947373.7943.35.camel@dell.home.lan> + + <1147956280.9324.7.camel@dell.home.lan> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1147956280.9324.7.camel@dell.home.lan> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060519:list@1006.org::MQHS4WLrK4qK4cyu:000015hZ +X-Hashcash: + 1:20:060519:olivier.andreotti@gmail.com::GyhVg3VFDFImARe8:0000000000 + 00000000000000000000000025Pl +X-Hashcash: + 1:20:060519:pgsql-performance@postgresql.org::xrKT/ToqTM91bt/B:00000 + 00000000000000000000000007Me +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/403 +X-Sequence-Number: 19190 + +On Thu, May 18, 2006 at 02:44:40PM +0200, Chris Mair wrote: +> Yes, pg_xlog ist also used with fsync=off. you might gain quite some +> performance if you can manage to put pg_xlog on its own disk (just +> symlink the directory). + +Substantially increasing wal buffers might help too. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri May 19 17:21:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C47259FA278 + for ; + Fri, 19 May 2006 17:21:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 82473-05 + for ; + Fri, 19 May 2006 17:21:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 69A9C9FA22C + for ; + Fri, 19 May 2006 17:21:40 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 4FC9756435; Fri, 19 May 2006 15:21:38 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Fri, 19 May 2006 15:21:36 -0500 +Date: Fri, 19 May 2006 15:21:35 -0500 +From: "Jim C. Nasby" +To: Jean-Paul Argudo +Cc: Olivier Andreotti , + pgsql-performance@postgresql.org +Subject: Re: Benchmarck PostgreSQL 8.1.4 MySQL 5.0.20 and Oracle +Message-ID: <20060519202134.GM64371@pervasive.com> +References: + <446C510A.9040609@argudo.org> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <446C510A.9040609@argudo.org> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060519:jean-paul@argudo.org::pwRZ+6CyFYDnuef9:00000000000000000 + 0000000000000000000000003nGp +X-Hashcash: + 1:20:060519:olivier.andreotti@gmail.com::TcXgzyq6BaFQjaIT:0000000000 + 0000000000000000000000008C4A +X-Hashcash: + 1:20:060519:pgsql-performance@postgresql.org::ltFBlKn+jtp6zcG3:00000 + 0000000000000000000000004va6 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/404 +X-Sequence-Number: 19191 + +On Thu, May 18, 2006 at 12:48:42PM +0200, Jean-Paul Argudo wrote: +> > autovaccuum = on +> +> Thats a critic point. Personaly I dont use autovacuum. Because I just +> don't want a vacuum to be started ... when the server is loaded :) +> +> I prefer control vacuum process, when its possible (if its not, +> autovacuum is the best choice!), for example, a nighlty vacuum... + +This can be problematic for a benchmark, which often will create dead +tuples at a pretty good clip. + +In any case, if you are going to use autovacuum, you should cut all the +thresholds and scale factors in half, and set cost_delay to something (I +find 5-10 is usually good). + +Depending on your write load, you might need to make the bgwriter more +aggressive, too. + +If you can graph some metric from your benchmark over time it should be +pretty easy to spot if the bgwriter is keeping up with things or not; if +it's not, you'll see big spikes every time there's a checkpoint. + +> A question for you: after setting up your test database, did you launch +> a vacuum full analyze of it ? + +Why would you vacuum a newly loaded database that has no dead tuples? +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri May 19 17:50:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 088529FA278 + for ; + Fri, 19 May 2006 17:50:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 20322-04 + for ; + Fri, 19 May 2006 17:50:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id B6AD09FA22C + for ; + Fri, 19 May 2006 17:50:18 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 2DB6E56423; Fri, 19 May 2006 15:50:17 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Fri, 19 May 2006 15:50:15 -0500 +Date: Fri, 19 May 2006 15:50:14 -0500 +From: "Jim C. Nasby" +To: Chris Mckenzie +Cc: pgsql-performance@postgresql.org +Subject: Re: Performance/Maintenance test result collection +Message-ID: <20060519205013.GN64371@pervasive.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060519:chris.mckenzie@entrust.com::cjQx9dmwRgwbqmqA:00000000000 + 0000000000000000000000005A+1 +X-Hashcash: + 1:20:060519:pgsql-performance@postgresql.org::C12yTbL4nIC1z9At:00000 + 000000000000000000000000Ak/D +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/405 +X-Sequence-Number: 19192 + +On Thu, May 18, 2006 at 11:20:17AM -0400, Chris Mckenzie wrote: +> Yes, regular versus full vacuum. Thanks for the comment but I was hoping to +> come to that conclusion on my own by observing the affects of the different +> vacuums. +> +> My original question was guidance on collecting data for confirmation on the +> impact that maintenance of a large database (as a result of my applications +> regular usage over a period of time) has. +> +> I can du the various tables and compare their size before/after against the +> verbose output of a VACUUM FULL. I can use sar during all of this to monitor +> cpu and i/o activity. I can turn on transaction logging once I get a better +> idea of maintenance impact on my hardware so identify the biggest +> transactions that might statement timeout if a VACUUM was running at the +> same time. + +Well, vacuum full re-writes the table completely from scratch. Lazy +vacuum reads the entire table (just like full), but only writes out +pages that have dead space on them. + +But if you're wondering about the impact that will have on your +application, you can stop wondering, because vacuum full will +essentially shut your application down because it locks out use of the +table while it's being vacuumed. + +> Any suggestions or comments related to collection of this type of data would +> be helpful. I've already read the Postges 7.4 (yes, I'm stuck on 7.4) +> manual, I was hoping for this mail-list' wisdom to supply me with some tips +> that can only be learnt through painful experience. :-) + +If you're stuck on 7.4, at least make sure you're using the most recent +version. Otherwise you're exposing yourself to a number of data loss +bugs. + +As for vacuuming, it depends a lot on what your application is doing. If +you have frequent-enough slow periods (like at night), you can probably +schedule a database-wide vacuum during that time, possibly supplimented +by vacuums on critical tables during the day. If you have something +closer to a 24x7 load then pg_autovacuum is probably your best bet, +along with vacuum_cost_delay (if that's available in 7.4; it's been so +long I don't remember). + +There's a few articles in our knowledge base +(http://www.pervasivepostgres.com/kb/index.asp) that might be worth +reading as well (search for 'vacuum'). In particular, "Is PostgreSQL +remembering what I vacuumed" has some critical information about +managing the free space map. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri May 19 17:59:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0F0EF9FA22C + for ; + Fri, 19 May 2006 17:59:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 24734-05 + for ; + Fri, 19 May 2006 17:59:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id C20799FA278 + for ; + Fri, 19 May 2006 17:59:22 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id EBF6156427; Fri, 19 May 2006 15:59:19 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Fri, 19 May 2006 15:59:16 -0500 +Date: Fri, 19 May 2006 15:59:15 -0500 +From: "Jim C. Nasby" +To: Stephen Byers +Cc: Tom Lane , + "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +Subject: Re: why is bitmap index chosen for this query? +Message-ID: <20060519205915.GO64371@pervasive.com> +References: <16019.1147973659@sss.pgh.pa.us> + <20060518193818.81332.qmail@web30710.mail.mud.yahoo.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060518193818.81332.qmail@web30710.mail.mud.yahoo.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060519:stephenabyers@yahoo.com::qgCVF1jAQqb9ajBA:00000000000000 + 00000000000000000000000018+p +X-Hashcash: + 1:20:060519:tgl@sss.pgh.pa.us::4sEZNNqBjL5IujCi:00000000000000000000 + 0000000000000000000000002iZ8 +X-Hashcash: + 1:20:060519:sgunderson@bigfoot.com::NycGZcOaO1b8M1SO:000000000000000 + 000000000000000000000000AJr4 +X-Hashcash: + 1:20:060519:pgsql-performance@postgresql.org::ivAhQ2xWxIlY8g+V:00000 + 000000000000000000000000DiLo +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/406 +X-Sequence-Number: 19193 + +On Thu, May 18, 2006 at 12:38:18PM -0700, Stephen Byers wrote: +> I repeated explain analyze on the query 5 times and it came up with the same plan. +> +> You asked about index order and physical table order. In general the index order is indeed close to the same order as the physical table order. However, this query is likely an exception. The data is actually from a backup server that has filled a hole for some of the time range that I'm specifying in my query. + +What's SELECT correlation FROM pg_stats WHERE tablename='packets' AND +attname='environment_name' show? + +What's effective_cache_size and random_page_cost set to? + +Also, out of curiosity, why not just use a timestamp instead of two +int's for storing time? + +> Wow -- so what does that mean? Do I need to leave my work_mem at 100MB?? I mentioned that my application actually uses a cursor to walk through this data. Even though the bitmap scan technically had the fastest time with explain analyze, it takes a long while (20 seconds) before the results start to come back through the cursor. Conversely, with the index scan, results immediately come back through the cursor method (which is more desirable). Thoughts? + +Do you really need to use a cursor? It's generally less efficient than +doing things with a single SQL statement, depending on what exactly +you're doing. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Fri May 19 20:11:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2271F9FAA6E + for ; + Fri, 19 May 2006 20:11:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 64446-10 + for ; + Fri, 19 May 2006 20:11:18 -0300 (ADT) +X-Greylist: delayed 01:23:57.264381 by SQLgrey- +Received: from swordfish.dnsvelocity.com (swordfish.dnsvelocity.com + [216.67.224.90]) + by postgresql.org (Postfix) with ESMTP id 8F2B29FA5FB + for ; + Fri, 19 May 2006 20:11:18 -0300 (ADT) +Received: from [24.87.22.207] (port=4215 helo=chris) + by swordfish.dnsvelocity.com with esmtpa (Exim 4.52) + id 1FhE7o-0006sg-Ap + for pgsql-performance@postgresql.org; Sat, 20 May 2006 00:11:16 +0100 +Message-ID: <03e001c67b99$8321f010$6401a8c0@chris> +From: "Cstdenis" +To: +Subject: How can I make this query faster (resend) +Date: Fri, 19 May 2006 15:56:49 -0700 +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_NextPart_000_03DD_01C67B5C.D6711260" +X-Priority: 3 +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook Express 6.00.2800.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +X-Antivirus-Scanner: Clean mail though you should still use an Antivirus +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - swordfish.dnsvelocity.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] +X-AntiAbuse: Sender Address Domain - voicio.com +X-Source: +X-Source-Args: +X-Source-Dir: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/407 +X-Sequence-Number: 19194 + +This is a multi-part message in MIME format. + +------=_NextPart_000_03DD_01C67B5C.D6711260 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +(Its been a hour and I dont see my message on the list so I'm sending it = +again. I've moved the queries and analyze out of the email incase it was = +rejected because too long) + +query: http://pastebin.ca/57218 + +In the pictures table all the ratings have a shared index=20 +=20 +CREATE INDEX idx_rating ON pictures USING btree (rating_nudity, = +rating_violence, rating_sex, rating_racism, rating_spoilers, = +rating_yaoi, rating_yuri, rating_profanity); +=20 +and approved and date_submitted and user_id also have their own btree = +indexes. +=20 +In the picture_categories table pid and cat_id have their own btree = +indices plus one together.=20 + +Full table definition: http://pastebin.ca/57219 + +the cat_id and rating values vary from query to query. The one listed = +above took 54 seconds in a test run just now. Here is explain analyze: = +http://pastebin.ca/57220 + + +Both pictures and picture categories have about 287,000 rows +=20 +This query needs to run in under about a second or it kills my site by = +clogging apache slots (apache maxes out at 256 and I can have several = +hundred people on my site at a time). How can I make it run faster? +=20 +=20 +Server is a dual xeon with a gig of ram dedicated mostly to postgresql. +Here is the changed lines in my postgresql.conf: = +http://pastebin.ca/57222 + +I know hyperthreading is considered something that can slow down a = +server but with my very high concurancy (averages about 400-500 = +concurant users during peak hours) I am hoping the extra virtual CPUs = +wil help. Anyone have experance that says diferent at high concurancy? +------=_NextPart_000_03DD_01C67B5C.D6711260 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + + + +
(Its been a hour and I dont see my = +message on the=20 +list so I'm sending it again. I've moved the queries and analyze out of = +the=20 +email incase it was rejected because too long)
+
 
+
query: http://pastebin.ca/57218 +
 
+
In the pictures table all the ratings have a shared index=20 +
 
CREATE INDEX idx_rating ON pictures USING btree =20 +(rating_nudity, rating_violence, rating_sex, rating_racism, = +rating_spoilers,=20 +rating_yaoi, rating_yuri, rating_profanity);
 
and approved = +and=20 +date_submitted and user_id also have their own btree = +indexes.
 
In=20 +the picture_categories table pid and cat_id have their own btree indices = +plus=20 +one together.
+
 
+
Full table definition: http://pastebin.ca/57219
+
 
+
the cat_id and rating values vary from query to query. The one = +listed above=20 +took 54 seconds in a test run just now. Here is explain analyze: http://pastebin.ca/57220
+
 
+
 
+
Both pictures and picture categories have about 287,000=20 +rows
 
This query needs to run in under about a second or it = +kills my=20 +site by clogging apache slots (apache maxes out at 256 and I can have = +several=20 +hundred people on my site at a time). How can I make it run=20 +faster?
 
 
Server is a dual xeon with a gig of ram = +dedicated=20 +mostly to postgresql.
Here is the changed lines in my = +postgresql.conf: http://pastebin.ca/57222
+
 
+
I know hyperthreading is considered something that can slow down a = +server=20 +but with my very high concurancy (averages about 400-500 concurant users = +during=20 +peak hours) I am hoping the extra virtual CPUs wil help. Anyone have = +experance=20 +that says diferent at high concurancy?
+ +------=_NextPart_000_03DD_01C67B5C.D6711260-- + + + +From pgsql-performance-owner@postgresql.org Fri May 19 23:37:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C5E8C9FAA6E + for ; + Fri, 19 May 2006 23:37:57 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 92167-10 + for ; + Fri, 19 May 2006 23:37:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from colo-dns-ext1.juniper.net (colo-dns-ext1.juniper.net + [207.17.137.57]) + by postgresql.org (Postfix) with ESMTP id D24309FA5FB + for ; + Fri, 19 May 2006 23:37:53 -0300 (ADT) +Received: from merlot.juniper.net (merlot.juniper.net [172.17.27.10]) + by colo-dns-ext1.juniper.net (8.11.3/8.9.3) with ESMTP id k4K2bpX20510 + for ; + Fri, 19 May 2006 19:37:51 -0700 (PDT) + (envelope-from kenjim@juniper.net) +Received: from kenjim-lnx.juniper.net (kenjim-lnx.juniper.net [172.17.58.60]) + by merlot.juniper.net (8.11.3/8.11.3) with ESMTP id k4K2bk597594; + Fri, 19 May 2006 19:37:46 -0700 (PDT) + (envelope-from kenjim@juniper.net) +Received: from kenjim-lnx.juniper.net (kenjim-lnx.juniper.net [127.0.0.1]) + by kenjim-lnx.juniper.net (8.13.4/8.13.4) with ESMTP id k4K2bk46014945; + Fri, 19 May 2006 19:37:46 -0700 +Received: (from kenjim@localhost) + by kenjim-lnx.juniper.net (8.13.4/8.13.4/Submit) id k4K2bje4014936; + Fri, 19 May 2006 19:37:45 -0700 +Date: Fri, 19 May 2006 19:37:45 -0700 +From: Kenji Morishige +To: pgsql-performance@postgresql.org +Cc: kenjim@juniper.net +Subject: utilizing multiple disks for i/o performance +Message-ID: <20060520023745.GA14877@juniper.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/408 +X-Sequence-Number: 19195 + +Where can I find any documentation to partition the tablespace disk files onto +different physical arrays for improved performance? + +-Kenji + +From pgsql-performance-owner@postgresql.org Sat May 20 01:51:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id CB7F59F9EEB + for ; + Sat, 20 May 2006 01:51:39 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 26674-02 + for ; + Sat, 20 May 2006 01:51:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail5.sea5.speakeasy.net (mail5.sea5.speakeasy.net + [69.17.117.7]) by postgresql.org (Postfix) with ESMTP id 3551D9FA3B3 + for ; + Sat, 20 May 2006 01:51:33 -0300 (ADT) +Received: (qmail 25768 invoked from network); 20 May 2006 04:51:33 -0000 +Received: from dsl093-038-250.pdx1.dsl.speakeasy.net (HELO [192.168.1.20]) + (davidw@[66.93.38.250]) (envelope-sender ) + by mail5.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted + SMTP + for ; 20 May 2006 04:51:32 -0000 +Mime-Version: 1.0 (Apple Message framework v750) +Content-Transfer-Encoding: 7bit +Message-Id: <1D5FC47D-8D90-4856-8EB7-833476A37587@kineticode.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: pgsql-performance +From: David Wheeler +Subject: Benchmarking Function +Date: Fri, 19 May 2006 21:51:30 -0700 +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/409 +X-Sequence-Number: 19196 + +Fellow PostgreSQLers, + +With a bit of guidance from Klint Gore, Neil Conway, Josh Berkus, and +Alexey Dvoychenkov, I have written a PL/pgSQL function to help me +compare the performance between different functions that execute the +same task. I've blogged the about the function here: + + http://www.justatheory.com/computers/databases/postgresql/ +benchmarking_functions.html + +My question for the list is: How important is it that I have the +control in there? In the version I've blogged, the control just +executes 'SELECT TRUE FROM generate_series( 1, n)' and iterates +loops over the results. But I wasn't sure how accurate that was. +Another approach I've tried it to simply loop without executing a +query, 'FOR i IN 1..n LOOP', but that takes virtually no time at all. + +The idea of the control is, of course, to subtract the overhead of +the benchmarking function from the code actually being tested. So I +guess my question is, how important is it to have the control there, +and, if it is important, how should it actually work? + +Many TIA, + +David + +From pgsql-performance-owner@postgresql.org Sun May 21 05:22:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A53DA9F9316 + for ; + Sun, 21 May 2006 05:22:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 30708-01 + for ; + Sun, 21 May 2006 05:22:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id D0D809F9EEB + for ; + Sun, 21 May 2006 05:22:05 -0300 (ADT) +Received: from [10.0.1.4] ([68.147.204.179]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)) + for pgsql-performance@postgresql.org; Sun, 21 May 2006 02:22:03 -0600 +Mime-Version: 1.0 (Apple Message framework v750) +To: PostgreSQL Performance +Message-Id: +Content-Type: multipart/alternative; boundary=Apple-Mail-6-241306946 +From: Brendan Duddridge +Subject: Performs WAY better with enable_seqscan = off +Date: Sun, 21 May 2006 02:21:55 -0600 +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/410 +X-Sequence-Number: 19197 + + +--Apple-Mail-6-241306946 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +Hi, + +I have a query that performs WAY better when I have enable_seqscan = +off: + +explain analyze select ac.attribute_id, la.name, ac.sort_order from +attribute_category ac, localized_attribute la where ac.category_id = +1001402 and la.locale_id = 1000001 and ac.is_browsable = 'true' and +la.attribute_id = ac.attribute_id and exists ( select 'x' from +product_attribute_value pav, category_product cp where +(pav.product_id || '.' || pav.attribute_id) = (cp.product_id || '.' +|| ac.attribute_id) and pav.status_code is null and (cp.category_id +|| '.' || cp.is_visible) = '1001402.true') order by (ac.sort_order is +null), ac.sort_order, la.name asc; + + QUERY PLAN +------------------------------------------------------------------------ +------------------------------------------------------------------------ +------------------------------------------------------------------------ +------ +Sort (cost=47.97..47.98 rows=7 width=34) (actual +time=33368.721..33368.721 rows=2 loops=1) + Sort Key: (ac.sort_order IS NULL), ac.sort_order, la.name + -> Nested Loop (cost=2.00..47.87 rows=7 width=34) (actual +time=13563.049..33368.679 rows=2 loops=1) + -> Index Scan using attribute_category__category_id_fk_idx +on attribute_category ac (cost=0.00..26.73 rows=7 width=8) (actual +time=13562.918..33368.370 rows=2 loops=1) + Index Cond: (category_id = 1001402) + Filter: (((is_browsable)::text = 'true'::text) AND +(subplan)) + SubPlan + -> Nested Loop (cost=0.02..278217503.21 +rows=354763400 width=0) (actual time=4766.821..4766.821 rows=0 loops=7) + -> Seq Scan on category_product cp +(cost=0.00..158150.26 rows=18807 width=4) (actual +time=113.595..4585.461 rows=12363 loops=7) + Filter: ((((category_id)::text || +'.'::text) || (is_visible)::text) = '1001402.true'::text) + -> Index Scan using +product_attribute_value__prod_id_att_id_status_is_null_ids on +product_attribute_value pav (cost=0.02..14171.84 rows=18863 width=8) +(actual time=0.012..0.012 rows=0 loops=86538) + Index Cond: ((((pav.product_id)::text +|| '.'::text) || (pav.attribute_id)::text) = +((("outer".product_id)::text || '.'::text) || ($0)::text)) + -> Bitmap Heap Scan on localized_attribute la +(cost=2.00..3.01 rows=1 width=30) (actual time=0.129..0.129 rows=1 +loops=2) + Recheck Cond: (la.attribute_id = "outer".attribute_id) + Filter: (locale_id = 1000001) + -> Bitmap Index Scan on +localized_attribute__attribute_id_fk_idx (cost=0.00..2.00 rows=1 +width=0) (actual time=0.091..0.091 rows=1 loops=2) + Index Cond: (la.attribute_id = +"outer".attribute_id) +Total runtime: 33369.105 ms + +Now when I disable sequential scans: + +set enable_seqscan = off; + +explain analyze select ac.attribute_id, la.name, ac.sort_order from +attribute_category ac, localized_attribute la where ac.category_id = +1001402 and la.locale_id = 1000001 and ac.is_browsable = 'true' and +la.attribute_id = ac.attribute_id and exists ( select 'x' from +product_attribute_value pav, category_product cp where +(pav.product_id || '.' || pav.attribute_id) = (cp.product_id || '.' +|| ac.attribute_id) and pav.status_code is null and (cp.category_id +|| '.' || cp.is_visible) = '1001402.true') order by (ac.sort_order is +null), ac.sort_order, la.name asc; + + QUERY PLAN +------------------------------------------------------------------------ +------------------------------------------------------------------------ +------------------------------------------------------------------------ +------ +Sort (cost=48.09..48.11 rows=7 width=34) (actual +time=1675.944..1675.945 rows=2 loops=1) + Sort Key: (ac.sort_order IS NULL), ac.sort_order, la.name + -> Nested Loop (cost=2.00..48.00 rows=7 width=34) (actual +time=687.600..1675.831 rows=2 loops=1) + -> Index Scan using attribute_category__category_id_fk_idx +on attribute_category ac (cost=0.00..26.86 rows=7 width=8) (actual +time=687.441..1675.584 rows=2 loops=1) + Index Cond: (category_id = 1001402) + Filter: (((is_browsable)::text = 'true'::text) AND +(subplan)) + SubPlan + -> Nested Loop (cost=0.03..278076992.97 +rows=354763400 width=0) (actual time=239.299..239.299 rows=0 loops=7) + -> Index Scan using +category_product__cat_id_is_visible_idx on category_product cp +(cost=0.01..17640.02 rows=18807 width=4) (actual time=0.036..30.205 +rows=12363 loops=7) + Index Cond: ((((category_id)::text || +'.'::text) || (is_visible)::text) = '1001402.true'::text) + -> Index Scan using +product_attribute_value__prod_id_att_id_status_is_null_ids on +product_attribute_value pav (cost=0.02..14171.84 rows=18863 width=8) +(actual time=0.013..0.013 rows=0 loops=86538) + Index Cond: ((((pav.product_id)::text +|| '.'::text) || (pav.attribute_id)::text) = +((("outer".product_id)::text || '.'::text) || ($0)::text)) + -> Bitmap Heap Scan on localized_attribute la +(cost=2.00..3.01 rows=1 width=30) (actual time=0.093..0.094 rows=1 +loops=2) + Recheck Cond: (la.attribute_id = "outer".attribute_id) + Filter: (locale_id = 1000001) + -> Bitmap Index Scan on +localized_attribute__attribute_id_fk_idx (cost=0.00..2.00 rows=1 +width=0) (actual time=0.060..0.060 rows=1 loops=2) + Index Cond: (la.attribute_id = +"outer".attribute_id) +Total runtime: 1676.727 ms + + +the tables involved with the query have all been vacuum analyzed. I +also have default_statistics_target = 100. + +There's something definitely wrong with that Nested Loop with the +high row count. That row count appears to be close to the product of +the number of rows in category_product and product_attribute_value. + +Any ideas and help would be greatly appreciated. + + +Thanks, + + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + + +--Apple-Mail-6-241306946 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=ISO-8859-1 + +Hi,

I have a query that = +performs WAY better when I have enable_seqscan =3D off:

explain analyze select = +ac.attribute_id, la.name, ac.sort_order from attribute_category ac, = +localized_attribute la where ac.category_id =3D 1001402 and la.locale_id = +=3D 1000001 and ac.is_browsable =3D 'true' and la.attribute_id =3D = +ac.attribute_id and exists ( select 'x' from product_attribute_value = +pav, category_product cp where (pav.product_id || '.' || = +pav.attribute_id) =3D (cp.product_id || '.' || ac.attribute_id) and = +pav.status_code is null and (cp.category_id || '.' || cp.is_visible) =3D = +'1001402.true') order by (ac.sort_order is null), ac.sort_order, la.name = +asc;
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = +=A0 =A0 QUERY PLAN=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = +=A0 =A0 =A0 = +
---------------------------------------------------------------= +--------------------------------------------------------------------------= +--------------------------------------------------------------------------= +-----------
Sort=A0 (cost=3D47.97..47.98 rows=3D7 width=3D34) = +(actual time=3D33368.721..33368.721 rows=3D2 loops=3D1)
=A0=A0 = +Sort Key: (ac.sort_order IS NULL), ac.sort_order, la.name
=A0=A0= + ->=A0 Nested Loop=A0 (cost=3D2.00..47.87 rows=3D7 width=3D34) = +(actual time=3D13563.049..33368.679 rows=3D2 loops=3D1)
=A0 =A0 = +=A0 =A0=A0 ->=A0 Index Scan using = +attribute_category__category_id_fk_idx on attribute_category ac=A0 = +(cost=3D0.00..26.73 rows=3D7 width=3D8) (actual = +time=3D13562.918..33368.370 rows=3D2 loops=3D1)
=A0 =A0 =A0 =A0 = +=A0 =A0 =A0=A0 Index Cond: (category_id =3D 1001402)
=A0 =A0 =A0= + =A0 =A0 =A0 =A0=A0 Filter: (((is_browsable)::text =3D 'true'::text) AND = +(subplan))
=A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 SubPlan
=A0 = +=A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 ->=A0 Nested Loop=A0 = +(cost=3D0.02..278217503.21 rows=3D354763400 width=3D0) (actual = +time=3D4766.821..4766.821 rows=3D0 loops=3D7)
=A0 =A0 =A0 =A0 = +=A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 ->=A0 Seq Scan on category_product cp=A0= + (cost=3D0.00..158150.26 rows=3D18807 width=3D4) (actual = +time=3D113.595..4585.461 rows=3D12363 loops=3D7)
=A0 =A0 =A0 =A0= + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 Filter: = +((((category_id)::text || '.'::text) || (is_visible)::text) =3D = +'1001402.true'::text)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = +=A0=A0 ->=A0 Index Scan using = +product_attribute_value__prod_id_att_id_status_is_null_ids on = +product_attribute_value pav=A0 (cost=3D0.02..14171.84 rows=3D18863 = +width=3D8) (actual time=3D0.012..0.012 rows=3D0 loops=3D86538)
=A0= + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 Index Cond: = +((((pav.product_id)::text || '.'::text) || (pav.attribute_id)::text) =3D = +((("outer".product_id)::text || '.'::text) || ($0)::text))
=A0 = +=A0 =A0 =A0=A0 ->=A0 Bitmap Heap Scan on localized_attribute la=A0 = +(cost=3D2.00..3.01 rows=3D1 width=3D30) (actual time=3D0.129..0.129 = +rows=3D1 loops=3D2)
=A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 Recheck = +Cond: (la.attribute_id =3D "outer".attribute_id)
=A0 =A0 =A0 =A0= + =A0 =A0 =A0=A0 Filter: (locale_id =3D 1000001)
=A0 =A0 =A0 =A0 = +=A0 =A0 =A0=A0 ->=A0 Bitmap Index Scan on = +localized_attribute__attribute_id_fk_idx=A0 (cost=3D0.00..2.00 rows=3D1 = +width=3D0) (actual time=3D0.091..0.091 rows=3D1 loops=3D2)
=A0 = +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 Index Cond: (la.attribute_id =3D = +"outer".attribute_id)
Total runtime: 33369.105 = +ms

Now when I = +disable sequential scans:

set enable_seqscan =3D = +off;

explain = +analyze select ac.attribute_id, la.name, ac.sort_order from = +attribute_category ac, localized_attribute la where ac.category_id =3D = +1001402 and la.locale_id =3D 1000001 and ac.is_browsable =3D 'true' and = +la.attribute_id =3D ac.attribute_id and exists ( select 'x' from = +product_attribute_value pav, category_product cp where (pav.product_id = +|| '.' || pav.attribute_id) =3D (cp.product_id || '.' || = +ac.attribute_id) and pav.status_code is null and (cp.category_id || '.' = +|| cp.is_visible) =3D '1001402.true') order by (ac.sort_order is null), = +ac.sort_order, la.name asc;
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 QUERY PLAN=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = +
---------------------------------------------------------------= +--------------------------------------------------------------------------= +--------------------------------------------------------------------------= +-----------
Sort=A0 (cost=3D48.09..48.11 rows=3D7 width=3D34) = +(actual time=3D1675.944..1675.945 rows=3D2 loops=3D1)
=A0=A0 = +Sort Key: (ac.sort_order IS NULL), ac.sort_order, la.name
=A0=A0= + ->=A0 Nested Loop=A0 (cost=3D2.00..48.00 rows=3D7 width=3D34) = +(actual time=3D687.600..1675.831 rows=3D2 loops=3D1)
=A0 =A0 =A0= + =A0=A0 ->=A0 Index Scan using attribute_category__category_id_fk_idx = +on attribute_category ac=A0 (cost=3D0.00..26.86 rows=3D7 width=3D8) = +(actual time=3D687.441..1675.584 rows=3D2 loops=3D1)
=A0 =A0 =A0= + =A0 =A0 =A0 =A0=A0 Index Cond: (category_id =3D 1001402)
=A0 = +=A0 =A0 =A0 =A0 =A0 =A0=A0 Filter: (((is_browsable)::text =3D = +'true'::text) AND (subplan))
=A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 = +SubPlan
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 ->=A0 Nested = +Loop=A0 (cost=3D0.03..278076992.97 rows=3D354763400 width=3D0) (actual = +time=3D239.299..239.299 rows=3D0 loops=3D7)
=A0 =A0 =A0 =A0 =A0 = +=A0 =A0 =A0 =A0 =A0 =A0=A0 ->=A0 Index Scan using = +category_product__cat_id_is_visible_idx on category_product cp=A0 = +(cost=3D0.01..17640.02 rows=3D18807 width=3D4) (actual = +time=3D0.036..30.205 rows=3D12363 loops=3D7)
=A0 =A0 =A0 =A0 =A0= + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 Index Cond: = +((((category_id)::text || '.'::text) || (is_visible)::text) =3D = +'1001402.true'::text)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = +=A0=A0 ->=A0 Index Scan using = +product_attribute_value__prod_id_att_id_status_is_null_ids on = +product_attribute_value pav=A0 (cost=3D0.02..14171.84 rows=3D18863 = +width=3D8) (actual time=3D0.013..0.013 rows=3D0 loops=3D86538)
=A0= + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 Index Cond: = +((((pav.product_id)::text || '.'::text) || (pav.attribute_id)::text) =3D = +((("outer".product_id)::text || '.'::text) || ($0)::text))
=A0 = +=A0 =A0 =A0=A0 ->=A0 Bitmap Heap Scan on localized_attribute la=A0 = +(cost=3D2.00..3.01 rows=3D1 width=3D30) (actual time=3D0.093..0.094 = +rows=3D1 loops=3D2)
=A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 Recheck = +Cond: (la.attribute_id =3D "outer".attribute_id)
=A0 =A0 =A0 =A0= + =A0 =A0 =A0=A0 Filter: (locale_id =3D 1000001)
=A0 =A0 =A0 =A0 = +=A0 =A0 =A0=A0 ->=A0 Bitmap Index Scan on = +localized_attribute__attribute_id_fk_idx=A0 (cost=3D0.00..2.00 rows=3D1 = +width=3D0) (actual time=3D0.060..0.060 rows=3D1 loops=3D2)
=A0 = +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0 Index Cond: (la.attribute_id =3D = +"outer".attribute_id)
Total runtime: 1676.727 = +ms


the tables involved with = +the query have all been vacuum analyzed.=A0 I also have = +default_statistics_target =3D 100.

There's something = +definitely wrong with that Nested Loop with the high row count. That row = +count appears to be close to the product of the number of rows in = +category_product and product_attribute_value.

Any ideas and help would be = +greatly appreciated.


Thanks,

= +

_________________________________________________________= +___________
Brendan Duddridge=A0| CTO | 403-277-5591 x24 | =A0brendan@clickspace.com = +

ClickSpace = +Interactive Inc.
Suite L100, 239 - 10th Ave. SE
Calgary, AB = +=A0T2G 0V9

http://www.clickspace.com=A0
= +

= + +--Apple-Mail-6-241306946-- + + +From pgsql-performance-owner@postgresql.org Sun May 21 07:39:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 92DE79FA131 + for ; + Sun, 21 May 2006 07:39:42 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 48745-04 + for ; + Sun, 21 May 2006 07:39:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.ipf.is (benz.ipf.is [85.197.192.156]) + by postgresql.org (Postfix) with ESMTP id 649B69FA159 + for ; + Sun, 21 May 2006 07:39:32 -0300 (ADT) +Received: (qmail 10299 invoked by uid 1010); 21 May 2006 10:38:00 +0000 +Received: from 85.197.216.186 by benz (envelope-from , + uid 1008) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1235. spamassassin: 3.1.1. perlscan: 1.25-st-qms. + Clear:RC:1(85.197.216.186):SA:0(-4.2/4.5):. + Processed in 0.314003 secs); 21 May 2006 10:38:00 -0000 +X-Antivirus-IPF-Mail-From: gnari@hive.is via benz +X-Antivirus-IPF: 1.25-st-qms (Clear:RC:1(85.197.216.186):SA:0(-4.2/4.5):. + Processed in 0.314003 secs Process 10292) +Received: from dsl-216-186.hive.is (HELO ?192.168.1.34?) (85.197.216.186) + by mx1.ipf.is with SMTP; 21 May 2006 10:37:59 +0000 +Subject: Re: Performs WAY better with enable_seqscan = off +From: Ragnar +To: Brendan Duddridge +Cc: PostgreSQL Performance +In-Reply-To: +References: +Content-Type: text/plain +Date: Sun, 21 May 2006 10:50:11 +0000 +Message-Id: <1148208611.28240.101.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/411 +X-Sequence-Number: 19198 + +On sun, 2006-05-21 at 02:21 -0600, Brendan Duddridge wrote: +> Hi, +> +> +> I have a query that performs WAY better when I have enable_seqscan = +> off: +> +> +> explain analyze select ac.attribute_id, la.name, ac.sort_order from +> attribute_category ac, localized_attribute la where ac.category_id = +> 1001402 and la.locale_id = 1000001 and ac.is_browsable = 'true' and +> la.attribute_id = ac.attribute_id and exists ( select 'x' from +> product_attribute_value pav, category_product cp where (pav.product_id +> || '.' || pav.attribute_id) = (cp.product_id || '.' || +> ac.attribute_id) and pav.status_code is null and (cp.category_id || +> '.' || cp.is_visible) = '1001402.true') order by (ac.sort_order is +> null), ac.sort_order, la.name asc; + +is there some reason for the complicated form of the +join conditions in the subselect? + +would this not be clearer: + +explain analyze + select ac.attribute_id, + la.name, + ac.sort_order + from attribute_category ac, + localized_attribute la + where ac.category_id = 1001402 + and la.locale_id = 1000001 + and ac.is_browsable = 'true' + and la.attribute_id = ac.attribute_id + and exists + (select 'x' from product_attribute_value pav, + category_product cp + where pav.product_id = cp.product_id + and pav.attribute_id = ac.attribute_id + and pav.status_code is null + and cp.category_id= '1001402' + and cp.is_visible = 'true' + ) + order by (ac.sort_order is null), + ac.sort_order, + la.name asc; + + +possibly the planner would have a better time +figuring out if any indexes are usable or estimating +the subselect rowcount + +gnari + + + +From pgsql-performance-owner@postgresql.org Sun May 21 16:24:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6D97C9FA19B + for ; + Sun, 21 May 2006 16:24:05 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 13171-06 + for ; + Sun, 21 May 2006 16:23:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from davinci.ethosmedia.com (server227.ethosmedia.com + [209.128.84.227]) + by postgresql.org (Postfix) with ESMTP id ED3919F9316 + for ; + Sun, 21 May 2006 16:23:56 -0300 (ADT) +X-EthosMedia-Virus-Scanned: no infections found +Received: from [63.195.55.98] (account josh@agliodbs.com HELO + spooky.sf.agliodbs.com) + by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.1.8) + with ESMTP id 9450849; Sun, 21 May 2006 12:27:04 -0700 +From: Josh Berkus +Organization: Aglio Database Solutions +To: pgsql-performance@postgresql.org +Subject: Re: Benchmarking Function +Date: Sun, 21 May 2006 12:23:49 -0700 +User-Agent: KMail/1.8.2 +Cc: David Wheeler +References: <1D5FC47D-8D90-4856-8EB7-833476A37587@kineticode.com> +In-Reply-To: <1D5FC47D-8D90-4856-8EB7-833476A37587@kineticode.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200605211223.49499.josh@agliodbs.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/412 +X-Sequence-Number: 19199 + +DW, + +> The idea of the control is, of course, to subtract the overhead of =A0 +> the benchmarking function from the code actually being tested. So I =A0 +> guess my question is, how important is it to have the control there, =A0 +> and, if it is important, how should it actually work? + +Well, per our conversation the approach doesn't really work. EXECUTE=20 +'string' + generate_series seems to carry a substantial and somewhat random= +=20 +overhead, between 100ms and 200ms -- enough to wipe out any differences=20 +between queries. + +=2D-=20 +Josh Berkus +Aglio Database Solutions +San Francisco + +From pgsql-performance-owner@postgresql.org Sun May 21 17:01:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 64A309FA19B + for ; + Sun, 21 May 2006 17:01:35 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 18481-01 + for ; + Sun, 21 May 2006 17:01:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 7FBDE9F9316 + for ; + Sun, 21 May 2006 17:01:25 -0300 (ADT) +Received: from [10.0.1.4] ([68.147.204.179]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Sun, 21 May 2006 14:01:22 -0600 +In-Reply-To: <1148208611.28240.101.camel@localhost.localdomain> +References: + <1148208611.28240.101.camel@localhost.localdomain> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: Performs WAY better with enable_seqscan = off +Date: Sun, 21 May 2006 14:01:14 -0600 +To: Ragnar +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/413 +X-Sequence-Number: 19200 + +> is there some reason for the complicated form of the +> join conditions in the subselect? + + +Yes, the simpler form query definitely works, but it's not always as +fast as the index version with the complicated join syntax. Although +even that query varies significantly with different category_id +values. Not sure why. Sometimes it finishes in 150 ms, other times it +takes over a second. + +Here's the explain plan from your query: + +explain analyze select ac.attribute_id, la.name, ac.sort_order from +attribute_category ac, localized_attribute la where ac.category_id = +1001402 and la.locale_id = 1000001 and ac.is_browsable = 'true' and +la.attribute_id = ac.attribute_id and exists (select 'x' from +product_attribute_value pav, category_product cp where pav.product_id += cp.product_id and pav.attribute_id = ac.attribute_id and +pav.status_code is null and cp.category_id= '1001402' and +cp.is_visible = 'true') order by ac.sort_order, la.name asc; + + QUERY PLAN +------------------------------------------------------------------------ +------------------------------------------------------------------------ +--------------------------------------------------------------- +Sort (cost=6343.18..6343.20 rows=7 width=34) (actual +time=2244.241..2244.242 rows=2 loops=1) + Sort Key: ac.sort_order, la.name + -> Nested Loop (cost=2.00..6343.08 rows=7 width=34) (actual +time=1831.970..2244.209 rows=2 loops=1) + -> Index Scan using attribute_category__category_id_fk_idx +on attribute_category ac (cost=0.00..6321.95 rows=7 width=8) (actual +time=1831.938..2244.142 rows=2 loops=1) + Index Cond: (category_id = 1001402) + Filter: (((is_browsable)::text = 'true'::text) AND +(subplan)) + SubPlan + -> Nested Loop (cost=2.00..10458.04 rows=30 +width=0) (actual time=320.572..320.572 rows=0 loops=7) + -> Index Scan using +product_attribute_value__attribute_id_fk_idx on +product_attribute_value pav (cost=0.00..2661.39 rows=2572 width=4) +(actual time=0.020..33.589 rows=18468 loops=7) + Index Cond: (attribute_id = $0) + Filter: (status_code IS NULL) + -> Bitmap Heap Scan on category_product cp +(cost=2.00..3.02 rows=1 width=4) (actual time=0.011..0.011 rows=0 +loops=129274) + Recheck Cond: ("outer".product_id = +cp.product_id) + Filter: ((category_id = 1001402) AND +((is_visible)::text = 'true'::text)) + -> Bitmap Index Scan on +x_category_product__product_id_fk_idx (cost=0.00..2.00 rows=1 +width=0) (actual time=0.008..0.008 rows=1 loops=129274) + Index Cond: ("outer".product_id = +cp.product_id) + -> Bitmap Heap Scan on localized_attribute la +(cost=2.00..3.01 rows=1 width=30) (actual time=0.019..0.019 rows=1 +loops=2) + Recheck Cond: (la.attribute_id = "outer".attribute_id) + Filter: (locale_id = 1000001) + -> Bitmap Index Scan on +localized_attribute__attribute_id_fk_idx (cost=0.00..2.00 rows=1 +width=0) (actual time=0.015..0.015 rows=1 loops=2) + Index Cond: (la.attribute_id = +"outer".attribute_id) +Total runtime: 2244.542 ms + + +Here's the schema for the two tables involved with the sub-select: + + \d category_product; + Table "public.category_product" + Column | Type | Modifiers +---------------------+------------------------+----------- +category_id | integer | not null +product_id | integer | not null +en_name_sort_order | integer | +fr_name_sort_order | integer | +merchant_sort_order | integer | +price_sort_order | integer | +merchant_count | integer | +is_active | character varying(5) | +product_is_active | character varying(5) | +product_status_code | character varying(32) | +product_name_en | character varying(512) | +product_name_fr | character varying(512) | +product_click_count | integer | +is_visible | character varying(5) | +is_pending_visible | character varying(5) | +min_price_cad | numeric(12,4) | +max_price_cad | numeric(12,4) | +Indexes: + "x_category_product_pk" PRIMARY KEY, btree (category_id, +product_id) + "category_product__cat_id_is_visible_idx" btree +(((category_id::text || '.'::text) || is_visible::text)) + "category_product__cat_id_prod_is_act_status_idx" btree +(category_id, product_is_active, product_status_code) + "category_product__category_id_is_active_and_status_idx" btree +(category_id, product_is_active, product_status_code) + "category_product__is_active_idx" btree (is_active) + "category_product__lower_product_name_en_idx" btree (lower +(product_name_en::text)) + "category_product__lower_product_name_fr_idx" btree (lower +(product_name_fr::text)) + "category_product__merchant_sort_order_idx" btree +(merchant_sort_order) + "category_product__min_price_cad_idx" btree (min_price_cad) + "category_product__product_id_category_id_status_idx" btree +(product_id, category_id, product_is_active, product_status_code) + "x_category_product__category_id_fk_idx" btree (category_id) +CLUSTER + "x_category_product__product_id_fk_idx" btree (product_id) +Foreign-key constraints: + "x_category_product_category_fk" FOREIGN KEY (category_id) +REFERENCES category(category_id) DEFERRABLE INITIALLY DEFERRED + "x_category_product_product_fk" FOREIGN KEY (product_id) +REFERENCES product(product_id) DEFERRABLE INITIALLY DEFERRED + + + +and + + +\d product_attribute_value + Table "public.product_attribute_value" + Column | Type | Modifiers +----------------------------+-----------------------+----------- +attribute_id | integer | not null +attribute_unit_id | integer | +attribute_value_id | integer | +boolean_value | character varying(5) | +decimal_value | numeric(30,10) | +product_attribute_value_id | integer | not null +product_id | integer | not null +product_reference_id | integer | +status_code | character varying(32) | +Indexes: + "product_attribute_value_pk" PRIMARY KEY, btree +(product_attribute_value_id) + "product_attribute_value__attribute_id_fk_idx" btree (attribute_id) + "product_attribute_value__attribute_unit_id_fk_idx" btree +(attribute_unit_id) + "product_attribute_value__attribute_value_id_fk_idx" btree +(attribute_value_id) + "product_attribute_value__normalized_value_idx" btree +(normalized_value(decimal_value, attribute_unit_id)) + "product_attribute_value__prod_id_att_id_status_is_null_ids" +btree (((product_id::text || '.'::text) || attribute_id::text)) WHERE +status_code IS NULL + "product_attribute_value__prod_id_att_val_id_status_is_null_idx" +btree (((product_id::text || '.'::text) || attribute_value_id::text)) +WHERE status_code IS NULL + "product_attribute_value__product_id_fk_idx" btree (product_id) +CLUSTER + "product_attribute_value__product_reference_id_fk_idx" btree +(product_reference_id) +Foreign-key constraints: + "product_attribute_value_attribute_fk" FOREIGN KEY +(attribute_id) REFERENCES attribute(attribute_id) DEFERRABLE +INITIALLY DEFERRED + "product_attribute_value_attributeunit_fk" FOREIGN KEY +(attribute_unit_id) REFERENCES attribute_unit(attribute_unit_id) +DEFERRABLE INITIALLY DEFERRED + "product_attribute_value_attributevalue_fk" FOREIGN KEY +(attribute_value_id) REFERENCES attribute_value(attribute_value_id) +DEFERRABLE INITIALLY DEFERRED + "product_attribute_value_product_fk" FOREIGN KEY (product_id) +REFERENCES product(product_id) DEFERRABLE INITIALLY DEFERRED + "product_attribute_value_productreference_fk" FOREIGN KEY +(product_reference_id) REFERENCES product(product_id) DEFERRABLE +INITIALLY DEFERRED + + + +When the query planner uses the indexes with the concatenated values +and the where clause, the query can be sub-second response times (but +not always depending on the category_id value). By just doing a +regular join as you suggested, it's always slower. The trick is +getting Postgres to use the proper index all the time. And so far the +only way I can do that is by turning off sequential scans, but that's +something I didn't want to do because I don't know how it would +affect the performance of the rest of my application. + +Just a note, I have random_page_cost set to 1 to try and get it to +favour index scans. The database machine has 8GB of RAM and I have +effective_cache_size set to 2/3 of that. + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On May 21, 2006, at 4:50 AM, Ragnar wrote: + +> On sun, 2006-05-21 at 02:21 -0600, Brendan Duddridge wrote: +>> Hi, +>> +>> +>> I have a query that performs WAY better when I have enable_seqscan = +>> off: +>> +>> +>> explain analyze select ac.attribute_id, la.name, ac.sort_order from +>> attribute_category ac, localized_attribute la where ac.category_id = +>> 1001402 and la.locale_id = 1000001 and ac.is_browsable = 'true' and +>> la.attribute_id = ac.attribute_id and exists ( select 'x' from +>> product_attribute_value pav, category_product cp where +>> (pav.product_id +>> || '.' || pav.attribute_id) = (cp.product_id || '.' || +>> ac.attribute_id) and pav.status_code is null and (cp.category_id || +>> '.' || cp.is_visible) = '1001402.true') order by (ac.sort_order is +>> null), ac.sort_order, la.name asc; +> +> is there some reason for the complicated form of the +> join conditions in the subselect? +> +> would this not be clearer: +> +> explain analyze +> select ac.attribute_id, +> la.name, +> ac.sort_order +> from attribute_category ac, +> localized_attribute la +> where ac.category_id = 1001402 +> and la.locale_id = 1000001 +> and ac.is_browsable = 'true' +> and la.attribute_id = ac.attribute_id +> and exists +> (select 'x' from product_attribute_value pav, +> category_product cp +> where pav.product_id = cp.product_id +> and pav.attribute_id = ac.attribute_id +> and pav.status_code is null +> and cp.category_id= '1001402' +> and cp.is_visible = 'true' +> ) +> order by (ac.sort_order is null), +> ac.sort_order, +> la.name asc; +> +> +> possibly the planner would have a better time +> figuring out if any indexes are usable or estimating +> the subselect rowcount +> +> gnari +> +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + + + +From pgsql-performance-owner@postgresql.org Sun May 21 19:45:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C2F889FB1B7 + for ; + Sun, 21 May 2006 19:45:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 39620-04 + for ; + Sun, 21 May 2006 19:45:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail7.sea5.speakeasy.net (mail7.sea5.speakeasy.net + [69.17.117.9]) by postgresql.org (Postfix) with ESMTP id CC0C59FA2EB + for ; + Sun, 21 May 2006 19:45:18 -0300 (ADT) +Received: (qmail 11030 invoked from network); 21 May 2006 22:45:16 -0000 +Received: from dsl093-038-250.pdx1.dsl.speakeasy.net (HELO [192.168.1.20]) + (davidw@[66.93.38.250]) (envelope-sender ) + by mail7.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted + SMTP + for ; 21 May 2006 22:45:16 -0000 +In-Reply-To: <200605211223.49499.josh@agliodbs.com> +References: <1D5FC47D-8D90-4856-8EB7-833476A37587@kineticode.com> + <200605211223.49499.josh@agliodbs.com> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: David Wheeler +Subject: Re: Benchmarking Function +Date: Sun, 21 May 2006 15:45:14 -0700 +To: Josh Berkus +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/414 +X-Sequence-Number: 19201 + +On May 21, 2006, at 12:23, Josh Berkus wrote: + +> Well, per our conversation the approach doesn't really work. EXECUTE +> 'string' + generate_series seems to carry a substantial and +> somewhat random +> overhead, between 100ms and 200ms -- enough to wipe out any +> differences +> between queries. + +Per our conversation I eliminated the EXECUTE 'string' + +generate_series. Check it out. + + http://theory.kineticode.com/computers/databases/postgresql/ +benchmarking_functions.html + +(Temporary URL; justatheory.com seems to have disappeared from DNS... + +Best, + +David + +From pgsql-performance-owner@postgresql.org Mon May 22 12:15:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8BA8D9F9A8D + for ; + Mon, 22 May 2006 12:15:02 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 45755-09 + for ; + Mon, 22 May 2006 12:14:52 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id AF68B9F9316 + for ; + Mon, 22 May 2006 12:14:52 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Mon, 22 May 2006 15:14:51 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 22 May 2006 10:14:51 -0500 +Subject: Re: utilizing multiple disks for i/o performance +From: Scott Marlowe +To: Kenji Morishige +Cc: pgsql-performance@postgresql.org +In-Reply-To: <20060520023745.GA14877@juniper.net> +References: <20060520023745.GA14877@juniper.net> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1148310891.30414.54.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Mon, 22 May 2006 10:14:51 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/415 +X-Sequence-Number: 19202 + +On Fri, 2006-05-19 at 21:37, Kenji Morishige wrote: +> Where can I find any documentation to partition the tablespace disk files onto +> different physical arrays for improved performance? + +There have been quite a few posts to this list in the past about this, +so searching it might be a good start. + +Firstly, you need to defined "improved performance". Are we talking +transactional throughput (OLTP), or batch updates (ETL), or report +generation (OLAP stuff)??? Or some other scenario. + +For write performance, the general rules are: + +You can only commit 1 transaction per rotation of a properly fsynced +disc that holds the WAL file (i.e. the pg_xlog directory). So, putting +that on it's own fast spinning disc is step one for improved +performance. + +A battery backed cache unit (BBU) on a RAID controller is a must. + +RAID 1+0 is a good choice for your data partition. + +For many hardware RAID controllers with the above mentioned BBU moving +the pg_xlog to another partition is no real help. + +Cheap RAID controllers are often worse than no RAID controller. If you +can't afford a good RAID controller, you're probably better off with +software RAID than using a cheapie. + +For READ performance: + +Often settings in postgresql.conf are far more important than the drive +layout. + +Lots of RAM is a good thing. + +Assuming you've got lots of RAM, making shared_buffers anywhere from 10 +to 25% of it is a pretty good size. + +work_mem usually works well at around 16 meg or so. + +drop random_page_cost to about 2 for most systems. + +Lastly, read this: + +http://www.varlena.com/GeneralBits/Tidbits/perf.html + +From pgsql-performance-owner@postgresql.org Mon May 22 12:20:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id CD1179F946D + for ; + Mon, 22 May 2006 12:20:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 53873-05 + for ; + Mon, 22 May 2006 12:20:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 7D2A79F9316 + for ; + Mon, 22 May 2006 12:20:21 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id C5A3456431; Mon, 22 May 2006 10:20:20 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Mon, 22 May 2006 10:20:19 -0500 +Date: Mon, 22 May 2006 10:20:18 -0500 +From: "Jim C. Nasby" +To: Cstdenis +Cc: pgsql-performance@postgresql.org +Subject: Re: How can I make this query faster (resend) +Message-ID: <20060522152016.GM64371@pervasive.com> +References: <03e001c67b99$8321f010$6401a8c0@chris> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <03e001c67b99$8321f010$6401a8c0@chris> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060522:cstdenis@voicio.com::hfddSE1OaHtJMBN2:000000000000000000 + 0000000000000000000000006m/7 +X-Hashcash: + 1:20:060522:pgsql-performance@postgresql.org::F63cFY9yjNGD1Ig3:00000 + 0000000000000000000000002fjC +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/416 +X-Sequence-Number: 19203 + +On Fri, May 19, 2006 at 03:56:49PM -0700, Cstdenis wrote: +> (Its been a hour and I dont see my message on the list so I'm sending it again. I've moved the queries and analyze out of the email incase it was rejected because too long) +> +> query: http://pastebin.ca/57218 +> +> In the pictures table all the ratings have a shared index +> +> CREATE INDEX idx_rating ON pictures USING btree (rating_nudity, rating_violence, rating_sex, rating_racism, rating_spoilers, rating_yaoi, rating_yuri, rating_profanity); +> +> and approved and date_submitted and user_id also have their own btree indexes. +> +> In the picture_categories table pid and cat_id have their own btree indices plus one together. +> +> Full table definition: http://pastebin.ca/57219 +> +> the cat_id and rating values vary from query to query. The one listed above took 54 seconds in a test run just now. Here is explain analyze: http://pastebin.ca/57220 + +pictures is the interesting table here. It looks like the planner would +do better to choose something other than a nested loop on it. Try +running EXPLAIN ANALYZE on the query with enable_nestloop=off and see +what you get (you'll need to compare it to what you get with +enable_nestloop on to see what the change is). + +> Both pictures and picture categories have about 287,000 rows +> +> This query needs to run in under about a second or it kills my site by clogging apache slots (apache maxes out at 256 and I can have several hundred people on my site at a time). How can I make it run faster? +> +> +> Server is a dual xeon with a gig of ram dedicated mostly to postgresql. +> Here is the changed lines in my postgresql.conf: http://pastebin.ca/57222 + +I suspect the low work_mem may be why it's using a nested loop. In +addition to the test above, it would be interesting to see what happens +to the plan if you set work_mem to 10000. + +To be honest, you're pushing things expecting a machine with only 1G to +serve 300 active connections. How large is the database itself? + +> I know hyperthreading is considered something that can slow down a server but with my very high concurancy (averages about 400-500 concurant users during peak hours) I am hoping the extra virtual CPUs wil help. Anyone have experance that says diferent at high concurancy? + +Best bet is to try it and see. Generally, people find HT hurts, but I +recently saw it double the performance of pgbench on a windows XP +machine, so it's possible that windows is just more clever about how to +use it than linux is. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon May 22 12:21:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C24449F946D + for ; + Mon, 22 May 2006 12:21:24 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 49270-09 + for ; + Mon, 22 May 2006 12:21:20 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id A2B229F9316 + for ; + Mon, 22 May 2006 12:21:20 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id A4D9E5643D; Mon, 22 May 2006 10:21:19 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Mon, 22 May 2006 10:21:18 -0500 +Date: Mon, 22 May 2006 10:21:18 -0500 +From: "Jim C. Nasby" +To: Kenji Morishige +Cc: pgsql-performance@postgresql.org +Subject: Re: utilizing multiple disks for i/o performance +Message-ID: <20060522152118.GN64371@pervasive.com> +References: <20060520023745.GA14877@juniper.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060520023745.GA14877@juniper.net> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060522:kenjim@juniper.net::AoY6ulp2sEtyKuvh:0000000000000000000 + 0000000000000000000000002U+6 +X-Hashcash: + 1:20:060522:pgsql-performance@postgresql.org::BjtNJ98iM+1sncgM:00000 + 0000000000000000000000002J0W +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/417 +X-Sequence-Number: 19204 + +On Fri, May 19, 2006 at 07:37:45PM -0700, Kenji Morishige wrote: +> Where can I find any documentation to partition the tablespace disk files onto +> different physical arrays for improved performance? + +Other than CREATE TABLESPACE?? +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon May 22 12:26:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 75C759F946D + for ; + Mon, 22 May 2006 12:26:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 54426-05 + for ; + Mon, 22 May 2006 12:26:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 30B289F9316 + for ; + Mon, 22 May 2006 12:25:59 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 39C2856435; Mon, 22 May 2006 10:25:56 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Mon, 22 May 2006 10:25:54 -0500 +Date: Mon, 22 May 2006 10:25:51 -0500 +From: "Jim C. Nasby" +To: Brendan Duddridge +Cc: Ragnar , + PostgreSQL Performance +Subject: Re: Performs WAY better with enable_seqscan = off +Message-ID: <20060522152549.GO64371@pervasive.com> +References: + <1148208611.28240.101.camel@localhost.localdomain> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060522:brendan@clickspace.com::Yj0UWf9pA8ZFJvPm:000000000000000 + 0000000000000000000000001g1V +X-Hashcash: 1:20:060522:gnari@hive.is::Hix/SskWJchKun0p:000014T0 +X-Hashcash: + 1:20:060522:pgsql-performance@postgresql.org::tYG6dK9VgZsjHZH7:00000 + 0000000000000000000000009hC7 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/418 +X-Sequence-Number: 19205 + +On Sun, May 21, 2006 at 02:01:14PM -0600, Brendan Duddridge wrote: +> When the query planner uses the indexes with the concatenated values +> and the where clause, the query can be sub-second response times (but +> not always depending on the category_id value). By just doing a +> regular join as you suggested, it's always slower. The trick is +> getting Postgres to use the proper index all the time. And so far the +> only way I can do that is by turning off sequential scans, but that's +> something I didn't want to do because I don't know how it would +> affect the performance of the rest of my application. + +You can always disable them for just that query... +BEGIN; +SET LOCAL enable_seqscan=off; +SELECT ... +COMMIT; + +> Just a note, I have random_page_cost set to 1 to try and get it to +> favour index scans. The database machine has 8GB of RAM and I have +> effective_cache_size set to 2/3 of that. + +That's rather low for that much memory; I'd set it to 7GB. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon May 22 12:30:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 36D879F946D + for ; + Mon, 22 May 2006 12:30:27 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 56013-09 + for ; + Mon, 22 May 2006 12:30:14 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id B733E9F9316 + for ; + Mon, 22 May 2006 12:30:12 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id A7C0956431; Mon, 22 May 2006 10:30:11 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Mon, 22 May 2006 10:30:10 -0500 +Date: Mon, 22 May 2006 10:30:08 -0500 +From: "Jim C. Nasby" +To: Brendan Duddridge +Cc: PostgreSQL Performance +Subject: Re: Performs WAY better with enable_seqscan = off +Message-ID: <20060522153007.GP64371@pervasive.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060522:brendan@clickspace.com::T8/GfzlfR7miT0MK:000000000000000 + 0000000000000000000000008MTj +X-Hashcash: + 1:20:060522:pgsql-performance@postgresql.org::+gYJ8T5Bqe4H2faa:00000 + 0000000000000000000000002KRH +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/420 +X-Sequence-Number: 19207 + +The problem is that the planner is guessing horribly at what the nodes +will return, and I'm betting the reason for that is your join criteria. +Why are you joining on fields that are concatenated together, instead of +just joining on the fields themselves? That's a sure-fire way to confuse +the planner, and greatly limit your options. + +On Sun, May 21, 2006 at 02:21:55AM -0600, Brendan Duddridge wrote: +> Hi, +> +> I have a query that performs WAY better when I have enable_seqscan = +> off: +> +> explain analyze select ac.attribute_id, la.name, ac.sort_order from +> attribute_category ac, localized_attribute la where ac.category_id = +> 1001402 and la.locale_id = 1000001 and ac.is_browsable = 'true' and +> la.attribute_id = ac.attribute_id and exists ( select 'x' from +> product_attribute_value pav, category_product cp where +> (pav.product_id || '.' || pav.attribute_id) = (cp.product_id || '.' +> || ac.attribute_id) and pav.status_code is null and (cp.category_id +> || '.' || cp.is_visible) = '1001402.true') order by (ac.sort_order is +> null), ac.sort_order, la.name asc; +> +> QUERY PLAN +> ------------------------------------------------------------------------ +> ------------------------------------------------------------------------ +> ------------------------------------------------------------------------ +> ------ +> Sort (cost=47.97..47.98 rows=7 width=34) (actual +> time=33368.721..33368.721 rows=2 loops=1) +> Sort Key: (ac.sort_order IS NULL), ac.sort_order, la.name +> -> Nested Loop (cost=2.00..47.87 rows=7 width=34) (actual +> time=13563.049..33368.679 rows=2 loops=1) +> -> Index Scan using attribute_category__category_id_fk_idx +> on attribute_category ac (cost=0.00..26.73 rows=7 width=8) (actual +> time=13562.918..33368.370 rows=2 loops=1) +> Index Cond: (category_id = 1001402) +> Filter: (((is_browsable)::text = 'true'::text) AND +> (subplan)) +> SubPlan +> -> Nested Loop (cost=0.02..278217503.21 +> rows=354763400 width=0) (actual time=4766.821..4766.821 rows=0 loops=7) +> -> Seq Scan on category_product cp +> (cost=0.00..158150.26 rows=18807 width=4) (actual +> time=113.595..4585.461 rows=12363 loops=7) +> Filter: ((((category_id)::text || +> '.'::text) || (is_visible)::text) = '1001402.true'::text) +> -> Index Scan using +> product_attribute_value__prod_id_att_id_status_is_null_ids on +> product_attribute_value pav (cost=0.02..14171.84 rows=18863 width=8) +> (actual time=0.012..0.012 rows=0 loops=86538) +> Index Cond: ((((pav.product_id)::text +> || '.'::text) || (pav.attribute_id)::text) = +> ((("outer".product_id)::text || '.'::text) || ($0)::text)) +> -> Bitmap Heap Scan on localized_attribute la +> (cost=2.00..3.01 rows=1 width=30) (actual time=0.129..0.129 rows=1 +> loops=2) +> Recheck Cond: (la.attribute_id = "outer".attribute_id) +> Filter: (locale_id = 1000001) +> -> Bitmap Index Scan on +> localized_attribute__attribute_id_fk_idx (cost=0.00..2.00 rows=1 +> width=0) (actual time=0.091..0.091 rows=1 loops=2) +> Index Cond: (la.attribute_id = +> "outer".attribute_id) +> Total runtime: 33369.105 ms +> +> Now when I disable sequential scans: +> +> set enable_seqscan = off; +> +> explain analyze select ac.attribute_id, la.name, ac.sort_order from +> attribute_category ac, localized_attribute la where ac.category_id = +> 1001402 and la.locale_id = 1000001 and ac.is_browsable = 'true' and +> la.attribute_id = ac.attribute_id and exists ( select 'x' from +> product_attribute_value pav, category_product cp where +> (pav.product_id || '.' || pav.attribute_id) = (cp.product_id || '.' +> || ac.attribute_id) and pav.status_code is null and (cp.category_id +> || '.' || cp.is_visible) = '1001402.true') order by (ac.sort_order is +> null), ac.sort_order, la.name asc; +> +> QUERY PLAN +> ------------------------------------------------------------------------ +> ------------------------------------------------------------------------ +> ------------------------------------------------------------------------ +> ------ +> Sort (cost=48.09..48.11 rows=7 width=34) (actual +> time=1675.944..1675.945 rows=2 loops=1) +> Sort Key: (ac.sort_order IS NULL), ac.sort_order, la.name +> -> Nested Loop (cost=2.00..48.00 rows=7 width=34) (actual +> time=687.600..1675.831 rows=2 loops=1) +> -> Index Scan using attribute_category__category_id_fk_idx +> on attribute_category ac (cost=0.00..26.86 rows=7 width=8) (actual +> time=687.441..1675.584 rows=2 loops=1) +> Index Cond: (category_id = 1001402) +> Filter: (((is_browsable)::text = 'true'::text) AND +> (subplan)) +> SubPlan +> -> Nested Loop (cost=0.03..278076992.97 +> rows=354763400 width=0) (actual time=239.299..239.299 rows=0 loops=7) +> -> Index Scan using +> category_product__cat_id_is_visible_idx on category_product cp +> (cost=0.01..17640.02 rows=18807 width=4) (actual time=0.036..30.205 +> rows=12363 loops=7) +> Index Cond: ((((category_id)::text || +> '.'::text) || (is_visible)::text) = '1001402.true'::text) +> -> Index Scan using +> product_attribute_value__prod_id_att_id_status_is_null_ids on +> product_attribute_value pav (cost=0.02..14171.84 rows=18863 width=8) +> (actual time=0.013..0.013 rows=0 loops=86538) +> Index Cond: ((((pav.product_id)::text +> || '.'::text) || (pav.attribute_id)::text) = +> ((("outer".product_id)::text || '.'::text) || ($0)::text)) +> -> Bitmap Heap Scan on localized_attribute la +> (cost=2.00..3.01 rows=1 width=30) (actual time=0.093..0.094 rows=1 +> loops=2) +> Recheck Cond: (la.attribute_id = "outer".attribute_id) +> Filter: (locale_id = 1000001) +> -> Bitmap Index Scan on +> localized_attribute__attribute_id_fk_idx (cost=0.00..2.00 rows=1 +> width=0) (actual time=0.060..0.060 rows=1 loops=2) +> Index Cond: (la.attribute_id = +> "outer".attribute_id) +> Total runtime: 1676.727 ms +> +> +> the tables involved with the query have all been vacuum analyzed. I +> also have default_statistics_target = 100. +> +> There's something definitely wrong with that Nested Loop with the +> high row count. That row count appears to be close to the product of +> the number of rows in category_product and product_attribute_value. +> +> Any ideas and help would be greatly appreciated. +> +> +> Thanks, +> +> +> ____________________________________________________________________ +> Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com +> +> ClickSpace Interactive Inc. +> Suite L100, 239 - 10th Ave. SE +> Calgary, AB T2G 0V9 +> +> http://www.clickspace.com +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Mon May 22 12:30:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2FAD79F9A8D + for ; + Mon, 22 May 2006 12:30:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 53873-09 + for ; + Mon, 22 May 2006 12:30:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (mail.logix-tt.com [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 649019F946D + for ; + Mon, 22 May 2006 12:30:13 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (Tb043.t.pppool.de + [89.55.176.67]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id 52666656C0; + Mon, 22 May 2006 17:31:30 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 9AA89185B60B8; + Mon, 22 May 2006 17:30:29 +0200 (CEST) +Message-ID: <4471D915.3010109@logix-tt.com> +Date: Mon, 22 May 2006 17:30:29 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: Cstdenis +Cc: pgsql-performance@postgresql.org +Subject: Re: How can I make this query faster (resend) +References: <03e001c67b99$8321f010$6401a8c0@chris> +In-Reply-To: <03e001c67b99$8321f010$6401a8c0@chris> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/419 +X-Sequence-Number: 19206 + +Hi, Cstendis, + +Cstdenis wrote: + +> Server is a dual xeon with a gig of ram dedicated mostly to postgresql. +> Here is the changed lines in my postgresql.conf: http://pastebin.ca/57222 + +3M is really low for a production server. + +Try using pg_pool and limiting it to about 30 or so backend connections, +and then give them at least 30 megs of RAM each. + +This should also cut down the connection creation overhead. + +HTH, +Markus +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Mon May 22 14:20:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F38B79F9B01 + for ; + Mon, 22 May 2006 14:20:24 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 76176-01 + for ; + Mon, 22 May 2006 14:20:11 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.200]) + by postgresql.org (Postfix) with ESMTP id 1BDB99F9D99 + for ; + Mon, 22 May 2006 14:20:10 -0300 (ADT) +Received: by wx-out-0102.google.com with SMTP id i28so211946wxd + for ; + Mon, 22 May 2006 10:20:09 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:mime-version:content-type; + b=fn6WBQ9mR/RXtviYYyJjZ7BqupOHqq/hn3Dx5m77UbT4Sc904hIhUhbHYzPC8KEj5tsA+hYWaGo2qC4F10uTdfuMx3+inwts1NIat7H05DFxjqw7OWADdXNof6J/yyrkUhl1UFg8e9qzliUcQ9pi/b4QQkES8O1kfrsxsgJgmWg= +Received: by 10.70.31.19 with SMTP id e19mr5392923wxe; + Mon, 22 May 2006 10:20:09 -0700 (PDT) +Received: by 10.70.38.2 with HTTP; Mon, 22 May 2006 10:20:09 -0700 (PDT) +Message-ID: +Date: Mon, 22 May 2006 12:20:09 -0500 +From: "Meetesh Karia" +Reply-To: meetesh.karia@alumni.duke.edu +To: pgsql-performance@postgresql.org +Subject: Query hanging/not finishing inconsistently +Cc: "Jean-David Dahan" +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_23864_27685936.1148318409488" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/421 +X-Sequence-Number: 19208 + +------=_Part_23864_27685936.1148318409488 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi all, + +We've recently started having a problem where a query that normally execute= +s +in ~15ms starts to take upwards of 20s to complete. When the connection +that ran query is returned to the connection pool, it appears as though a +transaction is still in progress so the connection pool tries to cancel the +transaction and close the connection. This fails and the connection is +removed from the connection pool. At this point, the situation rapidly +degrades and we run out of connections to the postgres server. + +An inspection of the pg_stat_activity table shows that practically every +connection is running the above-mentioned query and some of those queries +have been active for many minutes! We've looked at the pg_locks table as +well and the only exclusive locks are on transactions that are open. All +other locks are AccessShareLocks. Also, as far as we can tell (from lookin= +g +at the Hibernate stats), every db session that is opened is closed. + +When this happens, if I kill one of the running postgres processes (just by +picking the last process returned from "ps -ef | grep postgres"), the other +queries will immediately finish and the system will respond. However, +within 15 minutes, we'll be back in the same state as before. At that +point, I've cycled Apache, Tomcat and Postgres and the system then seems to +come back. + +This problem appears to be unrelated to load and in fact, the majority of +the time there is very little load on the site when this occurs. We've run +load tests on our dev boxes but we've been unable to reproduce the problem. +We're currently working on playing back the clicks on the site previous to +the weird state the site gets in and at the same time, we were wondering if +anyone has experienced a problem like this or has any suggestions. + +The query in question is: + +select distinct s.screening_id, f.film_id, f.title, s.period_start, +f.runtime, c.value, v.short_name, s.parent_id, + stats.avg_rating, coalesce(stats.num_adds, 0) as num_adds, coalesce= +( +stats.unique_visits, 0) as unique_visits, + f.*, s.* + from lte_screening s + inner join lte_film f on s.film_id =3D f.film_id + inner join lte_venue v on s.venue_id =3D v.venue_id + inner join lte_film_classifier c on c.film_id =3D f.film_id + left join lte_film_stats stats on stats.context =3D :context and +stats.film_id =3D s.film_id + where c.name =3D ? and s.period_start is not null and s.festival_id =3D= + ? + and s.period_start between ? + ? and ? + ? + order by s.period_start, f.title; + +And the result of explain analyze: + +QUERY PLAN +Unique (cost=3D1117.42..1118.71 rows=3D11 width=3D866) (actual time=3D +18.306..18.386 rows=3D15 loops=3D1) + -> Sort (cost=3D1117.42..1117.44 rows=3D11 width=3D866) (actual time=3D +18.300..18.316 rows=3D15 loops=3D1) + Sort Key: s.period_start, f.title, s.screening_id, f.film_id, +f.runtime, c.value, v.short_name, s.parent_id, stats.avg_rating, COALESCE( +stats.num_adds, 0), COALESCE(stats.unique_visits, 0::bigint), f.film_id, +f.sku, f.title, f."template", f.release_date, f.runtime, f."language", +f.country, f.mpaa_rating, f.synopsis, f."owner", f.ext_sales_rank, +f.small_image_url, f.medium_image_url, f.large_image_url, f.detail_page, +f.to_delete, f.coalesce_to, (subplan), (subplan), s.screening_id, +s.period_start, s.period_end, s.ticket_price, s.tickets_avail, +s.tickets_sold, s."type", s.venue_id, s.festival_id, s.film_id, s.parent_id= +, +s.ext_id, s.purchase_url, s.status, s.status_update_time + -> Nested Loop Left Join (cost=3D2.62..1117.23 rows=3D11 width=3D= +866) +(actual time=3D2.656..17.773 rows=3D15 loops=3D1) + -> Nested Loop (cost=3D2.62..976.00 rows=3D11 width=3D846) = +(actual +time=3D2.347..16.162 rows=3D15 loops=3D1) + -> Hash Join (cost=3D2.62..929.09 rows=3D10 width=3D8= +31) +(actual time=3D2.217..15.480 rows=3D15 loops=3D1) + Hash Cond: ("outer".venue_id =3D "inner".venue_id= +) + -> Nested Loop (cost=3D0.00..926.32 rows=3D10 +width=3D818) (actual time=3D1.915..14.974 rows=3D15 loops=3D1) + -> Seq Scan on lte_screening s (cost=3D +0.00..886.67 rows=3D10 width=3D159) (actual time=3D1.830..14.314 rows=3D15 = +loops=3D1) + Filter: ((period_start IS NOT NULL) +AND (festival_id =3D 316372) AND (period_start >=3D '2006-05-19 +05:00:00'::timestamp without time zone) AND (period_start <=3D '2006-05-20 +04:59:59'::timestamp without time zone)) + -> Index Scan using lte_film_pkey on +lte_film f (cost=3D0.00..3.95 rows=3D1 width=3D659) (actual +time=3D0.026..0.028rows=3D1 loops=3D15) + Index Cond: ("outer".film_id =3D +f.film_id) + -> Hash (cost=3D2.50..2.50 rows=3D50 width=3D21= +) +(actual time=3D0.215..0.215 rows=3D0 loops=3D1) + -> Seq Scan on lte_venue v (cost=3D +0.00..2.50 rows=3D50 width=3D21) (actual time=3D0.012..0.126 rows=3D52 loop= +s=3D1) + -> Index Scan using idx_classifier_film on +lte_film_classifier c (cost=3D0.00..4.67 rows=3D2 width=3D23) (actual time= +=3D +0.026..0.028 rows=3D1 loops=3D15) + Index Cond: (c.film_id =3D "outer".film_id) + Filter: ((name)::text =3D 'FestivalCategory'::tex= +t) + -> Index Scan using lte_film_stats_pkey on lte_film_stats +stats (cost=3D0.00..4.34 rows=3D1 width=3D28) (actual time=3D0.034..0.037 = +rows=3D1 +loops=3D15) + Index Cond: ((stats.context =3D 316372) AND +(stats.film_id=3D "outer".film_id)) + SubPlan + -> Index Scan using idx_collateral_film on +lte_film_collateral c (cost=3D0.00..4.24 rows=3D1 width=3D40) (actual time= +=3D +0.009..0.011 rows=3D1 loops=3D15) + Index Cond: (film_id =3D $0) + Filter: ((name)::text =3D 'TVRating'::text) + -> Index Scan using idx_collateral_film on +lte_film_collateral c (cost=3D0.00..4.24 rows=3D1 width=3D40) (actual time= +=3D +0.022..0.025 rows=3D1 loops=3D15) + Index Cond: (film_id =3D $0) + Filter: ((name)::text =3D 'IMDBId'::text) +Total runtime: 19.077 ms + + +Here is our setup: + +We have 2 machines. The first is the web server and the db server and the +second is just another web server: + +Machine A +- 1 GB RAM +- 1 Intel(R) Xeon(TM) CPU 2.80GHz HyperThreaded Processor +- CentOS 4.3 +- Linux moe 2.6.9-22.ELsmp #1 SMP Sat Oct 8 19:11:43 CDT 2005 i686 i686 i38= +6 +GNU/Linux + +Machine B +- 1 GB RAM +- 1 Intel(R) Xeon(TM) CPU 2.80GHz Processor +- CentOS 4.3 +- Linux larry 2.6.9-22.0.1.EL #1 Thu Oct 27 12:26:11 CDT 2005 i686 i686 i38= +6 +GNU/Linux + +We're using the following software: +- Apache 2.0.52 +- Tomcat 5.5.17 +- Postgres 8.0.6 +- JDK 1.5.0-Release 6 +- Proxool 0.8.3 +- Hibernate 3.1.3 + +Thanks in advance for any help, +Meetesh + +------=_Part_23864_27685936.1148318409488 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi all,

We've recently started having a problem where a query that n= +ormally executes in ~15ms starts to take upwards of 20s to complete.  = +When the connection that ran query is returned to the connection pool, it a= +ppears as though a transaction is still in progress so the connection pool = +tries to cancel the transaction and close the connection.  This fails = +and the connection is removed from the connection pool.  At this point= +, the situation rapidly degrades and we run out of connections to the postg= +res server. +

An inspection of the pg_stat_activity table shows that practically = +every connection is running the above-mentioned query and some of those que= +ries have been active for many minutes!  We've looked at the pg_locks = +table as well and the only exclusive locks are on transactions that are ope= +n.  All other locks are AccessShareLocks.  Also, as far as we can= + tell (from looking at the Hibernate stats), every db session that is opene= +d is closed. +

When this happens, if I kill one of the running postgres processes = +(just by picking the last process returned from "ps -ef | grep postgre= +s"), the other queries will immediately finish and the system will res= +pond.  However, within 15 minutes, we'll be back in the same state as = +before.  At that point, I've cycled Apache, Tomcat and Postgres and th= +e system then seems to come back. +

This problem appears to be unrelated to load and in fact, the major= +ity of the time there is very little load on the site when this occurs.&nbs= +p; We've run load tests on our dev boxes but we've been unable to reproduce= + the problem.  We're currently working on playing back the clicks on t= +he site previous to the weird state the site gets in and at the same time, = +we were wondering if anyone has experienced a problem like this or has any = +suggestions. +

The query in question is:

select distinct s.screening_id, f.film_id, f.title, s.per= +iod_start, f.runtime, c.value, v.short_name, s.parent_id,
+    = +;    stats.avg_rating, coalesce(stats.num_adds, 0) as num_ad= +ds, coalesce(stats.unique_visits, 0) as unique_visits,
+    = +;    f.*, s.*
  &= +nbsp; from lte_screening s
+    = +;    inner join lte_film f on s.film_id =3D f.film_id= +
        inner= + join lte_venue v on=20 +s.venue_id =3D v.venue_id
  &nbs= +p;     inner join lte_film_classifier c on c.film_id = +=3D f.film_id
+    = +;    left join lte_film_stats stats on stats.context =3D :co= +ntext and stats.film_id =3D s.film_id
+    where c.name =3D ? and s.p= +eriod_start is not null and s.festival_id =3D ?
        and s.period_start + between ? + ? and ? + ?
   = +; order by s.period_start, f.title;

And the result of explain= + analyze:

+QUERY PLAN
Unique  (cost=3D1117.42..1118.71 rows=3D11 width= +=3D866) (actual time=3D +18.306..18.386 rows=3D15 loops=3D1)
 = + ->  Sort  (cost=3D1117.42..1117.44 rows=3D11 width=3D866) (ac= +tual time=3D18.300..18.316 rows=3D15 loops=3D1) +
       = +; Sort Key: s.period_start, f.title, s.screening_id, f.film_id, f.runtime, = +c.value, v.short_name, s.parent_id,=20 +stats.avg_rating, COALESCE(stats.num_adds, 0), COALESCE(stats.unique_visits= +, 0::bigint), f.film_id, f.sku, f.title, f."template", f.release_= +date, f.runtime, f."language", f.country, f.mpaa_rating, f.synops= +is +, f."owner", f.ext_sales_rank, f.small_image_url, f.medium_image_= +url, f.large_image_url, f.detail_page, f.to_delete, f.coalesce_to, (subplan= +), (subplan), s.screening_id, s.period_start, s.period_end, s.ticket_price +, s.tickets_avail, s.tickets_sold, s."type", s.venue_id, s.festiv= +al_id, s.film_id, s.parent_id, s.ext_id, s.purchase_url, s.status, s.status= +_update_time
+        ->  Nested Loop Left Joi= +n  (cost=3D2.62..1117.23 rows=3D11 width=3D866) (actual time=3D2.656..= +17.773 rows=3D15 loops=3D1)
+            &nb= +sp; ->  Nested Loop  (cost=3D2.62..976.00 rows=3D11 width=3D84= +6) (actual time=3D2.347..16.162 rows=3D15 loops=3D1)
          &nbs= +p;         ->  Hash Join&nb= +sp; (cost=3D +2.62..929.09 rows=3D10 width=3D831) (actual time=3D2.217..15.480 rows=3D15 = +loops=3D1)
     &= +nbsp;           &nbs= +p;        Hash Cond: ("outer".= +venue_id =3D "inner".venue_id) +
       = +;            &n= +bsp;      ->  Nested Loop  (cost=3D0.= +00..926.32 rows=3D10 width=3D818) (actual time=3D1.915..14.974 rows=3D15 lo= +ops=3D1) +
       = +;            &n= +bsp;            ->= +;  Seq Scan on lte_screening s  (cost=3D0.00..886.67 rows=3D10 wi= +dth=3D159) (actual time=3D +1.830..14.314 rows=3D15 loops=3D1)
 &= +nbsp;           &nbs= +p;            &= +nbsp;           Filter: (= +(period_start IS NOT NULL) AND (festival_id =3D 316372) AND (period_start &= +gt;=3D '2006-05-19 05:00:00'::timestamp without time zone) AND (period_star= +t <=3D '2006-05-20 04:59:59'::timestamp without time zone)) +
       = +;            &n= +bsp;            ->= +;  Index Scan using lte_film_pkey on lte_film f  (cost=3D0.00..3.= +95 rows=3D1 width=3D659) (actual time=3D +0.026..0.028 rows=3D1 loops=3D15)
 &n= +bsp;            = +;            &n= +bsp;           Index Cond= +: ("outer".film_id =3D f.film_id +)
      &nbs= +p;            &= +nbsp;      ->  Hash  (cost=3D2.50..2.= +50 rows=3D50 width=3D21) (actual time=3D0.215..0.215 rows=3D0 loops=3D1) +
       = +;            &n= +bsp;            ->= +;  Seq Scan on lte_venue v  (cost=3D0.00..2.50 rows=3D50 width=3D= +21) (actual time=3D0.012..0.126 + rows=3D52 loops=3D1)
   &n= +bsp;            = +;    ->  Index Scan using idx_classifier_film on lte= +_film_classifier c  (cost=3D0.00..4.67 + rows=3D2 width=3D23) (actual time=3D0.026..0.028 rows=3D1 loops=3D15)
       &nbs= +p;            &= +nbsp;     Index Cond: (c.film_id =3D "outer".= +film_id) +
       = +;            &n= +bsp;      Filter: ((name)::text =3D 'FestivalCateg= +ory'::text)
+    = +;          ->  Index S= +can using lte_film_stats_pkey on lte_film_stats stats  (cost=3D0.00..4= +.34 rows=3D1 width=3D28) (actual time=3D0.034..0.037 rows=3D1 loops=3D15)
+    = +;            &n= +bsp;   Index Cond: ((stats.context =3D 316372) AND (stats.film_id= + =3D "outer".film_id))
+            &nb= +sp; SubPlan
     = +           ->  In= +dex Scan using idx_collateral_film on lte_film_collateral c  (cost=3D0= +.00..4.24 + rows=3D1 width=3D40) (actual time=3D0.009..0.011 rows=3D1 loops=3D15)
       &nbs= +p;            &= +nbsp; Index Cond: (film_id =3D $0)
+    = +;            &n= +bsp;     Filter: ((name)::text =3D 'TVRating'::text)
       &n= +bsp;        ->  Index Scan using= + idx_collateral_film on lte_film_collateral c  (cost=3D +0.00..4.24 rows=3D1 width=3D40) (actual time=3D0.022..0.025 rows=3D1 loops= +=3D15)
     &nbs= +p;            &= +nbsp;   Index Cond: (film_id =3D $0) +
       = +;            &n= +bsp;  Filter: ((name)::text =3D 'IMDBId'::text)
+Total runtime: 19.077 m= +s


Here is our setup:

We have 2 machines.  The= + first is the web server and the db server and the second is just another w= +eb server: +

Machine A
- 1 GB RAM
- 1 Intel(R) Xeon(TM) CPU 2.80GHz HyperT= +hreaded Processor
- CentOS 4.3
- Linux moe 2.6.9-22.ELsmp #1 SMP Sat = +Oct 8 19:11:43 CDT 2005 i686 i686 i386 GNU/Linux

Machine B
- 1 GB= + RAM +
+- 1 Intel(R) Xeon(TM) CPU 2.80GHz Processor
- CentOS 4.3
+- Linux larry 2.6.9-22.0.1.EL #1 Thu Oct 27 12:26:11 CDT 2005 i686 i686 i38= +6 GNU/Linux

We're using the following software:
- Apache 2.0.52- Tomcat 5.5.17
- Postgres 8.0.6
- JDK 1.5.0-Release 6
- Proxool= +=20 +0.8.3
- Hibernate 3.1.3

Thanks in advance for any help,
Meetes= +h
+ +------=_Part_23864_27685936.1148318409488-- + +From pgsql-performance-owner@postgresql.org Mon May 22 15:50:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 39FBB9F9D99 + for ; + Mon, 22 May 2006 15:50:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 88987-07 + for ; + Mon, 22 May 2006 15:50:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moonunit2.moonview.localnet (wsip-70-167-125-69.sd.sd.cox.net + [70.167.125.69]) + by postgresql.org (Postfix) with ESMTP id 6E7169F9B01 + for ; + Mon, 22 May 2006 15:50:26 -0300 (ADT) +Received: from [192.168.0.3] (moonunit3.moonview.localnet [192.168.0.3]) + by moonunit2.moonview.localnet (8.13.1/8.13.1) with ESMTP id + k4MIxDSR004236; Mon, 22 May 2006 11:59:13 -0700 +Message-ID: <447207C3.8000104@modgraph-usa.com> +Date: Mon, 22 May 2006 11:49:39 -0700 +From: "Craig A. James" +User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: meetesh.karia@alumni.duke.edu +CC: pgsql-performance@postgresql.org, Jean-David Dahan +Subject: Re: Query hanging/not finishing inconsistently +References: +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/422 +X-Sequence-Number: 19209 + +Meetesh Karia wrote: +> Hi all, +> +> We've recently started having a problem where a query that normally +> executes in ~15ms starts to take upwards of 20s to complete. When the +> connection that ran query is returned to the connection pool, it appears +> as though a transaction is still in progress so the connection pool +> tries to cancel the transaction and close the connection. This fails +> and the connection is removed from the connection pool. At this point, +> the situation rapidly degrades and we run out of connections to the +> postgres server. +> +> An inspection of the pg_stat_activity table shows that practically every +> connection is running the above-mentioned query and some of those +> queries have been active for many minutes! We've looked at the pg_locks +> table as well and the only exclusive locks are on transactions that are +> open. All other locks are AccessShareLocks. Also, as far as we can +> tell (from looking at the Hibernate stats), every db session that is +> opened is closed. +> +> When this happens, if I kill one of the running postgres processes (just +> by picking the last process returned from "ps -ef | grep postgres"), the +> other queries will immediately finish and the system will respond. +> However, within 15 minutes, we'll be back in the same state as before. +> At that point, I've cycled Apache, Tomcat and Postgres and the system +> then seems to come back. + +This sounds suspiciously like a question I asked a few weeks ago, on April 4. I have a process that just gets stuck. After some questions from various of the experts in this forum, I used gdb(1) to attach to one of the frozen Postgress backend processes, and here's what I found: + +On 5/12/2006, I wrote: +> Thanks, good advice. You're absolutely right, it's stuck on a +> mutex. After doing what you suggest, I discovered that the query +> in progress is a user-written function (mine). When I log in as +> root, and use "gdb -p " to attach to the process, here's +> what I find. Notice the second function in the stack, a mutex +> lock: +> +> (gdb) bt +> #0 0x0087f7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2 +> #1 0x0096cbfe in __lll_mutex_lock_wait () from /lib/tls/libc.so.6 +> #2 0x008ff67b in _L_mutex_lock_3220 () from /lib/tls/libc.so.6 +> #3 0x4f5fc1b4 in ?? () +> #4 0x00dc5e64 in std::string::_Rep::_S_empty_rep_storage () from /usr/local/pgsql/lib/libchmoogle.so +> #5 0x009ffcf0 in ?? () from /usr/lib/libz.so.1 +> #6 0xbfe71c04 in ?? () +> #7 0xbfe71e50 in ?? () +> #8 0xbfe71b78 in ?? () +> #9 0x009f7019 in zcfree () from /usr/lib/libz.so.1 +> #10 0x009f7019 in zcfree () from /usr/lib/libz.so.1 +> #11 0x009f8b7c in inflateEnd () from /usr/lib/libz.so.1 +> #12 0x00c670a2 in ~basic_unzip_streambuf (this=0xbfe71be0) at zipstreamimpl.h:332 +> #13 0x00c60b61 in OpenBabel::OBConversion::Read (this=0x1, pOb=0xbfd923b8, pin=0xffffffea) at istream:115 +> #14 0x00c60fd8 in OpenBabel::OBConversion::ReadString (this=0x8672b50, pOb=0xbfd923b8) at obconversion.cpp:780 +> #15 0x00c19d69 in chmoogle_ichem_mol_alloc () at stl_construct.h:120 +> #16 0x00c1a203 in chmoogle_ichem_normalize_parent () at stl_construct.h:120 +> #17 0x00c1b172 in chmoogle_normalize_parent_sdf () at vector.tcc:243 +> #18 0x0810ae4d in ExecMakeFunctionResult () +> #19 0x0810de2e in ExecProject () +> #20 0x08115972 in ExecResult () +> #21 0x08109e01 in ExecProcNode () +> #22 0x00000020 in ?? () +> #23 0xbed4b340 in ?? () +> #24 0xbf92d9a0 in ?? () +> #25 0xbed4b0c0 in ?? () +> #26 0x00000000 in ?? () +> +> It looks to me like my code is trying to read the input parameter +> (a fairly long string, maybe 2K) from a buffer that was gzip'ed +> by Postgres for the trip between the client and server... somewhere +> along the way, a mutex gets set, and then ... it's stuck forever. +> +> ps(1) shows that this thread had been running for about 7 hours, +> and the job status showed that this function had been +> successfully called about 1 million times, before this mutex lock +> occurred. + +This is not an issue that's been resolved. Nobody had ever seen this before. Tom Lane suggested it might be a libc/c++ bug, but unfortunately in my case this lockup occurs so rarely (every few days) that it will be very difficult to know if we've fixed the problem. + +If gdb(1) reveals that your process is stuck in a mutex, then you might have a better chance testing this hypothesis, since your problem happens within 15 minutes or so. + +Did this start recently, perhaps right after a kernel update? + +Craig + +From pgsql-performance-owner@postgresql.org Mon May 22 17:40:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5A2A19F9D99 + for ; + Mon, 22 May 2006 17:40:27 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27211-06 + for ; + Mon, 22 May 2006 17:40:14 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wx-out-0102.google.com (wx-out-0102.google.com [66.249.82.202]) + by postgresql.org (Postfix) with ESMTP id AC60C9F9B01 + for ; + Mon, 22 May 2006 17:40:14 -0300 (ADT) +Received: by wx-out-0102.google.com with SMTP id s17so230947wxc + for ; + Mon, 22 May 2006 13:40:12 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=iDf4ZiMaChKkoF/jIAdye5DkwVd09I3YMlNRod5XgBefSKX/fHYf/mlrfzm5kFguVYtjIdlY2oa3u864Dsnj099eXikXuSyyEecfA66T+GOIxwcT5A6vkXg6nnrVSi6n7QWyrgfmUjwk/Zp/gsfoi8QgxeAC6kmR1aM11u0wqTI= +Received: by 10.70.75.12 with SMTP id x12mr5587259wxa; + Mon, 22 May 2006 13:40:11 -0700 (PDT) +Received: by 10.70.38.2 with HTTP; Mon, 22 May 2006 13:40:11 -0700 (PDT) +Message-ID: +Date: Mon, 22 May 2006 15:40:11 -0500 +From: "Meetesh Karia" +Reply-To: meetesh.karia@alumni.duke.edu +To: "Craig A. James" +Subject: Re: Query hanging/not finishing inconsistently +Cc: pgsql-performance@postgresql.org, "Jean-David Dahan" +In-Reply-To: <447207C3.8000104@modgraph-usa.com> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_28113_30947148.1148330411700" +References: + <447207C3.8000104@modgraph-usa.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/423 +X-Sequence-Number: 19210 + +------=_Part_28113_30947148.1148330411700 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi Craig, + +Thanks for your response. This did start recently and it wasn't after a +kernel update, but it was after we moved the db from Machine B to Machine A +(which have slightly different kernel versions). However, the problem took +about a week to show up after we moved from one machine to the other. +Unfortunately, the problem only reappears after 15 mins once it occurs the +first time. If it occurs again today I'll attach gdb to it and see whether +it's stuck on a mutex. + +Meetesh + +On 5/22/06, Craig A. James wrote: +> +> Meetesh Karia wrote: +> > Hi all, +> > +> > We've recently started having a problem where a query that normally +> > executes in ~15ms starts to take upwards of 20s to complete. When the +> > connection that ran query is returned to the connection pool, it appear= +s +> +> > as though a transaction is still in progress so the connection pool +> > tries to cancel the transaction and close the connection. This fails +> > and the connection is removed from the connection pool. At this point, +> > the situation rapidly degrades and we run out of connections to the +> > postgres server. +> > +> > An inspection of the pg_stat_activity table shows that practically ever= +y +> > connection is running the above-mentioned query and some of those +> > queries have been active for many minutes! We've looked at the pg_lock= +s +> > table as well and the only exclusive locks are on transactions that are +> > open. All other locks are AccessShareLocks. Also, as far as we can +> > tell (from looking at the Hibernate stats), every db session that is +> > opened is closed. +> > +> > When this happens, if I kill one of the running postgres processes (jus= +t +> > by picking the last process returned from "ps -ef | grep postgres"), th= +e +> +> > other queries will immediately finish and the system will respond. +> > However, within 15 minutes, we'll be back in the same state as before. +> > At that point, I've cycled Apache, Tomcat and Postgres and the system +> > then seems to come back. +> +> This sounds suspiciously like a question I asked a few weeks ago, on Apri= +l +> 4. I have a process that just gets stuck. After some questions from +> various of the experts in this forum, I used gdb(1) to attach to one of t= +he +> frozen Postgress backend processes, and here's what I found: +> +> On 5/12/2006, I wrote: +> > Thanks, good advice. You're absolutely right, it's stuck on a +> > mutex. After doing what you suggest, I discovered that the query +> > in progress is a user-written function (mine). When I log in as +> > root, and use "gdb -p " to attach to the process, here's +> > what I find. Notice the second function in the stack, a mutex +> > lock: +> > +> > (gdb) bt +> > #0 0x0087f7a2 in _dl_sysinfo_int80 () from /lib/ld- linux.so.2 +> > #1 0x0096cbfe in __lll_mutex_lock_wait () from /lib/tls/libc.so.6 +> > #2 0x008ff67b in _L_mutex_lock_3220 () from /lib/tls/libc.so.6 +> > #3 0x4f5fc1b4 in ?? () +> > #4 0x00dc5e64 in std::string::_Rep::_S_empty_rep_storage () from +> /usr/local/pgsql/lib/libchmoogle.so +> > #5 0x009ffcf0 in ?? () from /usr/lib/libz.so.1 +> > #6 0xbfe71c04 in ?? () +> > #7 0xbfe71e50 in ?? () +> > #8 0xbfe71b78 in ?? () +> > #9 0x009f7019 in zcfree () from /usr/lib/libz.so.1 +> > #10 0x009f7019 in zcfree () from /usr/lib/libz.so.1 +> > #11 0x009f8b7c in inflateEnd () from /usr/lib/libz.so.1 +> > #12 0x00c670a2 in ~basic_unzip_streambuf (this=3D0xbfe71be0) at +> zipstreamimpl.h:332 +> > #13 0x00c60b61 in OpenBabel::OBConversion::Read (this=3D0x1, +> pOb=3D0xbfd923b8, pin=3D0xffffffea) at istream:115 +> > #14 0x00c60fd8 in OpenBabel::OBConversion::ReadString (this=3D0x8672b50= +, +> pOb=3D0xbfd923b8) at obconversion.cpp:780 +> > #15 0x00c19d69 in chmoogle_ichem_mol_alloc () at stl_construct.h:120 +> > #16 0x00c1a203 in chmoogle_ichem_normalize_parent () at +> stl_construct.h:120 +> > #17 0x00c1b172 in chmoogle_normalize_parent_sdf () at vector.tcc:243 +> > #18 0x0810ae4d in ExecMakeFunctionResult () +> > #19 0x0810de2e in ExecProject () +> > #20 0x08115972 in ExecResult () +> > #21 0x08109e01 in ExecProcNode () +> > #22 0x00000020 in ?? () +> > #23 0xbed4b340 in ?? () +> > #24 0xbf92d9a0 in ?? () +> > #25 0xbed4b0c0 in ?? () +> > #26 0x00000000 in ?? () +> > +> > It looks to me like my code is trying to read the input parameter +> > (a fairly long string, maybe 2K) from a buffer that was gzip'ed +> > by Postgres for the trip between the client and server... somewhere +> > along the way, a mutex gets set, and then ... it's stuck forever. +> > +> > ps(1) shows that this thread had been running for about 7 hours, +> > and the job status showed that this function had been +> > successfully called about 1 million times, before this mutex lock +> > occurred. +> +> This is not an issue that's been resolved. Nobody had ever seen this +> before. Tom Lane suggested it might be a libc/c++ bug, but unfortunately= + in +> my case this lockup occurs so rarely (every few days) that it will be ver= +y +> difficult to know if we've fixed the problem. +> +> If gdb(1) reveals that your process is stuck in a mutex, then you might +> have a better chance testing this hypothesis, since your problem happens +> within 15 minutes or so. +> +> Did this start recently, perhaps right after a kernel update? +> +> Craig +> + +------=_Part_28113_30947148.1148330411700 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Hi Craig,

Thanks for your response.  This did start recently an= +d it wasn't after a kernel update, but it was after we moved the db from Ma= +chine B to Machine A (which have slightly different kernel versions). = + However, the problem took about a week to show up after we moved from one = +machine to the other.  Unfortunately, the problem only reappears after= + 15 mins once it occurs the first time.  If it occurs again today I'll= + attach gdb to it and see whether it's stuck on a mutex. +

Meetesh

On 5/22/06, Craig A. James + <cjames@modgraph-usa.com= +> wrote:
+ +Meetesh Karia wrote:
> Hi all,
>
> We've recently started= + having a problem where a query that normally
> executes in ~15ms sta= +rts to take upwards of 20s to complete.  When the
> connect= +ion that ran query is returned to the connection pool, it appears +
> as though a transaction is still in progress so the connection poo= +l
> tries to cancel the transaction and close the connection. &n= +bsp;This fails
> and the connection is removed from the connection po= +ol.  At this point, +
> the situation rapidly degrades and we run out of connections to th= +e
> postgres server.
>
> An inspection of the pg_stat_act= +ivity table shows that practically every
> connection is running the = +above-mentioned query and some of those +
> queries have been active for many minutes!  We've looked= + at the pg_locks
> table as well and the only exclusive locks are on = +transactions that are
> open.  All other locks are AccessSh= +areLocks.  Also, as far as we can +
> tell (from looking at the Hibernate stats), every db session that = +is
> opened is closed.
>
> When this happens, if I kill o= +ne of the running postgres processes (just
> by picking the last proc= +ess returned from "ps -ef | grep postgres"), the +
> other queries will immediately finish and the system will respond.= +
> However, within 15 minutes, we'll be back in the same state as bef= +ore.
> At that point, I've cycled Apache, Tomcat and Postgres and the= + system +
> then seems to come back.

This sounds suspiciously like a qu= +estion I asked a few weeks ago, on April 4.  I have a process tha= +t just gets stuck.  After some questions from various of the expe= +rts in this forum, I used gdb(1) to attach to one of the frozen Postgress b= +ackend processes, and here's what I found: +

On 5/12/2006, I wrote:
> Thanks, good advice.  You'= +re absolutely right, it's stuck on a
> mutex.  After doing = +what you suggest, I discovered that the query
> in progress is a user= +-written function (mine).  When I log in as +
> root, and use "gdb -p <pid>" to attach to the proc= +ess, here's
> what I find.  Notice the second function in t= +he stack, a mutex
> lock:
>
> (gdb) bt
> #0 &n= +bsp;0x0087f7a2 in _dl_sysinfo_int80 () from /lib/ld- +linux.so.2
> #1  0x0096cbfe in __lll_mutex_lock_wait () fro= +m /lib/tls/libc.so.6
> #2  0x008ff67b in _L_mutex_lock_3220= + () from /lib/tls/libc.so.6
> #3  0x4f5fc1b4 in ?? ()
&g= +t; #4  0x00dc5e64 in std::string::_Rep::_S_empty_rep_storage () f= +rom /usr/local/pgsql/lib/libchmoogle.so +
> #5  0x009ffcf0 in ?? () from /usr/lib/libz.so.1
> = +#6  0xbfe71c04 in ?? ()
> #7  0xbfe71e50 in ?? ()= +
> #8  0xbfe71b78 in ?? ()
> #9  0x009f7019= + in zcfree () from /usr/lib/libz.so.1
> #10 0x009f7019 in zcfree () f= +rom /usr/lib/libz.so.1 +
> #11 0x009f8b7c in inflateEnd () from /usr/lib/libz.so.1
> #1= +2 0x00c670a2 in ~basic_unzip_streambuf (this=3D0xbfe71be0) at zipstreamimpl= +.h:332
> #13 0x00c60b61 in OpenBabel::OBConversion::Read (this=3D0x1,= + pOb=3D0xbfd923b8, pin=3D0xffffffea) at istream:115 +
> #14 0x00c60fd8 in OpenBabel::OBConversion::ReadString (this=3D0x86= +72b50, pOb=3D0xbfd923b8) at obconversion.cpp:780
> #15 0x00c19d69 in = +chmoogle_ichem_mol_alloc () at stl_construct.h:120
> #16 0x00c1a203 i= +n chmoogle_ichem_normalize_parent () at stl_construct.h:120 +
> #17 0x00c1b172 in chmoogle_normalize_parent_sdf () at vector.tcc:2= +43
> #18 0x0810ae4d in ExecMakeFunctionResult ()
> #19 0x0810de= +2e in ExecProject ()
> #20 0x08115972 in ExecResult ()
> #21 0x= +08109e01 in ExecProcNode () +
> #22 0x00000020 in ?? ()
> #23 0xbed4b340 in ?? ()
> #2= +4 0xbf92d9a0 in ?? ()
> #25 0xbed4b0c0 in ?? ()
> #26 0x0000000= +0 in ?? ()
>
> It looks to me like my code is trying to read th= +e input parameter +
> (a fairly long string, maybe 2K) from a buffer that was gzip'ed> by Postgres for the trip between the client and server... somewhere> along the way, a mutex gets set, and then ... it's stuck forever. +
>
> ps(1) shows that this thread had been running for about 7 = +hours,
> and the job status showed that this function had been
>= +; successfully called about 1 million times, before this mutex lock
+ +> occurred.

This is not an issue that's been resolved.  = +;Nobody had ever seen this before.  Tom Lane suggested it might b= +e a libc/c++ bug, but unfortunately in my case this lockup occurs so rarely= + (every few days) that it will be very difficult to know if we've fixed the= + problem. +

If gdb(1) reveals that your process is stuck in a mutex, then you m= +ight have a better chance testing this hypothesis, since your problem happe= +ns within 15 minutes or so.

Did this start recently, perhaps right a= +fter a kernel update? +

Craig

+ + +------=_Part_28113_30947148.1148330411700-- + +From pgsql-performance-owner@postgresql.org Mon May 22 19:33:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id DC9E39F9B14 + for ; + Mon, 22 May 2006 19:33:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 45780-02 + for ; + Mon, 22 May 2006 19:33:40 -0300 (ADT) +X-Greylist: delayed 00:22:28.381832 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 098369FA2BC + for ; + Mon, 22 May 2006 19:33:41 -0300 (ADT) +Received: from mail.optiosoftware.com (mail.optio.com [192.216.93.10]) + by svr4.postgresql.org (Postfix) with ESMTP id 633665B58C4 + for ; + Mon, 22 May 2006 22:11:11 +0000 (GMT) +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: slow query using sub select +Date: Mon, 22 May 2006 18:11:07 -0400 +Message-ID: <47668A1334CDBF46927C1A0DFEB223D340EED2@mail.optiosoftware.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: slow query using sub select +thread-index: AcZ97KAanKWDbSdZSf+p4rSohMfwuA== +From: "Tim Jones" +To: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/424 +X-Sequence-Number: 19211 + +Hi, + I am having a problem with a sub select query being kinda slow. The +query is as follows: +=20 +select batterycode, batterydescription, observationdate from Battery t1 +where patientidentifier=3D611802158 and observationdate =3D (select +max(observationdate) from Battery t2 where = +t2.batterycode=3Dt1.batterycode +and patientidentifier=3D611802158) order by batterydescription. +=20 +explain analyze: + =20 + +'Sort (cost=3D1697.16..1697.16 rows=3D1 width=3D31) (actual +time=3D910.721..910.729 rows=3D22 loops=3D1)' +' Sort Key: batterydescription' +' -> Index Scan using ix_battery_patient on battery t1 +(cost=3D0.00..1697.15 rows=3D1 width=3D31) (actual = +time=3D241.836..910.580 +rows=3D22 loops=3D1)' +' Index Cond: (patientidentifier =3D 611802158)' +' Filter: (observationdate =3D (subplan))' +' SubPlan' +' -> Aggregate (cost=3D26.25..26.26 rows=3D1 width=3D8) (actual +time=3D9.666..9.667 rows=3D1 loops=3D94)' +' -> Bitmap Heap Scan on battery t2 (cost=3D22.23..26.25 rows=3D1 = +width=3D8) +(actual time=3D9.606..9.620 rows=3D7 loops=3D94)' +' Recheck Cond: ((patientidentifier =3D 611802158) AND +((batterycode)::text =3D ($0)::text))' +' -> BitmapAnd (cost=3D22.23..22.23 rows=3D1 width=3D0) (actual +time=3D9.596..9.596 rows=3D0 loops=3D94)' +' -> Bitmap Index Scan on ix_battery_patient (cost=3D0.00..2.20 = +rows=3D58 +width=3D0) (actual time=3D0.039..0.039 rows=3D94 loops=3D94)' +' Index Cond: (patientidentifier =3D 611802158)' +' -> Bitmap Index Scan on ix_battery_code (cost=3D0.00..19.78 = +rows=3D2794 +width=3D0) (actual time=3D9.514..9.514 rows=3D27323 loops=3D94)' +' Index Cond: ((batterycode)::text =3D ($0)::text)' +'Total runtime: 910.897 ms' + +Basically I am just trying to display the batterycode with its most +recent date. Is there a better way to do this query ? + +thanks +=20 +=20 +Tim Jones +Healthcare Project Manager +Optio Software, Inc. +(770) 576-3555 + +From pgsql-performance-owner@postgresql.org Mon May 22 20:07:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2CCB29F9CD8 + for ; + Mon, 22 May 2006 20:07:37 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 48681-07 + for ; + Mon, 22 May 2006 20:07:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 7AD379F9B14 + for ; + Mon, 22 May 2006 20:07:27 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4MN7O74015853; + Mon, 22 May 2006 19:07:24 -0400 (EDT) +To: "Tim Jones" +cc: pgsql-performance@postgresql.org +Subject: Re: slow query using sub select +In-reply-to: <47668A1334CDBF46927C1A0DFEB223D340EED2@mail.optiosoftware.com> +References: <47668A1334CDBF46927C1A0DFEB223D340EED2@mail.optiosoftware.com> +Comments: In-reply-to "Tim Jones" + message dated "Mon, 22 May 2006 18:11:07 -0400" +Date: Mon, 22 May 2006 19:07:24 -0400 +Message-ID: <15852.1148339244@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/425 +X-Sequence-Number: 19212 + +"Tim Jones" writes: +> I am having a problem with a sub select query being kinda slow. The +> query is as follows: + +> select batterycode, batterydescription, observationdate from Battery t1 +> where patientidentifier=611802158 and observationdate = (select +> max(observationdate) from Battery t2 where t2.batterycode=t1.batterycode +> and patientidentifier=611802158) order by batterydescription. + +Yeah, this is essentially impossible for the planner to optimize, +because it doesn't see any way to de-correlate the subselect, so it does +it over again for every row. You might find it works better if you cast +the thing as a SELECT DISTINCT ON problem (look at the "weather report" +example in the SELECT reference page). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Mon May 22 20:33:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5792D9FA2D8 + for ; + Mon, 22 May 2006 20:33:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 52623-08 + for ; + Mon, 22 May 2006 20:33:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 7AB139F9B14 + for ; + Mon, 22 May 2006 20:33:35 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 2453831932; Tue, 23 May 2006 01:33:34 +0200 (MET DST) +From: "Steinar H. Gunderson" +X-Newsgroups: comp.databases.postgresql,pgsql.performance +Subject: Re: Query performance +Date: Mon, 22 May 2006 23:33:33 +0000 (UTC) +Organization: /etc/news/organization +Lines: 20 +Message-ID: +References: +X-Complaints-To: usenet@itea.ntnu.no +User-Agent: slrn/0.9.8.1pl1 (Debian) +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/427 +X-Sequence-Number: 19214 + +antonio.batovanja@humanomed.co.at wrote: +> The above query takes 5 seconds to execute! +> +> [...] +> +> Total runtime: 96109.571 ms + +It sure doesn't look like it... + +> Total runtime: 461.907 ms +> +> [...] +> +> Suddenly the query takes only 0.29 seconds! + +How are you timing this, really? + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Mon May 22 20:32:21 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 70B789FA999 + for ; + Mon, 22 May 2006 20:32:21 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 50986-08 + for ; + Mon, 22 May 2006 20:32:16 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from server.nextgap2000.com (server.nextgap2000.com [66.98.160.7]) + by postgresql.org (Postfix) with ESMTP id 966469FA92E + for ; + Mon, 22 May 2006 20:32:16 -0300 (ADT) +Received: from 85.64.42.28.dynamic.barak-online.net ([85.64.42.28] + helo=jonathanlaptop) + by server.nextgap2000.com with esmtpa (Exim 4.52) + id 1FiJsi-0007yB-AF; Tue, 23 May 2006 02:32:12 +0300 +From: "Jonathan Blitz" +To: "'Tim Jones'" , + +Subject: Re: slow query using sub select +Date: Tue, 23 May 2006 02:33:09 +0200 +Message-ID: <04e401c67e00$79648b50$ddf71005@jonathanlaptop> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="windows-1250" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook 11 +In-Reply-To: <47668A1334CDBF46927C1A0DFEB223D340EED2@mail.optiosoftware.com> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 +Thread-Index: AcZ97KAanKWDbSdZSf+p4rSohMfwuAAExGbw +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - server.nextgap2000.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] +X-AntiAbuse: Sender Address Domain - anykey.co.il +X-Source: +X-Source-Args: +X-Source-Dir: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/426 +X-Sequence-Number: 19213 + + + +> -----Original Message----- +> From: Tim Jones [mailto:TJones@optio.com] +> Sent: Tuesday, May 23, 2006 12:11 AM +> To: pgsql-performance@postgresql.org +> Subject: [PERFORM] slow query using sub select +> +> Hi, +> I am having a problem with a sub select query being kinda slow. The +> query is as follows: +> +> select batterycode, batterydescription, observationdate from Battery t1 +> where patientidentifier=611802158 and observationdate = (select +> max(observationdate) from Battery t2 where t2.batterycode=t1.batterycode +> and patientidentifier=611802158) order by batterydescription. + + +How about changing it into a standard join: + + +select t1.batterycode, t1.batterydescription, t2.observationdate +from Battery t1, +(Select batterycode ,max(observationdate) from Battery t2 where +patientidentifier=611802158 group by batterycode) AS T2 +where t1. batterycode = t2. batterycode + +Jonathan Blitz +AnyKey Limited +Israel + +-- +No virus found in this outgoing message. +Checked by AVG Free Edition. +Version: 7.1.392 / Virus Database: 268.6.1/344 - Release Date: 05/19/2006 + + + +From pgsql-performance-owner@postgresql.org Tue May 30 17:56:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D84F89F9EEB + for ; + Tue, 23 May 2006 04:11:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 17638-02 + for ; + Tue, 23 May 2006 04:11:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id AB70D9F9CAA + for ; + Tue, 23 May 2006 04:11:05 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 1603731932; Tue, 23 May 2006 09:11:04 +0200 (MET DST) +From: Antonio Batovanja +X-Newsgroups: comp.databases.postgresql,pgsql.performance +Subject: Re: Query performance +Followup-To: comp.databases.postgresql +Date: Tue, 23 May 2006 09:10:29 +0200 +Organization: Humanomed +Lines: 29 +Message-ID: +References: + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Transfer-Encoding: 7Bit +X-Complaints-To: abuse@uta.at +User-Agent: KNode/0.9.2 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/538 +X-Sequence-Number: 19325 + +Steinar H. Gunderson wrote: + +> antonio.batovanja@humanomed.co.at wrote: +>> The above query takes 5 seconds to execute! +>> +>> [...] +>> +>> Total runtime: 96109.571 ms +> +> It sure doesn't look like it... +> +>> Total runtime: 461.907 ms +>> +>> [...] +>> +>> Suddenly the query takes only 0.29 seconds! +> +> How are you timing this, really? +> +> /* Steinar */ + +I'm executing the queries from phpPgAdmin. +The above are for explain analyse. I was referring to the pure query +execution time. +Does anyone have an idea why the OR-query takes so long? +Any server-side tuning possibilities? I wouldn't like to change the code of +ldap's back-sql... + +Toni + +From pgsql-performance-owner@postgresql.org Tue May 23 10:26:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3EB269F94EA + for ; + Tue, 23 May 2006 10:26:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 69663-04 + for ; + Tue, 23 May 2006 10:26:40 -0300 (ADT) +X-Greylist: delayed 15:15:26.696014 by SQLgrey- +Received: from mail.optiosoftware.com (mail.optio.com [192.216.93.10]) + by postgresql.org (Postfix) with ESMTP id 39EE69F946D + for ; + Tue, 23 May 2006 10:26:39 -0300 (ADT) +X-MimeOLE: Produced By Microsoft Exchange V6.5 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="us-ascii" +Content-Transfer-Encoding: quoted-printable +Subject: Re: slow query using sub select +Date: Tue, 23 May 2006 09:26:37 -0400 +Message-ID: <47668A1334CDBF46927C1A0DFEB223D340EF94@mail.optiosoftware.com> +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] slow query using sub select +thread-index: AcZ99H95e0LzlgA4T722/LypaaE1kwAd8SiQ +From: "Tim Jones" +To: "Tom Lane" +Cc: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/428 +X-Sequence-Number: 19215 + +that worked like a champ nice call as always!=20 + +thanks + +Tim Jones +Healthcare Project Manager +Optio Software, Inc. +(770) 576-3555 + +-----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 +Sent: Monday, May 22, 2006 7:07 PM +To: Tim Jones +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] slow query using sub select=20 + +"Tim Jones" writes: +> I am having a problem with a sub select query being kinda slow. The + +> query is as follows: +=20 +> select batterycode, batterydescription, observationdate from Battery=20 +> t1 where patientidentifier=3D611802158 and observationdate =3D (select +> max(observationdate) from Battery t2 where=20 +> t2.batterycode=3Dt1.batterycode and patientidentifier=3D611802158) = +order +by batterydescription. + +Yeah, this is essentially impossible for the planner to optimize, +because it doesn't see any way to de-correlate the subselect, so it does +it over again for every row. You might find it works better if you cast +the thing as a SELECT DISTINCT ON problem (look at the "weather report" +example in the SELECT reference page). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 23 14:40:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7B24E9FA380 + for ; + Tue, 23 May 2006 14:40:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 06079-06 + for ; + Tue, 23 May 2006 14:40:47 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from corpmail.hi5.com (corpmail.hi5.com [204.13.49.5]) + by postgresql.org (Postfix) with ESMTP id 7ED249FA169 + for ; + Tue, 23 May 2006 14:40:47 -0300 (ADT) +Received: from [192.168.1.133] by hi5.com (MDaemon PRO v9.0.1) + with ESMTP id md50007242405.msg + for ; Tue, 23 May 2006 10:40:15 -0700 +Mime-Version: 1.0 (Apple Message framework v750) +Content-Transfer-Encoding: 7bit +Message-Id: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +To: pgsql-performance@postgresql.org +From: Dan Gorman +Subject: Selects query stats? +Date: Tue, 23 May 2006 10:40:01 -0700 +X-Mailer: Apple Mail (2.750) +X-Authenticated-Sender: dgorman@hi5.com +X-Spam-Processed: corpmail, Tue, 23 May 2006 10:40:15 -0700 + (not processed: message from valid local sender) +X-MDRemoteIP: 66.237.43.131 +X-Return-Path: dgorman@hi5.com +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +X-MDAV-Processed: corpmail, Tue, 23 May 2006 10:40:16 -0700 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/429 +X-Sequence-Number: 19216 + +All, + +I might be completely crazy here, but it seems every other database +exposes select query stats. Postgres only exposes updates/deletes/ +inserts. Is there something I am missing here? + +Best Regards, +Dan Gorman + + +From pgsql-performance-owner@postgresql.org Tue May 23 15:08:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0DBE09FA7BA + for ; + Tue, 23 May 2006 15:08:05 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 18380-04 + for ; + Tue, 23 May 2006 15:07:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp1.ActiveState.com (gw.activestate.com [209.17.183.249]) + by postgresql.org (Postfix) with ESMTP id B2E4C9FA380 + for ; + Tue, 23 May 2006 15:07:49 -0300 (ADT) +Received: from smtp3.activestate.com (smtp3.activestate.com [192.168.3.19]) + by smtp1.ActiveState.com (8.12.10/8.12.10) with ESMTP id k4NI7mhI001443 + for ; Tue, 23 May 2006 11:07:48 -0700 + (envelope-from mischa@ca.sophos.com) +Received: from [192.168.99.210] (mallet.activestate.com [192.168.99.210]) + by smtp3.ActiveState.com (8.13.4/8.13.4) with ESMTP id k4NI7lXa002752 + for ; Tue, 23 May 2006 11:07:47 -0700 + (envelope-from mischa@ca.sophos.com) +Message-ID: <4473512E.7020805@ca.sophos.com> +Date: Tue, 23 May 2006 11:15:10 -0700 +From: Mischa Sandberg +Reply-To: mischa@ca.sophos.com +User-Agent: Thunderbird 1.5.0.2 (X11/20060420) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Selects query stats? +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> +In-Reply-To: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/430 +X-Sequence-Number: 19217 + +Dan Gorman wrote: +> All, +> +> I might be completely crazy here, but it seems every other database +> exposes select query stats. Postgres only exposes +> updates/deletes/inserts. Is there something I am missing here? + +Perhaps. + +You can EXPLAIN ANALYZE a SELECT, just like i/u/d -- but then you +don't get the normal result set back. Is that what you mean? + +You can turn on log_min_duration_statement and get total SELECT duration +logged. + +There's a thread in pgsql-hackers ("Re: Porting MSSQL to PGSQL: trace and +profile") about server-side logging of query plans and stats (for all four of +s/i/u/d), which is indeed not there in PG. + +-- +Engineers think that equations approximate reality. +Physicists think that reality approximates the equations. +Mathematicians never make the connection. + +From pgsql-performance-owner@postgresql.org Tue May 23 15:15:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0F9D69FA279 + for ; + Tue, 23 May 2006 15:15:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 23031-03 + for ; + Tue, 23 May 2006 15:15:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from corpmail.hi5.com (corpmail.hi5.com [204.13.49.5]) + by postgresql.org (Postfix) with ESMTP id ED2DB9FA169 + for ; + Tue, 23 May 2006 15:15:27 -0300 (ADT) +Received: from [192.168.1.133] by hi5.com (MDaemon PRO v9.0.1) + with ESMTP id md50007244939.msg + for ; Tue, 23 May 2006 11:15:16 -0700 +In-Reply-To: <4473512E.7020805@ca.sophos.com> +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Dan Gorman +Subject: Re: Selects query stats? +Date: Tue, 23 May 2006 11:15:10 -0700 +To: mischa@ca.sophos.com +X-Mailer: Apple Mail (2.750) +X-Authenticated-Sender: dgorman@hi5.com +X-Spam-Processed: corpmail, Tue, 23 May 2006 11:15:16 -0700 + (not processed: message from valid local sender) +X-MDRemoteIP: 66.237.43.131 +X-Return-Path: dgorman@hi5.com +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +X-MDAV-Processed: corpmail, Tue, 23 May 2006 11:15:18 -0700 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/431 +X-Sequence-Number: 19218 + +What I am looking for is that our DB is doing X selects a min. + +Turning on logging isn't an option as it will create too much IO in +our enviornment. + +Regards, +Dan Gorman + +On May 23, 2006, at 11:15 AM, Mischa Sandberg wrote: + +> Dan Gorman wrote: +>> All, +>> I might be completely crazy here, but it seems every other +>> database exposes select query stats. Postgres only exposes updates/ +>> deletes/inserts. Is there something I am missing here? +> +> Perhaps. +> +> You can EXPLAIN ANALYZE a SELECT, just like i/u/d -- but then you +> don't get the normal result set back. Is that what you mean? +> +> You can turn on log_min_duration_statement and get total SELECT +> duration +> logged. +> +> There's a thread in pgsql-hackers ("Re: Porting MSSQL to PGSQL: +> trace and profile") about server-side logging of query plans and +> stats (for all four of s/i/u/d), which is indeed not there in PG. +> +> -- +> Engineers think that equations approximate reality. +> Physicists think that reality approximates the equations. +> Mathematicians never make the connection. +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq + + + +From pgsql-performance-owner@postgresql.org Tue May 23 15:25:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 89FDE9FA279 + for ; + Tue, 23 May 2006 15:25:18 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 23031-07 + for ; + Tue, 23 May 2006 15:25:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp1.ActiveState.com (gw.activestate.com [209.17.183.249]) + by postgresql.org (Postfix) with ESMTP id 0BBEB9FA169 + for ; + Tue, 23 May 2006 15:25:07 -0300 (ADT) +Received: from smtp3.activestate.com (smtp3.activestate.com [192.168.3.19]) + by smtp1.ActiveState.com (8.12.10/8.12.10) with ESMTP id k4NIP5hI002740 + for ; Tue, 23 May 2006 11:25:05 -0700 + (envelope-from mischa@ca.sophos.com) +Received: from [192.168.99.210] (mallet.activestate.com [192.168.99.210]) + by smtp3.ActiveState.com (8.13.4/8.13.4) with ESMTP id k4NIP5Qb006038 + for ; Tue, 23 May 2006 11:25:05 -0700 + (envelope-from mischa@ca.sophos.com) +Message-ID: <4473553C.1010804@ca.sophos.com> +Date: Tue, 23 May 2006 11:32:28 -0700 +From: Mischa Sandberg +Reply-To: mischa@ca.sophos.com +User-Agent: Thunderbird 1.5.0.2 (X11/20060420) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: Selects query stats? +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> +In-Reply-To: <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/432 +X-Sequence-Number: 19219 + +Dan Gorman wrote: +> What I am looking for is that our DB is doing X selects a min. + +What specifically would you like to measure? +Duration for specific queries? +Queries in an app for which you have no source? +There may be a way to get what you want by other means ... +Details? + +I gather you cannot just time the app that's doing the selects, +nor extract those selects and run them via psql and time them +on their own? + +>> Dan Gorman wrote: +>>> All, +>>> I might be completely crazy here, but it seems every other database +>>> exposes select query stats. Postgres only exposes +>>> updates/deletes/inserts. Is there something I am missing here? + + +From pgsql-performance-owner@postgresql.org Tue May 23 15:34:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 41FF29FA169 + for ; + Tue, 23 May 2006 15:34:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 24923-05 + for ; + Tue, 23 May 2006 15:33:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from corpmail.hi5.com (corpmail.hi5.com [204.13.49.5]) + by postgresql.org (Postfix) with ESMTP id 67A579FA279 + for ; + Tue, 23 May 2006 15:33:52 -0300 (ADT) +Received: from [192.168.1.133] by hi5.com (MDaemon PRO v9.0.1) + with ESMTP id md50007246564.msg + for ; Tue, 23 May 2006 11:33:17 -0700 +In-Reply-To: <4473553C.1010804@ca.sophos.com> +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> + <4473553C.1010804@ca.sophos.com> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: multipart/alternative; boundary=Apple-Mail-8-450784764 +Message-Id: <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> +Cc: pgsql-performance@postgresql.org +From: Dan Gorman +Subject: Re: Selects query stats? +Date: Tue, 23 May 2006 11:33:12 -0700 +To: mischa@ca.sophos.com +X-Mailer: Apple Mail (2.750) +X-Authenticated-Sender: dgorman@hi5.com +X-Spam-Processed: corpmail, Tue, 23 May 2006 11:33:17 -0700 + (not processed: message from valid local sender) +X-MDRemoteIP: 66.237.43.131 +X-Return-Path: dgorman@hi5.com +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +X-MDAV-Processed: corpmail, Tue, 23 May 2006 11:33:17 -0700 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/433 +X-Sequence-Number: 19220 + + +--Apple-Mail-8-450784764 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +In any other DB (oracle, mysql) I know how many queries (selects) per +second the database is executing. How do I get this +number out of postgres? + +I have a perl script that can test this, but no way the db tells me +how fast it's going. + +(e.g. in oracle: select sum(executions) from v$sqlarea;) + +Regards, +Dan Gorman + + + + +On May 23, 2006, at 11:32 AM, Mischa Sandberg wrote: + +> Dan Gorman wrote: +>> What I am looking for is that our DB is doing X selects a min. +> +> What specifically would you like to measure? +> Duration for specific queries? +> Queries in an app for which you have no source? +> There may be a way to get what you want by other means ... +> Details? +> +> I gather you cannot just time the app that's doing the selects, +> nor extract those selects and run them via psql and time them +> on their own? +> +>>> Dan Gorman wrote: +>>>> All, +>>>> I might be completely crazy here, but it seems every other +>>>> database exposes select query stats. Postgres only exposes +>>>> updates/deletes/inserts. Is there something I am missing here? +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 9: In versions below 8.0, the planner will ignore your desire to +> choose an index scan if your joining column's datatypes do not +> match + + +--Apple-Mail-8-450784764 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=ISO-8859-1 + +In any other DB (oracle, mysql) = +I know how many queries (selects) per second the database is executing. = +How do I get this=A0
number out of postgres?

I have a perl script that = +can test this, but no way the db tells me how fast it's = +going.

(e.g. = +in oracle:=A0select sum(executions) from = +v$sqlarea;)

Regards,
Dan Gorman




On May 23, 2006, at = +11:32 AM, Mischa Sandberg wrote:

Dan Gorman wrote:
What I am looking for is that our DB is doing X = +selects a min.

What specifically would you like = +to measure?
Duration for specific = +queries?
Queries in an app for which you = +have no source?
There may be a way to get what = +you want by other means ...
Details?

I gather you cannot just time the app that's doing = +the selects,
nor extract those selects and = +run them via psql and time them
on their = +own?

= +
Dan Gorman wrote:
All,
I might be = +completely crazy here, but it seems every other database exposes select = +query stats. Postgres only exposes updates/deletes/inserts. Is there = +something I am missing here?
= +


---------------------------(end of = +broadcast)---------------------------
TIP 9: = +In versions below 8.0, the planner will ignore your desire to
=A0 =A0 =A0 = +choose an index scan if your joining column's datatypes do = +not
=A0 =A0 =A0 match
= +

= + +--Apple-Mail-8-450784764-- + + +From pgsql-performance-owner@postgresql.org Tue May 23 15:41:13 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2979C9FA169 + for ; + Tue, 23 May 2006 15:41:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 20921-06 + for ; + Tue, 23 May 2006 15:41:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 248F49FA372 + for ; + Tue, 23 May 2006 15:41:02 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 69CC456437; Tue, 23 May 2006 13:41:01 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 23 May 2006 13:41:00 -0500 +Date: Tue, 23 May 2006 13:41:00 -0500 +From: "Jim C. Nasby" +To: Dan Gorman +Cc: mischa@ca.sophos.com, pgsql-performance@postgresql.org +Subject: Re: Selects query stats? +Message-ID: <20060523184100.GW64371@pervasive.com> +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> + <4473553C.1010804@ca.sophos.com> + <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060523:dgorman@hi5.com::z+IpjDrk05SZv2jp:005QwE +X-Hashcash: + 1:20:060523:mischa@ca.sophos.com::E8ET9L4x+y4x1PZH:00000000000000000 + 0000000000000000000000000Otp +X-Hashcash: + 1:20:060523:pgsql-performance@postgresql.org::b7ysQk6STEM7cKNb:00000 + 0000000000000000000000000Gqe +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/434 +X-Sequence-Number: 19221 + +On Tue, May 23, 2006 at 11:33:12AM -0700, Dan Gorman wrote: +> In any other DB (oracle, mysql) I know how many queries (selects) per +> second the database is executing. How do I get this +> number out of postgres? + +You can't. You also can't know how many DML statements were executed +(though you can see how many tuples were inserted/updated/deleted), or +how many transactions have occured (well, you can hack the last one, but +it's a bit of a mess). + +It would be nice if all of this was available. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 23 15:52:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BFF5E9FA169 + for ; + Tue, 23 May 2006 15:52:13 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29146-03-3 + for ; + Tue, 23 May 2006 15:52:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.187]) + by postgresql.org (Postfix) with ESMTP id 8137E9FA92E + for ; + Tue, 23 May 2006 15:51:28 -0300 (ADT) +Received: from [195.112.19.37] (helo=[192.168.0.7]) + by mrelayeu.kundenserver.de (node=mrelayeu2) with ESMTP (Nemesis), + id 0MKwtQ-1FibyU2HO7-0001pA; Tue, 23 May 2006 20:51:23 +0200 +Subject: Re: Selects query stats? +From: Simon Riggs +To: Dan Gorman +Cc: mischa@ca.sophos.com, pgsql-performance@postgresql.org +In-Reply-To: <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> + <4473553C.1010804@ca.sophos.com> + <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> +Content-Type: text/plain +Date: Tue, 23 May 2006 19:51:12 +0100 +Message-Id: <1148410273.2755.179.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.6.1 (2.6.1-1.fc5.2) +Content-Transfer-Encoding: 7bit +X-Provags-ID: kundenserver.de abuse@kundenserver.de + login:726643fe08f41a451f0fe7fa43bce239 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/435 +X-Sequence-Number: 19222 + +On Tue, 2006-05-23 at 11:33 -0700, Dan Gorman wrote: +> In any other DB (oracle, mysql) I know how many queries (selects) per +> second the database is executing. How do I get this +> number out of postgres? +> +> +> I have a perl script that can test this, but no way the db tells me +> how fast it's going. +> +> +> (e.g. in oracle: select sum(executions) from v$sqlarea;) + +The Oracle query you show doesn't do that either. It tells you how many +statements have been executed since startup, not per second. + +The main problem with what you ask is it only seems to have value. If +the value dips for some reason, you have no way of knowing whether that +occurred because the arrival rate dropped off, there is a system problem +or whether statements just happened to access more data over that time +period. You can collect information that would allow you to understand +what is happening on your system and summarise that as you choose. + +-- + Simon Riggs + EnterpriseDB http://www.enterprisedb.com + + +From pgsql-performance-owner@postgresql.org Tue May 23 16:08:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A2DBD9FA279 + for ; + Tue, 23 May 2006 16:08:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 30678-06 + for ; + Tue, 23 May 2006 16:08:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from corpmail.hi5.com (corpmail.hi5.com [204.13.49.5]) + by postgresql.org (Postfix) with ESMTP id D7FCB9FA169 + for ; + Tue, 23 May 2006 16:08:34 -0300 (ADT) +Received: from [192.168.1.133] by hi5.com (MDaemon PRO v9.0.1) + with ESMTP id md50007250344.msg + for ; Tue, 23 May 2006 12:08:15 -0700 +Mime-Version: 1.0 (Apple Message framework v750) +In-Reply-To: <1148410273.2755.179.camel@localhost.localdomain> +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> + <4473553C.1010804@ca.sophos.com> + <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> + <1148410273.2755.179.camel@localhost.localdomain> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <7FEA9FB3-7A9C-421F-BFE5-78FF1EF25034@hi5.com> +Content-Transfer-Encoding: 7bit +From: Dan Gorman +Subject: Re: Selects query stats? +Date: Tue, 23 May 2006 12:08:05 -0700 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.750) +X-Authenticated-Sender: dgorman@hi5.com +X-Spam-Processed: corpmail, Tue, 23 May 2006 12:08:15 -0700 + (not processed: message from valid local sender) +X-MDRemoteIP: 66.237.43.131 +X-Return-Path: dgorman@hi5.com +X-MDaemon-Deliver-To: pgsql-performance@postgresql.org +X-MDAV-Processed: corpmail, Tue, 23 May 2006 12:08:15 -0700 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/436 +X-Sequence-Number: 19223 + +Yeah, I'm not really concerned about the app or sys performance, just +a basic question of how do I get the rate of selects that are being +executed. + +In a previous post from Jim, he noted it cannot be done. I am very +surprised postgres can't do this basic functionality. Does anyone +know if the postgres team is working on this? + +(btw, I pasted in the wrong oracle query lol - but it can be done in +mysql and oracle) + +Best Regards, +Dan Gorman + +On May 23, 2006, at 11:51 AM, Simon Riggs wrote: + +> On Tue, 2006-05-23 at 11:33 -0700, Dan Gorman wrote: +>> In any other DB (oracle, mysql) I know how many queries (selects) per +>> second the database is executing. How do I get this +>> number out of postgres? +>> +>> +>> I have a perl script that can test this, but no way the db tells me +>> how fast it's going. +>> +>> +>> (e.g. in oracle: select sum(executions) from v$sqlarea;) +> +> The Oracle query you show doesn't do that either. It tells you how +> many +> statements have been executed since startup, not per second. +> +> The main problem with what you ask is it only seems to have value. If +> the value dips for some reason, you have no way of knowing whether +> that +> occurred because the arrival rate dropped off, there is a system +> problem +> or whether statements just happened to access more data over that time +> period. You can collect information that would allow you to understand +> what is happening on your system and summarise that as you choose. +> +> -- +> Simon Riggs +> EnterpriseDB http://www.enterprisedb.com +> + + + +From pgsql-performance-owner@postgresql.org Tue May 23 16:13:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7F4159FA279 + for ; + Tue, 23 May 2006 16:13:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29453-10 + for ; + Tue, 23 May 2006 16:13:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 092F99FA169 + for ; + Tue, 23 May 2006 16:13:21 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4NJDDUf017714; + Tue, 23 May 2006 15:13:13 -0400 (EDT) +To: "Jim C. Nasby" +cc: Dan Gorman , mischa@ca.sophos.com, + pgsql-performance@postgresql.org +Subject: Re: Selects query stats? +In-reply-to: <20060523184100.GW64371@pervasive.com> +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> + <4473553C.1010804@ca.sophos.com> + <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> + <20060523184100.GW64371@pervasive.com> +Comments: In-reply-to "Jim C. Nasby" + message dated "Tue, 23 May 2006 13:41:00 -0500" +Date: Tue, 23 May 2006 15:13:13 -0400 +Message-ID: <17713.1148411593@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/437 +X-Sequence-Number: 19224 + +"Jim C. Nasby" writes: +> On Tue, May 23, 2006 at 11:33:12AM -0700, Dan Gorman wrote: +>> In any other DB (oracle, mysql) I know how many queries (selects) per +>> second the database is executing. How do I get this +>> number out of postgres? + +> You can't. You also can't know how many DML statements were executed +> (though you can see how many tuples were inserted/updated/deleted), or +> how many transactions have occured (well, you can hack the last one, but +> it's a bit of a mess). + +Hack? We do count commits and rollbacks (see pg_stat_database); doesn't +seem that hacky to me. + +Counting individual statements would add overhead (which the OP already +declared unacceptable) and there are some definitional issues too, like +whether to count statements executed within functions. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 23 16:50:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D99F99FA372 + for ; + Tue, 23 May 2006 16:50:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 36392-02 + for ; + Tue, 23 May 2006 16:50:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from alvh.no-ip.org (201-221-200-231.bk11-dsl.surnet.cl + [201.221.200.231]) + by postgresql.org (Postfix) with ESMTP id 8E2DF9FA169 + for ; + Tue, 23 May 2006 16:50:15 -0300 (ADT) +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id CE24FC3737F; Tue, 23 May 2006 15:50:01 -0400 (CLT) +Date: Tue, 23 May 2006 15:50:01 -0400 +From: Alvaro Herrera +To: Tom Lane +Cc: "Jim C. Nasby" , Dan Gorman , + mischa@ca.sophos.com, pgsql-performance@postgresql.org +Subject: Re: Selects query stats? +Message-ID: <20060523195001.GH28863@surnet.cl> +Mail-Followup-To: Tom Lane , + "Jim C. Nasby" , Dan Gorman , + mischa@ca.sophos.com, pgsql-performance@postgresql.org +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> + <4473553C.1010804@ca.sophos.com> + <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> + <20060523184100.GW64371@pervasive.com> + <17713.1148411593@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <17713.1148411593@sss.pgh.pa.us> +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/438 +X-Sequence-Number: 19225 + +Tom Lane wrote: + +> Counting individual statements would add overhead (which the OP already +> declared unacceptable) and there are some definitional issues too, like +> whether to count statements executed within functions. + +Yeah, the problem seems underspecified. How do you count statements +added or removed by rewrite rules? Statements executed to answer RI +queries? Do you count the statements issued by clients as part of the +startup sequence? The hypothetical "reset session" of a connection pool +handler? How do you count 2PC -- when they are executed, or when they +are committed? What happens to statements in transactions that are +rolled back? What happens to a statement that is executed partially +because it failed partway (e.g. because of division by zero)? + + +OTOH ISTM it would be easy to modify Postgres so as to count statements +in the stat collector, by turning pgstat_report_activity into a routine +that sent a count (presumably always 1) instead of the query string, and +then just add the count to a counter on receiving. + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +The PostgreSQL Company - Command Prompt, Inc. + +From pgsql-performance-owner@postgresql.org Tue May 23 16:56:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1C2999FA279 + for ; + Tue, 23 May 2006 16:56:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 38052-06 + for ; + Tue, 23 May 2006 16:56:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 0D8CA9FA169 + for ; + Tue, 23 May 2006 16:55:57 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4NJtpVl019284; + Tue, 23 May 2006 15:55:51 -0400 (EDT) +To: Alvaro Herrera +cc: "Jim C. Nasby" , Dan Gorman , + mischa@ca.sophos.com, pgsql-performance@postgresql.org +Subject: Re: Selects query stats? +In-reply-to: <20060523195001.GH28863@surnet.cl> +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> + <4473553C.1010804@ca.sophos.com> + <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> + <20060523184100.GW64371@pervasive.com> + <17713.1148411593@sss.pgh.pa.us> <20060523195001.GH28863@surnet.cl> +Comments: In-reply-to Alvaro Herrera + message dated "Tue, 23 May 2006 15:50:01 -0400" +Date: Tue, 23 May 2006 15:55:50 -0400 +Message-ID: <19283.1148414150@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/439 +X-Sequence-Number: 19226 + +Alvaro Herrera writes: +> OTOH ISTM it would be easy to modify Postgres so as to count statements +> in the stat collector, by turning pgstat_report_activity into a routine +> that sent a count (presumably always 1) instead of the query string, and +> then just add the count to a counter on receiving. + +You wouldn't have to change the backends at all, just modify the +collector to count the number of report_activity messages received. +Might have to play some games with ignoring "" messages, but +otherwise simple (and simplistic...) + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 23 17:03:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C348B9FA380 + for ; + Tue, 23 May 2006 17:03:04 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 38639-01 + for ; + Tue, 23 May 2006 17:02:52 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 953029FA279 + for ; + Tue, 23 May 2006 17:02:51 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id A6A8D5643D; Tue, 23 May 2006 15:02:49 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 23 May 2006 15:02:48 -0500 +Date: Tue, 23 May 2006 15:02:48 -0500 +From: "Jim C. Nasby" +To: Tom Lane , Dan Gorman , + mischa@ca.sophos.com, pgsql-performance@postgresql.org +Subject: Re: Selects query stats? +Message-ID: <20060523200248.GY64371@pervasive.com> +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> + <4473553C.1010804@ca.sophos.com> + <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> + <20060523184100.GW64371@pervasive.com> + <17713.1148411593@sss.pgh.pa.us> <20060523195001.GH28863@surnet.cl> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060523195001.GH28863@surnet.cl> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060523:tgl@sss.pgh.pa.us::GWBwX+rALPhgo/M+:00000000000000000000 + 0000000000000000000000003QLe +X-Hashcash: 1:20:060523:dgorman@hi5.com::SyLhhhs9zBLUCbjp:003+yK +X-Hashcash: + 1:20:060523:mischa@ca.sophos.com::+fjiVxaT+vf3bcTH:00000000000000000 + 00000000000000000000000011g4 +X-Hashcash: + 1:20:060523:pgsql-performance@postgresql.org::pS5kLUj449itA25f:00000 + 0000000000000000000000004EoU +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/440 +X-Sequence-Number: 19227 + +On Tue, May 23, 2006 at 03:50:01PM -0400, Alvaro Herrera wrote: +> Tom Lane wrote: +> +> > Counting individual statements would add overhead (which the OP already +> > declared unacceptable) and there are some definitional issues too, like +> > whether to count statements executed within functions. +> +> Yeah, the problem seems underspecified. How do you count statements +> added or removed by rewrite rules? Statements executed to answer RI +> queries? Do you count the statements issued by clients as part of the +> startup sequence? The hypothetical "reset session" of a connection pool +> handler? How do you count 2PC -- when they are executed, or when they +> are committed? What happens to statements in transactions that are +> rolled back? What happens to a statement that is executed partially +> because it failed partway (e.g. because of division by zero)? +> +> +> OTOH ISTM it would be easy to modify Postgres so as to count statements +> in the stat collector, by turning pgstat_report_activity into a routine +> that sent a count (presumably always 1) instead of the query string, and +> then just add the count to a counter on receiving. + +Yeah, I doubt any other database gets mired neck-deep in exact details +of statment execution counts; a simple count of queries executed via a +client connection would be a great start. + +I often run into situations where people are having a performance issue +because they're building web pages that make 50 queries to the database. +Being able to identify that and determine how many were selects vs. DML +would be useful. + +Bonus points if there are seperate counters for statements from +functions. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 23 17:04:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2C0589FA279 + for ; + Tue, 23 May 2006 17:04:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 38028-10 + for ; + Tue, 23 May 2006 17:04:39 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.207]) + by postgresql.org (Postfix) with ESMTP id 1067C9FA169 + for ; + Tue, 23 May 2006 17:04:38 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id 18so1398002nzp + for ; + Tue, 23 May 2006 13:04:38 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=KmymR25dAROY1Puf1xuHziyP67plh67aYRdyZnLIxsn2Zvk74N432t7dL4Vv+GSODpqGKLJrbwTHhgXH5ubaLoOOJ48+mxXlR2Pat0snIMQcX5rTFfa8t+Kd1zjLwjRsdqwqXK1bMZoTct0QLTSb938R2Eo6jI2vKW+5Q03TeCI= +Received: by 10.64.152.2 with SMTP id z2mr2365360qbd; + Tue, 23 May 2006 13:04:36 -0700 (PDT) +Received: by 10.65.121.19 with HTTP; Tue, 23 May 2006 13:04:36 -0700 (PDT) +Message-ID: <1d4e0c10605231304k5d3005fdla5f596e5194578e3@mail.gmail.com> +Date: Tue, 23 May 2006 22:04:36 +0200 +From: "Guillaume Smet" +To: "Dan Gorman" +Subject: Re: Selects query stats? +Cc: mischa@ca.sophos.com, pgsql-performance@postgresql.org +In-Reply-To: <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/441 +X-Sequence-Number: 19228 + +On 5/23/06, Dan Gorman wrote: +> What I am looking for is that our DB is doing X selects a min. + +If you're using 7.4, you can use log_duration to only log duration. It +won't log all the query text, only one short line per query. Then you +can use pgFouine to analyze this and having a graph such like that +http://pgfouine.projects.postgresql.org/reports/sample_hourly.html . +If you only log duration, you won't be able to separate +insert/delete/update from select though. So it can be interesting only +if they negligible. + +Note that this is not possible in 8.x. You'll have to log the +statement to log the duration. I proposed a patch but it was refused +as it complexified the log configuration. + +> Turning on logging isn't an option as it will create too much IO in +> our enviornment. + +What we do here is logging on another machine via the network using +syslog. From our experience, it's not the fact to log that really +slows down the db but the generated I/O load. So if you do that, you +should be able to log the statements without slowing down your +database too much. + +On our production databases, we keep the log running all the time and +we generate reports daily. + +Regards, + +-- +Guillaume + +From pgsql-performance-owner@postgresql.org Tue May 23 18:47:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 71C969FA372 + for ; + Tue, 23 May 2006 18:47:45 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 50291-03 + for ; + Tue, 23 May 2006 18:47:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from moutng.kundenserver.de (moutng.kundenserver.de + [212.227.126.188]) + by postgresql.org (Postfix) with ESMTP id 09C879FA169 + for ; + Tue, 23 May 2006 18:47:34 -0300 (ADT) +Received: from [195.112.19.37] (helo=[192.168.0.7]) + by mrelayeu.kundenserver.de (node=mrelayeu4) with ESMTP (Nemesis), + id 0ML21M-1Fieir3Oun-0003gc; Tue, 23 May 2006 23:47:27 +0200 +Subject: Re: Selects query stats? +From: Simon Riggs +To: Tom Lane +Cc: Alvaro Herrera , + "Jim C. Nasby" , + Dan Gorman , mischa@ca.sophos.com, + pgsql-performance@postgresql.org +In-Reply-To: <19283.1148414150@sss.pgh.pa.us> +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> + <4473553C.1010804@ca.sophos.com> + <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> + <20060523184100.GW64371@pervasive.com> <17713.1148411593@sss.pgh.pa.us> + <20060523195001.GH28863@surnet.cl> <19283.1148414150@sss.pgh.pa.us> +Content-Type: text/plain +Date: Tue, 23 May 2006 22:47:16 +0100 +Message-Id: <1148420837.2755.196.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.6.1 (2.6.1-1.fc5.2) +Content-Transfer-Encoding: 7bit +X-Provags-ID: kundenserver.de abuse@kundenserver.de + login:726643fe08f41a451f0fe7fa43bce239 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/442 +X-Sequence-Number: 19229 + +On Tue, 2006-05-23 at 15:55 -0400, Tom Lane wrote: +> Alvaro Herrera writes: +> > OTOH ISTM it would be easy to modify Postgres so as to count statements +> > in the stat collector, by turning pgstat_report_activity into a routine +> > that sent a count (presumably always 1) instead of the query string, and +> > then just add the count to a counter on receiving. +> +> You wouldn't have to change the backends at all, just modify the +> collector to count the number of report_activity messages received. +> Might have to play some games with ignoring "" messages, but +> otherwise simple (and simplistic...) + +The OP wanted statements/sec rather than just a total. + +Having stats logged by time would be very useful, but I wouldn't limit +that just to numbers of statements in each time period. + +stats_logging_interval = 60 by default, 0 to disable, range 5-3600 + +-- + Simon Riggs + EnterpriseDB http://www.enterprisedb.com + + +From pgsql-performance-owner@postgresql.org Tue May 23 19:11:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A89229FA8EF + for ; + Tue, 23 May 2006 19:11:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 53632-06 + for ; + Tue, 23 May 2006 19:11:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp1.ActiveState.com (gw.activestate.com [209.17.183.249]) + by postgresql.org (Postfix) with ESMTP id 312569FA611 + for ; + Tue, 23 May 2006 19:11:32 -0300 (ADT) +Received: from smtp3.activestate.com (smtp3.activestate.com [192.168.3.19]) + by smtp1.ActiveState.com (8.12.10/8.12.10) with ESMTP id k4NMBTU9020999; + Tue, 23 May 2006 15:11:29 -0700 (envelope-from mischa@ca.sophos.com) +Received: from [192.168.99.210] (mallet.activestate.com [192.168.99.210]) + by smtp3.ActiveState.com (8.13.4/8.13.4) with ESMTP id k4NMBPsw011616; + Tue, 23 May 2006 15:11:29 -0700 (envelope-from mischa@ca.sophos.com) +Message-ID: <44738A49.2010504@ca.sophos.com> +Date: Tue, 23 May 2006 15:18:49 -0700 +From: Mischa Sandberg +Reply-To: mischa@ca.sophos.com +User-Agent: Thunderbird 1.5.0.2 (X11/20060420) +MIME-Version: 1.0 +To: Dan Gorman +CC: pgsql-performance@postgresql.org +Subject: Re: Selects query stats? +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> + <4473553C.1010804@ca.sophos.com> + <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> + <20060523184100.GW64371@pervasive.com> + <17713.1148411593@sss.pgh.pa.us> <20060523195001.GH28863@surnet.cl> +In-Reply-To: <20060523195001.GH28863@surnet.cl> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/443 +X-Sequence-Number: 19230 + +Alvaro Herrera wrote: +> Yeah, the problem seems underspecified. + +So, Dan, the question is, what are you trying to measure? +This might be a statistic that management has always been given, +for Oracle, and you need to produce the "same" number for PostgreSQL. + +If not, it's hard to figure out what a statement counter actually can measure, +to the extent that you can say, "If that number does THIS, I should do THAT." + +-- +Engineers think that equations approximate reality. +Physicists think that reality approximates the equations. +Mathematicians never make the connection. + +From pgsql-performance-owner@postgresql.org Tue May 30 17:56:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A149B9FA16E + for ; + Wed, 24 May 2006 05:44:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 40101-05 + for ; + Wed, 24 May 2006 05:44:44 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from web36309.mail.mud.yahoo.com (web36309.mail.mud.yahoo.com + [209.191.84.239]) + by postgresql.org (Postfix) with SMTP id AC10A9FA2E6 + for ; + Wed, 24 May 2006 05:44:44 -0300 (ADT) +Received: (qmail 37778 invoked by uid 60001); 24 May 2006 08:44:43 -0000 +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; + h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; + b=Voz6PPZ8yAMYCggGmmMDy8mwZ6DpUZ8R1UqNQ51uG6wLsqd3OVWYbtf6Ohbt33BuHeGE6EwZ6PM7xvFZICvPOFywbk1RaYdOzoE6iIsqiqdyyBQLjrEZsj2P0xzeL+jD3JBnbPWNCrzdlKXRVK5SNl4aHyZLjwx+xqOs6/lkg3E= + ; +Message-ID: <20060524084443.37776.qmail@web36309.mail.mud.yahoo.com> +Received: from [160.75.104.2] by web36309.mail.mud.yahoo.com via HTTP; + Wed, 24 May 2006 01:44:43 PDT +Date: Wed, 24 May 2006 01:44:43 -0700 (PDT) +From: sibel karaasma +Subject: compiling source code!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +To: pgsql-performance@postgresql.org +MIME-Version: 1.0 +Content-Type: multipart/alternative; boundary="0-1443344348-1148460283=:37573" +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/539 +X-Sequence-Number: 19326 + +--0-1443344348-1148460283=:37573 +Content-Type: text/plain; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +Hi I'm a new postgresql user. I wrote ACO (ant colony optimazition) and +want to replace it with GEQO in postres/src/backend/optimizer but I don't know how +to compile and run the source code :( + + I installed postgresql-8.1.3 and cygwin but I can not use them to +compile the source code. I want to compare GEQO and ACO optimizers performance using a small database + + Can you help me??????? + + +--------------------------------- +Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min. +--0-1443344348-1148460283=:37573 +Content-Type: text/html; charset=iso-8859-1 +Content-Transfer-Encoding: 8bit + +Hi I'm a new postgresql user. I wrote ACO (ant colony optimazition) and
want to replace it with GEQO in postres/src/backend/optimizer but I don't know how
to compile and run the source code :(
  
  I installed postgresql-8.1.3 and cygwin but I can not use them to
compile the source code. I want to compare GEQO and ACO optimizers performance using a small database
   
  Can you help me???????

+


Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min. +--0-1443344348-1148460283=:37573-- + +From pgsql-performance-owner@postgresql.org Wed May 24 07:27:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 292B69FA42B + for ; + Wed, 24 May 2006 07:27:53 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 50592-08 + for ; + Wed, 24 May 2006 07:27:43 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.199]) + by postgresql.org (Postfix) with ESMTP id 44F079FA2DB + for ; + Wed, 24 May 2006 07:27:42 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id 18so1525468nzp + for ; + Wed, 24 May 2006 03:27:42 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=c8rVjWsDZslxfpqlPbU+tLmG0TkaZg/0VyIaLa7Vr4r0+fBbO/HggJykAag1Kx3MnrpojRQJLym3Yu4hYwCFAxHuc4y0ZzwRm6BB0lQbmWVA55hek4jsvePsLfJUw/iNFVClampnLLzW26GAHRD2dWUBgF4H78HsCGFA08IX9kI= +Received: by 10.64.152.2 with SMTP id z2mr2802248qbd; + Wed, 24 May 2006 03:27:42 -0700 (PDT) +Received: by 10.65.216.18 with HTTP; Wed, 24 May 2006 03:27:41 -0700 (PDT) +Message-ID: +Date: Wed, 24 May 2006 12:27:41 +0200 +From: "Robin Ericsson" +To: "Dan Gorman" +Subject: Re: Selects query stats? +Cc: pgsql-performance@postgresql.org +In-Reply-To: <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> + <4473553C.1010804@ca.sophos.com> + <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/444 +X-Sequence-Number: 19231 + +On 5/23/06, Dan Gorman wrote: +> +> In any other DB (oracle, mysql) I know how many queries (selects) per sec= +ond +> the database is executing. How do I get this +> number out of postgres? + +Mysql does AFAIR only count the number of queries and then uses the +"seconds since startup" to estimate the number of queries per second. +If your server is hammered with queries 1 hour a day it's not giving +you a fair result. + + +--=20 + regards, + Robin + +From pgsql-performance-owner@postgresql.org Tue May 30 17:56:28 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C6ECB9FA2DB + for ; + Wed, 24 May 2006 12:50:06 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 94959-04 + for ; + Wed, 24 May 2006 12:49:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail3.panix.com (mail3.panix.com [166.84.1.74]) + by postgresql.org (Postfix) with ESMTP id D8DA79F9F8F + for ; + Wed, 24 May 2006 12:49:53 -0300 (ADT) +Received: from panix3.panix.com (panix3.panix.com [166.84.1.3]) + by mail3.panix.com (Postfix) with ESMTP id A586813A876 + for ; + Wed, 24 May 2006 11:49:52 -0400 (EDT) +Received: (from kynn@localhost) + by panix3.panix.com (8.11.6p3/8.8.8/PanixN1.1) id k4OFnqx05310; + Wed, 24 May 2006 11:49:52 -0400 (EDT) +Date: Wed, 24 May 2006 11:49:52 -0400 (EDT) +Message-Id: <200605241549.k4OFnqx05310@panix3.panix.com> +From: +To: pgsql-performance@postgresql.org +Subject: Optimizing a huge_table/tiny_table join +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/540 +X-Sequence-Number: 19327 + + + + + + +I want to optimize this simple join: + +SELECT * FROM huge_table h, tiny_table t WHERE UPPER( h.id ) = UPPER( t.id ) + +huge_table has about 2.5 million records, can be assumed as fixed, and +has the following index: + +CREATE INDEX huge_table_index ON huge_table( UPPER( id ) ); + +...while tiny_table changes with each user request, and typically will +contain on the order of 100-1000 records. For this analysis, I put +300 records in tiny_table, resulting in 505 records in the join. + +I tried several approaches. In order of increasing speed of +execution: + +1. executed as shown above, with enable_seqscan on: about 100 s. + +2. executed as shown above, with enable_seqscan off: about 10 s. + +3. executed with a LIMIT 6000 clause added to the SELECT statement, and + enable_seqscan on: about 5 s. + +4. executed with a LIMIT 600 clause added to the SELECT statement, and + enable_seqscan on: less than 1 s. + + + +Clearly, using LIMIT is the way to go. Unfortunately I *do* want all +the records that would have been produced without the LIMIT clause, +and I don't have a formula for the limit that will guarantee this. I +could use a very large value (e.g. 20x the size of tiny_table, as in +approach 3 above) which would make the probability of hitting the +limit very small, but unfortunately, the query plan in this case is +different from the query plan when the limit is just above the +expected number of results (approach 4 above). + +The query plan for the fastest approach is this: + + QUERY PLAN +--------------------------------------------------------------------------------------------------------- + Limit (cost=0.01..2338.75 rows=600 width=84) + -> Nested Loop (cost=0.01..14766453.89 rows=3788315 width=84) + -> Seq Scan on tiny_table t (cost=0.00..19676.00 rows=300 width=38) + -> Index Scan using huge_table_index on huge_table h (cost=0.01..48871.80 rows=12628 width=46) + Index Cond: (upper(("outer".id)::text) = upper((h.id)::text)) + + + +How can I *force* this query plan even with a higher limit value? + +I found, by dumb trial and error, that in this case the switch happens +at LIMIT 5432, which, FWIW, is about 0.2% of the size of huge_table. +Is there a simpler way to determine this limit (hopefully +programmatically)? + + +Alternatively, I could compute the value for LIMIT as 2x the number of +records in tiny_table, and if the number of records found is *exactly* +this number, I would know that (most likely) some records were left +out. In this case, I could use the fact that, according to the query +plan above, the scan of tiny_table is sequential to infer which +records in tiny_table were disregarded when the limit was reached, and +then repeat the query with only these left over records in tiny_table. + +What's your opinion of this strategy? Is there a good way to improve +it? + +Many thanks in advance! + +kj + +PS: FWIW, the query plan for the query with LIMIT 6000 is this: + + QUERY PLAN +------------------------------------------------------------------------------------- + Limit (cost=19676.75..21327.99 rows=6000 width=84) + -> Hash Join (cost=19676.75..1062244.81 rows=3788315 width=84) + Hash Cond: (upper(("outer".id)::text) = upper(("inner".id)::text)) + -> Seq Scan on huge_table h (cost=0.00..51292.43 rows=2525543 width=46) + -> Hash (cost=19676.00..19676.00 rows=300 width=38) + -> Seq Scan on tiny_table t (cost=0.00..19676.00 rows=300 width=38) + +From pgsql-performance-owner@postgresql.org Tue May 30 17:56:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7CA0E9F94EA + for ; + Wed, 24 May 2006 14:42:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 12611-05 + for ; + Wed, 24 May 2006 14:42:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail1.panix.com (mail1.panix.com [166.84.1.72]) + by postgresql.org (Postfix) with ESMTP id 368A39F9398 + for ; + Wed, 24 May 2006 14:42:48 -0300 (ADT) +Received: from panix3.panix.com (panix3.panix.com [166.84.1.3]) + by mail1.panix.com (Postfix) with ESMTP id 661665964D; + Wed, 24 May 2006 13:42:46 -0400 (EDT) +Received: (from kynn@localhost) + by panix3.panix.com (8.11.6p3/8.8.8/PanixN1.1) id k4OHgkg06460; + Wed, 24 May 2006 13:42:46 -0400 (EDT) +Date: Wed, 24 May 2006 13:42:46 -0400 (EDT) +Message-Id: <200605241742.k4OHgkg06460@panix3.panix.com> +From: +To: pgsql-performance@postgresql.org +Subject: Optimizing a huge_table/tiny_table join +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/541 +X-Sequence-Number: 19328 + + + + + +[ I had a problem with my mailer when I first sent this. My apologies + for any repeats. ] + + +I want to optimize this simple join: + +SELECT * FROM huge_table h, tiny_table t WHERE UPPER( h.id ) = UPPER( t.id ) + +huge_table has about 2.5 million records, can be assumed as fixed, and +has the following index: + +CREATE INDEX huge_table_index ON huge_table( UPPER( id ) ); + +...while tiny_table changes with each user request, and typically will +contain on the order of 100-1000 records. For this analysis, I put +300 records in tiny_table, resulting in 505 records in the join. + +I tried several approaches. In order of increasing speed of +execution: + +1. executed as shown above, with enable_seqscan on: about 100 s. + +2. executed as shown above, with enable_seqscan off: about 10 s. + +3. executed with a LIMIT 6000 clause added to the SELECT statement, and + enable_seqscan on: about 5 s. + +4. executed with a LIMIT 600 clause added to the SELECT statement, and + enable_seqscan on: less than 1 s. + + + +Clearly, using LIMIT is the way to go. Unfortunately I *do* want all +the records that would have been produced without the LIMIT clause, +and I don't have a formula for the limit that will guarantee this. I +could use a very large value (e.g. 20x the size of tiny_table, as in +approach 3 above) which would make the probability of hitting the +limit very small, but unfortunately, the query plan in this case is +different from the query plan when the limit is just above the +expected number of results (approach 4 above). + +The query plan for the fastest approach is this: + + QUERY PLAN +--------------------------------------------------------------------------------------------------------- + Limit (cost=0.01..2338.75 rows=600 width=84) + -> Nested Loop (cost=0.01..14766453.89 rows=3788315 width=84) + -> Seq Scan on tiny_table t (cost=0.00..19676.00 rows=300 width=38) + -> Index Scan using huge_table_index on huge_table h (cost=0.01..48871.80 rows=12628 width=46) + Index Cond: (upper(("outer".id)::text) = upper((h.id)::text)) + + + +How can I *force* this query plan even with a higher limit value? + +I found, by dumb trial and error, that in this case the switch happens +at LIMIT 5432, which, FWIW, is about 0.2% of the size of huge_table. +Is there a simpler way to determine this limit (hopefully +programmatically)? + + +Alternatively, I could compute the value for LIMIT as 2x the number of +records in tiny_table, and if the number of records found is *exactly* +this number, I would know that (most likely) some records were left +out. In this case, I could use the fact that, according to the query +plan above, the scan of tiny_table is sequential to infer which +records in tiny_table were disregarded when the limit was reached, and +then repeat the query with only these left over records in tiny_table. + +What's your opinion of this strategy? Is there a good way to improve +it? + +Many thanks in advance! + +kj + +PS: FWIW, the query plan for the query with LIMIT 6000 is this: + + QUERY PLAN +------------------------------------------------------------------------------------- + Limit (cost=19676.75..21327.99 rows=6000 width=84) + -> Hash Join (cost=19676.75..1062244.81 rows=3788315 width=84) + Hash Cond: (upper(("outer".id)::text) = upper(("inner".id)::text)) + -> Seq Scan on huge_table h (cost=0.00..51292.43 rows=2525543 width=46) + -> Hash (cost=19676.00..19676.00 rows=300 width=38) + -> Seq Scan on tiny_table t (cost=0.00..19676.00 rows=300 width=38) + +From pgsql-performance-owner@postgresql.org Wed May 24 16:45:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A7A7A9F94EA + for ; + Wed, 24 May 2006 16:45:35 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 28971-01 + for ; + Wed, 24 May 2006 16:45:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id BEF089F9398 + for ; + Wed, 24 May 2006 16:45:25 -0300 (ADT) +Received: from gandalf.geeklair.net (gandalf.geeklair.net [129.250.34.2]) + by svr4.postgresql.org (Postfix) with ESMTP id 6492E5AF069 + for ; + Wed, 24 May 2006 19:45:24 +0000 (GMT) +Received: from [192.168.5.3] (c-67-172-95-82.hsd1.mi.comcast.net + [67.172.95.82]) (authenticated bits=0) + by gandalf.geeklair.net (8.13.6/8.13.6) with ESMTP id k4OJjIq9011240 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) + for ; + Wed, 24 May 2006 15:45:19 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v750) +Content-Transfer-Encoding: 7bit +Message-Id: +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg=pgp-sha1; boundary="Apple-Mail-9-541509132" +To: pgsql-performance@postgresql.org +From: "Daniel J. Luke" +Subject: Getting even more insert performance (250m+rows/day) +Date: Wed, 24 May 2006 15:45:17 -0400 +X-Pgp-Agent: GPGMail 1.1.2 (Tiger) +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/445 +X-Sequence-Number: 19232 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--Apple-Mail-9-541509132 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed + +I have a system that currently inserts ~ 250 million rows per day (I +have about 10k more raw data than that, but I'm at the limit of my +ability to get useful insert performance out of postgres). + +Things I've already done that have made a big difference: +- modified postgresql.conf shared_buffers value +- converted to COPY from individual insert statements +- changed BLCKSZ to 32768 + +I currently get ~35k/sec inserts on a table with one index (~70k/sec +inserts if I don't have any indexes). + +The indexed field is basically a time_t (seconds since the epoch), +autovacuum is running (or postgres would stop choosing to use the +index). The other fields have relatively lower cardinality. + +Each days worth of data gets inserted into its own table so that I +can expire the data without too much effort (since drop table is much +faster than running a delete and then vacuum). + +I would really like to be able to have 1 (or 2) more indexes on the +table since it takes a while for a sequential scan of 250million rows +to complete, but CPU time goes way up. + +In fact, it looks like I'm not currently IO bound, but CPU-bound. I +think some sort of lazy-index generation (especially if it could be +parallelized to use the other processors/cores that currently sit +mostly idle) would be a solution. Is anyone working on something like +this? Any other ideas? Where should I look if I want to start to +think about creating a new index that would work this way (or am I +just crazy)? + +Thanks for any insight! + +-- +Daniel J. Luke ++========================================================+ +| *---------------- dluke@geeklair.net ----------------* | +| *-------------- http://www.geeklair.net -------------* | ++========================================================+ +| Opinions expressed are mine and do not necessarily | +| reflect the opinions of my employer. | ++========================================================+ + + + +--Apple-Mail-9-541509132 +content-type: application/pgp-signature; x-mac-type=70674453; + name=PGP.sig +content-description: This is a digitally signed message part +content-disposition: inline; filename=PGP.sig +content-transfer-encoding: 7bit + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.3 (Darwin) + +iD8DBQFEdLfNjUs5tAKawAoRAsoTAJ4lp6u6lH8L3tVhCu106IHfAbo+SQCfZYPK +CPEXpXq8zgyqqPBg0HSRy7E= +=kh39 +-----END PGP SIGNATURE----- + +--Apple-Mail-9-541509132-- + +From pgsql-performance-owner@postgresql.org Wed May 24 17:02:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 56D8A9F94EA + for ; + Wed, 24 May 2006 17:02:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 28473-10 + for ; + Wed, 24 May 2006 17:02:47 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id 6C4DD9F9398 + for ; + Wed, 24 May 2006 17:02:45 -0300 (ADT) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [67.90.96.2] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 91281520; Wed, 24 May 2006 13:02:44 -0700 +From: "Dave Dutcher" +To: "'Daniel J. Luke'" , + +Subject: Re: Getting even more insert performance (250m+rows/day) +Date: Wed, 24 May 2006 15:02:44 -0500 +Message-ID: <01f701c67f6d$0578bf40$8300a8c0@tridecap.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.2627 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +In-Reply-To: +Importance: Normal +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/446 +X-Sequence-Number: 19233 + + +If you can live with possible database corruption, you could try turning +Fsync off. For example if you could just reinsert the data on the off +chance a hardware failure corrupts the database, you might get a decent +improvement. + +Also have you tried creating the index after you have inserted all your +data? (Or maybe copy already disables the indexes while inserting?) + + + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of +> Daniel J. Luke +> Sent: Wednesday, May 24, 2006 2:45 PM +> To: pgsql-performance@postgresql.org +> Subject: [PERFORM] Getting even more insert performance +> (250m+rows/day) +> +> +> I have a system that currently inserts ~ 250 million rows per day (I +> have about 10k more raw data than that, but I'm at the limit of my +> ability to get useful insert performance out of postgres). +> +> Things I've already done that have made a big difference: +> - modified postgresql.conf shared_buffers value +> - converted to COPY from individual insert statements +> - changed BLCKSZ to 32768 +> +> I currently get ~35k/sec inserts on a table with one index (~70k/sec +> inserts if I don't have any indexes). +> +> The indexed field is basically a time_t (seconds since the epoch), +> autovacuum is running (or postgres would stop choosing to use the +> index). The other fields have relatively lower cardinality. +> +> Each days worth of data gets inserted into its own table so that I +> can expire the data without too much effort (since drop table +> is much +> faster than running a delete and then vacuum). +> +> I would really like to be able to have 1 (or 2) more indexes on the +> table since it takes a while for a sequential scan of +> 250million rows +> to complete, but CPU time goes way up. +> +> In fact, it looks like I'm not currently IO bound, but CPU-bound. I +> think some sort of lazy-index generation (especially if it could be +> parallelized to use the other processors/cores that currently sit +> mostly idle) would be a solution. Is anyone working on +> something like +> this? Any other ideas? Where should I look if I want to start to +> think about creating a new index that would work this way (or am I +> just crazy)? +> +> Thanks for any insight! +> +> -- +> Daniel J. Luke +> +========================================================+ +> | *---------------- dluke@geeklair.net ----------------* | +> | *-------------- http://www.geeklair.net -------------* | +> +========================================================+ +> | Opinions expressed are mine and do not necessarily | +> | reflect the opinions of my employer. | +> +========================================================+ +> +> +> + + +From pgsql-performance-owner@postgresql.org Wed May 24 17:03:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C746C9F9398 + for ; + Wed, 24 May 2006 17:03:57 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29293-07 + for ; + Wed, 24 May 2006 17:03:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id 7F4139FA2D8 + for ; + Wed, 24 May 2006 17:03:51 -0300 (ADT) +Received: from trofast.sesse.net ([129.241.93.32]) + by cassarossa.samfundet.no with esmtp (Exim 4.50) + id 1Fiza8-0006u8-1J; Wed, 24 May 2006 22:03:48 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1Fiza9-0002ob-00; Wed, 24 May 2006 22:03:49 +0200 +Date: Wed, 24 May 2006 22:03:49 +0200 +From: "Steinar H. Gunderson" +To: "Daniel J. Luke" +Cc: pgsql-performance@postgresql.org +Subject: Re: Getting even more insert performance (250m+rows/day) +Message-ID: <20060524200349.GA10753@uio.no> +Mail-Followup-To: "Daniel J. Luke" , + pgsql-performance@postgresql.org +References: +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: +X-Operating-System: Linux 2.6.16.11 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/447 +X-Sequence-Number: 19234 + +On Wed, May 24, 2006 at 03:45:17PM -0400, Daniel J. Luke wrote: +> Things I've already done that have made a big difference: +> - modified postgresql.conf shared_buffers value +> - converted to COPY from individual insert statements +> - changed BLCKSZ to 32768 + +Have you tried fiddling with the checkpointing settings? Check your logs -- +if you get a warning about checkpoints being too close together, that should +give you quite some boost. + +Apart from that, you should have quite a bit to go on -- somebody on this +list reported 2 billion rows/day earlier, but it might have been on beefier +hardware, of course. :-) + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Wed May 24 17:08:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2C5249F9398 + for ; + Wed, 24 May 2006 17:08:20 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 31489-04-2 + for ; + Wed, 24 May 2006 17:08:10 -0300 (ADT) +X-Greylist: delayed 00:22:45.887861 by SQLgrey- +Received: from gandalf.geeklair.net (gandalf.geeklair.net [129.250.34.2]) + by postgresql.org (Postfix) with ESMTP id F0C569FA278 + for ; + Wed, 24 May 2006 17:08:09 -0300 (ADT) +Received: from [192.168.5.3] (c-67-172-95-82.hsd1.mi.comcast.net + [67.172.95.82]) (authenticated bits=0) + by gandalf.geeklair.net (8.13.6/8.13.6) with ESMTP id k4OK88NA012386 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT); + Wed, 24 May 2006 16:08:08 -0400 (EDT) +In-Reply-To: <01f701c67f6d$0578bf40$8300a8c0@tridecap.com> +References: <01f701c67f6d$0578bf40$8300a8c0@tridecap.com> +Mime-Version: 1.0 (Apple Message framework v750) +X-Priority: 3 (Normal) +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg=pgp-sha1; boundary="Apple-Mail-10-542878774" +Message-Id: +Cc: +Content-Transfer-Encoding: 7bit +From: "Daniel J. Luke" +Subject: Re: Getting even more insert performance (250m+rows/day) +Date: Wed, 24 May 2006 16:08:06 -0400 +To: "Dave Dutcher" +X-Pgp-Agent: GPGMail 1.1.2 (Tiger) +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/448 +X-Sequence-Number: 19235 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--Apple-Mail-10-542878774 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed + +On May 24, 2006, at 4:02 PM, Dave Dutcher wrote: +> If you can live with possible database corruption, you could try +> turning +> Fsync off. For example if you could just reinsert the data on the off +> chance a hardware failure corrupts the database, you might get a +> decent +> improvement. + +I tried, but I didn't see much of an improvement (and it's not really +acceptable for this application). + +> Also have you tried creating the index after you have inserted all +> your +> data? (Or maybe copy already disables the indexes while inserting?) + +The data gets inserted in batches every 5 minutes and I potentially +have people querying it constantly, so I can't remove and re-create +the index. + +-- +Daniel J. Luke ++========================================================+ +| *---------------- dluke@geeklair.net ----------------* | +| *-------------- http://www.geeklair.net -------------* | ++========================================================+ +| Opinions expressed are mine and do not necessarily | +| reflect the opinions of my employer. | ++========================================================+ + + + +--Apple-Mail-10-542878774 +content-type: application/pgp-signature; x-mac-type=70674453; + name=PGP.sig +content-description: This is a digitally signed message part +content-disposition: inline; filename=PGP.sig +content-transfer-encoding: 7bit + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.3 (Darwin) + +iD8DBQFEdL0njUs5tAKawAoRAuUKAJ47xK1PutU4L79E75LfJ01r60H5sQCfREpH +nHsM29UCu02w4f6r8WMjsIc= +=jtYK +-----END PGP SIGNATURE----- + +--Apple-Mail-10-542878774-- + +From pgsql-performance-owner@postgresql.org Wed May 24 17:10:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D0FA99F94EA + for ; + Wed, 24 May 2006 17:10:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 30286-06 + for ; + Wed, 24 May 2006 17:10:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gandalf.geeklair.net (gandalf.geeklair.net [129.250.34.2]) + by postgresql.org (Postfix) with ESMTP id 119E39F9398 + for ; + Wed, 24 May 2006 17:09:59 -0300 (ADT) +Received: from [192.168.5.3] (c-67-172-95-82.hsd1.mi.comcast.net + [67.172.95.82]) (authenticated bits=0) + by gandalf.geeklair.net (8.13.6/8.13.6) with ESMTP id k4OK9t9r012505 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT); + Wed, 24 May 2006 16:09:56 -0400 (EDT) +In-Reply-To: <20060524200349.GA10753@uio.no> +References: + <20060524200349.GA10753@uio.no> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg=pgp-sha1; boundary="Apple-Mail-11-542986433" +Message-Id: <9E8E3745-64F2-4908-BF16-284CF7834760@geeklair.net> +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: "Daniel J. Luke" +Subject: Re: Getting even more insert performance (250m+rows/day) +Date: Wed, 24 May 2006 16:09:54 -0400 +To: "Steinar H. Gunderson" +X-Pgp-Agent: GPGMail 1.1.2 (Tiger) +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/449 +X-Sequence-Number: 19236 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--Apple-Mail-11-542986433 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed + +On May 24, 2006, at 4:03 PM, Steinar H. Gunderson wrote: +> Have you tried fiddling with the checkpointing settings? Check your +> logs -- +> if you get a warning about checkpoints being too close together, +> that should +> give you quite some boost. + +no warnings in the log (I did change the checkpoint settings when I +set up the database, but didn't notice an appreciable difference in +insert performance). + +> Apart from that, you should have quite a bit to go on -- somebody +> on this +> list reported 2 billion rows/day earlier, but it might have been on +> beefier +> hardware, of course. :-) + +Probably :) I'll keep searching the list archives and see if I find +anything else (I did some searching and didn't find anything that I +hadn't already tried). + +Thanks! + +-- +Daniel J. Luke ++========================================================+ +| *---------------- dluke@geeklair.net ----------------* | +| *-------------- http://www.geeklair.net -------------* | ++========================================================+ +| Opinions expressed are mine and do not necessarily | +| reflect the opinions of my employer. | ++========================================================+ + + + +--Apple-Mail-11-542986433 +content-type: application/pgp-signature; x-mac-type=70674453; + name=PGP.sig +content-description: This is a digitally signed message part +content-disposition: inline; filename=PGP.sig +content-transfer-encoding: 7bit + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.3 (Darwin) + +iD8DBQFEdL2SjUs5tAKawAoRAv9CAJ4o/bCXcwbTiEAqB7TAvO1b+73UGgCeIGDt +8w4CeSSrQJRkDBd5ciEqBUM= +=cGoF +-----END PGP SIGNATURE----- + +--Apple-Mail-11-542986433-- + +From pgsql-performance-owner@postgresql.org Wed May 24 17:12:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6498C9FA278 + for ; + Wed, 24 May 2006 17:12:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 28082-10 + for ; + Wed, 24 May 2006 17:12:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ausimss.pervasive.com (ausimss.pervasive.com [66.45.103.246]) + by postgresql.org (Postfix) with ESMTP id 0CE629F94EA + for ; + Wed, 24 May 2006 17:12:32 -0300 (ADT) +Received: from ausbayes2.aus.pervasive.com ([172.16.8.6]) by + ausimss.pervasive.com with InterScan Messaging Security Suite; + Wed, 24 May 2006 15:12:28 -0500 +Received: from AUSOWA.aus.pervasive.com ([172.16.4.8]) by + ausbayes2.aus.pervasive.com with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 24 May 2006 15:12:27 -0500 +Received: from ausmaildd.aus.pervasive.com ([172.16.4.63]) by + AUSOWA.aus.pervasive.com with Microsoft SMTPSVC(6.0.3790.1830); + Wed, 24 May 2006 15:12:26 -0500 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Getting even more insert performance (250m+rows/day) +Date: Wed, 24 May 2006 15:12:26 -0500 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Getting even more insert performance (250m+rows/day) +Thread-Index: AcZ/beu/A9fJGdSoQZ+eIA2/GnnJJAAADRZg +From: "Larry Rosenman" +To: "Daniel J. Luke" , "Dave Dutcher" +Cc: +X-OriginalArrivalTime: 24 May 2006 20:12:26.0865 (UTC) + FILETIME=[607E2E10:01C67F6E] +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/450 +X-Sequence-Number: 19237 + +Daniel J. Luke wrote: +> On May 24, 2006, at 4:02 PM, Dave Dutcher wrote: +>> If you can live with possible database corruption, you could try +>> turning Fsync off. For example if you could just reinsert the data +>> on the off chance a hardware failure corrupts the database, you +>> might get a decent improvement. +>=20 +> I tried, but I didn't see much of an improvement (and it's not really +> acceptable for this application). +>=20 +>> Also have you tried creating the index after you have inserted all +>> your data? (Or maybe copy already disables the indexes while +>> inserting?)=20 +>=20 +> The data gets inserted in batches every 5 minutes and I potentially +> have people querying it constantly, so I can't remove and re-create +> the index. +>=20 +are the batches single insert's, or within a big transaction? + +I.E., does the inserts look like: +INSERT +INSERT +INSERT + +or + +BEGIN +INSERT +INSERT +INSERT +COMMIT + +If the former, the latter is a big win. + +Also, what release(s) are you running? + +LER + +--=20 +Larry Rosenman =09 +Database Support Engineer + +PERVASIVE SOFTWARE. INC. +12365B RIATA TRACE PKWY +3015 +AUSTIN TX 78727-6531=20 + +Tel: 512.231.6173 +Fax: 512.231.6597 +Email: Larry.Rosenman@pervasive.com +Web: www.pervasive.com=20 + +From pgsql-performance-owner@postgresql.org Wed May 24 17:13:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D9EF19F9398 + for ; + Wed, 24 May 2006 17:13:57 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 32584-01-3 + for ; + Wed, 24 May 2006 17:13:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id 2A2749FA3AD + for ; + Wed, 24 May 2006 17:13:50 -0300 (ADT) +Received: from trofast.ipv6.sesse.net ([2001:700:300:dc03:20e:cff:fe36:a766] + helo=trofast.sesse.net) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1Fizjp-0007ek-2b + for pgsql-performance@postgresql.org; Wed, 24 May 2006 22:13:49 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1Fizjq-0002rw-00 + for ; Wed, 24 May 2006 22:13:50 +0200 +Date: Wed, 24 May 2006 22:13:50 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: Getting even more insert performance (250m+rows/day) +Message-ID: <20060524201350.GB10918@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <20060524200349.GA10753@uio.no> + <9E8E3745-64F2-4908-BF16-284CF7834760@geeklair.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: <9E8E3745-64F2-4908-BF16-284CF7834760@geeklair.net> +X-Operating-System: Linux 2.6.16.11 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/451 +X-Sequence-Number: 19238 + +On Wed, May 24, 2006 at 04:09:54PM -0400, Daniel J. Luke wrote: +> no warnings in the log (I did change the checkpoint settings when I +> set up the database, but didn't notice an appreciable difference in +> insert performance). + +How about wal_buffers? Upping it might not help all that much if only one +thread is writing, but you might give it a try... + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Wed May 24 17:21:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 60A409F9398 + for ; + Wed, 24 May 2006 17:21:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 31647-09 + for ; + Wed, 24 May 2006 17:21:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gandalf.geeklair.net (gandalf.geeklair.net [129.250.34.2]) + by postgresql.org (Postfix) with ESMTP id B29CC9F94EA + for ; + Wed, 24 May 2006 17:21:21 -0300 (ADT) +Received: from [192.168.5.3] (c-67-172-95-82.hsd1.mi.comcast.net + [67.172.95.82]) (authenticated bits=0) + by gandalf.geeklair.net (8.13.6/8.13.6) with ESMTP id k4OKI7O3012874 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT); + Wed, 24 May 2006 16:18:08 -0400 (EDT) +In-Reply-To: + +References: + +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg=pgp-sha1; boundary="Apple-Mail-12-543478584" +Message-Id: <7E2D9162-867B-4DB1-B8A3-9ED701434488@geeklair.net> +Cc: "Dave Dutcher" , +Content-Transfer-Encoding: 7bit +From: "Daniel J. Luke" +Subject: Re: Getting even more insert performance (250m+rows/day) +Date: Wed, 24 May 2006 16:18:06 -0400 +To: "Larry Rosenman" +X-Pgp-Agent: GPGMail 1.1.2 (Tiger) +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/454 +X-Sequence-Number: 19241 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--Apple-Mail-12-543478584 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed + +On May 24, 2006, at 4:12 PM, Larry Rosenman wrote: +> are the batches single insert's, or within a big transaction? +> If the former, the latter is a big win. + +One big transaction every 5 minutes using 'COPY FROM' (instead of +inserts). + +> Also, what release(s) are you running? + +8.1.x (I think we're upgrading from 8.1.3 to 8.1.4 today). + +-- +Daniel J. Luke ++========================================================+ +| *---------------- dluke@geeklair.net ----------------* | +| *-------------- http://www.geeklair.net -------------* | ++========================================================+ +| Opinions expressed are mine and do not necessarily | +| reflect the opinions of my employer. | ++========================================================+ + + + +--Apple-Mail-12-543478584 +content-type: application/pgp-signature; x-mac-type=70674453; + name=PGP.sig +content-description: This is a digitally signed message part +content-disposition: inline; filename=PGP.sig +content-transfer-encoding: 7bit + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.3 (Darwin) + +iD8DBQFEdL9+jUs5tAKawAoRAqM5AJ94HJg0hsHJnybs6EnuUAS0SHaJiwCfaCV8 +hKVkwzZz+SdN+kBFiLQpmWs= +=HZXu +-----END PGP SIGNATURE----- + +--Apple-Mail-12-543478584-- + +From pgsql-performance-owner@postgresql.org Wed May 24 17:18:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 474359FA278 + for ; + Wed, 24 May 2006 17:18:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 28530-10 + for ; + Wed, 24 May 2006 17:18:35 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) + by postgresql.org (Postfix) with ESMTP id A89C89F9398 + for ; + Wed, 24 May 2006 17:18:35 -0300 (ADT) +Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP + with MS-WebStorage 6.0.6249 +Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; + 24 May 2006 13:18:33 -0700 +Subject: Re: Getting even more insert performance (250m+rows/day) +From: Mark Lewis +To: "Daniel J. Luke" +Cc: Dave Dutcher , pgsql-performance@postgresql.org +In-Reply-To: +References: <01f701c67f6d$0578bf40$8300a8c0@tridecap.com> + +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: MIR3, Inc. +Date: Wed, 24 May 2006 13:18:32 -0700 +Message-Id: <1148501913.28095.70.camel@archimedes> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-27) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/452 +X-Sequence-Number: 19239 + +> The data gets inserted in batches every 5 minutes and I potentially +> have people querying it constantly, so I can't remove and re-create +> the index. + +How live does your data need to be? One possibility would be to use a +separate table for each batch instead of a separate table per day, +create the indexes after the import and only after the indexes have been +created make the table available for user queries. + +You'd be trading latency for throughput in that case. + +Also, you mentioned that you're CPU-bound, but that you have multiple +CPU's. In that case, performing N concurrent imports (where N is the +number of processor cores available) might be a win over a single- +threaded import. + +-- Mark Lewis + +From pgsql-performance-owner@postgresql.org Wed May 24 17:20:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 015029FA278 + for ; + Wed, 24 May 2006 17:20:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 32790-07 + for ; + Wed, 24 May 2006 17:20:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gandalf.geeklair.net (gandalf.geeklair.net [129.250.34.2]) + by postgresql.org (Postfix) with ESMTP id E4B889F94EA + for ; + Wed, 24 May 2006 17:20:29 -0300 (ADT) +Received: from [192.168.5.3] (c-67-172-95-82.hsd1.mi.comcast.net + [67.172.95.82]) (authenticated bits=0) + by gandalf.geeklair.net (8.13.6/8.13.6) with ESMTP id k4OKKLYv012960 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT); + Wed, 24 May 2006 16:20:22 -0400 (EDT) +In-Reply-To: <20060524201350.GB10918@uio.no> +References: + <20060524200349.GA10753@uio.no> + <9E8E3745-64F2-4908-BF16-284CF7834760@geeklair.net> + <20060524201350.GB10918@uio.no> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg=pgp-sha1; boundary="Apple-Mail-13-543612260" +Message-Id: <6D9B6E0B-21C3-4F2F-88AD-D097069E0220@geeklair.net> +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: "Daniel J. Luke" +Subject: Re: Getting even more insert performance (250m+rows/day) +Date: Wed, 24 May 2006 16:20:20 -0400 +To: "Steinar H. Gunderson" +X-Pgp-Agent: GPGMail 1.1.2 (Tiger) +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/453 +X-Sequence-Number: 19240 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--Apple-Mail-13-543612260 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed + +On May 24, 2006, at 4:13 PM, Steinar H. Gunderson wrote: +> On Wed, May 24, 2006 at 04:09:54PM -0400, Daniel J. Luke wrote: +>> no warnings in the log (I did change the checkpoint settings when I +>> set up the database, but didn't notice an appreciable difference in +>> insert performance). +> +> How about wal_buffers? Upping it might not help all that much if +> only one +> thread is writing, but you might give it a try... + +I tried, but I didn't notice a difference. + +I should probably emphasize that I appear to be CPU bound (and I can +double my # of rows inserted per second by removing the index on the +table, or half it by adding another index). + +I really should run gprof just to verify. + +-- +Daniel J. Luke ++========================================================+ +| *---------------- dluke@geeklair.net ----------------* | +| *-------------- http://www.geeklair.net -------------* | ++========================================================+ +| Opinions expressed are mine and do not necessarily | +| reflect the opinions of my employer. | ++========================================================+ + + + +--Apple-Mail-13-543612260 +content-type: application/pgp-signature; x-mac-type=70674453; + name=PGP.sig +content-description: This is a digitally signed message part +content-disposition: inline; filename=PGP.sig +content-transfer-encoding: 7bit + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.3 (Darwin) + +iD8DBQFEdMAEjUs5tAKawAoRAksvAKCLCX+zwkR6kovPwv1D4NgXxjt5YACgjjIZ +KBfUlZdiEkfGssvLp2On+Kg= +=SHnV +-----END PGP SIGNATURE----- + +--Apple-Mail-13-543612260-- + +From pgsql-performance-owner@postgresql.org Wed May 24 17:24:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 772719FA278 + for ; + Wed, 24 May 2006 17:24:39 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 34092-01 + for ; + Wed, 24 May 2006 17:24:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from ausimss.pervasive.com (ausimss.pervasive.com [66.45.103.246]) + by postgresql.org (Postfix) with ESMTP id ECC729F9398 + for ; + Wed, 24 May 2006 17:24:26 -0300 (ADT) +Received: from ausbayes2.aus.pervasive.com ([172.16.8.6]) by + ausimss.pervasive.com with InterScan Messaging Security Suite; + Wed, 24 May 2006 15:24:21 -0500 +Received: from AUSOWA.aus.pervasive.com ([172.16.4.8]) by + ausbayes2.aus.pervasive.com with Microsoft SMTPSVC(5.0.2195.6713); + Wed, 24 May 2006 15:24:21 -0500 +Received: from ausmaildd.aus.pervasive.com ([172.16.4.63]) by + AUSOWA.aus.pervasive.com with Microsoft SMTPSVC(6.0.3790.1830); + Wed, 24 May 2006 15:24:20 -0500 +X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 +Content-class: urn:content-classes:message +MIME-Version: 1.0 +Content-Type: text/plain; + charset="US-ASCII" +Content-Transfer-Encoding: quoted-printable +Subject: Re: Getting even more insert performance (250m+rows/day) +Date: Wed, 24 May 2006 15:24:20 -0500 +Message-ID: + +X-MS-Has-Attach: +X-MS-TNEF-Correlator: +Thread-Topic: [PERFORM] Getting even more insert performance (250m+rows/day) +Thread-Index: AcZ/b75z7l2qg2XYQau/kqXjc6IUmgAADJKg +From: "Larry Rosenman" +To: "Daniel J. Luke" +Cc: "Dave Dutcher" , + +X-OriginalArrivalTime: 24 May 2006 20:24:20.0972 (UTC) + FILETIME=[0A2242C0:01C67F70] +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/455 +X-Sequence-Number: 19242 + +Daniel J. Luke wrote: +> On May 24, 2006, at 4:12 PM, Larry Rosenman wrote: +>> are the batches single insert's, or within a big transaction? +>> If the former, the latter is a big win. +>=20 +> One big transaction every 5 minutes using 'COPY FROM' (instead of +> inserts). +>=20 +>> Also, what release(s) are you running? +>=20 +> 8.1.x (I think we're upgrading from 8.1.3 to 8.1.4 today). +>=20 +Had to ask :)=20 + +Also, is pg_xlog on the same or different spindles from the rest of the +PG Data directory? + +LER + +--=20 +Larry Rosenman =09 +Database Support Engineer + +PERVASIVE SOFTWARE. INC. +12365B RIATA TRACE PKWY +3015 +AUSTIN TX 78727-6531=20 + +Tel: 512.231.6173 +Fax: 512.231.6597 +Email: Larry.Rosenman@pervasive.com +Web: www.pervasive.com=20 + +From pgsql-performance-owner@postgresql.org Wed May 24 17:29:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8BD659F94EA + for ; + Wed, 24 May 2006 17:29:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 32868-05 + for ; + Wed, 24 May 2006 17:29:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gandalf.geeklair.net (gandalf.geeklair.net [129.250.34.2]) + by postgresql.org (Postfix) with ESMTP id 76E509F9398 + for ; + Wed, 24 May 2006 17:29:29 -0300 (ADT) +Received: from [192.168.5.3] (c-67-172-95-82.hsd1.mi.comcast.net + [67.172.95.82]) (authenticated bits=0) + by gandalf.geeklair.net (8.13.6/8.13.6) with ESMTP id k4OKTQGx013257 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT); + Wed, 24 May 2006 16:29:27 -0400 (EDT) +In-Reply-To: + +References: + +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg=pgp-sha1; boundary="Apple-Mail-16-544157950" +Message-Id: <4D7AF15D-0F5D-4AAA-85F7-B06089F826B1@geeklair.net> +Cc: "Dave Dutcher" , +Content-Transfer-Encoding: 7bit +From: "Daniel J. Luke" +Subject: Re: Getting even more insert performance (250m+rows/day) +Date: Wed, 24 May 2006 16:29:25 -0400 +To: Larry Rosenman +X-Pgp-Agent: GPGMail 1.1.2 (Tiger) +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/456 +X-Sequence-Number: 19243 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--Apple-Mail-16-544157950 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed + +On May 24, 2006, at 4:24 PM, Larry Rosenman wrote: +> Also, is pg_xlog on the same or different spindles from the rest of +> the +> PG Data directory? + +It's sitting on the same disk array (but I'm doing 1 transaction +every 5 minutes, and I'm not near the array's sustained write +capacity, so I don't think that's currently limiting performance). + +-- +Daniel J. Luke ++========================================================+ +| *---------------- dluke@geeklair.net ----------------* | +| *-------------- http://www.geeklair.net -------------* | ++========================================================+ +| Opinions expressed are mine and do not necessarily | +| reflect the opinions of my employer. | ++========================================================+ + + + +--Apple-Mail-16-544157950 +content-type: application/pgp-signature; x-mac-type=70674453; + name=PGP.sig +content-description: This is a digitally signed message part +content-disposition: inline; filename=PGP.sig +content-transfer-encoding: 7bit + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.3 (Darwin) + +iD8DBQFEdMImjUs5tAKawAoRAi30AJsGbTRtdSK54blhAnNRVUem/Ium6QCfcibS +Uawk3giuLLGSIGB7bADa2WI= +=3Ix3 +-----END PGP SIGNATURE----- + +--Apple-Mail-16-544157950-- + +From pgsql-performance-owner@postgresql.org Wed May 24 18:32:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1EAF29F94EA + for ; + Wed, 24 May 2006 18:32:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 42282-02 + for ; + Wed, 24 May 2006 18:32:29 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 115689F9398 + for ; + Wed, 24 May 2006 18:32:28 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 9B03B56435; Wed, 24 May 2006 16:32:27 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 24 May 2006 16:32:26 -0500 +Date: Wed, 24 May 2006 16:32:25 -0500 +From: "Jim C. Nasby" +To: "Daniel J. Luke" +Cc: "Steinar H. Gunderson" , + pgsql-performance@postgresql.org +Subject: Re: Getting even more insert performance (250m+rows/day) +Message-ID: <20060524213225.GM59464@pervasive.com> +References: + <20060524200349.GA10753@uio.no> + <9E8E3745-64F2-4908-BF16-284CF7834760@geeklair.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <9E8E3745-64F2-4908-BF16-284CF7834760@geeklair.net> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060524:dluke@geeklair.net::NAyqE+P59FnQW9yq:0000000000000000000 + 0000000000000000000000007eSL +X-Hashcash: + 1:20:060524:sgunderson@bigfoot.com::RknI5T08qESiPNhW:000000000000000 + 0000000000000000000000006Xeb +X-Hashcash: + 1:20:060524:pgsql-performance@postgresql.org::g/Rd2hyDC8A2Lbo/:00000 + 00000000000000000000000047rt +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/457 +X-Sequence-Number: 19244 + +On Wed, May 24, 2006 at 04:09:54PM -0400, Daniel J. Luke wrote: +> On May 24, 2006, at 4:03 PM, Steinar H. Gunderson wrote: +> >Have you tried fiddling with the checkpointing settings? Check your +> >logs -- +> >if you get a warning about checkpoints being too close together, +> >that should +> >give you quite some boost. +> +> no warnings in the log (I did change the checkpoint settings when I +> set up the database, but didn't notice an appreciable difference in +> insert performance). + +Keep in mind that the default warning time of 30 seconds is pretty +conservative; you'd want to bump that up to 300 seconds or so, probably. + +As for the suggestion of multiple insert runs at a time, I suspect that +would just result in a lot of contention for some mutex/semaphore in the +index. + +Your best bet really is to run gprof and post those results. It's also +possible that this is fixed be a recent patch to HEAD that reduces the +amount of traffic on the index metapage, something gprof would probably +confirm. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 24 18:34:12 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C44BD9F9398 + for ; + Wed, 24 May 2006 18:34:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 42059-04-3 + for ; + Wed, 24 May 2006 18:33:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id A0A1B9FA3AD + for ; + Wed, 24 May 2006 18:33:56 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 6A7B656431; Wed, 24 May 2006 16:33:55 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 24 May 2006 16:33:53 -0500 +Date: Wed, 24 May 2006 16:33:53 -0500 +From: "Jim C. Nasby" +To: Robin Ericsson +Cc: Dan Gorman , pgsql-performance@postgresql.org +Subject: Re: Selects query stats? +Message-ID: <20060524213352.GN59464@pervasive.com> +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> + <4473553C.1010804@ca.sophos.com> + <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060524:lobbin@gmail.com::eGIZIcesqs0wgw6x:06bwP +X-Hashcash: 1:20:060524:dgorman@hi5.com::v0wiC8vauIMRbtyW:0087B/ +X-Hashcash: + 1:20:060524:pgsql-performance@postgresql.org::ZYoYtSlXRNrkCYsR:00000 + 0000000000000000000000000WOa +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/458 +X-Sequence-Number: 19245 + +On Wed, May 24, 2006 at 12:27:41PM +0200, Robin Ericsson wrote: +> On 5/23/06, Dan Gorman wrote: +> > +> >In any other DB (oracle, mysql) I know how many queries (selects) per +> >second +> >the database is executing. How do I get this +> >number out of postgres? +> +> Mysql does AFAIR only count the number of queries and then uses the +> "seconds since startup" to estimate the number of queries per second. +> If your server is hammered with queries 1 hour a day it's not giving +> you a fair result. + +Somehow that doesn't surprise me... + +In any case, if we at least provide a raw counter, it's not that hard to +turn that into selects per second over some period of time. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 24 21:53:04 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C60B79FA38E + for ; + Wed, 24 May 2006 21:53:03 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 16076-01 + for ; + Wed, 24 May 2006 21:52:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail3.panix.com (mail3.panix.com [166.84.1.74]) + by postgresql.org (Postfix) with ESMTP id 8A0AD9FA3A6 + for ; + Wed, 24 May 2006 21:52:54 -0300 (ADT) +Received: from panix3.panix.com (panix3.panix.com [166.84.1.3]) + by mail3.panix.com (Postfix) with ESMTP id 27DAD13A8CE; + Wed, 24 May 2006 20:52:53 -0400 (EDT) +Received: (from kynn@localhost) + by panix3.panix.com (8.11.6p3/8.8.8/PanixN1.1) id k4P0qrT11965; + Wed, 24 May 2006 20:52:53 -0400 (EDT) +Date: Wed, 24 May 2006 20:52:53 -0400 (EDT) +Message-Id: <200605250052.k4P0qrT11965@panix3.panix.com> +From: +To: pgsql-performance@postgresql.org +Subject: Optimizing a huge_table/tiny_table join +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/459 +X-Sequence-Number: 19246 + + + + + +I want to optimize this simple join: + +SELECT * FROM huge_table h, tiny_table t WHERE UPPER( h.id ) = UPPER( t.id ) + +huge_table has about 2.5 million records, can be assumed as fixed, and +has the following index: + +CREATE INDEX huge_table_index ON huge_table( UPPER( id ) ); + +...while tiny_table changes with each user request, and typically will +contain on the order of 100-1000 records. For this analysis, I put +300 records in tiny_table, resulting in 505 records in the join. + +I tried several approaches. In order of increasing speed of +execution: + +1. executed as shown above, with enable_seqscan on: about 100 s. + +2. executed as shown above, with enable_seqscan off: about 10 s. + +3. executed with a LIMIT 6000 clause added to the SELECT statement, and + enable_seqscan on: about 5 s. + +4. executed with a LIMIT 600 clause added to the SELECT statement, and + enable_seqscan on: less than 1 s. + + + +Clearly, using LIMIT is the way to go. Unfortunately I *do* want all +the records that would have been produced without the LIMIT clause, +and I don't have a formula for the limit that will guarantee this. I +could use a very large value (e.g. 20x the size of tiny_table, as in +approach 3 above) which would make the probability of hitting the +limit very small, but unfortunately, the query plan in this case is +different from the query plan when the limit is just above the +expected number of results (approach 4 above). + +The query plan for the fastest approach is this: + + QUERY PLAN +--------------------------------------------------------------------------------------------------------- + Limit (cost=0.01..2338.75 rows=600 width=84) + -> Nested Loop (cost=0.01..14766453.89 rows=3788315 width=84) + -> Seq Scan on tiny_table t (cost=0.00..19676.00 rows=300 width=38) + -> Index Scan using huge_table_index on huge_table h (cost=0.01..48871.80 rows=12628 width=46) + Index Cond: (upper(("outer".id)::text) = upper((h.id)::text)) + + + +How can I *force* this query plan even with a higher limit value? + +I found, by dumb trial and error, that in this case the switch happens +at LIMIT 5432, which, FWIW, is about 0.2% of the size of huge_table. +Is there a simpler way to determine this limit (hopefully +programmatically)? + + +Alternatively, I could compute the value for LIMIT as 2x the number of +records in tiny_table, and if the number of records found is *exactly* +this number, I would know that (most likely) some records were left +out. In this case, I could use the fact that, according to the query +plan above, the scan of tiny_table is sequential to infer which +records in tiny_table were disregarded when the limit was reached, and +then repeat the query with only these left over records in tiny_table. + +What's your opinion of this strategy? Is there a good way to improve +it? + +Many thanks in advance! + +kj + +PS: FWIW, the query plan for the query with LIMIT 6000 is this: + + QUERY PLAN +------------------------------------------------------------------------------------- + Limit (cost=19676.75..21327.99 rows=6000 width=84) + -> Hash Join (cost=19676.75..1062244.81 rows=3788315 width=84) + Hash Cond: (upper(("outer".id)::text) = upper(("inner".id)::text)) + -> Seq Scan on huge_table h (cost=0.00..51292.43 rows=2525543 width=46) + -> Hash (cost=19676.00..19676.00 rows=300 width=38) + -> Seq Scan on tiny_table t (cost=0.00..19676.00 rows=300 width=38) + +------------=_1148485808-20617-3-- + + +From pgsql-performance-owner@postgresql.org Wed May 24 22:32:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 291B39FA3A6 + for ; + Wed, 24 May 2006 22:32:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 34392-05 + for ; + Wed, 24 May 2006 22:32:05 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from projects.commandprompt.com (host-130.commandprompt.net + [207.173.203.130]) + by postgresql.org (Postfix) with ESMTP id A4EA79FA15F + for ; + Wed, 24 May 2006 22:32:05 -0300 (ADT) +Received: from [192.168.1.50] (or-67-76-146-141.sta.sprint-hsd.net + [67.76.146.141]) (authenticated bits=0) + by projects.commandprompt.com (8.13.6/8.13.6) with ESMTP id + k4P1W1Es002692; Wed, 24 May 2006 18:32:02 -0700 +Message-ID: <4475090C.6010303@commandprompt.com> +Date: Wed, 24 May 2006 18:31:56 -0700 +From: "Joshua D. Drake" +Organization: Command Prompt, Inc. +User-Agent: Thunderbird 1.5.0.2 (X11/20060521) +MIME-Version: 1.0 +To: kynn@panix.com +CC: pgsql-performance@postgresql.org +Subject: Re: Optimizing a huge_table/tiny_table join +References: <200605250052.k4P0qrT11965@panix3.panix.com> +In-Reply-To: <200605250052.k4P0qrT11965@panix3.panix.com> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV version 0.88.2, + clamav-milter version 0.88.2 on projects.commandprompt.com +X-Virus-Status: Clean +X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by + milter-greylist-1.6 (projects.commandprompt.com + [192.168.2.159]); Wed, 24 May 2006 18:32:02 -0700 (PDT) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/460 +X-Sequence-Number: 19247 + + +> kj +> +> PS: FWIW, the query plan for the query with LIMIT 6000 is this: + +What is the explain analyze? + +> +> QUERY PLAN +> ------------------------------------------------------------------------------------- +> Limit (cost=19676.75..21327.99 rows=6000 width=84) +> -> Hash Join (cost=19676.75..1062244.81 rows=3788315 width=84) +> Hash Cond: (upper(("outer".id)::text) = upper(("inner".id)::text)) +> -> Seq Scan on huge_table h (cost=0.00..51292.43 rows=2525543 width=46) +> -> Hash (cost=19676.00..19676.00 rows=300 width=38) +> -> Seq Scan on tiny_table t (cost=0.00..19676.00 rows=300 width=38) +> +> ------------=_1148485808-20617-3-- +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> + + +-- + + === The PostgreSQL Company: Command Prompt, Inc. === +Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240 + Providing the most comprehensive PostgreSQL solutions since 1997 + http://www.commandprompt.com/ + + + +From pgsql-performance-owner@postgresql.org Wed May 24 22:42:09 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 37C529FA38E + for ; + Wed, 24 May 2006 22:42:09 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 35698-06 + for ; + Wed, 24 May 2006 22:42:03 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 8ED649FA15F + for ; + Wed, 24 May 2006 22:42:03 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4P1fx0S007083; + Wed, 24 May 2006 21:41:59 -0400 (EDT) +To: kynn@panix.com +cc: pgsql-performance@postgresql.org +Subject: Re: Optimizing a huge_table/tiny_table join +In-reply-to: <200605250052.k4P0qrT11965@panix3.panix.com> +References: <200605250052.k4P0qrT11965@panix3.panix.com> +Comments: In-reply-to + message dated "Wed, 24 May 2006 20:52:53 -0400" +Date: Wed, 24 May 2006 21:41:59 -0400 +Message-ID: <7082.1148521319@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/461 +X-Sequence-Number: 19248 + + writes: +> Limit (cost=19676.75..21327.99 rows=6000 width=84) +> -> Hash Join (cost=19676.75..1062244.81 rows=3788315 width=84) +> Hash Cond: (upper(("outer".id)::text) = upper(("inner".id)::text)) +> -> Seq Scan on huge_table h (cost=0.00..51292.43 rows=2525543 width=46) +> -> Hash (cost=19676.00..19676.00 rows=300 width=38) +> -> Seq Scan on tiny_table t (cost=0.00..19676.00 rows=300 width=38) + +Um, if huge_table is so much bigger than tiny_table, why are the cost +estimates for seqscanning them only about 2.5x different? There's +something wacko about your statistics, methinks. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu May 25 00:40:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 318099FA38E + for ; + Thu, 25 May 2006 00:40:11 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 55828-05 + for ; + Thu, 25 May 2006 00:39:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from rwcrmhc13.comcast.net (rwcrmhc13.comcast.net [216.148.227.153]) + by postgresql.org (Postfix) with ESMTP id 06EDE9FA15F + for ; + Thu, 25 May 2006 00:39:56 -0300 (ADT) +Received: from spectre (c-66-30-214-31.hsd1.ma.comcast.net[66.30.214.31]) + by comcast.net (rwcrmhc13) with SMTP + id <20060525033751m1300gksh5e>; Thu, 25 May 2006 03:37:51 +0000 +From: "Ian Westmacott" +To: "Daniel J. Luke" +Cc: +Subject: Re: Getting even more insert performance (250m+rows/day) +Date: Wed, 24 May 2006 23:20:24 -0400 +Message-ID: <000301c67faa$296831a0$1fd61e42@hsd1.ma.comcast.net> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="utf-8" +Content-Transfer-Encoding: 7bit +X-Priority: 3 (Normal) +X-MSMail-Priority: Normal +X-Mailer: Microsoft Outlook 8.5, Build 4.71.2377.0 +In-Reply-To: <20060524200349.GA10753@uio.no> +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 +Importance: Normal +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/462 +X-Sequence-Number: 19249 + +We were able to achieve 2B (small) rows per day sustained with +very little latency. It is beefy hardware, but things that did +help include WAL on its own I/O channel, XFS, binary copy, +and tuning bgwriter and checkpoint settings for the application +and hardware. Things that didn't help much were shared_buffers +and wal_buffers. But our application is single-writer, and a +small number of readers. + +Although there is tons of great advice in this and other forums, +I think you just have to do a lot of experimentation with careful +measurement to find what's right for your application/environment. +i.e., YMMV. + +-----Original Message----- +From: pgsql-performance-owner@postgresql.org +[mailto:pgsql-performance-owner@postgresql.org]On Behalf Of Steinar H. +Gunderson +Sent: Wednesday, May 24, 2006 4:04 PM +To: Daniel J. Luke +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] Getting even more insert performance +(250m+rows/day) + + +On Wed, May 24, 2006 at 03:45:17PM -0400, Daniel J. Luke wrote: +> Things I've already done that have made a big difference: +> - modified postgresql.conf shared_buffers value +> - converted to COPY from individual insert statements +> - changed BLCKSZ to 32768 + +Have you tried fiddling with the checkpointing settings? Check your logs -- +if you get a warning about checkpoints being too close together, that should +give you quite some boost. + +Apart from that, you should have quite a bit to go on -- somebody on this +list reported 2 billion rows/day earlier, but it might have been on beefier +hardware, of course. :-) + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +---------------------------(end of broadcast)--------------------------- +TIP 6: explain analyze is your friend + + +From pgsql-performance-owner@postgresql.org Thu May 25 13:16:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 24A809F9B01 + for ; + Thu, 25 May 2006 13:16:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 90006-02 + for ; + Thu, 25 May 2006 13:16:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from my.endian.it (unknown [62.146.87.34]) + by postgresql.org (Postfix) with ESMTP id D5BFE9F94EA + for ; + Thu, 25 May 2006 13:16:26 -0300 (ADT) +Received: from dell.home.lan (host45-104.pool875.interbusiness.it + [87.5.104.45]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id k4PGL8c31910 + for ; Thu, 25 May 2006 18:21:08 +0200 +Subject: lowering priority automatically at connection +From: Chris Mair +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Date: Thu, 25 May 2006 18:16:24 +0200 +Message-Id: <1148573784.6017.26.camel@dell.home.lan> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-27) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/463 +X-Sequence-Number: 19250 + +Hi, + +I find this very helpful: + + Lowering the priority of a PostgreSQL query + http://weblog.bignerdranch.com/?p=11 + +Now I was wondering whether one could have a + SELECT pg_setpriority(10); +executed automatically each time a certain user +connects (not necessarily using psql)? + +Any ideas if and how this might be possible? + +Regards :) +Chris. + + + +From pgsql-performance-owner@postgresql.org Tue May 30 17:56:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 26D9B9F9B01 + for ; + Thu, 25 May 2006 13:22:03 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 91664-01 + for ; + Thu, 25 May 2006 13:21:55 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wr-out-0506.google.com (wr-out-0506.google.com + [64.233.184.238]) + by postgresql.org (Postfix) with ESMTP id 7965E9F94EA + for ; + Thu, 25 May 2006 13:21:55 -0300 (ADT) +Received: by wr-out-0506.google.com with SMTP id 67so164163wri + for ; + Thu, 25 May 2006 09:21:54 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; + b=TuDp8v+vPQqA23WhtiB+07E0gHTSjb0t/KDMTOQlVVlyCktwTbDcCWQ5GPHMgRHoBk0qUQ8oXLUFupqPLEUGs2zRQBaH2kWRSJYuIs/Ii4KIAgMPyYU+C6RJyTJRcibJnz6LOwbiexIhhL5dE8+u0l5NqogIwftzdMruefxO0U0= +Received: by 10.54.143.10 with SMTP id q10mr814350wrd; + Thu, 25 May 2006 09:21:53 -0700 (PDT) +Received: by 10.54.101.2 with HTTP; Thu, 25 May 2006 09:21:53 -0700 (PDT) +Message-ID: +Date: Thu, 25 May 2006 12:21:53 -0400 +From: "Kynn Jones" +To: pgsql-performance@postgresql.org +Subject: Re: Optimizing a huge_table/tiny_table join +Cc: "Tom Lane" +In-Reply-To: <7082.1148521319@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_19611_32327247.1148574113949" +References: <200605250052.k4P0qrT11965@panix3.panix.com> + <7082.1148521319@sss.pgh.pa.us> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/542 +X-Sequence-Number: 19329 + +------=_Part_19611_32327247.1148574113949 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +On 5/24/06, Tom Lane wrote: +> +> writes: +> > Limit (cost=3D19676.75..21327.99 rows=3D6000 width=3D84) +> > -> Hash Join (cost=3D19676.75..1062244.81 rows=3D3788315 width=3D8= +4) +> > Hash Cond: (upper(("outer".id)::text) =3D +> upper(("inner".id)::text)) +> > -> Seq Scan on huge_table h (cost=3D0.00..51292.43 rows=3D25= +25543 +> width=3D46) +> > -> Hash (cost=3D19676.00..19676.00 rows=3D300 width=3D38) +> > -> Seq Scan on tiny_table t (cost=3D0.00..19676.00rows= +=3D300 width=3D38) +> +> Um, if huge_table is so much bigger than tiny_table, why are the cost +> estimates for seqscanning them only about 2.5x different? There's +> something wacko about your statistics, methinks. + + + +You mean there's a bug in explain? I agree that it makes no sense that the +costs don't differ as much as one would expect, but you can see right there +the numbers of rows for the two tables, which are exactly as I described. +At any rate, how would one go about finding an explanation for these strang= +e +stats? + +More bewildering still (and infuriating as hell--because it means that all +of my work for yesterday has been wasted) is that I can no longer reproduce +the best query plan, even though the tables have not changed at all. (Henc= +e +I can't post the explain analyze for the best query plan.) No matter what +value I use for LIMIT, the query planner now insists on sequentially +scanning huge_table and ignoring the available index. (If I turn off +enable_seqscan, I get the second worst query plan I posted yesterday.) + +Anyway, I take it that there is no way to bypass the optimizer and instruct +PostgreSQL exactly how one wants the search performed? + +Thanks! + +kj + +------=_Part_19611_32327247.1148574113949 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +

+
On 5/24/06, = +Tom Lane <tgl@sss.pgh.pa.us= +> wrote:=20 +
<kynn@panix.com> writes:
>  Limit  (c= +ost=3D19676.75..21327.99 + rows=3D6000 width=3D84)
>    ->  Ha= +sh Join  (cost=3D19676.75..1062244.81 rows=3D3788315 width=3D84)<= +br>>          Hash Con= +d: (upper(("outer".id)::text) =3D upper(("inner".id)::t= +ext))
>          -&= +gt;  Seq Scan on huge_table h  (cost=3D +0.00..51292.43 rows=3D2525543 width=3D46)
>    &n= +bsp;     ->  Hash  (cost=3D= +19676.00..19676.00 rows=3D300 width=3D38)
>    &n= +bsp;           ->= +  Seq Scan on tiny_table t  (cost=3D0.00..19676.00 rows= +=3D300 width=3D38)

Um, if huge_table is so much bigger than tiny_tab= +le, why are the cost +
estimates for seqscanning them only about 2.5x different?  Th= +ere's
something wacko about your statistics, methinks.
+
 
+
 
+
You mean there's a bug in explain?  I agree that it makes no sens= +e that the costs don't differ as much as one would expect, but you can see = +right there the numbers of rows for the two tables, which are exactly as I = +described.  At any rate, how would one go about finding an explan= +ation for these strange stats? +
+
 
+
More bewildering still (and infuriating as hell--because it means that= + all of my work for yesterday has been wasted) is that I can no l= +onger reproduce the best query plan, even though the tables have not c= +hanged at all.  (Hence I can't post the explain analyze for the b= +est query plan.)  No matter what value I use for LIMIT, the query plan= +ner now insists on sequentially scanning huge_table and ignoring the a= +vailable index.  (If I turn off enable_seqscan, I get the second worst= + query plan I posted yesterday.) +
+
 
+
Anyway, I take it that there is no way to bypass the optimizer and ins= +truct PostgreSQL exactly how one wants the search performed?
+
 
+
Thanks!
+
 
+
kj
+
 
+ +------=_Part_19611_32327247.1148574113949-- + +From pgsql-performance-owner@postgresql.org Thu May 25 13:26:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 623C39F9B01 + for ; + Thu, 25 May 2006 13:26:56 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 89429-05 + for ; + Thu, 25 May 2006 13:26:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 459DE9F94EA + for ; + Thu, 25 May 2006 13:26:46 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4PGQin0013759; + Thu, 25 May 2006 12:26:44 -0400 (EDT) +To: Chris Mair +cc: pgsql-performance@postgresql.org +Subject: Re: lowering priority automatically at connection +In-reply-to: <1148573784.6017.26.camel@dell.home.lan> +References: <1148573784.6017.26.camel@dell.home.lan> +Comments: In-reply-to Chris Mair + message dated "Thu, 25 May 2006 18:16:24 +0200" +Date: Thu, 25 May 2006 12:26:43 -0400 +Message-ID: <13758.1148574403@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/464 +X-Sequence-Number: 19251 + +Chris Mair writes: +> I find this very helpful: +> Lowering the priority of a PostgreSQL query +> http://weblog.bignerdranch.com/?p=11 + +That guy doesn't actually have the foggiest idea what he's doing. +The reason there is no built-in capability to do that is that it *does +not work well*. Search the list archives for "priority inversion" to +find out why not. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu May 25 13:33:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0E0D99F9B01 + for ; + Thu, 25 May 2006 13:31:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 91211-05 + for ; + Thu, 25 May 2006 13:31:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail1.panix.com (mail1.panix.com [166.84.1.72]) + by postgresql.org (Postfix) with ESMTP id DB17D9F94EA + for ; + Thu, 25 May 2006 13:31:05 -0300 (ADT) +Received: from panix3.panix.com (panix3.panix.com [166.84.1.3]) + by mail1.panix.com (Postfix) with ESMTP id CD89A58AAF; + Thu, 25 May 2006 12:31:04 -0400 (EDT) +Received: (from kynn@localhost) + by panix3.panix.com (8.11.6p3/8.8.8/PanixN1.1) id k4PGV4O28645; + Thu, 25 May 2006 12:31:04 -0400 (EDT) +Date: Thu, 25 May 2006 12:31:04 -0400 (EDT) +Message-Id: <200605251631.k4PGV4O28645@panix3.panix.com> +From: +To: pgsql-performance@postgresql.org +Subject: Re: Optimizing a huge_table/tiny_table join +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/465 +X-Sequence-Number: 19252 + + +On 5/24/06, Tom Lane wrote: +> +> writes: +> > Limit (cost=19676.75..21327.99 rows=6000 width=84) +> > -> Hash Join (cost=19676.75..1062244.81 rows=3788315 width=84) +> > Hash Cond: (upper(("outer".id)::text) upper(("inner".id)::text)) +> > -> Seq Scan on huge_table h (cost= 0.00..51292.43 rows=2525543 width=46) +> > -> Hash (cost=19676.00..19676.00 rows=300 width=38) +> > -> Seq Scan on tiny_table t (cost=0.00..19676.00 rows=300 width=38) +> +> Um, if huge_table is so much bigger than tiny_table, why are the cost +> estimates for seqscanning them only about 2.5x different? There's +> something wacko about your statistics, methinks. + + + +Well, they're not my statistics; they're explain's. You mean there's +a bug in explain? I agree that it makes no sense that the costs don't +differ as much as one would expect, but you can see right there the +numbers of rows for the two tables. At any rate, how would one go +about finding an explanation for these strange stats? + +More bewildering still (and infuriating as hell--because it means that +all of my work for yesterday has been wasted) is that I can no longer +reproduce the best query plan I posted earlier, even though the tables +have not changed at all. (Hence I can't post the explain analyze for +the best query plan, which Josh Drake asked for.) No matter what +value I use for LIMIT, the query planner now insists on sequentially +scanning huge_table and ignoring the available index. (If I turn off +enable_seqscan, I get the second worst query plan I posted yesterday.) + +Anyway, I take it that there is no way to bypass the optimizer and +instruct PostgreSQL exactly how one wants the search performed? + +Thanks! + +kj + +From pgsql-performance-owner@postgresql.org Thu May 25 13:35:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 533F99F9B01 + for ; + Thu, 25 May 2006 13:35:40 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 91664-06 + for ; + Thu, 25 May 2006 13:35:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from my.endian.it (unknown [62.146.87.34]) + by postgresql.org (Postfix) with ESMTP id 90A349F94EA + for ; + Thu, 25 May 2006 13:35:30 -0300 (ADT) +Received: from dell.home.lan (host45-104.pool875.interbusiness.it + [87.5.104.45]) (authenticated (0 bits)) + by my.endian.it (8.11.6/8.11.6) with ESMTP id k4PGeCc32685 + for ; Thu, 25 May 2006 18:40:12 +0200 +Subject: Re: lowering priority automatically at connection +From: Chris Mair +To: pgsql-performance@postgresql.org +In-Reply-To: <13758.1148574403@sss.pgh.pa.us> +References: <1148573784.6017.26.camel@dell.home.lan> + <13758.1148574403@sss.pgh.pa.us> +Content-Type: text/plain +Date: Thu, 25 May 2006 18:35:28 +0200 +Message-Id: <1148574928.6017.36.camel@dell.home.lan> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-27) +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/466 +X-Sequence-Number: 19253 + + +> > I find this very helpful: +> > Lowering the priority of a PostgreSQL query +> > http://weblog.bignerdranch.com/?p=11 +> +> That guy doesn't actually have the foggiest idea what he's doing. +> The reason there is no built-in capability to do that is that it *does +> not work well*. Search the list archives for "priority inversion" to +> find out why not. +> +> regards, tom lane + +Ok, +I've learned something new (*). +I'll drop that idea :) + +Bye, +Chris. + +(*) +http://en.wikipedia.org/wiki/Priority_inversion + + + + +From pgsql-performance-owner@postgresql.org Thu May 25 13:48:50 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1EF1E9F9B01 + for ; + Thu, 25 May 2006 13:48:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 91732-09 + for ; + Thu, 25 May 2006 13:48:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from r1.mycybernet.net (r1.mycybernet.net [209.5.206.8]) + by postgresql.org (Postfix) with ESMTP id 2A2209F94EA + for ; + Thu, 25 May 2006 13:48:42 -0300 (ADT) +Received: from 227-54-222-209.mycybernet.net ([209.222.54.227]:37668 + helo=phlogiston.dydns.org) + by r1.mycybernet.net with esmtp (Exim 4.50 (FreeBSD)) + id 1FjJ0q-000FPe-VV + for pgsql-performance@postgresql.org; Thu, 25 May 2006 12:48:41 -0400 +Received: by phlogiston.dydns.org (Postfix, from userid 1000) + id 495B73FAF; Thu, 25 May 2006 12:48:40 -0400 (EDT) +Date: Thu, 25 May 2006 12:48:40 -0400 +From: Andrew Sullivan +To: pgsql-performance@postgresql.org +Subject: Re: Optimizing a huge_table/tiny_table join +Message-ID: <20060525164840.GA2954@phlogiston.dyndns.org> +References: <200605251631.k4PGV4O28645@panix3.panix.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <200605251631.k4PGV4O28645@panix3.panix.com> +User-Agent: Mutt/1.5.9i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/467 +X-Sequence-Number: 19254 + +On Thu, May 25, 2006 at 12:31:04PM -0400, kynn@panix.com wrote: +> Well, they're not my statistics; they're explain's. You mean there's + +Explain doesn't get them from nowhere. How often is the table being +ANALYSEd? + +> More bewildering still (and infuriating as hell--because it means that +> all of my work for yesterday has been wasted) is that I can no longer +> reproduce the best query plan I posted earlier, even though the tables +> have not changed at all. (Hence I can't post the explain analyze for + +I find that very hard to believe. Didn't change _at all_? Are you +sure no VACUUMs or anything are happening automatically? + +> Anyway, I take it that there is no way to bypass the optimizer and +> instruct PostgreSQL exactly how one wants the search performed? + +No, there isn't. + +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 Thu May 25 13:55:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A01209F9B01 + for ; + Thu, 25 May 2006 13:55:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 90934-09 + for ; + Thu, 25 May 2006 13:55:06 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) + by postgresql.org (Postfix) with ESMTP id 33F799F94EA + for ; + Thu, 25 May 2006 13:55:05 -0300 (ADT) +Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) + by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id k4PGsu56016456 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Thu, 25 May 2006 10:54:59 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: from winnie.fuhr.org (localhost [127.0.0.1]) + by winnie.fuhr.org (8.13.6/8.13.6) with ESMTP id k4PGsuJv070356; + Thu, 25 May 2006 10:54:56 -0600 (MDT) + (envelope-from mfuhr@winnie.fuhr.org) +Received: (from mfuhr@localhost) + by winnie.fuhr.org (8.13.6/8.13.6/Submit) id k4PGsuJk070355; + Thu, 25 May 2006 10:54:56 -0600 (MDT) (envelope-from mfuhr) +Date: Thu, 25 May 2006 10:54:56 -0600 +From: Michael Fuhr +To: Chris Mair +Cc: pgsql-performance@postgresql.org +Subject: Re: lowering priority automatically at connection +Message-ID: <20060525165456.GA70276@winnie.fuhr.org> +References: <1148573784.6017.26.camel@dell.home.lan> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1148573784.6017.26.camel@dell.home.lan> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/468 +X-Sequence-Number: 19255 + +On Thu, May 25, 2006 at 06:16:24PM +0200, Chris Mair wrote: +> I find this very helpful: +> +> Lowering the priority of a PostgreSQL query +> http://weblog.bignerdranch.com/?p=11 +> +> Now I was wondering whether one could have a +> SELECT pg_setpriority(10); +> executed automatically each time a certain user +> connects (not necessarily using psql)? + +Beware that setting priorities can have unintended, adverse effects. +Use a search engine to find information about "priority inversion" +before deciding that query priorities are a good idea. + +-- +Michael Fuhr + +From pgsql-performance-owner@postgresql.org Thu May 25 14:07:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1AB869F9B01 + for ; + Thu, 25 May 2006 14:07:24 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 97595-01 + for ; + Thu, 25 May 2006 14:07:13 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from py-out-1112.google.com (py-out-1112.google.com + [64.233.166.183]) + by postgresql.org (Postfix) with ESMTP id F3A639F94EA + for ; + Thu, 25 May 2006 14:07:12 -0300 (ADT) +Received: by py-out-1112.google.com with SMTP id i49so2387159pye + for ; + Thu, 25 May 2006 10:07:11 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=D785Rp29PyVb/AzigXBAQCpwSdcJGoRFYUXesCigoel40zxv5v/f69+xVq/UKW58BWYt6N2g9cBAYY7Rl7e7NfKewK63Jy1TfMwvT5neENUqpnpAGmndE6Arlms36myUmfp3kHm/RpS34JnC8a2hIUqat9wOMOZZoQtqpXmFTLI= +Received: by 10.35.127.7 with SMTP id e7mr1763552pyn; + Thu, 25 May 2006 10:07:11 -0700 (PDT) +Received: by 10.35.41.15 with HTTP; Thu, 25 May 2006 10:07:11 -0700 (PDT) +Message-ID: <758d5e7f0605251007k284fe658m42958e13ee7971e1@mail.gmail.com> +Date: Thu, 25 May 2006 19:07:11 +0200 +From: "Dawid Kuroczko" +To: "kynn@panix.com" +Subject: Re: Optimizing a huge_table/tiny_table join +Cc: pgsql-performance@postgresql.org +In-Reply-To: <200605251631.k4PGV4O28645@panix3.panix.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <200605251631.k4PGV4O28645@panix3.panix.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/469 +X-Sequence-Number: 19256 + +On 5/25/06, kynn@panix.com wrote: +> Well, they're not my statistics; they're explain's. You mean there's +> a bug in explain? I agree that it makes no sense that the costs don't +> differ as much as one would expect, but you can see right there the +> numbers of rows for the two tables. At any rate, how would one go +> about finding an explanation for these strange stats? + +Well, the query planner uses statistics to deduce the best plan +possible. Explain includes this statistical data in its output. +See: +http://www.postgresql.org/docs/8.1/interactive/planner-stats.html +...for information about what it is all about. + +The idea is that your statistics are probably not detailed enough +to help the planner. See ALTER TABLE SET STATISTICS to change +that. + +> More bewildering still (and infuriating as hell--because it means that +> all of my work for yesterday has been wasted) is that I can no longer +> reproduce the best query plan I posted earlier, even though the tables +> have not changed at all. (Hence I can't post the explain analyze for +> the best query plan, which Josh Drake asked for.) No matter what +> value I use for LIMIT, the query planner now insists on sequentially +> scanning huge_table and ignoring the available index. (If I turn off +> enable_seqscan, I get the second worst query plan I posted yesterday.) +> +> Anyway, I take it that there is no way to bypass the optimizer and +> instruct PostgreSQL exactly how one wants the search performed? + +There is no way to bypass. But there are many ways to tune it. + + + +Hmm, there is a probability (though statistics are more probable +go) that you're using some older version of PostgreSQL, and you're +hitting same problem as I did: + +http://archives.postgresql.org/pgsql-performance/2005-07/msg00345.php + +Tom has provided back then a patch, which fixed it: + +http://archives.postgresql.org/pgsql-performance/2005-07/msg00352.php + +...but I don't remember when it made into release. + + Regfa + +From pgsql-performance-owner@postgresql.org Thu May 25 17:07:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0B48C9F9B01 + for ; + Thu, 25 May 2006 17:07:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 25621-05 + for ; + Thu, 25 May 2006 17:07:20 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.196]) + by postgresql.org (Postfix) with ESMTP id 247F59F94EA + for ; + Thu, 25 May 2006 17:07:19 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id 18so1885169nzp + for ; + Thu, 25 May 2006 13:07:19 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=gkQkQTplhtfuvHuz7msmVKv1R4NWupFwyPcZqLRL/A+azCi+L+wDRko9Zjb6F/m94kT6qkYUR0a+1aPTVrl4Xjnchw8XE5872EbXLb6Wmr2mpM2m7KMTJatkNjW8f3S+qaxvodJPJwv63Abu9QNLGoPxZkNgEv8xFWbJD9/Okuo= +Received: by 10.65.233.20 with SMTP id k20mr1815804qbr; + Thu, 25 May 2006 13:07:19 -0700 (PDT) +Received: by 10.65.137.19 with HTTP; Thu, 25 May 2006 13:07:19 -0700 (PDT) +Message-ID: +Date: Thu, 25 May 2006 16:07:19 -0400 +From: "Merlin Moncure" +To: "Postgresql Performance" +Subject: is it possible to make this faster? +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/470 +X-Sequence-Number: 19257 + +been doing a lot of pgsql/mysql performance testing lately, and there +is one query that mysql does much better than pgsql...and I see it a +lot in normal development: + +select a,b,max(c) from t group by a,b; + +t has an index on a,b,c. + +in my sample case with cardinality of 1000 for a, 2000 for b, and +300000 records in t, pgsql does a seq. scan on dev box in about a +second (returning 2000 records). + +recent versions of mysql do much better, returning same set in < 20ms. +mysql explain says it uses an index to optimize the group by somehow. +is there a faster way to write this query? + +Merlin + +From pgsql-performance-owner@postgresql.org Thu May 25 17:21:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C33C39FA315 + for ; + Thu, 25 May 2006 17:21:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 28130-06 + for ; + Thu, 25 May 2006 17:21:09 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id 9A54A9F94EA + for ; + Thu, 25 May 2006 17:21:09 -0300 (ADT) +Received: (qmail 22909 invoked by uid 500); 25 May 2006 20:23:14 -0000 +Date: Thu, 25 May 2006 15:23:14 -0500 +From: Bruno Wolff III +To: Merlin Moncure +Cc: Postgresql Performance +Subject: Re: is it possible to make this faster? +Message-ID: <20060525202314.GA20747@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Merlin Moncure , + Postgresql Performance +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/471 +X-Sequence-Number: 19258 + +On Thu, May 25, 2006 at 16:07:19 -0400, + Merlin Moncure wrote: +> been doing a lot of pgsql/mysql performance testing lately, and there +> is one query that mysql does much better than pgsql...and I see it a +> lot in normal development: +> +> select a,b,max(c) from t group by a,b; +> +> t has an index on a,b,c. +> +> in my sample case with cardinality of 1000 for a, 2000 for b, and +> 300000 records in t, pgsql does a seq. scan on dev box in about a +> second (returning 2000 records). +> +> recent versions of mysql do much better, returning same set in < 20ms. +> mysql explain says it uses an index to optimize the group by somehow. +> is there a faster way to write this query? + +SELECT DISTINCT ON (a, b) a, b, c FROM t ORDER BY a DESC, b DESC, c DESC; + +From pgsql-performance-owner@postgresql.org Thu May 25 17:32:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id AEC639FA43B + for ; + Thu, 25 May 2006 17:32:02 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29014-04 + for ; + Thu, 25 May 2006 17:31:42 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.207]) + by postgresql.org (Postfix) with ESMTP id 476169FA42B + for ; + Thu, 25 May 2006 17:31:42 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id 18so1889663nzp + for ; + Thu, 25 May 2006 13:31:41 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=eI+Vd/Sr2OiIQZSHPxXiyghNWoC52s8PVczPaLrNo1nWmv8NLKN1Nl3EtZ1aFO7ikZIt+rzx56ZC/9eWzi3hg8P11m9YUh8BS1HH01Ekhj5hjs5RAKyTMedsTp/wyeAZj8xcCh+J0H3Iw+ZUXN4IPFgDyIu8OaGWkGy6ZY8VAro= +Received: by 10.65.35.5 with SMTP id n5mr1540135qbj; + Thu, 25 May 2006 13:31:41 -0700 (PDT) +Received: by 10.65.137.19 with HTTP; Thu, 25 May 2006 13:31:40 -0700 (PDT) +Message-ID: +Date: Thu, 25 May 2006 16:31:40 -0400 +From: "Merlin Moncure" +To: "Bruno Wolff III" , + "Postgresql Performance" +Subject: Re: is it possible to make this faster? +In-Reply-To: <20060525202314.GA20747@wolff.to> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <20060525202314.GA20747@wolff.to> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/472 +X-Sequence-Number: 19259 + +On 5/25/06, Bruno Wolff III wrote: +> On Thu, May 25, 2006 at 16:07:19 -0400, +> Merlin Moncure wrote: +> > been doing a lot of pgsql/mysql performance testing lately, and there +> > is one query that mysql does much better than pgsql...and I see it a +> > lot in normal development: +> > +> > select a,b,max(c) from t group by a,b; +> > + +> SELECT DISTINCT ON (a, b) a, b, c FROM t ORDER BY a DESC, b DESC, c DESC; + +that is actually slower than group by in my case...am i missing +something? (both essentially resolved to seq_scan) + +merlin + +From pgsql-performance-owner@postgresql.org Thu May 25 17:36:35 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 47D369FA315 + for ; + Thu, 25 May 2006 17:36:35 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 30299-04 + for ; + Thu, 25 May 2006 17:36:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id 65F3E9F9B01 + for ; + Thu, 25 May 2006 17:36:28 -0300 (ADT) +Received: from trofast.sesse.net ([129.241.93.32]) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1FjMZE-0005AU-LJ + for pgsql-performance@postgresql.org; Thu, 25 May 2006 22:36:26 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1FjMZK-0005BJ-00 + for ; Thu, 25 May 2006 22:36:30 +0200 +Date: Thu, 25 May 2006 22:36:30 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: is it possible to make this faster? +Message-ID: <20060525203630.GA19881@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: +X-Operating-System: Linux 2.6.16.11 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/473 +X-Sequence-Number: 19260 + +On Thu, May 25, 2006 at 04:07:19PM -0400, Merlin Moncure wrote: +> been doing a lot of pgsql/mysql performance testing lately, and there +> is one query that mysql does much better than pgsql...and I see it a +> lot in normal development: +> +> select a,b,max(c) from t group by a,b; +> +> t has an index on a,b,c. + +The planner _should_ TTBOMK be able to do it by itself in 8.1, but have you +tried something along the following lines? + + select a,b,(select c from t t2 order by c desc where t1.a=t2.a and t1.b=t2.b) + from t t1 group by a,b; + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Thu May 25 17:36:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C0AA89F9B01 + for ; + Thu, 25 May 2006 17:36:39 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29309-06 + for ; + Thu, 25 May 2006 17:36:34 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from skynet.simkin.ca (skynet.simkin.ca [199.175.137.210]) + by postgresql.org (Postfix) with ESMTP id 678AE9F94EA + for ; + Thu, 25 May 2006 17:36:33 -0300 (ADT) +Received: from charon.medialogik.com (crecy.medialogik.com [72.51.27.2]) + (using TLSv1 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by skynet.simkin.ca (Postfix) with ESMTP id 428D6FAC5 + for ; + Thu, 25 May 2006 13:36:31 -0700 (PDT) +From: Alan Hodgson +Organization: Simkin Network Consulting +To: pgsql-performance@postgresql.org +Subject: Re: is it possible to make this faster? +Date: Thu, 25 May 2006 13:36:30 -0700 +User-Agent: KMail/1.8.3 +References: + <20060525202314.GA20747@wolff.to> + +In-Reply-To: +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +Message-Id: <200605251336.30985@hal.medialogik.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/474 +X-Sequence-Number: 19261 + +On May 25, 2006 01:31 pm, "Merlin Moncure" wrote: +> > SELECT DISTINCT ON (a, b) a, b, c FROM t ORDER BY a DESC, b DESC, c +> > DESC; +> +> that is actually slower than group by in my case...am i missing +> something? (both essentially resolved to seq_scan) + +Try it with an index on a,b,c. + +-- +Alan + +From pgsql-performance-owner@postgresql.org Thu May 25 17:45:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F21999F9B01 + for ; + Thu, 25 May 2006 17:45:53 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29322-09 + for ; + Thu, 25 May 2006 17:45:43 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id 7FD489F94EA + for ; + Thu, 25 May 2006 17:45:43 -0300 (ADT) +Received: (qmail 27753 invoked by uid 500); 25 May 2006 20:47:46 -0000 +Date: Thu, 25 May 2006 15:47:46 -0500 +From: Bruno Wolff III +To: Merlin Moncure +Cc: Postgresql Performance +Subject: Re: is it possible to make this faster? +Message-ID: <20060525204746.GA26341@wolff.to> +Mail-Followup-To: Bruno Wolff III , + Merlin Moncure , + Postgresql Performance +References: + <20060525202314.GA20747@wolff.to> + +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/475 +X-Sequence-Number: 19262 + +On Thu, May 25, 2006 at 16:31:40 -0400, + Merlin Moncure wrote: +> On 5/25/06, Bruno Wolff III wrote: +> >On Thu, May 25, 2006 at 16:07:19 -0400, +> > Merlin Moncure wrote: +> >> been doing a lot of pgsql/mysql performance testing lately, and there +> >> is one query that mysql does much better than pgsql...and I see it a +> >> lot in normal development: +> >> +> >> select a,b,max(c) from t group by a,b; +> >> +> +> >SELECT DISTINCT ON (a, b) a, b, c FROM t ORDER BY a DESC, b DESC, c DESC; +> +> that is actually slower than group by in my case...am i missing +> something? (both essentially resolved to seq_scan) + +If there aren't many c's for each (a,b), then a sort might be the best way to +do this. I don't remember if skip scanning ever got done, but if it did, it +would have been 8.1 or later. + +From pgsql-performance-owner@postgresql.org Thu May 25 17:52:40 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9674E9FA315 + for ; + Thu, 25 May 2006 17:52:39 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 33259-02 + for ; + Thu, 25 May 2006 17:52:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id D3F0B9F9B01 + for ; + Thu, 25 May 2006 17:52:32 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4PKqRt6015920; + Thu, 25 May 2006 16:52:27 -0400 (EDT) +To: "Merlin Moncure" +cc: "Postgresql Performance" +Subject: Re: is it possible to make this faster? +In-reply-to: +References: +Comments: In-reply-to "Merlin Moncure" + message dated "Thu, 25 May 2006 16:07:19 -0400" +Date: Thu, 25 May 2006 16:52:27 -0400 +Message-ID: <15919.1148590347@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/476 +X-Sequence-Number: 19263 + +"Merlin Moncure" writes: +> been doing a lot of pgsql/mysql performance testing lately, and there +> is one query that mysql does much better than pgsql...and I see it a +> lot in normal development: + +> select a,b,max(c) from t group by a,b; + +> t has an index on a,b,c. + +The index won't help, as per this comment from planagg.c: + + * We don't handle GROUP BY, because our current implementations of + * grouping require looking at all the rows anyway, and so there's not + * much point in optimizing MIN/MAX. + +Given the numbers you mention (300k rows in 2000 groups) I'm not +convinced that an index-based implementation would help much; we'd +still need to fetch at least one record out of every 150, which is +going to cost near as much as seqscanning all of them. + +> recent versions of mysql do much better, returning same set in < 20ms. + +Well, since they don't do MVCC they can answer this query from the +index without going to the heap at all. But that still seems remarkably +fast for something that has to grovel through 300k index entries. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu May 25 17:54:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 095949FA317 + for ; + Thu, 25 May 2006 17:54:22 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 31849-05 + for ; + Thu, 25 May 2006 17:54:10 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.192]) + by postgresql.org (Postfix) with ESMTP id 53DB69F9B01 + for ; + Thu, 25 May 2006 17:54:10 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id 18so1893722nzp + for ; + Thu, 25 May 2006 13:54:09 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=b9C3IXaumXeHiK4yHjpXuQZRhek4Rbr1o7j/Lek+TyShapjayILqWa6t9OT/ixrzj7YJ6oR1V8b6AiSwF3DtfVzjYpQ4348ZERFTTnMsghNLlzLz02rs4ONFQzX1r6U1TmmQ8ckP8CXWst0AYsbF4fteZM7Gn6PUdORCHra9wuc= +Received: by 10.65.248.12 with SMTP id a12mr4689187qbs; + Thu, 25 May 2006 13:54:09 -0700 (PDT) +Received: by 10.65.137.19 with HTTP; Thu, 25 May 2006 13:54:09 -0700 (PDT) +Message-ID: +Date: Thu, 25 May 2006 16:54:09 -0400 +From: "Merlin Moncure" +To: pgsql-performance@postgresql.org +Subject: Re: is it possible to make this faster? +Cc: sgunderson@bigfoot.com +In-Reply-To: <20060525203630.GA19881@uio.no> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <20060525203630.GA19881@uio.no> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/477 +X-Sequence-Number: 19264 + +On 5/25/06, Steinar H. Gunderson wrote: +> On Thu, May 25, 2006 at 04:07:19PM -0400, Merlin Moncure wrote: +> > been doing a lot of pgsql/mysql performance testing lately, and there +> > is one query that mysql does much better than pgsql...and I see it a +> > lot in normal development: +> > +> > select a,b,max(c) from t group by a,b; + +> select a,b,(select c from t t2 order by c desc where t1.a=3Dt2.a and t1= +.b=3Dt2.b) +> from t t1 group by a,b; + +this came out to a tie with the group by approach, although it +produced a different (but similar) plan. we are still orders of +magnitude behind mysql here. + +Interestingly, if I extract out the distinct values of a,b to a temp +table and rejoin to t using your approach, I get competitive times +with mysql. this means the essential problem is: + +select a,b from t group by a,b + +is slow. This feels like the same penalty for mvcc we pay with count(*)...= +hm. + +merlin + +From pgsql-performance-owner@postgresql.org Thu May 25 18:08:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D20A99F9B01 + for ; + Thu, 25 May 2006 18:08:53 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 34378-04 + for ; + Thu, 25 May 2006 18:08:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from cassarossa.samfundet.no (cassarossa.samfundet.no + [129.241.93.19]) + by postgresql.org (Postfix) with ESMTP id 0A7389F94EA + for ; + Thu, 25 May 2006 18:08:47 -0300 (ADT) +Received: from trofast.ipv6.sesse.net ([2001:700:300:dc03:20e:cff:fe36:a766] + helo=trofast.sesse.net) + by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1FjN4X-0007Nd-8C + for pgsql-performance@postgresql.org; Thu, 25 May 2006 23:08:46 +0200 +Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) + id 1FjN4c-0005Ho-00 + for ; Thu, 25 May 2006 23:08:50 +0200 +Date: Thu, 25 May 2006 23:08:50 +0200 +From: "Steinar H. Gunderson" +To: pgsql-performance@postgresql.org +Subject: Re: is it possible to make this faster? +Message-ID: <20060525210850.GA20274@uio.no> +Mail-Followup-To: pgsql-performance@postgresql.org +References: + <20060525203630.GA19881@uio.no> + +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: +X-Operating-System: Linux 2.6.16.11 on a x86_64 +X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/478 +X-Sequence-Number: 19265 + +On Thu, May 25, 2006 at 04:54:09PM -0400, Merlin Moncure wrote: +>> select a,b,(select c from t t2 order by c desc where t1.a=t2.a and +>> t1.b=t2.b) +>> from t t1 group by a,b; +> this came out to a tie with the group by approach, although it +> produced a different (but similar) plan. we are still orders of +> magnitude behind mysql here. + +Actually, it _should_ produce a syntax error -- it's missing a LIMIT 1 in the +subquery. + +/* Steinar */ +-- +Homepage: http://www.sesse.net/ + +From pgsql-performance-owner@postgresql.org Thu May 25 18:11:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C51559F9B01 + for ; + Thu, 25 May 2006 18:11:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 35348-04 + for ; + Thu, 25 May 2006 18:11:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id AD4739F94EA + for ; + Thu, 25 May 2006 18:11:41 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4PLBbew016120; + Thu, 25 May 2006 17:11:38 -0400 (EDT) +To: "Merlin Moncure" , + "Postgresql Performance" +Subject: Re: is it possible to make this faster? +In-reply-to: <15919.1148590347@sss.pgh.pa.us> +References: + <15919.1148590347@sss.pgh.pa.us> +Comments: In-reply-to Tom Lane + message dated "Thu, 25 May 2006 16:52:27 -0400" +Date: Thu, 25 May 2006 17:11:37 -0400 +Message-ID: <16119.1148591497@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/479 +X-Sequence-Number: 19266 + +Tom Lane writes: +> "Merlin Moncure" writes: +>> recent versions of mysql do much better, returning same set in < 20ms. + +> Well, since they don't do MVCC they can answer this query from the +> index without going to the heap at all. But that still seems remarkably +> fast for something that has to grovel through 300k index entries. + +Are you sure you measured that right? I tried to duplicate this using +mysql 5.0.21, and I see runtimes of 0.45 sec without an index and +0.15 sec with. This compares to psql times around 0.175 sec. Doesn't +look to me like we're hurting all that badly, even without using the +index. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu May 25 18:15:39 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E56659F9B01 + for ; + Thu, 25 May 2006 18:15:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 33839-08 + for ; + Thu, 25 May 2006 18:15:33 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id 402A79F94EA + for ; + Thu, 25 May 2006 18:15:33 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Thu, 25 May 2006 21:15:29 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 25 May 2006 16:15:29 -0500 +Subject: Re: is it possible to make this faster? +From: Scott Marlowe +To: Tom Lane +Cc: Merlin Moncure , + Postgresql Performance +In-Reply-To: <15919.1148590347@sss.pgh.pa.us> +References: + <15919.1148590347@sss.pgh.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1148591729.25526.57.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Thu, 25 May 2006 16:15:29 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/480 +X-Sequence-Number: 19267 + +On Thu, 2006-05-25 at 15:52, Tom Lane wrote: +> "Merlin Moncure" writes: +> > been doing a lot of pgsql/mysql performance testing lately, and there +> > is one query that mysql does much better than pgsql...and I see it a +> > lot in normal development: +> +> > select a,b,max(c) from t group by a,b; +> +> > t has an index on a,b,c. +> +> The index won't help, as per this comment from planagg.c: +> +> * We don't handle GROUP BY, because our current implementations of +> * grouping require looking at all the rows anyway, and so there's not +> * much point in optimizing MIN/MAX. +> +> Given the numbers you mention (300k rows in 2000 groups) I'm not +> convinced that an index-based implementation would help much; we'd +> still need to fetch at least one record out of every 150, which is +> going to cost near as much as seqscanning all of them. +> +> > recent versions of mysql do much better, returning same set in < 20ms. +> +> Well, since they don't do MVCC they can answer this query from the +> index without going to the heap at all. But that still seems remarkably +> fast for something that has to grovel through 300k index entries. + +Well, they do, just with innodb tables. + +Merlin, have you tried this against innodb tables to see what you get? + +From pgsql-performance-owner@postgresql.org Thu May 25 18:26:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1E0129F9B01 + for ; + Thu, 25 May 2006 18:26:38 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 35892-04 + for ; + Thu, 25 May 2006 18:26:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mir3-fs.mir3.com (mail.mir3.com [65.208.188.100]) + by postgresql.org (Postfix) with ESMTP id 313BA9F94EA + for ; + Thu, 25 May 2006 18:26:27 -0300 (ADT) +Received: mir3-fs.mir3.com 172.16.1.11 from 172.16.2.68 172.16.2.68 via HTTP + with MS-WebStorage 6.0.6249 +Received: from archimedes.mirlogic.com by mir3-fs.mir3.com; + 25 May 2006 14:26:24 -0700 +Subject: Re: is it possible to make this faster? +From: Mark Lewis +To: Tom Lane +Cc: Merlin Moncure , + Postgresql Performance +In-Reply-To: <15919.1148590347@sss.pgh.pa.us> +References: + <15919.1148590347@sss.pgh.pa.us> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Organization: MIR3, Inc. +Date: Thu, 25 May 2006 14:26:23 -0700 +Message-Id: <1148592384.9750.13.camel@archimedes> +Mime-Version: 1.0 +X-Mailer: Evolution 2.0.2 (2.0.2-27) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/481 +X-Sequence-Number: 19268 + +On Thu, 2006-05-25 at 16:52 -0400, Tom Lane wrote: +> "Merlin Moncure" writes: +> > been doing a lot of pgsql/mysql performance testing lately, and there +> > is one query that mysql does much better than pgsql...and I see it a +> > lot in normal development: +> +> > select a,b,max(c) from t group by a,b; +> +> > t has an index on a,b,c. +> +> The index won't help, as per this comment from planagg.c: +> +> * We don't handle GROUP BY, because our current implementations of +> * grouping require looking at all the rows anyway, and so there's not +> * much point in optimizing MIN/MAX. +> +> Given the numbers you mention (300k rows in 2000 groups) I'm not +> convinced that an index-based implementation would help much; we'd +> still need to fetch at least one record out of every 150, which is +> going to cost near as much as seqscanning all of them. + +Well, if the MySQL server has enough RAM that the index is cached (or +index + relevant chunks of data file if using InnoDB?) then that would +explain how MySQL can use an index to get fast results. + +-- Mark Lewis + +From pgsql-performance-owner@postgresql.org Thu May 25 19:13:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1BE289FA8EF + for ; + Thu, 25 May 2006 19:13:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 41907-04 + for ; + Thu, 25 May 2006 19:13:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 5EBB69F9B14 + for ; + Thu, 25 May 2006 19:13:23 -0300 (ADT) +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by svr4.postgresql.org (Postfix) with ESMTP id 3DD7F5B0FA6 + for ; + Thu, 25 May 2006 22:13:22 +0000 (GMT) +Received: from [172.16.5.75] (64-132-13-2.static.twtelecom.net [64.132.13.2]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by noel.decibel.org (Postfix) with ESMTP id 98CD256408; + Thu, 25 May 2006 17:13:09 -0500 (CDT) +In-Reply-To: <758d5e7f0605251007k284fe658m42958e13ee7971e1@mail.gmail.com> +References: <200605251631.k4PGV4O28645@panix3.panix.com> + <758d5e7f0605251007k284fe658m42958e13ee7971e1@mail.gmail.com> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: +Cc: "kynn@panix.com" , + pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Jim Nasby +Subject: Re: Optimizing a huge_table/tiny_table join +Date: Thu, 25 May 2006 17:13:07 -0500 +To: Dawid Kuroczko +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/482 +X-Sequence-Number: 19269 + +On May 25, 2006, at 12:07 PM, Dawid Kuroczko wrote: +> On 5/25/06, kynn@panix.com wrote: +>> Well, they're not my statistics; they're explain's. You mean there's +>> a bug in explain? I agree that it makes no sense that the costs +>> don't +>> differ as much as one would expect, but you can see right there the +>> numbers of rows for the two tables. At any rate, how would one go +>> about finding an explanation for these strange stats? +> +> Well, the query planner uses statistics to deduce the best plan +> possible. Explain includes this statistical data in its output. +> See: +> http://www.postgresql.org/docs/8.1/interactive/planner-stats.html +> ...for information about what it is all about. +> +> The idea is that your statistics are probably not detailed enough +> to help the planner. See ALTER TABLE SET STATISTICS to change +> that. + +http://www.pervasive-postgres.com/lp/newsletters/2006/ +Insights_postgres_Mar.asp#4 might also be worth your time to read. + +> Hmm, there is a probability (though statistics are more probable +> go) that you're using some older version of PostgreSQL, and you're +> hitting same problem as I did: +> +> http://archives.postgresql.org/pgsql-performance/2005-07/msg00345.php +> +> Tom has provided back then a patch, which fixed it: +> +> http://archives.postgresql.org/pgsql-performance/2005-07/msg00352.php +> +> ...but I don't remember when it made into release. + +According to cvs, it's been in since 8.1 and 8.0.4: + +Revision 1.111.4.2: download - view: text, markup, annotated - select +for diffs +Fri Jul 22 19:12:33 2005 UTC (10 months ago) by tgl +Branches: REL8_0_STABLE +CVS tags: REL8_0_8, REL8_0_7, REL8_0_6, REL8_0_5, REL8_0_4 +Diff to: previous 1.111.4.1: preferred, colored; branchpoint 1.111: +preferred, colored; next MAIN 1.112: preferred, colored +Changes since revision 1.111.4.1: +18 -37 lines + +Fix compare_fuzzy_path_costs() to behave a bit more sanely. The +original +coding would ignore startup cost differences of less than 1% of the +estimated total cost; which was OK for normal planning but highly not OK +if a very small LIMIT was applied afterwards, so that startup cost +becomes +the name of the game. Instead, compare startup and total costs fuzzily +but independently. This changes the plan selected for two queries in +the +regression tests; adjust expected-output files for resulting changes in +row order. Per reports from Dawid Kuroczko and Sam Mason. + +Revision 1.124: download - view: text, markup, annotated - select for +diffs +Fri Jul 22 19:12:01 2005 UTC (10 months ago) by tgl +Branches: MAIN +CVS tags: REL8_1_0BETA3, REL8_1_0BETA2, REL8_1_0BETA1 +Diff to: previous 1.123: preferred, colored +Changes since revision 1.123: +18 -37 lines + +Fix compare_fuzzy_path_costs() to behave a bit more sanely. The +original +coding would ignore startup cost differences of less than 1% of the +estimated total cost; which was OK for normal planning but highly not OK +if a very small LIMIT was applied afterwards, so that startup cost +becomes +the name of the game. Instead, compare startup and total costs fuzzily +but independently. This changes the plan selected for two queries in +the +regression tests; adjust expected-output files for resulting changes in +row order. Per reports from Dawid Kuroczko and Sam Mason. + +-- +Jim C. Nasby, Database Architect decibel@decibel.org +Give your computer some brain candy! www.distributed.net Team #1828 + +Windows: "Where do you want to go today?" +Linux: "Where do you want to go tomorrow?" +FreeBSD: "Are you guys coming, or what?" + + + +From pgsql-performance-owner@postgresql.org Thu May 25 19:17:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 64AE79FA278 + for ; + Thu, 25 May 2006 19:17:53 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 42700-08 + for ; + Thu, 25 May 2006 19:17:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 9B7C19F9B14 + for ; + Thu, 25 May 2006 19:17:47 -0300 (ADT) +Received: from [172.16.5.75] (64-132-13-2.static.twtelecom.net [64.132.13.2]) + (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by noel.decibel.org (Postfix) with ESMTP id 185DA56408; + Thu, 25 May 2006 17:17:46 -0500 (CDT) +In-Reply-To: <16119.1148591497@sss.pgh.pa.us> +References: + <15919.1148590347@sss.pgh.pa.us> <16119.1148591497@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <346F1F9F-10E6-43F7-80E4-0DE989E5D760@pervasive.com> +Cc: "Merlin Moncure" , + "Postgresql Performance" +Content-Transfer-Encoding: 7bit +From: Jim Nasby +Subject: Re: is it possible to make this faster? +Date: Thu, 25 May 2006 17:17:43 -0500 +To: Tom Lane +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/483 +X-Sequence-Number: 19270 + +On May 25, 2006, at 4:11 PM, Tom Lane wrote: +> Tom Lane writes: +>> "Merlin Moncure" writes: +>>> recent versions of mysql do much better, returning same set in < +>>> 20ms. +> +>> Well, since they don't do MVCC they can answer this query from the +>> index without going to the heap at all. But that still seems +>> remarkably +>> fast for something that has to grovel through 300k index entries. +> +> Are you sure you measured that right? I tried to duplicate this using +> mysql 5.0.21, and I see runtimes of 0.45 sec without an index and +> 0.15 sec with. This compares to psql times around 0.175 sec. Doesn't +> look to me like we're hurting all that badly, even without using the +> index. + +Well, that would depend greatly on how wide the rows were, and I +don't believe the OP ever mentioned that. If he's got a nice, fat +varchar(1024) in that table, then it's not surprising that an index +would help things. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + + + +From pgsql-performance-owner@postgresql.org Thu May 25 19:30:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 207409FA2FA + for ; + Thu, 25 May 2006 19:30:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 43787-05 + for ; + Thu, 25 May 2006 19:30:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 8F6BE9FA278 + for ; + Thu, 25 May 2006 19:30:37 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4PMUYxm016780; + Thu, 25 May 2006 18:30:34 -0400 (EDT) +To: Jim Nasby +cc: "Merlin Moncure" , + "Postgresql Performance" +Subject: Re: is it possible to make this faster? +In-reply-to: <346F1F9F-10E6-43F7-80E4-0DE989E5D760@pervasive.com> +References: + <15919.1148590347@sss.pgh.pa.us> <16119.1148591497@sss.pgh.pa.us> + <346F1F9F-10E6-43F7-80E4-0DE989E5D760@pervasive.com> +Comments: In-reply-to Jim Nasby + message dated "Thu, 25 May 2006 17:17:43 -0500" +Date: Thu, 25 May 2006 18:30:34 -0400 +Message-ID: <16779.1148596234@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/484 +X-Sequence-Number: 19271 + +Jim Nasby writes: +> On May 25, 2006, at 4:11 PM, Tom Lane wrote: +>> Are you sure you measured that right? I tried to duplicate this using +>> mysql 5.0.21, and I see runtimes of 0.45 sec without an index and +>> 0.15 sec with. This compares to psql times around 0.175 sec. Doesn't +>> look to me like we're hurting all that badly, even without using the +>> index. + +> Well, that would depend greatly on how wide the rows were, and I +> don't believe the OP ever mentioned that. If he's got a nice, fat +> varchar(1024) in that table, then it's not surprising that an index +> would help things. + +Wide rows might slow down the psql side of things somewhat (though +probably not as much as you think). That doesn't account for the +discrepancy in our mysql results though. + +For the record, I was testing with a table like + create table t(a int, b int, c int); + create index ti on t(a,b,c); + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Thu May 25 20:28:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BD4299FA278 + for ; + Thu, 25 May 2006 20:27:59 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 51893-06 + for ; + Thu, 25 May 2006 20:27:48 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-5.paradise.net.nz (bm-5a.paradise.net.nz + [203.96.152.184]) + by postgresql.org (Postfix) with ESMTP id 1B39B9F9B14 + for ; + Thu, 25 May 2006 20:27:47 -0300 (ADT) +Received: from smtp-3.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-5.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IZU00NEWH684G@linda-5.paradise.net.nz> for + pgsql-performance@postgresql.org; Fri, 26 May 2006 11:27:45 +1200 (NZST) +Received: from [192.168.1.11] + (218-101-29-172.dsl.clear.net.nz [218.101.29.172]) by + smtp-3.paradise.net.nz (Postfix) with ESMTP id 7560814D423E; + Fri, 26 May 2006 11:27:44 +1200 (NZST) +Date: Fri, 26 May 2006 11:27:09 +1200 +From: Mark Kirkwood +Subject: Re: Optimizing a huge_table/tiny_table join +In-reply-to: <7082.1148521319@sss.pgh.pa.us> +To: kynn@panix.com +Cc: Tom Lane , pgsql-performance@postgresql.org +Message-id: <44763D4D.6090305@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +User-Agent: Thunderbird 1.5 (X11/20060417) +References: <200605250052.k4P0qrT11965@panix3.panix.com> + <7082.1148521319@sss.pgh.pa.us> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/485 +X-Sequence-Number: 19272 + +Tom Lane wrote: +> writes: +>> Limit (cost=19676.75..21327.99 rows=6000 width=84) +>> -> Hash Join (cost=19676.75..1062244.81 rows=3788315 width=84) +>> Hash Cond: (upper(("outer".id)::text) = upper(("inner".id)::text)) +>> -> Seq Scan on huge_table h (cost=0.00..51292.43 rows=2525543 width=46) +>> -> Hash (cost=19676.00..19676.00 rows=300 width=38) +>> -> Seq Scan on tiny_table t (cost=0.00..19676.00 rows=300 width=38) +> +> Um, if huge_table is so much bigger than tiny_table, why are the cost +> estimates for seqscanning them only about 2.5x different? There's +> something wacko about your statistics, methinks. +> + +This suggests that tiny_table is very wide (i.e a lot of columns +compared to huge_table), or else has thousands of dead tuples. + +Do you want to post the descriptions for these tables? + +If you are running 8.1.x, then the output of 'ANALYZE VERBOSE +tiny_table' is of interest too. + +If you are running a pre-8.1 release, then lets see 'VACUUM VERBOSE +tiny_table'. + +Note that after either of these, your plans may be altered (as ANALYZE +will recompute your stats for tiny_table, and VACUUM may truncate pages +full of dead tuples at the end of it)! + + +From pgsql-performance-owner@postgresql.org Thu May 25 22:26:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 696289F9B14 + for ; + Thu, 25 May 2006 22:26:01 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 07308-02 + for ; + Thu, 25 May 2006 22:25:56 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from houston.familyhealth.com.au (houston.au.fhnetwork.com + [203.22.197.21]) + by postgresql.org (Postfix) with ESMTP id AEA1C9FA278 + for ; + Thu, 25 May 2006 22:25:56 -0300 (ADT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id BB1242573A; + Fri, 26 May 2006 09:25:54 +0800 (WST) +Received: from [127.0.0.1] (work-48.internal [192.168.0.48]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 8FDE525723; + Fri, 26 May 2006 09:25:51 +0800 (WST) +Message-ID: <44765AC8.5060003@calorieking.com> +Date: Fri, 26 May 2006 09:32:56 +0800 +From: Christopher Kings-Lynne +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: Tom Lane +Cc: Chris Mair , pgsql-performance@postgresql.org +Subject: Re: lowering priority automatically at connection +References: <1148573784.6017.26.camel@dell.home.lan> + <13758.1148574403@sss.pgh.pa.us> +In-Reply-To: <13758.1148574403@sss.pgh.pa.us> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chris.kings-lynne@calorieking.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/486 +X-Sequence-Number: 19273 + +> That guy doesn't actually have the foggiest idea what he's doing. +> The reason there is no built-in capability to do that is that it *does +> not work well*. Search the list archives for "priority inversion" to +> find out why not. + +http://en.wikipedia.org/wiki/Priority_inversion + + +From pgsql-performance-owner@postgresql.org Fri May 26 00:10:19 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 455C79FA278 + for ; + Fri, 26 May 2006 00:10:18 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 25137-04 + for ; + Fri, 26 May 2006 00:10:11 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from insiderscore.com (mail01.insiderscore.com [69.84.139.233]) + by postgresql.org (Postfix) with ESMTP id C3F039F9B14 + for ; + Fri, 26 May 2006 00:10:11 -0300 (ADT) +Received: from jefftrout.com (pool-71-248-161-225.bstnma.fios.verizon.net + [71.248.161.225]) + by insiderscore.com (Postfix) with SMTP id 005D011C429B + for ; + Thu, 25 May 2006 23:10:09 -0400 (EDT) +Received: (qmail 58016 invoked from network); 26 May 2006 03:10:52 -0000 +Received: from pool-71-248-161-225.bstnma.fios.verizon.net (HELO + ?10.10.10.102?) (71.248.161.225) + by 192.168.0.101 with SMTP; 26 May 2006 03:10:52 -0000 +Mime-Version: 1.0 (Apple Message framework v750) +In-Reply-To: <20060525203630.GA19881@uio.no> +References: + <20060525203630.GA19881@uio.no> +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <8720F349-98E6-4420-B81F-ABB85EA0F3CB@torgo.978.org> +Content-Transfer-Encoding: 7bit +From: Jeff - +Subject: Re: is it possible to make this faster? +Date: Thu, 25 May 2006 23:10:08 -0400 +To: pgsql-performance@postgresql.org +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/487 +X-Sequence-Number: 19274 + +Also, are you sure your numbers are not coming out of the mysql query +cache? + +That might explain some of it - also with Tom seeing comprable +numbers in his test. + +-- +Jeff Trout +http://www.jefftrout.com/ +http://www.stuarthamm.net/ + + + + + +From pgsql-performance-owner@postgresql.org Fri May 26 00:29:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 708099FA2FA + for ; + Fri, 26 May 2006 00:29:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 26467-04 + for ; + Fri, 26 May 2006 00:29:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 2A1519FA278 + for ; + Fri, 26 May 2006 00:29:22 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4Q3TLWe018693; + Thu, 25 May 2006 23:29:21 -0400 (EDT) +To: Jeff - +cc: pgsql-performance@postgresql.org +Subject: Re: is it possible to make this faster? +In-reply-to: <8720F349-98E6-4420-B81F-ABB85EA0F3CB@torgo.978.org> +References: + <20060525203630.GA19881@uio.no> + <8720F349-98E6-4420-B81F-ABB85EA0F3CB@torgo.978.org> +Comments: In-reply-to Jeff - + message dated "Thu, 25 May 2006 23:10:08 -0400" +Date: Thu, 25 May 2006 23:29:21 -0400 +Message-ID: <18692.1148614161@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/488 +X-Sequence-Number: 19275 + +Jeff - writes: +> Also, are you sure your numbers are not coming out of the mysql query +> cache? +> That might explain some of it - also with Tom seeing comprable +> numbers in his test. + +Indeed, enabling the mysql query cache makes the timings drop to +nil ... as long as I present a query that's strcmp-equal to the +last one (not different in whitespace for instance). + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri May 26 01:47:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E65E19FA16E + for ; + Fri, 26 May 2006 01:47:45 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 35445-08 + for ; + Fri, 26 May 2006 01:47:36 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.204]) + by postgresql.org (Postfix) with ESMTP id 56AE49F9EEB + for ; + Fri, 26 May 2006 01:47:36 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id 18so1977919nzp + for ; + Thu, 25 May 2006 21:47:35 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=Rlz6+sR+bmmvyuacgl3C6pixluAflKi5x0fST3BtiMb2uhh1mYndqN/AgotPNyziXLX3fYVIXfHYh5Z8Tap0TrLhJlE/TcEFzn699hFnc+piXqLE1ZvZEmoFRisFpvOnIqBPBA2oMBB7Y3zKrJLbSNcILpA8tRNKIMhoX6mbiuI= +Received: by 10.64.114.10 with SMTP id m10mr1358754qbc; + Thu, 25 May 2006 21:47:35 -0700 (PDT) +Received: by 10.65.137.19 with HTTP; Thu, 25 May 2006 21:47:35 -0700 (PDT) +Message-ID: +Date: Fri, 26 May 2006 00:47:35 -0400 +From: "Merlin Moncure" +To: "Postgresql Performance" +Subject: Re: is it possible to make this faster? +In-Reply-To: <16119.1148591497@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <15919.1148590347@sss.pgh.pa.us> <16119.1148591497@sss.pgh.pa.us> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/489 +X-Sequence-Number: 19276 + +On 5/25/06, Tom Lane wrote: +> Tom Lane writes: +> > "Merlin Moncure" writes: +> >> recent versions of mysql do much better, returning same set in < 20ms. + +> Are you sure you measured that right? I tried to duplicate this using +> mysql 5.0.21, and I see runtimes of 0.45 sec without an index and +> 0.15 sec with. This compares to psql times around 0.175 sec. Doesn't +> look to me like we're hurting all that badly, even without using the +> index. + +Well, my numbers were approximate, but I tested on a few different +machines. the times got closer as the cpu speed got faster. pg +really loves a quick cpu. on 600 mhz p3 I got 70ms on mysql and +1050ms on pg. Mysql query cache is always off for my performance +testing. + +My a and b columns were ID columns from another table, so I rewrote +the join and now pg is smoking mysql (again). + +To quickly answer the other questions: + +1. no, not testing innodb +2, rows are narrow + +Merlin + +From pgsql-performance-owner@postgresql.org Fri May 26 07:26:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A59AA9FA7BA + for ; + Fri, 26 May 2006 07:26:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 76909-09 + for ; + Fri, 26 May 2006 07:26:48 -0300 (ADT) +X-Greylist: delayed 00:29:47.045594 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id D0C2C9FA2E6 + for ; + Fri, 26 May 2006 07:26:48 -0300 (ADT) +Received: from ctb-mesg7.saix.net (ctb-mesg7.saix.net [196.25.240.77]) + by svr4.postgresql.org (Postfix) with ESMTP id 671F55B09CE + for ; + Fri, 26 May 2006 09:56:59 +0000 (GMT) +Received: from [192.168.0.8] (dsl-146-254-85.telkomadsl.co.za + [165.146.254.85]) + by ctb-mesg7.saix.net (Postfix) with ESMTP id 94C8C3BC1 + for ; + Fri, 26 May 2006 11:56:54 +0200 (SAST) +Message-ID: <4476D0D7.1080006@silversphere.co.za> +Date: Fri, 26 May 2006 11:56:39 +0200 +From: James Neethling +Reply-To: pgsql-performance@postgresql.org +User-Agent: 1.5 (X11/20060309) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: column totals +Content-Type: multipart/mixed; boundary="------------040003010701040104030006" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/490 +X-Sequence-Number: 19277 + +This is a multi-part message in MIME format. +--------------040003010701040104030006 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Hi There, + +I've got a situation where I need to pull profit information by product +category, as well as the totals for each branch. + +Basically, something like + +SELECT branch_id, prod_cat_id, sum(prod_profit) as prod_cat_profit + FROM () as b1 +WHERE x = y +GROUP BY branch, prod_cat_id + + +Now, I also need the branch total, effectively, +SELECT branch_id, sum(prod_profit) as branch_total + FROM () as b1 +WHERE x = y +GROUP BY branch_id. + + +Since the actual queries for generating prod_profit are non-trivial, how +do I combine them to get the following select list? + +Or is there a more efficient way? + +Kind Regards, +James + + + +--------------040003010701040104030006 +Content-Type: text/x-vcard; charset=utf-8; + name="james.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="james.vcf" + +begin:vcard +fn:James Neethling +n:Neethling;James +org:Silver Sphere Business Solutions +adr:Centurion Business Park A2;;25633 Democracy Way;Prosperity Park;Milnerton;Cape Town;7441 +email;internet:james@silversphere.co.za +title:Managing Member +tel;work:27 21 552 7108 +tel;fax:27 21 552 7106 +tel;cell:27 83 399 2799 +x-mozilla-html:FALSE +url:http://www.silversphere.co.za +version:2.1 +end:vcard + + +--------------040003010701040104030006-- + +From pgsql-performance-owner@postgresql.org Tue May 30 17:56:44 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D164C9FA279 + for ; + Fri, 26 May 2006 09:11:48 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 07855-01 + for ; + Fri, 26 May 2006 09:11:40 -0300 (ADT) +X-Greylist: delayed 00:06:37.498503 by SQLgrey- +Received: from smtp-31.ig.com.br (smtp-31.ig.com.br [200.226.132.31]) + by postgresql.org (Postfix) with ESMTP id DDF579F9B01 + for ; + Fri, 26 May 2006 09:11:39 -0300 (ADT) +Received: (qmail 31784 invoked from network); 26 May 2006 12:04:56 -0000 +Received: from 70.131.226.200.in-addr.arpa.ig.com.br (HELO + localhost.localdomain) ([200.226.131.70]) + (envelope-sender ) + by email-31.ig.com.br (qmail-ldap-1.03) with SMTP + for ; 26 May 2006 12:04:56 -0000 +To: pgsql-performance@postgresql.org +From: wmiro@ig.com.br +Subject: Why the 8.1 plan is worst than 7.4? +Date: Fri, 26 May 2006 09:04:56 -0300 +X-Priority: 3 (Normal) +Message-ID: <20060526_120456_040065.wmiro@ig.com.br> +X-Originating-IP: [10.17.1.70]192.168.3.243, 200.171.147.216 +X-Mailer: iGMail [www.ig.com.br] +X-user: wmiro@ig.com.br +Teste: asaes +MIME-Version: 1.0 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Spam-Status: No, hits=2.024 tagged_above=0 required=5 tests=BAYES_20, + DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FORGED_RCVD_HELO, + RCVD_IN_NJABL_PROXY +X-Spam-Level: ** +Content-Description: Mail message body +Content-Type: text/plain; charset=ISO-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +X-Archive-Number: 200605/543 +X-Sequence-Number: 19330 + +Hi, + +I have 2 servers, one of them has a 7.4 postgres and the other has a 8.1 + +I have this query: + +select fagrempr,fagrdocr,fagrserr,fagrparr +from arqcfat +left join arqfagr on fagrorig = 'CFAT' and fagrdocu = cfatdocu and fagrempe += cfatempe and fagrseri = cfatseri +where cfatdata between '2006-01-01' and '2006-01-31' +and cfattipo = 'VD' +and cfatstat <> 'C' +and fagrform = 'CT' +and fagrtipr = 'REC' +group by fagrempr,fagrdocr,fagrserr,fagrparr + +The 8.1 give me this plan: + + HashAggregate (cost=59.07..59.08 rows=1 width=20) + -> Nested Loop (cost=0.00..59.06 rows=1 width=20) + -> Index Scan using arqfagr_arqfa3_key on arqfagr +(cost=0.00..53.01 rows=1 width=36) + Index Cond: ((fagrorig = 'CFAT'::bpchar) AND (fagrform = +'CT'::bpchar)) + Filter: (fagrtipr = 'REC'::bpchar) + -> Index Scan using arqcfat_arqcfat1_key on arqcfat +(cost=0.00..6.03 rows=1 width=16) + Index Cond: (("outer".fagrempe = arqcfat.cfatempe) AND +("outer".fagrdocu = arqcfat.cfatdocu) AND ("outer".fagrseri = +arqcfat.cfatseri)) + Filter: ((cfatdata >= '01-01-2006'::date) AND (cfatdata <= +'31-01-2006'::date) AND (cfattipo = 'VD'::bpchar) AND (cfatstat <> +'C'::bpchar)) + +The 7.4 give me this plan: + +HashAggregate (cost=2163.93..2163.93 rows=1 width=19) + -> Nested Loop (cost=0.00..2163.92 rows=1 width=19) + -> Index Scan using arqcfat_arqcfat2_key on arqcfat +(cost=0.00..2145.78 rows=3 width=15) + Index Cond: ((cfatdata >= '01-01-2006'::date) AND (cfatdata +<= '31-01-2006'::date)) + Filter: ((cfattipo = 'VD'::bpchar) AND (cfatstat <> +'C'::bpchar)) + -> Index Scan using arqfagr_arqfa1_key on arqfagr +(cost=0.00..6.03 rows=1 width=34) + Index Cond: ((arqfagr.fagrorig = 'CFAT'::bpchar) AND +(arqfagr.fagrempe = "outer".cfatempe) AND (arqfagr.fagrdocu = +"outer".cfatdocu) AND (arqfagr.fagrseri = "outer".cfatseri)) + Filter: ((fagrform = 'CT'::bpchar) AND (fagrtipr = +'REC'::bpchar)) + +Why the plan is worst in postgres 8.1? + +I know the best plan is read fisrt the table which has a date index as the +7.4 did, because in a few days I will have few lines too, so the query will +be faster. + +Is there some thing I have to change in 8.1 to make the plans as the 7.4? + +Thanks , + +Waldomiro C. Neto. + + + +From pgsql-performance-owner@postgresql.org Fri May 26 10:20:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1B70F9FA42B + for ; + Fri, 26 May 2006 10:20:16 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 40429-01 + for ; + Fri, 26 May 2006 10:20:09 -0300 (ADT) +X-Greylist: delayed 03:23:08.398908 by SQLgrey- +Received: from ctb-mesg7.saix.net (ctb-mesg7.saix.net [196.25.240.77]) + by postgresql.org (Postfix) with ESMTP id 744F19FA279 + for ; + Fri, 26 May 2006 10:20:09 -0300 (ADT) +Received: from [192.168.0.8] (dsl-146-254-85.telkomadsl.co.za + [165.146.254.85]) + by ctb-mesg7.saix.net (Postfix) with ESMTP id F21D75E5D + for ; + Fri, 26 May 2006 15:20:06 +0200 (SAST) +Message-ID: <44770077.8010506@silversphere.co.za> +Date: Fri, 26 May 2006 15:19:51 +0200 +From: James Neethling +User-Agent: 1.5 (X11/20060309) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Re: column totals +References: <4476D0D7.1080006@silversphere.co.za> +In-Reply-To: <4476D0D7.1080006@silversphere.co.za> +Content-Type: multipart/mixed; boundary="------------000807050705010609010201" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/491 +X-Sequence-Number: 19278 + +This is a multi-part message in MIME format. +--------------000807050705010609010201 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + + + +James Neethling wrote: +> Hi There, +> +> I've got a situation where I need to pull profit information by +> product category, as well as the totals for each branch. +> +> Basically, something like +> +> SELECT branch_id, prod_cat_id, sum(prod_profit) as prod_cat_profit +> FROM () as b1 +> WHERE x = y +> GROUP BY branch, prod_cat_id +> +> +> Now, I also need the branch total, effectively, +> SELECT branch_id, sum(prod_profit) as branch_total +> FROM () as b1 +> WHERE x = y +> GROUP BY branch_id. +> +> +> Since the actual queries for generating prod_profit are non-trivial, +> how do I combine them to get the following select list? +SELECT branch_id, prod_cat_id, sum(prod_profit) as prod_cat_profit, +sum(prod_profit) as branch_total +> +> Or is there a more efficient way? +> +> Kind Regards, +> James +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 4: Have you searched our list archives? +> +> http://archives.postgresql.org +> + +--------------000807050705010609010201 +Content-Type: text/x-vcard; charset=utf-8; + name="james.vcf" +Content-Transfer-Encoding: 7bit +Content-Disposition: attachment; + filename="james.vcf" + +begin:vcard +fn:James Neethling +n:Neethling;James +org:Silver Sphere Business Solutions +adr:Centurion Business Park A2;;25633 Democracy Way;Prosperity Park;Milnerton;Cape Town;7441 +email;internet:james@silversphere.co.za +title:Managing Member +tel;work:27 21 552 7108 +tel;fax:27 21 552 7106 +tel;cell:27 83 399 2799 +x-mozilla-html:FALSE +url:http://www.silversphere.co.za +version:2.1 +end:vcard + + +--------------000807050705010609010201-- + +From pgsql-performance-owner@postgresql.org Fri May 26 11:22:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9941C9FA279 + for ; + Fri, 26 May 2006 11:22:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 52216-07 + for ; + Fri, 26 May 2006 11:22:40 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 07BC99F9B01 + for ; + Fri, 26 May 2006 11:22:40 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4QEMc1E025669; + Fri, 26 May 2006 10:22:38 -0400 (EDT) +To: "Merlin Moncure" +cc: "Postgresql Performance" +Subject: Re: is it possible to make this faster? +In-reply-to: +References: + <15919.1148590347@sss.pgh.pa.us> <16119.1148591497@sss.pgh.pa.us> + +Comments: In-reply-to "Merlin Moncure" + message dated "Fri, 26 May 2006 00:47:35 -0400" +Date: Fri, 26 May 2006 10:22:38 -0400 +Message-ID: <25668.1148653358@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/492 +X-Sequence-Number: 19279 + +"Merlin Moncure" writes: +> On 5/25/06, Tom Lane wrote: +>> "Merlin Moncure" writes: +>>> recent versions of mysql do much better, returning same set in < 20ms. + +>> Are you sure you measured that right? I tried to duplicate this using +>> mysql 5.0.21, and I see runtimes of 0.45 sec without an index and +>> 0.15 sec with. This compares to psql times around 0.175 sec. Doesn't +>> look to me like we're hurting all that badly, even without using the +>> index. + +> Well, my numbers were approximate, but I tested on a few different +> machines. the times got closer as the cpu speed got faster. pg +> really loves a quick cpu. on 600 mhz p3 I got 70ms on mysql and +> 1050ms on pg. Mysql query cache is always off for my performance +> testing. + +Well, this bears looking into, because I couldn't get anywhere near 20ms +with mysql. I was using a dual Xeon 2.8GHz machine which ought to be +quick enough, and the stock Fedora Core 5 RPM of mysql. (Well, actually +that SRPM built on FC4, because this machine is still on FC4.) I made a +MyISAM table with three integer columns as mentioned, and filled it with +about 300000 rows with 2000 distinct values of (a,b) and random values +of c. I checked the timing both in the mysql CLI, and with a trivial +test program that timed mysql_real_query() plus mysql_store_result(), +getting pretty near the same timings each way. + +BTW, in pgsql it helps a whole lot to raise work_mem a bit for this +example --- at default work_mem it wants to do sort + group_aggregate, +while with work_mem 2000 or more it'll use a hash_aggregate plan which +is quite a bit faster. + +It seems possible that there is some equivalently simple tuning on the +mysql side that you did and I didn't. This is an utterly stock mysql +install, just "rpm -i" and "service mysqld start". + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri May 26 13:23:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C3C3E9FA218 + for ; + Fri, 26 May 2006 13:23:24 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 69448-01 + for ; + Fri, 26 May 2006 13:23:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx1.ipf.is (benz.ipf.is [85.197.192.156]) + by postgresql.org (Postfix) with ESMTP id 8D07D9FA12E + for ; + Fri, 26 May 2006 13:23:17 -0300 (ADT) +Received: (qmail 12374 invoked by uid 1010); 26 May 2006 16:21:18 +0000 +Received: from 85.197.216.186 by benz (envelope-from , + uid 1008) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1235. spamassassin: 3.1.1. perlscan: 1.25-st-qms. + Clear:RC:1(85.197.216.186):SA:0(-4.2/4.5):. + Processed in 0.7405 secs); 26 May 2006 16:21:18 -0000 +X-Antivirus-IPF-Mail-From: gnari@hive.is via benz +X-Antivirus-IPF: 1.25-st-qms (Clear:RC:1(85.197.216.186):SA:0(-4.2/4.5):. + Processed in 0.7405 secs Process 12357) +Received: from dsl-216-186.hive.is (HELO ?192.168.1.34?) (85.197.216.186) + by mx1.ipf.is with SMTP; 26 May 2006 16:21:17 +0000 +Subject: Re: column totals +From: Ragnar +To: pgsql-performance@postgresql.org +In-Reply-To: <4476D0D7.1080006@silversphere.co.za> +References: <4476D0D7.1080006@silversphere.co.za> +Content-Type: text/plain; charset=ISO-8859-1 +Date: Fri, 26 May 2006 16:23:37 +0000 +Message-Id: <1148660617.8566.51.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/493 +X-Sequence-Number: 19280 + +On f�s, 2006-05-26 at 11:56 +0200, James Neethling wrote: + +> SELECT branch_id, prod_cat_id, sum(prod_profit) as prod_cat_profit +> FROM () as b1 +> WHERE x = y +> GROUP BY branch, prod_cat_id +> +> +> Now, I also need the branch total, effectively, +> SELECT branch_id, sum(prod_profit) as branch_total +> FROM () as b1 +> WHERE x = y +> GROUP BY branch_id. +> +> +> Since the actual queries for generating prod_profit are non-trivial, how +> do I combine them to get the following select list? + +one simple way using temp table and 2 steps: + +CREATE TEMP TABLE foo AS + SELECT branch_id, + prod_cat_id, + sum(prod_profit) as prod_cat_profit + FROM () as b1 + WHERE x = y + GROUP BY branch, prod_cat_id; + +SELECT branch_id, + prod_cat_id, + prod_cat_profit, + branch_total +FROM foo as foo1 + JOIN + (SELECT branch_id, + sum(prod_cat_profit) as branch_total + FROM foo + GROUP BY branch_id + ) as foo2 USING branch_id; + + +(untested) + +gnari + + + +From pgsql-performance-owner@postgresql.org Fri May 26 13:57:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C28049FA1F1 + for ; + Fri, 26 May 2006 13:57:28 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 72193-06 + for ; + Fri, 26 May 2006 13:57:19 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wr-out-0506.google.com (wr-out-0506.google.com + [64.233.184.224]) + by postgresql.org (Postfix) with ESMTP id C2AFA9FA12E + for ; + Fri, 26 May 2006 13:57:18 -0300 (ADT) +Received: by wr-out-0506.google.com with SMTP id i31so112063wra + for ; + Fri, 26 May 2006 09:57:17 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=GztsXYNYNmxj0CRh5w9YmVkK8kqes9nBQCGxP/5cqPphLz51DvEf108wuGsq7XygAkw76NfgiE3l4toAjk5vZgvwREfNUfHvKemv8iQTWfKJZ7uyYXx/SbC1MJpo1SQ8MYXMrfSpTmQy9lZGCEBLObBTHwVLWyyuxWUsWuDp4tw= +Received: by 10.64.241.8 with SMTP id o8mr560678qbh; + Fri, 26 May 2006 09:56:44 -0700 (PDT) +Received: by 10.65.137.19 with HTTP; Fri, 26 May 2006 09:56:44 -0700 (PDT) +Message-ID: +Date: Fri, 26 May 2006 12:56:44 -0400 +From: "Merlin Moncure" +To: "Tom Lane" +Subject: Re: is it possible to make this faster? +Cc: "Postgresql Performance" +In-Reply-To: <25668.1148653358@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <15919.1148590347@sss.pgh.pa.us> <16119.1148591497@sss.pgh.pa.us> + + <25668.1148653358@sss.pgh.pa.us> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/494 +X-Sequence-Number: 19281 + +On 5/26/06, Tom Lane wrote: +> Well, this bears looking into, because I couldn't get anywhere near 20ms +> with mysql. I was using a dual Xeon 2.8GHz machine which ought to be + +did you have a key on a,b,c? if I include unimportant unkeyed field d +the query time drops from 70ms to ~ 1 second. mysql planner is +tricky, it's full of special case optimizations... + +select count(*) from (select a,b,max(c) group by a,b) q; +blows the high performance case as does putting the query in a view. + +mysql> select version(); ++-----------+ +| version() | ++-----------+ +| 5.0.16 | ++-----------+ +1 row in set (0.00 sec) + +mysql> set global query_cache_size =3D 0; +Query OK, 0 rows affected (0.00 sec) + +mysql> select user_id, acc_id, max(sample_date) from usage_samples group by= + 1,2 +[...] ++---------+--------+------------------+ +939 rows in set (0.07 sec) + +mysql> select user_id, acc_id, max(sample_date) from usage_samples group by= + 1,2 +[...] ++---------+--------+------------------+--------------+ +939 rows in set (1.39 sec) + +merlin + +From pgsql-performance-owner@postgresql.org Fri May 26 14:07:48 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id CA3CB9FA218 + for ; + Fri, 26 May 2006 14:07:47 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 75106-01 + for ; + Fri, 26 May 2006 14:07:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 31EB79FA12E + for ; + Fri, 26 May 2006 14:07:42 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4QH7d4O027138; + Fri, 26 May 2006 13:07:39 -0400 (EDT) +To: "Merlin Moncure" +cc: "Postgresql Performance" +Subject: Re: is it possible to make this faster? +In-reply-to: +References: + <15919.1148590347@sss.pgh.pa.us> <16119.1148591497@sss.pgh.pa.us> + + <25668.1148653358@sss.pgh.pa.us> + +Comments: In-reply-to "Merlin Moncure" + message dated "Fri, 26 May 2006 12:56:44 -0400" +Date: Fri, 26 May 2006 13:07:39 -0400 +Message-ID: <27137.1148663259@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/495 +X-Sequence-Number: 19282 + +"Merlin Moncure" writes: +> did you have a key on a,b,c? + +Yeah, I did + create index t1i on t1 (a,b,c); +Do I need to use some other syntax to get it to work? + +> select count(*) from (select a,b,max(c) group by a,b) q; +> blows the high performance case as does putting the query in a view. + +I noticed that too, while trying to suppress the returning of the +results for timing purposes ... still a few bugs in their optimizer +obviously. (Curiously, EXPLAIN still claims that the index is being +used.) + +> mysql> select user_id, acc_id, max(sample_date) from usage_samples group by 1,2 +> [...] +> +---------+--------+------------------+ +> 939 rows in set (0.07 sec) + +> mysql> select user_id, acc_id, max(sample_date) from usage_samples group by 1,2 +> [...] +> +---------+--------+------------------+--------------+ +> 939 rows in set (1.39 sec) + +I don't understand what you did differently in those two cases? +Or was there a DROP INDEX between? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Fri May 26 14:47:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 1A1219FA1F1 + for ; + Fri, 26 May 2006 14:47:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 82663-02 + for ; + Fri, 26 May 2006 14:47:03 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wr-out-0506.google.com (wr-out-0506.google.com + [64.233.184.228]) + by postgresql.org (Postfix) with ESMTP id AAD0A9FA12E + for ; + Fri, 26 May 2006 14:47:03 -0300 (ADT) +Received: by wr-out-0506.google.com with SMTP id 50so121155wri + for ; + Fri, 26 May 2006 10:47:02 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=GCHkheQosdAWs9DbT2mdqJr6Olh2gONWr+47w4t0z5Ji+wFDE1B0nMOSo2osRbvgIc40DoR9gtrUH8kr2tXDcg50YXWmSPXDy3RZNiDcQbmlZbamejTGkbQbTTWUXLPFdMMDTGjkXIiEUp8VZI/GoJzddX1oaZmHja7M5N9VHvQ= +Received: by 10.64.181.17 with SMTP id d17mr602769qbf; + Fri, 26 May 2006 10:46:30 -0700 (PDT) +Received: by 10.65.137.19 with HTTP; Fri, 26 May 2006 10:46:30 -0700 (PDT) +Message-ID: +Date: Fri, 26 May 2006 13:46:30 -0400 +From: "Merlin Moncure" +To: "Tom Lane" +Subject: Re: is it possible to make this faster? +Cc: "Postgresql Performance" +In-Reply-To: <27137.1148663259@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <15919.1148590347@sss.pgh.pa.us> <16119.1148591497@sss.pgh.pa.us> + + <25668.1148653358@sss.pgh.pa.us> + + <27137.1148663259@sss.pgh.pa.us> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/496 +X-Sequence-Number: 19283 + +On 5/26/06, Tom Lane wrote: +> "Merlin Moncure" writes: +> > did you have a key on a,b,c? +> Yeah, I did +> create index t1i on t1 (a,b,c); +> Do I need to use some other syntax to get it to work? + +can't thing of anything, I'm running completely stock, did you do a +optimize table foo? is the wind blowing in the right direction? + +> > select count(*) from (select a,b,max(c) group by a,b) q; +> > blows the high performance case as does putting the query in a view. + +> I noticed that too, while trying to suppress the returning of the +> results for timing purposes ... still a few bugs in their optimizer +> obviously. (Curiously, EXPLAIN still claims that the index is being +> used.) + +well, they do some tricky things pg can't do for architectural reasons +but the special case is obviously hard to get right. I suppose this +kinda agrues against doing all kinds of acrobatics to optimize mvcc +weak cases like the above and count(*)...better to make heap access as +quick as possible. + +> > mysql> select user_id, acc_id, max(sample_date) from usage_samples grou= +p by 1,2 +> > 939 rows in set (0.07 sec) + +> > mysql> select user_id, acc_id, max(sample_date) from usage_samples grou= +p by 1,2 +> > 939 rows in set (1.39 sec) + +oops, pasted the wrong query..case 2 should have been +select user_id, acc_id, max(sample_date), disksize from usage_samples +group by 1,2 +illustrating what going to the heap does to the time. + +merlin + +From pgsql-performance-owner@postgresql.org Fri May 26 14:55:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F32D79FA218 + for ; + Fri, 26 May 2006 14:55:24 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 84799-01 + for ; + Fri, 26 May 2006 14:55:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 42EB39FA12E + for ; + Fri, 26 May 2006 14:55:17 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4QHtGf4027571; + Fri, 26 May 2006 13:55:16 -0400 (EDT) +To: "Merlin Moncure" +cc: "Postgresql Performance" +Subject: Re: is it possible to make this faster? +In-reply-to: +References: + <15919.1148590347@sss.pgh.pa.us> <16119.1148591497@sss.pgh.pa.us> + + <25668.1148653358@sss.pgh.pa.us> + + <27137.1148663259@sss.pgh.pa.us> + +Comments: In-reply-to "Merlin Moncure" + message dated "Fri, 26 May 2006 13:46:30 -0400" +Date: Fri, 26 May 2006 13:55:15 -0400 +Message-ID: <27570.1148666115@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/497 +X-Sequence-Number: 19284 + +"Merlin Moncure" writes: +> can't thing of anything, I'm running completely stock, did you do a +> optimize table foo? + +Nope, never heard of that before. But I did it, and it doesn't seem to +have changed my results at all. + +> mysql> select user_id, acc_id, max(sample_date) from usage_samples group by 1,2 +> 939 rows in set (0.07 sec) + +0.07 seconds is not impossibly out of line with my result of 0.15 sec, +maybe your machine is just 2X faster than mine. This is a 2.8GHz dual +Xeon EM64T, what are you testing? You said "less than 20 msec" before, +what was that on? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 30 17:56:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id F20679FA1F1 + for ; + Fri, 26 May 2006 15:49:00 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 94470-01 + for ; + Fri, 26 May 2006 15:48:56 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nf-out-0910.google.com (nf-out-0910.google.com + [64.233.182.188]) + by postgresql.org (Postfix) with ESMTP id 2A88C9FA12E + for ; + Fri, 26 May 2006 15:48:55 -0300 (ADT) +Received: by nf-out-0910.google.com with SMTP id b2so102423nfe + for ; + Fri, 26 May 2006 11:48:54 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=ixMVnCAG10YxhmwEWa82m0Kb8wVQS4YY9U8fmTHmwKxT3n2OPv04E1RsJukrp1EMX95lRtxgzsrhnp45dqPdH/6wlqOsZYeoHKbNUnD+VWGKAj2deJQAc5rcyheM1iWwiUgr5mkbo9yF1dIAIL3UBMWLx/p6vV/Km8AV3eN5qNo= +Received: by 10.48.31.8 with SMTP id e8mr366424nfe; + Fri, 26 May 2006 11:47:35 -0700 (PDT) +Received: by 10.48.164.19 with HTTP; Fri, 26 May 2006 11:48:20 -0700 (PDT) +Message-ID: +Date: Fri, 26 May 2006 14:48:20 -0400 +From: "Worky Workerson" +To: pgsql-performance@postgresql.org +Subject: Bulk loading/merging +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/544 +X-Sequence-Number: 19331 + +I've set up something similar the 'recommended' way to merge data into +the DB, i.e. + +http://www.postgresql.org/docs/current/static/plpgsql-control-structures.ht= +ml#PLPGSQL-ERROR-TRAPPING + +however I did it with a trigger on insert, i.e. (not my schema :) ): + +CREATE TABLE db (a INT PRIMARY KEY, b TEXT, c INTEGER, d INET); + +CREATE FUNCTION merge_db() RETURNS TRIGGER AS +$$ +BEGIN + UPDATE db SET b =3D NEW.data + WHERE a =3D NEW.key + AND NOT (c IS DISTINCT FROM NEW.c) + AND NOT (d IS DISTINCT FROM NEW.d); + IF found THEN + RETURN NULL; + END IF; + RETURN NEW; +END; +$$ +LANGUAGE plpgsql; + +CREATE TRIGGER merge_db_tr BEFORE INSERT ON db +FOR EACH ROW EXECUTE PROCEDURE merge_db(); + +Is this the best/fastest way to do this sort of thing? I only get +about 50 records/second inserts, while without the trigger (inserting +unmerged data) I can get more like 1000/second. I'm doing the whole +NOT ... IS DISTINCT stuff to handle NULL values that might be in the +columns ... I'm only considering two column keys equal if (a,c,d) are +all the same (i.e. either the same value or both NULL). + +I read that there is a race condition with the above method as applied +to a normal function ... does this apply to a trigger as well? + +Optimization Questions: +-Can I do better with the trigger function itself? + +-I realize that I can create indexes on some of the lookup columns +('key' in the above example). This would speed up the location of the +update record but slow down the actual update insert, right? Would +this be a win? I tested an index on 10000 rows, and it beat out the +non-indexed by about 7% (3:31 with index, 3:45 without) ... is this +all the benefit that I can expect? + +-Will moving pg_xlog to a different disk help all that much, if the +whole DB is currently on a 4 disk RAID10? What about moving the +indexes? I've set up my postgresql.conf according to the docs and +Josh Berkus' presentation, i.e. (16GB ram, quad Opteron moachine, not +all settings are relevant): +shared_buffers =3D 60000 +temp_buffers =3D 10000 +work_mem =3D 131072 +maintenance_work_mem =3D 524288 +effective_cache_size =3D 120000 +random_page_cost =3D 2 +wal_buffers =3D 128 +checkpoint_segments =3D 128 +checkpoint_timeout =3D 3000 +max_fsm_pages =3D 2000000 +max_fsm_relations =3D 1000000 + +-If I break up my dataset into smaller chunks and parallelize it, +could I get better total performance, or would I most likely be +thrashing the disk? + +-If I sort the data in the COPY file by key (i.e. a,c,d) before +inserting it into the database, will this help out the DB at all? + +-Its cleaner to just be able to insert everything into the database +and let the DB aggregate the records, however I could use some of our +extra hardware to do aggregation in perl and then output the already +aggregated records to the DB ... this has the advantage of being +easily parallelizable but requires a bit of extra work to get right. +Do you think that this is the best way to go? + +Also, as a slight aside, without a trigger, COPY seems to process each +record very quickly (using Perl DBI, about 7000 records/second) +however there is a long pause once the last record has been delivered. + Is this just the backend queuing up the insert commands given by +perl, or is there extra processing that needs to be done at the end of +the COPY that could be taking a while (10s on 500K record COPY). + +Thanks! + +From pgsql-performance-owner@postgresql.org Tue May 30 17:56:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7BB9E9FA5DD + for ; + Fri, 26 May 2006 16:05:44 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 99160-01-2 + for ; + Fri, 26 May 2006 16:05:36 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nf-out-0910.google.com (nf-out-0910.google.com + [64.233.182.189]) + by postgresql.org (Postfix) with ESMTP id BF9519FA12E + for ; + Fri, 26 May 2006 16:05:33 -0300 (ADT) +Received: by nf-out-0910.google.com with SMTP id l36so113647nfa + for ; + Fri, 26 May 2006 12:05:31 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; + b=AGU5ksD/lGvDhS8EMIMAgqE779vJf4Jt949UuODG8Nl/2XsboldotgVsQ3Rybgy0YmfT/MCADQahPb4WtAgXRG05HBnglFEnI4MohC027Du91BAu64n3ZorMEGKFLrlrPFPootwuLzxtncsoSr8E6SadEU4KhVck5LDxeS1RcgA= +Received: by 10.48.203.12 with SMTP id a12mr7406nfg; + Fri, 26 May 2006 12:04:59 -0700 (PDT) +Received: by 10.48.164.19 with HTTP; Fri, 26 May 2006 12:04:59 -0700 (PDT) +Message-ID: +Date: Fri, 26 May 2006 15:04:59 -0400 +From: "Worky Workerson" +To: pgsql-performance@postgresql.org +Subject: Re: Bulk loading/merging +In-Reply-To: +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="----=_Part_217414_4407177.1148670299461" +References: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/545 +X-Sequence-Number: 19332 + +------=_Part_217414_4407177.1148670299461 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Another little question ... would using any sort of TEMP table help out, i.= +e. +loading the unaggregated data into a TEMP table, aggregating the data via a +SELECT INTO another TEMP table, and then finally INSERT ... SELECT into the +master, aggregated, triggered table? It seems like this might be a win if +A) the TEMP tables fit into memory, and B) the load data aggregates well. +Worst case (i.e. all unique data in the load) seems like it might take much +longer, however, since I'm creating 2 new TEMP tables .... + +------=_Part_217414_4407177.1148670299461 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline + +Another little question ... would using any sort of TEMP table help out, i.= +e. loading the unaggregated data into a TEMP table, aggregating the data vi= +a a SELECT INTO another TEMP table, and then finally INSERT ... SELECT into= + the master, aggregated, triggered table?  It seems like this might be= + a win if A) the TEMP tables fit into memory, and B) the load data aggregat= +es well.  Worst case ( +i.e. all unique data in the load) seems like it might take much longer, how= +ever, since I'm creating 2 new TEMP tables ....

+ +------=_Part_217414_4407177.1148670299461-- + +From pgsql-performance-owner@postgresql.org Fri May 26 16:40:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E08489FA218 + for ; + Fri, 26 May 2006 16:40:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 03523-01 + for ; + Fri, 26 May 2006 16:40:24 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from wr-out-0506.google.com (wr-out-0506.google.com + [64.233.184.229]) + by postgresql.org (Postfix) with ESMTP id CA38B9FA12E + for ; + Fri, 26 May 2006 16:40:24 -0300 (ADT) +Received: by wr-out-0506.google.com with SMTP id 50so146851wri + for ; + Fri, 26 May 2006 12:40:23 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=sXcsG6lEvM/3OS8RLJ37xpb03HtmcG2E0HzfSrai0goDuJSOODyheJl+LnDPIFli6ekQnA1JQaCEJb11XbX2FqDdcYni+a6kKBKo6l53znKo6X6yXllBfObJhVB8NcqXPFh1adfOLKLB6Usei8hQ/XFrRAQta+q6TYP5OFvskoU= +Received: by 10.65.228.12 with SMTP id f12mr646491qbr; + Fri, 26 May 2006 12:40:23 -0700 (PDT) +Received: by 10.65.137.19 with HTTP; Fri, 26 May 2006 12:40:22 -0700 (PDT) +Message-ID: +Date: Fri, 26 May 2006 15:40:22 -0400 +From: "Merlin Moncure" +To: "Tom Lane" +Subject: Re: is it possible to make this faster? +Cc: "Postgresql Performance" +In-Reply-To: <27570.1148666115@sss.pgh.pa.us> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: + <15919.1148590347@sss.pgh.pa.us> <16119.1148591497@sss.pgh.pa.us> + + <25668.1148653358@sss.pgh.pa.us> + + <27137.1148663259@sss.pgh.pa.us> + + <27570.1148666115@sss.pgh.pa.us> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/498 +X-Sequence-Number: 19285 + +On 5/26/06, Tom Lane wrote: +> > mysql> select user_id, acc_id, max(sample_date) from usage_samples grou= +p by 1,2 +> > 939 rows in set (0.07 sec) +> +> 0.07 seconds is not impossibly out of line with my result of 0.15 sec, +> maybe your machine is just 2X faster than mine. This is a 2.8GHz dual +> Xeon EM64T, what are you testing? You said "less than 20 msec" before, +> what was that on? + +600 mhz p3: 70 ms, 1100 ms slow case +1600 mhz p4: 10-30ms (mysql timer not very precise) 710ms slow case +quad opteron 865: 0 :-) +dual p3 1133 Mhz xeon, mysql 4.0.16: 500 ms + +using steinar's 'substitute group by' for pg I get 40ms on the p3 and +low times on all else. your time of 150 ms is looking like the slow +case on my results. + +merlin + +From pgsql-performance-owner@postgresql.org Fri May 26 17:45:01 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8B8499FA1F1 + for ; + Fri, 26 May 2006 17:45:01 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10909-01 + for ; + Fri, 26 May 2006 17:44:52 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 104979FA12E + for ; + Fri, 26 May 2006 17:44:51 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4QKikMt029952; + Fri, 26 May 2006 16:44:47 -0400 (EDT) +To: "Merlin Moncure" +cc: "Postgresql Performance" +Subject: Re: is it possible to make this faster? +In-reply-to: +References: + <15919.1148590347@sss.pgh.pa.us> <16119.1148591497@sss.pgh.pa.us> + + <25668.1148653358@sss.pgh.pa.us> + + <27137.1148663259@sss.pgh.pa.us> + + <27570.1148666115@sss.pgh.pa.us> + +Comments: In-reply-to "Merlin Moncure" + message dated "Fri, 26 May 2006 15:40:22 -0400" +Date: Fri, 26 May 2006 16:44:46 -0400 +Message-ID: <29951.1148676286@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/499 +X-Sequence-Number: 19286 + +"Merlin Moncure" writes: +> your time of 150 ms is looking like the slow case on my results. + +Yeah... so what's wrong with my test? Anyone else care to duplicate +the test and see what they get? + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sat May 27 18:02:27 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A0FAC9FA2D8 + for ; + Sat, 27 May 2006 18:02:26 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 43194-05 + for ; + Sat, 27 May 2006 18:02:21 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 406BD9FA176 + for ; + Sat, 27 May 2006 18:02:20 -0300 (ADT) +Received: (qmail 29479 invoked from network); 27 May 2006 23:04:52 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 27 May 2006 23:04:52 +0200 +Date: Sat, 27 May 2006 23:04:51 +0200 +From: PFC +To: "Christian Paul Cosinas" , + pgsql-performance@postgresql.org +Subject: Re: Speed Up Offset and Limit Clause +References: <00e101c67997$6aa049f0$1e21100a@ghwk02002147> +Message-ID: +In-Reply-To: <00e101c67997$6aa049f0$1e21100a@ghwk02002147> +User-Agent: Opera M2/8.54 (Linux, build 1745) +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/500 +X-Sequence-Number: 19287 + + +> Thread 1 : gets offset 0 limit 5000 +> Thread 2 : gets offset 5000 limit 5000 +> Thread 3 : gets offset 10000 limit 5000 +> +> Would there be any other faster way than what It thought? + + Yeah, sure, use a thread which does the whole query (maybe using a +cursor) and fills a queue with the results, then N threads consuming from +that queue... it will work better. + +From pgsql-performance-owner@postgresql.org Sat May 27 22:12:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B77129FA43B + for ; + Sat, 27 May 2006 22:12:04 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 15584-02 + for ; + Sat, 27 May 2006 22:11:54 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from linda-3.paradise.net.nz (bm-3a.paradise.net.nz + [203.96.152.182]) + by postgresql.org (Postfix) with ESMTP id B73229F94EA + for ; + Sat, 27 May 2006 22:11:54 -0300 (ADT) +Received: from smtp-2.paradise.net.nz + (tclsnelb1-src-1.paradise.net.nz [203.96.152.172]) by + linda-3.paradise.net.nz (Paradise.net.nz) with ESMTP id + <0IZY00KACBBRV6@linda-3.paradise.net.nz> for + pgsql-performance@postgresql.org; Sun, 28 May 2006 13:11:52 +1200 (NZST) +Received: from [192.168.1.11] (218-101-29-78.dsl.clear.net.nz [218.101.29.78]) + by smtp-2.paradise.net.nz (Postfix) with ESMTP id 891D4128A3F5; Sun, + 28 May 2006 13:11:51 +1200 (NZST) +Date: Sun, 28 May 2006 13:11:47 +1200 +From: Mark Kirkwood +Subject: Re: is it possible to make this faster? +In-reply-to: <29951.1148676286@sss.pgh.pa.us> +To: Tom Lane +Cc: Merlin Moncure , + Postgresql Performance +Message-id: <4478F8D3.7040104@paradise.net.nz> +MIME-version: 1.0 +Content-type: text/plain; format=flowed; charset=ISO-8859-1 +Content-transfer-encoding: 7bit +User-Agent: Thunderbird 1.5 (X11/20060417) +References: + <15919.1148590347@sss.pgh.pa.us> <16119.1148591497@sss.pgh.pa.us> + + <25668.1148653358@sss.pgh.pa.us> + + <27137.1148663259@sss.pgh.pa.us> + + <27570.1148666115@sss.pgh.pa.us> + + <29951.1148676286@sss.pgh.pa.us> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/501 +X-Sequence-Number: 19288 + +Tom Lane wrote: +> "Merlin Moncure" writes: +>> your time of 150 ms is looking like the slow case on my results. +> +> Yeah... so what's wrong with my test? Anyone else care to duplicate +> the test and see what they get? + +Using your test [generating c from int(rand(1000))], I get 230 ms using +5.0.18 on a P3 1000 Mhz (doing optimize table on t made no difference at +all). + +Cheers + +Mark + +From pgsql-performance-owner@postgresql.org Sun May 28 06:38:16 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A97A79FA317 + for ; + Sun, 28 May 2006 06:38:15 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 23421-08 + for ; + Sun, 28 May 2006 06:38:05 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 2BF109FA2EB + for ; + Sun, 28 May 2006 06:38:04 -0300 (ADT) +Received: from [10.0.1.4] ([68.147.204.179]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)) + for pgsql-performance@postgresql.org; Sun, 28 May 2006 03:38:03 -0600 +Mime-Version: 1.0 (Apple Message framework v750) +To: PostgreSQL Performance +Message-Id: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> +Content-Type: multipart/alternative; boundary=Apple-Mail-3-850669039 +From: Brendan Duddridge +Subject: App very unresponsive while performing simple update +Date: Sun, 28 May 2006 03:37:57 -0600 +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/502 +X-Sequence-Number: 19289 + + +--Apple-Mail-3-850669039 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +Hi, + +Is Postgres supposed to be able to handle concurrent requests while +doing large updates? + +This morning I was executing the following simple update statement +that would affect 220,000 rows in my product table: + +update product set is_hungry = 'true' where date_modified > +current_date - 10; + +But the application that accesses the product table for reading +became very unresponsive while the update was happening. + +Is it just a matter of slow I/O? The CPU usage seemed very low (less +than 5%) and iostat showed less than 1 MB / sec throughput. + +I was doing the update in psql. + +Are there any settings that I could tweak that would help with this +sort of thing? + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + + +--Apple-Mail-3-850669039 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=ISO-8859-1 + +Hi,

Is Postgres supposed to be = +able to handle concurrent requests while doing large = +updates?

This = +morning I was executing the following simple update statement that would = +affect 220,000 rows in my product table:

update product set = +is_hungry =3D 'true'=A0 where date_modified > current_date - = +10;

But the = +application that accesses the product table for reading became very = +unresponsive while the update was happening.

Is it just a matter of slow = +I/O? The CPU usage seemed very low (less than 5%) and iostat showed=A0 = +less than 1 MB / sec throughput.

I was doing the update in = +psql.

Are = +there any settings that I could tweak that would help with this sort of = +thing?

Thanks,

_________________________________________________________= +___________
Brendan Duddridge=A0| CTO | 403-277-5591 x24 | =A0brendan@clickspace.com = +

ClickSpace = +Interactive Inc.
Suite L100, 239 - 10th Ave. SE
Calgary, AB = +=A0T2G 0V9

http://www.clickspace.com=A0
= +

= + +--Apple-Mail-3-850669039-- + + +From pgsql-performance-owner@postgresql.org Sun May 28 06:43:41 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E8C3C9FA380 + for ; + Sun, 28 May 2006 06:43:40 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 11490-10 + for ; + Sun, 28 May 2006 06:43:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 072C39FA317 + for ; + Sun, 28 May 2006 06:43:30 -0300 (ADT) +Received: from [10.0.1.4] ([68.147.204.179]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)) + for pgsql-performance@postgresql.org; Sun, 28 May 2006 03:43:29 -0600 +Mime-Version: 1.0 (Apple Message framework v750) +In-Reply-To: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> +Content-Type: multipart/alternative; boundary=Apple-Mail-4-850995727 +Message-Id: <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> +From: Brendan Duddridge +Subject: Re: App very unresponsive while performing simple update +Date: Sun, 28 May 2006 03:43:23 -0600 +To: PostgreSQL Performance +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/503 +X-Sequence-Number: 19290 + + +--Apple-Mail-4-850995727 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; + charset=US-ASCII; + delsp=yes; + format=flowed + +Further to my issue, the update never did finish. I received the +following message in psql: + +ssprod=# update product set is_hungry = 'true' where date_modified > +current_date - 10; +ERROR: deadlock detected +DETAIL: Process 18778 waits for ShareLock on transaction 711698780; +blocked by process 15784. +Process 15784 waits for ShareLock on transaction 711697098; blocked +by process 18778. + +This is the second time I've tried to run this query without success. + +Would changing the isolation level to serializable in my psql session +help with this? + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On May 28, 2006, at 3:37 AM, Brendan Duddridge wrote: + +> Hi, +> +> Is Postgres supposed to be able to handle concurrent requests while +> doing large updates? +> +> This morning I was executing the following simple update statement +> that would affect 220,000 rows in my product table: +> +> update product set is_hungry = 'true' where date_modified > +> current_date - 10; +> +> But the application that accesses the product table for reading +> became very unresponsive while the update was happening. +> +> Is it just a matter of slow I/O? The CPU usage seemed very low +> (less than 5%) and iostat showed less than 1 MB / sec throughput. +> +> I was doing the update in psql. +> +> Are there any settings that I could tweak that would help with this +> sort of thing? +> +> Thanks, +> +> ____________________________________________________________________ +> Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com +> +> ClickSpace Interactive Inc. +> Suite L100, 239 - 10th Ave. SE +> Calgary, AB T2G 0V9 +> +> http://www.clickspace.com +> + + +--Apple-Mail-4-850995727 +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; + charset=ISO-8859-1 + +Further to my issue, the update = +never did finish. I received the following message in psql:

ssprod=3D# update product = +set is_hungry =3D 'true'=A0 where date_modified > current_date - = +10;
ERROR:=A0 deadlock detected
DETAIL:=A0 Process = +18778 waits for ShareLock on transaction 711698780;=A0=A0blocked by = +process 15784.
Process 15784 waits for ShareLock on = +transaction 711697098;=A0blocked by process 18778.

This is the second time = +I've tried to run this query without success.

Would changing the = +isolation level to serializable in my psql session help with = +this?

Thanks,

_________________________________________________________= +___________
Brendan Duddridge=A0| CTO | 403-277-5591 x24 | =A0brendan@clickspace.com = +

ClickSpace = +Interactive Inc.
Suite L100, 239 - 10th Ave. SE
Calgary, AB = +=A0T2G 0V9

http://www.clickspace.com=A0
= +

On May 28, 2006, at 3:37 AM, Brendan Duddridge = +wrote:

Hi,

Is = +Postgres supposed to be able to handle concurrent requests while doing = +large updates?

This morning I was = +executing the following simple update statement that would affect = +220,000 rows in my product table:

update product set = +is_hungry =3D 'true'=A0 where date_modified > current_date - = +10;

But the = +application that accesses the product table for reading became very = +unresponsive while the update was happening.

Is it just a matter of slow = +I/O? The CPU usage seemed very low (less than 5%) and iostat showed=A0 = +less than 1 MB / sec throughput.

I was doing the update in = +psql.

Are = +there any settings that I could tweak that would help with this sort of = +thing?

Thanks,

_________________________________________________________= +___________
Brendan Duddridge=A0| CTO | 403-277-5591 x24 | =A0brendan@clickspace.com = +

ClickSpace = +Interactive Inc.
Suite L100, 239 - 10th Ave. SE
Calgary, AB = +=A0T2G 0V9

http://www.clickspace.com=A0
= +


= + +--Apple-Mail-4-850995727-- + + +From pgsql-performance-owner@postgresql.org Sun May 28 11:16:37 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2B2EB9FA326 + for ; + Sun, 28 May 2006 11:16:37 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 21368-08 + for ; + Sun, 28 May 2006 11:16:27 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from swordfish.dnsvelocity.com (swordfish.dnsvelocity.com + [216.67.224.90]) + by postgresql.org (Postfix) with ESMTP id 210089F9F3D + for ; + Sun, 28 May 2006 11:16:26 -0300 (ADT) +Received: from [24.87.22.207] (port=4069 helo=chris) + by swordfish.dnsvelocity.com with esmtpa (Exim 4.52) + id 1FkM48-0002LR-08; Sun, 28 May 2006 15:16:24 +0100 +Message-ID: <001601c68261$4a975c70$6401a8c0@chris> +From: "Cstdenis" +To: "Jim C. Nasby" +Cc: +References: <03e001c67b99$8321f010$6401a8c0@chris> + <20060522152016.GM64371@pervasive.com> +Subject: Re: How can I make this query faster (resend) +Date: Sun, 28 May 2006 03:49:06 -0700 +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.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +X-Antivirus-Scanner: Clean mail though you should still use an Antivirus +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - swordfish.dnsvelocity.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] +X-AntiAbuse: Sender Address Domain - voicio.com +X-Source: +X-Source-Args: +X-Source-Dir: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/505 +X-Sequence-Number: 19292 + +From: "Jim C. Nasby" +To: "Cstdenis" +Cc: +Sent: Monday, May 22, 2006 8:20 AM +Subject: Re: [PERFORM] How can I make this query faster (resend) + + +> On Fri, May 19, 2006 at 03:56:49PM -0700, Cstdenis wrote: +> > (Its been a hour and I dont see my message on the list so I'm sending it +again. I've moved the queries and analyze out of the email incase it was +rejected because too long) +> > +> > query: http://pastebin.ca/57218 +> > +> > In the pictures table all the ratings have a shared index +> > +> > CREATE INDEX idx_rating ON pictures USING btree (rating_nudity, +rating_violence, rating_sex, rating_racism, rating_spoilers, rating_yaoi, +rating_yuri, rating_profanity); +> > +> > and approved and date_submitted and user_id also have their own btree +indexes. +> > +> > In the picture_categories table pid and cat_id have their own btree +indices plus one together. +> > +> > Full table definition: http://pastebin.ca/57219 +> > +> > the cat_id and rating values vary from query to query. The one listed +above took 54 seconds in a test run just now. Here is explain analyze: +http://pastebin.ca/57220 +> +> pictures is the interesting table here. It looks like the planner would +> do better to choose something other than a nested loop on it. Try +> running EXPLAIN ANALYZE on the query with enable_nestloop=off and see +> what you get (you'll need to compare it to what you get with +> enable_nestloop on to see what the change is). + +With enable_nestloop=off the same query as is explained further down in this +email took much longer 63 seconds insted of 6. It decided to do sequencial +scans on pictures and users with nested loop disabled. + +Merge Join (cost=146329.63..146963.96 rows=231 width=66) (actual +time=61610.538..62749.176 rows=1305 loops=1) + Merge Cond: ("outer".user_id = "inner".user_id) + -> Sort (cost=123828.88..123829.46 rows=231 width=47) (actual +time=60445.367..60451.176 rows=1305 loops=1) + Sort Key: pictures.user_id + -> Hash Join (cost=634.36..123819.81 rows=231 width=47) (actual +time=128.088..60423.623 rows=1305 loops=1) + Hash Cond: ("outer".pid = "inner".pid) + -> Seq Scan on pictures (cost=0.00..121670.43 rows=302543 +width=47) (actual time=0.210..58795.925 rows=291318 loops=1) + -> Hash (cost=633.78..633.78 rows=231 width=4) (actual +time=38.443..38.443 rows=1305 loops=1) + -> Bitmap Heap Scan on picture_categories +(cost=2.81..633.78 rows=231 width=4) (actual time=4.753..32.259 rows=1305 +loops=1) + Recheck Cond: (cat_id = 182) + -> Bitmap Index Scan on +idx_picture_categories_cat_id (cost=0.00..2.81 rows=231 width=0) (actual +time=4.398..4.398 rows=1305 loops=1) + Index Cond: (cat_id = 182) + -> Sort (cost=22500.74..22816.79 rows=126418 width=23) (actual +time=1163.788..1505.104 rows=52214 loops=1) + Sort Key: users.user_id + -> Seq Scan on users (cost=0.00..11788.18 rows=126418 width=23) +(actual time=0.017..692.992 rows=54605 loops=1) +Total runtime: 62776.720 ms + + +> > Both pictures and picture categories have about 287,000 rows +> > +> > This query needs to run in under about a second or it kills my site by +clogging apache slots (apache maxes out at 256 and I can have several +hundred people on my site at a time). How can I make it run faster? +> > +> > +> > Server is a dual xeon with a gig of ram dedicated mostly to postgresql. +> > Here is the changed lines in my postgresql.conf: +http://pastebin.ca/57222 +> +> I suspect the low work_mem may be why it's using a nested loop. In +> addition to the test above, it would be interesting to see what happens +> to the plan if you set work_mem to 10000. + +I moved to a more powerful server (2gb ram and mirrored scsi HDs) and upped +the work mem to 10mb. Its much faster now, however its still doing a nested +loop. (see also my reply to Markus Schaber) + + +Nested Loop (cost=2.81..3398.76 rows=231 width=66) (actual +time=14.946..5797.701 rows=1305 loops=1) + -> Nested Loop (cost=2.81..2022.71 rows=231 width=47) (actual +time=14.551..5181.042 rows=1305 loops=1) + -> Bitmap Heap Scan on picture_categories (cost=2.81..633.78 +rows=231 width=4) (actual time=9.966..140.606 rows=1305 loops=1) + Recheck Cond: (cat_id = 182) + -> Bitmap Index Scan on idx_picture_categories_cat_id +(cost=0.00..2.81 rows=231 width=0) (actual time=9.720..9.720 rows=1305 +loops=1) + Index Cond: (cat_id = 182) + -> Index Scan using pictures_pkey on pictures (cost=0.00..6.00 +rows=1 width=47) (actual time=3.802..3.820 rows=1 loops=1305) + Index Cond: (pictures.pid = "outer".pid) + -> Index Scan using users_pkey on users (cost=0.00..5.94 rows=1 +width=23) (actual time=0.095..0.100 rows=1 loops=1305) + Index Cond: ("outer".user_id = users.user_id) +Total runtime: 5812.238 ms + + +> To be honest, you're pushing things expecting a machine with only 1G to +> serve 300 active connections. How large is the database itself? + +The database is 3.7G on disk. There is about 1G of actual data in it -- the +rest is dead tuples and indices. (I vacuum regularly, but a vacuum full +causes too much downtime to do unless I have to) + +> > I know hyperthreading is considered something that can slow down a +server but with my very high concurancy (averages about 400-500 concurant +users during peak hours) I am hoping the extra virtual CPUs wil help. Anyone +have experance that says diferent at high concurancy? +> +> Best bet is to try it and see. Generally, people find HT hurts, but I +> recently saw it double the performance of pgbench on a windows XP +> machine, so it's possible that windows is just more clever about how to +> use it than linux is. + +Anyone know if those who have found it hurts are low concurancy complex cpu +intensive queries or high concurancy simple queries or both? I can +understand it hurting in the former, but not the later. I'll have to give it +a try I guess. It should at least help my very high load averages. + +> -- +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> + + + +From pgsql-performance-owner@postgresql.org Sun May 28 10:11:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 65D929FA326 + for ; + Sun, 28 May 2006 10:11:37 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 17477-02 + for ; + Sun, 28 May 2006 10:11:28 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id 483BA9F9F3D + for ; + Sun, 28 May 2006 10:11:28 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1FkL3B-0005YG-00; Sun, 28 May 2006 09:11:21 -0400 +To: Brendan Duddridge +Cc: PostgreSQL Performance +Subject: Re: App very unresponsive while performing simple update +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> + <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> +In-Reply-To: <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 28 May 2006 09:11:21 -0400 +Message-ID: <874pzanvk6.fsf@stark.xeocode.com> +Lines: 34 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/504 +X-Sequence-Number: 19291 + +Brendan Duddridge writes: + +> Further to my issue, the update never did finish. I received the following +> message in psql: +> +> ssprod=# update product set is_hungry = 'true' where date_modified > +> current_date - 10; +> ERROR: deadlock detected +> DETAIL: Process 18778 waits for ShareLock on transaction 711698780; blocked +> by process 15784. +> Process 15784 waits for ShareLock on transaction 711697098; blocked by process +> 18778. + +What queries are those two processes executing? And what foreign keys do you +have on the product table or elsewhere referring to the product table? And +what indexes do you have on those columns? + +I think this indicates you have foreign keys causing the deadlock. One process +is waiting until an update elsewhere finishes before modifying a record that +other update refers to via a foreign key. But that other process is waiting +similarly for the first one. + +Do you have any foreign keys in other tables referring to the product table? +Do you have indexes on those other tables? The update needs to check those +other tables to make sure there are no references to the records you're +updating. If there's no index it has to do a sequential scan. + +To get a deadlock I think you would need another update running somewhere +though. + + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sun May 28 13:05:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A56DA9FA42B + for ; + Sun, 28 May 2006 13:05:04 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 34025-02 + for ; + Sun, 28 May 2006 13:04:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id F08649FA38E + for ; + Sun, 28 May 2006 13:04:58 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4SG4r9f017734; + Sun, 28 May 2006 12:04:53 -0400 (EDT) +To: Greg Stark +cc: Brendan Duddridge , + PostgreSQL Performance +Subject: Re: App very unresponsive while performing simple update +In-reply-to: <874pzanvk6.fsf@stark.xeocode.com> +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> + <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> + <874pzanvk6.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "28 May 2006 09:11:21 -0400" +Date: Sun, 28 May 2006 12:04:52 -0400 +Message-ID: <17733.1148832292@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/506 +X-Sequence-Number: 19293 + +Greg Stark writes: +> What queries are those two processes executing? And what foreign keys do you +> have on the product table or elsewhere referring to the product table? And +> what indexes do you have on those columns? + +And what PG version is this? Alvaro fixed the +foreign-keys-take-exclusive-locks problem in 8.1 ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Sun May 28 14:56:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 873BC9F9F3D + for ; + Sun, 28 May 2006 14:56:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 43983-08 + for ; + Sun, 28 May 2006 14:56:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id C7A359FA42B + for ; + Sun, 28 May 2006 14:56:08 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1FkPUY-0008IJ-00; Sun, 28 May 2006 13:55:54 -0400 +To: Tom Lane +Cc: Greg Stark , Brendan Duddridge , + PostgreSQL Performance +Subject: Re: App very unresponsive while performing simple update +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> + <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> + <874pzanvk6.fsf@stark.xeocode.com> <17733.1148832292@sss.pgh.pa.us> +In-Reply-To: <17733.1148832292@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 28 May 2006 13:55:54 -0400 +Message-ID: <87slmum3th.fsf@stark.xeocode.com> +Lines: 17 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/507 +X-Sequence-Number: 19294 + +Tom Lane writes: + +> Greg Stark writes: +> > What queries are those two processes executing? And what foreign keys do you +> > have on the product table or elsewhere referring to the product table? And +> > what indexes do you have on those columns? +> +> And what PG version is this? Alvaro fixed the +> foreign-keys-take-exclusive-locks problem in 8.1 ... + +Except I don't think this is taking an exclusive lock at all. The original +post had the deadlock detection fire on a SharedLock. I think the other +process is also an update and is holding an exclusive lock while also +trying to acquire a SharedLock for a foreign key column. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sun May 28 16:17:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 2055B9FA510 + for ; + Sun, 28 May 2006 16:17:33 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 57339-09 + for ; + Sun, 28 May 2006 16:17:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id 26D559F9F3D + for ; + Sun, 28 May 2006 16:17:24 -0300 (ADT) +Received: from [10.0.1.4] ([68.147.204.179]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Sun, 28 May 2006 13:17:14 -0600 +In-Reply-To: <17733.1148832292@sss.pgh.pa.us> +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> + <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> + <874pzanvk6.fsf@stark.xeocode.com> <17733.1148832292@sss.pgh.pa.us> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <3C756C36-DC66-4D13-B2CE-99CFCE7BF390@clickspace.com> +Cc: Greg Stark , + PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: App very unresponsive while performing simple update +Date: Sun, 28 May 2006 13:17:07 -0600 +To: Tom Lane +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/508 +X-Sequence-Number: 19295 + +Hi, + +Thanks for your replies. + +We are using PostgreSQL 8.1.3 on OS X Server. + +We do have foreign keys on other tables that reference the product +table. Also, there will be updates going on at the same time as this +update. When anyone clicks on a product details link, we issue an +update statement to increment the click_count on the product. e.g. +update product set click_count = click_count + 1; + +There are 1.2 million rows in this table and my update will affect +200,000 of them. + +We do have indexes on all foreign keys that reference the product table. + +Here's what our product table looks like: + + Table "public.product" + Column | Type | Modifiers +------------------------------+-----------------------------+----------- +click_count | integer | +date_created | timestamp without time zone | not null +date_modified | timestamp without time zone | +date_of_last_keyphrase_match | timestamp without time zone | +ean | character varying(32) | +gtin | character varying(32) | +home_category_id | integer | +is_active | character varying(5) | +is_featured | character varying(5) | +is_hungry | character varying(5) | +isbn | character varying(32) | +manufacturer_id | integer | +media_for_clipboard_id | integer | +media_for_detail_id | integer | +media_for_thumbnail_id | integer | +mpn | character varying(512) | +product_id | integer | not null +status_code | character varying(32) | +unsps_code | bigint | +upc | character varying(32) | +riding_id | integer | +name_en | character varying(512) | +name_fr | character varying(512) | +short_description_en | character varying(2048) | +short_description_fr | character varying(2048) | +long_description_en | text | +long_description_fr | text | +Indexes: + "product_pk" PRIMARY KEY, btree (product_id) + "product__active_status_idx" btree (is_active, status_code) + "product__additional_0__idx" btree (riding_id) + "product__date_created_idx" btree (date_created) + "product__date_modified_idx" btree (date_modified) + "product__date_of_last_keyphrase_match_idx" btree +(date_of_last_keyphrase_match) + "product__home_category_id_fk_idx" btree (home_category_id) + "product__hungry_idx" btree (is_hungry) + "product__lower_name_en_idx" btree (lower(name_en::text)) + "product__lower_name_fr_idx" btree (lower(name_fr::text)) + "product__manufacturer_id_fk_idx" btree (manufacturer_id) + "product__manufacturer_id_mpn_idx" btree (manufacturer_id, mpn) + "product__media_for_clipboard_id_fk_idx" btree +(media_for_clipboard_id) + "product__media_for_detail_id_fk_idx" btree (media_for_detail_id) + "product__media_for_thumbnail_id_fk_idx" btree +(media_for_thumbnail_id) + "product__upc_idx" btree (upc) + "product_additional_2__idx" btree (is_active, status_code) WHERE +is_active::text = 'true'::text AND status_code::text = 'complete'::text +Foreign-key constraints: + "product_homecategory_fk" FOREIGN KEY (home_category_id) +REFERENCES category(category_id) DEFERRABLE INITIALLY DEFERRED + "product_manufacturer_fk" FOREIGN KEY (manufacturer_id) +REFERENCES manufacturer(manufacturer_id) DEFERRABLE INITIALLY DEFERRED + "product_mediaforclipboard_fk" FOREIGN KEY +(media_for_clipboard_id) REFERENCES media(media_id) DEFERRABLE +INITIALLY DEFERRED + "product_mediafordetail_fk" FOREIGN KEY (media_for_detail_id) +REFERENCES media(media_id) DEFERRABLE INITIALLY DEFERRED + "product_mediaforthumbnail_fk" FOREIGN KEY +(media_for_thumbnail_id) REFERENCES media(media_id) DEFERRABLE +INITIALLY DEFERRED + + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On May 28, 2006, at 10:04 AM, Tom Lane wrote: + +> Greg Stark writes: +>> What queries are those two processes executing? And what foreign +>> keys do you +>> have on the product table or elsewhere referring to the product +>> table? And +>> what indexes do you have on those columns? +> +> And what PG version is this? Alvaro fixed the +> foreign-keys-take-exclusive-locks problem in 8.1 ... +> +> regards, tom lane +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 9: In versions below 8.0, 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 Sun May 28 18:32:36 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 8A7959FA510 + for ; + Sun, 28 May 2006 18:32:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 71291-09 + for ; + Sun, 28 May 2006 18:32:26 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 198CE9F9F3D + for ; + Sun, 28 May 2006 18:32:26 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4SLWJbK000160; + Sun, 28 May 2006 17:32:19 -0400 (EDT) +To: Greg Stark +cc: Brendan Duddridge , + PostgreSQL Performance +Subject: Re: App very unresponsive while performing simple update +In-reply-to: <87slmum3th.fsf@stark.xeocode.com> +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> + <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> + <874pzanvk6.fsf@stark.xeocode.com> <17733.1148832292@sss.pgh.pa.us> + <87slmum3th.fsf@stark.xeocode.com> +Comments: In-reply-to Greg Stark + message dated "28 May 2006 13:55:54 -0400" +Date: Sun, 28 May 2006 17:32:19 -0400 +Message-ID: <159.1148851939@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/509 +X-Sequence-Number: 19296 + +Greg Stark writes: +> Tom Lane writes: +>> And what PG version is this? Alvaro fixed the +>> foreign-keys-take-exclusive-locks problem in 8.1 ... + +> Except I don't think this is taking an exclusive lock at all. The original +> post had the deadlock detection fire on a SharedLock. + +Yeah, but it was a ShareLock on a transaction ID, which is the trace +of something doing XactLockTableWait, which is only done if we're +blocking on a locked or updated-but-uncommitted row. + +Since Brendan says he's using 8.1, the FK theory is out, and I think +what this probably is is a garden-variety deadlock on tuple updates, ie, +two concurrent transactions tried to update the same tuples in different +orders. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 30 17:57:06 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 503ED9FA5D8 + for ; + Sun, 28 May 2006 18:56:42 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 76349-03 + for ; + Sun, 28 May 2006 18:56:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 1A6059F9F3D + for ; + Sun, 28 May 2006 18:56:31 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 9826831963; Sun, 28 May 2006 23:56:29 +0200 (MET DST) +Date: Sun, 28 May 2006 23:56:27 +0200 +From: Erwin Brandstetter +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql,pgsql.performance +Subject: Re: Query performance +References: + <1148294589.715695@proxy.dienste.wien.at> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +Message-ID: +X-Complaints-To: abuse@chello.at +Organization: chello.at +Lines: 30 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/547 +X-Sequence-Number: 19334 + +Antonio Batovanja wrote: +> Laurenz Albe wrote: +> +>> Antonio Batovanja wrote: +>>> I'm having trouble understanding, why a specific query on a small +>>> database is taking so long... +>>> +>> Before I try to understand the execution plans: +>> +>> Have you run ANALYZE on the tables involved before you ran the query? +> +> Hi, +> +> Just to be on the safe side, I've run ANALYZE now. +> Here are the query plans for the two queries: + +I suspect a misunderstanding here. What Laurenz probably meant is to run + analyze on the involved _tables_ so the statistics data is refreshed. +If the query planner runs with outdated statistics, queries may perform +very poorly. Try + + vacuum full analyze yourdatabase + +To fully vacuum your database and analyze all tables. +(vacuum full is extra, but can't hurt.) + +http://www.postgresql.org/docs/8.1/static/sql-vacuum.html +http://www.postgresql.org/docs/8.1/static/sql-analyze.html + +Regards, Erwin + +From pgsql-performance-owner@postgresql.org Tue May 30 17:57:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9A7909FA48C + for ; + Sun, 28 May 2006 19:39:05 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 81906-09 + for ; + Sun, 28 May 2006 19:38:58 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) + by postgresql.org (Postfix) with ESMTP id 624699FA131 + for ; + Sun, 28 May 2006 19:38:59 -0300 (ADT) +Received: by floppy.pyrenet.fr (Postfix, from userid 106) + id 73C8931963; Mon, 29 May 2006 00:38:57 +0200 (MET DST) +Date: Mon, 29 May 2006 00:38:55 +0200 +From: Erwin Brandstetter +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +X-Newsgroups: comp.databases.postgresql,pgsql.performance +Subject: Re: Query performance +References: + <1148294589.715695@proxy.dienste.wien.at> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +Message-ID: +X-Complaints-To: abuse@chello.at +Organization: chello.at +Lines: 65 +To: pgsql-performance@postgresql.org +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/546 +X-Sequence-Number: 19333 + +Antonio Batovanja wrote: +(...) + +> 1) the slooooow query: +> EXPLAIN ANALYZE SELECT DISTINCT ldap_entries.id, organization.id, +> text('organization') AS objectClass, ldap_entries.dn AS dn FROM +> ldap_entries, organization, ldap_entry_objclasses WHERE +> organization.id=ldap_entries.keyval AND ldap_entries.oc_map_id=1 AND +> upper(ldap_entries.dn) LIKE '%DC=HUMANOMED,DC=AT' AND 1=1 OR +> (ldap_entries.id=ldap_entry_objclasses.entry_id AND +> ldap_entry_objclasses.oc_name='organization'); + + +First, presenting your query in any readable form might be helpful if +you want the community to help you. (Hint! Hint!) + +SELECT DISTINCT ldap_entries.id, organization.id, + text('organization') AS objectClass, ldap_entries.dn AS dn + FROM ldap_entries, organization, ldap_entry_objclasses + WHERE organization.id=ldap_entries.keyval + AND ldap_entries.oc_map_id=1 + AND upper(ldap_entries.dn) LIKE '%DC=HUMANOMED,DC=AT' + AND 1=1 + OR (ldap_entries.id=ldap_entry_objclasses.entry_id + AND ldap_entry_objclasses.oc_name='organization'); + +Next, you might want to use aliases to make it more readable. + +SELECT DISTINCT e.id, o.id, text('organization') AS objectClass, e.dn AS dn + FROM ldap_entries AS e, organization AS o, ldap_entry_objclasses AS eo + WHERE o.id=e.keyval + AND e.oc_map_id=1 + AND upper(e.dn) LIKE '%DC=HUMANOMED,DC=AT' + AND 1=1 + OR (e.id=eo.entry_id + AND eo.oc_name='organization'); + +There are a couple redundant (nonsensical) items, syntax-wise. Let's +strip these: + +SELECT DISTINCT e.id, o.id, text('organization') AS objectClass, e.dn + FROM ldap_entries AS e, organization AS o, ldap_entry_objclasses AS eo + WHERE o.id=e.keyval + AND e.oc_map_id=1 + AND e.dn ILIKE '%DC=HUMANOMED,DC=AT' + OR e.id=eo.entry_id + AND eo.oc_name='organization'; + +And finally, I suspect the lexical precedence of AND and OR might be the +issue here. +http://www.postgresql.org/docs/8.1/static/sql-syntax.html#SQL-PRECEDENCE +Maybe that is what you really want (just guessing): + +SELECT DISTINCT e.id, o.id, text('organization') AS objectClass, e.dn + FROM ldap_entries e + JOIN organization o ON o.id=e.keyval + LEFT JOIN ldap_entry_objclasses eo ON eo.entry_id=e.id + WHERE e.oc_map_id=1 + AND e.dn ILIKE '%DC=HUMANOMED,DC=AT' + OR eo.oc_name='organization)'; + +I didn't take the time to read the rest. My appologies if I guessed wrong. + + +Regards, Erwin + +From pgsql-performance-owner@postgresql.org Sun May 28 20:21:15 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D0C4C9FA32D + for ; + Sun, 28 May 2006 20:21:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 87906-01 + for ; + Sun, 28 May 2006 20:21:08 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id 978369FA131 + for ; + Sun, 28 May 2006 20:21:09 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1FkUZA-0003hh-00; Sun, 28 May 2006 19:21:00 -0400 +To: Brendan Duddridge +Cc: Tom Lane , Greg Stark , + PostgreSQL Performance +Subject: Re: App very unresponsive while performing simple update +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> + <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> + <874pzanvk6.fsf@stark.xeocode.com> <17733.1148832292@sss.pgh.pa.us> + <3C756C36-DC66-4D13-B2CE-99CFCE7BF390@clickspace.com> +In-Reply-To: <3C756C36-DC66-4D13-B2CE-99CFCE7BF390@clickspace.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 28 May 2006 19:20:59 -0400 +Message-ID: <87hd39n3c4.fsf@stark.xeocode.com> +Lines: 48 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/510 +X-Sequence-Number: 19297 + +Brendan Duddridge writes: + +> We do have foreign keys on other tables that reference the product table. +> Also, there will be updates going on at the same time as this update. When +> anyone clicks on a product details link, we issue an update statement to +> increment the click_count on the product. e.g. update product set click_count +> = click_count + 1; + +You should realize this will produce a lot of garbage records and mean you'll +have to be running vacuum very frequently. You might consider instead of +updating the main table inserting into a separate clickstream table. That +trades off not getting instantaneous live totals with isolating the +maintenance headache in a single place. That table will grow large but you can +prune it at your leisure without impacting query performance on your main +tables. + +> There are 1.2 million rows in this table and my update will affect 200,000 +> of them. +> +> We do have indexes on all foreign keys that reference the product table. + +Well I suppose you had an update running concurrently against one of CATEGORY, +MANUFACTURER, or MEDIA. Do any of those tables have a reference back to the +product table? Is it possible to have a record with a reference back to the +same record that refers to it? + +I think you're seeing the problem because these foreign keys are all initially +deferred. That means you can update both tables and then can't commit either +one because it needs to obtain a shared lock on the other record which is +already locked for the update. + +I'm not certain that making them not deferred would actually eliminate the +deadlock. It might just make it less likely. + +The deferred foreign key checks may also be related to the performance +complaints. In my experience they're quite fast but I wonder what happens when +you do a large batch update and then need to perform a whole slew of deferred +foreign key checks. + +More likely you were blocking on some lock. Until that other query holding +that lock tries to commit Postgres won't actually detect a deadlock, it'll +just sit waiting until the lock becomes available. + +Also, you have a lot of indexes here. That alone will make updates pretty +slow. + +-- +greg + + +From pgsql-performance-owner@postgresql.org Sun May 28 20:24:31 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A7A7F9FA32D + for ; + Sun, 28 May 2006 20:24:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 88954-01 + for ; + Sun, 28 May 2006 20:24:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id 083909FA131 + for ; + Sun, 28 May 2006 20:24:22 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1FkUcI-00043F-00; Sun, 28 May 2006 19:24:14 -0400 +To: Tom Lane +Cc: Greg Stark , Brendan Duddridge , + PostgreSQL Performance +Subject: Re: App very unresponsive while performing simple update +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> + <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> + <874pzanvk6.fsf@stark.xeocode.com> <17733.1148832292@sss.pgh.pa.us> + <87slmum3th.fsf@stark.xeocode.com> <159.1148851939@sss.pgh.pa.us> +In-Reply-To: <159.1148851939@sss.pgh.pa.us> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 28 May 2006 19:24:14 -0400 +Message-ID: <8764jpn36p.fsf@stark.xeocode.com> +Lines: 20 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/511 +X-Sequence-Number: 19298 + + +Tom Lane writes: + +> Greg Stark writes: +> +> > Except I don't think this is taking an exclusive lock at all. The original +> > post had the deadlock detection fire on a SharedLock. +> +> Yeah, but it was a ShareLock on a transaction ID, which is the trace +> of something doing XactLockTableWait, which is only done if we're +> blocking on a locked or updated-but-uncommitted row. + +Oops, didn't see this before I sent my last message. Brendan, in case it's not +clear, in case of a conflict between my explanation and Tom's listen to Tom. + +:) + + +-- +greg + + +From pgsql-performance-owner@postgresql.org Mon May 29 06:53:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B5FA59FA380 + for ; + Mon, 29 May 2006 06:53:37 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 65005-09 + for ; + Mon, 29 May 2006 06:53:25 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from py-out-1112.google.com (py-out-1112.google.com + [64.233.166.176]) + by postgresql.org (Postfix) with ESMTP id 68C1D9FA2FA + for ; + Mon, 29 May 2006 06:53:25 -0300 (ADT) +Received: by py-out-1112.google.com with SMTP id o67so16959pye + for ; + Mon, 29 May 2006 02:53:24 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; + b=I3HhcEtwx+WF/87r8dHZcAkDF32NSExlF0FyKNWc8PXcF2C2ZNNy6bt1xsg6Szgu7dLEXJI4LESiece4Lbz6pjrmHcx28N3ITI4W+s1+B6vLK8XuTPspVz+/bwp9G1eXF3Flo+tvLcBGV2+XJmulL+n59vgRBWaWDZ+bdRGECX8= +Received: by 10.35.109.2 with SMTP id l2mr589382pym; + Mon, 29 May 2006 02:53:24 -0700 (PDT) +Received: by 10.35.89.9 with HTTP; Mon, 29 May 2006 02:53:24 -0700 (PDT) +Message-ID: <8cac8dd0605290253v75d43b9p249ebf58ee28b63c@mail.gmail.com> +Date: Mon, 29 May 2006 15:53:24 +0600 +From: "Anton Maksimenkov" +To: pgsql-performance@postgresql.org +Subject: select with "like" from another table +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/512 +X-Sequence-Number: 19299 + +Hi. + +I have 2 tables - one with calls numbers and another with calls codes. +The structure almost like this: +billing=3D# \d a_voip + Table "public.a_voip" + Column | Type | + Modifiers +--------------------+-----------------------------+------------------------= +----------------------------- + id | integer | not null default +nextval('a_voip_id_seq'::regclass) + tm | timestamp without time zone | not null + user_name | character varying(50) | not null +... + calling_station_id | character varying(20) | not null + called_station_id | character varying(20) | not null +Indexes: + "a_voip_pkey" PRIMARY KEY, btree (id) + "a_voip_tm" btree (tm) + +billing=3D# \d a_voip_codes + Table "public.a_voip_codes" + Column | Type | Modifiers +--------+-----------------------+----------- + code | integer | not null + region | character varying(77) | + tarif | numeric(13,7) | +Indexes: + "a_voip_codes_pkey" PRIMARY KEY, btree (code) + +I need to select longest codes from a_voip_codes which match with the +the called_station_id. Because codes (very rarely) changes I construct +query + +SELECT user_name, called_station_id, +(SELECT code FROM a_voip_codes AS c where v.called_station_id like +c.code || '%' order by code desc limit 1) AS code + FROM a_voip AS v WHERE user_name =3D 'dixi' AND tm between '2006-04-01' +and '2006-05-01' group by user_name, called_station_id; + +Analyzed variant +billing=3D# explain analyze SELECT user_name, called_station_id, (SELECT +code FROM a_voip_codes AS c where v.called_station_id like c.code || +'%' order by code desc limit 1) AS code FROM a_voip AS v WHERE +user_name =3D 'dixi' AND tm between '2006-04-01' and '2006-05-01' group +by user_name, called_station_id; + + QUERY PLAN +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +------- + HashAggregate (cost=3D11515.93..12106.26 rows=3D69 width=3D22) (actual +time=3D215.719..677.044 rows=3D130 loops=3D1) + -> Bitmap Heap Scan on a_voip v (cost=3D1106.66..11513.16 rows=3D554 +width=3D22) (actual time=3D72.336..207.618 rows=3D848 loops=3D1) + Recheck Cond: ((tm >=3D '2006-04-01 00:00:00'::timestamp +without time zone) AND (tm <=3D '2006-05-01 00:00:00'::timestamp without +time zone)) + Filter: ((user_name)::text =3D 'dixi'::text) + -> Bitmap Index Scan on a_voip_tm (cost=3D0.00..1106.66 +rows=3D90943 width=3D0) (actual time=3D69.441..69.441 rows=3D93594 loops=3D= +1) + Index Cond: ((tm >=3D '2006-04-01 00:00:00'::timestamp +without time zone) AND (tm <=3D '2006-05-01 00:00:00'::timestamp without +time zone)) + SubPlan + -> Limit (cost=3D0.00..8.55 rows=3D1 width=3D4) (actual +time=3D3.565..3.567 rows=3D1 loops=3D130) + -> Index Scan Backward using a_voip_codes_pkey on +a_voip_codes c (cost=3D0.00..85.45 rows=3D10 width=3D4) (actual +time=3D3.560..3.560 rows=3D1 loops=3D130) + Filter: (($0)::text ~~ ((code)::text || '%'::text)) + Total runtime: 678.186 ms +(11 rows) + +It is ugly, however not so long (but only for 69 rows). If I want to +select for ALL users it goes veeeery long: +billing=3D# explain analyze SELECT user_name, called_station_id, (SELECT +code FROM a_voip_codes AS c where v.called_station_id like c.code || +'%' order by code desc limit 1) AS code FROM a_voip AS v WHERE tm +between '2006-04-01' and '2006-05-01' group by user_name, +called_station_id; + + QUERY PLAN +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +--------- + HashAggregate (cost=3D11740.52..107543.85 rows=3D11198 width=3D22) (actua= +l +time=3D779.488..75637.623 rows=3D20564 loops=3D1) + -> Bitmap Heap Scan on a_voip v (cost=3D1106.66..11285.81 +rows=3D90943 width=3D22) (actual time=3D72.539..274.850 rows=3D90204 loops= +=3D1) + Recheck Cond: ((tm >=3D '2006-04-01 00:00:00'::timestamp +without time zone) AND (tm <=3D '2006-05-01 00:00:00'::timestamp without +time zone)) + -> Bitmap Index Scan on a_voip_tm (cost=3D0.00..1106.66 +rows=3D90943 width=3D0) (actual time=3D69.853..69.853 rows=3D93594 loops=3D= +1) + Index Cond: ((tm >=3D '2006-04-01 00:00:00'::timestamp +without time zone) AND (tm <=3D '2006-05-01 00:00:00'::timestamp without +time zone)) + SubPlan + -> Limit (cost=3D0.00..8.55 rows=3D1 width=3D4) (actual +time=3D3.631..3.633 rows=3D1 loops=3D20564) + -> Index Scan Backward using a_voip_codes_pkey on +a_voip_codes c (cost=3D0.00..85.45 rows=3D10 width=3D4) (actual +time=3D3.623..3.623 rows=3D1 loops=3D20564) + Filter: (($0)::text ~~ ((code)::text || '%'::text)) + Total runtime: 75652.199 ms +(10 rows) + +So I want to ask, how can I reorganize query/structure for achieve +good performance? + + I experiment with additional column (matched_code) for a_voip table +and think about RULE which will update that column "matched_code" +doing the (SELECT code FROM a_voip_codes AS c where +v.called_station_id like c.code || '%' order by code desc limit 1) job +when a_voip_codes updated. Or about TRIGGER. But this may also takes +long time, especially with short "code" numbers (like 1 digit). Look: + +billing=3D# explain analyze UPDATE a_voip SET matched_code =3D (SELECT +code FROM a_voip_codes AS c WHERE a_voip.called_station_id like c.code +|| '%' order by code desc limit 1) WHERE matched_code LIKE '1%'; + + QUERY PLAN +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +---------- + Bitmap Heap Scan on a_voip (cost=3D20.34..20467.27 rows=3D2057 +width=3D168) (actual time=3D13.407..22201.369 rows=3D2028 loops=3D1) + Filter: ((matched_code)::text ~~ '1%'::text) + -> Bitmap Index Scan on a_voip_matched_code (cost=3D0.00..20.34 +rows=3D2057 width=3D0) (actual time=3D2.035..2.035 rows=3D2028 loops=3D1) + Index Cond: (((matched_code)::text >=3D '1'::character varying) +AND ((matched_code)::text < '2'::character varying)) + SubPlan + -> Limit (cost=3D0.00..8.55 rows=3D1 width=3D4) (actual +time=3D10.909..10.911 rows=3D1 loops=3D2028) + -> Index Scan Backward using a_voip_codes_pkey on +a_voip_codes c (cost=3D0.00..85.45 rows=3D10 width=3D4) (actual +time=3D10.923..10.923 rows=3D1 loops=3D2028) + Filter: (($0)::text ~~ ((code)::text || '%'::text)) + Total runtime: 23216.770 ms +(9 rows) + +Is there any other ways to connect longest "code" with "called_station_id"? +--=20 +engineer + +From pgsql-performance-owner@postgresql.org Mon May 29 07:36:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 581259FA315 + for ; + Mon, 29 May 2006 07:36:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 74643-02 + for ; + Mon, 29 May 2006 07:36:45 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nz-out-0102.google.com (nz-out-0102.google.com + [64.233.162.199]) + by postgresql.org (Postfix) with ESMTP id 42FA19FA2C7 + for ; + Mon, 29 May 2006 07:36:44 -0300 (ADT) +Received: by nz-out-0102.google.com with SMTP id o1so522113nzf + for ; + Mon, 29 May 2006 03:36:43 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=X5a8MwTwO/vf9YwuO/ZdeMD3K3f/2l7Ui5dFxyWG4NdPKTo0kS+mwM9Vo5bUsr6st8f29bkcmNRxX3lLmYkHpyu5HxdOeGbtnvboGUjZRQ2cMnXxJoT5llCKYA3ePdTnMAbZBOa3gm63adC+oF2FAcpSa7nE0C7aprxRrRKgUHA= +Received: by 10.36.119.18 with SMTP id r18mr2866380nzc; + Mon, 29 May 2006 03:36:43 -0700 (PDT) +Received: by 10.36.97.2 with HTTP; Mon, 29 May 2006 03:36:43 -0700 (PDT) +Message-ID: <3c1395330605290336q5c894215ge28eea597626c781@mail.gmail.com> +Date: Mon, 29 May 2006 20:36:43 +1000 +From: "chris smith" +To: "Anton Maksimenkov" +Subject: Re: select with "like" from another table +Cc: pgsql-performance@postgresql.org +In-Reply-To: <8cac8dd0605290253v75d43b9p249ebf58ee28b63c@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <8cac8dd0605290253v75d43b9p249ebf58ee28b63c@mail.gmail.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/513 +X-Sequence-Number: 19300 + +On 5/29/06, Anton Maksimenkov wrote: +> Hi. +> +> I have 2 tables - one with calls numbers and another with calls codes. +> The structure almost like this: +... + +How long does this query take? + +SELECT code FROM a_voip_codes c, a_voip v where v.called_station_id +like c.code || +'%' order by code desc limit 1 + +I wonder if you'll benefit from an index on a_voip(called_station_id) +to speed up this join. + +--=20 +Postgresql & php tutorials +http://www.designmagick.com/ + +From pgsql-performance-owner@postgresql.org Mon May 29 08:11:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7028C9FA16E + for ; + Mon, 29 May 2006 08:11:08 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 79357-01 + for ; + Mon, 29 May 2006 08:11:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.logix-tt.com (mail.logix-tt.com [212.211.145.186]) + by postgresql.org (Postfix) with ESMTP id 7B6219FA2C7 + for ; + Mon, 29 May 2006 08:11:01 -0300 (ADT) +Received: from kingfisher.intern.logix-tt.com (T94a6.t.pppool.de + [89.55.148.166]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by mail.logix-tt.com (Postfix) with ESMTP id C5DF66583A; + Mon, 29 May 2006 13:12:21 +0200 (CEST) +Received: from [127.0.0.1] (localhost [127.0.0.1]) + by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 5C12D1819FBDD; + Mon, 29 May 2006 13:11:13 +0200 (CEST) +Message-ID: <447AD6D1.3070904@logix-tt.com> +Date: Mon, 29 May 2006 13:11:13 +0200 +From: Markus Schaber +Organization: Logical Tracking and Tracing International AG, Switzerland +User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: "Daniel J. Luke" +Cc: pgsql-performance@postgresql.org +Subject: Re: Getting even more insert performance (250m+rows/day) +References: + + <7E2D9162-867B-4DB1-B8A3-9ED701434488@geeklair.net> +In-Reply-To: <7E2D9162-867B-4DB1-B8A3-9ED701434488@geeklair.net> +X-Enigmail-Version: 0.93.0.0 +Content-Type: text/plain; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/514 +X-Sequence-Number: 19301 + +Hi, Daniel, + +Daniel J. Luke wrote: + +> One big transaction every 5 minutes using 'COPY FROM' (instead of +> inserts). + +Are you using "COPY table FROM '/path/to/file'", having the file sitting +on the server, or "COPY table FROM STDIN" or psql "/copy", having the +file sitting on the client? + + From our tests, having the file on the server can speed up the things by + factor 2 or 3 in some cases. + +Also, using BINARY copy may give great benefits due to lower parsing +overhead. + +As you say you're I/O bound, spreading tables, indices, wal and input +file to different spindles won't help you much. + + +HTH +Markus + + + +-- +Markus Schaber | Logical Tracking&Tracing International AG +Dipl. Inf. | Software Development GIS + +Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org + +From pgsql-performance-owner@postgresql.org Mon May 29 11:33:56 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D59529FA16E + for ; + Mon, 29 May 2006 11:33:55 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 14268-03-3 + for ; + Mon, 29 May 2006 11:33:47 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from swordfish.dnsvelocity.com (swordfish.dnsvelocity.com + [216.67.224.90]) + by postgresql.org (Postfix) with ESMTP id A0F1E9FA2C7 + for ; + Mon, 29 May 2006 11:33:47 -0300 (ADT) +Received: from [24.87.22.207] (port=4446 helo=chris) + by swordfish.dnsvelocity.com with esmtpa (Exim 4.52) + id 1Fkio7-00089L-Jo; Mon, 29 May 2006 15:33:23 +0100 +Message-ID: <010201c6832c$d6ab7b80$6401a8c0@chris> +From: "Cstdenis" +To: "Markus Schaber" +Cc: +References: <03e001c67b99$8321f010$6401a8c0@chris> + <4471D915.3010109@logix-tt.com> +Subject: Re: How can I make this query faster (resend) +Date: Mon, 29 May 2006 07:33:18 -0700 +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.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +X-Antivirus-Scanner: Clean mail though you should still use an Antivirus +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - swordfish.dnsvelocity.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] +X-AntiAbuse: Sender Address Domain - voicio.com +X-Source: +X-Source-Args: +X-Source-Dir: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/515 +X-Sequence-Number: 19302 + +(re-sending because my first one forgot the CC to the list. Sorry) + +I moved my database to a more powerful server. Mirrored ultra 320 SCSI HDs +and 2GB of ram. It performs much faster. + +I also changed some conf settings accordingly +work_mem = 10240 +shared_buffers = 25600 +max_connections = 450 (Also moved the webserver and needed more connections +during the DNS propagation). + +I've been looking into pgpool. If I understand things correctly I can have +persistent connections from all 256 apache processes to a pgpool and it can +have like 30 persistent connections to the actual server thus saving lots of +server memory (due to very high concurrency I would probably actually use at +least 100) Is this correct? + +However, memory doesn't seem to be my problem anymore, the query is still +taking longer than I'd like for the larger categories (6 seconds for one +with 1300 pictures) but its more managable. The problem now is that my +server's load average during peak hours has gone as high as 30 (tho the +server seems to still be responding fairly quickly it still worrysome) + + +Given my new server specs can anyone suggest any other config file +improvements? Perhaps some of the *_cost variables could be adjusted to +better reflect my server's hardware? + +----- Original Message ----- +From: "Markus Schaber" +To: "Cstdenis" +Cc: +Sent: Monday, May 22, 2006 8:30 AM +Subject: Re: [PERFORM] How can I make this query faster (resend) + + +> Hi, Cstendis, +> +> Cstdenis wrote: +> +> > Server is a dual xeon with a gig of ram dedicated mostly to postgresql. +> > Here is the changed lines in my postgresql.conf: +http://pastebin.ca/57222 +> +> 3M is really low for a production server. +> +> Try using pg_pool and limiting it to about 30 or so backend connections, +> and then give them at least 30 megs of RAM each. +> +> This should also cut down the connection creation overhead. +> +> HTH, +> Markus +> -- +> Markus Schaber | Logical Tracking&Tracing International AG +> Dipl. Inf. | Software Development GIS +> +> Fight against software patents in EU! www.ffii.org +www.nosoftwarepatents.org +> + + + +From pgsql-performance-owner@postgresql.org Mon May 29 11:35:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C52909FA2C7 + for ; + Mon, 29 May 2006 11:35:31 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 13123-09 + for ; + Mon, 29 May 2006 11:35:22 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from swordfish.dnsvelocity.com (swordfish.dnsvelocity.com + [216.67.224.90]) + by postgresql.org (Postfix) with ESMTP id E5FD69FA16E + for ; + Mon, 29 May 2006 11:35:22 -0300 (ADT) +Received: from [24.87.22.207] (port=4510 helo=chris) + by swordfish.dnsvelocity.com with esmtpa (Exim 4.52) + id 1Fkiq1-0008IR-4d; Mon, 29 May 2006 15:35:21 +0100 +Message-ID: <013801c6832d$1cf73d90$6401a8c0@chris> +From: "Cstdenis" +To: "Nis Jorgensen" +Cc: +References: <03e001c67b99$8321f010$6401a8c0@chris> + <447177B2.2020109@superlativ.dk> +Subject: Re: How can I make this query faster (resend) +Date: Mon, 29 May 2006 07:35:14 -0700 +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.1506 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506 +X-Antivirus-Scanner: Clean mail though you should still use an Antivirus +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - swordfish.dnsvelocity.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] +X-AntiAbuse: Sender Address Domain - voicio.com +X-Source: +X-Source-Args: +X-Source-Dir: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/516 +X-Sequence-Number: 19303 + +(Resending because my other send didn't get a CC to the list) + +From: "Jim C. Nasby" +To: "Cstdenis" +Cc: +Sent: Monday, May 22, 2006 8:20 AM +Subject: Re: [PERFORM] How can I make this query faster (resend) + + +> On Fri, May 19, 2006 at 03:56:49PM -0700, Cstdenis wrote: +> > (Its been a hour and I dont see my message on the list so I'm sending it +again. I've moved the queries and analyze out of the email incase it was +rejected because too long) +> > +> > query: http://pastebin.ca/57218 +> > +> > In the pictures table all the ratings have a shared index +> > +> > CREATE INDEX idx_rating ON pictures USING btree (rating_nudity, +rating_violence, rating_sex, rating_racism, rating_spoilers, rating_yaoi, +rating_yuri, rating_profanity); +> > +> > and approved and date_submitted and user_id also have their own btree +indexes. +> > +> > In the picture_categories table pid and cat_id have their own btree +indices plus one together. +> > +> > Full table definition: http://pastebin.ca/57219 +> > +> > the cat_id and rating values vary from query to query. The one listed +above took 54 seconds in a test run just now. Here is explain analyze: +http://pastebin.ca/57220 +> +> pictures is the interesting table here. It looks like the planner would +> do better to choose something other than a nested loop on it. Try +> running EXPLAIN ANALYZE on the query with enable_nestloop=off and see +> what you get (you'll need to compare it to what you get with +> enable_nestloop on to see what the change is). + +With enable_nestloop=off the same query as is explained further down in this +email took much longer 63 seconds insted of 6. It decided to do sequencial +scans on pictures and users with nested loop disabled. + +Merge Join (cost=146329.63..146963.96 rows=231 width=66) (actual +time=61610.538..62749.176 rows=1305 loops=1) + Merge Cond: ("outer".user_id = "inner".user_id) + -> Sort (cost=123828.88..123829.46 rows=231 width=47) (actual +time=60445.367..60451.176 rows=1305 loops=1) + Sort Key: pictures.user_id + -> Hash Join (cost=634.36..123819.81 rows=231 width=47) (actual +time=128.088..60423.623 rows=1305 loops=1) + Hash Cond: ("outer".pid = "inner".pid) + -> Seq Scan on pictures (cost=0.00..121670.43 rows=302543 +width=47) (actual time=0.210..58795.925 rows=291318 loops=1) + -> Hash (cost=633.78..633.78 rows=231 width=4) (actual +time=38.443..38.443 rows=1305 loops=1) + -> Bitmap Heap Scan on picture_categories +(cost=2.81..633.78 rows=231 width=4) (actual time=4.753..32.259 rows=1305 +loops=1) + Recheck Cond: (cat_id = 182) + -> Bitmap Index Scan on +idx_picture_categories_cat_id (cost=0.00..2.81 rows=231 width=0) (actual +time=4.398..4.398 rows=1305 loops=1) + Index Cond: (cat_id = 182) + -> Sort (cost=22500.74..22816.79 rows=126418 width=23) (actual +time=1163.788..1505.104 rows=52214 loops=1) + Sort Key: users.user_id + -> Seq Scan on users (cost=0.00..11788.18 rows=126418 width=23) +(actual time=0.017..692.992 rows=54605 loops=1) +Total runtime: 62776.720 ms + + +> > Both pictures and picture categories have about 287,000 rows +> > +> > This query needs to run in under about a second or it kills my site by +clogging apache slots (apache maxes out at 256 and I can have several +hundred people on my site at a time). How can I make it run faster? +> > +> > +> > Server is a dual xeon with a gig of ram dedicated mostly to postgresql. +> > Here is the changed lines in my postgresql.conf: +http://pastebin.ca/57222 +> +> I suspect the low work_mem may be why it's using a nested loop. In +> addition to the test above, it would be interesting to see what happens +> to the plan if you set work_mem to 10000. + +I moved to a more powerful server (2gb ram and mirrored scsi HDs) and upped +the work mem to 10mb. Its much faster now, however its still doing a nested +loop. (see also my reply to Markus Schaber) + + +Nested Loop (cost=2.81..3398.76 rows=231 width=66) (actual +time=14.946..5797.701 rows=1305 loops=1) + -> Nested Loop (cost=2.81..2022.71 rows=231 width=47) (actual +time=14.551..5181.042 rows=1305 loops=1) + -> Bitmap Heap Scan on picture_categories (cost=2.81..633.78 +rows=231 width=4) (actual time=9.966..140.606 rows=1305 loops=1) + Recheck Cond: (cat_id = 182) + -> Bitmap Index Scan on idx_picture_categories_cat_id +(cost=0.00..2.81 rows=231 width=0) (actual time=9.720..9.720 rows=1305 +loops=1) + Index Cond: (cat_id = 182) + -> Index Scan using pictures_pkey on pictures (cost=0.00..6.00 +rows=1 width=47) (actual time=3.802..3.820 rows=1 loops=1305) + Index Cond: (pictures.pid = "outer".pid) + -> Index Scan using users_pkey on users (cost=0.00..5.94 rows=1 +width=23) (actual time=0.095..0.100 rows=1 loops=1305) + Index Cond: ("outer".user_id = users.user_id) +Total runtime: 5812.238 ms + + +> To be honest, you're pushing things expecting a machine with only 1G to +> serve 300 active connections. How large is the database itself? + +The database is 3.7G on disk. There is about 1G of actual data in it -- the +rest is dead tuples and indices. (I vacuum regularly, but a vacuum full +causes too much downtime to do unless I have to) + +> > I know hyperthreading is considered something that can slow down a +server but with my very high concurancy (averages about 400-500 concurant +users during peak hours) I am hoping the extra virtual CPUs wil help. Anyone +have experance that says diferent at high concurancy? +> +> Best bet is to try it and see. Generally, people find HT hurts, but I +> recently saw it double the performance of pgbench on a windows XP +> machine, so it's possible that windows is just more clever about how to +> use it than linux is. + +Anyone know if those who have found it hurts are low concurancy complex cpu +intensive queries or high concurancy simple queries or both? I can +understand it hurting in the former, but not the later. I'll have to give it +a try I guess. It should at least help my very high load averages. + +> -- +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> + + + +From pgsql-performance-owner@postgresql.org Mon May 29 12:40:00 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A04209FA2C7 + for ; + Mon, 29 May 2006 12:40:00 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 22433-05 + for ; + Mon, 29 May 2006 12:39:53 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from py-out-1112.google.com (py-out-1112.google.com + [64.233.166.182]) + by postgresql.org (Postfix) with ESMTP id D164C9FA16E + for ; + Mon, 29 May 2006 12:39:52 -0300 (ADT) +Received: by py-out-1112.google.com with SMTP id o67so85641pye + for ; + Mon, 29 May 2006 08:39:51 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=cgHG/4IVXgsDws4xtyWOh8805GK6zvGcdzZefWbRBQCo0YNEqI7HogZWpeJXyJOcCtnbLwO9JCT7bMZQQQtkYMfP4OosYA/QgmlwWin5FLnZ580OH9pn33QMdF9uUehUtpPZCbYmLWjMRYQYIbCt11o7n4EFeiy8pulOSFHf4xs= +Received: by 10.35.91.15 with SMTP id t15mr977337pyl; + Mon, 29 May 2006 08:39:51 -0700 (PDT) +Received: by 10.35.89.9 with HTTP; Mon, 29 May 2006 08:39:51 -0700 (PDT) +Message-ID: <8cac8dd0605290839j1f1aa30bj124d617012da0009@mail.gmail.com> +Date: Mon, 29 May 2006 21:39:51 +0600 +From: "Anton Maksimenkov" +To: "chris smith" +Subject: Re: select with "like" from another table +Cc: pgsql-performance@postgresql.org +In-Reply-To: <3c1395330605290336q5c894215ge28eea597626c781@mail.gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +References: <8cac8dd0605290253v75d43b9p249ebf58ee28b63c@mail.gmail.com> + <3c1395330605290336q5c894215ge28eea597626c781@mail.gmail.com> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/517 +X-Sequence-Number: 19304 + +> > I have 2 tables - one with calls numbers and another with calls codes. +> > The structure almost like this: +> ... +> How long does this query take? +> +> SELECT code FROM a_voip_codes c, a_voip v where v.called_station_id +> like c.code || +> '%' order by code desc limit 1 + +billing=3D# explain analyze SELECT code FROM a_voip_codes c, a_voip v +where v.called_station_id like c.code || '%' order by code desc limit +1; + + QUERY PLAN +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +----- + Limit (cost=3D0.00..11.24 rows=3D1 width=3D4) (actual +time=3D15809.846..15809.848 rows=3D1 loops=3D1) + -> Nested Loop (cost=3D0.00..35877212.61 rows=3D3192650 width=3D4) +(actual time=3D15809.841..15809.841 rows=3D1 loops=3D1) + Join Filter: (("inner".called_station_id)::text ~~ +(("outer".code)::text || '%'::text)) + -> Index Scan Backward using a_voip_codes_pkey on +a_voip_codes c (cost=3D0.00..69.87 rows=3D2078 width=3D4) (actual +time=3D0.029..0.106 rows=3D6 loops=3D1) + -> Seq Scan on a_voip v (cost=3D0.00..11887.81 rows=3D307281 +width=3D13) (actual time=3D1.696..935.368 rows=3D254472 loops=3D6) + Total runtime: 15810.088 ms +(6 rows) + + +> I wonder if you'll benefit from an index on a_voip(called_station_id) +> to speed up this join. + +Yes, it's long. But index gives no help here: + +billing=3D# CREATE INDEX a_voip_called_station_id ON a_voip(called_station_= +id); +CREATE INDEX +billing=3D# vacuum analyze; +VACUUM +billing=3D# explain analyze SELECT code FROM a_voip_codes c, a_voip v +where v.called_station_id like c.code || '%' order by code desc limit +1; + + QUERY PLAN +---------------------------------------------------------------------------= +---------------------------------------------------------------------------= +----- + Limit (cost=3D0.00..11.27 rows=3D1 width=3D4) (actual +time=3D15254.783..15254.785 rows=3D1 loops=3D1) + -> Nested Loop (cost=3D0.00..35767665.65 rows=3D3172732 width=3D4) +(actual time=3D15254.778..15254.778 rows=3D1 loops=3D1) + Join Filter: (("inner".called_station_id)::text ~~ +(("outer".code)::text || '%'::text)) + -> Index Scan Backward using a_voip_codes_pkey on +a_voip_codes c (cost=3D0.00..69.87 rows=3D2078 width=3D4) (actual +time=3D0.021..0.097 rows=3D6 loops=3D1) + -> Seq Scan on a_voip v (cost=3D0.00..11868.64 rows=3D305364 +width=3D13) (actual time=3D0.006..750.337 rows=3D254472 loops=3D6) + Total runtime: 15255.066 ms +(6 rows) + + +The main problem with first (main) query: + +SELECT user_name, called_station_id, +(SELECT code FROM a_voip_codes AS c where v.called_station_id LIKE +c.code || '%' order by code desc limit 1) AS code + FROM a_voip AS v WHERE user_name =3D 'dixi' AND tm between '2006-04-01' +and '2006-05-01' group by user_name, called_station_id; + +is that internal (SELECT... v.called_station_id LIKE c.code || '%'...) +executed for each row, returned by external SELECT user_name... part. +So I looking how to avoid internal (SELECT ...) part of query. + + Terrible oracle gives something like "over by (partition by ... order +by code desc) rnum ... where rnum =3D 1" which works like DISTINCT and +numerate similate rows, then we get just longest (rnum =3D 1) rows. But +I can't imagine how to implement some kind of this algorithm with +postgres. +--=20 +engineer + +From pgsql-performance-owner@postgresql.org Tue May 30 17:57:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 083DC9FA2EB + for ; + Mon, 29 May 2006 21:26:58 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 88637-06 + for ; + Mon, 29 May 2006 21:26:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 71CC69FA2DB + for ; + Mon, 29 May 2006 21:26:53 -0300 (ADT) +Received: from smtp.sw.oz.au (alt.aurema.com [203.217.18.57]) + by svr4.postgresql.org (Postfix) with ESMTP id 0F92F5AFBA2 + for ; + Tue, 30 May 2006 00:26:52 +0000 (GMT) +Received: from [192.41.203.74] (anthonyr.sw.oz.au [192.41.203.74]) + by smtp.sw.oz.au with ESMTP id k4U0Qh4J029830 + for ; + Tue, 30 May 2006 10:26:43 +1000 (EST) +Message-ID: <447B9143.6010407@aurema.com> +Date: Tue, 30 May 2006 10:26:43 +1000 +From: Anthony Ransley +User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) +X-Accept-Language: en-us, en +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: Split select completes, single select doesn't and becomes IO bound! +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Scanned-By: MIMEDefang 2.52 on 192.41.203.35 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/548 +X-Sequence-Number: 19335 + +Can any one explain why the following query + +select f(q) from +( + select * from times + where '2006-03-01 00:00:00'<=q and q<'2006-03-08 00:00:00' + order by q +) v; + +never completes, but splitting up the time span into single days does work. + +select f(q) from +( + select * from times + where '2006-03-01 00:00:00'<=q and q<'2006-03-02 00:00:00' + order by q +) v; +select f(q) from +( + select * from times + where '2006-03-02 00:00:00'<=q and q<'2006-03-03 00:00:00' + order by q +) v; +... +select f(q) from +( + select * from times + where '2006-03-07 00:00:00'<=q and q<'2006-03-08 00:00:00' + order by q +) v; + +The stored procedure f(q) take a timestamp and does a select and a +calculation and then an update of a results table. The times table +containes only a 100 rows per day. It is also observed that the cpu +starts the query with 100% usage and then the slowly swings up and down +from 100% to 20% over the first half hour, and then by the following +morning the query is still running and the cpu usage is 3-5%. IO bound +i'm guessing as the hdd is in constant use at 5 to 15 MB per second usage. +In contrast the query that is split up into days has a 100% cpu usage +all the way through to its completion, which only takes twenty minutes +each. The computer is not being used for anything else, and is a dual +core Athlon 4400+ with 4GB of ram. + +Thanks for any information you can give on this. + +From pgsql-performance-owner@postgresql.org Tue May 30 00:22:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 21F019FA2EB + for ; + Tue, 30 May 2006 00:22:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 09995-10 + for ; + Tue, 30 May 2006 00:22:42 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id 1B4629FA2DB + for ; + Tue, 30 May 2006 00:22:42 -0300 (ADT) +Received: from localhost (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with SMTP id 4A4A7B81F + for ; + Mon, 29 May 2006 23:22:41 -0400 (EDT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id 15DF8B822; + Mon, 29 May 2006 23:22:37 -0400 (EDT) +Received: from zoraida.natserv.net (zoraida.natserv.net [66.114.65.147]) + by zoraida.natserv.net (Postfix) with ESMTP id D9024B81F; + Mon, 29 May 2006 23:22:36 -0400 (EDT) +References: <01b401c6794f$f27355e0$ddf71005@jonathanlaptop> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Jonathan Blitz +Cc: pgsql-performance@postgresql.org +Subject: Re: Adding and filling new column on big table +Date: Mon, 29 May 2006 23:22:36 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-DSPAM-Result: Innocent +X-DSPAM-Processed: Mon May 29 23:22:40 2006 +X-DSPAM-Confidence: 1.0000 +X-DSPAM-Probability: 0.0023 +X-DSPAM-Signature: 58,447bba80348141151220975 +X-DSPAM-Factors: 27, writes+>, 0.40000, Received*Mon+29, 0.40000, + Received*Mon+29, 0.40000, Date*May, 0.40000, never, 0.40000, + To*anykey.co.il>, 0.40000, Subject*on+big, 0.40000, + Content-Type*charset="US, 0.40000, Date*22+36, 0.40000, + Received*(zoraida.natserv.net+[66.114.65.147]), 0.40000, + Received*ESMTP, 0.40000, Received*ESMTP, 0.40000, + Content-Disposition*inline, 0.40000, Jonathan+Blitz, 0.40000, + References*<01b401c6794f$f27355e0$ddf71005+jonathanlaptop>, 0.40000, + Received*[66.114.65.147]), 0.40000, the+table?, 0.40000, + Date*Mon, 0.40000, about, 0.40000, + Message-ID*, + 0.40000, Received*(zoraida.natserv.net, 0.40000, + Subject*new+column, 0.40000, and+a, 0.40000, run+the, 0.40000, + and+hour, 0.40000, hour+and, 0.40000, ever, 0.40000 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/518 +X-Sequence-Number: 19305 + +Jonathan Blitz writes: + +> So, I have tried to run the following command. The command never finishes +> (I gave up after about and hour and a half!). + +Did you ever find what was the problem? +Perhaps you needed to run a vacuum full on the table? + + +From pgsql-performance-owner@postgresql.org Tue May 30 00:52:52 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 941079FA6A2 + for ; + Tue, 30 May 2006 00:52:51 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 13328-09 + for ; + Tue, 30 May 2006 00:52:46 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id 5595F9FA2EB + for ; + Tue, 30 May 2006 00:52:46 -0300 (ADT) +Received: from localhost (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with SMTP id 763D6B824 + for ; + Mon, 29 May 2006 23:52:45 -0400 (EDT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id 128CFB822; + Mon, 29 May 2006 23:52:36 -0400 (EDT) +Received: from zoraida.natserv.net (zoraida.natserv.net [66.114.65.147]) + by zoraida.natserv.net (Postfix) with ESMTP id B6949B81F; + Mon, 29 May 2006 23:52:35 -0400 (EDT) +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> + <4473553C.1010804@ca.sophos.com> + <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> + + <20060524213352.GN59464@pervasive.com> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Jim =?ISO-8859-1?B?Qy4=?= Nasby +Cc: Robin Ericsson , Dan Gorman , + pgsql-performance@postgresql.org +Subject: Re: Selects query stats? +Date: Mon, 29 May 2006 23:52:35 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-DSPAM-Result: Innocent +X-DSPAM-Processed: Mon May 29 23:52:45 2006 +X-DSPAM-Confidence: 1.0000 +X-DSPAM-Probability: 0.0023 +X-DSPAM-Signature: 58,447bc18d348141671817791 +X-DSPAM-Factors: 27, once, 0.40000, many, 0.40000, could, 0.40000, + could, 0.40000, but, 0.40000, but, 0.40000, what+the, 0.40000, + Cc*Dan+Gorman, 0.40000, in+MysQL, 0.40000, measure, 0.40000, + Received*Mon+29, 0.40000, Received*Mon+29, 0.40000, + be+very, 0.40000, By+the, 0.40000, Date*May, 0.40000, + how+moving, 0.40000, that+scenario, 0.40000, an, 0.40000, + we+hopefully, 0.40000, poster, 0.40000, + Cc*Robin+Ericsson, 0.40000, References*2A15+4823, 0.40000, + References*mail.gmail.com>+<20060524213352.GN59464, 0.40000, + of, 0.40000, of, 0.40000, References*4297+AF32, 0.40000, + References*4823, 0.40000 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/519 +X-Sequence-Number: 19306 + +I am not sure if this is what the original poster was refering to, but I +have used an application called mtop that shows how many queries per second +mysql is doing. + +In my case this is helpfull because we have a number of machines running +postfix and each incoming mail generates about 7 queries. Queries are all +very simmilar to each other in that scenario. + +Having access to that query/second stat allowed me to improve the +settings in MysQL. Ultimately once we migrated to a new server I could see +how moving to the new machine increased the speed at which we could accept +emails. + +I am, little by little, getting PostgreSQL to be used, but for now the +postfix queries are tied to MySQL. By the time we hopefully do move to +PostgreSQL for the Postfix backend it will be very helpfull to have some +sort of way to measure queries/time period. + + +From pgsql-performance-owner@postgresql.org Tue May 30 05:36:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 08F869FA5E9 + for ; + Tue, 30 May 2006 05:36:20 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 48761-01 + for ; + Tue, 30 May 2006 05:36:10 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from server.nextgap2000.com (server.nextgap2000.com [66.98.160.7]) + by postgresql.org (Postfix) with ESMTP id 6DD9B9FA317 + for ; + Tue, 30 May 2006 05:36:09 -0300 (ADT) +Received: from 85.64.46.244.dynamic.barak-online.net ([85.64.46.244] + helo=jonathanlaptop) + by server.nextgap2000.com with esmtpa (Exim 4.52) + id 1FkzhF-0005ua-CX; Tue, 30 May 2006 11:35:26 +0300 +From: "Jonathan Blitz" +To: "'Francisco Reyes'" +Cc: +Subject: Re: Adding and filling new column on big table +Date: Tue, 30 May 2006 11:35:55 +0200 +Message-ID: <005701c683cc$7757af00$ddf71005@jonathanlaptop> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="windows-1250" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook 11 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 +In-reply-to: +Thread-Index: AcaDmGicd+uhOzvEQ7y0TIFGt8auewAM9yVQ +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - server.nextgap2000.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] +X-AntiAbuse: Sender Address Domain - anykey.co.il +X-Source: +X-Source-Args: +X-Source-Dir: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/520 +X-Sequence-Number: 19307 + +> > So, I have tried to run the following command. The command never +finishes +> > (I gave up after about and hour and a half!). +> +> Did you ever find what was the problem? +> Perhaps you needed to run a vacuum full on the table? + +Nope. +I just gave up in the end and left it with NULL as the default value. +There were, in fact, over 2 million rows in the table rather than 1/4 of a +million so that was part of the problem. + +Jonathan + + +-- +No virus found in this outgoing message. +Checked by AVG Free Edition. +Version: 7.1.394 / Virus Database: 268.7.4/351 - Release Date: 05/29/2006 + + + +From pgsql-performance-owner@postgresql.org Tue May 30 07:33:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BEC919FA61D + for ; + Tue, 30 May 2006 07:33:36 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 61543-08 + for ; + Tue, 30 May 2006 07:33:29 -0300 (ADT) +X-Greylist: delayed 00:27:48.772798 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 12F879FA5E2 + for ; + Tue, 30 May 2006 07:33:29 -0300 (ADT) +Received: from gamma.datatechlabs.com (unknown [80.81.37.226]) + by svr4.postgresql.org (Postfix) with ESMTP id C5FE55AF83F + for ; + Tue, 30 May 2006 10:05:36 +0000 (GMT) +Received: from [10.1.1.205] (gamma.datatechlabs.com [80.81.37.227]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by gamma.datatechlabs.com (Postfix) with ESMTP id 4A5851CC45; + Tue, 30 May 2006 10:05:07 +0000 (UTC) +Message-ID: <447C4331.4090005@datatechlabs.com> +Date: Tue, 30 May 2006 13:05:53 +0000 +From: Alvis Tunkelis +User-Agent: Thunderbird 1.5.0.2 (X11/20060427) +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Cc: Francisco Reyes +Subject: Re: Selects query stats? +References: <9C4E40CF-6C06-4297-AF32-A7EF2A3F3C0F@hi5.com> + <4473512E.7020805@ca.sophos.com> + <82252882-2A15-4823-A517-7AB3161889D1@hi5.com> + <4473553C.1010804@ca.sophos.com> + <127D68F6-7620-4A62-8D1A-9B475E7571CD@hi5.com> + + <20060524213352.GN59464@pervasive.com> + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/521 +X-Sequence-Number: 19308 + +try pgtop. It is mytop clone for postgresql. + +Regards, +alvis + +Francisco Reyes wrote: +> I am not sure if this is what the original poster was refering to, but I +> have used an application called mtop that shows how many queries per +> second mysql is doing. +> +> In my case this is helpfull because we have a number of machines running +> postfix and each incoming mail generates about 7 queries. Queries are +> all very simmilar to each other in that scenario. +> +> Having access to that query/second stat allowed me to improve the +> settings in MysQL. Ultimately once we migrated to a new server I could +> see how moving to the new machine increased the speed at which we could +> accept emails. +> +> I am, little by little, getting PostgreSQL to be used, but for now the +> postfix queries are tied to MySQL. By the time we hopefully do move to +> PostgreSQL for the Postfix backend it will be very helpfull to have some +> sort of way to measure queries/time period. +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings + + +From pgsql-performance-owner@postgresql.org Tue May 30 11:18:22 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0B0E49FA5E6 + for ; + Tue, 30 May 2006 11:18:22 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 18887-05 + for ; + Tue, 30 May 2006 11:18:15 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) + by postgresql.org (Postfix) with ESMTP id 0AD439FA5E2 + for ; + Tue, 30 May 2006 11:18:14 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by pjetlic.mobart.hr (Postfix) with ESMTP id DBBF317A95 + for ; + Tue, 30 May 2006 16:18:10 +0200 (CEST) +Received: from pjetlic.mobart.hr ([127.0.0.1]) + by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 24981-02-10 for ; + Tue, 30 May 2006 16:18:10 +0200 (CEST) +Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) + (using SSLv3 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by pjetlic.mobart.hr (Postfix) with ESMTP id B6BB717A64 + for ; + Tue, 30 May 2006 16:18:10 +0200 (CEST) +Subject: Speedup hint needed, if available? :) +From: Mario Splivalo +Reply-To: mario.splivalo@mobart.hr +To: pgsql-performance@postgresql.org +Content-Type: text/plain +Organization: Mob-Art +Date: Tue, 30 May 2006 16:18:01 +0200 +Message-Id: <1148998681.18422.24.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by OpenSource AV+AS Mail Server +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/522 +X-Sequence-Number: 19309 + +Hello again. + +I have to track user subscriptions to certain mailinglists, and I also +need to track credits users have on those mailinglists. On one side I +have procedures that add credits, on other side I have procedures that +subtract available credits. Add/subtract is pretty intensive, around +30-50 adds per minute (usualy 10 or 100 credits), and around 200-500 +subtracts per minute (usualy by one or two credits). + +I have created table user_subscriptions to track user subscriptions to +certain mailing list. I have derived subscription_id as primary key. I +have two other tables, user_subscription_credits_given, and +_credits_taken, wich track credits for subscription added or subtracted +to or from certain subscription. I created those two tables so I could +eliminate a lot of UPDATES on user_subscriptions table (if I were to +have a column 'credits' in that table). user_subscriptions table is +projected to have around 100.000 rows, and _credits_given/_credits_taken +table is projected to have around 10.000.000 rows. + +Now, I have filled the tables with test data, and the query results is +kind of poor. It takes almost 50 seconds to get the data for the +particular subscription. Now, is there a way to speed this up, or I need +different approach? + +Here is the DDL/DML: + +CREATE TABLE user_subscriptions +( + subscription_id int4 NOT NULL DEFAULT +nextval('user_subscriptions_id_seq'::regclass), + user_id int4 NOT NULL, + mailinglist_id int4 NOT NULL, + valid_from timestamptz NOT NULL, + valid_to timestamptz, + CONSTRAINT user_subscriptions_pkey PRIMARY KEY (subscription_id) +); + +CREATE TABLE user_subscription_credits_given +( + subscription_id int4 NOT NULL, + credits int4 NOT NULL, + CONSTRAINT user_subscription_credits_given_fk__subscription_id FOREIGN +KEY (subscription_id) + REFERENCES user_subscriptions (subscription_id) MATCH SIMPLE + ON UPDATE NO ACTION ON DELETE NO ACTION +); + + +CREATE INDEX fki_user_subscriptions_fk__mailinglist_id + ON user_subscriptions + USING btree + (mailinglist_id); + +CREATE INDEX fki_user_subscriptions_fk__users_id + ON user_subscriptions + USING btree + (user_id); + +CREATE INDEX fki_user_subscription_credits_given_fk__subscription_id + ON user_subscription_credits_given + USING btree + (subscription_id); + +CREATE INDEX fki_user_subscription_credits_taken_fk__subscription_id + ON user_subscription_credits_taken + USING btree + (subscription_id); + + +Here is the query which gets information on particular user, shows +subscriptions to mailinglists and available credits on those +mailinglists: + +SELECT u.subscription_id, u.user_id, u.mailinglist_id, u.valid_from, +u.valid_to, sum(credits.credits_given - credits.credits_taken)::integer +AS credits +FROM user_subscriptions u +LEFT JOIN + (SELECT user_subscription_credits_given.subscription_id, +user_subscription_credits_given.credits AS credits_given, 0 AS +credits_taken + FROM user_subscription_credits_given + UNION ALL + SELECT user_subscription_credits_taken.subscription_id, 0 AS +credits_given, user_subscription_credits_taken.credits AS credits_taken + FROM user_subscription_credits_taken) credits + ON u.subscription_id = credits.subscription_id +where + u.user_id = 1 +GROUP BY u.subscription_id, u.user_id, u.mailinglist_id, u.valid_from, +u.valid_to + +And here is the 'explain analyze' of the above query: + + +QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + HashAggregate (cost=200079055.24..200079055.28 rows=2 width=36) +(actual time=56527.153..56527.163 rows=2 loops=1) + -> Nested Loop Left Join (cost=200033690.72..200078931.34 rows=8260 +width=36) (actual time=0.432..54705.844 rows=275366 loops=1) + Join Filter: ("outer".subscription_id = +"inner".subscription_id) + -> Index Scan using fki_user_subscriptions_fk__users_id on +user_subscriptions u (cost=0.00..3.03 rows=2 width=28) (actual +time=0.030..0.055 rows=2 loops=1) + Index Cond: (user_id = 1) + -> Materialize (cost=200033690.72..200045984.63 rows=825991 +width=12) (actual time=0.043..22404.107 rows=826032 loops=2) + -> Subquery Scan credits +(cost=100000000.00..200028830.73 rows=825991 width=12) (actual +time=0.050..31500.589 rows=826032 loops=1) + -> Append (cost=100000000.00..200020570.82 +rows=825991 width=8) (actual time=0.041..22571.540 rows=826032 loops=1) + -> Subquery Scan "*SELECT* 1" +(cost=100000000.00..100001946.96 rows=78148 width=8) (actual +time=0.031..1226.640 rows=78148 loops=1) + -> Seq Scan on +user_subscription_credits_given (cost=100000000.00..100001165.48 +rows=78148 width=8) (actual time=0.022..404.253 rows=78148 loops=1) + -> Subquery Scan "*SELECT* 2" +(cost=100000000.00..100018623.86 rows=747843 width=8) (actual +time=0.032..12641.705 rows=747884 loops=1) + -> Seq Scan on +user_subscription_credits_taken (cost=100000000.00..100011145.43 +rows=747843 width=8) (actual time=0.023..4386.769 rows=747884 loops=1) + Total runtime: 56536.774 ms +(13 rows) + + +Thank you all in advance, + + Mario +-- +Mario Splivalo +Mob-Art +mario.splivalo@mobart.hr + +"I can do it quick, I can do it cheap, I can do it well. Pick any two." + + + +From pgsql-performance-owner@postgresql.org Tue May 30 11:31:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id BE7179FA5E6 + for ; + Tue, 30 May 2006 11:31:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 20339-08 + for ; + Tue, 30 May 2006 11:31:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from morpheus.bostonstock.com (unknown [192.233.205.44]) + by postgresql.org (Postfix) with ESMTP id 496CB9FA5E2 + for ; + Tue, 30 May 2006 11:31:16 -0300 (ADT) +Received: by MORPHEUS with Internet Mail Service (5.5.2653.19) + id <2R02FJ8T>; Tue, 30 May 2006 10:25:04 -0400 +Message-ID: + <9765373733A7DF4681B12225D2FC44050D6D0C@bosexprod001.bostonstock.local> +From: "mcelroy, tim" +To: pgsql-performance@postgresql.org +Subject: pg_dump issue +Date: Tue, 30 May 2006 10:31:08 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C683F5.B1039251" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/523 +X-Sequence-Number: 19310 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C683F5.B1039251 +Content-Type: text/plain; + charset="iso-8859-1" + +Good morning, + +I have identical postgres installations running on identical machines. Dual +Core AMD Opteron(tm) Processor 870 , 16GB RAM, Red Hat Linux 3.2.3-20 and +120GB worth of disk space on two drives. + +Recently, I have noticed that my nightly backups take longer on one machine +than on the other. I back up five (5) databases totaling 8.6GB in size. On +Prod001 the backups take app. 7 minutes, on Prod002 the backups take app. 26 +minutes! Quite a discrepancy. I checked myself than checked with our +Engineering staff and have been assured that the machines are identical +hardware wise, CPU, disk, etc. + +Question; has anyone run into a similar issue? Here is the command I use +for the nightly backup on both machines: + +pg_dump -F c -f $DB.backup.$DATE $DB + +Kind of scratching my head on this one.... + +Thank you, +Tim McElroy + + +------_=_NextPart_001_01C683F5.B1039251 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +pg_dump issue + + + +

Good morning, +

+ +

I have identical postgres installations running on = +identical machines.  Dual Core AMD Opteron(tm) Processor 870 , = +16GB RAM, Red Hat Linux 3.2.3-20 and 120GB worth of disk space on two = +drives.

+ +

Recently, I have noticed that my nightly backups take = +longer on one machine than on the other.  I back up five (5) = +databases totaling 8.6GB in size.  On Prod001 the backups take = +app. 7 minutes, on Prod002 the backups take app. 26 minutes!  = +Quite a discrepancy.  I checked myself than checked with our = +Engineering staff and have been assured that the machines are identical = +hardware wise, CPU, disk, etc. 

+ +

Question; has anyone run into a similar issue?  = +Here is the command I use for the nightly backup on both = +machines: +

+ +

pg_dump -F c -f $DB.backup.$DATE $DB +

+ +

Kind of scratching my head on this one.... +

+ +

Thank you, +
Tim McElroy +

+ + + +------_=_NextPart_001_01C683F5.B1039251-- + +From pgsql-performance-owner@postgresql.org Tue May 30 12:06:08 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 782319FA5E6 + for ; + Tue, 30 May 2006 12:06:07 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 25840-04 + for ; + Tue, 30 May 2006 12:06:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 605DD9FA5E2 + for ; + Tue, 30 May 2006 12:06:00 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4UF5uZ7023932; + Tue, 30 May 2006 11:05:56 -0400 (EDT) +To: mario.splivalo@mobart.hr +cc: pgsql-performance@postgresql.org +Subject: Re: Speedup hint needed, if available? :) +In-reply-to: <1148998681.18422.24.camel@localhost.localdomain> +References: <1148998681.18422.24.camel@localhost.localdomain> +Comments: In-reply-to Mario Splivalo + message dated "Tue, 30 May 2006 16:18:01 +0200" +Date: Tue, 30 May 2006 11:05:55 -0400 +Message-ID: <23931.1149001555@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/524 +X-Sequence-Number: 19311 + +Mario Splivalo writes: +> Here is the query which gets information on particular user, shows +> subscriptions to mailinglists and available credits on those +> mailinglists: + +> SELECT u.subscription_id, u.user_id, u.mailinglist_id, u.valid_from, +> u.valid_to, sum(credits.credits_given - credits.credits_taken)::integer +> AS credits +> FROM user_subscriptions u +> LEFT JOIN +> (SELECT user_subscription_credits_given.subscription_id, +> user_subscription_credits_given.credits AS credits_given, 0 AS +> credits_taken +> FROM user_subscription_credits_given +> UNION ALL +> SELECT user_subscription_credits_taken.subscription_id, 0 AS +> credits_given, user_subscription_credits_taken.credits AS credits_taken +> FROM user_subscription_credits_taken) credits +> ON u.subscription_id = credits.subscription_id +> where +> u.user_id = 1 +> GROUP BY u.subscription_id, u.user_id, u.mailinglist_id, u.valid_from, +> u.valid_to + +Do you have realistic test data? The EXPLAIN shows that this is pulling +275366 of the 826032 rows in the two tables, which seems like rather a +lot for a single user. If it's reasonable that the query needs to fetch +one-third of the data, then you should resign yourself to it taking +awhile :-( + +If the expected number of matching rows were much smaller, it would +make sense to use indexscans over the two big tables, but unfortunately +existing PG releases don't know how to generate an indexscan join +with a UNION ALL in between :-(. FWIW, 8.2 will be able to do it. +In current releases the only thing I can suggest is to merge +user_subscription_credits_given and user_subscription_credits_taken +into one table so you don't need the UNION ALL. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 30 12:16:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 18B269FA5FB + for ; + Tue, 30 May 2006 12:16:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 27939-02 + for ; + Tue, 30 May 2006 12:16:00 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 6852D9FA5E2 + for ; + Tue, 30 May 2006 12:16:00 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4UFFmUH024065; + Tue, 30 May 2006 11:15:48 -0400 (EDT) +To: "mcelroy, tim" +cc: pgsql-performance@postgresql.org +Subject: Re: pg_dump issue +In-reply-to: + <9765373733A7DF4681B12225D2FC44050D6D0C@bosexprod001.bostonstock.local> +References: + <9765373733A7DF4681B12225D2FC44050D6D0C@bosexprod001.bostonstock.local> +Comments: In-reply-to "mcelroy, tim" + message dated "Tue, 30 May 2006 10:31:08 -0400" +Date: Tue, 30 May 2006 11:15:48 -0400 +Message-ID: <24064.1149002148@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/525 +X-Sequence-Number: 19312 + +"mcelroy, tim" writes: +> I have identical postgres installations running on identical machines. Dual +> Core AMD Opteron(tm) Processor 870 , 16GB RAM, Red Hat Linux 3.2.3-20 and +> 120GB worth of disk space on two drives. + +> Recently, I have noticed that my nightly backups take longer on one machine +> than on the other. I back up five (5) databases totaling 8.6GB in size. On +> Prod001 the backups take app. 7 minutes, on Prod002 the backups take app. 26 +> minutes! Quite a discrepancy. + +Are the resulting backup files identical? Chasing down the reasons for +any diffs might yield some enlightenment. + +One idea that comes to mind is that Prod002 is having performance +problems due to table bloat (maybe a missing vacuum cron job or +some such). A quick "du" on the two $PGDATA directories to check +for significant size differences would reveal this if so. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 30 12:17:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 08FC59FA5FB + for ; + Tue, 30 May 2006 12:17:03 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 25187-10 + for ; + Tue, 30 May 2006 12:16:51 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) + by postgresql.org (Postfix) with ESMTP id 18C959FA7B6 + for ; + Tue, 30 May 2006 12:16:51 -0300 (ADT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by pjetlic.mobart.hr (Postfix) with ESMTP id C4A0D17A97; + Tue, 30 May 2006 17:16:49 +0200 (CEST) +Received: from pjetlic.mobart.hr ([127.0.0.1]) + by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) + with LMTP id 26771-03-2; Tue, 30 May 2006 17:16:49 +0200 (CEST) +Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) + (using SSLv3 with cipher RC4-MD5 (128/128 bits)) + (No client certificate requested) + by pjetlic.mobart.hr (Postfix) with ESMTP id AB08C17A95; + Tue, 30 May 2006 17:16:49 +0200 (CEST) +Subject: Re: Speedup hint needed, if available? :) +From: Mario Splivalo +Reply-To: mario.splivalo@mobart.hr +To: Tom Lane +Cc: pgsql-performance@postgresql.org +In-Reply-To: <23931.1149001555@sss.pgh.pa.us> +References: <1148998681.18422.24.camel@localhost.localdomain> + <23931.1149001555@sss.pgh.pa.us> +Content-Type: text/plain +Organization: Mob-Art +Date: Tue, 30 May 2006 17:16:40 +0200 +Message-Id: <1149002200.18422.41.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: by OpenSource AV+AS Mail Server +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/526 +X-Sequence-Number: 19313 + +On Tue, 2006-05-30 at 11:05 -0400, Tom Lane wrote: + +> Do you have realistic test data? The EXPLAIN shows that this is pulling +> 275366 of the 826032 rows in the two tables, which seems like rather a +> lot for a single user. If it's reasonable that the query needs to fetch +> one-third of the data, then you should resign yourself to it taking +> awhile :-( + +I'd say so, yes. The user_subscription table now has only six rows, but +the number of actions (giving/taking credits) for a user could easily be +as high as 50.000. + +> If the expected number of matching rows were much smaller, it would +> make sense to use indexscans over the two big tables, but unfortunately +> existing PG releases don't know how to generate an indexscan join +> with a UNION ALL in between :-(. FWIW, 8.2 will be able to do it. +> In current releases the only thing I can suggest is to merge +> user_subscription_credits_given and user_subscription_credits_taken +> into one table so you don't need the UNION ALL. + +See, that's an idea! :) Thnx, I'll try that. + +Is it inapropriate to ask about rough estimate on availableness of +8.2? :) + + Mario +-- +Mario Splivalo +Mob-Art +mario.splivalo@mobart.hr + +"I can do it quick, I can do it cheap, I can do it well. Pick any two." + + + +From pgsql-performance-owner@postgresql.org Tue May 30 12:34:18 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A0AC89FA5E6 + for ; + Tue, 30 May 2006 12:34:17 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 30111-07 + for ; + Tue, 30 May 2006 12:34:10 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from morpheus.bostonstock.com (morpheus.bostonstock.com + [192.233.205.44]) + by postgresql.org (Postfix) with ESMTP id C6FA69FA5E2 + for ; + Tue, 30 May 2006 12:34:09 -0300 (ADT) +Received: by MORPHEUS with Internet Mail Service (5.5.2653.19) + id <2R02FKJ8>; Tue, 30 May 2006 11:27:57 -0400 +Message-ID: + <9765373733A7DF4681B12225D2FC44050D6D12@bosexprod001.bostonstock.local> +From: "mcelroy, tim" +To: 'Tom Lane' +Cc: pgsql-performance@postgresql.org +Subject: Re: pg_dump issue +Date: Tue, 30 May 2006 11:33:54 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C683FE.756D4611" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/527 +X-Sequence-Number: 19314 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C683FE.756D4611 +Content-Type: text/plain; + charset="iso-8859-1" + +Thanks Tom. I have scheduled vacuums as follows and all have run without +error. + +Mon - Thu after-hours: vacuumdb -z -e -a -v On Fridays I add the -f +option vacuumdb -z -e -a -v -f + +The du . -h in $PGDATA showed PROD001 at 9.1G and Prod0002 at 8.8G so +they're pretty much the same, one would think the smaller one should be +faster. Yes, the backup files are identical in size. BTW - this is +postgres 8.0.1. Stuck at this due to "that is the latest postgresql version +certified by our vendor's application". + +I'm hoping the Engineering staff can find something system related as I +doubted and still doubt that it's a postgres issue. + +Tim + + + -----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: Tuesday, May 30, 2006 11:16 AM +To: mcelroy, tim +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] pg_dump issue + +"mcelroy, tim" writes: +> I have identical postgres installations running on identical machines. +Dual +> Core AMD Opteron(tm) Processor 870 , 16GB RAM, Red Hat Linux 3.2.3-20 and +> 120GB worth of disk space on two drives. + +> Recently, I have noticed that my nightly backups take longer on one +machine +> than on the other. I back up five (5) databases totaling 8.6GB in size. +On +> Prod001 the backups take app. 7 minutes, on Prod002 the backups take app. +26 +> minutes! Quite a discrepancy. + +Are the resulting backup files identical? Chasing down the reasons for +any diffs might yield some enlightenment. + +One idea that comes to mind is that Prod002 is having performance +problems due to table bloat (maybe a missing vacuum cron job or +some such). A quick "du" on the two $PGDATA directories to check +for significant size differences would reveal this if so. + + regards, tom lane + +------_=_NextPart_001_01C683FE.756D4611 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] pg_dump issue + + + +

Thanks Tom.  I have scheduled vacuums as follows = +and all have run without error. +

+ +

Mon - Thu after-hours:  vacuumdb -z -e -a = +-v   On Fridays I add the -f option  vacuumdb -z -e -a = +-v -f +

+ +

The du . -h  in $PGDATA showed PROD001 at 9.1G = +and Prod0002 at 8.8G so they're pretty much the same, one would think = +the smaller one should be faster.  Yes, the backup files are = +identical in size.  BTW - this is postgres 8.0.1.  Stuck at = +this due to "that is the latest postgresql version certified by = +our vendor's application".

+ +

I'm hoping the Engineering staff can find something = +system related as I doubted and still doubt that it's a postgres = +issue.

+ +

Tim +

+
+ +

 -----Original Message----- +
From:   Tom Lane [mailto:tgl@sss.pgh.pa.us] +
Sent:   Tuesday, May 30, 2006 11:16 = +AM +
To:     mcelroy, tim +
Cc:     = +pgsql-performance@postgresql.org +
Subject:        = +Re: [PERFORM] pg_dump issue +

+ +

"mcelroy, tim" = +<tim.mcelroy@bostonstock.com> writes: +
> I have identical postgres installations running = +on identical machines.  Dual +
> Core AMD Opteron(tm) Processor 870 , 16GB RAM, = +Red Hat Linux 3.2.3-20 and +
> 120GB worth of disk space on two drives. +

+ +

> Recently, I have noticed that my nightly backups = +take longer on one machine +
> than on the other.  I back up five (5) = +databases totaling 8.6GB in size.  On +
> Prod001 the backups take app. 7 minutes, on = +Prod002 the backups take app. 26 +
> minutes!  Quite a discrepancy. +

+ +

Are the resulting backup files identical?  = +Chasing down the reasons for +
any diffs might yield some enlightenment. +

+ +

One idea that comes to mind is that Prod002 is having = +performance +
problems due to table bloat (maybe a missing vacuum = +cron job or +
some such).  A quick "du" on the two = +$PGDATA directories to check +
for significant size differences would reveal this = +if so. +

+ +

        = +        = +        regards, tom = +lane +

+ + + +------_=_NextPart_001_01C683FE.756D4611-- + +From pgsql-performance-owner@postgresql.org Tue May 30 12:58:51 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id EE7F29FA61D + for ; + Tue, 30 May 2006 12:58:50 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 32859-06 + for ; + Tue, 30 May 2006 12:58:44 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id 304AA9FA5E2 + for ; + Tue, 30 May 2006 12:58:44 -0300 (ADT) +Received: from localhost (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with SMTP id 95E11B81F + for ; + Tue, 30 May 2006 11:58:42 -0400 (EDT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id 05780B822; + Tue, 30 May 2006 11:58:39 -0400 (EDT) +Received: from zoraida.natserv.net (zoraida.natserv.net [66.114.65.147]) + by zoraida.natserv.net (Postfix) with ESMTP id A8EEFB81F; + Tue, 30 May 2006 11:58:38 -0400 (EDT) +References: <005701c683cc$7757af00$ddf71005@jonathanlaptop> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Jonathan Blitz +Cc: pgsql-performance@postgresql.org +Subject: Re: Adding and filling new column on big table +Date: Tue, 30 May 2006 11:58:38 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-DSPAM-Result: Innocent +X-DSPAM-Processed: Tue May 30 11:58:42 2006 +X-DSPAM-Confidence: 1.0000 +X-DSPAM-Probability: 0.0023 +X-DSPAM-Signature: 58,447c6bb2348141774319805 +X-DSPAM-Factors: 27, writes+>, 0.40000, many, 0.40000, but, 0.40000, + That, 0.40000, 4GB, 0.40000, done+a, 0.40000, just, 0.40000, + just, 0.40000, Received*2006+11, 0.40000, + Received*2006+11, 0.40000, 1/4+of, 0.40000, Date*May, 0.40000, + Received*Tue, 0.40000, Received*Tue, 0.40000, + Received*A8EEFB81F, 0.40000, Date*38, 0.40000, end, 0.40000, + an, 0.40000, record+table, 0.40000, ever?+>, 0.40000, + 10, 0.40000, To*anykey.co.il>, 0.40000, opteron+with, 0.40000, + record, 0.40000, (SATA), 0.40000, Subject*on+big, 0.40000, + of, 0.40000 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/528 +X-Sequence-Number: 19315 + +Jonathan Blitz writes: + +> I just gave up in the end and left it with NULL as the default value. + + +Could you do the updates in batches instead of trying to do them all at +once? + +Have you done a vacuum full on this table ever? + +> There were, in fact, over 2 million rows in the table rather than 1/4 of a +> million so that was part of the problem. + +What hardware? +I have a dual CPU opteron with 4GB of RAM and 8 disks in RAID 10 (SATA). +Doing an update on a 5 million record table took quite a while, but it did +fininish. :-) + +I just did vacuum full before and after though.. That many updates tend to +slow down operations on the table aftewards unless you vacuum the table. +Based on what you wrote it sounded as if you tried a few times and may have +killed the process.. this would certainly slow down the operations on that +table unless you did a vacuum full. + +I wonder if running vacuum analyze against the table as the updates are +running would be of any help. + + +From pgsql-performance-owner@postgresql.org Tue May 30 13:20:38 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id C62499FA60C + for ; + Tue, 30 May 2006 13:20:37 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 36257-06 + for ; + Tue, 30 May 2006 13:20:31 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id 5C0809F9312 + for ; + Tue, 30 May 2006 13:20:30 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4UGKNpA024586; + Tue, 30 May 2006 12:20:23 -0400 (EDT) +To: "mcelroy, tim" +cc: pgsql-performance@postgresql.org +Subject: Re: pg_dump issue +In-reply-to: + <9765373733A7DF4681B12225D2FC44050D6D12@bosexprod001.bostonstock.local> +References: + <9765373733A7DF4681B12225D2FC44050D6D12@bosexprod001.bostonstock.local> +Comments: In-reply-to "mcelroy, tim" + message dated "Tue, 30 May 2006 11:33:54 -0400" +Date: Tue, 30 May 2006 12:20:23 -0400 +Message-ID: <24585.1149006023@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/530 +X-Sequence-Number: 19317 + +"mcelroy, tim" writes: +> The du . -h in $PGDATA showed PROD001 at 9.1G and Prod0002 at 8.8G so +> they're pretty much the same, one would think the smaller one should be +> faster. Yes, the backup files are identical in size. + +Hmph. You should carry the "du" analysis down to the subdirectory +level, eg make sure that it's not a case of lots of pg_xlog bloat +balancing out bloat in a different area on the other system. But I +suspect you won't find anything. + +> I'm hoping the Engineering staff can find something system related as I +> doubted and still doubt that it's a postgres issue. + +I tend to agree. You might try watching "vmstat 1" output while taking +the dumps, so you could at least get a clue whether the problem is CPU +or I/O related ... + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Tue May 30 13:11:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 761CF9FA5E2 + for ; + Tue, 30 May 2006 13:11:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 34634-07 + for ; + Tue, 30 May 2006 13:11:24 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from server.nextgap2000.com (server.nextgap2000.com [66.98.160.7]) + by postgresql.org (Postfix) with ESMTP id 83B7B9FA5DD + for ; + Tue, 30 May 2006 13:11:24 -0300 (ADT) +Received: from 85.64.46.244.dynamic.barak-online.net ([85.64.46.244] + helo=jonathanlaptop) + by server.nextgap2000.com with esmtpa (Exim 4.52) + id 1Fl6oM-0006rg-2M; Tue, 30 May 2006 19:11:20 +0300 +From: "Jonathan Blitz" +To: "'Francisco Reyes'" +Cc: +Subject: Re: Adding and filling new column on big table +Date: Tue, 30 May 2006 19:11:30 +0200 +Message-ID: <00d201c6840c$2543eb80$ddf71005@jonathanlaptop> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="windows-1250" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook 11 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 +In-reply-to: +Thread-Index: AcaEAgxu43PlolVPQLuJRPcvUE1A7wACYUGQ +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - server.nextgap2000.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] +X-AntiAbuse: Sender Address Domain - anykey.co.il +X-Source: +X-Source-Args: +X-Source-Dir: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/529 +X-Sequence-Number: 19316 + +> +> +> Could you do the updates in batches instead of trying to do them all at +> once? + +Nope. Didn't think it would make any difference. +> +> Have you done a vacuum full on this table ever? + +Many times + +> +> What hardware? +> I have a dual CPU opteron with 4GB of RAM and 8 disks in RAID 10 (SATA). +> Doing an update on a 5 million record table took quite a while, but it did +> fininish. :-) + +I am using a laptop :). +Pentium 4 (not 4M) with 1GB of memory - 2 MHZ + +Must do it on that since the program is aimed for use at home. + +Jonathan + +-- +No virus found in this outgoing message. +Checked by AVG Free Edition. +Version: 7.1.394 / Virus Database: 268.7.4/351 - Release Date: 05/29/2006 + + + +From pgsql-performance-owner@postgresql.org Tue May 30 14:12:58 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 710D39FAE4E + for ; + Tue, 30 May 2006 14:12:57 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 65660-07 + for ; + Tue, 30 May 2006 14:12:45 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from morpheus.bostonstock.com (unknown [192.233.205.44]) + by postgresql.org (Postfix) with ESMTP id 234A19FA5E9 + for ; + Tue, 30 May 2006 14:12:44 -0300 (ADT) +Received: by MORPHEUS with Internet Mail Service (5.5.2653.19) + id <2R02FK58>; Tue, 30 May 2006 13:06:32 -0400 +Message-ID: + <9765373733A7DF4681B12225D2FC44050D6D16@bosexprod001.bostonstock.local> +From: "mcelroy, tim" +To: 'Tom Lane' +Cc: pgsql-performance@postgresql.org +Subject: Re: pg_dump issue +Date: Tue, 30 May 2006 13:12:33 -0400 +MIME-Version: 1.0 +X-Mailer: Internet Mail Service (5.5.2653.19) +Content-Type: multipart/alternative; + boundary="----_=_NextPart_001_01C6840C.3D71C445" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/531 +X-Sequence-Number: 19318 + +This message is in MIME format. Since your mail reader does not understand +this format, some or all of this message may not be legible. + +------_=_NextPart_001_01C6840C.3D71C445 +Content-Type: text/plain; + charset="iso-8859-1" + +I did carry it down to the subdirectory level but only included the total +for brevity. I'll paste the complete readout at the end of the email. I'll +try the "vmstat 1" as you suggest next time the backups run. If the Eng +staff finds anything I'll post the results and maybe save someone else some +grief if they have the same issue. Thanks again for your input Tom. + +Tim + +PROD001 PROD002 +220K ./global[PARA]4.0K ./pg_xlog/archive_status[PARA]529M +./pg_xlog[PARA]36K ./pg_clog[PARA]256K ./pg_subtrans[PARA]4.0K +./base/1/pgsql_tmp[PARA]4.8M ./base/1[PARA]4.8M ./base/17229[PARA]4.0K +./base/62878500/pgsql_tmp[PARA]4.8M ./base/62878500[PARA]5.5M +./base/1152695[PARA]4.0K ./base/67708567/pgsql_tmp[PARA]1.6G +./base/67708567[PARA]12K ./base/1157024/pgsql_tmp[PARA]6.3G +./base/1157024[PARA]4.0K ./base/1159370/pgsql_tmp[PARA]543M +./base/1159370[PARA]4.0K ./base/1157190/pgsql_tmp[PARA]164M +./base/1157190[PARA]4.0K ./base/1621391/pgsql_tmp[PARA]81M +./base/1621391[PARA]8.6G ./base[PARA]4.0K ./pg_tblspc[PARA]604K +./pg_log[PARA]9.1G . 220K ./global[PARA]4.0K +./pg_xlog/archive_status[PARA]529M ./pg_xlog[PARA]136K +./pg_clog[PARA]208K ./pg_subtrans[PARA]4.0K +./base/1/pgsql_tmp[PARA]4.9M ./base/1[PARA]4.8M ./base/17229[PARA]5.3M +./base/1274937[PARA]4.0K ./base/64257611/pgsql_tmp[PARA]1.6G +./base/64257611[PARA]4.0K ./base/71683200/pgsql_tmp[PARA]6.1G +./base/71683200[PARA]4.0K ./base/1281929/pgsql_tmp[PARA]478M +./base/1281929[PARA]4.0K ./base/58579022/pgsql_tmp[PARA]154M +./base/58579022[PARA]81M ./base/1773916[PARA]4.0K +./base/55667447/pgsql_tmp[PARA]4.8M ./base/55667447[PARA]8.3G +./base[PARA]4.0K ./pg_tblspc[PARA]588K ./pg_log[PARA]8.8G . + + + -----Original Message----- +From: Tom Lane [mailto:tgl@sss.pgh.pa.us] +Sent: Tuesday, May 30, 2006 12:20 PM +To: mcelroy, tim +Cc: pgsql-performance@postgresql.org +Subject: Re: [PERFORM] pg_dump issue + +"mcelroy, tim" writes: +> The du . -h in $PGDATA showed PROD001 at 9.1G and Prod0002 at 8.8G so +> they're pretty much the same, one would think the smaller one should be +> faster. Yes, the backup files are identical in size. + +Hmph. You should carry the "du" analysis down to the subdirectory +level, eg make sure that it's not a case of lots of pg_xlog bloat +balancing out bloat in a different area on the other system. But I +suspect you won't find anything. + +> I'm hoping the Engineering staff can find something system related as I +> doubted and still doubt that it's a postgres issue. + +I tend to agree. You might try watching "vmstat 1" output while taking +the dumps, so you could at least get a clue whether the problem is CPU +or I/O related ... + + regards, tom lane + +------_=_NextPart_001_01C6840C.3D71C445 +Content-Type: text/html; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + + + + + + +RE: [PERFORM] pg_dump issue + + + +

I did carry it down to the subdirectory level but = +only included the total for brevity.  I'll paste the complete = +readout at the end of the email.  I'll try the "vmstat = +1" as you suggest next time the backups run.  If the Eng = +staff finds anything I'll post the results and maybe save someone else = +some grief if they have the same issue.  Thanks again for your = +input Tom.

+ +

Tim +

+ +

PROD001 PROD002 +
220K    = +./global[PARA]4.0K    = +./pg_xlog/archive_status[PARA]529M    = +./pg_xlog[PARA]36K     = +./pg_clog[PARA]256K    = +./pg_subtrans[PARA]4.0K    = +./base/1/pgsql_tmp[PARA]4.8M    = +./base/1[PARA]4.8M    = +./base/17229[PARA]4.0K    = +./base/62878500/pgsql_tmp[PARA]4.8M    = +./base/62878500[PARA]5.5M    = +./base/1152695[PARA]4.0K    = +./base/67708567/pgsql_tmp[PARA]1.6G    = +./base/67708567[PARA]12K     = +./base/1157024/pgsql_tmp[PARA]6.3G    = +./base/1157024[PARA]4.0K    = +./base/1159370/pgsql_tmp[PARA]543M    = +./base/1159370[PARA]4.0K    = +./base/1157190/pgsql_tmp[PARA]164M    = +./base/1157190[PARA]4.0K    = +./base/1621391/pgsql_tmp[PARA]81M     = +./base/1621391[PARA]8.6G    = +./base[PARA]4.0K    = +./pg_tblspc[PARA]604K    = +./pg_log[PARA]9.1G    .   = +220K    ./global[PARA]4.0K    = +./pg_xlog/archive_status[PARA]529M    = +./pg_xlog[PARA]136K    = +./pg_clog[PARA]208K    = +./pg_subtrans[PARA]4.0K    = +./base/1/pgsql_tmp[PARA]4.9M    = +./base/1[PARA]4.8M    = +./base/17229[PARA]5.3M    = +./base/1274937[PARA]4.0K    = +./base/64257611/pgsql_tmp[PARA]1.6G    = +./base/64257611[PARA]4.0K    = +./base/71683200/pgsql_tmp[PARA]6.1G    = +./base/71683200[PARA]4.0K    = +./base/1281929/pgsql_tmp[PARA]478M    = +./base/1281929[PARA]4.0K    = +./base/58579022/pgsql_tmp[PARA]154M    = +./base/58579022[PARA]81M     = +./base/1773916[PARA]4.0K    = +./base/55667447/pgsql_tmp[PARA]4.8M    = +./base/55667447[PARA]8.3G    = +./base[PARA]4.0K    = +./pg_tblspc[PARA]588K    = +./pg_log[PARA]8.8G    .

+
+ +

 -----Original Message----- +
From:   Tom Lane [mailto:tgl@sss.pgh.pa.us] +
Sent:   Tuesday, May 30, 2006 12:20 = +PM +
To:     mcelroy, tim +
Cc:     = +pgsql-performance@postgresql.org +
Subject:        = +Re: [PERFORM] pg_dump issue +

+ +

"mcelroy, tim" = +<tim.mcelroy@bostonstock.com> writes: +
> The du . -h  in $PGDATA showed PROD001 at = +9.1G and Prod0002 at 8.8G so +
> they're pretty much the same, one would think = +the smaller one should be +
> faster.  Yes, the backup files are = +identical in size. +

+ +

Hmph.  You should carry the "du" = +analysis down to the subdirectory +
level, eg make sure that it's not a case of lots of = +pg_xlog bloat +
balancing out bloat in a different area on the other = +system.  But I +
suspect you won't find anything. +

+ +

> I'm hoping the Engineering staff can find = +something system related as I +
> doubted and still doubt that it's a postgres = +issue. +

+ +

I tend to agree.  You might try watching = +"vmstat 1" output while taking +
the dumps, so you could at least get a clue whether = +the problem is CPU +
or I/O related ... +

+ +

        = +        = +        regards, tom = +lane +

+ + + +------_=_NextPart_001_01C6840C.3D71C445-- + +From pgsql-performance-owner@postgresql.org Tue May 30 14:25:47 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D2EAD9FA5E9 + for ; + Tue, 30 May 2006 14:25:46 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 88708-01 + for ; + Tue, 30 May 2006 14:25:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id CCAA59FADD1 + for ; + Tue, 30 May 2006 14:25:40 -0300 (ADT) +Received: from localhost (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with SMTP id AADE2B81F + for ; + Tue, 30 May 2006 13:25:39 -0400 (EDT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id 0A06CB822; + Tue, 30 May 2006 13:25:37 -0400 (EDT) +Received: from 35st-server.simplicato.com + (static-71-249-233-130.nycmny.east.verizon.net [71.249.233.130]) + by zoraida.natserv.net (Postfix) with ESMTP id 85AB7B81F; + Tue, 30 May 2006 13:25:36 -0400 (EDT) +References: <00d201c6840c$2543eb80$ddf71005@jonathanlaptop> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Jonathan Blitz +Cc: pgsql-performance@postgresql.org +Subject: Re: Adding and filling new column on big table +Date: Tue, 30 May 2006 13:25:35 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-DSPAM-Result: Innocent +X-DSPAM-Processed: Tue May 30 13:25:39 2006 +X-DSPAM-Confidence: 0.9899 +X-DSPAM-Probability: 0.0000 +X-DSPAM-Signature: 58,447c8013348147593317928 +X-DSPAM-Factors: 27, Date*May, 0.01000, Content-Type*charset="US, 0.01000, + Received*ESMTP, 0.01000, Received*ESMTP, 0.01000, + Content-Disposition*inline, 0.01000, + Content-Type*ASCII", 0.01000, Cc*pgsql, 0.01000, + Received*zoraida.natserv.net, 0.01000, + Received*zoraida.natserv.net, 0.01000, + Received*May+2006, 0.01000, Received*May+2006, 0.01000, + Date*May+2006, 0.01000, Received*May, 0.01000, + Received*May, 0.01000, Received*with, 0.01000, + Received*with, 0.01000, X-Mailer*mta.org/cone/, 0.01000, + Received*id, 0.01000, Received*id, 0.01000, + Received*ESMTP+id, 0.01000, Received*ESMTP+id, 0.01000, + Content-Type*charset="US+ASCII", 0.01000, + X-Mailer*http, 0.01000, From*Francisco+Reyes, 0.01000, + Cc*performance, 0.01000, + Received*from+zoraida.natserv.net, 0.01000, Date*0400, 0.01000 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/532 +X-Sequence-Number: 19319 + +Jonathan Blitz writes: + +> Nope. Didn't think it would make any difference. + +May be worth a try. + +> I am using a laptop :). +> Pentium 4 (not 4M) with 1GB of memory - 2 MHZ + +Most laptop drives are only 5,400 RPM which would make a transaction like +you are describing likely take a while. + +> Must do it on that since the program is aimed for use at home. + +No desktop at home you could try it on? +I think the problem with the laptop is likely it's drive. + + +From pgsql-performance-owner@postgresql.org Tue May 30 17:57:26 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 124779FB0D1 + for ; + Tue, 30 May 2006 15:53:39 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 97476-05 + for ; + Tue, 30 May 2006 15:53:34 -0300 (ADT) +X-Greylist: delayed 00:27:47.580025 by SQLgrey- +Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) + by postgresql.org (Postfix) with ESMTP id 628B09FB1B9 + for ; + Tue, 30 May 2006 15:53:30 -0300 (ADT) +Received: from burta.hst.terra.com.br (burta.hst.terra.com.br + [200.176.10.199]) + by svr4.postgresql.org (Postfix) with ESMTP id 8E1795AFA09 + for ; + Tue, 30 May 2006 18:25:42 +0000 (GMT) +Received: from caliope.hst.terra.com.br (caliope.hst.terra.com.br + [200.176.10.8]) + by burta.hst.terra.com.br (Postfix) with ESMTP id 24EE64B78094 + for ; + Tue, 30 May 2006 15:25:35 -0300 (BRT) +X-Terra-Karma: -2% +X-Terra-Hash: c8335fc1d0ecf755e79b71f0e33385bb +Received-SPF: none (caliope.hst.terra.com.br: 200.176.10.8 is neither + permitted nor denied by domain of shx.com.br) + client-ip=200.176.10.8; envelope-from=waldomiro@shx.com.br; + helo=[192.168.3.243]; +Received: from [192.168.3.243] (unknown [200.207.161.27]) + (authenticated user shx134) + by caliope.hst.terra.com.br (Postfix) with ESMTP id BDA4D1BD4129 + for ; + Tue, 30 May 2006 15:25:34 -0300 (BRT) +Message-ID: <447C8F1D.8090404@shx.com.br> +Date: Tue, 30 May 2006 15:29:49 -0300 +From: Waldomiro +User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) +X-Accept-Language: pt-br, pt +MIME-Version: 1.0 +To: pgsql-performance@postgresql.org +Subject: INSERT OU UPDATE WITHOUT SELECT? +Content-Type: multipart/alternative; + boundary="------------090707040903070803030802" +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Spam-Status: No, hits=0.305 tagged_above=0 required=5 tests=BAYES_00, + HTML_50_60, HTML_MESSAGE, HTML_TITLE_EMPTY, RCVD_IN_BL_SPAMCOP_NET, + SUBJ_ALL_CAPS +X-Spam-Level: +X-Archive-Number: 200605/549 +X-Sequence-Number: 19336 + +This is a multi-part message in MIME format. +--------------090707040903070803030802 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit + +Hi, + +Is there a command to Insert a record If It does not exists and a update +if It exists? + +I do not want to do a select before a insert or update. + +I mean the postgres should test if a record exist before insert and if +It exist then the postgres must do an update instead an insert. + +Thanks, + +WMiro. + + +--------------090707040903070803030802 +Content-Type: text/html; charset=ISO-8859-1 +Content-Transfer-Encoding: 7bit + + + + + + + + +Hi,
+
+Is there a command to Insert a record If It does not exists and a +update if It exists?
+
+I do not want to do a select before a insert or update.
+
+I mean the postgres should test if a record exist before insert and if +It exist then the postgres must do an update instead an insert.
+
+Thanks,
+
+WMiro.

+

+
+ + + +--------------090707040903070803030802-- + +From pgsql-performance-owner@postgresql.org Tue May 30 16:59:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 611D49FADD1 + for ; + Tue, 30 May 2006 16:59:43 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 06878-07 + for ; + Tue, 30 May 2006 16:59:32 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gandalf.geeklair.net (gandalf.geeklair.net [129.250.34.2]) + by postgresql.org (Postfix) with ESMTP id 6F8309FA5E9 + for ; + Tue, 30 May 2006 16:59:31 -0300 (ADT) +Received: from [192.168.5.3] (c-67-172-95-82.hsd1.mi.comcast.net + [67.172.95.82]) (authenticated bits=0) + by gandalf.geeklair.net (8.13.6/8.13.6) with ESMTP id k4UJxLRe019999 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT); + Tue, 30 May 2006 15:59:21 -0400 (EDT) +In-Reply-To: <447AD6D1.3070904@logix-tt.com> +References: + + <7E2D9162-867B-4DB1-B8A3-9ED701434488@geeklair.net> + <447AD6D1.3070904@logix-tt.com> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg=pgp-sha1; boundary="Apple-Mail-3-1060751722" +Message-Id: <23960DE1-EE76-4FEC-A93C-26E0565A21C0@geeklair.net> +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: "Daniel J. Luke" +Subject: Re: Getting even more insert performance (250m+rows/day) +Date: Tue, 30 May 2006 15:59:19 -0400 +To: Markus Schaber +X-Pgp-Agent: GPGMail 1.1.2 (Tiger) +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/533 +X-Sequence-Number: 19320 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--Apple-Mail-3-1060751722 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed + +On May 29, 2006, at 7:11 AM, Markus Schaber wrote: +>> One big transaction every 5 minutes using 'COPY FROM' (instead of +>> inserts). +> +> Are you using "COPY table FROM '/path/to/file'", having the file +> sitting +> on the server, or "COPY table FROM STDIN" or psql "/copy", having the +> file sitting on the client? + +COPY table FROM STDIN using psql on the server + +I should have gprof numbers on a similarly set up test machine soon ... +-- +Daniel J. Luke ++========================================================+ +| *---------------- dluke@geeklair.net ----------------* | +| *-------------- http://www.geeklair.net -------------* | ++========================================================+ +| Opinions expressed are mine and do not necessarily | +| reflect the opinions of my employer. | ++========================================================+ + + + +--Apple-Mail-3-1060751722 +content-type: application/pgp-signature; x-mac-type=70674453; + name=PGP.sig +content-description: This is a digitally signed message part +content-disposition: inline; filename=PGP.sig +content-transfer-encoding: 7bit + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.3 (Darwin) + +iD8DBQFEfKQYjUs5tAKawAoRAlfCAJ4weL7PoG2GZZz4A7gothGpFVXiBgCfUeMF +OWnPmvkUyV6OqBUneIWS4Oo= +=ZIlQ +-----END PGP SIGNATURE----- + +--Apple-Mail-3-1060751722-- + +From pgsql-performance-owner@postgresql.org Tue May 30 17:07:30 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 526CC9FADD1 + for ; + Tue, 30 May 2006 17:07:30 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 08649-01 + for ; + Tue, 30 May 2006 17:07:18 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from exchange.g2switchworks.com (mail.g2switchworks.com + [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id D97C39FA5E9 + for ; + Tue, 30 May 2006 17:07:17 -0300 (ADT) +Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com + ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; + Tue, 30 May 2006 20:07:15 +0000 +Received: from state.g2switchworks.com by mail.g2switchworks.com; + 30 May 2006 15:07:15 -0500 +Subject: Re: Adding and filling new column on big table +From: Scott Marlowe +To: Jonathan Blitz +Cc: 'Francisco Reyes' , + pgsql-performance@postgresql.org +In-Reply-To: <012501c6842c$bb8438f0$ddf71005@jonathanlaptop> +References: <012501c6842c$bb8438f0$ddf71005@jonathanlaptop> +Content-Type: text/plain +Content-Transfer-Encoding: 7bit +Message-Id: <1149019635.25526.94.camel@state.g2switchworks.com> +Mime-Version: 1.0 +X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) +Date: Tue, 30 May 2006 15:07:15 -0500 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/535 +X-Sequence-Number: 19322 + +On Tue, 2006-05-30 at 16:04, Jonathan Blitz wrote: +> > +> > Most laptop drives are only 5,400 RPM which would make a transaction like +> > you are describing likely take a while. +> +> Not sure what my one is but it is new(ish). +> +> > +> > No desktop at home you could try it on? +> > I think the problem with the laptop is likely it's drive. +> +> I suppose I could do but I need to install PostgreSQL there and then copy +> over the database. + +Keep in mind, most, if not all IDE drives lie about fsync, so the speed +of the drive is a limit only if you're actually writing a lot of data. +If you're doing a lot of little transactions, the drive should be lying +and holding the data in cache on board, so the speed should be OK. + +From pgsql-performance-owner@postgresql.org Tue May 30 17:24:42 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9612D9FADD1 + for ; + Tue, 30 May 2006 17:24:41 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 10935-04 + for ; + Tue, 30 May 2006 17:24:37 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id CFD609FA5E9 + for ; + Tue, 30 May 2006 17:24:36 -0300 (ADT) +Received: (qmail 15318 invoked from network); 30 May 2006 22:24:34 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 30 May 2006 22:24:34 +0200 +To: "Jonathan Blitz" , + "'Francisco Reyes'" +Cc: pgsql-performance@postgresql.org +Subject: Re: Adding and filling new column on big table +References: <012501c6842c$bb8438f0$ddf71005@jonathanlaptop> +Message-ID: +Date: Tue, 30 May 2006 22:24:32 +0200 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <012501c6842c$bb8438f0$ddf71005@jonathanlaptop> +User-Agent: Opera M2/8.54 (Linux, build 1745) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/536 +X-Sequence-Number: 19323 + + +>> Most laptop drives are only 5,400 RPM which would make a transaction +>> like +>> you are describing likely take a while. +> +> Not sure what my one is but it is new(ish). + + If you're doing data intensive operations (like a big update which looks +like what you're doing) it will write many megabytes to the harddrive... +my laptop HDD (5400 rpm) does about 15 MB/s throughput while a standard +desktop 7200rpm drive does 55-60 MB/s throughput. Plus, seek times on a +laptop drive are horrendous. + +From pgsql-performance-owner@postgresql.org Sat Jun 3 22:24:07 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 61ACC9FA5E9 + for ; + Tue, 30 May 2006 17:48:02 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 14367-05 + for ; + Tue, 30 May 2006 17:47:53 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from smtp-32.ig.com.br (smtp-32.ig.com.br [200.226.132.32]) + by postgresql.org (Postfix) with ESMTP id CC99F9FADD1 + for ; + Tue, 30 May 2006 17:47:52 -0300 (ADT) +Received: (qmail 5095 invoked from network); 30 May 2006 20:47:46 -0000 +Received: from 70.131.226.200.in-addr.arpa.ig.com.br (HELO + localhost.localdomain) ([200.226.131.70]) + (envelope-sender ) + by email-32.ig.com.br (qmail-ldap-1.03) with SMTP + for ; 30 May 2006 20:47:46 -0000 +To: pgsql-performance@postgresql.org +From: wmiro@ig.com.br +Subject: INSERT OR UPDATE WITHOUT SELECT +Date: Tue, 30 May 2006 17:47:47 -0300 +X-Priority: 3 (Normal) +Message-ID: <20060530_204747_020181.wmiro@ig.com.br> +X-Originating-IP: [10.17.1.70]192.168.3.243, 200.171.147.216 +X-Mailer: iGMail [www.ig.com.br] +X-user: wmiro@ig.com.br +Teste: asaes +MIME-Version: 1.0 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Spam-Status: No, hits=1.846 tagged_above=0 required=5 tests=AWL, BAYES_40, + FORGED_RCVD_HELO, RCVD_IN_NJABL_PROXY, SUBJ_ALL_CAPS +X-Spam-Level: * +Content-Description: Mail message body +Content-Type: text/plain; charset=ISO-8859-1 +Content-Disposition: inline +Content-Transfer-Encoding: 8bit +X-Archive-Number: 200606/26 +X-Sequence-Number: 19383 + +Hi, + +Is there a command to Insert a record If It does not exists and a update if +It exists? + +I do not want to do a select before a insert or update. + +I mean the postgres should test if a record exist before insert and if It +exist then the postgres must do an update instead an insert. + +Thanks, + +WMiro. + + + +From pgsql-performance-owner@postgresql.org Tue May 30 17:52:53 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D0ABE9FAE4E + for ; + Tue, 30 May 2006 17:52:52 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 14797-06 + for ; + Tue, 30 May 2006 17:52:41 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from zoraida.natserv.net (p65-147.acedsl.com [66.114.65.147]) + by postgresql.org (Postfix) with ESMTP id A8B979FA5E9 + for ; + Tue, 30 May 2006 17:52:41 -0300 (ADT) +Received: from localhost (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with SMTP id AE65CB81F + for ; + Tue, 30 May 2006 16:52:36 -0400 (EDT) +Received: from zoraida.natserv.net (localhost.natserv.net [127.0.0.1]) + by zoraida.natserv.net (Postfix) with ESMTP id C372BB822; + Tue, 30 May 2006 16:52:33 -0400 (EDT) +Received: from 35st-server.simplicato.com + (static-71-249-233-130.nycmny.east.verizon.net [71.249.233.130]) + by zoraida.natserv.net (Postfix) with ESMTP id 4ECB0B81F; + Tue, 30 May 2006 16:52:33 -0400 (EDT) +References: <012501c6842c$bb8438f0$ddf71005@jonathanlaptop> +Message-ID: +X-Mailer: http://www.courier-mta.org/cone/ +From: Francisco Reyes +To: Jonathan Blitz +Cc: pgsql-performance@postgresql.org +Subject: Re: Adding and filling new column on big table +Date: Tue, 30 May 2006 16:52:32 -0400 +Mime-Version: 1.0 +Content-Type: text/plain; format=flowed; charset="US-ASCII" +Content-Disposition: inline +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: ClamAV using ClamSMTP +X-DSPAM-Result: Innocent +X-DSPAM-Processed: Tue May 30 16:52:36 2006 +X-DSPAM-Confidence: 0.9899 +X-DSPAM-Probability: 0.0000 +X-DSPAM-Signature: 58,447cb094348141809116389 +X-DSPAM-Factors: 27, writes+>, 0.01000, Date*May, 0.01000, + To*anykey.co.il>, 0.01000, Subject*on+big, 0.01000, + Content-Type*charset="US, 0.01000, Received*ESMTP, 0.01000, + Received*ESMTP, 0.01000, Content-Disposition*inline, 0.01000, + Jonathan+Blitz, 0.01000, Subject*new+column, 0.01000, + writes, 0.01000, Subject*filling, 0.01000, + Subject*column+on, 0.01000, Subject*[PERFORM]+Adding, 0.01000, + Content-Type*ASCII", 0.01000, Blitz, 0.01000, that, 0.01000, + that, 0.01000, Cc*pgsql, 0.01000, Subject*table, 0.01000, + Received*zoraida.natserv.net, 0.01000, + Received*zoraida.natserv.net, 0.01000, + Received*May+2006, 0.01000, Received*May+2006, 0.01000, + Date*May+2006, 0.01000, Subject*big+table, 0.01000, + Received*May, 0.01000 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/537 +X-Sequence-Number: 19324 + +Jonathan Blitz writes: + +> I suppose I could do but I need to install PostgreSQL there and then copy +> over the database. +> Maybe I will give it a try. + +I really think that is your best bet. +If for whatever reason that will not be an option perhaps you can just let +the process run over the weekend.. possibly monitor the process from the OS +to make sure it is not frozen. + +Don't recall if you mentioned the OS.. is it any unix like os? +If so there are several ways you could check to make sure the process is not +frozen such as iostats, top, vmstats(these from FreeBSD, but most unix like +os should have tools like those if not some with the same name). + + +From pgsql-performance-owner@postgresql.org Tue May 30 17:04:46 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id CCC889FADD1 + for ; + Tue, 30 May 2006 17:04:45 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 07792-04 + for ; + Tue, 30 May 2006 17:04:38 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from server.nextgap2000.com (server.nextgap2000.com [66.98.160.7]) + by postgresql.org (Postfix) with ESMTP id 741209FA5E9 + for ; + Tue, 30 May 2006 17:04:36 -0300 (ADT) +Received: from 85.64.46.244.dynamic.barak-online.net ([85.64.46.244] + helo=jonathanlaptop) + by server.nextgap2000.com with esmtpa (Exim 4.52) + id 1FlAS8-0000VY-OX; Tue, 30 May 2006 23:04:33 +0300 +From: "Jonathan Blitz" +To: "'Francisco Reyes'" +Cc: +Subject: Re: Adding and filling new column on big table +Date: Tue, 30 May 2006 23:04:48 +0200 +Message-ID: <012501c6842c$bb8438f0$ddf71005@jonathanlaptop> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="windows-1250" +Content-Transfer-Encoding: 7bit +X-Mailer: Microsoft Office Outlook 11 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 +In-reply-to: +Thread-Index: AcaEDi3VMYRf6fz9QLaG7/3TKwkY0wAHhxwQ +X-AntiAbuse: This header was added to track abuse, + please include it with any abuse report +X-AntiAbuse: Primary Hostname - server.nextgap2000.com +X-AntiAbuse: Original Domain - postgresql.org +X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] +X-AntiAbuse: Sender Address Domain - anykey.co.il +X-Source: +X-Source-Args: +X-Source-Dir: +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/534 +X-Sequence-Number: 19321 + +> +> Most laptop drives are only 5,400 RPM which would make a transaction like +> you are describing likely take a while. + +Not sure what my one is but it is new(ish). + +> +> No desktop at home you could try it on? +> I think the problem with the laptop is likely it's drive. + +I suppose I could do but I need to install PostgreSQL there and then copy +over the database. +Maybe I will give it a try. + +Jonathan + +-- +No virus found in this outgoing message. +Checked by AVG Free Edition. +Version: 7.1.394 / Virus Database: 268.7.4/351 - Release Date: 05/29/2006 + + + +From pgsql-performance-owner@postgresql.org Tue May 30 18:05:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9B1809FAE4E + for ; + Tue, 30 May 2006 18:05:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 17455-03 + for ; + Tue, 30 May 2006 18:05:20 -0300 (ADT) +X-Greylist: domain auto-whitelisted by SQLgrey- +Received: from nf-out-0910.google.com (nf-out-0910.google.com + [64.233.182.186]) + by postgresql.org (Postfix) with ESMTP id BBD3B9FA5E9 + for ; + Tue, 30 May 2006 18:05:19 -0300 (ADT) +Received: by nf-out-0910.google.com with SMTP id y25so14354nfb + for ; + Tue, 30 May 2006 14:05:18 -0700 (PDT) +DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; + h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; + b=F8b0lzP3vGYMi8JaKMEZvvCxyOfvHmVUmjg5qkuySlnV+qu0Zf8kiV3y6XGcxrkpwFD8MMAD0DAyOXzEQLrdH5EYYZSjspGLBzPpSVEhqKq1QI1PpKRmCL3GnlHQAAWgov4TpOo/o8Ej7326ZM9khlynVx1Mn1SSunJr4ZxG8NY= +Received: by 10.48.218.19 with SMTP id q19mr44804nfg; + Tue, 30 May 2006 14:05:17 -0700 (PDT) +Received: by 10.67.87.1 with HTTP; Tue, 30 May 2006 14:05:17 -0700 (PDT) +Message-ID: <36e682920605301405u4d665fcftbe0a97b5753f5209@mail.gmail.com> +Date: Tue, 30 May 2006 17:05:17 -0400 +From: "Jonah H. Harris" +To: Waldomiro +Subject: Re: INSERT OU UPDATE WITHOUT SELECT? +Cc: pgsql-performance@postgresql.org +In-Reply-To: <447C8F1D.8090404@shx.com.br> +MIME-Version: 1.0 +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +Content-Disposition: inline +References: <447C8F1D.8090404@shx.com.br> +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/550 +X-Sequence-Number: 19337 + +On 5/30/06, Waldomiro wrote: +> Is there a command to Insert a record If It does not exists and a update if +> It exists? + +Sure, it's called MERGE. See http://en.wikipedia.org/wiki/Merge_%28SQL%29 + +> I mean the postgres should test if a record exist before insert and if It +> exist then the postgres must do an update instead an insert. + +PostgreSQL does not support MERGE at the moment, sorry. + +-- +Jonah H. Harris, Software Architect | phone: 732.331.1300 +EnterpriseDB Corporation | fax: 732.331.1301 +33 Wood Ave S, 2nd Floor | jharris@enterprisedb.com +Iselin, New Jersey 08830 | http://www.enterprisedb.com/ + +From pgsql-performance-owner@postgresql.org Tue May 30 18:52:29 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 972BD9FB0D1 + for ; + Tue, 30 May 2006 18:52:29 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 22162-03 + for ; + Tue, 30 May 2006 18:52:17 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mx2.ipf.is (scania.ipf.is [85.197.192.147]) + by postgresql.org (Postfix) with ESMTP id 2C9C09FA5E9 + for ; + Tue, 30 May 2006 18:52:15 -0300 (ADT) +Received: (qmail 25647 invoked by uid 1010); 30 May 2006 21:50:25 +0000 +Received: from 85.197.216.186 by scania (envelope-from , + uid 1008) with qmail-scanner-1.25-st-qms + (clamdscan: 0.88/1235. spamassassin: 3.1.1. perlscan: 1.25-st-qms. + Clear:RC:1(85.197.216.186):SA:0(-4.2/4.5):. + Processed in 0.66575 secs); 30 May 2006 21:50:25 -0000 +X-Antivirus-IPF-Mail-From: gnari@hive.is via scania +X-Antivirus-IPF: 1.25-st-qms (Clear:RC:1(85.197.216.186):SA:0(-4.2/4.5):. + Processed in 0.66575 secs Process 25635) +Received: from dsl-216-186.hive.is (HELO ?192.168.1.34?) (85.197.216.186) + by mx2.ipf.is with SMTP; 30 May 2006 21:50:24 +0000 +Subject: Re: Split select completes, single select doesn't and +From: Ragnar +To: Anthony Ransley +Cc: pgsql-performance@postgresql.org +In-Reply-To: <447B9143.6010407@aurema.com> +References: <447B9143.6010407@aurema.com> +Content-Type: text/plain; charset=ISO-8859-1 +Date: Tue, 30 May 2006 21:53:20 +0000 +Message-Id: <1149026000.8566.119.camel@localhost.localdomain> +Mime-Version: 1.0 +X-Mailer: Evolution 2.4.1 +Content-Transfer-Encoding: 8bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/551 +X-Sequence-Number: 19338 + +On �ri, 2006-05-30 at 10:26 +1000, Anthony Ransley wrote: +> Can any one explain why the following query +> +> select f(q) from +> ( +> select * from times +> where '2006-03-01 00:00:00'<=q and q<'2006-03-08 00:00:00' +> order by q +> ) v; +> +> never completes, but splitting up the time span into single days does work. +> +> select f(q) from +> ( +> select * from times +> where '2006-03-01 00:00:00'<=q and q<'2006-03-02 00:00:00' +> order by q +> ) v; + +first question: is f() relevant to your problem? + +I mean do you see the same effect with: + select q from + ( + select * from times + where '2006-03-01 00:00:00'<=q and q<'2006-03-08 00:00:00' + order by q + ) v; + +or even: + select q from times + where '2006-03-01 00:00:00'<=q and q<'2006-03-08 00:00:00' + order by q + + +if f() is needed to make this happen show us f() + +if f() is not relevant, show us the simplest cases where +you see this. show us EXPLAIN on the query that does not +finish, show us EXPLAIN ANALYZE on the queries that do. + +second question: what indexes exist on the table "times" ? + +another question: how many rows in the table ? + +next question: is the table newly ANALYZED? + +finally: what version of postgresql are you using? + + +whithout more info , it is difficult to guess what +your problem is, but possibly you need to increase +the statistics target of column "q" + +gnari + + + + +From pgsql-performance-owner@postgresql.org Tue May 30 19:03:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 0E6619FA5D2 + for ; + Tue, 30 May 2006 19:03:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 22310-06 + for ; + Tue, 30 May 2006 19:03:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from gandalf.geeklair.net (gandalf.geeklair.net [129.250.34.2]) + by postgresql.org (Postfix) with ESMTP id 56B9B9FA5C4 + for ; + Tue, 30 May 2006 19:03:13 -0300 (ADT) +Received: from [192.168.5.3] (c-67-172-95-82.hsd1.mi.comcast.net + [67.172.95.82]) (authenticated bits=0) + by gandalf.geeklair.net (8.13.6/8.13.6) with ESMTP id k4UM3Bvw023930 + (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) + for ; + Tue, 30 May 2006 18:03:12 -0400 (EDT) +Mime-Version: 1.0 (Apple Message framework v750) +In-Reply-To: <23960DE1-EE76-4FEC-A93C-26E0565A21C0@geeklair.net> +References: + + <7E2D9162-867B-4DB1-B8A3-9ED701434488@geeklair.net> + <447AD6D1.3070904@logix-tt.com> + <23960DE1-EE76-4FEC-A93C-26E0565A21C0@geeklair.net> +Content-Type: multipart/signed; protocol="application/pgp-signature"; + micalg=pgp-sha1; boundary="Apple-Mail-5-1068183029" +Message-Id: <6C76F87D-B716-4FAC-8291-A8BEDFF41D76@geeklair.net> +Content-Transfer-Encoding: 7bit +From: "Daniel J. Luke" +Subject: Re: Getting even more insert performance (250m+rows/day) +Date: Tue, 30 May 2006 18:03:11 -0400 +To: pgsql-performance@postgresql.org +X-Pgp-Agent: GPGMail 1.1.2 (Tiger) +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/552 +X-Sequence-Number: 19339 + +This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +--Apple-Mail-5-1068183029 +Content-Transfer-Encoding: 7bit +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed + +On May 30, 2006, at 3:59 PM, Daniel J. Luke wrote: +> I should have gprof numbers on a similarly set up test machine +> soon ... + +gprof output is available at http://geeklair.net/~dluke/ +postgres_profiles/ + +(generated from CVS HEAD as of today). + +Any ideas are welcome. + +Thanks! +-- +Daniel J. Luke ++========================================================+ +| *---------------- dluke@geeklair.net ----------------* | +| *-------------- http://www.geeklair.net -------------* | ++========================================================+ +| Opinions expressed are mine and do not necessarily | +| reflect the opinions of my employer. | ++========================================================+ + + + +--Apple-Mail-5-1068183029 +content-type: application/pgp-signature; x-mac-type=70674453; + name=PGP.sig +content-description: This is a digitally signed message part +content-disposition: inline; filename=PGP.sig +content-transfer-encoding: 7bit + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.3 (Darwin) + +iD8DBQFEfMEfjUs5tAKawAoRAh6CAJ9gJIMBfMdpDXKUDRic4B6Fn4a0QwCeKhTB +0wfUKCkSzLz5nyAxR7EoMVw= +=pAJ5 +-----END PGP SIGNATURE----- + +--Apple-Mail-5-1068183029-- + +From pgsql-performance-owner@postgresql.org Tue May 30 19:35:14 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 3CD779FA5E9 + for ; + Tue, 30 May 2006 19:35:14 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 25946-04 + for ; + Tue, 30 May 2006 19:35:10 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id E053A9FA5E1 + for ; + Tue, 30 May 2006 19:35:09 -0300 (ADT) +Received: (qmail 16389 invoked from network); 31 May 2006 00:35:16 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 31 May 2006 00:35:16 +0200 +To: "Jonah H. Harris" , + Waldomiro +Cc: pgsql-performance@postgresql.org +Subject: Re: INSERT OU UPDATE WITHOUT SELECT? +References: <447C8F1D.8090404@shx.com.br> + <36e682920605301405u4d665fcftbe0a97b5753f5209@mail.gmail.com> +Message-ID: +Date: Wed, 31 May 2006 00:35:15 +0200 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <36e682920605301405u4d665fcftbe0a97b5753f5209@mail.gmail.com> +User-Agent: Opera M2/8.54 (Linux, build 1745) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/553 +X-Sequence-Number: 19340 + +> PostgreSQL does not support MERGE at the moment, sorry. + + Issue an UPDATE, and watch the rowcount ; if the rowcount is 0, issue an +INSERT. + Be prepared to retry if another transaction has inserted the row +meanwhile, though. + + MERGE would be really useful. + + +From pgsql-performance-owner@postgresql.org Tue May 30 19:37:02 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id E69249FA5F0 + for ; + Tue, 30 May 2006 19:37:01 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 26095-05 + for ; + Tue, 30 May 2006 19:36:57 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from peufeu.com (boutiquenumerique.com [82.67.9.10]) + by postgresql.org (Postfix) with ESMTP id 0CBEE9FA5E1 + for ; + Tue, 30 May 2006 19:36:56 -0300 (ADT) +Received: (qmail 16407 invoked from network); 31 May 2006 00:37:04 +0200 +Received: from boutiquenumerique.com (HELO apollo13) (82.67.9.10) + by boutiquenumerique.com with SMTP; 31 May 2006 00:37:04 +0200 +To: kynn@panix.com, pgsql-performance@postgresql.org +Subject: Re: Optimizing a huge_table/tiny_table join +References: <200605241742.k4OHgkg06460@panix3.panix.com> +Message-ID: +Date: Wed, 31 May 2006 00:37:03 +0200 +From: PFC +Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 +MIME-Version: 1.0 +Content-Transfer-Encoding: 8bit +In-Reply-To: <200605241742.k4OHgkg06460@panix3.panix.com> +User-Agent: Opera M2/8.54 (Linux, build 1745) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/554 +X-Sequence-Number: 19341 + + +> SELECT * FROM huge_table h, tiny_table t WHERE UPPER( h.id ) = +> UPPER( t.id ) + + What about : + +SELECT * FROM huge_table h WHERE UPPER(id) IN (SELECT upper(id) FROM +tiny_table t) + + Or, try opening a cursor on your original query and using FETCH. It might +result in a different plan. + Or lower random_page_cost. + +From pgsql-performance-owner@postgresql.org Tue May 30 19:38:25 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 298A89FA5E1 + for ; + Tue, 30 May 2006 19:38:25 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 25230-06 + for ; + Tue, 30 May 2006 19:38:20 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from alvh.no-ip.org (201-221-200-231.bk11-dsl.surnet.cl + [201.221.200.231]) + by postgresql.org (Postfix) with ESMTP id 145679FA5E9 + for ; + Tue, 30 May 2006 19:38:20 -0300 (ADT) +Received: by alvh.no-ip.org (Postfix, from userid 1000) + id 6D650C3A214; Tue, 30 May 2006 18:38:18 -0400 (CLT) +Date: Tue, 30 May 2006 18:38:18 -0400 +From: Alvaro Herrera +To: PFC +Cc: "Jonah H. Harris" , + Waldomiro , pgsql-performance@postgresql.org +Subject: Re: INSERT OU UPDATE WITHOUT SELECT? +Message-ID: <20060530223818.GK31547@surnet.cl> +Mail-Followup-To: PFC , + "Jonah H. Harris" , + Waldomiro , pgsql-performance@postgresql.org +References: <447C8F1D.8090404@shx.com.br> + <36e682920605301405u4d665fcftbe0a97b5753f5209@mail.gmail.com> + +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.11+cvs20060403 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/555 +X-Sequence-Number: 19342 + +PFC wrote: +> >PostgreSQL does not support MERGE at the moment, sorry. +> +> Issue an UPDATE, and watch the rowcount ; if the rowcount is 0, +> issue an INSERT. +> Be prepared to retry if another transaction has inserted the row +> meanwhile, though. + +Oh, you mean, like the example that's in the documentation? + +http://www.postgresql.org/docs/8.1/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING + +Example 36-1 + +> MERGE would be really useful. + +It has been discussed before -- MERGE is something different. + +-- +Alvaro Herrera http://www.CommandPrompt.com/ +PostgreSQL Replication, Consulting, Custom Development, 24x7 support + +From pgsql-performance-owner@postgresql.org Tue May 30 19:54:11 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5D0689FA5E9 + for ; + Tue, 30 May 2006 19:54:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29494-01 + for ; + Tue, 30 May 2006 19:54:04 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from globalrelay.com (mail1.globalrelay.com [216.18.71.77]) + by postgresql.org (Postfix) with ESMTP id 569BC9FA5E1 + for ; + Tue, 30 May 2006 19:54:02 -0300 (ADT) +X-Virus-Scanned: Scanned by GRC-AntiVirus Gateway +X-GR-Acctd: YES +Received: from [67.90.96.2] (HELO DaveEMachine) + by globalrelay.com (CommuniGate Pro SMTP 4.2.3) + with ESMTP id 91957859; Tue, 30 May 2006 15:54:00 -0700 +From: "Dave Dutcher" +To: "'PFC'" +Cc: +Subject: Re: INSERT OU UPDATE WITHOUT SELECT? +Date: Tue, 30 May 2006 17:54:00 -0500 +Message-ID: <039201c6843b$f11eeaf0$8300a8c0@tridecap.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.2627 +X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 +In-Reply-To: +Importance: Normal +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/556 +X-Sequence-Number: 19343 + +What I do when I'm feeling lazy is execute a delete statement and then +an insert. I only do it when I'm inserting/updating a very small number +of rows, so I've never worried if its optimal for performance. Besides +I've heard that an update in postgres is similar in performance to a +delete/insert. + + +> -----Original Message----- +> From: pgsql-performance-owner@postgresql.org +> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of PFC +> Sent: Tuesday, May 30, 2006 5:35 PM +> To: Jonah H. Harris; Waldomiro +> Cc: pgsql-performance@postgresql.org +> Subject: Re: [PERFORM] INSERT OU UPDATE WITHOUT SELECT? +> +> +> > PostgreSQL does not support MERGE at the moment, sorry. +> +> Issue an UPDATE, and watch the rowcount ; if the +> rowcount is 0, issue an +> INSERT. +> Be prepared to retry if another transaction has +> inserted the row +> meanwhile, though. +> +> MERGE would be really useful. +> +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + + +From pgsql-performance-owner@postgresql.org Tue May 30 20:05:23 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 5702B9FA5E9 + for ; + Tue, 30 May 2006 20:05:23 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 29391-03 + for ; + Tue, 30 May 2006 20:05:13 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from druid.net (druid.net [66.96.28.249]) + by postgresql.org (Postfix) with ESMTP id 6EA0F9FA5E1 + for ; + Tue, 30 May 2006 20:05:13 -0300 (ADT) +Received: from dilbert (H245.C18.B96.tor.eicat.ca [66.96.18.245]) + by druid.net (Postfix) with SMTP id BAD41B483; + Tue, 30 May 2006 19:05:12 -0400 (EDT) +Date: Tue, 30 May 2006 19:05:08 -0400 +From: "D'Arcy J.M. Cain" +To: "Dave Dutcher" +Cc: lists@peufeu.com, pgsql-performance@postgresql.org +Subject: Re: INSERT OU UPDATE WITHOUT SELECT? +Message-Id: <20060530190508.aa47bafe.darcy@druid.net> +In-Reply-To: <039201c6843b$f11eeaf0$8300a8c0@tridecap.com> +References: + <039201c6843b$f11eeaf0$8300a8c0@tridecap.com> +X-Mailer: Sylpheed version 2.2.4 (GTK+ 2.8.12; i386--netbsdelf) +Mime-Version: 1.0 +Content-Type: text/plain; charset=US-ASCII +Content-Transfer-Encoding: 7bit +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/557 +X-Sequence-Number: 19344 + +On Tue, 30 May 2006 17:54:00 -0500 +"Dave Dutcher" wrote: +> What I do when I'm feeling lazy is execute a delete statement and then +> an insert. I only do it when I'm inserting/updating a very small number +> of rows, so I've never worried if its optimal for performance. Besides +> I've heard that an update in postgres is similar in performance to a +> delete/insert. + +Well, they are basically the same operation in PostgreSQL. An update +adds a row to the end and marks the old one dead. A delete/insert +marks the row dead and adds one at the end. There may be some +optimization if the engine does both in one operation. + +-- +D'Arcy J.M. Cain | Democracy is three wolves +http://www.druid.net/darcy/ | and a sheep voting on ++1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. + +From pgsql-performance-owner@postgresql.org Tue May 30 21:38:33 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id B83759FA5E9 + for ; + Tue, 30 May 2006 21:38:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 37316-09 + for ; + Tue, 30 May 2006 21:38:20 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 213C19FA5E1 + for ; + Tue, 30 May 2006 21:38:19 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 41F9E56423; Tue, 30 May 2006 19:38:18 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 30 May 2006 19:38:17 -0500 +Date: Tue, 30 May 2006 19:38:17 -0500 +From: "Jim C. Nasby" +To: "wmiro@ig.com.br" +Cc: pgsql-performance@postgresql.org +Subject: Re: Why the 8.1 plan is worst than 7.4? +Message-ID: <20060531003817.GB59464@pervasive.com> +References: <20060526_120456_040065.wmiro@ig.com.br> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060526_120456_040065.wmiro@ig.com.br> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060531:wmiro@ig.com.br::oCHXbmltTR2oJtIg:002BKu +X-Hashcash: + 1:20:060531:pgsql-performance@postgresql.org::Y3RMTv41U5j51Q4r:00000 + 0000000000000000000000003FGW +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/558 +X-Sequence-Number: 19345 + +What's explain analyze show? + +On Fri, May 26, 2006 at 09:04:56AM -0300, wmiro@ig.com.br wrote: +> Hi, +> +> I have 2 servers, one of them has a 7.4 postgres and the other has a 8.1 +> +> I have this query: +> +> select fagrempr,fagrdocr,fagrserr,fagrparr +> from arqcfat +> left join arqfagr on fagrorig = 'CFAT' and fagrdocu = cfatdocu and fagrempe +> = cfatempe and fagrseri = cfatseri +> where cfatdata between '2006-01-01' and '2006-01-31' +> and cfattipo = 'VD' +> and cfatstat <> 'C' +> and fagrform = 'CT' +> and fagrtipr = 'REC' +> group by fagrempr,fagrdocr,fagrserr,fagrparr +> +> The 8.1 give me this plan: +> +> HashAggregate (cost=59.07..59.08 rows=1 width=20) +> -> Nested Loop (cost=0.00..59.06 rows=1 width=20) +> -> Index Scan using arqfagr_arqfa3_key on arqfagr +> (cost=0.00..53.01 rows=1 width=36) +> Index Cond: ((fagrorig = 'CFAT'::bpchar) AND (fagrform = +> 'CT'::bpchar)) +> Filter: (fagrtipr = 'REC'::bpchar) +> -> Index Scan using arqcfat_arqcfat1_key on arqcfat +> (cost=0.00..6.03 rows=1 width=16) +> Index Cond: (("outer".fagrempe = arqcfat.cfatempe) AND +> ("outer".fagrdocu = arqcfat.cfatdocu) AND ("outer".fagrseri = +> arqcfat.cfatseri)) +> Filter: ((cfatdata >= '01-01-2006'::date) AND (cfatdata <= +> '31-01-2006'::date) AND (cfattipo = 'VD'::bpchar) AND (cfatstat <> +> 'C'::bpchar)) +> +> The 7.4 give me this plan: +> +> HashAggregate (cost=2163.93..2163.93 rows=1 width=19) +> -> Nested Loop (cost=0.00..2163.92 rows=1 width=19) +> -> Index Scan using arqcfat_arqcfat2_key on arqcfat +> (cost=0.00..2145.78 rows=3 width=15) +> Index Cond: ((cfatdata >= '01-01-2006'::date) AND (cfatdata +> <= '31-01-2006'::date)) +> Filter: ((cfattipo = 'VD'::bpchar) AND (cfatstat <> +> 'C'::bpchar)) +> -> Index Scan using arqfagr_arqfa1_key on arqfagr +> (cost=0.00..6.03 rows=1 width=34) +> Index Cond: ((arqfagr.fagrorig = 'CFAT'::bpchar) AND +> (arqfagr.fagrempe = "outer".cfatempe) AND (arqfagr.fagrdocu = +> "outer".cfatdocu) AND (arqfagr.fagrseri = "outer".cfatseri)) +> Filter: ((fagrform = 'CT'::bpchar) AND (fagrtipr = +> 'REC'::bpchar)) +> +> Why the plan is worst in postgres 8.1? +> +> I know the best plan is read fisrt the table which has a date index as the +> 7.4 did, because in a few days I will have few lines too, so the query will +> be faster. +> +> Is there some thing I have to change in 8.1 to make the plans as the 7.4? +> +> Thanks , +> +> Waldomiro C. Neto. +> +> +> +> ---------------------------(end of broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> + +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Tue May 30 22:36:05 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id A5F099FA5F0 + for ; + Tue, 30 May 2006 22:36:04 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 45145-09 + for ; + Tue, 30 May 2006 22:35:58 -0300 (ADT) +X-Greylist: delayed 00:31:42.956827 by SQLgrey- +Received: from houston.familyhealth.com.au (iihouston.familyhealth.com.au + [203.59.102.239]) + by postgresql.org (Postfix) with ESMTP id DD8709FA5E1 + for ; + Tue, 30 May 2006 22:35:58 -0300 (ADT) +Received: from houston.familyhealth.com.au (localhost [127.0.0.1]) + by houston.familyhealth.com.au (Postfix) with ESMTP id D0DF62573F; + Wed, 31 May 2006 09:04:11 +0800 (WST) +Received: from [127.0.0.1] (work-48.internal [192.168.0.48]) + by houston.familyhealth.com.au (Postfix) with ESMTP id 4354C2573B; + Wed, 31 May 2006 09:04:09 +0800 (WST) +Message-ID: <447CEC56.3070106@calorieking.com> +Date: Wed, 31 May 2006 09:07:34 +0800 +From: Christopher Kings-Lynne +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: Antonio Batovanja +Cc: pgsql-performance@postgresql.org +Subject: Re: Query performance +References: + + +In-Reply-To: +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-familyhealth-MailScanner-Information: Please contact the ISP for more + information +X-familyhealth-MailScanner: Found to be clean +X-familyhealth-MailScanner-From: chris.kings-lynne@calorieking.com +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/560 +X-Sequence-Number: 19347 + +> I'm executing the queries from phpPgAdmin. +> The above are for explain analyse. I was referring to the pure query +> execution time. +> Does anyone have an idea why the OR-query takes so long? +> Any server-side tuning possibilities? I wouldn't like to change the code of +> ldap's back-sql... + +If you're using phpPgAdmin's timings, they could be more off than the +real explain analyze timings. Make sure you're using the figure given +by explain analyze itself. + +Chris + + +From pgsql-performance-owner@postgresql.org Tue May 30 22:09:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 644399FA5E9 + for ; + Tue, 30 May 2006 22:09:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 40053-10 + for ; + Tue, 30 May 2006 22:09:25 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id A67D59FA5E1 + for ; + Tue, 30 May 2006 22:09:25 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id A1D9656423; Tue, 30 May 2006 20:09:23 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Tue, 30 May 2006 20:09:23 -0500 +Date: Tue, 30 May 2006 20:09:22 -0500 +From: "Jim C. Nasby" +To: Worky Workerson +Cc: pgsql-performance@postgresql.org +Subject: Re: Bulk loading/merging +Message-ID: <20060531010922.GC59464@pervasive.com> +References: +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: + 1:20:060531:worky.workerson@gmail.com::uxyLlipPEik9oPuX:000000000000 + 0000000000000000000000004CX1 +X-Hashcash: + 1:20:060531:pgsql-performance@postgresql.org::zSTal/Z4dB6eMjsS:00000 + 0000000000000000000000001fqE +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/559 +X-Sequence-Number: 19346 + +Your best bet is to do this as a single, bulk operation if possible. +That way you can simply do an UPDATE ... WHERE EXISTS followed by an +INSERT ... SELECT ... WHERE NOT EXISTS. + +On Fri, May 26, 2006 at 02:48:20PM -0400, Worky Workerson wrote: +> I've set up something similar the 'recommended' way to merge data into +> the DB, i.e. +> +> http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING +> +> however I did it with a trigger on insert, i.e. (not my schema :) ): +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 31 00:20:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 61CD89FA5E9 + for ; + Wed, 31 May 2006 00:20:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 70292-03 + for ; + Wed, 31 May 2006 00:20:50 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) + by postgresql.org (Postfix) with ESMTP id A86FC9FA5E1 + for ; + Wed, 31 May 2006 00:20:49 -0300 (ADT) +Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) + by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k4V3KkW9006070; + Tue, 30 May 2006 23:20:46 -0400 (EDT) +To: "wmiro@ig.com.br" +cc: pgsql-performance@postgresql.org +Subject: Re: Why the 8.1 plan is worst than 7.4? +In-reply-to: <20060526_120456_040065.wmiro@ig.com.br> +References: <20060526_120456_040065.wmiro@ig.com.br> +Comments: In-reply-to "wmiro@ig.com.br" + message dated "Fri, 26 May 2006 09:04:56 -0300" +Date: Tue, 30 May 2006 23:20:46 -0400 +Message-ID: <6069.1149045646@sss.pgh.pa.us> +From: Tom Lane +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/561 +X-Sequence-Number: 19348 + +"wmiro@ig.com.br" writes: +> Why the plan is worst in postgres 8.1? + +(1) you have not actually shown us that the plan is worse. If you are +complaining that the planner is wrong, EXPLAIN output (which contains +only the planner's estimates) is useless for proving your point. Show +EXPLAIN ANALYZE. + +(2) Have you ANALYZEd these tables recently in either database? The +discrepancies in estimated rowcounts suggest that the two planners +are working with different statistics. + + regards, tom lane + +From pgsql-performance-owner@postgresql.org Wed May 31 03:23:20 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 7D73F9FA5D2 + for ; + Wed, 31 May 2006 03:23:20 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 92153-03 + for ; + Wed, 31 May 2006 03:23:10 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id DDEB49F9312 + for ; + Wed, 31 May 2006 03:23:09 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id 4D99A56431; Wed, 31 May 2006 01:23:08 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 31 May 2006 01:23:07 -0500 +Date: Wed, 31 May 2006 01:23:07 -0500 +From: "Jim C. Nasby" +To: Greg Stark +Cc: Brendan Duddridge , Tom Lane , + PostgreSQL Performance +Subject: Re: App very unresponsive while performing simple update +Message-ID: <20060531062307.GG53487@pervasive.com> +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> + <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> + <874pzanvk6.fsf@stark.xeocode.com> <17733.1148832292@sss.pgh.pa.us> + <3C756C36-DC66-4D13-B2CE-99CFCE7BF390@clickspace.com> + <87hd39n3c4.fsf@stark.xeocode.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <87hd39n3c4.fsf@stark.xeocode.com> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060531:gsstark@mit.edu::/oFP40Jq4p3yO3oF:000Tu4 +X-Hashcash: + 1:20:060531:brendan@clickspace.com::tT2Hzc8pFZoyZyD0:000000000000000 + 0000000000000000000000004MDr +X-Hashcash: + 1:20:060531:tgl@sss.pgh.pa.us::9laWk8PUZN9uX6+9:00000000000000000000 + 0000000000000000000000002iKX +X-Hashcash: + 1:20:060531:pgsql-performance@postgresql.org::8t4bW82CtNRjArdx:00000 + 0000000000000000000000000M+8 +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/562 +X-Sequence-Number: 19349 + +On Sun, May 28, 2006 at 07:20:59PM -0400, Greg Stark wrote: +> Brendan Duddridge writes: +> +> > We do have foreign keys on other tables that reference the product table. +> > Also, there will be updates going on at the same time as this update. When +> > anyone clicks on a product details link, we issue an update statement to +> > increment the click_count on the product. e.g. update product set click_count +> > = click_count + 1; +> +> You should realize this will produce a lot of garbage records and mean you'll +> have to be running vacuum very frequently. You might consider instead of +> updating the main table inserting into a separate clickstream table. That +> trades off not getting instantaneous live totals with isolating the +> maintenance headache in a single place. That table will grow large but you can +> prune it at your leisure without impacting query performance on your main +> tables. + +Actually, you can still get instant results, you just have to hit two +tables to do it. + +> More likely you were blocking on some lock. Until that other query holding +> that lock tries to commit Postgres won't actually detect a deadlock, it'll +> just sit waiting until the lock becomes available. + +Wow, are you sure that's how it works? I would think it would be able to +detect deadlocks as soon as both processes are waiting on each other's +locks. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 31 03:29:17 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D9F2F9FA60C + for ; + Wed, 31 May 2006 03:29:16 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 90795-07 + for ; + Wed, 31 May 2006 03:29:11 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) + by postgresql.org (Postfix) with ESMTP id 5F4739F9312 + for ; + Wed, 31 May 2006 03:29:11 -0300 (ADT) +Received: by noel.decibel.org (Postfix, from userid 1001) + id E863E56427; Wed, 31 May 2006 01:29:09 -0500 (CDT) +Received: (hashcash-sendmail, from uid 1001); Wed, 31 May 2006 01:29:08 -0500 +Date: Wed, 31 May 2006 01:29:08 -0500 +From: "Jim C. Nasby" +To: "D'Arcy J.M. Cain" +Cc: Dave Dutcher , lists@peufeu.com, + pgsql-performance@postgresql.org +Subject: Re: INSERT OU UPDATE WITHOUT SELECT? +Message-ID: <20060531062908.GH53487@pervasive.com> +References: + <039201c6843b$f11eeaf0$8300a8c0@tridecap.com> + <20060530190508.aa47bafe.darcy@druid.net> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060530190508.aa47bafe.darcy@druid.net> +X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 +X-Distributed: Join the Effort! http://www.distributed.net +User-Agent: Mutt/1.5.11 +X-Hashcash: 1:20:060531:darcy@druid.net::pj2/PI7/HcMYvMQM:000dj+ +X-Hashcash: + 1:20:060531:dave@tridecap.com::aw5YZ6UJxfHQFf3s:00000000000000000000 + 00000000000000000000000003cr +X-Hashcash: 1:20:060531:lists@peufeu.com::gpbsp/64o8yoqcFx:06t/U +X-Hashcash: + 1:20:060531:pgsql-performance@postgresql.org::GHTwWKOE9R4VDBvm:00000 + 0000000000000000000000006QyV +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/563 +X-Sequence-Number: 19350 + +On Tue, May 30, 2006 at 07:05:08PM -0400, D'Arcy J.M. Cain wrote: +> On Tue, 30 May 2006 17:54:00 -0500 +> "Dave Dutcher" wrote: +> > What I do when I'm feeling lazy is execute a delete statement and then +> > an insert. I only do it when I'm inserting/updating a very small number +> > of rows, so I've never worried if its optimal for performance. Besides +> > I've heard that an update in postgres is similar in performance to a +> > delete/insert. +> +> Well, they are basically the same operation in PostgreSQL. An update +> adds a row to the end and marks the old one dead. A delete/insert +> marks the row dead and adds one at the end. There may be some +> optimization if the engine does both in one operation. + +The new tuple will actually go on the same page during an update, if +possible. If not, the FSM is consulted. Appending to the end of the +table is a last resort. + +Update is more effecient than delete/insert. First, it's one less +statement to parse and plan. Second, AFAIK insert always goes to the +FSM; it has no way to know you're replacing the row(s) you just deleted. +-- +Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +Pervasive Software http://pervasive.com work: 512-231-6117 +vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 + +From pgsql-performance-owner@postgresql.org Wed May 31 03:30:43 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id D08ED9FA5D2 + for ; + Wed, 31 May 2006 03:30:42 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 91376-08 + for ; + Wed, 31 May 2006 03:30:36 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id E04CB9F9312 + for ; + Wed, 31 May 2006 03:30:35 -0300 (ADT) +Received: from [10.0.1.4] ([68.147.204.179]) + (authenticated user brendan@clickspace.com) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Wed, 31 May 2006 00:29:59 -0600 +In-Reply-To: <20060531062307.GG53487@pervasive.com> +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> + <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> + <874pzanvk6.fsf@stark.xeocode.com> <17733.1148832292@sss.pgh.pa.us> + <3C756C36-DC66-4D13-B2CE-99CFCE7BF390@clickspace.com> + <87hd39n3c4.fsf@stark.xeocode.com> + <20060531062307.GG53487@pervasive.com> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <09F270C9-7DF8-4574-AC70-CD7F9DA2C020@clickspace.com> +Cc: Greg Stark , Tom Lane , + PostgreSQL Performance +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: App very unresponsive while performing simple update +Date: Wed, 31 May 2006 00:29:50 -0600 +To: "Jim C. Nasby" +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/564 +X-Sequence-Number: 19351 + +>> You should realize this will produce a lot of garbage records and +>> mean you'll +>> have to be running vacuum very frequently. You might consider +>> instead of +>> updating the main table inserting into a separate clickstream +>> table. That +>> trades off not getting instantaneous live totals with isolating the +>> maintenance headache in a single place. That table will grow large +>> but you can +>> prune it at your leisure without impacting query performance on +>> your main +>> tables. + +We actually already have a table for this purpose. product_click_history + +> +> Actually, you can still get instant results, you just have to hit two +> tables to do it. + +Well, not really for our situation. We use the click_count on product +to sort our product listings by popularity. Joining with our +product_click_history to get live counts would be very slow. Some +categories have many tens of thousands of products. Any joins outside +our category_product table tend to be very slow. + +We'll probably have to write a process to update the click_count from +querying our product_click_history table. + + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On May 31, 2006, at 12:23 AM, Jim C. Nasby wrote: + +> On Sun, May 28, 2006 at 07:20:59PM -0400, Greg Stark wrote: +>> Brendan Duddridge writes: +>> +>>> We do have foreign keys on other tables that reference the +>>> product table. +>>> Also, there will be updates going on at the same time as this +>>> update. When +>>> anyone clicks on a product details link, we issue an update +>>> statement to +>>> increment the click_count on the product. e.g. update product +>>> set click_count +>>> = click_count + 1; +>> +>> You should realize this will produce a lot of garbage records and +>> mean you'll +>> have to be running vacuum very frequently. You might consider +>> instead of +>> updating the main table inserting into a separate clickstream +>> table. That +>> trades off not getting instantaneous live totals with isolating the +>> maintenance headache in a single place. That table will grow large +>> but you can +>> prune it at your leisure without impacting query performance on +>> your main +>> tables. +> +> Actually, you can still get instant results, you just have to hit two +> tables to do it. +> +>> More likely you were blocking on some lock. Until that other query +>> holding +>> that lock tries to commit Postgres won't actually detect a +>> deadlock, it'll +>> just sit waiting until the lock becomes available. +> +> Wow, are you sure that's how it works? I would think it would be +> able to +> detect deadlocks as soon as both processes are waiting on each other's +> locks. +> -- +> Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com +> Pervasive Software http://pervasive.com work: 512-231-6117 +> vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 5: don't forget to increase your free space map settings +> + + + +From pgsql-performance-owner@postgresql.org Wed May 31 06:30:10 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 4BA589FA5D2 + for ; + Wed, 31 May 2006 06:30:10 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 45927-01 + for ; + Wed, 31 May 2006 06:30:01 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from fw.greenpeace.org (fw.greenpeace.org [212.19.215.77]) + by postgresql.org (Postfix) with ESMTP id C7D1E9F9312 + for ; + Wed, 31 May 2006 06:30:00 -0300 (ADT) +Received: (from root@localhost) by fw.greenpeace.org (8.9.3c/8.6.12) id + LAA65837 for ; + Wed, 31 May 2006 11:29:40 +0200 (CEST) +Received: by fw.greenpeace.org (TUNIX/Firewall SMTP Server) + for id sma064182; + Wed, 31 May 06 11:27:49 +0200 +Received: from bb.nli.gl3 (root@localhost) + by bb.nli.gl3 (8.12.8/8.12.5) with SMTP id k4V9RnGA025738 + for ; Wed, 31 May 2006 11:27:49 +0200 +Received: from maila.greenpeace.org (fw.nli.gl3 [192.168.31.7]) + by bb.nli.gl3 (8.12.8/8.13.3) with ESMTP id k4V9Rn7j025729; + Wed, 31 May 2006 11:27:49 +0200 +Received: from [192.168.200.143] (vpni.greenpeace.org [212.19.215.76]) + (authenticated (128 bits)) + by maila.greenpeace.org (8.13.4/8.11.6) with ESMTP id k4V9Rnb7002698 + (using TLSv1/SSLv3 with cipher RC4-MD5 (128 bits) verified NO); + Wed, 31 May 2006 11:27:49 +0200 +Message-ID: <447D61BA.1040201@superlativ.dk> +Date: Wed, 31 May 2006 11:28:26 +0200 +From: Nis Jorgensen +User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) +MIME-Version: 1.0 +To: mario.splivalo@mobart.hr +CC: pgsql-performance@postgresql.org +Subject: Re: Speedup hint needed, if available? :) +References: <1148998681.18422.24.camel@localhost.localdomain> +In-Reply-To: <1148998681.18422.24.camel@localhost.localdomain> +Content-Type: text/plain; charset=ISO-8859-1; format=flowed +Content-Transfer-Encoding: 7bit +X-Anti-Virus: Kaspersky Anti-Virus for MailServers 5.5.2/RELEASE, + bases: 25072005 #131892, status: clean +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/565 +X-Sequence-Number: 19352 + +Mario Splivalo wrote: +> Hello again. +> +> I have to track user subscriptions to certain mailinglists, and I also +> need to track credits users have on those mailinglists. On one side I +> have procedures that add credits, on other side I have procedures that +> subtract available credits. Add/subtract is pretty intensive, around +> 30-50 adds per minute (usualy 10 or 100 credits), and around 200-500 +> subtracts per minute (usualy by one or two credits). +> +> I have created table user_subscriptions to track user subscriptions to +> certain mailing list. I have derived subscription_id as primary key. I +> have two other tables, user_subscription_credits_given, and +> _credits_taken, wich track credits for subscription added or subtracted +> to or from certain subscription. I created those two tables so I could +> eliminate a lot of UPDATES on user_subscriptions table (if I were to +> have a column 'credits' in that table). + +It sounds to me like you have decided beforehand that the obvious +solution (update a credit field in the user_subscriptions table) is not +going to perform well. Have you tried it? How does it perform? + +If it does indeed give you performance problems, you could instead run +some kind of batch job to update the credits field (and delete the +/given/taken records). + +Finally: You could refactor the query to get rid of the union: + +SELECT u.subscription_id, u.user_id, u.mailinglist_id, u.valid_from, +u.valid_to, ( + SELECT sum(credits) + FROM credits_given + WHERE subscription_id = u.subscription_id +) - ( + SELECT sum(credits) + FROM credits_taken + WHERE subscription_id = u.subscription_id) +) AS credits +FROM user_subscriptions u +WHERE u.user_id = 1 + +(Not tested). + +You will probably need a COALESCE around each of the subqueries to avoid +problems with nulls. The sum of an empty set of numbers is 0. The +conjunction of an empty set of booleans is true. The SQL standard +somehow manages to get this wrong + +/Nis + + + +From pgsql-performance-owner@postgresql.org Wed May 31 09:34:55 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id DC8069FA5F0 + for ; + Wed, 31 May 2006 09:34:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 16760-07 + for ; + Wed, 31 May 2006 09:34:47 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.digitalfairway.ca (ns.digitalfairway.ca [207.164.133.170]) + by postgresql.org (Postfix) with ESMTP id C9C2C9FA5DD + for ; + Wed, 31 May 2006 09:34:47 -0300 (ADT) +Received: from toronto.toronto.digitalfairway.ca (unknown [192.168.100.10]) + by mail.digitalfairway.ca (Postfix) with ESMTP id B508AA0553 + for ; + Wed, 31 May 2006 08:34:45 -0400 (EDT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by toronto.toronto.digitalfairway.ca (Postfix) with ESMTP id + 72A2E164603 for ; + Wed, 31 May 2006 08:34:45 -0400 (EDT) +Received: from toronto.toronto.digitalfairway.ca ([127.0.0.1]) + by localhost (toronto.toronto.digitalfairway.ca [127.0.0.1]) + (amavisd-new, port 10024) + with ESMTP id 26089-08 for ; + Wed, 31 May 2006 08:34:45 -0400 (EDT) +Received: from [192.168.100.50] (unknown [192.168.100.50]) + (using SSLv3 with cipher EXP1024-RC4-SHA (56/128 bits)) + (No client certificate requested) + by toronto.toronto.digitalfairway.ca (Postfix) with ESMTP id + DF9EF164607 for ; + Wed, 31 May 2006 08:34:44 -0400 (EDT) +From: Jan de Visser +To: pgsql-performance@postgresql.org +Subject: Re: App very unresponsive while performing simple update +Date: Wed, 31 May 2006 08:34:44 -0400 +User-Agent: KMail/1.9.1 +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> + <20060531062307.GG53487@pervasive.com> + <09F270C9-7DF8-4574-AC70-CD7F9DA2C020@clickspace.com> +In-Reply-To: <09F270C9-7DF8-4574-AC70-CD7F9DA2C020@clickspace.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200605310834.44935.jdevisser@digitalfairway.com> +X-Virus-Scanned: amavisd-new at digitalfairway.ca +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/566 +X-Sequence-Number: 19353 + +On Wednesday 31 May 2006 02:29, Brendan Duddridge wrote: +> We'll probably have to write a process to update the click_count from =A0 +> querying our product_click_history table. + +How about an insert trigger on product_click_history which updates click_co= +unt=20 +every say 10000 transactions or so? + +jan + +=2D-=20 +=2D------------------------------------------------------------- +Jan de Visser =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 jdevisser@digitalfair= +way.com + +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Baruk Khazad! Khazad ai-menu! +=2D------------------------------------------------------------- + +From pgsql-performance-owner@postgresql.org Wed May 31 12:09:24 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 479AF9FA5F0 + for ; + Wed, 31 May 2006 12:09:24 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 49128-08 + for ; + Wed, 31 May 2006 12:09:19 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from wolff.to (wolff.to [66.93.197.194]) + by postgresql.org (Postfix) with SMTP id 368089FA5DD + for ; + Wed, 31 May 2006 12:09:18 -0300 (ADT) +Received: (qmail 22293 invoked by uid 500); 31 May 2006 15:11:41 -0000 +Date: Wed, 31 May 2006 10:11:41 -0500 +From: Bruno Wolff III +To: "Jim C. Nasby" +Cc: Greg Stark , Brendan Duddridge , + Tom Lane , + PostgreSQL Performance +Subject: Re: App very unresponsive while performing simple update +Message-ID: <20060531151141.GA20992@wolff.to> +Mail-Followup-To: Bruno Wolff III , + "Jim C. Nasby" , Greg Stark , + Brendan Duddridge , + Tom Lane , + PostgreSQL Performance +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> + <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> + <874pzanvk6.fsf@stark.xeocode.com> <17733.1148832292@sss.pgh.pa.us> + <3C756C36-DC66-4D13-B2CE-99CFCE7BF390@clickspace.com> + <87hd39n3c4.fsf@stark.xeocode.com> + <20060531062307.GG53487@pervasive.com> +Mime-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <20060531062307.GG53487@pervasive.com> +User-Agent: Mutt/1.4.2.1i +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/567 +X-Sequence-Number: 19354 + +On Wed, May 31, 2006 at 01:23:07 -0500, + "Jim C. Nasby" wrote: +> On Sun, May 28, 2006 at 07:20:59PM -0400, Greg Stark wrote: +> > Brendan Duddridge writes: +> > More likely you were blocking on some lock. Until that other query holding +> > that lock tries to commit Postgres won't actually detect a deadlock, it'll +> > just sit waiting until the lock becomes available. +> +> Wow, are you sure that's how it works? I would think it would be able to +> detect deadlocks as soon as both processes are waiting on each other's +> locks. + +I don't see how it could wait for a commit. If a command is blocked waiting for +a lock, how are you going to get a commit (you might get a rollback if the +query is aborted)? + +From pgsql-performance-owner@postgresql.org Wed May 31 12:24:32 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6AAEB9FA5F0 + for ; + Wed, 31 May 2006 12:24:32 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 47862-08 + for ; + Wed, 31 May 2006 12:24:23 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) + by postgresql.org (Postfix) with ESMTP id 373CB9FA5DD + for ; + Wed, 31 May 2006 12:24:23 -0300 (ADT) +Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) + by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) + id 1FlSYH-0007nn-00; Wed, 31 May 2006 11:24:05 -0400 +To: "Jim C. Nasby" +Cc: Greg Stark , Brendan Duddridge , + Tom Lane , + PostgreSQL Performance +Subject: Re: App very unresponsive while performing simple update +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> + <21B15664-F4EE-462C-88B4-EEEB2B4A979F@clickspace.com> + <874pzanvk6.fsf@stark.xeocode.com> <17733.1148832292@sss.pgh.pa.us> + <3C756C36-DC66-4D13-B2CE-99CFCE7BF390@clickspace.com> + <87hd39n3c4.fsf@stark.xeocode.com> + <20060531062307.GG53487@pervasive.com> +In-Reply-To: <20060531062307.GG53487@pervasive.com> +From: Greg Stark +Organization: The Emacs Conspiracy; member since 1992 +Date: 31 May 2006 11:24:05 -0400 +Message-ID: <874pz6jjze.fsf@stark.xeocode.com> +Lines: 99 +User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/568 +X-Sequence-Number: 19355 + +"Jim C. Nasby" writes: + +> On Sun, May 28, 2006 at 07:20:59PM -0400, Greg Stark wrote: +> > Brendan Duddridge writes: +> > +> > > We do have foreign keys on other tables that reference the product table. +> > > Also, there will be updates going on at the same time as this update. When +> > > anyone clicks on a product details link, we issue an update statement to +> > > increment the click_count on the product. e.g. update product set click_count +> > > = click_count + 1; +> > +> > You should realize this will produce a lot of garbage records and mean you'll +> > have to be running vacuum very frequently. You might consider instead of +> > updating the main table inserting into a separate clickstream table. That +> > trades off not getting instantaneous live totals with isolating the +> > maintenance headache in a single place. That table will grow large but you can +> > prune it at your leisure without impacting query performance on your main +> > tables. +> +> Actually, you can still get instant results, you just have to hit two +> tables to do it. + +But that defeats the purpose of moving this traffic out to the clickstream +table. The whole point is to avoid generating garbage records in your main +table that you're doing a lot of real-time queries against. + +I would probably keep the clickstream table, then once a day or perhaps more +often perform an aggregate query against it to generate a summary table (and +then vacuum full or cluster it since it's half garbage). Then join from the +main product table to the summary table to sort by popularity. + +If you need results that are more up-to-date than 24 hours and/or can't stand +the downtime of the daily vacuum full on the summary table it becomes a lot +harder. + +> > More likely you were blocking on some lock. Until that other query holding +> > that lock tries to commit Postgres won't actually detect a deadlock, it'll +> > just sit waiting until the lock becomes available. +> +> Wow, are you sure that's how it works? I would think it would be able to +> detect deadlocks as soon as both processes are waiting on each other's +> locks. + +I didn't mean to describe the general situation, just what I suspected was +happening in this case. The user had a large batch update that was performing +poorly. I suspect it may have been performing poorly because it was spending +time waiting to acquire an exclusive lock. There would be no deadlock yet, +just very slow updates. + +However the other client updating the other table has deferred foreign key +constraints back to the table the big update is acquiring all these exclusive +locks. Locks for deferred constraints aren't taken until they're checked. So +the actual deadlock doesn't occur until the commit occurs. + +In any case Tom said I was misunderstanding the deadlock message he posted. +The kind of situation I'm talking about would look something like this: + +stark=> begin; +BEGIN + stark=> begin; + BEGIN +stark=> update t1 set a = 0; +UPDATE 1 +stark=> update t1 set a = 1; +UPDATE 1 + + stark=> update t2 set b = 0; + UPDATE 1 + stark=> update t2 set b = 2; + UPDATE 1 +stark=> commit; + stark=> commit; + ERROR: deadlock detected + DETAIL: Process 16531 waits for ShareLock on transaction 245131; blocked by process 16566 + Process 16566 waits for ShareLock on transaction 245132; blocked by process 16531. + CONTEXT: SQL statement "SELECT 1 FROM ONLY "public"."t1" x WHERE "a" = $1 FOR SHARE OF x" + stark=> > +COMMIT +stark=> \d t1 + Table "public.t1" + Column | Type | Modifiers +--------+---------+----------- + a | integer | not null + b | integer | +Indexes: + "t1_pkey" PRIMARY KEY, btree (a) +Foreign-key constraints: + "fk" FOREIGN KEY (b) REFERENCES t2(b) DEFERRABLE INITIALLY DEFERRED + +stark=> \d t2 + Table "public.t2" + Column | Type | Modifiers +--------+---------+----------- + a | integer | + b | integer | not null +Indexes: + "t2_pkey" PRIMARY KEY, btree (b) +Foreign-key constraints: + "fk" FOREIGN KEY (a) REFERENCES t1(a) DEFERRABLE INITIALLY DEFERRED + + +From pgsql-performance-owner@postgresql.org Wed May 31 14:35:03 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 6142D9FA6A2 + for ; + Wed, 31 May 2006 14:35:03 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 89438-07 + for ; + Wed, 31 May 2006 14:34:49 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.clickspace.com (router2.clickspace.com [65.110.166.227]) + by postgresql.org (Postfix) with ESMTP id C3F7D9FA5E1 + for ; + Wed, 31 May 2006 14:34:49 -0300 (ADT) +Received: from localhost ([127.0.0.1]) by mail.clickspace.com + (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits)); + Wed, 31 May 2006 11:34:48 -0600 +In-Reply-To: <200605310834.44935.jdevisser@digitalfairway.com> +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> + <20060531062307.GG53487@pervasive.com> + <09F270C9-7DF8-4574-AC70-CD7F9DA2C020@clickspace.com> + <200605310834.44935.jdevisser@digitalfairway.com> +Mime-Version: 1.0 (Apple Message framework v750) +Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed +Message-Id: <5C36D400-CDCE-41D1-AD5F-EBF03E5F9656@clickspace.com> +Cc: pgsql-performance@postgresql.org +Content-Transfer-Encoding: 7bit +From: Brendan Duddridge +Subject: Re: App very unresponsive while performing simple update +Date: Wed, 31 May 2006 11:34:38 -0600 +To: Jan de Visser +X-Mailer: Apple Mail (2.750) +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/569 +X-Sequence-Number: 19356 + +Hi Jan, + +That sounds like a great idea! How would you control the update to +occur only every 10,000 transactions? + +Is there a trigger setting for that somewhere? + +Thanks, + +____________________________________________________________________ +Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com + +ClickSpace Interactive Inc. +Suite L100, 239 - 10th Ave. SE +Calgary, AB T2G 0V9 + +http://www.clickspace.com + +On May 31, 2006, at 6:34 AM, Jan de Visser wrote: + +> On Wednesday 31 May 2006 02:29, Brendan Duddridge wrote: +>> We'll probably have to write a process to update the click_count from +>> querying our product_click_history table. +> +> How about an insert trigger on product_click_history which updates +> click_count +> every say 10000 transactions or so? +> +> jan +> +> -- +> -------------------------------------------------------------- +> Jan de Visser jdevisser@digitalfairway.com +> +> Baruk Khazad! Khazad ai-menu! +> -------------------------------------------------------------- +> +> ---------------------------(end of +> broadcast)--------------------------- +> TIP 3: Have you checked our extensive FAQ? +> +> http://www.postgresql.org/docs/faq +> + + + +From pgsql-performance-owner@postgresql.org Wed May 31 14:43:54 2006 +X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org +Received: from localhost (mx1.hub.org [200.46.208.251]) + by postgresql.org (Postfix) with ESMTP id 9CFDF9FA6A2 + for ; + Wed, 31 May 2006 14:43:54 -0300 (ADT) +Received: from postgresql.org ([200.46.204.71]) + by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) + with ESMTP id 95206-03 + for ; + Wed, 31 May 2006 14:43:44 -0300 (ADT) +X-Greylist: from auto-whitelisted by SQLgrey- +Received: from mail.digitalfairway.ca (ns.digitalfairway.ca [207.164.133.170]) + by postgresql.org (Postfix) with ESMTP id 226859FA5E9 + for ; + Wed, 31 May 2006 14:43:43 -0300 (ADT) +Received: from toronto.toronto.digitalfairway.ca (unknown [192.168.100.10]) + by mail.digitalfairway.ca (Postfix) with ESMTP id B5AA39AE83; + Wed, 31 May 2006 13:43:42 -0400 (EDT) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by toronto.toronto.digitalfairway.ca (Postfix) with ESMTP id + 6536A163650; Wed, 31 May 2006 13:43:42 -0400 (EDT) +Received: from toronto.toronto.digitalfairway.ca ([127.0.0.1]) + by localhost (toronto.toronto.digitalfairway.ca [127.0.0.1]) + (amavisd-new, port 10024) + with ESMTP id 10755-09; Wed, 31 May 2006 13:43:42 -0400 (EDT) +Received: from [192.168.100.50] (unknown [192.168.100.50]) + (using SSLv3 with cipher EXP1024-RC4-SHA (56/128 bits)) + (No client certificate requested) + by toronto.toronto.digitalfairway.ca (Postfix) with ESMTP id + 4335616359F; Wed, 31 May 2006 13:43:42 -0400 (EDT) +From: Jan de Visser +To: Brendan Duddridge +Subject: Re: App very unresponsive while performing simple update +Date: Wed, 31 May 2006 13:43:40 -0400 +User-Agent: KMail/1.9.1 +Cc: pgsql-performance@postgresql.org +References: <961F6F02-4B00-494C-B071-6DF76A305C14@clickspace.com> + <200605310834.44935.jdevisser@digitalfairway.com> + <5C36D400-CDCE-41D1-AD5F-EBF03E5F9656@clickspace.com> +In-Reply-To: <5C36D400-CDCE-41D1-AD5F-EBF03E5F9656@clickspace.com> +MIME-Version: 1.0 +Content-Type: text/plain; + charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Content-Disposition: inline +Message-Id: <200605311343.40925.jdevisser@digitalfairway.com> +X-Virus-Scanned: amavisd-new at digitalfairway.ca +X-Virus-Scanned: Maia Mailguard 1.0.1 +X-Archive-Number: 200605/570 +X-Sequence-Number: 19357 + +On Wednesday 31 May 2006 13:34, Brendan Duddridge wrote: +> Hi Jan, +> +> That sounds like a great idea! How would you control the update to +> occur only every 10,000 transactions? +> +> Is there a trigger setting for that somewhere? + +I was thinking something like + +IF count(*) % 10000 =3D 0 then + ... do stuff ... +end if + +Problem may be that that may be a bit expensive; maybe better to have a=20 +sequence and use the sequence value.=20 + +Or something like that. + +Also, maybe you should do the actual update of click_count not in the trigg= +er=20 +itself, but have the trigger do a NOTIFY and have another process do a=20 +LISTEN. Depends how long the update takes. + +jan + +> +> Thanks, +> +> ____________________________________________________________________ +> Brendan Duddridge | CTO | 403-277-5591 x24 | brendan@clickspace.com +> +> ClickSpace Interactive Inc. +> Suite L100, 239 - 10th Ave. SE +> Calgary, AB T2G 0V9 +> +> http://www.clickspace.com +> +> On May 31, 2006, at 6:34 AM, Jan de Visser wrote: +> > On Wednesday 31 May 2006 02:29, Brendan Duddridge wrote: +> >> We'll probably have to write a process to update the click_count from +> >> querying our product_click_history table. +> > +> > How about an insert trigger on product_click_history which updates +> > click_count +> > every say 10000 transactions or so? +> > +> > jan +> > +> > -- +> > -------------------------------------------------------------- +> > Jan de Visser jdevisser@digitalfairway.com +> > +> > Baruk Khazad! Khazad ai-menu! +> > -------------------------------------------------------------- +> > +> > ---------------------------(end of +> > broadcast)--------------------------- +> > TIP 3: Have you checked our extensive FAQ? +> > +> > http://www.postgresql.org/docs/faq + +=2D-=20 +=2D------------------------------------------------------------- +Jan de Visser =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 jdevisser@digitalfair= +way.com + +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Baruk Khazad! Khazad ai-menu! +=2D------------------------------------------------------------- +